# Euclidean Rhythm Generator (MIDI) > Spread k beats evenly over n steps for several drums at once and download the groove as a MIDI file. Builds Euclidean rhythms with Bjorklund’s algorithm — E(3,8), E(5,16), E(7,12) and any other pulses/steps pair — with rotation, for up to eight drum voices. Voices of different lengths run against each other as a polymeter. You get the patterns as text, their beat intervals, a Standard MIDI File on the General MIDI drum channel and a Tickwork project to keep editing. Part of usefulweb.app (https://usefulweb.app/). Part of [Tickwork](https://tickwork.usefulweb.app/) (ownerApp: tickwork). Results are deterministic calculations from the inputs and the listed assumptions; the API returns exactly what the web page shows. ## Use it - Human interface: https://tickworkeuclideanrhythm.usefulweb.app/ (interactive tool at https://tickworkeuclideanrhythm.usefulweb.app/tool) - JSON API: POST https://tickworkeuclideanrhythm.usefulweb.app/api/v1/calculate with a JSON object of inputs (schema: https://tickworkeuclideanrhythm.usefulweb.app/api/v1/tool) - OpenAPI: https://tickworkeuclideanrhythm.usefulweb.app/openapi.json - MCP (Streamable HTTP): https://tickworkeuclideanrhythm.usefulweb.app/mcp - tool `tickwork_euclidean_rhythm` ## Inputs - voices (textarea): Rhythm voices - One voice per line: pulses, steps, rotation (optional), sound (optional: kick, snare, clap, closed-hat, open-hat, low-tom, high-tom, rim or a MIDI key 0–127), velocity (optional). Example: 3, 8, 0, kick - tempo (number): Tempo - swing (number): Swing - 50 = straight; 54–62 = light to strong shuffle on the off-beat sixteenths. - bars (integer): Bars in the MIDI file ## Method - Bjorklund’s algorithm distributes k onsets over n steps as evenly as possible by repeatedly pairing the groups of onsets with the remainder groups, like Euclid’s algorithm for the greatest common divisor (Toussaint 2005). The first step is always a hit; rotation r shifts the pattern r steps later. - Each voice is one step lane of its own length on a sixteenth-note grid, so voices of 8, 12 and 16 steps drift against each other and line up again after their least common multiple. - The MIDI file (format 1, 480 ticks per quarter note) puts every voice on channel 10 with its General MIDI percussion key; swing delays every off-beat sixteenth to the given share of an eighth note (50 % = straight). Notes last half a sixteenth.