FFT-based filtering and the short

Download Report

Transcript FFT-based filtering and the short

FFT-based filtering
and the
Short-Time Fourier Transform
(STFT)
R.C. Maher
ECEN4002/5002 DSP Laboratory
Spring 2002
Using the FFT for DSP
• Because the FFT provides the means to
reduce the computational complexity of the
DFT from order (N2) to order (N log2(N)), it
is often desirable to do FFT-based
processing for DSP systems
• Even the computational cost of doing both
FFT and IFFT may be less than
conventional methods
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
2
Linear Convolution via FFT
Convolution
• FIR digital filter computes the linear
convolution of the unit sample response
with the input signal
• A filter of length P requires P2 complexity
• Recall that convolution in time domain is
multiplication in frequency domain
• So, consider multiplying signal and filter
transforms in the frequency domain
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
4
Circular Convolution
• The DFT is a sampled version of the Fourier
transform, so multiplying DFTs corresponds
to circular convolution
• Circular convolution can be thought of as
“time-domain aliasing”
• If we want linear convolution, we must
ensure time-limited input signals to avoid
time-domain aliasing (like bandlimiting to
avoid frequency-domain aliasing)
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
5
Linear convolution with the DFT
• Consider a unit sample response h[n] with
finite length P, and a signal x[n] of length L
• Linear convolution h*x has length L+P-1
• To avoid time-domain aliasing, we zero pad
both sequences to at least length L+P-1, do
FFT, multiply the transforms, then IFFT to
get L+P-1 result
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
6
Overlap Processing
• Now consider filter response of length P,
but assume input signal is of arbitrarily long
length: need to run filter “on the fly” as
blocks of input data become available
• Plan: break signal into consecutive blocks
of length L, pad each with zeros to length
L+P-1, and do FFT/multiply/IFFT
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
7
Overlap algorithm
• Note that the last P-1 output samples will
overlap the start of the next block, and the
overlapping points must be added to get the
proper response. This is known as the
overlap-add algorithm.
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
8
Overlap-Add Process
0
L
2L
3L
4L
x[n]
h[n]
y0[n]=h[n]*x0[n]
y1[n]=h[n]*x1[n]
y2[n]=h[n]*x2[n]
y3[n]=h[n]*x3[n]
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
9
Short-Time Fourier Transform
Short-Time Fourier Transform
• It is often desirable to have an estimate of
the input signal spectrum for a “short”
interval, especially for non-stationary
signals. Want to see changes in spectrum
with time.
• The Fourier transform gives the frequency
response, but it has infinite summation
   x[n]e
X e j 

 jn
n  
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
11
STFT (cont.)
• Consider calculating a spectral “snapshot”
by calculating Fourier transform of a short
interval of the input signal
w[n-m]
x[n]
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
12
STFT (cont.)
• Express the short-time Fourier transform as a 2dimensional signal
X n,   

 x[n]w[n  m]e
 jm
DT ST FT
m  
X n, k  

 j 2mk
x
[
n
]
w
[
n

m
]
e

N
DST FT
m  
• Multiplying signal by a short time function causes
smeared spectrum: convolution of the transforms
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
13
STFT viewpoints
• Fourier transform viewpoint: group x[]·w[]
– Take a sequence of DFTs as the window w[nm] slides along the signal
• Filter bank viewpoint: group x[n]e-jn
– Transform of w[n] is a low pass function
– x[n]e-jn is modulation: shifts spectrum of x[n]
by , where it can be filtered by low pass
function
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
14
STFT Reconstruction
• With some restrictions, it is possible to do
perfect reconstruction. STFT and inverse
STFT are a transform pair.
• Typically use overlapping window functions
during analysis, then overlap-add during
synthesis
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
15
DSP Analysis/Process/Synthesis
• Read in then next overlapping block of
input samples
• Apply analysis window
• Perform FFT
• Do frequency domain processing
• Perform IFFT
• Overlap-add into the output buffer
ECEN4002 Spring 2002
Fast Convolution and the STFT
R. C. Maher
16