Discrete Fourier Transform (DFT) Jyh-Shing Roger Jang (張智星) MIR Lab (多媒體資訊檢索實驗室) CSIE, NTU (台灣大學 資訊工程系) jang@mirlab.org, http://mirlab.org/jang
Discrete Fourier Transform Goal Decompose a given vector of discrete signals into sinusoidal components whose amplitudes can be view as energy distribution over a range of frequencies Applications Speech recognition Digital filtering Many many more... Due to sampling
Decomposition How to decompose xn=x(n/fs), n=0~N-1 into a linear combination of sinusoidal functions? Magnitude spectrum Phase spectrum Remaining problems To determine no. of terms and their frequencies
How to Select Frequencies Signals of N points with sample rate fs Total duration d=N/fs (sec) Periods = d, d/2, d/3, … Freq. of sinusoids (bin frequencies) Total count = N/2+1
No. of Terms for Decomposition Curve fitting for a parabola # of unknowns = # of equations (= # of points) Curve fitting view for sinusoidal decomp. How many terms do we need if there are N points? N/2+1!
Example When N=4
Example When N=8
Sinusoidal Basis Functions (1/2) Can be converted into sin & cos Phase is necessary
Sinusoidal Basis Functions (2/2)
Decompose x(t) into Basis Functions n=0,1,2,…, N-1 # of terms = # of bin freq = N/2+1 # of fitting parameters = N
Decomposition into Basis Functions Overall expression: No. of parameters is 1+2*(N/2-1)+1=N, which is equal to the no. of data points Exact solution is likely to exist. Amplitude Freq= Phase
Parameter Identification How to identify coefficients of the basis functions: Solving simultaneous linear equations Integration (which take advantage of the orthogonality of the basis functions) Fast Fourier transform (FFT) A fast algorithm with a complexity of O(N log N)
From Time-domain to Freq-domain Many animation over the web 3D animation Please post on FB if you find more.
Frequencies of Basis Functions Due to Euler identity, we can express the k-th term shown on the right. Quiz!
Frequencies of Basis Functions Plug in the simplified k-th term: Include the first and last terms:
Representations of DFT: Two-side Characteristics General representation If x is complex, then c is not conjugate symmetric MATLAB command: c=fft(x) Usually complex numbers
Representations of DFT: One-side Characteristics When x is real, c is conjugate symmetric and we only have to look at one-side of FFT result. MATLAB command: magSpec=fftOneside(x) Real Real In SAP toolbox Complex conjugate
Representations of DFT: One-side Formulas
Example: Conjugate Symmetric Conjugate symmetric of DFT for real x fftSym01.m
Example: Two-side FFT Two-side FFT of a pure sinusoid at one of the bin freqency fft01.m
Example: Two-side FFT Two-side FFT of a pure sinusoid NOT at one of the bin frequencies fft02.m
Example: One-side FFT One-side FFT of a pure sinusoid NOT at one of the bin frequencies fft03.m
Example: One-side FFT One-side FFT of a frame of audio signals fft04.m
Example: FFT for Data Compression Use partial coefficients to reconstruct the original signals fftApproximate01.m High-frequency components are not so important
Example: FFT for Data Compression Use low-freq components to reconstruct a frame fftApproximate01.m
Example: FFT for Periodic Signals Quiz! FFT on periodic signals fftRepeat01.m Useful for pitch tracking Interpretation of harmonics from viewpoints of Approximation by basis functions Integration for obtaining the coefficients
Why Harmonic Structures?
Example: Zero-padding for FFT Purpose N’=N+a=2^n, easier for FFT computation Interpolation to have better resolution Example fftZeroPadding01.m Quiz!
Example: Down-sampling High-frequency components are missing fftResample01.m
Harmonics Why do we have harmonic structures in a power spectrum? Since the original frame is quasi-periodic… If we want to use the spectrum for pitch tracking, we need to enhance the harmonics. How?
How to Enhance Harmonics? Goal Enhance harmonics for pitch tracking Approach Take an integer number of fundamental periods Hard! Use windowing Use zero-padding for better resolution
Example: Harmonics Enhancement (1) fftHarmonics01.m
Example: Harmonics Enhancement (2) fftHarmonics02.m
Example: Harmonics Enhancement (3) fftHarmonics03.m