E(k, n)
Distribute k beats across n steps. As evenly as possible. This simple constraint produces every traditional rhythm on earth.
Four channels. Four Euclidean patterns. Dial in the math.
beats (k) controls density. steps (n) controls resolution. offset rotates the pattern. Together: infinite rhythm.
Bjorklund. Euclidean. Bresenham.
In 2004, Godfried Toussaint noticed something. Every traditional rhythm from every culture could be described by one algorithm. Distribute k beats as evenly as possible across n steps.
It's the same algorithm Bresenham used to draw a line on a pixel grid in 1962. It's the same algorithm used in nuclear physics for neutron accelerators — the Bjorklund algorithm. It draws lines. It fires neutrons. It makes rhythm.
The math doesn't know what it's doing. It just distributes. And when it distributes beats, humans feel something inevitable. Something right.
function euclidean(k, n) {
const pattern = Array(n).fill(0);
let bucket = 0;
for (let i = 0; i < n; i++) {
bucket += k;
if (bucket >= n) {
bucket -= n;
pattern[i] = 1;
}
}
return pattern;
}
euclidean(3, 8)
// → [1,0,0,1,0,0,1,0]
// Tresillo. Cuban. Universal. Every continent. One algorithm.
These rhythms emerged independently across cultures separated by oceans. The math is the same because the math is the most efficient distribution. Evolution found it. Humans found it. Computers find it.
The most common rhythm in the world. Three beats, eight steps. The backbone of son, cumbia, tresillo. You have heard this ten thousand times.
The simplest asymmetry. Two against three. A waltz. A march. The heartbeat of children's songs on every continent.
Five beats, eight steps. Fills the tresillo. Together they make Cuban music. Separately they explain half of world rhythm.
Seven against twelve. Asymmetric but inevitable. When you hear it, you feel it before you count it.
Four in nine. Aksak means 'limping.' The rhythm actually limps. Mathematics explaining culture.
Five in sixteen. Stretched. Laid back. The DNA of bossa nova is just five evenly-spaced hits in a long measure.
Offset is everything.
E(3,8) = [1,0,0,1,0,0,1,0]. Rotate by 2: [0,1,0,0,1,0,0,1]. Same beats. Different feel. Different groove.
Cuban son and West African bell patterns are the same Euclidean rhythm, offset by two steps. A shift in time. A shift in culture.
The offset control in the machine above is not a gimmick. It's the difference between the downbeat hitting on one or on the and-of-two. Between a march and a shuffle. Between right and right.