IIR filter design equations for Sound Terminal® devices
Introduction
The purpose of this document is to provide a tool to calculate the IIR filter coefficients to
program the Sound Terminal
For each filter the procedure and the formulas to calculate the coefficient will be described;
the Matlab code is given in Appendix A: Matlab code (functions) on page 24.
A generalized set of equations can be formulated for the design of first-order low-pass and
high-pass filters and of second-order filters.
A specialized set of equations is devised for designing parametric biquad EQ filters. As with
any other filter design procedure, the desired characteristics of the filter are to be made
available.
The parameters governing the characteristics of each filter are:
■ fc: filter cutoff frequency which is the -3dB corner frequency or the midpoint frequency in
a peak or notch filter
■ fs: sampling frequency
■ Q: quality factor (not applicable for low and high-shelf filters)
■ Slope: applicable only for low and high-shelf filters
■ Gain: the boost or the attenuation at f = fc
These parameters can be used to determine the coefficients of the digital filter transfer
function.
The transfer function for a first-order filter in the digital z-domain is:
Equation 1
1
−
zbb
⋅+
)z(H
=
For a second-order filter (a biquad) the transfer function is:
Equation 2
)(
=
zH
This equation can be modified normalizing the a0 coefficient; the new equation is:
Equation 3
()() ()
)(
=
zH
() ()
1
10
1
−
zaa
⋅+
10
1
10
1
10
0100
1
01
2
−−
⋅+⋅+
zbzbb
2
2
−−
⋅+⋅+
zazaa
2
1
02
2
−−
⋅+⋅+
zabzabab
02
2
−−
⋅+⋅+
zaazaa
The most straightforward implementation form using Equation 3 is:
Equation 4
() ()()()()
]2n[yaa]1n[yaa]2n[xab]1n[xab]n[xab]n[y
−⋅−−⋅−−⋅+−⋅+⋅=
0201020100
Doc ID 022240 Rev 15/46
Filter stabilityAN3984
2 Filter stability
2.1 Definition
A filter is said to be stable in the z-domain if the roots (or poles) of the filter lie inside the unit
circle.
This definition of stability can be translated in terms of the filter coefficients.
2.2 First-order filter
For a first-order filter, the stability condition that needs to be satisfied is that the pole of the
filter lies within the unit circle.
In terms of the coefficients, the condition can be given as:
Equation 5
11<a
2.3 Second-order filter
For a 2nd-order filter, two conditions must be satisfied to ensure filter stability and translated
in terms of the filter coefficients they are:
Equation 6
a+<<
1
2
)1(
aa
21
6/46Doc ID 022240 Rev 1
AN3984First-order filter design (LPF and HPF)
3 First-order filter design (LPF and HPF)
The preliminary step to obtain the coefficients for the first-order low-pass filter or high-pass
filter is to define three constants obtained from the filter parameters:
Equation 7
ff
⋅⋅=
2
πω
K
α
()
=
ω
K
+=
1
scc
2tan
c
In a first-order filter both the coefficients a
and b2 are null.
2
The denominator coefficients are identical for both an LPF and an HPF designed for the
same cutoff frequency and they are computed as follows:
Equation 8
a
=11
0
()
K
a
1
−
−=
α
The numerator for an LPF can be calculated as follows:
Equation 9
K
b==
0
α
K
b
1
α
The numerator for an HPF can be calculated as follows:
Equation 10
1
b
0
α
1
−==b
1
α
The coefficient used in APWorkbench can be calculated by applying these formulas:
Equation 11
b
()
b
1
t Coefficien
2
t bCoefficien
=
2
a
1
t Coefficien
2
=
t aCoefficien
2
b
0
t Coefficien
2
Doc ID 022240 Rev 17/46
2
1
=
a
0
()
b
2
a
0
()
2
a
−
1
=
a
0
−
a
2
a
0
()
2
b
0
=
a
0
Second-order filter designAN3984
4 Second-order filter design
4.1 Low-pass and high-pass filters
The preliminary step to obtain the coefficients for a second-order filter is the calculation of
these coefficients obtained from the filter parameters:
Equation 12
f
c
πϑ
⋅⋅=
2
c
K
=
=
α
DE
The denominator coefficients are the same for both an LPF and an HPF if designed for the
same cutoff frequency. They are computed as follows:
f
s
ω
()
2tan
c
2
KW
K
+=
1
K
W
++=
1
Q
Equation 13
4.1.1 Low-pass filter
The numerator coefficient for a second-order LPF can be calculated as follows:
Equation 14
=
1
a
0
−
1
W
()
⋅=
2
a
1
a
2
DE
K
1
=
=
b
0
b
1
=
b
2
DE
2
DE
W
W
Q
DE
⋅=
W
DE
W
+−
8/46Doc ID 022240 Rev 1
AN3984Second-order filter design
For a second-order LPF, the coefficients given in APWorkbench can be calculated as
follows:
Equation 15
W
b
1
t Coeffi cien
=
2
DE
W
t bCoeffi cien
=
2
DE
W
1
a
1
t Coeffi cien
2
t aCoeffi cien
−=
2
b
0
t Coeffi cien
2
−
1
⋅−=
DE
K
1
W
+−
Q
DE
W
1
⋅=
DE
2
4.1.2 High-pass filter
The numerator coefficient for a second-order HPF can be calculated as follows:
Equation 16
1
b
=
0
DE
W
2
⋅−=
b
1
b
DE
1
=
2
DE
For a second-order HPF, the coefficients given in APWorkbench can be calculated as
follows:
Equation 17
b
1
t Coefficien
2
t bCoefficien
2
a
1
t Coefficien
t aCoefficien
2
b
0
t Coefficien
1
−=
DE
1
=
DE
−
W
1
⋅−=
1
2
2
DE
K
+−
1
−=
W
Q
DE
1
1
⋅=
DE
2
Doc ID 022240 Rev 19/46
Second-order filter designAN3984
4.2 Peak filters
The first step is the calculation of the constant gain obtained from the gain filter parameter
(GdB is expressed in dB).
Equation 18
The filter coefficients are different if the gain is positive or negative.
4.2.1 Peak filter - negative gain (cut)
The cut value is calculated with the following equation:
Equation 19
The filter coefficient can be calculated as follows:
Equation 20
a
0
a
1
a
2
b
0
b
1
b
2
GainGain
=
1
()
W
⋅=
4
CutValue
⎛
1
⎜
⎜
=
⎜
CutValue
⎜
⎝
⎛
⎜
1
⎜
⎝
=
CutValue
()
W
⋅=
2
CutValue
K
Q
=
CutValue
dB
Q
⎛
KCutValue+⎟
⎜
⋅+= 1
Gain
⎝
−
1
Q
+−
W
Gain
⎞
K
⎟
++
W
⎟
Q
⎠
−
1
+−
W
)1(
)115129 254.0exp(⋅=
⎞
W
⎠
⎞
⎟
⎟
⎟
⎟
⎠
10/46Doc ID 022240 Rev 1
AN3984Second-order filter design
The coefficients in the APWorkbench are consequently calculated as follows:
Equation 21
−
W
b
1
=
t Coefficien
2
=
t bCo effic ien
2
a
1
=
t Coefficien
2
−=
t aCo effic ien
2
b
0
t Coefficien
2
1
CutVa lue
K
+−
W
Q
CutValue
−
1
W
CutVa lue
Q
1
Gain
CutValue
1
1
⋅=
2
CutValue
)1(
WK
+⋅−
K
W
++
Q
4.2.2 Peak filter - positive gain (boost)
The boost value is calculated with the following equation:
Equation 22
K
BoostValue++= 1
W
Q
The filter coefficient can be calculated as follows:
Equation 23
=
a
1
0
Gain
+⋅+
=
a
1
=
a
2
b
0
b
1
=
b
2
K
BoostValue
⎛
K
⎜
1
⎜
Q
⎝
BoostValue
K
⋅=
2
BoostValue
W
⋅=
2
BoostValue
K
BoostValue
Q
+−
W
Gain
−
1
Gain
Q
W
)1(
⎞
⎟
⎟
⎠
+⋅+
W
Q
+⋅−
W
)1(
)1(
Doc ID 022240 Rev 111/46
Second-order filter designAN3984
The coefficients in the APWorkbench are consequently calculated as follows:
Equation 24
W
−
b
1
t Coefficien
=
2
=
t bCoefficien
2
a
1
t Coefficien
=
2
−=
t aCoefficien
2
BoostValue
b
0
t Coefficien
2
1
Boo stValue
Gain
Q
BoostValue
−
1
W
BoostValue
K
W
+−
1
Q
Gain
1
1
2
⋅=
BoostValue
Q
WK
+⋅−
)1(
+⋅+
WK
4.3 Shelf filters
The coefficient gain is defined in Equation 25.
Equation 25
The coefficients α and β are calculated as follows:
Equation 26
4.3.1 Low-shelf filter
The coefficients for an LSF can be calculated as follows:
Equation 27
10
Gain =
sin
α
2
αβ
2
()()
0
1
()()
2
0
1
2
⎛
()
ϑ
⎛
c
⎜
⎜
Gain
⎜
⎜
⎝
⎝
Gain
⋅⋅=
GainGaina
()()
Ga inGaina
GainGaina
()()()
()()()
()()()
Ga in
dB
(
⎛
+⋅=
⎜
⎝
)
40
11
⎞
⎛
⎞
⎟
−⋅
⎜
⎟
⎟
SGain
⎝
⎠
⎠
βϑ
+⋅−++=
cos11
c
ϑ
⋅++−⋅−=
cos112
c
βϑ
−⋅−++=
cos11
c
GainGainGai nb
Gai nGainGainb
GainGainGai nb
cos11
⋅+−−⋅⋅=
cos112
co s11
⎞
⎞
⎟
21
+
⎟
⎟
⎠
⎠
βϑ
+⋅−−+⋅=
c
ϑ
c
βϑ
−⋅−−+⋅=
c
The coefficient to load in APWorkbench can be calculated by applying the calculation
already shown in Equation 11.
12/46Doc ID 022240 Rev 1
AN3984Second-order filter design
4.3.2 High-shelf filter
The coefficients for an HSF can be calculated as follows:
Equation 28
()()
0
()()
1
()()
2
0
1
2
GainGaina
Gai nGaina
GainGaina
()()()
()()()
()()()
cos11
cos11
GainGainGai nb
Gai nGainGainb
GainGainGai nb
βϑ
+⋅−−+=
c
ϑ
⋅+−−⋅=
cos112
c
βϑ
−⋅−−+=
c
βϑ
+⋅−++⋅=
co s11
c
ϑ
⋅+−−⋅⋅−=
cos112
c
βϑ
−⋅−++⋅=
cos11
c
The coefficient to load in APWorkbench to program a HSF can be computed by applying the
formulas shown in Equation 11.
4.4 Notch filter
The first step is to define the constant α
Equation 29
(a)
:
()
ϑ
sin
α
Qc⋅=2
The coefficients for a notch filter can be calculated as follows:
Equation 30
α
1
+=
a
0
ϑ
cos2
a
a
b
b
b
⋅−=
1
1
2
1
=
0
1
1
=
2
c
α
−=
ϑ
cos2
⋅−=
The coefficients to load in APWorkbench can be calculated using Equation 11.
a. ϑc is defined in Equation 12
Doc ID 022240 Rev 113/46
Second-order filter designAN3984
4.5 All-pass filter
Equation 29 allows calculating the constant α.
The coefficients for an APF can be calculated as follows:
Equation 31
1
α
+=
a
0
cos2
ϑ
⋅−=
a
1
1
a
2
1
−=
b
0
1
+=
b
2
c
α
−=
α
cos2
ϑ
=⋅−=
ab
c
11
α
The coefficients to load in APWorkbench can be calculated using Equation 11.
4.6 Band-pass filter
Equation 29 allows calculating the constant α while Equation 32 is used to calculate the
normalized gain.
Equation 32
⎛
⎞
Ga in
dB
⎜
⎟
⎝
(b)
⎠
:
NormGain
=2010
The coefficients for a BPF can be calculated as follows
Equation 33
a
+=
α
1
0
a
a
b
⋅−=
ϑ
1
2
0
1
cos2
c
−=
α
1
NormGainb
⋅=
α
=
0
NormGainbb
⋅−=−=
α
02
The coefficients to load in APWorkbench can be calculated using Equation 11.
b. α is defined in Equation 29, ϑc is defined in Equation 12.
14/46Doc ID 022240 Rev 1
Loading...
+ 32 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.