Sequencing & Clock
Euclidean
Euclidean rhythm generator — distribute K hits across N steps as evenly as possible. The math behind tresillo, cinquillo, and most of world music.
Try one in your browser →
What is a Euclidean?
A Euclidean rhythm generator answers a deceptively deep question: given K hits to place across N steps, how do you space them as evenly as possible? The mathematical answer turns out to also be the rhythmic backbone of most of the world's traditional music. E(3,8) produces [x . . x . . x .] — the tresillo, the foundation of Cuban son, hip-hop, reggaeton. E(5,8) gives [x . x x . x x .] — the cinquillo. E(7,12) is a West African bell pattern. E(2,5) is a Persian khafif-e ramal. The generator is, essentially, a knob that scrolls through traditional rhythms.
The algorithm is Bjorklund's algorithm, named for Eric Bjorklund who first applied it in 2003 to schedule the firing of pulses in a spallation neutron source at Los Alamos. Two years later, computational geometer Godfried Toussaint published "The Euclidean Algorithm Generates Traditional Musical Rhythms" and showed that Bjorklund's procedure was structurally identical to Euclid's algorithm for finding the greatest common divisor — and that its output reproduced rhythms documented across dozens of musical traditions. The same recursive even-distribution that times neutron pulses produces a clave.
Mechanically the algorithm is simple: lay out N empty slots, then distribute K hits into them by recursively taking the remainder. A practical equivalent is the Bresenham line-drawing algorithm from computer graphics — for each step, accumulate K, and when the accumulator exceeds N, place a hit and subtract N. Either way, the output is a binary pattern of length N with exactly K ones, spaced as uniformly as integer math allows.
On top of the basic E(K, N) pattern, Euclidean modules typically add rotation (cyclically shift the pattern's start point — same hits, different downbeat — which generates the family of "necklace-equivalent" rhythms Toussaint catalogues), and accent outputs that fire on the first hit of each evenly-spaced group, producing a secondary ghost-note layer.
Our Euclidean
Our Euclidean is 10 HP with three independent channels sharing a single clock. Each channel has Steps (1-32), Hits (0-steps), and Rotation (0-steps-1). Three channels means three layered rhythms from one clock — the standard recipe for drum-machine-in-a-rack.
We use a Bresenham-style distribution that is mathematically equivalent to Bjorklund's recursive algorithm but cheaper to compute on the audio thread — for each step, accumulate hits, and emit a gate when the accumulator overflows steps. Pure integer arithmetic, regenerated only when the parameters change, so the per-sample work is just a table lookup.
Each channel exposes both a gate output and an accent output (the accent fires on the first hit of each evenly-spaced group). CV inputs for hits per channel let you modulate density on the fly — patch an LFO into H1 to slowly evolve channel 1's pattern. The reset input syncs all three channels back to step 1 in lockstep with whatever is driving the main clock.
In a patch
The canonical use is rhythmic. Patch a clock into CLK and the channel gates into ADSR envelopes that drive drum voices: bass drum on E(3,8), snare on E(5,16), hi-hat on E(11,16). Three Euclidean channels feeding three drum voices is one of the fastest ways to a working drum machine ever invented in a modular.
Euclidean gates also work brilliantly as melodic triggers. Patch the gate output to an envelope, the envelope to a VCA, and a separate step sequencer (or random CV through a quantizer) to a VCO for pitch. The Euclidean rhythm shapes when notes happen; the sequencer shapes which notes. The two are independent, which means you can change the rhythm without touching the melody and vice versa.
For more random rhythmic textures rather than mathematically-derived ones, reach for MI-Marbles. For ratio-based rather than pattern-based timing, use a clock divider. Euclidean sits in a third category: mathematically-grounded ethnomusicology.
Inputs
- CLK (gate) — Clock input. Each rising edge advances all three channels by one step.
- RST (gate) — Reset input. Returns all three channels to step 1 on a rising edge.
- H1 (cv) — CV modulation for Channel 1 hits. Adds to the Hits knob value.
- H2 (cv) — CV modulation for Channel 2 hits.
- H3 (cv) — CV modulation for Channel 3 hits.
Inspired by
Three-channel Euclidean rhythm generator. The algorithm comes from Godfried Toussaint's 2005 paper showing that Euclid's GCD procedure (the same algorithm Bjorklund 2003 used to time spallation neutron pulses) produces the bell patterns of West African, Cuban, Brazilian, and Balkan music. Per-channel accent outputs and rotation are the contemporary additions.
- Mutable Instruments Grids
- Vermona Random Rhythm
- Toussaint 2005 — The Euclidean Algorithm Generates Traditional Musical Rhythms
← Back to all modules