# Analog Devices Wiki

This version (09 Jan 2021 00:58) was approved by Robin Getz.The Previously approved version (02 May 2019 11:49) is available.

# General Filters

1. General 2nd Order (No-Slew)
2. General 2nd Order (HW-Slew)
3. Coefficient Calculations on DSP (ADAU145X)

——————————————————————————————————

## 1.General 2nd Order

The General (2nd-Order) block gives access to a wide variety of 2nd-order (biquad)filter algorithms.The coefficient calculations happen in the controller.

• The available filter types are:
• Parametric
• Shelving
• General High-Pass
• General Low-Pass
• General Band-Pass
• General Band-Stop
• Butterworth Low-Pass / High-Pass
• Bessel Low-Pass / High-Pass
• Tone Control
• 1st-Order Low-Pass / High-Pass
• All-pass
• Peaking
• Notch
• Chebyshev Low-Pass / High-Pass

To open the filter control window, click on the icon button:

Select the desired filter type from the drop-down combo-box list. The filter controls and the icon button image will change to reflect the selected filter type.

This block's algorithms use biquad filter designs (Direct Form II) based on Robert Bristow-Johnson's work in this field.

common variables:

Note that the b0 and b2 coefficients for the high pass filter below are inverted from what is stored in RAM. The correct equations for b0, b1, and b2 for a high pass filter are as follows:
b0 = -(1 + cos(ω0)) * gainLinear / 2
b1 = -(1 + cos(ω0)) * gainLinear
b2 = -(1 + cos(ω0)) * gainLinear / 2

Note that the minus signs on b0 and b2 values are erroneous for the Butterworth HP and Bessel HP. They should not be included. See http://ez.analog.com/message/4769

For all of the above filters, the coefficients are divided by a0, normalizing them and making a0 = 1 so that only 5 coefficients must be stored. In the actual implementation on the DSP, when the coefficients are stored in parameter RAM, a1 and a2 need to be inverted. This is done automatically, in software, before the parameters are written to memory.

By default, the Q is shown with the value adjusted (from the classical EE definition) so that a boost of N dB followed by a cut of N dB for identical Q and f0/Fs results in a precisely flat unity gain filter or “wire”. This is equal to A*Q, where A = 10^(dBgain/40).

The “Classic EQ” version of Q can optionally be shown by clicking the small circular button next to the Q control.

## 2.General 2nd Order (HW-Slew)

The General (2nd-Order) filter is a variant of a second order bi-quad filter which enables a smooth transition of the filter parameters when filter parameters are changed, this is done by slewing from the current filter parameters(coefficients) to the one being set.

The slew type and slew time can be set by the user in GUI as shown below. Right click on the General 2nd Order filter module

On click on the Custom, the “Set Slew Mode” form will open as shown below

The algorithm supports three slew types

``` 1. Linear Slew
2. RC Slew
3. Exponential Slew```

This block gives access to a wide variety of 2nd-order (biquad)filter algorithms. he available filter types are:

• Parametric
• Shelving
• General High-Pass
• General Low-Pass
• General Band-Pass
• General Band-Stop
• Butterworth Low-Pass / High-Pass
• Bessel Low-Pass / High-Pass
• Tone Control
• IIR Coefficient (direct coefficient entry)
• 1st-Order Low-Pass / High-Pass
• All-pass
• Peaking
• Notch
• Chebyshev Low-Pass / High-Pass

### Shelving

GUI Control NameDefault ValueRangeFunction Description
Shelf typeLow ShelfLow Shelf/High ShelfShelving type for the filter
Frequency1000Hz0-96kHzCut off frequency of the filter
Gain0dB-15 to +15 dBdB gain of the filter coefficients
Q1.410-16Q Factor for filter calculations
Slope10-2Slope

### General

GUI Control NameDefault ValueRangeFunction Description
TypeLow Pass FilterLow Pass/High Pass/BandPass/BandStopGeneral filter type
Frequency1000Hz0-96kHz Cut off frequency of the filter
Gain0dB-15 to +15 dBdB gain of the filter coefficients
Q1.410-16Q Factor for filter calculations

### Butterworth/Bessel

GUI Control NameDefault ValueRangeFunction Description
TypeBessel Low PassBessel Low Pass/Bessel High Pass/Butterworth Low Pass/Butterworth High PassFilter type
Frequency1000Hz0-96kHzCut off frequency of the filter
Gain0dB-15 to +15 dBdB gain of the filter coefficients

### Tone Control

GUI Control NameDefault ValueRangeFunction Description
Treble Frequency1000Hz0-96kHzTreble Cut off frequency of the filter
Treble Gain0dB-15 to +15 dBTreble dB gain of the filter coefficients
Bass Frequency1000Hz0-96kHzBass Cut off frequency of the filter
Bass Gain0dB-15 to +15 dBBass dB gain of the filter coefficients

### IIR Coefficient

GUI Control NameDefault ValueRangeFunction Description
b01-100 to 100B0 coefficient for the filter
b10-100 to 100B1 coefficient for the filter
b20-100 to 100B2 coefficient for the filter
a10-100 to 100A1 coefficient for the filter
a20-100 to 100A2 coefficient for the filter

### First Order Filters

GUI Control NameDefault ValueRangeFunction Description
Filter Frequency1000Hz0-96kHzCut off frequency of the filter
Active Checked Checked/UncheckedIndicates whether the filter is active
TypeHigh for 1st filter,Low - for second filterLow/High/All passType of the filter
Gain0dB-15 to +15 dBdB gain of the filter coefficients
Q1.410-16Q Factor for filter calculations

### All Pass,Peaking,Notch

GUI Control NameDefault ValueRangeFunction Description
Frequency1000Hz0-96kHzCut off frequency of the filter
Gain0dB-15 to +15 dBdB gain of the filter coefficients
Q1.410-16Q Factor for filter calculations

### Chebyshev

GUI Control NameDefault ValueRangeFunction Description
Frequency1000Hz0-96kHzCut off frequency of the filter
Gain0dB-15 to +15 dBdB gain of the filter coefficients
Ripple0.10-10Ripple Factor for filter calculations

## DSP Parameter Information

GUI Control NameCompiler NameFunction Description
Targ_B2_EQS300MultiSpHWSlewAlg1Targ_B2_1Bi-quad filter coefficient B2 for filter 1
Targ_B1_EQS300MultiSpHWSlewAlg1Targ_B1_1Bi-quad filter coefficient B1 for filter 1
Targ_B0_EQS300MultiSpHWSlewAlg1Targ_B0_1Bi-quad filter coefficient B0 for filter 1
Targ_A2_EQS300MultiSpHWSlewAlg1Targ_A2_1Bi-quad filter coefficient A2 for filter 1
Targ_A1_EQS300MultiSpHWSlewAlg1Targ_A1_1Bi-quad filter coefficient A1 for filter 1

Here,

• Green - Algorithm Name
• Red - Instance Number (Changes for each instance)
• Blue - Parameter Name
• Brown - Stage number

## 3.Coefficient Calculations on DSP

The General (2nd-Order) block gives access to a wide variety of 2nd-order (biquad)filter algorithms.The coefficient calculations happen in the controller.

• The available filter types are:
• Parametric
• Shelving
• General High-Pass
• General Low-Pass
• General Band-Pass
• General Band-Stop
• Butterworth Low-Pass / High-Pass
• Bessel Low-Pass / High-Pass
• All-pass
• Peaking
• Notch
• Chebyshev Low-Pass / High-Pass

To open the filter control window, click on the icon button:

Select the desired filter type from the drop-down combo-box list. The filter controls and the icon button image will change to reflect the selected filter type.

### GUI Control

GUI Control NameDefault ValueRangeFunction Description
Filter Type LowpassLowPass/Highpass/BandPass/BandStopType of the filter
Frequency1000 Hz0-96000 HzThe cut off frequency of the filter
Gain0 dB -15 to 15 Filter Gain
Q Factor0 0 to 16 Q Factor of the filter
Enable1 0 t0 1 Enable or disable filter
Phase Shift0 0 to 1 Phase shift by 180 deg

### DSP parameter Information

GUI Control NameCompiler NameFunction Description
FrequencyFREQ_DSP_CALC0_ _The cut off frequency of the filter
GainGAIN_DSP_CALC0_ _Filter Gain
Q FactorQ_DSP_CALC0_ _Q Factor of the filter
Filter TypeFILTER_TYPE0_ _Type of the filter
NAINVERT__Negate the Coefficients corresponding to the input
NAONE_BY_FS_DSP_CALC0_ _1/ Sample Rate