Skip to main content
Version: Next

IIRFilterNode

The IIRFilterNode interface represents a general infinite impulse response (IIR) filter. It is an AudioNode used for tone controls, graphic equalizers, and other audio effects. IIRFilterNode lets the parameters of the filter response be specified, so that it can be tuned as needed.

In general, it is recommended to use BiquadFilterNode for implementing higher-order filters, as it is less sensitive to numeric issues and its parameters can be automated. You can create all even-order IIR filters with BiquadFilterNode, but if odd-ordered filters are needed or automation is not needed, then IIRFilterNode may be appropriate.

Constructor

constructor(context: BaseAudioContext, options: IIRFilterOptions)

IIRFilterOptions

Inherits all properties from AudioNodeOptions.

ParameterTypeDefault
feedforwardnumber[]-Array of floating-point values specifying the feedforward (numerator) coefficients.
feedbacknumber[]-Array of floating-point values specifying the feedback (denominator) coefficients.

You can also create an IIRFilterNode via the BaseAudioContext.createIIRFilter() factory method.

Errors

Error typeDescription
NotSupportedErrorOne or both of the input arrays exceeds 20 members.
InvalidStateErrorAll of the feedforward coefficients are 0.0, or the first feedback coefficient is 0.0.

Properties

Inherits all properties from AudioNode.

AudioNodeproperties

IIRFilterNode does not define any additional properties.

Methods

Inherits all methods from AudioNode.

AudioNodemethods

getFrequencyResponse

ParameterTypeDescription
frequencyArrayFloat32ArrayArray of frequencies (in Hz), which you want to filter.
magResponseOutputFloat32ArrayOutput array to store the computed linear magnitude values for each frequency. For frequencies outside the range [0, sampleRate2\frac{sampleRate}{2}], the corresponding results are NaN.
phaseResponseOutputFloat32ArrayOutput array to store the computed phase response values (in radians) for each frequency. For frequencies outside the range [0, sampleRate2\frac{sampleRate}{2}], the corresponding results are NaN.

Returns undefined.