Random sequences of numbers are called "noise" even though the sequences of note numbers we're talking about are at frequencies below the range of human hearing. Also, we'll still be talking about "power", which varies like the square of amplitude, even though these aren't sequences of voltages.
Brownian noise is white noise integrated. That is, each number in the sequence is a random number in a range centered on zero, added to the previous number. With brownian noise, the amplitude of each frequency is the inverse of the frequency, and since the power is the square of the amplitude, it's proportional to 1/f2.
Noise is "pink" when the power at each frequency is proportional to 1/f, which means the amplitude is like 1/sqrt(f). This isn't as easy to arrange as white or brown noise. Pink noise (or any other spectrum shape) can be made with inverse Fourier transforms, or with multi-stage filters applied to white noise, but Voss found an easy way to get pretty-good pink noise.
Alternatively, we can draw this as a binary tree of numbers:.
The best information I've seen on generating 1/f noise with computers is [4]
These hierarchically-combined, transposed phrases still have 1/f spectra (although more spikey), but sound more musical than plain 1/f melodies. Repetition and transposition give you themes and melodies, and the two together make it sound as if something's going on here, as if somebody's doing something on purpose. Pink melodies sometimes sound childish or pedantic, but always as if they're intended to be music even when they're really bad. Artificial intelligence programs often act alien, stiff or inscruitable; sometimes they make mistakes that no person would make, but I think consistent artificial childishness or human-like stupidity holds some kind of clue that's rare in AI.
It would be easy for the random structure choices to use some phrases a lot, and leave other phrases out altogether. I add the constraint that every phrase (or note) from one layer be used in the layer above. The diagram above follows this rule. The way the program enforces the rule is just to redo the whole set of structure choices for a layer until they satisfy the rule (I spent a lot of time sweating over inventing a smarter method before seeing this obvious way!)
This allows syncopation: the notes from the
lower level don't have to start on a boundary where a whole phrase was assembled,
but can be offset by some number of beats. The yellow blocks in the score below
show how the "Maple Leaf Rag" uses variations of the same phrase, once starting at
the second beat of a measure, then starting at the first beat:
The most natural method I've found so far is to let each note be a compromise between one sequence that goes up and down a chromatic scale, and another sequence that goes around the circle of fifths. I call the current incarnation of this method "PyraQuant5." There are more details about it below.
The second is a larger file that plays for a much shorter time:
PyraQuantTheme.mp3
It's a 45-second, 381k MP3 version of my favorite two pieces from the MIDI
file. They sound a bit like Vince Guaraldi's Charlie Brown music.
Everyone asks whether I've tried making the notes different lengths instead of just pounding eighth notes. I would like to. A phrase at any level of the hierarchy could be replaced by a single note, or a rest. But I haven't figured out how to combine longer notes and rests with syncopation and leading and trailing notes.
Meanwhile, an ancestor of PyraQuant called PYRAMUS7, produced long and short notes by what I think of as a cheat: it combined any string of eighth notes at the same pitch into a single longer note. PYRAMUS7 produces pyramid music on a diatonic scale, not using the circle-of-fifths method. Here are 17 minutes of PYRAMUS7 songs that I found interesting and collected years ago, now converted to MIDI: PYRAMUS7 HITS.
You might find PyraMus7HitsToTxt's 48 lines of BASIC easier to digest than the 2500 or so lines of C that go into PyraQuant (!) There is more about the program in the source tar file below.
The following is a slightly out-of-date description of how the main program works. See the README file in the source code directory for descriptions of the other source files involved.
I generate two streams of pyramid random numbers. The "linear number" goes up and down the chromatic scale, like a 1/f melody. The "circle number" goes around the circle of fifths. Generally it doesn't go more than half way around in either direction. So,
0 = A, 1 = E, 2 = B, 3 = Gb/F#, 4 = Db/C#, 5 = Ab/G#, 6 = Eb,
-1 = D, -2 = G, -3 = C, -4 = F, -5 = Bb, -6 = Eb again.
The generated numbers aren't necessarily rounded to ints (see below).
The note for the melody is a compromise between the "linear" and "circle"
numbers: for each of an octave of (exact) chromatic notes around the linear
number, it looks at the distance the note
is from the linear number, combined with the distance it is on the
circle of fifths from the circle number. The note with the
minimum combined distance is picked for the output melody.
The combining function has been Euclidian distance and Manhattan distance
(sum of the absolute values of the differences)
at various times. Right now it's Manhattan distance with varying weights.
The "pyramid" sequences are built out of phrases arranged in layers. The bottom layer of a 2(n-1)-note song is n independent random notes (one-note "phrases").
In the higher levels, each phrase is built by concatenating two adjacent phrases from the layer below, then transposing the resulting phrase up or down by a small random amount. Each phrase may also be inverted or time-reversed, and there are additional tweaks having to do with syncopation and with making sure that each phrase in a level is used at least once in the next.
Bottom layer: n phrases of 1 note each.
Second layer: n-1 phrases of 2 notes each.
Third layer: n-2 phrases of 4 notes each.
...
Top layer: one phrase of 2(n-1) notes--the song.
Some variations or improvements as the program developed:
mfiles.co.uk for the Scott Joplin excerpt.
[2] RF Voss, J Clarke (1978), "1/f noise in music: music from 1/f noise", Journal of Acoustical Society of America, 63(1):258-263.
[3] M. Gardner, Sci. Am. 238 (1978) 16.
[4] Robin Whittle, DSP generation of Pink (1/f) Noise,
http://www.firstpr.com.au/dsp/pink-noise/.
Up to my home page.
--Steve Witham