Web Audio helper — CC0 UI sound clips with opt-in toggle (default off)
Sound is off by default. State persists to localStorage. AudioContext is created lazily on first user gesture.
Click any button to preview. First click initialises the AudioContext and registers clips. All clips are CC0 (Kenney Interface Sounds).
Success
Task complete, save confirmed
Error
Action failed, validation error
Notify
New message or notification
Toggle
Toggle or checkbox state change
Send
Message sent, form submitted
Pop
Subtle click or button tap
| Export | Signature | Description |
|---|---|---|
registerSound | (name, dataUri) → Promise<void> | Decode and cache a clip. Call after first user gesture. |
play | (name, options?) → void | Play a registered clip. No-op if sound is disabled or unavailable. |
setSoundEnabled | (enabled: boolean) → void | Persist preference to localStorage. |
isSoundEnabled | () → boolean | Read current preference (default: false). |