Filters

Filters remove or boost specific frequencies. @web-kits/audio supports all 8 biquad types and IIR filters with custom coefficients. Chain multiple filters on a single layer, each with its own envelope.

Basic usage

{
  source: { type: "sawtooth", frequency: 110 },
  filter: {
    type: "lowpass",
    frequency: 800,
    resonance: 6,
  },
}

Biquad types

lowpass, highpass, bandpass, notch, allpass, peaking, lowshelf, highshelf

PropertyTypeDescription
typestringOne of the 8 biquad types
frequencynumberCutoff or center frequency (Hz)
resonancenumberQ factor
gainnumberBoost/cut in dB (peaking, shelf)

Filter chains

Pass an array to run filters in series:

{
  filter: [
    { type: "lowpass", frequency: 800, resonance: 6 },
    { type: "peaking", frequency: 400, gain: 6, resonance: 2 },
  ],
}

Filter envelope

Sweep the cutoff frequency over time. The filter starts at frequency, ramps to peak, and decays back.

{
  filter: {
    type: "lowpass",
    frequency: 200,
    resonance: 8,
    envelope: { attack: 0.01, peak: 4000, decay: 0.3 },
  },
}
PropertyTypeDescription
attacknumberTime to reach peak (s)
peaknumberMaximum cutoff frequency (Hz)
decaynumberTime to return to base (s)

IIR filters

For custom transfer functions, provide feedforward and feedback coefficients directly:

{
  filter: {
    type: "iir",
    feedforward: [0.1, 0.2, 0.1],
    feedback: [1.0, -0.5, 0.3],
  },
}