SoundDefinition is either a single layer or a multi-layer sound. It’s plain JSON, so the same shape works in defineSound, generated sound files and theme files. Times are in seconds, frequencies in Hz, and detune in cents.
Layer
The signal generator. See sources.
Amplitude envelope. Defaults to a short 0.5 second fade. See envelope.
Filters applied before the envelope. See filters.
3D position. See 3D panner.
Periodic modulation. See LFO.
Effects chain applied after the envelope. See effects.
Multi-layer sound
Sources
Oscillator: sine, triangle, square, sawtooth
Oscillator: sine, triangle, square, sawtooth
frequency(required): a fixed value, or{ start, end }for a pitch sweep.detune: cents.fm: frequency modulation.ratiois modulator to carrier,depthis the modulation index.
Noise
Noise
color: white (default), pink or brown.Wavetable
Wavetable
harmonics lists the amplitude of each harmonic, starting with the fundamental. frequency works like an oscillator’s.Sample
Sample
url: fetched, decoded and cached after the first load. Or pass a decodedbufferin code.playbackRate(default1),detune.loop,loopStart,loopEnd.
Stream
Stream
{ type: "stream", stream: MediaStream } plays live input such as a microphone. Code only, and only with a real-time AudioContext.Constant
Constant
1), useful as a control signal.Envelope
Filters
A biquad filter:
Or an IIR filter:
{ "type": "iir", "feedforward": number[], "feedback": number[] }.
LFO
Effects
Most effects take amix from 0 (dry) to 1 (wet).
3D panner
positionX, positionY and positionZ are required. Optional: orientationX/Y/Z, panningModel (HRTF default, or equalpower), distanceModel (inverse default, linear, exponential), maxDistance, refDistance, rolloffFactor, coneInnerAngle, coneOuterAngle, coneOuterGain.
Position the listener with setListener or useListener.