Use of Frequency Domain Frequency Response Telecommunication Channel |A| fc f Signal frequencies > fc are attenuated and distorted |A| IAN’S “A” SPEECH ANALYSIS RECOGNITION IDENTIFICATION JOHN’S “A” f Spectrum analyzers convert a time-domain signal into frequency domain LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-1 Fourier Series Original Signal xp(t) First 4 Terms of Fourier Series Sum of First 4 Terms of Fourier Series and xp(t) Original xp(t) Tp First 4 Terms of Fourier Series Periodic signal expressed as infinite sum of sinusoids. xp (t ) ck 1 Tp c e k jk 0 t k , w here x p ( t )e jk 0 t dt Tp Ck’s are frequency domain amplitude and phase representation For the given value xp(t) (a square value), the sum of the first four terms of trigonometric Fourier series are: xp(t) 1.0 + sin(t) + sin(3t) + sin(5t) LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-2 Fourier Transform x(t) = Ckej(k k=- Tp/2 0 t) WHERE Ck = 1 Tp x(t) e-j(k0t) dt -Tp/2 Increase TP = Period Increases TP No Repetition 1 Tp x(t) e-j t dt d / 2p FT PAIR C() normalize d 2p C() Discrete coefficients Ck become continuous d C() = 2p 2p k 0 Discrete frequency variable becomes continuous = = X() = x(t) e -jt dt INVERSE LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-3 x(t) = 1 2p X() e jt d Discrete Time Fourier Transform Fourier Transform x() x(t )e jt Discrete Time Fourier Transform x() dt x(n)e jn n Replace t with Tsn Continuous x(t) becomes discrete x(n) Sum rather than integrate all discrete samples Inverse Fourier Transform Inverse Discrete Time Fourier Transform p 1 j( n ) x(n) x ( ) e d 2p p 1 jt x( t ) x ( ) e d 2p Limits of integration need not go beyond ±p because the spectrum repeats itself outside ±p (every 2p) Keep integration because X() is continuous LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-4 Discrete Fourier Transformation Recall DTFT Pair: X() x (n) e x(n) jn n 1 2p X () e jn d 2p There are an infinite number of time domain samples is continuous To Make DTFT Practical: Take only N time domain samples Sample the frequency domain, i.e. only evaluate x() at N discrete points. The equal spacing between points is = 2p/N The result is the Discrete Fourier Transform (DFT) pair: N1 XN (k ) x(n)W n 0 kn N and w here WN e LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 1 N1 x(n) XN (k )WNkn N k 0 j 2p N Tw iddle Factor 4-5 DFT Relationships Time Domain Frequency Domain |x(k)| N Samples N Samples 0 Ts 0 1 2Ts 3Ts (N-1)Ts 2 3 N-1 LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved X(n) t 0 1 2 N/2 n 0 Fs N 2Fs N Fs 2 4-6 N-2 N-1 k 2Fs N f Fs N Practical Considerations N1 Standard DFT XN (k ) Xn (k )WNkn ,0 k N 1 n 0 An example of an 8 point DFT 7 Xn (k ) Xn (k )W 7kn , k 0,1,2,...,7 n 0 Writing this out for each value of n Xn (k) x(0)W7k 0 x(1)W7k1 ....... x(7)W7k7,k 0,1,...,7 Each term such as x(0)W7k 0 requires 8 multiplications Total number of multiplications required: 8 * 8 = 64 Do not forget that each multiplication is complex 8-point DFT requires 8 2 = 64 multiplications 1000-point DFT requres 10002 = 1 million multiplications And all of these need to be summed LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-7 Fast Fourier Transformation Symmetry Property WNk N / 2 WNk Periodicity Property WNk N WNk Splitting the DFT in two or Manipulating the twiddle factor N 1 2 N 1 2 r 0 r 0 XN (k ) x(2r ).WN2rk x(2r 1).WN( 2r 1)k N 1 2 N 1 2 r 0 r 0 XN (k ) x(2r ).(WN2 )rk WNk x(2r 1).(WN2 )rk W e 2 N j( 2p 2) N e j( 2p ) N/ 2 WN / 2 THE FAST FOURIER TRANSFORM N 1 2 N 1 2 r 0 r 0 Xn (k ) x(2r )WNrk 2 WNk x(2r 1)WNrk 2 LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-8 Time Savings N 1 2 N 1 2 r 0 r 0 xN (k) x(2r )WNrk/ 2 WNk x(2r 1)WNrk/ 2 (N/2) 2 Multiplications (N/2) 2 Multiplications N/2 Multiplications For an 8-point FFT, 42 + 42 + 4 = 36 multiplications, saving 64 - 36 = 28 multiplications For 1000 point FFT, 5002 + 5002 + 500 = 50,500 multiplications, saving 1,000,000 - 50,500 = 945,000 multiplications Time savings assume 50ns cycle time 8-point FFT saves 1.2 ms 1000-point FFT saves 47.25ms LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-9 Decimation in Time Splitting the original series into two is called decimation in time Let us take a short series where N = 8 Decimate once Called Radix-2 since we divided by 2 n = {0, 1, 2, 3, 4, 5, 6, 7} n = { 0, 2, 4, 6 } and { 1, 3, 5, 7 } Decimate again n = { 0, 4 } { 2, 6 } { 1, 5 } and { 3, 7 } The result is a savings of N2 – (N/2)log2N multiplications 1024 point DFT = 1,048,576 multiplications 1024 point FFT = 5120 multiplication Decimation simplifies mathematics but there are more twiddle factors to calculate A practical FFT incorporates these extra factors into the algorithm LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-10 4-Point FFT 3 Let us consider an example where N=4: X4(k) = kn x(n) W4 0 1 Decimate in time into 2 series: X4(k) = n = {0 , 2} and {1, 3} r=0 rk k x(2r) W2 + W4 1 r=0 rk x(2r+1) W2 k k k = [ x(0) + x(2) W2 ] + W4 [ x(1) + x(3) W2 ] REMEMBER: We have two twiddle factors. Can we relate them? k W2 Now our FFT becomes: LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved k WN = e -j 2p k N -j 2p * k 2k -j 2p * 2k =e 2 =e 4 = W4 2k k 2k = [ x(0) + x(2) W4 ] + W4 [ x(1) + x(3) W4 ] 4-11 Flow Diagram Two DFTs: 2k k 2k X4(k) = [ x(0) + x(2) W4 ] + W4 [ x(1) + x(3) W4 ], k=0,1,2,3 Write out values for k=0 only: 0 0 0 X4(0) = [ x(0) + x(2) W4 ] + W4 [ x(1) + x(3) W4 ] Represent with a flow diagram: X4(0) x(0) 0 x02 0 0 0 = W4 x(2) x(1) 0 x13 x(3) This is only one quarter of the flow diagram LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-12 Full Flow Diagram Write out all values for k: 0 0 0 = [ x(0) + x(2) W4 ] + W4 [ x(1) + x(3) W4 ] 2 1 NOTICE 2 = [ x(0) + x(2) W4 ] + W4 [ x(1) + x(3) W4 ] 6 -j 2p * 6 W4 = e 2 3 2 = [ x(0) + x(2) W4 ] + W4 [ x(1) + x(3) W4 ] 4 4 0 = 1 = W4 2 = -1 = W4 X4(0) x(0) 0 0 2 1 x(1) X4(1) SPOT THE BUTTERFLY ? 2 X4(2) 3 X4(3) 0 x(3) -j 2p * 4 W4 = e 0 2 0 = [ x(0) + x(2) W4 ] + W4 [ x(1) + x(3) W4 ] x(2) 4 2 LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-13 The Butterfly Twiddle Conversions Typical Butterfly x1 X1 k X1 = x1 + WN x2 0 W4 = 1 1 W4 = -j x2 k WN X2 k X2 = x1 – WN x2 2 W4 = -1 3 W4 = j 4 Point FFT Butterfly a x0 4 Point FFT Equations X0 0 X0 = (x0 + x2) + W4 (x1+x3) 1 x2 0 W4 x1 X1 X2 b 1 W4 x3 X3 LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-14 X1 = (x0 – x2) + W4 (x1–x3) 0 X2 = (x0 + x2) – W4 (x1+x3) 1 X3 = (x0 – x2) – W4 (x1–x3) A Practical Example Frequency Domain Time Domain Amplitude Amplitude 2 2 1 1 0 0 1 2 3 Time (nTs) -5.0 2 NTs 2.5 5.0 1 2 Frequency kHz X0=x0+ x2 +x1+x3 = 1 + 0 + 0 + 1 = 2 SAMPLED AT 10kHz Ts= 100 uS F= 0 0 FFT Conversion xk = {1,0,0,1} 1 -2.5 3 X1=x0–x2 + -j(x1–x3) = 1–0 + -j(0–1) = 1 + j X2=(x0+ x2) – (x1+ x3) = (1 + 0) - (0 + 1) = 0 = Frequency Spacing X3=(x0–x2)– -j (x1–x3) = (1–0)– -j(0–1) = 1– j AMPLITUDE OF X1= 12+j2 = 2 LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-15 DSP and FFT Fast Fourier Transform is a generic name for reducing DFT computations. We considered Radix-2 here, but many other algorithms exist. The simplified butterflies can be implemented with a DSP very efficiently Special FFT chips implement it even faster But DSPs are programmable And they can perform other operations on the signal FFT requires address shuffling for faster data table access Most DSPs can perform shuffling in the background Modern DSPs can perform an FFT of 1024 samples in well under 5 ms LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-16 Summary Frequency domain information for a signal is important for processing Sinusoids can be represented by phasors Fourier series can be used to represent any periodic signal Fourier transforms are used to transform signals From time to frequency domain From frequency to time domain DFT allows transform operations on sampled signals DFT computations can be sped up by splitting the original series into two or more series FFT offers considerable savings in computation time DSPs can implement FFT efficiently LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-17 Sliding Windows Input signal sample buffer T Original windowed signal T T= 0 Figure 1 Figure 2 Subtract old New-old sample window Next windowed signal T T=N Figure 3 T= 0 Add new value T Figure 4 Window is time shifted by one sample LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-18 Example Frequency Bin New Sample x[0] Old Sample x[N-1] x K2 N Delay K2 = K1N - Note: K1=0.999 Further Frequency Bins + K1 x K1 x (X[k]*ej2pn/N) ej2pn/N X[k] LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-19 The Phasor Model COMPLEX PLANE Im = Imaginary Re = Real Im A b PHASOR = VECTOR ROTATING f Speed = rad per second Amplitude = A Re a 1. Rectangular Form x(t) = a + jb A= a2 + b2 x(t) = Ae j(t) where j = -1 where and 2. Polar Form f = t = tan -1 b a e j(t) = cos(t) + j sin(t) = 2pf p = 180 degrees LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved 4-20 Modeling Sinusoids REWRITE: e jt AS e LET AND j(f ) = cos(f ) + jsin(f ) f ( t + a) OR (nTs + a) cos f = AND e THEN - j(f ) = cos(f ) - jsin(f ) sin f = e j(f )- e - j(f ) 2j e j(f )+ e - j(f ) 2 Drawing the phasors for cos f Im R/2 b In general: x(t) = R cos(t + a ) f A a x(t) = R cos(t + a ) j(t + a ) - j(t + a ) R (e +e ) x(t) = 2 -b R/2 LECTURE 4 Copyright 1998, Texas Instruments Incorporated All Rights Reserved Or as a sum of two phasors: 4-21