Today's algorithmic composition tutorial looks at using OpenMusic to manipulate and generate musical material from tone rows.
If you haven't already got OpenMusic 6.5 installed you can download OpenMusic free for Mac and PC here. IRCAM supply a number of tutorials but you can also look through the OpenMusic tutorials available here.
Jump to the end of the post to hear some sample algorithmic music output from this patch.
Serialism developed as a framework for composing and organising atonally and moves away from the sense of a key by giving each pitch equal worth. This patch starts with a tone row from the Berg Violin Concerto:
G, Bb, D, F#, A, C, E, G#, B, C#, Eb, F
All pitches must be played through in order, in order to provide more melodic material the tone row can be transposed to any pitch, inverted and played backwards.
First we'll create our tone row (to create a new object CMD click and type in to the box created).
Showing posts with label omalea. Show all posts
Showing posts with label omalea. Show all posts
Friday, 2 September 2011
Thursday, 20 May 2010
Algorithmic Composition with OpenMusic | Markov Chains and Rhythm
Previous Algorithmic Composition tutorials have looked at using Markov Chains in OpenMusic, using some of the functions available in the OMalea library to analyse the pitches of a MIDI file and create new algorithmic compositions based on these.
Today we're looking using Markov Chains in OpenMusic to generate rhythmic patterns for algorithmic compositions.
Our previous OpenMusic tutorial used these functions from OpenMusic's OMalea library:
Today we're looking using Markov Chains in OpenMusic to generate rhythmic patterns for algorithmic compositions.
Our previous OpenMusic tutorial used these functions from OpenMusic's OMalea library:
- ana-mark to analyse a MIDI file to create a transition table of pitches and
- markov1 to generate a new algorithmic composition based on the transition table.
Friday, 23 April 2010
OpenMusic Markov Chains and omlea
We've looked at using OpenMusic for algorithmic composition in a number of posts before, we've also looked at using the OpenMusic OMalea library and random walks in OpenMusic. Today we're going to use OpenMusic and OMalea to work with Markov Chains.
Markov Chains are a very useful tool for the algorithmic composer, we've looked at Markov Chains in keykit here. If you're not familiar with how Markov Chains work it's definitely worth reading this algorithmic composition post.
In brief, Markov Chains chose the next note using a probability. For example if the current note is E, there might be a 70% chance of the next note being a A and a 30% chance of it being an C#. These probabilities are stored in something called a transition table or transition matrix.
We can either create the transition matrix by hand or we can create it by analysing an existing piece of music (or any other piece of data).
This is the approach we'll take in today's post. We'll load up a MIDI file, create a transition matrix from this using the ana-mark function, and then generate new melodies based upon this.
1. First of all we need to load up a MIDI file. Create a new class MIDIfile, either by choosing from the menu or CMD clicking (CTRL click on PC) and typing midifile.
2. Evaluate the midifile class by hitting the 'v' key or CMD clicking on it's output (CTRL click on PC). This will allow you to load up a MIDI file, once it's loaded make sure the midifile class is selected and press b to lock it. This will ensure that you don't have to load the MIDIfile every time you evaluate the patch.
3. We next have to extract the pitch data from the MIDI file. We can also use markov chains to generate rhythm, dynamics and other musical information, but for now we'll stick with pitch. Add a mf-info function, this allows to extract each note from the MIDI file.
4. If you evaluate the mf-info function, you can see a list of lists that describe each note, something like this, where the values are pitch, onset, duration, velocity and MIDI channel
((64 1000 500 52 1) (73 1500 385 58 1) (74 1875 125 43 1) (62 2000 500 32 1))
5. We need to access just the first element of each set of parentheses: the pitch. There are a number of ways we can do this, but the simplest is to use the mat-trans function followed by the first function. Add these in one a time and evaluate them to see what they do. You patch should now look like this:
6. Now when we evaluate our patch we get a list of pitches. This can be fed into the ana-mark function (remember you need the omalea library enabled to be able to use this function - this can be turned on in preferences if it's not already).
The ana-mark function in OpenMusic automatically generates a Markov transition matrix for us of the form:
((list-of-pitches ((first-pitch-probabilities) (second-pitch-probabilities... ... (last-pitch-probabilities)))
Something like this:
((1 2 3) ((0.0 1.0 0.0) (0.333 0.0 0.667) (0.0 1.0 0.0)))
7. We need to be able to separate our list of pitches, the first element in the list [ (1 2 3) in the above example ] from the list of probabilities [the second element in the list]. For this we can use the Lisp functions first and second. You can type first and second directly into a new box to create them, or create them from the drop down menu. So far our patch looks like this:
8. We can now connect a Markov function. There are two Markov functions in the OpenMusic omalea library, markov1 generates a single next pitch and can be used with repeat-n to generate a series of pitches. Markov2 generates a series of pitches. Here we've added a markov2 function and asked it to create a series of 50 notes starting with the first note.
9. When you evaluate markov2 you'll notice that outputs the index rather than the actual pitch we entered. So if we were using notes 60, 64, 65 and 67 the markov2 function thinks of them as 1, 2, 3 and 4. We can easily map this index to our original list of pitches by using the posn-match function (position match). Your finished patch should look like this:
Now when you evaluate the patch, we generate a list of pitches based upon the original set of pitches in out MIDI file. To get a better understanding of what's happening at each stage, evaluate each function in turn by selecting and pressing v and looking at the output in the listener window. To get a better understanding of Markov Chains in general do have a read through a previous on Markov chains and algorithmic composition.
You can also try using the Markov chains to generate elements of your CSound scores as looked at in the post on algorithmic composition, OpenMusic and CSound - using the om2csound library.
Check back soon for more algorithmic composition techniques and tutorials.
Markov Chains are a very useful tool for the algorithmic composer, we've looked at Markov Chains in keykit here. If you're not familiar with how Markov Chains work it's definitely worth reading this algorithmic composition post.
In brief, Markov Chains chose the next note using a probability. For example if the current note is E, there might be a 70% chance of the next note being a A and a 30% chance of it being an C#. These probabilities are stored in something called a transition table or transition matrix.
We can either create the transition matrix by hand or we can create it by analysing an existing piece of music (or any other piece of data).
This is the approach we'll take in today's post. We'll load up a MIDI file, create a transition matrix from this using the ana-mark function, and then generate new melodies based upon this.
1. First of all we need to load up a MIDI file. Create a new class MIDIfile, either by choosing from the menu or CMD clicking (CTRL click on PC) and typing midifile.
2. Evaluate the midifile class by hitting the 'v' key or CMD clicking on it's output (CTRL click on PC). This will allow you to load up a MIDI file, once it's loaded make sure the midifile class is selected and press b to lock it. This will ensure that you don't have to load the MIDIfile every time you evaluate the patch.
3. We next have to extract the pitch data from the MIDI file. We can also use markov chains to generate rhythm, dynamics and other musical information, but for now we'll stick with pitch. Add a mf-info function, this allows to extract each note from the MIDI file.
4. If you evaluate the mf-info function, you can see a list of lists that describe each note, something like this, where the values are pitch, onset, duration, velocity and MIDI channel
((64 1000 500 52 1) (73 1500 385 58 1) (74 1875 125 43 1) (62 2000 500 32 1))
5. We need to access just the first element of each set of parentheses: the pitch. There are a number of ways we can do this, but the simplest is to use the mat-trans function followed by the first function. Add these in one a time and evaluate them to see what they do. You patch should now look like this:
6. Now when we evaluate our patch we get a list of pitches. This can be fed into the ana-mark function (remember you need the omalea library enabled to be able to use this function - this can be turned on in preferences if it's not already).
The ana-mark function in OpenMusic automatically generates a Markov transition matrix for us of the form:
((list-of-pitches ((first-pitch-probabilities) (second-pitch-probabilities... ... (last-pitch-probabilities)))
Something like this:
((1 2 3) ((0.0 1.0 0.0) (0.333 0.0 0.667) (0.0 1.0 0.0)))
7. We need to be able to separate our list of pitches, the first element in the list [ (1 2 3) in the above example ] from the list of probabilities [the second element in the list]. For this we can use the Lisp functions first and second. You can type first and second directly into a new box to create them, or create them from the drop down menu. So far our patch looks like this:
8. We can now connect a Markov function. There are two Markov functions in the OpenMusic omalea library, markov1 generates a single next pitch and can be used with repeat-n to generate a series of pitches. Markov2 generates a series of pitches. Here we've added a markov2 function and asked it to create a series of 50 notes starting with the first note.
9. When you evaluate markov2 you'll notice that outputs the index rather than the actual pitch we entered. So if we were using notes 60, 64, 65 and 67 the markov2 function thinks of them as 1, 2, 3 and 4. We can easily map this index to our original list of pitches by using the posn-match function (position match). Your finished patch should look like this:
Now when you evaluate the patch, we generate a list of pitches based upon the original set of pitches in out MIDI file. To get a better understanding of what's happening at each stage, evaluate each function in turn by selecting and pressing v and looking at the output in the listener window. To get a better understanding of Markov Chains in general do have a read through a previous on Markov chains and algorithmic composition.
You can also try using the Markov chains to generate elements of your CSound scores as looked at in the post on algorithmic composition, OpenMusic and CSound - using the om2csound library.
Check back soon for more algorithmic composition techniques and tutorials.
Saturday, 17 April 2010
The OpenMusic OMalea library - Random Walk
In our last post we had a look at some of the functions in the omalea OpenMusic library.
In the last post we looked at mapping some different probability distributions to pitch. Using other omalea functions, we can explore a number of random walk functions to generate pitch sequences:
Random walks
Imagine a drunk walking home. When he reaches a junction he can turn left, right or carry straight on, being quite drunk he randomly chooses a direction, then he reaches another junction and repeats the process.
Using a random walk process for deciding pitches with algorithmic composition, we choose a start note and then randomly choose between the same note, a note above or a note below, we can usually choose how big a steps our 'drunk' can take.
These two random walks brownian1 and randwalk1 set a start point, upper and lower boundaries, a sequence length and a bandwidth or maximum step.
brownian1:
rand-walk1:
The layout of both examples if fairly straightforward with the random walk function and a rhythm-tree, feeding into a voice object.
In a future post we'll look at some of the remaining omalea functions, including using markov chains in OpenMusic.
In the last post we looked at mapping some different probability distributions to pitch. Using other omalea functions, we can explore a number of random walk functions to generate pitch sequences:
Random walks
Imagine a drunk walking home. When he reaches a junction he can turn left, right or carry straight on, being quite drunk he randomly chooses a direction, then he reaches another junction and repeats the process.
Using a random walk process for deciding pitches with algorithmic composition, we choose a start note and then randomly choose between the same note, a note above or a note below, we can usually choose how big a steps our 'drunk' can take.
These two random walks brownian1 and randwalk1 set a start point, upper and lower boundaries, a sequence length and a bandwidth or maximum step.
brownian1:
rand-walk1:
The layout of both examples if fairly straightforward with the random walk function and a rhythm-tree, feeding into a voice object.
In a future post we'll look at some of the remaining omalea functions, including using markov chains in OpenMusic.
Subscribe to:
Comments (Atom)












