# The Rise of the Machines - Algorithmic and Stochastic Composition



## soundandfury

*Stochastic Composition*
The idea of a mechanical, chance-driven process to produce music is not a new one; _Musikalisches Würfelspielen_, systems for concatenating musical fragments according to the rolls of a die, predate the electronic computer by at least two centuries. However, these early systems were very stereotyped, since the only algorithmic part was the ordering of the fragments.
The computational power required to generate truly algorithmic music only began to become available with the advent of the electronic computer in the middle of the 20th century; the possibilities thereby afforded were soon seized upon by that century's avant-garde art musicians, desperately seeking novelty (which can be argued to characterise a large part of 20th century art composition) - musicians such as Iannis Xenakis, whose _Metastaesis_ evokes an eerie landscape sculpted by 'spectralism'.
With further improvements to available hardware, it became possible to apply AI techniques to composition, a path followed by eg. David Cope.

*Polyphon*
Recently, I've been experimenting with a fairly simple algorithm for producing polyphonic music: essentially, it rates each note in each instrument's range according to melody, harmony (with respect to the other notes that are playing concurrently) and key, uses the ratings to weight the probabilities of each note, and randomly selects a note according to those probabilities. Thus it proceeds forwards, writing all the lines simultaneously, occasionally triggering larger events such as modulation to a new key (which is implemented simply by changing the key against which notes are rated, and waiting for the music to drift into the new key).
This algorithm, which I have implemented as a piece of software called Polyphon (which outputs as a MIDI file), is surprisingly effective with struck or plucked instruments such as keyboards (piano, hpsd, etc.), harps, and guitars; it also works fairly well with most string instruments, and lower winds such as bassoons. However, its handling of higher winds (particularly trumpets and clarinets) leaves much to be desired; I think all that is needed is to change the rating coefficients to discourage dissonant intervals more strongly where these types of instruments are involved.
The other significant limitation of Polyphon is that its algorithm is purely local, which brings me onto my next section.

*Locality and Form*
When I say that Polyphon's algorithm is *local*, I mean that it only considers possibilities in relation to events which are happening at the same time; there is no way for it to provide a piece with 'shape' or 'structure'. For instance, most (short) classical pieces will be either U-shaped or hump-shaped; that is, either they will start with energy, go through a more tranquil episode, then finish forcefully, or they will start gently, build up to a climax, then die away. (Of course, longer pieces will involve more complex structures, and there are many variations on even the simple U and hump)
Polyphon, on the other hand, will typically produce a rather homogeneous piece, which starts with moderate energy, and continues at roughly that same level throughout. The current version doesn't even attempt to vary dynamics!
Of course, this is much less satisfying; although Polyphon's output can be pleasant to listen to, when it finishes it typically sounds _unfinished_. It leaves the music sounding _background-y_ (to the extent that that's a word).
A more technical way of describing it might be to say that the stochastic process driving the composition is essentially *stationary* - if you take a short enough window, one part of the output looks (or rather sounds) much like another.
The most frustrating thing about this is that, given a 'signal' controlling the 'level of energy' (or some similar parameter), it would be fairly easy to make that present in the output; mostly it would just come down to varying the coefficients in the various rating functions. However, the only way I can see to generate such a signal is to have a collection of stereotyped 'shapes', and pick one at random, scaled to the length of the piece; this would be at odds with my goal of creating truly algorithmic music.
So, do any of the plethora of musicians here have any ideas as to how to generate the 'shape' of a piece of music? If so, please post your suggestions in the comments below.


----------



## nosmelc

while using math to create music is interesting in itself, i personally find it to be irresponsible and morally objectionable. numbers, inhuman as they are, drive our economy and way of life. i prefer music and art to be tools with which we struggle to bring humanity back to life and keep it there.


----------



## algorithmic

Algorithms are simply a series of steps, so I'd say it's a bit of a stretch to say they're morally objectionable, even Mozart created some algorithmic compositions with his Musikalisches Würfelspiel and Guido D'Arrezo's method of assigning vowels to pitches can be described as algorithmic composition. Algorithmic composition isn't for everyone as it does take some time to get to grips with but it can produce interesting results that you wouldn't get otherwise. You can find some more algorithmic composition tutorials here.


----------



## Philip

of course if the harmonic progression doesn't follow any established musical form it will sound random.


----------

