Back to Silas S. Brown's home page
Back to Clara Empricost page

Algorithmic Composition and Reductionist Analysis: Can a Machine Compose?

This article appeared in CamNotes (the newsletter of the now-defunct Cambridge University New Music Society) in 1997.

What is it about music that makes it an art?  It has been said that any definite answer to this question would be paradoxical, since the answer would destroy the idea.  Many experiments have been carried out this century to attempt to unravel the enigma of why music (especially Western music) is what it is.  Scientists have studied electroencephalogram (EEG) traces formed while people listen to series of suspensions, or studied PET reactions when "wrong notes" are played.

PET (Positron Emission Tomography) tends to be more interesting, since, by measuring how blood is distributed throughout the brain, one can tell in some detail which parts of the brain are being used.  It turns out that listening to music generates a very similar pattern to merely imagining that one is listening to music.

If, though, it is possible to explain music in this level of detail, would it not be possible to create it automatically, simply by finding non-trivial solutions to massive equations?  (In case you're not mathematical, I mean finding something that fits a complicated set of rules, and not just looking for the simplest thing that fits those rules) If music can be created like this, then where would this leave human composers?  And would anyone ever listen to all the music that is generated?

The idea of automatic composition had been around for some time before this century.  The Aleatoric Waltz, commonly credited to Mozart (but no-one's really sure) [1], is perhaps the most famous example.  It consists of fragments of music that can be put together in a number of possible ways, to be determined at random.  A similar idea has appeared in home computer magazines from time to time (eg BBC Acorn User 1990).  The number of permutations may be very large indeed, but the fragments still have to be composed in the first place, and, with such a small number of them, the pieces produced can get somewhat boring after a while.

Do humans compose in a similar fashion, but with a much larger database of fragments?  After all, listening to much music is said to improve one's compositional skills.  If this were the case, though, then how did the "great composers" write those fragments in the first place?  While idioms, quotations, and so on, can be used from time to time, they cannot be fundamental.  New music which tries as hard as possible to "break free of everything" (i.e.  conventional harmonies, tonalities etc) can induce altered states of consciousness and be unique in its expression, but is nevertheless not the same experience as music that does not do this.  If the idea that humans compose by accessing a large database of musical fragments were fundamentally correct, then there should be very little difference between listening to Mozart and to Schoenberg.

Everyone who has taken an 'A' level in music has come across a harmony textbook.  These books are different in their approach, but they very often present a set of "rules" which must be followed in the exercises.  The rules are often the result of years of research by the musicologist who wrote the book, and could they be the key to algorithmic composition?

My own experiment took this approach.  I used an object-oriented programming language (C++) to represent chords, notes, intervals and so on, and produced a list of conditions for rejecting a composition as it was being built up, hence the name Clara Empricost (Condition List Action Rejection Algorithm for the Evaluation of Music at Pseudo-Random Idea Construction Stage).  The "randomness" of the selection was quite important, particularly if the possibilities that the listener would find interesting were not likely to be chosen by the program.  I experimented with different random number generators, and found that the ones that are known to be "better" produced what I thought to be better compositions, especially at the cadences, which had a habit of being monotonous.

Running in the background as a TSR distributed over a Novell network, and building each phrase recursively on a chord-by-chord basis (usually backtracking quite a bit when it needed a cadence and couldn't fit one in), it produced a "symphony" in about a week. The instruments were chosen at random, within a few restrictions (such as "Don't write for gun shots and space invaders").  The output was input to Manuscript Writer (the music program I'm developing) [3], from where it could be printed, converted to MIDI, or whatever.  I never finished encoding all of the music harmony textbooks that I had [2], so it is not as good as it could be, and also there were a few errors in the program that I did not have time to fix, leading to a few curious notes.  However, I was surprised at how well it did (I might borrow some of its ideas myself).  This is a compliment to those harmony textbooks, not to my programming.

I was not the first to do something like this.  A group of people in America had produced a product called "CPU Bach" [4], which writes pseudo-Bach chorales (without words), based on their analysis of the real thing.  Fortunately for them, Bach wrote enough chorales for their statistical methods to work.  The product is being sold commercially, although I'm not sure how big the market would be.

Cambridge company Sibelius Software [5] are in the process of taking this one step further - they are producing a program which, given 16 bars of music, will use analysis methods to generate another 16 bars in the same style, and they hope that this will be useful to real composers who are writing to a tight deadline!  In particular, composers of incidental music, at points where the music is relatively unimportant, could use this, as could composers for the music accompanying computer games (although a simple aleatoric segmentation algorithm will probably suffice for the latter, as has been done many times on the BBC Microcomputer).  When the product is complete, such composers should be able to generate the music in a few mouse-clicks, in the same way as they edit music normally.  At nearly 900 pounds, however, you would not be advised to buy this product out of mere curiosity.

An infinite number of monkeys on an infinite number of electric typewriters may be able to produce the works of Shakespeare an infinite number of times in an infinite number of places, but a wordprocessor's spelling and grammar checkers can't write a Charles Dickens novel for you.  If, though, music follows rules, and they are correctly stated, could all the "great" music be produced from the right random number seed - a whole more than the sum of its parts?  Is it simply that nobody has yet found what the rules actually are?

Heuristically programmed algorithms are another idea that has been pursued.  Heuristic programming is, in essence, where you find a method that works, but you may or may not have the faintest idea why it does. If you are doing this automatically, then you need a way of evaluating each method automatically as well, otherwise it will take a very long time and a lot of listening!

(NB Heuristic programming is not quite the same thing as heuristic algorithms; the latter involves a program that searches possibilities for an answer, whereas the former searches for a program itself, or even does not use a "program" in the conventional sense)

Two well-known examples of heuristic algorithms are genetic algorithms and neural networks.  Both of these are based on the simulation of what scientists understand from biology, and most experiments in both rely on an evaluator that "knows" what the outcome should be for a particular set of inputs, adjusts the workings of the system until it works for all of the test cases, and then tries it out on new inputs to see if it still works.  In the case of neural networks, each "neuron" is connected to its neighbours, is stimulated by a certain threshold of signal, and, once stimulated, produces (or maybe inhibits) a certain strength of signal, these two strengths being the variables that can be "fiddled with" during "training".

But what if there isn't any input?  If you have been reading New Scientist for the past year or so then you will have noticed a leading article some time ago on "noisy" neural networks.  A researcher trained a neural network to recognise makes of car from a photograph, and he decided to look inside the network at the individual neurons, rather than regarding it as a "black box" that somehow worked for some incomprehensible reason.  He found that certain areas of the network were specialising into recognising certain features of the car, and, by introducing a level of random "noise" into the network, got the network to design its own cars.  They were usually not very good, but, by connecting the network to another one, which evaluated the output, he could filter out good examples.

Among designing hard molecules and other things, the network was tried at composing music.  In this case, it was given some extracts of popular music, and produced 11,000 or so extracts in response.  They were sent off to the American authorities for copyrighting!

This raises another question: Who is going to listen to those 11,000 pieces of music, if only to check that they really are original?  Actually, in the latter case, programs do exist to check for similarity of melodies, which are used for research into folk songs [6].  But, given especially that the network was using a very small sample of the music out there, and that it was not a very big network, I doubt if its compositions would be incredibly inspiring.

I have always felt very uneasy about throwing any musical ideas away, as it would amount to destroying something that I think is unique.  But, if computer composition took over to a degree, would the 'preservation people' be content with the idea that the music exists, somewhere, within the set of possibilities?  May I delete Clara Empricost's symphony with impunity, once it has generated it?  Should I preserve the algorithm and the random number seeds somewhere?  An interesting set of problems.

For the foreseeable future, though, computers will not replace humans in the composition of music.  They may help with tasks that may be tedious to some human composers, such as "filling in" in film scores, continuing "jingles", or providing harmonisations.  However, as long as people enjoy writing music, as long as that urge to notate what is going through one's mind exists, or the experience of having one's own ideas played in concert, humanity will continue to compose music.

References

[1]: [these links no longer work] 204.96.11.210/jchuang/Music/Mozart/mozart.cgi (where you can try creating an Aleatoric Waltz online); www.design.nl/~zsofi/mozart/

[2]: "First Year Harmony", "Second Year Harmony", "Third Year Harmony" all by Lovelock, pub Hammond & Co 1945-1947

[3]: Manuscript Writer home page

[4]: [now a dead link] turboguide.com/cdprod1/cdhrec/004/516.shtml

[5]: http://www.sibelius-software.com/

[6]: "Beyond MIDI: The Handbook of Musical Codes" edited by Eleanor Selfridge-Field, MIT Press, 0-262-19394-9, p343-361


All material © Silas S. Brown unless otherwise stated.