Skip to content

Audio system / game feel

Zero-File WebAudio Combat Soundscape

Tested with Claude · produced Long Wind

The Prompt

Design and implement a complete combat soundscape for a browser game with NO audio files. Everything must be synthesized at runtime with the WebAudio API, inside the same self-contained HTML file as the game.

Sound design:
- Build a small synth toolkit: noise burst with a bandpass, pitched click with a fast pitch envelope, low sine thump, filtered saw for metal, and a short convolution reverb generated from noise. Compose every sound from these five pieces.
- Required cues: sword swing (whoosh), light hit, heavy hit, deflect, guard block, dodge, execution, footstep, enemy death, boss roar, rain bed, wind bed and one UI confirm.
- Each cue gets three variants with randomised pitch (±6%), gain and start offset. Never play the same buffer twice in a row.
Layering and mixing:
- Separate buses: combat, ambience, UI, music. Ambience sits at -18dB under combat; duck ambience by 6dB for 300ms on heavy hits and deflects.
- Add a compressor on the master bus and a limiter at -1dBFS. Never clip when ten enemies die at once.
- Throttle identical sounds with a 30ms retrigger gate and a voice cap of 24. Report every dropped voice to a debug counter.
- Positional audio: use PannerNode for enemy sounds with distance attenuation and a stereo pan tied to camera space. Sounds off-screen must still be audible but dulled.
Timing:
- Schedule with AudioContext.currentTime, never setTimeout. All timing windows (deflect, hit-stop) must read from the same clock as gameplay.
- Hit-stop of 40-80ms on heavy hits and deflects; the audio must start at the hit, not after the freeze.
Platform and accessibility:
- Unlock the AudioContext on the first user gesture and show a mute button that works before unlock.
- Respect prefers-reduced-motion and a separate reduced-audio setting: cap simultaneous voices at 8 in reduced mode and remove low-frequency rumble.
- Provide master, combat and ambience volume sliders that persist in localStorage.
Deliverable and testing:
- A demo scene that lets each cue be triggered from a keyboard, plus a stress test that fires 50 sounds in one second and reports clipping, dropped voices and CPU cost.
- Print the bus levels, voice cap, cue table and measured frame impact at the end. Remove any cue that costs more than 1ms of main-thread time.

What This Prompt Produces

Long Wind ships zero audio files: every sword hit, footstep, rain layer and crowd murmur is generated with WebAudio, which is why three chapters download in seconds. The bus structure and voice cap are what keep a busy fight from turning into noise.

Modification Tips

  • Generate the reverb impulse from noise at load. It removes the last audio file without making the mix sound dry.
  • Duck ambience under combat, not the other way round. Players need to hear the deflect cue more than the rain.
  • Cap voices and throttle retriggers. Ten simultaneous death sounds is the fastest way to make good synthesis sound broken.
  • Schedule everything from AudioContext.currentTime so hit-stop and deflect windows stay in sync with gameplay.

The Game This Prompt Produced

Want to try it? Open Claude, paste the prompt, and you'll have a playable game in minutes. When you're happy with the result, submit it to Daily AI Games.