euclidean rhythm

A rhythm maker: give it a number of beats to play and a number of steps to play them in, and it spreads the beats out as evenly as it can, which turns out to make many of the world's favourite rhythms.

The euclidean rhythm node, playing 5 beats in 16 steps

In the menu: sequencing, then clocks.

Inputs

Outputs

What it does

Imagine you're asked to clap 3 times during 8 even counts, as evenly spaced as you can. You can't space them perfectly, since 8 doesn't divide by 3, so the best you can do is to leave gaps of 3, 3 and 2: clap on counts 1, 4 and 7. Count it out loud, "ONE two three FOUR five six SE-ven eight", and you'll recognise it at once: it's the rhythm under countless songs, from Cuban son to rock and roll to modern pop, called the tresillo.


Listen: 3 beats in 8 steps, the tresillo, on claves (8 seconds)

That's all this node does: it spreads its pulses as evenly as it can over its steps. What's surprising is how musical the results are. Spreading 5 beats over 8 steps gives the Cuban cinquillo; 5 over 16 the bossa nova's clave; 7 over 12 the bell pattern at the heart of much West African music. Each comes out exactly, once it's turned to start in the right place. The circles below show each rhythm as a ring of steps going round, with the beats filled in, joined up into a shape. The steps between the beats are never more than one apart in size, which is what spreading them evenly means:

Four rhythms the node makes, as circles of steps with their beats filled in

Listen: 5 beats in 8 steps, turned 2: the cinquillo (8 seconds)

The node's graph shows its pattern as a row of bars: a tall bar is a beat, a short one a rest. Each time its clock ticks, it moves on a step; on a beat its trigger output ticks too, and on a rest its rest output does. Each tick lasts as long as the clock's.

Rotation

Rotation turns the pattern so it starts somewhere else, as if you started counting from a different point on the circle. The beats keep their spacing; only where the pattern starts changes. This can make a big difference to how a rhythm feels: 5 beats in 16 steps, as it comes, goes "x...x..x..x..x..", but turned 10 steps it's the bossa nova clave, "x..x..x...x..x..".

A whole groove

Several euclidean rhythms on one clock make a groove. This synth has a clock ticking sixteenth notes, and four euclidean rhythms of 16 steps each playing a drum: 4 beats for the bass drum, 5 turned 10 for the claves, 7 turned 2 for a conga, and 11 for the hi-hat. A trigger timeline in the middle shows all four as they play:

The groove synth: one clock, four euclidean rhythms, a trigger timeline, four drums and a mixer

Watch and listen: the groove playing, with the timeline scrolling (10 seconds, WebM video)



Listen: the groove alone (12 seconds)

Here's the same groove as a drum machine's grid, each row a drum, each column a step, with the beats lit:

The groove's four patterns, as a grid of 16 steps

When you might use it

The pattern starts from its first step when the synth starts. To keep a pattern lined up with the bar when it has a different number of steps, or after changing its steps, connect a trigger that ticks on each bar's first beat (a clock through a clock divider, for example) to its reset input.

For music nerds

In 2005, the computer scientist Godfried Toussaint showed that the rhythms you get by spreading k onsets as evenly as possible over n pulses, which he called Euclidean rhythms, E(k, n), include a remarkable number of traditional rhythms, timelines and clave patterns from all over the world. The name comes from the procedure: the even spreading can be done by Euclid's algorithm for the greatest common divisor, as E. Bjorklund had used it to space out timing pulses in a particle accelerator.

Some rhythms to dial in

Each of these is steps n and pulses k, then the rotation that turns it to its usual starting point. The gaps between onsets, in steps, are given in brackets.

Rhythmic character

Because the onsets are as evenly spread as possible, the result is always maximally even, and has at most two sizes of gap, which differ by one step. When k doesn't divide n, the uneven gaps give the rhythm a syncopated lilt; the closer k/n is to a simple fraction, the more the pattern sounds like a straight pulse with a hiccup. The rest output is the complement, n − k rests, and it's maximally even too, so a rhythm and its rests interlock: kick on the trigger, hi-hat on the rest, and you have a hocket.

Rotations change the feel without changing the gap sizes, by changing which onset falls on the downbeat. Of the 16 rotations of E(5, 16), only some sound like clave; others sound like a shuffle, a backbeat or a melody's phrasing. Try them all.

Polymeter and phasing

All the rhythms on one clock share the same tick, but needn't share a length. E(3, 7) against E(4, 16) realigns only every 112 steps, so the pair keeps generating new composite patterns, in the manner of a Steve Reich phase piece or a polymetric Balinese texture. To keep a long pattern from drifting off the bar, reset it from a clock divider at the bar or phrase.

Beyond percussion

The trigger can drive a note sequencer, so the sequencer's melody follows the euclidean rhythm, and its rest output can drive a second sequencer that fills in between. A euclidean rhythm can also gate an adsr on a pad for rhythmic chords, or drive a sample and hold for rhythmic random melodies.

For math nerds

The rule

Step i (counting from 0) of a rhythm with n steps, p pulses and rotation r is a pulse exactly when:

step i is a pulse ⇔ (((i + r) mod n) · p) mod n < p

The node keeps a step counter, advanced modulo n at each rising edge of the clock (and set so that the next edge is step 0 by a rising edge of reset); it computes no pattern in advance, so the settings can change at any time.

Why it's even

Adding p to a number mod n wraps around (carries) exactly when the result is less than p. So the rule says step i is a pulse when (i + r) p / n passes a whole number:

⇔ ⌊(i + r) p / n⌋ − ⌊(i + r − 1) p / n⌋ = 1

The pulses are where the line of slope p/n crosses the integers, the same digital straight line that Bresenham's algorithm draws: a staircase whose steps are as even as integer steps can be.

The pulses of E(5, 16): wherever the staircase under the line 5 i / 16 steps up

Solving for the crossings, with rotation 0 the onsets are at

pulses at i_m = ⌈m n / p⌉ − r (mod n), m = 0, 1, …, p − 1

and the gaps between them take only two values, n mod p of them long and the rest short:

i_(m+1) − i_m ∈ { ⌊n/p⌋, ⌈n/p⌉ }

This is the maximally even set of Clough and Douthett, and, read as a word in x and ., a Christoffel word: of all the ways of choosing p of n points on a circle, it spreads them most evenly (it maximises, for instance, the sum of the distances between them). Bjorklund's algorithm, which builds the same pattern by repeatedly distributing the remainder groups as Euclid's algorithm does for gcd(p, n − p), gives the same rhythm up to rotation, since a maximally even set is unique up to rotation.

Structure

Back to Sequencing: clocks
Node reference
Contents