Professional Documents
Culture Documents
Web site:
http://www.ee.columbia.edu/~dpwe/e4810/
Book:
Mitra Digital Signal Processing
(3rd ed., 2005)
Instructor: dpwe@ee.columbia.edu
2012-09-05 Dan Ellis 3
Grading structure
Homeworks: 20%
Wednesday-Wednesday schedule
Midterm: 20%
One session
Project: 30%
2012-09-05 Dan Ellis 4
Course project
Practical implementation
Recommend MATLAB
Ideas on website
Speech/Music Discrimination
Room sonar
DTMF decoder
Reverb algorithms
Compression algorithms
o
n
w
e
b
s
i
t
e
W
2012-09-05 Dan Ellis 6
MATLAB
Access:
Signals:
Information-bearing function
Dimensionality:
Sound: 1-Dimension
Greyscale image i(x,y) : 2-D
Video: 3 x 3-D: {r(x,y,t) g(x,y,t) b(x,y,t)}
2012-09-05 Dan Ellis 9
Example signals
ECG - biological
Music
Image/video - compression
.
2012-09-05 Dan Ellis 10
Signal processing
Examples
Noise reduction
Data compression
Digital SP system:
Processor p(t) q(t)
Processor p(t) q(t) A/D D/A
p[n] q[n]
2012-09-05 Dan Ellis 13
Digital vs. analog
Pros
Stability/duplicability
Novelty
Cons
Sequence {x[n]} = x
a
(nT), n=-1,0,1,2
Thus,
{x[n]} = {. . . , 0.2, 2.2, 1.1, 0.2, 3.7, 2.9, . . .}
N
1
n N
2
: Finite length (length = )
N
1
n: Right-sided (Causal if N
1
0)
n N
2
: Left-sided (Anticausal)
Addition operation:
Adder
Multiplication operation
Multiplier
A
x[n]
y[n]
x[n]
y[n]
w[n]
y[n] = x[n] +w[n]
y[n] = Ax[n]
2012-09-05 Dan Ellis 19
More operations
Modulator
E.g. Windowing:
Multiplying an infinite-length sequence
by a finite-length window sequence
to extract a region
x[n]
y[n]
w[n]
y[n] = x[n] w[n]
2012-09-05 Dan Ellis 20
Time shifting
Time-shifting operation:
where N is an integer
Unit delay
Unit advance
y[n]
x[n]
y[n]
x[n]
2012-09-05 Dan Ellis 21
Combination of basic operations
Example
y[n] =
1
x[n] +
2
x[n 1]
+
3
x[n 2] +
4
x[n 3]
2012-09-05 Dan Ellis 22
Up- and down-sampling
An example of down-sampling
y[n] = x[3n]
3
2012-09-05 Dan Ellis 25
Up-sampling
x[n/L] n = 0, L, 2L, . . .
0 otherwise
2012-09-05 Dan Ellis 26
Up-sampling
An example of up-sampling
3
not inverse of downsampling!
2012-09-05 Dan Ellis 27
Complex numbers
Rectangular form: x = x
re
+ jx
im
where magnitude |x| = (x
re
2
+ x
im
2
)
and phase = tan
-1
(x
im
/x
re
)
When multiplying,
magnitudes multiply
and phases add:
re
j
se
j
= rse
j(
Phases modulo 2
x
2012-09-05 Dan Ellis 29
Complex conjugate
Finite/infinite (extent in n)
Real/complex:
x[n] = x
re
[n] + jx
im
[n]
2012-09-05 Dan Ellis 31
Classification by symmetry
Conjugate antisymmetric:
x
ca
[n] = x
ca
*[-n] = x
re
[-n] + jx
im
[-n]
if x[n] = x
re
[n] + jx
im
[n]
then x
cs
[n] = x
cs
*[-n]
= x
re
[-n] jx
im
[-n]
2012-09-05 Dan Ellis 32
Conjugate symmetric decomposition
Shift in time:
[n - k]
A sequence satisfying
is called a periodic sequence with a
period N where N is a positive integer and
k is any integer.
Smallest value of N satisfying
is called the fundamental period
2012-09-05 Dan Ellis 39
Periodic exponentials
o
N = 2r
2012-09-05 Dan Ellis 40
Symmetry of periodic sequences
Symmetry of x
f
[n] is not defined
because x
f
[n] is undefined for n < 0
[n
N
])
=1/2
x
f
[n] +x
f
[N n]
1 n < N
n modulo N n
N
= n +rN
s.t. 0 n
N
< N, r Z
2012-09-05 Dan Ellis 41
Sampling sinusoids
{y[n]} = f ({x[n]})
n
A
2012-09-12 Dan Ellis 3
Moving Average (MA)
x[n]
y[n]
+
z
-1
z
-1
1/M
1/M
1/M
x[n-1]
x[n-2]
n
x[n]
-1 1 2 3 4 5 6 7 8 9
A
n
x[n-1]
-1 1 2 3 4 5 6 7 8 9
n
x[n-2]
-1 1 2 3 4 5 6 7 8 9
n
y[n]
-1 1 2 3 4 5 6 7 8 9
y[n] =
1
M
x[n k]
k=0
M1
e.g.
signal noise
y[n] =
1
5
x[n k]
k=0
4
5-pt
moving
average
x[n] = s[n] + d[n]
2012-09-12 Dan Ellis 5
Accumulator
= x[]
=
n1
+ x[n]
= y[n 1] + x[n]
2012-09-12 Dan Ellis 6
Accumulator
n
x[n]
-1 1 2 3 4 5 6 7 8 9
A
n
y[n-1]
-1 1 2 3 4 5 6 7 8 9
n
y[n]
-1 1 2 3 4 5 6 7 8 9
x[n] y[n] +
z
-1
y[n-1]
M
2012-09-12 Dan Ellis 7
Classes of DT systems
if input x
1
[n] output y
1
[n], x
2
y
2
...
then output
for all , , x
1
, x
2
i.e. same linear combination of outputs
x[n]
DT system
y[n]
2012-09-12 Dan Ellis 8
Linearity: Example 1
Accumulator:
Linear
y[n] = x[]
=
n
y[n] = x
1
[] + x
2
[]
( )
=
n
= x
1
[]
( )
+ x
2
[]
( )
= x
1
[]
+ x
2
[]
= y
1
[n] + y
2
[n]
x[n] = x
1
[n] + x
2
[n]
2012-09-12 Dan Ellis 9
Linearity Example 2:
Offset accumulator:
but
Nonlinear
.. unless C = 0
y[n] = C+ x[]
=
n
y
1
[n] = C+ x
1
[]
=
n
y[n] = C+ x
1
[] +x
2
[]
( )
=
n
y
1
[n] +y
2
[n]
2012-09-12 Dan Ellis 11
Property: Shift (time) invariance
Time-shift of input
causes same shift in output
i.e. if x
1
[n] y
1
[n]
then
Upsampler: L
Not shift invariant
y[n] =
x[n/L] n = 0, L, 2L, . . .
0 otherwise
y
1
[n] = x
1
[n/L] (n = r L)
x[n] = x
1
[n n
0
]
y[n] = x[n/L] = x
1
[n/L n
0
]
= x
1
n L n
0
L
= y
1
[n L n
0
] = y
1
[n n
0
]
x[n]
y[n]
2012-09-12 Dan Ellis 13
Another counterexample
Hence
If
then
y[n] = n x[n]
scaling by time index
y
1
[n n
0
] = n n
0
( )
x
1
[n n
0
]
x[n] = x
1
[n n
0
]
y[n] = n x
1
[n n
0
]
2012-09-12 Dan Ellis 14
Linear Shift Invariant (LSI)
Formally, if x
1
[n] y
1
[n] & x
2
[n] y
2
[n]
Causal
x
1
[n] = x
2
[n] n < N
y
1
[n] = y
2
[n] n < N
2012-09-12 Dan Ellis 16
Causality example
Moving average:
y[n] depends on x[n-k], k 0 causal
y
c
n [ ] = y n + M 1 ( ) / 2 [ ]
=
1
M
x[n] + x[n k] + x[n + k]
k=1
(M 1) / 2
( )
2012-09-12 Dan Ellis 17
Impulse response (IR)
Impulse
(unit sample sequence)
Given a system:
if x[n] = [n] then y[n] = h[n]
impulse response
2012-09-12 Dan Ellis 18
Impulse response example
Simple system:
1
x[n]
y[n]
+
z
-1
z
-1
3
n
x[n]
-1 1 2 3 4 5 6 7
1
-2 -3
n
y[n]
-1 1 2 3 4 5 6 7
1
-2 -3
3
x[n] = [n] impulse
y[n] = h[n] impulse response
2012-09-12 Dan Ellis 19
2. Convolution
Impulse response:
Shift invariance:
+ Linearity:
Hence, since
For LSI,
written as
y[n] = x[k]h[n k]
k=
*
y[n] = x[n] h[n]
*
x[n] h[n] = x[n l]h[l]
l=
= h[n] x[n]
*
2012-09-12 Dan Ellis 21
Convolution properties
Commutative:
Associative:
Distributive:
x[n] h[n] = h[n] x[n]
* *
(x[n] h[n]) y[n] = x[n] (h[n] y[n])
* * * *
h[n] (x[n] + y[n]) = h[n] x[n] + h[n] y[n]
* *
*
2012-09-12 Dan Ellis 22
Interpreting convolution
x[n]={0 3 1 2 -1}
h[n] = {3 2 1}
n
-1 1 2 3 4 5 6 7 -2 -3
n
-1 1 2 3 5 6 7 -2 -3
y[n] = x[k]h[n k]
k=
= h[k]x[n k]
k=
Time-reverse h,
shift by n, take inner
product against
fixed x
k
-1 1 2 3 5 6 7 -2 -3
x[k]
k
-1 1 2 3 4 5 6 7 -2 -3
h[0-k]
k
-1 1 2 3 4 5 6 7 -2 -3
h[1-k]
k
-1 1 2 3 4 5 6 7 -2 -3
h[2-k]
n
-1 1 2 3 5 7 -2 -3
y[n]
0
9 9
11
2
-1
y[n] = x[k]h[n k]
k=
=g[k]
=g[k-1]
call h[-n] = g[n]
2012-09-12 Dan Ellis 24
Convolution interpretation 2
Shifted xs
weighted by
points in h
Conversely,
weighted,
delayed
versions of h ...
n
-1 1 2 3 5 7 -2 -3
y[n]
0
9 9
11
2
-1
n
-1 1 2 3 5 6 7 -2 -3
x[n]
n
-1 1 2 3 4 6 7 -2 -3
x[n-1]
n
-1 1 2 3 4 5 7 -2 -3
x[n-2]
k
-
1
1
2
3
4
5
6
7
-
2
-
3
h
[
k
]
y[n] = h[k]x[n k]
k=
y[0]
y[1]
y[2]
...
=
x[0]
x[1]
x[2]
...
x[1]
x[0]
x[1]
...
x[2]
x[1]
x[0]
...
h[0]
h[1]
h[2]
2012-09-12 Dan Ellis 26
Convolution notes
k + n k
( )
= n
2012-09-12 Dan Ellis 27
Convolution in MATLAB
If
then conv(a,b) yields
a = [0 3 1 2 -1]
b = [3 2 1]
[0 9 9 11 2 0 -1]
M
2012-09-12 Dan Ellis 28
Connected systems
Cascade connection:
Impulse response h[n] of the cascade of
two systems with impulse responses
h
1
[n] and h
2
[n] is
By commutativity,
*
*
h[n] = h
1
[n]
2012-09-12 Dan Ellis 29
Inverse systems
Consider
h
2
[n] is the inverse system of h
1
[n]
x[n] [n]
=
x[n] *
x[n] y[n] z[n]
=
x[n]
z[n]
=
h
2
[n] y[n]
=
h
2
[n] h
1
[n] x[n]
* * *
if
*
h
2
[n] h
1
[n] = [n]
2012-09-12 Dan Ellis 30
Inverse systems
Accumulator:
Impulse response h
1
[n] = [n]
Backwards difference
.. has desired property:
defined by {d
k
},{p
k
}
order = max(N,M)
d
k
y[n k]
k=0
N
= p
k
x[n k]
k=0
M
y[n] =
d
k
d
0
y[n k]
k=1
N
+
p
k
d
0
x[n k]
k=0
M
Total solution
Complementary Solution
satisfies
Particular Solution
for given forcing function
x[n]
y[n] = y
c
[n] + y
p
[n]
d
k
y[n k]
k=0
N
= 0
2012-09-12 Dan Ellis 35
Complementary Solution
Assume y
c
has form
Characteristic polynomial
of system - depends only on {d
k
}
y
c
[n] =
n
d
k
nk
k=0
N
= 0
nN
d
0
N
+ d
1
N1
++ d
N1
+ d
N
( )
= 0
d
k
Nk
k=0
N
= 0
2012-09-12 Dan Ellis 36
Complementary Solution
Each/any
i
satisfies eqn.
Nk
k=0
N
= 0
(
1
)(
2
)... = 0
y
c
[n] =
1
1
n
+
2
2
n
+
3
3
n
+ ...
2012-09-12 Dan Ellis 37
Complementary Solution
Complex
i
s sinusoidal
y
c
[n] =
1
1
n
+
2
n
1
n
+
3
n
2
1
n
+... +
L
n
L1
1
n
+ ...
(
1
)
L
(
2
)... = 0
y
c
[n] =
i
i
n
2012-09-12 Dan Ellis 38
Particular Solution
Complementary solution:
1
,
2
are unknown at this point
roots
1
= -3,
2
= 2
y[n] + y[n 1] 6y[n 2] = 0; y[n] =
n
n2
2
+ 6
( )
= 0
+ 3
( )
2
( )
= 0
y
c
[n] =
1
3
( )
n
+
2
2
( )
n
2012-09-12 Dan Ellis 41
LCCDE example
Particular solution:
Total solution
n = 0
LCCDE example
from ICs
=
1
3
( )
n
+
2
2
( )
n
+
y[n] = y
c
[n] + y
p
[n]
y[n] + y[n 1] 6y[n 2] = x[n]
y[0] + y[1] 6y[2] = x[0]
1
+
2
+ +1+ 6 = 8
1
+
2
= 3
2012-09-12 Dan Ellis 43
LCCDE example
n = 1
solve:
1
= -1.8,
2
= 4.8
Dont find
i
s by solving with ICs at
n = -1,-2
(ICs may not reflect natural modes;
Mitra example 2.37/38 is wrong)
y[1] + y[0] 6y[1] = x[1]
1
(3) +
2
(2) + +
1
+
2
+ 6 = 8
2
1
+ 3
2
=18
y[n] = 1.8(3)
n
+ 4.8(2)
n
2 n 0
M
2012-09-12 Dan Ellis 44
LCCDE solving summary
Particular soln: y
p
[n] ~ x[n]
solve for
0
n
at large n
i
s by substituting DE at n = 0, 1, ...
ICs for y[-1], y[-2]; y
t
=y
c
+y
p
for y[0], y[1]
y
c
[n] =
i
i
n
y
zi
[n], response with zero input (just ICs)
y
zs
[n], response with zero state (just x[n])
Impulse response:
i.e. solve with x[n] = [n] y[n] = h[n]
(zero ICs)
e.g.
(from before); x[n] = [n]; y[n] = 0 for n<0
n = 0:
n = 1:
n = 2:
thus
1
n 0
Infinite length
y[n] + y[n 1] 6y[n 2] = x[n]
y
c
[n] =
1
3
( )
n
+
2
2
( )
n
h[n] = 0.6 3
( )
n
+ 0.4 2
( )
n
M
y
p
[n] = [n]
1
+
2
+ = 1
1
= 0.6,
2
= 0.4, = 0
1
(3) +
2
(2) + 1 = 0
1
(9) +
2
(4) 1 6 = 0
2012-09-12 Dan Ellis 48
System property: Stability
MA filter:
BIBO Stable
y[n] =
1
M
x[n k]
k=0
M1
y[n] =
1
M
x[n k]
k=0
M1
1
M
x[n k]
k=0
M1
1
M
M B
x
B
y
2012-09-12 Dan Ellis 51
Stability & LCCDEs
1
n
+
2
2
n
+ ... +
0
n
+ ...
2012-09-12 Dan Ellis 52
4. Correlation
Note:
Cross
correlation
of x against y
lag
call m = n
M
r
xy
[] =
n=
x[n]y[n ]
r
yx
[] =
n=
y[n]x[n ]
=
m=
y[m+ ]x[m] = r
xy
[]
2012-09-12 Dan Ellis 53
Correlation and convolution
Correlation:
Convolution:
Hence:
Correlation may be calculated by
convolving with time-reversed sequence
r
xy
[n] =
k=
x[k]y[k n]
x[n] y[n] =
k=
x[k]y[n k]
r
xy
[n] = x[n] y[n]
2012-09-12 Dan Ellis 54
Autocorrelation
Note:
Energy of
sequence x[n]
r
xx
[] = x[n]x[n ]
n=
= r
xx
[]
r
xx
[0] = x
2
[n]
n=
=
x
2012-09-12 Dan Ellis 55
Correlation maxima
Note:
Similarly:
From geometry,
y
r
xy
[]
r
xx
[0]r
yy
[0]
1
xy = x
i
y
i
i
= x y cos
x
i
2
Sequence of period N:
=
1
N
x [n] x [n ]
n=0
N1
= P
x
r
x x
[ + N] =
1
N
x [n] x [n N]
n=0
N1
= r
x x
[]
2012-09-12 Dan Ellis 58
What correlations look like
AC of any x[n]
AC of periodic
Cross correlation
r
x x
[
]
r
xx
[
]
r
xy
[
Short-time
cross-correlation
2012-09-24 Dan Ellis 1
ELEN E4810: Digital Signal Processing
Topic 3: Fourier domain
1. The Fourier domain
2. Discrete-Time Fourier Transform (DTFT)
3. Discrete Fourier Transform (DFT)
4. Convolution with the DFT
2012-09-24 Dan Ellis 2
1. The Fourier Transform
i.e. if
we can approach with
Harmonics
of the
fundamental
x (t) = x (t +T)
x
x(t)
M
k=0
a
k
cos
2k
T
t +
k
k=0
a
k
cos
2k
T
t +
k
x(t) = cos
2
T
t
1
3
cos
2
T
3t
+
1
5
cos
2
T
5t
. . .
k
= 0; a
k
=
(1)
k1
2
1
k
k = 1, 3, 5, . . .
0 otherwise
2012-09-24 Dan Ellis 4
Fourier domain
x is equivalently described
by its Fourier Series
parameters:
Complex form:
Negative a
k
is
equivalent to phase of
k
1 2 3 5 6 7 4
a
k
1.0
k
1 2 3 5 6 7 4
a
k
= (1)
k1
2
1
k
k = 1, 3, 5, . . .
x(t)
M
k=M
c
k
e
j
2k
T
t
2012-09-24 Dan Ellis 5
Fourier analysis
How to find ?
Inner product with complex sinusoids:
but
e
j
= cos + jsin
{|c
k
|}, {arg{c
k
}}
=
1
T
x(t) cos(
2k
T
t)dt j
x(t) sin(
2k
T
t)dt
x(t)
M
k=M
c
k
e
j
2k
T
t
c
k
=
1
T
T/2
T/2
x(t)e
j
2k
T
t
dt
2012-09-24 Dan Ellis 6
Fourier analysis
Consider
.. so c
k
should = 0 except k = l
Then
c
k
=
1
T
x t ( ) cos
2kt
T
dt j x t ( ) sin
2kt
T
dt
( )
=
1
T
cos
2lt
T
cos
2kt
T
dt j cos
2lt
T
sin
2kt
T
dt
( )
0
evenodd
x(t) = cos
l
2
T
t
x(t)
M
k=M
c
k
e
j
2k
T
t
2012-09-24 Dan Ellis 7
Fourier analysis
(say
T=2)
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
-1
-0.5
0
0.5
1
cos(1t)
cos(2t)
t /
=
1
4
sin(k+l)t
k+l
+
sin(kl)t
kl
=
1
2
(sinc(k + l) + sinc(k l))
1
2
cos(kt) cos(lt)dt =
1 k = l
0 otherwise
2012-09-24 Dan Ellis 8
sinc
= 1 when x = 0
= 0 when x = r, r 0, r = 1, 2, 3,...
sincx =
sin x
x
1.0
2 3 4 4 3 2
sin(x)
sin(x)
/x
y=x
x
2012-09-24 Dan Ellis 9
Fourier Analysis
Thus,
because real & imag sinusoids in
pick out the corresponding sinusoidal
components linearly combined
in
c
k
=
1
T
T/2
T/2
x(t)e
j
2k
T
t
dt
e
j
2k
T
t
x(t) =
M
k=M
c
k
e
j
2k
T
t
2012-09-24 Dan Ellis 10
Fourier Transform
X(j)e
jt
d
X(j) =
x(t)e
jt
dt
2012-09-24 Dan Ellis 11
Fourier Transform
arg{X()}
2012-09-24 Dan Ellis 12
Fourier Transform of a sine
Assume
Now, since
...we know
...where (x) is the Dirac delta function
(continuous time) i.e.
f(x)
x
x
0
(x-x
0
)
x(t) = e
j
0
t
x x
0
( )
f x ( )dx = f x
0
( )
x(t) = Ae
j
0
t
X() = A(
0
)
x(t) =
1
2p
Z
X(W)e
jWt
dW
X(W) = 2pd(WW
0
)
2012-09-24 Dan Ellis 13
Fourier Transforms
Time Frequency
Fourier Series
(FS)
Continuous
periodic x(t)
Discrete
infinite c
k
Fourier
Transform (FT)
Continuous
infinite x(t)
Continuous
infinite X()
Discrete-Time
FT (DTFT)
Discrete
infinite x[n]
Continuous
periodic X(e
j
)
Discrete FT
(DFT)
Discrete
finite/pdc x[n]
Discrete
finite/pdc X[k]
~
~
2012-09-24 Dan Ellis 14
2. Discrete Time FT (DTFT)
Discrete (normalized)
frequency variable !
Argument is e
j!
, not j!
DTFT
X(e
j
) = x[n]e
jn
n=
e.g. x[n] =
n
[n], || < 1
n
-1 1 2 3 4 5 6 7
X(e
j
) =
n
[n]e
jn
n=
= e
j
( )
n
n=0
=
1
1e
j
S = c
n
n=0
cS = c
n
n=1
S cS = c
0
=1
S =
1
1 c
Im
Re
n
1 - e
-j
0
|X(e
j
)|
2 3 4 5
1
2
3
arg{X(e
j
)}
2 3 4 5
( |c | < 1 )
2012-09-24 Dan Ellis 16
Periodicity of X(e
j!
)
X(e
j!
) has periodicity 2 in ! :
Phase ambiguity of e
j!
makes it implicit
X(e
j (+2 )
) = x[n]
e
j (+2 )n
= x[n]
e
jn
e
j 2n
= X(e
j
)
0
|X(e
j
)|
2 3 4 5
1
2
3
arg{X(e
j
)}
2 3 4 5
2012-09-24 Dan Ellis 17
Inverse DTFT (IDTFT)
=
1
2
x[l]e
jl
l
( )
e
jn
d
= x[l]
l
1
2
e
j(nl )
d
= x[l]sinc
l
(n l) = x[n]
2012-09-24 Dan Ellis 19
sinc again
1
2
e
j(nl)
dw =
1
2
e
j(nl)
j(n l)
=
1
2
e
j(nl)
e
j(nl)
j(n l)
=
1
2
2j sin(n l)
j(n l)
= sinc (n l)
2012-09-24 Dan Ellis 20
x[n] = [n]
)
X(e
j
) = x[n]e
jn
n=
= e
j0
=1
2012-09-24 Dan Ellis 21
DTFTs of simple sequences
:
over - < ! <
but X(e
j!
) must be periodic in !
If !
0
= 0 then x[n] = 1 n
so
IDTFT
x[n] = e
j
0
n
x[n] =
1
2
X(e
j
)e
jn
d
X(e
j
) = 2 (
0
)
e
j
0
n
2 (
0
2k)
k
1 2 ( 2k)
k
X(e
j
!
)
0 24
2012-09-24 Dan Ellis 22
[n]
1
1 e
j
+ ( + 2k)
k
From before:
n
[n]
1
1e
j
2012-09-24 Dan Ellis 23
DTFT properties
Linear:
Time shift:
Frequency shift:
delay
in
frequency
g[n] + h[n] G(e
j
) + H(e
j
)
g[n n
0
] e
jn
0
G(e
j
)
e
j
0
n
g[n] G e
j
0
( )
( )
2012-09-24 Dan Ellis 24
DTFT example
x[n] = [n] +
n
[n-1] ?
= [n] + (
n-1
[n-1])
x[n] =
n
[n]
X(e
je
) =1+o e
je1
1
1oe
je
|
\
|
.
|
=1+
oe
je
1oe
je
=
1oe
je
+oe
je
1oe
je
=
1
1oe
je
2012-09-24 Dan Ellis 25
DTFT symmetry
If x[n] X(e
j!
) then...
x[-n] X(e
-j!
)
x
*
[n] X
*
(e
-j!
)
Re{x[n]} X
CS
(e
j!
)
jIm{x[n]} X
CA
(e
j!
)
x
cs
[n] Re{X(e
j!
)}
x
ca
[n] jIm{X(e
j!
)}
conjugate symmetry cancels Im parts on IDTFT
from summation
(e
-j!
)
*
= e
j!
=
1
2
X e
j
( )
+ X
*
e
j
( ) [ ]
=
1
2
X e
j
( )
X
*
e
j
( ) [ ]
X(e
j
) = x[n]e
jn
n=
Convolution:
Convolution
becomes
multiplication
x[n] = g[n] h[n]
X(e
j
) = g[n] h[n] ( )e
jn
n=
= g[k]h[n k]
k
( )
n
e
jn
= g[k]e
jk
h[n k]e
j(nk )
n
( )
k
= G(e
j
) H(e
j
)
g[n] h[n] G(e
j
)H(e
j
)
2012-09-24 Dan Ellis 28
Convolution with DTFT
Since
we can calculate a convolution by:
finding DTFTs of g, h G, H
multiply them: GH
x[n] =
n
[n]
Modulation:
Could solve if g[n] was just sinusoids...
h[n]e
jen
=
1
2t
G(e
ju
) h[n]e
j (eu )n
n
[ ]
du
t
t
}
g[n] h[n]
1
2
G(e
j
)H(e
j ( )
)d
If g = h, then gg
*
= |g|
2
= energy...
g[n]h
*
[n]
n
=
1
2
G(e
j
)H
*
(e
j
)d
Energy of sequence
By Parseval
g
= g[n]
n
g
=
1
2
G(e
j
)
2
d
S
gg
(e
j
) = G(e
j
)
2
2012-09-24 Dan Ellis 33
EDS and autocorrelation
Autocorrelation of g[n]:
= g[n] g[n]
DTFT r
gg
[]
{ }
= G(e
j
)G(e
j
)
DTFT r
gg
[]
{ }
= G(e
j
)
2
= S
gg
(e
j
)
2012-09-24 Dan Ellis 34
3. Discrete FT (DFT)
DFT:
where i.e. 1/N
th
of a revolution
DFT and IDFT
X[k] = X(e
j
)
=
2k
N
= x[n]e
j
2k
N
n
n=0
N1
X[k] = x[n]W
N
kn
n=0
N1
W
N
= e
j
2
N
1
2/N
W
N
2012-09-24 Dan Ellis 36
IDFT
Check:
Sum of complete set
of rotated vectors
= 0 if l n; = N if l = n
re
im
W
N
W
N
2
x[n] =
1
N
X[k]W
N
nk
k=0
N1
x[n] =
1
N
x[l]W
N
kl
l
( )
W
N
nk
k
=
1
N
x[l] W
N
k (ln)
k=0
N1
l=0
N1
= x[n]
0 n < N
or finite
geometric series
= (1-W
N
lN
)/(1-W
N
l
)
2012-09-24 Dan Ellis 37
DFT examples
Finite impulse
Periodic sinusoid:
x[n] =
1 n = 0
0 n =1..N 1
X[k] = x[n]W
N
kn
n=0
N1
= W
N
0
=1 k
X[k] =
1
2
W
N
rn
+W
N
rn
( )
n=0
N1
W
N
kn
=
N / 2 k = r,k = N r
0 o.w.
(0 k < N)
x[n] = cos
2rn
N
=
1
2
W
rn
N
+W
rn
N
(r Z)
2012-09-24 Dan Ellis 38
DFT: Matrix form
as a matrix multiply:
i.e.
X[k] = x[n] W
N
kn
n=0
N1
X= D
N
x
X[0]
X[1]
X[2]
.
.
.
X[N 1]
1 1 1 1
1 W
1
N
W
2
N
W
(N1)
N
1 W
2
N
W
4
N
W
2(N1)
N
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1 W
(N1)
N
W
2(N1)
N
W
(N1)
2
N
x[0]
x[1]
x[2]
.
.
.
x[N 1]
If
then
1 1 1 1
1 W
1
N
W
2
N
W
(N1)
N
1 W
2
N
W
4
N
W
2(N1)
N
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1 W
(N1)
N
W
2(N1)
N
W
(N1)
2
N
X[k] = x[n]W
N
kn
n=0
N1
X[k] = X(e
j
)
=
2k
N
2012-09-24 Dan Ellis 42
DTFT from DFT
|
\
|
.
|
e
jen
n=0
N1
=
1
N
X[k]
k=0
N1
e
j e
2tk
N
( )
n
n=0
N1
=
1
N
X[k]
k=0
N1
sin N
Ae
k
2
sin
Ae
k
2
e
j
( N1)
2
Ae
k
k
=
2k
N
2012-09-24 Dan Ellis 43
Periodic sinc
= N when !
k
= 0; = (-)N when !
k
/2 =
= 0 when !
k
/2 = r/N, r = 1, 2, ...
other values in-between...
e
j
k
n
n=0
N1
=
1 e
jN
k
1 e
j
k
=
e
jN
k
/ 2
e
j
k
/ 2
e
jN
k
/ 2
e
jN
k
/ 2
e
j
k
/ 2
e
j
k
/ 2
= e
j
( N1)
2
k
sin N
k
2
sin
k
2
pure phase
pure real
2012-09-24 Dan Ellis 44
Periodic sinc
DFT DTFT
= interpolation
by periodic
sinc
X[k]X(e
j!
)
sin Nx
sin x
(N = 8)
2
sinx
sinNx
sinNx
/
sinx
x
0
N
-N
-1 0 k = 1
= 2/N
k = 3
= 6/N
k = 4
= 8/N
-0.5
0
0.5
1
1.5
X(e
j
0) = X[k]
sin N
k
/2
N sin
k
/2
X[3]
sin N
3
/2
N sin
3
/2
X[k] = X(e
j2k/N
)
0
freq
2012-09-24 Dan Ellis 45
DFT from overlength DTFT
)
IDFT
X[k]
0 n < N -A n < B
x [n]
0 n < N
x[n] =
1
N
N1
k=0
=
x[]W
k
N
W
nk
N
=
=
x[]
1
N
N1
k=0
W
k(n)
N
x[n] =
r=
x[n rN]
2012-09-24 Dan Ellis 47
DFT from DTFT example
If x[n] = { 8, 5, 4, 3, 2, 2, 1, 1} (8 point)
8 5 4 3
+ + + +
2 2 2 1
= {10 7 5 4}
x[n] =
r=
x[n rN]
2012-09-24 Dan Ellis 48
DFT from DTFT example
x[n]
x[n+N]
(r = -1)
N
] W
kn
0
N
G[k]
g[n n
0
N
] =
g[n n
0
] n n
0
g[N +n n
0
] n < n
0
2012-09-24 Dan Ellis 50
Circular time shift
Duality:
if
then
i.e.
(0 n < N)
2012-09-24 Dan Ellis 54
Circular convolution
Written as
g[n] h[n]
N
g m
[ ]
h n m
N
[ ]
m=0
N1
G[k]H[k]
2012-09-24 Dan Ellis 55
Circular convolution example
4 pt sequences: g[n]={1 2 0 1}
n
1 2 3
h[n]={2 2 1 0}
n
1 2 3
1
2
0
1
n
h[<n - 0>
4
]
1 2 3
n
h[<n - 1>
4
]
1 2 3
n
h[<n - 2>
4
]
1 2 3
n
h[<n - 3>
4
]
1 2 3
n
g[n] h[n]={4 7 5 4}
1 2 3
4
check: g[n] h[n]
={2 6 5 4 2 1 0}
*
g m
[ ]
h n m
N
[ ]
m=0
N1
Circular convolution
Modulation
Duality
Parseval
G n
[ ]
N g k
N
[ ]
g m
[ ]
h n m
N
[ ]
m=0
N1
G[k]H[k]
g n
[ ]
h n
[ ]
1
N
G[m]H[ k m
N
]
m=0
N1
x n
[ ]
2
n=0
N1
=
1
N
X k
[ ]
2
k=0
N1
Procedure (N = L + M - 1):
IDFT{Y[k]}
n
g[n]
L
n
h[n]
M
n
y
c
[n]
N
= y
L
n + rN
[ ]
r=
= y
L
n
[ ]
(0 n < N)
2012-09-24 Dan Ellis 59
Overlap-Add convolution
Make
g[n] i N n < (i + 1) N
0 otherwise
g[n] =
i
g
i
[n]
h[n] g[n] =
i
h[n] g
i
[n]
2012-09-24 Dan Ellis 60
Overlap-Add convolution
n
g[n]
n
g
0
[n]
n
g
1
[n]
n
g
2
[n]
N 2N 3N
n
g
0
[n] h[n]
n
n
h[n]
n
g
1
[n] h[n]
g
2
[n] h[n]
n
N 2N 3N
h[n] g[n]
valid OLA sum
*
L
L
*
*
*
2012-10-03 Dan Ellis 1
ELEN E4810: Digital Signal Processing
Topic 4: The Z Transform
1. The Z Transform
2. Inverse Z Transform
2012-10-03 Dan Ellis 2
1. The Z Transform
z is complex...
z = e
j!
DTFT
z = re
j!
G(z) = Z g n
[ ] { }
= g[n]z
n
n=
Z Transform
g n
[ ]
r
n
e
jn
n
DTFT of
r
-n
g[n]
2012-10-03 Dan Ellis 3
Region of Convergence (ROC)
Critical question:
Does summation
converge (to a finite value)?
Region of Convergence:
Portion of complex z-plane
for which a particular G(z)
will converge
G(z) = x[n]z
n
n=
z-plane
Re{z}
Im{z}
ROC
|z| >
e.g. x[n] =
n
[n]
=
1
1 z
1
(see previous slide)
n
-1 1 2 3 4 -2
2012-10-03 Dan Ellis 5
About ROCs
If ROC includes
unit circle (|z| = 1),
g[n] has a DTFT
(finite energy
sequence)
z-plane
Re{z}
Im{z}
Unit circle
lies in ROC
DTFT OK
1
2012-10-03 Dan Ellis 6
Another ROC example
Same ZT as
n
[n], different sequence?
x n
[ ]
=
n
n 1
[ ]
n
-1
1 2 3 4
-2 -3 -4 -5
X z ( ) =
n
n 1 [ ]
( )
z
n
n
=
n
z
n
n=
1
=
m
z
m
m=1
=
1
z
1
1
1
z
=
1
1 z
1
ROC:
|| > |z|
2012-10-03 Dan Ellis 7
ROC is necessary!
z
1
( )
d
0
=1
N
1
z
1
( )
=
z
M
p
0
=1
M
z
( )
z
N
d
0
=1
N
z
( )
2012-10-03 Dan Ellis 10
Pole-zero diagram
poles
(cpx conj for real g[n])
zeros
Thus, if
then
G(z) = Z g n
[ ] { }
= g[n]z
n
n
Z Transform
y[n] =
1
1
n
[n] +
2
2
n
[n]
Y(z) =
1
1
1
z
1
+
2
1
2
z
1
y[n] = g[n] + h[n]
Y(z) = (g[n]+h[n])z
-n
= g[n]z
-n
+ h[n]z
-n
= G(z)+H(z)
ROC:
|z|>|
1
|,|
2
|
Linear
2012-10-03 Dan Ellis 14
ZT of LCCDEs
Hence ZT
Each term
i
n
in g[n] corresponds to a
pole
i
of G(z) ... and vice versa
i
n
n
[ ]
+ ...
Y
c
z ( ) =
i
1
i
z
1
+
(same
s)
outside
circles
2012-10-03 Dan Ellis 15
ROCs and sidedness
Consider
with |
1
| < 1 , |
2
| > 1 ...
Similarly for
2
...
4 possible g[n] seqs and ROCs ...
no ROC specified
1
n
[n]
n
-
1
n
[-n-1]
n
or
n
-
2
n
[-n-1]
n
2
n
[n]
or
2012-10-03 Dan Ellis 17
ROC intersections: Case 1
ROC: |z| > |
1
| and |z| > |
2
|
Im
Re
|
1
| |
2
|
Im
G(z) =
1
1
1
z
1
+
1
1
2
z
1
n
g[n] =
1
n
[n] +
2
n
[n]
both right-sided:
2012-10-03 Dan Ellis 18
ROC intersections: Case 2
Im
Re
|
1
| |
2
|
Im
G(z) =
1
1
1
z
1
+
1
1
2
z
1
n
g[n] = -
1
n
[-n-1] -
2
n
[-n-1]
both left-sided:
ROC: |z| < |
1
| and |z| < |
2
|
2012-10-03 Dan Ellis 19
ROC intersections: Case 3
ROC: |z| > |
1
| and |z| < |
2
|
Im
Re
|
1
| |
2
|
Im
G(z) =
1
1
1
z
1
+
1
1
2
z
1
n
g[n] =
1
n
[n] -
2
n
[-n-1]
two-sided:
2012-10-03 Dan Ellis 20
ROC intersections: Case 4
ROC: |z| < |
1
| and |z| > |
2
| ?
Re
|
1
| |
2
|
Im
G(z) =
1
1
1
z
1
+
1
1
2
z
1
n
g[n] = -
1
n
[-n-1] +
2
n
[n]
two-sided:
no ROC
...
2012-10-03 Dan Ellis 21
ROC intersections
No overlap in ROCs
ZT does not exist
(does not converge for any z)
g n
[ ]
=
n
=
n
n
[ ]
+
n
n 1
[ ]
< n <
ROC
|z| > ||
ROC
|z| < ||
Re
||
Im
n
2012-10-03 Dan Ellis 22
Some common Z transforms
g[n] G(z) ROC
[n] 1 z
[n] |z| > 1
n
[n] |z| > ||
r
n
cos(!
0
n)[n] |z| > r
r
n
sin(!
0
n)[n] |z| > r
1
1z
1
1
1z
1
1r cos
0
( )
z
1
12r cos
0
( )
z
1
+r
2
z
2
r sin
0
( )
z
1
12r cos
0
( )
z
1
+r
2
z
2
sum of
re
j!
0
n
+ re
-j!
0
n
poles at z = re
j!
0
conjugate pole
pair
2012-10-03 Dan Ellis 23
Z Transform properties
g[n] G(z) w/ROC Rg
Conjugation g
*
[n] G
*
(z
*
) Rg
Time reversal g[-n] G(1/z) 1/Rg
Time shift g[n-n
0
] z
-n
0G(z) Rg (0/?)
Exp. scaling
n
g[n] G(z/) ||Rg
Diff. wrt z ng[n] Rg (0/?)
z
dG(z)
dz
2012-10-03 Dan Ellis 24
Z Transform properties
g[n] G(z) ROC
Convolution g[n] h[n] G(z)H(z)
Modulation g[n]h[n]
Parseval:
at least
RgRh
1
2j
G v
( )
H
z
v
( )
v
1
dv
C
g n
[ ]
h
*
n
[ ]
n=
=
1
2j
G v
( )
H
*
1
v
( )
v
1
dv
C
at least
RgRh
2012-10-03 Dan Ellis 25
ZT Example
; can express as
Hence,
x n
[ ]
= r
n
cos
0
n
( )
n
[ ]
1
2
n
[ ]
re
j
0
( )
n
+ re
j
0
( )
n
= v n
[ ]
+ v
*
n
[ ]
v[n] =
1
/
2
[n]
n
; = re
j!
0
V(z) = 1/(2(1- re
j!
0
z
-1
))
ROC: |z| > r
X z
( )
= V z
( )
+V
*
z
*
( )
=
1
2
1
1re
j
0
z
1
+
1
1re
j
0
z
1 ( )
=
1r cos
0
( )
z
1
12r cos
0
( )
z
1
+r
2
z
2
2012-10-03 Dan Ellis 26
Another ZT example
y n
[ ]
= n +1
( )
n
n
[ ]
= x[n] + nx[n]
where x[n] =
n
[n]
X z
( )
=
1
1z
1
z
dX z
( )
dz
= z
d
dz
1
1oz
1
|
\
|
.
|
=
oz
1
(1oz
1
)
2
Y z
( )
=
1
1z
1
+
z
1
(1z
1
)
2
=
1
(1z
1
)
2
repeated
root - IZT
( |z| > || )
ROC |z| > ||
2012-10-03 Dan Ellis 27
2. Inverse Z Transform (IZT)
the useful
one
2012-10-03 Dan Ellis 28
IZT #1: Generalize IDTFT
If then
so
re
j
e
jn
d
=
1
2j
C
G(z) z
n1
r
n
dz
G(z) = G(re
j
) =
g[n]r
n
e
jn
= DTFT
g[n]r
n
Since
if we could express G(z) as a simple
power series G(z) = a + bz
-1
+ cz
-2
...
then can just read off g[n] = {a, b, c, ...}
G z
( )
=
P(z)
D(z)
2012-10-03 Dan Ellis 30
IZT #2: Long division
Procedure:
e.g.
H z
( )
=
1+ 2z
1
1+ 0.4z
1
0.12z
2
1+ 0.4z
1
0.12z
2
1+ 2z
1
)
1+1.6z
1
0.52z
2
+ 0.4z
3
...
1+ 0.4z
1
0.12z
2
1.6z
1
+ 0.12z
2
1.6z
1
+ 0.64z
2
0.192z
3
0.52z
2
+ 0.192z
3
...
Result
2012-10-03 Dan Ellis 32
IZT#3: Partial Fractions
especially
or sin/cos forms
A
1z
1
+
B
1 z
1
+
2012-10-03 Dan Ellis 33
Partial Fractions
Note that:
=1
N
(1
z
1
)
z
1
=1
N
else cancel
w/ long div.
2012-10-03 Dan Ellis 34
Partial Fractions
Procedure:
where
i.e. evaluate F(z) at the pole
but multiplied by the pole term
dominates = residue of pole
F(z) =
P(z)
=1
N
(1
z
1
)
=
z
1
=1
N
= 1
z
1
( )
F z
( )
z=
f n
[ ]
=
( )
n
n
[ ]
=1
N
order N-1
(cancels term in
denominator)
no repeated
poles!
2012-10-03 Dan Ellis 35
Partial Fractions Example
Given (again)
factor:
where:
H z
( )
=
1+ 2z
1
1+ 0.4z
1
0.12z
2
=
1+ 2z
1
1+ 0.6z
1
( )
1 0.2z
1
( )
=
1
1+ 0.6z
1
+
2
1 0.2z
1
1
= 1+ 0.6z
1
( )
H z
( )
z=0.6
=
1+ 2z
1
1 0.2z
1
z=0.6
= 1.75
2
=
1+ 2z
1
1+ 0.6z
1
z=0.2
= 2.75
2012-10-03 Dan Ellis 36
Partial Fractions Example
Hence
X(e
j
)e
jn
d
2012-10-10 Dan Ellis 3
Sinusoids as Eigenfunctions
m
h[m]x[n m] x[n]
h[n]
x[n] = e
j
0
n
y[n] =
m
h[m]e
j
0
(nm)
=
m
h[m]e
j
0
m
e
j
0
n
y[n] = H(e
j
0
) x[n] = |H(e
j
0
)| e
j(
0
n+(
0
))
H(e
j
)
= |H(e
j
)|e
j()
0
2012-10-10 Dan Ellis 4
System Response from H(e
j
!
)
|H(e
j!
)| magnitude response gain
arg{H(e
j!
)} phase resp. phase shift
2012-10-10 Dan Ellis 5
Real
Real Sinusoids
-
0
0
|X(e
j
)|
A/2
x[n] =Acos(
0
n +)
=
A
2
e
j(
0
n+)
+e
j(
0
n+)
=
A
2
e
j
e
j
0
n
+
A
2
e
j
e
j
0
n
y[n] =
A
2
e
j
H(e
j
0
)e
j
0
n
+
A
2
e
j
H(e
j
0
)e
j
0
n
h[n] H(e
j
) = H
(e
j
) = |H(e
j
)|e
j()
y[n] = A|H(e
j
0
)| cos (
0
n + +(
0
))
2012-10-10 Dan Ellis 6
Real Sinusoids
m=
h[m]e
j
0
(nm)
m=n+1
h[m]e
j
0
(nm)
= H(e
j
0
)e
j
0
n
(
m=n+1
h[m]e
j
0
m
)e
j
0
n
x[n] = e
j
0
n
[n]
2012-10-10 Dan Ellis
-40 -30 -20 -10 0 10 20 30 40 time / n
Total output
Steady State
Transient
8
Transient / Steady State
m=n+1
h[m]e
j
0
m
)e
j
0
n
x[n] = e
j
0
n
[n]
2012-10-10 Dan Ellis 9
FR example
MA filter
n
-1 1 2 3 4 5 6
1/M
y[n] =
1
M
M1
=0
x[n ]
=x[n] h[n]
H(e
j
) = DTFT{h[n]}
=
n=
h[n]e
jn
=
1
M
M1
n=0
e
jn
=
1
M
1 e
jM
1 e
j
=
1
M
e
j
(M1)
2
sin(M/2)
sin(/2)
2012-10-10 Dan Ellis
0
2
4
6
0
2
4
6
0 2 2
-
0
10
FR example
MA filter:
Response to ...
(jumps at sign changes:
r=M!/2)
(M = 5)
H(e
j
) =
1
M
e
j
(M1)
2
sin(M/2)
sin(/2)
H(e
j
)
1
M
sin(M/2)
sin(/2)
() =
(M 1)
2
+ r
x[n] = e
j
0
n
+e
j
1
n
2012-10-10 Dan Ellis
-20 0 20 40 60 80
-2
-1
0
1
2
n
x[n]
y[n]
11
FR example
MA filter
input
output
M
y[n] = H(e
j
0
)e
j
0
n
+ H(e
j
1
)e
j
1
n
x[n] = e
j
0
n
+e
j
1
n
0
= 0.1 H(e
j
0
) 0.8e
j
0
1
= 0.5 H(e
j
1
) ()0.2e
j
1
0
2
4
6
0
2
4
6
0 2 2
-
0
LCCDE:
Take ZT:
Hence:
or:
Transfer
function
H(z)
N
k=0
d
k
y[n k] =
N
k=0
p
k
x[n k]
k
d
k
z
k
Y (z) =
k
p
k
z
k
X(z)
Y (z) =
P
k
p
k
z
k
P
k
d
k
z
k
X(z)
Y (z) = H(z)X(z)
2012-10-10 Dan Ellis 13
Transfer Function (TF)
Alternatively,
ZT
k=0
h
k
x[n k]
=
P
p
k
z
k
P
d
k
z
k
n
h[n]z
n
2012-10-10 Dan Ellis 14
Transfer Function (TF)
Hence, MA filter:
z-plane
Re{z}
Im{z}
1
z
M
=1 i.e.
M roots of 1
@ z=e
j2r/M
pole @ z=1
cancels
ROC?
|H(e
j!
)|
h[n] =
1
M
0 n M
0 otherwise
(ignore poles
at z=0)
y[n] =
1
M
M1
=0
x[n ]
H(z) =
1
M
M1
=0
z
n
=
1z
M
M(1z
1
)
=
z
M
1
Mz
M1
(z1)
2012-10-10 Dan Ellis 15
TF example
factorize:
0
= 0.6+j0.8
0
= 0.3
1
= 0.5+j0.7
...
y[n] = x[n 1] 1.2x[n 2] + x[n 3]
+ 1.3y[n 1] 1.04y[n 2] + 0.222y[n 3]
H(z) =
z
1
(1
0
z
1
)(1
0
z
1
)
(1
0
z
1
)(1
1
z
1
)(1
1
z
1
)
H(z) =
Y (z)
X(z)
=
z
1
1.2z
2
+z
3
1 1.3z
1
+ 1.04z
2
0.222z
3
2012-10-10 Dan Ellis 16
TF example
Poles
i
ROC
0
*
H(z) =
z
1
(1
0
z
1
)(1
0
z
1
)
(1
0
z
1
)(1
1
z
1
)(1
1
z
1
)
0
= 0.6+j0.8
0
= 0.3
1
= 0.5+j0.7
2012-10-10 Dan Ellis 17
TF FR
DTFT H(e
j
) = ZT H(z)|
z = e
j
i.e. Frequency Response is
Transfer Function evald on Unit Circle
H z
( )
=
p
0
1
k
z
1
( )
k=1
M
d
0
1
k
z
1
( )
k=1
N
=
p
0
z
M
z
k
( )
k=1
M
d
0
z
N
z
k
( )
k=1
N
H e
j
( )
=
p
0
d
0
e
j NM
( )
e
j
k
( )
k=1
M
e
j
k
( )
k=1
N
factor:
2012-10-10 Dan Ellis 18
TF FR
Magnitude
response
k
,
k
are
TF roots
on z-plane
Phase
response
() =arg
p
0
d
0
+ (N M)
+
M
k=1
arg
e
j
k=1
arg
e
j
H(e
j
) =
p
0
d
0
e
j(NM)
M
k=1
e
j
N
k=1
(e
j
k
)
H(e
j
)
p
0
d
0
M
k=1
e
j
N
k=1
|e
j
k
|
2012-10-10 Dan Ellis 19
FR: Geometric Interpretation
Have
On z-plane:
H e
j
( )
=
p
0
d
0
e
j NM
( )
e
j
k
( )
k=1
M
e
j
k
( )
k=1
N
Constant/
linear part
Product/ratio of terms
related to poles/zeros
Each (e
j!
- ) term corresponds
to a vector from pole/zero to
point e
j!
on the unit circle
Overall FR is product/ratio of
all these vectors
Im{z}
e
j!
i
e
j!
i
Re{z}
e
j!
2012-10-10 Dan Ellis 20
FR: Geometric Interpretation
Magnitude |H(e
j!
)| is product of
lengths of vectors from zeros
divided by product of lengths
of vectors from poles
e
j!
i
e
j!
i
Re{z}
e
j!
i
2012-10-10 Dan Ellis
-1 -0.5 0 0.5 1
-1
-0.5
0
0.5
1
Real Part
I
m
a
g
i
n
a
r
y
P
a
r
t
-0.8
-0.6 -0.4
-0.2
0.0
0.2
0.4 0.6
0.8
0
1
2
magnitude
phase
0 0.5 1.5 2
-
-/2
0
/2
21
FR: Geometric Interpretation
22
FR: Geometric Interpretation
Multiple
poles,
zeros:
H z
( )
=
z 0.8e
j0.3
( )
z 0.8e
j0.3
( )
z 0.9e
j0.3
( )
z 0.9e
j0.3
( )
V
2012-10-10 Dan Ellis 23
Geom. Interp. vs. 3D surface
e.g.
Construct a filter:
|H(e
j!
1)| 1
|H(e
j!
2)| 0
Then
x n
[ ]
= Acos
1
n
( )
+ Bcos
2
n
( )
interested
in this part
dont care about
this part
y n
[ ]
= h n
[ ]
x n
[ ]
Acos
1
n +
1
( ) ( )
filtered
out
!
!
2
!
1
!
1
!
2
H(e
j!
)
X(e
j!
)
B
/
2
B
/
2
A
/
2
A
/
2
2012-10-10 Dan Ellis 26
Filtering example
Consider
filter family:
3 pt FIR filters
with h[n] = { }
Frequency Response:
n
-1 1 2 3 4 -2
H e
j
( )
= h n
[ ]
e
jn
n
= + e
j
+e
2 j
= e
j
+ e
j
+ e
j
( ) ( )
= e
j
+ 2cos
( )
H e
j
( )
= + 2cos
x[n]
+
z
-1
z
-1
y[n]
h[n] = { }
Solve
= -12.46, = 6.76 ...
want to remove
i.e. make H(e
j!
2) = 0
H e
j
( )
= + 2cos
H(e
j
)
= | + 2cos |
=
1 =
1
= 0.1
0 =
2
= 0.4
2012-10-10 Dan Ellis 28
Filtering example (contd)
Filter
IR
Freq.
resp
input/
output
0 5 10 15 20 25 30 35 40 45
n
n
-15
-10
-5
0
5
10
15
0 0.2 0.4 0.6 0.8 1
/ rad
-20
-10
0
10
20
0 20 40 60 80 100 120 140 160 180
-2
-1
0
1
2
dB
2012-10-10 Dan Ellis 29
3. Phase- and group-delay
i.e.
or
p
( )
=
( )
subtraction so
positive
p
means
delay (causal)
2012-10-10 Dan Ellis 30
Phase delay example
H e
j
( )
= e
j
+ 2cos
( )
u e
( )
= e
t
p
e
( )
=
e
e
|
\
|
.
|
= +1
2012-10-10 Dan Ellis 31
Group Delay
Now:
Assume |H(e
j!
)| 1 around !
c
!
m
but (!
c
-!
m
) =
l
; (!
c
+!
m
) =
u
...
!
!
c
X(e
j!
)
!
c
+!
m
!
c
-!
m
=
A
2
cos
c
m
( )
n + cos
c
+
m
( )
n
[ ]
y n
[ ]
= h n
[ ]
- x n
[ ]
=
A
2
H e
j e
c
e
m
( )
( )
cos e
c
e
m
( )
n
+H e
j e
c
+e
m
( )
( )
cos e
c
+e
m
( )
n
|
\
|
.
|
|
2012-10-10 Dan Ellis 33
Group Delay
y n
[ ]
=
A
2
cos e
c
e
m
( )
n +u
l
[ ]
+cos e
c
+e
m
( )
n +u
u
[ ]
|
\
|
.
|
= Acos e
c
n +
u
u
+u
l
2
|
\
|
.
|
cos e
m
n +
u
u
u
l
2
|
\
|
.
|
phase shift
of carrier
phase shift
of envelope
2012-10-10 Dan Ellis 34
Group Delay
If (!
c
) is locally linear i.e.
" (!
c
+!) = (!
c
) + S!,
l
+
u
2
=
c
( )
c
( )
c
=
p
u
l
2
=
m
S
g
c
( )
=
d
( )
d
=
c
!
c
(!)
S
!
!
c
!
m
!
c
+!
m
u
2012-10-10 Dan Ellis 35
Group Delay
p
, phase
delay
g
, group
delay
(!)
n
0 50 100 150 200 250 300 350 400
-1
-0.5
0
0.5
1
Envelope
(group) delay
Carrier
(phase) delay
M
2012-10-17 Dan Ellis 1
ELEN E4810: Digital Signal Processing
Topic 6:
Filters - Introduction
1. Simple Filters
2. Ideal Filters
3. Linear Phase and FIR filter types
2012-10-17 Dan Ellis 2
1. Simple Filters
LSI systems:
h
L
[n] = {
1
/
2
1
/
2
}
(2 pt moving avg.)
H
L
z
( )
=
1
2
1+ z
1
( )
=
z +1
2z
1
ZP
zero at
z = -1
H
L
e
j
( )
= e
j 2
cos 2
( )
n
-1 1 2 3 4 -2
1
/
2
h
L
[n]
!
|H
L
(e
j!
)|
1
/
2
sample delay
e
j!/2
+e
-j!/2
2012-10-17 Dan Ellis 5
If
then
H e
j
c
( )
2
=
1
2
max H e
j
( )
2
{ }
H =
1
2
H
max
Simple FIR Lowpass
!
!
c
|H(e
j!
)|
H e
j
( )
= cos 2
( )
c
= 2cos
1
1
2
=
2
1
1/2
0.707
/2
2012-10-17 Dan Ellis 6
deciBels
A gain of 0 corresponds to - dB
deciBels
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1/2
1
/
|
H
(
e
j
)
|
0 0.2 0.4 0.6 0.8 1
-20
-15
-10
-5
-3
0
/
|
H
(
e
j
)
|
/
d
B
2012-10-17 Dan Ellis 8
Simple FIR Highpass
h
H
[n] = {
1
/
2
-
1
/
2
}
3dB point !
c
=
/
2
(again)
H
H
z
( )
=
1
2
1 z
1
( )
=
z 1
2z
1
ZP
zero at
z = 1
H
H
e
j
( )
= je
j 2
sin 2
( )
!
|H
H
(e
j!
)|
n
-1 2 3 4 -2
1
/
2
h
H
[n]
-
1
/
2
!
c
/2
2012-10-17 Dan Ellis 9
FIR Lowpass and Highpass
Note:
h
L
[n] = {
1
/
2
1
/
2
} h
H
[n] = {
1
/
2
-
1
/
2
}
i.e.
)
|
|
H
(
e
j
)
|
freq /
0 0.5 1
0
0.5
1
10
-2
10
-1
10
0
10
-2
10
-1
10
0
1 1
10
Simple IIR Lowpass
IIR feedback, zeros and poles,
conditional stability, h[n] less useful
scale to make
gain = 1 at ! = 0
K = (1 - )/2
pole-zero
diagram
frequency
response
FR on
log-log axes
0dB
-20dB
-40dB
x[n]
z
-1
+
z
-1
+
y[n]
K
H
LP
(z) = K
1 +z
1
1 z
1
2012-10-17 Dan Ellis 11
Simple IIR Lowpass
Cutoff freq. !
c
from
H
LP
z
( )
= K
1+ z
1
1z
1
H
LP
e
j
c
( )
2
=
max
2
max = 1
using K=(1-)/2
1
( )
2
4
1+ e
j
c
( )
1+ e
j
c
( )
1e
j
c
( )
1e
j
c
( )
=
1
2
cos
c
=
2
1+
2
=
1 sin
c
cos
c
Design Equation
2012-10-17 Dan Ellis
-1 0 1
-1
-0.5
0
0.5
1
z-plane
Freq /
Freq /
|
H
(
e
j
)
|
/
d
B
|
H
(
e
j
)
|
10
-2
10
-1
10
0
-40
-30
-20
-10
0
0 0.5 1
0
0.5
1
1
1
12
Simple IIR Highpass
Pass ! = H
HP
(-1) = 1
K = (1+)/2
Design Equation:
(again)
=
1 sin
c
cos
c
H
HP
(z) = K
1z
1
1 z
1
2012-10-17 Dan Ellis 13
Highpass and Lowpass
Then:
However,
(unless H(e
j!
) is pure real - not for IIR)
Highpass
c/w (-1)
n
h[n]
just another z poly
H
LP
(e
j
) =
1 0
0 large
1 H
LP
(e
j
) =
0 0
1 large
|1 H
LP
(z)| = 1 |H
LP
(z)|
2012-10-17 Dan Ellis
-1 0 1
1
0.5
0
0.5
1
z-plane
/
/
|
H
(
e
j
w
)
|
|
H
(
e
j
w
)
|
/
d
B
0 0.5 1
0
0.5
1
10
-2
10
-1
10
0
-40
-30
-20
-10
0
r
B
14
Simple IIR Bandpass
H
BP
z
( )
=
1
2
1 z
2
1 1+
( )
z
1
+z
2
= K
1+ z
1
( )
1 z
1
( )
1 2r cos z
1
+ r
2
z
2
where
Center freq
3dB bandwidth
r = cos =
1+
( )
2
B = cos
1
2
1+
2
c
= cos
1
D
e
s
i
g
n
B 1/2
2012-10-17 Dan Ellis 15
Simple Filter Example
c
= 0.4 = cos
c
= 0.3090
B = 0.1
2
1+
2
= cos 0.1
( )
= 0.7265
H
BP
z
( )
=
1
2
1 z
2
1 1+
( )
z
1
+z
2
=
0.1367 1 z
2
( )
1 0.5335z
1
+ 0.7265z
2
M
sensitive..
2012-10-17 Dan Ellis
/
/
|
H
(
e
j
w
)
|
|
H
(
e
j
w
)
|
/
d
B
-1 0 1
-1
-0.5
0
0.5
1
0 0.5 1
0
0.5
1
10
-2
10
-1
10
0
-40
-30
-20
-10
0
z-plane
16
Simple IIR Bandstop
Design eqns:
H
BS
z
( )
=
1+
2
1 2z
1
+ z
2
1 1+
( )
z
1
+z
2
zeros at !
c
(per 1 - 2r cos z
-1
+ r
2
z
-2
)
same poles as H
BP
B = cos
1
2o
1+o
2
|
\
|
.
|
o =
1
cos B
1
cos
2
B
1
c
= cos
1
= cos
c
B
2012-10-17 Dan Ellis 17
Cascading Filters
)
|
19
Cascading Filters
M
j=1
(1
j
z
1
)
N
k=1
(1
k
z
1
)
X(z)
y[n] =
M
j=0
p
j
x[n j]
N
k=1
d
k
y[n k]
h
[
k
]
x[n k]
0
1
2
3
0
0 W
W
\He
jW
\
[He
jW
]
DTFT
IDTFT
Z
T
I
Z
T
X(e
j
) =
n
x[n]e
jn
x[n] =
1
2
X(e
j
)e
jn
d
j
p
j
x[n j]
j
p
j
z
j
X(z)
X
(
z
)
=
n
x
[n
]z
n
X(e
j
) = X(z)|
z=e
j
y
c
[n] + y
p
[n] =
n
i
+
n
0
n 0
x[n] y[n] +
z
p
0
p
1
p
2
-d
1
-d
2
-1
z
-1
z
-1
z
-1
Re{z}
Im{z}
0
1
1
0
0
*
*
[n
]
1
1
1 |z
|
>
|
|
2012-10-17 Dan Ellis 21
2. Ideal filters
Ideal characteristics
would be like:
!
!
c
!
c
h n
[ ]
= IDTFT H e
j
( ) { }
=
1
2
H e
j
( )
e
jn
d
=
1
2
e
jn
d
h n
[ ]
=
sin
c
n
n
Ideal lowpass filter
0
2012-10-17 Dan Ellis 23
Ideal Lowpass Filter
Problems!
easier to design...
Practical filter specifications
|
H
(
e
j
!
)
|
/
d
B !
-40
-1
1
Pass band Stop band
T
r
a
n
s
i
t
i
o
n
allow PB ripples
allow SB ripples
allow transition band
2012-10-17 Dan Ellis 25
|H(e
j!
)| alone can hide phase distortion
4 types:
Odd length Even length
Symmetric
Anti-
symmetric
Type 1 Type 2
Type 3 Type 4
n n
n
n
0 N N/2
2012-10-17 Dan Ellis
0.4 0.2 0 0.2 0.4 0.6 0.8 1
-1
-0.5
0
0.5
1
/
n=1
n=2
28
Linear Phase FIR: Type 1
H e
j
( )
= h n
[ ]
e
jn
n=0
N
= e
j
N
2
h
N
2
[ ]
+ 2 h
N
2
n
[ ]
cosn
n=1
N / 2
( )
linear phase
D = -(!)/! = N/2
pure-real H(!) from cosine basis
~
!
H(!)
~
2012-10-17 Dan Ellis
0 2 4 6 8 1 3 5 7 n
0
1
2
3
4
5
-10
0
10
20
- -0. 5 0 0.5 - -0. 5 0 0.5
-
-0.5
0
0.5
( )
= 0
Reciprocal zeros
(as well as cpx conj)
Reciprocal
pair
Conjugate
reciprocal
constellation
No reciprocal
on u.circle
= -D!
-2
2012-10-17 Dan Ellis
0.4 0.2 0 0.2 0.4 0.6 0.8 1
1
0.5
0
0.5
1
/
n -
1
/
2
=
1
/
2
n -
1
/
2
= 1
1
/
2
n -
1
/
2
= 2
1
/
2
30
Linear Phase FIR: Type 2
H e
j
( )
= e
j
N
2
h
N+1
2
n
[ ]
cos n
1
2
( )
n=1
N+1
( )
/ 2
Non-integer delay
of N/2 samples
H(!) from double-length cosine basis
~
always
zero
at !=
2012-10-17 Dan Ellis
0 2 4 6 8 10
0
1
2
3
4
5
- -0.5 0 0.5
- -0.5 0 0.5
-20
0
20
-0.5
0
0.5
-
-2 -1 0 1 2
-1
-0.5
0
0.5
1
Impulse Response Magnitude Response
Phase Response
Pole-zero diagram
31
Linear Phase FIR: Type 2
Zeros:
at z = -1,
H z
( )
= z
N
H
1
z
( )
H 1
( )
= 1
( )
N
H 1
( )
H e
j
( )
= 0
odd
LPF-like
dB
2012-10-17 Dan Ellis
-0. 4 -0. 2 0 0.2 0.4 0.6 0.8 1
-1
-0. 5
0
0.5
1
/
n
= 2
n = 1
odd
functions
zero at
= 0,
32
Linear Phase FIR: Type 3
H e
j
( )
= h
N
2
n
[ ]
e
j
N
2
n
( )
e
j
N
2
+n
( )
( )
n=1
N / 2
= je
j
N
2
2 h
N
2
n
[ ]
n=1
N / 2
sinn
( )
(!) = /2 - !N/2
Antisymmetric
/2 phase shift in
addition to linear phase
2012-10-17 Dan Ellis
- -0.5 0 0.5
- -0.5 0 0.5 -2 -1 0 1 2
Impulse Response Magnitude Response
Phase Response
Pole-zero diagram
0 2 4 6 8 10
-2
0
2
-20
0
20
-0.5
0
0.5
-
33
Linear Phase FIR: Type 3
Zeros:
H z
( )
= z
N
H
1
z
( )
H 1
( )
= H 1
( )
= 0 ; H 1
( )
= H 1
( )
= 0
2012-10-17 Dan Ellis 34
Linear Phase FIR: Type 4
H e
j
( )
= je
j
N
2
2 h
N+1
2
n
[ ]
n=1
N / 2
sin n
1
2
( )
fractional-sample
delay
/2 offset offset sine basis
0.4 0.2 0 0.2 0.4 0.6 0.8 1
1
0.5
0
0.5
1
/
odd
functions
n -
1
/
2
=
1
/
2
n -
1
/
2
= 1
1
/
2
2012-10-17 Dan Ellis 35
Linear Phase FIR: Type 4
Zeros:
(H(-1) OK because N is odd)
H 1
( )
= H 1
( )
= 0
- -0.5 0 0.5
Impulse Response Magnitude Response
Phase Response
Pole-zero diagram
-20
0
20
-0.5
0
0.5
-
0 2 4 6 8 10
-4
-2
0
2
4
-2 0 2
-1
0
1
- -0.5 0 0.5
dB
h[n]
n
!
H(!)
~
ZP
D
h[n]
n
!
H(!)
~
ZP
D
Thus,
G z
( )
= g n
[ ]
z
n
n
= h n
[ ]
z
nL
n
= H z
L
( )
L-1 zeros
2012-10-31 Dan Ellis 5
Comb Filters
Low-pass response
e.g.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
400
300
200
100
0
Normalized Frequency ( rad/sample)
P
h
a
s
e
(
d
e
g
r
e
e
s
)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
20
15
10
5
0
5
Normalized Frequency ( rad/sample)
M
a
g
n
i
t
u
d
e
(
d
B
)
2012-10-31 Dan Ellis 7
Allpass Filters
A
M
(z) has poles where D
M
() = 0
A
M
(z) has zeros = 1/ =
-1
A
M
z
( )
=
d
M
+ d
M1
z
1
+ ... + d
1
z
M1
( )
+ z
M
1+ d
1
z
1
+ ... + d
M1
z
M1
( )
+ d
M
z
M
= z
M
D
M
z
1
( )
D
M
z
( )
mirror-image
polynomials
=
2012-10-31 Dan Ellis 8
Allpass Filters
Any (stable) D
M
can be used:
Phase is always
decreasing:
-M at ! =
A
M
z
( )
= z
M
D
M
z
1
( )
D
M
z
( )
poles
from 1/D
M
(z)
reciprocal
zeros
from D
M
(z
-1
)
M
peak
group
delay
0 0.2 0.4 0.6 0.8 1
3
2
0
/
a
r
g
{
H
(
z
)
}
3 2 1 0 1 2
1
0
1
Re{z}
I
m
{
z
}
2012-10-31 Dan Ellis 9
Why do mirror-img polys give const gain?
z = e
j!
z
-1
= e
-j!
also on u.circle...
Allpass Filters
A
M
z
( )
=
K z
i
*
1
( )
i
z
i
( )
i
=
K
i
*
1
z
i
*
z
1
( )
i
z
i
( )
i
e
j!
e
-j!
ZP
i
o
+ complex
conjugate p/z
i
*
1
i
*
2012-10-31 Dan Ellis 10
2. Minimum/Maximum Phase
reciprocals of zeros?
Variants of filters with same magnitude
response, different phase
2012-10-31 Dan Ellis 11
Minimum/Maximum Phase
Hence:
reciprocal
zero..
.. added
phase
lag
.. same
mag..
0
1
2
3
0 0.2 0.4 0.6 0.8 /
-
-0.5
0
0.5
1
2
3
0 0.2 0.4 0.6 0.8 /
-
-0.5
0
0.5
a a
b 1/b
0
H
1
(z) =
z - b
z - a
H
2
(z) =
b(z - 1/b)
z - a
|H(e
j
)|
(H(e
j
))
2012-10-31 Dan Ellis 12
Minimum/Maximum Phase
Note:
Min. phase + Allpass = Max. phase
o
o
o
o
o
o
z
( )
z
*
( )
z
z
1
( )
z
1
*
( )
z
( )
z
*
( )
z
1
( )
z
1
*
( )
z
x =
pole-
zero
cancln
2012-10-31 Dan Ellis 14
Inverse Systems
h
i
[n] is called the inverse of h
f
[n] iff
Z-transform:
i.e. H
i
(z) recovers x[n] from o/p of H
f
(z)
h
i
n
[ ]
h
f
n
[ ]
= n
[ ]
H
f
e
j
( )
H
i
e
j
( )
=1
H
f
(z) H
i
(z)
x[n] y[n] w[n]
W z
( )
= H
i
z
( )
Y z
( )
= H
i
z
( )
H
f
z
( )
X z
( )
= X z
( )
w n
[ ]
= x n
[ ]
2012-10-31 Dan Ellis 15
What is H
i
(z)?
H
i
(z) is reciprocal polynomial of H
f
(z)
Just swap
poles and
zeros:
Inverse Systems
H
i
z
( )
H
f
z
( )
=1
H
i
z
( )
=1/ H
f
z
( )
H
f
z
( )
=
P z
( )
D z
( )
H
i
z
( )
=
D z
( )
P z
( )
poles of fwd
zeros of bwd
zeros of fwd
poles of bwd
o
o
o
H
f
(z) H
i
(z)
2012-10-31 Dan Ellis 16
Inverse Systems
When does H
i
(z) exist?
Causal+stable all H
i
(z) poles inside u.c.
all zeros of H
f
(z) must be inside u.c.
H
f
(z) must be minimum phase
H
f
(z) zeros outside u.c. unstable H
i
(z)
H
f
(z) zeros on u.c. unstable H
i
(z)
only invert if min.phase, H
f
(e
j!
) 0
H
i
e
j
( )
=1/ H
f
e
j
( )
=1/ 0
=
!
lose...
2012-10-31 Dan Ellis 17
System Identification
H(z)
x[n] y[n]
y n
[ ]
= h k
[ ]
x n k
[ ]
k=0
y 0
[ ]
= h 0
[ ]
x 0
[ ]
h 0
[ ]
y 1
[ ]
= h 0
[ ]
x 1
[ ]
+ h 1
[ ]
x 0
[ ]
h 1
[ ]
...
but: errors
accumulate
deconvolution
2012-10-31 Dan Ellis 18
System Identification
If r
xx
is simple, can recover h
?
[n]...
Approach
+ z
-1
-
"
w
1
w
2
w
3
+
W
1
= X z
1
W
3
W
2
= W
1
z
1
W
2
W
3
= z
1
W
2
+W
2
Y = z
1
W
3
+ W
1
W
2
=
W
1
1+z
1
W
3
=
z
1
+
( )
W
1
1+z
1
Y
X
=
+ z
1
+
( )
+ z
2
( )
1+ z
1
+
( )
+ z
2
( )
stackable
2nd order section
2012-10-31 Dan Ellis 23
Delay-Free Loops
Algebra:
x
+
y
+
u
v
x
y
+
u
v
+
1
1 BA
B
1 BA
B
1 BA
BA
1 BA
can simplify...
y = B(v +Au) u = x +y
y = B(v +A(x +y))
y(1 BA) = Bv +BAx
y =
Bv +BAx
1 BA
2012-10-31 Dan Ellis 24
Equivalent Structures
e.g. Commutation H = AB = BA
A(z)B(z)
+
C(z)B(z)
x
1
x
2
y
A(z)
+
x
1
x
2
y
C(z)
B(z)
fewer blocks less computation
2012-10-31 Dan Ellis 25
Equivalent Structures
Transpose
reverse paths
addersnodes
inputoutput
+
z
-1
z
-1
y x b
1
b
2
b
3
+
z
-1
z
-1
x y b
1
b
2
b
3
+
Y = b
1
X + b
2
z
1
X + b
3
z
2
X
= b
1
X + z
1
b
2
X + z
1
b
3
X
( )
2012-10-31 Dan Ellis 26
FIR Filter Structures
Transpose
y
z
-1
+
z
-1
+
z
-1
+
z
-1
+
x
h
4
h
3
h
2
h
1
h
0
y
2012-10-31 Dan Ellis 27
FIR Filter Structures
Cascade
0
+
2012-10-31 Dan Ellis 28
FIR Filter Structures
Linear Phase:
Symmetric filters with h[n] = (-)h[N - n]
real root
2012-10-31 Dan Ellis 33
Cascade IIR Structure
Implement as cascade of
second order sections (in DFII)
1
x y
2
2
+
2
2
(
2
2
+
2
2
)
fwd gain
factored
out
z
-1
z
-1
2012-10-31 Dan Ellis 34
Second-Order Sections
Free choices:
order of sections
z
1
=1
N
= 1
z
1
( )
F z
( )
z=
H(z) =
0
+
0k
+
1k
z
1
1+
1k
z
1
+
2k
z
2
k
Why do this?
stability/sensitivity
01
11
+
z
-1
z
-1
-
11
-
21
+
0
+
02
12
+
z
-1
z
-1
-
12
-
22
x
y
2012-11-12 Dan Ellis 1
ELEN E4810: Digital Signal Processing
Topic 8:
Filter Design: IIR
1. Filter Design Specifications
2. Analog Filter Design
3. Digital Filters from Analog Prototypes
2012-11-12 Dan Ellis 2
1. Filter Design Specifications
Best filter:
Or, ripple
1
1+
2
max
= 20log
10
1+
2
dB
PB ripple
parameter
1
\G(e
jW
)\
Passband
detail
s
= 20log
10
1
A
= 20log
10
A dB
0
freqW
Stopband
detail
1
A
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 P
-40
-30
-20
-10
0
\G(e
jW
)\
2012-11-12 Dan Ellis 7
Filter Type Choice: FIR vs. IIR
FIR
No feedback
(just zeros)
Always stable
Can be
linear phase
High order
(20-2000)
Unrelated to
continuous-
time filtering
IIR
Feedback
(poles & zeros)
May be unstable
Difficult to control
phase
Derive from
analog prototype
BUT
2012-11-12 Dan Ellis 8
FIR vs. IIR
Basic choices:
H
d
z
( )
= h
d
n
[ ]
z
n
Transform
Frequency
response
Pole/zero
diagram
H
a
j
( )
H
d
e
j
( )
s-plane
Re{s}
Im{s}
j
stable
poles
stable
poles
z-plane
Re{z}
Im{z}
1
e
j!
s scales freq
2012-11-12 Dan Ellis 12
Maximally flat in pass and stop bands
Magnitude
response (LP):
c
,
|H
a
(j)|
2
1
=
c
,
|H
a
(j)|
2
=
1
/
2
Butterworth Filters
H
a
j
( )
2
=
1
1+
c
( )
2N
filter
order
N
3dB point
0 1 2 3
0
0.2
0.4
0.6
0.8
1
\
H
a
(
j
7
)
\
7/7
c
N
N
2012-11-12 Dan Ellis 13
Butterworth Filters
c
, |H
a
(j)|
2
(
c
/)
2
N
flat
@ = 0 for n = 1 .. 2N-1
d
n
d
n
H
a
j
( )
2
= 0
Log-log
magnitude
response
6N dB/oct
rolloff
10
-1
10
0
10
1
-70
-60
-50
-40
-30
-20
-10
0
\
H
a
(
j
7
)
\
/
d
B
7/7
c
N
N
slope
-6N dB/oct
2012-11-12 Dan Ellis
\H
a
(j7)\
7
7
p
7
s
A
14
Butterworth Filters
1
1 +
p
c
( )
2N
1
1 +
2
1
1 +
s
c
( )
2N
1
A
2
k
1
=
A
2
1
=discrimination, 1
k =
s
=selectivity, < 1
N
1
2
log
10
A
2
1
2 ( )
log
10
s
p
( )
Design
Equation
2012-11-12 Dan Ellis 15
Butterworth Filters
In fact,
where
H
a
j
( )
2
=
1
1+ (
c
)
2N
H
a
s
( )
=
1
s p
i
( )
i
p
i
=
c
e
j
N+2i1
2N
i =1..N
s-plane
Re{s}
Im{s}
c
2N
= 1
odd-indexed uniform divisions of
c
-radius circle
2012-11-12 Dan Ellis
7
1kHz
7
p
5kHz
7
s
A
0 dB
= -1 dB
= -40 dB
16
Butterworth Example
1dB= 20log
10
1
1+
2
2
= 0.259
40dB= 20log
10
1
A
A =100
Design a Butterworth
filter with 1 dB cutoff
at 1kHz and a
minimum attenuation
of 40 dB at 5 kHz
p
= 5
N
1
2
log
10
9999
0.259
log
10
5
N = 4 3.28
2012-11-12 Dan Ellis
0 2000 4000 6000
-60
-50
-40
-30
-20
-10
0
freq / Hz
g
a
i
n
/
d
B
17
Butterworth Example
from a table,
-1dB
= 0.845 when
c
= 1
c
= 1000/0.845 = 1.184 kHz
p
)
T
N
() =
cos(N cos
1
) || 1
cosh(N cosh
1
) || > 1
2012-11-12 Dan Ellis 19
Chebyshev I Filter
-2
0
-1
1
2
T
5
(7)
-1
0
1
2
3
T
5
2
(7)
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
0
0.5
1
1/(1+0.1 T
5
2
(7
7
))
T
N
() =
cos(N cos
1
) || 1
cosh(N cosh
1
) || > 1
|H(j)|
2
=
1
1 +
2
T
2
N
(
p
)
2012-11-12 Dan Ellis 20
Chebyshev I Filter
Design procedure:
p
)
=
1
1+
2
cosh N cosh
1
s
p
( )
[ ]
2
N
cosh
1
A
2
1
( )
cosh
1
s
p
( )
1/k
1
, discrimination
1/k, selectivity
2012-11-12 Dan Ellis 21
Chebyshev I Filter
What is H
a
(s)?
p
)
T
N
(
)
2
zeros on imaginary axis
constant
~1/T
N
(1/)
0 0.5 1 1.5 2
-60
-50
-40
-30
-20
-10
0
7
g
a
i
n
/
d
B
N
N
peak of
stopband
ripples
2012-11-12 Dan Ellis
0 0.5 1 1.5 2
-60
-50
-40
-30
-20
-10
0
7
g
a
i
n
/
d
B
N
N
peak
SB
ripples
PB
ripple
depth
23
Elliptical (Cauer) Filters
p
)
function; satisfies
R
N
(
-1
) = R
N
()
-1
zeros for <1 poles for >1
2012-11-12 Dan Ellis 24
Analog Filter Types Summary
N = 6
r = 3 dB
A = 40 dB
0 0.5 1 1.5 2
-60
-50
-40
-30
-20
-10
0
0 0.5 1 1.5 2
-60
-50
-40
-30
-20
-10
0
0 0.5 1 1.5 2
-60
-50
-40
-30
-20
-10
0
0 0.5 1 1.5 2
-60
-50
-40
-30
-20
-10
0
c
g
a
i
n
/
d
B
g
a
i
n
/
d
B
g
a
i
n
/
d
B
g
a
i
n
/
d
B
Butterworth Chebyshev I
Chebyshev II Elliptical
p
r
r
A A
p
2012-11-12 Dan Ellis 25
Analog Filter Transformations
i.e.
Example transformation:
take prototype H
LP
(s) polynomial
replace s with
p
p
s
p
p
s
^
2012-11-12 Dan Ellis 27
Lowpass-to-Highpass
=
p
p
=
p
=
p
<
p
<
p
LP passband HP passband
>
p
>
p
LP stopband HP stopband
imaginary axis
stays on self...
...freq.freq.
7
7p
7
^
7p
^
LPF
HPF
2012-11-12 Dan Ellis 28
Transformation Example
Design a Butterworth highpass filter
with PB edge -0.1dB @ 4 kHz (
p
)
and SB edge -40 dB @ 1 kHz (
s
)
Butterworth -0.1dB @
p
=1, -40dB @
s
=4
^
^
s
=
( )
p
p
s
=
( )
4
N
1
2
log
10
A
2
1
2 ( )
log
10
s
p
( )
p
@ 0.1dB
1
1+ (
c
)
10
=10
0.1
10
c
=
p
/ 0.6866 =1.4564
N=5, 2N=10
2012-11-12 Dan Ellis 29
Transformation Example
Map to HPF:
p
=
c
e
j
N+21
2N
Re{s}
Im{s}
H
LP
s ( ) =
c
N
s p
( )
=1
N
H
HP
s
( )
= H
LP
s
( )
s=
p
p
s
H
HP
s
( )
=
c
N
p
p
s
p
( )
=1
N
=
c
N
s
N
p
p
p
s
( )
=1
N
N zeros
@ s = 0
^
new poles @ s =
p
p
/p
l
^
^
2012-11-12 Dan Ellis 30
Transformation Example
In Matlab:
[N,Wc]=buttord(1,4,0.1,40,'s');
[B,A] = butter(N, Wc, 's');
[U,D] = lp2hp(B,A,2*pi*4000);
p
s
R
p
R
s
-2 -1 0 1
x 10
4
-1.5
-1
-0.5
0
0.5
1
1.5
x 10
4
Re{s}
I
m
{
s
}
0 1000 2000 3000 4000 5000
-60
-50
-40
-30
-20
-10
0
7 / Hz
g
a
i
n
/
d
B
2012-11-12 Dan Ellis 31
3. Analog Protos IIR Filters
Approach: transformation H
a
(s)G(z)
i.e.
where s = F(z) maps s-plane z-plane:
G z
( )
= H
a
s
( )
s=F z
( )
s-plane
Re{s}
Im{s}
z-plane
Re{z}
Im{z}
1
H
a
(s
0
)
G(z
0
)
Every value of G(z)
is a value of H
a
(s)
somewhere on the
s-plane & vice-versa
s = F(z)
z = F
-1
(s)
2012-11-12 Dan Ellis 32
CT to DT Transformation
Solution:
Hence inverse:
Freq. axis?
Poles?
Bilinear
Transform
z =
1+ s
1 s
unique,
1:1 mapping
s = j z =
1+ j
1 j
|z| = 1 i.e.
on unit circle
s = + j z =
1+
( )
+ j
1
( )
j
z
2
=
1+ 2 +
2
+
2
1 2 +
2
+
2
< 0
|z| < 1
s =
1 z
1
1 +z
1
=
z 1
z +1
2012-11-12 Dan Ellis
-4 -2 0 2 4
-4
-3
-2
-1
0
1
2
3
4
-4 -2 0 2 4
-4
-3
-2
-1
0
1
2
3
4
34
Bilinear Transformation
i.e.
nonlinear; as !
z = e
j
s =
1e
j
1+e
j
=
2 j sin / 2
2 cos / 2
= j tan
2
u.circle
im.axis
= tan
2
( )
= 2 tan
1
< <
< <
d
d
|H
a
(j)|
|G(e
j
)|
= 2tan
1
()
2012-11-12 Dan Ellis 37
Design Procedure
H
a
(s), CT filter polynomial
Convert to DT domain:
p
,
s
,
1
1+
2
,
1
A
p
= tan
p
2
s
= tan
s
2
p
,
s
,
1
1+
2
,
1
A
G z
( )
= H
a
s
( )
s=
1z
1
1+z
1
Old-
style
2012-11-12 Dan Ellis 38
Bilinear Transform Example
DT domain requirements:
Lowpass, 1 dB ripple in PB, !
p
= 0.4,
SB attenuation 40 dB @ !
s
= 0.5,
attenuation increases with frequency
PB ripples,
SB monotonic
Chebyshev I
0.4 0. 1 5
WP
-40
-1
0
|
G
(
e
j
W
)
|
/
d
B
2012-11-12 Dan Ellis 39
Bilinear Transform Example
Warp to CT domain:
Magnitude specs:
1 dB PB ripple
40 dB SB atten.
p
= tan
p
2
= tan 0.2 = 0.7265 rad/sec
s
= tan
s
2
= tan 0.25 =1.0 rad/sec
1
1+
2
=10
1/ 20
= 0.8913 = 0.5087
1
A
=10
40 / 20
= 0.01 A =100
2012-11-12 Dan Ellis
0 0.5 1 1.5 2
-60
-50
-40
-30
-20
-10
0
0 0.2 0.4 0.6 0.8 1
-60
-50
-40
-30
-20
-10
0
\
H
a
(
j
7
)
\
/
d
B
7 W/P
\
G
(
e
j
W
)
\
/
d
B
CT DT
40
Bilinear Transform Example
( )
cosh
1
s
p
( )
= 7.09 i.e. need N = 8
>> N=8;
>> wp=0.7265;
>> pbripple = 1.0;
>> [B,A] = cheby1(N,pbripple,wp,'s');
>> [b,a] = bilinear(B,A,.5);
M
freqs(B,A) freqz(b,a)
2012-11-12 Dan Ellis 41
Other Filter Shapes
i.e.
Simplest mapping
has effect of warping frequency axis:
z = F z
( )
=
z
1 z
tan
2
( )
=
1+
1
tan
2
( )
> 0 :
expand HF
< 0 :
expand LF
z e
j
z e
j
e
j
1 e
j
0 0.2 0.4 0.6 0.8 P
W
W
^
0
0.2
0.4
0.6
0.8
P
A = 0.6
A = -0.6
2012-11-12 Dan Ellis 44
Another Design Example
Spec:
Frequency prewarping
800 Hz @ SR = 8kHz
= 800/8000 x 2 rad/sample
L
=0.2 ,
U
=1600/8000 x 2 =0.4
L
= tan
L
/2 = 0.3249,
U
= 0.7265
FIR filters
Approaches
Given desired FR H
d
(e
j!
), what is the
best finite h
t
[n] to approximate it?
= DTFT{h
t
[n]}
2012-11-19 Dan Ellis 4
Least Integral-Squared Error
Ideal IR is h
d
[n] = IDTFT{H
d
(e
j!
)},
(usually infinite-extent)
By Parseval, ISE
But: h
t
[n] only exists for n = -M..M ,
= h
d
n
[ ]
h
t
n
[ ]
2
n=
= h
d
n [ ] h
t
n [ ]
2
n=M
M
+ h
d
n [ ]
2
n<M, n>M
minimized by making
h
t
[n] = h
d
[n], -M n M
not altered by h
t
[n]
2012-11-19 Dan Ellis 5
Least Integral-Squared Error
1
2
H
d
(e
j
)e
jn
d M n M
0 otherwise
2012-11-19 Dan Ellis
-20 -15 -10 -5 0 5 10 15
-0.05
0
0.05
0.1
0.15
0.2
n
h[n]
6
Approximating Ideal Filters
From topic 6,
ideal lowpass
has:
and:
!
!
c
!
c
(doubly infinite)
H
LP
(e
j
) =
1 || <
c
0
c
< || <
h
LP
[n] =
sin
c
n
n
2012-11-19 Dan Ellis 7
Approximating Ideal Filters
h
LP
[n] =
sin
c
(nM)
(nM)
0 n 2M
0 otherwise
2012-11-19 Dan Ellis
0 0.2 0.4 0.6 0.8
WP
-0.2
0
0.2
0.4
0.6
0.8
1
1.2
H
t
(
e
j
W
)
129
point
25
point
Gibbs ears
8
Gibbs Phenomenon
Truncation of h
d
[n] to 2M+1 points is
multiplication by a rectangular window:
1 M n M
0 otherwise
g[n] h[n]
1
2
G(e
j
)H(e
j()
)d
2012-11-19 Dan Ellis
W
P P
W
P P
W
P P
10
Where Gibbs comes from
Rectangular window:
Mainlobe width
( 1/L) determines
transition band
Sidelobe height
determines ripples
periodic sinc
invariant
with length
-P -0.5P 0 0.5P P
0
W
R
(e
jW
)
W
pP
2M + 1
Mainlobe
Sidelobes
/
w
R
[n] =
1 M n M
0 otherwise
W
R
(e
j
) =
M
n=M
e
jn
=
sin(2M+1)
2
sin
2
2012-11-19 Dan Ellis 12
2. Window Shapes for Filters
Rectangular:
Hann:
Hamming:
Blackman:
w n
[ ]
=1 M n M
0.5 + 0.5cos(2
n
2M+1
)
0.54 + 0.46cos(2
n
2M+1
)
double width
mainlobe
reduced 1st
sidelobe
triple width
mainlobe
big
sidelobes!
2012-11-19 Dan Ellis
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 P
W
-80
-70
-60
-50
-40
-30
-20
-10
0
Blackman
Hamming
Hann
Rectangular \
W
(
e
j
W
)
\
/
d
B
14
Window Shapes for FIR Filters
Comparison on dB scale:
2
2M+1
2012-11-19 Dan Ellis 15
Adjustable Windows
4 kHz
0.15
600 Hz
H(e
j!
)
c
=
600
8000
2 = 0.15
(f
s
)
2012-11-19 Dan Ellis 17
Windowed Filter Example
1. Get ideal filter impulse response:
2. Get window:
Hamming @ N = 25 M = 12 (N = 2M+1)
3. Apply window:
c
= 0.15
h
d
n
[ ]
=
sin0.15n
n
w n
[ ]
= 0.54 + 0.46cos 2
n
25
( )
12 n 12
h n
[ ]
= h
d
n
[ ]
w n
[ ]
=
sin0.15n
n
0.54 + 0.46cos
2n
25
( )
12 n 12
M
-20 -10 0 10
n
h[n]
0
0.05
0.1
0.15
2012-11-19 Dan Ellis 18
Freq. Resp. (FR) Arithmetic
t
w
o
r
k
i
f
p
h
a
s
e
s
w
e
r
e
n
o
n
z
e
r
o
!
+
=
0
2012-11-19 Dan Ellis 19
3. Iterative FIR Filter Design
p
d
error
measurement
region
error
weighting
desired
response
actual
response
exponent:
2 least sq
minimax
= W(!)[D(e
j!
) H(e
j!
)]
W
1
W
2
W
3
W
4
W
W
H(e
jW
)
W(W)
R
D(e
jW
)
W
E(W)
2012-11-19 Dan Ellis 21
Minimax FIR Filters
linear-phase
symmetric IR h[n] = ()h[-n]
a[0] = h[M]
a[k] = 2h[M - k]
n
M
(type I
order 2M)
2012-11-19 Dan Ellis 22
Minimax FIR Filters
H() =
M
k=0
a[k]cos(k) =
M
k=0
[k](cos)
k
H
( )
= a k
[ ]
cos k
( )
k=0
M
An M
th
order polynomial has at most
M - 1 maxima and minima:
has at most M-1 min/max (ripples)
H
( )
= k
[ ]
cos
( )
k
k=0
M
M
th
order
polynomial in cos!
H
( )
5
th
order
polynomial
in cos!
1
2
3
4
-1 -0.5 0 0.5 1
-0.2
-0.1
0
0.1
0.2
0 0.2 0.4 0.6 0.8 P
W WP
-0.2
-0.1
0
0.1
0.2
cosW
cosW
W
1
2
3
4
M
k=0
[k](cos )
k
H()
2012-11-19 Dan Ellis 24
0
<
1
< ... <
M
<
M+1
i
( )
= i
i
( )
=
i+1
( )
By Alternation Theorem,
M+2 extrema of alternating signs
optimal minimax filter
For M = 5 (10
th
order):
8 extrema (M+3,
4 band edges)
- great!
7 extrema (M+2,
3 band edges)
- OK!
6 extrema (M+1,
only 2 transition
band edges)
NOT OPTIMAL
0 0.2 0.4 0.6 0.8 P
W
W
H
1
W
~
H
2
W
~
H
3
W
~
W
P
P
0
0.5
1
0 0.2 0.4 0.6 0.8
0
0.5
1
0 0.2 0.4 0.6 0.8
0
0.5
1
2012-11-19 Dan Ellis 28
Parks-McClellan Algorithm
To recap:
Zero-phase FIR
H(!) =
k
k
cos
k
! M-1 min/max
Alternation theorem
optimal M+2 pk errs, alterng sign
Converges rapidly!
~ ~
M
2012-11-19 Dan Ellis 30
Parks-McClellan Algorithm
In Matlab,
>> h=firpm(10,[0 0.4 0.6 1],
[1 1 0 0],
[1 2]);
filter order (2M) band edges
desired magnitude
at band edges
error weights
per band
-5 0 5
-0.2
0
0.2
0.4
0.6
0 0.5 1
0
0.5
1
-1 0 1 2
-1
-0.5
0
0.5
1
h[n]
H(W)
n
W
~
z-plane
2012-11-28 Dan Ellis 1
ELEN E4810: Digital Signal Processing
Topic 10:
The Fast Fourier Transform
1. Calculation of the DFT
2. The Fast Fourier Transform algorithm
3. Short-Time Fourier Transform
2012-11-28 Dan Ellis 2
1. Calculation of the DFT
Matrix form:
X[k] = x[n]W
N
kn
n=0
N1
W
N
= e
j
2
N
( )
W
N
r
has only
N distinct values
W
N
@2/N
Structure
opportunities
for
efficiency
X[0]
X[1]
X[2]
.
.
.
X[N 1]
1 1 1 1
1 W
1
N
W
2
N
W
(N1)
N
1 W
2
N
W
4
N
W
2(N1)
N
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1 W
(N1)
N
W
2(N1)
N
W
(N1)
2
N
x[0]
x[1]
x[2]
.
.
.
x[N 1]
N complex multiplies
+ N-1 complex adds per point (k)
N points (k = 0.. N-1)
N points: 4N
2
real mults, 4N
2
-2N real adds
X[k] = x[n]W
N
kn
n=0
N1
Now:
i.e.
where
X k
[ ]
= x
[ ]
W
N
k
=0
N1
= W
N
kN
x
[ ]
W
N
k N
( )
looks like a
convolution
X k
[ ]
= y
k
N
[ ]
y
k
n
[ ]
= x
e
n
[ ]
h
k
[n]
x
e
[n] = {
x[n] 0 n < N
0 n = N
h
k
[n] = {
W
N
-kn
n 0
0 n < 0
+
z
-1
W
N
-k
x
e
[n]
x
e
[N] = 0
y
k
[n]
y
k
[-1] = 0
y
k
[N] = X[k]
2012-11-28 Dan Ellis 6
Goertzels Algorithm
= x 2m
[ ]
W
N
2mk
+ x 2m+1
[ ]
W
N
2m+1
( )
k
( )
m=0
N
2
1
= x 2m
[ ]
W
N
2
mk
m=0
N
2
1
+W
N
k
x 2m+1
[ ]
W
N
2
mk
m=0
N
2
1
But if DFT
N
{} ~ O(N
2
)
then DFT
N/2
{} ~ O((N/2)
2
) = 1/4 O(N
2
)
Total computation ~ 2 1/4 O(N
2
)
= 1/2 the computation (+") of direct DFT
DFT
N
x n
[ ] { }
= DFT
N
2
x
0
n
[ ] { }
+W
N
k
DFT
N
2
x
1
n
[ ] { }
x[n] for even n x[n] for odd n
2012-11-28 Dan Ellis 10
One-Stage DIT Flowgraph
Classic FFT structure
Even
points
from
x[n]
Odd
points
from
x[n]
Same as
X[0..3]
except for
factors on
X
1
[]
terms
twiddle factors:
always apply to
odd-terms output
NOT mirror-image
X k
[ ]
= X
0
k
N
2
[ ]
+W
N
k
X
1
k
N
2
[ ]
x[0]
x[2]
x[4]
x[6]
x[1]
x[3]
x[5]
x[7]
X[0]
X[1]
X[2]
X[3]
X[4]
X[5]
X[6]
X[7]
X
0
[0]
X
0
[1]
X
0
[2]
X
0
[3]
X
1
[0]
X
1
[1]
X
1
[2]
X
1
[3]
DFT
N
2
DFT
N
2
W
N
0
W
N
1
W
N
2
W
N
3
W
N
4
W
N
5
W
N
6
W
N
7
2012-11-28 Dan Ellis 11
i.e.
make:
Similarly,
Multiple DIT Stages
X k
[ ]
= X
0
k
N
2
[ ]
+W
N
k
X
1
k
N
2
[ ]
0 k < N
X
0
k
[ ]
= X
00
k
N
4
[ ]
+W
N
2
k
X
01
k
N
4
[ ]
0 k < N/2
N/4-pt DFT of even points
in even subset of x[n]
N/4-pt DFT of odd points
from even subset
X
1
k
[ ]
= X
10
k
N
4
[ ]
+W
N
2
k
X
11
k
N
4
[ ]
2012-11-28 Dan Ellis 12
Two-Stage DIT Flowgraph
x[0]
x[4]
x[2]
x[6]
x[1]
x[5]
x[3]
x[7]
X[0]
X[1]
X[2]
X[3]
X[4]
X[5]
X[6]
X[7]
X
0
[0]
X
00
X
01
X
10
X
11
X
0
[1]
X
0
[2]
X
0
[3]
X
1
[0]
X
1
[1]
X
1
[2]
X
1
[3]
DFT
N
4
DFT
N
4
DFT
N
4
DFT
N
4
W
N
0
W
N
1
W
N
2
W
N
3
W
N
4
W
N
5
W
N
6
W
N
7
W
N/2
3
W
N/2
0
W
N/2
3
W
N/2
0
different from before same as before
2012-11-28 Dan Ellis 13
Multi-stage DIT FFT
Can simplify:
W
N
r
W
N
r+N/2
X
X
[r]
X
X
[r+N/2]
X
X0
[r]
X
X1
[r]
2 cpx mults
X
X
[r]
X
X
[r+N/2]
X
X0
[r]
X
X1
[r]
W
N
r
-1
just one cpx mult!
i.e. SUB rather than ADD
2012-11-28 Dan Ellis 15
8-pt DIT FFT Flowgraph
W
N
0
disappears
Having N = 2
M
meant we could divide
each stage into 2 halves = radix-2 FFT
N = 3
M
radix-3
N = 4
M
radix-4 - more optimized radix-2
etc...
Recall IDFT:
Thus:
only differences
from forward DFT
Nx
*
[n] = X[k]W
N
nk
( )
*
k=0
N1
= X
*
[k]W
N
nk
k=0
N1
*
2012-11-28 Dan Ellis 18
Spectrum of
whole sequence
indicates
modulation
indirectly...
... as
cancellation
between
closely-
tuned
sines
2cAcB
= cA+B
+cA-B
Nsin2kn
N
-Nsin2(k-1)n
N 2
-Nsin2(k+1)n
N 2
0 0.02 0.04 0.06 0.08
0
200
400
600
N
N/2
\X[k]\
WP
k/(N/2)
-1
-0.5
0
0.5
1
-1
-0.5
0
0.5
1
0 128 256 384 512 640 768 896
-1
-0.5
0
0.5
1
M
2012-11-28 Dan Ellis 21
Fourier Transform of AM Sine
A[n] varies on a
different (slower) timescale
One approach:
frequency
index
time
index
N
FT
points of x
starting at n
window
DFT
kernel
2012-11-28 Dan Ellis 25
STFT Window Shape
e.g. rectangular
selects x[n], n
0
n < n
0
+N
W
Alternate tilings
of time-freq:
disks show blurring
due to window length;
area of disk is constant
Uncertainty principle:
ft k
half-length window half as many DFT samples
0 100 200 300
0
0.5
1
0
50
100
150
200
250
n
k
2012-11-28 Dan Ellis 29
Spectrograms of Real Sounds
individual t-f
cells merge
into continuous
image
time-domain
successive
short
DFTs
time / s
time / s
f
r
e
q
/
H
z
i
n
t
e
n
s
i
t
y
/
d
B
2.35 2.4 2.45 2.5 2.55 2.6
0
1000
2000
3000
4000
f
r
e
q
/
H
z
0
1000
2000
3000
4000
0
0.1
-50
-40
-30
-20
-10
0
10
0 0.5 1 1.5 2 2.5
2012-11-28 Dan Ellis 30
Narrowband vs. Wideband
= h
k
m
[ ]
x n
0
m
[ ]
m=0
N1
( )
h
k
n
[ ]
= w n
[ ]
e
j
2kn
N
just one freq.
convolution
with
complex IR
2012-11-28 Dan Ellis 33
STFT as a Filterbank
If
then
e.g. if
then
Can shift by n
0
, combine, to get x[n]:
Prefer to
overlap windows:
i.e. sample X[k,n
0
]
at n
0
= rH where H = N/2 (for example)
Then
hopsize window length
x n
[ ]
= x n
[ ]
w n rH
[ ]
r
= x n
[ ]
w n rH
[ ]
r
=1
if
n
^
x[n]
x[n]w[n-rH]
2012-11-28 Dan Ellis 36
STFT Analysis-Synthesis
i.e. relate
and
g n
[ ]
= g
a
nT
( )
Discrete Continuous
Sampling period T
samp.freq.
samp
= 2/T rad/sec
G
a
j
( )
= g
a
t
( )
e
jt
dt
G(e
j
) = g n
[ ]
e
jn
CTFT
DTFT
in rad/second
! in rad/sample
2012-12-05 Dan Ellis 4
Sampling
g
p
(t) = g
a
(t)p(t) is a CT signal with the
same information as DT sequence g[n]
t
t
t
p(t)
g
a
(t)
g
p
(t)
sampled signal:
still continuous
- but discrete
values
T 3T
= t nT
( )
n=
CT delta fn
Given CT
CTFT Spectrum
Compare to DTFT
i.e.
by linearity
! ~ T
~ !/T
/
T
=
samp
/2
g
p
(t) =
n=
g
a
(nT) (t nT)
G
p
(j) = F{g
p
(t)} =
n
g
a
(nT)F{(t nT)}
G
p
(j) =
n
g
a
(nT)e
jnT
G(e
j
) =
n
g[n]e
jn
G(e
j
) = G
p
(j)|
T=
2012-12-05 Dan Ellis 6
Spectra of sampled signals
But
so
p t
( )
= t nT
( )
n
p t
( )
=
1
T
e
j
2
T
( )
kt
k=
c
k
=
1
T
p t
( )
e
j 2kt / T
dt
T / 2
T / 2
=
1
T
F e
j
0
t
x t
( )
{ }
= X j
0
( ) ( )
shift in
frequency
G
p
j ( ) =
1
T
G
a
j k
samp
( ) ( )
k
G e
jT
( )
=
1
T
G
a
j k
samp
( ) ( )
k
DTFT CTFT
g
a
t
( )
G
a
j
( )
p t
( )
P j
( )
g
p
t
( )
G
p
j
( )
g n
[ ]
G e
j
( )
So:
M
g
a
(t) is bandlimited
@
samp
samp
!
M
2
samp
2
samp
M/T
shifted/scaled copies
2 4 2 4
at
have
samp
2
T
T
2
2012-12-05 Dan Ellis 8
Avoiding aliasing
g
a
(t) is bandlimited to
M
rad/sec
samp
samp
M
samp
M
samp
+
M
G
p
(j)
G
a
(j)
alias of baseband
signal
2012-12-05 Dan Ellis 9
Aliasing & The Nyquist Limit
If bandlimit
M
is too large, or sampling
rate
samp
is too small, aliases will overlap:
Avoid by:
i.e. bandlimit g
a
(t) at
M
samp
samp
samp
M
G
p
(j)
samp
M
M
samp
2
M
Sampling theorum
Nyquist
frequency
samp
2
2012-12-05 Dan Ellis 10
Anti-Alias Filter
Basic limit:
samp
/2 bandwidth
H
L
L
H
A
Bandwidth =
H
L
samp
samp
2
samp
A/T
samp
/2
2012-12-05 Dan Ellis 12
make a continuous
impulse train g
p
(t)
lowpass filter to
extract baseband
g
a
(t)
Reconstruction
To turn g[n]
back to g
a
(t):
!
G(e
j!
)
G
p
(j)
G
a
(j)
samp
/2
^
^
^
^
^
^
2012-12-05 Dan Ellis 13
2. Quantization
e
2
dB
signal power
noise power
(quantizer step = ")
e
2
=
2
12
-
/
2
+
/
2
P(e[n])
2012-12-05 Dan Ellis 17
Quantization SNR
Now,
x
2
is limited by dynamic range of
converter (to avoid clipping)
R
FS
2
...
R
FS
2
R
FS
2
b1
SNR = 10 log
10
2
x
R
2
FS
2
2(b+1)
12
6b + 16.8 20 log
10
R
FS
x
2012-12-05 Dan Ellis 18
Coefficient Quantization
.. depending on implementation
Some coefficients
are very sensitive
to small changes
Performance Margins
2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 P
-40
-30
-20
-10
0
frequencyW
g
a
i
n
/
d
B
passband
edge
frequency
Passband
Stopband
passband
ripple
minimum
stopband
attenuation
optimal
filter
will touch
here
stopband
edge
frequency
t
r
a
n
s
i
t
i
o
n
b
a
n
d
\G(e
jW
)\
2012-12-12 Dan Ellis
Allpass Filters
Mirror-image polynomial
Reciprocal
poles/zeros
3
A
M
z
( )
=
d
M
+ d
M1
z
1
+ ... + d
1
z
M1
( )
+ z
M
1+ d
1
z
1
+ ... + d
M1
z
M1
( )
+ d
M
z
M
= z
M
D
M
z
1
( )
D
M
z
( )
3 2 1 0 1 2
1
0
1
Re{z}
I
m
{
z
}
2012-12-12 Dan Ellis
Minimum & Maximum Phase
( )
z
1
*
( )
z
( )
z
*
( )
z
1
( )
z
1
*
( )
z
x =
pole-
zero
cancln
2012-12-12 Dan Ellis
Analog Filter Types
c
g
a
i
n
/
d
B
g
a
i
n
/
d
B
g
a
i
n
/
d
B
g
a
i
n
/
d
B
Butterworth Chebyshev I
Chebyshev II Elliptical
p
r
r
A A
p
s-plane
Re{s}
Im{s}
c
2N
= 1
-1 -0.5 0 0.5 1
-1
-0.5
0
0.5
1
Re{s}
I
m
{
s
}
2012-12-12 Dan Ellis
Bilinear Transform
Pre-warp to design
6
s-plane
Re{s}
Im{s}
j
z-plane
Re{z}
Im{z}
1
e
j!
LHHPUCI
Imu.c.
s =
1 z
1
1 +z
1
=
z 1
z +1
0 1 2 3 4 5 6
-60
-40
-20
0
-60 -40 -20 0
0
0.2
0.4
0.6
0.8
|H
a
(j)|
|G(e
j
)|
= 2tan
1
()
G e
j
( )
= H
a
j
( )
=2 tan
1
= e
j
N
2
h
N
2
[ ]
+ 2 h
N
2
n
[ ]
cosn
n=1
N / 2
( )
linear phase
D = -(!)/! = N/2
2012-12-12 Dan Ellis
Parks-McClellan FIR design
1
x y
2
2
+
2
2
(
2
2
+
2
2
)
z
-1
z
-1
2012-12-12 Dan Ellis
FFT
10
x[0]
x[4]
x[2]
x[6]
x[1]
x[5]
x[3]
x[7]
X[0]
X[1]
X[2]
X[3]
X[4]
X[5]
X[6]
X[7]
X
0
[0]
X
00
X
01
X
10
X
11
X
0
[1]
X
0
[2]
X
0
[3]
X
1
[0]
X
1
[1]
X
1
[2]
X
1
[3]
DFT
N
4
DFT
N
4
DFT
N
4
DFT
N
4
W
N
0
W
N
1
W
N
2
W
N
3
W
N
4
W
N
5
W
N
6
W
N
7
W
N/2
3
W
N/2
0
W
N/2
3
W
N/2
0
different from before same as before
N/2 pt DFT of x for even n N/2 pt DFT of x for odd n
X
0
[<k>
N/2
] X
1
[<k>
N/2
]
X[k] =
N1
n=0
x[n] W
nk
N
=
N
2
1
m=0
x[2m] W
mk
N
2
+W
k
N
N
2
1
m=0
x[2m+ 1] W
mk
N
2