Sunday, October 12, 2025

Emergent Order

I use a thermodynamic simulation in my algorithmic composition software. Randomized decisions are at the heart of this simulation. A piece of music might have ten thousand note events, a voice and a point in time at which a pitch is to be sounded. The pitch to be sounded at each note event is randomly chosen. Each possible pitch that could be played, selected from the options provided by the tuning system, is assigned a probability. A pitch that fits well into the musical context will be assigned a high probability; a pitch that would sound very out of place is assigned a low probability. The musical context is defined by the pitches that have been chosen at related note events:
  • vertical relationships: pitches sounding at the same time in other voices
  • horizontal relationships: pitches immediately before or after in the same voices
  • thematic relationships: pitches sounding at more distant times that are in the same corresponding place in a different expression of a musical phrase or motif or theme.
The choice of the pitch to sound at one note event depends on the pitches chosen to sound at other note events. There is a problem of circularity here! How can the first choices be made? Won't the result depend heavily on the order in which choices are made?

I use a variety of technniques for the initial choices, but the main way around the problem of circularity is that choices are made again and again. After initial pitches have been chosen for all ten thousand note events, those choices are revisited. Some single note event is randomly selected from among the ten thousand. The probabilities are computed for this note event, based on the pitches currently assigned to related note events. A fresh random pitch choice is made, using these probabilities, and the chosen pitch is assigned to this note event. This process is repeated again and again, many millions of times. So the pitch to be assigned to a single note event will be chosen again and again, thousands of times. Between each choice, though, the pitches assigned to the related note events will also have changed, so the probabilities will be different each time the pitch is chosen.

The calculation of the probabilities is based on a cost function. A low cost is assigned to pitches that fit well with pitches at related note events. A system temperature parameter is used in deriving probabilities from the costs. When possible pitches have cost differences that are small relative to the temperature, they will be assigned similar probabilities. When cost differences are large relative to the temperature, then the probabilities will be very different.

The overall process of pitch selection usually involves starting the system at a high temperature, assigning and reassigning pitches to note events again and again, then slowly lowering the temperature, again reassigning pitches many times at each temperature. The pitch choice made at one note event will affect the choices to be made at related note events, and then those choices will affect yet other choices, and this propagation of choices will let the whole system organize itself.

A total cost for the system can be computed, as simply the sum of the costs for all the note events in the system. At high temperatures, high cost pitches have a higher probability, so the total system cost will be high. As the temperature is lowered, the total system cost goes down. A curious feature of thermodynamic systems like this is that the decrease in cost with temperature is often not smooth. Phase transitions occur, where long range order arises and the system cost suddenly decreases. The graph above, with temperature on the horizontal axis and cost on the vertical axis, shows a sudden drop in cost around temperature 230.

A tonal center would be a typical kind of long range order in a musical system. Looking at a particular note event, if the pitches at the related note events are quite unrelated harmonically, then there will be no strong bias in the probabilities for assigning a new pitch at this event. But once the pitches at the related note events are all harmonically close to some tonal center, then there will be a strong bias to assign a harmonically related pitch at this event, too.

The slow decrease in system temperature allows long range order to emerge spontaneously. I took eighteen snapshots of the evolution of the system in a run of this software. The first snapshots are at a very high temperature, so the pitches are quite disordered. The last snapshots are at a very low temperature, after long range order has emerged and established itself. At these extremes of very little order or very strong order, the pieces are rather boring. The most musically interesting pieces are in the middle, at the boundary between order and disorder.

  1. temp=4983.67001252014; cost=10544386.267572;
  2. temp=3178.35877439225; cost=8365076.82243706;
  3. temp=1768.29608835035; cost=6691731.54375484;
  4. temp=907.870229277442; cost=5341434.10767405;
  5. temp=437.105167762909; cost=4254305.00978789;
  6. temp=253.151000149135; cost=3362954.84572504;
  7. temp=226.226281845489; cost=2575694.51859118;
  8. temp=213.857636486513; cost=1992138.33672853;
  9. temp=194.206977218147; cost=1593476.40311909;
  10. temp=168.06408964933; cost=1268744.01912949;
  11. temp=144.276865461673; cost=1010195.00479415;
  12. temp=119.940307483187; cost=804750.28245681;
  13. temp=103.794718800345; cost=639506.147892938;
  14. temp=88.3911327966952; cost=494414.291970105;
  15. temp=77.7312146561222; cost=382966.425501626;
  16. temp=69.4638522645718; cost=300979.198963986;
  17. temp=60.1130776123832; cost=239863.346055088
  18. temp=48.7834419649326; cost=190764.398975199
Even the final piece here has not settled into utter monotony. When a tuning system tempers out simple commas, the system can get stuck in some pattern of comma traversal. That seems to have happened here. The tuning system I used here is 34edo. Studying the scores a bit, I think a traversal of the diaschisma is what got caught.

No comments:

Post a Comment