## 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

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.

## Thursday 25 March 2010

### Tone Rows And Rhythm

In today's post we're looking at another relatively simple example that introduces two more ideas:
• working tone rows (serialism)
• working with rhythm
As it's the firs time we've used this ideas in patches we'll use fairly straight forward implementations. Here's a summary of what our algorithmic composition patch will do:

1. Specify a tone row, this will always be played through in order. The tone row is specified by using pitch classes in a message that is then stored in a table, the tone row in the example patch is

11 10 7 1 3 0 2 9 6 4 8 5 though feel free to change this.

2. Specify a series of rhythms. For this we've assumed a tempo of 60BPM. So:
• Whole note (semibreve) = 4000ms
• 1/2 note (minim) = 2000ms
• 1/4 note (crotchet) = 1000ms
• 1/8 note (quaver) = 500ms
• 1/16 note (semiquaver) = 125ms
• 1/32 note (demisemiquaver) = 62.5ms

3. Assuming a consistent tempo of 60BPM makes working with rhythmic values easy, we don't have to stick to 60 BPM however. If we multiplied each value by 2 the tempo would be twice as quick. We've included a simple tempo multiplier slider that is connected to a multiply object:

4. We'll follow serialist principles, each note of the row is of equal importance and the tone row is played through in order. A counter counts from 0 to 11, this is connected to a tabread object that read through our tone row:

5. We can transpose the tone row to any starting pitch, play it backwards and invert it. Here, once the counter has completed we trigger a random transposition for the next play through the row, we also invert the row every other time:

6. The notes of the tone row can appear in any octave. We've included a random transposition of octaves for each note:

7. For each note we're choosing a random rhythm from our rhythm list. You can see some of the rhythms are set to 0, so if this rhythm is chosen we'll have two notes played at once:

8. Here is the final patch (click on the image to see a larger image):

I recommend creating the patch yourself by copying the layout of the screenshot, however you can also download the patch here.

## Tuesday 23 March 2010

### Piano Phase | PureData

Steve Reich was an algorithmic composer. His composition Piano Phase (1967) involves two pianists playing an identical twelve note phrase, however one is played at a slightly faster tempo than the other.

Gradually as the piece progresses the two parts drift further out of phase with each and listening, you can hear new melodic fragments appear created by the combination of the two parts.

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

If you want to implement the patch in Max there's another algorithmic composition post here.
Here is a PureData algorithmic composition patch that realises Piano Phase. Here's how the patch works:
• 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 a tabread object, this object reads through our stored piano phrase
• This is then sent out to a makenote and noteout object to create and output MIDI notes.
Here's a screenshot of the finished patch, you can view a larger version by clicking on the image.

As ever I recommend creating the patch yourself by copying the layout of the screenshot, however you can also download the patch here.

The good thing about creating a computer version of Steve Reich's algorithm is that it's easy to manipulate. If you want to try the same process with a different melody then alter the notes stored in our pianoPhrase message. If you want to try adding a 3rd part with a new tempo then it is easy to select and duplicate the necessary objects.

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

## Monday 22 March 2010

### Interpolate Between Two Chords

The last two PureData posts have introduced the idea of simple indeterminacy: including random elements in your compositions.

Today we'll look at a deterministic example, one that given the same input parameters will produce the same output each time.

Imagine we have two notes, we can create an algorithm to 'join the dots', moving from one note to another in a specified number of steps. We need to:
• Define the start note
• Define the target note
• State how many steps we want to take to get from A to B
Now imagine we have two four note chords, we can interpolate between the notes of the two chords in exactly the same way. This leads to some interesting harmonies, but of course is a very different way of thinking about chords, harmony and voice leading than is usual. Not wrong, just different.

This example patch defines two chords using MIDI notes:
• 36, 43, 49, 79, 100
• 61, 64, 67, 42, 24
Here we're using 5 note chords but your chords can have as many voices as you like.

This patch uses the 'list-inter' object to interpolate between individual list elements. You need to make sure you have PD extended installed to use this. This object takes 3 inputs
• A number between 0 and 1 that represents the interpolation between the lists. 0 will output the first list, 1 will output the end list, .5 will be half way between the two.
• A starting list
• An ending list
Creating The PureData Algorithmic Composition Patch
This section of the patch divides the number of steps by 1 to give us our interpolation amount between 0 and 1.

This is used together with the counter. We count from 0 to the number of steps, this count is multiplied by our interpolation factor:

This section loads our two chords, the list-inter object is used to interpolate between them, the iter object takes the list of notes and outputs them quickly one after another - so that we hear them at the same time.

The >= 1 object on the left sends a message to the metronome to stop when we reach our target chord.

This final section includes our MIDI output objects. We've also included a random object that is controlling our MIDI velocity to make the dynamics a little more varied and musically interesting.

Here's the entire patch - you can click on the image to see a larger version.

It's worth trying to build the patch yourself, make your patch look like the screenshot, from the put menu, use objects [PD: CTRL 1, Mac: CMD 1], messages [PD: CTRL 2, Mac: CMD 2], numbers [PD: CTRL 2, Mac: CMD 2], a toggle and bang to create the patch.

Once you've created the patch, experiment - this is one of the big advantages of algorithmic composition, you create the process that will write the music and can experiment with the input parameters until you find results that you like. In this patch we can:
• Change the start and end chords, including the number of voices
• Change the number of steps that we take to get from A to B
• Change the metronome speed so we generate our interpolated chords faster or slower
You can hear some sample output here:

In future posts we'll introduce more algorithmic composition ideas and start to link these together to form full compositions. We'll also be looking at more examples in other algorithmic composition software including Open Music, Max, Common Music / Grace, Supercollider, Lisp and Java.

## Saturday 20 March 2010

### Tutorial - PD2: Random Major Scale Pitches

Following on from our last PureData tutorial that played random chromatic pitches, we'll make our patch a little more melodic by choosing our pitches from a major scale.

If you haven't already work through the last PureData algorithmic composition tutorial or download the PureData patch here.

Our last patch looked like this:

1. Open our last patch from tutorial one. You can see the finished version of the patch at the bottom of this post.
2. We'll store the pitches of our major scale in a message: create a new message [PD: CTRL 2, Mac: CMD 2] and type this is into the message ; majorScale 0 0 2 3 5 7 9 11 12
3. This defines the intervals of a major scale. We need to store this in a table, create a new object [PD: CTRL 1, Mac: CMD 1] 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.
5. We'll set the patch up so the scale is stored automatically when the patch loads. Enter edit mode [PD: CTRL E, Mac: CMD E]. Create a new object [PD: CTRL 1, Mac: CMD 1], type 'loadbang' into the object and connect it to the message.
6. Break the connection between the 'random' object and the '+' object. Create a new object and type 'tabread majorScale' into this object.
7. Optional: create two new number boxes [PD: CTRL 3, Mac: CMD 3] 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.
8. 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.
9. 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.

Remember to make sure you have set a MIDI output in preferences/Midi settings.

It's definitely worth building the patch yourself to get used to working with the program, but you can also download the patch here.

## Friday 19 March 2010

### Open Music

Open Music is a visual programming language for algorithmic composition that is written in LISP. It uses a graphical interface in which you connect objects together to create your patch:

Open music has many built in functions and can output MIDI, traditional scores in musicXML format to Sibelius and Finale, Csound scores and more.

In addition to the built in tutorials, two books are available. The OM Composers Book1 and The OM Composers Book2, a future post will give a full review of these books.

Openmusic is available for Apple Macs and Windows computers. A version with additional libraries is available by subscribing to the IRCAM forum but a full and free open source version is also available

We'll include some full Openmusic tutorials in a future post, but for now here is the OpenMusic version of the simple random pitches patch created in PureData last time.

## Wednesday 10 March 2010

### Tutorial - PD1: Random Pitches in Puredata

This is a simple tutorial example to generate random pitches. For this example we'll use a program called Puredata. It's free, runs on Macs, PC's and Linux and can manipulate MIDI, audio and video.
2. Start the program and create a new patch from the file menu [PC: CTRL N, Mac: CMD N]
3. Now we need to start creating the patch, from the put menu add a toggle
4. Again from the put menu add an 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.
5. Add another object from the put menu or use the shortcut [PD: CTRL 1, Mac: CMD 1] 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)
6. Add a number box, either from the put menu or using the keyboard shortcut [PC: CTRL 3, Mac: CMD 3]. This is not strictly necessary but will display the random number that has been chosen.
7. Add another object '+ 48' (don't forget the space. This will add 48 to our random number to lift it into a sensible MIDI range.
8. Add a further number, again not strictly necessary but will show the resulting number.
9. Add a makenote object as per the screenshot. The other arguments included are velocity and duration.
10. Add a noteout object and connect everything up as shown in the screenshot.
11. Go to preferences MIDI settings and choose a MIDI output.
12. 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.

Here are some things to try:
• Change the value in the metronome box 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

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.

## Monday 8 March 2010

### What Is Algorithmic Composition?

What Is Algorithmic Composition?
An algorithm can be defined as “a set of rules for solving a problem in a finite number of steps”, (David Cope, 2000). Algorithms are instructions that are followed to complete a task. When composing algorithmically we write the instructions that will create the music rather than the musical notes themselves.

If you were to write a song or compose a piece of music, traditionally the composer(s) decide exactly what note is played where, for how long and on what instrument. You may have a plan in mind of what the finished piece of music will sound like, but work through step by step explicitly writing down each note on a piece of paper or recording it in a sequencer or multitrack recorder.

With algorithmic composition, rather than spelling out each note and instrumental part, you create an algorithm or 'set of rules' that will create the musical surface for you. Heinreich Taube describes this as composing at the metalevel.

Here's a simple example. If you were writing a song you might start by writing a chord progression. If you were to write a chord progression algorithmically, you would specify:
• The list of chords that could be used
• How often these chords could or would change
• A way of choosing between these chords
• How many chords you wish to generate
This could be choosing between the diatonic chords of C major twice a bar, for four bars and choosing the chords completely randomly, or choosing the possible chords that could follow the current chord.

Why Compose Algorithmically?
This brings us to a few of the benefits of being an algorithmic composer:

1. Using computers, it's just as easy to generate 1000 chords as it is to generate 4.
2. We can use the system to generate ideas for us, if we want we can discard those we don't like
3. Once we've created the algorithm, we can tweak it to generate variations e.g. use a different set of chords or rhythm

This is a very simple example and is obviously quite limited. However it introduces us to some ideas that we'll look at in more depth in future posts.