Euclidean rhythms

Euclidean patterns app screenshot

Euclidean patterns

Last week I read a really interesting article about computer generated rhythms: “Generating African rhythms using the euclidean algorithm” on Ruin & Wesen’s website. Usually I’m not so impressed by generative and algorithmic music, but this formula gives some very cool results. The formula is simple really. It’s an algorithm to distribute an amount of notes as evenly as possible over a period of time, where time is divided in equal parts. A very basic example: Say you have one measure of sixteen sixteenth notes and there are four notes to be played, then this is how those four notes would be equally distributed by the algorithm: x . . . x . . . x . . . x . . . A basic house or techno kick drum pattern. There’s four notes on sixteen steps, so the division is easy, 16 / 4 = 4. It gives you one note every four steps. But it gets more interesting when the numbers don’t divide so easily. Take five hits on sixteen steps. Then the pattern becomes more irregular: x . . . x . . x . . x . . x . . It’s these irregular patterns that create the best rhythms. Especially when several patterns are combined. In Ruin & Wesen’s article there’s a few audio examples and here’s a video on of a MiniCommand MIDI controller generating Euclidean rhythms on a Machinedrum.

The algorithm

The algorithm is very well explained in the article I mentioned, so I won’t repeat it here. There’s another article on the weblog of Robin Price which includes a Max/MSP example, there’s a Pure Data example by Dave Poulter as well as one in Java by Kristopher Reese. Absolutely worth reading is the paper by Godfried Toussaint who as far as I know first recognized the connection between the Euclidean algorithm and musical rhythms. It’s downlaodable as a PDF: “The Euclidean Algorithm Generates Traditional Musical Rhythms”.

The Flash app

Get Adobe Flash player
Download the full source code here. This is a Flash app I made over the weekend to quickly try out combining rhythms. It’s by no means complete, but it does work:
  • To create a new pattern doubleclick somewhere in the lower panel. A basic sixteen step quarter note pattern appears where you clicked.
  • To edit the pattern doubleclick it’s center circle. A settings popup appears with sliders for pattern length and number of hits. Change these to quickly get a feel for how these Euclidean patterns work. The ‘Sound’ dropdown menu lets you select a different sample for the pattern to play.
  • Click and drag the center circle to move a pattern.
  • The controls at the top are obvious: Start / stop playback, adjust volume and change tempo (in beats per minute).
You will notice that when you create a new pattern while patterns are already playing, the new pattern is not synchronized. To synchronize all patterns stop and restart playback.
Euclid of Alexandria

Euclid of Alexandria

There’s a lot I should add to make this a complete app: An open and save option for pattern combinations and their settings, an option to load and use your own samples, basic sample editing like volume, speed and sample start adjustment and more pattern options. But the first thing I’d like to do is to add MIDI output. So I can use these patterns to drive music software like Ableton Live or hardware like my Machinedrum. It seems Java is the easiest way to write software that can use MIDI, so next I will be learning to program Java.