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.

The prompt

Prompt
You are a front-end developer and sound designer who builds polished browser music toys. Build "Pocket Groove", a 16-step drum sequencer in one HTML file with a dark studio theme. Show five rows (Kick, Snare, Clap, Hi-hat, Open hat), each with 16 clickable step squares. A moving playhead lights the current column while the loop plays. Rules: 1) Synthesize every drum with the Web Audio API: a sine pitch-drop kick, plus filtered noise for the snare, clap and hats. Create the AudioContext on the first click, tap or key press, keep master volume low and include a visible mute toggle. 2) Use a lookahead scheduler for tight timing. Add a tempo slider (60-180 BPM) and a swing slider (0-75%) that delays every second sixteenth note; both must work while the loop plays. 3) Include four preset groove buttons (Four on the Floor, Boom Bap, Breakbeat, Funky Shuffle) that set pattern, tempo and swing, plus a Clear button. Load one preset on start so the grid looks alive. 4) Make the steps real buttons with aria-pressed. Space plays and stops, M mutes, C clears, and turning a step on previews its sound. 5) Give each row its own color on a dark navy panel and shade beats in groups of four. The layout must fit 360-1280px wide, and the playhead pulse turns off under prefers-reduced-motion. Use no external files, storage or network calls. Output format: one complete HTML file in a single code block, then 3 short ideas to extend it.

Example output

One HTML file. Save it and open it in any browser.Open full screen

Example: Pocket Groove, a 16-step drum machine that runs in the browser.

The page opens with the Four on the Floor groove already loaded. Press Play or Space and a highlighted column sweeps across the grid. Tap squares to add or remove kick, snare, clap and hat hits. Try Boom Bap, then drag Swing up and down to hear the shuffle change. Use M to mute and C to clear the grid and start your own pattern.

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • A lookahead Web Audio scheduler keeps the beat steady even when the UI is busy, so the loop sounds tight on the first run.
  • Preset grooves load on start, so beginners hear a working beat before touching a single step.
  • Real buttons with aria-pressed plus Space, M and C shortcuts make the grid usable by mouse, touch and keyboard.

Paste the prompt into ChatGPT, Claude or Gemini. Save the returned code as pocket-groove.html and open it in any modern browser, or run it in the chat's preview or canvas. Click Play to hear the loop.

Common edits

  • Change the theme by swapping the five track colors and the accent yellow, or rename the rows and presets to fit a genre like trap or reggae.
  • Add a sixth track such as a cowbell (two detuned square oscillators) or a tom (sine pitch drop at 120 Hz).

Prompt details

By
Prompts-GPT editors
Published

Did this prompt work?

Keep exploring

More in Sound Effects & Music