Algebraic Operations on Melodies

Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

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.

Contributed by: Justin Lubin (July 2015)
(Mathematica Summer Camp 2015)
Open content licensed under CC BY-NC-SA



"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)

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.