Build a Two-Octave Synth Keyboard with ADSR, Filter and Waveform Controls

A single HTML file synth keyboard you can play with the mouse, several fingers or computer keys, with waveform, filter, ADSR, presets and live visuals.

You getone complete HTML file in a single code block, then 3 short ideas to extend it.

The prompt

Prompt
Act as a front-end audio developer and music teacher who builds clear classroom demos.

Build Tone Lab, a two-octave synth keyboard (C3 to C5, 25 keys) in one HTML file using only the Web Audio API. Every key shows its note name and the computer key that plays it, so students can connect what they press with what they hear.

Rules:
1. Input: mouse, true multitouch with pointer events (each finger holds its own note, and sliding a finger glides between keys), and computer keys: the Z row and S row for the lower octave, the Q row and number row for the upper. Ignore key repeat. Add octave down and up buttons.
2. Sound: create the AudioContext on the first press. Each voice is an oscillator feeding its own envelope gain, then a shared low-pass filter, a compressor and a quiet master gain. Include a visible mute toggle.
3. Controls: four waveform buttons (sine, triangle, square, saw), a log-scale filter cutoff, resonance, and Attack, Decay, Sustain and Release sliders with live value readouts. Add five presets: Organ, Pluck, Pad, Bell and Brass.
4. Teaching visuals: a canvas that redraws the ADSR shape as the sliders move, a live oscilloscope, and a now-playing line showing the note and its frequency in Hz.
5. Design: dark navy panels with amber and teal accents, responsive cards from 360 to 1280px, visible focus rings, reduced motion respected, and short Try this tips under the keyboard.

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: Tone Lab, a two-octave classroom synth keyboard.

Click or tap the keys, hold several with multiple fingers, or play with the computer keys Z–M (lower octave) and Q–I (upper). Switch between sine, triangle, square and saw while watching the oscilloscope. Drag the ADSR sliders and the envelope graph redraws instantly. Try the Pad preset for slow swells, or Pluck with Sustain at 0. Use − Oct / + Oct to shift the range, and the mute button to silence it.

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

Tips and common edits

Why this works

  • Each voice gets its own envelope gain while all voices share one filter, so slider changes are heard live without clicks or stuck notes.
  • Pointer capture with a hold count per note gives reliable multitouch, glides and mixed mouse-plus-keyboard play.
  • The ADSR graph, oscilloscope and Hz readout turn each control change into something students can see as well as hear.

Paste into ChatGPT, Claude or Gemini. Save the code as tone-lab.html and open it in a browser, or use the chat's preview or canvas. Click once to enable sound. On a projector, use the computer keys.

Common edits

  • Swap the presets or the amber and teal palette to suit a lesson, for example add a Flute preset with a sine wave and a slow attack.
  • Add a second detuned oscillator or an LFO on the filter cutoff to demonstrate chorus and wah effects.

Prompt details

By
Prompts-GPT editors
Published

Did this prompt work?

Keep exploring

More in Sound Effects & Music