Synthlet
Audio Modifiers
npm package

State Variable Filter

A resonant filter suitable for modulation

A filter implemented with a state variable filter algorithm suitable for modulation.

import { Svf, SvfType } from "synthlet";
 
const audioContext = new AudioContext();
const osc = new OscillatorNode(audioContext);
const filter = Svf(audioContext, {
  type: SvfType.LowPass
  frequency: 440,
  Q: 1,
});
 
osc.connect(filter).connect(audioContext.destination);
 
filter.frequency.value = 880;
filter.Q.value = 3;

What

This is an alternative filter from BiquadFilterNode implemented in Web Audio API.

From Digital State Variable Filters:

... the biquad is not without problems. One of them is potential instability in case the coefficients are interpolated, for example to avoid ’zipper noise’ in audio equalisers. Another problem is numerical precision.

The digital state-variable filter does not have these problems. So one may wonder why it is not used more often.

It uses an optimized version described by Solving continuous SVF equations using trapezoidal integration by Andrew Simper (Cytomic) and implemented by Fred Anton Corvest. Thanks both!

Parameters

  • filterType: the type of the filter. By default is SvfType.LowPass.
  • frequency: the frequency of the filter in Hz. Default is 440Hz. Range: [20-2000]
  • Q: the resonance of the filter. Default is 0.5. Range: [0.025-40]

Available filter types are:

  • SvfType.ByPass = 0,
  • SvfType.LowPass = 1,
  • SvfType.BandPass = 2,
  • SvfType.HighPass = 3,
  • SvfType.Notch = 4,
  • SvfType.Peak = 5,
  • SvfType.AllPass = 6,

References

On this page