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
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
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 like this
Build a Touch-Friendly Synth Drum Pad With Keyboard Shortcuts in One HTML File
Get a single HTML file with an eight-pad drum machine that synthesizes kick, snare, hats, clap, toms and bell live and responds to taps or QWERTY keys.
Build a Four-Lane Rhythm Tap Game with a Synthesized Beat in One HTML File
A ready-to-paste prompt that builds an original four-lane rhythm game with a Web Audio backing loop, Perfect/Good/Miss timing judgments, combos, and keyboard plus touch lanes.
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.