Vous êtes sur la page 1sur 221

DSP & Digital Filters

Mike Brookes

DSP and Digital Filters (2015-7034) 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
1: Introduction
Inverse z-Transform
MATLAB routines
Summary

DSP and Digital Filters (2015-7034) Introduction: 1 2 / 16


Organization

1: Introduction
Organization
18 lectures: feel free to ask questions
Signals
Processing Textbooks:
Syllabus
Sequences
(a) Mitra Digital Signal Processing ISBN:0071289461 41 covers
Time Scaling most of the course except for some of the multirate stuff
z-Transform
Region of (b) Harris Multirate Signal Processing ISBN:0137009054 49
Convergence
z-Transform examples covers multirate material in more detail but less rigour than
Rational z-Transforms
Rational example
Mitra
Inverse z-Transform
MATLAB routines Lecture slides available via Blackboard or on my website:
Summary
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 (2015-7034) Introduction: 1 3 / 16


Signals

1: Introduction
Organization
A signal is a numerical quantity that is a function of one or more
Signals independent variables such as time or position.
Processing
Syllabus
Sequences
Real-world signals are analog and vary continuously and take
Time Scaling continuous values.
z-Transform
Region of
Convergence Digital signals are sampled at discrete times and are quantized to a
z-Transform examples
Rational z-Transforms
finite number of discrete values
Rational example
Inverse z-Transform We will mostly consider one-dimensionsal real-valued signals with
MATLAB routines
Summary
regular sample instants; except in a few places, we will ignore the
quantization.
Extension to multiple dimensions and complex-valued signals
is straighforward in many cases.
Examples:

DSP and Digital Filters (2015-7034) Introduction: 1 4 / 16


Processing

1: Introduction
Organization
 Aims to improve a signal in some way or extract some information
Signals from it
Processing
Syllabus  Examples:
Sequences
Time Scaling
z-Transform Modulation/demodulation
Region of
Convergence Coding and decoding
z-Transform examples
Rational z-Transforms Interference rejection and noise suppression
Rational example
Inverse z-Transform Signal detection, feature extraction
MATLAB routines
Summary
 We are concerned with linear, time-invariant processing

DSP and Digital Filters (2015-7034) Introduction: 1 5 / 16


Syllabus

1: Introduction
Organization
Main topics:
Signals
Processing
Syllabus  Introduction/Revision
Sequences
Time Scaling  Transforms
z-Transform
Region of
Convergence
 Discrete Time Systems
z-Transform examples
Rational z-Transforms
 Filter Design
Rational example
Inverse z-Transform
MATLAB routines
FIR Filter Design
Summary
IIR Filter Design

 Multirate systems

Multirate Fundamentals
Multirate Filters
Subband processing

DSP and Digital Filters (2015-7034) Introduction: 1 6 / 16


Sequences

1: Introduction
Organization
We denote the nth sample of a signal as x[n] where < n < + and
Signals the entire sequence as {x[n]} although we will often omit the braces.
Processing
Syllabus
Sequences Special sequences: (
Time Scaling
1 n0
z-Transform
Region of
Unit step: u[n] =
Convergence 0 otherwise
z-Transform examples
(
Rational z-Transforms 1 n=0
Rational example Unit impulse: [n] =
Inverse z-Transform 0 otherwise
MATLAB routines (
Summary 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 |x[n]| < (e.g. x[n] = n1 u[n 1])

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

DSP and Digital Filters (2015-7034) Introduction: 1 7 / 16


Time Scaling

n 1
1: Introduction
Organization
For sampled signals, the nth sample is at time t = nT = fs where fs = T
Signals
Processing
is the sample frequency.
Syllabus
Sequences Often easiest to scale time so that fs = 1 Hz. E.g. to design a 1 kHz
Time Scaling
low-pass filter for fs = 44.1 kHz we can design a 0.0227 Hz filter for
z-Transform
Region of
Convergence
fs = 1 Hz.
z-Transform examples
Rational z-Transforms To scale back to real-world values: Every quantity of dimension (Time)n is
Rational example
Inverse z-Transform
multiplied by T n (or equivalently by fsn ). Thus all times are multiplied by
MATLAB routines T and all frequencies and angular frequencies by T 1 .
Summary

We use for real angular frequencies and for normalized angular


frequency. The units of are radians per sample.
Power is measured in units of energy per sample: to convert back to
energy per second you must multiply by T 1 = fs .

Warning: Several MATLAB routines scale time so that fs = 2 Hz. Weird,


non-standard and irritating.

DSP and Digital Filters (2015-7034) Introduction: 1 8 / 16


z-Transform

1: Introduction
Organization
The z-transform converts a sequence, {x[n]}, into a function, X(z), of an
Signals arbitrary complex-valued variable z.
Processing
Syllabus
Sequences
Why do it?
Time Scaling
z-Transform Complex functions are easier to manipulate than sequences
Region of
Convergence
z-Transform examples Useful operations on sequences correspond to simple operations on
Rational z-Transforms
Rational example
the z-transform:
Inverse z-Transform
MATLAB routines addition, multiplication, scalar multiplication, time-shift,
Summary
convolution
Definition: X(z) = + n
P
n= x[n]z

DSP and Digital Filters (2015-7034) Introduction: 1 9 / 16


Region of Convergence

1: Introduction
Organization
The set of z for which X(z) converges is its Region of Convergence (ROC).
Signals
Processing Complex analysis : the ROC of a power series (if it exists at all) is always
Syllabus
Sequences
an annular region of the form 0 Rmin < |z| < Rmax .
Time Scaling
z-Transform X(z) will always converge absolutely inside the ROC and may converge on
Region of
Convergence some, all, or none of the boundary.
P+
z-Transform examples
Rational z-Transforms
converge absolutely n= |x[n]z n | <
Rational example
Inverse z-Transform finite length Rmin = 0, Rmax =
MATLAB routines
Summary
ROC may included either, both or none of 0 and
absolutely summable X(z) converges for |z| = 1.
right-sided & |x[n]| < A B n Rmax =
+ causal X() converges
left-sided & |x[n]| < A B n Rmin = 0
+ anticausal X(0) converges

DSP and Digital Filters (2015-7034) Introduction: 1 10 / 16


[Convergence Properties]

Null Region of Convergence:


It is possible to define a sequence, x[n], whose z-transform
P n never converges (i.e. theROC is null). An
example is x[n] 1. The z-transfom is X(z) = z and it is clear that this fails to converge for
any real value of z.
Convergence for x[n] causal:
n
P
If x[n] is causal with |x[n]| < A B for some A and B, then |X(z)| =
n=0 x[n]z
n
P n n = A
P
n and so, for |z| = R B, |X(z)| < .
n=0 x[n]z n=0 AB R 1BR1

Convergence for x[n] right-sided:


If x[n] is right-sided with |x[n]| < A B n for some A and B and x[n] = 0 for n < N , then
y[n] = x[n N ] is causal with |y[n]| < A B n+N = AB N B n . Hence, from the previous result, we
known that Y (z) converges for |z| B. The z-transform, X(z), is given by X(z) = z N Y (z) so X(z)
will converge for any B |z| < since z N < for |z| in this range.

DSP and Digital Filters (2015-7034) Introduction: 1 note 1 of slide 10


z-Transform examples

The sample at n = 0 is indicated by an open circle.


1
u[n] 1z 1 1 < |z|

x[n] 2z 2 + 2 + z 1 0 < |z| <


2
3 1

x[n 3] z 2z + 2 + z 0 < |z|
1
n u[n]=0.8 1z 1 < |z|
1
n u[n 1] 1z 1 0 |z| <
z 1
nu[n] 12z 1 +z 2 1 < |z|
z 1 sin()
sin(n)u[n]=0.5 12z 1 cos()+z 2 1 < |z|
1z 1 cos()
cos(n)u[n]=0.5 12z 1 cos()+z 2 1 < |z|

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

DSP and Digital Filters (2015-7034) Introduction: 1 11 / 16


Rational z-Transforms

1: Introduction
Organization
Most z-transforms that we will meet are rational polynomials with real
Signals coefficients, usually one polynomial in z 1 divided by another.
Processing
QM QM
Syllabus (
m=1 1zm z
1
) (zzm )
Sequences G(z) = g QK = gz KM Qm=1
K
k=1 (1pk z
1 )
Time Scaling k1 (zpk )
z-Transform
Region of Completely defined by the poles, zeros and gain.
Convergence
z-Transform examples
Rational The absolute values of the poles define the ROCs:
z-Transforms
R + 1 different ROCs
Rational example
Inverse z-Transform where R is the number of distinct pole magnitudes.
MATLAB routines
Summary

Note: There are K M zeros or M K poles at z = 0 (easy to overlook)

DSP and Digital Filters (2015-7034) Introduction: 1 12 / 16


Rational example

1: Introduction 82z 1
Organization G(z) = 44z 1 3z 2
Signals
Processing 2z(z0.25))
Syllabus Poles/Zeros: G(z) = (z+0.5)(z1.5)
Sequences
Time Scaling
Poles at z = {0.5, +1.5)},
z-Transform
Region of
Zeros at z = {0, +0.25}
Convergence
z-Transform examples
Rational z-Transforms
0.75 1.25
Rational example Partial Fractions: G(z) = 1+0.5z 1 + 11.5z 1
Inverse z-Transform
MATLAB routines
0.75 1.25
Summary ROC ROC 1+0.5z 1 11.5z 1 G(z)

a 0 |z| < 0.5


b 0.5 < |z| < 1.5

c 1.5 < |z|

DSP and Digital Filters (2015-7034) Introduction: 1 13 / 16


Inverse z-Transform

1
1: Introduction
G(z)z n1 dz where the integral is anti-clockwise around a
H
Organization
g[n] = 2j
Signals
Processing
circle within the ROC, z = Rej .
Syllabus
Sequences Proof: H P
Time Scaling 1 n1 1 n1
H m

z-Transform 2j G(z)z dz= 2j m= g[m]z z dz
Region of
(i) P 1
H nm1
Convergence
z-Transform examples
= m= g[m] 2j z dz
Rational z-Transforms (ii) P
Rational example = m= g[m][n m]= g[n]
Inverse
z-Transform
(i) depends on the circle with radius R lying within the ROC
MATLAB routines
Summary
1
H k1
(ii) Cauchys theorem: 2j z dz = [k] for z = Rej anti-clockwise.
dz j 1
H k1 1
R 2 k1 j(k1)
d = jRe 2j z dz = 2j =0 R e jRej d
Rk 2 jk
R
= 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 (2015-7034) Introduction: 1 14 / 16


MATLAB routines

1: Introduction
b(z 1)
Organization tf2zp,zp2tf a(z 1 ) {zm , pk , g}
Signals
b(z 1) P rk
Processing
Syllabus
residuez a(z )1 k 1pk z 1
Sequences b(z 1) Q b0,l +b1,l z1 +b2,l z2
Time Scaling tf2sos,sos2tf a(z 1 ) l 1+a1,l z 1 +a2,l z 2
z-Transform Q b0,l +b1,l z1 +b2,l z2
Region of
Convergence
zp2sos,sos2zp {zm , pk , g} l 1+a1,l z1 +a2,l z2
(
z-Transform examples
Rational z-Transforms
x = Ax + Bu
Rational example
zp2ss,ss2zp {zm , pk , g}
Inverse z-Transform
y = Cx + Du
MATLAB routines
(
Summary b(z 1) x = Ax + Bu
tf2ss,ss2tf a(z 1 )
y = Cx + Du

DSP and Digital Filters (2015-7034) Introduction: 1 15 / 16


Summary

1: Introduction
Organization
Time scaling: assume fs = 1 Hz so <
Signals
z-transform: X(z) = + n
P
Processing n= x[n]
Syllabus
Sequences ROC: 0 Rmin < |z| < Rmax
Time Scaling
z-Transform Causal: ROC
Region of
Convergence Absolutely summable: |z| = 1 ROC
z-Transform examples
1
Inverse z-transform: g[n] = 2j G(z)z n1 dz
H
Rational z-Transforms
Rational example
Inverse z-Transform Not unique unless ROC is specified
MATLAB routines
Summary Use partial fractions and/or a table

For further details see Mitra:1 & 6.

DSP and Digital Filters (2015-7034) 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 2: Three Different Fourier Transforms
Summary
MATLAB routines

DSP and Digital Filters (2015-7036) Fourier Transforms: 2 1 / 13


Fourier Transforms

2: Three Different
Fourier Transforms
Three different Fourier Transforms:
Fourier Transforms
Convergence of
DTFT
Continuous-Time Fourier Transform (CTFT): x(t) X(j)
DTFT Properties Discrete-Time Fourier Transform (DTFT): x[n] X(ej )
DFT Properties
Symmetries
Discrete Fourier Transform (DFT): x[n] X[k]
Parsevals Theorem
Convolution Forward Transform Inverse Transform
Sampling Process R R
1
Zero-Padding CTFT X(j) = x(t)ejt dt x(t) = 2 X(j)ejt d
Phase Unwrapping R
j 1
x[n] = 2 X(ej )ejn d
P
Summary DTFT X(e ) = x[n]ejn
MATLAB routines PN 1 PN 1
kn 1 kn
DFT X[k] = 0 x[n]ej2 N x[n] = N 0 X[k]ej2 N
We use for real and = T for normalized angular frequency.
Nyquist frequency is at Nyq = 2 f2s = T and Nyq = .
For power signals (energy time interval), CTFT & DTFT are
unbounded.
Fix this by normalizing:
1
RA
X(j) = limA 2A A x(t)ejt dt
j 1
PA
X(e ) = limA 2A A x[n]ejn

DSP and Digital Filters (2015-7036) Fourier Transforms: 2 2 / 13


Convergence of DTFT

2: Three Different j
P
Fourier Transforms DTFT: X(e ) = x[n]ejn does not converge for all x[n].
Fourier Transforms j
PK
Convergence of Consider the finite sum: XK (e ) = K x[n]ejn
DTFT
DTFT Properties
DFT Properties
Strong Convergence:
j
Symmetries x[n] absolutely summable X(e ) converges uniformly
Parsevals Theorem

Convolution
P
|x[n]| < sup
X(ej ) XK (ej ) 0
K
Sampling Process
Zero-Padding
Phase Unwrapping Weaker convergence:
Summary x[n] finite energy X(ej ) converges in mean square
MATLAB routines
j 2
P 2 1
R j

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

K
sin 0.5n
Example: x[n] = n
1 K=5 1 K=20 1 K=50
0.8 0.8 0.8
0.6 0.6 0.6
j

j
K

K
0.4 0.4 0.4
0.2 0.2 0.2
0 0 0
-0.2 -0.2 -0.2
0 0.1 0.2 0.3 0.4 0.5 0 0.1 0.2 0.3 0.4 0.5 0 0.1 0.2 0.3 0.4 0.5
/2 (rad/sample) /2 (rad/sample) /2 (rad/sample)

Gibbs phenomenon:
Converges at each as K but peak error does not get smaller.
DSP and Digital Filters (2015-7036) Fourier Transforms: 2 3 / 13
[DTFT Convergence Proofs]

(1) Strong Convergence: [these proofs are not examinable]


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

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

sup |n|>K x[n]e
=
|n|>K |x[n]| <

(2) Weak Convergence:


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

= |n|>K x[n]ejn = [K] [n]ejn = Y [K] (ej )


P P
y
[K] 2
From Parsevals theorem, y [n] = 1 Y [K] (ej ) 2 d
P R
2
X(ej ) XK (ej ) 2 d
1
R
= 2
j ) X (ej ) 2 d =
P [K] 2 P
1
[n] = |n|>N |x[n]|2 <
R
Hence for K N , 2 X(e K y

DSP and Digital Filters (2015-7036) Fourier Transforms: 2 note 1 of slide 3


DTFT Properties

2: Three Different j
P
Fourier Transforms DTFT: X(e ) = x[n]ejn
Fourier Transforms
Convergence of DTFT is periodic in : X(ej(+2m ) = X(ej ) for integer m.
DTFT
DTFT Properties z-Transform evaluated at the point ej :
DTFT is the P
DFT Properties
Symmetries X(z) = x[n]z n
Parsevals Theorem
Convolution
DTFT converges iff the ROC includes |z| = 1.
Sampling Process
Zero-Padding DTFT is the same as the CTFT of a signal comprising impulses at
Phase Unwrapping
Summary P (Dirac functions) of P
the sample times appropriate heights:
MATLAB routines x (t) = x[n](t nT )= x(t) (t nT )
Equivalent to multiplying a continuous x(t) by an impulse train.
j
P
Proof: X(e ) = x[n]ejn
j Tt
P R
n= x[n] (t nT )e dt
(i) R P t
= n= x[n](t nT )ej T dt
(ii) R
= x (t)ejt dt
(i) OK if
P
|x[n]| < . (ii) use = T .

DSP and Digital Filters (2015-7036) Fourier Transforms: 2 4 / 13


DFT Properties

2: Three Different PN 1 kn
Fourier Transforms DFT: X[k] = 0 x[n]ej2 N
Fourier Transforms
j
Convergence of
P
DTFT DTFT: X(e ) = x[n]ejn
DTFT Properties
DFT Properties
Symmetries Case 1: x[n] = 0 for n
/ [0, N 1]
Parsevals Theorem
2
Convolution
Sampling Process
DFT is the same as DTFT at k = N k.
Zero-Padding
Phase Unwrapping The {k } are uniformly spaced from = 0 to = 2 NN1 .
Summary
MATLAB routines
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 )

where XK (ej ) = K
P
K x[n]e
jn

DSP and Digital Filters (2015-7036) Fourier Transforms: 2 5 / 13


Symmetries

2: Three Different
Fourier Transforms If x[n] has a special property then X(ej )and X[k] will have corresponding
Fourier Transforms
Convergence of
properties as shown in the table (and vice versa):
DTFT
DTFT Properties
DFT Properties
Symmetries
One domain Other domain
Parsevals Theorem
Convolution
Discrete Periodic
Sampling Process Symmetric Symmetric
Zero-Padding
Phase Unwrapping Antisymmetric Antisymmetric
Summary
MATLAB routines
Real Conjugate Symmetric
Imaginary Conjugate Antisymmetric
Real + Symmetric Real + Symmetric
Real + Antisymmetric Imaginary + Antisymmetric

Symmetric: x[n] = x[n]


X(ej ) = X(ej )
X[k] = X[(k)mod N
] = X[N k] for k > 0
Conjugate Symmetric: x[n] = x [n]
Conjugate Antisymmetric: x[n] = x [n]
DSP and Digital Filters (2015-7036) Fourier Transforms: 2 6 / 13
Parsevals Theorem

2: Three Different
Fourier Transforms
Fourier transforms preserve energy
Fourier Transforms
2
|x(t)| dt = 2 |X(j)|2 d
1
R R
Convergence of
DTFT
CTFT
j 2
DTFT Properties
P 2 1
R
DFT Properties
DTFT |x[n]| = 2 X(e ) d

Symmetries PN 1 2 1
PN 1 2
Parsevals DFT 0 |x[n]| = N 0 |X[k]|
Theorem
Convolution
Sampling Process
More generally, they actually preserve complex inner products:
Zero-Padding
Phase Unwrapping PN 1 PN 1
1
Summary 0 x[n]y [n] =

N 0 X[k]Y [k]
MATLAB routines

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 (2015-7036) Fourier Transforms: 2 7 / 13


Convolution

2: Three Different
Fourier Transforms
DTFT: Convolution Product
P
Fourier Transforms
Convergence of
x[n] = g[n] h[n]= k= g[k]h[n k]
DTFT X(ej ) = G(ej )H(ej )
DTFT Properties
DFT Properties
Symmetries DFT: Circular convolutionPProduct
Parsevals Theorem
Convolution
x[n] = g[n] N h[n]= N 1
k=0 g[k]h[(n k)modN ]
Sampling Process X[k] = G[k]H[k]
Zero-Padding
Phase Unwrapping
Summary
DTFT: Product Circular Convolution 2
MATLAB routines y[n] = g[n]h[n] R
1 1
Y (e ) = 2 G(e ) H(e ) = 2 G(ej )H(ej() )d
j j j

DFT: Product Circular Convolution N


y[n] = g[n]h[n]
X[k] = N1 G[k] N H[k]

g[n] : h[n] : g[n] h[n] : g[n] 3 h[n]

DSP and Digital Filters (2015-7036) Fourier Transforms: 2 8 / 13


Sampling Process

Time Time Frequency


CTFT
Analog

Low Pass CTFT


*
Filter
DTFT
Sample

DTFT
Window

DFT
DFT

DSP and Digital Filters (2015-7036) Fourier Transforms: 2 9 / 13


Zero-Padding

2: Three Different
Fourier Transforms
Zero padding means added extra zeros onto the end of x[n] before
Fourier Transforms
Convergence of
performing the DFT.
DTFT
DTFT Properties
DFT Properties Time x[n] Frequency |X[k]|
Symmetries
Parsevals Theorem
Convolution Windowed
Sampling Process
Zero-Padding Signal
Phase Unwrapping
Summary
MATLAB routines
With zero-
padding

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 (2015-7036) Fourier Transforms: 2 10 / 13


Phase Unwrapping

2: Three Different
Fourier Transforms
Phase of a DTFT is only defined to within an integer multiple of 2.
Fourier Transforms
Convergence of
DTFT
DTFT Properties 6
DFT Properties
4
Symmetries
Parsevals Theorem 2
Convolution
Sampling Process 0
-2 0 2
Zero-Padding (rad/sample)
Phase Unwrapping
Summary x[n] |X[k]|
MATLAB routines

0
2

0 -20
-2
-40
-2 0 2 -2 0 2
(rad/sample) (rad/sample)

X[k] 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 (2015-7036) Fourier Transforms: 2 11 / 13


Summary

2: Three Different
Fourier Transforms
 Three types: CTFT, DTFT, DFT
Fourier Transforms
Convergence of
DTFT DTFT = CTFT of continuous signal impulse train
DTFT Properties
DFT Properties
DFT = DTFT of periodic or finite support signal
Symmetries
Parsevals Theorem DFT is a scaled unitary transform
Convolution
Sampling Process
Zero-Padding  DTFT: Convolution Product; Product Circular Convolution
Phase Unwrapping
Summary  DFT: Product Circular Convolution
MATLAB routines
 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 (2015-7036) Fourier Transforms: 2 12 / 13


MATLAB routines

2: Three Different
Fourier Transforms fft, ifft DFT with optional zero-padding
Fourier Transforms
Convergence of
fftshift swap the two halves of a vector
DTFT
DTFT Properties
conv convolution or polynomial multiplication (not
DFT Properties circular)
Symmetries
Parsevals Theorem x[n]y[n] real(ifft(fft(x).*fft(y)))
Convolution
Sampling Process
unwrap remove 2 jumps from phase spectrum
Zero-Padding
Phase Unwrapping
Summary
MATLAB routines

DSP and Digital Filters (2015-7036) 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)
MDCT Basis
Elements
Summary
MATLAB routines

DSP and Digital Filters (2015-7058) Transforms: 3 1 / 15


DFT Problems

3: Discrete Cosine
Transform For processing 1-D or 2-D signals (especially coding), a common method is
DFT Problems
to divide the signal into frames and then apply an invertible transform to
DCT
DCT of sine wave each frame that compresses the information into few coefficients.
DCT/DFT
Equivalence
DCT Properties The DFT has some problems when used for this purpose:
IDCT
N
Energy Conservation N real x[n] N complex X[k] : 2 real, 2 1 conjugate pairs
Energy Compaction
Frame-based coding
Lapped Transform
MDCT (Modified
DCT)
MDCT Basis
Elements
Summary
MATLAB routines 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 (2015-7058) Transforms: 3 2 / 15


DCT

3: Discrete Cosine
Transform To form the Discrete Cosine Transform (DCT), replicate x[0 : N 1] but in
DFT Problems
DCT
reverse order and insert a zero between each pair of samples:
DCT of sine wave y[r]
DCT/DFT
Equivalence
DCT Properties
IDCT

Energy Conservation
Energy Compaction
0 12 23
Frame-based coding
Lapped Transform Take the DFT of length 4N real, symmetric, odd-sample-only sequence.
MDCT (Modified
DCT) Result is real, symmetric and anti-periodic: only need first N values
MDCT Basis
Elements Y[k]
Summary
MATLAB routines
12
0 23

PN 1
Forward DCT: XC [k] = n=0 x[n] cos 2(2n+1)k
4N for k = 0 : N 1
PN 1
Compare DFT: XF [k] = n=0 x[n] exp j2(4n+0)k
4N

DSP and Digital Filters (2015-7058) Transforms: 3 3 / 15


DCT of sine wave

3: Discrete Cosine PN 1
Transform DCT: XC [k] = n=0 x[n] cos 2(2n+1)k
4N
DFT Problems
DCT m m
DCT of sine wave
f= N f 6= N
DCT/DFT
Equivalence
DCT Properties
IDCT x[n] N=20 N=20
Energy Conservation f=0.10 f=0.08

Energy Compaction
Frame-based coding
Lapped Transform
MDCT (Modified
DCT) |XF [k]|
MDCT Basis
Elements
Summary
MATLAB routines

|XC [k]|

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


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

DSP and Digital Filters (2015-7058) Transforms: 3 4 / 15


DCT/DFT Equivalence

3: Discrete Cosine y[r]


Transform PN 1
DFT Problems XC [k] = n=0 x[n] cos 2(2n+1)k
4N
DCT
0 12 23
DCT of sine wave

DCT/DFT
Equivalence 0 
r even
Define y[r] = x r1

DCT Properties
IDCT 2 r odd, 1 r 2N 1
4N 1r
 
Energy Conservation
Energy Compaction
x 2 r odd, 2N + 1 r 4N 1
Frame-based coding
YF [k] = 4N
P 1 kr b j 2b
Lapped Transform
r=0 y[r]W 4N where W a = e a
MDCT (Modified
DCT) (i) P2N 1 (2n+1)k
MDCT Basis = n=0 y[2n + 1]W4N
Elements
Summary (ii) PN 1 (2n+1)k
MATLAB routines = n=0 y[2n + 1]W4N
PN 1 (4N 2m1)k
+ m=0 y[4N 2m 1]W4N
(iii) PN 1 (2n+1)k PN 1 (2m+1)k
= n=0 x[n]W 4N + m=0 x[m]W 4N
PN 1
= 2 n=0 x[n] cos 2(2n+1)k 4N = 2XC [k]
(i) odd r only: r = 2n + 1, (ii) reverse order for n N : m = 2N 1 n
4N k
4N k
(iii) substitute y definition & W4N = ej2 4N 1

DSP and Digital Filters (2015-7058) Transforms: 3 5 / 15


DCT Properties

3: Discrete Cosine PN 1
Transform Definition: X[k] = n=0 x[n] cos 2(2n+1)k
4N
DFT Problems
DCT Linear: x[n] + y[n] X[k] + Y [k]
DCT of sine wave
DCT/DFT
DFT ConvolutionMultiplication property does not hold /
Equivalence
DCT Properties
Symmetric: X[k] = X[k] since cos k = cos +k
IDCT Anti-periodic: X[k + 2N ] = X[k] because:
Energy Conservation
Energy Compaction
cos ( + ) = cos
Frame-based coding 2(2n + 1)(k + 2N ) = 2(2n + 1)k + 8N n + 4N
Lapped Transform
MDCT (Modified X[N ] = 0 since X[N ] = X[N ] = X[N + 2N ]
DCT)
MDCT Basis Periodic: X[k + 4N ] = X[k + 2N ] = X[k]
Elements
Summary
DCT basis functions:
MATLAB routines

3:
0:

1: 4:

2: 5:

DSP and Digital Filters (2015-7058) Transforms: 3 6 / 15


IDCT

3: Discrete Cosine 1
P4N 1 rk 1
P4N 1 rk
Transform y[r] = 4N k=0 Y [k]W4N = 2N k=0 X[k]W4N
DFT Problems
1
P4N 1 (2n+1)k
DCT x[n] = y[2n + 1] = 2N k=0 X[k]W4N [Y [k] = 2X[k]]
DCT of sine wave
DCT/DFT Y[k]
Equivalence (i)1
P2N 1 (2n+1)k
DCT Properties = 2N k=0 X[k]W 4N 0
12
23
IDCT 1
P 2N 1 (2n+1)(l+2N )
Energy Conservation 2N l=0 X[l]W 4N
Energy Compaction
Frame-based coding (ii) 1 P2N 1 (2n+1)k 2b
Lapped Transform = N k=0 X[k]W4N Wab = ej a
MDCT (Modified
DCT) (iii) 1 1
PN 1 (2n+1)k (2n+1)N
MDCT Basis = N X[0] + N k=1 X[k]W4N + N1 X[N ]W4N
Elements PN 1 (2n+1)(2N r)
1
Summary + N r=1 X[2N r]W4N
MATLAB routines
(iv) 1 1
PN 1 (2n+1)k
= N X[0] + N k=1 X[k]W4N
1
PN 1 (2n+1)r+2N
+ N r=1 X[r]W4N
P 1 2(2n+1)k
x[n] = N1 X[0] + N2 N k=1 X[k] cos 4N = Inverse DCT
(i) k = l + 2N for k 2N and X[k + 2N ] = X[k]
(2n+1)(l+2N ) (2n+1)l 1 j2 (n+ 12 )
(ii) 4N = 4N + n + 2 and e = 1
(iii) k = 2N r for k > N (iv) X[N ] = 0 and X[2N r] = X[r]

DSP and Digital Filters (2015-7058) Transforms: 3 7 / 15


Energy Conservation

3: Discrete Cosine PN 1 2(2n+1)k


Transform DCT: X[k] = n=0 x[n] cos
DFT Problems
1 2
PN 14N 2(2n+1)k
DCT IDCT: x[n] = N X[0] + N k=1 X[k] cos 4N
DCT of sine wave
DCT/DFT Y[k]
Equivalence y[r]

DCT Properties rep DFT 12 2


IDCT 0 23
Energy
Conservation 0 12 23

Energy Compaction
Frame-based coding
PN 1 2
Lapped Transform
Energy: E = n=0 |x[n]| : E 2E 8N E 0.5N E
MDCT (Modified
|X|2 [0] + N2 n=1
PN 1
DCT)
MDCT Basis
E= 1
N |X|2 [n]
Elements
Summary
MATLAB routines Orthogonal DCT (preserves
q energy) q
Define: c[0] = N1 , c[k 6= 0] = N2
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 (2015-7058) Transforms: 3 8 / 15


Energy Compaction

3: Discrete Cosine
Transform If consecutive x[n] are positively correlated, DCT concentrates energy in a
DFT Problems
DCT
few X[k] and decorrelates them.
DCT of sine wave p
DCT/DFT Example: Markov Process: x[n] = x[n 1] + 1 2 u[n]
Equivalence
DCT Properties where
u[n] is i.i.d. unit Gaussian.
IDCT
Energy Conservation
Then x2 [n] = 1 and hx[n]x[n 1]i = .
Covariance of vector x is Si,j = xx i,j = |ij| .
Energy

H
Compaction
Frame-based coding
Lapped Transform Suppose ODCT of x is Cx D and DFT Eis Fx.
MDCT (Modified
DCT)
MDCT Basis
Covariance of Cx is CxxH CH = CSCH (similarly FSFH )
Elements
Summary
Diagonal elements give mean coefficient energy.
MATLAB routines 100
Used in MPEG and JPEG (superseded by
DCT
Cumulative energy (%)

90

80 JPEG2000 using wavelets)


70
Used in speech recognition to decorrelate
DFT
60

50
spectral coeficients: DCT of log spectrum
=0.9
N=32

5 10 15 20 25 30
No of coefficients

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 (2015-7058) Transforms: 3 9 / 15


Frame-based coding

3: Discrete Cosine
Transform Divide continuous signal
x[n]
DFT Problems into frames
DCT
DCT of sine wave X[k] k=30/220
DCT/DFT Apply DCT to each frame
Equivalence
DCT Properties y[n]
IDCT
Encode DCT
y[n]-x[n]
Energy Conservation
Energy Compaction e.g. keep only 30 X[k]
Frame-based
coding Apply IDCT y[n]
Lapped Transform
MDCT (Modified
DCT)
MDCT Basis
Problem: Coding may create discontinuities at frame boundaries
Elements
Summary
e.g. JPEG, MPEG use 8 8 pixel blocks
MATLAB routines

8.3 kB (PNG) 1.6 kB (JPEG) 0.5 kB (JPEG)


DSP and Digital Filters (2015-7058) Transforms: 3 10 / 15
Lapped Transform

3: Discrete Cosine
Transform Modified Discrete Cosine Transform (MDCT): overlapping frames 2N long
DFT Problems
DCT
DCT of sine wave
x[0 : 2N 1]
DCT/DFT MDCT
Equivalence X0 [0 : N 1] x[n] N 2N 3N 4N

DCT Properties IMDCT


IDCT y0 [0 : 2N 1] X0[k]
Energy Conservation
Energy Compaction x[N : 3N 1] X1[k]
X2[k]
Frame-based coding
MDCT y0[n]
Lapped Transform X1 [N : 2N 1]
MDCT (Modified
DCT) IMDCT y1[n]
MDCT Basis
y1 [N : 3N 1] y2[n]
Elements
Summary x[2N : 4N 1] y[n]
MATLAB routines
MDCT
X2 [2N : 3N 1] y[n]-x[n] = error
IMDCT
y2 [2N : 4N 1] 0 N 2N 3N 4N

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 (2015-7058) Transforms: 3 11 / 15


MDCT (Modified DCT)

P2N 1
MDCT: X[k] = n=0 x[n] cos 2(2n+1+N
8N
)(2k+1)
0k<N
PN 1
IMDCT: y[n] = 1
N k=0 X[k] cos 2(2n+1+N
8N
)(2k+1)
0 n < 2N
1 T 1 T
If x, X and y are column vectors, then X = Mx and y = N M X = N M Mx
where M is an N 2N matrix with mk,n = cos 2(2n+1+N
8N
)(2k+1)
.
Quasi-Orthogonality: The 2N 2N matrix, N1 MT M, is almost the identity:

  1 0 0 1
1 T 1 IJ 0 .. . . .. , J = .. . ..
M M = 2 with I = . . . . . . .
N 0 I+J
0 1 1 0
When two consective y frames are overlapped by N samples, the second half of the first
frame has thus been multiplied by 12 (I + J) and the first half of the second frame by
1
2 (I J). When these y frames are added together, the corresponding x samples have
been multiplied by 21 (I + J) + 12 (I J) = I giving perfect reconstruction.
Normally the 2N -long x and y frames are windowed before the MDCT and again after the
IMDCT to avoid any discontinuities; if the window is symmetric and satisfies
w2 [i] + w2 [i + N ] = 2 the perfect reconstruction property is still true.
DSP and Digital Filters (2015-7058) Transforms: 3 12 / 15
1 T
[Deriving the value of N M M]

This proof is not examinable.


1 2(2n+1+N )(2k+1)
If we define A = N MT M with mkn = cos 8N
, we want to show that
 
I + J 0
A = 21 . To avoid fractions, we write = 2
8N
so that mkn =
0 IJ
cos ((2n + 1 + N )(2k + 1)). Now we can say

N 1
1 X
arn = mkr mkn
N k=0
N 1
1 X
= cos ((2r + 1 + N )(2k + 1)) cos ((2n + 1 + N )(2k + 1))
N k=0
N 1 N 1
1 X 1 X
= cos (2(r n)(2k + 1)) + cos (2(r + n + 1 + N )(2k + 1))
2N k=0 2N k=0
1 1
where, in the last line, we used the identity cos cos = 2
cos ( ) + 2
cos ( + ).
We now convert these terms to complex exponentials to sum them as geometric progressions.

DSP and Digital Filters (2015-7058) Transforms: 3 note 1 of slide 12


1
PN 1
[ 2N k=0 cos (2(r n)(2k + 1))]

2
Converting to a the real part () of geometric progression (with = 8N
):

N N
1 1
!
1 X 1 X
cos (2(r n)(2k + 1)) = exp (j2(r n)(2k + 1))
2N k=0
2N k=0
N 1
!
1 X
= exp (j2(r n)) exp (j4(r n)k)
2N k=0
 
1 1 exp (j4(r n)N )
= exp (j2(r n))
2N 1 exp (j4(r n))
 
1 1 exp (j4(r n)N )
=
2N exp (j2(r n)) exp (j2(r n))
 
1 1 exp (j4(r n)N )
=
2N 2j sin (2(r n))
1 sin (4(r n)N ) 1 sin ((r n))
= =
4N sin rn

4N sin (2(r n)) 2N

The numerator is sine of a multiple of and is therefore 0. Therefore the whole sum is zero unless
the denominator is zero or, equivalently, (r n) is a multiple of 2N . Since 0 r, n < 2N , this only
1 PN 1 1
happens when r = n in which case the sum becomes 2N k=0 cos 0 = 2 .

DSP and Digital Filters (2015-7058) Transforms: 3 note 2 of slide 12


1
PN 1
[ 2N k=0 cos (2(r + n + 1 + N )(2k + 1))]

1 PN 1
2N k=0 cos (2(r + n + 1 + N )(2k + 1)) is the same as before with r n replaced by r + n + 1 + N .
We can therefore write

N 1
1 X 1 sin ((r + n + 1 + N ))
cos (2(r + n + 1 + N )(2k + 1)) =  
2N k=0 4N sin r+n+1+N

2N

The numerator is again the sine of a multiple of and is therefore 0. Therefore the whole sum is zero
unless (r + n + 1 + N ) is a multiple of 2N . This only happens when r + n = N 1 or 3N 1 since
0 r, n < 2N . The constraint r + n = N 1 corresponds to the anti-diagonal of the top left quadrant
of the A matrix, while r + n = 3N 1 corresponds to the anti-diagonal of the bottom right quadrant.
1 sin(x)
Writing r + n + 1 + N = x, we can use LHpitals rule to evaluate 4N sin( x )
at x = {2N, 4N }.
2N
1 cos(x)
 1 1
Differentiating numerator and denominator gives 2 cos( x )
which comes to 2 , 2 respectively at
2N
x = {2N, 4N }.

DSP and Digital Filters (2015-7058) Transforms: 3 note 3 of slide 12


MDCT Basis Elements

3: Discrete Cosine P2N 1


Transform MDCT: X[k] = n=0 x[n] cos 2(2n+1+N
8N
)(2k+1)
0k<N
DFT Problems
DCT PN 1
DCT of sine wave IMDCT: y[n] = 1
N k=0 X[k] cos 2(2n+1+N
8N
)(2k+1)
0 n < 2N
DCT/DFT
Equivalence
DCT Properties In vector notation: X = Mx and y = 41 MT X = 41 MT Mx
IDCT
Energy Conservation
Energy Compaction
The rows of M form the
Frame-based coding MDCT basis elements.
Lapped Transform
MDCT (Modified
DCT)
MDCT Basis
Elements
Summary
MATLAB routines
Example (N = 4):

M=
0.56 0.20 0.20 0.56 0.83 0.98 0.98 0.83
0.98 0.56 0.56 0.98 0.20 0.83 0.83 0.20

0.20 0.83 0.83 0.20 0.98 0.56 0.56 0.98
0.83 0.98 0.98 0.83 0.56 0.20 0.20 0.56

The basis frequencies are {0.5, 1.5, 2.5, 3.5} times the fundamental.

DSP and Digital Filters (2015-7058) Transforms: 3 13 / 15


Summary

3: Discrete Cosine
Transform DCT: Discrete Cosine Transform
DFT Problems

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

DCT
DCT of sine wave Often scaled to make an orthogonal transform (ODCT)
DCT/DFT
Equivalence Better than DFT for energy compaction and decorrelation ,
DCT Properties
IDCT
Energy Compaction: Most energy is in only a few coefficients
Energy Conservation Decorrelation: The coefficients are uncorrelated with each other
Energy Compaction
Frame-based coding Nice convolution property of DFT is lost /
Lapped Transform
MDCT (Modified
DCT)
MDCT: Modified Discrete Cosine Transform
MDCT Basis Lapped transform: 2N N 2N
Elements
Summary Aliasing errors cancel out when overlapping output frames are added
MATLAB routines
Similar to DCT for energy compaction and decorrelation ,
Overlapping windowed frames can avoid edge discontinuities ,
Used in audio coding: MP3, WMA, AC-3, AAC, Vorbis, ATRAC
For further details see Mitra: 5.

DSP and Digital Filters (2015-7058) Transforms: 3 14 / 15


MATLAB routines

3: Discrete Cosine
Transform dct, idct ODCT with optional zero-padding
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)
MDCT Basis
Elements
Summary
MATLAB routines

DSP and Digital Filters (2015-7058) 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
4: Linear Time Invariant Systems
Overlap Add
Overlap Save
Summary
MATLAB routines

DSP and Digital Filters (2015-6724) LTI Systems: 4 1 / 14


LTI Systems

4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
Linear Time-invariant (LTI) systems have two properties:
Passive and Lossless
Convolution Linear: H (u[n] + v[n]) = H (u[n]) + H (v[n])
Complexity
Circular Convolution Time Invariant: y[n] = H (x[n]) y[n r] = H (x[n r]) r
Frequency-domain
convolution
Overlap Add
The behaviour of an LTI system is completely defined by its impulse
Overlap Save response: h[n] = H ([n])
Summary
MATLAB routines
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 (2015-6724) LTI Systems: 4 2 / 14


Convolution Properties

4: Linear Time
P
Invariant Systems Convolution: x[n] v[n] = r= x[r]v[n r]
LTI Systems
Convolution
Properties Convolution obeys normal arithmetic rules for multiplication:
BIBO Stability
Frequency Response Commutative: x[n] v[n] = v[n] x[n]
Causality P (i) P
Passive and Lossless Proof: r x[r]v[n r] = p x[n p]v[p]
Convolution
Complexity (i) substitute p = n r
Circular Convolution
Frequency-domain
convolution Associative: x[n] (v[n] w[n]) = (x[n] v[n]) w[n]
Overlap Add
Overlap Save
x[n] v[n] w[n] is unambiguous
Summary
P (i) P
MATLAB routines
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] (i) all terms zero except r = 0.

DSP and Digital Filters (2015-6724) LTI Systems: 4 3 / 14


BIBO Stability

4: Linear Time
Invariant Systems BIBO Stability: Bounded Input, x[n] Bounded Output, y[n]
LTI Systems
Convolution The following are equivalent:
Properties
BIBO Stability (1) An LTI system is BIBO stable P
Frequency Response
Causality
(2) h[n] is absolutely summable, i.e. n= |h[n]| <
Passive and Lossless
Convolution
(3) H(z) region of absolute convergence includes |z| = 1.
Complexity
Circular Convolution Proof (1) (2):(
Frequency-domain
convolution 1 h[n] 0
Overlap Add Define x[n] =
Overlap Save 1 h[n] < 0
Summary P P
MATLAB routines 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 (2015-6724) LTI Systems: 4 4 / 14


Frequency Response

4: Linear Time
Invariant Systems For a BIBO stable system Y (ej ) = X(ej )H(ej )
LTI Systems
Convolution
where H(ej )is the DTFT of h[n] i.e. H(z) evaluated at z = ej .
Properties  
BIBO Stability Example: h[n] = 1 1 1
Frequency
Response
H(ej ) = 1 + ej + ej2
0

Causality 3

Passive and Lossless


Convolution
= ej (1 + 2 cos ) 2

Complexity
Circular Convolution H(ej ) = |1 + 2 cos | 1

Frequency-domain
H(ej ) = + 1sgn(1+2 cos ) 0
convolution 0 1 2 3

Overlap Add 2
10
Overlap Save
Summary Sign change in (1 + 2 cos ) at = 2.1 gives 5

MATLAB routines
(a) gradient discontinuity in |H(ej )| 0

-5
(b) an abrupt phase change of . -10
0 1 2 3

d
Group delay is d H(ej ): gives delay of the 1

modulation envelope at each . 0

Normally varies with but for a symmetric filter it -1


is constant: in this case +1 samples. -2
0 1 2 3
Discontinuities of k do not affect group delay.

DSP and Digital Filters (2015-6724) LTI Systems: 4 5 / 14


Causality

4: Linear Time
Invariant Systems Causal System: cannot see into the future
LTI Systems i.e. output at time n depends only on inputs up to time n.
Convolution
Properties
BIBO Stability Formal definition:
Frequency Response
Causality
If v[n] = x[n] for n n0 then H (v[n]) = H (x[n]) for n n0 .
Passive and Lossless
Convolution The following are equivalent:
Complexity
Circular Convolution (1) An LTI system is causal
Frequency-domain
convolution (2) h[n] is causal h[n] = 0 for n < 0
Overlap Add
Overlap Save
(3) H(z) converges for z =
Summary
MATLAB routines 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 (2015-6724) LTI Systems: 4 6 / 14


Passive and Lossless

4: Linear Time
Invariant Systems
LTI Systems
Convolution
Properties
BIBO Stability
Frequency Response
Causality
A
Ppassive system canPnever gain energy:
2 2
Passive and
n= |y[n]| n= |x[n]| for any finite energy input x[n].
Lossless
Convolution
j
Complexity A passive LTI system must have H(e ) 1

Circular Convolution
Frequency-domain Somewhat analogous to a circuit consisting of R, L and C only.
convolution
Overlap Add
Overlap Save
A
Plossless system always preserves energy exactly:
2 P 2
Summary
n= |y[n]| = n= |x[n]| for any finite energy input x[n].
MATLAB routines
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 (2015-6724) LTI Systems: 4 7 / 14


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

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

Causal h[n] = 0 for n < 0


P
BIBO Stable n= |h[n]| <

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

Causal H() converges


BIBO Stable H(z) converges for |z| = 1
Passive |H(z)| 1 for |z| = 1
Lossless or Allpass |H(z)| = 1 for |z| = 1

DSP and Digital Filters (2015-6724) LTI Systems: 4 note 1 of slide 7


Convolution Complexity

4: Linear Time
Invariant Systems y[n] = x[n] h[n]: convolve x[0 : N 1] with h[0 : M 1]
LTI Systems
Convolution x
Properties
BIBO Stability
y[0] y[9]

Frequency Response
Causality ConvolutionP
sum:
M 1
Passive and Lossless
Convolution
y[n] = r=0 h[r]x[n r]
Complexity
Circular Convolution y[n] is only non-zero in the range
Frequency-domain
convolution 0nM +N 2
Overlap Add
Overlap Save
Thus y[n] has only
Summary M + N 1 non-zero values
MATLAB routines

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 (2015-6724) LTI Systems: 4 8 / 14


Circular Convolution

4: Linear Time
Invariant Systems y [n] = x[n] N h[n]: circ convolve x[0 : N 1] with h[0 : M 1]
LTI Systems
Convolution x
Properties
BIBO Stability
N y[0] y[7]

Frequency Response
Causality Convolution sum:
Passive and Lossless
Convolution PM 1
Complexity yN [n] = r=0 h[r]x[(n r)mod N ]
Circular
Convolution
Frequency-domain yN [n] has period N
convolution
Overlap Add yN [n] has N distinct values
Overlap Save
Summary
MATLAB routines 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 (2015-6724) LTI Systems: 4 9 / 14


Frequency-domain convolution

4: Linear Time
Invariant Systems Idea: Use DFT to perform circular convolution - less computation
LTI Systems
Convolution (1) Choose L M + N 1 (normally round up to a power of 2)
Properties
BIBO Stability
Frequency Response (2) Zero pad x[n] and h[n] to give sequences of length L: x
[n] and h[n]
Causality
Passive and Lossless H[k])
(3) Use DFT: y[n] = F 1 (X[k] =x
[n] L h[n]
Convolution
Complexity
Circular Convolution (4) y[n] = y[n] for 0 n M + N 2.
Frequency-domain
convolution
Arithmetic Complexity:
Overlap Add
Overlap Save DFT or IDFT take 4L log2 L operations if L is a power of 2
Summary
MATLAB routines (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 (2015-6724) LTI Systems: 4 10 / 14


Overlap Add

4: Linear Time
Invariant Systems If N is very large:
N
LTI Systems (1) chop x[n] into K chunks of length K
Convolution
Properties (2) convolve each chunk with h[n]
BIBO Stability
Frequency Response (3) add up the results
Causality
Passive and Lossless
Convolution Each output chunk is of length K + M 1 and overlaps the next chunk
Complexity
N
Circular Convolution Operations: K 8 (M + K) log2 (M + K)
Frequency-domain
convolution Computational saving if 100 < M K N
Overlap Add
Overlap Save Example: M = 500, K = 104 , N = 107
Summary
MATLAB routines 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 (2015-6724) LTI Systems: 4 11 / 14


Overlap Save

4: Linear Time
Invariant Systems Alternative method:
N
LTI Systems (1) chop x[n] into K overlapping
Convolution
Properties chunks of length K + M 1
BIBO Stability
Frequency Response (2) K+M 1 each chunk with h[n]
Causality
Passive and Lossless
(3) discard first M 1 from each chunk
Convolution (4) concatenate to make y[n]
Complexity
Circular Convolution
Frequency-domain
convolution
The first M 1 points of each output chunk are invalid
Overlap Add
Overlap Save Operations: slightly less than overlap-add because no addition needed to
Summary
MATLAB routines
create y[n]
Advantages: same as overlap add
Strangely, rather less popular than overlap-add

DSP and Digital Filters (2015-6724) LTI Systems: 4 12 / 14


Summary

4: Linear Time
Invariant Systems LTI systems: impulse response, frequency response, group delay
LTI Systems
Convolution BIBO stable, Causal, Passive, Lossless systems
Properties
BIBO Stability
Frequency Response Convolution and circular convolution properties
Causality
Passive and Lossless Efficient methods for convolution
Convolution
Complexity single DFT
Circular Convolution
Frequency-domain overlap-add and overlap-save
convolution
Overlap Add
Overlap Save
Summary For further details see Mitra: 4 & 5.
MATLAB routines

DSP and Digital Filters (2015-6724) LTI Systems: 4 13 / 14


MATLAB routines

4: Linear Time
Invariant Systems fftfilt Convolution using overlap add
LTI Systems
Convolution
x[n]y[n] real(ifft(fft(x).*fft(y)))
Properties
BIBO Stability
Frequency Response
Causality
Passive and Lossless
Convolution
Complexity
Circular Convolution
Frequency-domain
convolution
Overlap Add
Overlap Save
Summary
MATLAB routines

DSP and Digital Filters (2015-6724) 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
5: Filters
responses
Stability Triangle
Low-pass filter
Allpass filters
Group Delay
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines

DSP and Digital Filters (2015-7228) Filters: 5 1 / 19


Difference Equations

5: Filters
Difference
Most useful LTI systems can be described by a difference equation:
Equations
y[n] = M
P PN
FIR Filters
r=0 b[r]x[n r] r=1 a[r]y[n r]
FIR Symmetries
IIR Frequency PN PM
Response r=0 a[r]y[n r] = r=0 b[r]x[n r] with a[0] = 1
Negating z
Cubing z
Scaling z
a[n] y[n] = b[n] x[n]
IIR Impulse response
B(z)
examples
IIR Impulse response
Y (z) = A(z) X(z)
Other BIBO
responses j B(ej ) j
Stability Triangle Y (e ) = A(ej ) X(e )
Low-pass filter
Allpass filters
Group Delay
(1) Always causal.
Minimum Phase (2) Order of system is max(M, N ), the highest r with a[r] 6= 0 or b[r] 6= 0.
Linear Phase Filters
Summary
(3) We assume that a[0] = 1; if not, divide A(z) and B(z) by a[0].
MATLAB routines (4) 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 (2015-7228) Filters: 5 2 / 19


FIR Filters

5: Filters
Difference Equations
A(z) = 1: Finite Impulse Response (FIR) filter: Y (z) = B(z)X(z).
FIR Filters Impulse response is b[n] and is of length M + 1.
FIR Symmetries
IIR Frequency
Response Frequency response is B(ej ) and is the DTFT of b[n].
Negating z
Cubing z
Comprises M complex sinusoids + const:
Scaling z b[0] + b[1]ej + + b[M ]ejM
IIR Impulse response
examples
IIR Impulse response Small M response contains only low quefrencies
Other BIBO jM
M
responses
Stability Triangle
Symmetrical b[n]H(ej )e 2 consists of 2 cosine waves [+ const]
Low-pass filter
Allpass filters
Group Delay M=4 M=14 M=24
Minimum Phase
Linear Phase Filters
Summary
MATLAB routines
1 1 1

0.5 0.5 0.5

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

2
Rule of thumb: Fastest possible transition M (marked line)

DSP and Digital Filters (2015-7228) Filters: 5 3 / 19


FIR Symmetries

5: Filters PM
Difference Equations
j
B(e ) is determined by the zeros of z B(z) = r=0 b[M r]z r M
FIR Filters
FIR Symmetries Real b[n] conjugate zero pairs: z z
IIR Frequency
Response Symmetric: b[n] = b[M n] reciprocal zero pairs: z z 1
Negating z
Cubing z
Real + Symmetric b[n] conjugate+reciprocal groups of four
Scaling z or else pairs on the real axis
IIR Impulse response
examples Real: Symmetric: Real + Symmetric:
IIR Impulse response
[1, 1.28, 0.64] [1, 1.64 + 0.27j, 1] [1, 3.28, 4.7625, 3.28, 1]
Other BIBO
responses
Stability Triangle 1 1 1
Low-pass filter 0.5 0.5 0.5
Allpass filters 0 0 0
Group Delay -0.5 -0.5 -0.5
Minimum Phase
-1 -1 -1
Linear Phase Filters
Summary -1 0 1 -1 0 1 -1 0 1
z z z
MATLAB routines

3
10
2
2
1 5
1

0 0 0
-2 0 2 -2 0 2 -2 0 2
(rad/sample) (rad/sample) (rad/sample)

DSP and Digital Filters (2015-7228) Filters: 5 4 / 19


[FIR Symmetry Proofs]

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

(1) Real b[n]


r
PM
B(z0 ) =

r=0 b[r] z 0
PM r
= r=0 b [r] z0 since b[r] is real
P 
M r
= r=0 b[r]z0 take complex conjugate
= 0 = 0 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 substitute r = M n
n
z0M M take out z0M factor
P
= n=0 b[M n]z0
n
z0M M
P
= n=0 b[n]z0 since b[M n] = b[n]
= z0M 0 = 0 since B(z0 ) = 0

DSP and Digital Filters (2015-7228) Filters: 5 note 1 of slide 4


IIR Frequency Response

5: Filters
Q
b[0] Mi=1 (1qi z )
1
B(z)
Difference Equations Factorize H(z) = A(z) = QN
i=1 (1pi z )
1
FIR Filters
FIR Symmetries

IIR Frequency
Response
Roots of A(z) and B(z) are the poles {pi } and zeros {qi } of H(z)
Negating z Also an additional N M zeros at the origin (affect phase only)
Cubing z
M QM
Scaling z
H(ej ) = |b[0]|| z | i=1 |zqi | j
IIR Impulse response
|z N |
Q N
|zp |
for z = e
examples i=1 i
IIR Impulse response
Other BIBO Example:
responses
2+2.4z 1 2(1+1.2z 1 )
Stability Triangle
Low-pass filter
H(z) = 10.96z 1 +0.64z 2 = (1(0.480.64j)z 1 )(1(0.48+0.64j)z 1 )
Allpass filters
21.76

j
Group Delay At = 1.3: H(e ) = 1.620.39
= 5.6
Minimum Phase
Linear Phase Filters H(ej ) = (0.6 + 1.3) (1.7 + 2.2) = 1.97
Summary
MATLAB routines
1 0.39 1
2.2
10 0.5 0.5
1.76 1.62
0.6 1.3
0 0


5 -0.5 -0.5 1.7
-1 -1
0 -1 0 1 -1 0 1
0 1 2 3
(z) (z)

DSP and Digital Filters (2015-7228) Filters: 5 5 / 19


Negating z

5: Filters
Difference Equations
Given a filter H(z) we can form a new one HR (z) = H(z)
FIR Filters Negate all odd powers of z, i.e. negate alternate a[n] and b[n]
FIR Symmetries
IIR Frequency 2+2.4z 1
Response Example: H(z) = 10.96z 1 +0.64z 2
Negating z
Cubing z
Scaling z 1
IIR Impulse response 0.5 10
examples
0
IIR Impulse response

5
Other BIBO -0.5
responses
-1
Stability Triangle 0
-1 0 1 0 1 2 3
Low-pass filter (z)
Allpass filters
Group Delay
22.4z 1
Minimum Phase Negate z: HR (z) = 1+0.96z 1 +0.64z 2 Negate odd coefficients
Linear Phase Filters
Summary
MATLAB routines 1
0.5 10

-0.5 5

-1
-1 0 1 0
0 1 2 3
(z)

Pole and zero positions are negated, magnitude response flipped.


DSP and Digital Filters (2015-7228) Filters: 5 6 / 19
Cubing z

5: Filters
Difference Equations
Given a filter H(z) we can form a new one HC (z) = H(z 3 )
FIR Filters Insert two zeros between each a[n] and b[n] term
FIR Symmetries
IIR Frequency
2+2.4z 1
Response Example: H(z) = 10.96z 1 +0.64z 2
Negating z
Cubing z
Scaling z 1
IIR Impulse response 0.5 10
examples
IIR Impulse response 0

5
Other BIBO -0.5
responses
-1
Stability Triangle 0
-1 0 1 -2 0 2
Low-pass filter
(z) (rad/sample)
Allpass filters
Group Delay
2+2.4z 3
Minimum Phase Cube z: HC (z) = 10.96z 3 +0.64z 6 Insert 2 zeros between coefs
Linear Phase Filters
Summary
1
MATLAB routines
0.5 10
C

0
5
-0.5

-1
0
-1 0 1 -2 0 2
z (rad/sample)

Pole and zero positions are replicated, magnitude response replicated.


DSP and Digital Filters (2015-7228) Filters: 5 7 / 19
Scaling z

5: Filters
Difference Equations
Given a filter H(z) we can form a new one HS (z) = H( z )
FIR Filters Multiply a[n] and b[n] by n
FIR Symmetries
IIR Frequency 2+2.4z 1
Response Example: H(z) = 10.96z 1 +0.64z 2
Negating z
Cubing z
1
Scaling z
0.5 10
IIR Impulse response
0
examples

-0.5 5
IIR Impulse response
Other BIBO -1
0
responses -1 0 1 0 1 2 3
(z)
Stability Triangle
Low-pass filter
z 2+2.64z 1
Allpass filters Scale z: HS (z) = H( 1.1 )= 11.056z 1 +0.7744z 2
Group Delay
Minimum Phase 1
20
Linear Phase Filters
0.5
Summary 15
0
MATLAB routines 10
-0.5
5
-1
0
-1 0 1 0 1 2 3
z (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 (2015-7228) Filters: 5 8 / 19


IIR Impulse response examples

5: Filters B(z)
Difference Equations To find the impulse response of A(z) , use partial fractions:
FIR Filters
FIR Symmetries
IIR Frequency
Example 1: M < N
Response
B(z) 13.4z 1
3 2
Negating z
Cubing z A(z) = 10.3z 1 0.4z 2 = 1+0.5z 1 + 10.8z 1
n n
Scaling z h[n] = (3 (0.5) 2 (0.8) ) u[n]
IIR Impulse
response examples
IIR Impulse response Example 2: M N
Other BIBO
responses B(z) 25.7z 1 +0.2z 2 +0.8z 3
Stability Triangle A(z) = 10.3z 1 0.4z 2
Low-pass filter 13.4z 1
1
Allpass filters = 1 2z + 10.3z1 0.4z2
Group Delay 3 2
Minimum Phase = 1 2z 1 + 1+0.5z 1 + 10.8z 1
Linear Phase Filters n n
Summary
h[n] = [n] 2[n 1] + (3 (0.5) 2 (0.8) ) u[n]
MATLAB routines
Example 3: repeated pole at z = 0.5
B(z) 1 2

A(z) = 1+0.3z35z 1.3z


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

DSP and Digital Filters (2015-7228) Filters: 5 9 / 19


IIR Impulse response

5: Filters B(z)
Difference Equations H(z) = A(z) we want h[n], the inverse z-Transform of H(z).
FIR Filters
FIR Symmetries
B(z)
IIR Frequency (1) Assume M < N else, do a long division: H(z) = D(z) + A(z)
Response
Negating z
1 Ki
QNp 
Cubing z
Scaling z
(2) Factorize A(z) = i=1 1 pi z (Np = # of distinct poles)
IIR Impulse response
examples

B(z) PNp PKi r
(3) Then A(z) = i=1 k=1 (1p i,k 1 )k (Ki = multiplicity of pi )
IIR Impulse iz
response kKi K
 
where ri,k = (pi) B(z)
k
d i 1 Ki
Other BIBO
responses (Ki k)! d(z 1 )Ki k A(z) (1 p i z )
z=pi
Stability Triangle
Low-pass filter
Allpass filters
For the common case Ki = 1 i (e.g. all poles distinct):
Group Delay

B(z) P N p ri
B(z) 1
Minimum Phase A(z) = i=1 1pi z 1 where r i = A(z) (1 p i z )
z=pi
Linear Phase Filters
Summary (4) The impulse response is given by
MATLAB routines
PNp PKi n+k1
h[n] = i=1 k=1 Ck1 ri,k pni for n 0
! n+k1
where C = is a binomial coefficient Ck1
!()! nk1
PNp
For the common case Ki = 1 i: h[n] = i=1 ri pni for n 0

DSP and Digital Filters (2015-7228) Filters: 5 10 / 19


[Impulse Response: Proof of (3)]

[You do not need to memorise this proof]



B(z) PNp PKj rj,l
We assume that = j=1 l=1 and we want to determine ri,k
A(z) (1pj z1 )l
K
(1) Multiply both sides by 1 pi z 1 i :

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

B(z) 1
Ki PKi 1
Ki l P PKj rj,l (1pi z1 )Ki
1 pi z = l=1 ri,l 1 pi z + j6=i l=1
A(z) (1pj z1 )l

dKi k
(2) DifferentiateKi k times with respect to z 1 : and evaluate at z = pi
d(z 1 )Ki k

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 i z
(1pj z1 )l
numerator and will equal zero at z = pi .
PKi K l
Similarly, terms in l=1 ri,l 1 pi z 1 i with l < k will also vanish.
PKi K l
ri,l 1 pi z 1 i

Also, terms in l=1 with l > k will also differentiate to zero.
The only term remaining is: (p)Ki k (Ki k)!ri,k from which the result follows.
 
dn
[Similarly (xm ) is zero unless m = n in which case it equals m!]

dxn
x=0

DSP and Digital Filters (2015-7228) Filters: 5 note 1 of slide 10


[Impulse Response: Proof of (4)]

[You do not need to memorise this proof]


1 k n+k1 n n
 P
We use induction on k to show that 1 pz = n=0 Ck1 p z

(1) Suppose the formula is true for k and differentiate both sides with respect to z 1 :
n k P o
d 1 n+k1 n n
d(z 1 )
1 pz = n=0 Ck1 p z
This gives:
(k+1) P n+k1 n (n1) n+k1 n (n1)
pk 1 pz 1 =
P
= n=0 nCk1 p z n=1 nCk1 p z
where we have omitted the term with n = 0 because it equals zero.
Now substitute, m = n 1:
1
(k+1) P m+k m+1 m
pk 1 pz = m=0 (m + 1)Ck1 p z
(k+1) m+1 m+k m m m+k m m
=
P
1 pz 1
 P
m=0 k C k1 p z = m=0 Ck p z
which proves the result for k + 1.
(2) To start the induction at k = 1:
1 P
1 pz 1 = n=0 C0n pn z n = n n
P
n=0 p z
This is true from the standard geometric progression formula. (Note that C0n = 1 n).

DSP and Digital Filters (2015-7228) Filters: 5 note 2 of slide 10


Other BIBO responses

5: Filters
Difference Equations
All LTI systems described by difference equations have h[n] decaying
FIR Filters exponentially or exponentially times a power of n.
FIR Symmetries
IIR Frequency
Response It is perfectly possible to have BIBO stable LTI systems whose impulse
Negating z
Cubing z
responses decay more slowly than this.
Scaling z 1
IIR Impulse response Example: h[n] = 1+n2 for n 0
examples
IIR Impulse response
P
Other BIBO
BIBO stable since |h[n]| = 2.077... <
responses Hence H(ej ) exists.
Stability Triangle
Low-pass filter
Allpass filters However, no finite difference equation can have this impulse response.
Group Delay
Minimum Phase
Linear Phase Filters 2
Summary
MATLAB routines 1.5

0.5

0
0 1 2 3

DSP and Digital Filters (2015-7228) Filters: 5 11 / 19


Stability Triangle

5: Filters
Difference Equations
Not normally easy to tell if poles lie within
FIR Filters |z| = 1, but easy test for a 2nd order filter: K2
S
FIR Symmetries
R
IIR Frequency
Response Suppose A(z) = 1 + a[1]z 1 + a[2]z 2 0
P
Negating z Q
Cubing z a[1] a[1]2 4a[2] -K2
Scaling z
The roots are p1,2 = 2
-2K 0 2K
IIR Impulse response
examples Want the conditions that |p1,2 | < K a[1]

IIR Impulse response


Other BIBO Case 1: Real roots:
responses
Stability Triangle
(P) a[1]2 4a[2] p
Low-pass filter (Q) 2K < a[1] a[1]2 4a[2] < 2K
Allpass filters p
Group Delay
Minimum Phase
a[1]2 4a[2] < 2K a[1]
Linear Phase Filters
Summary
a[1]2 4a[2] < 4K 2 4a[1]K + a[1]2
MATLAB routines
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 (2015-7228) Filters: 5 12 / 19


Low-pass filter

5: Filters
Difference Equations
1st order low pass filter: extremely common
1p
FIR Filters y[n] = (1 p)x[n] + py[n 1] H(z) = 1pz 1
FIR Symmetries
IIR Frequency
Response Impulse response:
n
Negating z
Cubing z
h[n] = (1 p)pn = (1 p)e
1
Scaling z where = ln p is the time constant in samples.
IIR Impulse response
examples
Magnitude response: H(e ) = 1p
j

IIR Impulse response
2
12p cos +p
Other BIBO
responses
Stability Triangle
Low-pass filter with DC gain of unity.
2
 
Low-pass filter
3 dB frequency is 3dB = cos1 1 2p (1p)
2 1p 1
Allpass filters 1+p
Group Delay 1
Minimum Phase Compare continuous time: HC (j) = 1+j
Linear Phase Filters
Summary
Indistinguishable for low but H(ej ) is periodic, HC (j) is not
MATLAB routines 0
1 p=0.80
0.5 -10 H(j)
0

-20
-0.5
HC(j)
-1 -30
-1 0 1 0.01 1/ 0.1 2
(z) (rad/sample)

DSP and Digital Filters (2015-7228) Filters: 5 13 / 19


Allpass filters

5: Filters B(z)
Difference Equations If H(z) = A(z) with b[n] = a [M n] then we have an allpass filter:
FIR Filters
FIR Symmetries
PM PM js
j a [M r]ejr jM

s=0 a [s]e
IIR Frequency H(e ) = P
r=0
M =e P M [s = M r]
r=0 a[r]e r=0 a[r]e
jr jr
Response
Negating z
Cubing z The two sums
arejcomplex conjugates they have the same magnitude
Scaling z

IIR Impulse response Hence H(e ) = 1 allpass
examples
IIR Impulse response
Other BIBO
However phase is not constant: H(ej ) = M 2A(ej )
responses
p+z 1 1p1 z 1
Stability Triangle 1st order allpass: H(z) = 1pz 1 = p 1pz1
Low-pass filter
Allpass filters 1
Pole at p and zero at p : reflected in unit circle
Group Delay
e p = |p| ej 1
Minimum Phase
j
Constant distance ratio:

Linear Phase Filters p
Summary
0
MATLAB routines 1
1
0.8 -1 0.5

0.6 0


0.4 -2
-0.5
0.2
-3 -1
0
0 1 2 3 0 1 2 3 -1 0 1
(z)

In an allpass filter, the zeros are the poles reflected in the unit circle.

DSP and Digital Filters (2015-7228) Filters: 5 14 / 19


[Allpass Filter Properties]

B(z)
An allpass filter is one in which H(z) = A(z) with b[n] = a [M n]. Of course, if the coefficients
a[n] are all real, then the conjugation has no effect and the numerator coefficients are identical to the
numerator coefficients but in reverse order.
If A(z) has order M , we can express the relation between A(z) and B(z) algebraically as
1 ) where the coefficients of A(z)
B(z) = z M A(z are the conjugates of the coefficients of A(z).
If the roots of A(z) are pi , then we can express H(z) in factorized form as
M M
Y pi + z 1 Y 1 pi z
H(z) = 1
=
i=1
1 p i z i=1
z pi

We can therefore write


M M
1 pi z (1 pi z )

Y Y 1 pi z pi z + pi pi zz
|H(z)|2 =  =
i=1
(z p i ) z p
i i=1
zz pi z pi z + pi pi
  
2 2

YM 
1 + pi pi zz zz pi pi
 YM 1 |z| 1 |pi |
= 1+
= 1+ 2

i=1
zz pi z pi z + pi pi i=1
|z pi |

If all the |pi | < 1, then each term in the product is T1 according to whether |z| S 1.
It follows that, provided H(z) is stable, |H(z)| T 1 according to whether |z| S 1.

DSP and Digital Filters (2015-7228) Filters: 5 note 1 of slide 14


Group Delay

5: Filters
j dH(ej )
Difference Equations Group delay: H (e ) = = delay of the modulation envelope.
d
FIR Filters
FIR Symmetries
IIR Frequency
j j
Trick to get at phase: ln H(e ) = ln H(e ) + jH(ej )
Response
d((ln H(ej )))
Negating z
 j
  
1 dH(e ) z dH
Cubing z H = d = H(ej ) d = H(z) dz
Scaling z z=ej
IIR Impulse response P
examples H(e ) = n=0 h[n]ejn = F (h[n])
j
[F = DTFT]
IIR Impulse response
dH(ej ) P
Other BIBO
d = n=0 jnh[n]ejn = jF (nh[n])
responses
Stability Triangle  j
    
1 dH(e ) jF (nh[n]) F (nh[n])
Low-pass filter H = H(e j ) d = F (h[n]) = F (h[n])
Allpass filters
Group Delay  
Minimum Phase 1 pej
Linear Phase Filters Example: H(z) = 1pz1 H = [1 p] = 1pej
Summary
0
MATLAB routines 1 p=0.80
-0.2 3 p=0.80
0.5
-0.4 2
0

-0.6 1
-0.5

H
-1 -0.8 0
-1 0 1 0 1 2 3 0 1 2 3
(z)

Average group delay (over ) = (# poles # zeros) within the unit circle
Zeros on the unit circle count
DSP and Digital Filters (2015-7228) 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
dH(ej )
of the envelope of a modulated sine wave at a frequency . It is defined as H (ej )
= d
.
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
dH(ej ) d  jk  d
H (e j
)= = 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 (2015-7228) 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 re = ln |r| + j or, in general, ln H = ln |H| + jH. By rearranging this equation, we get
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])
dz
In order to express H in terms of z, we first note that if z = ej then d
= jz. By substituting
z = ej into equation (1), we get

       
1 dH(z) 1 dH(z) dz jz dH(z) z dH(z)
H = = = = .
H(z) d H(z) dz d H(z) dz H(z) dz
z=e j

DSP and Digital Filters (2015-7228) Filters: 5 note 2 of slide 15


[Group Delay Example]

1
As an example, suppose we want to determine the group delay of : H(z) = 1pz 1
. As noted above,
B(z)
if H(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].

Applying the definition of the DTFT, we get


p ej p

pej p cos p2
   
p
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 (2015-7228) Filters: 5 note 3 of slide 15


Minimum Phase

5: Filters
Difference Equations
Average group delay (over ) = (# poles # zeros) within the unit circle
FIR Filters
FIR Symmetries
zeros on the unit circle count 4

3
IIR Frequency
Response Reflecting an interior zero to the exterior 2
Negating z
multiplies H(ej ) by a constant but
1
Cubing z
0
Scaling z
IIR Impulse response
increases average group delay by 1 sample. 0 1

2 3

examples
0
IIR Impulse response 1
Other BIBO 0.5
responses 0 -5

Stability Triangle -0.5


-10
Low-pass filter -1
Allpass filters -1 0 1 0 1 2 3
Group Delay (z)

Minimum Phase 30
Linear Phase Filters 1
20
Summary 0.5
MATLAB routines

H
0 10

-0.5
0
-1
-10
-1 0 1 0 1 2 3
(z)

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 (2015-7228) Filters: 5 16 / 19
Linear Phase Filters

5: Filters
Difference Equations
The phase of a linear phase filter is: H(ej ) = 0
FIR Filters
dH(ej )
FIR Symmetries
IIR Frequency
Equivalently constant group delay: H = d =
Response
Negating z A filter has linear phase iff h[n] is symmetric or antisymmetric:
Cubing z
Scaling z h[n] = h[M n] n or else h[n] = h[M n] n
IIR Impulse response
examples
IIR Impulse response
M can be even ( mid point) or odd ( mid point)
Other BIBO
responses Proof : PM PM
jn
Stability Triangle
Low-pass filter
j
2H(e ) = 0 h[n]e + 0 h[M n]ej(M n)
Allpass filters j M
PM j (n M ) j (n M
2 )
Group Delay
=e 2
0 h[n]e
2 + h[M n]e
Minimum Phase

Linear Phase
Filters
h[n] symmetric:
j j M
PM M

Summary 2H(e ) = 2e 2
0 h[n] cos n 2
MATLAB routines

h[n] anti-symmetric:
j j M
PM M

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

= 2e 2 2
0 h[n] sin n 2

DSP and Digital Filters (2015-7228) Filters: 5 17 / 19


Summary

5: Filters
Difference Equations
Useful filters have difference equations:
FIR Filters
FIR Symmetries Freq response determined by pole/zero positions
IIR Frequency
Response N M zeros at origin (or M N poles)
Negating z
Cubing z
Geometric construction of |H(ej )|
Scaling z Pole bandwidth 2 |log |p|| 2 (1 |p|)
IIR Impulse response
examples Stable if poles have |p| < 1
IIR Impulse response
Other BIBO
responses
Allpass filter: a[n] = b[M n]
Stability Triangle Reflecting a zero in unit circle leaves |H(ej )| unchanged
Low-pass filter
Allpass filters
j
 dH(ej )
Group Delay Group delay: H e = d samples
Minimum Phase  M
j
Linear Phase Filters Symmetrical h[n] H e = 2
Summary
MATLAB routines 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 (2015-7228) Filters: 5 18 / 19
MATLAB routines

5: Filters
Difference Equations
filter filter a signal
FIR Filters impz Impulse response
FIR Symmetries
IIR Frequency residuez partial fraction expansion
Response
Negating z grpdelay Group Delay
Cubing z
Scaling z
freqz 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 (2015-7228) 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
6: Window Filter Design

DSP and Digital Filters (2015-6729) Windows: 6 1 / 12


Inverse DTFT

6: Window Filter
Design For any BIBO stable filter, H(ej ) is the DTFT of h[n]
Inverse DTFT
j
P jn 1
R
Rectangular window H(e ) = h[n]e h[n] = 2 H(ej )ejn d
Dirichlet Kernel
Window relationships
Common Windows If we know H(ej ) exactly, the IDTFT gives the ideal h[n]
Uncertainty principle
Order Estimation Example: Ideal Lowpass filter
Example Design
Frequency sampling
(
Summary
j 1 || 0 sin 0 n
MATLAB routines H(e ) = h[n] = n
0 || > 0
1 2/0

20
0.5

0 0
-2 0 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 (2015-6729) Windows: 6 2 / 12


Rectangular window

6: Window Filter
Design Truncate to M
2 to make finite; h1 [n] is now of length M + 1
Inverse DTFT

Rectangular
window
MSE Optimality:
Dirichlet Kernel Define mean square error (MSE) in frequency domain
Window relationships
j 2
1
R j

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

Uncertainty principle 2
M

Order Estimation 1
R j
P jn
= 2 H(e ) 2
h [n]e d

Example Design M 1
2
Frequency sampling
Summary
MATLAB routines
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] 1 M=28
M=14
M=14

0.5

0 0
0 1 2 3

M M
Normal to delay by 2 to make causal. Multiplies H(ej ) by ej 2
.

DSP and Digital Filters (2015-6729) Windows: 6 3 / 12


Dirichlet Kernel

6: Window Filter
Design
Truncation Multiply h[n] by a rectangular window, w[n] = M n M
2 2
Inverse DTFT j 1 j j
Rectangular window
Circular Convolution HM +1 (e ) = 2 H(e ) W (e )
Dirichlet Kernel
Window relationships P M2 (i) P0.5M (ii) sin 0.5(M +1)
Common Windows W (e ) = j
M
ejn = 1 + 2 1 cos (n) = sin 0.5
Uncertainty principle 2
j(n)
Order Estimation Proof: (i) e + ej(+n) = 2 cos (n) (ii) Sum geom. progression
Example Design
Frequency sampling
Summary
Effect: convolve ideal freq response with Dirichlet kernel (aliassed sinc)
MATLAB routines
1 1 1

0.5 0.5 4/(M+1) 0.5

0 0 0

-2 0 2 -2 0 2 -2 0 2

1
M=14
Provided that M4+1 < 2 0 M + 1 > 2
0 :
0.5
Passband ripple: M4 +1 , stopband 2
M +1
4
0
Transition pk-to-pk: M +1

d|H| +1
-2 0

2 Transition Gradient: d M2
=0

DSP and Digital Filters (2015-6729) Windows: 6 4 / 12


[Dirichlet Kernel]

Other properties of W (ej ):


sin 0.5(M +1)
The DTFT of a symmetric rectangular window of length M + 1 is W (ej ) = sin 0.5
. For
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
which is when sin 0.5(M + 1) = 1 i.e. = 0.5(M +1)
= M3+1
. Hence min W (ej )
+1
min 2 1 sin 0.5(M + 1) = M
1.5
.
Passband and Stopband ripple:
sin 0.5(+1) 2 4
The ripple in W (ej ) = sin 0.5
has a period of = 0.5(+1)
= 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 (2015-6729) Windows: 6 note 1 of slide 4


Window relationships

6: Window Filter
Design
When you multiply an impulse response by a window M + 1 long
1
Inverse DTFT HM +1 (ej ) = 2 H(ej ) W (ej )
Rectangular window
Dirichlet Kernel
1
Window 20 M=20
1
relationships
Common Windows 10

1
0.5 0.5
Uncertainty principle
Order Estimation
0
Example Design 0
0
Frequency sampling -2 0 2 -2 0 2 -2 0 2

Summary
MATLAB routines
w[0] 0.5
R j
(a) passband gain w[0]; peak + 2 2
mainlobe
W (e )d
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 (2015-6729) Windows: 6 5 / 12
Common Windows

6: Window Filter
Design
Rectangular: w[n] 1 0
6.27/(M+1) -13 dB

Inverse DTFT dont use -50


Rectangular window
0 1 2 3
Dirichlet Kernel
Window relationships Hanning: 0.5 + 0.5c1 0
12.56/(M+1)
Common Windows
ck = cos M2kn -31 dB

Uncertainty principle +1 -50

Order Estimation rapid sidelobe decay 0 1 2 3


Example Design
0
Frequency sampling
Summary
Hamming: 0.54 + 0.46c1 12.56/(M+1)
-40 dB

MATLAB routines best peak sidelobe -50

0 1 2 3

Blackman-Harris 3-term: 0
18.87/(M+1)

0.42 + 0.5c1 + 0.08c2 -50


-70 dB
best peak sidelobe 0 1

2 3

 q  0
13.25/(M+1)
2n 2
I0 1( M ) = 5.3 -40 dB

Kaiser: I0 ()
-50

0 1 2 3

controls width v sidelobes 0


21.27/(M+1)

Good compromise: -50


= 9.5
-70 dB

Width v sidelobe v decay 0 1



2 3

DSP and Digital Filters (2015-6729) Windows: 6 6 / 12


Uncertainty principle

6: Window Filter R 2 2
 12  R 2 2
 21
Design t |x(t)| dt |X(j)| d 1
Inverse DTFT
CTFT uncertainty principle: R
|x(t)|2 dt
R
|X(j)|2 d
2
Rectangular window
Dirichlet Kernel
Window relationships
The first term measures the width of x(t) around t = 0.
2
Common Windows
Uncertainty
It is like if |x(t)| was a zero-mean probability distribution.
principle The second term is similarly the width of X(j) in frequency.
Order Estimation
Example Design A signal cannot be concentrated in both time and frequency.
Frequency sampling
Summary
So a short window cannot have a narrow main lobe.
MATLAB routines
Proof: R 2 R 2
Assume |x(t)| dt = 1 |X(j)| d = 2 [Parseval]
Set v(t) = dx V (j) = jX(j) [by parts]
R dxdt 2
Now tx dt dt= 2 tx t= 2 x dt = 21 [by parts]
1
R 1 2

1
R dx 2 R 2 2  R dx 2 
So 4 = tx dt dt t x dt dt
dt [Schwartz]
R 2 2  R 2
 R 2 2  1 R 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 (2015-6729) 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
R dt jt h
1
i
1
R dx(t) jt 1
X(j) = x(t)e dt = j x(t)e jt + j dt e dt = 0 + j
V (j)

d 1 2 dx

(2) Since dt 2
x = x dt
, we can apply integration by parts to get
dx 1 2 1 2 1 1 1
R   R dt R 2
tx dt dt = t 2 x t= dt 2 x dt = 2 x dt = 2 1 = 2
R 2 2
It follows that tx dt dt = 21 = 14 which we will use below.
dx

(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,
R 2 R
2
R 2
this becomes u(t)v(t)dt u (t)dt v (t)dt. We apply this with u(t) = tx(t)

dx(t)
and v(t) = dt
to get
2    
R 2
1
tx dx 2 x2 dt dx
R  R R 2 2  R 2 
= dt t dt = t x dt v (t)dt

4 dt dt

1
(4) From Parsevals theorem for the CTFT, v 2 (t)dt = 2 |V (j|2 d. From step (1), we can
R R

substitute V (j) = jX(j) to obtain v (t)dt = 2 |X(j|2 d. Making this substitution


1
R 2 R 2
in (3) gives
1
R 2 2  R 2  R 2 2  1 R 2 2

4
t x dt v (t)dt = t x dt 2 |X(j| d

DSP and Digital Filters (2015-6729) Windows: 6 note 1 of slide 7


Order Estimation

6: Window Filter
Design
Several formulae estimate the required order of a filter, M .
Inverse DTFT
Rectangular window E.g. for lowpass filter
Dirichlet Kernel
Window relationships Estimated order is
Common Windows
Uncertainty principle 5.64.3 log10 () 820 log10
Order Estimation
M 2 1 2.2
Example Design
Frequency sampling Required M increases as either the
Summary
MATLAB routines 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,.
1 = 2f
fs
1
= 0.943, 2 = 2f2
fs = 1.047

Ripple: 20 log10 (1 + ) = 0.1 dB, 20 log10 = 35 dB


0.1 35
= 10 20 1 = 0.0116, = 10 20 = 0.0178
5.64.3 log10 (2104 ) 10.25 358
M 1.0470.943 = 0.105 = 98 or 2.2 = 117

DSP and Digital Filters (2015-6729) Windows: 6 8 / 12


Example Design

6: Window Filter
Design
Specifications: 1
Inverse DTFT Bandpass: 1 = 0.5, 2 = 1
Rectangular window
Dirichlet Kernel Transition bandwidth: = 0.1 0.5
Window relationships
Common Windows
Ripple: = = 0.02
Uncertainty principle 20 log10 = 34 dB 0
Order Estimation 0 1 2 3
Example Design 20 log10 (1 + ) = 0.17 dB

Frequency sampling 1
M=92
Summary Order: = 2.5
MATLAB routines 5.64.3 log10 ()
M 2 1 = 92 0.5

Ideal Impulse Response:


Difference of two lowpass filters 0
0 1 2 3
h[n] = sinn
2 n
sinn
1 n

0
M=92
Kaiser Window: = 2.5 = 2.5
-20

M=92
-40
0

-60
0 1 2 3

DSP and Digital Filters (2015-6729) Windows: 6 9 / 12


Frequency sampling

6: Window Filter
Design Take M + 1 uniform samples of H(ej ); take IDFT to obtain h[n]
Inverse DTFT
Rectangular window Advantage:
Dirichlet Kernel
Window relationships exact match at sample points
Common Windows
Uncertainty principle Disadvantage:
Order Estimation
Example Design poor intermediate approximation if spectrum is varying rapidly
Frequency
sampling
Solutions:
Summary
MATLAB routines (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
1
M+1=93

0.5
0.5

0 0
-2 0 2 0 1 2 3

DSP and Digital Filters (2015-6729) Windows: 6 10 / 12


Summary

6: Window Filter
Design
Make an FIR filter by windowing the IDTFT of the ideal response
Inverse DTFT
Rectangular window
Ideal lowpass has h[n] = sinn
0 n

Dirichlet Kernel
Window relationships Add/subtract lowpass filters to make any piecewise constant
Common Windows response
Uncertainty principle
Order Estimation
Example Design Ideal filter response is with the DTFT of the window
Frequency sampling
Summary
Rectangular window (W (z) = Dirichlet kernel) has 13 dB
MATLAB routines sidelobes and is always a bad idea
Hamming, Blackman-Harris are good
Kaiser good with trading off main lobe width v. sidelobes
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 (2015-6729) Windows: 6 11 / 12


MATLAB routines

6: Window Filter
Design diric(x,n) Dirichlet kernel: sin 0.5nx
sin 0.5x
Inverse DTFT
Rectangular window
hanning Window functions
Dirichlet Kernel hamming (Note periodic option)
Window relationships
Common Windows kaiser
Uncertainty principle
Order Estimation
kaiserord Estimate required filter order and
Example Design
Frequency sampling
Summary
MATLAB routines

DSP and Digital Filters (2015-6729) 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
7: Optimal FIR filters
MATLAB routines

DSP and Digital Filters (2015-6729) Optimal FIR: 7 1 / 11


Optimal Filters

7: Optimal FIR filters


Optimal Filters
We restrict ourselves to zero-phase filters of odd length M + 1, symmetric
Alternation Theorem around h[0], i.e. h[n] = h[n].
Chebyshev P M2 P M2
j jn
Polynomials
Maximal Error
H() = H(e ) = M h[n]e = h[0] + 2 1 h[n] cos n
2
Locations
j
Remez Exchange H() is real but not necessarily positive (unlike H(e ) ).

Algorithm
Determine Polynomial

Example Design Weighted error: e() = s() H() d() where d() is the target.
FIR Pros and Cons
Summary
Choose s() to control the error variation with .
MATLAB routines
Example: lowpass filter
(
1 0 1
d() =
0 2
(
1 0 1
s() = 1
2

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 (2015-6729) Optimal FIR: 7 2 / 11


Alternation Theorem

7: Optimal FIR filters


Optimal Filters
Want to find the best fit line: with the smallest maximal error.
Alternation
Theorem Best fit line always attains the 8
Chebyshev
Polynomials maximal error three times with 6
Maximal Error
Locations
alternate signs 4

Remez Exchange 2
Algorithm 2 4 6 8
Determine Polynomial
Example Design
Proof:
FIR Pros and Cons Assume the first maximal deviation from the line is negative as shown.
Summary
MATLAB routines 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 (2015-6729) Optimal FIR: 7 3 / 11


Chebyshev Polynomials

7: Optimal FIR filters P M2


j
Optimal Filters H() = H(e ) = h[0] + 2 1 h[n] cos n
Alternation Theorem
Chebyshev
Polynomials But cos n = Tn (cos ): Chebyshev polynomial of 1st kind
Maximal Error
Locations
Remez Exchange
cos 2 = 2 cos2 1 = T2 (cos ) T2 (x) = 2x2 1
Algorithm cos 3 = 4 cos3 3 cos = T3 (cos ) T3 (x) = 4x3 3x
Determine Polynomial
Example Design
FIR Pros and Cons Recurrence Relation:
Summary
MATLAB routines
Tn+1 (x) = 2xTn (x) Tn1 (x) with T0 (x) = 1, T1 (x) = x
Proof: cos (n + ) + cos (n ) = 2 cos cos n
M
So H() is an 2 order polynomial in cos : alternation theorem applies.
Example: Symmetric lowpass filter of orderM = 4
H(z) = 0.1766z 2 + 0.4015z + 0.2124 + 0.4015z 1 + 0.1766z 2

DSP and Digital Filters (2015-6729) Optimal FIR: 7 4 / 11


Maximal Error Locations

7: Optimal FIR filters


Optimal Filters
Maximal error locations occur either at band 1.2
M=18
Alternation Theorem edges or when dH
d = 0 1
Chebyshev
0.8
Polynomials
P M2

|H|
Maximal Error
Locations H() = h[0] + 2 1 h[n] cos n 0.6

0.4
Remez Exchange
Algorithm
= P (cos ) 0.2
Determine Polynomial
M
Example Design where P (x) is a polynomial of order 2 .
0
0 0.5 1 1.5

2 2.5 3

FIR Pros and Cons


Summary
dH
MATLAB routines
d = P (cos ) sin
M
= 0 at = 0, and at most 2 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):


M
1 zeros of P (x).

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

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


DSP and Digital Filters (2015-6729) Optimal FIR: 7 5 / 11


Remez Exchange Algorithm

7: Optimal FIR filters


Optimal Filters
1. Guess the positions of the M 2 + 2 maximal error frequencies and give
Alternation Theorem
Chebyshev
alternating signs to the errors (e.g. choose evenly spaced ).
Polynomials
Maximal Error 2. Determine the error magnitude, , and the M
2 + 1 coefficients of
Locations
Remez Exchange the polynomial that passes through the maximal error locations.
Algorithm
Determine Polynomial
Example Design
3. Find the local maxima of the
 error function by evaluating
FIR Pros and Cons e() = s() H() d() on a dense set of .
Summary
MATLAB routines
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].

DSP and Digital Filters (2015-6729) Optimal FIR: 7 6 / 11


Remex Step 2: Determine Polynomial

7: Optimal FIR filters


Optimal Filters
For each extremal frequency, i for 1 i M
2 +2
Alternation Theorem
Chebyshev (1)i P M2 (1)i
Polynomials d(i ) = H(i ) + s(i ) = h[0] + 2 n=1 h[n] cos ni + s(i )
Maximal Error
Locations
Remez Exchange
Algorithm Method 1: (Computation time M 3 )

Determine
Polynomial Solve M2 + 2 equations in M
2 + 2 unknowns for h[n] + .
Example Design P M2
FIR Pros and Cons In step 3, evaluate H() = h[0] + 2 n=1 h[n] cos ni
Summary
MATLAB routines
2
Method 2: Dont calculate h[n] explicitly (Computation time M )
1
Q
Multiply equations by ci = j6=i cos i cos j and add:
P M2 +2  P M2 (1)i
 PM
2 +2
i=1 c i h[0] + 2 n=1 h[n] cos n + s(i ) = i=1 ci d(i )
All terms involving h[n] sum to zero leaving
P M2 +2 (1)i ci P M2 +2
i=1 s(i ) = i=1 ci d(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

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

DSP and Digital Filters (2015-6729) Optimal FIR: 7 7 / 11


Example Design

7: Optimal FIR filters


Optimal Filters
Filter Specifications:
Alternation Theorem Bandpass = [0.5, 1], Transition widths: = 0.2
Chebyshev
Polynomials Stopband Attenuation: 25 dB and 15 dB
Maximal Error
Locations Passband Ripple: 0.3 dB
Remez Exchange
Algorithm
Determine Polynomial
Determine gain tolerances for each band:
Example Design 25 dB = 0.056, 0.3 dB = 1 0.034, 15 dB = 0.178
FIR Pros and Cons
Summary
MATLAB routines
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 0 M=36
1
-5
0.8
0.5
-10
|H| (dB)

0.6
|H|

-15 0
0.4 -20
-0.5
0.2 -25
-1
-30
0
0 0.5 1 1.5 2 2.5 3 0 0.5 1 1.5 2 2.5 3 -1 0 1 2

DSP and Digital Filters (2015-6729) Optimal FIR: 7 8 / 11


FIR Pros and Cons

7: Optimal FIR filters


Optimal Filters
Can have linear phase
Alternation Theorem no envelope distortion, all frequencies have the same delay ,
Chebyshev
Polynomials symmetric or antisymmetric: h[n] = h[n]n or h[n]n
Maximal Error
Locations antisymmetric filters have H(ej0 ) = H(ej ) = 0
Remez Exchange
Algorithm
symmetry means you only need M 2 + 1 multiplications
Determine Polynomial to implement the filter.
Example Design
FIR Pros and Cons
Summary Always stable ,
MATLAB routines
Low coefficient sensitivity ,
Optimal design method fast and robust ,
Normally needs higher order than an IIR filter /
Filter order M dB3.5 where is the most rapid transition
atten

Filtering complexity M fs dB atten


3.5 fs = dBatten 2
3.5 fs
fs2 for a given specification in unscaled units.

DSP and Digital Filters (2015-6729) Optimal FIR: 7 9 / 11


Summary

7: Optimal FIR filters


Optimal Filters
Optimal Filters: minimax error criterion
Alternation Theorem
Chebyshev use weight function, s(), to allow different errors
Polynomials
Maximal Error in different frequency bands
Locations
Remez Exchange
symmetric filter has zeros on unit circle or in reciprocal pairs
Algorithm
Determine Polynomial
Response of symmetric filter is a polynomial in cos
Example Design Alternation Theorem: M 2 + 2 maximal errors with alternating signs
FIR Pros and Cons
Summary
Remez Exchange Algorithm (also known as Parks-McLellan Algorithm)
MATLAB routines

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 (2015-6729) Optimal FIR: 7 10 / 11


MATLAB routines

7: Optimal FIR filters


Optimal Filters
firpm optimal FIR filter design
Alternation Theorem
Chebyshev
firpmord estimate require order for firpm
Polynomials cfirpm arbitrary-response filter design
Maximal Error
Locations remez [obsolete] optimal FIR filter design
Remez Exchange
Algorithm
Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2015-6729) 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 8: IIR Filter Transformations
Summary
MATLAB routines

DSP and Digital Filters (2015-6707) IIR Transformations: 8 1 / 10


Continuous Time Filters

8: IIR Filter
Transformations
Classical continuous-time filters optimize tradeoff: 1
N=5

Continuous Time
Filters
passband ripple v stopband ripple v transition width 0.8

0.6

There are explicit formulae for pole/zero positions.

|H|
Bilinear Mapping 0.4
Continuous Time
Filters 2 0.2

Mapping Poles and


e 2 () = H(j)
e
= 1+1 2N
0

Zeros Butterworth: G 0.1 0.2 0.5 1 2


Frequency (rad/s)
5 10

Spectral 1
Transformations
Constantinides Monotonic 0.8

Transformations 0.6
e
G() = 1 12 2N + 38 4N +

|H|
Impulse Invariance 0.4

Summary
MATLAB routines
Maximally flat: 2N 1 derivatives are zero 0.2

0
0.1 0.2 0.5 1 2 5 10

e2
Chebyshev: G () = 2
1
2 ()
Frequency (rad/s)

1+ TN 1

0.8

where polynomial TN (cos x) = cos N x 0.6

|H|
0.4

passband equiripple + very flat at 0.2

e 2 () =
Inverse Chebyshev: G 1 0
0.1 0.2 0.5 1 2
Frequency (rad/s)
5 10

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

0.8

stopband equiripple + very flat at 0 0.6

|H|
0.4

Elliptic: [no nice formula] 0.2

Very steep + equiripple in pass and stop bands 0


0.1 0.2 0.5 1 2
Frequency (rad/s)
5 10

DSP and Digital Filters (2015-6707) IIR Transformations: 8 2 / 10


Bilinear Mapping

+s
8: IIR Filter
Transformations Change variable: z = s s = z1
z+1 : a one-to-one invertible mapping
Continuous Time
Filters
Bilinear Mapping
axis (s) axis (z)
Continuous Time
Filters
Mapping Poles and
axis (s) Unit circle (z)

ej 1 ej 2 ej 2
Zeros
Spectral Proof: z = e s = ej +1 = j 2 j 2 = j tan 2 = j
j
Transformations
e +e
Constantinides
Transformations Left half plane(s) inside of unit circle (z)
Impulse Invariance 2 |(+x)+jy|2
Summary Proof: s = x + jy |z| = |(x)jy|2
MATLAB routines
2 +2x+x2 +y 2 4x
= 2 2x+x2 +y 2 =1+ (x)2 +y 2
x < 0 |z| < 1
Unit circle (s) axis (z)
4 2.5 3
s-plane z-plane
=1 2 =1
3
2.5
1.5
2
1 2
1 0.5
1.5


0 0

-1 -0.5
1
-1
-2
-1.5 0.5
-3 -2
-4 -2.5 0
-4 -2 0 2 4 -2 -1 0 1 2 0 2 4 6 8 10
/

DSP and Digital Filters (2015-6707) IIR Transformations: 8 3 / 10


Continuous Time Filters

8: IIR Filter
Transformations
e
Take H(s) = 1
and choose = 1 2.5

Continuous Time
s2 +0.2s+4 2

Filters
Substitute: s = z1
1.5

[extra zeros at z = 1]

|H|
Bilinear Mapping
z+1 1
Continuous Time
Filters
1
0.5

Mapping Poles and H(z) = 2 0

Zeros z+1 ) +0.2 z+1 +4


( z1 z1 1 2 3 4
Frequency (rad/s)
5 6

Spectral 2.5
=1
Transformations 2
(z+1) 2
Constantinides
Transformations
= (z1) +0.2(z1)(z+1)+4(z+1)2
2 1.5

|H|
Impulse Invariance 1
2
Summary z +2z+1 1+2z +z 1 2
MATLAB routines
= 5.2z 2 +6z+4.8 = 0.19 1+1.15z 1 +0.92z 2
0.5

0
0 0.5 1 1.5 2 2.5 3
(rad/sample)

Frequency response is identical (both magnitude and 3

phase) but with a distorted frequency axis: 2.5

1.5


Frequency mapping: = 2 tan1

1

  0.5

= 2 3 4 5 
0
0 2 4
/
6 8 10

= 1.6 2.2 2.5 2.65 2.75


0
Choosing : Set = tan 21 0
to map 0 0
2
Set = 2fs = T to map low frequencies to themselves

DSP and Digital Filters (2015-6707) IIR Transformations: 8 4 / 10


Mapping Poles and Zeros

8: IIR Filter
Transformations
e
Alternative method: H(s) = 1 2.5

Continuous Time
s2 +0.2s+4 2

Filters
Find the poles and zeros: ps = 0.1 2j 1.5

|H|
Bilinear Mapping 1
Continuous Time
Filters
Map using z = 1+s
1s pz = 0.58 0.77j 0.5

Mapping Poles and 0

Zeros
After the transformation we will always end up with
1 2 3 4
Frequency (rad/s)
5 6

Spectral 2
Transformations
Constantinides
the same number of poles as zeros: 1

Transformations Add extra poles or zeros at z = 1 0


Impulse Invariance
-1
Summary (1+z 1 )2
MATLAB routines H(z) = g (1+(0.580.77j)z1 )(1+(0.58+0.77j)z1 ) -2
-3 -2 -1 0 1 2
s
1+2z 1 +z 2
= g 1+1.15z1 +0.92z2 1 =1

0.5

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

at any convenient pair of mapped


frequencies:
-0.5

e -1

At 0 = 0 s0 = 0 H(s )
0 = 0.25 -1
z
0 1

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

|H|
1

1+2z +z1 2
H(z) = 0.19 1+1.15z 1 +0.92z 2
0.5

0
0 0.5 1 1.5 2 2.5 3
(rad/sample)

DSP and Digital Filters (2015-6707) IIR Transformations: 8 5 / 10


Spectral Transformations

8: IIR Filter
Transformations
We can transform the z-plane to change the cutoff 2
z

Continuous Time
Filters
frequency by substituting 1

z z+
Bilinear Mapping z = 1z
z = 1+z
0

Continuous Time -1
Filters
Mapping Poles and Frequency Mapping: -2
-2 -1 0 1 2
Zeros
j 1+z 1
Spectral If z = e , then z = z 1+z has modulus 1 2

Transformations
z^
= 0.6
Constantinides since the numerator and denominator are 1

Transformations
Impulse Invariance complex conjugates. 0

Summary
MATLAB routines
Hence the unit circle is preserved. -1

ej +
ej = 1+e
-2
-2 -1 0 1 2
j
  1

1+
Some algebra gives: tan 2 = 1 tan 2 0.8

0.6

|H|
0.4

Equivalent to: 0.2


z1 1 1+
s
z s = z+1 s = 1+ s z = 1
s
0
0 0.5 1 1.5
(rad/s)
2 2.5 3

Lowpass Filter example:


1
= 0.6
^ = 0.49
0.8

Inverse Chebyshev 0.6

|H^|
=0.6 0.4

0 = 2 = 1.57 0 = 0.49 0.2

0
0 0.5 1 1.5 2 2.5 3
^ (rad/s)

DSP and Digital Filters (2015-6707) IIR Transformations: 8 6 / 10


Constantinides Transformations

Transform any lowpass filter with cutoff frequency 0 to:


Target Substitute Parameters

z1 sin( 0 2 1 )
Lowpass z 1 = 1 z 1 = +
sin( 0 2 1 )
<1
0 + 1
1 z1 + cos( )
Highpass z = 1+z1 = 2
0 1
cos( 2 )
> 1

2 +1
1 (1)2
z 1 +(+1)
z 2 cos(
)
Bandpass z = (+1)2z1 +(1)z2 =
2
2 1
cos( )
1 <
<2  2

= cot 2
2
1
tan 0
2

+
1 (1)2
z 1 +(+1)
z 2 cos( 2 2 1 )
Bandstop z = (+1)2
z 1 +(1)
z 2 =

cos( 2 2 1 )
1
2 2
1
 0

= tan 2 tan 2

Bandpass and bandstop transformations are quadratic and so will double the order:
1 1
Lowpass Bandpass
|H^|
|H|

0.5 0.5

0 0
-3 -2 -1 0 1 2 3 -3 -2 -1 0 1 2 3
(rad/s) ^ (rad/s)
DSP and Digital Filters (2015-6707) IIR Transformations: 8 7 / 10
Impulse Invariance

8: IIR Filter
Transformations
Bilinear transform works well for a lowpass filter but the non-linear
Continuous Time
Filters
compression of the frequency distorts any other response.
Bilinear Mapping L 1 sample Z
Continuous Time
e
Alternative method: H(s) h(t) h[n] = T h(nT ) H(z)
Filters
e e PN gi
Mapping Poles and Express H(s) as a sum of partial fractions H(s) = i=1 se pi
Zeros
= u(t) P N pi t
Spectral
Transformations
Impulse response is h(t) i=1 gi e
H(z) PN
Constantinides
Transformations Digital filter T = i=1 1epgiiT z1 has identical impulse response
Impulse Invariance
1
Summary
MATLAB routines
Poles of H(z) are pi = epi T (where T = fs is sampling period)
Zeros do not map in a simple way
Properties:
, Impulse response correct. , No distortion of frequency axis.
/ Frequency response is aliased.
Example: Standard telephone filter - 300 to 3400 Hz bandpass
1 1 1
0.8
0.6
|H|

|H|

|H|
0.5 0.5
Bilinear (f s = 8 kHz) 0.4
Analog Filter Matched at 3.4 kHz Impulse Invariance (f s = 8 kHz)
0.2
0 0
0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 0 0.5 1 1.5 2 2.5 3
Frequency (krad/s) (rad/sample) (rad/sample)

DSP and Digital Filters (2015-6707) IIR Transformations: 8 8 / 10


Summary

8: IIR Filter
Transformations
Classical filters have optimal tradeoffs in continuous time domain
Continuous Time
Filters
Order transition width pass ripple stop ripple
Bilinear Mapping Monotonic passband and/or stopband
Continuous Time
Filters
Mapping Poles and Bilinear mapping
Zeros
Spectral Exact preservation of frequency response (mag + phase)
Transformations
Constantinides non-linear frequency axis distortion
Transformations
Impulse Invariance can choose to map 0 0 for one specific frequency
Summary
MATLAB routines 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 (2015-6707) IIR Transformations: 8 9 / 10


MATLAB routines

8: IIR Filter
Transformations bilinear Bilinear mapping
Continuous Time
Filters impinvar Impulse invariance
Bilinear Mapping
Continuous Time
butter Analog or digital
Filters
Mapping Poles and
butterord Butterworth filter
Zeros
Spectral
cheby1 Analog or digital
Transformations
Constantinides
cheby1ord Chebyshev filter
Transformations cheby2 Analog or digital
Impulse Invariance
Summary cheby2ord Inverse Chebyshev filter
MATLAB routines
ellip Analog or digital
ellipord Elliptic filter

DSP and Digital Filters (2015-6707) 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 9: Optimal IIR Design
MATLAB routines

DSP and Digital Filters (2015-7197) Optimal IIR: 9 1 / 11


Error choices

9: Optimal IIR
j B(ej )
Design We want to find a filter H(e ) = that approximates a target
A(ej )
Error choices
Linear Least Squares response D(). Assume A is order N and B is order M .
Frequency Sampling
Iterative Solution
Newton-Raphson
Two possible error measures:
Magnitude-only  
B(ej )
Specification
Hilbert Relations
Solution Error: ES () = WS () A(ej ) D()
Magnitude Phase
Relation j j

Summary Equation Error: EE () = WE () B(e ) D()A(e )
MATLAB routines
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.
WS ()
However if WE () = |A(ej )| , then |EE ()| = |ES ()|

DSP and Digital Filters (2015-7197) Optimal IIR: 9 2 / 11


Linear Least Squares

9: Optimal IIR
Design
Overdetermined set of equations Ax = b (#equations > #unknowns)
Error choices

Linear Least
Squares
We want to minimize ||e||2 where e = Ax b
Frequency Sampling
2 T T T T

Iterative Solution ||e|| = e e = x A b (Ax b)
Newton-Raphson
Magnitude-only
Specification
Differentiate with respect to x:
T T T T T T
 
Hilbert Relations d e e = dx A (Ax b) + x A b Adx
Magnitude Phase
Relation [since d (uv) = du v + u dv]
Summary
MATLAB routines = 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
2 T
1 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 (2015-7197) Optimal IIR: 9 3 / 11


Frequency Sampling

9: Optimal IIR j j

Design For every we want: 
0 = W () B(e ) D()A(e  ) 
Error choices PM jm
D() 1 + N jn
P
Linear Least Squares = W () m=0 b[m]e n=1 a[n]e
Frequency

 
Sampling
a
u()T v()T

Iterative Solution = W ()D()
Newton-Raphson b 
Magnitude-only T j j2 jN

Specification where u() = W ()D() e e e
Hilbert Relations T j j2 jM
 
Magnitude Phase v() = W () 1 e e e
Relation
Summary
[with K M +N +1

MATLAB routines
Choose K valuesof , 1 K 2 ]
T T
 a
U V =d [K equations, M + N + 1 unkowns]
 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)
=
UT VT b (d)

DSP and Digital Filters (2015-7197) Optimal IIR: 9 4 / 11


Iterative Solution

9: Optimal IIR
Design
Least squares solution minimizes the EE rather than ES .
Error choices
WS ()
Linear Least Squares However EE = ES if WE () = |A(ej )| .
Frequency Sampling
Iterative Solution
Newton-Raphson We can use an iterative solution technique:
Magnitude-only
Specification
Hilbert Relations
1 Select K frequencies {k } (e.g. uniformly spaced)
Magnitude Phase
Relation 2 Initialize WE (k ) = WS (k )
Summary
MATLAB routines
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
WS (k )
5 Update weights: WE (k ) =
|A(ejk )|
6 Return to step 3 until convergence

But for faster convergence use Newton-Raphson . . .

DSP and Digital Filters (2015-7197) Optimal IIR: 9 5 / 11


Newton-Raphson

9: Optimal IIR
Design
Newton: To solve f (x) = 0 given an initial guess x0 , we write
Error choices
Linear Least Squares
f (x) f (x0 ) + (x x0 )f (x0 ) x = x0 ff(x0)
(x0 )
Frequency Sampling Converges very rapidly once x0 is close to the solution
Iterative Solution
Newton-Raphson j
Magnitude-only So for each k ,we can write
 (omitting the and e arguments)
Specification
Hilbert Relations E S WS B 0
A0 D + WS
A0 (B B 0 ) WS B0
A20
(A A0 )
Magnitude Phase  
Relation
Summary =WA0
S
B 0 A 0 D + B B 0 B0
A0 (A 1) B0
A0 + B0
MATLAB routines

From which we get a linear equation for each k :


  a   
B0 T T B0
DA0 u v = W A 0 D + A0 B0
b
where W = W A0 and, as before, un () = W ()D()e
S jn

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 (2015-7197) Optimal IIR: 9 6 / 11


Magnitude-only Specification

9: Optimal IIR
Design
If the filter specification only dictates the target magnitude: |D()|, we
Error choices need to select the target phase.
Linear Least Squares
Frequency Sampling
Iterative Solution Solution:
Newton-Raphson
Magnitude-only
Make an initial guess of the phase and then at each iteration
j
Specification update D() = B(e )
Hilbert Relations A(e ) .
j
Magnitude Phase
Relation
Summary
Initial Guess:
MATLAB routines 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
ln H(e ) = ln |H()| + H(ej ) cot 2
j

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 (2015-7197) Optimal IIR: 9 7 / 11


Hilbert Relations

9: Optimal IIR
Design
We define t[n] = u[n 1] u[1 n] t[n]

Error choices z 1 z 1+z 1


Linear Least Squares
T (z) = 1z 1 1z = 1z 1
0


Frequency Sampling j 1+ej ej 2 +ej 2
Iterative Solution T (e ) = 1ej = j 2 j 2
Newton-Raphson
e e h[n]

2 cos
Magnitude-only
Specification
= 2j sin 2 = j cot 2
2
Hilbert Relations 0

Magnitude Phase
Relation
h[n]even/odd parts: he [n] = 21 (h[n] + h[n]) h[-n]
1
Summary h o [n] = 2 (h[n] h[n])
MATLAB routines
so H(ej ) = He (ej )

0

H(ej ) = jHo (ej ) he[n]

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


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

ho[n]

Hence, for causal h[n]: 0


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

= H() + H(ej ) cot 2

DSP and Digital Filters (2015-7197) Optimal IIR: 9 8 / 11


Magnitude Phase Relation

9: Optimal IIR
Q
Q
(1qm z1 ) 1
Design
Error choices
Given H(z) = g (1pn z1 ) 0.5

Linear Least Squares 0


1
P 
Frequency Sampling ln H(z) = ln(g) + ln 1 qmz -0.5
Iterative Solution
ln 1 pn z 1
P
Newton-Raphson -1

Magnitude-only -1.5 -1 -0.5 0 0.5 1

Specification = ln |H(z)| + jH(z) z

Hilbert Relations 0.4

Magnitude
Phase Relation
Taylor Series:  0.3

a2 2 a3 3

ln|H|
1 1
Summary ln 1 az = az 2 z 3 z . . . 0.2

MATLAB routines 0.1

causal and stable provided |a| < 1 -3 -2 -1 0


(rad/s)
1 2 3

So, if H(z) is minimum phase (all pn and qm inside 20

unit circle) then ln H(z) is the z-transform of a 10

cot( )
0

stable causal sequence and: -10


-20

-3 -2 -1 0 1 2 3
(rad/s)

j
j

H(e ) = ln H(e ) cot 2
ln H(e ) = ln |g| + H(e ) cot 2
j
j 1
0.5

H (rad)
0
1
107z -0.5

Example: H(z) = 10040z 1 11z 2 +68z 3


-1

-3 -2 -1 0 1 2 3
(rad/s)

Note symmetric dead band in cot 2 for || <

DSP and Digital Filters (2015-7197) Optimal IIR: 9 9 / 11


Summary

9: Optimal IIR
Design
Want to minimize solution
 j error, ES , but
 EE gives linear equations:
)
Error choices
Linear Least Squares
ES () = WS () B(eA(e ) D()
j
Frequency Sampling
j j

Iterative Solution EE () = WE () B(e ) D()A(e )
Newton-Raphson
Magnitude-only
Specification
use W () to weight errors at different .
Hilbert Relations
Magnitude Phase Linear least squares: solution to overdetermined Ax = b
Relation
T
1 T
Summary Least squares error: x = A A A b
MATLAB routines
Closed form solution: least squares EE at {k }
WS ()
use WE () = |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 (2015-7197) Optimal IIR: 9 10 / 11


MATLAB routines

9: Optimal IIR
Design invfreqz IIR design for complex response
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 (2015-7197) 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 10: Digital Filter Structures
Allpass Filters
Lattice Stage
Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Lattice Example
Numerator
Summary
MATLAB routines

DSP and Digital Filters (2015-7227) Structures: 10 1 / 19


Direct Forms

10: Digital Filter


Structures Filter: H(z) = B(z)
A(z) with input x[n] and output y[n]
Direct Forms
Transposition PM PN
State Space y[n] = k=0 b[k]x[n k] k=1 a[k]y[n k]
Precision Issues
Coefficient Sensitivity
Cascaded Biquads
Direct forms use coefficients a[k] and b[k] directly
Pole-zero
Pairing/Ordering Direct Form 1:
Linear Phase
Hardware Direct implementation of difference equation
Implementation 1
Allpass Filters
Can view as B(z) followed by A(z)
Lattice Stage
Example
A(z) D(z)
Direct Form II:
1
Allpass Lattice Implements A(z) followed by B(z)
Lattice Filter
Lattice Example Saves on delays (= storage)
Lattice Example
Numerator
Summary
MATLAB routines

DSP and Digital Filters (2015-7227) Structures: 10 2 / 19


Transposition

10: Digital Filter


Structures
Can convert any block diagram into an equivalent transposed form:
Direct Forms Reverse direction of each interconnection
Transposition
State Space Reverse direction of each multiplier
Precision Issues
Coefficient Sensitivity
Change junctions to adders and vice-versa
Cascaded Biquads Interchange the input and output signals
Pole-zero
Pairing/Ordering
Linear Phase Example:
Hardware
Implementation
Direct form II Direct Form IIt
Allpass Filters Would normally be drawn with input on the left
Lattice Stage
Example
A(z) D(z) Note: A valid block diagram must never have any feedback loops that dont
Allpass Lattice
Lattice Filter
go through a delay (z 1 block).
Lattice Example
Lattice Example
Numerator
Summary
MATLAB routines

DSP and Digital Filters (2015-7227) Structures: 10 3 / 19


State Space

10: Digital Filter


Structures
v[n] is a vector of delay element outputs
Direct Forms
Transposition Can write: v[n + 1] = Pv[n] + qx[n]
State Space
Precision Issues y[n] = rT v[n] + sx[n]
Coefficient Sensitivity
T

Cascaded Biquads P, q, r , s is the state-space
Pole-zero
Pairing/Ordering representation of the filter structure.
Linear Phase
Hardware
Implementation The transfer function is given by:
Allpass Filters
Lattice Stage B(z) det(zIP+qrT )
Example
H(z) = A(z) = det(zIP) +s1
A(z) D(z)
T
Allpass Lattice The transposed form has P P and q r same H(z)
Lattice Filter
Lattice Example
Lattice Example Example: Direct Form IIt
Numerator    
Summary
a[1] 1 b[1] b[0]a[1]
MATLAB routines P= q=
a[2] 0 b[2] b[0]a[2]
T

r = 1 0 s = b[0]
b[0]z 2 +b[1]z+b[2]
From which H(z) = z 2 +a[1]z+a[2]

DSP and Digital Filters (2015-7227) Structures: 10 4 / 19


[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 0 1 r
1 = .
0 A A q I 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] zV = PV + qX


ztransform
y[n] = rT v[n] + sx[n] Y = rT V + sX

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

DSP and Digital Filters (2015-7227) Structures: 10 note 1 of slide 4


Precision Issues

10: Digital Filter


Structures
If all computations were exact, it would not make any difference which of
Direct Forms the equivalent structures was used. However ...
Transposition
State Space
Precision Issues Coefficient precision
Coefficient Sensitivity Coefficients are stored to finite precision and so are not exact.
Cascaded Biquads
Pole-zero The filter actually implemented is therefore incorrect.
Pairing/Ordering
Linear Phase
Hardware
Arithmetic precision
Implementation
Allpass Filters
Arithmetic calculations are not exact.
Lattice Stage Worst case for arithmetic errors is when calculating the
Example
A(z) D(z) difference between two similar values:
Allpass Lattice
Lattice Filter
1.23456789 1.23455678 = 0.00001111: 9 s.f. 4 s.f.
Lattice Example Arithmetic errors introduce noise that is then filtered by the transfer
Lattice Example
Numerator function between the point of noise creation and the output.
Summary
MATLAB routines

DSP and Digital Filters (2015-7227) Structures: 10 5 / 19


Coefficient Sensitivity

10: Digital Filter


Structures
The roots of high order polynomials can be very sensitive to small changes
Direct Forms in coefficient values.
Transposition
State Space
Precision Issues Wilkinsons polynomial: (famous example)
Coefficient
Sensitivity
Q20
f (x) = n=1 (x n) = x20 210x19 + 20615x18 . . .
Cascaded Biquads
Pole-zero
Pairing/Ordering has roots well separated on the real axis.
Linear Phase
Hardware
Implementation Multiplying the coefficient of x19 by 1.000001 moves the roots a lot.
Allpass Filters
Lattice Stage Speaking for myself I regard it as the most traumatic experience in
Example
A(z) D(z) my career as a numerical analyst, James Wilkinson 1984
Allpass Lattice
Lattice Filter
Lattice Example 5 5
Lattice Example
Numerator
0 0
Summary
MATLAB routines
-5 -5

0 5 10 15 20 25 0 5 10 15 20 25

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

DSP and Digital Filters (2015-7227) Structures: 10 6 / 19


Cascaded Biquads

10: Digital Filter


Structures
Avoid high order polynomials by factorizing into quadratic terms:
Direct Forms
Transposition
Q
State Space B(z) Q
(1+bk,1 z1 +bk,2 z2 ) QK 1+bk,1 z 1 +bk,2 z 2
Precision Issues
A(z) = g (1+ak,1 z1 +ak,2 z2 ) = g k=1 1+ak,1 z 1 +ak,2 z 2
Coefficient Sensitivity
Cascaded Biquads
Pole-zero  M   N 
Pairing/Ordering
Linear Phase
where K = max 2 , 2 .
Hardware
Implementation 1+bk,1 z 1 +bk,2 z 2
Allpass Filters
The term 1+ak,1 z 1 +ak,2 z 2 is a biquad (bi-quadratic section).
Lattice Stage
Example
A(z) D(z)
We need to choose:
Allpass Lattice (a) which poles to pair with which zeros in each biquad
Lattice Filter
Lattice Example (b) how to order the biquads
Lattice Example
Numerator
Summary
MATLAB routines

Direct Form II
Transposed

DSP and Digital Filters (2015-7227) Structures: 10 7 / 19


Pole-zero Pairing/Ordering

10: Digital Filter


Structures
Example: Elliptic lowpass filter 1

Direct Forms 0.5


Transposition 2 pole pairs and 2 zero pairs 0
State Space
Precision Issues need 2 biquads -0.5
Coefficient Sensitivity -1
Cascaded Biquads Noise introduced in one biquad is amplified -1 0 1
Pole-zero z
Pairing/Ordering by all the subsequent ones:
Linear Phase
Hardware
Implementation Make the peak gain of each biquad as small as possible
Allpass Filters
Lattice Stage
Pair poles with nearest zeros to get lowest peak gain
Example
A(z) D(z)
begin with the pole nearest the unit circle
Allpass Lattice Pairing with farthest zeros gives higher peak biquad gain
Lattice Filter
Lattice Example
Lattice Example
Poles near the unit circle have the highest peaks and introduce most
Numerator noise so place them last in the chain
Summary
MATLAB routines 20 Nearest 20 Farthest
Gain (dB)

Gain (dB)

0 0

-20 -20

-40 -40
0 0.5 1 1.5 2 2.5 3 0 0.5 1 1.5 2 2.5 3

DSP and Digital Filters (2015-7227) Structures: 10 8 / 19


Linear Phase

10: Digital Filter


Structures
Implementation can take advantage of any symmetry in the coefficients.
Direct Forms
Transposition Linear phase filters are always FIR and have symmetric (or, more rarely,
State Space
Precision Issues antisymmetric) coefficients.
Coefficient Sensitivity PM
Cascaded Biquads H(z) = m=0 h[m]z m h[M m] = h[m]
Pole-zero
Pairing/Ordering  M  M P M2 1
Linear Phase
=h 2 z 2 + m=0 h[m] z m
+z mM

[m even]
Hardware
Implementation
Allpass Filters
Lattice Stage
For M even, we only need M
2 + 1 multiplies instead of M + 1.
Example We need M additions in each case.
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Lattice Example
Numerator
Summary
MATLAB routines

M = 6:
M +1
For M odd (no central coefficient), we need 2 multiplies.

DSP and Digital Filters (2015-7227) Structures: 10 9 / 19


Hardware Implementation

10: Digital Filter


Structures
Software Implementation:
Direct Forms All that matters is the total number of multiplies and adds
Transposition
State Space
Precision Issues Hardware Implementation:
Coefficient Sensitivity Delay elements (z 1 ) represent storage registers
Cascaded Biquads
Pole-zero The maximum clock speed is limited by the number of sequential
Pairing/Ordering
Linear Phase operations between registers
Hardware
Implementation
Example: Symmetric Linear Phase Filter
Allpass Filters
Lattice Stage
Example Direct form: Maximum sequential delay = 4a + m
A(z) D(z)
Allpass Lattice Transpose form: Maximum sequential delay = a + m ,
Lattice Filter
Lattice Example
a and m are the delays of adder and multiplier respectively
Lattice Example
Numerator
Summary
MATLAB routines

DSP and Digital Filters (2015-7227) Structures: 10 10 / 19


Allpass Filters

10: Digital Filter


Structures
Allpass filters have mirror image numerator and denominator coefficients:
Direct Forms
Transposition b[n] = a[N n] B(z) = z N A(z 1 )
State Space
Precision Issues j
Coefficient Sensitivity
H(e ) 1

Cascaded Biquads
Pole-zero There are several efficient structures, e.g.
Pairing/Ordering
Linear Phase a[1]+z 1
Hardware First Order: H(z) = 1+a[1]z 1
Implementation
Allpass Filters
a[2]+a[1]z 1 +z 2
Lattice Stage Second Order: H(z) = 1+a[1]z 1 +a[2]z 2
Example
A(z) D(z)
Allpass Lattice
Lattice Filter
Lattice Example
Lattice Example
Numerator
Summary
MATLAB routines

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

DSP and Digital Filters (2015-7227) Structures: 10 11 / 19


Lattice Stage

10: Digital Filter z N A(z 1 )


Structures Suppose G is allpass: G(z) = A(z)
Direct Forms
Transposition
State Space V (z) = X(z) kGz 1 V (z)
Precision Issues
1
Coefficient Sensitivity
Cascaded Biquads
V (z) = 1+kGz 1 X(z)
Pole-zero
Pairing/Ordering 1 k+z 1 G
Linear Phase Y (z) = kV (z) + Gz V (z) = 1+kGz 1 X(z)
Hardware
Implementation
Y (z) kA(z)+z N 1 A(z 1 ) z (N +1) D(z 1 )
Allpass Filters
X(z) = A(z)+kz N 1 A(z 1 )
, D(z)
Lattice Stage
Example
A(z) D(z) Obtaining {d[n]} from {a[n]}:
Allpass Lattice

Lattice Filter 1
n=0
Lattice Example
Lattice Example d[n] = a[n] + ka[N + 1 n] 1 n N
Numerator
k n=N +1

Summary
MATLAB routines

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


d[n]kd[N +1n]
k = d[N + 1] a[n] = 1k2
Y (z)
If G(z) is stable then X(z) is stable if and only if |k| < 1 (see note)

DSP and Digital Filters (2015-7227) Structures: 10 12 / 19


[Proof of Stability Criterion]

Y (z) k+z 1 G(z)


We want to show that if G(z) is a stable allpass filter then X(z)
= 1+kz 1 G(z)
is stable if and only if
|k| < 1.

We make use of a property of allpass filters (proved in a note in lecture 5) that if G(z) is a stable allpass
filter, then |G(z)| T 1 according to whether |z| S 1.

If z is a root of the denominator 1 + kz 1 G(z), then


kz 1 G(z) = 1
|k| |z 1 | |G(z)| = 1
|z|
|k| =
|G(z)|
|z|
It follows from the previously stated property of G(z) that |z| S 1 |G(z)|
S 1 |k| S 1.

DSP and Digital Filters (2015-7227) Structures: 10 note 1 of slide 12


Example A(z) D(z)

10: Digital Filter


Structures
Suppose N = 3, k = 0.5 and
Direct Forms A(z) = 1 + 4z 1 6z 2 + 10z 3
Transposition
State Space
Precision Issues
Coefficient Sensitivity
Cascaded Biquads A(z) D(z)
Pole-zero
Pairing/Ordering z0 z 1 z 2 z 3 z 4
Linear Phase
Hardware
Implementation
A(z) 1 4 6 10
Allpass Filters z 4 A(z 1 ) 10 6 4 1
Lattice Stage
Example D(z) = A(z) + kz 4 A(z 1 ) 1 9 9 12 0.5
A(z) D(z)
Allpass Lattice
Lattice Filter
D(z) A(z)
Lattice Example z0 z 1 z 2 z 3 z 4
Lattice Example
Numerator D(z) 1 9 9 12 0.5
Summary
MATLAB routines k = d[N + 1] 0.5
z 4 D(z 1 ) 0.5 12 9 9 1
D(z) kz 4 D(z 1 ) 0.75 3 4.5 7.5 0
D(z)kz 4 D(z 1 )
A(z) = 1k2 1 4 6 10 0

DSP and Digital Filters (2015-7227) Structures: 10 13 / 19


Allpass Lattice

10: Digital Filter z M A(z 1 )


Structures We can implement any allpass filter H(z) = A(z) as a lattice filter
Direct Forms
Transposition with M stages:
State Space
Precision Issues
Coefficient Sensitivity
Initialize AM (z) = A(z)
Cascaded Biquads Repeat for m = M : 1 : 1
Pole-zero
Pairing/Ordering
Linear Phase
k[m] = am [m]
Hardware
Implementation am [n]k[m]am [mn]
Allpass Filters
am1 [n] = 1k2 [m] for 0 n m 1
Lattice Stage
Example Am (z)k[m]z m Am (z 1 )
A(z) D(z) equivalently Am1 (z) = 1k2 [m]
Allpass Lattice
Lattice Filter
Lattice Example
Lattice Example
Numerator A(z) is stable iff |k[m]| < 1 for all m (good stability test)
Summary
MATLAB routines

DSP and Digital Filters (2015-7227) Structures: 10 14 / 19


Lattice Filter

Vm (z) z m Am (z 1 )
Label outputs um [n] and vm [n] and define Hm (z) = Um (z) = Am (z)

From earlier slide:


Um1 (z) 1 Am1 (z) Am1 (z)
Um (z) = 1+k[m]z 1 H m1 (z)
= Am1 (z)+k[m]z m Am1 (z 1 ) = Am (z)
Hence:
Um (z) Am (z) Vm (z) Um (z) Vm (z) z m Am (z 1 )
X(z) = A(z) and X(z) = X(z) Um (z) = A(z)

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

DSP and Digital Filters (2015-7227) Structures: 10 15 / 19


Lattice Example

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


[1, 0.2, 0.23]0.2[0.2, 0.23, 0.2]
k[3] = 0.2 a2 [ ] = 10.22 = [1, 0.256, 0.281]
[1, 0.256]+0.281[0.281, 0.256]
k[2] = 0.281 a1 [ ] = 10.2812 = [1, 0.357]
k[1] = 0.357 a0 [ ] = 1
V0 (z) 1 V1 (z) 0.357+z 1
X(z) = 1+0.2z 0.23z 2 +0.2z 3
1 X(z) = 1+0.2z 1 0.23z 2 +0.2z 3

V2 (z) 0.281+0.256z 1 +z 2 V3 (z) 0.20.23z 1 +0.2z 2 +z 3


X(z) = 1+0.2z 1 0.23z 2 +0.2z 3 X(z) = 1+0.2z 1 0.23z 2 +0.2z 3
Vm (z) B(z)
Add together multiples of X(z) to create an arbitrary 1+0.2z 1 0.23z 2 +0.2z 3

DSP and Digital Filters (2015-7227) Structures: 10 16 / 19


Lattice Example Numerator

PM
Form a new output signal as w[n] = m=0 cm vm [n]
PM B(z)
W (z) = m=0 cm Vm (z) = 1+0.2z1 0.23z 2 +0.2z 3 X(z)

V0 (z) 1 V1 (z) 0.357+z 1


X(z) = 1+0.2z 0.23z 2 +0.2z 3
1 X(z) = 1+0.2z 1 0.23z 2 +0.2z 3

V2 (z) 0.281+0.256z +z 1 2 V3 (z) 0.20.23z +0.2z +z 1 2 3


= 1+0.2z
X(z) 1 0.23z 2 +0.2z 3 X(z) = 1+0.2z 1 0.23z 2 +0.2z 3

b[0] 1 0.357 0.281 0.2 c0
b[1] 0 1 0.256 0.23 c1
We have =
b[2] 0 0 1 0.2 c2
b[3] 0 0 0 1 c3
1
c0 1 0.357 0.281 0.2 b[0]
c1 0 1 0.256 0.23 b[1]
Hence choose cm as =
c2 0 0 1 0.2 b[2]
c3 0 0 0 1 b[3]

DSP and Digital Filters (2015-7227) Structures: 10 17 / 19


Summary

10: Digital Filter


Structures
Filter block diagrams
Direct Forms Direct forms
Transposition
State Space Transposition
Precision Issues
Coefficient Sensitivity
State space representation
Cascaded Biquads
Pole-zero Precision issues: coefficient error, arithmetic error
Pairing/Ordering
Linear Phase cascaded biquads
Hardware
Implementation
Allpass Filters
Allpass filters
Lattice Stage first and second order sections
Example
A(z) D(z)
Allpass Lattice Lattice filters
Lattice Filter
Lattice Example
Arbitrary allpass response
Lattice Example Arbitrary IIR response by summing intermediate outputs
Numerator
Summary
MATLAB routines
For further details see Mitra: 8.

DSP and Digital Filters (2015-7227) Structures: 10 18 / 19


MATLAB routines

10: Digital Filter


b(z 1)
k 1prkkz1
P
Structures residuez a(z 1 )
Direct Forms
Transposition b(z 1) Q b0,l +b1,l z1 +b2,l z2
State Space
tf2sos,sos2tf a(z 1 ) l 1+a1,l z 1 +a2,l z 2
Precision Issues Q b0,l +b1,l z1 +b2,l z2
Coefficient Sensitivity zp2sos,sos2zp {zm , pk , g}
Cascaded Biquads (l 1+a1,l z1 +a2,l z2

Pole-zero x = Ax + Bu
Pairing/Ordering zp2ss,ss2zp {zm , pk , g}
Linear Phase
Hardware
y = Cx + Du
Implementation
(
Allpass Filters b(z 1) x = Ax + Bu
Lattice Stage tf2ss,ss2tf
a(z 1 )
Example y = Cx + Du
A(z) D(z)
Allpass Lattice poly poly(A) = det (zIA)
Lattice Filter
Lattice Example
Lattice Example
Numerator
Summary
MATLAB routines

DSP and Digital Filters (2015-7227) Structures: 10 19 / 19


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

DSP and Digital Filters (2015-6738) Multirate: 11 1 / 14


Multirate Systems

11: Multirate Systems


Multirate Systems
Multirate systems include more than one sample rate
Building blocks
Resampling Cascades Why bother?:
Noble Identities
Noble Identities Proof
Upsampled
May need to change the sample rate
z-transform
Downsampled
e.g. Audio sample rates include 32, 44.1, 48, 96 kHz
z-transform
Downsampled Can relax analog or digital filter requirements
Spectrum
Power Spectral e.g. Audio DAC increases sample rate so that the reconstruction filter
Density
Perfect
can have a more gradual cutoff
Reconstruction
Commutators Reduce computational complexity
Summary fs
MATLAB routines FIR filter length f where f is width of transition band
Lower fs shorter filter + fewer samples computation fs2

DSP and Digital Filters (2015-6738) Multirate: 11 2 / 14


Building blocks

11: Multirate Systems


Multirate Systems
Building blocks
Downsample y[m] = x[Km]
Resampling Cascades (  
n
Noble Identities u K K|n
Noble Identities Proof Upsample v[n] =
Upsampled
z-transform
0 else
Downsampled
z-transform
Downsampled
Example:
Spectrum Downsample by 3 then upsample by 4
Power Spectral
Density w[n] x[m] y[r]
Perfect
Reconstruction
Commutators 0 0 0
Summary
MATLAB routines

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 (2015-6738) Multirate: 11 3 / 14


Resampling Cascades

11: Multirate Systems


Multirate Systems
Building blocks
Successive downsamplers or up-
Resampling
Cascades samplers can be combined
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Upsampling can be exactly inverted
Downsampled
z-transform
Downsampled
Spectrum Downsampling destroys information
Power Spectral
Density permanently uninvertible
Perfect
Reconstruction
Commutators
Summary Resampling can be interchanged
MATLAB routines
iff P and Q are coprime (surprising!)
h i h i
1 P
Proof: Left side: y[n] = w Qn =x Qn if Q | n else y[n] = 0.
h i
P
Right side: v[n] = u [P n] = x Qn if Q | P n.
But {Q | P n Q | n} iff P and Q are coprime.
[Note: a | b means a divides into b exactly]

DSP and Digital Filters (2015-6738) Multirate: 11 4 / 14


Noble Identities

11: Multirate Systems


Multirate Systems
Building blocks
Resampling Cascades
Resamplers commute with addi-
Noble Identities tion and multiplication
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform Delays must be multiplied by the
Downsampled
Spectrum resampling ratio
Power Spectral
Density
Perfect
Reconstruction Noble identities:
Commutators
Summary Exchange resamplers and filters
MATLAB routines

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 (2015-6738) Multirate: 11 5 / 14


Noble Identities Proof

11: Multirate Systems


Multirate Systems
Define hQ [n] to be the
Building blocks impulse response of H(z Q ).
Resampling Cascades
Noble Identities Assume that h[r] is of length M + 1 so that hQ [n] is of length QM + 1.
Noble Identities
Proof We know that hQ [n] = 0 except when Q | n and that h[r] = hQ [Qr].
Upsampled
z-transform PQM
Downsampled w[r] = v[Qr] = s=0 hQ [s]x[Qr s]
z-transform
= M
P PM
Downsampled
Spectrum m=0 h Q [Qm]x[Qr Qm] = m=0 h[m]x[Q(r m)]
PM
Power Spectral
Density
= m=0 h[m]u[r m] = y[r] ,
Perfect
Reconstruction
Commutators Upsampled Noble Identity:
Summary
MATLAB routines 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]
If Q | n = Qr, then w[Qr] = M
P
h[m]v[Qr Qm]
PM m=0
= m=0 h[m]x[r m] = u[r] = y[Qr] ,

DSP and Digital Filters (2015-6738) Multirate: 11 6 / 14


Upsampled z-transform

11: Multirate Systems n n n


P P
Multirate Systems
V (z) = n v[n]z = n:K|n u[ K ]z
Building blocks
u[m]z Km = U (z K )
P
Resampling Cascades = m
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled Spectrum: V (ej ) = U (ejK )
z-transform
Downsampled Spectrum is horizontally shrunk and replicated K times.
Spectrum 1
Power Spectral Total energy unchanged; power (= energy/sample) multiplied by K
Density
Perfect
Upsampling normally followed by a LP filter to remove images.
Reconstruction
Commutators Example:
Summary
MATLAB routines K = 3: three images of the original spectrum in all.j 2
1 j 2 1
R R
Energy unchanged: 2 U (e ) d = 2
V (e ) d
1 1

0.5 0.5

0 0
-2 0 2 -2 0 2

DSP and Digital Filters (2015-6738) Multirate: 11 7 / 14


Downsampled z-transform

11: Multirate Systems 1


PK1 j2kn
Multirate Systems Define cK [n] = K|n [n] = K k=0 e
K
Building blocks (
Resampling Cascades
Noble Identities
x[n] K | n
Noble Identities Proof
Now define xK [n] = = cK [n]x[n]
Upsampled 0 Kn
z-transform P PK1 j2kn
1
XK (z) = n xK [n]z n = K x[n]z n
P
k=0 e
Downsampled K
z-transform n
 j2k n
Downsampled PK1 P PK1
1 1 j2k
Spectrum = K k=0 n x[n] e K z = K k=0 X(e K z)
Power Spectral
Density
Perfect
Reconstruction From previous slide:
Commutators
Summary
MATLAB routines
XK (z) = Y (z K )
1 1
PK1 j2k 1
Y (z) = XK (z K ) = K k=0 X(e K zK)
Frequency Spectrum:
PK1 j(2k)
j 1
Y (e ) = K  k=0 X(e K ) 
j j 2 j 4
1 K K K K
=K X(e ) + X(e
K ) + X(e ) +
Average of K aliased versions, each expanded in by a factor of K.
Downsampling is normally preceded by a LP filter to prevent aliasing.

DSP and Digital Filters (2015-6738) Multirate: 11 8 / 14


Downsampled Spectrum

11: Multirate Systems PK1 j(2k)


j 1
Multirate Systems Y (e ) = K k=0 X(e K )
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof Example 1:
Upsampled 1 1
z-transform K=3
Downsampled

z-transform Not quite limited to K 0.5 0.5

Downsampled
Spectrum Shaded region shows aliasing 0
-2 0

2
0
-2 0

2
Power Spectral
1 j 2 1 1 X(ej ) 2 d
Density
R R
Perfect
Energy decreases: 2 Y (e ) d

K 2
Reconstruction
Commutators Example 2:
Summary
1 1
MATLAB routines K=3

Energy all in K || < 2 K 0.5 0.5

No aliasing: , 0
-2 0

2
0
-2 0

2


No aliasing: If all energy is in r K || < (r + 1) K for some integer r

Normal case (r = 0): If all energy in 0 || K
1 1
Downsampling: Total energy multiplied by K (= K if no aliasing)
Average power unchanged (= energy/sample)
DSP and Digital Filters (2015-6738) Multirate: 11 9 / 14
Power Spectral Density

11: Multirate Systems


Multirate Systems
Example: Signal in 0.4 + Tones @ = 0.1 + White noise
Building blocks
Resampling Cascades
Power = Energy/sample = Average PSD original rate

PSD , = 0.5 + 0.1 = 0.6


1
Noble Identities R
1
Noble Identities Proof
Upsampled
= 2 PSD()d 0.5
z-transform
Downsampled Signal Power = 0.5, Noise Power = 0.1
z-transform 0

Downsampled Total Power = Energy/sample = 0.6 -3 -2 -1 0 1


Frequency (rad/samp)
2 3

Spectrum
Power Spectral
Density Upsampling:
Perfect upsample 2 upsample 3

PSD , = 0.056 + 0.14 = 0.2


PSD , = 0.13 + 0.18 = 0.3
Reconstruction
Commutators
Same energy 0.3
0.4
Summary per second 0.2
MATLAB routines 0.2
Power is K 0.1

0 0
-3 -2 -1 0 1 2 3 -3 -2 -1 0 1 2 3
Frequency (rad/samp) Frequency (rad/samp)

Downsampling:
downsample 2 downsample 3

PSD , = 0.49 + 0.11 = 0.6


Average power
PSD , = 0.5 + 0.1 = 0.6

0.6 0.6

is unchanged. 0.4 0.4

aliasing in 0.2 0.2

0 0
the 3 case. -3 -2 -1 0 1
Frequency (rad/samp)
2 3 -3 -2 -1 0 1
Frequency (rad/samp)
2 3

DSP and Digital Filters (2015-6738) Multirate: 11 10 / 14


[Power Spectral Density (1)]

The energy of a spectrum is Ex = +


P 2 1 P+N 2
|x[n]| and its power is P x = lim N 2N +1 N |x[n]| .
The energy, Ex , is the total energy in all samples while ( the power, Px , is the average energy per
x[n] |n| N
sample. If the finite signal xN [n] is defined as xN [n] = , then the power spectral
0 |n| > N
 2
density (PSD) is given by Sxx ej = limN 2N1+1 XN ej . From Parsevals theorem, Px is

1
R
the average value of Sxx ej or, equivalently, Px = 2 j d.
 
S
xx e
The signal on the previous slide has three components: (i) a signal component with a power of 0.3
and a trapezoidal PSD with a width of 0.4, (ii) a tonal component with a power of 0.2 whose PSD
consists of two delta functions and (iii) a white noise component of power 0.1 whose PSD is constant
at 0.1. The tonal component might arise from a time-domain waveform 0.4 cos (0.1n + ) where
is arbitrary and does not affect the PSD.
Upsampling by K inserts additional zero-valued samples and so does not affect Ex but, since there are
now K times as many samples, Px is divided by K. The original periodic PSD is shrunk horozontally by
a factor of K which means that there are now K images of the original PSD at spacings of = 2 K
.
So, for example, when K = 2, the central trapezoidal component has a maximum height of 0.5 and
a width of 0.2 and there is a second, identical, trapezoidal component shifted by = 2 K
= .
When K is an even number, one of the images will be centred on = and so will wrap around from
+ to . The power of each image is multiplied by K 2 but, since there are K images, the total
power is multiplied by K 1 . For the white noise, the images all overlap (and add in power), so the
white noise PSD amplitude is multiplied by K 1 . Finally, the amplitudes of the delta functions are
multiplied by K 2 so that the total power of all K images is multiplied by K 1 .

DSP and Digital Filters (2015-6738) Multirate: 11 note 1 of slide 10


[Power Spectral Density (2)]

Downsampling by K deletes samples but leaves the average power of the remaining ones unchanged.
Thus the total power of the downsampled spectra remains at 0.6. The downsampled PSD is the average
of K shifted versions of the original PSD that have been expanded horizontally by a factor of K. The
white noise component is the average of K identical expanded but attenuated versions of itself and so
its PSD amplitude remains at 0.1. The power of a tonal components is unchanged and so its amplitude
is also unchanged.
When downsampling by a factor of K = 3, the original width of the trapezoidal component expands
from 0.4 to 1.2 which exceeds the range of the graph. Thus, as approaches , the PSD
of the signal component is decreasing with but has not reached 0 at = . This portion of the
trapezium wraps around to = and gives rise to the little triangle of additional noise in the range
< < 0.8 where it adds onto the white noise component. In a similar way, the portion of the
trapezium that overflows the left edge of the graph gives rise to additional noise at the right of the
graph in the range 0.8 < < .

Energy and Power Upsample 1 : K Downsample K : 1


Spectral Densities ESD PSD ESD PSD
Summary of spectral density changes: Alias-free block 1 K K 2 K
Tone K K 2 K 1
White Noise 1 K K 1

DSP and Digital Filters (2015-6738) Multirate: 11 note 2 of slide 10


Perfect Reconstruction

11: Multirate Systems


Multirate Systems
x[n] cdefghijklmn
Building blocks u[m] c f i l
Resampling Cascades
Noble Identities p[n] -c--f--i--l
Noble Identities Proof
Upsampled
v[m] b e h k
z-transform
Downsampled
q[n] -bc-ef-hi-kl
z-transform
Downsampled
w[m] a d g j
Spectrum y[n] abcdefghijkl
Power Spectral
Density
Perfect
Reconstruction 1
Commutators Input sequence x[n] is split into three streams at 3 the sample rate:
Summary
MATLAB routines 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 (2015-6738) Multirate: 11 11 / 14


Commutators

11: Multirate Systems


Multirate Systems
x[n] cdefghijklmn
Building blocks u[m] c f i l
Resampling Cascades
Noble Identities v[m] b e h k
Noble Identities Proof
Upsampled
w[m] a d g j
z-transform
Downsampled
v[m + 13 ] e h k l
z-transform
Downsampled
w[m + 23 ] d g j m
Spectrum y[n] abcdefghijkl
Power Spectral
Density
Perfect
The combination of delays and downsamplers can be regarded as a
Reconstruction commutator that distributes values in sequence to u, w and v.
Commutators 1 2
Summary Fractional delays, z 3 and z 3 are needed to synchronize the streams.
MATLAB routines
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 (2015-6738) Multirate: 11 12 / 14
Summary

11: Multirate Systems


Multirate Systems
Multirate Building Blocks
1:K
Building blocks
Resampling Cascades
Upsample: X(z) X(z K )
Noble Identities Invertible, Inserts K 1 zeros between samples
Noble Identities Proof
Upsampled Shrinks and replicates spectrum
z-transform
Downsampled
Follow by LP filter to remove images
z-transform
Downsampled K:1 1 PK1 j2k 1
Spectrum Downsample: X(z) K k=0 X(e K z K )
Power Spectral
Density Destroys information and energy, keeps every K th sample
Perfect
Reconstruction
Expands and aliasses the spectrum
Commutators Spectrum is the average of K aliased expanded versions
Summary
MATLAB routines 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 (2015-6738) Multirate: 11 13 / 14


MATLAB routines

11: Multirate Systems


Multirate Systems
resample change sampling rate
Building blocks
Resampling Cascades
Noble Identities
Noble Identities Proof
Upsampled
z-transform
Downsampled
z-transform
Downsampled
Spectrum
Power Spectral
Density
Perfect
Reconstruction
Commutators
Summary
MATLAB routines

DSP and Digital Filters (2015-6738) Multirate: 11 14 / 14


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 (2015-6729) Polyphase Filters: 12 1 / 10


Heavy Lowpass filtering

12: Polyphase Filters


Heavy Lowpass
Filter Specification:
filtering Sample Rate: 20 kHz
Maximum Decimation
Frequency Passband edge: 100 Hz (1 = 0.03)
Polyphase
decomposition Stopband edge: 300 Hz (2 = 0.09)
Downsampled
Polyphase Filter Passband ripple: 0.05 dB ( = 0.006)
Polyphase Upsampler
Complete Filter
Stopband Gain: 80 dB ( = 0.0001)
Upsampler
Implementation
Downsampler This is an extreme filter because the cutoff frequency is only 1% of the
Implementation
Summary Nyquist frequency.
Symmetric FIR Filter:
Design with Remez-exchange algorithm
Order = 360
0 0
M=360
-20 -20
1 2
-40 -40

-60 -60

-80 -80
0 1 2 3 0 0.05 0.1
(rad/s) (rad/s)

DSP and Digital Filters (2015-6729) Polyphase Filters: 12 2 / 10


Maximum Decimation Frequency

12: Polyphase Filters


Heavy Lowpass
If a filter passband occupies only a small fraction 0
filtering
Maximum
of [0, ], we can downsample then upsample -20

Decimation
Frequency
without losing information. -40

-60
Polyphase 0 1 2 1 2 3
decomposition

Downsampled
= 2 /4 K=4
Polyphase Filter Downsample: aliased components at offsets of 0

Polyphase Upsampler
2
K are almost zero because of H(z)
-20
Complete Filter

Upsample: Images spaced at 2


-40
Upsampler
Implementation K can be -60
Downsampler
Implementation
removed using another low pass filter 0 1

2 3

Summary To avoid aliasing in the passband, we need 0


= 2 /7 K=7

-20
2 2
K 2 1 K 1 +2 -40

-60
0 1 2 3


Centre of transition band must be intermediate Nyquist freq, K

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 (2015-6729) Polyphase Filters: 12 3 / 10


Polyphase decomposition

12: Polyphase Filters


Heavy Lowpass
For our filter: original Nyquist frequency = 10 kHz and transition band
filtering
Maximum Decimation
centre is at 200 Hz so we can use K = 50.
Frequency
Polyphase
We will split H(z) into K filters each of order R 1. For convenience,
decomposition assume M + 1 is a multiple of K (else zero-pad h[n]).
Downsampled
Polyphase Filter
Polyphase Upsampler
Example: M = 399 R = MK+1 = 8
Complete Filter PM
Upsampler H(z) = m=0 h[m]z m
Implementation
Downsampler PK1 P2K1
Implementation = m=0 h[m]z m
+ m=K h[m]z m +
Summary
PK1 PR1
= m=0 r=0 h[m + Kr]z mKr
PK1 m PR1
= m=0 z r=0 hm [r]z
Kr

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 (2015-6729) Polyphase Filters: 12 4 / 10


Downsampled Polyphase Filter

12: Polyphase Filters


Heavy Lowpass
H(z) is low pass so we downsample its
filtering
Maximum Decimation
output by K without aliasing.
Frequency
Polyphase The number of multiplications per input
decomposition
Downsampled sample is M + 1 = 400.
Polyphase Filter
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 (2015-6729) Polyphase Filters: 12 5 / 10


Polyphase Upsampler

12: Polyphase Filters


Heavy Lowpass
To restore sample rate: upsample and
filtering
Maximum Decimation
then lowpass filter to remove images
Frequency
Polyphase We can use the same lowpass filter,
decomposition
Downsampled H(z), in polyphase form:
Polyphase Filter
Polyphase
PK1 m PR1
m=0 z r=0 hm [r]z
Kr
Upsampler
Complete Filter
Upsampler This time we put the delay z m after
Implementation
Downsampler the filters.
Implementation
Summary 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 (2015-6729) Polyphase Filters: 12 6 / 10


Complete Filter

12: Polyphase Filters


Heavy Lowpass
filtering
Maximum Decimation The overall system implements:
Frequency
Polyphase Need an extra gain of K to compensate for the downsampling energy loss.
decomposition
Downsampled
Polyphase Filter
Filtering at downsampled rate requires 16 multiplications per input sample
Polyphase Upsampler (8 for each filter). Reduced by K
2 from the original 400.
Complete Filter
Upsampler
Implementation H(ej ) reaches 10 dB at the downsampler 0

Downsampler
Implementation
Nyquist frequency of K . -20

-40
Summary Spectral components > K will be aliased 1 /50 2
-60
down in frequency in V (ej ). -80

For V (ej ), passband gain (blue curve) 0 0.05


(rad/s)
0.1

follows the same curve as X(ej ). 0

Noise arises from K aliased spectral intervals. -20


1
Unit white noise in X(ej ) gives passband -40

noise floor at 69 dB (red curve) even -60

though stop band ripple is below 83 dB -80


0 1 2 3
(downsampled)
(due to K 1 aliased stopband copies).

DSP and Digital Filters (2015-6729) Polyphase Filters: 12 7 / 10


Upsampler Implementation

12: Polyphase Filters


Heavy Lowpass
We can represent the upsampler
filtering
Maximum Decimation
compactly using a commutator.
Frequency
Polyphase
decomposition
Downsampled
Polyphase Filter
Polyphase Upsampler
Complete Filter
H0 (z) comprises a sequence of 7
Upsampler delays, 7 adders and 8 gains.
Implementation
Downsampler
Implementation We can share the delays between
Summary
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 (2015-6729) Polyphase Filters: 12 8 / 10
Downsampler Implementation

12: Polyphase Filters


Heavy Lowpass
We can again use a commutator.
filtering The outputs from all 50 filters are
Maximum Decimation
Frequency added together to form v[i].
Polyphase
decomposition
Downsampled We use the transposed form of
Polyphase Filter
Polyphase Upsampler Hm (z) because this will allow us
Complete Filter
Upsampler
to share components.
Implementation
Downsampler We can sum the outputs of the
Implementation
Summary gain elements using an
accumulator which sums blocks of
K samples.
PK1
Now we can share all the w[i] = r=0 u[Ki r]

components and use commutators


to switch the gain coefficients.
We need 7 delays, 7 adders, 8
gains and 8 accumulators in total.

DSP and Digital Filters (2015-6729) Polyphase Filters: 12 9 / 10


Summary

12: Polyphase Filters


Heavy Lowpass
Filtering should be performed at the lowest possible sample rate
filtering
Maximum Decimation
reduce filter computation by K
Frequency actual saving is only K 2 because you need a second filter
Polyphase
decomposition downsampled Nyquist frequency max (passband ) + 2
Downsampled
Polyphase Filter PK1 m
Polyphase Upsampler Polyphase decomposition: split H(z) as m=0 z Hm (z K )
Complete Filter
Upsampler
each Hm (z K ) can operate on subsampled data
Implementation
Downsampler
combine the filtering and down/up sampling
Implementation
Summary 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 (2015-6729) 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
13: Resampling Filters

DSP and Digital Filters (2015-6707) Resampling: 13 1 / 10


Resampling

13: Resampling
Filters
Suppose we want to change the sample rate while preserving information:
Resampling e.g. Audio 44.1 kHz48 kHz96 kHz
Halfband Filters
Dyadic 1:8 Upsampler
Rational Resampling
Downsample:

Arbitrary Resampling LPF to new Nyquist bandwidth: 0 = K
Polynomial
Approximation
Farrow Filter
Upsample:

Summary LPF to old Nyquist bandwidth: 0 = K
MATLAB routines
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 = K
d
Filter order M 3.5 where d is stopband attenuation in dB and
is the transition bandwidth (Remez-exchange estimate).

Fractional semi-Transition bandwidth, = 2 0
, is typically fixed.
dK
e.g. = 0.05 M 7 = 0.9dK (where 0 = K )

DSP and Digital Filters (2015-6707) Resampling: 13 2 / 10


Halfband Filters

13: Resampling
Filters
If K = 2 then the new Nyquist frequency is 1

Resampling 0 = 2 .
Halfband Filters 0.5

Dyadic 1:8 Upsampler


Rational Resampling We multiply ideal response sinn
0 n
by a Kaiser 0
Arbitrary Resampling
Polynomial
window. All even numbered points are zero 0 1
(rad/s)
2 3

Approximation except h[0] = 0.5. M=20


=2.5
Farrow Filter
Summary M
MATLAB routines If 4 | M and we make the filter causal (z 2 ),
M
P M2 1
H(z) = 0.5z 2 + z 1
r=0 h 1 [r]z 2r

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).
M
Computation: 4 multiplies per input sample

DSP and Digital Filters (2015-6707) Resampling: 13 3 / 10


Dyadic 1:8 Upsampler

13: Resampling
Filters
Resampling
Halfband Filters 1 0.8

Dyadic 1:8
Upsampler
0.5

Rational Resampling
Arbitrary Resampling
Suppose X(z): BW = 0.8 = 0.2 0
0 1

2 3

Polynomial 1 0.4 0.6


Approximation Upsample 1:2 U (z): 0.5 P=28
Farrow Filter
Summary
Filter HP (z) must remove image: = 0.2 0
0 1 2 3
60
MATLAB routines For attenuation = 60 dB, P 3.5 = 27.3 0.2 0.8
1
Round up to a multiple of 4: P = 28 0.5 Q=12

0
Upsample 1:2 V (z): = 0.6 Q = 12 0 1

2 3

1 0.1 0.9

Upsample 1:2 Y (z): = 0.8 R = 8 0.5 R=8

[diminishing returns + higher sample rate] 0


0 1 2 3

Multiplication Count: 1 0.15

1 + P4 fx + Q
M=110
R
 0.5

4 2fx + 4 4fx = 22fx 0


0 1 2 3

Alternative approach using direct 1:8 upsampling:


= 0.05 M = 110 111fx multiplications (using polyphase)

DSP and Digital Filters (2015-6707) Resampling: 13 4 / 10


Rational Resampling

13: Resampling P
Filters x[n] To resample by Q do 1:P
Resampling
Halfband Filters v[r] then LPF, then Q:1.
Dyadic 1:8 Upsampler
Rational
y[i]
Resampling
Arbitrary Resampling
Polynomial P
Approximation
Resample by Q 0 = max(P, Q)
Farrow Filter 2
Summary , 20 = max(P, Q)
MATLAB routines

Polyphase: H(z) = P Hp (z P )
P 1 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 =
2.7 max(P, Q)
 
M +1 2.7 Q
Hp (z): R + 1 = P = max 1, P M + 1 coeficients in all
 
Q
Multiplication rate: 2.7
max 1, P fy = 2.7
max (fy , fx )
DSP and Digital Filters (2015-6707) Resampling: 13 5 / 10
Arbitrary Resampling

13: Resampling
Filters
Sometimes need very large P and Q:
kHz
Resampling e.g. 44.1
48 kHz = 147
160
Halfband Filters
2.7 max(fy , fx )
Dyadic 1:8 Upsampler Multiplication rate OK:
Rational Resampling
Arbitrary
Resampling However # coefficients: 2.7 max(P,

Q)

Polynomial
Approximation Alternatively, use a conveniently large P
Farrow Filter
Summary
and round down to the nearest sample:
MATLAB routines E.g. for y[i] at time i Q
P use hp [r]
where p = (iQ)mod P
Equivalent to converting to analog with
P
zero-order hold and resampling at fy = Q .
1
Zero-order hold convolves with rectangular P -wide window multiplies

sin
periodic spectrum by
2P
. Resampling aliases to mod 2P .
2P Q

Unit power component at 1 gives alias components with total power:


2  2
12 2 2 21

2 1 P 2P 2P
sin 2P n=1 2nP +1 + 2nP 1 4P 2 62 = 12P 2

For worst case, 1 = , need P = 906 to get 60 dB /


DSP and Digital Filters (2015-6707) 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.
These components are multiplied by the sin0.5P
0.5P 1
1 function and therefore have amplitudes of
sin 0.5P 1 (2nP 1 ) sin(n0.5P 1 1 ) sin(1n 0.5P 1 1 )
= = .
0.5P 1 (2nP 1 ) (n0.5P 1 1 ) (n0.5P 1 1 )
P
When we do the downsampling to an output sample rate of Q , these images will be aliased to frequencies
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 sin2 (1n 0.5P 1 1 ) 2 1
 P 1
n=1 (n0.5P 1 )2 = sin 0.5P 1 n=1 (n0.5P 1 )2
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 approx-
imate this sum as
2 P 2 2 2 P
0.5P 1 1 n=1 (n) 2 = 4P
1
2 2 n=1 n
2

2
The summation is a standard result and equals 6
.
2
So the total power of the aliased components is 12P1 2 .

DSP and Digital Filters (2015-6707) Resampling: 13 note 1 of slide 6


Polynomial Approximation

13: Resampling
Filters
Suppose P = 50 and H(z) has order M = 249

Resampling H(z) is lowpass filter with 0 50
Halfband Filters
Dyadic 1:8 Upsampler Split into 50 filters of length R + 1 = MP+1 = 5:
Rational Resampling
Arbitrary Resampling hp [0] is the first P samples of h[m]
Polynomial
Approximation hp [1] is the next P samples, etc. 0
-20
Farrow Filter hp [r] = h[p + rP ] -40
Summary -60
MATLAB routines -80
Use a polynomial of order L to 0 1 2 3
approximate each segment:

hp [r] fr ( Pp ) with 0 Pp < 1 1


M=249, =6.5
0.5 h [0] hp[1] hp[2] hp[3] hp[4]
p
h[m] is smooth, so errors are low. 0
0 50 100 150 200
E.g. error < 103 for L = 4 m
-3
x 10
1
Resultant filter almost as good L=4

error
0
-1
Instead of M + 1 = 250 0 50 100 150 200

0
coefficients we only need -20 0
Farrow with L=4

(R + 1)(L + 1) = 25 -40
-60
where   -80
2.7 Q 0 1 2 3
R + 1 = max 1, P

DSP and Digital Filters (2015-6707) Resampling: 13 7 / 10


Farrow Filter

13: Resampling Q M +1
Filter coefficients depend on fractional part of R+1= =5
Filters i P: P
Resampling
j k
Halfband Filters [i] = i QP n where n = i Q
P
Dyadic 1:8 Upsampler
Rational Resampling PR
Arbitrary Resampling y[i] = r=0 fr ([i])x[n r]
Polynomial PL
Approximation where fr () = l=0 bl [r]l
Farrow Filter
Summary PR PL
MATLAB routines y[i] = r=0 l=0 bl [r][i]l x[n r]
PL l
PR
= 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

Each Bk (z) needs R + 1 per input sample R + 1 max 1, P
Horner needs L per output sample  
2.7(L+1) fx
Total: (L + 1) (R + 1) fx + Lfy = max 1, fy fx + Lfy
DSP and Digital Filters (2015-6707) Resampling: 13 8 / 10
Summary

13: Resampling
Filters
Transition band centre at 0
Resampling 0 = the lower of the old and new Nyquist frequencies
Halfband Filters
Dyadic 1:8 Upsampler Transition width = = 20 , typically 0.1
Rational Resampling
Arbitrary Resampling Factorizing resampling ratio can reduce computation
Polynomial
Approximation halfband filters very efficient (half the coefficients are zero)
Farrow Filter P
Summary Rational resampling Q
MATLAB routines
# multiplies per second: 2.7 max (fy , fx )
# coefficients: 2.7
max (P, Q)
Farrow Filter
approximate filter impulse response with polynomial segments
arbitrary, time-varying, resampling ratios
# multiplies per second: 2.7(L+1)
max (fy , fx ) fx
fy + Lfy
(L + 1) ffxy times rational resampling case
# coefficients: 2.7
max (P, Q) P
L+1

coefficients are independent of fy when upsampling

For further details see Mitra: 13 and Harris: 7, 8.


DSP and Digital Filters (2015-6707) Resampling: 13 9 / 10
MATLAB routines

13: Resampling
Filters gcd(p,q) Find p + q = 1 for coprime p, q
Resampling
Halfband Filters
polyfit Fit a polynomial to data
Dyadic 1:8 Upsampler polyval Evaluate a polynomial
Rational Resampling
Arbitrary Resampling upfirdn Perform polyphase filtering
Polynomial
Approximation resample Perform polyphase resampling
Farrow Filter
Summary
MATLAB routines

DSP and Digital Filters (2015-6707) 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 14: FM Radio Receiver
Summary

DSP and Digital Filters (2015-6738) FM Radio: 14 1 / 12


FM Radio Block Diagram

14: FM Radio
Receiver
FM spectrum: 87.5 to 108 MHz

FM Radio Block
Diagram
Each channel: 100 kHz
Aliased ADC
Channel Selection Baseband signal:
Channel Selection (1)
Channel Selection (2)
Mono (L + R): 15 kHz
Channel Selection (3) Pilot tone: 19 kHz
FM Demodulator
Differentiation Filter Stereo (L R): 38 15 kHz
Pilot tone extraction
Polyphase Pilot tone
RDS: 57 2 kHz
Summary
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 (2015-6738) FM Radio: 14 2 / 12
Aliased ADC

14: FM Radio
Receiver
FM band: 87.5 to 108 MHz
FM Radio Block
Diagram
Normally sample at fs > 2f
Aliased ADC
Channel Selection However:
Channel Selection (1)
Channel Selection (2)
fs = 80 creates aliased
Channel Selection (3) images at intervals of fs
FM Demodulator
Differentiation Filter
Pilot tone extraction ve frequencies also
Polyphase Pilot tone generate images
Summary

We want the image


between 7.5 and 28 MHz
Need an analogue bandpass
filter to extract the FM band

Transition band mid-points are at fs and 1.5fs


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 (2015-6738) FM Radio: 14 3 / 12


Channel Selection

14: FM Radio
Receiver
FM band shifted to 7.5 to 28 MHz (from 87.5 to 108 MHz)
FM Radio Block
Diagram
Aliased ADC
We need to select a single channel 200 kHz wide
Channel Selection
Channel Selection (1) We shift selected channel to DC and then downsample to fs = 400 kHz.
Channel Selection (2)
Channel Selection (3)
Assume channel centre frequency is fc = c 100 kHz
FM Demodulator
Differentiation Filter We must apply a filter before downsampling to remove unwanted images
Pilot tone extraction
Polyphase Pilot tone
Summary
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

DSP and Digital Filters (2015-6738) FM Radio: 14 4 / 12


Channel Selection (1)

14: FM Radio fc
Receiver Multiply by ej2r 80 MHz to shift
FM Radio Block
Diagram channel at fc to DC.
Aliased ADC
Channel Selection
fc = c 100 k 80fcM = 800 c
Channel Selection
(1) Result of multiplication is complex
Channel Selection (2)
Channel Selection (3) (thick lines on diagram)
FM Demodulator
Differentiation Filter
Pilot tone extraction
Next, lowpass filter to 100 kHz
k
Polyphase Pilot tone = 2 200
80 M = 0.157
Summary
60 dB
M = 3.5 = 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 (2015-6738) FM Radio: 14 5 / 12


Channel Selection (2)

14: FM Radio
Receiver
Channel centre frequency fc = c 100 kHz where c is an integer.
FM Radio Block Write c = 4k + l
Diagram
Aliased ADC where k = 4c and l = cmod 4
Channel Selection
Channel Selection (1)
Channel Selection
(2)
Channel Selection (3)
FM Demodulator
Differentiation Filter
c
Pilot tone extraction
Polyphase Pilot tone
We multiply u[r] by ej2r 800 then convolve with h[m]:
Summary PM c
v[n] = m=0 h[m]u[200n m]ej2(200nm) 800 [r = 200n]
PM mc 4k+l
= m=0 h[m]ej2 800 u[200n m]ej2200n 800 [c = 4k + 1]
PM j2 ln mc
j2 800
= m=0 g[c] [m]u[200n m]e 4 [g[c] [m] = h[m]e ]
= (j)ln M j2 ln
P
g
m=0 [c] [m]u[200n m] [e 4 indep of m]

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 ln ) = 12 80 MHz

DSP and Digital Filters (2015-6738) FM Radio: 14 6 / 12


Channel Selection (3)

14: FM Radio
Receiver
Channel frequency fc = c 100 kHz where c = 4k + l is an integer
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
cm
Summary
g[c] [m] = h[m]ej2 800
j2 c(200s+p)
g[c],p [s] = gc [200s + p]= h[200s + p]e 800 [polyphase]
cs cp cs
= h[200s + p]ej2 4 ej2 800 , h[200s + p]ej2 4 p
j2 (4k+l)s
Define f[c],p [s] = h[200s + p]e 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
j2 800
6 80 MHz (Fp (z)) + 4 80 MHz (e ) = 10 80 MHz

DSP and Digital Filters (2015-6738) 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
Complex FM signal centred at DC: v(t) = |v(t)|ej(t)
Differentiation Filter We know that log v = log |v| + j
Pilot tone extraction
Polyphase Pilot tone d
Summary
The instantaneous frequency of v(t) is dt .
d d(log v) 1 dv 1
v dv
 
We need to calculate dt = dt = v dt = |v|2 dt

We need:
(1) Differentiation filter, D(z)
(2) Complex multiply, w[n] v [n] (only need part)
(3) Real Divide by |v|2

x[n] is baseband signal (real):

DSP and Digital Filters (2015-6738) FM Radio: 14 8 / 12


Differentiation Filter

14: FM Radio
Receiver
Window design method:
FM Radio Block
Diagram
(1) calculate d[n] for the ideal filter
Aliased ADC (2) multiply by a window to give finite support
Channel Selection
Channel Selection (1)
(
Channel Selection (2) d jt jt j j || 0
Channel Selection (3) Differentiation: dt e = je D(e ) =
FM Demodulator 0 || > 0
Differentiation
Filter

h jn jn 0
i
1 j
jejn d = 2 ejn ej 2 n2
R 0
Pilot tone extraction
Polyphase Pilot tone
Hence d[n] = 2 0
[IDTFT]
0
Summary n0 cos n0 sin n0
= n2

1.5 0 0

|H| (dB) -20


1
|H|

-40

0.5 -60 0

-80
0
0 0.5 1 1.5 2 2.5 3 0 0.5 1 1.5 2 2.5 3
(rad/sample) (rad/sample)

2140 kHz
Using M = 18, Kaiser window, = 7 and 0 = 2.2 = 400 kHz :
Near perfect differentiation for 1.6 ( 100 kHz for fs = 400 kHz)
Broad transition region allows shorter filter
DSP and Digital Filters (2015-6738) 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)
Aim: extract 19 kHz pilot tone, double freq real 38 kHz tone.
FM Demodulator 20 kHz
Differentiation Filter (1) shift spectrum down by 20 kHz: multiply by ej2n 400 kHz
Pilot tone
extraction (2) low pass filter to 1 kHz to extract complex pilot at 1 kHz: H(z)
Polyphase Pilot tone jt 2
= ej2t ]

Summary
(3) square to double frequency to 2 kHz [ e
40 kHz
(4) shift spectrum up by 40 kHz: multiply by e+j2n 400 kHz
(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 (2015-6738) FM Radio: 14 10 / 12


Polyphase Pilot tone

14: FM Radio
Receiver
FM Radio Block
Diagram
Aliased ADC
Channel Selection Anti-alias filter: F (z)
Channel Selection (1) n
th j2 20
Channel Selection (2)
Each branch, Fp (z), gets every 20 sample and an identical e
p
j2 20
Channel Selection (3) So Fp (z) can filter a real signal and then multiply by fixed e
FM Demodulator
Differentiation Filter
Pilot tone extraction Anti-image filter: G(z)
n

Polyphase Pilot
tone
Each branch, Gp (z), multiplied by identical ej2 10
Summary 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 H(z) needs 273 400 kHz]

DSP and Digital Filters (2015-6738) FM Radio: 14 11 / 12


Summary

14: FM Radio
Receiver
Aliased ADC allows sampling below the Nyquist frequency
FM Radio Block
Diagram
Only works because the wanted signal fits entirely within a
Aliased ADC Nyquist band image
Channel Selection
Channel Selection (1)
Channel Selection (2)
Polyphase filter can be combined with complex multiplications to
Channel Selection (3) select the desired image
FM Demodulator
Differentiation Filter subsequent multiplication by j ln shifts by the desired multiple
Pilot tone extraction
Polyphase Pilot tone
of 41 sample rate
Summary No actual multiplications required
d
FM demodulation uses a differentiation filter to calculate 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 (2015-6738) 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
15: Subband Processing
Summary
Merry Xmas

DSP and Digital Filters (2015-6738) 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 The Hm (z) are bandpass analysis filters and divide x[n] into
Linear Phase QMF
IIR Allpass QMF
frequency bands
Tree-structured Subband processing often processes frequency bands independently
filterbanks
Summary The Gm (z) are synthesis filters and together reconstruct the output
Merry Xmas
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 (2015-6738) Subband Processing: 15 2 / 12


2-band Filterbank

15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
Polyphase QMF
Vm (z) = Hm (z)X(z) n  1  1 o
1
PK1 j2k 1 1
QMF Options
Linear Phase QMF
Um (z) = K k=0 Vm (e K z )=
K
2 Vm z
2 + Vm z 2
IIR Allpass QMF
Tree-structured
Wm (z) = Um (z 2 ) = 12 {Vm (z) + Vm (z)} [K = 2]
filterbanks
Summary
= 21 {Hm (z)X(z) + Hm (z)X(z)}
Merry Xmas  
  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) X(z) [X(z)A(z) is aliased term]
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 (2015-6738) Subband Processing: 15 3 / 12


Perfect Reconstruction

15: Subband
Processing
For perfect reconstruction without aliasing, we require
Subband processing     d 
2-band Filterbank 1 H0 (z) H1 (z) G0 (z) z
Perfect
2 =
Reconstruction H0 (z) H1 (z) G1 (z) 0
Quadrature Mirror
Filterbank (QMF)    1  
Polyphase QMF G0 (z) H0 (z) H1 (z) 2z d
QMF Options Hence: =
Linear Phase QMF G1 (z) H0 (z) H1 (z) 0
IIR Allpass QMF   
Tree-structured
2z d H1 (z) H1 (z) 1
filterbanks = H0 (z)H1 (z)H 0 (z)H1 (z)
Summary H0 (z) H0 (z) 0
Merry Xmas
 
2z d H1 (z)
= 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
     
G0 (z) H1 (z) d=k 2 H1 (z)
= 2c z kd = c
G1 (z) H0 (z) H0 (z)
1 1
Note: c just scales Hi (z) by c 2 and Gi (z) by c 2 .

DSP and Digital Filters (2015-6738) Subband Processing: 15 4 / 12


Quadrature Mirror Filterbank (QMF)

15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
QMF satisfies:
Polyphase QMF
QMF Options (a) H0 (z) is causal and real
Linear Phase QMF

j
IIR Allpass QMF
(b) H1 (z) = H0 (z): i.e. H0 (e ) is reflected around =

2
Tree-structured
filterbanks
(c) G0 (z) = 2H1 (z) = 2H0 (z)
Summary (d) G1 (z) = 2H0 (z) = 2H1 (z)
Merry Xmas

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 (2015-6738) Subband Processing: 15 5 / 12


Polyphase QMF

15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF)
Polyphase QMF Polyphase decomposition:
QMF Options
Linear Phase QMF
H0 (z) = P0 (z 2 ) + z 1 P1 (z 2 )
IIR Allpass QMF H1 (z) = H0 (z) = P0 (z 2 ) z 1 P1 (z 2 )
Tree-structured
filterbanks G0 (z) = 2H0 (z) = 2P0 (z 2 ) + 2z 1 P1 (z 2 )
Summary
Merry Xmas
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 )
we want 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 (2015-6738) Subband Processing: 15 6 / 12


QMF Options

15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
Quadrature Mirror
Filterbank (QMF) Polyphase decomposition:
Polyphase QMF
QMF Options
Linear Phase QMF
IIR Allpass QMF
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:
(A) Perfect Reconstruction: T (z) = z d H0 (z) is a bad filter.
(B) T (z) is Linear
Phase FIR:
Tradeoff: T (ej ) 1 versus H0 (z) stopband attenuation
(C) 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 (2015-6738) Subband Processing: 15 7 / 12


Option (B): Linear Phase QMF

15: Subband
Processing
Subband processing
2-band Filterbank
Perfect
Reconstruction
T (z) 1
Quadrature Mirror M
Filterbank (QMF) H0 (z) order M , linear phase H0 (ej ) = ej 2 H0 (ej )
Polyphase QMF
QMF Options
Linear Phase QMF T (ej ) = H02 (ej ) H12 (ej ) = H02 (ej ) H02 (ej )
IIR Allpass QMF j 2 j() 2

Tree-structured =e jM
H 0 (e ) e
j()M
H0 (e )
filterbanks
j 2 M j() 2

Summary =e jM
H0 (e ) (1) H0 (e )
Merry Xmas

M even T (e j
2 ) = 0 / so choose M odd (1)M = +1
Select h0 [n] by numerical iteration to minimize
j 2
R R
j
2
+ H0 (e ) d + (1 ) 0 T (e ) 1 d

2
balance between H0 (z) being lowpass and T (ej ) 1
0 0.04
Johnston filter h0[n] M=11 H0 H1
0.02
-20
(M = 11): -40
0

-0.02

-60 -0.04
0 1 2 3 0 1 2 3

DSP and Digital Filters (2015-6738) Subband Processing: 15 8 / 12


Option (C): IIR Allpass QMF

15: Subband
Processing
Subband processing
2-band Filterbank
Perfect |T (z)| = 1
Reconstruction
Quadrature Mirror
Filterbank (QMF) Choose P0 (z) and P1 (z) to be allpass IIR filters:
H0,1 (z) = 12 P0 (z 2 ) z 1 P1 (z 2 ) ,
Polyphase QMF

QMF Options
G0,1 (z) = 2H0,1 (z)
Linear Phase QMF
IIR Allpass QMF A(z) = 0 No aliasing
Tree-structured
filterbanks T (z) = H02 H12 = . . . = z 1 P0 (z 2 )P1 (z 2 ) is an allpass filter.
Summary
Merry Xmas H0 (z) and H1 (z) are power complementary :
H0 (ej ) 2 + H1 (ej ) 2 = H0 (ej )H0 (ej ) + H1 (ej )H1 (ej )

1 j 2 1 j 2

= . . . = P0 (e ) + P1 (e ) = 1 2 2

H0 (z) can be made a Butterworth or Elliptic filter with MH = 4MP + 1:


0 0
MP=1 M H=5 H0 H1 15
-2
-20
-4 P0(z2) H0(z) 10
-1
-6 A0=1+0.236z

-40
-1 z-1P1(z2) 5
T(z)
-8 A1=1+0.715z
-60
0 1 2 3 0 1 2 3 0 1 2 3
(rad/sample)

Phase cancellation: z 1 P1 = P0 + ; Ripples in H0 and H1 cancel.


DSP and Digital Filters (2015-6738) 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 1 2 3
1

Dividing the lower band in half repeatedly results in an octave band 0.5
U1 V1

filterbank. Each subband occupies one octave (= a factor of 2 in 0


0 1 2 3
frequency). 1

U2 V2 V1
The properties perfect reconstruction and allpass are preserved 0.5

by the iteration. 0
0 1 2 3
1

U3 V3 V2 V1
0.5

0
0 1 2 3

DSP and Digital Filters (2015-6738) Subband Processing: 15 10 / 12


Summary

15: Subband
Processing
Half-band filterbank:
Subband processing Reconstructed output is T (z)X(z) + A(z)X(z)
2-band Filterbank
Perfect Unwanted alias term is A(z)X(z)
Reconstruction
Quadrature Mirror
Filterbank (QMF) Perfect reconstruction: imposes strong constraints on analysis
Polyphase QMF
QMF Options
filters Hi (z) and synthesis filters Gi (z).
Linear Phase QMF
IIR Allpass QMF Quadrature Mirror Filterbank (QMF) adds an additional symmetry
Tree-structured
filterbanks constraint H1 (z) = H0 (z).
Summary
Perfect reconstruction now impossible except for trivial case.
Merry Xmas
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 (2015-6738) Subband Processing: 15 11 / 12


Merry Xmas

DSP and Digital Filters (2015-6738) 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.

Where necessary, the sample rate of a signal in a block diagram is indicated in the form @ f .

Abbreviations

BIBO Bounded Input, Bounded Output IIR Infinite Impulse Response


CTFT Continuous-Time Fourier Transform LTI Linear Time-Invariant
DCT Discrete Cosine Transform MDCT Modified Discrete Cosine Transform
DFT Discrete Fourier Transform PSD Power Spectral Density
DTFT Discrete-Time Fourier Transform SNR Signal-to-Noise Ratio
FIR Finite Impulse Response

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

1 r+1 zr1
rn=0 n zn = 1z1
provided that z1 6= 1.
n n = 1
provided that z1 < 1.


n=0 z 1z1

Digital Signal Processing and Digital Filters Imperial


c College London 1/3
Forward and Inverse Transforms
n 1

z: X(z) =
x[n]z x[n] = 2 j X(z)zn1 dz
jt dt 1
jt d
CTFT: X( j ) = x(t)e x(t) = 2 X( j )e

jn 1

DTFT: X(e j ) =
x[n]e x[n] = 2 X(e
j )e jn d

kn kn
DFT: X[k] = N1
0 x[n]e j2 N x[n] = 1
N 0N1 X[k]e j2 N

2(2n+1)k
DCT: X[k] = N1
n=0 x[n] cos 4N x[n] = X[0]
N
N1
+ N2 n=1 X[k] cos 2(2n+1)k
4N

2(2n+1+N)(2k+1) 2(2n+1+N)(2k+1)
MDCT: X[k] = 2N1
n=0 x[n] cos 8N y[n] = 1
N N1
0 X[k] cos 8N

Convolution

V e j = X e j Y e j
  
DTFT: v[n] = x[n] y[n] ,
r= x[r]y[n r]

1 1
j Y e j( ) d
V e j =

e j ~Y e j =
   
v[n] = x[n]y[n] 2 X 2 X e

DFT: v[n] = x[n] ~N y[n] , N1


r=0 x[r]y[(n r) mod N ] V [k] = X[k]Y [k]

N1
v[n] = x[n]y[n] V [k] = N1 X[k] ~N Y [k] , 1
N r=0 X[r]Y [(k r) mod N ]

Group Delay

F (nh[n])
j )
   
The group delay of a filter, H(z), is H (e j ) = dH(e = z dH(z)
= where

d H(z) dz
z=e j F (h[n])
F ( ) denotes the DTFT.

Order Estimation for FIR Filters

Three increasingly sophisticated formulae for estimating the minimum order of an FIR filter with unity
gain passbands:

a
1. M 3.5
a8
2. M 2.2
a1.220 log10 b
3. M 4.6

where a =stop band attenuation in dB, b = peak-to-peak passband ripple in dB and = width of
smallest transition band in radians per sample.

z-plane Transformations

A lowpass filter, H(z), with cutoff frequency 0 may be transformed into the filter H(z) as follows:

Digital Signal Processing and Digital Filters Imperial


c College London 2/3
Target H(z) Substitute Parameters
 

sin 0 2 1
z1
Lowpass z1 = 1 z1
= 
+

sin 0 2 1
< 1  
+
1 cos 0 2 1
Highpass z1 = 1+
z +
z1
= 


cos 0 2 1
> 1  
+
(1)2 z1 +(+1)z2 cos 2 2 1 
2 1

z1 0

Bandpass = (+1)2 z1 +(1)z2
= 

, = cot 2 tan 2
cos 2 2 1
1 < < 2  
+
(1)2 z1 +(+1)z2 cos 2 2 1 
2 1

z1 = 0

Bandstop (+1)2 z1 +(1)z2
= 

, = tan 2 tan 2
cos 2 2 1
1 2

Noble Identities

Multirate Spectra

( h i
v Qr if Q | r
Upsample: x[r] = X(z) = V (zQ )
0 if Q - r

 j2k 1 
1 Q1
Downsample: y[m] = v[Qm] Y (z) = Q k=0 V e Q z Q

Multirate Commutators

Input Commutator Output Commutator

Digital Signal Processing and Digital Filters Imperial


c College London 3/3