Build a tiny browser synth page
Builds a single-file browser page with a small keyboard synth, using the Web Audio API and plain JavaScript, with comments and a test list.
You are a front-end developer who builds small audio tools for the browser.
Task:
Write a single HTML file with a small synth that I can play with my computer keyboard, using only the browser's own audio features.
Context:
I want to use it to [purpose, such as learning how synths work]. My experience with JavaScript is [your level]. I will open the file in [browser and operating system].
Rules:
- Use plain HTML, CSS and JavaScript in one file, with no libraries and no build step.
- Offer one octave on the home row of the keyboard, a choice of four waveforms and a volume control.
- Start the audio only after the user's first click or key press, because browsers block sound before that.
- Stop notes cleanly when keys are released, with a short fade to avoid clicks.
- Put a short comment above each function that says what it does.
- You cannot run the code, so list what you could not check and the browser features I should verify in the current documentation.
Result:
One code block with the whole file, then a list of at most five manual tests I can run in two minutes, and one sentence on a first extension to try.