FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0...
Transcript of FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0...
![Page 1: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/1.jpg)
1
FFT analysis in practice Perception & Multimedia Computing Lecture 13
Rebecca Fiebrink Lecturer, Department of Computing Goldsmiths, University of London
![Page 2: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/2.jpg)
2
• Review of complex numbers: rectangular and polar representations • The complex exponential • The Fourier Series and Discrete Fourier Transform (DFT) • The Fast Fourier Transform (FFT)
• Lab: • Understanding convolution and systems
through hands-on practice • Signals and convolution in R
Last Week
![Page 3: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/3.jpg)
3
• Brief lab discussion (more tomorrow) • Brief coursework discussion • Using FFT in practice
• Choosing parameters and interpreting output • Short-time Fourier Transform • Example applications • Variants of Fourier transform
Today
![Page 4: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/4.jpg)
4
• Convolution by hand: Examples • h=[3,2,4] :
same as [3, 0, 0] + [0, 2, 0] + [0, 0, 4] same as 3[1] + 2[0, 1] + 4[0, 0, 1] same as 3[1] + 2T1{[1]} + 4T2{[1]}
• x ∗ h = x ∗ 3[1] + x ∗ 2T1{[1]} + x ∗ 4T2{[1]}
• Example on board
Lab discussion
![Page 5: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/5.jpg)
5
The FFT in Practice
![Page 6: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/6.jpg)
6
• Given a signal, what is its frequency content?
• Helps us understand audio content (pitch, timbre, melody, rhythm, genre, speech, …)
• Also a building block for designing and understanding effects (filters, equalization, reverb, echo)
• One of the most powerful and useful techniques for working with audio, image, and video!
Fast Fourier Transform (FFT) Review
![Page 7: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/7.jpg)
7
• Equation:
• Essentially, dot-product multiply our signal x with complex exponentials with periods of N, N/2, N/3, … 2 samples (i.e., frequencies of 1/N, 2/N, 3/N, … 1/2 oscillations per sample), as well as DC component
Fast Fourier Transform (FFT) Review
![Page 8: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/8.jpg)
8
• Each Xk is a complex number (e.g., 10+5i, or 3∠π/2)
• If the kth frequency is present in the signal, Xk will have non-zero magnitude, and its magnitude and phase will tell us how much of that frequency is present and at what phase (though not directly)
Fast Fourier Transform (FFT) Review
![Page 9: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/9.jpg)
9
1) Spectrum
Viewing FFT output
![Page 10: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/10.jpg)
10
2) Spectrogram
Viewing FFT output
![Page 11: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/11.jpg)
11
What will you hear?
![Page 12: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/12.jpg)
12
What will you hear?
![Page 13: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/13.jpg)
13
What will you hear?
![Page 14: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/14.jpg)
14
• N-point FFT computes N complex values • X0 to XN-1, representing frequencies of 0Hz
to (N-1/N * SampleRate) 0Hz, (1/N)*SR, (2/N)*SR, … (N/2)/N*SR, … (N-1)/N*SR
• These frequencies often called “bins” of FFT • Note that adjacent bins are (1/N)*SR apart
What is really output
=1/2*SR (Nyquist)
![Page 15: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/15.jpg)
15
Bins above Nyquist are redundant Magnitude spectrum is symmetric around the Nyquist frequency:
![Page 16: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/16.jpg)
16
Bins above Nyquist are redundant Magnitude spectrum is symmetric around the Nyquist frequency:
![Page 17: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/17.jpg)
17
Bins above Nyquist are redundant Bin k is complex conjugate of bin N-k:
Complex conjugates (equal in magnitude, opposite in phase)
![Page 18: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/18.jpg)
18
Bins above Nyquist are redundant Bin k is complex conjugate of bin N-k: phases of these bins are flipped
![Page 19: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/19.jpg)
19
Why??? If your input is a real-valued sinusoid, FFT decomposes it into one phasor rotating clockwise and one rotating counterclockwise, at the same frequency.
+
![Page 20: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/20.jpg)
20
Practical takeaway so far: You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued: always true for audio)
There are specific, simple relationships between magnitudes & phases of these first N/2+1 bins and the rest of the bins.
![Page 21: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/21.jpg)
21
• N bins of FFT evenly divide frequencies from 0 Hz to (N-1)/N * SR • Why not up to sample rate itself?
• SR indistinguishable from 0Hz!
• We’re chopping frequencies from 0 up to (but not including) the sample rate into N bins, SO consecutive bins are (1/N)*SR apart
Converting from bin # to frequency in Hz
![Page 22: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/22.jpg)
22
Width of spectrum bins
f
Mag
nitu
de
€
Δf = fmax /N = SampleRate /N
![Page 23: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/23.jpg)
23
I take an FFT of 128 samples; my sample rate is 1000Hz. N = 128; I have 128 “bins”. Bin 0 is? (assuming indexing starting w/ 0)
0 Hz Bin 1 is?
(1/128) * 1000 ≈ 7.8 Hz Bin 2 is?
(2/128) * 1000 ≈ 15.6 Hz
Example
![Page 24: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/24.jpg)
24
I take an FFT of 128 samples; my sample rate is 1000Hz. N = 128; I have 128 “bins”. 14th bin is?
(14/128) * 1000 ≈ 109 Hz Bins nearest to 300 Hz are?
(b/128) * 1000 = 300 ! b = 38.4 bins 38 and 39 are closest
Last bin I care about is? Nyquist: (b/128)*1000 = 500 ! b = 64
(equivalently, equal to N/2)
Example
![Page 25: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/25.jpg)
25
This frequency will “leak” into nearby bins.
What happens if my signal contains a frequency that’s not exactly equal to the center frequency of a bin?
![Page 26: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/26.jpg)
26
SR = 100Hz, sine at 24 Hz
![Page 27: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/27.jpg)
27
SR = 100Hz, sine at 25 Hz
![Page 28: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/28.jpg)
28
SR = 100Hz, sine at 24.5 Hz
![Page 29: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/29.jpg)
29
More bins? Better frequency resolution Worse time resolution (FFT can’t
detect changes within the analysis frame) Fewer bins?
Worse frequency resolution Better time resolution
How many bins to use? (What should N be?)
![Page 30: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/30.jpg)
30
Time/Frequency tradeoff
N=64 N=4096
![Page 31: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/31.jpg)
31
![Page 32: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/32.jpg)
32
![Page 33: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/33.jpg)
33
What’s all that extra stuff in the spectrum?
Not just clean peaks at frequencies and 0 elsewhere…
![Page 34: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/34.jpg)
34
FFT treats your analysis frame as one period of an infinite, periodic signal.
Signal doesn’t have an integer # of periods in frame? ! Contains frequency components other than 0, (1/N)*SR, (2/N)*SR, … SR/2.
Reasons for this “stuff”
![Page 35: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/35.jpg)
35
FFT treats your analysis frame as one period of an infinite, periodic signal.
“periodic” signal may have discontinuities ! only representable with high frequency content
Reasons for this “stuff”
Stay tuned for a way to help with this…
![Page 36: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/36.jpg)
36
Q: How many bins should we use? Q: Algorithm to determine pitch?
Practice: Pitch tracking
![Page 37: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/37.jpg)
37
saw <- readWave("sawtooth.wav")
X <- fft(saw@left[1:2048]) #saw@left gives # us left channel samples
plot(abs(X)[1:1025], type="h")
maxbin <- which.max(abs(X)[1:1025])
maxfreq <- (maxbin-1)/2048*44100 #assuming 44100 SR
Example R code
![Page 38: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/38.jpg)
38
Compute FFT at many points in time.
How to deal with music that changes over time?
![Page 39: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/39.jpg)
39
“Short-time Fourier Transform” (STFT)
N-point FFT N-point FFT N-point FFT
![Page 40: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/40.jpg)
40
STFT hop size
N-point FFT N-point FFT
# of samples between beginning of one frame and the next
Equivalently talk about “overlap” between adjacent frames. Adjust based on application needs.
![Page 41: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/41.jpg)
41
Pitch tracking over time (melody extraction) Onset detection (for rhythm/tempo analysis?) Audio fingerprinting More discussion on these in a few weeks
Example applications of STFT?
![Page 42: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/42.jpg)
42
• N = ? (Frame length) • Balances time & frequency resolutions
• FFT or STFT? • Is frequency content changing over time? • If STFT, choose hop size based on granularity of
analysis needed • Do I care about magnitude, phase, or both? • Magnitude alone useful for basic timbre analysis,
instrument identification, many other things; phase required for reconstruction of waveform
***Plus a few other things: revisiting this at end of lecture***
Practical FFT Questions
![Page 43: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/43.jpg)
43
Option 1: Take magnitude and phase of each bin (including second half of bins), compute a sinusoid at appropriate magnitude, frequency, and phase…
Option 2 (MUCH BETTER): Use inverse FFT (i.e., the IFFT)
Converting from FFT back into sound
![Page 44: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/44.jpg)
44
IDFT is just like DFT, but 1) has 1/N factor and positive exponent; 2) converts from complex into real (assuming original signal was real-valued)
The Inverse Discrete Fourier Transform (IDFT)
xn =1
N
N�1X
k=0
Xkei2⇡kn/N
Compare to DFT:
Xk =N�1X
n=0
xne�i2⇡kn/N
![Page 45: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/45.jpg)
45
Compute IDFT using the IFFT
N FFT bins ! N IFFT samples
In R, with signal library: x <- abs(ifft(X))
(abs enforces reasonable assumption of real valued elements of x)
The IFFT in practice
![Page 46: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/46.jpg)
46
Modify a sound by manipulating its spectrum:
A possible application of IFFT?
Original signal
FFT
Multiply 4th bin by 0.25
IFFT Modified signal
![Page 47: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/47.jpg)
47
Modify a sound by manipulating its spectrum:
A possible application of IFFT?
Original signal
FFT
Multiply 4th bin by 0.25
IFFT Modified signal
There are better ways of doing this…
![Page 48: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/48.jpg)
48
Why so many versions of Fourier analysis?
• Each of these also has an inverse. • You’ll mainly care about the FFT (the fast algorithm for computing the DFT).
Continuous Time Discrete Time
Aperiodic / unbounded time, continuous frequency
Fourier Transform Discrete-time Fourier Transform (DTFT)
Periodic or bounded time, discrete frequency
Fourier Series Discrete Fourier Transform (DFT) (FFT used here)
![Page 49: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/49.jpg)
49
Method 1) Design a useful impulse response.
How to build useful systems?
![Page 50: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/50.jpg)
50
A very simple system
Volume control!
[1] = [1, 0, 0, …] H h[n] = [2] Impulse in h[n] = [0.5]
y[n] = x[n] ∗ h[n]
![Page 51: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/51.jpg)
51
Another very simple system
[very simple] echo
[1] = [1, 0, 0, …] H h[n] = [1, 0, 0, 0.5]
Impulse in
y[n] = x[n] ∗ h[n]
![Page 52: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/52.jpg)
52
More realistic echo
Use this as h[n]
![Page 53: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/53.jpg)
53
Convolution reverb Record impulse response for concert halls, churches, etc. Use this as h[n].
Example impulse responses…
![Page 54: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/54.jpg)
54
Take average of nearby points:
A simple smoothing system
![Page 55: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/55.jpg)
55
A simple smoothing system
[1] = [1, 0, 0, …] H h[n] = [0.5, 0.5]
y[n] = .5x[n-1] + .5x[n]
![Page 56: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/56.jpg)
56
How to improve this? Can use h=[0.25, 0.25, 0.25, 0.25], h=[0.1, 0.1, … 0.1] to make signal even smoother
But there’s a better way... “smoother” = “less high-frequency content”
![Page 57: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/57.jpg)
57
Method 1) Design a useful impulse response We have to know how we want the time-domain sound signal to be changed by the system.
Method 2) Design a useful frequency response Instead, we can decide how we want the spectrum of the sound to be changed by the system.
How to build useful systems?
![Page 58: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/58.jpg)
58
Any LTI system has the ability to change the spectrum of a sound
Frequency response R
elat
ive
chan
ge
in
mag
nit
ud
e
Frequency
1.0
Doesn’t change magnitude spectrum
![Page 59: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/59.jpg)
59
Any LTI system has the ability to change the spectrum of a sound
Frequency response R
elat
ive
chan
ge
in
mag
nit
ud
e
Frequency
1.0
Removes higher frequencies, leaves lower freqs unchanged
![Page 60: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/60.jpg)
60
Any LTI system has the ability to change the spectrum of a sound
Frequency response R
elat
ive
chan
ge
in
mag
nit
ud
e
Frequency
1.0
Removes lower frequencies, leaves higher freqs unchanged
![Page 61: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/61.jpg)
61
Any LTI system has the ability to change the spectrum of a sound
Frequency response R
elat
ive
chan
ge
in
mag
nit
ud
e
Frequency
1.0
Allows only a range of frequencies to pass through system
![Page 62: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/62.jpg)
62
Any LTI system has the ability to change the spectrum of a sound
Frequency response R
elat
ive
chan
ge
in
mag
nit
ud
e
Frequency
1.0
Allows all but a range of frequencies to pass through system
![Page 63: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/63.jpg)
63
Any LTI system has the ability to change the spectrum of a sound
Frequency response R
elat
ive
chan
ge
in
mag
nit
ud
e
Frequency
1.0
Allows all but a range of frequencies to pass through system
![Page 64: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/64.jpg)
64
Each of these systems is an example of a common type of audio filter.
Filters
![Page 65: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/65.jpg)
65
Any LTI system has the ability to change the spectrum of a sound
Frequency response R
elat
ive
chan
ge
in
mag
nit
ud
e
Frequency
1.0
Doesn’t change magnitude spectrum
All-pass filter
![Page 66: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/66.jpg)
66
Any LTI system has the ability to change the spectrum of a sound
Frequency response R
elat
ive
chan
ge
in
mag
nit
ud
e
Frequency
1.0
Removes higher frequencies, leaves lower freqs unchanged
Low-pass filter
![Page 67: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/67.jpg)
67
Any LTI system has the ability to change the spectrum of a sound
Frequency response R
elat
ive
chan
ge
in
mag
nit
ud
e
Frequency
1.0
Removes lower frequencies, leaves higher freqs unchanged
high-pass filter
![Page 68: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/68.jpg)
68
Any LTI system has the ability to change the spectrum of a sound
Frequency response R
elat
ive
chan
ge
in
mag
nit
ud
e
Frequency
1.0
Allows only a range of frequencies to pass through system
band-pass filter
![Page 69: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/69.jpg)
69
Any LTI system has the ability to change the spectrum of a sound
Frequency response R
elat
ive
chan
ge
in
mag
nit
ud
e
Frequency
1.0
Allows all but a range of frequencies to pass through system
Band-stop filter
![Page 70: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/70.jpg)
70
The effect of a system on a signal can be understood as multiplying the signal’s spectrum by the frequency response.
nth bin in input x nth bin in frequency response = nth bin in output
The frequency response
![Page 71: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/71.jpg)
71
If h[n] is a system’s impulse response then the spectrum of h[n] (FFT(h[n])) is the frequency response!
Relationship of frequency response & impulse response
[1] = [1, 0, 0, …] H h[n] = [1, 0, 0, 0.5] Impulse in
Impulse response
FFT(h[n]) is frequency response
![Page 72: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/72.jpg)
72
1) Can take the FFT of h[n] to understand what an arbitrary system with known h[n] will do to a spectrum
Consequences
![Page 73: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/73.jpg)
73
Point-wise multiplication in spectral domain = convolution in time domain:
a[n] ∗ b[n] "! Ak× Bk
Point-wise multiplication in time domain = convolution in spectral domain:
a[n] × b[n] "! Ak∗ Bk
![Page 74: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/74.jpg)
74
Convolving in the time-domain (x[n] ∗ h[n]) is equivalent to multiplication in the frequency domain (Xk ·∙ Hk).
Convolution & Multiplication
×
∗ =
FFT
FFT
FFT
=
![Page 75: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/75.jpg)
75
Convolving in the time-domain (x[n] ∗ h[n]) is equivalent to multiplication in the frequency domain (Xk ·∙ Hk).
Convolution & Multiplication
∗ =
IFFT
IFFT
IFFT
![Page 76: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/76.jpg)
76
• Convolving in the time-domain (x[n] h[n]) is equivalent to multiplication in the frequency domain!
• Also, multiplying in the time domain is equivalent to convolving in the frequency domain.
Very important principles
![Page 77: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/77.jpg)
77
Filters like this are undesirable.
One big problem… R
elat
ive
chan
ge
in
mag
nit
ud
e
Frequency
1.0
![Page 78: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/78.jpg)
78
More practical FFT advice
![Page 79: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/79.jpg)
79
A problem:
Windowing: Motivation
![Page 80: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/80.jpg)
80
“Selecting” N time-domain samples is like point-by-point multiplication with a rectangular function (“window”):
Windowing
![Page 81: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/81.jpg)
81
A rectangular signal has a very “messy” spectrum!
Signal:
Spectrum:
Windowing
![Page 82: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/82.jpg)
82
Multiplying a signal by a rectangle in time…
Is equivalent to convolving their spectra!
Windowing
∗
![Page 83: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/83.jpg)
83
Before taking FFT, multiply the signal with a smooth window with a “nicer” spectrum
(Equivalently, something that will get rid of sharp edges at either end of analysis frame)
Solution: Apply a smoother window
![Page 84: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/84.jpg)
84
Windowing process
point-wise multiply with window:
Result (apply FFT to this)
![Page 85: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/85.jpg)
85
Example windows
From http://en.wikipedia.org/wiki/Window_function
![Page 86: FFT analysis in practicemas01rf/is52020b2013-14/2013-14/slides13.pdf · You only need to use bins 0 to N/2 for analysis, assuming your input signal is real-valued (and not complex-valued:](https://reader034.fdocuments.net/reader034/viewer/2022051912/6003489d5a19b769813f7abf/html5/thumbnails/86.jpg)
86
Example windows
From http://en.wikipedia.org/wiki/Window_function