Upload
vishal-dwivedi
View
219
Download
0
Embed Size (px)
Citation preview
8/12/2019 eck_fft
1/54
A Tutorial on Fourier Analysis
A Tutorial on Fourier Analysis
Douglas Eck
University of Montreal
NYU March 2006
http://find/http://goback/8/12/2019 eck_fft
2/54
A Tutorial on Fourier Analysis
0 20 40 60 80 100 120 140 160 180 2001
0.5
0
0.5
1A fundamental and three odd harmonics (3,5,7)
fund (freq 100)
3rd harm5th harm
7th harmm
0 20 40 60 80 100 120 140 160 180 200
1
0.5
0
0.5
1Sum of odd harmonics approximate square wave
fund (freq 100)
fund+3rd harm
fund+3rd+5th
fund+3rd+5th+7th
http://goback/http://find/http://goback/8/12/2019 eck_fft
3/54
A Tutorial on Fourier Analysis
0 20 40 60 80 100 120 140 160 180 2001
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
Sum of odd harmonics from 1 to 127
http://find/8/12/2019 eck_fft
4/54
A Tutorial on Fourier Analysis
Linear Combination
In the interval [u1, u2] a function (u) can be written as a linearcombination:
(u) =i=0
ii(u)
where functions i(u) make up a set of simple elementary
functions. If functions are orthogonal (roughly, perpindicular; innerproduct is zero)then coefficients iare independant from oneanother.
http://find/8/12/2019 eck_fft
5/54
A Tutorial on Fourier Analysis
Continuous Fourier Transform
The most commonly used set of orthogonal functions is the Fourierseries. Here is the analog version of the Fourier and Inverse Fourier:
X(w) =
+
x(t)e(2jwt)dt
x(t) = +
X(w)e(2jwt)
dw
A A
http://goforward/http://find/8/12/2019 eck_fft
6/54
A Tutorial on Fourier Analysis
Discrete Fourier and Inverse Fourier Transform
X(n) =
N1k=0
x(k)e2jnk/N
x(k) = 1
N
N1n=0
X(n)e2jnk/N
A T i l F i A l i
http://find/8/12/2019 eck_fft
7/54
A Tutorial on Fourier Analysis
Taylor Series Expansion
f(x) =f(x0)+ f
(x0)1 (xx0)+ f
(x0)1 2 (xx0)2+ f
(x0)1 2 3 (xx0)3+...
or more compactly as
f(x) =
n=0
f(n)(x0)
n! (x x0)n
A T t i l n F i An l sis
http://find/8/12/2019 eck_fft
8/54
A Tutorial on Fourier Analysis
Taylor series expansion of ej
Since ex is its own derivative, the Taylor series expansion forf(x) =ex is very simple:
ex =n=0
xn
n! = 1 +x+
x2
2 +
x3
3! +...
We can define:
ej ==n=0
(j)nn!
= 1 +j 22 j3
3! +...
A Tutorial on Fourier Analysis
http://find/http://goback/8/12/2019 eck_fft
9/54
A Tutorial on Fourier Analysis
Splitting out real and imaginary parts
All even order terms are real; all odd-order terms are imaginary:
reej = 1 2/2 + 4/4! ...
imej = 3/3! + 5/5! ...
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
10/54
A Tutorial on Fourier Analysis
Fourier Transform as sum of sines and cosines
Observe that:
cos() =
n>=0;n is even
(1)n/2
n!
n
sin() =
n>=0;n is odd
(1)(n1)/2
n! n
Thus yielding Eulers formula:
ej = cos() +j sin()
A Tutorial on Fourier Analysis
http://find/http://goback/8/12/2019 eck_fft
11/54
A Tutorial on Fourier Analysis
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
12/54
A Tutorial on Fourier Analysis
Fourier transform as kernel matrix
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
13/54
y
Example
Sum of cosines with frequencies 12 and 9, sampling rate = 120
0 20 40 60 80 100 1200.02
0.01
0
0.01
0.02
signal
0 20 40 60 80 100 1200.5
0
0.5
1
real part
0 20 40 60 80 100 1200.2
0.1
0
0.1
0.2
imag part
two cosines (freqs=9, 12)
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
14/54
Example
FFT coefficients mapped onto unit circle
1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 11
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1FFT projected onto unit circle
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
15/54
Impulse response
0 10 20 30 40 50 60 70 80 90 1000
0.5
1
signal
0 10 20 30 40 50 60 70 80 90 100
0.01
0.01
0.01
magnitude
impulse response
0 10 20 30 40 50 60 70 80 90 1001
0.5
0
0.5
1
phase
http://find/8/12/2019 eck_fft
16/54
A Tutorial on Fourier Analysis
8/12/2019 eck_fft
17/54
A look at phase shifting
Sinusoid frequency=5 phase shifted multiple times.
0 10 20 30 40 50 60 70 80 90 10049.5361
49.5361
49.5361
49.5361
magn
itude
number of points shifted
sinusoid freq=5 phase shifted repeatedly
0 10 20 30 40 50 60 70 80 90 1003
2
1
0
1
2
3
anglefreq=6
number of pointsshifted
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
18/54
Sin period 10 + period 30
0.5 0.4 0.3 0.2 0.1 0 0.1 0.2 0.3 0.4 0.50
100
200
freq (mag)
0.5 0.4 0.3 0.2 0.1 0 0.1 0.2 0.3 0.4 0.55
0
5
phase
0 100 200 300 400 500 6001
0
1
component sinusoids
0 100 200 300 400 500 6005
0
5
reconstructed signal using component sinusoids vs original
0 100 200 300 400 500 6002
0
2
reconstructed signalusing ifft vs original
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
19/54
Aliasing
The useful range is the Nyquist frequency (fs/2)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 11
0
1cos(21)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 11
0
1cos(21) sampled at 24 Hz
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 11
0
1cos(45)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 11
0
1cos(45) sampled at 24 Hz
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 11
0
1cos(3)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
1
0
1cos(3) sampled at 24 Hz
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
20/54
Leakage
Even below Nyquist, when frequencies in the signal do not alignwell with sampling rate of signal, there can be leakage. Firstconsider a well-aligned exampl (freq = .25 sampling rate)
0 10 20 30 40 50 60 701
0.5
0
0.5
1Sinusoid at 1/4 the Sampling Rate
Time (samples)
Amp
litude
a)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
10
20
30
40
Normalized Frequency (cycles per sample))
Mag
nitude(Linear)
b)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
300
200
100
0
Normalized Frequency (cyclesper sample))
Magnitude(dB)
c)
A Tutorial on Fourier Analysis
http://find/http://find/8/12/2019 eck_fft
21/54
Leakage
Now consider a poorly-aligned example (freq = (.25 + .5/N) *sampling rate)
0 10 20 30 40 50 60 701
0.5
0
0.5
1Sinusoid NEAR 1/4 the Sampling Rate
Time (samples)
Amplitude
a)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
10
20
30
Normalized Frequency (cycles per sample))
Magnitude(Linear)
b)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 110
0
10
20
30
Normalized Frequency (cyclesper sample))
Magnitude(dB)
c)
A Tutorial on Fourier Analysis
http://find/http://find/8/12/2019 eck_fft
22/54
Leakage
Comparison:
0 10 20 30 40 50 60 701
0.5
0
0.5
1Sinusoid at 1/4 the Sampling Rate
Time (samples)
Am
plitude
a)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
10
20
30
40
Normalized Frequency (cycles per sample))
Magnitude(Linear)
b)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
300
200
100
0
Normalized Frequency (cyclesper sample))
Magnitude(dB)
c)
0 10 20 30 40 50 60 701
0.5
0
0.5
1Sinusoid NEAR 1/4 the Sampling Rate
Time (samples)
Am
plitude
a)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
10
20
30
Normalized Frequency (cycles per sample))
Magnitude(Linear)
b)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 110
0
10
20
30
Normalized Frequency (cyclesper sample))
Magnitude(dB)
c)
A Tutorial on Fourier Analysis
http://find/http://find/http://find/8/12/2019 eck_fft
23/54
Windowing can help
Can minimize effects by multiplying time series by a window thatdiminishes magnitude of points near signal edge:
0 10 20 30 40 50 60 700
0.5
1Blackman Window
Time (samples)
Amplitude
a)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1100
50
0
Normalized Frequency (cycles per sample))
Magnitude(dB)
b)
0.5 0.4 0.3 0.2 0.1 0 0.1 0.2 0.3 0.4 0.5100
50
0
NormalizedFrequency (cycles per sample))
Magnitude(dB)
c)
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
24/54
Leakage Reduced
Comparison:
0 10 20 30 40 50 60 701
0.5
0
0.5
1Sinusoid NEAR 1/4 the Sampling Rate
Time (samples)
Amp
litude
a)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
10
20
30
Normalized Frequency (cycles per sample))
Magnitude(Linear)
b)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 110
0
10
20
30
Normalized Frequency (cyclesper sample))
Magnitude(dB)
c)
0 10 20 30 40 50 60 701
0.5
0
0.5
1Sinusoid at 1/4 the Sampling Rate
Time (samples)
Amp
litude
a)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
5
10
15
Normalized Frequency (cycles per sample))
Magnitude(Linear)
b)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 180
60
40
20
0
20
Normalized Frequency (cyclesper sample))
Magnitude(dB)
c)
A Tutorial on Fourier Analysis
http://find/http://find/http://find/8/12/2019 eck_fft
25/54
Convolution theorem
This can be understood in terms of the Convolution Theorem.
Convolution in the time domain is multiplication in the frequencydomain via the Fourier transform (F).
F(f g) = F(f) F(g)
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
26/54
Computing impulse response
The impulse response h[n] is the response of a system to the unit
impulse function.
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
27/54
Using the impulse response
Once computed, the impulse response can be used to filter anysignal x[n] yielding y[n].
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
28/54
Examples
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
29/54
Filtering using DFT
Goal is to choose good impulse response h[n]
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
30/54
Filtering using DFT
Goal is to choose good impulse response h[n]Transform signal into frequency domain
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
31/54
Filtering using DFT
Goal is to choose good impulse response h[n]Transform signal into frequency domain
Modify frequency properties of signal via multiplication
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
32/54
Filtering using DFT
Goal is to choose good impulse response h[n]Transform signal into frequency domain
Modify frequency properties of signal via multiplication
Transform back into time domain
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
33/54
Difficulties (Why not a perfect filter?)
Youcan
have a perfect filter(!)
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
34/54
Difficulties (Why not a perfect filter?)
Youcan
have a perfect filter(!)Need long impulse response function in both directions
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
35/54
Difficulties (Why not a perfect filter?)
You can have a perfect filter(!)
Need long impulse response function in both directions
Very non causal
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
36/54
Difficulties (Why not a perfect filter?)
You can have a perfect filter(!)
Need long impulse response function in both directions
Very non causal
In generating causal version, challenges arise
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
37/54
Gibbs Phenomenon
500 400 300 200 100 0 100 200 300 400 5000
0.5
1
ideal lopass filter in frequency domain
500 400 300 200 100 0 100 200 300 400 5000.1
0
0.1
ideal filter coeffs in time domain
0 100 200 300 400 500 600 700 800 900 10000.1
0
0.1
truncated causal filter
500 400 300 200 100 0 100 200 300 400 5000
0.5
1
1.5
Gibbsphenomenon
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
38/54
Spectral Analysis
Often we want to see spectral energy as a signal evolves overtime
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
39/54
Spectral Analysis
Often we want to see spectral energy as a signal evolves overtime
Compute Fourier Transform over evenly-spaced frames of data
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
40/54
Spectral Analysis
Often we want to see spectral energy as a signal evolves overtime
Compute Fourier Transform over evenly-spaced frames of data
Apply window to minimize edge effects
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
41/54
Short-Timescale Fourier Transform (STFT)
X(m, n) =
N1
k=0
x(k)w(km)e2jnk/N
Where w is some windowing function such as Hanning or gaussiancentered around zero.The spectrogram is simply the squared magnitude of these STFT
values
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
42/54
Trumpet (G4)
Time
Frequency
0 1 2 3 4 5 60
1000
2000
3000
4000
5000
[Listen]
A Tutorial on Fourier Analysis
http://wavs/trumpet-G4.wavhttp://wavs/trumpet-G4.wavhttp://find/8/12/2019 eck_fft
43/54
Violin (G4)
Time
Frequency
0 0.5 1 1.5 2 2.5 30
1000
2000
3000
4000
5000
[Listen]
A Tutorial on Fourier Analysis
http://wavs/violin-G4.wavhttp://wavs/violin-G4.wavhttp://find/8/12/2019 eck_fft
44/54
Flute (G4)
Time
Frequency
0 0.5 1 1.5 2 2.50
1000
2000
3000
4000
5000
[Listen]
A Tutorial on Fourier Analysis
http://wavs/flute-G4.wavhttp://wavs/flute-G4.wavhttp://find/8/12/2019 eck_fft
45/54
Piano (G4)
Time
Frequency
0 0.1 0.2 0.3 0.4 0.5 0.6 0.70
1000
2000
3000
4000
5000
[Listen]
A Tutorial on Fourier Analysis
http://wavs/piano-G4.wavhttp://wavs/piano-G4.wavhttp://find/8/12/2019 eck_fft
46/54
Voice
Time
Frequency
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20
1000
2000
3000
4000
5000
6000
7000
8000
[Listen]
A Tutorial on Fourier Analysis
http://wavs/Voice.wavhttp://wavs/Voice.wavhttp://find/8/12/2019 eck_fft
47/54
C Major Scale (Piano)
Time
Frequency
0 1 2 3 4 5 6 7 80
2000
4000
6000
8000
10000
12000
14000
16000
[Listen]
A Tutorial on Fourier Analysis
http://wavs/CMajorPianoScale.wavhttp://wavs/CMajorPianoScale.wavhttp://find/8/12/2019 eck_fft
48/54
C Major Scale (Piano)
Log Spectrogram (Constant-Q Transform) reveals low-frequencystructure
Time
Frequency
0 1 2 3 4 5 6 7 8
135
240
427
761
1356
2416
4305
7671
13669
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
49/54
Time-Space Tradeoff
0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
0.4
0.2
0
0.2
0.4
0.6
Amp.
spoken "Steven Usma"
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
50/54
Time-Space Tradeoff
Time
Frequency
Narrowband Spectrogram overlap=152 timepts=1633
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.60
1000
2000
3000
4000
Time
Frequency
Wideband Spectrogram overlap=30 timepts=6593
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.60
1000
2000
3000
4000
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
51/54
Auto-correlation and meter
Autocorrelation long used to find meter in music (Brown 1993)Lag kauto-correlation a(k) is a special case of cross-correlationwhere a signal x is correlated with itself:
a(k) = 1N
N1n=k
x(n)x(n k)
A Tutorial on Fourier Analysis
http://find/8/12/2019 eck_fft
52/54
Auto-correlation and meter
Autocorrelation long used to find meter in music (Brown 1993)Lag kauto-correlation a(k) is a special case of cross-correlationwhere a signal x is correlated with itself:
a(k) = 1N
N1n=k
x(n)x(n k)
Autocorrelation can also be defined in terms of Fourier analysis
a= F
1(|F(x)|)
whereFis the Fourier transform, F1 is the inverse Fouriertransform and || indicates taking magnitude from a complex value.
http://find/8/12/2019 eck_fft
53/54
A Tutorial on Fourier Analysis
8/12/2019 eck_fft
54/54
Fast Fourier Transform
Fourier Transform O(N2)
Fast version possible O(NlogN)
Size must be a power of two
Strategy is decimation in time or frequency
Divide and conquer
Rearrange the inputs in bit reversed order
Output transformation (Decimation in Time)
http://find/