MarkovMelodyGenerator
Simone Hill'
December 12, 2011
Attach:SimoneHill.FinalPaper.MarkovMelodyGenerator.pdf
Generates a random melody using Markov Chains built from states and transitions modeled from existing songs.

Concepts Demonstrated
- Statistics: Conditional probabilities are used in analysis by computing probability matrices of pitch and duration (in beats) transitions between notes in a melody sequence from an existing song.
- Markov Chains: These transitional probability matrices are used to model the finite state machine that represents the "Markov Chain" process for generating a new sequence of notes.
Samples
Attach:MarkovMelodyChainSamples.zip
Survey
Sample Markov Melodies bundled together with the original songs used for analysis
Attach:SampleMarkovMelodiesPlusOriginals.zip
Basic Explanation
First, a transitional probability matrices are constructed for pitch and durations of notes. If I'm analyzing Beethoven's Ode To Joy and find that a note with pitch A is followed by a B flat 50% of the time, and a C 30% of the time and a G 20% of the time, then I create a model of all the states (representing these pitches of notes i.e. C, G, B flat, etc) and the transitions between these states with these analyzed weights attached. Similarly, I repeat the process when analyzing the note durations. So if a half note is followed by a quarter note 70% of the time or a whole note 30% of the time, then this goes into a probability transition matrix i.e. a state transition machine expressed mathematically as a table of conditional probabilities more or less.
Then the process walks through this state transition machine making randomized choices. However, these artificial choices will biased according to the weightings gathered from analysis of existing human compositions. In other words, the transition of the next state will be conditionally dependent on what the previous state was, using statistical analysis of note transitions extracted from an existing song. The theory is that the resulting randomly generated tune will sound more melodic and have some structure rather than sound like an "aimless wandering around an audio landscape".
Innovation
Algorithmic composition has been around for hundreds of years so that concept is hardly new. This project is merely my first attempt at learning about algorithmic composition solutions for generating music. This version will only employ Markov Chains. However, its easy to see how many other concepts can be applied to expand on the possibilities, such as Hidden Markov Models to generate harmony, or genetic algorithms for evolving percussion beats.
Evaluation of Results
Since music is subjective, a Turing test will be employed in order to evaluate whether or not the Markov Melody Generator produced "good" results. A survey was made up with four different songs generated by the Markov Melody Generator. Subjects were asked to listen to each song and and then rate songs accordingly on a scale from 1 (=Boring) to 5 (=Interesting) as a way to measure the fitness of the Markov Chain composition.
The results of the survey were somewhat varied but overall ranged between neutral to positive. A majority of participants gave "Markov Chain 0" and "Markov Chain 2" a rating of 5 (maximum value for interesting) and gave "Markov Chain 1" and "Markov Chain 3" a rating of 2 and 3 respectively. According to median, the generated melodies are ranked as follows in order of interesting to boring: "Markov Chain 2", "Markov Chain 0", "Markov Chain 3" and "Markov Chain 1". Given that the criteria of the rating scale, i.e. from "boring" to "interesting", and interpretation of music in general are highly subjective, the results were relatively positive and higher than expected.
Discussion
Originally, I wanted to do a Turing test but I just ran out time to properly implement one so I turned it into a more subjective survey to at least gather some type of data with a "result" for the paper. I also realized, after getting my code to work completely and hearing some generated samples for the first time, that the project is still in a primitive stage anyways. In other words, I didn't think any of the generated samples were good enough to pass a Turing test.
However, the Markov chain does show promise as a building block and I discussed in my paper idea for other approaches that could be combined with Markov Chains to create a more sophisticated solution for algorithmic computation e.g. higher order Markov chains could add more phrasal structure, Hidden Markov Models could be used to establish harmonies by playing chords that accompany the "root note" and other ideas such as using a variation on a genetic algorithm for evolving drum beats and possibly apply some of the other concepts in learning, planning or even searching to model the music creation process, although I'm not sure how yet.
Anyways, I just didn't have the time to explore any of these additional ideas before the deadline. However, exploring the Markov Chains seemed to be a good first step in exploring algorithmic music composition and the field of computation creativity in general.