By the Numbers / Rhythm

Rhythm by the Numbers

When Roger Linn taught a drum machine to swing in the late 1970s, all he did was make every other 16th note wait a little, and that small piece of arithmetic is the idea behind this whole page: rhythm is arithmetic on time, the same way chords are arithmetic on pitch.

500 msOne beat at 120 BPM, about one step of a brisk walk
48 ticks/sMIDI clock at 120 BPM, twice the frame rate of film
≈ 6 msSmallest timing shift people notice in a fast run, the time sound takes to cross 2 m
≈ 30 HzWhere a pulse train becomes a note, just above the piano's lowest A (27.5 Hz)
16 steps, E(5,16)12 steps, E(7,12)7 steps, E(3,7)
Lines up again after lcm(16, 12, 7) = 336 steps

Part 1 · Tempo

Tempo is one division, and the rest is multiplication

Beethoven loved the metronome. Johann Maelzel patented it in 1815, and Beethoven went back and added tempo marks to the eight symphonies he'd already published. Orchestras have played them slower than marked ever since. In 2020 two researchers in Madrid measured 169 hours of recordings by 36 conductors and came up with a simple explanation. Beethoven may have read the scale at the wrong point on the sliding weight, which would add about 12 BPM to every mark.

The math he was fighting with is easy. A beat lasts 60,000 ÷ BPM milliseconds, so 120 BPM is 500 ms. That's about the pace you walk at, since people left to themselves settle into roughly two steps a second. Every other note value is a fraction of the beat: halve it for an 8th, add half again for a dotted note, take two thirds for a triplet. The table in the tool does them all.

Flip the division over and you get a frequency. 120 BPM is two beats a second, or 2 Hz, which is why a synced LFO, a synced delay and the drum pattern itself all use the same arithmetic. Synthesis by the Numbers covers LFOs from the oscillator side.

Machines need a finer ruler than the beat. Since 1983, MIDI has sent a timing tick 24 times per quarter note, so a 16th is 6 ticks. At 120 BPM that's 48 ticks a second, and here's the odd part: 48 clicks a second is fast enough to be a pitch. Feed MIDI clock to a speaker and you'd hear a low hum instead of a rhythm. Part 5 explains why.

Elektron's sequencers slice even finer. Micro timing moves a trig in steps of 1/384 of a whole note, which puts 24 steps inside every 16th. At 120 BPM each step is 5.2 ms, almost exactly the smallest timing shift a person can hear, so the grid sits right at the edge of perception. A user report for the Digitone puts the limit at −23/384, one step short of the next note; the manual doesn't say. User report

Tempo calculator and 24 PPQN metronome
500 msper beat
Click on top of the beat

Toy assumptions: clicks come from a 24-pulse-per-quarter counter scheduled ahead on the audio clock, the grid MIDI clock (timing byte 0xF8) uses. No MIDI is sent. Tap tempo averages your last four taps. Elektron figures assume a track scale of 1X. A ✕ marks a value that is not a whole number of clocks. The scheduler keeps about 120 ms of notes queued, so by Little's Law (Queues by the Numbers) roughly rate × 0.12 s notes are waiting at any moment.

Part 2 · Swing

Swing is a ratio, and microtiming is a nudge

Roger Linn was a 24-year-old guitarist when he announced the LM-1 in 1979, the first drum machine to use samples of real drums. He'd been playing with Leon Russell, who used the LM-1 on every track of his 1979 album Life and Love, and Russell taught him a feel he called shuffle. Linn built shuffle in on purpose. Quantization, the other feature the LM-1 became famous for, was an accident. Nine years later he gave the Akai MPC60 a swing setting measured in percentages, and those percentages became the language of hip-hop production.

Here's how the percentage works. Take a pair of 16ths. The first gets s percent of the 8th note and the second gets what's left. At 50% they're equal and the beat is straight. At 66.7% the first is twice as long as the second, which is triplet swing, and at 75% it's three times as long. So the second 16th of every pair moves late by

delay = (2s − 1) × one 16th

At 120 BPM a 16th is 125 ms, so a light 54% swing pushes the off-beats 10 ms late. That's tiny. Sound travels about 34 cm in a millisecond, so 10 ms is the delay you'd get from standing 3.4 m farther from the speaker. You'd never notice the distance, yet the swing changes how the beat feels.

How many swing settings a machine can offer depends on how finely its clock slices the beat, and the tool lists them for three common clocks. Linn has said he rarely needs finer steps than 48 pulses per quarter note allows.

Swing as a warp of time. Picture each 8th note as a rubber band with a mark in the middle. Swing slides the mark to the right: the first half stretches, the second compresses, and both ends stay pinned to the grid. Micro timing is different, because it moves one trig without touching anything else.

How small a nudge can you hear?

In 1995 Anders Friberg and Johan Sundberg asked 30 listeners to move one note in an even run until it sounded right. With fast notes, closer than about 240 ms apart, people could hear a shift of about 6 ms. With slower notes the threshold grew to about 2.5% of the gap.

Real music is more forgiving. In Butterfield's tests, listeners couldn't reliably spot deviations of up to 30 ms inside a groove. So a 54% swing at 120 BPM, just over the threshold for bare clicks, comes across as feel rather than as late notes. Part 7 picks this up with J Dilla, who built a whole style out of offsets like these.

Hi-hat loop with swing and per-step nudges
0.0 msoff-16ths late
Tapping a step will

Toy assumptions: swing delays every second 16th on lanes with swing turned on. Nudges are in Elektron steps of 1/384 of a whole note, capped here at ±23. Grey ticks show the straight grid, dots show where each hit sounds, and the line between them is the offset. The Digitakt manual gives swing as 51 to 80%, default 50%. Drums are synthesized: noise for hats and snare, a falling sine for the kick. The Dilla-ish preset illustrates Part 7's idea and transcribes no track.

Part 3 · Euclidean rhythms

Spread the hits evenly and the world's rhythms fall out

This one starts in a particle accelerator. Eric Bjorklund needed to space timing pulses as evenly as possible for the Spallation Neutron Source, so he wrote an algorithm to do it. In 2004 Godfried Toussaint, a computational geometer at McGill, noticed something strange. He published it in 2005. Ask Bjorklund's algorithm to put 3 pulses in 8 slots and you get the Cuban tresillo, the habanera bass line.

That's the whole idea: spread k hits over n steps as evenly as you can. Toussaint wrote it E(k,n). E(3,8) is x..x..x., with gaps of 3, 3 and 2. E(5,8) is the Cuban cinquillo, E(7,12) a West African bell pattern and E(5,16) the bossa nova, give or take where the bar starts. His paper names many more, and the tool knows them.

The circle is the chord clock from Chords by the Numbers with steps in place of semitones. A chord was a set of numbers mod 12. A rhythm is a set of numbers mod n.

Derivation: why it's Euclid's algorithm, and Bresenham's

Bjorklund starts with k groups [x] and n−k groups [.], then keeps tacking one leftover group onto each leading group until at most one is left over. The group counts follow Euclid's gcd on (k, n−k), done by repeated subtraction, and the tool prints each step.

You get the same pattern from Bresenham's line algorithm, the one that draws slanted lines on a pixel grid. Draw a line with slope k/n across n columns and put a hit wherever it climbs a row, so step i is a hit when (i·k) mod n < k. The error Bresenham carries along is Euclid's remainder. For every k ≤ n ≤ 32 the two give the same pattern up to rotation; the code behind this page checks it.

Rotation is a relabelling, not a new rhythm. Rotating by r sends step i to (i + r) mod n. As a matrix it's a permutation matrix: an identity matrix with its diagonal slid r places sideways. Think of a round table where everyone moves r seats clockwise. Nobody is added or removed and neighbours stay neighbours, so the gaps between hits don't change. Only the seat you call "step 1", the downbeat, moves. Steve Reich built a whole piece on this. In Clapping Music (1972) one performer repeats a 12-beat pattern while the other shifts it one eighth note at a time, through all twelve rotations, until they're clapping in unison again.
Euclidean circle
Pattern
Gaps
Known as
Bjorklund steps
Euclid on (k, n−k)
Bresenham

Toy assumptions: each step is a 16th at the chosen tempo. Hits play a rim click with a quiet hat on every step. Names come from Toussaint's paper, where many of these patterns are rotations ("necklaces") of the traditional one.

Part 4 · Polyrhythm and polymeter

Layered loops line up again at the least common multiple

Try this. Program a 16-step kick, a 12-step rim and a 7-step hat, press play, and wait for the first bar to come back. At 120 BPM you'll wait 42 seconds. The 7 shares no factor with 16 or 12, so the loops have to run 336 steps before they all land on step 1 together.

That's a polymeter. It's easy to mix up with a polyrhythm, so here's the difference:

  • Polyrhythm: one span split into different counts, like three even hits against two in the same bar. Everything meets at every barline.
  • Polymeter: one step length, different loop lengths, like the 16, 12 and 7 above. The loops drift apart and only meet at the least common multiple of their lengths.
Gears, not matrices. Two meshed gears with 16 and 12 teeth: mark the touching teeth and turn. The marks touch again after lcm(16, 12) = 48 teeth have passed, which is 3 turns of the big gear and 4 of the small one. Add a 7-tooth gear and nothing shares a factor with 7, so the wait jumps to 336. Coprime lengths give you the longest cycles.

Two loops that differ by a single step, say 16 and 15, slide apart and back together the way two slightly detuned oscillators beat against each other. Synthesis by the Numbers covers that beating in its detune section.

Elektron boxes do both. On the Digitakt, per-track scale mode gives each track its own length, and a master length decides how many steps play before everything restarts, so a 336-step polymeter only plays out if the master length lets it. Each track also gets one of seven speeds, from 1/8X to 2X. Put one track at 3/2X and another at 1X and you have a 3:2 polyrhythm. You can't get 5:4 from those speeds, though. For that you'd use track lengths.

Derivation: the common grid for a polyrhythm

To write a and b even hits on one grid you need a number of slots both divide, and the smallest is lcm(a, b). Three against two needs 6 slots: the triplet lands on 0, 2 and 4 and the pair on 0 and 3. Four against three needs 12. The tool builds this grid in polyrhythm mode and checks which ratios the seven Elektron speeds can make.

Three tracks, independent lengths
336steps to realign

Toy assumptions: in polymeter mode every track steps in 16ths, and each track's hits are spread with the Euclidean rule from Part 3. In polyrhythm mode each ring spreads its count evenly over one 4/4 bar. Outer ring is a kick, middle a rim click, inner a high blip. The Elektron line checks whether the seven speed settings (1/8X, 1/4X, 1/2X, 3/4X, 1X, 3/2X, 2X) can produce the ratio.

Part 5 · Rhythm becomes pitch

Play a polyrhythm fast enough and it turns into a chord

In 1957 Karlheinz Stockhausen published an essay called "...how time passes..." with a big claim: rhythm and pitch are the same thing at different speeds. Speed up a pulse and at some point you stop hearing beats and start hearing a note. He put the switch at about 16 pulses a second. His figure, via secondary sources Critics have called the essay's acoustics questionable, but the core idea holds up, and the tool lets you hear it.

Take a 3:2 polyrhythm, two click trains whose rates are in the ratio 3 to 2. A perfect fifth is two tones whose frequencies are in the ratio 3 to 2. Same ratio, different speed. At one cycle a second you hear three clicks against two. At 100 cycles a second the voices run at 300 and 200 Hz and you hear a fifth, 702 cents wide, which is 2 cents wider than a piano's fifth. That's the same gap Chords by the Numbers tabulates.

John Chowning hit the same boundary from the other side in 1967. He pushed vibrato up into the audio range, and it stopped sounding like a wobble and turned into tone color. That discovery became FM synthesis, which Synthesis by the Numbers takes apart.

So where exactly does rhythm turn into pitch? Research puts the change in three stages:

  • Below about 10 per second, it's a beat. Justin London puts the fastest usable beat at 100 ms between hits, and Bruno Repp found that's about where people can no longer tap along.
  • From about 10 to 30 per second, it's a flutter: too fast to count and not yet a note. Listeners hear the biggest change somewhere between 10 and 20.
  • Above about 30 per second, it's a note good enough to carry a melody. The lowest A on a piano is 27.5 Hz.

So "around 20 Hz" is a fair rule of thumb for where things start to change, but the fifth doesn't really sound like a fifth until both voices pass 30. Hit Sweep and listen for the moment the rhythm melts.

Rhythm to pitch
3 : 2
Faster voice
Slower voice
Interval

Toy assumptions: each voice is a band-limited click train (a sum of equal harmonics), lightly low-passed. The top strip always shows two cycles, so the picture stays the same while the time scale shrinks. Band edges at 10 and 30 Hz are approximate, taken from the studies cited.

Part 6 · Odd meters

Odd meters are built from 2s and 3s

In 1958 the Dave Brubeck Quartet was on a State Department tour when Brubeck heard street musicians in Turkey (he remembered it as Istanbul) playing in 9/8. They didn't count it as three groups of three. They counted 2+2+2+3, and a local musician told him the rhythm was to them what the blues was to Americans. Brubeck turned it into "Blue Rondo à la Turk", the opening track of Time Out in 1959.

That's how odd meters work. Nobody feels 7/8 as seven equal pulses; you feel short and long groups, 2s and 3s. 2+2+3 and 3+2+2 are the same length but feel different, because the long group lands in a different place. That's rotation again, and these groupings turn out to be Euclidean: 2+2+3 is E(3,7), 3+3+2 is the tresillo E(3,8), and Brubeck's 2+2+2+3 is E(4,9), the Turkish aksak.

How many ways can you split a bar into 2s and 3s? Seven pulses split 3 ways, but sixteen split 37 ways. The count follows c(n) = c(n−2) + c(n−3), because every split ends in either a 2 or a 3. The builder lists them for any bar you make.

Odd meters you've heard

  • 29/8Nine Inch Nails, "March of the Pigs": three bars of 7/8 then one of 8/8, so 7+7+7+8 (Billboard, via Wikipedia, and Mixdown).
  • 13/8Nine Inch Nails, "The Becoming" opens in 13/8; "Just Like You Imagined" moves into 10/4 when the drums come in (Mixdown; American Songwriter).
  • 7Soundgarden, "Spoonman": the main riff is in 7 (Stereogum). "The Day I Tried to Live" switches between 7/8 and 4/4.
  • 15/8Soundgarden, "Limo Wreck". On the same album "My Wave" switches between 5/4 and 4/4 and "Fell on Black Days" is in 6/4 (Guitar Player, via Wikipedia). Kim Thayil has said none of it was planned; the band only counted the meters after writing the songs.

No reliable source turned up for an odd-meter Depeche Mode or Kendrick Lamar track, so neither appears here. Song meters are as reported by those sources. How each bar is grouped inside isn't documented, so the builder doesn't guess.

Additive meter builder
7/82 + 2 + 3
Euclid link
Other splits

Toy assumptions: the pulse is an 8th note, given in pulses per minute. Bar starts get a kick, other group starts a rim click, the rest a closed hat. Groups up to 8 are allowed, so 7+7+7+8 works as four long groups.

Part 7 · Groove

Nobody fully knows what makes a groove

In Detroit in the 1990s, J Dilla made beats on an Akai MPC3000, the descendant of Linn's MPC60, and he often played them in by hand with quantization turned off. He'd set parts with different amounts of swing against each other, so the drums and the sample seem to disagree about where the beat is. Dan Charnas's 2022 book Dilla Time argues this wasn't sloppiness. It was a new kind of time, with straight and swung feels colliding at once.

Musicians had a theory for why this works long before anyone tested it. In 1987 the ethnomusicologist Charles Keil argued that music has to be a little "out of time" to pull people in, and he called the small gaps between players participatory discrepancies.

The lab hasn't been kind to that idea. In 2013 two separate studies, one by Matthew Davies and colleagues and one by Frühauf, Kopiez and Platz, found that adding microtiming made grooves rate worse, and quantized versions did at least as well. Kilchenmann and Senn (2015) found a small to moderate effect in the other direction, but only in experts: they moved a bit more when a performance's own timing quirks were scaled back by 60% than when it was fully quantized. In Senn's 2016 study, quantized and original performances rated the same, and exaggerated timing did worse.

Syncopation gives a clearer answer. Maria Witek and colleagues (2014) had 66 people rate 50 drum breaks. Medium syncopation got the most pleasure and the strongest urge to move, and with too little or too much, both dropped off. It's an inverted U, and it was strongest in people who dance.

You can even watch the brain lock on. Sylvie Nozaradan and colleagues (2011) recorded EEG while people listened to a steady beat and found a signal at the beat frequency. When listeners imagined a march or a waltz over the same sound, a second signal showed up at the imagined meter.

Groove lab: syncopation and timing
Pattern
Timing
0syncopation score

Toy assumptions: the score is a simplified Longuet-Higgins and Lee measure on kick plus snare. It adds up the cases where a hit on a weak 16th is followed by silence on a stronger one. Witek et al. used a modified version of the same family, with instrument weights, so the numbers are not comparable to theirs. The curve is a schematic of their finding, not their data. Random jitter is Gaussian with the given standard deviation, redrawn every bar. Systematic pushes offbeat hats and the snare late by fixed amounts.

Practice

Predict first, then check

Guess first, then check. Committing to a number before you see the answer is the quickest way to find out what stuck.

Tap the tresillo

How close to the beat can you tap? Write down a guess in milliseconds, hit Play, and tap the pad (or the space bar) on every kick of x..x..x.. After eight taps you'll see how you compare with the 6 ms shift people can hear in a fast run.

–mean absolute error
Press Play, then tap.

Toy assumptions: the tresillo is three hits on 8th notes in a 4/4 bar, with a quiet hat on every 8th. Each tap counts against the nearest hit if it lands within half an 8th. Output latency is removed using the browser's own audio timestamp, but touchscreens and Bluetooth audio add delays it cannot see, so treat the mean (early or late) as partly your device and the spread as mostly you.

When do three loops meet again?
–step lengths
Work it out on paper, type a number, then play until all three playheads are back on step 1.

Toy assumptions: three tracks of 16ths at 160 BPM, each with one hit on its first step, so the realignment is audible as a three-voice accent. Lengths are drawn at random from 3 to 16, keeping the cycle under 420 steps.

Quick ones

A dotted-8th delay at 90 BPM?

A beat is 60,000 ÷ 90 = 667 ms, an 8th is 333 ms, and dotted makes it 1.5 times as long: 500 ms.

MPC 58% swing at 100 BPM: how late are the off-16ths?

A 16th is 150 ms and 2 × 0.58 − 1 = 0.16, so 24 ms, the delay sound picks up crossing about 8 m.

Loops of 16 and 10 steps: when do they meet?

lcm(16, 10) = 80 steps, five bars of 16, because they share only the factor 2.

A 4:3 polyrhythm at 50 cycles a second: what do you hear?

Voices at 200 and 150 Hz, both above the 30 Hz pitch floor, so a perfect fourth (498 cents).

How many ways can 10 pulses split into 2s and 3s?

c(10) = c(8) + c(7) = 4 + 3 = 7, for example 2+2+3+3 and 3+3+2+2.

What changed

Two centuries of machines that keep time

The math of rhythm hasn't changed since Euclid. What changed is who does it. First it was a clockwork pendulum, then drum machines that quantize and swing for you, and now sequencers with a grid finer than you can hear. Meanwhile researchers went from arguing about what rhythm is to measuring what it does to people.

    Open questions

    What nobody can explain yet

    Is microtiming signal or noise?

    Lab studies keep finding that quantized grooves rate as well as human ones, yet producers spend hours nudging hits. Maybe the effect only shows up in experts. Maybe it depends on how busy the rhythm is (Senn et al., 2017). Or maybe it shows up in how people move, which ratings don't capture.

    Is a steady offset the same as feel?

    Random jitter is noise, but a fixed offset is a pattern you could learn to predict, so you'd expect it to read as feel. Senn et al. (2017) found the opposite in experts: a snare pushed by a fixed amount bothered them more than the drummer's own, looser timing. Try both in the groove lab at 10 to 15 ms and see what you think.

    Where is the syncopation sweet spot?

    The inverted U says there's a best amount, and that it depends on who's listening, since dancers showed it most. It probably moves with tempo and style too. Nobody can yet look at a new groove and predict where its peak will be.

    How does locking on turn into moving?

    EEG shows the brain locking to the beat and the meter, and low bass sounds make that locking stronger (Lenc et al., 2018). Nobody yet knows how that signal becomes the urge to nod your head.

    Further reading

    Four books worth your time

    Justin London, Hearing in Time (Oxford, 2004; second edition 2012). A music theorist explains meter as entrainment, the same habit that makes you fall into step with anything that repeats. It's where Part 5's speed limits come from, about 100 ms to about 2 s between beats, and the examples run from Bach to Brubeck to Ewe drumming.

    Godfried Toussaint, The Geometry of Musical Rhythm (CRC, 2013; second edition 2020). The long version of Part 3, by the geometer who spotted the Euclidean link. Necklaces, evenness, leap-year patterns and why the clave son works so well, with enough math for a programmer and enough music for a drummer.

    Dan Charnas, Dilla Time (2022). Half biography, half music theory. It follows J Dilla from Detroit to his death in 2006 and makes the case that his timing was a new idea, not sloppiness. If Part 7 made you curious, start here.

    Charles Keil and Steven Feld, Music Grooves (Chicago, 1994). Essays and conversations between two ethnomusicologists, including Keil's "participatory discrepancies" paper from Part 7. It's the theory the lab experiments set out to test, and a reminder that groove is as much about people as about milliseconds.

    Sources

    Last verified: 26 November 2026

    All tools are deliberately simple models running on Web Audio in your browser. Times assume the audio clock is accurate. Real hardware and MIDI connections add latency and jitter of their own, which none of these tools model.

    MusicChordsBluesJazz HarmonySynthesisMIDIVoiceSoftwareQueuesPostgresInfrastructureThe GridData CentersEarthHurricanesEarthquakesStartupsFounder Equity