Build an Accurate Web Audio Metronome with Tap Tempo in One HTML File
A single HTML file metronome with look-ahead Web Audio timing, tempo and time signature controls, accented downbeats, tap tempo and a pulsing beat display.
You getone complete HTML file in a single code block, then 3 short ideas to extend it.
The prompt
You are a front-end developer who specializes in Web Audio timing. Build a single-page metronome called Pulsewright with a calm, dark practice-room theme. The core is a rock-steady click track from a look-ahead scheduler: a setInterval loop every 25 ms schedules oscillator clicks up to 120 ms ahead on the AudioContext clock. Rules:
1. Tempo runs from 30 to 240 BPM via a range slider plus -5, -1, +1 and +5 buttons. Show a large BPM number and an Italian tempo marking from Largo to Prestissimo. Changes apply on the next beat without stopping.
2. Provide time signature buttons for 2/4, 3/4, 4/4, 5/4, 6/8 and 7/8. The downbeat is a higher, louder click. Add softer secondary accents for 6/8 on beat 4 and for 7/8 grouped 2+2+3.
3. A Tap tempo button averages the last six taps and resets after a two-second pause.
4. A ring pulses on each beat, amber on the downbeat, above a row of beat dots. Sync both from a note queue read in requestAnimationFrame. Under prefers-reduced-motion, change color only, with no scaling.
5. Create the AudioContext on the first click, tap or key press. Keep the volume low and show a visible mute toggle. Keyboard: Space starts and stops, T taps, the arrow keys change tempo by 1 (5 with Shift), and M mutes.
6. Use a dark palette with amber and teal accents and 44px touch targets. The page must fit 360-1280px widths and use no external files or storage.
Output format: one complete HTML file in a single code block, then 3 short ideas to extend it.Example output
Tips and common edits
Why this works
- Naming the look-ahead scheduler (25 ms loop, 120 ms ahead on the audio clock) avoids the drift that setTimeout-only metronomes suffer.
- A shared note queue drives the visuals, so the pulse lines up with what you hear instead of running on a separate timer.
- Exact ranges, accent patterns and key bindings leave nothing to guess, so the first output is usable without follow-up edits.
Paste into ChatGPT, Claude or Gemini. Save the returned code as pulsewright.html and open it in any modern browser, or run it in the chat's preview or canvas. Click Start to hear it.
Common edits
- Swap the sine clicks for short noise bursts or a woodblock-like envelope, or add a subdivision toggle for eighths and triplets.
- Change the palette or rename the app, and widen the tempo range to 20-300 BPM for drummers.
Keep exploring
More like this
Build a 16-Step Drum Sequencer with Tempo and Swing in One HTML File
A ready-to-paste prompt that makes an AI build a clickable 16-step drum machine with synthesized drums, preset grooves, tempo, swing and a moving playhead.
Build a Classroom Game Show Buzzer Board with Timer Sounds in HTML
A prompt that builds a single HTML quiz-night console with four colored team buzzers, correct and wrong sounds, scoring, and a ticking countdown that ends in a horn.
Build a Generative Ambient Chime Toy With Pentatonic Notes in One HTML File
A ready-to-paste prompt that builds a calm ambient music toy where every tap drops a glowing, drifting ripple and a pentatonic chime, with an auto-play mode.
Build a Guided Breathing Exercise App with Soft Rising Tones in One HTML File
A prompt that produces a single-file breathing guide with box, 4-7-8 and coherent patterns, an expanding circle and gentle synthesized sine swells.
Build a Piano Interval Ear-Training Quiz with Streak Scoring in One HTML File
A one-file interval ear trainer that plays two synthesized piano notes, gives four multiple-choice answers, tracks streaks and shows the answer on a keyboard.
Build a Pitch Pipe and Tuner Reference Tone Player for Guitar, Ukulele and Violin
A prompt that produces a single-file pitch pipe app playing sustained per-string reference tones for guitar, ukulele and violin, with A4 calibration from 432 to 446 Hz.