Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis 5. Fourier Transform and Spectrum Analysis 1 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Spectrum of Non-periodic Signals • Fourier series help us to find the spectrum of periodic signals • Most signals are not periodic • Speech, audio, etc. • Need another tool to find the spectrum of nonperiodic (aperiodic) signals ⇒ Fourier Transform 2 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Fourier Transform of Discretetime Signals • Let x(t) be an aperiodic continuous-time signal, x[n] is the samples of x(t) such that: x[n] = x(nTs) Radian frequency • The spectrum of x[n] is given by: X p (ω ) = 3 ∞ ∑ x[n]e n= −∞ − jωnTs or X p (ωˆ ) = ωˆ = ωTs ∞ ∑ x[n]e n= −∞ − jωˆ n Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Aperiodic Signals have Periodic Spectrum • It is interesting to note that Xp(ω) is periodic since X p (ωˆ + 2πk ) = = ∞ − j (ωˆ + 2πk ) n x [ n ] e ∑ n= −∞ ∞ ∑ x[n]e n= −∞ 4 1 − jωˆ n − j 2πnk e = X p (ωˆ ) Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis X p (ωˆ ) -2π 5 0 2π ωˆ = ωTs Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis • If x(t) has a spectrum of X(ω) and x[n] = x(nTs) has a spectrum of Xp(ω), it can be shown that 1 X p (ωˆ ) = Ts ∞ ∑ X (ωˆ + 2πk ) k = −∞ 1 X (ωˆ − 2π ) = K+ Ts 1 + X (ωˆ ) Ts 6 1 + X (ωˆ + 2π )+ K Ts −∞ ≤ω ≤ ∞ Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Time Domain Frequency Domain X(ω) 1 x(t) 0 t 7 Ideal low pass filter X p (ωˆ ) x[n]=x(nTs) 0 | |←Ts n ω -B 0 B -2π 0 2π ωˆ = ωTs Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Time Domain x(t) Frequency Domain X(ω) 1 t 0 -B 0 B X p (ωˆ ) x[n] 0 8 0 | |←Ts x[n] n |←Ts n | ω -2π 0 -2π 0 2π ωˆ = ωTs 2π ωˆ = ωTs X p (ωˆ ) Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Time Domain x(t) Frequency Domain X(ω) 1 0 t -B 0 B X p (ωˆ ) x[n] 0 | |←Ts n X’(ω) x’(t) 9 0 ω t -B 0 B ωˆ = ωTs ω Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis • If the signal has frequency components beyond |π|, after sampling, these frequency components will affect the other replicas in the spectrum • Even with an ideal low pass filter, the original signal cannot be reconstructed. This is the socalled alias effect • Restate the Shannon Sampling Theorem for general aperiodic signals ωˆ ≤ π ⇒ 2πf maxTs ≤ π 10 ⇒ 2πf max ≤ πf s or f s ≥ 2 f max Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Shannon Sampling Theorem A continuous-time aperiodic signal x(t) with frequencies no higher than fmax can be reconstructed exactly from its samples x[n] = x(nTs) if the samples are taken at a rate fs = 1/Ts that is greater than 2fmax Nyquist NyquistFrequency Frequency 11 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Real Examples Time Domain Frequency Domain Resulted signal Ideal low pass filter 12 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Time Domain Frequency Domain Resulted signal Ideal low pass filter 13 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Time Domain Frequency Domain Resulted signal Ideal low pass filter 14 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis How to Solve Aliasing Problems? 1. Increase the sampling rate such that fs ≥ 2fmax 2. Use anti-aliasing filter first Pre-filter Pre-filterthe theinput inputsignal signalsuch suchthat thatititwill willnever never has hasfrequency frequencycomponents componentsbeyond beyond|π| |π| Prefilter 15 A/D Digital Signal Processor D/A Postfilter Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Time Domain x(t) Frequency Domain X(ω) 1 t 0 -B 0 B X(ω) Anti-aliasing filter 0 16 | 1 X p (ωˆ ) x[n] |←Ts n ω -2π 0 2π ω ωˆ = ωTs Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis With anti-aliasing filter Without anti-aliasing filter X p (ωˆ ) X p (ωˆ ) Ideal low pass filter Ideal low pass filter X’(ω) ω 17 ωˆ = ωTs ωˆ = ωTs Look better X’(ω) ω Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Hear the effect! Original 44.1kHz sampling 18 8kHz sampling with aliasing 8kHz sampling with antialiasing filter Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Discrete Fourier Transform 19 • Spectrum of aperiodic discrete-time signals is periodic and continuous • Difficult to be handled by computer • Since the spectrum is periodic, there’s no point to keep all periods – one period is enough • Computer cannot handle continuous data, we can only keep some samples of the spectrum • Interesting enough, such requirements lead to a very simple way to find the spectrum of signals ⇒ Discrete Fourier Transform Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis • Recall the Fourier transform of an aperiodic discrete sequence X p (ωˆ ) = ∞ − jωˆ n x [ n ] e ∑ n= −∞ • Assume x[n] is an aperiodic sequence with N values, i.e. {x[n] : n = 0, 1, ..., N-1} X p (ωˆ ) = 20 N −1 − jωˆ n x [ n ] e ∑ n=0 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis • If we are now interested only in N equally spaced frequencies of 1 period of the Fourier spectrum, i.e. k .2π X [k ] = X p N k = 0,1, K N − 1 IfIfNN==13 13 X p (ωˆ ) k=4 k=0 -2π 21 0 2π/N 2π ωˆ = ω T s Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis • Now if we want to compute the value of these N frequencies, X [k ] = = k .2π − j N −1 Ts N x[n]e ∑ nTs W Nnk = e − j 2πnk / N n=0 N −1 N −1 n=0 n=0 − jk .2πn / N x [ n ] e = ∑ nk x [ n ] W ∑ N for k = 0,1,…, N-1 Discrete Fourier Transform 22 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis • Discrete Fourier Transform (DFT) is exactly the output of the Fourier Transform of an aperiodic sequence at some particular frequencies • Inherently periodic since X[k+N] = X[k], although we always only consider one period of X[k] 23 X [k ] = N −1 − j 2πnk / N x [ n ] e ∑ n=0 X [k + N ] = N −1 − j 2πn( k + N ) / N x [ n ] e ∑ n=0 = N −1 1 − j 2πnk / N − j 2πn x [ n ] e e = X [k ] ∑ n=0 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis • If we know X[k], we can reconstruct back the signal x[n] via the inverse discrete Fourier transform 1 x[n] = N 1 = N N −1 j 2πnk / N X [ k ] e ∑ n=0 N −1 − nk X [ k ] W ∑ N for n = 0,1,…, N-1 n=0 Inverse Discrete Fourier Transform 24 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis • It can be proven as follows: 1 N N −1 jk 2πn / N [ ] X k e ∑ k =0 1 = N 1 = N 0 N 25 if n ≠ m otherwise N −1 N −1 ∑ − jk 2πm / N jk 2πn / N [ ] x m e e ∑ ∑ jk .2π ( n − m ) / N [ ] x m e ∑ k =0 m =0 N −1 N −1 k =0 m =0 N −1 jk .2π ( n− m ) / N ∑ x[m ] ∑ e m =0 k =0 = x[n] for n = 0,1,..., N − 1 1 = N N −1 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis • Although DFT gives exact frequency response of a signal, sometimes it may not give the desired spectrum • Example Fourier Transform One period of X p (ωˆ ) x[n] n 0 9 NN==10 10 26 DFT 10 X[k] if N = 10 So different from X p (ωˆ ) k Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis • Need improved resolution • Achieve by padding zero to the end of x[n] to make N bigger x[n] Pad Pad40 40zeros zeros n 0 9 50 x[n] = {1 1 1 1 1 1 1 1 1 1 0 0 0 0 … 0} 40 zeros 27 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis N N == 50 50 28 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis N N == 100 100 29 Signal Processing Fundamentals – Part I Spectrum Analysis and Filtering 5. Fourier Transform and Spectrum Analysis Exercise Given that x[n] is defined in the following figure, determine its spectrum using DFT with N = 4 2 1 0 30 x[n] 2 1 3 n