Ch. 6 – Randomness and Choices

Topics:   Randomness and creativity, Mozart, indeterminism, serialism, Python random functions, stochastic music, Iannis Xenakis, probabilities, wind chimes, melody generator, selection, Python if statement, flipping a coin, Russian roulette, throwing dice, realistic drums, relational and logical operators, generative music.

Many composers have experimented with randomness (chance, or indeterminism) in their compositions, including Wolfgang Amadeus Mozart, John Cage, and Iannis Xenakis. Ultimately though it is the interplay of, or balance between, unpredictability and predictability that creates aesthetically pleasing artifacts (Arnheim, 1971).  If an artifact is too chaotic it may be difficult to comprehend and appreciate.  At the other extreme, if the artifact is too regular it may be uninteresting and boring.

Computers offer us a source of untamed possibilities in the form of a random number generator. This chapter focuses on ways to tame this source of possibilities to serve our aesthetic purposes.

Creating Mozart’s “Musikalisches Würfelspiel”

In 1787, Wolfgang Amadeus Mozart wrote “Musikalisches Würfelspiel”, a musical process involving randomness (by way of rolling dice) for generating a 16-measure waltz.  In this process, each measure is selected from a set of 11 precomposed chunks of music (the number of possible outcomes of throwing two dice). These selections are concatenated to generate the whole piece.

The sets of pre-composed measures were constructed so that any measure from one set could connect with any measure from the next set, and so on.  In one particular implementation of this musical “game”, there are 1116 = 45,949,729,863,572,161 different waltzes possible (Zbikowski 2005, p. 148).

This code sample (Ch. 6, p. 157) demonstrates how to implement a simplified version of Mozart’s musical game, as the comments indicate.


Creating Pierre Cage’s “Structures pour deux Chances”

An interesting way of applying randomness in music is in a style referred to as chance music. Chance music, also known as aleatoric music, is a compositional technique that introduces elements of randomness (or indeterminism) into the compositional process. John Cage, among other composers, is particularly well known for his indeterministic compositions.

On the other hand, serialism involves using deterministic rules to control choices within the compositional process. A common form of serialism is atonal music where every pitch in the chromatic scale has to be used before any pitch can be repeated.  This method of atonal music was developed in the early 20th century by Arnold Schoenberg.

Clearly, aleatoric and serial techniques are compositional opposites of each other. Surprisingly, thought, the musical outcome can appear to be very similar. This can be observed in these two pieces — the first aleatoric, the second serialist:

This code sample (Ch. 6, p. 161) capitalizes on this similarity to create a program where is impossible to determine, simply by listening to it, if the compositional approach was aleatoric or a serialist. This piece is attributed to Pierre Cage.  Pierre Cage is a fictitious composer (a remix of the names, Pierre Boulez and John Cage).


Creating Iannis Xenakis’ stochastic piece,“Concret PH”

Stochastic music is a compositional method employed by Iannis Xenakis, as a reaction to the abstractness and complexity of music from the Serialist movement.  Xenakis proposed that the mathematics of probability could be the basis of a more general and manageable compositional technique (Xenakis 1971).

“Concret PH” is a very influential piece of stochastic music. It was created by Xenakis to be played inside the Philips Pavilion in the 1958 World’s Fair in Brussels. This building was designed by architect Le Corbusier, who employed Xenakis as an architect and mathematician at the time.

The following program (Ch. 6, p. 167) demonstrates how to generate a stochastic piece of music.  In the original piece, Xenakis used spliced tape of sounds made by burning charcoal. Here, we mimic the sound using the MIDI instrument BREATHNOISE, which at short “bursts” (notes with short duration) sounds much like Xenakis’ original sound elements.


Harnessing (or sieving) randomness – wind chimes

As mentioned above, a way to generate artifacts that are aesthetically pleasing, starting with pure randomness, is to filter a random process through a sieve. For example, consider wind chimes. Wind chimes take the random displacements of air molecules in the atmosphere and map them into melodic sequences. In other words, wind chimes capture random movements of air and force them onto a narrow set of aesthetic possibilities. Typically limiting sounding options to tubes that are already tuned to a particular music scale, for instance.

The following program (Ch. 6, p. 169) demonstrates how to create wind chimes out of randomness. First, notice how we stretch the values generated by the random() function by multiplying with duration. Then, by using pitches that sound harmonious together, we make sure that generated notes will sound good together. This is the idea behind sieving randomness – forcing it through some ordered process or set of rules or fixed, interesting (non-chaotic) choices. This is similar to how randomness is used in, say, video games to control an automated character’s movements or actions (the choices are fixed and meaningful – which is choice is made is left to chance).