Skip to content

BiquadSparseHP

Overview

Sparse Biquad cascade filters with most of the coefficients as bypass and high precision implementation

Discussion

This module implements a high precision version of a custom biquad filter that is capable of realizing many different filter types along with the option to specify raw coefficients. The module performs internal smoothing allowing the filters to be updated without introducing clicks. In all cases, the module implements an underlying cascade of second order filters. First order filters are realized by setting some of the second order coefficients to zero.

The behavior of the cascade filters are controlled by the filterType arrary. The variable, filterType is an integer in the range from 0 to 23 inclusive.

After specifying filterType, adjust the filter parameters by setting the fields, gain, freq, and Q. Some filter parameters are not applicable to all filter types. If the filter type is RawCoeffs then the coefficients from rawCoeffs array are used and all other controls are ignored. The variable freq controls the center frequency of the filter, gain determines the boost or cut in dB, and Q determines how sharp the filter is. Low Q values lead to broad filters and high Q values lead to narrow filters.

The following table discusses the various filter types and which variables are active in each case.

  • filterType=0, Simple pass through with unity gain.

  • filterType=1, Gain in dB. [gain].

  • filterType=2, 1st order Butterworth low pass filter. [freq].

  • filterType=3, 2nd order Butterworth low pass filter. [freq].

  • filterType=4, 1st order Butterworth high pass filter. [freq].

  • filterType=5, 2nd order Butterworth high pass filter. [freq].

  • filterType=6, 1st order allpass filter. [freq].

  • filterType=7, 2nd order allpass filter. [freq, Q].

  • filterType=8, 2nd order low shelf. It allows you to vary the gain of the low frequencies. The high frequencies have a gain of 1.0. [freq, gain].

  • filterType=9, 2nd order low shelf with Q. It allows you to vary the gain of the low frequencies. The high frequencies have a gain of 1.0. [freq, gain, Q].

  • filterType=10, 2nd order high shelf. It allows you to vary the gain of the high frequencies. The low frequencies have a gain of 1.0. [freq, gain].

  • filterType=11, 2nd order high shelf with Q. It allows you to vary the gain of the high frequencies. The low frequencies have a gain of 1.0. [freq, gain, Q].

  • filterType=12, 2nd order peaking filter. It has unity gain except around the specified frequency. By varying gain, you can get a peak or a notch in the frequency band. [freq, gain, Q].

  • filterType=13, 2nd order notch filter. It has unity gain except around the specified frequency. At the specified frequency, the filter has a true notch with -inf dB gain. [freq, Q].

  • filterType=14, 2nd order bandpass filter. It has unity gain at the specified frequency and falls off in both directions. The bandwidth of the filter is determined by Q. [freq, Q].

  • filterType=15, 1st order Bessel low pass filter. [freq].

  • filterType=16, 1st order Bessel high pass filter. [freq].

  • filterType=17, 1st order asymmetrical low shelf. [freq, gain].

  • filterType=18, 1st order asymmetrical high shelf. [freq, gain].

  • filterType=19, 1st order symmetrical low shelf. [freq, gain].

  • filterType=20, 1st order symmetrical high shelf. [freq, gain].

  • filterType=21, 2nd order Butterworth low pass filter with variable Q. [freq, Q].

  • filterType=22, 2nd order Butterworth high pass filter with variable Q. [freq, Q].

  • filterType=23, 2nd order Resonant bandpass filter. [freq, Q].

  • filterType=24, raw coefficients from rawCoeffs array.

The hidden variable .bulkParamsUpdate can be used to control currentCoeffs calculation after all parameters are updated. This is useful when changing all four parameters, filterType, freq, gain and Q, simultaneously from host, to avoid intermediate coefficient transitions. Set this variable before writing filter parameters and then clear this after all filter parameters are updated.

On the ADI SHARC+ platforms, except ADSP-2157x and ADSP-2158x, the module make use of IIR Accelerators, in legacy mode, to optimize the processing time. The processing load is distributed as 1 channel processing in IIRA is equivalent to 2 channel core processing. i.e. the IIRA channels=floor(numChannels/3). As the accelerators access data by DMA, when the dm and pm caches are enabled, extra cycles are needed to maintain cache coherence. It is highly recommended to increase the allocation priority of this module instance in the signal flow to have a larger chance to allocate in the AWE fast heaps. In this way, the overhead from accelerator can be minimized. If any of this module instances allocated in the AWE slow heap, please note that the CPU load might be higher than without IIRA due to cache coherence maintenance. Maximum number of channels that can be processed in IIR Accelerator is limited to 32 and the remaining channels are processed by the core. i.e. IIRA channels=min(floor(numChannels/3), 32)

On the processors of 2159x where 8 IIR accelerators are available with dual SHARC+ cores, 4 IIR accelerators are statically reserved for each core. The processing load is distributed as IIRA channels = floorf(numChannels/3) * 2. i.e. if the numChannels are 10 then 6 channels are processed in 4 IIR accelerators in parallel with 4 channels in core processing. On SHARC+ processor, additional memory is allocated for accelerator TCB with size of numAcceleratorChannels*13. Also, a separate coefficient/state buffer is allocated as per the accelerator requirement.

As there is no processing if a biquad stage is bypassed, IIR Accelerators maybe expensive if the module is used with a majority of the biquad stages bypassed. Please use the BiquadSparseV3 module in that case.

When using Raw Coefficients, the order of coefficients in the table is:

b0, b1, b2, a1, a2

TargetCoeffs are calculated from rawCoeffs to suit the structure of the High Precision filter.

CurrentCoeffs are in the same format/order as targetCoeffs subjected to the smoothing process. After the smoothing interval, the currentCoeffs should converge towards the Target Coeffs.

Module Pack

Advanced

ClassID

classID = 1432

Type Definition

typedef struct _ModuleBiquadSparseHP
{
ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
INT32 numStages;                              // Number of cascaded stages of the second order filter.
FLOAT32 smoothingTime;                        // Time constant of the smoothing process.
INT32 updateActive;                           // Specifies whether the filter coefficients are updating (=1) or fixed (=0).
FLOAT32 smoothingCoeff;                       // Smoothing coefficient. This is computed based on the smoothingTime, sample rate, and block size of the module.
INT32 bulkParamsUpdate;                       // State variable to handle bulk changes in filter parameters.
INT32 rawCoeffsIndex;                         // Raw coefficient filter type index.
INT32* filterType;                            // Selects the type of filter that is implemented by the module: Bypass=0, Gain=1, Butter1stLPF=2, Butter2ndLPF=3, Butter1stHPF=4, Butter2ndHPF=5, Allpass1st=6, Allpass2nd=7, Shelf2ndLow=8, Shelf2ndLowQ=9, Shelf2ndHigh=10, Shelf2ndHighQ=11, PeakEQ=12, Notch=13, Bandpass=14, Bessel1stLPF=15, Bessel1stHPF=16, AsymShelf1stLow=17, AsymShelf1stHigh=18, SymShelf1stLow=19, SymShelf1stHigh=20, VariableQLPF=21, VariableQHPF=22, Resonant=23, RawCoeffs=24.
FLOAT32* freq;                                // Cutoff frequency of the filter, in Hz.
FLOAT32* gain;                                // Amount of boost or cut to apply, in dB if applicable.
FLOAT32* Q;                                   // Specifies the Q of the filter, if applicable.
FLOAT32* rawCoeffs;                           // Matrix of filter raw coefficients. The size of the matrix is 5 x numStages x numChannels. Each column contains the variables for a biquad arranged as [b0; b1; b2; a1; a2].
FLOAT32* currentCoeffs;                       // Matrix of filter current coefficients. The size of the matrix is 5 x numStages x numChannels. Each column contains the variables for a biquad arranged as [b0; b1; b2; a1; a2].
FLOAT32* targetCoeffs;                        // Matrix of filter coefficients in the High Precision format. The size of the matrix is 5 x numStages x numChannels. Each column contains the variables for a biquad arranged as [Fb; Gaa; Gab; K; Fa].
FLOAT32* state;                               // State variables. 2*numChannels per section.
INT32* bypass;                                // State buffer used internally to store coeffs bypass status.
INT32* currentBypass;                         // State buffer used internally to store coeffs bypass status.
void * hardware_specific_struct_pointer;      // This is the internal array used for ADI IIR accelerator. Size is determined internally
} ModuleBiquadSparseHPClass;

Variables

Properties

Name Type Usage isHidden Default Value Range Units
numStages int const 0 2 1:1:100
smoothingTime float parameter 0 10 0:1:1000 msec
updateActive int parameter 1 1 0:1
smoothingCoeff float derived 1 0.06449 Unrestricted
bulkParamsUpdate int state 1 0 Unrestricted
rawCoeffsIndex int state 1 24 Unrestricted
filterType int* parameter 0 [2 x 1] 0:24
freq float* parameter 0 [2 x 1] 10:0.1:23990 Hz
gain float* parameter 0 [2 x 1] -24:0.1:24 dB
Q float* parameter 0 [2 x 1] 0:0.1:20
rawCoeffs float* parameter 0 [10 x 1] Unrestricted
currentCoeffs float* state 1 [10 x 1] Unrestricted
targetCoeffs float* derived 0 [10 x 1] Unrestricted
state float* state 1 [4 x 1] Unrestricted
bypass int* state 1 [1 x 1] Unrestricted
currentBypass int* state 1 [1 x 1] Unrestricted
hardware_specific_struct_pointer void * state 1 Unrestricted

Pins

Input Pins

Name in
Description audio input
Data type float
Channel range Unrestricted
Block size range Unrestricted
Sample rate range Unrestricted
Complex support Real

Output Pins

Name out
Description audio output
Data Type float

Matlab Usage

File Name: biquad_sparseHP_module.m 
 M=biquad_sparseHP_module(NAME, NUMSTAGES, NUMCHANNELS) 
 Creates a Biquad sparse filter that implements a number of standard  
 filter types with additional option to provide raw IIR coefficients.  
 The filter operates on multiple interleaved channels, with different  
 coefficients for each channel.  

 Arguments: 
    NAME - name of the module. 
    NUMSTAGES - number of second order filter stages. 
    NUMCHANNELS - number of channels for the module. 

Copyright (c) 2026 DSP Concepts, Inc.