McAlpine, Kenneth Et Al. - 'Making Music With Algorithms - A Case-Study System'
McAlpine, Kenneth Et Al. - 'Making Music With Algorithms - A Case-Study System'
Musicians, perhaps more so than any other group premier of The Illiac Suite. Later, Gottfried Koenig
of artists, have always been quick to embrace tech- developed the Project 1 and 2 composition pro-
nology in all its forms. From early attempts at syn- grams (Koenig 1970a, b).
thesis with the Telharmonium (Roads 1996) to the Computer-based algorithmic composition contin-
latest digital-audio workstations (see, for example, ues the post-war trend toward formalized and sys-
Lehrman 1997; Manning 1993), musicians have tematic composition methods, such as Arnold
looked to science to provide them with new and Schoenberg’s tone-row and Anton Webern’s
challenging ways of working. serialism methods (Roads 1996). Considered thus, it
One composition method that has benefited is apparent that the computer is merely a tool for
greatly from advances in technology is algorithmic the realization of abstract design constructs, and is
composition. Algorithmic composition is by no best employed as a labor-saving device to free the
means new—formal techniques for melody compo- composer from performing menial calculations by
sition date back to at least 1026, when Guido hand. Using a computer, it is possible to preview and
d’Arezzo proposed a scheme that assigned pitches test the musical capabilities of many different algo-
to each vowel sound in a religious text (Loy rithmic types and judge whether they have the po-
1989)—but the advent of affordable and powerful tential to be developed into full-fledged composition
computing resources has meant that more and systems. This is also the view subscribed to by the
more people, armed with no more than a little pro- authors. Computers in music, and indeed, the algo-
gramming knowledge and some musical ideas, rithmic composition systems themselves, are best
have been able to realize their composition algo- thought of as composition tools rather than one-stop
rithms from the comfort of their own desktops. music solutions. It was with this in mind that we
The use of computers as composition generators developed CAMUS 3D, a composition system of our
was pioneered in the mid-1950s by such people as own design that likens the process of music compo-
Lejaren Hiller (Hiller and Isaacson 1959), whose sition to that of pattern propagation. In this article,
1956 work, The Illiac Suite for String Quartet, is we introduce the system and show how two classes
recognized as being the first computer-composed of algorithms are used to generate musical data.
composition. Iannis Xenakis (Xenakis 1960, 1971),
although not the first to publish a computer-com-
posed work, had been composing stochastically Two Classes of Musical Algorithms
generated pieces by hand for some time before the
We now present a brief summary of two classes of
Computer Music Journal, 23:2, pp. 19–30, Summer 1999 algorithms that have been used for music composi-
© 1999 Massachusetts Institute of Technology. tion: stochastic algorithms and algorithms based on
(a) (d)
(b) (e)
(c)
used to describe the normal distribution. Here, known as the order of the chain. Thus, a Markov
however, we use the term to denote any distri- chain that takes only an event’s predecessor into
bution that exhibits a distinctive n-shaped account is of first order, a chain that considers both
curve. Bell-shaped distributions may or may not an event’s predecessor and the predecessor’s prede-
be symmetrical and have their minima at the cessor is of second order, and so on.
endpoints. In general, an Nth-order Markov chain can be
U-shaped distributions (see Figure 1e) are essen- represented by a state-transition matrix—an
tially upturned bell-shaped distributions. They N + 1-dimensional probability table. The state-
peak at the endpoints, and need not be sym- transition matrix gives us information on the like-
metrical. lihood of an event’s occurring, given the previous
N states. Figure 3 shows a possible state-transition
Probability tables may be utilized as, say, part of matrix for a first-order Markov chain with four
a decision-making routine as follows: The com- possible outcomes. Here, the previous states are
poser specifies a number, n, of possible outcomes. listed vertically, and the transition states are listed
With each of these outcomes is associated a proce- horizontally. Thus, if we wish to find, for example,
dure that will be executed if that particular out- the probability of state B occurring immediately
come is selected, and a real number between 0 and after state A, we simply find state A in the first
1 that gives the probability that the outcome will column, and then move along horizontally to the
be selected. Upon normalization, this probability B column. The entry here is 0.5, so there is a 1 in 2
distribution corresponds to a partition of the real chance of this transition occurring.
line segment [0, 1] into n distinct regions, whose For a Markov chain, a state X is said to be reach-
interval widths are the probabilities of the respec- able from a state Y if it is possible to reach state Y
tive outcomes. A random-number generator is used from state X after a finite number of steps. If state
to generate a real number between 0 and 1. The de- Y is reachable from state X and state X is reach-
cision can then be made by observing in which of able from state Y, then the two states are said to
the n segments the number lies (see Figure 2). For communicate. For example, in Figure 3, states A
further information on the implementation of and C communicate, since clearly C is reachable
probability tables, see the work of Lorrain (1980). from A and A is reachable from C. However, nei-
ther A and B nor B and C communicate: although
B is reachable from A (and thus also from C), nei-
Markov Chains
ther state is reachable from B, which is always fol-
Markov chains are discrete probability systems in lowed by itself.
which the probability of future events depends on It can be shown fairly easily that the communi-
one or more past events (Jones 1981). In other cation relation on a Markov chain is an equiva-
words, Markov chains are stochastic processes that lence. That is, the communication relation is
retain memory of past events to influence the out- reflexive (since a state always communicates with
come of future events. The number of past events itself), symmetric (since if a state X communicates
that are taken into consideration at each stage is with a state Y, then clearly Y communicates with
(a) (b)
X), and transitive (since if a state X communicates transition matrix of the Markov chain. Each rhyth-
with a state Y, and state Y communicates with a mic figure that the composer wishes to use is then
state Z, then state X also communicates with state assigned a unique integral value that is used to in-
Z). Grouping communicating states together, we dex the state-transition matrix. The index of the
can partition the states of the chain into equiva- previous state is stored as a temporary variable,
lence classes of communicating states. and used to select the correct row of the state-tran-
Those states that are certain to occur again once sition matrix. The probabilities stored in this row
they have been reached by the chain are called re- are then used to drive a stochastic selection rou-
current, and the equivalence class they belong to tine like that described in the previous section.
is known as a recurrent class. States that may
never occur again (i.e., those that are not recur-
rent) are called transient, and the class they belong Cellular Automata
to is known as a transient class. It can be shown
that every Markov chain consists of at least one Cellular automata are very important to scientists
recurrent class and some number (possibly none) as modeling and simulation tools. They have
of transient classes. found applications in many different disciplines,
Markov processes are exceptionally well suited from physics, chemistry, and biology to philoso-
for rhythm selection. Rhythmic lines often exhibit phy and sociology (Peitgen, Jürgens, and Saupe
semi-cyclic behavior in that short phrases often re- 1992). Cellular automata are discrete dynamical
peat exactly or slightly altered as the line systems; that is, they change some feature with
progresses—the human ear tends to like this sort time. We often view a cellular automaton as an ar-
of regularity. Similar behavior can be engineered ray of elements, referred to as cells, to which we
by careful manipulation of the recurrent and tran- apply some evolution rule that determines how
sient classes within the Markov chain. A Markov the automaton develops in time. Each cell can ex-
chain for rhythm selection may be constructed as ist in one of p possible states, represented by the
follows: The composer first decides on the order of integers 0, 1, 2,…, p – 1. We often refer to such an
the Markov chain that is to be used in the compo- automaton as a p-state cellular automaton. To
sition, and then initializes an array whose dimen- specify fully and run a cellular automaton, we
sionality is 1 greater than the order of the chain, need one further piece of information: an initial
and whose size is determined by the number of cell configuration. When this is specified, the au-
different rhythmic components that are to form tomaton can be set to run and the cellular evolu-
the states. This array will correspond to the state- tion can be observed.
It is important to notice that any long-term glo- The behavior of the system is such that after a
bal trends that arise in the automaton’s develop- number of time steps, the cells self-organize to a
ment are examples of emergent behavior. The patchwork pattern like that of Figure 5.
evolution rules in a cellular automaton are con- We illustrate the musical usage of cellular au-
cerned only with local neighborhoods around the tomata in the following section. The interested
cell under consideration. Global trends are not ex- reader is also referred to the works of Beyls (1997)
plicitly coded beforehand. and McAlpine, Miranda, and Hoggar (1997a, b).
Game of Life
CAMUS 3D
The Game of Life (Wolfram 1984) is a two-dimen-
sional cellular automaton that attempts to model CAMUS 3D (Cellular Automata MUSic in 3 Di-
a colony of simple organisms. The automaton con- mensions) is part of an ongoing research project.
sists of an array of (m × n) cells, each of which can The system is a development of an earlier two-
exist in two states—alive, represented by 0, or dimensional system (Miranda 1993, 1994;
dead, represented by 1. The rule that determines McAlpine, Miranda, and Hoggar 1997a, b), and
the development of the automaton is: a cell will uses three-dimensional extensions of the Game of
be alive at time-step t + 1 if and only if it has pre- Life and Demon Cyclic Space automata to gener-
cisely three live neighbors (other than itself) at ate compositions. The composition process is
time-step t. Figure 4 shows six successive steps of modeled on pattern propagation; we may view
the Game of Life. each theme in a composition as a separate pattern.
As the composition progresses, the patterns are
subjected to certain transformations (such as
Demon Cyclic Space
straight repetition, transposition, inversion, aug-
The Demon Cyclic Space (Wolfram 1984) is a two- mentation, and so on), according to the formal
dimensional p-state automaton of (m × n) cells. structure that the composer has chosen for the
The evolution of the automaton is determined by work. This structure can be rigidly adhered to or
the following rule: a cell that is in state j at time- used as a general guiding principle, but so long as
step t will dominate any neighboring cells that are certain design constructs are in place to guide the
in state j – 1, so that they increase their state to j temporal development of the composition, we can
at time-step t + 1. It is important to note, however, say that we have a system of pattern propagation
that the two-dimensional automaton space is cy- according to some predetermined constraints.
clic. Thus, cells in state 0 dominate cells in state Traditionally, composers have employed pattern
n – 1, so that the influence that each cell exerts on propagation intuitively, but algorithmic composi-
its neighbors has far-reaching consequences, often tion techniques, such as those described below, al-
extending beyond the eight cells that immediately low the pattern propagation to be formalized,
border the cell in question. The cells in the Demon albeit at a much higher level. Here, the composer
Cyclic Space are, in general, initially randomized. does not in general apply specific transformations
to a particular pattern. Instead, all of the musical ment in the composition. The state of the corre-
patterns evolve according to the rules and con- sponding cell of the Demon Cyclic Space automa-
straints that have been specified at the design ton is used to determine the instrumentation of the
stage. Thus, any common stylistic musical fea- piece. This configuration is demonstrated in Figure
tures that emerge from the use of cellular au- 6. In this case, the cell in the Game of Life at (5, 5,
tomata as music generators can be said to be a 2) is alive, and thus constitutes a musical event.
sonification of the emergent behavior of the au- The coordinates (5, 5, 2) describe the intervals in
tomaton; the temporal development arises as a re- a four-note chord: The x cell position (starting at 0
sult of the local evolution rules, and is not in the bottom-left corner) defines a semitone inter-
specified in full in advance. val from a fundamental pitch to the second-lowest
Cellular automata are used to drive the CAMUS pitch of the chord. The y cell position defines a
3D composition process, since these are a well- semitone interval from the second-lowest to the
known and well-understood form of pattern propa- second-highest pitch in the chord. The z cell posi-
gation. Stochastic selection routines are also quite tion defines a semitone interval from the second-
widely utilized within the system, as they offer a highest pitch to the top note of the chord. Note
quick and efficient method of specifying long-term that if the cell position is 0 (corresponding to the
structure while avoiding the often laborious task first cell in each direction), the “higher” pitch de-
of specifying details at each step. fined by the associated interval will be identical to
To begin the composition process, the Game of the “lower” pitch.
Life automaton is initialized with a starting cell The corresponding cell in the Demon Cyclic
configuration, the Demon Cyclic Space automaton Space is in state 4, which means that the sonic
is initialized with random states, and both are set event would be played by instrument number four
to run. At each time step, the coordinates of each (for example, by using MIDI channel 4). Note that
live cell are analyzed and used to determine a four- for the sake of clarity the first two layers of the De-
note chord: a set of four (not necessarily distinct) mon Cyclic Space have been omitted in Figure 6.
notes that may or may not sound simultaneously The use of a discrete three-dimensional Euclid-
and that will be played at the corresponding mo- ean space to represent musical intervals is an ex-
tension of the two-dimensional von Neumann precise note durations. This is achieved by means of
Music Space used in an earlier version of the sys- a first-order Markov chain.
tem (Miranda 1993, 1994). The probabilities in the transition matrix of the
Having established the intervallic content of the Markov chain are, again, user specified. Note
chord associated with a live cell, we must then es- lengths are quantized to sixteenth-note resolution,
tablish the fundamental note to specify fully each and simultaneous note events are catered for by al-
of the pitches in the chord. This can be done either lowing starting times of duration 0.
manually, by reading note data sequentially from a Two methods for specifying the probabilities in
user-specified list, or automatically, by using sto- the Markov state-transition matrix are offered by
chastic selection routines that allow the composer CAMUS 3D. The standard option provides the
to specify the relative weightings of the pitch val- composer with a graphical means of viewing and
ues for the fundamental pitches. altering the probability values. The probabilities
To avoid a piece that is composed entirely of block are represented on-screen by a graded color scheme
chords, we must implement a routine that staggers that ranges from pure red (probability value 0) to
the starting (and possibly ending) times of each of the pure green (probability value 1). This scheme is
notes of the chord. It is a simple matter to calculate natural to use, as it ties in with the natural color
that there are 24 different ways of arranging the start- schemes of the physical world: red often signifies a
ing order of these 4 (nonsimultaneous) notes. For warning or danger (impossible), while green indi-
CAMUS 3D, a stochastic selection routine is used cates safety (certain).
that consults a user-specified table for the associated The standard window is probably best used to
probabilities of each of the 24 possible starting ar- view the probability data to see quickly which
rangements (see Figure 7). When a starting arrange- note lengths are likely to arise. To actually set the
ment has been chosen, CAMUS 3D calculates the probability values, the advanced window allows
direct access to the numerical values. The ad- Composing with CAMUS 3D
vanced window presents exactly the same infor-
mation as the standard option, but does so by We now illustrate the workings of the CAMUS 3D
using numerical values. As with all of the prob- music algorithm by presenting a brief example of
ability tables described herein, CAMUS 3D auto- the system in use.
matically renormalizes the probability data When the system is first loaded, the user is pre-
whenever changes are made. sented with a two-dimensional isometric display of
When the composition process is started, the the three-dimensional Game of Life. This serves as
music is performed in real time, and can be saved the musical score, in the sense that the live cells in
as a type-0 standard MIDI file. In addition, this graphical display correspond to the chord
CAMUS 3D allows the user to save the composi- events in much the same way that the dots on
tion as a set of parameters that correspond to the manuscript paper correspond to note events. This
states of the automata and the probability tables window, as shown in Figure 8, combines the infor-
for the selection routines. While this allows the mation from the Game of Life and Demon Cyclic
composer to recreate the “same” composition, the Space automata, by coloring the live cells from the
resulting music may sound quite different. Game of Life according to the state of the corre-
Whereas the automata are wholly deterministic— sponding Demon Cyclic Space cell. The composer
and so produce identical chord sequences and in- may choose to view the automaton data as a plan,
strumentations each time they run with identical elevation, or end elevation by selecting one or more
initial configurations—the stochastic selection of the view options from the menu (see Figure 9).
routines may lead to very different fundamental The initial configuration of the Game of Life au-
pitches, note orderings, and note durations. tomaton may be set using the CAMUS 3D toolbar.
gorithm design, and represents part of the system’s note ordering will become much more complex as
emergent behavior. For the composer who is pre- we move from considering just four notes at any
pared to put a little effort into the system, the re- one time to a maximum of 12 × 12 × 12 × 4 = 6,912
sults can be very pleasing, and often sound much notes per time step. This is clearly not a trivial mat-
more natural than compositions obtained using ter, and will require a system considerably more in-
comparable algorithmic techniques. We believe that tricate than the current stochastic decision routine.
this is owing to the organic nature of the automata There is also the issue of harmonic content;
used to generate the raw compositional data and to when playing back several simultaneous note
the careful choice of mapping from these abstract events, the likelihood is that a sizeable portion of
mathematical systems to the musical output. the music will sound extremely unpleasant. Thus,
Further developments for the system include when implementing parallel cell checking, we also
implementing a number of different forms of pat- intend to implement a system of chord filtering
tern propagation, such as fractal zooms and other that will examine the note events that are gener-
types of automata, to drive the composition. More ated on each time step and decide which cell com-
complex evolution rules and tools for manipulat- binations produce music that most closely matches
ing the Game of Life cells are also planned, along the composer’s aesthetic preferences. This will be
with a dynamics processor that will color the mu- accomplished by using a neural network (Haykin
sic in a natural way. 1994) that is designed to classify chords and is
One significant limitation of the system at trained to respond to harmony in a similar manner
present is that it will only generate music one cell to the human composer operating the system.
at a time, using a fixed checking order. This means We are aware that research of this sort is a
that the music is generated monotimbrally, and never-ending process, and we are by no means
suffers from a fixed order of chord progression. The searching for the ultimate composition system.
solution to this problem seems to lie with the in- Rather, we seek to develop creative tools that
troduction of parallel cell processing, which will serve a particular purpose or generate specific
not only enable the system to generate several mu- kinds of musical passages.
sical parts at once, but will also overcome the An earlier version of the CAMUS 3D system
problem of the fixed chord sequence. was used by Eduardo Miranda to compose a piece
Parallel processing will, however, raise several entitled Entre l’Absurde et le Mystère for chamber
further difficulties (Miranda 1998). For example, orchestra. The composition was premiered in