# iirparameq

IIR biquad digital parametric equalizer filter

`iirparameq` function will be removed in a future release. Existing code using the function continues to run. For new code, use the `designParamEQ` function from Audio Toolbox™ instead.

## Syntax

``````[SOS,SV] = iirparameq(N,G,Wo,BW)``````
``````[SOS,SV,B,A] = iirparameq(N,G,Wo,BW)``````

## Description

example

``````[SOS,SV] = iirparameq(N,G,Wo,BW)``` returns the coefficients of an `N``th` order IIR biquad digital parametric equalizer with gain `G`, center frequency `Wo`, and bandwidth `BW`. The coefficients are returned in a second-order section matrix, `SOS`, and a vector of scale values between each biquad stage, `SV`.```

example

``````[SOS,SV,B,A] = iirparameq(N,G,Wo,BW)``` additionally returns a matrix of numerator fourth-order sections, B, and a matrix `A` of denominator fourth-order sections, A. These can be used in lieu of a biquad implementation and are useful for the case `Wo = 0.5`.```

## Examples

collapse all

Compute the second-order section matrix and scale values of a parametric equalizer.

```[SOS,SV] = iirparameq(6,5,0.0042,0.0028) ```
```SOS = 1.0000 -1.9892 0.9894 1.0000 -1.9911 0.9912 1.0000 -1.9926 0.9929 1.0000 -1.9941 0.9944 1.0000 -1.9964 0.9965 1.0000 -1.9967 0.9968 SV = 1.0009 1.0000 1.0009 1.0000```

Compute the numerator and denominator coefficients of the fourth-order sections of the parametric equalizer.

```[SOS,SV,B,A] = iirparameq(6,5,0.0042,0.0028) ```
```SOS = 1.0000 -1.9892 0.9894 1.0000 -1.9911 0.9912 1.0000 -1.9926 0.9929 1.0000 -1.9941 0.9944 1.0000 -1.9964 0.9965 1.0000 -1.9967 0.9968 SV = 1.0009 1.0000 1.0009 1.0000 B = 1.0009 -1.9911 0.9903 0 0 1.0009 -3.9927 5.9729 -3.9715 0.9903 A = 1.0000 -1.9911 0.9912 0 0 1.0000 -3.9908 5.9729 -3.9733 0.9912```

Design two equalizers centered at 100 Hz and 1000 Hz respectively, both with a gain of 5 dB and a Q-factor of 1.5, for a system running at 48 kHz.

```Fs = 48e3; N = 6; G = 5; Q = 1.5; Wo1 = 100/(Fs/2); Wo2 = 1000/(Fs/2); % Obtain the bandwidth of the equalizers from the center frequencies and % Q-factors. BW1 = Wo1/Q; BW2 = Wo2/Q; % Design the equalizers and obtain their SOS and SV values. [SOS1,SV1] = iirparameq(N,G,Wo1,BW1); [SOS2,SV2] = iirparameq(N,G,Wo2,BW2);```

Design biquad filters using the obtained SOS and SV values.

```BQ1 = dsp.BiquadFilter('SOSMatrix',SOS1,'ScaleValues',SV1); BQ2 = dsp.BiquadFilter('SOSMatrix',SOS2,'ScaleValues',SV2);```

Plot the magnitude response of both filters using a log scale.

```fvtool(BQ1,BQ2,'Fs',Fs,'FrequencyScale','Log'); legend('Equalizer centered at 100 Hz','Equalizer centered at 1000 Hz');``` Design an eighth-order notch filter and compare it to a traditional second-order notch filter designed with `IIRNOTCH`.

```Fs = 44.1e3; N = 8; G = -inf; Q = 1.8; Wo = 60/(Fs/2); % Notch at 60 Hz BW = Wo/Q; % Bandwidth occurs at -3 dB for this special case [SOS1,SV1] = iirparameq(N,G,Wo,BW); [NUM,DEN] = iirnotch(Wo,BW); SOS2 = [NUM,DEN];```

Design the notch filters using the SOS and SV values.

```BQ1 = dsp.BiquadFilter('SOSMatrix',SOS1,'ScaleValues',SV1); BQ2 = dsp.BiquadFilter('SOSMatrix',SOS2);```

Plot the magnitude response of both filters. The filters intersect at -3 dB point.

```FVT = fvtool(BQ1,BQ2,'Fs',Fs,'FrequencyScale','Log'); legend(FVT,'8th order notch filter','2nd order notch filter');``` ## Input Arguments

collapse all

Order of the parametric equalizer, specified as an even positive integer.

Example: `6`

Example: `10`

Data Types: `single` | `double`

Gain of the parametric equalizer in dB, specified as a real scalar.

Example: `2`

Example: `-2.2`

Data Types: `single` | `double`

Center frequency of the parametric equalizer, specified as a real scalar in the range `[0.0 1.0]`. A value of `1.0` corresponds to π radians/sample.

Example: `0.0`

Example: `1.0`

Data Types: `single` | `double`

Bandwidth of the parametric equalizer, specified as a real scalar in the range `[0.0 1.0]`. A value of `1.0` corresponds to π radians/sample.

Example: `0.0`

Example: `1.0`

Data Types: `single` | `double`

## Output Arguments

collapse all

Second-order section matrix, returned as a real-valued `L`-by-`6` matrix, where L is the number of second-order sections of the filter.

Scale values between each biquad stage, returned as a real-valued vector of length L + 1.

Numerator coefficients of the fourth-order sections of the parametric equalizer, returned as a real-valued M-by-`5` matrix. M is the number of fourth-order sections of the filter.

Denominator coefficients of the fourth-order sections of the parametric equalizer, returned as a real-valued `M`-by-`5` matrix. M is the number of fourth-order sections of the filter.

## Algorithms

collapse all

### High-order Parametric Equalizer

Parametric equalizers are digital filters used in audio processing for adjusting the frequency content of a sound signal. Parametric equalizers provide capabilities beyond those of graphic equalizers by allowing the adjustment of gain, center frequency, and bandwidth of each filter. In contrast, graphic equalizers allow for the adjustment of the gain of each filter only. Digital parametric audio equalizers are commonly implemented as biquadratic (second-order IIR) filters. Due to low order, biquadratic filters can present relatively large ripple or transition regions. When several filters are connected in cascade, they can overlap with each other. In such circumstances, high-order filters are preferred. High-order filters provide flatter passbands, sharper band edges, and more control over the shape of each filter. In addition, if the order of the filter is set to two, the design changes to a special case: a traditional second-order parametric equalizer.

The figure shows the magnitude response of a second-order parametric equalizer compared with a high-order parametric equalizer. W0 = `0.3` × π radians/sample is the center frequency of the equalizer, BW = `0.2` radians/sample is the bandwidth of the equalizer, G = `10` is the peak gain of the equalizer, G0 = `1`, and GB = (G02 + G2) / `2`.

### Algorithm

The first step in the filter design is to design a high-order analog lowpass shelving filter that meets the specified gain and bandwidth. A high-order Butterworth filter is used for this purpose. The analog Butterworth filter is then transformed into a digital lowpass shelving filter, and finally into a peaking equalizer that is centered at the specified peak frequency.

The design specifications for the digital equalizer are the order of the equalizer, N, the gain of the equalizer, G, the center frequency of the equalizer, W0, and the bandwidth of the equalizer, BW.

The transfer function of the high-order parametric equalizer is given by:

`$H\left(z\right)={\left[\frac{{b}_{00}+{b}_{01}{z}^{-1}+{b}_{02}{z}^{-2}}{1+{a}_{01}{z}^{-1}+{a}_{02}{z}^{-2}}\right]}^{r}×\prod _{i=1}^{L}\left[\frac{{b}_{i0}+{b}_{i1}{z}^{-1}+{b}_{i2}{z}^{-2}+{b}_{i3}{z}^{-3}+{b}_{i4}{z}^{-4}}{1+{a}_{i1}{z}^{-1}+{a}_{i2}{z}^{-2}+{a}_{i3}{z}^{-3}+{a}_{i4}{z}^{-4}}\right]$`

where b00, b01, b02, a01, and a02 are coefficients of the second-order section of the equalizer. bi0, bi1, bi2, bi3, bi4, ai1, ai2, and ai3 are coefficients of the fourth-order sections of the equalizer. L = (Nr) / `2`, where r = `1` when N is odd, and r = `0` when N is even. The fourth-order sections are factored into second-order sections so that you can implement them using biquad filters.

For more information on how coefficients are computed in terms of the design specifications, see the "Butterworth Designs" section in .

 Sophocles J. Orphanidis. "High-Order Digital Parametric Equalizer Design." J. Audio Eng. Soc. Vol. 53, November 2005, pp. 1026–1046.

Watch now