Overview
2nd order IIR filter
Discussion
Second order 5 multiply recursive filter with algorithm precision selectable. Precision type 0 uses 24x24 with 56-bit accumulator, 1 uses 32x32 with 32-bit accumulator, 2 uses 32x32 with 64-bit accumulator and 3 uses 24x24 with 24-bit accumulator. The module is designed to operate on multiple channels and applies the same coefficients across all channels. The state array is allocated to contain 4*numChannels values. The frequency response of the module is determined by the values of the 5 coefficients, and the coefficients come directly from the MATLAB second order representation. The leading a0 coefficient is not supplied and is assumed to equal 1.0. The module implements the difference equation:
$y[n]=b_0x[n]+b_1x[n-1]+b_2x[n-2]-a_1y[n-1]-a_2y[n-2].$
Type Definition
Code Block |
---|
typedef struct _ModuleBiquadV2Fract32 { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure INT32 precisionType; // Boolean value that determines whether all channels are summed to form a single output. INT32 updateActive; // Specifies whether the filter coefficients are updating (=1) or fixed (=0). INT32 postShift; // Number of bits to shift INT32 bShift; // Number of bits to shift of Numerator coefficients INT32 currentBShift; // Current post shift of Numerator coefficients INT32 aShift; // Number of bits to shift of Denominator coefficients INT32 currentAShift; // Current post shift of Denominator coefficients FLOAT32* coeffs; // coefficients fract32* coeffsFract32; // coefficients in Fract32 fract32* state; // State variables. 6 per channel. fract32* currentCoeffsFract32; // Current coefficients in Fract32 } ModuleBiquadV2Fract32Class; |
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
precisionType | int | const | 0 | 0 | Unrestricted | |
updateActive | int | state | 0 | 1 | 0:1 | |
postShift | int | parameter | 1 | 2 | Unrestricted | |
bShift | int | derived | 1 | 1 | Unrestricted | |
currentBShift | int | state | 1 | 3 | Unrestricted | |
aShift | int | derived | 1 | 1 | Unrestricted | |
currentAShift | int | state | 1 | 2 | Unrestricted | |
coeffs | float* | parameter | 0 | [5 x 1] | Unrestricted | |
coeffsFract32 | fract32* | derived | 0 | [5 x 1] | Unrestricted | |
state | fract32* | state | 1 | [6 x 1] | Unrestricted | |
currentCoeffsFract32 | fract32* | state | 0 | [5 x 1] | Unrestricted |
Pins
Input Pins
Name: in
Description: audio input
...
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: out
Description: audio output
Data type: fract32
MATLAB Usage
File Name: biquad_v2_fract32_module.m
...