PowerPoint Slides

Download Report

Transcript PowerPoint Slides

Time Frequency Analysis
• We want to see how the frequencies of a signal change with time.
• Typical example of a Time/Frequency representation:
log(freq)
time
Short Time Fourier Transform (STFT)
• Given a signal we take the FFT on a window sliding with time
w[ n   ]
x[n ]
n


  N 1
n
| X [k , ] |
x[ n ] w[ n   ]
FFT

n
N

k
Spectrogram: ideally
• The evolution of the magnitude with time is called Spectrogram.
• Ideally we would like to have this:
frequency
x[n ]
1
2
2
1
time
n0
time
n0
1
2
Spectrogram: in practice
• We need to deal with the effects of the window: main lobe and sidelobes
N
  t  N  TS
frequency
2
1
  m
N
time


1
2


2
 F  m
FS
N
Spectrogram: effect of window length
• Let N be the length of the window
frequency
2
1
  m
2
N
 F  m
FS
N
time
N
• Frequency Resolution  F  m
• Time resolution:
  t  N  TS
FS
N
 t  N  TS
with m depending on the window;
Windows
Rectangular
Hamming
Blackman
1.5
w[ n ]
1
w[ n ]
w[ n ]
0.9
0.8
0.7
1
0.6
0.5
0.4
0.5
0.3
0.2
0.1
0
0
5
10
15
20
25
30
35
40
45
0
50
0
5
10
15
20
25
30
35
40
45
50
N 1
0
W N ( )
W N ( )
W N ( )
0
0
-10
-10
0
-10
-20
-20
-20
-30
-30
-30
-40
-40
-50
-50
-60
-60
-70
-70
-80
-80
-40
-50
-60
-70
-3
-2
-1
0
w (rad)
1
2
3
   4 / N
-3
-2
-1
0
w (rad)
1
2
3
   8 / N
-80
-3
-2
-1
0
w (rad)
1
2
3
   16  / N
Time/Frequency Uncertainty Principle
• either you have good resolution in time or in frequency, not both.
good localization in time ...
either
F
F0
x (t )
to
t
… or
to
t
good localization in freq.
F
F0
to
t
Example: a Chirp
A “Chirp” is a sinusoid with time varying frequency, with expression
x ( t )  A cos  2  F ( t ) t  

If the frequency changes linearly with time, it has the form shown below:
Frequency (Hz)
F1
F0
T1
t
Time (sec)
Chirp in Matlab
Fs=10000; Ts=1/Fs; t=(0:999)*Ts;
y=chirp(t, 100, t(1000), 4000);
plot(t(1:300), y(1:300))
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
0
0.005
0.01
0.015
time (sec)
0.02
0.025
0.03
Given Data
Four repetitions of a chirp:
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
0
0.05
0.1
0.15
0.2
time (sec)
0.25
0.3
0.35
0.4
Spectrogram of the Chirp: no window
spectrogram(y, rectwin(256), 250, 256,Fs,'yaxis');
Spectrogram of the Chirp: hamming window
spectrogram(y, hamming(256), 250, 256,Fs,'yaxis');
Spectrogram of the Chirp: shorter window
spectrogram(y, hamming(64), 60,64,Fs,'yaxis');
Spectrogram of the Chirp: shorter window
spectrogram(y, hamming(64), 60,256,Fs,'yaxis');
Spectrogram of the Chirp: blackman window
spectrogram(y, blackman(256), 250, 256,Fs,'yaxis');
Sealion
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
0
0.2
0.4
0.6
0.8
1
1.2
time (sec)
1.4
1.6
1.8
2
Spectrogram of Sealion: hamming window
spectrogram(y(2001:12000), hamming(256), 250, 256,Fs,'yaxis');
Spectrogram of Sealion: no window
spectrogram(y(2001:12000), rectwin(256), 250, 256,Fs,'yaxis');
Spectrogram of Sealion: blackman, longer
spectrogram(y(2001:12000), blackman(512), 500, 512,Fs,'yaxis');
Music
spectrogram(y(2001:12000), blackman(512), 500, 512,Fs,'yaxis');
Spectrogram
spectrogram(y(12001:22000), hamming(256), 250, 256,'yaxis');
Spectrogram: zoom
spectrogram(y(12001:22000), hamming(256), 250, 256,'yaxis');
Not enough frequency resolution!
Frequencies we expect to see
Since this signal contains music we expect to distinguish between
musical notes. These are the frequencies associated to it (rounded
to closest integer):
Notes
Freq.
(Hz)
C
Db
D
Eb
E
F
Gb
G
Ab
A
Bb
B
262 277 294 311 330 349 370 392 415 440 466 494
Desired Frequency Resolution***:  F  2
FS
 15 H z
N
This yields a window length of at least N=1024
***Note: the slide in the video has a typo, showing the inequality reversed.
Spectrogram: longer window
spectrogram(y(12001:22000), hamming(1024), 1000, 1024,'yaxis');
Spectrogram: longer window (zoom)
spectrogram(y(12001:22000), hamming(1024), 1000, 1024,'yaxis');
Spectrogram: recognize some notes
spectrogram(y(12001:22000), hamming(1024), 1000, 1024,'yaxis');
Closest Notes:
E: 330Hz, 660Hz
D: 294Hz, 588Hz
Check with the Music Score
E
E
B
D
D
A