Sei sulla pagina 1di 211

DSP & Digital Filters

Mike Brookes

DSP and Digital Filters (2014-5289)

Introduction: 1 1 / 16

1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary

DSP and Digital Filters (2014-5289)

1: Introduction

Introduction: 1 2 / 16

Organization
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary

18 lectures: feel free to ask questions


Textbooks:
(a) Mitra Digital Signal Processing ISBN:0071289461 41 covers
most of the course except for some of the multirate stuff
(b) Harris Multirate Signal Processing ISBN:0137009054 49
covers multirate material in more detail but less rigour than
Mitra
Lecture slides available via Blackboard or on my website:
http://www.ee.ic.ac.uk/hp/staff/dmb/courses/dspdf/dspdf.htm
quite dense - ensure you understand each line
email me if you dont understand or dont agree with anything
Prerequisites: 3rd year DSP - attend lectures if dubious
Exam + Formula Sheet (past exam papers + solutions on website)
Problems: Mitra textbook contains many problems at the end of each
chapter and also MATLAB exercises

DSP and Digital Filters (2014-5289)

Introduction: 1 3 / 16

Signals
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary

A signal is a numerical quantity that is a function of one or more


independent variables such as time or position.
Real-world signals are analog and vary continuously and take
continuous values.
Digital signals are sampled at discrete times and are quantized to a
finite number of discrete values
We will mostly consider one-dimensionsal real-valued signals with
regular sample instants; except in a few places, we will ignore the
quantization.
Extension to multiple dimensions and complex-valued signals
is mostly straighforward.
Examples:

DSP and Digital Filters (2014-5289)

Introduction: 1 4 / 16

Processing
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary




Aims to improve a signal in some way or extract some information


from it
Examples:

Modulation/demodulation
Coding and decoding
Interference rejection and noise suppression
Signal detection, feature extraction

We are concerned with linear, time-invariant processing

DSP and Digital Filters (2014-5289)

Introduction: 1 5 / 16

Syllabus
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary

Main topics:





Introduction/Revision
Transforms
Discrete Time Systems
Filter Design
FIR Filter Design
IIR Filter Design

Multirate systems
Multirate Fundamentals
Multirate Filters
Subband processing

DSP and Digital Filters (2014-5289)

Introduction: 1 6 / 16

Sequences
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary

We denote the nth sample of a signal as x[n] where < n < + and
the entire sequence as {x[n]} although we will often omit the braces.
Special sequences:
1 n0
0 otherwise
(
1 n=0
Unit impulse: [n] =
0 otherwise
(
1 condition is true
Condition: condition [n] =
(e.g. u[n] = n0 )
0 otherwise
Right-sided: x[n] = 0 for n < Nmin
Left-sided: x[n] = 0 for n > Nmax
Finite length: x[n] = 0 for n
/ [Nmin , Nmax ]
Causal: x[n] = 0 for n < 0, Anticausal: x[n] = 0 for n > 0
P
2
Finite Energy: n=P
(e.g. x[n] = n1 u[n 1])
|x[n]| <

Absolutely Summable: n= |x[n]| < Finite energy

Unit step: u[n] =

DSP and Digital Filters (2014-5289)

Introduction: 1 7 / 16

Time Scaling
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary

For sampled signals, the nth sample is at time t = nT =


is the sample frequency.

n
fs

where fs =

1
T

Often easiest to scale time so that fs = 1 Hz. E.g. to design a 1 kHz


low-pass filter for fs = 44.1 kHz we can design a 0.0227 Hz filter for
fs = 1 Hz.
To scale back to real-world values: Every quantity of dimension (Time)n is
multiplied by T n (or equivalently by fsn ). Thus all times are multiplied by
T and all frequencies and angular frequencies by T 1 .
We use for real angular frequencies and for normalized angular
frequency. The units of are radians per sample.
Warning: Several MATLAB routines scale time so that fs = 2 Hz. Weird,
non-standard and irritating.

DSP and Digital Filters (2014-5289)

Introduction: 1 8 / 16

z-Transform
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary

The z-transform converts a sequence, {x[n]}, into a function, X(z), of an


arbitrary complex-valued variable z.
Why do it?
Complex functions are easier to manipulate than sequences
Useful operations on sequences correspond to simple operations on
the z-transform:
addition, multiplication, scalar multiplication, time-shift,
convolution
P
n
Definition: X(z) = +
x[n]z
n=

DSP and Digital Filters (2014-5289)

Introduction: 1 9 / 16

Region of Convergence
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary

The set of z for which X(z) converges is its Region of Convergence (ROC).
Complex analysis : the ROC of a power series (if it exists at all) is always
an annular region of the form 0 Rmin < |z| < Rmax .
X(z) will always converge absolutely inside the ROC and may converge on
some, all, or none of the boundary.
P+
converge absolutely n= |x[n]z n | <
finite Rmin = 0, Rmax =
ROC may included either, both or none of 0 and
absolutely summable X(z) converges for |z| = 1.
right-sided Rmax =
causal X() converges
left-sided Rmin = 0
anticausal X(0) converges

DSP and Digital Filters (2014-5289)

Introduction: 1 10 / 16

z-Transform examples
The sample at n = 0 is indicated by an open circle.
u[n]

1
1z 1

1 < |z|

x[n]

2z 2 + 2 + z 1

0 < |z| <

x[n 3]

2z + 2 + z

0 < |z|

n u[n]=0.8

1
1z 1

n u[n 1]

1
1z 1

0 |z| <

nu[n]

z 1
12z 1 +z 2

1 < |z|

sin(n)u[n]=0.5

z 1 sin()
12z 1 cos()+z 2

1 < |z|

cos(n)u[n]=0.5

1z 1 cos()
12z 1 cos()+z 2

1 < |z|

< |z|

Note: Examples 4 and 5 have the same z-transform but different ROCs.
Pr
Geometric Progression: n=q n z n =

DSP and Digital Filters (2014-5289)

q z q r+1 z r1
1z 1

Introduction: 1 11 / 16

Rational z-Transforms
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational
z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary

Most z-transforms that we will meet are rational polynomials with real
coefficients, usually one polynomial in z 1 divided by another.
G(z) = g

QM

1
m=1 1zm z
QK
1 )
k=1 (1pk z

QM
(zzm )
gz KM Qm=1
K
k1 (zpk )

Completely defined by the poles, zeros and gain.


The absolute values of the poles define the ROCs:
R + 1 different ROCs
where R is the number of distinct pole magnitudes.
Note: There are K M zeros or M K poles at z = 0 (easy to overlook)

DSP and Digital Filters (2014-5289)

Introduction: 1 12 / 16

Rational example
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary

G(z) =

82z 1
44z 1 3z 2

2z(z0.25))
Poles/Zeros: G(z) = (z+0.5)(z1.5)
Poles at z = {0.5, +1.5)},
Zeros at z = {0, +0.25}

Partial Fractions: G(z) =


ROC

ROC

0 |z| < 0.5

0.5 < |z| < 1.5

1.5 < |z|

DSP and Digital Filters (2014-5289)

0.75
1+0.5z 1

1.25
11.5z 1

0.75
1+0.5z 1

1.25
11.5z 1

G(z)

Introduction: 1 13 / 16

Inverse z-Transform
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse
z-Transform
MATLAB routines
Summary

1
2j

G(z)z n1 dz where the integral is anti-clockwise around a


g[n] =
circle within the ROC, z = Rej .
H

Proof:
H
1
n1
G(z)z
dz=
2j

1
2j

H P

n1
g[m]z
z
dz
m=
H nm1
(i) P
1
= m= g[m] 2j z
dz
(ii) P
= m= g[m][n m]= g[n]
m

(i) depends on the circle with radius R lying within the ROC
H k1
1
(ii) Cauchys theorem: 2j z
dz = [k] for z = Rej anti-clockwise.
H k1
R 2 k1 j(k1)
1
1
dz
j
e
jRej d
z
dz = 2j =0 R
d = jRe 2j
R
Rk 2 jk
= 2 =0 e d
= Rk (k)= (k)

[R0 = 1]

In practice use a combination of partial fractions and table of z-transforms.

DSP and Digital Filters (2014-5289)

Introduction: 1 14 / 16

MATLAB routines
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary

tf2zp,zp2tf
residuez
tf2sos,sos2tf
zp2sos,sos2zp
zp2ss,ss2zp

tf2ss,ss2tf

DSP and Digital Filters (2014-5289)

b(z 1)
a(z 1 ) {zm , pk , g}
P
b(z 1)
rk

1
k 1pk z 1
a(z )
Q b0,l +b1,l z1 +b2,l z2
b(z 1)
l 1+a1,l z 1 +a2,l z 2
a(z 1 )
Q b0,l +b1,l z1 +b2,l z2
{zm , pk , g} l 1+a1,l z1 +a2,l z2
(

x = Ax + Bu
{zm , pk , g}
y = Cx + Du
(
x = Ax + Bu
b(z 1)
a(z 1 )
y = Cx + Du

Introduction: 1 15 / 16

Summary
1: Introduction
Organization
Signals
Processing
Syllabus
Sequences
Time Scaling
z-Transform
Region of
Convergence
z-Transform examples
Rational z-Transforms
Rational example
Inverse z-Transform
MATLAB routines
Summary

Time scaling: assume fs = 1 Hz so <


P
n
z-transform: X(z) = +
n= x[n]
ROC: 0 Rmin < |z| < Rmax
Causal: ROC
Absolutely summable: |z| = 1 ROC
H
1
Inverse z-transform: g[n] = 2j G(z)z n1 dz
Not unique unless ROC is specified
Use partial fractions and/or a table

For further details see Mitra:1 & 6.

DSP and Digital Filters (2014-5289)

Introduction: 1 16 / 16

2: Three Different

Fourier Transforms
Fourier Transforms
Convergence of
DTFT
DTFT Properties
DFT Properties
Symmetries
Parsevals Theorem
Convolution
Sampling Process
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

2: Three Different Fourier Transforms

DSP and Digital Filters (2014-5289)

Fourier Transforms: 2 1 / 13

Fourier Transforms
2: Three Different
Fourier Transforms
Fourier Transforms
Convergence of
DTFT
DTFT Properties
DFT Properties
Symmetries
Parsevals Theorem
Convolution
Sampling Process
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

Three different Fourier Transforms:


Continuous-Time Fourier Transform (CTFT): x(t) X(j)
Discrete-Time Fourier Transform (DTFT): x[n] X(ej )
Discrete Fourier Transform (DFT): x[n] X[k]
CTFT
DTFT
DFT

Forward Transform
R
X(j) = x(t)ejt dt
P
j
X(e ) = x[n]ejn
PN 1
kn
X[k] = 0
x[n]ej2 N

Inverse Transform
R
1
x(t) = 2 X(j)ejt d
R
1
x[n] = 2 X(ej )ejn d
PN 1
kn
1
X[k]ej2 N
x[n] = N 0

We use for real and = T for normalized angular frequency.


Nyquist frequency is = 2 f2s = T and = .
For power signals (energy time interval), CTFT & DTFT are
unbounded.
Fix this by normalizing:
RA
1
X(j) = limA 2A A x(t)ejt dt
PA
1
j
X(e ) = limA 2A A x[n]ejn

DSP and Digital Filters (2014-5289)

Fourier Transforms: 2 2 / 13

Convergence of DTFT
2: Three Different
Fourier Transforms
Fourier Transforms
Convergence of
DTFT
DTFT Properties
DFT Properties
Symmetries
Parsevals Theorem
Convolution
Sampling Process
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

DTFT: X(e ) = x[n]ejn does not converge for all x[n].


PK
j
Consider the finite sum: XK (e ) = K x[n]ejn
Strong Convergence:
j
x[n]
absolutely
summable

X(e
) converges uniformly

P
X(ej ) XK (ej ) 0
|x[n]|
<

sup

Weaker convergence:
x[n] finite energy X(ej ) converges in mean square

R
P
2
1
j
j 2

0
|x[n]| < 2 X(e ) XK (e ) d
K

Example: x[n] =

sin 0.5n
n

K=5

K=20

1
0.8

0.6

0.6

0.6

0.4

0.2

0.2

-0.2
0

0.1
0.2
0.3
0.4
/2 (rad/sample)

0.5

0.4

0.8
j

0.8

-0.2
0

K=50

0.4
0.2
0

0.1
0.2
0.3
0.4
/2 (rad/sample)

0.5

-0.2
0

0.1
0.2
0.3
0.4
/2 (rad/sample)

0.5

Gibbs phenomenon:
Converges at each as K but peak error does not get smaller.
DSP and Digital Filters (2014-5289)

Fourier Transforms: 2 3 / 13

[DTFT Convergence Proofs]


(1) Strong Convergence:
[these proofs are not examinable]
P
P
|x[n]| <
|x[n]|
<

>
0,

N
such
that
We are given that
|n|>N





P

For K N , sup X(ej ) XK (ej ) = sup |n|>K x[n]ejn
P

 P
jn

=
sup
|n|>K |x[n]| <
|n|>K x[n]e
(2) Weak Convergence:

P
P
2
2
|x[n]|
<

>
0,

N
such
that
We are given that
|n|>N |x[n]| <

(
P
0
|n| K
[K] [n]ejn
Define y [K] [n] =
so that its DTFT is, Y [K] (ej ) =
y
x[n] |n| > K
P
PK
jn
jn
We see that X(ej ) XK (ej ) =
x[n]e

K x[n]e
P
P
[K] [n]ejn = Y [K] (ej )
= |n|>K x[n]ejn =
y
[K] 2


R
P
y [n] = 1 Y [K] (ej ) 2 d
From Parsevals theorem,

2

R
1
X(ej ) XK (ej ) 2 d
= 2



R
P [K] 2 P

1
j ) X (ej ) 2 d =
[n] = |n|>N |x[n]|2 <
X(e
Hence for K N , 2
K
y

DSP and Digital Filters (2014-5289)

Fourier Transforms: 2 note 1 of slide 3

DTFT Properties
2: Three Different
Fourier Transforms
Fourier Transforms
Convergence of
DTFT
DTFT Properties
DFT Properties
Symmetries
Parsevals Theorem
Convolution
Sampling Process
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

DTFT: X(e ) = x[n]ejn


DTFT is periodic in : X(ej(+2m ) = X(ej ) for integer m.
z-Transform evaluated at the point ej :
DTFT is the P

X(z) = x[n]z n
DTFT converges iff the ROC includes |z| = 1.
DTFT is the same as the CTFT of a signal comprising impulses at
:
the sample times
P (dirac delta functions)P
x (t) = x[n](t nT )= x(t)
(t nT )
Equivalent to multiplying a continuous x(t) by an impulse train.
P
j
Proof: X(e ) = x[n]ejn
R
P
j Tt
dt
n= x[n] (t nT )e
(i) R P
t
= n= x[n](t nT )ej T dt
(ii) R
= x (t)ejt dt
P
(i) OK if
(ii) use = T .
|x[n]| < .

DSP and Digital Filters (2014-5289)

Fourier Transforms: 2 4 / 13

DFT Properties
2: Three Different
Fourier Transforms
Fourier Transforms
Convergence of
DTFT
DTFT Properties
DFT Properties
Symmetries
Parsevals Theorem
Convolution
Sampling Process
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

DFT: X[k] =
j

PN 1
0

DTFT: X(e ) =

kn

x[n]ej2 N

x[n]ejn

Case 1: x[n] = 0 for n


/ [0, N 1]
DFT is the same as DTFT at k =

2
N k.

The {k } are uniformly spaced from = 0 to = 2 NN1 .


DFT is the z-Transform evaluated at N equally spaced points
around the unit circle beginning at z = 1.
Case 2: x[n] is periodic with period N
DFT equals the normalized DTFT
N
X[k] = limK 2K+1
XK (ejk )
P
jn
where XK (ej ) = K
K x[n]e

DSP and Digital Filters (2014-5289)

Fourier Transforms: 2 5 / 13

Symmetries
2: Three Different
Fourier Transforms
Fourier Transforms
Convergence of
DTFT
DTFT Properties
DFT Properties
Symmetries
Parsevals Theorem
Convolution
Sampling Process
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

If x[n] has a special property then X(ej )and X[k] will have corresponding
properties as shown in the table (and vice versa):
One domain
Discrete
Symmetric
Antisymmetric
Real
Imaginary
Real + Symmetric
Real + Antisymmetric

Symmetric: x[n] = x[n]


X(ej ) = X(ej )
X[k] = X[(k)mod

Other domain
Periodic
Symmetric
Antisymmetric
Conjugate Symmetric
Conjugate Antisymmetric
Real + Symmetric
Imaginary + Antisymmetric

] = X[N k] for k > 0

Conjugate Symmetric: x[n] = x [n]


Conjugate Antisymmetric: x[n] = x [n]
DSP and Digital Filters (2014-5289)

Fourier Transforms: 2 6 / 13

Parsevals Theorem
2: Three Different
Fourier Transforms
Fourier Transforms
Convergence of
DTFT
DTFT Properties
DFT Properties
Symmetries
Parsevals

Theorem

Convolution
Sampling Process
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

Fourier transforms preserve energy


R
R
2
1
|x(t)| dt = 2 |X(j)|2 d
CTFT

R
P
2
1
j 2

DTFT
|x[n]| = 2 X(e ) d
PN 1
PN 1
2
2
1
DFT
|x[n]|
=
|X[k]|
0
0
N

More generally, they actually preserve complex inner products:


PN 1
0

x[n]y [n] =

1
N

PN 1
0

X[k]Y [k]

Unitary matrix viewpoint for DFT:

If we regard x and X as vectors, then X = Fx where F is


kn
a symmetric matrix defined by fk+1,n+1 = ej2 N .
The inverse DFT matrix is F1 = N1 FH
equivalently, G = 1N F is a unitary matrix with GH G = I.

DSP and Digital Filters (2014-5289)

Fourier Transforms: 2 7 / 13

Convolution
2: Three Different
Fourier Transforms
Fourier Transforms
Convergence of
DTFT
DTFT Properties
DFT Properties
Symmetries
Parsevals Theorem
Convolution
Sampling Process
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

DTFT: Convolution Product


P
x[n] = g[n] h[n]= k= g[k]h[n k]
X(ej ) = G(ej )H(ej )
DFT: Circular convolutionPProduct
1
x[n] = g[n] N h[n]= N
k=0 g[k]h[(n k)modN ]
X[k] = G[k]H[k]
DTFT: Product Circular Convolution 2
y[n] = g[n]h[n]
R
1
1
j
j
j
Y (e ) = 2 G(e ) H(e ) = 2 G(ej )H(ej() )d
DFT: Product Circular Convolution N
y[n] = g[n]h[n]
X[k] = N1 G[k] N H[k]
g[n] :

DSP and Digital Filters (2014-5289)

h[n] :

g[n] h[n] :

g[n] 3 h[n]

Fourier Transforms: 2 8 / 13

Sampling Process
Time

Time

Frequency
CTFT

Analog

Low Pass
Filter

CTFT

Sample

DTFT

Window

DTFT

DFT

DSP and Digital Filters (2014-5289)

DFT

Fourier Transforms: 2 9 / 13

Zero-Padding
2: Three Different
Fourier Transforms
Fourier Transforms
Convergence of
DTFT
DTFT Properties
DFT Properties
Symmetries
Parsevals Theorem
Convolution
Sampling Process
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

Zero padding means added extra zeros onto the end of x[n] before
performing the DFT.
Time x[n]

Frequency |X[k]|

Windowed
Signal
With zeropadding

Zero-padding causes the DFT to evaluate the DTFT at more values


of k . Denser frequency samples.
Width of the peaks remains constant: determined by the length and
shape of the window.
Smoother graph but increased frequency resolution is an illusion.
DSP and Digital Filters (2014-5289)

Fourier Transforms: 2 10 / 13

Phase Unwrapping
2: Three Different
Fourier Transforms
Fourier Transforms
Convergence of
DTFT
DTFT Properties
DFT Properties
Symmetries
Parsevals Theorem
Convolution
Sampling Process
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

Phase of a DTFT is only defined to within an integer multiple of 2.


6
4
2
0

-2

x[n]

0
(rad/sample)

|X[k]|
0

2
0

-20

-2
-2

0
(rad/sample)

X[k]

-40

-2

0
(rad/sample)

X[k] unwrapped

Phase unwrapping adds multiples of 2 onto each X[k] to make the


phase as continuous as possible.
DSP and Digital Filters (2014-5289)

Fourier Transforms: 2 11 / 13

Summary
2: Three Different
Fourier Transforms
Fourier Transforms
Convergence of
DTFT
DTFT Properties
DFT Properties
Symmetries
Parsevals Theorem
Convolution
Sampling Process
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

Three types: CTFT, DTFT, DFT


DTFT = CTFT of continuous signal impulse train
DFT = DTFT of periodic or finite support signal







DFT is a scaled unitary transform

DTFT: Convolution Product; Product Circular Convolution


DFT: Product Circular Convolution
DFT: Zero Padding Denser freq sampling but same resolution
Phase is only defined to within a multiple of 2.
Whenever you integrate frequency components you get a scale factor
1
2
for CTFT and DTFT or N1 for DFT
Inverse transform, Parseval, frequency domain convolution

For further details see Mitra: 3 & 5.

DSP and Digital Filters (2014-5289)

Fourier Transforms: 2 12 / 13

MATLAB routines
2: Three Different
Fourier Transforms
Fourier Transforms
Convergence of
DTFT
DTFT Properties
DFT Properties
Symmetries
Parsevals Theorem
Convolution
Sampling Process
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

fft, ifft
fftshift
conv
x[n]y[n]
unwrap

DFT with optional zero-padding


swap the two halves of a vector
convolution or polynomial multiplication (not
circular)
real(ifft(fft(x).*fft(y)))
remove 2 jumps from phase spectrum

DSP and Digital Filters (2014-5289)

Fourier Transforms: 2 13 / 13

3: Discrete Cosine

Transform

DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy Compaction
Frame-based coding
Lapped Transform

3: Discrete Cosine Transform

MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

DSP and Digital Filters (2014-5349)

Transforms: 3 1 / 15

DFT Problems
3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy Compaction
Frame-based coding
Lapped Transform

MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

For processing 1-D or 2-D signals (especially coding), a common method is


to divide the signal into frames and then apply an invertible transform to
each frame that compresses the information into few coefficients.
The DFT has some problems when used for this purpose:
N real x[n] N complex X[k] : 2 real,

N
2

1 conjugate pairs

DFT the DTFT of a periodic signal formed by replicating x[n] .


Spurious frequency components from boundary discontinuity.

N=20
f=0.08

The Discrete Cosine Transform (DCT) overcomes these problems.

DSP and Digital Filters (2014-5349)

Transforms: 3 2 / 15

DCT
3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy Compaction
Frame-based coding
Lapped Transform

MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

To form the Discrete Cosine Transform (DCT), replicate x[0 : N 1] but in


reverse order and insert a zero between each pair of samples:
y[r]

12

23

Take the DFT of length 4N real symmetric sequence


Result is real, symmetric and anti-periodic: only need first N values
Y[k]
12
0

Forward DCT: XC [k] =

23

PN 1

Compare DFT: XF [k] =


DSP and Digital Filters (2014-5349)

n=0

x[n] cos 2(2n+1)k


for k = 0 : N 1
4N

PN 1
n=0

x[n] exp j2(4n+0)k


4N
Transforms: 3 3 / 15

DCT of sine wave


3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy Compaction
Frame-based coding
Lapped Transform

DCT: XC [k] =

n=0

x[n] cos 2(2n+1)k


4N

f=

MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

PN 1

x[n]

N=20
f=0.10

m
N

f 6=

m
N

N=20
f=0.08

|XF [k]|

|XC [k]|
DFT:
DCT:

RealComplex; Freq range [0, 1]; Poorly localized


m
; |XF [k]| k1 for N f < k N2
unless f = N
RealReal; Freq range [0, 0.5]; Well localized f ;
|XC [k]| k2 for 2N f < k < N

DSP and Digital Filters (2014-5349)

Transforms: 3 4 / 15

DCT/DFT Equivalence
3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy Compaction
Frame-based coding
Lapped Transform

MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

y[r]

XC [k] =

PN 1
n=0

x[n] cos 2(2n+1)k


4N
0

12

23

r even
0 

Define y[r] = x r1
r = 1 : 2 : 2N 1
2



4N 1r
x
r = 2N + 1 : 2 : 4N 1
2
P4N 1
j2
kr
YF [k] = r=0 y[r]W4N
where WM = e M
(i) P2N 1
(2n+1)k
= n=0 y[2n + 1]W4N
(ii) PN 1
(2n+1)k
= n=0 y[2n + 1]W4N
P 1
(4N 2m1)k
+ N
y[4N

2m

1]W
4N
m=0
P 1
(iii) P
(2n+1)k
(2m+1)k
=
x[n]W4N
+ N
x[m]W
4N
m=0
P 1
2(2n+1)k
= 2XC [k]
=2 N
x[n]
cos
n=0
4N

(i) odd r only: r = 2n + 1, (ii) reverse order for n N : m = 2N 1 n


4N k
= ej2
(iii) substitute y definition & W4N
DSP and Digital Filters (2014-5349)

4N k
4N

1
Transforms: 3 5 / 15

DCT Properties
3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy Compaction
Frame-based coding
Lapped Transform

MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

Definition: X[k] = n=0 x[n] cos 2(2n+1)k


4N
Linear: x[n] + y[n] X[k] + Y [k]
DFT ConvolutionMultiplication property does not hold /
Symmetric: X[k] = X[k] since cos k = cos +k
Anti-periodic: X[k + 2N ] = X[k] because:
cos ( + ) = cos
2(2n + 1)(k + 2N ) = 2(2n + 1)k + 8N n + 4N
X[N ] = 0 since X[N ] = X[N ] = X[N + 2N ]
Periodic: X[k + 4N ] = X[k + 2N ] = X[k]
DCT basis functions:
PN 1

3:
0:

1:

4:

2:

5:

DSP and Digital Filters (2014-5349)

Transforms: 3 6 / 15

IDCT
3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy Compaction
Frame-based coding
Lapped Transform

1
4N

P4N 1

y[r] =
x[n] = y[2n

P4N 1
rk
rk
1
k=0 Y [k]W4N = 2N
k=0 X[k]W4N
P4N 1
(2n+1)k
1
[Y [k]
+ 1] = 2N k=0 X[k]W4N

= 2X[k]]

Y[k]

(i)

P2N 1
(2n+1)k
1
= 2N
X[k]W
4N
k=0
P
(2n+1)(l+2N )
2N
1
1
X[l]W
2N
4N
l=0

MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

x[n]

12
23

(ii) 1 P2N 1
2b
(2n+1)k
Wab = ej a
= N k=0 X[k]W4N
PN 1
(iii) 1
(2n+1)N
(2n+1)k
1
+ N1 X[N ]W4N
= N X[0] + N k=1 X[k]W4N
PN 1
(2n+1)(2N r)
1
+ N r=1 X[2N r]W4N
PN 1
(iv) 1
(2n+1)k
1
= N X[0] + N k=1 X[k]W4N
PN 1
(2n+1)r+2N
1
+ N r=1 X[r]W4N
P 1
2(2n+1)k
X[k]
cos
= N1 X[0] + N2 N
= Inverse DCT
k=1
4N

(i) k = l + 2N for k 2N and X[k + 2N ] = X[k]


(2n+1)l
)
1
=
+
n
+
(ii) (2n+1)(l+2N
4N
4N
2
(iii) k = 2N r for k > N
(iv) X[N ] = 0 and X[2N r] = X[r]
DSP and Digital Filters (2014-5349)

Transforms: 3 7 / 15

Energy Conservation
3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy
Conservation
Energy Compaction
Frame-based coding
Lapped Transform

DCT: X[k] =
IDCT: x[n] =

Y[k]

y[r]

rep

DFT

MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

2(2n+1)k
x[n]
cos
n=0
PN 14N
2(2n+1)k
1
2
X[0]
+
X[k]
cos
k=1
N
N
4N

PN 1

Energy: E =
E=

12

12
0

23

23

2
|x[n]|
: E 2E 8N E 0.5N E
n=0
PN 1
|X|2 [0] + N2 n=1
|X|2 [n]

PN 1
1
N

Orthogonal DCT (preserves


energy) q
q
q
2k
1
2

c[0]
=
,
c[k
=
6
0]
=
Define: c[k] =
N
N
N
PN 1
ODCT: X[k] = c[k] n=0 x[n] cos 2(2n+1)k
4N
PN 1
IODCT: x[n] = k=0 c[k]X[k] cos 2(2n+1)k
4N

Note: MATLAB dct() calculates the ODCT

DSP and Digital Filters (2014-5349)

Transforms: 3 8 / 15

Energy Compaction
3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy
Compaction
Frame-based coding
Lapped Transform

MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

If consecutive x[n] are positively correlated, DCT concentrates energy in a


few X[k] and decorrelates them.
p
Example: Markov Process: x[n] = x[n 1] + 1 2 u[n]
where
u[n] is i.i.d. unit Gaussian.
Then x2 [n] = 1 and hx[n]x[n 1]i = .

H
Covariance of vector x is Si,j = xx i,j = |ij| .

Suppose ODCT of x is Cx
D and DFT Eis Fx.
Covariance of Cx is CxxH CH = CSCH (similarly FSFH )
Diagonal elements give mean coefficient energy.
Used in MPEG and JPEG (superseded by
JPEG2000 using wavelets)
Used in speech recognition to decorrelate
spectral coeficients: DCT of log spectrum
Cumulative energy (%)

100

DCT

90
80
70

DFT

60

=0.9
N=32

50

10
15
20
No of coefficients

25

30

Energy compaction good for coding (low-valued coefficients can be set to 0)


Decorrelation good for coding and for probability modelling
DSP and Digital Filters (2014-5349)

Transforms: 3 9 / 15

Frame-based coding
3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy Compaction

Divide continuous signal


into frames

x[n]

Apply DCT to each frame

X[k]

Encode DCT

y[n]

k=30/220

y[n]-x[n]

e.g. keep only 30 X[k]

Frame-based

coding

Lapped Transform
MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

Apply IDCT y[n]


Problem: Coding may create discontinuities at frame boundaries
e.g. JPEG, MPEG use 8 8 pixel blocks

8.3 kB (PNG)
DSP and Digital Filters (2014-5349)

1.6 kB (JPEG)

0.5 kB (JPEG)
Transforms: 3 10 / 15

Lapped Transform
3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy Compaction
Frame-based coding
Lapped Transform

MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

Modified Discrete Cosine Transform (MDCT): overlapping frames 2N long


x[0 : 2N 1]
MDCT
X0 [0 : N 1]
IMDCT
y0 [0 : 2N 1]

x[n]

X1 [N : 2N 1]
IMDCT
y1 [N : 3N 1]

x[2N : 4N 1]
MDCT
X2 [2N : 3N 1]
IMDCT
y2 [2N : 3N 1]

2N

3N

4N

2N

3N

4N

X0[k]

x[N : 3N 1]
MDCT

X1[k]

X2[k]

y0[n]
y1[n]

y2[n]
y[n]
y[n]-x[n] = error
0

y[n] = y0 [n] + y1 [n] + y2 [n]


MDCT: 2N N coefficients, IMDCT: N 2N samples
Add yi [n] together to get y[n]. Only two non-zero terms far any n.
Errors cancel exactly: Time-domain alias cancellation (TDAC)
DSP and Digital Filters (2014-5349)

Transforms: 3 11 / 15

MDCT (Modified DCT)


3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy Compaction
Frame-based coding
Lapped Transform
MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

MDCT: XM [k] =

P2N 1

IMDCT: yA,B [n] =

n=0

1
N

)(2k+1)
x[n] cos 2(2n+1+N
8N

PN 1
k=0

)(2k+1)
XM [k] cos 2(2n+1+N
8N

MDCT from a DCT of length 2N :


N
Split x[n]
into
four
-vectors:
2

x= a b c d

Form hthe N -vector


i

u = d
c a b

where
c is in reverse order



Form v = u u
Take 2N DCT: v VC

Symmetry VC [2k] = 0

N
a

2N

-d -c<

1N
d

u1,2

-b<

v
VC

XM
0

1N

2N

Set XM [k] = VC [2k + 1]


MDCT calculates N coefficients from 2N data points
DSP and Digital Filters (2014-5349)

Transforms: 3 12 / 15

IMDCT & TDAC


IMDCT
Start with N coefficients XM [k]
Create 2N long VC : VC [2k + 1] = XM [k] and VC [2k] = 0



Take IDCT VC v = u u

From previous slide: v = [d


c a b b
a c+ d ]

Set y0 = [ a b b
a c+ d d+
c ]

[2N long]

Time-domain Alias Cancellation (TDAC)


y0
y1

=
=

y0 + y1

a b

b
a

c+ d

c d

d+
c

d
c

e+ f

f +
e

2c

2d

Where consecutive frames overlap, all errors cancel out.


With a suitable window, frame-edge discontinuities can be eliminated.
MDCT is used in audio coding: MP3, WMA, AC-3, AAC, Vorbis, ATRAC
DSP and Digital Filters (2014-5349)

Transforms: 3 13 / 15

Summary
3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy Compaction
Frame-based coding
Lapped Transform

DCT: Discrete Cosine Transform





Equivalent to a DFT of time-shifted double-length x x


Often scaled to make an orthogonal transform (ODCT)
Better than DFT for energy compaction and decorrelation ,
Energy Compaction: Most energy is in only a few coefficients
Decorrelation: The coefficients are uncorrelated with each other
Nice convolution property of DFT is lost /

MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

MDCT: Modified Discrete Cosine Transform


Lapped transform: 2N N 2N
Aliasing errors cancel out when overlapping output frames are added
Similar to DCT for energy compaction and decorrelation ,
Overlapping windowed frames can avoid edge effects ,

For further details see Mitra: 5.

DSP and Digital Filters (2014-5349)

Transforms: 3 14 / 15

MATLAB routines
3: Discrete Cosine
Transform
DFT Problems
DCT
DCT of sine wave
DCT/DFT
Equivalence
DCT Properties
IDCT
Energy Conservation
Energy Compaction
Frame-based coding
Lapped Transform

dct, idct

ODFT with optional zero-padding

MDCT (Modified
DCT)
IMDCT & TDAC
Summary
MATLAB routines

DSP and Digital Filters (2014-5349)

Transforms: 3 15 / 15

4: Linear Time

Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

4: Linear Time Invariant Systems

DSP and Digital Filters (2014-5233)

LTI Systems: 4 1 / 14

LTI Systems
4: Linear Time
Invariant Systems
LTI Systems

Convolution
Properties
BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

Linear Time-invariant (LTI) systems have two properties:


Linear: H (u[n] + v[n]) = H (u[n]) + H (v[n])
Time Invariant: y[n] = H (x[n]) y[n r] = H (x[n r]) r
The behaviour of an LTI system is completely defined by its impulse
response: h[n] = H ([n])
Proof:
P
We can always write x[n] = r= x[r][n r]

P
Hence
H (x[n]) = H
r= x[r][n r]
P
= r= x[r]H ([n r])
P
= r= x[r]h[n r]
= x[n] h[n]

DSP and Digital Filters (2014-5233)

LTI Systems: 4 2 / 14

Convolution Properties
4: Linear Time
Invariant Systems
LTI Systems
Convolution

Properties

BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

Convolution: x[n] v[n] =

r= x[r]v[n

r]

Convolution obeys normal arithmetic rules for multiplication:


Commutative: x[n] v[n] = v[n] x[n]
P
(i) P
Proof: r x[r]v[n r] = p x[n p]v[p]
(i) substitute p = n r
Associative: x[n] (v[n] w[n]) = (x[n] v[n]) w[n]
x[n] v[n] w[n] is unambiguous
P
(i) P
Proof: r,s x[n r]v[r s]w[s] = p,q x[p]v[q p]w[n q]
(i) substitute p = n r, q = n s
Distributive over +:
x[n] (v[n]P+ w[n]) = (x[n] v[n]) + (x[n] w[n])
Proof: r x[n r] (v[r]P
+ w[r]) =
P
r x[n r]v[r] + r x[n r]w[r]
Identity: x[n] [n] = x[n]
P
(i)
Proof: r [r]x[n r] = x[n]

DSP and Digital Filters (2014-5233)

(i) all terms zero except r = 0.


LTI Systems: 4 3 / 14

BIBO Stability
4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

BIBO Stability: Bounded Input, x[n] Bounded Output, y[n]


The following are equivalent:
(1) An LTI system is BIBO stable P

(2) h[n] is absolutely summable, i.e. n= |h[n]| <


(3) H(z) region of absolute convergence includes |z| = 1.
Proof (1) (2):(

1
h[n] 0
Define x[n] =
1 h[n] < 0
P
P
then y[0] =P x[0 n]h[n] = |h[n]|.
But |x[n]| 1n so BIBO y[0] =
|h[n]| < .

Proof (2) P(1):


Suppose
|h[n]| = S < and |x[n]| B is bounded.
P



Then |y[n]| =
r= x[n r]h[r]
P
r= |x[n r]| |h[r]|
P
B r= |h[r]| BS <

DSP and Digital Filters (2014-5233)

LTI Systems: 4 4 / 14

Frequency Response
4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency
Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

H(ej ) = 1 + ej + ej2
= ej (1 + 2 cos )


H(ej ) = |1 + 2 cos |
cos )
H(ej ) = + 1sgn(1+2
2

Sign change in (1 + 2 cos ) at = 2.1 gives


(a) gradient discontinuity in |H(ej )|
(b) an abrupt phase change of .

3
2
1
0

DSP and Digital Filters (2014-5233)

5
0
-5
-10
0

d
H(ej )
d

: gives delay of the


Group delay is
modulation envelope at each .
Normally varies with but for a symmetric filter it
is constant: in this case +1 samples.
Discontinuities of k do not affect group delay.

10

1
0

For a BIBO stable system Y (ej ) = X(ej )H(ej )


where H(ej )is the DTFT of h[n] i.e. H(z) evaluated at z = ej .


Example: h[n] = 1 1 1

-1
-2
0

LTI Systems: 4 5 / 14

Causality
4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

Causal System: cannot see into the future


i.e. output at time n depends only on inputs up to time n.
Formal definition:
If v[n] = x[n] for n n0 then H (v[n]) = H (x[n]) for n n0 .
The following are equivalent:
(1) An LTI system is causal
(2) h[n] is causal h[n] = 0 for n < 0
(3) H(z) converges for z =
Any right-sided sequence can be made causal by adding a delay.
All the systems we will deal with are causal.

DSP and Digital Filters (2014-5233)

LTI Systems: 4 6 / 14

Passive and Lossless


4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
Passive and

Lossless

Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

A
system can
Ppassive
Pnever gain energy:

2
2
|y[n]|

|x[n]|
for any finite energy input x[n].
n=
n=


j

A passive LTI system must have H(e ) 1
Somewhat analogous to a circuit consisting of R, L and C only.

A
system always
preserves energy exactly:
Plossless
P

2
2
|y[n]|
=
|x[n]|
for any finite energy input x[n].
n=
n=


j

A lossless LTI system must have H(e ) = 1
called an allpass system.
Somewhat analogous to a circuit consisting of L and C only.

Passive and lossless building blocks can be used to design systems which
are insensitive to coefficient changes

DSP and Digital Filters (2014-5233)

LTI Systems: 4 7 / 14

++Conditions on h[n] and H(z)


Summary of conditions on h[n] for LTI systems:
Causal
BIBO Stable

h[n] = 0 for n < 0


P
n= |h[n]| <

Summary of conditions on H(z) for LTI systems:


Causal
BIBO Stable
Passive
Lossless or Allpass

DSP and Digital Filters (2014-5233)

H() converges
H(z) converges for |z| = 1
|H(z)| 1 for |z| = 1
|H(z)| = 1 for |z| = 1

LTI Systems: 4 note 1 of slide 7

Convolution Complexity
4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

y[n] = x[n] h[n]: convolve x[0 : N 1] with h[0 : M 1]


x

y[0]

y[9]

ConvolutionP
sum:
M 1
y[n] = r=0 h[r]x[n r]

y[n] is only non-zero in the range


0nM +N 2
Thus y[n] has only
M + N 1 non-zero values

Algebraically:

N = 8, M = 3
M + N 1 = 10

x[n r] 6= 0 0 n r N 1
n+1N r n
Pmin(M 1,n))
Hence: y[n] = r=max(0,n+1N ) h[r]x[n r]

We must multiply each h[n] by each x[n] and add them to a total
total arithmetic complexity ( or + operations) 2M N
DSP and Digital Filters (2014-5233)

LTI Systems: 4 8 / 14

Circular Convolution
4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular
Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

y [n] = x[n] N h[n]: circ convolve x[0 : N 1] with h[0 : M 1]


x

y[0]

y[7]

Convolution sum:
yN [n] =

PM 1
r=0

h[r]x[(n r)mod N ]

yN [n] has period N


yN [n] has N distinct values
N = 8, M = 3
Only the first M 1 values are affected by the circular repetition:
yN [n] = y[n] for M 1 n N 1
If we append M 1 zeros (or more) onto x[n], then the circular
repetition has no effect at all and:
yN +M 1 [n] = y[n] for 0 n N + M 2
Circular convolution is a necessary evil in exchange for using the DFT

DSP and Digital Filters (2014-5233)

LTI Systems: 4 9 / 14

Frequency-domain convolution
4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

Idea: Use DFT to perform circular convolution - less computation


(1) Choose L M + N 1 (normally round up to a power of 2)

(2) Zero pad x[n] and h[n] to give sequences of length L: x


[n] and h[n]

H[k])

(3) Use DFT: y[n] = F 1 (X[k]


=x
[n] L h[n]
(4) y[n] = y[n] for 0 n M + N 2.
Arithmetic Complexity:
DFT or IDFT take 4L log2 L operations if L is a power of 2
(or 16L log2 L if not).
Total operations: 12L log2 L 12 (M + N ) log2 (M + N )
Beneficial if both M and N are > 100 .
Example: M = 103 , N = 104 :
Direct: 2M N = 2 107
with DFT: 12 (M + N ) log2 (M + N ) = 1.8 106 ,
But: (a) DFT may be very long if N is large
(b) No output samples until all x[n] has been input.

DSP and Digital Filters (2014-5233)

LTI Systems: 4 10 / 14

Overlap Add
4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

If N is very large:
N
(1) chop x[n] into K
chunks of length K
(2) convolve each chunk with h[n]
(3) add up the results
Each output chunk is of length K + M 1 and overlaps the next chunk
N
Operations: K
8 (M + K) log2 (M + K)
Computational saving if 100 < M K N
Example: M = 500, K = 104 , N = 107
Direct: 2M N = 1010
single DFT: 12 (M + N ) log2 (M + N ) = 2.8 109
N
overlap-add: K
8 (M + K) log2 (M + K) = 1.1 109 ,
Other advantages:
(a) Shorter DFT
(b) Can cope with N =
(c) Can calculate y[0] as soon as x[K 1] has been read:
algorithmic delay = K 1 samples

DSP and Digital Filters (2014-5233)

LTI Systems: 4 11 / 14

Overlap Save
4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

Alternative method:
N
(1) chop x[n] into K
overlapping
chunks of length K + M 1
(2) K+M 1 each chunk with h[n]
(3) discard first M 1 from each chunk
(4) concatenate to make y[n]
The first M 1 points of each output chunk are invalid
Operations: slightly less than overlap-add because no addition needed to
create y[n]
Advantages: same as overlap add
Strangely, rather less popular than overlap-add

DSP and Digital Filters (2014-5233)

LTI Systems: 4 12 / 14

Summary
4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

LTI systems: impulse response, frequency response, group delay


BIBO stable, Causal, Passive, Lossless systems
Convolution and circular convolution properties
Efficient methods for convolution
single DFT
overlap-add and overlap-save

DSP and Digital Filters (2014-5233)

For further details see Mitra: 4 & 5.

LTI Systems: 4 13 / 14

MATLAB routines
4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

fftfilt
x[n]y[n]

Convolution using overlap add


real(ifft(fft(x).*fft(y)))

DSP and Digital Filters (2014-5233)

LTI Systems: 4 14 / 14

5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z
IIR Impulse response
examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

DSP and Digital Filters (2014-5241)

5: Filters

Filters: 5 1 / 19

Difference Equations
5: Filters
Difference
Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z

Most useful LTI systems can be described by a difference equation:


P
PN
y[n] = M
b[r]x[n

r]

r=0
r=1 a[r]y[n r]
PN
PM
r=0 a[r]y[n r] = r=0 b[r]x[n r]
with a[0] = 1
a[n] y[n] = b[n] x[n]

IIR Impulse response


examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

Y (z) =
j

Y (e ) =
(1)
(2)
(3)
(4)

B(z)
A(z) X(z)
B(ej )
j
A(ej ) X(e )

Always causal.
Order of system is max(M, N ), the highest r with a[r] 6= 0 or b[r] 6= 0.
We assume that a[0] = 1; if not, divide A(z) and B(z) by a[0].
Filter is BIBO stable iff roots of A(z) all lie within the unit circle.

Note negative sign in first equation.


Authors in some SP fields reverse the sign of the a[n]: BAD IDEA.

DSP and Digital Filters (2014-5241)

Filters: 5 2 / 19

FIR Filters
5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z

Frequency response is B(ej ) and is the DTFT of b[n].


Comprises M complex sinusoids + const:
b[0] + b[1]ej + + b[M ]ejM

IIR Impulse response


examples
IIR Impulse response

Small M response contains only low quefrencies

Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

A(z) = 1: Finite Impulse Response (FIR) filter: Y (z) = B(z)X(z).


Impulse response is b[n] and is of length M + 1.

Symmetrical b[n]H(ej )e

jM
2

M=4

consists of

M
2

cosine waves [+ const]

M=14

M=24

0.5

0.5

0.5

0
0

0
0

Rule of thumb: Fastest possible transition


DSP and Digital Filters (2014-5241)

0
0

2
M

(marked line)
Filters: 5 3 / 19

FIR Symmetries
5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z

IIR Impulse response


examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

PM

B(e ) is determined by the zeros of z B(z) = r=0 b[M r]z r


Real b[n] conjugate zero pairs: z z
Symmetric: b[n] = b[M n] reciprocal zero pairs: z z 1
Real + Symmetric b[n] conjugate+reciprocal groups of four
or else pairs on the real axis
Real:
Symmetric:
Real + Symmetric:
[1, 1.28, 0.64]

[1, 1.64 + 0.27j, 1]

[1, 3.28, 4.7625, 3.28, 1]

0.5

0.5

0.5

-0.5

-0.5

-0.5

-1

-1

-1

-1

0
z

-1

0
z

-1

0
z

10

2
2
1
0

1
-2

DSP and Digital Filters (2014-5241)

0
(rad/sample)

-2

0
(rad/sample)

-2

0
2
(rad/sample)

Filters: 5 4 / 19

[FIR Symmetry Proofs]


In all of the proofs below, we assume that z = z0 is a root of B(z) so that B(z0 ) =
and then we prove that this implies that other values of z also satisfy B(z) = 0.

PM

r=0

b[r]z0r = 0

(1) Real b[n]



r
b[r]
z
r=0
0
r
PM
= r=0 b [r] z0

P
r
M
=
r=0 b[r]z0

B(z0 ) =

PM

= 0 = 0

since b[r] is real


take complex conjugate
since B(z0 ) = 0

(2) Symmetric: b[n] = b[M n]


B(z01 ) =
=
=
=
=

PM

r
r=0 b[r]z0
PM
M n
n=0 b[M n]z0
P
n
z0M M
n=0 b[M n]z0
P
n
z0M M
n=0 b[n]z0
z0M 0 = 0

DSP and Digital Filters (2014-5241)

substitute r = M n
take out z0M factor
since b[M n] = b[n]
since B(z0 ) = 0

Filters: 5 note 1 of slide 4

IIR Frequency Response

IIR Impulse response


examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

Factorize H(z) =

Q
1
b[0] M
)
B(z)
i=1 (1qi z
QN
=
1
A(z)
)
i=1 (1pi z

Roots of A(z) and B(z) are the poles {pi } and zeros {qi } of H(z)
Also an additional N M zeros at the origin (affect phase only)
M QM


|b[0]|
z
|
| i=1 |zqi |
j
H(ej ) =
Q
for
z
=
e
N
N
|z
|
|zp |
i=1

Example:
H(z) =

2(1+1.2z 1 )
2+2.4z 1
10.96z 1 +0.64z 2 = (1(0.480.64j)z 1 )(1(0.48+0.64j)z 1 )



21.76
j

= 5.6
At = 1.3: H(e ) = 1.620.39
H(ej ) = (0.6 + 1.3) (1.7 + 2.2) = 1.97
1
10

0.5

0
0

DSP and Digital Filters (2014-5241)

0.39
1.76

1.62

-0.5

-0.5

-1

-1
-1

0
(z)

2.2

0.5

5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z

0.6

1.3
1.7

-1

0
(z)

Filters: 5 5 / 19

Negating z

IIR Impulse response


examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

Given a filter H(z) we can form a new one HR (z) = H(z)


Negate all odd powers of z, i.e. negate alternate a[n] and b[n]
Example: H(z) =

2+2.4z 1
10.96z 1 +0.64z 2

1
10

0.5

5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z

0
5

-0.5
-1
-1

0
(z)

Negate z: HR (z) =

0
0

22.4z 1
1+0.96z 1 +0.64z 2

Negate odd coefficients

1
10

0.5
0

-0.5
-1
-1

0
(z)

0
0

Pole and zero positions are negated, frequency response flipped.


DSP and Digital Filters (2014-5241)

Filters: 5 6 / 19

Cubing z
5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z

Given a filter H(z) we can form a new one HC (z) = H(z 3 )


Insert two zeros between each a[n] and b[n] term
Example: H(z) =

Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

1
10

0.5
0

IIR Impulse response


examples
IIR Impulse response

2+2.4z 1
10.96z 1 +0.64z 2

-0.5
-1
-1

0
(z)

Cube z: HC (z) =

-2

0
(rad/sample)

2+2.4z 3
10.96z 3 +0.64z 6

Insert 2 zeros between coefs

1
10
C

0.5
0

-0.5
-1
-1

0
z

-2

0
(rad/sample)

Pole and zero positions are replicated, magnitude response replicated.


DSP and Digital Filters (2014-5241)

Filters: 5 7 / 19

Scaling z
5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z

Given a filter H(z) we can form a new one HS (z) = H( z )


Multiply a[n] and b[n] by n
Example: H(z) =
1

Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

10

0.5
0

IIR Impulse response


examples
IIR Impulse response

2+2.4z 1
10.96z 1 +0.64z 2

-0.5
-1
-1

0
(z)

0
0

z
Scale z: HS (z) = H( 1.1
)=
1

2+2.64z 1
11.056z 1 +0.7744z 2

20

0.5

15

10

-0.5

-1
-1

0
z

0
0

(rad/s)

Pole and zero positions are multiplied by , > 1 peaks sharpened.


Pole at z = p gives peak bandwidth 2 |log |p|| 2 (1 |p|)
For pole near unit circle, decrease bandwidth by 2 log
DSP and Digital Filters (2014-5241)

Filters: 5 8 / 19

IIR Impulse response examples


5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z
IIR Impulse

response examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

To find the impulse response of

B(z)
A(z) ,

use partial fractions:

Example 1: M < N
1

B(z)
A(z)

3
13.4z
= 10.3z
1 0.4z 2 = 1+0.5z 1 +
n
n
h[n] = (3 (0.5) 2 (0.8) ) u[n]

2
10.8z 1

Example 2: M N
B(z)
A(z)

25.7z 1 +0.2z 2 +0.8z 3


=
10.3z 1 0.4z 2
13.4z 1
1
= 1 2z + 10.3z1 0.4z2
2
3
= 1 2z 1 + 1+0.5z
1 + 10.8z 1
n

h[n] = [n] 2[n 1] + (3 (0.5) 2 (0.8) ) u[n]


Example 3: repeated pole at z = 0.5
B(z)
A(z)

1.3z
= 1+0.3z35z
1 0.55z 2 0.2z 3
2
3
2
= 1+0.5z
2 + 10.8z 1
1 +
1
(1+0.5z )
n
n
n
h[n] = (2 (0.5) + 3(n + 1) (0.5) 2 (0.8) ) u[n]

DSP and Digital Filters (2014-5241)

Filters: 5 9 / 19

IIR Impulse response


5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z
IIR Impulse response
examples
IIR Impulse

response

Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

H(z) =

B(z)
A(z)

we want h[n], the inverse z-Transform of H(z).

B(z)
A(z)

(1) Assume M < N else, do a long division: H(z) = D(z) +



QNp
1 Ki
(2) Factorize A(z) = i=1 1 pi z
(Np = # of distinct poles)
PNp PKi

r
B(z)
(3) Then A(z) = i=1 k=1 (1p i,k
(Ki = multiplicity of pi )
1 )k
iz


kKi
K
k
B(z)
d i
i)
1 Ki
where ri,k = (p
(1

p
z
)

i
(Ki k)! d(z 1 )Ki k
A(z)
z=pi

For the common case Ki = 1 i (e.g. all poles distinct):



P

N
B(z)
B(z)
p
ri
1
where
r
=
=
(1

p
z
)
i
i
i=1 1pi z 1
A(z)
A(z)

z=pi

(4) The impulse response is given by


PNp PKi
n+k1
ri,k pni for n 0
h[n] = i=1 k=1 Ck1

n+k1
nk1
is a binomial coefficient Ck1
PNp
For the common case Ki = 1 i: h[n] = i=1 ri pni for n 0

where C =

DSP and Digital Filters (2014-5241)

!
!()!

Filters: 5 10 / 19

[Impulse Response: Proof of (3)]


[You do not need to memorise this proof]

B(z)
A(z)

PNp PKj

rj,l

and we want to determine ri,k


(1pj z1 )l
K
(1) Multiply both sides by 1 pi z 1 i :
Ki
PNp PKj rj,l (1pi z1 )Ki

B(z)
1
1 pi z
= j=1 l=1
A(z)
(1pj z1 )l
now separate out the term with j = i:
Ki
Ki l P
PKi
PKj rj,l (1pi z1 )Ki

B(z)
1
1
1 pi z
= l=1 ri,l 1 pi z
+ j6=i l=1
A(z)
(1pj z1 )l
We assume that

j=1

l=1

(2) DifferentiateKi k times with respect to z 1 :

dKi k
d(z 1 )Ki k

and evaluate at z = pi

1 k Ki Ki k < Ki so we are differentiating < Ki times.



P
PKj rj,l (1pi z1 )Ki
1 in the
Hence all terms in j6=i l=1
will
still
include
a
factor
1

p
z
i
(1pj z1 )l
numerator and will equal zero at z = pi .
K l
PKi
with l < k will also vanish.
ri,l 1 pi z 1 i
Similarly, terms in l=1

PKi
K l
with l > k will also differentiate to zero.
ri,l 1 pi z 1 i
Also, terms in l=1
The only term remaining is: (p)Ki k (Ki k)!ri,k from which the result follows.
[Similarly
DSP and Digital Filters (2014-5241)

dn
(xm )
dxn

x=0

is zero unless m = n in which case it equals m!]


Filters: 5 note 1 of slide 10

[Impulse Response: Proof of (4)]

We use induction on k to show that 1 pz


1 k

[You do not need to memorise this proof]


n+k1 n n
p z
n=0 Ck1

(1) Suppose the formula is true for k and differentiate both sides with respect to z 1 :
o
n
k P
n+k1 n n
d
1
1 pz
= n=0 Ck1 p z
d(z 1 )

This gives:
(k+1) P
P
n+k1 n (n1)
n+k1 n (n1)
p z
p z
=
pk 1 pz 1
= n=0 nCk1
n=1 nCk1

where we have omitted the term with n = 0 because it equals zero.

Now substitute, m = n 1:
(k+1) P
m+k m+1 m
1
p
z
pk 1 pz
= m=0 (m + 1)Ck1

P
P
(k+1)
m+k m m
m+1 m+k m m
1 pz 1
=
p z
p
z
=
C
m=0 k
m=0 Ck
k1
which proves the result for k + 1.

(2) To start the induction at k = 1:


1 P
P
n n
1 pz 1
= n=0 C0n pn z n =
n=0 p z

This is true from the standard geometric progression formula. (Note that C0n = 1 n).

DSP and Digital Filters (2014-5241)

Filters: 5 note 2 of slide 10

Other BIBO responses


5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z
IIR Impulse response
examples
IIR Impulse response
Other BIBO

responses

Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

All LTI systems described by difference equations have h[n] decaying


exponentially or exponentially times a power of n.
It is perfectly possible to have BIBO stable LTI systems whose impulse
responses decay more slowly than this.
1
1+n2

for n 0
P
BIBO stable since
|h[n]| = 2.077... <
Hence H(ej ) exists.

Example: h[n] =

However, no finite difference equation can have this impulse response.


2
1.5
1
0.5
0
0

DSP and Digital Filters (2014-5241)

Filters: 5 11 / 19

Stability Triangle
5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z
IIR Impulse response
examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

Not normally easy to tell if poles lie within


|z| = 1, but easy test for a 2nd order filter:
Suppose A(z) = 1 + a[1]z 1 + a[2]z 2

a[1] a[1]2 4a[2]


The roots are p1,2 =
2
Want the conditions that |p1,2 | < K
Case 1: Real roots:
(P) a[1]2 4a[2]
p
(Q) 2K < a[1] a[1]2 4a[2] < 2K
p
a[1]2 4a[2] < 2K a[1]
a[1]2 4a[2] < 4K 2 4a[1]K + a[1]2

K2

S
R
P

0
Q
-K2
-2K

0
a[1]

2K

a[2] > K 2 a[1]K


Case 2: Complex roots:
(R) a[1]2 < 4a[2]
(S) |p1,2 |2 = a[2] < K 2
Hence coefficients must lie within a stability triangle.

DSP and Digital Filters (2014-5241)

Filters: 5 12 / 19

Low-pass filter
5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z
IIR Impulse response
examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

1p
1pz 1

Impulse response:
n
h[n] = (1 p)pn = (1 p)e
1
where = ln
p is the time constant in samples.


j

Magnitude response: H(e ) = 1p
2
12p cos +p

Low-pass filter with DC gain of unity.




2
(1p)
2 1p
3 dB frequency is 3dB = cos1 1 2p
1+p

1
Compare continuous time: HC (j) = 1+j
Indistinguishable for low but H(ej ) is periodic, HC (j) is not
0

p=0.80
H(j)

-10

0.5

1st order low pass filter: extremely common


y[n] = (1 p)x[n] + py[n 1] H(z) =

-20

-0.5
-30

-1
-1

0
(z)

DSP and Digital Filters (2014-5241)

0.01

HC(j)
1/
0.1
(rad/sample)

Filters: 5 13 / 19

Allpass filters

IIR Impulse response


examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

If a[n] = b[M n] we have an allpass filter


j

H(e ) =

PM

b[r]ejr
r=0
PM
j(M r)
r=0 b[r]e

PM
jr
jM Pr=0 b[r]e
e
M
jr
r=0 b[r]e

The two sums


conjugates they have the same magnitude
arejcomplex

Hence H(e ) = 1 allpass
However phase is not constant: H(ej ) = M + 2B(ej )

1st order allpass: H(z) =

p+z 1
1pz 1 =

1p1 z 1
p 1pz1

Pole at p and zero at p1 : reflected in unit circle



j



Constant distance ratio: e p = |p| ej p1
0

1
0.8

0.5

-1

0.6

5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z

-2

0.4

-0.5

0.2
0
0

-3
0

-1
1

-1

0
(z)

In an allpass filter, the zeros are the poles reflected in the unit circle.
DSP and Digital Filters (2014-5241)

Filters: 5 14 / 19

Group Delay
5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z
IIR Impulse response
examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

dH(ej )
d

= delay of the modulation envelope.




j
j

Trick to get at phase: ln H(e ) = ln H(e ) + jH(ej )




j
d((ln H(ej )))
1 dH(e )
z dH
=

H =
d
H(ej )
d
H(z) dz
z=ej
P
j
H(e ) = n=0 h[n]ejn = F (h[n])
[F = DTFT]
P
dH(ej )
= n=0 jnh[n]ejn = jF (nh[n])
d






j
dH(e
)
jF
(nh[n])
F
(nh[n])
1
= F (h[n]) = F (h[n])
H = H(e
j )
d


pej
1
Example: H(z) = 1pz1 H = [1 p] = 1pej
Group delay: H (e ) =

p=0.80

-0.2

p=0.80

0.5
0

-0.4

-0.6

-0.5

-0.8

-1
-1

0
(z)

0
0

Average group delay (over ) = (# poles # zeros) within the unit circle
Zeros on the unit circle count
DSP and Digital Filters (2014-5241)

Filters: 5 15 / 19

[Group Delay Properties]


The group delay of a filter H(z) at a frequency , measured in seconds or samples, gives the time delay
(ej )

dH(ej )

.
d

of the envelope of a modulated sine wave at a frequency . It is defined as H


=
For example, H(z) = z k defines a filter that delays its input by k samples and we can calculate the
group delay by evaluating
j

H (e

dH(ej )
d  jk 
d
)=
=
e
=
(k) = k
d
d
d

which tells us that this filter has a constant group delay of k samples that is independent of .
The average value of H equals the total change in H(ej ) as goes from to + divided by
2. If you imagine an elastic string connecting a pole or zero to the point z = ej , you can see that as
goes from to + the string will wind once around the pole or zero if it is inside the unit circle but
not if it is outside. Thus, the total change in H(ej ) is equal to 2 times the number of poles inside
the unit circle minus the number of zeros inside the unit circle. A zero that is exactly on the unit circle
counts 12 since there is a sudden discontinuity of in H(ej ) as passes through the zero position.
When you multiply or divide complex numbers, their phases add or subtract, so it follows that when
you multiply or divide transfer functions their group delays will add or subtract. Thus, for example,
B(z)
the group delay of an IIR filter, H(z) = A(z) , is given by H = B A . This means too that we
can determine the group delay of a factorized transfer function by summing the group delays of the
individual factors.

DSP and Digital Filters (2014-5241)

Filters: 5 note 1 of slide 15

[Group Delay from h[n] or H(z)]


The slide shows how to determine the group delay, H , from either the impulse response, h[n], or
the transfer function, H(z). We start by using a trick that is very common: if you want to get at
the magnitude
and phase of a complex number separately, you can do so by taking its natural log:

j
= ln |r| + j or, in general, ln H = ln |H| + jH. By rearranging this equation, we get
ln re
H = (ln H) where ( ) denotes taking the imaginary part of a complex number. Using this, we can
write

!


d ln H(ej )
d ln H(ej )
1 dH(ej )
H =
=
=
.
(1)
d
d
H(ej )
d
dH(ej )

=
By going back to the definition of the DTFT, we find that H(ej ) = F (h[n]) and
d
jF (nh[n]) where F ( ) denotes the DTFT. Substituting these expressions into the above equation
gives us a formula for H in terms of the impulse response h[n].


F (nh[n])
H =
(2)
F (h[n])
In order to express H in terms of z, we first note that if z = ej then
z = ej into equation (1), we get

H =

1 dH(z)
H(z) d

DSP and Digital Filters (2014-5241)

1 dH(z) dz
H(z) dz d

jz dH(z)
H(z) dz

dz
d

= jz. By substituting


z dH(z)
.

H(z) dz
j
z=e

Filters: 5 note 2 of slide 15

[Group Delay Example]


As an example, suppose we want to determine the group delay of : H(z) =

1
.
1pz 1

As noted above,

B(z)
,
A(z)

then H = B A . In this case B = 0 so H = [1 p] .




F ([0 p])
Using equation (2) gives H = F ([1 p]) since nh[n] = [0 1] [1 p].

if H(z) =

Applying the definition of the DTFT, we get







p ej p
pej
p
p cos p2
H =
=
= j
=
1 pej
ej p
(e p) (ej p)
1 2p cos + p2
As demonstrated above, the average value of H is zero for this filter because there is one pole and one
zero inside the unit circle.

DSP and Digital Filters (2014-5241)

Filters: 5 note 3 of slide 15

Minimum Phase

Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

zeros on the unit circle count

4
3

Reflecting an interior
zero to the exterior

multiplies H(ej ) by a constant but
increases average group delay by 1 sample.

2
1
0
0

0.5
-5

IIR Impulse response


examples
IIR Impulse response

Average group delay (over ) = (# poles # zeros) within the unit circle

5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z

-0.5
-10

-1
-1

0
(z)

30

1
20
H

0.5
0
-0.5

10
0

-1
-1

0
(z)

-10
0

A filter with all zeros inside the unit circle is a minimum phase filter:
Lowest possible group delay for a given magnitude response
Energy in h[n] is concentrated towards n = 0
DSP and Digital Filters (2014-5241)

Filters: 5 16 / 19

Linear Phase Filters


5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z
IIR Impulse response
examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase
Filters
Summary
MATLAB routines

The phase of a linear phase filter is: H(ej ) = 0


Equivalently constant group delay: H =

dH(ej )
d

A filter has linear phase iff h[n] is symmetric or antisymmetric:


h[n] = h[M n]n or else h[n] = h[M n]n
M can be even ( mid point) or odd ( mid point)
Proof :
PM
PM
j
jn
2H(e ) = 0 h[n]e
+ 0 h[M n]ej(M n)
PM
j (n M
j (n M
)
j M
2
2 )
2
+ h[M n]e
=e
0 h[n]e
h[n] symmetric:
PM
j
j M
2
2H(e ) = 2e
0 h[n] cos n

M
2

h[n] anti-symmetric:

PM
M
j
j M
2
2H(e ) = 2je
0 h[n] sin n 2

PM
+ M
j (
M
)
2
2
h[n] sin n
= 2e

DSP and Digital Filters (2014-5241)

Filters: 5 17 / 19

Summary
5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z
IIR Impulse response
examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

Useful filters have difference equations:


Freq response determined by pole/zero positions
N M zeros at origin (or M N poles)
Geometric construction of |H(ej )|
Pole bandwidth 2 |log |p|| 2 (1 |p|)
Stable if poles have |p| < 1
Allpass filter: a[n] = b[M n]
Reflecting a zero in unit circle leaves |H(ej )| unchanged

dH(ej )
j
Group delay: H e
samples
= d
 M
j
Symmetrical h[n] H e
= 2
Average H over = (# poles # zeros) within the unit circle
Minimum phase if zeros have |q| 1
Lowest possible group delay for given |H(ej )|
Linear phase = Constant group Delay = symmetric/antisymmetric h[n]
For further details see Mitra: 6, 7.

DSP and Digital Filters (2014-5241)

Filters: 5 18 / 19

MATLAB routines
5: Filters
Difference Equations
FIR Filters
FIR Symmetries
IIR Frequency
Response
Negating z
Cubing z
Scaling z

filter
impz
residuez
grpdelay
freqz

filter a signal
Impulse response
partial fraction expansion
Group Delay
Calculate filter frequency response

IIR Impulse response


examples
IIR Impulse response
Other BIBO
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

DSP and Digital Filters (2014-5241)

Filters: 5 19 / 19

6: Window Filter

Design

Inverse DTFT
Rectangular window
Dirichlet Kernel
Window relationships
Common Windows
Uncertainty principle
Order Estimation
Example Design
Frequency sampling
Summary
MATLAB routines

DSP and Digital Filters (2014-5241)

6: Window Filter Design

Windows: 6 1 / 12

Inverse DTFT
6: Window Filter
Design
Inverse DTFT
Rectangular window
Dirichlet Kernel
Window relationships
Common Windows
Uncertainty principle
Order Estimation
Example Design
Frequency sampling
Summary
MATLAB routines

For any BIBO stable filter, H(ej ) is the DTFT of h[n]


R
P
1
j
jn
H(e ) = h[n]e
h[n] = 2 H(ej )ejn d
If we know H(ej ) exactly, the IDTFT gives the ideal h[n]

Example: Ideal Lowpass filter


(
1 || 0
j
H(e ) =

0 || > 0

h[n] =

2/0

20

0.5

sin 0 n
n

-2

Note: Width in is 20 , width in n is 2


0 : product is 4 always
Sadly h[n] is infinite and non-causal. Solution: multiply h[n] by a window

DSP and Digital Filters (2014-5241)

Windows: 6 2 / 12

Rectangular window
6: Window Filter
Design
Inverse DTFT
Rectangular
window
Dirichlet Kernel
Window relationships
Common Windows
Uncertainty principle
Order Estimation
Example Design
Frequency sampling
Summary
MATLAB routines

Truncate to M
2 to make finite; h1 [n] is now of length M + 1
MSE Optimality:
Define mean square error (MSE) in frequency domain

R
1
j
j 2

E = 2 H(e ) H1 (e ) d
2

M
R
P


1
jn
j
2
= 2
h
[n]e
H(e
)

d

1

M
2

Minimum E is when h1 [n] = (h[n])


Proof: Differentiate w.r.t. h1 [r] and set to zero
However: 9% overshoot at a discontinuity even for large n.
h1[n]

M=14

M=28
M=14

0.5

Normal to delay by
DSP and Digital Filters (2014-5241)

0
0

M
2

to make causal. Multiplies H(ej ) by ej

M
2

Windows: 6 3 / 12

Dirichlet Kernel
6: Window Filter
Design
Inverse DTFT
Rectangular window
Dirichlet Kernel
Window relationships
Common Windows
Uncertainty principle
Order Estimation
Example Design
Frequency sampling
Summary
MATLAB routines

Truncation Multiply h[n] by a rectangular window, w[n] = M n M


2
2
1
j
j
j
Circular Convolution HM +1 (e ) = 2 H(e ) W (e )
j

W (e ) =

P M2

(i)

ejn = 1 + 2

M
2
j(n)

Proof: (i) e

P0.5M
1

(ii) sin 0.5(M +1)


sin 0.5

cos (n) =

+ ej(+n) = 2 cos (n) (ii) Sum geom. progression

Effect: convolve ideal freq response with Dirichlet kernel (aliassed sinc)
1

0.5

0.5

0
-2

M=14

0.5

0
-2

DSP and Digital Filters (2014-5241)

1
4/(M+1)

0.5

0
-2

-2

2
Provided that M4
<
2

M
+
1
>
0
+1
0 :
2
Passband ripple: M4
,
stopband
+1
M +1
4
Transition pk-to-pk: M +1

d|H|
+1
M2
Transition Gradient: d
=0

Windows: 6 4 / 12

[Dirichlet Kernel]
Other properties of W (ej ):
sin 0.5(+1)

. For
The DTFT of a symmetric rectangular window of length M + 1 is W (ej ) =
sin 0.5
small x we can approximate sin x x; the error is < 1% for x < 0.25. So, for < 0.5,we have
W (ej ) 2 1 sin 0.5(M + 1).
The peak value is at = 0 and equals M + 1;this means that the peak gradient of HM +1 (ej ) will
+1
be M2
.
The minimum value of W (ej ) is approximately equal to the minimuum of 2 1 sin 0.5(M + 1)
1.5
= M3
. Hence min W (ej )
which is when sin 0.5(M + 1) = 1 i.e. = 0.5(M
+1)
+1
+1
min 2 1 sin 0.5(M + 1) = M
.
1.5

Passband and Stopband ripple:


The ripple in W (ej ) =

sin 0.5(+1)
sin 0.5

has a period of =

2
0.5(+1)

4
M +1

and this gives rise to

ripple with this period in both the passband and stopband of HM +1 (ej ).
However the stopband ripple takes the value
of HM +1 (ej ) alternately positive and negative. If you

plot the magnitude response, HM +1 (ej ) then this ripple will be full-wave rectified and will double in
frequency so its period will now be M2
.
+1

DSP and Digital Filters (2014-5241)

Windows: 6 note 1 of slide 4

Window relationships
When you multiply an impulse response by a window M + 1 long
1
HM +1 (ej ) = 2
H(ej ) W (ej )
1

20 M=20

10

0.5

6: Window Filter
Design
Inverse DTFT
Rectangular window
Dirichlet Kernel
Window
relationships
Common Windows
Uncertainty principle
Order Estimation
Example Design
Frequency sampling
Summary
MATLAB routines

0.5

0
0

0
-2

-2

w[0]
2

-2

0.5
2

j
+
W
(e
)d
(a) passband gain w[0]; peak
mainlobe
rectangular window: passband gain = 1; peak gain = 1.09

(b) transition bandwidth, = width of the main lobe


transition amplitude, H = integral of main lobe2
rectangular window: = M4
+1 , H 1.18
(c) stopband gain is an integral over
oscillating
sidelobes of W (ej )


+1
rect window: min H(ej ) = 0.09 min W (ej ) = M
1.5
(d) features narrower than the main lobe will be broadened and
attenuated
DSP and Digital Filters (2014-5241)

Windows: 6 5 / 12

Common Windows
6: Window Filter
Design
Inverse DTFT
Rectangular window
Dirichlet Kernel
Window relationships
Common Windows
Uncertainty principle
Order Estimation
Example Design
Frequency sampling
Summary
MATLAB routines

Rectangular: w[n] 1
dont use

-50
0

Hanning: 0.5 + 0.5c1


2kn
ck = cos M
+1
rapid sidelobe decay
Hamming: 0.54 + 0.46c1
best peak sidelobe

Kaiser:

 q

2n 2
I0 1( M )
I0 ()

controls width v sidelobes


Good compromise:
Width v sidelobe v decay

DSP and Digital Filters (2014-5241)

12.56/(M+1)
-31 dB

-50
0
0

12.56/(M+1)
-40 dB

-50
0

Blackman-Harris 3-term:
0.42 + 0.5c1 + 0.08c2
best peak sidelobe

-13 dB

6.27/(M+1)

18.87/(M+1)

-50

-70 dB

0
0

-50

13.25/(M+1)
-40 dB

= 5.3

-50

21.27/(M+1)
= 9.5

-70 dB
1

Windows: 6 6 / 12

Uncertainty principle
6: Window Filter
Design
Inverse DTFT
Rectangular window
Dirichlet Kernel
Window relationships
Common Windows
Uncertainty
principle
Order Estimation
Example Design
Frequency sampling
Summary
MATLAB routines

CTFT uncertainty principle:

R

t |x(t)| dt
R
|x(t)|2 dt

 12  R

|X(j)| d
R
|X(j)|2 d

 21

1
2

The first term measures the width of x(t) around t = 0.


2
It is like if |x(t)| was a zero-mean probability distribution.
The second term is similarly the width of X(j) in frequency.
A signal cannot be concentrated in both time and frequency.
So a short window cannot have a narrow main lobe.
Proof:
R
R
2
2
Assume |x(t)| dt = 1 |X(j)| d = 2 [Parseval]
Set v(t) = dx
V (j)
= jX(j) [by parts]

R 1 2
R dxdt
1
2
Now tx dt dt= 2 tx t= 2 x dt = 21 [by parts]
R dx 2
R 2 2  R dx 2 
1
dt
So 4 = tx dt dt
[Schwartz]
t x dt
dt


R 2 2  R
R 2 2  1 R
2
2
=
t x dt
|v(t)| dt =
t x dt 2 |V (j)| d

R 2 2  1 R 2
2
=
t x dt 2 |X(j)| d

No exact equivalent for DTFT/DFT but a similar effect is true


DSP and Digital Filters (2014-5241)

Windows: 6 7 / 12

[Uncertainty Principle Proof Steps]


(1) Suppose v(t) = dx
. Then integrating the CTFT definition by parts w.r.t. t gives
h
i
R dt jt
R dx(t) jt
1
1
jt
X(j) = x(t)e
dt = j x(t)e
+ j dt e
dt = 0 +

1
V
j

(j)


1 2
dx
d
=
x
x
, we can apply integration by parts to get
(2) Since dt
2
dt
R

R

R dt
1
1 2
1 2
1
1
dx
2
tx dt dt = t 2 x t= dt 2 x dt = 2 x dt = 2 1 = 2
R
2
2

dx
It follows that tx dt dt = 21 = 14 which we will use below.

(3) The Cauchy-Schwarz inequality is that in a complex inner product space


|u v|2 (u u) (v v). For the inner-product space of real-valued square-integrable functions,
2 R
R
R 2

2
this becomes u(t)v(t)dt u (t)dt v (t)dt. We apply this with u(t) = tx(t)
and v(t) =

1
4

dx(t)
dt

to get
  

R
2
2
R

R
R 2 2  R 2



dx
2 x2 dt

t
tx dx
dt
=
t
x
dt
v
(t)dt
=
dt

dt
dt

R
R
1
(4) From Parsevals theorem for the CTFT, v 2 (t)dt = 2
|V (j|2 d. From step (1), we can
R 2
R 2
1
substitute V (j) = jX(j) to obtain v (t)dt = 2 |X(j|2 d. Making this substitution
in (3) gives

R 2 2  R 2

R 2 2  1 R 2
2
1

t x dt
v (t)dt =
t x dt 2 |X(j| d
4
DSP and Digital Filters (2014-5241)

Windows: 6 note 1 of slide 7

Order Estimation
6: Window Filter
Design
Inverse DTFT
Rectangular window
Dirichlet Kernel
Window relationships
Common Windows
Uncertainty principle
Order Estimation
Example Design
Frequency sampling
Summary
MATLAB routines

Several formulae estimate the required order of a filter, M .


E.g. for lowpass filter
Estimated order is
M

5.64.3 log10 ()
2 1

820 log10
2.2

Required M increases as either the


transition width, 2 1 , or the gain
tolerances and get smaller.
Only approximate.
Example:
Transition band: f1 = 1.8 kHz, f2 = 2.0 kHz, fs = 12 kHz,.
2f2
1
1 = 2f
=
0.943,

=
2
fs
fs = 1.047
Ripple: 20 log10 (1 + ) = 0.1 dB, 20 log10 = 35 dB
35
0.1
= 10 20 1 = 0.0116, = 10 20 = 0.0178
M

5.64.3 log10 (2104 )


1.0470.943

DSP and Digital Filters (2014-5241)

10.25
0.105

= 98

or

358
2.2

= 117
Windows: 6 8 / 12

Example Design
6: Window Filter
Design
Inverse DTFT
Rectangular window
Dirichlet Kernel
Window relationships
Common Windows
Uncertainty principle
Order Estimation
Example Design
Frequency sampling
Summary
MATLAB routines

Specifications:
Bandpass: 1 = 0.5, 2 = 1
Transition bandwidth: = 0.1
Ripple: = = 0.02
20 log10 = 34 dB
20 log10 (1 + ) = 0.17 dB
Order:
M

0.5

0
0

5.64.3 log10 ()
2 1

= 92

Ideal Impulse Response:


Difference of two lowpass filters
1 n
2 n
sinn
h[n] = sinn
Kaiser Window: = 2.5

M=92
= 2.5

0.5

0
0

M=92
= 2.5

-20

M=92

-40
0

-60
0

DSP and Digital Filters (2014-5241)

Windows: 6 9 / 12

Frequency sampling
6: Window Filter
Design
Inverse DTFT
Rectangular window
Dirichlet Kernel
Window relationships
Common Windows
Uncertainty principle
Order Estimation
Example Design
Frequency
sampling
Summary
MATLAB routines

Take M + 1 uniform samples of H(ej ); take IDFT to obtain h[n]


Advantage:
exact match at sample points
Disadvantage:
poor intermediate approximation if spectrum is varying rapidly
Solutions:
(1) make the filter transitions smooth over width
(2) oversample and do least squares fit (cant use IDFT)
(3) use non-uniform points with more near transition (cant use IDFT)
1

M+1=93

0.5

M+1=93

0.5

-2

DSP and Digital Filters (2014-5241)

0
0

Windows: 6 10 / 12

Summary
6: Window Filter
Design
Inverse DTFT
Rectangular window
Dirichlet Kernel
Window relationships
Common Windows
Uncertainty principle
Order Estimation
Example Design
Frequency sampling
Summary
MATLAB routines

Make an FIR filter by windowing the IDTFT of ideal response


0 n
Ideal lowpass has h[n] = sinn
Add/subtract lowpass filters to make any piecewise constant
response
Ideal response is with window DTFT
Rectangular window (Dirichlet kernel) has 13 dB sidelobes
and is always a bad idea
Hamming, Blackman-Harris are good; Kaiser good with
Uncertainty principle: cannot be concentrated in both time and frequency
Frequency sampling: IDFT of uniform frequency samples: not so great
For further details see Mitra: 7, 10.

DSP and Digital Filters (2014-5241)

Windows: 6 11 / 12

MATLAB routines
6: Window Filter
Design
Inverse DTFT
Rectangular window
Dirichlet Kernel
Window relationships
Common Windows
Uncertainty principle
Order Estimation
Example Design
Frequency sampling
Summary
MATLAB routines

diric(x,n)
hanning
hamming
kaiser
kaiserord

0.5nx
Dirichlet kernel: sin
sin 0.5x
Window functions
(Note periodic option)

Estimate required filter order and

DSP and Digital Filters (2014-5241)

Windows: 6 12 / 12

7: Optimal FIR

filters

Optimal Filters
Alternation Theorem
Chebyshev
Polynomials
Maximal Error
Locations
Remez Exchange
Algorithm
Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5241)

7: Optimal FIR filters

Optimal FIR: 7 1 / 11

Optimal Filters
7: Optimal FIR filters
Optimal Filters
Alternation Theorem
Chebyshev
Polynomials

Maximal Error
Locations
Remez Exchange
Algorithm
Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

We restrict ourselves to zero-phase filters of odd length M + 1, symmetric


around h[0], i.e. h[n] = h[n].
P M2
P M2
j
jn
H() = H(e ) = M h[n]e
= h[0] + 2 1 h[n] cos n
2


j

H() is real but not necessarily positive (unlike H(e ) ).

Weighted error: e() = s() H() d() where d() is the target.
Choose s() to control the error variation with .
Example: lowpass filter
(
1 0 1
d() =
0 2
(
1 0 1
s() = 1

e() = 1 when H() lies at the edge of the specification.


Minimax criterion: h[n] = arg minh[n] max |e()|: minimize max error
DSP and Digital Filters (2014-5241)

Optimal FIR: 7 2 / 11

Alternation Theorem
7: Optimal FIR filters
Optimal Filters
Alternation

Theorem
Chebyshev
Polynomials

Maximal Error
Locations
Remez Exchange
Algorithm
Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Want to find the best fit line: with the smallest maximal error.
Best fit line always attains the
maximal error three times with
alternate signs

8
6
4
2
2

Proof:
Assume the first maximal deviation from the line is negative as shown.
There must be an equally large positive deviation; or else just move the line
downwards to reduce the maximal deviation.
This must be followed by another maximal negative deviation; or else you
can rotate the line and reduce the deviations.
Alternation Theorem:
A polynomial fit of degree n to a bounded set of points is minimax if and
only if it attains its maximal error at n + 2 points with alternating signs.
There may be additional maximal error points.
Fitting to a continuous function is the same as to an infinite number of
points.

DSP and Digital Filters (2014-5241)

Optimal FIR: 7 3 / 11

Chebyshev Polynomials
7: Optimal FIR filters
Optimal Filters
Alternation Theorem
Chebyshev
Polynomials

Maximal Error
Locations
Remez Exchange
Algorithm
Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

H() = H(e ) = h[0] + 2

P M2

h[n] cos n

But cos n = Tn (cos ): Chebyshev polynomial of 1st kind


cos 2 = 2 cos2 1 = T2 (cos )
cos 3 = 4 cos3 3 cos = T3 (cos )
Recurrence Relation:
Tn+1 (x) = 2xTn (x) Tn1 (x) with T0 (x) = 1, T1 (x) = x
Proof: cos (n + ) + cos (n ) = 2 cos cos n
So H() is an

M
2

order polynomial in cos : alternation theorem applies.

Example: Low-pass filter of length 5 (M = 4)


1.4

M=4

M=4

1.2

M=2

0
1

|g|

0.8
0.6

-5
g

|g| (dB)

0.5

-10

0.4
0
0.2
0
0

-15
0.5

1.5

DSP and Digital Filters (2014-5241)

2.5

3.5

0.5

1.5

2.5

-1

-0.5

0
cos()

0.5

Optimal FIR: 7 4 / 11

Maximal Error Locations

Maximal Error

Locations

Remez Exchange
Algorithm
Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Maximal error locations occur either at band


edges or when dH
d = 0
P M2
H() = h[0] + 2 1 h[n] cos n
= P (cos )
where P (x) is a polynomial of order
dH
d

= P (cos ) sin
= 0 at = 0, and at most

M
2

M
2 .

1.2

M=18

1
0.8
|H|

7: Optimal FIR filters


Optimal Filters
Alternation Theorem
Chebyshev
Polynomials

0.6
0.4
0.2
0
0

0.5

1.5

2.5

1 zeros of polynomial P (x).

With two bands, we have at most M


2 + 3 maximal error frequencies.
We require M
2 + 2 of alternating signs for the optimal fit.
Only three possibilities exist (try them all):

1
zeros
of
P
(x).
(a) = 0 + two band edges + M
2

(b) = + two band edges + M


2 1 zeros of P (x).

2
zeros
of
P
(x).
(c) = {0 and } + two band edges + M
2

DSP and Digital Filters (2014-5241)

Optimal FIR: 7 5 / 11

Remez Exchange Algorithm


7: Optimal FIR filters
Optimal Filters
Alternation Theorem
Chebyshev
Polynomials
Maximal Error
Locations
Remez Exchange
Algorithm
Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

2. Determine the error magnitude, , and the M


2 + 1 coefficients of
the polynomial that passes through the maximal error locations.
3. Find the local maxima of the
 error function by evaluating
e() = s() H() d() on a dense set of .

4. Update the maximal error frequencies to be an alternating subset of


the local maxima + band edges + {0 and/or }.
If maximum error is > , go back to step 2. (typically 15 iterations)
5. Evaluate H() on M + 1 evenly spaced and do an IDFT to get h[n].
M=4
Iteration 1

1.5

M=4
Iteration 2

M=4
Iteration 3

0.5
0

|g|

|g|

1
|g|

1. Guess the positions of the M


2 + 2 maximal error frequencies and give
alternating signs to the errors (e.g. choose evenly spaced ).

0.5

0.5

-0.5
0

0.5

DSP and Digital Filters (2014-5241)

1.5

2.5

0.5

1.5

2.5

0.5

1.5

2.5

Optimal FIR: 7 6 / 11

Determine Polynomial
7: Optimal FIR filters
Optimal Filters
Alternation Theorem
Chebyshev
Polynomials
Maximal Error
Locations
Remez Exchange
Algorithm
Determine
Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

For each extremal frequency, i for 1 i M


2 +2
P M2
(1)i
d(i ) = H(i ) + s(i ) = h[0] + 2 n=1 h[n] cos ni +

(1)i
s(i )

Method 1: (Computation time M 3 )


M
Solve M
+
2
equations
in
2
2 + 2 unknowns for h[n] + .
P M2
In step 3, evaluate H() = h[0] + 2 n=1 h[n] cos ni

2
Method 2: Dont calculate h[n]
explicitly
(Computation
time

M
)
Q
1
Multiply equations by ci = j6=i cos i cos
j and add:
 PM
P M2 +2 
P M2
(1)i
2 +2
=
h[n]
cos
n
+
c
h[0]
+
2
i
n=1
i=1
i=1 ci d(i )
s(i )
All terms involving h[n] sum to zero leaving
P M2 +2
P M2 +2 (1)i ci
i=1
i=1 ci d(i )
s(i ) =

Solve for then calculate the H(i ) then use Lagrange interpolation:
P M2 +2
Q
cos cos
H() = P (cos ) = i=1 H(i ) j6=i cos i cos jj

M
M
H(
)
[actually
order
+
1
-polynomial
going
through
all
the
i
2
2 ]

DSP and Digital Filters (2014-5241)

Optimal FIR: 7 7 / 11

Example Design
7: Optimal FIR filters
Optimal Filters
Alternation Theorem
Chebyshev
Polynomials
Maximal Error
Locations
Remez Exchange
Algorithm
Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Determine gain tolerances for each band:


25 dB = 0.056, 0.3 dB = 1 0.034, 15 dB = 0.178
Predicted order: M = 36
M
2 + 2 extremal frequencies are distributed between the bands
Filter meets specs ,; clearer on a decibel scale
Most zeros are on the unit circle + three reciprocal pairs
Reciprocal pairs give a linear phase shift
1

M=36

|H| (dB)

0.6
0.4

1
0.5

-10
-15

-20

-0.5

-25

0.2
0
0

M=36

-5

0.8
|H|

Filter Specifications:
Bandpass = [0.5, 1], Transition widths: = 0.2
Stopband Attenuation: 25 dB and 15 dB
Passband Ripple: 0.3 dB

0.5

DSP and Digital Filters (2014-5241)

1.5

2.5

-30
0

-1
0.5

1.5

2.5

-1

Optimal FIR: 7 8 / 11

FIR Pros and Cons


7: Optimal FIR filters
Optimal Filters
Alternation Theorem
Chebyshev
Polynomials
Maximal Error
Locations
Remez Exchange
Algorithm
Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Can

have linear phase


no envelope distortion, all frequencies have the same delay ,
symmetric or antisymmetric: h[n] = h[n]n or h[n]n
antisymmetric filters have H(ej0 ) = H(ej ) = 0
symmetry means you only need M
2 + 1 multiplications
to implement the filter.

Always stable ,
Low coefficient sensitivity ,
Optimal design method fast and robust ,
Normally needs higher order than an IIR filter /
atten
Filter order M dB
3.5 where is the most rapid transition
dBatten 2
atten
Filtering complexity M fs dB
f
=
s
3.5
3.5 fs
fs2 for a given specification in unscaled units.

DSP and Digital Filters (2014-5241)

Optimal FIR: 7 9 / 11

Summary
7: Optimal FIR filters
Optimal Filters
Alternation Theorem
Chebyshev
Polynomials
Maximal Error
Locations
Remez Exchange
Algorithm
Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Optimal Filters: minimax error criterion


use weight function, s(), to allow different errors
in different frequency bands
symmetric filter has zeros on unit circle or in reciprocal pairs
Response of symmetric filter is a polynomial in cos
Alternation Theorem: M
2 + 2 maximal errors with alternating signs
Remez Exchange Algorithm (also known as Parks-McLellan Algorithm)

multiple constant-gain bands separated by transition regions


very robust, works for filters with M > 1000
Efficient: computation M 2
can go mad in the transition regions

Modified version works on arbitrary gain function


Does not always converge
For further details see Mitra: 10.
DSP and Digital Filters (2014-5241)

Optimal FIR: 7 10 / 11

MATLAB routines
7: Optimal FIR filters
Optimal Filters
Alternation Theorem
Chebyshev
Polynomials
Maximal Error
Locations
Remez Exchange
Algorithm
Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

firpm
firpmord
cfirpm
remez

optimal FIR filter design


estimate require order for firpm
arbitrary-response filter design
[obsolete] optimal FIR filter design

DSP and Digital Filters (2014-5241)

Optimal FIR: 7 11 / 11

8: IIR Filter

Transformations

Continuous Time
Filters
Bilinear Mapping
Continuous Time
Filters
Mapping Poles and
Zeros
Spectral
Transformations
Constantinides
Transformations
Impulse Invariance
Summary
MATLAB routines

DSP and Digital Filters (2014-5241)

8: IIR Filter Transformations

IIR Transformations: 8 1 / 10

Continuous Time Filters

e2

Chebyshev: G () =

|H|

0.6
0.4
0.2
0
0.1

0.2

0.5
1
2
Frequency (rad/s)

10

0.2

0.5
1
2
Frequency (rad/s)

10

0.2

0.5
1
2
Frequency (rad/s)

10

0.2

0.5
1
2
Frequency (rad/s)

10

1
0.8
0.6
0.4
0.2
0
0.1

1
2 ()
2
1+ TN

1
0.8

where polynomial TN (cos x) = cos N x


passband equiripple + very flat at
e 2 () =
Inverse Chebyshev: G

N=5

0.8

|H|

Monotonic
e
G()
= 1 12 2N + 38 4N +
Maximally flat: 2N 1 derivatives are zero

0.6
|H|

Classical continuous-time filters optimize tradeoff:


passband ripple v stopband ripple v transition width
There are explicit formulae for pole/zero positions.

2


e 2 () = H(j)
e
Butterworth: G
= 1+1 2N

0.4
0.2
0
0.1

1
2 (1 ) 1
1+(2 TN
)

stopband equiripple + very flat at 0

1
0.8
0.6
|H|

8: IIR Filter
Transformations
Continuous Time
Filters
Bilinear Mapping
Continuous Time
Filters
Mapping Poles and
Zeros
Spectral
Transformations
Constantinides
Transformations
Impulse Invariance
Summary
MATLAB routines

0.4

Elliptic: [no nice formula]


Very steep + equiripple in pass and stop bands
DSP and Digital Filters (2014-5241)

0.2
0
0.1

IIR Transformations: 8 2 / 10

Bilinear Mapping
8: IIR Filter
Transformations
Continuous Time
Filters
Bilinear Mapping
Continuous Time
Filters
Mapping Poles and
Zeros
Spectral
Transformations
Constantinides
Transformations
Impulse Invariance
Summary
MATLAB routines

+s
s

s = z1
z+1 : a one-to-one invertible mapping

axis (s) axis (z)


axis (s) Unit circle (z)

ej 2 ej 2
ej 1
j
Proof: z = e s = ej +1 = j 2 j 2 = j tan 2 = j
+e

Left half plane(s) inside of unit circle (z)


2
|(+x)+jy|2
Proof: s = x + jy |z| = |(x)jy|2
=

2 +2x+x2 +y 2
2 2x+x2 +y 2

4x
(x)2 +y 2

=1+

x < 0 |z| < 1


Unit circle (s) axis (z)
4
3

s-plane

=1

2.5
2

z-plane

=1

2.5

1.5

1
1

0.5

-1

-0.5

Change variable: z =

-1
-2

-1.5

-3
-4
-4

1.5

0.5

-2
-2

DSP and Digital Filters (2014-5241)

-2.5

-2

-1

0
0

10

IIR Transformations: 8 3 / 10

Continuous Time Filters


and choose = 1

Substitute: s = z1
z+1
H(z) =

2.5
2

[extra zeros at z = 1]

1.5
|H|

1
s2 +0.2s+4

1
0.5

1
2
z1
( z1
z+1 ) +0.2 z+1 +4

2.5

(z+1)
2
(z1) +0.2(z1)(z+1)+4(z+1)2

2
3
4
Frequency (rad/s)

=1

2
1.5
1

z +2z+1
5.2z 2 +6z+4.8

1+2z +z
= 0.19 1+1.15z
1 +0.92z 2

0.5
0
0

Frequency response is identical (both magnitude and


phase) but with a distorted frequency axis:
2 tan1

Frequency mapping: =


= 2 3 4 5

= 1.6 2.2 2.5 2.65 2.75
Choosing : Set =

0
tan 21 0

Set = 2fs =
DSP and Digital Filters (2014-5241)

0.5

1.5
2
(rad/sample)

2.5

3
2.5
2

e
Take H(s)
=

|H|

8: IIR Filter
Transformations
Continuous Time
Filters
Bilinear Mapping
Continuous Time
Filters
Mapping Poles and
Zeros
Spectral
Transformations
Constantinides
Transformations
Impulse Invariance
Summary
MATLAB routines

1.5
1
0.5
0
0

10

to map 0 0
2
T

to map low frequencies to themselves


IIR Transformations: 8 4 / 10

Mapping Poles and Zeros

1
s2 +0.2s+4

Find the poles and zeros: ps = 0.1 2j


Map using z = 1+s
1s pz = 0.58 0.77j

2.5
2
1.5
|H|

e
Alternative method: H(s)
=

1
0.5
0

After the transformation we will always end up with


the same number of poles as zeros:
Add extra poles or zeros at z = 1
H(z)

0 = 2 tan1 0 = 0 z0 = ej0 = 1
4
|H(z0 )| = g 3.08
= 0.25 g = 0.19

2
1
0
-1

(1+z 1 )2
= g (1+(0.580.77j)z1 )(1+(0.58+0.77j)z1 )
1+2z 1 +z 2
= g 1+1.15z1 +0.92z2

Choose overall scale factor, g, to give the same gain


at any convenient pair of mapped

frequencies:
e

At 0 = 0 s0 = 0 H(s
)
0 = 0.25

2
3
4
Frequency (rad/s)

-2
-3

-2

-1

0
s

=1

0.5
0
-0.5
-1
-1

2.5

0
z

=1

2
1.5
|H|

8: IIR Filter
Transformations
Continuous Time
Filters
Bilinear Mapping
Continuous Time
Filters
Mapping Poles and
Zeros
Spectral
Transformations
Constantinides
Transformations
Impulse Invariance
Summary
MATLAB routines

1+2z +z
H(z) = 0.19 1+1.15z
1 +0.92z 2
DSP and Digital Filters (2014-5241)

0.5
0
0

0.5

1.5
2
(rad/sample)

2.5

IIR Transformations: 8 5 / 10

Spectral Transformations

2
z
1

-1

Frequency Mapping:
1+z 1
j
If z = e , then z = z 1+z has modulus 1
since the numerator and denominator are
complex conjugates.
Hence the unit circle is preserved.
ej +
ej = 1+e
j


1+
tan 2
Some algebra gives: tan 2 = 1
Equivalent to:
z s =

-2
-2

2
z^
= 0.6
1

-1

-2
-2

-1

1
0.8
0.6
0.4
0.2

z1
z+1

s =

1
1+ s

z =

Lowpass Filter example:


Inverse Chebyshev
=0.6
0 = 2 = 1.57
0 = 0.49

1+
s
1
s

0
0

0.5

1.5
2
(rad/s)

2.5

= 0.6
^ = 0.49

0.8
0.6
0.4
0.2
0
0

DSP and Digital Filters (2014-5241)

-1

|H|

We can transform the z-plane to change the cutoff


frequency by substituting
z
z+
z = 1

=
z
1+z

|H^|

8: IIR Filter
Transformations
Continuous Time
Filters
Bilinear Mapping
Continuous Time
Filters
Mapping Poles and
Zeros
Spectral
Transformations
Constantinides
Transformations
Impulse Invariance
Summary
MATLAB routines

0.5

1.5
2
^ (rad/s)

2.5

IIR Transformations: 8 6 / 10

Constantinides Transformations
Transform any lowpass filter with cutoff frequency 0 to:
Target

Substitute

Lowpass

<
1

z 1 =

Highpass

>
1

Bandpass

1 <
<
2

Bandstop

1

2

Parameters

sin( 0 2 1 )
=
+

sin( 0 2 1 )

z1
1
z 1

z1 +
1+z1

cos(

(1)2
z 1 +(+1)
z 2
(+1)2
z 1 +(1)
z 2

cos(

0 +
1
2
0
1
2

)
)

2 +
1
2

2
1
2

)
cos(
)

1
tan
= cot 2
2

cos( 2 2 1 )
=

cos( 2 2 1 )


2
1
tan
= tan
2

(1)2
z 1 +(+1)
z 2
(+1)2z1 +(1)z2

cos(

0
2

0
2

Bandpass and bandstop transformations are quadratic and so will double the order:
1

Lowpass
|H^|

|H|

1
0.5
0

-3

-2

-1

0
(rad/s)

DSP and Digital Filters (2014-5241)

Bandpass

0.5
0

-3

-2

-1

0
^ (rad/s)

IIR Transformations: 8 7 / 10

Impulse Invariance
8: IIR Filter
Transformations
Continuous Time
Filters
Bilinear Mapping
Continuous Time
Filters
Mapping Poles and
Zeros
Spectral
Transformations
Constantinides
Transformations
Impulse Invariance
Summary
MATLAB routines

1
fs

Poles of H(z) are pi = epi T (where T =


Zeros do not map in a simple way

Properties:
, Impulse response correct.
,
/ Frequency response is aliased.

is sampling period)

No distortion of frequency axis.

Example: Standard telephone filter - 300 to 3400 Hz bandpass


1

0.5

0.5

Bilinear (f s = 8 kHz)
Matched at 3.4 kHz

Analog Filter
0
0

10
15
Frequency (krad/s)

DSP and Digital Filters (2014-5241)

20

25

0
0

|H|

|H|

0.8
|H|

Bilinear transform works well for a lowpass filter but the non-linear
compression of the frequency distorts any other response.
sample
L 1
Z
e
Alternative method: H(s) h(t) h[n] H(z)
PN
gi
e
e
Express H(s) as a sum of partial fractions H(s) = i=1 se
pi
P
N
= u(t)
Impulse response is h(t)
gi epi t
i=1
PN
Digital filter H(z) = i=1 1epgiiT z1 has identical impulse response

0.5

1.5
2
(rad/sample)

0.6
0.4
0.2

2.5

Impulse Invariance (f s = 8 kHz)


0.5

1.5
2
(rad/sample)

2.5

IIR Transformations: 8 8 / 10

Summary
8: IIR Filter
Transformations
Continuous Time
Filters
Bilinear Mapping
Continuous Time
Filters
Mapping Poles and
Zeros
Spectral
Transformations
Constantinides
Transformations
Impulse Invariance
Summary
MATLAB routines

Classical filters have optimal tradeoffs in continuous time domain


Order transition width pass ripple stop ripple
Monotonic passband and/or stopband
Bilinear mapping
Exact preservation of frequency response (mag + phase)
non-linear frequency axis distortion
can choose to map 0 0 for one specific frequency
Spectral transformations
lowpass lowpass, highpass, bandpass or bandstop
bandpass and bandstop double the filter order
Impulse Invariance
Aliassing distortion of frequency response
preserves frequency axis and impulse response
For further details see Mitra: 9.

DSP and Digital Filters (2014-5241)

IIR Transformations: 8 9 / 10

MATLAB routines
8: IIR Filter
Transformations
Continuous Time
Filters
Bilinear Mapping
Continuous Time
Filters
Mapping Poles and
Zeros
Spectral
Transformations
Constantinides
Transformations
Impulse Invariance
Summary
MATLAB routines

bilinear
impinvar
butter
butterord
cheby1
cheby1ord
cheby2
cheby2ord
ellip
ellipord

DSP and Digital Filters (2014-5241)

Bilinear mapping
Impulse invariance
Analog or digital
Butterworth filter
Analog or digital
Chebyshev filter
Analog or digital
Inverse Chebyshev filter
Analog or digital
Elliptic filter

IIR Transformations: 8 10 / 10

9: Optimal IIR

Design

Error choices
Linear Least Squares
Frequency Sampling
Iterative Solution
Newton-Raphson
Magnitude-only
Specification
Hilbert Relations
Magnitude Phase
Relation
Summary
MATLAB routines

DSP and Digital Filters (2014-4123)

9: Optimal IIR Design

Optimal IIR: 9 1 / 11

Error choices
9: Optimal IIR
Design
Error choices
Linear Least Squares
Frequency Sampling
Iterative Solution
Newton-Raphson

Magnitude-only
Specification
Hilbert Relations
Magnitude Phase
Relation
Summary
MATLAB routines

B(ej )
A(ej )

that approximates a target


We want to find a filter H(e ) =
response D(). Assume A is order N and B is order M .
Two possible error measures:
Solution Error: ES () = WS ()

B(ej )
A(ej )
j

D()

Equation Error: EE () = WE () B(e ) D()A(e )

We may know D() completely or else only |D()|


R
We minimize |E ()|p d
where p = 2 (least squares) or (minimax).
Weight functions W () are chosen to control relative errors at different
frequencies. WS () = |D()|1 gives constant dB error.
We actually want to minimize ES but EE is easier because it gives
rise to linear equations.
However if WE () =

DSP and Digital Filters (2014-4123)

WS ()
|A(ej )| ,

then |EE ()| = |ES ()|


Optimal IIR: 9 2 / 11

Linear Least Squares


9: Optimal IIR
Design
Error choices
Linear Least
Squares
Frequency Sampling
Iterative Solution
Newton-Raphson

Magnitude-only
Specification
Hilbert Relations
Magnitude Phase
Relation
Summary
MATLAB routines

Overdetermined set of equations Ax = b (#equations > #unknowns)


We want to minimize ||e||2 where e = Ax b

2
T
T T
T
||e|| = e e = x A b (Ax b)

Differentiate:


T
T T
T T
T
d e e = dx A (Ax b) + x A b Adx
[since d (uv) = du v + u dv]
= 2dxT AT (Ax b) 
[since uT v = vT u]
= 2dxT AT Ax AT b
This is zero for any dx iff AT Ax = AT b
1 T
2
T
Thus ||e|| is minimized if x = A A
A b

These are the Normal Equations (Normal because AT e = 0)


The pseudoinverse x = A+ b works even if AT A is singular and finds the x
with minimum ||x||2 that minimizes ||e||2 .
This is a very widely used technique.
DSP and Digital Filters (2014-4123)

Optimal IIR: 9 3 / 11

Frequency Sampling
9: Optimal IIR
Design
Error choices
Linear Least Squares
Frequency
Sampling
Iterative Solution
Newton-Raphson

Magnitude-only
Specification
Hilbert Relations
Magnitude Phase
Relation
Summary
MATLAB routines

For every we want: 


0 = W () B(e ) D()A(e
)


PM
P
jm
jn
= W ()
D() 1 + N
m=0 b[m]e
n=1 a[n]e



a
u()T v()T
= W ()D()
b 

j
j2
jN
T
e
e
e
where u() = W ()D()


j
j2
jM
T
e
e
v() = W () 1 e



+1
]
Choose K valuesof , 1 K
[with K M +N
2
 a
T
T
U
V
[K equations, M + N + 1 unkowns]
=d
b


where U =  u(1 ) u(K ) ,
V = v(1 ) v(K ) ,

T
d = W (1 )D(1 ) W (K )D(K )
We want to force a and b to be real; find least squares solution to

 

 

T
T
U  V 
a
(d)
=
b
(d)
UT
VT

DSP and Digital Filters (2014-4123)

Optimal IIR: 9 4 / 11

Iterative Solution
9: Optimal IIR
Design
Error choices
Linear Least Squares
Frequency Sampling
Iterative Solution
Newton-Raphson

Magnitude-only
Specification
Hilbert Relations
Magnitude Phase
Relation
Summary
MATLAB routines

Least squares solution minimizes the EE rather than ES .


However EE = ES if WE () =

WS ()
A(ej ) .

We can use an iterative solution technique:


1 Select K frequencies {k } (e.g. uniformly spaced)
2 Initialize WE (k ) = WS (k )
3 Find least squares solution to

jk
jk
WE (k ) B(e ) D(k )A(e ) = 0k

4 Force A(z) to be stable


Replace pole pi by (pi )1 whenever |pi | 1
5 Update weights: WE (k ) =

WS (k )
A(ejk )

6 Return to step 3 until convergence


But for faster convergence use Newton-Raphson . . .

DSP and Digital Filters (2014-4123)

Optimal IIR: 9 5 / 11

Newton-Raphson
9: Optimal IIR
Design
Error choices
Linear Least Squares
Frequency Sampling
Iterative Solution
Newton-Raphson

Magnitude-only
Specification
Hilbert Relations
Magnitude Phase
Relation
Summary
MATLAB routines

Newton: To solve f (x) = 0 given an initial guess x0 , we write


0)
f (x) f (x0 ) + (x x0 )f (x0 ) x = x0 ff(x
(x0 )
Converges very rapidly once x0 is close to the solution
j
So for each k ,we can write
(omitting
the

and
e
arguments)

WS
WS B0
0
(A A0 )

D
+
(B

B
)

E S WS B
0
A0
A0
A20


B0
B0
S
=W

(A

1)
+
B

A
D

0
A0
A0
A0 + B0

From which we get a linear


equation for each k :
 a 



B0
B0
T
T
u
v
=
W
A
D
+
0
DA0
A0 B0
b
jn
S
where W = W
A0 and, as before, un () = W ()D()e
for n 1 : N and vm () = W ()ejm for m 0 : M .

At each iteration, calculate A0 (ejk ) and B0 (ejk ) based on a and b from


the previous iteration.
Then use linear least squares to minimize the linearized ES using the above
equation replicated for each of the k .
DSP and Digital Filters (2014-4123)

Optimal IIR: 9 6 / 11

Magnitude-only Specification
9: Optimal IIR
Design
Error choices
Linear Least Squares
Frequency Sampling
Iterative Solution
Newton-Raphson
Magnitude-only

Specification

Hilbert Relations
Magnitude Phase
Relation
Summary
MATLAB routines

If the filter specification only dictates the target magnitude: |D()|, we


need to select the target phase.
Solution:
Make an initial guess of the phase and then at each iteration
j
)
update D() = B(e
j
A(e ) .
Initial Guess:
If H(ej ) is causal and minimum phase then the magnitude and
phase are not independent:

j
j

H(e
)
=

ln
H(e
)

cot
2


j

ln H(e ) = ln |H()| + H(ej ) cot 2

where is circular convolution and cot x is taken to be zero for


< x < for some small value of and we take the limit as 0.
This result is a consequence of the Hilbert Relations.

DSP and Digital Filters (2014-4123)

Optimal IIR: 9 7 / 11

Hilbert Relations
9: Optimal IIR
Design
Error choices
Linear Least Squares
Frequency Sampling
Iterative Solution
Newton-Raphson
Magnitude-only
Specification
Hilbert Relations
Magnitude Phase
Relation
Summary
MATLAB routines

We define t[n] = u[n 1] u[1 n]


z 1
z
1+z 1
T (z) = 1z

=
1
1z
1z 1
j

T (e )

t[n]

ej 2 +ej 2
1+ej
= 1ej = j 2 j 2
e
e
2 cos
= 2j sin 2 = j cot 2
2

h[n]

h[n]even/odd parts: he [n] = 21 (h[n] + h[n])


1
h
[n]
=
o
2 (h[n] h[n])

so H(ej ) = He (ej )
H(ej ) = jHo (ej )

h[-n]

he[n]

If h[n] is causal: ho [n] = he [n]t[n]


he [n] = h[0][n] + ho [n]t[n]

Hence, for causal


h[n]:




j
j
H(e ) = j H(e ) j cot 2
= H(ej ) cot 2


j
j
H(e ) = H() + j H(e )  j cot 2
= H() + H(ej ) cot 2

DSP and Digital Filters (2014-4123)

ho[n]
0

Optimal IIR: 9 8 / 11

Magnitude Phase Relation

0.5

ln H(z) = ln(g) + ln 1 qmz


P
ln 1 pn z 1
= ln |H(z)| + jH(z)

Taylor Series: 
a2 2
a3 3
1
1
ln 1 az
= az 2 z 3 z . . .
causal and stable provided |a| < 1
So, if H(z) is minimum phase (all pn and qm inside
unit circle) then ln H(z) is the z-transform of a
stable causal sequence and:

j
j

H(e
)
=

ln
H(e
)

cot
2


j
j
ln H(e ) = ln |g| + H(e ) cot 2
Example: H(z) =

107z

10040z 1 11z 2 +68z 3

Note symmetric dead band in cot 2 for || <


DSP and Digital Filters (2014-4123)

-0.5
-1
-1.5

-1

-0.5

0
z

0.5

0.4
0.3
ln|H|

0.2
0.1
-3

-2

-1

0
(rad/s)

-3

-2

-1

0
(rad/s)

-3

-2

-1

0
(rad/s)

20
cot( )

Magnitude-only
Specification
Hilbert Relations
Magnitude
Phase Relation
Summary
MATLAB routines

Given H(z) =

Q
(1qm z1 )
Q
g (1pn z1 )

10
0
-10
-20

1
H (rad)

9: Optimal IIR
Design
Error choices
Linear Least Squares
Frequency Sampling
Iterative Solution
Newton-Raphson

0.5
0
-0.5
-1

Optimal IIR: 9 9 / 11

Summary
9: Optimal IIR
Design
Error choices
Linear Least Squares
Frequency Sampling
Iterative Solution
Newton-Raphson
Magnitude-only
Specification
Hilbert Relations
Magnitude Phase
Relation
Summary
MATLAB routines

Want to minimize solution


error, ES , but
 j
 EE gives linear equations:
)
ES () = WS () B(e
j
A(e ) D()

j
j
EE () = WE () B(e ) D()A(e )
use W () to weight errors at different .
Linear least squares: solution to overdetermined Ax = b
1 T
T
= A A
Least squares error: x
A b

Closed form solution: least squares EE at {k }


WS ()
use W () = A(e
j ) to approximate ES
use Taylor series to approximate ES better (Newton-Raphson)
Hilbert relations


j
j
relate H e
and H e
for causal stable sequences




j
j

relate ln H e
and H e
for causal stable minimum
phase sequences

For further details see Mitra: 9.

DSP and Digital Filters (2014-4123)

Optimal IIR: 9 10 / 11

MATLAB routines
9: Optimal IIR
Design
Error choices
Linear Least Squares
Frequency Sampling
Iterative Solution
Newton-Raphson

invfreqz

IIR design for complex response

Magnitude-only
Specification
Hilbert Relations
Magnitude Phase
Relation
Summary
MATLAB routines

DSP and Digital Filters (2014-4123)

Optimal IIR: 9 11 / 11

10: Digital Filter

Structures

Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads
Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage

10: Digital Filter Structures

Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

DSP and Digital Filters (2014-5241)

Structures: 10 1 / 18

Direct Forms
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads

Filter: H(z) = B(z)


A(z) with input x[n] and output y[n]
PM
PN
y[n] = k=0 b[k]x[n k] k=1 a[k]y[n k]

Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage

Direct Form 1:
Direct implementation of difference equation
1
Can view as B(z) followed by A(z)

Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

Direct forms use coefficients a[k] and b[k] directly

Direct Form II:


1
followed by B(z)
Implements A(z)
Saves on delays (= storage)

DSP and Digital Filters (2014-5241)

Structures: 10 2 / 18

Transposition
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads

Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage
Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

Can

convert any block diagram into an equivalent transposed form:


Reverse direction of each interconnection
Reverse direction of each multiplier
Change junctions to adders and vice-versa
Interchange the input and output signals

Example:
Direct form II Direct Form IIt
Would normally be drawn with input on the left
Note: A valid block diagram must never have any feedback loops that dont
go through a delay (z 1 block).

DSP and Digital Filters (2014-5241)

Structures: 10 3 / 18

State Space
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads

Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage
Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

v[n] is a vector of delay element outputs


Can write: v[n + 1] = Pv[n] + qx[n]
y[n] = rT v[n] + sx[n]


T
P, q, r , s is the state-space
representation of the filter structure.
The transfer function is given by:
H(z) =

B(z)
A(z)

det(zIP+qrT )
det(zIP)
T

+s1

The transposed form has P P and q r


Example: Direct Form IIt


a[1] 1
P=
a[2] 0

T
r = 1 0
From which H(z) =

DSP and Digital Filters (2014-5241)

q=

same H(z)

b[1] b[0]a[1]
b[2] b[0]a[2]

s = b[0]
b[0]z 2 +b[1]z+b[2]
z 2 +a[1]z+a[2]
Structures: 10 4 / 18

[State-Space Transfer Function]


[This is not examinable]
We start by proving a useful formula which shows how the determinant of a matrix, A, changes when
you add a rank-1 matrix, qrT , onto it. The formula is known as the Matrix Determinant Lemma. For
any matrix A and column vectors q and r, we can write


 


T
T
1
T
T
T
1
r
1+r A q 0
1 r
1
0
=
.
1
0 A
q
I
A q
I
0 A + qrT

It is easy to verify this by multiplying out the matrices. We now take the determinant of both sides
making use of the result than a block triangular matrix is the product of the blocks along the diagonal
(assuming they are all square). This gives the result we want:


det (A) 1 + rT A1 q = det A + qrT
Now we take the z-transform of the state space equations
v[n + 1] = Pv[n] + qx[n]
y[n] = rT v[n] + sx[n]

ztransform

zV = PV + qX
Y = rT V + sX

The upper equation gives (zI P) V = qX from which V = (zI P)1 qX and by substituting this
det(zIP+qrT )
1
Y
T
+ s 1.
in the lower equation, we get X = r (zI P) q + s =
det(zIP)
DSP and Digital Filters (2014-5241)

Structures: 10 note 1 of slide 4

Precision Issues
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads

Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage
Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

If all computations were exact, it would not make any difference which of
the equivalent structures was used. However ...
Coefficient precision
Coefficients are stored to finite precision and so are not exact.
The filter actually implemented is therefore incorrect.
Arithmetic precision
Arithmetic calculations are not exact.
Worst case for arithmetic errors is when calculating the
difference between two similar values:
1.23456789 1.23455678 = 0.00001111: 9 s.f. 4 s.f.
Arithmetic errors introduce noise that is then filtered by the transfer
function between the point of noise creation and the output.

DSP and Digital Filters (2014-5241)

Structures: 10 5 / 18

Coefficient Sensitivity
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient
Sensitivity
Cascaded Biquads

Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage
Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

The roots of high order polynomials can be very sensitive to small changes
in coefficient values.
Wilkinsons polynomial: (famous example)
Q20
f (x) = n=1 (x n) = x20 210x19 + 20615x18 . . .
has roots well separated on the real axis.

Multiplying the coefficient of x19 by 1.000001 moves the roots a lot.


Speaking for myself I regard it as the most traumatic experience in
my career as a numerical analyst, James Wilkinson 1984
5

-5

-5

10

15

20

25

10

15

20

25

Moral: Avoid using direct form for filters orders over about 10.

DSP and Digital Filters (2014-5241)

Structures: 10 6 / 18

Cascaded Biquads
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads

Avoid high order polynomials by factorizing into quadratic terms:


B(z)
A(z)

Q
(1+bk,1 z1 +bk,2 z2 )
Q
g (1+ak,1 z1 +ak,2 z2 ) =

Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage
Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

The term

1+bk,1 z 1 +bk,2 z 2
k=1 1+ak,1 z 1 +ak,2 z 2

QK

 M   N 
where K = max 2 , 2 .
1+bk,1 z 1 +bk,2 z 2
1+ak,1 z 1 +ak,2 z 2

is a biquad (bi-quadratic section).

We need to choose:
(a) which poles to pair with which zeros in each biquad
(b) how to order the biquads

Direct Form II
Transposed

DSP and Digital Filters (2014-5241)

Structures: 10 7 / 18

Pole-zero Pairing/Ordering
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads
Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage

Example: Elliptic lowpass filter

1
0.5

2 pole pairs and 2 zero pairs


need 2 biquads

0
-0.5
-1

Noise introduced in one biquad is amplified


by all the subsequent ones:

-1

0
z

Make the peak gain of each biquad as small as possible


Pair poles with nearest zeros to get lowest peak gain
begin with the pole nearest the unit circle
Pairing with farthest zeros gives higher peak biquad gain

Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

Poles near the unit circle have the highest peaks and introduce most
noise so place them last in the chain
Nearest

0
-20
-40
0

0.5

DSP and Digital Filters (2014-5241)

1.5

2.5

Farthest

20
Gain (dB)

Gain (dB)

20

0
-20
-40
0

0.5

1.5

2.5

Structures: 10 8 / 18

Linear Phase
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads
Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage

Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

Implementation can take advantage of any symmetry in the coefficients.


Linear phase filters are always FIR and have symmetric (or, more rarely,
antisymmetric) coefficients.
PM
H(z) = m=0 h[m]z m
h[M m] = h[m]
 M  M P M2 1

m
mM
2
+ m=0 h[m] z
=h 2 z
[m even]
+z
For M even, we only need M
2 + 1 multiplies instead of M + 1.
We need M additions in each case.

M = 6:
For M odd (no central coefficient), we only need

DSP and Digital Filters (2014-5241)

M
2

1
2

multiplies.

Structures: 10 9 / 18

Hardware Implementation
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads
Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage

Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

Software Implementation:
All that matters is the total number of multiplies and adds
Hardware Implementation:
Delay elements (z 1 ) represent storage registers
The maximum clock speed is limited by the number of sequential
operations between registers
Example: Symmetric Linear Phase Filter
Direct form: Maximum sequential delay = 4a + m
Transpose form: Maximum sequential delay = a + m ,
a and m are the delays of adder and multiplier respectively

DSP and Digital Filters (2014-5241)

Structures: 10 10 / 18

Allpass Filters
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads
Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage

Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

Allpass filters have mirror image numerator and denominator coefficients:


b[n] = a[N n]



j

H(e ) 1

B(z) = z N A(z 1 )

There are several efficient structures, e.g.


First Order: H(z) =

a[1]+z 1
1+a[1]z 1

Second Order: H(z) =

a[2]+a[1]z 1 +z 2
1+a[1]z 1 +a[2]z 2

Allpass filters have a gain magnitude of 1 even with coefficient errors.

DSP and Digital Filters (2014-5241)

Structures: 10 11 / 18

Lattice Stage
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads
Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage

Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

Suppose G is allpass: G(z) =

z N A(z 1 )
A(z)

V (z) = X(z) kGz 1 V (z)


V (z) =

1
1+kGz 1 X(z)

Y (z) = kV (z) + Gz
If |k| < 1 then
Y (z)
X(z)

Y (z)
X(z)

V (z) =

k+z 1 G
1+kGz 1 X(z)



j j

<1
is stable since kG(e )e

kA(z)+z N 1 A(z 1 )
A(z)+kz N 1 A(z 1 )

z (N +1) D(z 1 )
D(z)

Obtaining {d[n]}
from {a[n]}:

n=0
1
d[n] = a[n] + ka[N + 1 n] 1 n N

k
n=N +1
Obtaining {a[n]} from {d[n]}:
k = d[N + 1]
a[n] =

DSP and Digital Filters (2014-5241)

d[n]kd[N +1n]
1k2
Structures: 10 12 / 18

Example A(z) D(z)


10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads
Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage
Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

A(z) = 1 + 4z 1 6z 2 + 10z 3
k = 0.5, N = 3
A(z) D(z)
z0
1

A(z)
z 4 A(z 1 )
D(z) = A(z) + kz 4 A(z 1 )

z 1
4
10
9

z 2
6
6
9

z 3
10
4
12

z 4
1
0.5

D(z) A(z)
D(z)
k = d[N + 1]
z 4 D(z 1 )
D(z) kz 4 D(z 1 )
A(z) =

D(z)kz 4 D(z 1 )
1k2

DSP and Digital Filters (2014-5241)

z0
1

z 1
9

z 2
9

z 3
12

0.5
0.75

12
3

9
4.5

9
7.5

z 4
0.5
0.5
1
0

10

Structures: 10 13 / 18

Allpass Lattice
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads
Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage
Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

We can implement any allpass filter H(z) =


with M stages:

z M A(z 1 )
A(z)

as a lattice filter

Initialize AM (z) = A(z)


Repeat for m = M : 1 : 1
k[m] = am [m]
am1 [n] =

am [n]k[m]am [mn]
1k2 [m]

equivalently Am1 (z) =

for 0 n m 1

Am (z)k[m]z m Am (z 1 )
1k2 [m]

A(z) is stable iff |k[m]| < 1 for all m (good stability test)

DSP and Digital Filters (2014-5241)

Structures: 10 14 / 18

Lattice Filter

Label outputs um [n] and vm [n] and define Hm (z) =

Vm (z)
Um (z)

z m Am (z 1 )
Am (z)

From earlier slide:


Um1 (z)
Um (z)

1
1+k[m]z 1 H

m1 (z)

Am1 (z)
Am1 (z)+k[m]z m Am1 (z 1 )

Am1 (z)
Am (z)

Hence:
Um (z)
X(z)

Am (z)
A(z)

and

Vm (z)
X(z)

Um (z)
X(z)

Vm (z)
Um (z)

z m Am (z 1 )
A(z)

m (z)
is of order m so you can create any numerator of order M by
The numerator of VX(z)
summing appropriate multiples of Vm (z):
PM
m
PM
Am (z 1 )
m=0 c[m]z
g[n] = m=0 c[m]vm [n] G(z) =
A(z)

DSP and Digital Filters (2014-5241)

Structures: 10 15 / 18

Lattice Example

A(z) = A3 (z) = 1 + 0.2z 1 0.23z 2 + 0.2z 3


k[3] = 0.2 a2 [ ] =

[1, 0.2, 0.23]0.2[0.2, 0.23, 0.2]


10.22

k[2] = 0.281 a1 [ ] =

= [1, 0.256, 0.281]

[1, 0.256]+0.281[0.281, 0.256]


10.2812

= [1, 0.357]

k[1] = 0.357 a0 [ ] = 1
V0 (z)
X(z)

1
1
1+0.2z 0.23z 2 +0.2z 3

V1 (z)
X(z)

0.357+z 1
1+0.2z 1 0.23z 2 +0.2z 3

V2 (z)
X(z)

0.281+0.256z 1 +z 2
1+0.2z 1 0.23z 2 +0.2z 3

V3 (z)
X(z)

0.20.23z 1 +0.2z 2 +z 3
1+0.2z 1 0.23z 2 +0.2z 3

Add together multiples of Vi (z) to create an arbitrary


DSP and Digital Filters (2014-5241)

B(z)
1+0.2z 1 0.23z 2 +0.2z 3
Structures: 10 16 / 18

Summary
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads
Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage
Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

Filter block diagrams


Direct forms
Transposition
State space representation
Precision issues: coefficient error, arithmetic error
cascaded biquads
Allpass filters
first and second order sections
Lattice filters
Arbitrary allpass response
Arbitrary IIR response by summing intermediate outputs
For further details see Mitra: 8.

DSP and Digital Filters (2014-5241)

Structures: 10 17 / 18

MATLAB routines
10: Digital Filter
Structures
Direct Forms
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads
Pole-zero
Pairing/Ordering
Linear Phase
Hardware
Implementation
Allpass Filters
Lattice Stage
Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Summary
MATLAB routines

residuez
tf2sos,sos2tf
zp2sos,sos2zp
zp2ss,ss2zp
tf2ss,ss2tf
poly

b(z 1)
a(z 1 )
b(z 1)
a(z 1 )

k 1prkkz1
Q b0,l +b1,l z1 +b2,l z2

{zm , pk , g}

l 1+a1,l z 1 +a2,l z 2
Q b0,l +b1,l z1 +b2,l z2
(l 1+a1,l z1 +a2,l z2

{zm , pk , g}
(

x = Ax + Bu
y = Cx + Du

x = Ax + Bu

y = Cx + Du
poly(A) = det (zIA)

b(z 1)
a(z 1 )

DSP and Digital Filters (2014-5241)

Structures: 10 18 / 18

11: Multirate

Systems

Multirate Systems
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum

11: Multirate Systems

Perfect
Reconstruction
Commutators
Summary
MATLAB routines

DSP and Digital Filters (2014-5260)

Multirate: 11 1 / 13

Multirate Systems
11: Multirate Systems
Multirate Systems
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum

Perfect
Reconstruction
Commutators
Summary
MATLAB routines

Multirate systems include more than one sample rate


Why bother?:
May need to change the sample rate
e.g. Audio sample rates include 32, 44.1, 48, 96 kHz
Can relax analog or digital filter requirements
e.g. Audio DAC increases sample rate so that the reconstruction filter
can have a more gradual cutoff
Reduce computational complexity
fs
where f is width of transition band
FIR filter length f
Lower fs shorter filter + fewer samples computation fs2

DSP and Digital Filters (2014-5260)

Multirate: 11 2 / 13

Building blocks
11: Multirate Systems
Multirate Systems
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum

Perfect
Reconstruction
Commutators
Summary
MATLAB routines

Downsample

y[m] = x[Km]
(  
n
u K
K|n
v[n] =
0
else

Upsample

Example:
Downsample by 3 then upsample by 4
w[n]

x[m]

y[r]

We use different index variables (n, m, r) for different sample rates


Use different colours for signals at different rates (sometimes)
Synchronization: all signals have a sample at n = 0.

DSP and Digital Filters (2014-5260)

Multirate: 11 3 / 13

Resampling Cascades
11: Multirate Systems
Multirate Systems
Building blocks
Resampling

Cascades

Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum
Perfect
Reconstruction
Commutators
Summary
MATLAB routines

Successive downsamplers
samplers can be combined

or

up-

Upsampling can be exactly inverted


Downsampling destroys information
permanently uninvertible
Resampling can be interchanged
iff P and Q are coprime (surprising!)
Proof: Left side: y[n] = x

P
Qn

if Q | n else y[n] = 0.
h i
P
n if Q | P n.
Right side: y[n] = x Q

But {Q | P n Q | n} iff P and Q are coprime.


[Note: a | b means b is a multiple of a]

DSP and Digital Filters (2014-5260)

Multirate: 11 4 / 13

Noble Identities
11: Multirate Systems
Multirate Systems
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum

Perfect
Reconstruction
Commutators
Summary
MATLAB routines

Resamplers commute with addition and multiplication


Delays must be multiplied by the
resampling ratio
Noble identities:
Exchange resamplers and filters
Corrollary
Example: H(z) = h[0] + h[1]z 1 + h[2]z 2 +
H(z 3 ) = h[0] + h[1]z 3 + h[2]z 6 +

DSP and Digital Filters (2014-5260)

Multirate: 11 5 / 13

Noble Identities Proof


11: Multirate Systems
Multirate Systems
Building blocks
Resampling Cascades
Noble Identities
Noble Identities
Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum

Perfect
Reconstruction
Commutators
Summary
MATLAB routines

Define hQ [n] to be the


impulse response of H(z Q ).
Assume that h[r] is of length M + 1 so that hQ [n] is of length QM + 1.
We know that hQ [n] = 0 except when Q | n and that h[r] = hQ [Qr].
PQM
w[r] = v[Qr] = s=0 hQ [s]x[Qr s]
P
PM
= M
h
[Qm]x[Qr

Qm]
=
h[m]x[Q(r m)]
Q
m=0
m=0
PM
= m=0 h[m]u[r m] = y[r] ,
Upsampled Noble Identity:

We know that v[n] = 0 except when Q | n and that v[Qr] = x[r].


PQM
PM
w[n] = s=0 hQ [s]v[n s] = m=0 hQ [Qm]v[n Qm]
PM
= m=0 h[m]v[n Qm]

If Q n, then v[n Qm] = 0 m so w[n] = 0 = y[n]


P
If Q | n = Qr, then w[Qr] = M
h[m]v[Qr Qm]
PM m=0
= m=0 h[m]x[r m] = u[r] = y[Qr] ,

DSP and Digital Filters (2014-5260)

Multirate: 11 6 / 13

Upsampled z-transform
11: Multirate Systems
Multirate Systems
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum

Perfect
Reconstruction
Commutators
Summary
MATLAB routines

V (z) =

v[n]z

n:K|n

n n
]z
u[ K

u[m]z Km = U (z K )

Spectrum: V (ej ) = U (ejK )


Spectrum is horizontally shrunk and replicated K times.
Total energy unchanged; power (= energy/sample) multiplied by
Upsampling normally followed by a LP filter to remove images.

1
K

Example:
Asymmetric real spectrum ( complex signal)
K = 3: three images of the
original
spectrum in all.


R
R
2
1
1
j 2

Energy unchanged: 2 U (e ) d = 2 V (ej ) d
1

0.5

0.5

DSP and Digital Filters (2014-5260)

-2

-2

Multirate: 11 7 / 13

Downsampled z-transform
11: Multirate Systems
Multirate Systems
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum

Perfect
Reconstruction
Commutators
Summary
MATLAB routines

1
K

PK1

1
K

PK1

j2kn

K
Define cK [n] = K|n [n] =
k=0 e
(
x[n] K | n
Now define xK [n] =
= cK [n]x[n]
0
Kn
P
P PK1 j2kn
1
K
XK (z) = n xK [n]z n = K
x[n]z n
n
k=0 e
 j2k n
PK1 P
PK1
j2k
1
1
K
K
= K k=0
=
z
z)
x[n]
e
X(e
n
k=0
K

From previous slide:

XK (z) = Y (z K )
1
Y (z) = XK (z K ) =

k=0

X(e

Frequency Spectrum:
PK1
j(2k)
1
j
Y (e ) = K  k=0 X(e K )
j
K

j
2
K K

j2k
K

zK)

j
4
K K

1
X(e ) + X(e
=K
) + X(e
) +
Horizontally expanded by a factor of K, average of K aliased versions.
Downsampling is normally preceded by a LP filter to prevent aliasing.

DSP and Digital Filters (2014-5260)

Multirate: 11 8 / 13

Downsampled Spectrum
11: Multirate Systems
Multirate Systems
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum

Perfect
Reconstruction
Commutators
Summary
MATLAB routines

Y (e ) =

1
K

Example 1:

PK1
k=0

X(e

j(2k)
K

0.5

0.5

K=3

Not quite limited to K


Shaded region shows aliasing

R
1
j 2

Energy decreases: 2 Y (e ) d
0

-2

1
2K

Example 2:

K=3

Energy all in K
|| < 2 K
No aliasing: ,

-2


R
X(ej ) 2 d
1

0.5

0.5

-2

-2

No aliasing: All energy is in r K


|| < (r + 1) K
for some integer r

Normal case (r = 0): All energy in 0 || K


1
if there is no aliasing
Downsampling: Total energy multiplied by K
Average power (= energy/sample) unchanged
DSP and Digital Filters (2014-5260)

Multirate: 11 9 / 13

Perfect Reconstruction
11: Multirate Systems
Multirate Systems
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum
Perfect

x[n]
u[m]
p[n]
v[m]
q[n]
w[m]
y[n]

cdefghijklmn
c f i l
-c--f--i--l
b e h k
-bc-ef-hi-kl
a d g j
abcdefghijkl

Reconstruction
Commutators
Summary
MATLAB routines

Input sequence x[n] is split into three streams at

1
3

the sample rate:

u[m] = x[3m], v[m] = x[3m 1], w[m] = x[3m 2]


Following upsampling, the streams are aligned by the delays and then added
to give:
y[n] = x[n 2]
Perfect Reconstruction: output is a delayed scaled replica of the input

DSP and Digital Filters (2014-5260)

Multirate: 11 10 / 13

Commutators
11: Multirate Systems
Multirate Systems
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum
Perfect
Reconstruction
Commutators
Summary
MATLAB routines

x[n]
u[m]
v[m]
w[m]
v[m + 13 ]
w[m + 23 ]
y[n]

cdefghijklmn
c f i l
b e h k
a d g j
e h k l
d g j m
abcdefghijkl

The combination of delays and downsamplers can be regarded as a


commutator that distributes values in sequence to u, w and v.
2
1
Fractional delays, z 3 and z 3 are needed to synchronize the streams.
The output commutator takes values from the streams in sequence.
For clarity, we omit the fractional delays and regard each terminal, , as
holding its value until needed. Initial commutator position has zero delay.

The commutator direction is against the direction of the z 1 delays.


DSP and Digital Filters (2014-5260)

Multirate: 11 11 / 13

Summary
11: Multirate Systems
Multirate Systems
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum
Perfect
Reconstruction
Commutators
Summary
MATLAB routines

Multirate Building Blocks


1:K
Upsample: X(z) X(z K )
Invertible, Inserts K 1 zeros between samples
Shrinks and replicates spectrum
Follow by LP filter to remove images
j2k
1
K:1 1 PK1
Downsample: X(z) K k=0 X(e K z K )
Destroys information and energy, keeps every K th sample
Expands and aliasses spectrum
Precede by LP filter to prevent aliases
Equivalences
Noble Identities: H(z) H(z K )
Interchange P : 1 and 1 : Q iff P and Q coprime
Commutators
Combine delays and down/up sampling
For further details see Mitra: 13.

DSP and Digital Filters (2014-5260)

Multirate: 11 12 / 13

MATLAB routines
11: Multirate Systems
Multirate Systems
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum

resample

change sampling rate

Perfect
Reconstruction
Commutators
Summary
MATLAB routines

DSP and Digital Filters (2014-5260)

Multirate: 11 13 / 13

12: Polyphase

Filters

Heavy Lowpass
filtering
Maximum Decimation
Frequency
Polyphase
decomposition
Downsampled
Polyphase Filter
Polyphase Upsampler
Complete Filter
Upsampler
Implementation

12: Polyphase Filters

Downsampler
Implementation
Summary

DSP and Digital Filters (2014-5260)

Polyphase Filters: 12 1 / 10

Heavy Lowpass filtering


12: Polyphase Filters
Heavy Lowpass
filtering
Maximum Decimation
Frequency

Polyphase
decomposition
Downsampled
Polyphase Filter
Polyphase Upsampler
Complete Filter
Upsampler
Implementation
Downsampler
Implementation
Summary

Filter Specification:
Sample Rate: 20 kHz
Passband edge: 100 Hz (1 = 0.03)
Stopband edge: 300 Hz (2 = 0.09)
Passband ripple: 0.05 dB ( = 0.006)
Stopband Gain: 80 dB ( = 0.0001)
This is an extreme filter because the cutoff frequency is only 1% of the
Nyquist frequency.
Symmetric FIR Filter:
Design with Remez-exchange algorithm
Order = 360
0

0
M=360

-20

-20

-40

-40

-60

-60

-80

-80

DSP and Digital Filters (2014-5260)

(rad/s)

0.05
(rad/s)

0.1

Polyphase Filters: 12 2 / 10

Maximum Decimation Frequency


12: Polyphase Filters
Heavy Lowpass
filtering
Maximum
Decimation
Frequency

If a filter passband occupies only a small fraction


of [0, ], we can downsample then upsample
without losing information.

Upsampler
Implementation
Downsampler
Implementation
Summary

-20
-40
-60
0 1

Polyphase
decomposition
Downsampled
Polyphase Filter
Polyphase Upsampler
Complete Filter

Downsample: aliased components at offsets of


2
K are almost zero because of H(z)
Upsample: Images spaced at 2
K can be
removed using another low pass filter
To avoid aliasing in the passband, we need
2
K

2 1

2
1 +2

= 2 /4

K=4

-20
-40
-60
0

= 2 /7

K=7

-20
-40
-60
0

Centre of transition band must be intermediate Nyquist freq,

We must add a lowpass filter to remove the images:


Passband noise = noise floor at output of H(z) plus 10 log10 (K 1) dB.
DSP and Digital Filters (2014-5260)

Polyphase Filters: 12 3 / 10

Polyphase decomposition
12: Polyphase Filters
Heavy Lowpass
filtering
Maximum Decimation
Frequency

Polyphase
decomposition

Downsampled
Polyphase Filter
Polyphase Upsampler
Complete Filter
Upsampler
Implementation
Downsampler
Implementation
Summary

For our filter: original Nyquist frequency = 10 kHz and transition band
centre is at 200 Hz so we can use K = 50.
Split H(z) into K filters each of order R 1. For convenience, assume
M + 1 is a multiple of K (else zero-pad h[n]).
Example:
M = 399 R = MK+1 = 8
PM
H(z) = m=0 h[m]z m
PK1
P2K1
m
= m=0 h[m]z
+ m=K h[m]z m +
PK1 PR1
= m=0 r=0 h[m + Kr]z mKr
P
PR1
m
Kr
= K1
z
m=0
r=0 hm [r]z
where hm [r] = h[m + Kr]

Example: 

h0 [r] =  h[0] h[50] h[350] 
h1 [r] = h[1] h[51] h[351]

This is a polyphase implementation of the filter H(z)


DSP and Digital Filters (2014-5260)

Polyphase Filters: 12 4 / 10

Downsampled Polyphase Filter


12: Polyphase Filters
Heavy Lowpass
filtering
Maximum Decimation
Frequency
Polyphase
decomposition
Downsampled

Polyphase Filter

H(z) is low pass so we downsample its


output by K without aliasing.
The number of multiplications per input
sample is M + 1 = 400.

Polyphase Upsampler
Complete Filter
Upsampler
Implementation
Downsampler
Implementation
Summary

Using the Noble identities, we can move


the resampling back through the adders
and filters. Hm (z K ) turns into Hm (z)
at a lower sample rate.
We still perform 400 multiplications but
now only once for every K input
samples.
Multiplications per input sample = 8 (down by a factor of 50 ,) but v[n]
has the wrong sample rate (/).

DSP and Digital Filters (2014-5260)

Polyphase Filters: 12 5 / 10

Polyphase Upsampler
12: Polyphase Filters
Heavy Lowpass
filtering
Maximum Decimation
Frequency
Polyphase
decomposition
Downsampled
Polyphase Filter
Polyphase

Upsampler
Complete Filter
Upsampler
Implementation
Downsampler
Implementation
Summary

To restore sample rate: upsample and


then lowpass filter to remove images
We can use the same lowpass filter,
H(z), in polyphase form:
PK1 m PR1
Kr
m=0 z
r=0 hm [r]z

This time we put the delay z m after


the filters.
Multiplications per output sample =
400
Using the Noble identities, we can move
the resampling forwards through the
filters. Hm (z K ) turns into Hm (z) at a
lower sample rate.
Multiplications per output sample = 8
(down by a factor of 50 ,).

DSP and Digital Filters (2014-5260)

Polyphase Filters: 12 6 / 10

Complete Filter
12: Polyphase Filters
Heavy Lowpass
filtering
Maximum Decimation
Frequency
Polyphase
decomposition

The overall system implements:


Need an extra gain of K to compensate for the downsampling energy loss.

Downsampled
Polyphase Filter
Polyphase Upsampler
Complete Filter

Filtering at downsampled rate requires 16 multiplications per input sample


(8 for each filter). Reduced by K
2 from the original 400.

Upsampler
Implementation

H(ej ) reaches 10 dB at the downsampler

.
Nyquist frequency of K

Spectral components > K


will be aliased
down in frequency in V (ej ).

Downsampler
Implementation
Summary

For V (ej ), passband gain (blue curve)


follows the same curve as X(ej ).
Noise arises from K aliased spectral intervals.
Unit white noise in X(ej ) gives passband
noise floor at 69 dB (red curve) even
though stop band ripple is below 83 dB
(due to K 1 aliased stopband copies).
DSP and Digital Filters (2014-5260)

0
-20
-40
-60

/50

-80
0

0.05
(rad/s)

0.1

0
-20
-40

-60
-80
0

1
2
(downsampled)

Polyphase Filters: 12 7 / 10

Upsampler Implementation
12: Polyphase Filters
Heavy Lowpass
filtering
Maximum Decimation
Frequency

We can represent the upsampler


compactly using a commutator.

Polyphase
decomposition
Downsampled
Polyphase Filter
Polyphase Upsampler
Complete Filter
Upsampler

Implementation
Downsampler
Implementation
Summary

H0 (z) comprises a sequence of 7


delays, 7 adders and 8 gains.
We can share the delays between
all 50 filters.

We can also share the gains and


adders between all 50 filters and
use commutators to switch the
coefficients.
We now need 7 delays, 7 adders and 8 gains for the entire filter.
DSP and Digital Filters (2014-5260)

Polyphase Filters: 12 8 / 10

Downsampler Implementation
12: Polyphase Filters
Heavy Lowpass
filtering
Maximum Decimation
Frequency
Polyphase
decomposition
Downsampled
Polyphase Filter
Polyphase Upsampler
Complete Filter
Upsampler
Implementation
Downsampler

Implementation
Summary

We can again use a commutator.


The outputs from all 50 filters are
added together to form v[i].
We use the transposed form of
Hm (z) because this will allow us
to share components.
We can sum the outputs of the
gain elements using an
accumulator which sums blocks of
K samples.
Now we can share all the
components and use commutators
to switch the gain coefficients.

w[i] =

PK1
r=0

u[Ki r]

We need 7 delays, 7 adders, 8


gains and 8 accumulators in total.

DSP and Digital Filters (2014-5260)

Polyphase Filters: 12 9 / 10

Summary
12: Polyphase Filters
Heavy Lowpass
filtering
Maximum Decimation
Frequency
Polyphase
decomposition
Downsampled
Polyphase Filter
Polyphase Upsampler
Complete Filter
Upsampler
Implementation
Downsampler
Implementation
Summary

Filtering should be performed at the lowest possible sample rate


reduce filter computation by K
actual saving is only K
2 because you need a second filter
downsampled Nyquist frequency max (passband ) +
2
PK1 m
Polyphase decomposition: split H(z) as m=0 z Hm (z K )
each Hm (z K ) can operate on subsampled data
combine the filtering and down/up sampling
Noise floor is higher because it arises from K spectral intervals that
are aliased together by the downsampling.
Share components between the K filters
multiplier gain coefficients switch at the original sampling rate
need a new component: accumulator/downsampler (K : )
For further details see Harris 5.

DSP and Digital Filters (2014-5260)

Polyphase Filters: 12 10 / 10

13: Resampling

Filters

Resampling
Halfband Filters
Dyadic 1:8 Upsampler
Rational Resampling
Arbitrary Resampling
Polynomial
Approximation
Farrow Filter
Summary
MATLAB routines

DSP and Digital Filters (2014-5272)

13: Resampling Filters

Resampling: 13 1 / 10

Resampling
13: Resampling
Filters
Resampling
Halfband Filters
Dyadic 1:8 Upsampler
Rational Resampling
Arbitrary Resampling

Polynomial
Approximation
Farrow Filter
Summary
MATLAB routines

Suppose we want to change the sample rate while preserving information:


e.g. Audio 44.1 kHz48 kHz96 kHz
Downsample:
LPF to new Nyquist bandwidth: 0 =
Upsample:
LPF to old Nyquist bandwidth: 0 =

P
Rational ratio: fs Q
LPF to lower of old and new Nyquist

bandwidths: 0 = max(P,Q)

Polyphase decomposition reduces computation by K = max(P, Q).


The transition band centre should be at the Nyquist frequency, 0 =

d
where d is stopband attenuation in dB and
Filter order M 3.5
is the transition bandwidth (Remez-exchange estimate).

, is typically fixed.
Fractional semi-Transition bandwidth, = 2
0
dK
e.g. = 0.05 M 7
= 0.9dK
DSP and Digital Filters (2014-5272)

Resampling: 13 2 / 10

Halfband Filters
13: Resampling
Filters
Resampling
Halfband Filters
Dyadic 1:8 Upsampler
Rational Resampling
Arbitrary Resampling

Polynomial
Approximation
Farrow Filter
Summary
MATLAB routines

If K = 2 then the new Nyquist frequency is


0 = 2 .

0.5

0 n
by a Kaiser
We multiply ideal response sinn
window. All even numbered points are zero
except h[0] = 0.5.

0
0

(rad/s)

M=20
=2.5

If 4 | M and we make the filter causal (z 2 ),


P M2 1
1
M
2r
H(z) = 0.5z 2 + z
h
[r]z
1
r=0
Half-band upsampler:

We interchange the filters with the 1:2 block


and use the commutator notation.
H1 (z) is symmetrical with M
2 coefficients
so we need M
4 multipliers in total (input gain
of 0.5 can usually be absorbed elsewhere).
Computation:
DSP and Digital Filters (2014-5272)

M
4

multiplies per input sample


Resampling: 13 3 / 10

Dyadic 1:8 Upsampler


13: Resampling
Filters
Resampling
Halfband Filters
Dyadic 1:8
Upsampler
Rational Resampling
Arbitrary Resampling

Polynomial
Approximation
Farrow Filter
Summary
MATLAB routines

0.8

1
0.5

Suppose X(z): BW = 0.8 = 0.2

0
0

Upsample 1:2 U (z):


Filter HP (z) must remove image: = 0.2
60
For attenuation = 60 dB, P 3.5
= 27.3
Round up to a multiple of 4: P = 28

Upsample 1:2 V (z): = 0.6 Q = 12


Upsample 1:2 Y (z): = 0.8 R = 8
[diminishing returns + higher sample rate]
Multiplication
Count:

1 + P4 fx + Q
4 2fx +

R
4

4fx = 22fx

0.4

0
0

3
0.8

0.1

3
0.9

R=8

0.5
1

0.15

0.5

M=110

0
0

Q=12

0
0

0
0

0.6

0.2

0.5

P=28

0.5

Alternative approach using direct 1:8 upsampling:


= 0.05 M = 110 111fx multiplications (using polyphase)
DSP and Digital Filters (2014-5272)

Resampling: 13 4 / 10

Rational Resampling
13: Resampling
Filters
Resampling
Halfband Filters
Dyadic 1:8 Upsampler
Rational
Resampling
Arbitrary Resampling

P
To resample by Q
do 1:P
then LPF, then Q:1.

x[n]
v[r]
y[i]

Polynomial
Approximation
Farrow Filter
Summary
MATLAB routines

Resample by

P
Q

0 =

, 20 =

max(P, Q)

2
max(P, Q)

P 1 p
Polyphase: H(z) = P
Hp (z P )
p=0 z
Commutate coefficients:
P samples of v[s] for each x[n]
Keep only every Qth output:
y[i] uses Hp (z) with p = Qi mod P
Multiplication Count:
[dB]
H(z): M + 1 60
3.5 =
Hp (z): R + 1 =

M +1
P

2.7 max(P, Q)


Q
2.7
max
1,


Multiplication rate: 2.7
max 1,

DSP and Digital Filters (2014-5272)

Q
P

fy =

M + 1 coeficients in all
2.7

max (fy , fx )
Resampling: 13 5 / 10

Arbitrary Resampling
13: Resampling
Filters
Resampling
Halfband Filters
Dyadic 1:8 Upsampler
Rational Resampling
Arbitrary

Resampling
Polynomial
Approximation
Farrow Filter
Summary
MATLAB routines

Sometimes need very large P and Q:


kHz
147
e.g. 44.1
=
48 kHz
160
2.7 max(fy , fx )
Multiplication rate OK:

Q)
However # coefficients: 2.7 max(P,

1/P

Alternatively, use a conveniently large P


and round down to the nearest sample:
E.g. for y[i] at time i Q
P use hp [r]
where p = (iQ)mod P

1
0.5

Equivalent to converting to analog with


P
.
zero-order hold and resampling at fy = Q
Zero-order hold convolves with rectangular
periodic spectrum by

sin 2P

2P

0
0

1
P

Q/P

1) Upsample @ P
2) LPC to 0
3) Zero-order hold
2P
(rad/s)

4P

-wide window multiplies

. Resampling aliases to mod 2P .


Q

Unit power component at 1 gives alias components with total power:


2 
2

12 2 2
21
2 1 P
2P
2P
4P 2 62 = 12P 2
sin 2P n=1 2nP +1 + 2nP 1

For worst case, 1 = , need P = 906 to get 60 dB /


DSP and Digital Filters (2014-5272)

Resampling: 13 6 / 10

[Alias Components]
Ignoring the polyphase implementation, the low pass filter operates at a sample rate of P and therefore
has a periodic spectrum that repeats at intervals of 2P . Therefore, considering positive frequencies
only, a signal component in the passband at 1 will have images at = 2nP 1 for all positive
integers n.
0.5P 1
These components are multiplied by the sin0.5P
function and therefore have amplitudes of
1
sin(n0.5P 1 1 )
sin(1n 0.5P 1 1 )
sin 0.5P 1 (2nP 1 )
=
=
.
0.5P 1 (2nP 1 )
(n0.5P 1 1 )
(n0.5P 1 1 )
P
, these images will be aliased to frequencies
When we do the downsampling to an output sample rate of Q
mod 2P . In general, these alias frequencies will be scattered throughout the range (0, ) and will
Q
result in broadband noise.

We need to sum the squared amplitudes of all these components:


 P
P sin2 (1n 0.5P 1 1 )
1
2
1
0.5P 1
n=1 (n0.5P 1 )2
n=1 (n0.5P 1 )2 = sin
1
1

1
1
1
If we assume that n 0.5P 1 and also that sin 0.5P 1 0.5P 1 , then we can approximate this sum as
2 P
2
2
2 P
2
1
0.5P 1 1
=

2
2
n=1 (n)
n=1 n
4P
2
2
.
6
2
is 12P1 2 .

The summation is a standard result and equals

So the total power of the aliased components

DSP and Digital Filters (2014-5272)

Resampling: 13 note 1 of slide 6

Polynomial Approximation
13: Resampling
Filters
Resampling
Halfband Filters
Dyadic 1:8 Upsampler
Rational Resampling
Arbitrary Resampling
Polynomial

Approximation
Farrow Filter
Summary
MATLAB routines

Suppose P = 50 and H(z) has order M = 249

H(z) is lowpass filter with 0 50


Split into 50 filters of length R + 1 = MP+1 = 5:
hp [0] is the first P samples of h[m]
0
hp [1] is the next P samples, etc.
-20
hp [r] = h[p + rP ]
-40
Use a polynomial of order N to
approximate each segment:
hp [r] fr ( Pp ) with 0 Pp < 1

-60
-80
0

1
0.5 h [0]
p

h[m] is smooth, so errors are low.


E.g. error < 103 for L = 4

0
0

M=249, =6.5
hp[2] hp[3] hp[4]

hp[1]
50

100

150

200

m
-3

DSP and Digital Filters (2014-5272)

error

Resultant filter almost as good


Instead of M + 1 = 250
coefficients we only need
(R + 1)(L + 1) = 25
where


Q
2.7
R + 1 = max 1, P

x 10

L=4

0
-1
0

0
-20 0
-40
-60
-80
0

50

100

150

200

Farrow with L=4

Resampling: 13 7 / 10

Farrow Filter
13: Resampling
Filters
Resampling
Halfband Filters
Dyadic 1:8 Upsampler
Rational Resampling
Arbitrary Resampling
Polynomial
Approximation
Farrow Filter
Summary
MATLAB routines

Q
Filter coefficients depend on fractional
part
of
i
P:
j k
Q

n
where
n
=
i
[i] = i Q
P
P

R+1=

M +1
P

=5

PR

y[i] = r=0 fr ([i])x[n r]


PL
where fr () = l=0 bl [r]l
PR PL
y[i] = r=0 l=0 bl [r][i]l x[n r]
PL
PR
l
= l=0 [i]
r=0 bl [r]x[n r]
PL
= l=0 [i]l vl [n]
where vl [n] = bk [n] x[n]
[like a Taylor series expansion]

Horners Rule:
y[i] = v0 [n] + (v1 [n] + (v2 [n] + ( )))
Multiplication Rate:

Q
2.7
R + 1 max 1, P
Each Bk (z) needs R + 1 per input sample
Horner needs L per output sample


fx
2.7
Total rate: (L + 1) (R + 1) fx + Lfy = max 1, fy fx + Lfy

DSP and Digital Filters (2014-5272)

Resampling: 13 8 / 10

Summary
13: Resampling
Filters
Resampling
Halfband Filters
Dyadic 1:8 Upsampler
Rational Resampling
Arbitrary Resampling
Polynomial
Approximation
Farrow Filter
Summary
MATLAB routines

Transition band centre at 0


0 = the lower of the old and new Nyquist frequencies
Transition width = = 20 , typically 0.1
Factorizing resampling ratio can reduce computation
halfband filters very efficient (half the coefficients are zero)
P
Rational resampling Q
# multiplies per second: 2.7
max (fy , fx )
# coefficients: 2.7
max (P, Q)
Farrow Filter
approximate filter impulse response with polynomial segments
arbitrary resampling ratios
fx
# multiplies per second: 2.7
max (fy , fx ) fy + Lfy
fx
fy

times rational resampling case good for upsampling




Q
# coefficients: 2.7
(L + 1) max 1, P
coefficients are independent of fy when upsampling

For further details see Mitra: 13 and Harris: 7, 8.


DSP and Digital Filters (2014-5272)

Resampling: 13 9 / 10

MATLAB routines
13: Resampling
Filters
Resampling
Halfband Filters
Dyadic 1:8 Upsampler
Rational Resampling
Arbitrary Resampling
Polynomial
Approximation
Farrow Filter
Summary
MATLAB routines

gcd(p,q)
polyfit
polyval
upfirdn
resample

Find p + q = 1 for coprime p, q


Fit a polynomial to data
Evaluate a polynomial
Perform polyphase filtering
Perform polyphase resampling

DSP and Digital Filters (2014-5272)

Resampling: 13 10 / 10

14: FM Radio

Receiver

FM Radio Block
Diagram
Aliased ADC
Channel Selection
Channel Selection (1)
Channel Selection (2)
Channel Selection (3)
FM Demodulator
Differentiation Filter
Pilot tone extraction
Polyphase Pilot tone
Summary

DSP and Digital Filters (2014-5272)

14: FM Radio Receiver

FM Radio: 14 1 / 12

FM Radio Block Diagram


14: FM Radio
Receiver
FM Radio Block
Diagram
Aliased ADC
Channel Selection
Channel Selection (1)
Channel Selection (2)
Channel Selection (3)
FM Demodulator
Differentiation Filter
Pilot tone extraction
Polyphase Pilot tone
Summary

FM spectrum: 87.5 to 108 MHz


Each channel: 100 kHz
Baseband signal:
Mono (L + R): 15 kHz
Pilot tone: 19 kHz
Stereo (L R): 38 15 kHz
RDS: 57 2 kHz

200 kHz per channel

87.5

108

MHz

L-R

L+R

RDS
0

15 19 23

38

53 57 kHz

FM Modulation:
Freq deviation: 75 kHz

LR signal is multiplied by 38 kHz to shift it to baseband


[This example is taken from Ch 13 of Harris: Multirate Signal Processing]
DSP and Digital Filters (2014-5272)

FM Radio: 14 2 / 12

-80

-40

72.5

87.5

40

ff s

f+2f s

However:
fs = 80 creates aliased
images at intervals of fs

f+f s

FM band: 87.5 to 108 MHz


Normally sample at fs > 2f

80 MHz

ve frequencies also
generate images
We want the image
between 7.5 and 28 MHz
Need an analogue bandpass
filter to extract the FM band

0
|H| (dB)

14: FM Radio
Receiver
FM Radio Block
Diagram
Aliased ADC
Channel Selection
Channel Selection (1)
Channel Selection (2)
Channel Selection (3)
FM Demodulator
Differentiation Filter
Pilot tone extraction
Polyphase Pilot tone
Summary

f2f s

Aliased ADC

-60
108

132 MHz

Transition band mid-points are at fs and 32 fs


You can use an aliased analog-digital converter (ADC) provided that the
target band fits entirely between two consecutive multiples of 21 fs .
Lower ADC sample rate ,. Image = undistorted frequency-shifted copy.
DSP and Digital Filters (2014-5272)

FM Radio: 14 3 / 12

Channel Selection
14: FM Radio
Receiver
FM Radio Block
Diagram
Aliased ADC
Channel Selection
Channel Selection (1)
Channel Selection (2)
Channel Selection (3)
FM Demodulator
Differentiation Filter
Pilot tone extraction
Polyphase Pilot tone
Summary

FM band shifted to 7.5 to 28 MHz (from 87.5 to 108 MHz)


We need to select a single channel 200 kHz wide
We downsample to fs = 400 kHz and shift selected channel to DC.
Assume channel centre frequency is fc = c 100 kHz
We must apply a filter before downsampling to remove unwanted images
The downsampled signal is complex since positive and negative frequencies
contain different information.
Three methods:
1 Freq shift, then polyphase lowpass filter
2 Polyphase bandpass complex filter
3 Polyphase bandpass real filter
1
200 kHz per channel

7.5

DSP and Digital Filters (2014-5272)

f c=c100kHz

28

MHz

0
40

-400 -300

-100

100

300 400 kHz

FM Radio: 14 4 / 12

Channel Selection (1)


14: FM Radio
Receiver
FM Radio Block
Diagram
Aliased ADC
Channel Selection
Channel Selection
(1)
Channel Selection (2)
Channel Selection (3)
FM Demodulator
Differentiation Filter
Pilot tone extraction
Polyphase Pilot tone
Summary

fc

Multiply by ej2r 80M to shift


channel at fc to DC.
fc
c
fc = c 100 k 80M
= 800
Result of multiplication is complex
(thick lines on diagram)

Next, lowpass filter to 100 kHz


k
= 2 200
80 M = 0.157

M =

60 dB
3.5

-400 -300

-100

100

300 400 kHz

= 1091

Finally, downsample 200:1


Polyphase: 

1092
Hp (z) has 200 = 6 taps

Complex data Real Coefficients (needs 2 multiplies per tap)

Multiplication Load:
2 80 MHz (freq shift) + 12 80 MHz (Hp (z)) = 14 80 MHz
DSP and Digital Filters (2014-5272)

FM Radio: 14 5 / 12

Channel Selection (2)


14: FM Radio
Receiver
FM Radio Block
Diagram
Aliased ADC
Channel Selection
Channel Selection (1)
Channel Selection

Channel centre frequency fc = c 100 kHz where c is an integer.


Write c = 4k + l
where k = 4c and l = cmod 4

(2)

Channel Selection (3)


FM Demodulator
Differentiation Filter
Pilot tone extraction
Polyphase Pilot tone
Summary

We multiply u[r] by ej2r 800 then convolve with h[m]:


PM
c
[r = 200n]
v[n] = m=0 h[m]u[200n m]ej2(200nm) 800
PM
4k+l
mc
= m=0 h[m]ej2 800 u[200n m]ej2200n 800
[c = 4k + 1]
PM
mc

j2 800
j2 ln
4
]
= m=0 g[c] [m]u[200n m]e
[g[c] [m] = h[m]e
P
j2 ln
4 indep of m]
= (j)ln M
[e
g
[m]u[200n

m]
m=0 [c]
Multiplication Load for polyphase implementation:
G[c],p (z) has complex coefficients real input 2 mults per tap
(j)ln {+1, j, 1, +j} so no actual multiplies needed
Total: 12 80 MHz (G[c],p (z)) + 0 (j lr ) = 12 80 MHz

DSP and Digital Filters (2014-5272)

FM Radio: 14 6 / 12

Channel Selection (3)


14: FM Radio
Receiver
FM Radio Block
Diagram
Aliased ADC
Channel Selection
Channel Selection (1)
Channel Selection (2)

Channel frequency fc = c 100 kHz where c = 4k + l is an integer

Channel Selection

(3)

FM Demodulator
Differentiation Filter
Pilot tone extraction
Polyphase Pilot tone
Summary

cm

g[c] [m] = h[m]ej2 800


j2 c(200s+p)
800

g[c],p [s] = gc [200s + p]= h[200s + p]e


cp
j2 ls
j2 800
4

= h[200s + p]e

[polyphase]
[l = cmod 4 ]

ls

Define f[c],p [s] = h[200s + p]ej2 4 = j ls h[200s + p]


Although f[c],p [s] is complex it requires only one multiplication per
tap because each tap is either purely real or purely imaginary.
Multiplication Load:
cp
6 80 MHz (Fp (z)) + 4 80 MHz (ej2 800 ) = 10 80 MHz
DSP and Digital Filters (2014-5272)

FM Radio: 14 7 / 12

FM Demodulator
14: FM Radio
Receiver
FM Radio Block
Diagram
Aliased ADC
Channel Selection
Channel Selection (1)
Channel Selection (2)
Channel Selection (3)
FM Demodulator
Differentiation Filter
Pilot tone extraction
Polyphase Pilot tone
Summary

0
-400 -300

-100

300 400 kHz

100

Complex FM signal centred at DC: v(t) = |v(t)|ej(t)


We know that log v = log |v| + j
The instantaneous frequency of v(t) is
We need to calculate

d
dt

d(log v)
dt

d
dt .

1 dv
v dt

1
|v|2

We need:
(1) Differentiation filter, D(z)
(2) Complex multiply, w[n] v [n] (only need part)
(3) Real Divide by |v|2

v dv
dt

L-R

L+R

RDS

x[n] is baseband signal (real):


DSP and Digital Filters (2014-5272)

15 19 23

38

53 57 kHz

FM Radio: 14 8 / 12

Differentiation Filter
14: FM Radio
Receiver
FM Radio Block
Diagram
Aliased ADC
Channel Selection
Channel Selection (1)
Channel Selection (2)
Channel Selection (3)
FM Demodulator
Differentiation
Filter
Pilot tone extraction
Polyphase Pilot tone
Summary

(
j || 0
d jt
jt
j
= je
D(e ) =
Differentiation: dt e
0
|| > 0
i
h jn
R
jn 0

0
j
1
Hence d[n] = 2
[IDTFT]
jejn d = 2 ejn ej 2 n2
0
=

1
0.5

0
0

n0 cos n0 sin n0
n2

0
|H| (dB)

1.5

|H|

Window design method:


(1) calculate d[n] for the ideal filter
(2) multiply by a window to give finite support

-20
-40
0

-60
-80
0.5

1.5
2
(rad/sample)

2.5

0.5

1.5
2
(rad/sample)

2.5

Using M = 18, Kaiser window, = 7 and 0 = 2.2 =

2140 kHz
400 kHz :

Near perfect differentiation for 1.6 ( 100 kHz @ 400 kHz fs )


Broad transition region allows shorter filter
DSP and Digital Filters (2014-5272)

FM Radio: 14 9 / 12

Pilot tone extraction


14: FM Radio
Receiver
FM Radio Block
Diagram
Aliased ADC
Channel Selection
Channel Selection (1)
Channel Selection (2)
Channel Selection (3)
FM Demodulator
Differentiation Filter
Pilot tone
extraction
Polyphase Pilot tone
Summary

F(z)

G(z)
L-R

L+R
H(z)

RDS
0

15 19 23

38

53 57 kHz

Aim: extract 19 kHz pilot tone, double freq real 38 kHz tone.
20k

(1) shift spectrum down by 20 kHz: multiply by ej2n 400k


(2) low pass filter to 1 kHz to extract complex pilot at 1 kHz: H(z)

jt 2
[ e
= ej2t ]
(3) square to double frequency to 2 kHz
40k

(4) shift spectrum up by 40 kHz: multiply by e+j2n 400k


(5) take real part

More efficient to do low pass filtering at a low sample rate:

Transition bands:
F (z): 1 19 kHz,
H(z): 1 3 kHz,
G(z): 2 18 kHz
= 0.28 M = 60, = 0.63 27, = 0.25 68
DSP and Digital Filters (2014-5272)

FM Radio: 14 10 / 12

Polyphase Pilot tone


14: FM Radio
Receiver
FM Radio Block
Diagram
Aliased ADC
Channel Selection
Channel Selection (1)
Channel Selection (2)
Channel Selection (3)
FM Demodulator
Differentiation Filter
Pilot tone extraction
Polyphase Pilot
tone
Summary

Anti-alias filter: F (z)


n
th
j2 20
Each branch, Fp (z), gets every 20 sample and an identical e
p
j2 20
So Fp (z) can filter a real signal and then multiply by fixed e
Anti-image filter: G(z)
n
Each branch, Gp (z), multiplied by identical ej2 10
So Gp (z) can filter a real signal

Multiplies:
F and G each: (3 + 2) 400 kHz, H + x2 : (2 30 + 4) 20 kHz
Total: 13.2 400 kHz [Full-rate bandpass H(z) needs 273 400 kHz]

DSP and Digital Filters (2014-5272)

FM Radio: 14 11 / 12

Summary
14: FM Radio
Receiver
FM Radio Block
Diagram
Aliased ADC
Channel Selection
Channel Selection (1)
Channel Selection (2)
Channel Selection (3)
FM Demodulator
Differentiation Filter
Pilot tone extraction
Polyphase Pilot tone
Summary

Aliased ADC allows sampling below the Nyquist frequency


Only works because the wanted signal fits entirely within a
Nyquist band image
Polyphase filter can be combined with complex multiplications to
select the desired image
subsequent multiplication by j ln shifts by the desired multiple
of 41 sample rate
No actual multiplications required
FM demodulation uses a differentiation filter to calculate

d
dt

Pilot tone bandpass filter has narrow bandwidth so better done at a


low sample rate
double the frequency of a complex tone by squaring it
This example is taken from Harris: 13.

DSP and Digital Filters (2014-5272)

FM Radio: 14 12 / 12

15: Subband

Processing

Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
Polyphase QMF
QMF Options
Linear Phase QMF
IIR Allpass QMF
Tree-structured
filterbanks
Summary
Merry Xmas

DSP and Digital Filters (2014-5273)

15: Subband Processing

Subband Processing: 15 1 / 12

Subband processing
15: Subband
Processing
Subband

processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
Polyphase QMF
QMF Options
Linear Phase QMF
IIR Allpass QMF
Tree-structured
filterbanks
Summary
Merry Xmas

The Hm (z) are bandpass analysis filters and divide x[n] into
frequency bands
Subband processing often processes frequency bands independently
The Gm (z) are synthesis filters and together reconstruct the output
The Hm (z) outputs are bandlimited and so can be subsampled
without loss of information
P 1
Sample rate multiplied overall by
Pi
P 1
= 1 critically sampled : good for coding
P P1i
Pi > 1 oversampled : more flexible
Goals:
(a) good frequency selectivity in Hm (z)
(b) perfect reconstruction: y[n] = x[n d] if no processing
Benefits: Lower computation, faster convergence if adaptive

DSP and Digital Filters (2014-5273)

Subband Processing: 15 2 / 12

2-band Filterbank
15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
Polyphase QMF
QMF Options
Linear Phase QMF
IIR Allpass QMF

Tree-structured
filterbanks
Summary
Merry Xmas

Vm (z) = Hm (z)X(z)
PK1
j2k
1
1
K
K
z )=
Um (z) = K k=0 Vm (e

 1 o
n
 1
1
2
+ Vm z 2
2 Vm z

Wm (z) = Um (z 2 ) = 12 {Vm (z) + Vm (z)}


[K = 2]
= 21 {Hm (z)X(z) + Hm (z)X(z)}



 G0 (z)
Y (z) = W0 (z) W1 (z)
G1 (z)





H0 (z)
H1 (z)
G0 (z)
= 21 X(z) X(z)
H0 (z) H1 (z)
G1 (z)



 T (z)
[X(z)A(z) is aliased term]
= X(z) X(z)
A(z)

We want (a) T (z) = 12 {H0 (z)G0 (z) + H1 (z)G1 (z)} = z d


and (b) A(z) = 12 {H0 (z)G0 (z) + H1 (z)G1 (z)} = 0
DSP and Digital Filters (2014-5273)

Subband Processing: 15 3 / 12

Perfect Reconstruction
15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
Polyphase QMF
QMF Options
Linear Phase QMF
IIR Allpass QMF

Tree-structured
filterbanks
Summary
Merry Xmas

For perfect reconstruction without aliasing, we require





 d

H0 (z)
H1 (z)
G0 (z)
1
0
= z
2
H0 (z) H1 (z)
G1 (z)
Hence:

 
1 

d
G0 (z)
H0 (z)
H1 (z)
2z
=
G1 (z)
H0 (z) H1 (z)
0



d
H1 (z) H1 (z)
1
2z
= H0 (z)H1 (z)H
0 (z)H1 (z)
H0 (z) H0 (z)
0


H1 (z)
2z d
= H0 (z)H1 (z)H
0 (z)H1 (z)
H0 (z)
For all filters to be FIR, we need the denominator to be
H0 (z)H1 (z) H0 (z)H1 (z) = cz k , which implies






H1 (z)
H1 (z)
G0 (z)
d=k 2
= c
= 2c z kd
H0 (z)
G1 (z)
H0 (z)

DSP and Digital Filters (2014-5273)

Subband Processing: 15 4 / 12

Quadrature Mirror Filterbank (QMF)


15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
Polyphase QMF
QMF Options
Linear Phase QMF
IIR Allpass QMF

Tree-structured
filterbanks
Summary
Merry Xmas

QMF satisfies:
(a) H0 (z) is causal and real

j

(b) H1 (z) = H0 (z): i.e. H0 (e ) is reflected around =
(c) G0 (z) = 2H1 (z) = 2H0 (z)
(d) G1 (z) = 2H0 (z) = 2H1 (z)

QMF is alias-free:
A(z) = 12 {H0 (z)G0 (z) + H1 (z)G1 (z)}
=

1
2

{2H1 (z)H0 (z) 2H0 (z)H1 (z)} = 0

QMF Transfer Function:


T (z) = 12 {H0 (z)G0 (z) + H1 (z)G1 (z)}
= H02 (z) H12 (z) = H02 (z) H02 (z)

DSP and Digital Filters (2014-5273)

Subband Processing: 15 5 / 12

Polyphase QMF
15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
Polyphase QMF
QMF Options
Linear Phase QMF
IIR Allpass QMF

Tree-structured
filterbanks
Summary
Merry Xmas

Polyphase decomposition:
H0 (z) = P0 (z 2 ) + z 1 P1 (z 2 )
H1 (z) = H0 (z) = P0 (z 2 ) z 1 P1 (z 2 )
G0 (z) = 2H0 (z) = 2P0 (z 2 ) + 2z 1 P1 (z 2 )
G1 (z) = 2H0 (z) = 2P0 (z 2 ) + 2z 1 P1 (z 2 )

Transfer Function:
T (z) = H02 (z) H12 (z) = 4z 1 P0 (z 2 )P1 (z 2 )
T (z) = z d P0 (z) = a0 z k , P1 (z) = a1 z k+1d
H0 (z) has only two non-zero taps poor freq selectivity
Perfect reconstruction QMF filterbanks cannot have good freq selectivity
DSP and Digital Filters (2014-5273)

Subband Processing: 15 6 / 12

QMF Options
15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
Polyphase QMF
QMF Options
Linear Phase QMF
IIR Allpass QMF

Polyphase decomposition:

Tree-structured
filterbanks
Summary
Merry Xmas

A(z) = 0 no alias term


T (z) = H02 (z) H12 (z) = H02 (z) H02 (z) = 4z 1 P0 (z 2 )P1 (z 2 )
Options:
Perfect Reconstruction: T (z) = z d H0 (z) is a bad filter.
T (z) is Linear Phase FIR:
Tradeoff: T (ej ) 1 versus H0 (z) stopband attenuation

T (z) is Allpass IIR: H0 (z) can be Butterworth or Elliptic filter


Tradeoff: T (ej ) versus H0 (z) stopband attenuation

DSP and Digital Filters (2014-5273)

Subband Processing: 15 7 / 12

Linear Phase QMF


15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
Polyphase QMF
QMF Options
Linear Phase QMF
IIR Allpass QMF

Tree-structured
filterbanks
Summary
Merry Xmas

H0 (z) order M , linear phase H0 (ej ) = ej

M
2

T (z) 1


H0 (ej )

T (ej ) = H02 (ej ) H12 (ej ) = H02 (ej ) H02 (ej )






jM
j 2
j()M
j() 2
=e
H0 (e
)
0 (e ) e
H



M
jM
j 2
j() 2
=e
H0 (e ) (1) H0 (e
)
j
2

M even T (e

) = 0 / so choose M odd (1)M = +1

Select h0 [n] by numerical iteration to minimize





2
R
R
j
j 2


+ H0 (e ) d + (1 ) 0 T (e ) 1 d
2

balance between H0 (z) being lowpass and T (ej ) 1


Johnston filter
(M = 11):

h0[n]

M=11

0.04

H1

0.02

-20

0
-40
-60
0

DSP and Digital Filters (2014-5273)

H0

-0.02
1

-0.04
0

Subband Processing: 15 8 / 12

IIR Allpass QMF


15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
Polyphase QMF
QMF Options
Linear Phase QMF
IIR Allpass QMF

Tree-structured
filterbanks
Summary
Merry Xmas

|T (z)| = 1
Choose P0 (z) and P1 (z) to be allpass
IIR filters:

H0,1 (z) = 12 P0 (z 2 ) z 1 P1 (z 2 ) ,
G0,1 (z) = 2H0,1 (z)
A(z) = 0 No aliasing
T (z) = H02 H12 = . . . = z 1 P0 (z 2 )P1 (z 2 ) is an allpass filter.

H0 (z) and H1 (z) are power complementary :






H0 (ej ) 2 + H1 (ej ) 2 = H0 (ej )H0 (ej ) + H1 (ej )H1 (ej )




1
1
j 2
j 2
= . . . = P0 (e ) + P1 (e ) = 1
2

H0 (z) can be made a Butterworth or Elliptic filter with MH = 4MP + 1:


0

-2

-4
-6

M P=1

-8
0

P0(z2)

-20

z-1P1(z2)

-40

M H=5

H0

15

H1
H0(z)

10
5

-60
0

T(z)
1

(rad/s)

Phase cancellation: z 1 P1 = P0 + ; Ripples in H0 and H1 cancel.


DSP and Digital Filters (2014-5273)

Subband Processing: 15 9 / 12

Tree-structured filterbanks
A half-band filterbank divides the full band into two equal halves.

1
X=Y

0.5

You can repeat the process on either or both of the signals u1 [p]
and v1 [p].

0
0

Dividing the lower band in half repeatedly results in an octave band


filterbank. Each subband occupies one octave (= a factor of 2 in
frequency).
The properties perfect reconstruction and allpass are preserved
by the iteration.

U1

0.5
0
0

V1

1
0.5

U2

0
0

V2

V1

1
0.5
0
0

DSP and Digital Filters (2014-5273)

U3

V3

V2

V1

Subband Processing: 15 10 / 12

Summary
15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
Polyphase QMF
QMF Options
Linear Phase QMF
IIR Allpass QMF
Tree-structured
filterbanks
Summary
Merry Xmas

Half-band filterbank:
Reconstructed output is T (z)X(z) + A(z)X(z)
Unwanted alias term is A(z)X(z)
Perfect reconstruction: imposes strong constraints on analysis
filters Hi (z) and synthesis filters Gi (z).
Quadrature Mirror Filterbank (QMF) adds an additional symmetry
constraint H1 (z) = H0 (z).
Perfect reconstruction now impossible except for trivial case.
Neat polyphase implementation with A(z) = 0
Johnston filters: Linear phase with T (z) 1
Allpass filters: Elliptic or Butterworth with |T (z)| = 1
Can iterate to form a tree structure with equal or unequal
bandwidths.
See Mitra chapter 14 (which also includes some perfect reconstruction
designs).

DSP and Digital Filters (2014-5273)

Subband Processing: 15 11 / 12

Merry Xmas

DSP and Digital Filters (2014-5273)

Subband Processing: 15 12 / 12

F ORMULA S HEET AVAILABLE IN E XAM


The following formulae will be available in the exam:

Notation
All signals and filter coefficients are real-valued unless explicitly noted otherwise.
Unless otherwise specified, upper and lower case letters are used for sequences and their z-transforms
respectively. The signal at a block diagram node V is v[n] and its z-transform is V (z).
x[n] = [a, b, c, d, e, f ] means that x[0] = a, . . . x[5] = f and that x[n] = 0 outside this range.
(z), (z), z , |z| and z denote respectively the real part, imaginary part, complex conjugate,
magnitude and argument of a complex number z.

Abbreviations
BIBO
CTFT
DCT
DFT
DTFT
LTI
MDCT
SNR

Bounded Input, Bounded Output


Continuous-Time Fourier Transform
Discrete Cosine Transform
Discrete Fourier Transform
Discrete-Time Fourier Transform
Linear Time-Invariant
Modified Discrete Cosine Transform
Signal-to-Noise Ratio

Standard Sequences
[n] = 1 for n = 0 and 0 otherwise.
condition [n] = 1 whenever "condition" is true and 0 otherwise.
u[n] = 1 for n 0 and 0 otherwise.

Geometric Progression
rn=0 n zn =

1 r+1 zr1
1z1

or, more generally, rn=q n zn =

Digital Signal Processing and Digital Filters

q zq r+1 zr1
1z1

c
Imperial
College London

1/3

Forward and Inverse Transforms


n
X(z) =
x[n]z

z:

x[n] =

jt dt

CTFT:

X( j ) =

DTFT:

jn
X(e j ) =
x[n]e

DFT:

x[n]e j2 N
X[k] = N1
0

DCT:

2(2n+1)k
X[k] = N1
n=0 x[n] cos
4N

x(t)e

x(t) =

1
2

x[n] =

1
2

kn

2(2n+1+N)(2k+1)
X[k] = 2N1
n=0 x[n] cos
8N

MDCT:

y[n] =

X(z)zn1 dz

X( j )e

X(e

1
N

jt d

j )e jn d
kn

0N1 X[k]e j2 N

N1
+ N2 n=1
X[k] cos 2(2n+1)k
4N

X[0]
N

X[k] cos
N1
0

1
N

x[n] =
x[n] =

1
2 j

2(2n+1+N)(2k+1)
8N

Convolution
v[n] = x[n] y[n] ,
r= x[r]y[n r]

DTFT:

v[n] = x[n]y[n]


V e j =

1
2 X

v[n] = x[n] ~N y[n] , N1


r=0 x[r]y[(n r)

DFT:

v[n] = x[n]y[n]




V e j = X e j Y e j



e j ~Y e j =

1
2



e j Y e j( ) d

mod N ]

V [k] = N1 X[k] ~N Y [k] ,

V [k] = X[k]Y [k]


1
N

N1
X[r]Y [(k r)
r=0

mod N ]

Group Delay
The group delay of a filter, H(z), is H (e j ) = dH(e
d

j )

z dH(z)
H(z) dz

F ( ) denotes the DTFT.

z=e j

F (nh[n])
F (h[n])

where

Order Estimation for FIR Filters


Three increasingly sophisticated formulae for estimating the minimum order of an FIR filter with unity
gain passbands:
1. M

a
3.5

2. M

a8
2.2

3. M

a1.220 log10 b
4.6

where a =stop band attenuation in dB, b = peak-to-peak passband ripple in dB and = width of
smallest transition band in normalized rad/s.

Digital Signal Processing and Digital Filters

c
Imperial
College London

2/3

z-plane Transformations
A lowpass filter, H(z), with cutoff frequency 0 may be transformed into the filter H(z) as follows:
Target H(z)

Substitute
z1

Lowpass
< 1

Bandstop
1 2

z1
1 z1

z +
z1 = 1+
z1

Highpass
> 1
Bandpass

1 < < 2

Parameters

z1

(1)2 z1 +(+1)z2
(+1)2
z1 +(1)z2

(1)2 z1 +(+1)z2
(+1)2 z1 +(1)z2

z1 =

Digital Signal Processing and Digital Filters



+
cos 2 2 1

,

cos 2 2 1


+
cos 2 2 1
,


cos 2 2 1

c
Imperial
College London




sin 0 2 1


+
sin 0 2 1


+
cos 0 2 1



cos 0 2 1

= cot

2 1
2

tan

0
2

= tan

2 1
2

tan

0
2

3/3

Potrebbero piacerti anche