Rather than generating music completely randomly, this Demonstration starts with a simple melody and applies a set of random operations that transform the music into a very complex-sounding song. It is powered by a versatile musical API that can easily be expanded and used for algorithmic composition.
"tonality shifting" sets the semitones available to the shifting operation. If "Major" or "Minor" is selected, then the melody will only be shifted up and down on the tonic chord; "Atonal" sets no restrictions on the available semitones.
"maximum recursive depth" cuts off the randomization algorithm at a given depth to ensure that the algorithm does not run forever. A larger depth tends to result in longer songs.
"recursion complexity" represents the probability that the next iteration of the recursive algorithm will actually be executed. A larger probability tends to result in more complex songs.
Mathematically, the structure of music can be represented by different algebraic structures. The operation that creates a sequence forms a monoid over the set of all possible melodies, with note concatenation acting as monoid addition and the note with length zero representing the identity element.
In addition to the sequential monoid, parallel composition (chords) form a group over the set of all possible chords, with the layering of notes acting as group addition and the empty note as the identity. The inverse of each element in this group is its negative waveform.
Lastly, the set of pitch classes (C, C#, D, ...) is an Abelian group isomorphic to .