Investigation of AI Computer Music Composition Techniques

Jeffrey Grafton
Main
Logs
Links
Code
Test runs
Research

Papers
Project proposal
Research paper

Other Work
Weather Station
Systems Administration

Research

Research and development of musical composition algorithms has been taking place since the 1950s and is still a hot topic today. While there are many systems that have been developed, I will focus for the time being on Markov chains and Lindenmayer systems.

ABC Plus Music Notation

ABC Plus has been the notation of choice for me, due to its simplicity and portability. User-level programs exist to convert the ABC files to either postscript or MIDI format, and using these utilities the music samples on this page have been created. For more information, check the links page.

Markov Chains

Using Markov chains is a popular approach to analyzing and modeling existing musical compositions. A transition matrix is created which gives the probability for some event to follow another. In my simple beginning code, I am worrying only about single pitches - no chords, and no rhythms.

To begin my exploration, I transcribed a classic, Mortal Kombat, to ABC notation. You can see the simplified score below. Click on the image for a MIDI file.

One can construct a transition matrix by lining up the letters of the musical alphabet on both sides of the table. For simplicity, we will ignore octives and accidentals for now.

First, we can tally up how many times a note follows a given note:

ABCDEFG
A16 11113
B1     1
C311 223
D1 21   
E1 2  1 
F1 2  1 
G 1411 1

Then we can normalize the table by making each row sum to one to obtain a transition matrix.

ABCDEFG
A16/23 1/231/231/231/233/23
B1/2     1/2
C1/41/121/12 1/61/61/4
D1/4 1/21/4   
E1/4 1/2  1/4 
F1/4 1/2  1/4 
G 1/81/21/81/8 1/8

Now, we have a set of values that describes the probability that a note will follow a given note; in our example, A follows itself 16 times out of 23. Mortal Kombat is very weird like that, and probably not an ideal song, but it should provide a decent test of the theories.

It should be noted, however, that Markov chains present several limitations. First, they are extremely complex to make for complex music; it is suitable for short compositions such as this one, however. Also, some produced music must be provided as an input, and the resulting music produced using a Markov model will be similar to the input - not entirely unique.

Lindenmayer Systems

Lindenmayer systems, or L-systems, provide a grammar-based approach to composing music. They can be applied to music based on the prinicpal that music often follows patterns similar to language. The function is given a set of productions and an axiom. and then is run over a finite number of iterations. For example, given the productions and axiom below:

p1A->D
p2D->D A E C
p3E->E A A
p4C->D
aC

One would expect the following iterations:

IterationString
0C
1D
2D A E C
3D A E C D E A A D
4D A E C D E A A D D A E C E A A D D D A E C

Then, by concatenating all of the strings together, one would arrive at the composition C D D A E C D A E C D E A A D D A E C D E A A D D A E C E A A D D D A E C, also shown below, given a generic rhythm. Click on the image for a MIDI file.

The limitations of this method are quickly apparent. The music is very repetative - some human-composed music can be - but doesn't seem to ever progress anywhere or have any sense of meaning. A solution to this is to combine the Markov model with the L-systems; the productions correlate to the probabilities expressed in the transition matrix. For example, the set for Mortal Kombat would begin to look like the following:

p1A16/23->A
1/23->C
1/23->D
1/23->E
1/23->F
3/23->G
p2B1/2->A
1/2->G
aany note in Markov model

Some entropy could be used in deciding what note is next, and the resulting composition would exihibit some variability, though it will imitate the original composition; in this case, Mortal Kombat.

Genetic Algorithms

I still have a bit to accomplish in implementing as much as I've described so far, but one could conceivably see using genetic algorithms to produce new music. After a pleasing composition has been produced using the above methods, it could be fed back into the Markov function, producing a new model and a new composition. Over time, theoretically new and unique music could be produced.

Before I get there, though, I would need to look into integrating multiple voices and the notion of rhythm. This can be accomplished using multiple Markov models with multiple recurisions of L-systems, or it can also be applied using other techniques. At some point, the complexity becomes too great and other mechanisms must be used.


All content copyright Jeffrey Grafton 2003-2004. Page last updated 1/21/2004 23:20 EST.