Never fire a click when a timer goes off. Work out WHEN each beat should sound, hand that time to the audio hardware in advance, and let a late loop be late.
A browser timer promises “at least this long” and never “exactly this long” — a repaint, a garbage collection or another tab can delay the callback, and a click fired from inside it inherits the delay. Scheduling instead means the beat time is computed by exact addition from the previous one, so the error cannot accumulate: nothing is ever measured to produce it. Two milliseconds of drift a beat is a third of a beat after two minutes at 100 BPM.
It does not help with output latency. The operating system’s buffer, Bluetooth headphones and the speaker itself all delay the sound, and no amount of careful scheduling removes that — it only guarantees the delay is the same for every beat. Recording against a browser click and expecting sample-accurate alignment is still a mistake.
Estimate with the rule, then check it against the calculator that models it properly.
Open Metronome →Never fire a click when a timer goes off. Work out WHEN each beat should sound, hand that time to the audio hardware in advance, and let a late loop be late. A browser timer promises “at least this long” and never “exactly this long” — a repaint, a garbage collection or another tab can delay the callback, and a click fired from inside it inherits the delay.