0% found this document useful (0 votes)
33 views

Advanced Filter Design

This document is a reference manual for advanced filter design. It covers various techniques for designing linear phase FIR filters, including least squares design to approximate speech spectra and other functions. It also discusses designing FIR filters using complex approximations and window functions. Additional sections cover designing IIR filters, half-band FIR filters, filter banks, and other advanced filter design topics. The document provides detailed explanations and design examples for a wide range of digital filter design methods.

Uploaded by

BOSHI .J
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Advanced Filter Design

This document is a reference manual for advanced filter design. It covers various techniques for designing linear phase FIR filters, including least squares design to approximate speech spectra and other functions. It also discusses designing FIR filters using complex approximations and window functions. Additional sections cover designing IIR filters, half-band FIR filters, filter banks, and other advanced filter design topics. The document provides detailed explanations and design examples for a wide range of digital filter design methods.

Uploaded by

BOSHI .J
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 83

Advanced filter design

Reference manual

©2004 Anders Johansson


Contents

1 Least square design of linear phase FIR filters 3


1.1 Speech spectrum approximation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Modified speech spectrum approximation . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Differentiator approximation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Hilbert filter approximation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2 Least squares design of FIR filters using complex approximation 8


2.1 Fractional delay filter design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2 Fractional delay filter design analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Differentiator with short group-delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Fractional delay filter design analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5 Low-pass FIR filter with short group-delay . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3 Weighted minimax-design of linear phase FIR filters 15


3.1 Low-pass filter design using linear programming . . . . . . . . . . . . . . . . . . . . . . 16
3.2 High-pass filter design using linear programming . . . . . . . . . . . . . . . . . . . . . . 16
3.3 Low-pass filter design using linear programming . . . . . . . . . . . . . . . . . . . . . . 17

4 Linear FIR filter design using Remes algorithm 19


4.1 Polynomial equation solving using Remes exchange algorithm . . . . . . . . . . . . . . . 19
4.2 FIR Filter design using Remes exchange algorithm . . . . . . . . . . . . . . . . . . . . . 20
4.3 FIR Filter design using Remes exchange algorithm . . . . . . . . . . . . . . . . . . . . . 20
4.4 Low-pass FIR filter design using Remes exchange algorithm . . . . . . . . . . . . . . . . 20
4.5 High-pass FIR filter design using Remes exchange algorithm . . . . . . . . . . . . . . . . 21

5 Minimum phase optimum magnitude Chebyshev FIR filter design 25


5.1 Low-pass FIR filter design using Remes exchange algorithm . . . . . . . . . . . . . . . . 26
5.2 High-pass FIR filter design using Remes exchange algorithm . . . . . . . . . . . . . . . . 26

6 Minimax design of FIR filters using complex approximation 31


6.1 Low-pass FIR filter with short group-delay . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.2 Design of FIR equaliser for elliptic filters . . . . . . . . . . . . . . . . . . . . . . . . . . 32

7 Design of FIR filters using complex approximation and group-delay constraints 36


7.1 Low-pass least squares FIR filter with group-delay constraints . . . . . . . . . . . . . . . 38
7.2 Low-pass least squares FIR filter with group-delay constraints . . . . . . . . . . . . . . . 38
7.3 Design of FIR equaliser with group-delay constraint for elliptic filters . . . . . . . . . . . 39

8 Design of IIR filters 43


8.1 Fixed frequency response IIR filter design . . . . . . . . . . . . . . . . . . . . . . . . . . 45
8.2 Fixed length IIR filter design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
8.3 IIR filter implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
8.4 Analog filter transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
CONTENTS 2

9 Half-band FIR filters 53


9.1 Low-pass FIR filter design using Remes exchange algorithm . . . . . . . . . . . . . . . . 54

10 Design of FIR filters using optimum window design 57


10.1 Optimum window low-pass FIR filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
10.2 Minimax optimum window low-pass FIR filter . . . . . . . . . . . . . . . . . . . . . . . 58
10.3 Low-pass FIR filter design using eigen window method . . . . . . . . . . . . . . . . . . . 58
10.4 Kaiser window design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

11 Minimum phase FIR filter design by spectral factorisation 62


11.1 Low-pass FIR filter design using Remes exchange algorithm . . . . . . . . . . . . . . . . 63
11.2 High-pass FIR filter design using Remes exchange algorithm . . . . . . . . . . . . . . . . 64
11.3 High-pass FIR filter design using Remes exchange algorithm . . . . . . . . . . . . . . . . 65

12 Cepstrum minimum phase FIR-filter design 71


12.1 Low-pass FIR-filter design using complex cepstrum technique . . . . . . . . . . . . . . . 72

13 Allpass Realisation of Recursive Digital Filters 75


13.1 Design example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

14 Uniform over-sampled DFT filter-bank design and implementation 79


14.1 DFT filterbank implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
14.2 Parallel DFT filterbank implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

Reference Manual
Chapter 1

Least square design of linear phase FIR


filters

Linear phase FIR filters can be designed by minimizing the weighted least squared error between a desired
amplitude function, and the actual amplitude function for the filter. The resulting filter is denoted h, with
the amplitude function A(ω). The vector Ad denotes the desired amplitude values for the frequencies
ωk ; k = 0, 1, . . . , L − 1, stacked in into a vector according to

Ad = [Ad (ω0 ), Ad (ω1 ), . . . , Ad (ωL−1 )]T . (1.1)


2πfk
The frequency values ωk are defined according to ωk = Fs , where Fs is the sample frequency.
The filter design is performed according to

a0 = (ΦWΦT )−1 ΦWAd (1.2)

where W is a diagonal matrix with diagonal elements [v02 , v12 . . . , vL−12


] that determines the design ac-
curacy of each frequency band k. The vector Φ is a vector of base functions defined according to Φ =
[φ(ω0 ), φ(ω1 ), . . . , φ(ωL−1 )], where φ(ωk ) is defined differently dependent on filter type see table 1. The
resulting vector a0 denotes half of the filter taps in h and is defined differently depending on filter type, see
table 1. The design routine is for this type of filters called fd_ls() and is implemented in firls.c.

Type 1 Type 2
   
1 2 cos(1/2ω)
 2 cos(ω)   2 cos(3/2ω) 
φ(ω) =  .. φ(ω) =  ..
   
. .
 
   
2 cos(ωM ) 2 cos(M ω)

Type 3 Type 4
   
2 sin(ω) 2 sin(1/2ω)
 2 sin(2ω)   2 sin(3/2ω) 
φ(ω) =  .. φ(ω) =  ..
   
. .
 
   
2 sin(M ω) 2 sin(M ω)

Table 1.1: Base functions for type 1-4 filters, M = 2 .


N −1
1.1 Speech spectrum approximation 4

Type 1 Type 2
   
h(M ) h(N/2 − 1)
 h(M − 1)   h(N/2 − 2) 
a0 =  .. a0 =  ..
   
. .
 
   
h(0) h(0)

Type 3 Type 4
   
h(M ) h(N/2 − 1)
 h(M − 1)   h(N/2 − 2) 
a0 =  .. a0 =  ..
   
 
 .   . 
h(0) h(0)

Table 1.2: Relation between a0 and h for type 1-4 filters, M = 2 .


N −1

1.1 Speech spectrum approximation


Design of type 1 linear-phase FIR filter h whos amplitude function approximates that of speech. The
average spectrum of speech g is given by

g= (1.3)
[0.5, 1, 0.5, 0, −1, −3.5, −8.5, −11, −12, −14, −18,
−19.5, −22, −24, −28, −29, −30] dB

for the frequencies fk = 100 · (1.2589)k+3 Hz, k = 0, . . . , 16. The desired amplitude function is calcu-
lated according to
gk
Ad (ωk ) = 10 20 (1.4)
where gk denotes the k th element in g.
In the design a uniform weighting vector is used, and the amplitude and frequency vector is interpolated
from the 17 point exponential scale given above to a linear scale with 388 points. The implementation for
the interpolation is found in file l1.m.
The desired amplitude function and the amplitude function for h is presented in figure 1.1. See file
l1a.c for implementation.

1.2 Modified speech spectrum approximation


This design is performed using the same parameters and method as described in chapter 1.1. The difference
is that a non-uniform weighting has been used. The weighing vector is given by

 1.0 200 Hz ≤ f ≤ 2 kHz
v(f ) = 10.0 2 kHz < f ≤ 4 kHz (1.5)
1.0 4 kHz < f ≤ 8 kHz

The result from the filter design is presented in figure 1.2. The figure shows that the resulting filter has
better performance in the interval where the weighting is high. See file l1b.c for implementation.

Reference Manual
1.3 Differentiator approximation 5

10

1 Ad (ωk )
A(ωk )
A(ω)

0.1

0.01 π π 3π
0 4 2 4
π
ω

Figure 1.1: Desired and resulting amplitude functions.

1.3 Differentiator approximation


An ideal differentiator can be approximated using an FIR filter. The amplitude function for an ideal differ-
entiator is given by
Hd (ω) = jωe−jω(N −1)/2 (1.6)
Since the function has a constant 90o phase shift and A(π) 6= 0 a type 4 filter is the best choice for the
approximation.
The design is made using a 10 long filter and 100 equidistant frequency points in the interval 0 to π.
The result is seen in figure 1.3. See file l1c.c for implementation.

1.4 Hilbert filter approximation


A Hilbert filter can be approximated using an FIR filter. The transfer function for a Hilbert filter is given
by
Hd (ω) = −je−jω(N −1)/2 (1.7)
Since the function has a constant 90o phase shift and A(π) 6= 0 a type 4 filter is the best choice for the
approximation. However the filter will not be exact close to 0 since A(ω) is odd about ω = 0.
The design is made using a 20 long filter and 90 equidistant frequency points in the interval ω ∈
[0.1π, π]. The result is seen in figure 1.4. See file l1d.c for implementation.

Reference Manual
1.4 Hilbert filter approximation 6

10

1 Ad (ωk )
A(ωk )
A(ω)

0.1

0.01 π π 3π π
0 4 2 4
ω

Figure 1.2: Desired and resulting amplitude functions.

0.8

0.6
A(ω)
0.4

0.2 Ad (ωk )
A(ωk )

0 π π 3π
0 4 2 4
π
ω

Figure 1.3: Desired and resulting amplitude functions.

Reference Manual
1.4 Hilbert filter approximation 7

1.4
Ad (ωk )
1.2 A(ωk )

0.8
A(ω)
0.6

0.4

0.2

0 π π 3π
0 4 2 4
π
ω

Figure 1.4: Desired and resulting amplitude functions.

Reference Manual
Chapter 2

Least squares design of FIR filters using


complex approximation

Non linear FIR filters can be designed using least squared (LS) complex approximation. The resulting
filter h minimises the weighted least squares error between its frequency response and a desired frequency
response Hd according to
L−1 N −1 2
X X
v(ωk ) Hd (ωk ) − hn e −jnωk
. (2.1)
k=0 n=0

The vector v is a positive weight vector, that determines the design accuracy for each discrete frequency
point ωk in the interval [0, π], for k = 0, 1, . . . , L − 1.
The solution for the LS design problem can be formulated using vector notation as

h = <(ΦWΦH )−1 <(ΦWHd ) (2.2)

where W is a diagonal matrix with diagonal elements [v(ω0 )2 , . . . , v(ωL−1 )2 ]. The vector Φ is a vector of
base functions defined according to

Φ = [φ(ω1 ), φ(ω2 ), . . . , φ(ω(L−1) )], (2.3)

where φ(ωk ) = [1, e−j2πωk , . . . , e−j(N −1)2πωk ]T .


The above described design method is implemented as the function fd_cls(), in the file firls.c.

2.1 Fractional delay filter design


A fractional delay filter can be approximated using a FIR filter deigned with the specification

Hd (ωk ) = e−jωk τ for ωk ∈ [0, π], (2.4)

v(ωk ) = 1.0 ∀ k, N = 21 and L = 100.


The resulting impulse response for τ = 9.6 and τ = 10.1 is presented in figure 2.1. The frequency
response for the two filters is presented in figure 2.1. The figure shows that the filter with τ = 10.1 is closer
to the desired frequency response.
The group delay for the two filters is presented in figure 2.1. It again shows that the filter with τ = 10.1
is closer to the specification than the filter with τ = 9.6. The implementation is found in file l2a.c.

2.2 Fractional delay filter design analysis


The reason for the filter designed using τ = 10.1 being closer to its desired properties than the filter
designed using τ = 9.6 is that it approaches a linear type 1 FIR filter.
2.3 Differentiator with short group-delay 9

1.5

h[n] 0.5 τ = 9.6


τ = 10.1

−0.5
0.00 5.00 10.00 15.00 20.00
n

Figure 2.1: Impulse response for fractional delay filter.

2.3 Differentiator with short group-delay


A differentiating filter with short group-delay can be constructed using a FIR filter with the specifications

Hd (ωk ) = −jωk e−jωk τ for ωk ∈ [0, π], (2.5)

v(ωk ) = 1.0 ∀ k, N = 21 and L = 100.


The resulting impulse response for τ = 5 and τ = 5.5 is presented in figure 2.3. The frequency
response for the two filters is presented in figure 2.3. The figure shows that the filter with τ = 5.5 is closer
to the desired frequency response.
The group delay for the two filters is presented in figure 2.3. It again shows that the filter with τ = 5.5
is closer to the specification than the filter with τ = 5. The implementation is found in file l2c.c.

2.4 Fractional delay filter design analysis


The reason for the filter designed using τ = 5.5 being closer to its desired properties than the filter designed
using τ = 5 is that it approaches a linear type 4 FIR filter.

2.5 Low-pass FIR filter with short group-delay


A 21 tap low-pass FIR filter with short group delay has been designed using the above described method.
The specification is given by

for ω ∈ [0, 0.4π] 1 for ω ∈ [0, 0.4π]


 −jω 5 
e k
Hd (ω) = v(ω) = .
0 for ω ∈ [0.6π, π] 10 for ω ∈ [0.6π, π]

The resulting impulse response is presented in figure 2.5 along with the impulse response for a filter linear
filter with N = 11 designed using linear LS design. The figure shows hat the non linear filter should have
the same delay as linear filter.
The frequency response for the two filters is presented in dB scale in figure 2.5. The figure shows that
the 21 tap filter has better performance than the 11 tap filter.

Reference Manual
2.5 Low-pass FIR filter with short group-delay 10

10

|H(ω)|

0.1 τ = 9.6
τ = 10.1

0.01 π π 3π
0 4 2 4
π
ω

Figure 2.2: Frequency response for fractional delay filter.

The group delay presented in figure 2.5 shows that the two filter has the same group-delay in the
passband. The group delay is however varying for the non linear filter. The implementation is found in file
l2e.c.

Reference Manual
2.5 Low-pass FIR filter with short group-delay 11

30

25

20 τ = 9.6
τ = 10.1
− dΘ

k
15

10

0 π π 3π π
0 4 2 4
ω

Figure 2.3: Group delay for fractional delay filter.

0.4
τ = 5.0
τ = 5.5
0.2

h[n] 0

−0.2

−0.4

0.00 5.00 10.00 15.00 20.00


n

Figure 2.4: Impulse response for differentiating filter.

Reference Manual
2.5 Low-pass FIR filter with short group-delay 12

0.8

0.6
|H(ω)| τ = 5.0
τ = 5.5
0.4

0.2

0 π π 3π π
0 4 2 4
ω

Figure 2.5: Frequency response for differentiating filter.

30

20 τ = 5.0
τ = 5.5
10

− dΘ

k
0

−10

−20

−30 π π 3π
0 4 2 4
π
ω

Figure 2.6: Group delay for differentiating filter.

Reference Manual
2.5 Low-pass FIR filter with short group-delay 13

0.4
Non linear
Linear
0.2

h[n] 0

−0.2

−0.4

0.00 5.00 10.00 15.00 20.00


n

Figure 2.7: Impulse response for low-pass filter.

−10 Non linear


Linear
−20

−30
|H(ω)|
−40

−50

−60

−70 π π 3π
0 4 2 4
π
ω

Figure 2.8: Frequency response for low-pass filter.

Reference Manual
2.5 Low-pass FIR filter with short group-delay 14

12

10
Non linear
8 Linear

− dΘ

k
6

0 π π π

0 8 4 8 2
ω

Figure 2.9: Group delay for low-pass filter.

Reference Manual
Chapter 3

Weighted minimax-design of linear


phase FIR filters

Linear phase FIR filters can be designed using weighted minimax-design frequency-domain design. The
resulting filter h minimises the weighted maximum absolute error δ between its amplitude vector A and a
desired amplitude vector Ad . The amplitude vector is defined as A = aT Φ, where a and Φ are defined as
in chapter 1. The weights are defined in the vector v. The design problem is formulated as

 minimize δ, under the constarints


vk (φT (ωk )a − Ad (ωk )) − δ ≤ 0 for k = 0, 1, . . . , L − 1 . (3.1)


−vk (φT (ωk )a − Ad (ωk )) − δ ≤ 0 for k = 0, 1, . . . , L − 1

The filter design can be performed using linear programming. A linear program description is given by

minimizef T x, under the constarints



, (3.2)
Bx ≤ b

where the minimisation is performed over the vector x.


By rewriting the problem formulation given in equation 3.1 into the form given by equation 3.2 we get
   
a0 0
 a1  0 
x =  ...  f =  ... 
   
   
   
aL−1  0 
δ 1

v0 φT (ω0 )
   
−1 v0 Ad (ω0 )
 v1 φT (ω1 )
−1  v1 Ad (ω1 )  (3.3)
.. ..  ..
   
. .  .
  
  
 vL−1 φT (ωL−1 ) −1
   
 vL−1 Ad (ωL−1 ) 
B= 
 −v0 φT (ω0 )
 b=  
 −1 
 −v0 Ad (ω0 ) 
 
 −v1 φT (ω1 ) −1  −v1 Ad (ω1 ) 
.. ..  ..
   
  
 . .   . 
−vL−1 φT (ωL−1 ) −1 −vL−1 Ad (ωL−1 )

The design routine is for this type of filters called fd_minimax() and is implemented in firminimax.c.
The implementation of is made using the software package lp-solve. The internal function used by
lp-solve is simplex.
3.1 Low-pass filter design using linear programming 16

3.1 Low-pass filter design using linear programming


A linear FIR filter type 1 with 21 taps has been designed using the method outlined above. The specification
for the filter is given by

1 for ω ∈ [0, 0.4π] for ω ∈ [0, 0.4π]


 
1
Ad (ω) = v(ω) = .
0 for ω ∈ [0.6π, π] 100 for ω ∈ [0.6π, π]

The implementation is found in the file l3a.c. The amplitude function for the resulting filter is presented
in figure 3.1, along with the amplitude function for a filter designed using the least squares method from
chapter 1. The figure shows that the least squares design gives higher stop-band attenuation for this specific
problem, and can therefore be regarded as somewhat better. The maximum norm for the least squares and
the minimax solutions are 0.195 and 0.088 respectively, which confirms that the least squares design is
superior.

1 Least squares
Minimax

0.1

0.01
A(ω)

0.001

0.0001

1e − 05 π π 3π
0 4 2 4
π
ω

Figure 3.1: Design using least squares and linear programming.

3.2 High-pass filter design using linear programming


A linear FIR filter type 1 with 21 taps has been designed using the method outlined above. The specification
for the filter is given by

0 for ω ∈ [0, 0.4π] for ω ∈ [0, 0.4π]


 
1
Ad (ω) = v(ω) = .
1 for ω ∈ [0.6π, π] 100 for ω ∈ [0.6π, π]

The implementation is found in the file l3b.c. The amplitude function for the resulting filter is presented
in figure 3.2, along with the amplitude function for a filter designed using the least squares approach from
chapter 1. The figure shows that the least squares design gives higher stop-band attenuation for this specific
problem, and can therefore be regarded as somewhat better. The maximum norm for the least-squares and
the minimax solutions are 0.195 and 0.088 respectively, which confirms that the least squares design is
superior.

Reference Manual
3.3 Low-pass filter design using linear programming 17

0.1 Least squares


Minimax

0.01
A(ω)

0.001

0.0001

1e − 05 π π 3π
0 4 2 4
π
ω

Figure 3.2: Design using least squares and linear programming.

3.3 Low-pass filter design using linear programming


A linear FIR filter type 1 with 21 taps has been designed using the method outlined above. The specification
for the filter is given by 
0 for 0 ≤ ω < 0.4π
Ad (ω) = , (3.4)
1 for ωs ≤ ω ≤ π
with a pass-band ripple of 0.1 and a stop-band attenuation of 50dB.
A stop-band attenuation of 50 dB gives a maximum amplitude function value of
50
A = 10 10 = 1.0e − 5. (3.5)

The given specification is accomplished when the stop-band cutoff frequency is ω s = 0.67π and the
weights vector is given by

1.0 for 0 ≤ ω < 0.4π
v(ω) = . (3.6)
10000.0 for ωs ≤ ω ≤ π

The implementation is found in the file l3c.c. The amplitude function for the resulting filter is presented
in figure 3.3. The upper plot shows the amplitude function of the passband section in linear scale. The
lower plot shows the whole amplitude function plotted in log scale.

Reference Manual
3.3 Low-pass filter design using linear programming 18

1.2

1.15

1.1

1.05

A(ω) 1

0.95

0.9

0.85

0.8 π π
0 4 2
ω

0.1

0.01

A(ω) 0.001

0.0001

1e − 05

1e − 06 π π 3π
0 4 2 4
π
ω

Figure 3.3: Design of low-pas filter using linear programming.

Reference Manual
Chapter 4

Linear FIR filter design using Remes


algorithm

Linear phase FIR filters can be designed using the Remes exchange algorithm. This chapter uses Remes
exchange algorithm to solve various filter design problems. The sections below shows the steps in the
execution of the algorithm.

4.1 Polynomial equation solving using Remes exchange algorithm


The third order polynomial Ad (ω) = 1 + 2ω + 3ω 2 has been solved using the second order polynomial
A(ω) = a0 + a1 ω + a2 ω 2 on the interval ω ∈ [−1, 1], using the initial set T = {−0.8, −0.2, 0.2, 0.8}. The
first iteration gives T = {−1, −0.3, 0.3, 1} second iteration gives the optimum solution T = {−1, −0.5, 0.5, 1}.
The error curve E(ω) as a function of ω for the three iterations is shown in figure 4.1, along with the op-
timum solution. The resulting amplitude function along with the desired amplitude function is shown in
figure 4.1. The implementation is found in file l4a.m

2 Initial set +
First itteration ×
Second itteration 3 +
×3
×3 ×× Optimum solution
1 ×3 33 +
× 3 ×
3 + + ×
3 3
× + ++3 × + ×
3 ++ +3×
× +× + 3
E(ω) 0 3 + +
3 ×
+
×
3 + +
× + ×++
3 + 3
×
3 × ++++
3 3
+ 3
× 3 ×
× 3
-1 3 ×3×3
×3 ××
×3
+

-2 +

-1 -0.5 0 0.5 1
ω

Figure 4.1: Error versus frequency for different design sets.


4.2 FIR Filter design using Remes exchange algorithm 20

10

A(ω) 4

2 Ad (ω)
A(ω)

-2
-1 -0.5 0 0.5 1
ω

Figure 4.2: Desired and resulting amplitude functions.

4.2 FIR Filter design using Remes exchange algorithm


A type 1, length N = 5 FIR filter with the desired amplitude function Ad (ω) = (ω − π/2)2 has
been designed by manually executing the the Remes exchange algorithm. A five tap FIR filter has the
amplitude function A(ω) = a0 + a1 cos(ω) + a2 cos(2ω). The filter is designed using the initial set
T = {0, 0.3π, 0.5π, 0.9π}. The first iteration gives T = {0, 0.15π, 0.5π, 0.8π} second iteration gives the
optimum solution T = {0, π/4, pi/2, 3π/4}. The error curve E(ω) as a function of ω for the three itera-
tions is shown in figure 4.2. The resulting amplitude function along with the desired amplitude function is
shown in figure 4.2. The implementation is found in file l4b.m

4.3 FIR Filter design using Remes exchange algorithm


A type 1, length N = 7 FIR filter with the desired amplitude function

ω for 0 ≤ ω < π/2
Ad (ω) = , (4.1)
π − ω for π/2 ≤ ω ≤ π

has been designed by manually executing the the Remes exchange algorithm. A seven tap FIR filter has
the amplitude function A(ω) = a0 + a1 cos(ω) + a2 cos(2ω) + a3 cos(3ω). The filter is designed using the
initial set T = {0.1, 0.7, 1.5, 2.3, 3}. The first iteration gives T = {0.5, 1.2, 1.7, 2, 2.7} second iteration
gives the optimum solution T = {π/6, π/3, π/2, 2π/3, 5π/6}. The error curve E(ω) as a function of
ω for the three iterations is shown in figure 4.3. The resulting amplitude function along with the desired
amplitude function is shown in figure 4.3. The implementation is found in file l4c.m

4.4 Low-pass FIR filter design using Remes exchange algorithm


A 21 tap type 1 low-pass FIR filter has been designed using the Remes algorithm. The desired amplitude
function is given by

1 for ω ∈ [0, 0.4π] for ω ∈ [0, 0.4π]


 
1
Ad (ω) = v(ω) = 1 .
0 for ω ∈ [0.6π, π] 100 for ω ∈ [0.6π, π]

Reference Manual
4.5 High-pass FIR filter design using Remes exchange algorithm 21

1
Initial set +
First itteration ×
Second itteration 3
0.5
× × ×
× +
3 + 3 +
+ × 3 3 ×
+
3 3
× + +
×
E(ω) 0 3 3 +
× × + + ×
3 3 ×
3 3
+ × + + +
× × + + ×
3 × × 3
+
3
× × 3
+ 3 3 3 3
-0.5 + +

-1 π π 3π
0 4 2 4
π
ω

Figure 4.3: Error versus frequency for different design sets.

The resulting amplitude function is presented in figure 4.4 along with the amplitude function obtained in
chapter 3.1. The two designs are nearly identical. The execution times on this specific implementation for
the the Remes and the simplex algorithms is 1.13ms and 18.1ms respectively. The implementation is found
in file l4d.c. The design routine is called fir_remez() and is implemented in firremez.c.

4.5 High-pass FIR filter design using Remes exchange algorithm


A 21 tap type 1 high-pass FIR filter has been designed using the Remes algorithm. The desired amplitude
function is given by

0 for ω ∈ [0, 0.4π] for ω ∈ [0, 0.4π]


 
1
Ad (ω) = v(ω) = .
1 for ω ∈ [0.6π, π] 100 for ω ∈ [0.6π, π]

The resulting amplitude function is presented in figure 4.5 along with the amplitude function obtained in
chapter 3.2. The implementation is found in file l4e.c. The design routine is called fir_remez() and
is implemented in firremez.c.

Reference Manual
4.5 High-pass FIR filter design using Remes exchange algorithm 22

3
Ad (ω)
A(ω)
2.5

1.5
A(ω)
1

0.5

-0.5 π π 3π π
0 4 2 4
ω

Figure 4.4: Desired and resulting amplitude functions.

0.2
Initial set +
0.15 First itteration ×
× Second itteration 3
0.1 33 × +3+3
+ ++3
3
+
3
+
3 3
0.05 + ××+
3 3
+ × + × ×
×3 3 × +
× × × 3 × ×
+3 + + 3
E(ω) 0 3 + × × ×
3 ×+
× × × +
3 +
×
+3 3 ×
× × × × ×3
+
-0.05 ×× + ×3
× +3 3
+ 3
+ +3
+
3 3 + +
333
-0.1 + 33+
+ + ×
-0.15 × +

-0.2 π π 3π
0 4 2 4
π
ω

Figure 4.5: Error versus frequency for different design sets.

Reference Manual
4.5 High-pass FIR filter design using Remes exchange algorithm 23

2
Ad (ω)
A(ω)

1.5

A(ω) 1

0.5

0 π π 3π π
0 4 2 4
ω

Figure 4.6: Desired and resulting amplitude functions.

1 Remes
Minimax

0.1

0.01
A(ω)

0.001

0.0001

1e − 05 π π 3π
0 4 2 4
π
ω

Figure 4.7: Amplitude function for low-pass filter.

Reference Manual
4.5 High-pass FIR filter design using Remes exchange algorithm 24

0.1 Remes
Minimax

0.01
A(ω)

0.001

0.0001

1e − 05 π π 3π
0 4 2 4
π
ω

Figure 4.8: Amplitude function for high-pass filter.

Reference Manual
Chapter 5

Minimum phase optimum magnitude


Chebyshev FIR filter design

Minimum phase optimum magnitude FIR filters can be deigned by combing Remes algorithm and polyno-
mial factorisation. The obtained filter H1 (ω) is optimum in the sense that the difference
max v(ω)|Ad (ω) − |H1 (ω)|2 |. (5.1)
ω∈F

is minimised. Here F is a set of band edges in the interval [0, π], and
 
1 + δ2 for ω ∈ Fp 1 for ω ∈ Fp
Ad (ω) = v(ω) = (5.2)
δ2 for ω ∈ Fs K for ω ∈ Fs
where δ2 is the stop-band deviation, K = δ1 /δ2 and Fp ∪ Fs = F. The optimum filter H1 (ω) will have
the passband deviation δ1 , and the stop-band deviation δ2 . An N long filter h1 (n) is designed using the
following three steps
1. Linear phase design Design a 2N − 1 long type 1 linear FIR filter h(n) with the specifications,
using Remes exchange algorithm.
 
1 for ω ∈ Fp 1 for ω ∈ Fp
A(ω) = v(ω) = (5.3)
0 for ω ∈ Fs K for ω ∈ Fs

2. Scale filter Form the filter h0 (n) according to



h(N − 1) + δ2 for n=N =1
h(n) = (5.4)
h(n) otherwise

3. Factorisation Form H 0 (z) by factorising h0 (n) using numerical root finding


s
h0 (0)
0
H (z) = (1 − z −1
z1 )(z1∗ −z −1
) · · · (1 − z −1 ∗
zN −1 )(zN −1 −z −1
) QN −1 ∗ (5.5)
i=1 zi

where z1 , . . . , zN are the zeros of H 0 (z) are the zeros inside or on the unit circle. The filter H1 (z) is
formed according to
s
|h0 (0)|
−1 −1
H1 (z) = (1 − z z1 ) · · · (1 − z zN −1 ) QN −1 . (5.6)
i=1 |zi |

The obtained filter H1 (z) will have minimum phase. The filter-taps h1 (n) are formed by evaluating
the polynomial z1 , . . . , zN .
The above described design method is called fd_minphase(), and is implemented in firminphase.c.
In the design the factor δ2 is found by searching for the maximum deviation in the stop-band of the filter.
The roots are found using numerical root solving followed by sorting with regards to the magnitude of the
obtained roots.
5.1 Low-pass FIR filter design using Remes exchange algorithm 26

5.1 Low-pass FIR filter design using Remes exchange algorithm


A 21 tap type 1 low-pass FIR filter has been designed using the above described method. The specification
is given by
1 for ω ∈ [0, 0.4π] 1 for ω ∈ [0, 0.4π]
 
Ad (ω) = v(ω) = .
0 for ω ∈ [0.6π, π] 20 for ω ∈ [0.6π, π]

The zeros for the intermediate filter H 0 (z) is presented in figure 5.1. The resulting impulse response is
presented in figure 5.1 along with the impulse response for a filter with the same passband suppression
designed using the Remes algorithm. The figure shows hat the minimum-phase filter should have much
lower delay than the filter designed using the Remes algorithm.
The frequency response for the two filters is presented in dB scale in figure 5.1.The figure shows that
the passband deviation for the min-phase filter is smaller than for the Remes filter.
The group delay presented in figure 5.1 shows that the Remes algorithm results in a filter with linear
phase response while the minimum-phase filter has lower but non linear phase response.
The implementation is found in file l5a.c and l5.m.

1.5
?
?
1
? ?
? ?
?
0.5 ?? ?
?? ? ?
?
0 ?? ? ?
?
?? ? ?
-0.5 ?? ?
? ?
?
? ?
-1
?
?
-1.5
-1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

Figure 5.1: Root locations for low-pass filter.

5.2 High-pass FIR filter design using Remes exchange algorithm


A 21 tap type 1 high-pass FIR filter has been designed using the above described method. The specification
is given by
0 for ω ∈ [0, 0.4π] 20 for ω ∈ [0, 0.4π]
 
Ad (ω) = v(ω) = .
1 for ω ∈ [0.6π, π] 1 for ω ∈ [0.6π, π]

The zeros for the intermediate filter H 0 (z) is presented in figure 5.2. The resulting impulse response is
presented in figure 5.2 along with the impulse response for a filter with the same passband suppression
designed using the Remes algorithm. The figure shows hat the minimum-phase filter should have much
lower delay than the filter designed using the Remes algorithm.
The frequency response for the two filters is presented in dB scale in figure 5.2.The figure shows that
the passband deviation for the min-phase filter is smaller than for the Remes filter.

Reference Manual
5.2 High-pass FIR filter design using Remes exchange algorithm 27

0.5

0.4 Min-phase
Remes
0.3

0.2
h[n]
0.1

−0.1

−0.2
0.00 5.00 10.00 15.00 20.00
n

Figure 5.2: Impulse response for low-pass filter.

The group delay presented in figure 5.2 shows that the Remes algorithm results in a filter with linear
phase response while the minimum-phase filter has lower but non linear phase response.
The implementation is found in file l5b.c and l5.m.

Reference Manual
5.2 High-pass FIR filter design using Remes exchange algorithm 28

−10 Min-phase
Remes
−20

|H(ω)| −30

−40

−50

−60 π π 3π π
0 4 2 4
ω

Figure 5.3: Frequency response for low-pass filter.

20

15

10

− dΘ

k
0

−5 Min-phase
Remes
−10

−15

−20 π π π

0 8 4 8 2
ω

Figure 5.4: Group delay for low-pass filter.

Reference Manual
5.2 High-pass FIR filter design using Remes exchange algorithm 29

1.5
?
?
1 ? ?
? ?
?
0.5 ? ?
? ? ?
?
0 ? ? ?
?
? ? ?
-0.5 ? ?
? ?
?
-1 ? ?
?
?
-1.5
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5

Figure 5.5: Root locations for high-pass filter.

0.6
0.5
0.4 Min-phase
Remes
0.3
0.2
h[n] 0.1
0
−0.1
−0.2
−0.3
−0.4
0.00 5.00 10.00 15.00 20.00
n

Figure 5.6: Impulse response for high-pass filter.

Reference Manual
5.2 High-pass FIR filter design using Remes exchange algorithm 30

−10 Min-phase
Remes
−20

|H(ω)| −30

−40

−50

−60 π π 3π π
0 4 2 4
ω

Figure 5.7: Frequency response for high-pass filter.

20

15

10

− dΘ

k
0

−5 Min-phase
Remes
−10

−15

−20 π
5π 3π 7π
2 8 4 8
π
ω

Figure 5.8: Group delay for high-pass filter.

Reference Manual
Chapter 6

Minimax design of FIR filters using


complex approximation

Non linear FIR filters can be designed using minimax complex approximation. The resulting filter h
minimises the weighted minimax error between its frequency response and a desired frequency response
Hd according to
min max vk |H(ωk ) − Hd (ωk )|, (6.1)
h∈RN k∈[0,1,...,L−1]

where v(ω) is a complex weighting vector and


N
X −1
H(ω) = h(n)ejωn (6.2)
n=0

Minimax complex approximation


Using real rotation theorem the unit circle is approximated using and octagon and equation 6.1 is rewritten
into the linear programming problem
min δ, subject to


vk <{φ(ωk )}h − δ ≤ vk <{Hd (ωk )} k ∈ [0, 1, . . . , L − 1]




jπ/4 jπ/4



 v k <{φ(ω k )e }h − δ ≤ v k <{H (ω
d k )e } k ∈ [0, 1, . . . , L − 1]
jπ/2 jπ/2


 k
 v <{φ(ω k )e }h − δ ≤ v k <{H (ω
d k )e } k ∈ [0, 1, . . . , L − 1]
vk <{φ(ωk )ej3π/4 }h − δ ≤ vk <{Hd (ωk )ej3π/4 } k ∈ [0, 1, . . . , L − 1] (6.3)
jπ jπ
v <{φ(ω )e }h − δ ≤ v <{H (ω )e } k ∈ [0, 1, . . . , L − 1]

 k

 k k d k
 vk <{φ(ωk )ej5π/4 }h − δ ≤ vk <{Hd (ωk )ej5π/4 } k ∈ [0, 1, . . . , L − 1]



 vk <{φ(ωk )ej3π/2 }h − δ ≤ vk <{Hd (ωk )ej3π/2 } k ∈ [0, 1, . . . , L − 1]



vk <{φ(ωk )ej7π/4 }h − δ ≤ vk <{Hd (ωk )ej7π/4 } k ∈ [0, 1, . . . , L − 1]

where δ is the minimax error and φ(ω) = [1, ejω , . . . , ejωN −1 ]. The design method is implemented as the
function fd_firminimax() and is found in firminimax.c. The linear program is solved using the
simplex algorithm.

Phase equaliser design using minimax complex approximation


The theory described above can be extended to a method for designing phase equalisers for filters with an
arbitrary frequency response G(ω). The resulting method can be formulated as the linear programming
problem

 min δ, subject to

v(ω)<{G(ω)φ(ω)ejθ }h − δ ≤ v(ω)<{Hd (ω)ejθ } ω ∈ Fp , θ ∈ [0, π4 , . . . , 7π 4 ] , (6.4)


v(ω)<{φ(ω)ejϕ }h − δ ≤ σ(ω) ω ∈ Fs , ϕ ∈ [0, π4 , . . . , 7π ]

4
6.1 Low-pass FIR filter with short group-delay 32

where σ(ω) is the stop-band limit, and Fp defines the pass-band and Fs the stop-band. This design method
is implemented as the function fd_cminimaxeq() in the file fireq.c.

6.1 Low-pass FIR filter with short group-delay


A 21 tap type 1 low-pass FIR filter with short group delay has been designed using the above described
method. The specification is given by
for ω ∈ [0, 0.4π] 1 for ω ∈ [0, 0.4π]
 −jω 5 
e k
Hd (ω) = v(ω) = .
0 for ω ∈ [0.6π, π] 10 for ω ∈ [0.6π, π]
The frequency response for the filter is presented in figure 6.1 along with the frequency response of a filter
designed using least squares design, and the same specifications. The figure shows that the least squares
filter has higher stop-band attenuation than the minimax filter.
The absolute weighted minimax error w(ω)|H(ω) − Hd (ω)| is presented for the two filters in dB scale
in figure 6.1. The figure shows that the least squares filter has better performance both in the stop-band and
in the pass-band than the minimax filter.
The group delay presented in figure 6.1 shows that the two filter has the same group-delay in the
passband.
The implementation is found in file l6a.c.

−10 Minimax
Least squares
−20

−30
|H(ω)|
−40

−50

−60

−70 π π 3π
0 4 2 4
π
ω

Figure 6.1: Frequency response for low-pass filter.

6.2 Design of FIR equaliser for elliptic filters


A 31 tap FIR phase equaliser for the 4 tap elliptic filter with the stop-band attenuation 34 dB, pass-band
ripple 0.5 and cutoff frequency 0.5 has been designed using the above described method. The specification
is given by Hd (ω) = e−jω13 , thus the overall filter should have a delay of 13 samples.
The frequency response for the original and equalised filter is shown in figure 6.2, for σ(ω) = 0dB.
The figure shows that the phase equaliser has little effect on the frequency response for the filter.
The frequency response for the equaliser is presented in figure 6.2 for two different values of σ(ω). The
figure shows that the equaliser can be made to increase or decrease the stop-band attenuation of the overall
filter, by varying σ(ω).

Reference Manual
6.2 Design of FIR equaliser for elliptic filters 33

2.5 Minimax
Least squares
2

1.5
v(ω)|H(ω) − Hd (ω)|

0.5

−0.5 π π 3π
0 4 2 4
π
ω

Figure 6.2: Absolute design error for low-pass filter.

The group-delay for the overall filter along with the group-delay for the elliptic filter is presented in
figure 6.2 for different values of σ(ω). The figure shows that the group-delay for the overall filter is 13
samples in the passband as desired in the specification.

Reference Manual
6.2 Design of FIR equaliser for elliptic filters 34

12

10
Minimax
Least squares
8

− dΘ

k
6

0 π π π

0 8 4 8 2
ω

Figure 6.3: Group delay for low-pass filter.

10

0 |G(ω)|
|G(ω)H(ω)|
−10

−20

|F (ω)| −30

−40

−50

−60

−70 π π 3π
0 4 2 4
π
ω

Figure 6.4: Frequency response for over all system.

Reference Manual
6.2 Design of FIR equaliser for elliptic filters 35

25
20 20 log σ = +10 dB
20 log σ = −10 dB
15
10
5
|H(ω)| 0
−5
−10
−15
−20
−25 π π 3π π
0 4 2 4
ω

Figure 6.5: Frequency response for phase equaliser.

20

15

− dΘ

k
10
G(ω)
G(ω)H(ω), 20 log σ = +10
G(ω)H(ω), 20 log σ = −10
5

0 π π π

0 8 4 8 2
ω

Figure 6.6: Group delay for over all system.

Reference Manual
Chapter 7

Design of FIR filters using complex


approximation and group-delay
constraints

Group-delay constraints can be added to FIR filter design using minimax and least squares complex ap-
proximation by introducing a limit to the group-delay error e(ω) in the design procedure. The group-delay
error is given by
e(ω) = τ (ω) − τd (ω) ≈ ψ T (ω)h (7.1)
where τ and τd are the actual and desired group-delay, and ψ(ω) is given by
 
(0 − τd (ω))cos(ω(0 − τd ))
1   (1 − τd (ω))cos(ω(1 − τd )) 
ψ(ω) = .. (7.2)

Ad (ω)  .
 

(N − 1 − τd (ω))cos(ω(N − 1 − τd ))

where Ad (ω) is the desired amplitude function for the filter and N is the length of the filter. The constraint
is introduced as an additional linear constraint in minimax design and as a part of the equation system in
least squares complex approximation.

Least squares complex approximation with group-delay constraints


Non linear FIR filters can be designed using least squares complex approximation. The resulting filter h
minimises the weighted least squares error between its frequency response and a desired frequency response
Hd according to
L−1 N −1 2
X X
vk Hd (ωk ) − h(n)e −jnωk
. (7.3)
k=0 n=0

The vector v = is a positive weight vector, that determines the design accuracy for each
[v02 , v12 , . . . , vL−1
2
]
discrete frequency ωk ∈ [0, π], k = 0, 1, . . . , L − 1.
The group-delay constraint is added to the solution of the above problem as an quadratic term. The
solution is formulated using vector notation as
h = (<(ΦWΦH ) + ΨUΨT )−1 <(ΦWHd ) (7.4)
where W and U are diagonal matrices with diagonal elements v and u respectively. The vector u =
[u20 , u21 , . . . , u2L−1 ] are weights that constrain the group-delay, and Ψ = [ψ(ω0 ), ψ(ω1 ), . . . , ψ(ωL−1 )].
The vector Φ is a vector of base functions defined according to
Φ = [φ(ω1 ), φ(ω2 ), . . . , φ(ω(L−1) )], (7.5)
37

where φ(ωk ) = [1, e−j2πωk , . . . , e−j(N −1)2πωk ]T . The design method is implemented as the function
fd_clsgd() and is found in firls.c.

Minimax complex approximation with group-delay constraints


Non linear FIR filters can be designed using minimax complex approximation. The resulting filter h
minimises the weighted minimax error between its frequency response and a desired frequency response
Hd according to
min max vk |H(ωk ) − Hd (ωk )|, (7.6)
h∈RN k∈[0,1,...,L−1]

where v(ω) is a complex weighting vector and


N
X −1
H(ω) = h[n]ejωn (7.7)
n=0

Using real rotation theorem the unit circle is approximated using and octagon and equation 7.6 can be
rewritten into a linear programming problem, where the group-delay constraint is added as an additional
linear constraint. The problem is defined as

min δ, subject to


v <{φ(ωk )}h − δ ≤ vk <{Hd (ωk )} k ∈ [0, 1, . . . , L − 1]


 k


jπ/4 jπ/4


 v k <{φ(ω k )e }h − δ ≤ v k <{H (ω
d k )e } k ∈ [0, 1, . . . , L − 1]
jπ/2 jπ/2



 vk <{φ(ωk )e }h − δ ≤ vk <{Hd (ωk )e } k ∈ [0, 1, . . . , L − 1]
 vk <{φ(ωk )ej3π/4 }h − δ ≤ vk <{Hd (ωk )ej3π/4 } k ∈ [0, 1, . . . , L − 1]



vk <{φ(ωk )ejπ }h − δ ≤ vk <{Hd (ωk )ejπ } k ∈ [0, 1, . . . , L − 1] (7.8)
j5π/4 j5π/4
v <{φ(ω )e }h − δ ≤ v <{H (ω )e } k ∈ [0, 1, . . . , L − 1]

k k k d k



vk <{φ(ωk )ej3π/2 }h − δ ≤ vk <{Hd (ωk )ej3π/2 } k ∈ [0, 1, . . . , L − 1]




j7π/4
 vk <{φ(ωk )e }h − δ ≤ vk <{Hd (ωk )ej7π/4 } k ∈ [0, 1, . . . , L − 1]



T
 ψ(ωk ) h ≤ τd (ωk ) k ∈ [0, 1, . . . , L − 1]



−ψ(ωk )T h ≤ τd (ωk ) k ∈ [0, 1, . . . , L − 1]

where δ is the minimax error and φ(ω) = [1, ejω , . . . , ejωN −1 ]. The problem is solved using linear pro-
gramming. The design method is implemented as the function fd_cminimaxgd() and is found in
firminimax.c. The linear problem is solved using the simplex algorithm.

Phase equaliser design using minimax complex approximation with group-delay constraints
The theory described above can be extended to a method for designing phase equalisers for systems with
an arbitrary frequency response G(ω). The resulting method can be formulated as the linear programming
problem

min δ, subject to


ω ∈ Fs , ϕ ∈ [0, π4 , . . . , 7π

 v(ω)<{φ(ω)ejϕ }h − δ ≤ σ(ω) 4 ]


v(ω)<{G(ω)φ(ω)e }h − δ ≤ v(ω)<{Hd (ω)e } ω ∈ Fp , θ ∈ [0, π4 , . . . , 7π 4 ] , (7.9)
jθ jθ
T
q (ω)h ≤ τ (ω) ω ∈ F

d p



−qT (ω)h ≤ τd (ω) ω ∈ Fp

where σ(ω) is the stop-band limit, and Fp defines the pass-band and Fs the stop-band. The elements qn (ω)
of q(ω) are given by

qn (ω) = (n − τd (ω) − τG (ω)) cos(ω(n − τd (ω)) − θG (ω)) (7.10)

where τG (ω) is the group-delay and θG (ω) the phase-response of G(ω).


This design method is implemented as the function fd_cminimaxeqgd() in the file fireq.c.

Reference Manual
7.1 Low-pass least squares FIR filter with group-delay constraints 38

7.1 Low-pass least squares FIR filter with group-delay constraints


A 21 tap low-pass FIR filter with short group-delay has been designed using least squares complex approx-
imation with and without group-delay constraints. The specification for the filter is given by

for ω ∈ [0, 0.4π] 1 for ω ∈ [0, 0.4π]


 −jω 5 
e k
Hd (ω) = v(ω) = .
0 for ω ∈ [0.6π, π] 10 for ω ∈ [0.6π, π]

The frequency response for the filters is presented in figure 7.1. The figure shows that the regular least
squares filter has higher stop-band attenuation and lower passband deviation than the filter with group-
delay constraints.
The group delay presented in figure 7.1 shows that the the filter designed with group-delay constraints
has lower group-delay deviation in the passband than the filter designed using ordinary least squares com-
plex approximation.
The implementation is found in file l7a.c.

−10 Constarined least squares


Least squares
−20

−30
|H(ω)|
−40

−50

−60

−70 π π 3π
0 4 2 4
π
ω

Figure 7.1: Frequency response for low-pass filter.

7.2 Low-pass least squares FIR filter with group-delay constraints


A 21 tap low-pass FIR filter with short group-delay has been designed using minimax complex approxima-
tion with and without group-delay constraints. The specification for the filter is given by

for ω ∈ [0, 0.4π] 1 for ω ∈ [0, 0.4π]


 −jω 5 
e k
Hd (ω) = v(ω) = .
0 for ω ∈ [0.6π, π] 10 for ω ∈ [0.6π, π]

The frequency response for the filters is presented in figure 7.2. The figure shows that the regular mini-
max filter has higher stop-band attenuation and lower passband deviation than the filter with group-delay
constraints.
The group delay presented in figure 7.2 shows that the the filter designed with group-delay constraints
has lower group-delay deviation in the passband than the filter designed using ordinary minimax complex
approximation.
The implementation is found in file l7a.c.

Reference Manual
7.3 Design of FIR equaliser with group-delay constraint for elliptic filters 39

10

9 Constarined least squares


Least squares

− dΘ

k
7

4 π π π

0 8 4 8 2
ω

Figure 7.2: Group-delay in the pass-band for low-pass filter.

7.3 Design of FIR equaliser with group-delay constraint for elliptic


filters
A 31 tap FIR phase equaliser for the 4 tap elliptic filter with the stop-band attenuation 34 dB, pass-band
ripple 0.5 and cutoff frequency 0.5 has been designed using minimax complex approximation with group-
delay constraints. The specification for the overall system is given by H d (ω) = e−jω13 , thus the overall
filter should have a delay of 13 samples in the pass-band.
The frequency response for the original and equalised filter is shown in figure 7.3. The figure shows
that the phase equaliser has little effect on the frequency response for the filter in the pass- band, and that
it helps increasing the attenuation in the stop-band.
The frequency response for the equaliser is presented in figure 7.3.
The group-delay for the overall filter along with the group-delay for the elliptic filter is presented in
figure 7.3. The figure shows that the group-delay for the overall filter is 13 samples in the passband.

Reference Manual
7.3 Design of FIR equaliser with group-delay constraint for elliptic filters 40

−10 Constarined minimax


Minimax
−20

−30
|H(ω)|
−40

−50

−60

−70 π π 3π π
0 4 2 4
ω

Figure 7.3: Frequency response for low-pass filter.

10

9 Constarined minimax
Minimax
8

− dΘ

k
7

4 π π π

0 8 4 8 2
ω

Figure 7.4: Group-delay in the pass-band for low-pass filter.

Reference Manual
7.3 Design of FIR equaliser with group-delay constraint for elliptic filters 41

20
|G(ω)|
|G(ω)H(ω)|
0

−20

|F (ω)| −40

−60

−80

−100 π π 3π π
0 4 2 4
ω

Figure 7.5: Frequency response for over all system.

10

−10

|H(ω)| −20

−30

−40

−50 π π 3π
0 4 2 4
π
ω

Figure 7.6: Frequency response for phase equaliser.

Reference Manual
7.3 Design of FIR equaliser with group-delay constraint for elliptic filters 42

20

15

− dΘ

k
10
τG (ω)
τGH (ω)

0 π π π

0 8 4 8 2
ω

Figure 7.7: Group delay for over all system.

Reference Manual
Chapter 8

Design of IIR filters

Infinite impulse response (IIR) filters can be designed from analog filters using bilinear transformation.
This chapter describes design methods for five types of analog filters and how to convert them into IIR
filters using bilinear transformation. It also describes how to change the cutoff frequency for analog filters
and how to transform them into high-pass band-pass and band-stop filters. The filters described here are
all split up into first and second order sections for easy fixed precision implementation using cascaded
biquads. The filter order is denoted by N .

Analog filter design


The five types of classic analog filters are Bessel-Thomson, Butterworth, Chebyshev, inverse Chebyshev,
and elliptic function filters are characterised by:
1. Bessel-Thomson filters have nearly constant group delay in the pass-band, which makes them suit-
able for audio applications. The constant group delay comes however at the expense of a wide
transition region. The frequency response of the filter can only be controlled by varying N . No sim-
ple method for selecting the necessary length exists, there are however tables of formulas available
for approximating it.
2. Butterworth filters are maximally flat at ω = 0 and ω = ∞, and has very smooth frequency and
phase response. The frequency response of the filter can only be controlled by varying N . The
necessary length can be approximated as
log((1/G)2 − 1)
N≥ , (8.1)
2 log(ωp )
where the frequency response of the filter remains between unity and G in the interval 0 < ω < ω p ,
where ωp < 1 and 0 < G < 1.
3. Chebyshev filters provide control over the maximum ripple in the passband, through the parameter
ε. The frequency response is maximally flat at ω = ∞. The parameter ε can be determined according
to s
2δ1 − δ12 p
ε= 2 = 10a/10 − 1 (8.2)
1 − 2δ1 + δ1
where δ1 is the desired passband ripple in times and a is the desired passband ripple in dB. The filter
order can be approximated according to
√ 
1−G2
cosh−1 εG2
N≥ , (8.3)
cosh−1 (ωs )
where frequency response of the filter remains between 0 and G in the interval ω s < ω < ∞, where
1 < ωs and 0 < G < 1.
44

4. Inverse Chebyshev filters provides control of the maximum stop-band attenuation, through the pa-
rameter k1 . The frequency response is maximally flat at ω = 0. The parameter k 1 can be determined
according to
δ2 1
k1 = p =√ (8.4)
1 − δ22 10b/10 − 1
where δ2 is the desired stop-band ripple in times and b is the desired positive stop-band attenuation
in dB. The filter order can be approximated according to
 
cosh−1 k √G 2
1 1−G
N≥   , (8.5)
−1 1
cosh ωp

where frequency response of the filter remains between unity and G in the interval 0 < ω < ω p ,
where 0 < ωp < 1 and 0 < G < 1.
5. Elliptic Function filters are characterised by the four parameters
(a) The passband ripple δ1 .
(b) The width of the transition band (1 − ωs )
(c) The maximum stop-band ripple δ2
(d) The order of the filter N
Given three of the above parameters the fourth will be minimal. The design is specified through the
parameters ε and k1 . These parameters can be calculated according to
q
2δ1 −δ12 √
ε = 1−2δ 1 +δ1
2 = 10a/10 − 1
, (8.6)
k1 = √ 2 = √ ε
ε
1/δ2 −1 10b/10 −1

where a is the desired passband ripple in dB, and b is the desired positive stop-band attenuation in
dB. Using the above equations the transition region will be minimal for a given filter length N .
The above design methods are implemented as the functions id_bessel(), id_butterworth(),
id_shebyshev(), id_ichebyshev and id_elliptic in the file iiranalog.c. The filters re-
turned from the design functions are here referred to as prototype filters. They have a cutoff frequency of
1Hz and unity gain in the passband.
Only Bessel-Thomson and Butterworth has unity passband gain, the other three has a passband gain
that varies with the design parameters. This gain offset has to be compensated for, and is therefore returned
from the design functions. When the filter length is odd a first order link must be prepended to the array
of biquads. The parameters for this first order filter is stored in the first two positions of the numerator and
denominator vectors returned from the design functions.

Analog filter transformation


It is possible to change the cutoff frequency and the response of an analog prototype filter using frequency
transformation. The four most basic transformations and their properties are:
1. Low-pass to low-pass transformation changes the cutoff frequency for a prototype filter to F .
s
s→ (8.7)
F

2. Low-pass to high-pass transformation transforms a low-pass prototype filter to a high-pass filter


with the cutoff frequency F .
F
s→ (8.8)
s

Reference Manual
8.1 Fixed frequency response IIR filter design 45

3. Low-pass to band-pass transformation transforms a low-pass prototype filter to a band-pass filter


with the cutoff frequencies Fl and Fh . The resulting filter is twice as long as the prototype filter.

s 2 + F h Fl
s→ (8.9)
s(Fh − Fl )

4. Low-pass to band-stop transformation transforms a low-pass prototype filter to a band-stop filter


with the cutoff frequencies Fl and Fh . The resulting filter is twice as long as the prototype filter.

s(Fh − Fl )
s→ (8.10)
s 2 + F h Fl

These transformations are implemented as the functions it_lp2lp(), it_lp2hp(), it_lp2bp()


and it_lp2bs in the file iirtrans.c.

Bilinear transformation
The bilinear transformation is used for transforming an analog filter, into a digital IIR filter with similar
properties. The transform projects the left half plane of the Laplace transform of the analog filter to the
inside the unit circle of the Z-transform of the digital filter. This transformation results in a stable IIR filter
of the same order as the analog filter. The digital IIR filter is obtained using the substitution
F z−1
s= , (8.11)
tan (πFz /Fs ) z + 1

where F ∈ [0, ∞] is the critical frequency for the analog filter, Fs ∈ [0, ∞] the sample frequency and Fz ∈
[0, Fs /2] is the critical frequency for the digital IIR filter. The transformation will project the frequency F
to Fz according to  
Fz
F = 2Fs tan π (8.12)
Fs
This projection is referred to as frequency warping and must be carefully compensated for especially when
designing filters with more than one critical frequency.
The substitution can be simplified if the sample frequency and the critical frequency for the analog filter
is equal to 1. The result is
1 z−1
s= , (8.13)
tan(πfz ) z + 1
where fz ∈ [0, 0.5].
In this implementation the transformation is defined for first and second order sections. The implemen-
tation is made such that the resulting biquad sections has unity gain for z 0 . This results in a gain error
which must be compensated for in order to reach the desired passband gain for the filter. The advanced and
the simplified transformation described above are implemented as the functions it_bilinear_adv()
and it_bilinear() and are found in the file iirtrans.c. The first order section required for odd
length filters is returned in the first two positions in the weight vector for the IIR filter.

8.1 Fixed frequency response IIR filter design


IIR filters has been designed using the above described analog filter design procedures followed by bilinear
transformation. The five filters fulfils the specification

−3dB ≤ Hd (ω) ≤ 0dB for ω ∈ [0, 0.4π]



.
Hd (ω) ≤ −40dB for ω ∈ [0.5π, π]

The required design parameters for the five filters is summarised in table 8.1.

Reference Manual
8.2 Fixed length IIR filter design 46

The frequency response for the filters is presented in figure 8.1. The Bessel-Thomson filter can not be
made to meet the specification. The frequency response for the passband of the filters is shown in figure
8.1. The two figures shows that all the filters except the Bessel-Thomson fulfils the frequency response
specification.
The group delay for the filters is presented in figure 8.1. The figure shows that The Chebyshev filter has
the worst group delay followed by the Butterworth and the elliptic function filter. The lowest group delay
are obtained by the inverse Chebyshev and the Bessel-Thomson filters.
The implementation is found in file l8a.c.

0
Elliptic function
−10 Inverse Chebyshev
Chebyshev
Butterworth
−20 Bessel-Thomson

20 log |H(ω)|
−30

−40

−50

−60 π π 3π π
0 4 2 4
ω

Figure 8.1: Frequency response for elliptic low-pass IIR filters.

8.2 Fixed length IIR filter design


Five N = 10 long IIR filters has been designed using the above described methods. The specification for
the filters is given by
−3dB ≤ Hd (ω) ≤ 0dB for ω ∈ [0, 0.4π]

.
Hd (ω) ≤ −40dB for ω ∈ [0.5π, π]
The required design parameters for the five filters is summarised in table 8.2.
The frequency response for the filters is presented in figure 8.2. The frequency response for the pass-
band of the filters is shown in figure 8.2. The figures shows that all filters fulfils the design specification
except the Butterworth and the Bessel-Thomson filters. This is consistent with the results obtained in the
designs made in section 8.2.

Filter type N a b wc
Elliptic function 4 -3dB -40dB 0.4π
Inverse Chebyshev 6 - -40dB 0.5π
Chebyshev 8 -3dB - 0.39π
Butterworth 14 - - 0.4π
Bessel-Thomson 14 - - 0.4π

Table 8.1: Design parameters for filters.

Reference Manual
8.3 IIR filter implementation 47

6 Elliptic function
Inverse Chebyshev
Chebyshev
4 Butterworth
Bessel-Thomson
2
20 log |H(ω)|
0

−2

−4
π π 3π π
0 8 4 8 2
ω

Figure 8.2: Passband frequency response for low-pass IIR filters.

The group delay presented in figure 8.2 shows that the the Bessel-Thomson filter has the lowest group
delay followed by the Butterworth, the inverse Chebyshev and the Chebyshev filters. The worst group
delay is obtained by the Elliptic function filter.
The implementation is found in file l8b.c.

8.3 IIR filter implementation


Efficient implementations of IIR filters is difficult. Filters with poles close to the unit circle has a tendency
to oscillate if the numerical resolution used in the implementation is too low.
An eight order inverse Chebyshev filter with a stop-band rejection of 40dB and a cutoff frequency
ωc = 0.4π has been designed the frequency response for the filter is presented in figure 8.3. The step
response for the filter is presented in figure 8.3.
The implementation of the filter is found in in file l8c.c. The calculation kernel for the IIR biquad
link has been implemented as a macro for easy loop unrolling.

8.4 Analog filter transformation


An N = 5 long Elliptic function prototype filter with a passband ripple of 1 dB and a stop-band attenuation
of 40 dB has been designed and transformed using the above described transformation methods. The

Filter type a b wc
Elliptic function -3dB -40dB 0.40π
Inverse Chebyshev - -40dB 0.46π
Chebyshev -3dB - 0.40π
Butterworth - - 0.40π
Bessel-Thomson - - 0.60π

Table 8.2: Design parameters for filters.

Reference Manual
8.4 Analog filter transformation 48

30

25 Elliptic function
Inverse Chebyshev
Chebyshev
20 Butterworth
Bessel-Thomson
− dΘ
dω 15

10

0 π π π

0 8 4 8 2
ω

Figure 8.3: Group-delay in the pass-band for low-pass IIR filters.

specifications for the transformed filters are given by The frequency response for the filters are presented

Type Centre or cutoff frequency Bandwidth


Low-pass 2 Hz -
High-pass 2 Hz -
Band-pass 2 Hz 3 Hz
Band-stop 2 Hz 3 Hz

in figure 8.4. The implementation is found in file l8d.c.

Reference Manual
8.4 Analog filter transformation 49

−10 Elliptic function


Inverse Chebyshev
Chebyshev
−20 Butterworth
Bessel-Thomson
20 log |H(ω)|
−30

−40

−50

−60 π π 3π π
0 4 2 4
ω

Figure 8.4: Frequency response for low-pass IIR filters.

6 Elliptic function
Inverse Chebyshev
Chebyshev
4 Butterworth
Bessel-Thomson
2
20 log |H(ω)|
0

−2

−4
π π 3π π
0 8 4 8 2
ω

Figure 8.5: Passband frequency response for low-pass IIR filters.

Reference Manual
8.4 Analog filter transformation 50

100

80 Elliptic function
Inverse Chebyshev
Chebyshev
60 Butterworth
Bessel-Thomson
− dΘ
dω 40

20

−20 π π π

0 8 4 8 2
ω

Figure 8.6: Group-delay in the pass-band for low-pass IIR filters.

−10

−20

20 log |H(ω)|
−30

−40

−50

−60 π π 3π
0 4 2 4
π
ω

Figure 8.7: Frequency response for eight order inverse Chebyshev low-pass IIR filter.

Reference Manual
8.4 Analog filter transformation 51

1.4
1.2
1 x[n]
y[n]
0.8
0.6
a[n]
0.4
0.2
0
−0.2
−0.4
0 10 20 30 40 50 60 70 80
n

Figure 8.8: Step response for eight order inverse Chebyshev low-pass IIR filter.

Reference Manual
8.4 Analog filter transformation 52

20 log |H(F )|
0
−10 Low-pass
−20
−30
−40
−50
−60
0.1 1.0 10.0
F
20 log |H(F )|

0
−10 High-pass
−20
−30
−40
−50
−60
0.1 1.0 10.0
F
20 log |H(F )|

0
−10 Band-pass
−20
−30
−40
−50
−60
0.1 1.0 10.0
F
20 log |H(F )|

0
−10 Band-stop
−20
−30
−40
−50
−60
0.1 1.0 10.0
F

Figure 8.9: Frequency responses for filters.

Reference Manual
Chapter 9

Half-band FIR filters

This chapter describes a simple half-band filter-bank, see figure 9.1. A filter-bank consists of an analysis
(filter and decimator) and a synthesis part (interpolator and filter). The filters in the upper part (H 0 (z) and
F0 (z)) are low-pass filters and the two filters in the lower part (H1 (z) and F1 (z)) are high-pass filters. The
cutoff frequency for the two filter pairs ωc = π2 .
Analysis Synthesis

X(z) Y (z)
H0 (z) 2 2 F0 (z)

H1 (z) 2 2 F1 (z)

Figure 9.1: Analysis and synthesis filter-bank.

Perfect reconstruction Y (z) = z M X(z), is possible if



F0 (z) = H1 (−z)
. (9.1)
F1 (z) = −H0 (z)
By setting
H1 (z) = −z −M H0 (z) (9.2)
it is possible to design one single filter H0 (z) which the rest of the filter-bank can be derived from.
The filter H0 (z) is designed such that

H(z) = H0 (z)H0 (z −1 ) (9.3)

where 
c n=0
H(z) + H(−z) = 2c ⇐⇒ h(2n) = (9.4)
0 elsewhere
and where c is a constant that big enough to ensure that H(ω) ≥ 0. The design procedure for H(z) is
outlined below:

1. Linear phase design Design a N long type 2 linear FIR filter q1 (n) with the specifications seen
below, using Remes exchange algorithm.

1 for 0 ≤ ω < 2fc
Aq (ω) = (9.5)
0 for ω = π
where fc is close to π2 , also define M = N − 1.
9.1 Low-pass FIR filter design using Remes exchange algorithm 54

2. Interpolate Form the filter q2 (n) by interpolating q1 (n) according to to



g1 (n/2) n = 0, 2, 4, . . .
q2 (n) = (9.6)
0 elsewhere

3. Scale filter Form the filter q3 (n) by scaling q2 (n) according to to



c n=0
q3 (n) = (9.7)
q3 elsewhere

4. Factorisation Form H(z) by factorising q3 (n) using numerical root finding

|g3 (M )|
H(z) = (1 − z −1 z1 )(z1∗ − z −1 ) · · · (1 − z −1 zM )(zM

− z −1 ) QM (9.8)
i=1 |zi |

where z1 , . . . , zN are the zeros of H(z). The filter H0 (z) is formed according to
s
|g3 (M )|
−1 −1
H0 (z) = (1 − z z1 ) · · · (1 − z zM ) QM . (9.9)
i=1 |zi |

The obtained filter H0 (z) will have minimum phase. The filter-taps h0 (n) are formed by evaluating
the polynomial z1 , . . . , zN .

9.1 Low-pass FIR filter design using Remes exchange algorithm


A filter-bank with N = 12 filter taps has been designed using the above described method. The passband
ripple for q1 (n) is displayed in figure 9.1. It has been limited to 0.005 by setting fc = 0.76π.
The impulse response for the four filters h0 (n), h1 (n), f0 (n) and f1 (n) is displayed in figure 9.1. The
frequency response is displayed in figure 9.1.
The implementation is found in file l9a.c.

1.01

1.005

|Q1 (ω)| 1

0.995

0.99 π π 3π
0 4 2 4
π
ω

Figure 9.2: Frequency response for low-pass filter.

Reference Manual
9.1 Low-pass FIR filter design using Remes exchange algorithm 55

0.5

0.25

h0 [n] 0

−0.25

−0.5
0 2 4 6 8 10
n
0.5

0.25

h1 [n] 0

−0.25

−0.5
0 2 4 6 8 10
n
0.5

0.25

f0 [n] 0

−0.25

−0.5
0 2 4 6 8 10
n
0.5

0.25

f1 [n] 0

−0.25

−0.5
0 2 4 6 8 10
n

Figure 9.3: Impulse response for filters.

Reference Manual
9.1 Low-pass FIR filter design using Remes exchange algorithm 56

10
0
−10
−20
H0 (ω)
−30
−40
−50
−60 π π 3π
0 4 2 4
π
ω
10
0
−10
−20
H1 (ω)
−30
−40
−50
−60 π π 3π π
0 4 2 4
ω
10
0
−10
−20
F0 (ω)
−30
−40
−50
−60 π π 3π π
0 4 2 4
ω
10
0
−10
−20
F1 (ω)
−30
−40
−50
−60 π π 3π
0 4 2 4
π
ω

Figure 9.4: Frequency response for filters.

Reference Manual
Chapter 10

Design of FIR filters using optimum


window design

In optimum window design the the total side lobe energy is minimised subject to the constraint that H(0) =
1. The method gives an optimum compromise between least squares and minimax criterias. The method is
compared with the eigen window design and with Kaiser window design. The implementation is currently
limited to type 1 and type 2 linear low-pass FIR filters. The amplitude function is here given by A(ω) =
φT (ω)a, where φ(ω) is defined according to table 10 and a according to table 10. The optimum window
is defined as the optimisation problem

 mina∈RM +1 ωs |A(ω)|2 dw, subject to

|A(ω)| ≤ σ, ω ∈ [ωs , π] (10.1)


A(0) = 1

where the integral is the stop-band energy and σ is the maximum stop-band level. The optimisation problem
can be solved using quadratic or linear programming

Type 1 Type 2
 √
1
  
√ √2 cos(1/2ω)
 2 cos(ω)   2 cos(3/2ω) 
φ(ω) =  .. φ(ω) =  ..
   
.
 


 
√ . 
2 cos(ωM ) 2 cos(M ω)

Table 10.1: Base functions for type 1-2 filters, M = 2 .


N −1

Type 1 Type 2
 √
√ h(M )
  
√2h(N/2 − 1)
 2h(M − 1)   2h(N/2 − 2) 
a= .. a= ..
   
√ .
 
√ .
   
2h(0) 2h(0)

Table 10.2: Relation between a and h for type 1-2 filters, M = 2 .


N −1
10.1 Optimum window low-pass FIR filter 58

Optimum window FIR filter design using quadratic programming


The problem can be reformulated as the quadratic programming problem

 min aT Ra
 T

φ (ω)a ≤ σ ω ∈ [ωs , π]
T (10.2)

 −φ (ω)a ≤ σ ω ∈ [ωs , π]
 T
φ (0)a = 1
where Z π
R= φ(ω)φT (ω)dw. (10.3)
ωs
The design method is implemented as the function fd_qpoptwin() and is found in firoptwin.c.

Eigen window FIR filter design


A FIR filter can be designed by finding the eigenvector λ1 belonging to the smallest eigen value of R using
eigen decomposition. The filter is found as a = λ1 and is optimal in terms of stop-band energy.

Minimax optimum window FIR filter design


By sacrificing the control over the side-lobe level, the problem can be formulated as the linear programming
problem 

 min δ
 T
φ (ω)a ≤ δ ω ∈ [ωs , π]
T (10.4)

 −φ (ω)a ≤ δ ω ∈ [ωs , π]
 T
φ (0)a = 1
The design method is implemented as the function fd_minimaxoptwin() and is found in firoptwin.c.

10.1 Optimum window low-pass FIR filter


A 41 tap low-pass type 1 FIR filter has been designed using least squares optimum window design. The
cutoff frequency for the filter is ωs = 0.1π, and 20 log σ = [−48.5, −48.0, . . . , −36] (dB). The frequency
response for 20 log σ = −48.5 is presented in figure 10.1. The figure shows that the maximum stop-band
level is -48.5 dB as given by the specification. The total stop-band energy versus maximum stop-band
energy is presented in figure 10.3. The figure shows that there exists a tradeoff between stop-band energy
and maximum stop-band level.
The implementation is found in file l10a.c.

10.2 Minimax optimum window low-pass FIR filter


A 41 tap low-pass type 1 FIR filter has been designed using minimax optimum window design. The cutoff
frequency for the filter is ωs = 0.1π. The frequency response is presented in figure 10.2. The figure shows
that the maximum stop-band level is -50 dB. The total stop-band energy versus maximum stop-band energy
for the filter is presented in figure 10.3. The figure shows that the minimax design is superior in terms of
maximum stop-band level but inferior in terms of stop-band energy.
The implementation is found in file l10b.c.

10.3 Low-pass FIR filter design using eigen window method


A 41 tap low-pass type 1 FIR filter has been designed using eigen window design. The cutoff frequency
for the filter is ωs = 0.1π. The total stop-band energy versus maximum stop-band energy for the filter is
presented in figure 10.3. The figure shows that the eigen window design is superior in terms of stop-band
energy level.

Reference Manual
10.4 Kaiser window design 59

10

−10

−20

A(ω) −30

−40

−50

−60

−70 π π 3π
0 4 2 4
π
ω

Figure 10.1: Frequency response for low-pass filter.

10.4 Kaiser window design

Reference Manual
10.4 Kaiser window design 60

10

−10

−20

A(ω) −30

−40

−50

−60

−70 π π 3π π
0 4 2 4
ω

Figure 10.2: Frequency response for low-pass filter.

-90
Least squares
Minimax ?
Eigen window 3
-95 ?

-100

-105
3

-110
-50 -48 -46 -44 -42 -40 -38 -36

Figure 10.3: Total stop-band energy versus maximum stop-band energy.

Reference Manual
10.4 Kaiser window design 61

10

−10

−20

A(ω) −30

−40

−50

−60

−70 π π 3π π
0 4 2 4
ω

Figure 10.4: Frequency response for over all system.

−18.8
−19
−19.2
−19.4
−19.6
−19.8
Maximum sidelobe energy [dB]

−20
−20.2
−20.4
−20.6
−20.8
−21
−6 −6 −6 −6 −6 −6 −6 −6 −6 −6
Total sidelobe energy [dB]

Figure 10.5: Frequency response for phase equaliser.

Reference Manual
Chapter 11

Minimum phase FIR filter design by


spectral factorisation

Minimum phase FIR filters with arbitrary magnitude specification can be designed by combining minimax
design of linear phase filters with spectral factorisation. A linear type 1 FIR filter R(z) with the length 2N −
1 is designed using Remes algorithm or using linear programming. The linear filter is then transformed
into a N long minimum phase filter h using spectral factorisation.
A spectral factorisation of R(z) exists iff R(z) = R(−z), R(ejω ) > 0 and the zeros of R(z) on the
unit circle are double. The first and the third criteria is automatically fulfilled by using a linear phase filter
with odd length. The second criteria R(ejω ) > 0 is however a constraint on R(z), which must be included
in the design procedure. The frequency response of R(z) is given by
N
X −1 N
X −1
R(ejω ) = r(n)e−jωn = r(0) + r(n)2 cos(ωn) = φT (ω)r, (11.1)
n=−(N −1) n=1

where φ(ω) and r are given according to the definition in chapter 1.


The desired amplitude function of the filter is here specified according to

Hl (ω) ≤ |H(ejω )| ≤ Hu (ω), ω ∈ Ω



, (11.2)
H(ejωi ) = 0 ωi ∈ Ωs , i = 0, 1, . . . , I − 1

where Hl (ω) ≥ 0 and R(ω) relates to H(ω) as Rl (ω) = Hl2 (ω), Ru (ω) = Hu2 (ω) and R(ejω ) =
|H(ejω )|2 . The design constraints H(ejωi ) = 0 are referred to as null constraints, and can be used to move
the position of zeros in the stop-band. Below follows three methods of calculating R(z) given the above
specification of h.

Minimax criterion
Remes exchange algorithm can be used in order to obtain a filter with a regular minimax specification, i.e.
one without null constraints. The minimax optimisation problem is defined according to
1
min max R(ejω ) − Rd (ω) , (11.3)
r∈RN ω∈Ω ε(ω)

where
Ru (ω) + Rl (ω)
Rd (ω) = (11.4)
2
Ru (ω) − Rl (ω)
ε= (11.5)
2
11.1 Low-pass FIR filter design using Remes exchange algorithm 63

The design can be performed using the implementation made in chapter 5. The design function used
is fd_minphase() and is found in the file firminimac.c. Note that the raising of the amplitude
function above zero inside the design function becomes redundant, since the amplitude function R(ω) is
positive for all values of ω.

Modified minimax criterion


In order to design a filter with null constraints a modified minimax design is necessary. The resulting linear
program formulation is given by

minr,δ δ subject to


 v(ω)φT (ω)r − δ ≤ v(ω)Rd (ω),

ω ∈ Ω p ∪ Ωs


−v(ω)φT (ω)r − δ ≤ v(ω)Rd (ω), ω ∈ Ωp , (11.6)
T
φ (ω)r ≥ 0, ω ∈ Ω

s



 T
φ (ωi )r = 0, ωi ∈ Ωs , i = 0, 1, . . . , I − 1

where
Ru (ω)+Rl (ω)

, ω ∈ Ωp
Rd (ω) = 2 (11.7)
0, ω ∈ Ωs

and
Ru (ω)−Rl (ω)

, ω ∈ Ωp
ε= 2 (11.8)
Ru (ω), ω ∈ Ωs

The first two constraints in the linear program definition 11.6 shapes the amplitude function of R(ω).
The third constraint enables for the spectral factorisation and the last constraint contains the null constraints.
This design method is implemented as the function fd_minphaseminimax() in firminphase.c.

Modified least squares criterion


Using a similar approach to the modified minimax criterion a modified least squares criterion for the design
of r can be formulated. The resulting linear program is formulated according to

r∈RN c r subject to
 T
 min

T
φ (ω)r ≤ Ru (ω), ω ∈ Ω p ∪ Ωs

T , (11.9)

 −φ (ω)r ≤ R l (ω), ω ∈ Ω p ∪ Ωs
 T
φ (ωi )r = 0, ωi ∈ Ωs , i = 0, 1, . . . , I − 1

where Z
c= φ(ω)dω. (11.10)
Ωs

The design minimises the energy in the stop-band while maintaining the passband within the limits
using the first two constraints. The null constraints are placed using the third constraint. This design
method is implemented as the function fd_minphasels() in firminphase.c

11.1 Low-pass FIR filter design using Remes exchange algorithm


A minphase FIR filter has been designed using a minimax criterion without null constraints. The specifi-
cation is given by

101/20

ω ∈ Ωp = [0, 0.4π]
Hu (ω) =
10−40/40 ω ∈ Ωs = [0.5π, π]

Reference Manual
11.2 High-pass FIR filter design using Remes exchange algorithm 64

and

10−1/20 ω ∈ Ωp = [0, 0.4π]
Hl (ω) =
0 ω ∈ Ωs = [0.5π, π]
The shortest filter that fulfills the specification is N = 28 taps long. The zeros for the intermediate filter
R(z) is presented in figure 11.1. The resulting impulse response is presented in figure 11.1 along with the
impulse response for a linear filter with the same specifications designed using the Remes algorithm. The
figure shows hat the minimum-phase filter should have much lower delay than the filter designed using
the Remes algorithm. The linear Remes filter needs N = 49 taps to reach the same specification as the
minphase filter.
The frequency response for the two filters is presented in dB scale in figure 11.1.
The group delay presented in figure 11.1 shows that the Remes algorithm results in a filter with linear
phase response while the minimum-phase filter has lower but non linear phase response.
The implementation is found in file l11a.c and l11.m.

1.5

1 ? ? ??? ?
?? ? ? ? ?
?
0.5 ? ?? ?
? ?
?? ? ?
0 ?? ?? ? ?
?? ? ?
-0.5 ? ?? ?
? ? ? ?
? ?? ? ?
-1 ? ? ??? ?

-1.5

-2
-3 -2 -1 0 1 2 3

Figure 11.1: Root locations for minimax filter.

11.2 High-pass FIR filter design using Remes exchange algorithm


A minphase FIR filter has been designed using a minimax criterion with null constraints. The specification
is given by
10(−20+200ω/π)/20 ω ∈ [0, 0.1π]



100/20 ω ∈ [0.1π, 0.5π]

Hu (ω) = (200−400ω/π)/20

 10 ω ∈ [0.5π, 0.6π]
10(−25−25ω/π)/20 ω ∈ [0.6π, π]

and
10(−25+200ω/π)/20


 ω ∈ [0, 0.1π]
10−5/20 ω ∈ [0.1π, 0.5π]

Hl (ω) =
 10(195−400ω/π)/20
 ω ∈ [0.5π, 0.6π]
0 ω ∈ [0.6π, π]

Reference Manual
11.3 High-pass FIR filter design using Remes exchange algorithm 65

0.5

0.4 Min-phase
Remes
0.3

0.2
h[n]
0.1

−0.1

−0.2
0 5 10 15 20 25 30 35 40 45 50
n

Figure 11.2: Impulse response for minimax filter.

with the additional null constraints

H(ej0.7π )

=0
H(ej0.8π ) =0

The shortest filter that fulfills the specification is N = 23 taps long. The zeros for the intermediate filter
R(z) is presented in figure 11.2. The resulting impulse response is presented in figure 11.2.
The frequency response for the filter is presented in dB scale in figure 11.2. The figure shows that the
filter fulfills the specification including the null constraints. The group delay is presented in figure 11.2.
The implementation is found in file l11b.c and l11.m.

11.3 High-pass FIR filter design using Remes exchange algorithm


A minphase FIR filter has been designed using a least-squares criterion with null constraints, and the same
specifications as in 11.2. The shortest filter that fulfills the specification is N = 24 taps long. The zeros
for the intermediate filter R(z) is presented in figure 11.3, and the impulse response is presented in figure
11.3.
The frequency response for the filter is presented in dB scale in figure 11.3. The figure shows that the
filter fulfills the specification including the null constraints. The group delay is presented in figure 11.3.
The implementation is found in file l11c.c and l11.m.

Reference Manual
11.3 High-pass FIR filter design using Remes exchange algorithm 66

10

−10 Min-phase
Remes
−20 Limits
|H(ω)|
−30

−40

−50

−60 π π 3π π
0 4 2 4
ω

Figure 11.3: Frequency response for minimax filter.

30
25
20
15
10
− dΘ

k
5
0
−5 Min-phase
Remes
−10
−15
−20 π π π

0 8 4 8 2
ω

Figure 11.4: Group delay for minimax filter.

Reference Manual
11.3 High-pass FIR filter design using Remes exchange algorithm 67

1.5

1 ? ?? ?
??
? ?
?? ??
0.5 ?
? ? ??
0 ? ? ? ? ???
??
? ? ??
-0.5 ?? ?
??
? ? ?
-1 ? ?? ??

-1.5

-2
-3 -2 -1 0 1 2 3

Figure 11.5: Root locations for modified minimax filter.

Min-phase

0.3

0.2

0.1

h[n] 0

−0.1

−0.2

−0.3
0 5 10 15 20 25
n

Figure 11.6: Impulse response for modified minimax filter.

Reference Manual
11.3 High-pass FIR filter design using Remes exchange algorithm 68

10
0
−10 Min-phase
Limits
−20
−30
|H(ω)|
−40
−50
−60
−70
−80 π π
0 4 2 0.7π 0.8π π
ω

Figure 11.7: Frequency response for modified minimax filter.

30
25
20
15
10
− dΘ

k
5
0
−5 Min-phase
−10
−15
−20 π π
0 4 2 0.7π 0.8π π
ω

Figure 11.8: Group delay for modified minimax filter.

Reference Manual
11.3 High-pass FIR filter design using Remes exchange algorithm 69

1 ? ??
? ? ?? ? ??
? ? ?
? ??
?
?? ? ?? ?
0 ??
? ? ??
?? ? ?
? ?? ? ??
-1 ? ??

-2

-3 -2 -1 0 1 2 3 4 5

Figure 11.9: Root locations for modified least-squares filter.

Min-phase

0.3

0.2

0.1

h[n] 0

−0.1

−0.2

−0.3
0 5 10 15 20 25
n

Figure 11.10: Impulse response for modified least-squares filter.

Reference Manual
11.3 High-pass FIR filter design using Remes exchange algorithm 70

10
0
−10 Min-phase
Limits
−20
−30
|H(ω)|
−40
−50
−60
−70
−80 π π
0 4 2 0.7π 0.8π π
ω

Figure 11.11: Frequency response for modified least-squares filter.

30
25
20
15
10
− dΘ

k
5
0
−5 Min-phase
−10
−15
−20 π π
0 4 2 0.7π 0.8π π
ω

Figure 11.12: Group delay for modified least-squares filter.

Reference Manual
Chapter 12

Cepstrum minimum phase FIR-filter


design

Long minimum phase FIR-filters are hard to design using root finding due to numerical difficulties. By
employing complex cepstrum transformation and fast Fourier transform (FFT) these numerical problems
can be circumvented. This chapter describes how to design FIR-filters with an arbitrary amplitude response
using an iterative method based on FFT and cepstrum processing.
An N long minimum phase FIR-filter h(n) with the magnitude response |H(e jω )| described by
0 ≤ Hl (ω) ≤ |H(ejω )| ≤ Hu (ω) (12.1)
can be designed using complex cepstrum technique using the following procedure
1. Initialise parameters Define the FFT size K > 10 ∗ N and the upper and lower magnitude response
limits Hu (ωk ) and Hl (ωk ), for k = 0, 1, . . . , K − 1. Set the initial desired magnitude response to
Hl (ωk ) + Hu (ωk )
|H(ejωk )| = . (12.2)
2
Define the truncation tolerance ε for the algorithm to
Hu (ωk ) − Hl (ωk )
0 < ε < max . (12.3)
∀k 2
This constant will determine the convergence speed of the algorithm.
2. Apply cepstrum transformation Form the filter ĥe (n) according to

ĥe (n) = IFFT log(|H(ejωk )|) (12.4)




and define the cepstrum ĥ(n) as



 ĥe (n) n=0
ĥ(n) = 2ĥe (n) 0 < n ≤ K/2 (12.5)
0 K/2 < n ≤ K − 1

The minimum phase filter h(n) is now given by


n o
h(n) = IFFT eFFT{ĥ(n)} (12.6)

3. Truncate filter Truncate the minimum phase filter h(n) to an FIR-filter h1 (n) of length N according
to 
h(n) 0 ≤ n ≤ N − 1
h1 (n) = (12.7)
0 N ≤n≤K −1
12.1 Low-pass FIR-filter design using complex cepstrum technique 72

4. Test for convergence Calculate the frequency response of the truncated filter H 1 (ω) = FFT {h1 (n)},
and defined the new desired magnitude response

 Hu (ω)/ε if |H1 (ejω )| > Hu (ω)/ε




|H(e )| = |H1 (ejω )| if Hl (ω) · ε ≤ |H1 (ejω )| ≤ Hu (ω)/ε . (12.8)
Hl (ω) · ε if |H1 (ejω )| < Hl (ω) · ε

If Hl (ω) ≤ |H1 (ejω )| ≤ Hu (ω) for all ω stop else return to step 2.

The above described design method is called fd_cepminphase(), and is implemented in firminphase.c.
The truncation parameter ε will determine weather the algorithm will converge or not. A too small value
will make the algorithm very slow while a too big value will cause divergence.

12.1 Low-pass FIR-filter design using complex cepstrum technique


A minimum phase FIR filter with the following specification

10(−20+200ω/π)/20 ω


 ∈ [0, 0.1π]
100/20 ω ∈ [0.1π, 0.5π]

Hu (ω) = (200−400ω/π)/20

 10 ω ∈ [0.5π, 0.6π]
10(−25−25ω/π)/20 ω ∈ [0.6π, π]

and

10(−25+200ω/π)/20


 ω ∈ [0, 0.1π]
10−5/20 ω ∈ [0.1π, 0.5π]

Hl (ω) = ,

 10(195−400ω/π)/20 ω ∈ [0.5π, 0.6π]
0 ω ∈ [0.6π, π]

has been designed with a truncation tolerance of ε = 0.5dB. The design specification is met for an N = 28
long filter. The resulting impulse response is presented in figure 12.1. The frequency response for the filter
is presented in dB scale in figure 12.1 along with the design limits. The group delay presented in figure
12.1.
The implementation is found in file l12a.c.

Reference Manual
12.1 Low-pass FIR-filter design using complex cepstrum technique 73

0.3

0.2

0.1

h[n] 0

−0.1

−0.2

−0.3
0 5 10 15 20 25
n

Figure 12.1: Impulse response for low-pass filter.

10

−10 |H(ω)|
Limits
−20
|H(ω)|
−30

−40

−50

−60 π π 3π
0 4 2 4
π
ω

Figure 12.2: Frequency response for low-pass filter.

Reference Manual
12.1 Low-pass FIR-filter design using complex cepstrum technique 74

20

15

10

− dΘ

k
0

−5

−10

−15

−20 π π π

0 8 4 8 2
ω

Figure 12.3: Group delay for low-pass filter.

Reference Manual
Chapter 13

Allpass Realisation of Recursive Digital


Filters

Some IIR filters can be realized as a sum of two allpass filters, see figure 13.1. These filters are robust to
parameter quantisation, especially in the passband. Another advantage is that they can be implemented with
a minimum of multipliers. Both these properties makes the filters suitable for implementation in hardware.

1
A1 (z) 2
X(z) Y (z)

A2 (z)

Figure 13.1: IIR filter implemented as a sum of two allpass sections.

A necessary and sufficient condition for a filter


P (z)
H1 (z) = (13.1)
D(z)
to be realizable as a sum of two allpass filters is that there exists a power complimentary filter
Q(z)
H2 (z) = (13.2)
D(z)
such that
H1 (z)H1 (z −1 ) + H2 (z)H2 (z −1 ) = 1 (13.3)
and that the characteristic function given by
H2 (z) Q(z)
K(z) = = (13.4)
H1 (z) P (z)
is a rational function formed as the quotient of an anti mirror image polynomial by an mirror image poly-
nomial, both of the same degree.
An IIR filter of the order N is transformed using the following procedure:
1. Find the polynomial Q(z).
Form R(z) according to
2N
X
R(z) = Q2 (z) = P 2 (z) − z −N D(z)D(z −1 ) = rn z −1 (13.5)
n=0
76

Taking the inverse Z-transform of R(z) yields


n
X
rn = qk qn−k (13.6)
k=0

with in turn gives us the recursive formulas for qn



q0 = r0
r1
q1 =
2q0 (13.7)
Pn−1
rn − k=1 qk qn−k
qn = ,n ≥ 2
2q0

2. Find the two allpass filters A1 (z) and A2 (z).


Find the magnitude of zeros of P (z) + Q(z) and sort them according to magnitude. Let z 1 , . . . , zr
be the zeros inside the unit circle and zr+1 , . . . , zN the ones outside the unit circle. Form the two
allpass filters A1 (z) and A2 (z) according to
N
Y z−1 − zk−1
A1 (z) =
k=r+1
1 − z −1 zk−1
r
(13.8)
Y z−1 − zk−1
A2 (z) =
k=1
1 − z −1 zk−1

3. Quantise the filter taps.


The above two products can be evaluated and implemented directly. They can also be grouped
in regular first and second order sections and implemented as in chapter 8. The third and most
computationally efficient option is to group them into first and second order sections and implement
them according to figures 13.2 and 13.3. The parameters in the figures are defined according to
• First order sections
αk = −zk . (13.9)
• Second order sections
<{zk }
αk = −2
1 + |zk |2 (13.10)
2
βk = |zk |
The parameters in all the above mentioned implementations can be heavily quantised with small
change in the filter response. Observe however that the change in filter response will be different
depending on the implementation method.

−αk

X(z) Y (z)

z −1

Figure 13.2: First order allpass filter section.

The transformation method is implemented as it_sos2allpass(), reverse transformation of one all-


pass filter can be done with it_allpass2poly. Use the function it_quant_allpass() can be
used for quantisation of the allpass filters.

Reference Manual
13.1 Design example 77

−βk

X(z) Y (z)

z −1

−αk

z −1

Figure 13.3: Second order allpass filter section.

13.1 Design example


An IIR filter specified according to table 13.1 has been implemented in direct form, as cascaded second

Filter type Elliptic function


Filter order 7
Passband ripple 0.5dB
Stop-band suppression 50dB

Table 13.1: Design parameters for filters.

order sections and as a sum of allpass filters using the above transformation method. The magnitude
function for the three filters is shown in figures 13.1 and 13.1. The number of bits used for each section is
summarised in table 13.1. The conclusion is that for this specific filter the best option is to implement it as
second order sections.

Implementation method Quantisation


Direct form 14 bits
Second order sections 6 bits
Sum of allpass sections 8 bits

Table 13.2: Design parameters for filters.

Reference Manual
13.1 Design example 78

−10 Ideal
Direct form
Second order sections
−20 Sum of allpass
Limits
20 log |H(ω)|
−30

−40

−50

−60 π π 3π
0 4 2 4
π
ω

Figure 13.4: Frequency response for elliptic low-pass IIR filters implemented using three different ap-
proaches.

1.5

Ideal
1 Direct form
Second order sections
Sum of allpass
0.5 Limits
20 log |H(ω)|
0

−0.5

−1 π π π

0 8 4 8 2
ω

Figure 13.5: Passband frequency response for elliptic low-pass IIR filters implemented using three different
approaches.

Reference Manual
Chapter 14

Uniform over-sampled DFT filter-bank


design and implementation

This chapter describes uniform over-sampled DFT filterbanks. A DFT filterbank consists of an analysis
and a synthesis part. The analysis part consists of a tapped delay line, a decimator, a polyphase FIR filter
and an inverse discrete Fourier transform (IDFT), see figure 14.1. The synthesis part consists of a discrete
Fourier transform (DFT), a polyphase FIR filter, an interpolator and a tapped delay line, see figure 14.2.
The analysis filterbank is a single input - multiple output (SIMO) system where the sample rate of the
outputs is P times lower than the sample rate for the input. The system converts the input signal X(z)
into K signals Xk (z), where k ∈ [0, K − 1]. These signals are are referred to as subband signals and are
decimated by a factor of D, where K = D · P . The subband signals are wide-band, each representing
a unique narrow frequency band of the full-band signal, with the fullband centre frequency 2πk K and the
fullband bandwidth 2π K . The bandwidth of each subband signal is 2π
P . The oversampling is performed in
order to reduce the effect of aliasing between the subbands.
The frequency response for the polyphase FIR filter will determine the frequency response for the
subband signals, and thereby the frequency response for the over all system. The filter is designed using a
prototype filter H0 (z) with the length L = K · N , where N is an integer. The prototype filter must be a
low-pass filter in order for the subband signals to represent unique frequency bands of the fullband signal.
The stop-band attenuation of the prototype filter will determine the aliasing between the subbands. The
cutoff frequency, passband ripple and the main-lobe width will determine the overall frequency response
of the DFT filterbank. The cutoff frequency is set to fc = 2π K but can be adjusted to f c ≈ 1.1 K If the

main-lobe of H0 (z) is narrow.


Methods for designing and executing DFT filterbanks are implemented in firfb.c. An alternative
execution kernel optimised in SSE2 assembly can be compiled by setting the define HAVE_SSE to 1 at
the top of the file. The implementation also contains design and execution routines for multichannel DFT
filterbanks.

14.1 DFT filterbank implementation


A DFT filter bank with K = 8 subbands, a prototype filter length L = 4K and an oversampling factor
of P = 2 has been designed using the above described method. The prototype filter is designed using a
Hamming window and a cutoff frequency ωc = 2.2π K . The frequency response for the prototype filter is
displayed in figure 14.1. The time-signal for a ramp wave filtered through the filter bank is displayed in
figure 14.1. The figure shows that the filter bank delays the signal by L samples.
The implementation is found in file l14a.c.
14.2 Parallel DFT filterbank implementation 80

X(z)
D E0 (z) X0 (z)

z −1

D E1 (z) X1 (z)

z −1

IDFT
D E2 (z) X2 (z)

D EK−1 (z) XK−1 (z)

Figure 14.1: Analysis filter-bank.

Y0 (z) F0 (z) D
z −1

Y1 (z) F1 (z) D
z −1
DFT

Y2 (z) F2 (z) D

Y (z)
YK−1 (z) FK−1 (z) D

Figure 14.2: Synthesis filter-bank.

14.2 Parallel DFT filterbank implementation


A parallel DFT filter bank with two channels has been designed using the same specifications as in section
14.1. The time-signal for a ramp wave and a sinus signal filtered through the two channels in the filter bank
is displayed in figure 14.2.

Reference Manual
14.2 Parallel DFT filterbank implementation 81

−20

−40

H0 (ω) −60

−80

−100

−120 π π 3π π
0 4 2 4
ω

Figure 14.3: Frequency response for prototype filter.

100
90
80 x(n)
y(n)
70
60
50
a[n]
40
30
20
10
0
−10
0 10 20 30 40 50 60 70 80 90 100
n

Figure 14.4: Input and output time signals.

Reference Manual
14.2 Parallel DFT filterbank implementation 82

12
10 x0 (n)
y0 (n)
8 x1 (n)
y1 (n)
6
4
a[n]
2
0
−2
−4
−6
0 5 10 15 20 25 30 35 40 45 50
n

Figure 14.5: Input and output time signals.

Reference Manual

You might also like