4. APPROACH
Many problems of life are hard to solve directly and require a search in order to find the
best solution. Often the solution domain is far too vast to weigh all options, so searches
must be cleverly designed to rapidly find optimal candidates. Genetic algorithms are
heuristics that model the processes of nature for the purpose of expediting search. In
this case, the search is for music.
Several facets characterize evolution. Heredity is the passing of characteristics from
parent to offspring. Selection is when individuals are assessed by their fitness and
chosen for breeding. Mutation is when one characteristic of an individual randomly
changes. To model music, a melody is an individual, and its characteristics are its
constituent notes. A population is a collection of melodies.
The Little Ludwig undergoes two phases. The first is the “inspiration phase” and
consists of the Little Ludwig building a relational vector for the input inspiration piece.
A relational vector is simply a list of each symbol’s probability of being n positions away
from any other symbol.
The next phase is the “composition phase.” It begins with the generation of an initial
population containing melodies whose notes are randomly chosen. Each melody is
assessed for fitness. In order to determine the next generation, a small, random group
of these melodies are picked out, and the most fit within this small group either copies
itself or mates to produce offspring. After the copy or child randomly mutates, it waits
in the next population while the selected group returns to the current population. This
selection process continues until the next generation is full of individuals, and then the
Journal of the ACM, Vol. 1, No. 1, Article 1, Publication date: May 2011.
1:4 E. Bellinger
procedure repeats [Sivanandam and Deepa 2007]. It is easy to see how this procedure
facilitates the production of fitter individuals.
The fitness of each composed melody is determined by the probability of its note
arrangement occurring given the compositional influence provided by the user. When
the Little Ludwig composes music, it operates on the assumption that context dictates
the note placement within a piece. In other words, a note fits within a melody if it has
a high probability of occurring when the notes surrounding it also occur. More specifically,
the fitness of an individual is the dot product between the relational vectors of
the inspiration piece and that individual.
5. KNOWLEDGE REPRESENTATION
The Little Ludwig can operate on any list of symbols. In fact, the program was constructed
with Common Lisp, a list processing language. For musical composition, individuals
are melodies modeled as lists of notes. The symbols used for notes can be
those of JFugue, an open source Java library for music programming [Surhone et al.
2010]. In this representation, the notes are written as their pitch, such as C, D, E, etc.,
but have the capacity to represent complex musical notions by simple concatenation
of more information. For instance, to play C for a whole beat, one uses the symbol Cw.
To put that note in the fifth octave, one writes C5w. The first bar of “Twinkle Twinkle
Little Star” may be represented as this list: (C5q C5q G5q G5q A5q A5q G5h). A list
of any other symbols works just as well. For example, consider this list of words: (this
list of words). The Little Ludwig is able to process that list and generate a new list of
words with similar positional qualities.
6. RESULTS
Due to its nature, many hundreds of thousands of pieces composed by the Little Ludwig
exist. Figures 1 and 2 show two examples of such compositions in the form of
JFugue music strings. In both of these cases, Bach’s Crab canon was used as the inspiration
piece. Table 1 illustrates that the Little Ludwig learns over time by presenting
the fitness of the least and most fit individuals as well as the mean fitness
of the entire population for each generation in one sample run of the program. For
Journal of the ACM, Vol. 1, No. 1, Article 1, Publication date: May 2011.
Little Ludwig, an evolutionary learning machine for musical composition 1:5
aural examples, please visit the YouTube channel for the Little Ludwig, found at
http://www.youtube.com/user/TheLittleLudwig.
D5H G5I E5H E5Q A5Q G5I E5I F5Q F5I A5Q D6Q G5Q C#5H E5I RQ C#5Q A5I
E5H BB5I AB5H D5Q A3Q F5I EB5Q F5I E5H G5Q F5H C#6I RQ G5I E5H F6I F5H
C#5Q BB5I BB5H A5I F5H A3Q D6I A5I E5H B5I A5I F#5H E5I D6I BB5I EB6I
BB5I F6I RQ C#6I EB6I E5I B5I A5Q EB6I G6I F6I EB6I EB5Q A3Q F5I E6I EB5Q
A5I F5H G6I EB6I RQ F5H A3Q B5I A5I A5H E6I E5I A5Q E6I D5Q B5I C6I C#6I
D5H BB5H BB5I D6I D6Q C6I E5H D5Q
Fig. 1: The most fit melody composed in the first generation of one sample run of
the Little Ludwig when using Bach’s Crab canon as inspiration. This melody scored a
fitness of 0.091179.
D5H A5Q E5H A5Q A5Q G5I A5I F5Q F5I A5Q G5I G5Q A5I F5I G5I A5I A5I A5I
BB5I A5I A5I G5I F5I A5I F5I A5I A5I A5I A5I E5I G5I G5I A5I A5I A5I BB5I A5I
A5I A5I F5I D6I A5I A5I A5I A5I G5I E5I A5I BB5I G5I BB5I A5I A5I C#6I A5I BB5I
A5I G5I A5I A5I BB5I D6I E6I D6I D6I C#6I A5I E6I D6I D6I C#6I G6I A5I A5I
BB5I D6I E6I E6I A5I D6I E6I F6I D6I E6I D6I D6I F6I F6I A5Q F6I E6I D6I D5Q
Fig. 2: The most fit melody composed in the 99th generation in the same sample run.
This melody scored a fitness of 0.555080.