1
Discrete Fourier Transform Graduate School of Culture Technology - - PowerPoint PPT Presentation
Discrete Fourier Transform Graduate School of Culture Technology - - PowerPoint PPT Presentation
CTP 431 Music and Audio Computing Discrete Fourier Transform Graduate School of Culture Technology (GSCT) Juhan Nam 1 Outlines Fourier Series Fourier Transform Discrete-Time Fourier Transform Discrete Fourier Transform
Outlines
§ Fourier Series § Fourier Transform § Discrete-Time Fourier Transform § Discrete Fourier Transform
– Fast Fourier Transform
2
Fourier Series
§ Recall the “modes” in oscillation: the periodic signal x(t) with period T can be represented as
– Correct?
§ General form of a periodic signal x(t) with period T
– Add phase and D.C. offset
3
x(t) = 1 N r
k sin(2 k=1 ∞
∑
πkt /T)
x(t) = a0 + 1 N (ak cos(2πkt /T)+ bk sin(2
k=1 ∞
∑
πkt /T)) x(t) = a0 + 1 N r
k sin(2πkt /T +φ(k)) k=1 ∞
∑
Fourier Series
§ How can you get the coefficients?
– Use the orthogonality of sinusoids
§ Coefficients
4
cos(2πmt /T)sin(2πnt /T)
−T/2 T/2
∫
dt = 0
cos(2πmt /T)cos(2πnt /T)
−T/2 T/2
∫
dt = T (m = n) 0 (m ≠ n) $ % & ' &
ak = 1 T x(t)cos(2πkt /T)
−T/2 T/2
∫
dt bk = 1 T x(t)sin(2πkt /T)
−T/2 T/2
∫
dt
a0 = 1 T x(t)
−T/2 T/2
∫
dt
Fourier Transform
§ What if the signal is not periodic?
– An aperiodic signal can be approximated by – Angular frequency
§ The general form is converted to § The coefficients are to
5
T → ∞
ωk = 2πk /T = 2π(kF)
Discrete ¡frequency ¡
→ ω = 2π f
Con0nuous ¡frequency ¡
x(t) = (A(ω)cos(ωt)
∞
∫
+ B(ω)sin(ωt))dω
A(ω) = 1 π x(t)cos(ωt)
−∞ ∞
∫
dt B(ω) = 1 π x(t)sin(ωt)
−∞ ∞
∫
dt
Fourier Transform
§ Can we represent the transform in a simpler form?
– Combine A(w) and B(w) into a single term – Amplitude and phase are explicit – Explain the properties of Fourier transform easily
6
Fourier Transform
§ Euler’s identity
– Proof) Taylor’s series – If , (“the most beautiful equation in math”)
§ Properties
7
e jθ = cosθ + jsinθ
θ = π e jπ +1= 0
cosθ = e jθ +e− jθ 2 sinθ = e jθ −e− jθ 2 j
Fourier Transform
§ Plugging Euler’s identify in Fourier transform § Fourier Transform
8
x(t) = 1 2π (A'(ω)cos(ωt)
−∞ ∞
∫
+ B'(ω)sin(ωt))dω A'(ω) = π A(ω) = x(t)cos(ωt)
−∞ ∞
∫
dt B'(ω) = πB(ω) = x(t)sin(ωt)
−∞ ∞
∫
dt F(ω) = A'(ω)− jB'(ω) = x(t)(cos(ωt)− jsin(ωt))
−∞ ∞
∫
dt = x(t)e− jωt
−∞ ∞
∫
dt F(ω) = x(t)e− jωt
−∞ ∞
∫
dt
Fourier Transform
§ Inverse Fourier Transform
9
x(t) = 1 2π (A'(ω)cos(ωt)
−∞ ∞
∫
+ B'(ω)sin(ωt))dω x(t) = 1 2π (A'(ω)(e jωt +e− jωt 2 )
−∞ ∞
∫
+ B'(ω)(e jωt −e− jωt 2 j ))dω x(t) = 1 2π 1 2 (A'(ω)− jB'(ω))e jωt
−∞ ∞
∫
+ 1 2 (A'(ω)+ jB'(ω))e− jωtdω x(t) = 1 2π (1 2 F(ω)e jωt
−∞ ∞
∫
+ 1 2 F(ω)e jωt)dω = Real{ 1 2π F(ω)e jωt
−∞ ∞
∫
dω} x(t) = 1 2π F(ω)e jωt
−∞ ∞
∫
dω
Discrete-Time Fourier Transform (DTFT)
§ DTFT
– Time is sampled
§ Inverse DTFT
– is periodic in frequency domain
10
F(ω) = x(n)e− jωn
−∞ ∞
∑
x(t) = 1 2π F(ω)e jωt
−π π
∫
dω
F(ω)
Discrete Fourier Transform
§ Now, what if the discrete signal is finite in length (N ) ?
– This is the signal that we really handle
§ We assume that x(n) is periodic with period N
– Periodic in time à Sampling in frequency
11
x(n) =[x0, x1, x2,!, xN−1]
ωk = 2πkfk = 2πk / N
Discrete ¡frequency ¡
→
ω = 2π f
Con0nuous ¡frequency ¡
Discrete Fourier Transform
§ Discrete Fourier Transform
– Magnitude spectrum: – Phase spectrum:
§ Inverse Discrete Fourier Transform
12
X(k) = x(n)e− j2πkn/N
n=0 N−1
∑
= XR(k)+ jXI(k)
x(n) = 1 N X(k)e j2πkn/N
k=0 N−1
∑
X(k) = A(k) = XR
2(k)+ XI 2(k)
∠X(k) = Θ(k) = tan−1( XI(k) XR(k))
(Extra) Discrete Fourier Transform
§ Can we represent x(n) with a finite set of sinusoids?
– Finding
§ Orthogonality of Sinusoids
– Inner product between two sinusoids
13
x(n) = 1 N A(k)cos(2
k=0 N−1
∑
πkn / N +φ(k))
A(k),φ(k)
cos(2
n=0 N−1
∑
π pn / N)cos(2πqn / N)) = N / 2 if p = q or p = N −q
- therwise
# $ % & % sin(2
n=0 N−1
∑
π pn / N)sin(2πqn / N)) =
- therwise
N / 2 if p = q −N / 2 if p = N − q # $ % & % %
cos(2
n=0 N−1
∑
π pn / N)sin(2πqn / N)) = 0
(Extra) Discrete Fourier Transform
§ Do the inner product with the signal and sinusoids § Using Euler’s Identity
14
XR(k) = x(n)cos(2
n=0 N−1
∑
πkn / N) XI(k) = − x(n)sin(2
n=0 N−1
∑
πkn / N) X(k) = XR(k)+ jXI(k) = x(n)e− j2πkn/N
n=0 N−1
∑
x(n) = 1 N (XR(k)cos(2
k=0 N−1
∑
πkn / N)− XI(k)sin(2πkn / N))
XR(k) = A(k)cosΘ(k) XI(k) = A(k)sinΘ(k) A(k) = A(N − k)
We ¡assume ¡that ¡ ¡
(Extra) Discrete Fourier Transform
§ Now the inverse discrete Fourier transform is derived as
15
x(n) = 1 N A(k)cos(2
k=0 N−1
∑
πkn / N +Θ(k)) = 1 N A(k)(e j(2πkn/N+Θ(k))
k=0 N−1
∑
+e− j(2πkn/N+Θ(k))) / 2 = 1 N (X(k)e j2πkn/N
k=0 N−1
∑
+ X(k)e− j2πkn/N ) / 2 = Real{ 1 N X(k)e j2πkn/N} = 1 N X(k)e j2πkn/N
k=0 N−1
∑
k=0 N−1
∑
Fast Fourier Transform
§ Matrix multiplication view of DFT § In fact, we don’t compute this directly. There is a more efficiently way, which is called “Fast Fourier Transform (FFT)”
– Complexity reduction by FFT: O(N2)à O(Nlog2N) – Divide and conquer
16
Examples of DFT
17
Sine ¡waveform ¡ Drum ¡ Flute ¡
Properties of DFT
§ Linearity: § Shift: § Modulation (frequency shift): § Symmetry
– If x(n) is real, the magnitude is even-symmetry and the phase is
- dd-symmetry
§ Convolution:
18
ax1(n)+ bx2(n)↔ aX1(k)+ bX2(k)
x(n − m)↔ e− j2πmk/NX(k) e j2πmn/Nx(n)↔ X(k − m) x1(n)* x2(n)↔ X1(k)X2(k) x1(n)x2(n)↔ X1(k)* X2(k)
(Duality) ¡
Zero-padding
§ Adding zeros to a windowed frame in time domain
– Corresponds to “ideal interpolation” in frequency domain – In practice, FFT size increases by the size of zero-padding
19
Demo: Fourier Series
§ Web Audio Demo
– http://codepen.io/anon/pen/jPGJMK (additive synthesis)
20