Uploaded by ANURAG K K P

lustig-stft-0

advertisement
EE123
Digital Signal Processing
Lecture 5B
Time-Frequency Tiling
M. Lustig, EECS UC Berkeley
FREQUENCY ANALYSIS
„
Frequency Spectrum
„
„
„
Be basically the frequency components (spectral
components) of that signal
Show what frequencies exists in the signal
Fourier Transform (FT)
„
„
One way to find the frequency content
Tells how much of each frequency exists in a
signal
X (k + 1 ) =
∞
N −1
∑ x (n + 1 ) ⋅ W
n=0
N −1
kn
N
1
x (n + 1) = ∑ X (k + 1) ⋅W N− kn
N k =0
w
N
= e
2π ⎞
− j ⎛⎜
⎟
⎝ N ⎠
X ( f ) = ∫ x(t ) ⋅ e −2 jπft dt
x(t ) =
∞
−∞
2 jπft
(
)
X
f
⋅
e
df
∫
−∞
STATIONARITY OF SIGNAL
„
Stationary Signal
„
„
„
Signals with frequency content unchanged
in time
All frequency components exist at all times
Non-stationary Signal
„
„
Frequency changes in time
One example: the “Chirp Signal”
STATIONARITY OF SIGNAL
3
6 0 0
2
5 0 0
Magnitud
e
Stationary
Magnitud
e
2 Hz + 10 Hz + 20Hz
1
4 0 0
0
3 0 0
-1
2 0 0
-2
1 0 0
-3
0
0 .2
0 .4
0 .6
0 .8
0
1
0
5
Time
2 0
2 5
1
2 5 0
0 .6
2 0 0
Magnitud
e
NonStationary
1 5
0 .8
Magnitud
e
0.0-0.4: 2 Hz +
0.4-0.7: 10 Hz +
0.7-1.0: 20Hz
1 0
Frequency (Hz)
0 .4
0 .2
1 5 0
0
-0 .2
1 0 0
-0 .4
-0 .6
5 0
-0 .8
-1
0
0 .5
Time
1
0
0
5
1 0
1 5
Frequency (Hz)
2 0
2 5
CHIRP SIGNALS
Frequency: 2 Hz to 20 Hz
150
1
0.8
0.8
0.6
0.6
Magnitud
e
0.4
100
Magnitud
e
Magnitud
e
0.4
0.2
0
-0.2
100
0.2
0
-0.2
50
-0.4
50
-0.4
-0.6
-0.6
-0.8
-0.8
-1
150
Magnitud
e
1
Frequency: 20 Hz to 2 Hz
Different in Time Domain
0
0.5
Time
1
0
0
5
10
15
20
Frequency (Hz)
25
-1
0
0.5
Time
1
0
0
5
10
15
20
Frequency (Hz)
Same in Frequency Domain
Atwhat
whattime
timethe
thefrequency
frequencycomponents
componentsoccur?
occur? FT
FTcan
cannot
nottell!
tell!
At
25
NOTHING MORE, NOTHING
LESS
„
„
„
FT Only Gives what Frequency Components Exist in
the Signal
The Time and Frequency Information can not be
Seen at the Same Time
Time-frequency Representation of the Signal is
Needed
Most of Transportation Signals are Non-stationary.
(We need to know whether and also when an incident was happened.)
ONE EARLIER SOLUTION: SHORT-TIME FOURIER TRANSFORM (STFT)
SFORT TIME FOURIER
TRANSFORM (STFT)
„
Dennis Gabor (1946) Used STFT
„
„
„
To analyze only a small section of the signal at a time
-- a technique called Windowing the Signal.
The Segment of Signal is Assumed Stationary
A 3D transform
STFTX( ω ) (t ′, f ) = ∫ [x(t ) • ω* (t − t ′)]• e − j 2 πft dt
t
ω(t ) : the window function
A function of time
and frequency
DRAWBACKS OF STFT
„
„
Unchanged Window
Dilemma of Resolution
„
„
„
Narrow window -> poor frequency resolution
Wide window -> poor time resolution
Heisenberg Uncertainty Principle
„
Cannot know what frequency exists at what time intervals
Via Narrow Window
Via Wide Window
Example of spectral analysis
• Spectrum of a bird chirping
– Interesting,.... but...
– Does not tell the whole story
– No temporal information!
ple: Bird Chirp
x[n]
Sound!
n
Spectrum of a bird chirp
600
500
400
300
200
100
0
0
0.5
1
1.5
Hz
2
2.5
4
x 10
M. Lustig, EECS UC Berkeley
Time Dependent Fourier Transform
• To get temporal information, use part of
the signal around every time point
X[n, !) =
1
X
x[n + m]w[m]e
j!m
m= 1
*Also called Short-time Fourier Transform (STFT)
• Mapping from 1D
2D, n discrete, w
cont.
M. Lustig, EECS UC Berkeley
Time Dependent Fourier Transform
• To get temporal information, use part of
the signal around every time point
X[n, !) =
1
X
x[n + m]w[m]e
j!m
m= 1
*Also called Short-time Fourier Transform (STFT)
M. Lustig, EECS UC Berkeley
15
10
Spectrogram
5
0
0
500
1000
1500
2000
2500
Frequency, Hz
3000
3500
4000
4500
12
30
10
25
8
20
6
15
4
10
2
0
500
1000
1500
2000
2500
Frequency, Hz
3000
3500
4000
0
4500
0
500
1000
1500
2000
2500
Frequency, Hz
3000
3500
4000
4500
0
500
1000
1500
2000
2500
Frequency, Hz
3000
3500
4000
4500
12
10
8
6
4000
4
2
Frequency, Hz
0
5
0
3000
2000
1000
0
2
4
6
8
10
Time, s
12
14
16
18
M. Lustig, EECS UC Berkeley
Discrete Time Dependent FT
Xr [k] =
L
X1
x[rR + m]w[m]e
j2⇡km/N
m=0
• L - Window length
• R - Jump of samples
• N - DFT length
• Tradeoff between time and frequency
resolution
M. Lustig, EECS UC Berkeley
• Time-Frequency uncertainty principle
1
t· !
2
!
http://www.jonasclaesson.co
Heisenberg Boxes
t
!
t
M. Lustig, EECS UC Berkeley
DFT
X[k] =
2⇡
!=
N
t=N
!·
N
X1
x[n]e
j2⇡kn/N
n=0
!
t = 2⇡
t
one DFT coefficient
M. Lustig, EECS UC Berkeley
DFT
X[k] =
N
X1
x[n]e
j2⇡kn/N
n=0
!
2⇡
!=
N
t=N
!·
t = 2⇡
t
Question: What is the effect of zero-padding?
Answer: Overlapped Tiling!
M. Lustig, EECS UC Berkeley
Discrete STFT
X[r, k] =
2⇡
!=
L
L
X1
optional
x[rR + m]w[m]e
j2⇡km/N
m=0
!
t=L
t
one STFT coefficient
M. Lustig, EECS UC Berkeley
Discrete STFT
X[r, k] =
2⇡
!=
L
L
X1
optional
x[rR + m]w[m]e
j2⇡km/N
m=0
!
t=L
t
one STFT coefficient
M. Lustig, EECS UC Berkeley
Discrete STFT
X[r, k] =
L
X1
optional
x[rR + m]w[m]e
j2⇡km/N
m=0
!
2⇡
!=
L
t=L
Question: What is the effect of R on tiling? what effect of N?
Answer: Overlapping in time or frequency or both!
t
M. Lustig, EECS UC Berkeley
Applications
• Time Frequency Analysis
Spectrogram of Orca whale
Frequency, Hz
4000
3000
2000
1000
0
1
2
3
4
Time, s
5
6
7
8
M. Lustig, EECS UC Berkeley
Spectrogram
Frequency, Hz
4000
(A)
3000
2000
1000
0
2
4
6
8
10
Time, s
12
14
16
Frequency, Hz
4000
18
(B)
3000
2000
1000
0
2
4
6
8
10
Time, s
12
14
16
18
• What is the difference between the
a) Window size B<A
c) Window type is different
b) Window size B>A
d) (A) uses overlapping window
M. Lustig, EECS UC Berkeley
=
1/T
=
20
Hz.
Sidelobes of Hann vs rectangular window
ngular Window, L = 32
Rectangular Window, L = 32
DTFT of Hamming Window
1.2
20
DTFT of Rectangular Window
40
35
1
30
15
0.8
w[n]
|W(ej T)|
T
)|
25
|W(ej
0.6
10
0.4
0.2
0
20
15
10
5
5
00
-20
5
10
-10
15
20
0
n
/2 (Hz)
25
10
0
-20
30
20
Sampled, Windowed
Signal, Rectangular Window, L = 32
DTFT of Sampled, Windowed Signal
-10
0
/2 (Hz)
10
20
DTFT of Sampled, Windowed Signal
20
1.510
1
15
8
0
)|
T
6
|V(ej
v[n]
|V(ej T)|
0.5
10
M. Lustig, EECS UC Berkeley
Spectrogram
Frequency, Hz
4000
(A)
3000
2000
1000
0
2
4
6
8
10
Time, s
12
14
16
Frequency, Hz
4000
18
(B)
3000
2000
1000
0
2
4
6
8
10
Time, s
12
14
16
18
• What is the difference between the
a) Window size B<A
c) Window type is different
b) Window size B>A
d) (A) uses overlapping window
M. Lustig, EECS UC Berkeley
Windows Examples
Spectrogram
Hamming Window, L = 32
Hamming Window, L = 32
DTFT of Hamming Window
1.2
20
1
15
0.6
|W(ej
w[n]
T
)|
0.8
10
0.4
5
0.2
Windows Examples
0
0
5
10
15
n
20
25
0
-20
30
Hamming Window, L = 64
Sampled, Windowed Signal, Hamming Window, L = 32
10
20
10
Hamming Window, L = 64
DTFT of Hamming Window
1
1.2
8
40
0.4
-1.5
0.20
0
30
20
2
15
T
0.6
-1
0
5
10
15
n
20
25
10
20
30
n
Course
40
50
Miki Lustig UCB. Based on
30
60
Notes by J.M Kahn
356
)| |V(ej
T
)|
0.5
1
0
0.8
-0.5
|W(ej
v[n]
0
/2 (Hz)
DTFT of Sampled, Windowed Signal
1.5
w[n]
-10
254
100
-20
5
0
-20
-10
0
/2 (Hz)
0
10
10
20
20
Fall 2011, EE123 Digital
/2 (Hz) Signal Processing
Sampled, Windowed Signal, Hamming Window, L = 64
1.5
-10
DTFT of Sampled, Windowed Signal
20
M. Lustig, EECS UC Berkeley
200KHz slots. This is relatively a large bandwidth and therefor it is also called wideba
d to narrowband FM which can be as low as 5 Khz. In FM radio the information is encod
Spectrogram
ofcarrier,
FM
the
frequency of the
✓
Z t
◆
yc (t) = A cos 2⇡fc t + 2⇡ f
x(⌧ )d⌧ .
R already demodulates by the carrier frequency 0fc , so the samples you get are actually
!
Z
f is the frequency deviation and
nT x(t) is a normalized baseband signa
carrier frequency,
y[n] = y(nT ) = A exp j2⇡ f
x(⌧ )d⌧ ,
0
FM baseband signal, x(t), consists of mono (Left+Right) Channels from 30Hz to 15 KH
at fsampling
19 KHz,
Stereo (Left - Right) channels around 2 · fp = 38K
he
rate.amplitude
p =Spectrogram
of FM modulated
radio
BDS,
88.6 which encodes the station information, song name etc. at 3 · fp = 57KHz. (S
vorite radio station (make sure there is good reception where you live! Don’t try it in
in rooms inside Cory that do not have windows). I’ve tested good reception from Cory
88.5Mhz and 94.1Mhz. Acquire 4 seconds
of data at a sampling rate of 200,000 Hz. Y
8
r rtl_tcp or rtl_sdr for that. Compute and display a spectrogram with a window of
ude
88.5the spectrogram in your report. What is the spectral and temporal resolution? Exp
. Don’t forget to play with di↵erent dynamic ranges of the spectrogram for best visualizat
alog radio systems, FM demodulation is performed by implementing a phased-locked l
he
frequency of the signal and extract the message x(t). However, it is very easy to implem
88.4
odulation
to
t=0 when the samples are discrete. Note, that the signal x(t) is proportional
t=2sec
Lustig,
EECSWe
UC Berkeley
s frequency of the signal. It is also proportional to the derivative of M.
the
phase!
can im
R already demodulates by the carrier frequency fc , so the samples you get are actually
Spectrogram of FM radio Baseband
y[n] = y(nT ) = A exp j2⇡ f
Z nT
!
x(⌧ )d⌧ ,
http://en.wikipedia.org/wiki/FM_broadcasting for more information). The baseband signal is:
0
p://en.wikipedia.org/wiki/FM_broadcasting for more
information). The baseband signal is:
x(t) = (L + R) + 0.1 · cos(2⇡fp t) + (L
| {z }
mono
|
{z
}
pilot
he sampling
rate.
x(t) = (L
+ R) + 0.1 · cos(2⇡fp t) + (L
|
R) cos(2⇡(2fp )t) + 0.05 · RBDS(t) cos(2⇡(3fp )t) .
{z
}
stereo
|
{z
digital RBDS
}
R) cos(2⇡(2fp )t) + 0.05 · RBDS(t) cos(2⇡(3fp )t) .
| {zThe}signal| RBDS(t){zis a signal }consists
| of ±1 at constant
{z intervals which
} encode
| 0, and 1 bits. This
{z is the
mono
spectrum of x(t): pilot
stereo
digital RBDS
}
vorite radio station (make sure there is good reception where you live! Don’t try it in
ein
signal
RBDS(t)
a signal
consists
of have
±1 at windows).
constant intervals
which good
encodereception
0, and 1 bits.
is t
rooms
insideisCory
that
do not
I’ve tested
fromThis
Cory
ctrum of x(t):
88.5Mhz and 94.1Mhz. Acquire 4 seconds of data at a sampling rate of 200,000 Hz. Y
r rtl_tcp or rtl_sdr for that. Compute and display a spectrogram with a window of
ude the spectrogram in your report. What is the spectral and temporal resolution? Exp
. Don’t forget to play with di↵erent dynamic ranges of the spectrogram for best visualizat
Spectrogram
of Demodulated FM radio (Adele on 96.5 MHz)
Now, the SDR already demodulates by the carrier frequency f , so the samples you get are actually
c
!
Z nT
alog57KHz
radio systems, FM demodulation
a phased-locked l
y[n] = y(nT ) is
= Aperformed
exp j2⇡ f
x(⌧by
)d⌧ implementing
,
0
he frequency of the
signal and extract the message x(t). However, it is very easy to implem
where T is the sampling rate.
odulation
38KHz when the samples are discrete. Note, that the signal x(t) is proportional to
Pick your favorite radio station (make sure there is good reception where you live! Don’t try it in the
basement
or in rooms
Cory proportional
that do not have windows).
I’ve tested
good receptionof
from
Coryphase!
hall
s frequency of the
signal.
It inside
is also
to the
derivative
the
We can im
5th floor at 88.5Mhz and 94.1Mhz. Acquire 4 seconds of data at a sampling rate of 200,000 Hz. You
19KHz
computing
the can
finite
di↵erences
of the
phase
ofandour
signal
angle(y[n])-angle(y[n-1]).
use either
rtl_tcp or rtl_sdr
for that.
Compute
display
a spectrogram
with a window of 500
Include the spectrogram in your report. What is the spectral and temporal resolution?
Explain
⇤ [n
hat is robust to samples.
phase
wrapping
is
to
compute
the
product
y[n]y
1]
and then compute
what you see. Don’t forget to play with di↵erent dynamic ranges of the spectrogram for best visualization.
0SDR already demodulates by the carrier frequency fc , so the samples you get are actually
w,
the
nce yourself that it works! In matlab it can be simply implemented by:
M. Lustig, EECS UC Berkeley
In many analog radio systems, FM demodulation is performedZby implementing !
a phased-locked loop
nT
Subcarrier FM radio (Hidden Radio Stations)
92KHz
67KHz
57KHz
spelled wrong!
spelled wrong!
57KHz
38KHz
19KHz
0
M. Lustig, EECS UC Berkeley
Applications
• Time Frequency Analysis
Spectrogram of digital communications Frequency Shift Keying JT65
https://gm7something.wordpress.com/2012/12/09/nov-radio-days/
Signal Wiki:
http://www.sigidwiki.com/wiki/Category:Active
M. Lustig, EECS UC Berkeley
STFT Reconstruction
1
x[rR + m]wL [m] =
N
N
X1
X[n, k]e
j2⇡km/N
k=0
• For non-overlapping windows, R=L :
x[n rL]
x[n] =
wL [n rL]
rL  n  (r + 1)R
1
• What is the problem?
M. Lustig, EECS UC Berkeley
STFT Reconstruction
1
x[rR + m]wL [m] =
N
N
X1
X[n, k]e
j2⇡km/N
k=0
• For non-overlapping windows, R=L :
x[n rL]
x[n] =
wL [n rL]
rL  n  (r + 1)R
1
• For stable reconstruction must overlap
window 50% (at least)
M. Lustig, EECS UC Berkeley
STFT Reconstruction
• For stable reconstruction must overlap
window 50% (at least)
• For Hann, Bartlett reconstruct with
overlap and add. No division!
M. Lustig, EECS UC Berkeley
Applications
• Noise removal
x[n]
• Recall bird chirp
Example: Bird Chirp
n
Play Sound!
Spectrum of a bird chirp
600
500
400
300
200
100
0
0
0.5
1
1.5
Hz
2
2.5
4
x 10
M. Lustig, EECS UC Berkeley
Application
• Denoising of Sparse spectrograms
Frequency, Hz
4000
3000
2000
1000
0
2
4
6
8
10
Time, s
12
14
16
18
• Spectrum is sparse! can implement
adaptive filter, or just threshold!
M. Lustig, EECS UC Berkeley
Denoising
Chirp with Gaussian Noise
Thresholded Spectrogram
reconstructed time signal
M. Lustig, EECS UC Berkeley
Limitations of Discrete STFT
• Need overlapping
Not orthogonal
• Computationally intensive O(MN log N)
• Same size Heisenberg boxes
M. Lustig, EECS UC Berkeley
From STFT to Wavelets
• Basic Idea:
–low-freq changes slowly - fast tracking
unimportant
–Fast tracking of high-freq is important in many
apps.
–Must adapt Heisenberg box to frequency
• Back to continuous time for a bit.....
M. Lustig, EECS UC Berkeley
From STFT to Wavelets
• Continuous time
t
t
⌦
!
!
t
!
t
!
u
t
!
⌦
u
M. Lustig, EECS UC Berkeley
Download