How the Beat Maker Keeps the Groove Tight
AnyTool Beat Maker is a step-sequencer drum machine built on the Web Audio API’s “two clocks” lookahead scheduler — the same pattern as the AnyTool Metronome. A short setInterval timer fires about every 25 milliseconds and, on each wake-up, schedules every 16th-note step that falls within the next ~100 milliseconds onto the AudioContext sample clock with oscillator.start(time) and bufferSource.start(time) at exact AudioContext.currentTime values. Because the audio hardware clock decides the precise moment each hit plays, the loop is sample-accurate and does not drift, even while the tempo, swing or step count are changed live. Swing is applied per step: the odd (off-beat) 16th notes are pushed slightly later by a fraction of a step duration. A queue of scheduled steps is drained on requestAnimationFrame to highlight the playing column in sync with the audio.
- Lookahead scheduler: ~25 ms timer schedules 16th-note steps ~100 ms ahead
- Steps placed on the AudioContext sample clock (currentTime) — drift-free
- Swing delays odd 16th notes by a fraction of a step for shuffle
- Stays locked across live tempo / swing / step-count changes
- A queue of scheduled steps drives the playing-column highlight via requestAnimationFrame
