Class IirFilter
IIR (Infinite Impulse Response) filter using the Direct Form II Transposed structure.
Implements
Inherited Members
Namespace: MOSAIC.Components.SignalProcessing
Assembly: MOSAIC.dll
Syntax
public class IirFilter : IOnlineFilter
Remarks
The filter implements the difference equation:
y[n] = (b[0]·x[n] + b[1]·x[n−1] + … ) − (a[1]·y[n−1] + a[2]·y[n−2] + … ),
where b are the feedforward (numerator) coefficients and a are the feedback
(denominator) coefficients.
The Direct Form II Transposed structure is used because it minimises the number of delay elements and offers better numerical properties than Direct Form I for high-order filters.
If a[0] ≠ 1, both coefficient arrays are automatically normalised during construction.
Coefficients are typically produced by FilterDesign factory methods.
Thread-safety: This type is not thread-safe. If concurrent access is required, the caller must synchronize externally.
Constructors
IirFilter(double[], double[])
Initializes a new IirFilter with the given transfer-function coefficients.
Declaration
public IirFilter(double[] b, double[] a)
Parameters
| Type | Name | Description |
|---|---|---|
| double[] | b | Feedforward (numerator) coefficients. The array is stored by reference (not copied) and may be modified in-place if normalisation is required. |
| double[] | a | Feedback (denominator) coefficients. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
Fields
_a
Feedback (denominator) coefficients. Normalised so that a[0] == 1.
Declaration
private readonly double[] _a
Field Value
| Type | Description |
|---|---|
| double[] |
_b
Feedforward (numerator) coefficients. Normalised so that a[0] == 1.
Declaration
private readonly double[] _b
Field Value
| Type | Description |
|---|---|
| double[] |
_z
Internal state (delay) variables for the Direct Form II Transposed structure.
Length equals max(b.Length, a.Length).
Declaration
private readonly double[] _z
Field Value
| Type | Description |
|---|---|
| double[] |
Properties
Order
Gets the filter order, defined as max(b.Length, a.Length) − 1.
Declaration
public int Order { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
ProcessSample(double)
Processes a single input sample through the filter and returns the filtered output.
Declaration
public double ProcessSample(double sample)
Parameters
| Type | Name | Description |
|---|---|---|
| double | sample | The input sample value. |
Returns
| Type | Description |
|---|---|
| double | The filtered output sample. |
Remarks
Uses the Direct Form II Transposed update equations:
y[n] = b[0]·x[n] + z[0]
z[i] = b[i+1]·x[n] − a[i+1]·y[n] + z[i+1] (for i = 0 … N−2)
ProcessSamples(double[])
Processes an array of input samples sequentially through the filter.
Declaration
public double[] ProcessSamples(double[] samples)
Parameters
| Type | Name | Description |
|---|---|---|
| double[] | samples | The input sample array. |
Returns
| Type | Description |
|---|---|
| double[] | A new array of the same length containing the filtered output samples. |
Reset()
Resets the filter state by clearing all delay elements, as if no samples had been processed.
Declaration
public void Reset()