Why timing is hard in a browser — and how this metronome solves it
The naive way to build a metronome in JavaScript is setInterval firing a sound every beat. It sounds fine for a few seconds and then falls apart, because JS timers are not guaranteed to fire on time — they queue behind rendering, garbage collection and background-tab throttling, and every late tick becomes an audible stumble.
This metronome uses the Web Audio lookahead scheduler pattern instead. A modest 25 ms timer does no audio work itself; it only looks ahead and books every click due in the next 100 ms directly on the audio hardware clock. That clock counts samples, not milliseconds of event loop, so even if the JS timer arrives late, the clicks it already scheduled land exactly on the grid. The result is timing steady enough to record against.
Using tap tempo and accents
Tap the TAP TEMPO button along with any song and the metronome averages the intervals of your recent taps to estimate the BPM — pause for two seconds and it starts a fresh measurement. Choose a time signature to set how many clicks form a bar, and leave the accent on to hear beat one pitched higher, which makes it much easier to stay oriented in 3/4 or 6/8.
Practice ideas
Work passages up in small steps: find a tempo where every note is clean, then add 4–8 BPM per pass. Recording yourself against the click is the fastest way to hear where you rush — capture a take with the Voice Recorder, or check your tuning first with the Tone Generator’s 440 Hz preset.