Digital Signal Processing The Short-Time Fourier …spinlab.wpi.edu/courses/ece503_2014/12-6stft.pdf · DSP: The Short-Time Fourier Transform (STFT) Digital Signal Processing The
Post on 23-Mar-2018
225 Views
Preview:
Transcript
DSP: The Short-Time Fourier Transform (STFT)
Digital Signal ProcessingThe Short-Time Fourier Transform (STFT)
D. Richard Brown III
D. Richard Brown III 1 / 14
DSP: The Short-Time Fourier Transform (STFT)
Signals with Changing Frequency Content: Motivation
For signals that have frequency content that is changing over time,e.g., music, speech, ..., taking the DFT of the whole signal usually doesn’tprovide much insight.
Example: Two second linear chirp
N = 16000;
n = 0:N-1;
x = cos(2*pi/80000*(n+1000).^2); % linear chirp
soundsc(x,8000) % listen to sound
D. Richard Brown III 2 / 14
DSP: The Short-Time Fourier Transform (STFT)
Example Continued: FFT of Whole Signal
plot(2*n/N,20*log10(abs(fft(x)))); % FFT of whole signal
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2−60
−40
−20
0
20
40
60
normalized frequency (ω/π
FF
T m
agnitude
D. Richard Brown III 3 / 14
DSP: The Short-Time Fourier Transform (STFT)
Example Continued: FFTs of Smaller Chunks
plot(2*[0:127]/128,20*log10(abs(fft(x(1:128))))); % FFT near beginning
plot(2*[0:127]/128,20*log10(abs(fft(x(8001:8128))))); % FFT near middle
plot(2*[0:127]/128,20*log10(abs(fft(x(15001:15128))))); % FFT near end
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2−5
0
5
10
15
20
25
30
35
normalized frequency (ω/π
FF
T m
ag
nitu
de
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2−40
−30
−20
−10
0
10
20
30
40
normalized frequency (ω/π
FF
T m
agnitude
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2−40
−30
−20
−10
0
10
20
30
40
normalized frequency (ω/π
FF
T m
agnitude
D. Richard Brown III 4 / 14
DSP: The Short-Time Fourier Transform (STFT)
Short-Time Fourier Transform
Rather than analyzing the frequency content of the whole signal, we cananalyze the frequency content of smaller snapshots. The STFT is definedas
X[n, λ) =
∞∑m=−∞
x[n+m]w[m]e−jλm
where n ∈ Z is a time index and λ ∈ R is a normalized frequency index.
Remarks:
1. Implicit in this definition is a window function w[n] of length L.
2. The STFT results in a family of DTFTs indexed by n.
3. In practice, we don’t usually compute X[n, λ) for all n = 0, 1, . . .since the frequency content of the signal does not change much fromsample to sample. Instead, we typically pick a “block shift” integerR ≤ L and compute the STFT for values of n = 0, R, 2R, . . . .
D. Richard Brown III 5 / 14
DSP: The Short-Time Fourier Transform (STFT)
Short-Time Fourier Transform
n
x[n]
n
w[n]
L=81
n
x[n]w[n]
n
x[n+8]w[n]
n
x[n+16]w[n]
etc.
R=8
DTFT
DTFT
DTFT
X[0, λ)
X[8, λ)
X[16, λ)
λ
λ
λ
D. Richard Brown III 6 / 14
DSP: The Short-Time Fourier Transform (STFT)
Short-Time Fourier Transform with the DFT/FFT
We can also use the DFT/FFT to compute the STFT as
X[n, k] =
L−1∑m=0
x[n+m]w[m]e−j2πkm/N .
n
x[n]
n
w[n]
L=81
n
x[n]w[n]
n
x[n+8]w[n]
n
x[n+16]w[n]
R=8
DFT
DFT
DFT
N=8 X[0, k]
X[8, k]
X[16, k]
k
k
k
D. Richard Brown III 7 / 14
DSP: The Short-Time Fourier Transform (STFT)
Short-Time Fourier Transform Parameters
1. Window typeI Tradeoff between side lobe amplitude ASL and main lobe width ∆ML
2. Window length LI Larger L gives better frequency resolution (smaller ∆ML)I Smaller L gives less temporal averaging
3. Temporal block shift samples RI Usually R ≤ L and is related to L, e.g., R = L or R = L/2I Larger R result in less computationI Smaller R gives “smoother” results
4. FFT length NI Usually N ≥ L.I Larger N gives more frequency-domain samples of DTFT (better
location and amplitude of peaks)I Smaller N results in less computation.
D. Richard Brown III 8 / 14
DSP: The Short-Time Fourier Transform (STFT)
Matlab Spectrogram Example
Matlab function spectrogram is useful for easily computing STFTs.
[s,f,t] = spectrogram(x,kaiser(512,2),256,1024,8000); % x = lin chirp
image(t,f,20*log10(abs(s))); set(gca,’ydir’,’normal’); colorbar;
D. Richard Brown III 9 / 14
DSP: The Short-Time Fourier Transform (STFT)
Matlab Spectrogram Example (decrease R to 1)
[s,f,t] = spectrogram(x,kaiser(512,2),511,1024,8000); % x = lin chirp
image(t,f,20*log10(abs(s))); set(gca,’ydir’,’normal’); colorbar;
D. Richard Brown III 10 / 14
DSP: The Short-Time Fourier Transform (STFT)
Matlab Spectrogram Example (rectangular window)
[s,f,t] = spectrogram(x,ones(512,1),511,1024,8000); % x = lin chirp
image(t,f,20*log10(abs(s))); set(gca,’ydir’,’normal’); colorbar;
D. Richard Brown III 11 / 14
DSP: The Short-Time Fourier Transform (STFT)
Matlab Spectrogram Example (longer window)
[s,f,t] = spectrogram(x,kaiser(1024,2),1023,1024,8000); % x = lin chirp
image(t,f,20*log10(abs(s))); set(gca,’ydir’,’normal’); colorbar;
D. Richard Brown III 12 / 14
DSP: The Short-Time Fourier Transform (STFT)
Speech Signals Example
fre
qu
en
cy (
kH
z)
ref−mic [quiet]
0 2 40
0.2
0.4
0.6
0.8
1
time (s)
fre
qu
en
cy (
kH
z)
ref−mic [high−noise]
0 2 40
0.2
0.4
0.6
0.8
1
phys−mic [quiet]
0 2 40
0.2
0.4
0.6
0.8
1
time (s)
phys−mic [high−noise]
0 2 40
0.2
0.4
0.6
0.8
1
TERC sensor [quiet]
0 2 40
0.2
0.4
0.6
0.8
1
time (s)
TERC sensor [high−noise]
0 2 40
0.2
0.4
0.6
0.8
1
D. Richard Brown III 13 / 14
DSP: The Short-Time Fourier Transform (STFT)
“Aphex Face” Spectrogram (log scale frequency axis)
On Aphex Twin’s Windowlicker album, track 2, ∼ 5:27–5:37.D. Richard Brown III 14 / 14
top related