How I Built a Precise Browser Metronome (And Why setTimeout Wasn't Good Enough)
A deep dive into Web Audio API timing, and the surprising complexity behind a "simple" click. The Problem With Online Metronomes I play guitar. Not professionally — just a hobby I've had for years....
Source: dev.to
A deep dive into Web Audio API timing, and the surprising complexity behind a "simple" click. The Problem With Online Metronomes I play guitar. Not professionally — just a hobby I've had for years. Like most self-taught musicians, I knew I needed a metronome, and like most people in 2026, I reached for a browser-based one. What I found was disappointing. Most online metronomes fall into two categories: overly bloated apps with ads everywhere, or minimal tools that drift at higher tempos. Try setting one to 180 BPM and you'll hear it — the clicks start to feel uneven, rushed, then behind. It's subtle, but as a musician, you feel it. So I decided to build my own: Tap Metronome. Why JavaScript Timers Fail at Music Here's something most web developers don't realize: setTimeout and setInterval are not accurate enough for music. The browser's event loop is single-threaded. When you write: setInterval(() => playClick(), 500); // 120 BPM You're asking the browser to schedule a callback appr