RunTheTests
/

Metronome

A metronome scheduled on the audio clock, so it does not drift the way browser timers do.

120BPM

Tempo

Beats per bar

Result

120 BPM ready

Beats are computed as exact times on the audio hardware clock and queued ahead of when they sound. That is what keeps a browser metronome steady: a metronome driven directly by setInterval accumulates every timer overshoot, and JavaScript timers are allowed to fire late — under load one drifts audibly within a minute. What this cannot control is output latency, so the click reaches your ears a few milliseconds after the scheduled time. That offset is constant, so the tempo is right even though the absolute timing is not.

Diagnostic telemetry
Tempo
120 BPM
Beat interval
500.0 ms
Time signature
4/4
SchedulingBeats are queued 150 ms ahead onto the audio hardware clock, so a late timer tick cannot shift the beat
Audio clock

What this cannot tell you

  • Output latency is not controllable from a browser, so the click reaches your ears a few milliseconds after its scheduled time. The offset is constant, so the tempo is correct even though absolute timing is not.
  • Bluetooth headphones add substantial and variable latency — often over 100 ms. Use wired output if you are playing along with something else that has to line up.
  • A backgrounded browser tab is throttled by the operating system. The scheduler resumes from the present rather than firing a burst of catch-up beats, but the pulse will have paused.

Take this with you

How this test works

Every beat is computed as an exact time on the audio hardware's clock and queued 150 milliseconds before it should sound, with a scheduler waking every 25 milliseconds to top up the queue. That indirection is the entire engineering content of a browser metronome. Driving one directly from setInterval seems obvious and does not work: JavaScript timers are permitted to fire late and routinely do under load, and because each beat is timed from the previous callback rather than from a fixed grid, every overshoot accumulates. Such a metronome slides audibly within a minute, which is a total failure at the one job it has. Scheduling ahead against the audio clock means a late scheduler tick simply queues two beats instead of one, and the beats themselves land exactly where the tempo says.

What the results mean

Tempo
Beats per minute. The beat interval below it is the same number expressed as time, which is the form that matters for scheduling.
Beat interval
Milliseconds between beats. At 120 BPM this is exactly 500 ms, and every beat lands on that grid rather than 500 ms after the last callback.
Scheduling
Reported as audio clock rather than timer, because that is what separates a metronome that holds tempo from one that does not.
Accented downbeat
The first beat of each bar sounds higher, so you can hear where the bar starts without counting.

Common problems and fixes

The click is late relative to what I am playing along with
That is output latency, and it is fixed rather than drifting. Bluetooth is the usual culprit and can exceed 100 ms — switch to wired output.
It stopped when I switched tabs
Browsers throttle background tabs. The scheduler resumes from the present rather than replaying missed beats, so nothing catches up in a burst.
The tempo seems slightly off against another metronome
Compare the beat interval rather than the tempo. Some metronomes round the interval to whole milliseconds, which at high tempos is a real difference.

Frequently asked questions

Why do browser metronomes drift?

Because they are usually built on setInterval, and JavaScript timers are allowed to fire late. Each beat gets timed from the last callback rather than from a fixed grid, so overshoots accumulate. This one schedules onto the audio hardware clock instead, where the beat times are absolute.

Is a browser metronome accurate enough to practise with?

For tempo, yes — the interval between beats is exact. What it cannot control is how long the sound takes to reach you, which is constant and therefore does not affect keeping time.

Why does the first beat sound different?

It is the downbeat, pitched higher so you can hear the start of each bar without counting. Change the beats per bar to match the time signature you are playing in.

More in Audio