Algebraic Operations on Melodies

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.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


"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 .
[1] Wikipedia. "Transformational Theory." (Jul 30, 2015)
[2] Wikipedia. "Pitch Space." (Jul 30, 2015)
[3] Wikipedia. "Pitch Class." (Jul 30, 2015)
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.