Sound · lib · 15K

Sound

An opt-in WebAudio synth for original alert sounds (no samples): Chirp, Clonk, Ping, Wood, Zap and Drip, a volume from 0 to 7, and useBeep() for a beep(voice?) that also fires a "s7ui:beep" window event, so an alert is never sound-only. Off by default.

Settings ({ enabled, volume, voice }) persist in localStorage under "s7ui:sound" and sync across components and tabs (useSoundSettings). The AudioContext is created lazily, only after the page has had a user gesture; while sound is enabled, useBeep() also primes it on the next pointer or key press. Volume 0 or sound off still dispatches the event: useBeepFlash() gives you a 160ms flag to invert a menu bar or frame (set data-highlighted too, for forced colours). Add a voice by extending SOUND_VOICES with { title, play(ctx, out, at) }.

Install

pnpm dlx shadcn@latest add @s7ui/sound

Info

Files:
lib/sound.ts, hooks/use-beep.ts
Uses:
—
Packages:
—