Sunteți pe pagina 1din 6

Evolving Musical Harmonisation

Somnuk Phon-Amnuaisuk, Andrew Tuson!, and Geraint Wiggins


Music Informatics Research Group, Division of Informatics, University of Edinburgh
80 South Bridge, Edinburgh EHI IHN, Scotland, UK.
Email: {somnukpa.andrewt.geraint}@dai.ed.ac. uk

Abstract This paper is structured as follows. We present


a brief statement on the issues interaction vs. non-
We describe a series of experiments in generating tradi- interaction in GAs from the point of view of this study.
tional musical harmony using Genetic Algorithms. We We then outline existing applications of GAs in com-
discuss some problems which are specific to the musical puter music. We present a case study of a knowledge-
domain, and conclude that a GA with no notion of meta- rich musical GA, including a discussion of some signi-
level control of the reasoning process is unlikely to solve ficant problems, and then draw conclusions about the im-
the harmonisation problem well. plications of the work for musical GAs in general.

1 Introduction 2 Interactive GAs


In recent years, the use of evolutionary techniques such The interactive GA (lGA) approach, sometimes taken by
as Genetic Algorithms (GAs) has generated significant GA applications in the musical domain (see section 3,
interest in the artificial intelligence and computer sci- below), uses a human listener as a means to evaluate the
ence communities. This has been reflected in a number fitness of chromosomes. This approach is inappropriate
of publications in the computer music world, some of to our ends in this research, for the following reasons.
which will be discussed later.
In this paper, we explore two aspects of the ap- 1. It is subjective, because it relies on individual pref-
plication of GAs to music: erences - we want an objective measure of what is
going on in our system, so we can properly judge
1. the use of knowledge-rich structures and proced- its performance;
ures within the algorithm itself, as opposed to the
2. Human listeners tend to become more open to a
more traditional use of GA components which are
given piece of music on repeated hearings, and are
not problem-specific;
prone to other inconsistencies based on mood, at-
2. the strict use of objective methods, in the sense tention span, and so on;
that any reasoning encoded.in the GA ~hould be
3. An IGA does not allow us to study the fitness func-
stated explicitly, rather than being implicit in the
tion itself, to determine how faithful it is to our
expressed opinion of a human user.
chosen task - so using an IGA would be removing
These criteria are important because we are work- a major object of interest in this study.
ing in the wider context of simulating and understand- A further tenable position on this issue, lying
ing aspects of human behaviour, so we are not interested part-way between the two poles of interactive and non-
just in achieving a musical result: we wish to be able to interactive, is the idea of using a corpus of existing works
examine the internal behaviour of our methods, and at- and some form of machine learning system to infer a fit-
tempt to form some notion of why the answer we achieve ness function. This approach has been applied by, for ex-
is produced. In particular, we wish to compare the be- ample, Spector and Alpern [14], Burton and Valdimirova
haviour of our harmonisation system with human beha- [4] and Johanson and Poli [12]. Again, for our purposes,
viour, and attempt to explain any discrepancies. this approach is inappropriate, as we are primarily inter-
I Andrew Tuson may now be contacted care of the Department of
ested in the nature of the search space and how to control
Computing, City University, London. UK. search, rather than the nature of the result (given that it be

A. Dobnikar et al., Artificial Neural Nets and Genetic Algorithms


Springer-Verlag/Wien 1999
230

acceptable music). In fact, use of neural networks makes plemented in three parts of the GA. These are described
the fitness judgements even more inscrutable, since at in turn, and followed by an overview of the GA config-
least one can ask a human judge for the motivation be- uration used.
hind his or her judgements.
In the experiments described here, music- 4.1 Chromosome Representation
theoretical knowledge is used to construct a fitness func-
tion in objective and consistent logical terms, which al- Generally speaking, keys and chords are the main con-
lows us to examine the behaviour of the system more cepts in harmonisation of western tonal music. Har-
scientifically than would an IGA. The GA can then be monisation rules are expressed in terms of relationships
used to compare theories (psychological or otherwise) between triads, and between degrees of scale within a
of musical behaviour by observing the search patterns key signature (e.g., tonic-dominant, etc) but not the ab-
and results produced. In particular, it is to be emphas- solute pitch. Therefore, in this implementation, musical
ised that the encoded musical knowledge does not dir- information (e.g., pitch, interval, time, duration) is rep-
ectly constrain the search path - it merely constrains the resented after normalisation with respect to key - that
solution. So our interest focusses on what our GA can is, absolute pitch information is abstracted out. Then,
tell us about the search paths which arise from this un- pitch is expressed in terms of scale degree. To express all
constrained setup. twelve semitones, the standard five accidentals are used.
Different octaves are distinguished by an associated in-
teger. Finally, time intervals are represented as integers.
3 Existing Work on GAs in Music The representation conforms to the CHARM specifica-
tion of Wiggins et al. [16].
GAs have been used in music generation elsewhere. Ex- As noted earlier, a knowledge-rich and directly
amples include Horner and Goldberg [10] who used a meaningful representation is used in our chromosome
GA for thematic bridging; Biles [1], who used an IGA representation. This representation may be thought of
for Jazz improvisation; Jacob [11], who devised a com- as a matrix, which consists of five strings of equal, fixed
posing system using an IGA; and McIntyre [13] and length. The top four strings contain soprano (fixed), alto,
Horner and Ayers [9]. McIntyre used a GA to generate a tenor and bass parts, with the fifth describing the dura-
four part harmonisation of an input melody, focusing on tions of the chords. The user inputs the soprano inform-
Baroque harmony, while Horner and Ayers focussed on ation (assumed to be the melody); the GA will then har-
the harmonisation of chord progressions using GAs. monise the input soprano, homophonic ally, with a fur-
A main aim of our harmonisation project is to in- ther three voices in conjunction with the musical domain
vestigate the potential of a knowledge-rich GA and its knowledge encoded in its operators and fitness function.
performance in the musical domain. So our solution This approach is illustrated in Figure 1, using the
space is not artificially constrained as in McIntyre's sys- completed harmonisation for the first two bars of "0
tem (which only used a C major scale); nor is there prob- Come, All Ye Faithful"; see Figure 4 for the score rendi-
lem abstraction as in Horner and Ayres' system, (which tion of the corresponding output.
uses the GA to generate parts, given a chord progression,
which is a significantly simpler task). Our work aims chromosome length
, A
,
to harmonise input melodies with no explicit cues as to Soprano [0,0,3] [0,0,3] [1,0,3] [4,0,2]
[0,0,3] [4,0,2]
the required harmony, and does not limit itself to a spe- Alto [2,0,2] [2,0,2] [4,0,2] [1,0,2]
[2,0,2] [2,0,2]
cific key or scale; and it works at the level of individual Tenor [4,0,1] [0,0,2] [7,0,1] [1,0,1]
[4,0,1] [2,0,1]
voices, with all the extra constraints this entails. Bass [2,0,1] [4,0,1] [4,0,1] [7,0,0]
[0,0,1] [0,0,1]
Finally, for a more complete summary of GA DurationD
L_l_ _ _2 _ _ _ _ _ _ _ _2_ _ _ 2_
work in music, see Burton and Vladimirova [3].
Fig. 1. Schematic Diagram of a Four Voice Harmony
Chromosome
4 Harmonising Chorale Melodies
byGA In the figure, we can see the matrix arrangement
produced by the direct representation of time (left to
In this section, we present the results of a study on right along the structure) and vocal part and note dura-
the use of GAs in generating four-part homophonic tion (top to bottom down the structure). For the purposes
tonal harmony for user-specified melodies. The domain- of reproduction operators, we view the five horizontal
specific (i.e., musical) knowledge in this system is im- layers as inseparable.
231

4.2 Reproduction Operators omit the fifth only, except in 1st inversion; in inverted
chords, doubling of the bass is preferred; and we penal-
The following crossover and mutation operators are used
ise doubling oftones which give a strong harmonic tend-
in this implementation, described here in musical terms.
ency, such as leading notes.
The reader less familiar with musical jargon may find
In this implementation, the system does not have
solace in Taylor [15J.
enough knowledge to plan for large scale harmonic pro-
gression. The fitness function determines only the plaus-
Splice: One point crossover between two chromosomes
ible harmonic movement between two adjacent chords.
- selects a crossover point between successive notes
The fitness function prefers (in decreasing order of pref-
of the melody and corresponding chords.
erence): descending 5th movement; progression towards
Perturb: Mutate by allowing alto, tenor and bass to the tonic; retrogression; and repetition.
move up or down by one semitone or tone. The
selection of the various possible mutations is ran-
dom.
4.4 GA Configuration
In most of these experiments. exceptions being men-
Swap: Mutate by swapping two randomly picked voices
tioned explicitly here, a generational GA, in the style
between alto, tenor or bass. This gives the effect
of Davis (51, with a panmitic (unstructured) population
of changing the chord between different open and
model was used. Strings were initialised by randomly
closed positions, and of changing inversions.
picking chords containing the relevant soprano pitch. Fi-
Rechord: Mutate to a different chord type. This muta- nally, a popUlation size of at least 50 was used, with bin-
tion generates a new chord from the melody data. ary tournament selection.
A chord is built with the soprano note as root, 3rd
or 5th. Doubling (necessary for a four note chord)
can be in any position. 5 Results and Analysis
PhraseStart: Mutate the beginning of each phrase to All the output of the system was assessed by Dr. John
start with tonic root position on a down beat. Kitchen, a senior lecturer in the Faculty of Music at the
PhraseEnd: Mutate the end of each phrase to end with University of Edinburgh, according to the criteria he uses
a chord in root position. for 1st year undergraduate students' harmony. This ex-
ample scored 5 out of 10 - a clear pass. While other
examples were less successful (most earning around the
4.3 Fitness Function 30% mark), according to the assesser, this was mostly
The fitness function judges the fitness of each chromo- due to the lack of coherent large-scale musical progres-
some according to the following criteria derived directly sion - which was not evaluated in tbe fitness function,
from music theory. Within individual voices (as opposed so this is not a surprise. The system was judged by the
to between voices), we prefer stepwise progression over assesser to be better than student harmonisers at getting
large leaps, and we keep the voice within its proper the basic rules right.
range. We penalise progression to dissonant chords, and Figure 2 shows a harmonisation by OUr system of
we avoid leaps of major and minor 7ths, .:-f augmented the first eight notes of "Joy to the world". The output is
and diminished intervals, and of intervals larger than one not perfect, but it is surprisingly good given the limited,
octave. local nature of the rules built into the system.
Between voices, we apply the following criteria:
we avoid parallel unison. parallel perfect 5ths, and par-
allel octaves; we forbid progression from diminished 5th SA
to perfect 5th (though the converse is allowed); we avoid
hidden unison; we forbid crossing voices; and we forbid
hidden 5th and octave in the outer voices, when soprano
is not progressing stepWise. TB

Solutions are penalised for note doubling and


omission. in the primary major and minor triads: doub-
ling of the root (tonic) is preferred, while doubling of
the 3rd is penalised; doubling of the 3rd is forbidden Fig. 2. Harmonisation of th~ First Line of Joy to the World
in a dominant chord; if it is necessary to omit a voice,
232

Some experimentation was carried out with vari- Fitness profile from GA (Epiphany)

ous GA parameter settings, as shown in Figure 1; the


penalties given here are all-or-nothing penalties, except
100
..i. ..' ..... .
where two numbers are given, in which case either value
may be applied as appropriate. As expected, the weights 80

of the various penalties applied in the fitness function '"


::I
iii 60
....
.,'

have a significant effect on the solution. Other para- >

.."
>-
'ii
meters, such as crossover rate, mutation rate, and dif- D-
ferent selection schemes appear to affect the time taken
for the population to converge, and do little for the solu-
O
tion quality. This is due to the fact that it is the fitness 0
15
function which primarily defines the knowledge in the
system pertaining to what does or does not constitute a
good piece of music, while the other parameters define Generation 0 to 250 40 0
Position in a Chromosome
the search strategy.
Table 1. Probabilities and penalties used in the Fig. 3. A Typical Fitness Profile Landscape
experiments

Population: 30-200 penalties at the beginning is quite random. After a few


Migration interval: 20 generations generations, it starts to shape to a certain pattern. How-
Operator Probabilities ever, the GA could not reduce all the penalties in the fit-
P(Splice): 0.3 ness function even with enlarged populations and when
P(Perturb): 0.1 run for large amounts of time. In an attempt to solve
P(Swap): 0.2
this problem, an experiment with an island model [7]
P(Rechord): 0.3
with four population groups was carried out, to determ-
P(PhraseStart): 0.05
P(PhraseEnd): 0.05
ine whether different groups might be able to preserve
Fitness Penalties their own salient cultures, and so bring the GA to a more
Invalid Pitch: 1 globally acceptable solution. However, though the ex-
Invalid Chord: 10,1 periment showed an improvement in search efficiency,
Invalid Range: 10 the GA still could not reduce all of the penalties at once,
Invalid Interval: 10 and the general shape of the unacceptable contour above
Invalid Doubling: 10 was maintained. The musical output associated with that
Voice Crossing: 10 final contour is shown in Figure 4.
Hidden Unison: 10
Why, then, do these problems arise? They arise
Single voice progression: 10
Dual voice progression:
because the structure of a harmonisation of this kind is
10
Harmonic progression: 10,1 very specific, in that individual variations in chord are
Harmonic Analysis: 100,20 very strongly context dependent. Therefore, it is often
the case that one cannot change any given chord without
changing the chords around it. In terms of the GA, this
What is most significant - and problematic - is means that reduction of a fitness penalty in one position
that, with the current evaluation functions and reproduc- is likely to increase penalties in other positions, because
tion operators, the GA still cannot satisfy all the con- the movement from one chord to the next is not con-
straints within 300 generations. Figure 3 illustrates a sidered with respect to overall movement in the phrase.
typical fitness profile of the best solution in each gen- Human composers solve this problem by structuring the
eration. The data is from the first phrase of the hymn "0 construction process itself in an explicit way and design-
come, all ye faithful". which is twenty four notes long. ing an overall harmonic framework, and then filling in
The figure shows the distribution of penalties along the the most crucial parts first - in short, a least commitment
chromosome - in other words, the score of each har- strategy is taken. This kind of structured reasoning is not
monic movement or chord in the piece - as the gener- a feature of a simple GA of the kind used here, and so
ations proceed. The higher the contour, the less accept- the results are sub-optimal.
able the chord at that point. To restate this argument in terms of the search
In the figure, we can see that the distribution of space: we believe that the problem is due to a mul-
233

inclusion of well-established musical laws and con-


SA straints within the search seems to yield a fairly light-
weight but effective level of search control.
In summary, therefore, we conclude that while
GAs can be surprisingly good at small, constrained mu-
TB sical tasks, their performance, at least in this context of
simulating human musical behaviour, is currently lim-
ited by two issues.
Ib I Ib iic I Ie V Ie IVb Ie Vb Ib

1. GAs are a stochastic, heuristic search method, so


one cannot be sure that an optimal solution will be
reached, even if there is one. In particular, in a prob-
lem of this kind, they tend to get stuck in local op-
tima in the search space.

2. GAs of the form used here lack structure in their


vic iii IVb Vc vic Va Ie Vc ii V reasoning. On the other hand, composers have de-
veloped complex and subtle methods over several
Fig. 4. A GA Harmonisation of "0 Come, All Ye Faithful"
centuries involving different techniques for solv-
ing the problems highlighted here. No musician
would seriously suggest that an author of hymn
timodal fitness landscape, characterised by many local tunes works in the same way as our GA. Therefore,
optima in basins of attraction which separated by very while we may be able to produce (near) acceptable
high barriers, due to the interactions described above. results with a GA, doing so says little about the
Before the GA can move from one basin of attraction working of the compositional mind.
to another, multiple factors leading to a fitness penalty
need to be changed. Such a simultaneous change is very Other approaches to using GAs for this kind of
unlikely to occur. task may be more successful. For example, one might
There are various solutions which might be ap- take the approach of optimising a set of instructions to
plied to solve this problem in a GA context. Niching plan a harmonisation, rather than actually operating on
[6] might be expected to help with the problems of mul- the musical score directly; this approach is similar to the
timodality, and we expect to look at this in future. Link- indirect representational approach used by Burke [2] and
age learning [8] is unlikely to help as the spatial arrange- others for timetabling and scheduling problems.
ment of the genes in our chromosome is already optim- Genetic programming approaches may also be
ised, and so changing it is unlikely to help the search. fruitful, but we suggest that in order to produce music
Further, the nature of the epistatic interactions is well which is coherent within any accepted musical system
understood, and therefore this knowledge can be better (e.g., the tonal system used in the vast majority of rock
utilised directly, rather than by having the GA learn it. and pop music), there will need to be some encoding
of musical practice in the GP operators. An example
of a GP music system which suffers from lack of such
6 Conclusions knowledge is the GP-music program of Johanson and
Poli [12].
It is quite clear from the experiments here and elsewhere An alternative solution in the context of our GA
that GAs can be applied successfully in the musical do- would be to introduce even more knowledge-rich muta-
main - up to a point. Looking at the output of our sys- tions, which would possess knowledge about the en-
tems from an aesthetic viewpoint, the results are still far tire harmonic structure of each candidate solution, and
from ideal: the harmonisation produced by the GA has thus would be able to leap directly across the barriers in
neither clear plan nor intention. This is not a surprise the fitness landscape described earlier in a single bound.
as the discussion above suggested that we cannot expect However, it would be hard indeed to make a clear differ-
large scale structure to arise from the kind of program- entiation between this approach and a conventional KBS,
ming inherent in a GA containing (even in this experi- if indeed one could apply such a rule without being un-
ment) relatively little domain knowledge. acceptably ad hoc.
However, we would claim that they are surpris- We conclude, therefore, that neighbourhood
ingly successful musically, within this limitation. The search methods such as GAs are fundamentally limited
234

in the musical harmonisation domain by the non-local and B Manderick, editors, Parallel Problem Solv-
nature of the harmonisation problem itself. This said, ing from Nature 2, pages 553-42, Amsterdam,
at least intuitively, GAs seem to offer an interesting ap- 1992. Elsevier Science.
proach to the study of creativity. It would appear that,
if GAs are to both improve in musical performance, and [8] G. R. Harik and D. E. Goldberg. Learning linkage.
allow us to gain insights into the compositional mind, In Foundations of Genetic Algorithms IV, pages
dealing with the issues raised here is an urgent task. We 270-85. San Mateo: Morgan Kaufmann, 1996.
end with a suggestion that it is likely that much can be [9] A. Horner and L. Ayers. Harmonisation of musical
gained in this particular problem by somehow combin- progression with genetic algorithms. In ICMC Pro-
ing a GA with a conventional rule-based system. ceedings 1995, pages 483-484. The Computer Mu-
sic Association, 1995.

Acknowledgements [10] A. Horner and D. E. Goldberg. Genetic algorithms


and computer-assisted music composition. Tech-
Thanks to Dr. John Kitchen for his help in assessing the nical report, University of Illinois, December 1991.
harmonisation system. Andrew Tuson is supported by
EPSRC studentship, reference number 95306458. [11] B. L. Jacob. Composing with genetic algorithms.
Technical report, University of Michigan, Septem-
ber 1995.
References [12] B. Johanson and R. Polio Gp-music: An interactive
genetic programming system for music generation
[1] J. A. Biles. GenJam: A genetic algorithm for gen-
with automated fitness raters. In Proceedings of the
eratingjazz solos. In ICMC Proceedings 1994. The
3rd International Conference on Genetic Program-
Computer Music Association, 1994.
ming, GP'98. MIT Press, 1998.
[2] E. Burke, D. Elliman, and R. Weare. The Auto-
[13] R. A. McIntyre. Bach in a box: The evolution
mated Timetabling of University Exams using a
of four-part baroque harmony using a genetic al-
Hybrid Genetic Algorithm. In The AISB Workshop
gorithm. In First IEEE Conference on Evolutionary
on Evolutionary Computing, 1995.
Computation, pages 852-857. 1994.
[3] A. R. Burton and T. Vladimirova. Ap- [14] L. Spector and A. Alpern. Criticism, culture, and
plications of genetic techniques to musical the automatic generation of artworks. In Proceed-
composition, 1997. Available by WWW at ings of the 12th National Conference on Artificial
http://www.ee.surrey.ac.uk/Personal/ Intelligence, 1994.
A.Burton/work.html.
[15] E. Taylor. The AB Guide to Music Theory. The
[4] A. R. Burton and T. Vladimirova. A genetic al- Associated Board of the Royal Schools of Music,
gorithm for utilising neural network fitness eval- London, 1996.
uation for musical composition. In Proceedings
of the 1997 International Conference on Artificial [16] G. A. Wiggins, M. Harris, and A. Smaill. Rep-
Neural Networks and Genetic Algorithms, pages resenting music for analysis and composition. In
220-224,1997. M. Balaban, K. Ebcioglu, O. Laske, C. Lischka,
and L. Sorisio, editors, Proceedings of the 2nd
[5] L. Davis, editor. Handbook of Genetic Algorithms. IJCAI AI/Music Workshop, pages 63-71, Detroit,
New York: Van Nostrand Reinhold, 1991. Michigan, 1989. Also from Edinburgh as DAI Re-
search Paper No. 504.
[6] David E. Goldberg and Jon Richardson. Genetic al-
gorithms with sharing for multimodal function op-
timization. In Proceedings of the Second Interna-
tional Conference on Genetic Algorithms and Their
Applications, pages 41-49. San Mateo: Morgan
Kaufmann, 1987.

[7] V.S. Gordon, D. Whitley, and A. Bohn. Dataflow


parallelism in genetic algorithms. In R. Manner

S-ar putea să vă placă și