SoundDefinition: a JSON-serializable description that the engine turns into Web Audio nodes each time it plays. You can write one by hand with defineSound, edit one in a generated file, or put many in a custom theme.
A first sound
defineSound returns a function. Each call creates a new voice and returns a handle with stop(). The original definition stays available as pop.definition.
The parts of a layer
A single-layer sound has these fields:What makes the signal: an oscillator (
sine, triangle, square, sawtooth), noise, a wavetable, a sample URL or buffer, a stream, or a constant.How volume changes over time. Only
decay is required. Without attack, the sound starts at full volume. Without sustain, it fades to silence after the decay.Biquad filters (
lowpass, highpass, bandpass and others) applied before the envelope. A filter can have its own envelope that sweeps the cutoff.A chain after the envelope: reverb, delay, distortion, chorus, flanger, phaser, tremolo, vibrato, bitcrusher, compressor, EQ, gain and pan.
Low-frequency oscillators that modulate a parameter such as
frequency, gain, pan or filter.frequency.Layers
Most good UI sounds combine a short transient with a tonal body. Uselayers to play several layers together, with optional effects on the mix:
Shorthands
For quick one-off tones, use the oscillator and noise helpers:0.4).
Play-time options
Any sound accepts overrides when you play it:jitter adds a random offset of up to ±value each time, so repeated sounds don’t feel identical.
Render to a file
renderToWav renders offline, without speakers, and returns a WAV Blob:
Tips for UI sounds
- Keep most sounds under 150 ms. Feedback sounds like
successandcompletecan run longer. - Start with a low
gain. A UI sound should sit under the content, not over it. - Use
jitteron anything that repeats quickly. - Reserve
hoverandtypefor places where they help; they get tiring fast.