Thursday, 15 April 2010

Piano Phase - Max

In a previous post we implemented Steve Reich's Piano Phase in an algorithmic composition patch in PureData. Today we have a similar implementation in Max.

Piano Phase (1967) an identical twelve note phrase played by two pianists who are playing at slightly different tempos. As the piece progresses the two phrases drift further and further out of phase with each other.

The 12 note phrase is:
E4 F#4 B4 C#5 D5 F#4 E4 C#5 B4 F#4 D5 C#5

or in MIDI notes:
64 66 71 73 74 66 64 73 71 66 74 73

This is how the piano phase patch looks in Max:


This is how the patch works in Max:

  • The 12 note phrase is stored in a table object an labelled pianoPhrase.
  • Two metronomes with slightly different tempos send 'bang' pulses to counters.
  • These counters are connected to the table pianoPhrase object, this object reads through our stored piano phrase. Note the difference between this and our PureData implementation.
  • This is then sent out to a makenote and noteout object to create and output MIDI notes.
I recommend creating the patch yourself by copying the layout of the screenshot, however you can also download it here.

The good thing about implementing algorithmic compositions in a computer is that once you have created the process, you can tweak it and create brand new versions. Try the same process with a different melody by altering the notes stored in our pianoPhrase message. You could also try adding a 3rd part with a new tempo, by duplicating and modifying the relevant objects.

We'll implement some more of Steve Reich's compositions in future posts in PureData, Max, Lisp, OpenMusic and more..

Saturday, 10 April 2010

OpenMusic 6.2

We gave a brief introduction to OpenMusic a few posts ago. A new version of this algorithmic composition software has just been announced by IRCAM.

The new version, OpenMusic 6.2 is available for Windows XP, Vista and Mac OSX Univeral Binary and comes with updates, bug fixes and some new features.


New features:
- Compatible with LispWorks 5 and 6 (for LispWorks users)
- New "LispFunction" object
- Improvements and debug of the Audio system (memory management, update LibAudioStream, etc)
- Music package: "extra" tools
- Preferences activation/deactivation of the "multithread mode" MultiPlayer files
- OMChroma update of the kernel and a new version object;
- "Cr-control" improvements of the CSound instruments parser

Library Updates:
- OM-SuperVP 2.3 (Windows/mac)
- OMPrisma 1.12
- Modalys support
NOTE: There are still some libraries not yet ported (omKant ace, etc…)

We'll look at some further algorithmic composition techniques and explore some of the new OpenMusic algorithmic features in future http://www.algorithmiccomposer.com/ posts.

Sunday, 4 April 2010

Keykit | Algorithmic Composition Software

Keykit is a piece of algorithmic composition software that the developer describes as 'a programming language and graphical interface for manipulating and generating music'. It runs on Windows and Linux and is a free download available here: http://www.nosuch.com/keykit

Keykit read and write MIDI files so it can also be easily integrated with other programes and has a number of useful algorithmic composition tools:
We'll have a quick look at a couple of the algorithmic composition tools available:



Using Markov Chains for Algorithmic Composition
We'll use the Markov Maker tool to generate new MIDI files algorithmically. Markov chains choose the next note based on a probability factor. In the first example below, if our current note is an A, there is a 10% chance of the following note being an A again, a 60% chance of the following note being a C# and a 30% chance of the following note being an Eb. This table is called a transition matrix.



As shown in the second example, we can also base our next note choice on the previous two notes. This is called a second order Markov Chain. So for example if the previous two notes were G then D there would be a 100% probability of the following note being an A.

Transition tables can be created by hand, filling in the values that you'd like to work with, or we can create the transition table by analysing an existing piece of music, for example loading up a Mozart piano sonata and generating the transition table dile directly from this. Working with Markov chains in this way you can here the algorithmically generated piece having some similarities to the source piece of music. The higher order markov chain, the greater the similarity to the original.

"The "Markov Maker" tool lets you create music with markov-chain techniques. The top phrase window displays some existing piece of music that you read in, and the bottom phrase window display a "similar" piece of music that is created by the "Markov Maker."



1. Load up keykit and in a blank space, click and select tools 2, markov maker

2. Click - original -read file / load Smf. This allows you to load up a source piece of music in the Standard Midi File format.

3. Click original - set sim, the two values are the window size and window increment, the best settings depend on the source material and desired effect so do experiment.

4. Click the grey sim box, choose make sim and the number of generations you want to create. Every generation will sound different, you may need to experiment with the 'set sim' settings (step 3).



5. To save the file, click the grey sim box and choose snarf.


6. Click in a blank space and from tools 1 menu choose group.


7. In the group tool, choose file, read snarf. This will paste your markov generated composition into the group tool.

8. To save as a standard midi file, in the group tool click file, write / standard MIDI file.

We'll look at some further implementations of Markov Chains in future posts including creating implementations in PureData, Max and Lisp, so check back soon!

Sunday, 28 March 2010

Tutorial Max 2: Random Major Scale Pitches In Max

Our second PureData example looked at playing random major scale pitches. This post looks at creating the same patch in Max. Our last algorithmic composition example in Max played random chromatic pitches if you haven't already follow the tutorial to create or download this last Max patch,
it looked like this:
  1. Open our last patch from tutorial one.
  2. We'll be storing the pitches of our major scale in a message: create a new message by pressing 'm' and type this is into the message ; majorScale 0 0, 1 2, 2 3, 3 5, 4 7, 5 9, 6 11, 7 12. If you've built the PureData of this patch you'll notice that Max and Puredata store data in slightly different ways. In Max we're storing the numbers in pairs separated by a comma: the first number is the index and the second number the scale interval.
  3. Our table stores the intervals of a major scale. We need a table to store this data in, create a new object by pressing 'n' and type 'table majorScale' into this object box
  4. Come out of edit mode [PD: CTRL E, Mac: CMD E] and click on the message to store the scale to the table. In the example below we've added a loadbang object to automatically store this message when the patch loads.
  5. Break the connection between the 'random' object and the '+' object and connect the table object here (another difference between Max and PureData, PureData uses a separate tabread object).
  6. Optional: create two new integer number boxes by pressing 'i' and connect everything up as shown in the screenshot below. The numbers aren't strictly necessary as they don't actually do anything, they just display the current number.
  7. Previously we were choosing from 12 random pitches. Now we only have 8 notes to choose from in our scale, so we now need to change the number in our random object to 8.
  8. Come out of edit mode [PD: CTRL E, Mac: CMD E], click on the toggle and you should hear random notes from the C Major Scale.
It's worth building the patch yourself but you can also download the patch here.

Saturday, 27 March 2010

Tutorial Max 1: Random Pitches In Max5

A few days ago we posted an introductory algorithmic composition example that generated random pitches in PureData. Today we're creating the same example in Max 5.

Max is a commercial application available from Cycling 74. Max is very similar to the opensource programme PureData, in today's example the patches are very similar, as we start to implement more advanced algorithmic compositions we'll discover some of the differences between the two programes.

Max is a commercial application, however there is also a limited time demo version available here.

  1. Start MaxMSP and create a new patch from the file menu [PC: CTRL N, Mac: CMD N]
  2. Now we need to start creating the patch, press 't' to create a toggle.
  3. Press 'n' to create a new object and type 'metro 1000' into this. This object is a metronome and sends out regular pulses. We have used 1000 as the argument, so our metronome will send out a pulse every 1000ms.
  4. Press 'n' to create another object and type random 12 into this object. This object is a random number generator. As we used 12 as its argument it will choose a random number from 12 possibilities (from 0 to 11)
  5. Add an integer number box by pressing 'i'. This is not strictly necessary but will display the random number that has been chosen.
  6. Add another object (by pressing 'n') '+ 48' (don't forget the space. This will add 48 to our random number to lift it into a sensible MIDI range.
  7. Add a further integer box, again not strictly necessary but will show the resulting number.
  8. Add a makenote object as per the screenshot. The other arguments included are velocity and duration.
  9. Add a noteout object and connect everything up as shown in the screenshot.
  10. Go to Options MIDI setup and choose a MIDI output.
  11. Exit edit mode [PC: CTRL E, Mac: CMD E] and click in the toggle box, you should see the number boxes changing values and hear random MIDI notes being generated.
Your patch should look something like this - click on the image to see a larger version.
Here are some things to try:
  • Change the value in the metronome box or connect a slider to the metronome's right inlet to generate notes at a faster or slower speed
  • Change the value in the random box to generate a larger or smaller range of pitches
You can also download the Max patch here.

Algorithmic composition can get a lot more interesting and involved than this, we'll look at some more advanced examples and other software in future posts.