Skip to main content
Skip table of contents

SofV2HpFract32

Overview

General 2nd order filter designer with smoothing

Discussion

This module implements a general purpose second order filter that is capable of realizing many different filter types. The module performs internal smoothing allowing the filters to be updated without introducing clicks. In all cases, the module implements an underlying second order filter. First order filters are realized by setting some of the second order coefficients to zero.

The behavior of the filter is controlled by the filterType parameter. filterType is an integer in the range from 0 to 14 inclusive. After specifying filterType, set you adjust the filter parameters by setting the fields .gain, .freq, and .Q. Some filter types use only a subset of these parameters and ignore the others.

The following table discusses the various filter types and which variables are active in each case. The .freq variable controls the center frequency of the filter; .gain determines the boost or cut, in dB; .Q determines how sharp the filter is. Low .Q values lead to broad filters. High .Q values lead to narrow filters.

filterType = 0, Simple pass through with unity gain.

filterType = 1, Linear gain [.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 w/Q. It allows you to vary the gain of the low frequencies. The high frequencies have a gain of 1.0. This module also has an adjustable Q parameter. [.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 w/Q. It allows you to vary the gain of the high frequencies. The low frequencies have a gain of 1.0. This module also has an adjustable Q parameter. [.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 low 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]

Type Definition

CODE
typedef struct _ModuleSofV2HpFract32
{
    ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
    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
    FLOAT32 freq;                                 // Cutoff frequency of the filter
    FLOAT32 gain;                                 // Amount of boost or cut to apply, in decibels (if applicable)
    FLOAT32 Q;                                    // Specifies the Q of the filter, if applicable
    FLOAT32 smoothingTime;                        // Time constant of the smoothing process
    INT32 updateActive;                           // Specifies whether the filter coefficients are updating (=1) or fixed (=0)
    fract32 smoothingCoeff;                       // Smoothing coefficient. This is computed based on the smoothingTime, sample rate, and block size of the module
    INT32 bShift;                                 // Number of bits to shift of Numerator coefficients
    INT32 aShift;                                 // Number of bits to shift of Denominator coefficients
    fract32* targetCoeffs;                        // Target coefficients in Fract32
    fract32* currentCoeffs;                       // Instantaneous coefficients in Fract32
    fract32* state;                               // State variables. 6 per channel.
} ModuleSofV2HpFract32Class;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

filterType

int

parameter

0

0

0:20

freq

float

parameter

0

250

10:0.1:20000

Hz

gain

float

parameter

0

0

-24:0.1:24

dB

Q

float

parameter

0

1

0:0.1:20

smoothingTime

float

parameter

0

10

0:1:1000

msec

updateActive

int

parameter

1

1

0:1

smoothingCoeff

fract32

derived

1

0.06449

Unrestricted

bShift

int

derived

1

1

Unrestricted

aShift

int

derived

1

0

Unrestricted

targetCoeffs

fract32*

derived

0

[5 x 1]

Unrestricted

currentCoeffs

fract32*

state

0

[5 x 1]

Unrestricted

state

fract32*

state

1

[6 x 1]

Unrestricted

Pins

Input Pins

Name: in

Description: audio input

Data type: fract32

Channel range: Unrestricted

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out

Description: audio output

Data type: fract32

MATLAB Usage

File Name: sof_v2hp_fract32_module.m

CODE
 M=sof_v2hp_fract32_module(NAME)
 Creates a general purpose second order filter that implements a number
 of High Precision filter types.  The filter operates on multiple interleaved
 channels, with all channels being processed by the same set of 
 coefficients.  Arguments:
    NAME - name of the module.
 The module has the following variables that control the design:
   filterType - integer specifying the type of the design (details below).
   freq - frequency argument (in Hz)
   Q - the sharpness or Q of the filter (dimensionless)
   gain - cut or boost, in dB.
 The argument filterType determines what design routine is run, and not
 all input arguments are used in all cases:
   0 = Pass through mode (gain = 1)
   1 = Scaler with level gain
   2 = 1st order Butterworth LPF.  [freq].
   3 = 2nd order Butterworth LPF.  [freq].
   4 = 1st order Butterworth HPF.  [freq].
   5 = 2nd order Butterworth HPF.  [freq].
   6 = 1st order Allpass. [freq].
   7 = 2nd order Allpass. [freq, Q].
   8 = 2nd order low shelf [freq, gain].
   9 = 2nd order low shelf [freq, gain, Q].
   10 = 2nd order high shelf [freq, gain].
   11 = 2nd order high shelf [freq, gain, Q].
   12 = 2nd order Peak EQ [freq, gain, Q].
   13 = 2nd order Notch [freq, Q].
   14 = 2nd order bandpass [freq, Q].
   15 = 1st order Bessel LPF [freq]
   16 = 1st order Bessel HPF [freq]
   17 = 1st order asymmetrical low shelf [freq, gain]
   18 = 1st order asymmetrical high shelf [freq, gain]
   19 = 1st order symmetrical low shelf [freq, gain]
   20 = 1st order symmetrical high shelf [freq, gain]

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.