The Fourier transforms (FT, DTFT, DFT, etc.) do not clearly indicate how the frequency content of a signal changes over time.
That information is hidden in the phase - it is not revealed by the plot of the magnitude of the spectrum.
To see how the frequency content of a signal changes over time, we can cut the signal into blocks and compute the spectrum of each block.
To improve the result,
- blocks are overlapping
- each block is multiplied by a window that is tapered at its endpoints.
Several parameters must be chosen:
- Block length, R.
- The type of window.
- Amount of overlap between blocks. (Figure 1)
- Amount of zero padding, if any.
The short-time Fourier transform is defined as
X(ω,m) | = | (STFT(x(n)),≔,DTFT(x(n−m)w(n))) |
| = |
(x(n−m)w(n)ⅇ−(ⅈωn)) |
| = |
(x(n−m)w(n)ⅇ−(ⅈωn)) |
(1) where
w(n) is the window function of length
R.
- The STFT of a signal x(n) is a function of two variables: time and frequency.
- The block length is determined by the support of the window function w(n).
- A graphical display of the magnitude of the STFT, |X(ω,m)|, is called the spectrogram of the signal. It is often used in speech processing.
- The STFT of a signal is invertible.
- One can choose the block length. A long block length will provide higher frequency resolution (because the main-lobe of the window function will be narrow). A short block length will provide higher time resolution because less averaging across samples is performed for each STFT value.
- A narrow-band spectrogram is one computed using a relatively long block length R, (long window function).
- A wide-band spectrogram is one computed using a relatively short block length R, (short window function).
To numerically evaluate the STFT, we sample the frequency axis ω in N equally spaced samples from ω=0 to ω=2π.
We then have the discrete STFT,
(Xd(k,m),≔,X(
k,m)) | = |
(x(n−m)w(n)ⅇ−(ⅈωn)) |
| = |
(x(n−m)w(n)WN−(kn)) |
| = | DFTN(x(n−m)w(n)|n=0R−1,0,…0) |
(3) where
0,…0 is
N−R.
In this definition, the overlap between adjacent blocks is R−1. The signal is shifted along the window one sample at a time. That generates more points than is usually needed, so we also sample the STFT along the time direction. That means we usually evaluate Xd(k,Lm) where L is the time-skip. The relation between the time-skip, the number of overlapping samples, and the block length is Overlap=R−L
Match each signal to its spectrogram in
Figure 2.
% LOAD DATA
load mtlb;
x = mtlb;
figure(1), clf
plot(0:4000,x)
xlabel('n')
ylabel('x(n)')
% SET PARAMETERS
R = 256; % R: block length
window = hamming(R); % window function of length R
N = 512; % N: frequency discretization
L = 35; % L: time lapse between blocks
fs = 7418; % fs: sampling frequency
overlap = R - L;
% COMPUTE SPECTROGRAM
[B,f,t] = specgram(x,N,fs,window,overlap);
% MAKE PLOT
figure(2), clf
imagesc(t,f,log10(abs(B)));
colormap('jet')
axis xy
xlabel('time')
ylabel('frequency')
title('SPECTROGRAM, R = 256')
Here is another example to illustrate the frequency/time resolution trade-off (See figures -
Figure 5,
Figure 6, and
Figure 7).
A spectrogram is computed with different parameters: L∈{1,10} N∈{32,256}
- L = time lapse between blocks.
- N = FFT length (Each block is zero-padded to length N.)
In each case, the block length is 30 samples.
For each of the four spectrograms in
Figure 8 can you tell what
L and
N are?
L and N do not effect the time resolution or the frequency resolution. They only affect the 'pixelation'.
Shown below are four spectrograms of the same signal. Each spectrogram is computed using a different set of parameters. R∈{120,256,1024} L∈{35,250} where
- R = block length
- L = time lapse between blocks.
For each of the four spectrograms in
Figure 9, match the above values of
L and
R.
If you like, you may listen to this signal with the
soundsc
command; the data is in the file:
stft_data.m
.
Here is a figure of the signal.
0 comments:
Post a Comment