To: kfogel@red-bean.com, matt@braithwaite.net, jlodder@tezcat.com, jimb@red-bean.com cc: plexus23@aol.com, DanaSuss@aol.com Subject: Cool Program I wrote So I stayed up late and wrote this thing that came out of Martin Gardner's book "Fractal Music, Hypercards, and More". (Martin Gardner is the cool dude who writes the Mathematical Recreations column in the back of Scientific American.) The first chapter of his book discusses "scalable" noises, i.e. when graphed, they're self-similar at any zoom level. White noise is completely random, looks random on the graph, and has a spectral density of 1/(f^0), or 1. It's true randomness, where each number in the sequence has no relation to previous numbers. Brown noise (a.k.a. Brownian motion), on the other hand, has a spectral density of 1/(f^2). Each new number in a Brownian-walk sequence can be generated by randomly choosing to increment or decrement the previous number by a small random amount. Brownian motion is extremely correlated -- very boring to look at on the graph. It hardly moves, kinda like a blue-chip stock. Then there's the fractal walk, with a spectral density close to 1/f, although the exponent is fractional (not exactly equal to 1). This kind of random number sequence is a nice compromise between white and brown noise; it's self-similar and contains a moderate amount of historical knowledge (correlation) about itelf -- but not too much. There's still a bit of randomness in it. In any case, the famous Richard Voss did spectral analysis of pitches and durations and music, and found *all* music to approximate the 1/f frequency -- Beatles, classical music, eastern pentatonic scales, etc. His hypothesis is that our brains respond the best to this kind of fractal statistical property in a series of tones -- contributing to what makes music sound like "music" and not "noise". The article contained a simple algorithm to generate a random "fractal" walk of numbers; so I wrote a simple ANSI C program to do this. Theoretically, this sequence of numbers just needs to be converted into pitches on a keyboard. (You'll also need to generate a second fractal number-sequence to use as the durations for the notes). It should compile anywhere -- at most, you may need to link with the standard C math library (-lm). Give it a try. Anyway, here's the 1/f fractal-walk algorithm: 1. Choose N. Write out the numbers 0...N in binary as a decending list. (As if you were going to add them all up). Make sure each number is N columns wide. (i.e. if N=4, you'd write out 0000, 0001, 0010, etc.) 2. Roll N dice, output the sum. That's the first number in the sequence. 3. Examine the next number in the binary list, and note which place-columns experience a *change* in digit. (i.e. in moving from 0011 to 0100, all digits but the first experience a change.) 4. Re-roll only those dice which correspond to a changing column. (in the previous example, we'd re-roll the 2nd, 3rd, and 4th die, but not the 1st.) 5. Output the new dice sum, and repeat back to step 3 until you run out of binary list numbers. Here's a simple example for N=3: 000 001 010 011 100 101 110 111 Roll dice, output sum; re-roll 3rd die, output sum; re-roll 2nd & 3rd die, output sum; re-roll 3rd die, output sum; re-roll all dice, output sum; re-roll 3rd die, output sum; re-roll 2nd & 4d die, output sum; re-roll 3rd die, output sum.