The live demo starts when it’s in view.Click once to start audio, then the pads or keys 1 to 0 · drag Combo and let go to hear the pop climb · the scope draws every sound, even with sound off
The sounds of play for a 2D action game, made live with the Web Audio API and no files.
The sounds of play for a 2D action game, made live with the Web Audio API and no files: a dry crackle for a hit, kills that pop higher up a pentatonic scale as a combo grows (so any chain is a tune), pickups that climb while the streak lasts, a deep blast, a knock when the player is struck, a groan when something large arrives, a surge, a level-up arpeggio, and a fall or a swelling chord when the run ends. ui-sounds’ rules come with it: audio waits for a real gesture, every sound has its own repeat gap, a voice cap and a compressor keep a full swarm from turning into noise, and it rests while the page is hidden or the game’s Sound switch is off.
Measured 21 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged CPU <0.01–<0.01 ms). What ran: Measured idle: the bench has no user gesture, so headless Chrome keeps the AudioContext suspended and nothing plays. A sound costs a few short-lived Web Audio nodes; mixing runs on the audio thread, outside the frame. The scope redraws only when a sound is shown. Phones: tiers are being measured next.
How steadily it runs on RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference
Typical frame ?
16.80 ms
1% low ?
55 fps
Varies by ?
±0.51 ms
All metricsRTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · referenceHow long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.
Frames run on a 60 Hz timer (a page demo), so most frames take about one tick, 16.7 ms: the spread around it is what matters.
Frames
Median (p50) ?
16.80 ms
p95 ?
18.00 ms
p99 ?
18.11 ms
Slowest ?
18.55 ms
Mean ?
16.84 ms
Standard deviation ?
0.51 ms
1% low ?
55 fps
0.1% low ?
54 fps
Hitches ?
0 of 600
Over budget ?
0 of 600
Main thread
Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.1 / 0.2 / 0.2 ms
Input
No input during this run.
Memory
JavaScript heap ?
35.1 → 35.3 MB
Growth ?
+0.28 MB
Browser
JavaScript a frame ?
0.09 ms
All tasks a frame ?
0.20 ms
Layout / style ?
0.00 / 0.00 ms
Main thread busy ?
1%
Garbage collection
Collections ?
0 (0 minor, 0 major)
Pauses ?
0.0 ms in all, longest 0.0
What it needs
Renders with
DOM and CSSPlain DOM and CSS: every current browser.
Your browser
Runs hereNo WebGPU needed
Depends on
NothingNo other packages
With an agent
install("game-sfx")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it up
What it’s for
Hits, kills and pickups in a 2D action or arcade game
Combo chains that rise in pitch so the player hears the streak
A level-up, a boss arriving, a wave closing in
A win and a loss sting at the end of a run
A game jam that needs sound without an asset pipeline
Pitfalls, in brief
Browsers keep an AudioContext suspended until a click, a tap or a key press.
Make one per game, not one per scene: dispose() closes the AudioContext, and browsers cap how many a page may have. ui-sounds for the menus is a second context; that is fine (two), but not one per enemy kind.
A swarm asks for hundreds of hits a second.
Call the sounds from the events your rules emit after a tick, not from inside the simulation: the rules stay pure and replayable, and a hit-stop or a paused game makes no sound by itself.
The big pop (kind 3) has its own slot, so a boss dying is never dropped behind a swarm’s small pops; give anything else that must be heard its own name.
3 more in brief
Sound is never the only feedback: a level-up, a surge or a boss arriving must also show on screen (a banner, the HUD) and be said in a live region, for players who are deaf or play muted.
Pass the game’s Sound switch as enabled and call refresh() when it flips: the context then suspends at once, so the audio thread rests too.
render() is for drawing and tests: it plays the sound into an OfflineAudioContext at full volume without the compressor, so its peak reads louder than the game plays it.
8 pitfalls in full, the hook-up guide, the module source and its tests come with the part.
Where it comes from
From another of the maker’s apps. Fully custom code.
web audiosound designgame audiosynthesiscombopentatoniccompressorfeedbackno dependenciesdom
Swipe a list row, as on a phone: a short swipe shows its buttons, a long one runs the outer action (delete), a quick flick opens and a flick back closes.