Risograph bead rings play world rhythms made by a neutron accelerator timing algorithm.
Each ring is E(k, n): k hits spread as evenly as possible over n steps by the Bjorklund algorithm, written in 2003 to space the gate pulses of the Spallation Neutron Source and later shown by Godfried Toussaint to regenerate traditional rhythms such as the tresillo E(3,8), the cinquillo E(5,8), the bossa nova E(5,16) and the West African bell E(7,12). The hits of each ring are joined into a halftone polygon, so an even rhythm is the most nearly regular polygon that fits on its grid, and rings with different step counts become polyrhythms around one shared bar. The side panel replays the algorithm for the selected ring: Euclid's remainder steps, folding the leftover rests into the hit groups until one remainder is left. Kick, conga, rim, agogo bell and shaker are synthesized live and queued on the Web Audio clock by a lookahead scheduler, and the hand reads its position back from that clock so sight and sound stay locked.
Try it. Click for sound. Tap a bead to add or remove a hit (the ring re-solves and keeps as much of its old pattern as it can), drag around a ring to rotate it, and use the panel or the keys (1 to 5 select a ring, up and down change k, [ and ] change n, left and right rotate, + and - change the tempo, space for the next preset, M mutes).
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build an interactive Euclidean rhythm machine with JavaScript, the HTML canvas element and the Web Audio API. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window. Paint it warm off-white.
- Write the Bjorklund algorithm: to spread k hits over n steps, start with k groups [1] and n - k groups [0], then repeatedly append one remainder group to each of the front groups until at most one remainder group is left, and flatten. E(3,8) should give 1 0 0 1 0 0 1 0, the Cuban tresillo.
- Draw three concentric rings, each with n beads around it: filled beads for hits, small hollow circles for rests. Join each ring's hits into a polygon.
- Sweep a single hand around all rings once per bar, and when it passes a hit, make that bead pop.
- Only after the first click, create an AudioContext and synthesize a kick (a sine wave sweeping quickly from about 150 Hz down to 45 Hz), a rim click and a shaker (short bursts of filtered noise). Every animation frame, queue each hit due in the next 100 ms at its exact time on audioContext.currentTime, and read the hand's position from that clock so picture and sound stay locked.
Once that works, make it beautiful:
- Give each ring its own ink color and draw with globalCompositeOperation = "multiply", so overlapping polygons mix like a two-color risograph print.
- Let me click a bead to add or remove a hit, drag around a ring to rotate it, and use the keyboard to change n.
- Label famous patterns such as E(5,16), the bossa nova.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as showing each step of the Bjorklund algorithm, swing and accents, or exporting the pattern as MIDI.