Tuesday, March 15, 2011

Euclidean Rhythm MIDI File Resource in Ableton Live

"There is geometry in the humming of the strings" - Pythagoras


The Euclidean Algorithm

In 2004, Godfried Toussaint wrote a paper titled "The Euclidean Algorithm Generates Traditional Musical Rhythms" that describes the Euclidean Algorithm in detail. In fact, his paper was the inspiration for this project. You can read it here.

Simply stated, the Euclidean Algorithm computes the greatest common divisor of two integers. In the paper, Toussaint employs this algorithm and describes a very specific process that evenly and precisely distributes some number of things (k) over any other number of things (n).

If we were to imagine (n) as equal time intervals... let's say 16th notes in a bar of music and (k) as pulses that we were interested in triggering as evenly as possible over those time intervals, then we can generate on/off patterns for any combination of pulses and time intervals using the algorithm. These patterns have the distinction of being (as Toussaint described) "Euclidean Rhythms”, in other words.... some number of pulses (k) evenly and precisely distributed over some number of time intervals (n).

What's amazing here is that these Euclidean Rhythms happen to be the exact patterns that many cultures have traditionally defined their music by. Imagine these isolated cultures, independent of each other, with no prior (conscience) knowledge of Euclid, picking up on and embracing 1 pattern from a special set of patterns defined by an algorithm 2300 years ago!

It's best understood by seeing and hearing it in action.

3 pulses (k) evenly distributed over 8 intervals (n) would look like:

[ x . . x . . x . ]

This is the Cuban Tresillo pattern and according to Toussaint it is one of the most popular patterns in the world. It’s found in hundreds of rockabilly and rock n roll hits like “Hound Dog” by Elvis Presley.


5 pulses (k) evenly distributed over 9 intervals (n) would look like:

[ x . x . x . x . x ]

This is an Arab rhythm called Agsag-Samai


3 pulses (k) evenly distributed over 7 intervals (n) would look like:

[ x . x . x . . ]

This is the Ruchenitza rhythm from Bulgarian folk-dance, also used in Pink Floyd’s “Money”


If we were to put these 3 clips together and change the samples a bit, it would sound like this:

(I added a "4-on-the-floor" 1 (k) over 4 (n) kick drum to glue it together)


Pretty neat, and that was just with 3 randomly selected clips. This works to a degree with all combinations of these special patterns.

The Session/MIDI File Collection

I've assembled an Ableton Live Session file that contains the Euclidean Rhythm prime ratios of 1 through 32 pulses (k) over 1 through 32 intervals (n) as discrete clips. If you use another host like ProTools, Cubase, Logic, Reason or FL Studio, I've also included a folder with the individual MIDI files, although I can't guarantee your host will be able to loop them without tweaks. We’re dealing with looping patterns so there’s no sense in including a clip for 4 pulses (k) over 8 intervals (n) if we already have 1 pulse (k) over 2 intervals (n). They would sound and interact with other clips the same way. In other words, I’ve taken all the clips and reduced them so no clip is just a repeating part of another clip.


Each track represents a value of (n), clips represent variance in (k) over (n)


Cool pattern after removing the repeats

The MIDI clips in the resource file can be dragged, dropped and swapped interchangeably within sets. Incredibly syncopated, off time, offbeat rhythms can be made by combining the clips in interesting ways. Try placing a clip in only bar 1 of a 4 bar pattern. The next time it comes around, it sounds purposeful. Try side-chaining the output of one clip with the output of another for instant syncopation. Try “borrowing” the rhythmic component of 2 or 3 of these clips by merging into 1 clip, then randomly forcing the spread into a scale for instant inspiration. You can change the feel of a clip by just moving the start marker.

There are applications beyond dance and experimental music as well. If you play a traditional instrument and have some knowledge of music theory, you can use the Euclidean rhythms as a sort of scaffolding, enabling you to build complex arrangements around a well grounded foundation. Friend of the site, Dave Dominey, was inspired by the project and shared this track.


That which makes tongues turn blue by SharksFin

When asked to comment on the process as it relates to Euclidean rhythms, Dave says:
9 (k) over 25 (n), which i broke into 11, 11 and 3. 
I just used the Euclidean rhythm as a framework then created variations on it. I was messing about with the longer lengths to try and get away from the counter-rhythms against a basic pulse that the shorter rhythmic blocks tend to lead to.
To make it easier to score I broke the 25/8 (time signature) into 3 packets of 11/8, 11/8, 3/8.
X . . X . X . . X . .
X . . X . X . . X . .
X . .
The whole string of 25 is repeated twice for each theme.
It has four modulations: D Dorian, Eb Lydian, G Mixolydian, C Ionian (which is a standard chord progression of 1, 5, 2, 5 ..or something like that :p)
The whole thing then modulates up a semitone. I tagged on another bar of 3/8 for the final chord.

Much like the Circle of Fifths Chord Resource, you can’t hit a bum note. All these patterns sound good together. Some patterns sound “better” in combination with certain other patterns so you’ll soon develop an instinct for what patterns work. Try sticking to (k)/(n) ratios that are close to or less than 1/2. These tend to interact very well.

I ended up making some MIDI utilities in the process of creating this collection using the excellent nAudio library and I'll post about them in the future. Specifically, I need to clean up and document a text to MIDI command line tool that should allow programmers of any language (or even spreadsheet/notepad++ gurus) to write MIDI files, so long as the language API provides text file I/O.

You’re free to do what you like with the source files. If you end up being inspired or releasing tracks, I’d like to hear about it here… or better yet, you can donate. If everyone who had downloaded the Circle of Fifths Chord Resource had also donated $1, it wouldn't have been much individually, but would have made a big difference in my life.

Download, unzip and enjoy!
TonysPulses.zip