Sources

Every layer starts with a source - the raw signal that everything else shapes. @web-kits/audio supports six source types.

Oscillator

The most common source. Pick a waveform, set a frequency, and optionally sweep or FM-modulate it.

{
  source: {
    type: "sine",
    frequency: 440,
    detune: 0,
    fm: { ratio: 3.5, depth: 200 },
  },
}
PropertyTypeDescription
type"sine" | "triangle" | "square" | "sawtooth"Waveform shape
frequencynumber | { start, end }Hz, or a sweep between values
detunenumberCents offset
fm{ ratio, depth }FM synthesis modulator

Noise

Broadband noise. Useful for percussion, textures, and risers.

{ source: { type: "noise", color: "pink" } }

Colors: "white" (default), "pink", "brown".

Wavetable

Define your own harmonic content with an array of partial amplitudes.

{
  source: {
    type: "wavetable",
    harmonics: [1, 0.5, 0.25, 0.125],
    frequency: 440,
  },
}

Sample

Play back an audio file. The buffer is fetched and decoded automatically.

{
  source: {
    type: "sample",
    url: "/sounds/kick.wav",
    playbackRate: 1,
    loop: false,
  },
}
PropertyTypeDescription
urlstringPath to audio file
bufferAudioBufferPre-decoded buffer
playbackRatenumberSpeed multiplier
loopbooleanLoop playback
loopStartnumberLoop start point (s)
loopEndnumberLoop end point (s)

Stream

Route a live MediaStream - like a microphone - through the signal path.

{ source: { type: "stream", stream: mediaStream } }

Constant

A DC offset. Mainly useful as a modulation source for advanced signal routing.

{ source: { type: "constant", offset: 1 } }