Tip:
Highlight text to annotate it
X
This is the final presentation of the CS800 special topic course on procedurally generated
music. As part of this course a music web application has been created that generates
music using a combination of the following approaches: Markov imitation, scale transformation,genetic
algorithm. In the previous video presentation we had looked at how the Markov imitation
and scale transformation options were implemented. So in this presentation we will instead focus
on the genetic algorithm component.
When using a genetic algorithm to evolve an aesthetically pleasing piece of music one
has to deal with four important procedures: Encoding, which is essentially about how one
represents a piece of music as a sequence of numbers in a linear construct such as an
array; and then there is the task of generating variations of the encoded music, so that one
has a pool from which musical pieces can be selected from. Which musical piece will be
selected depends on how we assign fitness based on a particular pattern of notes. We
also look at how the algorithm actually implements selection.
The encoding of a musical piece is straight forward because the music itself is nothing
more than a sequence of notes arranged linearly, and this can be represented in a linear array
by using numbers to represent pitch and note duration as shown on the slide.
Now that we have our digital genome, how do we generate variation for selection to work
its magic?
There are three methods available: point mutation, recombination, transposon propagation.
Point mutation involves selecting a single note at a random position on the chromosome
and changing it to some other random note value.
Recombination requires a pair of chromosomes. We usually use the top 25% of our digital
genome population for this. A random crossover point is selected, and the sequences beyond
the crossover point are swapped as shown on the slide.
Transposon propagation is used by nature to more efficiently create order at multiple
length scales, something which cannot be quite easily achieved by the previous two methods.
We copy nature and implement a method for copying genetic information from one location
of the digital genome to another on the same chromosome.
The key to the success of a genetic algorithm, one that allows it to create melody that sounds
like real music, is the fitness function.
The slide is self explanatory so we will move on to consider how the selection mechanism
is implemented in code.
This slide shows the heart of the genetic algorithm. In the app we have used a population
size of 500, and the population of genomes has been allowed to evolve for 500 generations
before the genome with the highest fitness score is selected and used to generate the
music that the app plays. Now on to the actual demonstration.
The latest version of the CS800 music app has a genetic algorithm option, and in this
video I am going to show you how it works. When you first start the program the genetic
algorithm option is not switched on by default.You have to manually select one of the available
options.
Let's say we want to use the genetic algorithm option to create a music, a piece of music
that has the same musical features as Nella Fantasia. So we will select this option and
then we will just play a few notes on the keyboard. The notes that you play will not
directly influence the tune that will come out of the genetic algorithm. However it will
seed the algorithm so that it starts it's search at a particular point in the genome
space.
Ok, since the record button has already been armed, let's just play a couple of notes.
Then we press stop, and the genetic algorithm option kicks in, and this is going to take
some time. Ahh...because this is a very old computer, 10 year old computer. On your computer,
if it's one of the more recent ones, it will probably take less that a minute to ahh evolve
a suitable piece of music.
I'm just going to fast forward this so that we get to the end result.
Now that the genetic algorithm has finished its work, let's press play and have a listen
to the music that the genetic algorithm has created.
You'll notice that in addition to the main melody line, the genetic algorithm has...computed
the most appropriate chord sequence. Ahh...played here by the piano keys on the lower register.
Now you might be thinking that that doesn't sound really like Nella Fantasia. However
the goal of the genetic algorithm is not to create something that sounds exactly like
Nella Fantasia, only to create a piece of music that shares the same musical features
such as pitch intervals, note duration intervals, and so on.
The chord accompaniment is not played if you were to combine, the output of the genetic
algorithm with one of the Markov imitation options. SO if you want the chord accompaniment
to play, do not combine the genetic algorithm option with either the first order, second
order, or third order Markov imitation. You can however use the scale transformation option
if you wish.