Rhythm Necklace

Rhythm is geometry on a circle and number theory in disguise. Tap the beads, generate Euclidean rhythms, watch the center of gravity, and hear it. Euclidean = the Euclidean GCD algorithm applied to rhythm.

Tap a bead to toggle its onset. The polygon connects active onsets; the arrow from the center is the balance vector X[1].
Steps N (circle divisions)
Euclidean E(k, N) - Bjorklund
onsets k 5
Presets
Transport
tempo96 BPM
volume70%
Pattern
Inter-onset intervals
Distinct interval sizes
Rotational symmetry (cyclic group)
Maximally even = E(k,N)?
Well-formed / MOS
Perfect balance |X[1]| ≈ 0?
Center of gravity |X[1]|/k
DFT magnitudes |X[1 .. N-1]|   ■ = X[1] (balance)
k = 1k = N-1
The math under the beads (competition level)

Euclidean rhythm = Euclidean algorithm. Bjorklund's algorithm distributes k onsets as evenly as possible over N steps by the SAME subtract-and-recurse structure as gcd(k, N). E(3,8) = tresillo [x . . x . . x .], E(5,8) = cinquillo [x . x x . x x .], E(5,16) and E(7,16) are real Afro-Cuban and Balkan patterns.

Maximal evenness. A set of k onsets in N steps is maximally even when the onsets are spread as uniformly as the integer grid allows - intervals take at most two values differing by 1. The maximally even set is unique up to rotation and equals E(k,N). If N is a multiple of k it is perfectly regular.

DFT and balance. Treat the pattern as a 0/1 vector and take its Discrete Fourier Transform: X[m] = Σ e^{-2πi m p / N} over onset positions p. X[1] is exactly the sum of the onset unit vectors, i.e. their center of gravity. A rhythm is perfectly balanced (the XronoMorph idea) when X[1] = 0 - the beads balance on a pin at the center. Perfect balance is strictly more general than maximal evenness: every maximally even set is balanced, but sets like {0,1,2,6,7,8} in 12 are balanced yet not evenly spread. The other magnitudes |X[m]| reveal periodic sub-structure; a big spike at m means the pattern nearly repeats every N/m steps.

Well-formed / MOS. A pattern is a moment of symmetry when it has exactly two distinct step sizes and is generated by iterating one fixed interval (a generator), like the diatonic scale built by stacking fifths. The diatonic set {0,2,4,5,7,9,11} is both maximally even AND well-formed - generated by the perfect fifth (7 steps) or equivalently its complement the fourth (5 steps), which is the generator the readout reports.

Rotational symmetry. The rotations that map the pattern onto itself form a subgroup of the cyclic group Z/N. The whole-tone hexagon in 12 has symmetry order 6 - invariant under rotation by every 2 steps.

Native Web Audio, Canvas 2D, no libraries. Concepts after Toussaint's "Geometry of Musical Rhythm", Enkerli's Rhythm Pattern Explorer (CC0), and XronoMorph (Milne/Bulger/Sethares). Built for LIGHT HOPE Music Explorers.