Beat Pattern Lab

Swing and Timing on a Drum Machine, With the Numbers

Swing on a drum machine is one number, usually between 50% and 75%. It moves every second note of a pair later, so the groove leans back. This guide shows exactly how far it moves them, how to pick a value, and how the drum machine keeps its timing steady in a browser.

What the percentage means

Take two 16th notes that make up one 8th note. Played straight, the second 16th starts halfway through the pair, at 50%. Swing moves it later: at 60% it starts 60% of the way through the pair. The first note of each pair never moves.

The delay in milliseconds is:

delay = (swing − 50%) × 2 × one 16th note, where one 16th note = 15,000 ÷ BPM ms.

Tempo16th note54%58%62%66%
90 BPM166.7 ms13.3 ms26.7 ms40.0 ms53.3 ms
100 BPM150.0 ms12.0 ms24.0 ms36.0 ms48.0 ms
120 BPM125.0 ms10.0 ms20.0 ms30.0 ms40.0 ms
140 BPM107.1 ms8.6 ms17.1 ms25.7 ms34.3 ms

The same swing percentage is a smaller delay at a faster tempo, which is why a groove can need a little more swing as you speed it up.

Swing on 16ths or on 8ths

With 16th swing, every second 16th moves: the "e" and the "a" of each beat. It affects busy hi-hats and ghost notes; a pattern with hats on 8th notes won't change at all, because nothing is on the moving steps.

With 8th swing, the pair is a whole beat and only the "&" moves. At 100 BPM an 8th note is 300 ms, so 8th swing at 66% delays every "&" by 0.16 × 600 ms = 96 ms. Use it for shuffles and for hip-hop hats written in 8ths. The Shuffle and Boom bap presets use 8th swing; Simple funk uses 16th swing at 54%.

Where triplets come in

A true triplet puts the second note two-thirds of the way through the pair: 66.7%. The machine's slider moves in whole percent, so 66% is the closest setting. At 100 BPM with 8th swing that's 4 ms early compared with a perfect triplet, too little to hear.

Choosing a value by ear

SwingWhat it does
50%Straight. Rock, most pop, four-on-the-floor dance music
52–56%Felt more than heard. Loosens ghost notes and 16th hats in funk and R&B
57–62%A clear lilt. House hats, much hip-hop, neo-soul
63–67%Shuffle and triplet feel. Blues shuffles, swing, half-time shuffles
Above 70%Exaggerated, almost dotted. Use sparingly

A good habit: set the swing by ear on the hats alone (mute the other rows), then bring the kick and snare back.

How the drum machine keeps time

A web page can't rely on timers for music. JavaScript timers fire late whenever the page is busy, by anything from a few milliseconds to a whole second in a background tab. If every drum hit waited for a timer, the beat would wobble.

So the machine does what most software instruments do. Every 25 ms a scheduler wakes up and looks ahead 120 ms. Any step that starts inside that window is handed to the browser's audio clock with an exact start time:

start time = loop start + step number × 16th length + swing delay

The timer's lateness only changes how early a note is scheduled, never when it plays. Each time is computed from the step number rather than by adding up step lengths, so errors can't accumulate over a long session, and each hit starts on a whole audio sample (within 0.01 ms of the exact time).

We checked this in Chromium, the engine behind Chrome. Over 60 seconds of playback at 110 BPM, all 441 steps were scheduled, none skipped or doubled, every one between 60 and 120 ms before it was due, and every scheduled time matched the formula above exactly. The same test with swing at 54% gave the same result.

We also measured the audio the browser actually rendered: a rim click on every 16th at 90 BPM with 58% swing, for 60 seconds, recorded from the output sample by sample. All 361 clicks were there, each one started 0.10 ms after its scheduled time (the same for every click, so it's the click's attack, not wobble), and the offset was identical in the first and last 10 seconds: no drift. The swung clicks landed 26.7 ms late, exactly as the formula says. What happens after the browser (Bluetooth delay, for example) is a fixed delay, not drift.

When timing still goes wrong

  • Bluetooth speakers or headphones delay everything by 100–300 ms. The beat stays steady, but the playhead runs ahead of what you hear.
  • A very slow device can run out of time to compute audio, which you hear as clicks or dropouts rather than as a tempo change.
  • Changing the tempo while it plays takes effect from the next step that isn't scheduled yet, so the change lands within about a 16th note.

Exact loop lengths for export

Because every step has an exact time, the loop length is exactly steps × 15 ÷ BPM seconds:

PatternTempoOne loop
16 steps (1 bar)120 BPM2.000 s
16 steps90 BPM2.667 s
32 steps (2 bars)96 BPM5.000 s
32 steps128 BPM3.750 s

A loop-ready WAV is exactly that long times the number of loops, with the ring-out of the last hits folded back to the start, so it repeats seamlessly in a DAW or sampler. A ring-out WAV adds exactly 2 seconds so a crash on the last step can fade. Swing never pushes a note past the end of the loop: even at 75% the last 16th still starts inside it.

Try it: load a preset on the online drum machine, move the swing slider while it plays, and export both kinds of WAV to compare.

Beat Pattern Lab

A step drum machine in your browser. Beats you can hear, change and share as a link.

Open the drum machine

Questions

Is 50% swing the same as no swing?
Yes. At 50% the second note of each pair sits exactly halfway, which is straight time.
What swing setting gives a triplet feel?
About 66–67%. On this machine use 66% with 8th swing for a shuffle; it is within a few milliseconds of a true triplet.
Why does my exported loop click at the loop point?
Usually because the file includes a ring-out tail. Export with Loop-ready instead: the tail is wrapped to the start and the file is exactly the loop length.