Saturday, September 19, 2015

Fractal Music

Algorithmic methods for musical composition encompass a vast realm. The general pattern is that a person writes a computer program. When the program is executed, its output is a musical score. Such a program might be designed to generate scores that strongly resemble existing works by a particular composer, for example, or works of some specific musical genre. At the other extreme, the goal might be to create compositions quite unlike any previously existing music, compositions that even test the limits of what might be recognized as music, but preserving enough characteristics of conventional music to avoid violating those limits utterly.

Microtonality represents another vast realm. Microtonality can be used to give fresh expression to conventional musical compositions and structures. Microtonality also opens up musical spaces that push so far beyond conventionality as to degenerate into nonsense.

Algorithmic composition provides a tool for exploring microtonality in a way that avoids simply duplicating conventional tonal structures, while at the same time maintaining enough recognizable patterning so the result sounds at least a bit like music. The approach I have been exploring constructs a score from the very conventional musical intervals of octaves, fifths, and thirds. The rhythmic aspect is also generally built from simple conventional elements, but in the discussion here the rhythmic aspect is left at the most primitive level. What I want to focus on here is how the simple musical intervals are used to form combinations and sequences of pitches.

In the spring of 1977 I visited the University of Pennsylvania and heard a lecture by Richard Voss on the fractal structure of music. At that time he was calling it a 1/f structure, but that is just one example of a fractal. The key idea is that fluctuations in pitch happen over many different time scales, none of which dominate. Around the same time I was studying phase transitions, such as the transition of a material from a liquid to a gas. Some of these transitions are also characterized by fluctuations at many different scales. So the central idea here is to use a simulation of a phase transition to generate fractal fluctuations, but in pitch rather than e.g. material density.

So how can a computer program simulate a phase transition? I first read about this in 1975 when I was reading Introduction to Phase Transitions and Critical Phenomena by H. Eugene Stanley. The book included some wonderful pictures of two dimension systems at the critical point and their fractal fluctuations, though again the term fractal was not used then. Ever since reading about this, I have been fascinated by how long range order can abruptly emerge out of short range interactions. What is also fascinating is that these phenomena also exhibit universality, which is to say the coarse level behavior is only weakly dependent on the low level details. In other words, a very simple computer program can simulate some very complex behavior!

The foundation of such a simulation is a multidimensional array or network of some type. When simulating a physical system, the array corresponds to space, so typically one would use a three dimensional array. The value contained in each element the array corresponds to the physical state of the material in the spatial region represented by that element. For composing a musical score, each element of the array corresponds to a particular time interval and voice within the composition. The value contained in the element will then be the pitch to be played by that voice at that time.

The multidimensionality of a musical score is not immediately obvious. But on second thought, the musical structure of theme and variation is almost universal. Music consists of phrases that are varied and repeated. The pitch to be played during one statement of a phrase is very closely related to the pitch to be played at a later statement of the phrase in the same position within the phrase.

Given such an array of elements, each of which consists of a pitch value, how should a computer algorithm simulate a phase transition with its fractal fluctuations? The core idea is to repeatedly pick a single array element, reassign its pitch value, then pick a different array element, reassign that pitch value, doing this again and again so that every array element gets many different values over the course of the program’s execution. Each array element has a small set of neighboring elements in the array. When assigning a new pitch value for a particular array element, the pitch values of the neighboring elements are examined. The pitch value is chosen so that it has some good harmonic relationship with the pitches of those neighboring array elements. Each time an array element is assigned a fresh pitch value, that new value can differ from the old value for two reasons: the pitch values for the neighboring array elements may have changed in the intervening time, so a different pitch value is needed to maintain a good harmonic relationship with the new neighboring pitches; and a weighted randomization method is used, where more closely related pitches are preferentially selected, but sometimes a pitch is assigned that is not the best possible.

Harmonic distances are given fixed numerical values which correspond to the energy contributions of microscopic interactions in a physical system. Just as the total energy of a macroscopic physical system, such as a cup of water, consists of the sum of all the microscopic energies from the interactions of the water molecules in the cup, the total energy of a musical score can be computed by adding up all the individual contributions from the harmonic relationships between pitches assigned to neighboring array elements.

The degree of bias toward close harmonic relationships is governed by a top level control variable that corresponds to the temperature of a physical system. When the temperature is high, there is little preference for selecting pitches with close harmonic relationships. As the temperature is lowered, the degree of preference is gradually increased. What is quite remarkable about the behavior of such a simulation is that an abrupt drop in the total system energy arises, despite the gradual increase in preference for individual lower energy relationships.

This abrupt drop in energy corresponds to a phase transition and the emergence of long range order. Musically, a tonal center spontaneously arises! As the temperature drops, the score changes from highly disordered to highly ordered. With luck, a sweet spot will emerge where there is enough disorder to make the composition interesting, but enough order so it still makes some sense. This transition from disorder to order can be illustrated by four scores.

The first score, prw691, was built at a temperature of 6.91. From the above energy graph, this is clearly below the transition point. To my ear, this music is too disorderly to make much sense of. But a histogram of pitch class occurrences shows that a tonal center is already becoming clear:

Of the 53 pitch classes in the microtonal system in use here, many do not occur at all, and just few are dominating.

The next score, prw542, is from temperature 5.42. The pitch class histogram now shows a clear tonal center:

I must confess, the tonal center being around the pitch class 0 makes me suspect that there is a bug somewhere in my code. A very slight consistent bias to any particular pitch class will strongly bias the emergence of the tonal center to land on the preferred pitch class. I am still trying to find out how my code is creating a bias. The fact that a clear phase transition emerges does seem to indicate, though, that this bias is not too strong. In any case, despite the tonal center's clear presence in the pitch class histogram, this score still sounds overly disordered to my ear.

The next score, prw392, sounds close to the sweet spot. Perhaps a slightly higher temperature than 3.92 would be a bit better. Still, this score sounds interesting to me, despite the highly dominant tonal center shown in the pitch class histogram:

The final score, prw246, from temperature 2.46, does sound too orderly to be interesting enough. The total number of array elements in this structure is 8748. Of these, prw246 has assigned 8221 to pitch class 0:

4 comments:

  1. OK, one more: http://soundclick.com/share.cfm?id=13215008

    ReplyDelete
  2. Progress on the 0 bias... I managed to tweak the program so now it has a 1 bias! The heart of the program is a weighted random selection. I think there is some kind of rounding problem where the first choice has a little bit extra probability than it should. Still not clear how, but at least I have a rope to pull on now.

    ReplyDelete
  3. Here is a variation: http://soundclick.com/share.cfm?id=13217433

    With these pieces, each voice is a square mesh network, where each element has four neighbors. Then each voice has one more neighbor, an element in a different voice. With the variation here, first the array is brought to a temperature of 4.4. Then the top voice is held fixed, and the other three voices are brought down to a temperature of 4.1. They're still interacting with that top voice, but the top voice doesn't change in response. Then the second voice is fixed, and the lower two voices are brought to a temperature of 3.8. Finally, with the top three voices fixed, the bottom voice alone is brought to a temperature of 3.5.

    ReplyDelete
  4. This idea is blossoming!
    https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0280227

    ReplyDelete