7/30/2019 DSP Lecture 16-17
1/21
Lectures 16-17 EE-802 ADSP SEECS-NUST
EE 802-Advanced Digital SignalProcessing
Dr. Amir A. Khan
Office : A-218, SEECS
9085-2162; [email protected]
7/30/2019 DSP Lecture 16-17
2/21
Lectures 16-17 EE-802 ADSP SEECS-NUST
Lecture Outline
Discrete Fourier Transform (DFT)
7/30/2019 DSP Lecture 16-17
3/21
Lectures 16-17 EE-802 ADSP SEECS-NUST
DFT-Analysis and Synthesis Equations
12 /
0
1[ ]
Nj N kn
kx n X k eN
12 /
0[ ]
Nj N kn
nX k x n e
DFS Pair
12 /
0
[ ] 0 1
0
Nj N kn
n
x n e k NX k
else
1
2 /
0
10 1
[ ]0
Nj N kn
k
X k e n Nx n
Nelse
PERIODIC
ONE PERIOD ONLY
DFT
x n X k
1
0
[ ] ( ) , 0 1N
kn
N
n
X k x n W k N
1
0
1[ ] ( ) , 0 1
Nkn
N
k
x n X k W n NN
Analysis equation Synthesis equation
7/30/2019 DSP Lecture 16-17
4/21
Lectures 16-17 EE-802 ADSP SEECS-NUST
DFT-Ex: Rectangular Pulse
Minimum Value of N ?
Minimum Value ofN = 5
42 /5
0
2
2 /5
1
1
5 0, 5, 10,...0
j k n
n
j k
j k
X k e
e
e
kelse
DFS
Required N = 5-point DFT
7/30/2019 DSP Lecture 16-17
5/21
Lectures 16-17 EE-802 ADSP SEECS-NUST
DFT- Frequency Interpretation
1
0
[ ] ( ) , 0 1N
kn
Nn
X k x n W k N
DFT determines the spectral content of input at Nequally spaced frequency points What are the exact frequencies in the DFT spectrum?
depends on the number of DFT points N and
on the sampling frequencyfs, at which the original signal was sampled
X[k] : frequency content at discrete radial frequency: (rad/sample)
or cycles/sample
In real frequency terms (Hz) :
kN
k
2
N
kfk
N
kff sanalysis
In case your sampling frequency is not specified or not known, we talk of normalized
frequency (scale from -0.5 to 0.5)
7/30/2019 DSP Lecture 16-17
6/21
Lectures 16-17 EE-802 ADSP SEECS-NUST
DFT- Example
-1.5
-1
-0.5
0
0.5
1
1.5
0 1 2 3 4 5 6 7n
)4
320002sin(5.0)10002sin()(
tttx
Sample it with fs= 8000 Hz and take 8 samplesx[n]
0 1 2 3 4 5 6 70
0.5
1
1.5
2
2.5
3
3.5
4
k
|X
[k]|
Plug back in manually the real freq. axis
X[1] corresponds to 1x8000/8 = 1000 Hz
X[2] corresponds to 2x8000/8 = 2000 Hz
What are X[6] and X[7]?
-4000 -3000 -2000 -1000 0 1000 2000 30000
0.5
1
1.5
2
2.5
3
3.5
4
f(Hz)
|X(f)|
Apply 8-point DFT
7/30/2019 DSP Lecture 16-17
7/21Lectures 16-17 EE-802 ADSP SEECS-NUST
DFT Leakage
N = 64 (samples of input signal)
Falls in DFT Bin # k =3
NO DFT Bin # k = 3.4
Leaks into multiple DFT Bins
7/30/2019 DSP Lecture 16-17
8/21Lectures 16-17 EE-802 ADSP SEECS-NUST
DFT Leakage (The reality)
-4000 -3000 -2000 -1000 0 1000 2000 3000 4000
0
5
10
15
20
25
X= 875
Y= 15.9248
X= 750
Y= 24.4898
f (Hz)
)8002sin()( ttx Sample it with fs= 8000 Hz and take 64 samplesApply 64-point DFT
7/30/2019 DSP Lecture 16-17
9/21Lectures 16-17 EE-802 ADSP SEECS-NUST
DFT Leakage Work Around
Windowing (rectangular) is always taking place
For sinusoids with integer number of cycles in analysis period,
leakage does not occur
Unfortunately, for practical signals leakage will always be an issue
So we need to ensure better leakage management
One solution is to use better windows with reduced side lobes
Hamming, Hanning, Triangular, etc.
Cost paid would be the reduced resolution of different frequencies
Self-Exercises Further ReadingUnderstanding DSP (Lyons)
Chapter 3 : DFT (Sections 3.2, 3.5, 3.8, 3.9, 3.13, 3.17)
Practice on MATLAB at least with sinusoids and different
windows to clarify your concepts
7/30/2019 DSP Lecture 16-17
10/21Lectures 16-17 EE-802 ADSP SEECS-NUST
Properties of DFT-Linearity
1 1
2 2
1 2 1 2
DFT
DFT
DFT
x n X kx n X k
ax n bx n aX k bX k
N1 = length (x1) N2 = length (x2)
length (x3) =N3 = max(N1, N2)
x3 denote the sum sequence
For DFT ofx3 to meaningful, compute DFTs ofx1 andx2 on lengthN3
DFT of greater length than actual samples can be computed by zero
padding
7/30/2019 DSP Lecture 16-17
11/21Lectures 16-17 EE-802 ADSP SEECS-NUST
Properties of DFT-Circular Shift
2 /0 n N-1
DFT
j k N mDFT
N
x n X kx n m X k e
7/30/2019 DSP Lecture 16-17
12/21Lectures 16-17 EE-802 ADSP SEECS-NUST
Circular Convolution as LinearConvolution with Aliasing
[ ] ( )
DTFT j
x n X e
2
[ ] ( )
kj
N
X k X e
[ ] [ ]r
x n x n rN
Extracting one period of to form the finite-length sequence[ ]X k
2
( ) 0 1[ ]
0 otherwise
kj
NX e k NX k
[ ] 0 1[ ]
0 otherwisep
x n n Nx n
3 1 2j j j
X e X e X e
Linear Convolution:
2 /3 3 , 0 1j k NX k X e k N
2 / 2 / 3 1 2 , 0 1j k N j k NX k X e X e k N
3 1 2
3
3
[ ] [ ] [ ]
[ ] 0 1[ ]
0 otherwise
IDFT
rp
X k X k X k
x n rN n Nx n
may suffer from the time-aliasing distortion
7/30/2019 DSP Lecture 16-17
13/21Lectures 16-17 EE-802 ADSP SEECS-NUST
Circular Convolution as LinearConvolution with Aliasing (Contd.)
3 1 2
3
3
[ ] [ ] [ ]
[ ] 0 1[ ]
0 otherwise
IDFT
rp
X k X k X k
x n rN n Nx n
may suffer from the time-aliasing distortion
If , then x1
[n] =x1p
[n], i.e., no aliasing distortion in x1
[n],
likewise no distortion in x2[n]
PLN and
What about x3[n]? Possible Distortion unless Nis large enough
Nshould be greater than or equal to the length ofx3[n]
1 PLNIn this case circular convolution is same as performing the linear convolution and
hence no aliasing distortion is present
7/30/2019 DSP Lecture 16-17
14/21Lectures 16-17 EE-802 ADSP SEECS-NUST
Ex 2: Circular Convolution as LinearConvolution with Aliasing
Indexing problems in Book Fig. 8.18
Oppenheim
If N = L = P, all of sequence values of
circular convolution will be different from
linear convolution
-1 0
+
+
=
+ over interval 0 to N-1
7/30/2019 DSP Lecture 16-17
15/21Lectures 16-17 EE-802 ADSP SEECS-NUST
Ex : Circular Convolution as LinearConvolution with Aliasing
L > P
7/30/2019 DSP Lecture 16-17
16/21Lectures 16-17 EE-802 ADSP SEECS-NUST
Ex : Circular Convolution as LinearConvolution with Aliasing (Contd.)
FirstP-1 values in linear andcircular convolution are different
20 Pn
NextL-P+1 values in linear andcircular convolution are same
11 LnP
No values in circular convolutionfor
Ln Though present in linear convolution
Ill i f Ci l C l i
7/30/2019 DSP Lecture 16-17
17/21Lectures 16-17 EE-802 ADSP SEECS-NUST
Illustration of Circular Convolution asLinear Convolution with Aliasing
Wrapping around of circular convolution
7/30/2019 DSP Lecture 16-17
18/21Lectures 16-17 EE-802 ADSP SEECS-NUST
Linear FIR Filtering using DFT-filtering oflong data sequences
Assume that input sequence is very long and LTI system is FIR filter
Wait until all sequence has been acquired (too lengthy computation of
DFT)
or do Block convolution : Break up the input sequence into blocks,
process and restack
Block Convolution Methods (using DFT)
Method 1
Overlap Add
Method 2 Overlap Save
7/30/2019 DSP Lecture 16-17
19/21Lectures 16-17 EE-802 ADSP SEECS-NUST
Overlap Add Method
Partition the long input sequence into non-overlapping sections of
shorter length (L)
Consider the FIR filterh[n] of length P
Required operation
Perform the above operations using DFTs and IDFT
0
[ ] [ ]rr
x n x n rL
[ ] 0 1
[ ]0 otherwise
r
x n rL n Lx n
where
nhnxny
nhrLnxnyr
r
0
nhnxny rr
0r
r rLnyny
Linear filtering of total input
Linear filtering of each
input section
Total output = Addition of individual
outputs (separated by L samples)
7/30/2019 DSP Lecture 16-17
20/21Lectures 16-17 EE-802 ADSP SEECS-NUST
Overlap Add Method
Linear convolution = circular convolution if N = L+P-1
zero-pad filter (L-1 zeros) and input (P-1 zeros)
Take N-point DFTs of input chunk and filter
Multiply the DFTs to get an output chunks DFT
Take IDFT to obtain one chunk of output
Repeat for next input chunk of L samplesAdd (overlapping) output sections to obtain overall output
7/30/2019 DSP Lecture 16-17
21/21
Overlap Save Method
Partition input into overlapping sections (length L) & overlap (P-1) samples
Use N = L point DFTs and IDFTs (to obtain output chunks of length L)
time aliasing will occur as N = L+P-1 is not satisfied
discard starting P-1 points because they are incorrect (aliased)
Retain the correct data of lengthL-(P-1) points & patch them together (save)