ELEN E 4810 Digital Signal Processing Topic 3

  • Slides: 59
Download presentation
ELEN E 4810: Digital Signal Processing Topic 3: Fourier domain 1. 2. 3. 4.

ELEN E 4810: Digital Signal Processing Topic 3: Fourier domain 1. 2. 3. 4. The Fourier domain Discrete-Time Fourier Transform (DTFT) Discrete Fourier Transform (DFT) Convolution with the DFT Dan Ellis 2003 -09 -16 1

1. The Fourier Transform n n Basic observation (continuous time): A periodic signal can

1. The Fourier Transform n n Basic observation (continuous time): A periodic signal can be decomposed into sinusoids at integer multiples of the fundamental frequency i. e. if we can approach with Harmonics of the fundamental Dan Ellis 2003 -09 -16 2

Fourier Series n For a square wave, i. e. Dan Ellis 2003 -09 -16

Fourier Series n For a square wave, i. e. Dan Ellis 2003 -09 -16 3

Fourier domain n x is equivalently described by its Fourier Series parameters: ak 1.

Fourier domain n x is equivalently described by its Fourier Series parameters: ak 1. 0 fk k 1 2 3 4 5 6 7 k π Negative ak is equivalent to phase of p n 1 2 3 4 5 6 7 Complex form: Dan Ellis 2003 -09 -16 4

Fourier analysis n How to find {|ck|}, {arg[ck]}? Inner product with complex sinusoids: Dan

Fourier analysis n How to find {|ck|}, {arg[ck]}? Inner product with complex sinusoids: Dan Ellis 2003 -09 -16 5

Fourier analysis Works Dan Ellis n if k 1, k 2 are positive integers,

Fourier analysis Works Dan Ellis n if k 1, k 2 are positive integers, 2003 -09 -16 6

sinc ∆ n n = 1 when x = 0 when x = r·p,

sinc ∆ n n = 1 when x = 0 when x = r·p, r ≠ 0, r = ± 1, ± 2, ± 3, . . . Dan Ellis 2003 -09 -16 7

Fourier Analysis n Thus, because real & imag sinusoids in pick out corresponding sinusoidal

Fourier Analysis n Thus, because real & imag sinusoids in pick out corresponding sinusoidal components linearly combined in Dan Ellis 2003 -09 -16 8

Fourier Transform n Fourier series for periodic signals extends naturally to Fourier Transform for

Fourier Transform n Fourier series for periodic signals extends naturally to Fourier Transform for any (CT) signal (not just periodic): Fourier Transform (FT) Inverse Fourier Transform (IFT) n Discrete index k continuous freq. W Dan Ellis 2003 -09 -16 9

Fourier Transform n Mapping between two continuous functions: 2π ambiguity Dan Ellis 2003 -09

Fourier Transform n Mapping between two continuous functions: 2π ambiguity Dan Ellis 2003 -09 -16 10

Fourier Transform of a sine n Assume Now, since. . . we know. .

Fourier Transform of a sine n Assume Now, since. . . we know. . . where d(x) is the Dirac delta function d(x-x 0) (continuous time) i. e. x 0 n Dan Ellis 2003 -09 -16 11 f(x) x

Fourier Transforms Fourier Series (FS) Fourier Transform (FT) Discrete-Time FT (DTFT) Discrete FT (DFT)

Fourier Transforms Fourier Series (FS) Fourier Transform (FT) Discrete-Time FT (DTFT) Discrete FT (DFT) Dan Ellis Time Frequency Continuous Discrete periodic ~x(t) infinite ck Continuous infinite x(t) infinite X(W) Discrete Continuous infinite x[n] periodic X(ejw) Discrete finite/pdc ~x[n] finite/pdc X[k] 2003 -09 -16 12

2. Discrete Time FT (DTFT) n FT defined for discrete sequences: DTFT n n

2. Discrete Time FT (DTFT) n FT defined for discrete sequences: DTFT n n n Summation (not integral) Discrete (normalized) frequency variable w Argument is ejw, not plain w Dan Ellis 2003 -09 -16 13

DTFT example n e. g. x[n] = an·m[n], |a| < 1 -1 1 2

DTFT example n e. g. x[n] = an·m[n], |a| < 1 -1 1 2 3 4 5 6 7 Dan Ellis 2003 -09 -16 14 n

Periodicity of X(ejw) n X(ejw) has periodicity 2 p in w : n Phase

Periodicity of X(ejw) n X(ejw) has periodicity 2 p in w : n Phase ambiguity of ejw makes it implicit Dan Ellis 2003 -09 -16 15

Inverse DTFT (IDTFT) n Same basic form as other IFTs: IDTFT n n Note:

Inverse DTFT (IDTFT) n Same basic form as other IFTs: IDTFT n n Note: continuous, periodic X(ejw) discrete, infinite x[n]. . . IDTFT is actually forward Fourier Series (except for sign of w) Dan Ellis 2003 -09 -16 16

IDTFT n Verify by substituting in DTFT: = 0 unless n=l Dan Ellis 2003

IDTFT n Verify by substituting in DTFT: = 0 unless n=l Dan Ellis 2003 -09 -16 17

sinc again Same as cos Dan Ellis n imag jsin part cancels 2003 -09

sinc again Same as cos Dan Ellis n imag jsin part cancels 2003 -09 -16 18

DTFTs of simple sequences n x[n] = d[n] (for all w) n i. e.

DTFTs of simple sequences n x[n] = d[n] (for all w) n i. e. X(ejw) x[n] d[n] X(ejw) x[n] -3 -2 -1 Dan Ellis 1 1 2 3 n -p 2003 -09 -16 p w 19

DTFTs of simple sequences IDTFT : n over -p < w < p but

DTFTs of simple sequences IDTFT : n over -p < w < p but X(ejw) must be periodic in w n If w 0 = 0 then x[n] = 1 n so Dan Ellis 2003 -09 -16 20

DTFTs of simple sequences n From before: ( |a| < 1) n m[n] tricky

DTFTs of simple sequences n From before: ( |a| < 1) n m[n] tricky - not finite DTFT of 1/2 Dan Ellis 2003 -09 -16 21

DTFT properties n Linear: n Time shift: n Frequency shift: Dan Ellis 2003 -09

DTFT properties n Linear: n Time shift: n Frequency shift: Dan Ellis 2003 -09 -16 ‘delay’ in frequency 22

DTFT example n x[n] = d[n] + anm[n-1] ? = d[n] + a(an-1 m[n-1])

DTFT example n x[n] = d[n] + anm[n-1] ? = d[n] + a(an-1 m[n-1]) x[n] = anm[n] Dan Ellis 2003 -09 -16 23

DTFT symmetry If x[n] x[-n] x*[n] Re{x[n]} n X(ejw) then. . . X(e-jw) from

DTFT symmetry If x[n] x[-n] x*[n] Re{x[n]} n X(ejw) then. . . X(e-jw) from summation -jw)* = ejw (e X*(e-jw) XCS(ejw) conjugate symmetry cancels Im parts on IDTFT j. Im{x[n]} XCA(ejw) xcs[n] Re{X(ejw)} xca[n] j. Im{X(ejw)} Dan Ellis 2003 -09 -16 24

DTFT of real x[n] n When x[n] is pure real, X(ejw) = X*(e-jw) xcs[n]

DTFT of real x[n] n When x[n] is pure real, X(ejw) = X*(e-jw) xcs[n] xev[n] = xev[-n] XR(ejw) = XR(e-jw) xca[n] xod[n] = -xod[-n] XI(ejw) = -XI(e-jw) x[n] real, even X(ejw) even, real Dan Ellis 2003 -09 -16 25

DTFT and convolution n Convolution: Convolution becomes multiplication Dan Ellis 2003 -09 -16 26

DTFT and convolution n Convolution: Convolution becomes multiplication Dan Ellis 2003 -09 -16 26

DTFT modulation n Modulation: Could solve if g[n] was just sinusoids. . . Dual

DTFT modulation n Modulation: Could solve if g[n] was just sinusoids. . . Dual of convolution in time Dan Ellis 2003 -09 -16 27

Parseval’s relation n n “Energy” in time and frequency domains are equal: If g

Parseval’s relation n n “Energy” in time and frequency domains are equal: If g = h, then g·g* = |g|2 = energy. . . Dan Ellis 2003 -09 -16 28

Energy density spectrum n Energy of sequence n By Parseval n Define Energy Density

Energy density spectrum n Energy of sequence n By Parseval n Define Energy Density Spectrum (EDS) Dan Ellis 2003 -09 -16 29

EDS and autocorrelation n Autocorrelation of g[n]: n If g[n] is real, G(e-jw) =

EDS and autocorrelation n Autocorrelation of g[n]: n If g[n] is real, G(e-jw) = G*(ejw), so no phase info. n Mag-sq of spectrum is DTFT of autoco Dan Ellis 2003 -09 -16 30

Convolution with DTFT n Since we can calculate a convolution by: n n n

Convolution with DTFT n Since we can calculate a convolution by: n n n g[n] finding DTFTs of g, h G, H multiply them: G·H IDTFT of product is result, DTFT IDTFT h[n] Dan Ellis y[n] DTFT 2003 -09 -16 31

DTFT convolution example n n n x[n] = an·m[n] h[n] = d[n] - ad[n-1]

DTFT convolution example n n n x[n] = an·m[n] h[n] = d[n] - ad[n-1] y[n] = x[n] * h[n] y[n] = d[n] i. e. . Dan Ellis 2003 -09 -16 32

3. Discrete FT (DFT) n n n Discrete finite/pdc x[n] finite/pdc X[k] A finite

3. Discrete FT (DFT) n n n Discrete finite/pdc x[n] finite/pdc X[k] A finite or periodic sequence has only N unique values, x[n] for 0 ≤ n < N Spectrum is completely defined by N distinct frequency samples Divide 0. . 2 p into N equal steps, {wk} = 2 pk/N Dan Ellis 2003 -09 -16 33

DFT and IDFT n Uniform sampling of DTFT spectrum: n DFT: where Dan Ellis

DFT and IDFT n Uniform sampling of DTFT spectrum: n DFT: where Dan Ellis i. e. 1/Nth of a revolution 2003 -09 -16 34

IDFT n n Inverse DFT IDFT Check: Sum of complete set of rotated vectors

IDFT n n Inverse DFT IDFT Check: Sum of complete set of rotated vectors = 0 if l ≠ n; = N if l = n im WN 2 WN Dan Ellis 2003 -09 -16 re 35

DFT examples n Finite impulse n Periodic sinusoid: (r I) Dan Ellis 2003 -09

DFT examples n Finite impulse n Periodic sinusoid: (r I) Dan Ellis 2003 -09 -16 36

DFT: Matrix form as a matrix multiply: n n i. e. Dan Ellis 2003

DFT: Matrix form as a matrix multiply: n n i. e. Dan Ellis 2003 -09 -16 37

Matrix IDFT n n If then i. e. inverse DFT is also just a

Matrix IDFT n n If then i. e. inverse DFT is also just a matrix, = 1/ N D N * Dan Ellis 2003 -09 -16 38

DFT and DTFT • continuous freq w • infinite x[n], - <n< DTFT •

DFT and DTFT • continuous freq w • infinite x[n], - <n< DTFT • discrete freq k=Nw/2 p • finite x[n], 0≤n<N DFT n DFT ‘samples’ DTFT at discrete freqs: X[k] k=1. . . Dan Ellis 2003 -09 -16 X(ejw) w 39

DFT and MATLAB n n MATLAB is concerned with sequences not continuous functions like

DFT and MATLAB n n MATLAB is concerned with sequences not continuous functions like X(ejw) Instead, we use the DFT to sample X(ejw) on an (arbitrarily-fine) grid: n n X = freqz(x, 1, w); samples the DTFT of sequence x at angular frequencies in w X = fft(x); calculates the N-point DFT of an N-point sequence x M Dan Ellis 2003 -09 -16 40

DTFT from DFT n N-point DFT completely specifies the continuous DTFT of the finite

DTFT from DFT n N-point DFT completely specifies the continuous DTFT of the finite sequence “periodic sinc” interpolation Dan Ellis 2003 -09 -16 41

Periodic sinc n = N when Dwk = 0; = (-)N when Dwk/2 =

Periodic sinc n = N when Dwk = 0; = (-)N when Dwk/2 = p = 0 when Dwk/2 = r·p/N, r = ± 1, ± 2, . . . other values in-between. . . Dan Ellis 2003 -09 -16 42

Periodic sinc interpolation X[k] X(ejw) Dan Ellis 2003 -09 -16 43

Periodic sinc interpolation X[k] X(ejw) Dan Ellis 2003 -09 -16 43

DFT from overlength DTFT n If x[n] has more than N points, can still

DFT from overlength DTFT n If x[n] has more than N points, can still form n IDFT of X[k] will give N point n How does Dan Ellis relate to x[n] ? 2003 -09 -16 44

DFT from overlength DTFT x[n] DTFT -A ≤ n < B sample j w

DFT from overlength DTFT x[n] DTFT -A ≤ n < B sample j w X(e ) X[k] IDFT 0≤n<N =1 for n-l = r. N, r I = 0 otherwise all values shifted by exact multiples of N pts to lie in 0 ≤ n < N Dan Ellis 2003 -09 -16 45

DFT from DTFT example n n If x[n] = { 8, 5, 4, 3,

DFT from DTFT example n n If x[n] = { 8, 5, 4, 3, 2, 2, 1, 1} (8 point) We form X[k] for k = 0, 1, 2, 3 by sampling X(ejw) at w = 0, p/2, p, 3 p/2 IDFT of X[k] gives 4 pt Overlap only for r = -1: Dan Ellis 2003 -09 -16 (N = 4) 46

DFT from DTFT example n x[n] -1 n x[n+N] (r = -1) -5 -4

DFT from DTFT example n x[n] -1 n x[n+N] (r = -1) -5 -4 -3 -2 -1 1 2 3 4 5 6 7 8 n n 1 2 3 4 5 n 1 2 3 n n is the time aliased or ‘folded down’ version of x[n]. Dan Ellis 2003 -09 -16 47

Properties: Circular time shift n n n DFT properties mirror DTFT, with twists: Time

Properties: Circular time shift n n n DFT properties mirror DTFT, with twists: Time shift must stay within N-pt ‘window’ Modulo-N indexing keeps index between 0 and N-1: 0 ≤ n 0 < N Dan Ellis 2003 -09 -16 48

Circular time shift n Points shifted out to the right don’t disappear – they

Circular time shift n Points shifted out to the right don’t disappear – they come in from the left g[n] ‘delay’ by 2 n 5 -pt sequence 1 2 3 4 n g[<n-2>5] 1 2 3 4 n Like a ‘barrel shifter’: Dan Ellis 2003 -09 -16 49

Circular time reversal n Time reversal is tricky in ‘modulo-N’ indexing - not reversing

Circular time reversal n Time reversal is tricky in ‘modulo-N’ indexing - not reversing the sequence: 5 -pt sequence made periodic -7 -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 7 8 9 10 11 n Time-reversed periodic sequence n Zero point stays fixed; remainder flips Dan Ellis 2003 -09 -16 50

4. Convolution with the DFT n n n IDTFT of product of DTFTs of

4. Convolution with the DFT n n n IDTFT of product of DTFTs of two N-pt sequences is their 2 N-1 pt convolution IDFT of the product of two N-pt DFTs can only give N points! Equivalent of 2 N-1 pt result time aliased: n n n i. e. must be, because G[k]H[k] are exact samples of G(ejw)H(ejw) This is known as circular convolution Dan Ellis 2003 -09 -16 51

Circular convolution n Can also do entire convolution with modulo-N indexing Hence, Circular Convolution:

Circular convolution n Can also do entire convolution with modulo-N indexing Hence, Circular Convolution: n Written as n Dan Ellis N 2003 -09 -16 52

Circular convolution example n 4 pt sequences: g[n]={1 2 0 1} h[n]={2 2 1

Circular convolution example n 4 pt sequences: g[n]={1 2 0 1} h[n]={2 2 1 0} 1 2 3 h[<n - 0>4] h[<n - 1>4] h[<n - 2>4] h[<n - 3>4] Dan Ellis 1 2 3 n 1 1 2 3 n 2 1 2 3 n 0 1 2 3 n 1 2003 -09 -16 n 1 2 3 n g[n] 4 h[n]={4 7 5 4} 1 2 3 n check: g[n] * h[n] ={2 6 5 4 2 1 0} 53

Duality n DFT and IDFT are very similar n n both map an N-pt

Duality n DFT and IDFT are very similar n n both map an N-pt vector to an N-pt vector Duality: Circular time reversal if then n i. e. if you treat DFT sequence as a time sequence, result is almost symmetric Dan Ellis 2003 -09 -16 54

DFT properties summary n Circular convolution n Modulation n Duality n Parseval Dan Ellis

DFT properties summary n Circular convolution n Modulation n Duality n Parseval Dan Ellis 2003 -09 -16 55

Linear convolution w/ the DFT n n n DFT fast circular convolution. . but

Linear convolution w/ the DFT n n n DFT fast circular convolution. . but we need linear convolution Circular conv. is time-aliased linear conv. ; can aliasing be avoided? e. g. convolving L-pt g[n] with M-pt h[n]: y[n] = g[n] * h[n] has L+M-1 nonzero pts Set DFT size N ≥ L+M-1 no aliasing Dan Ellis 2003 -09 -16 56

Linear convolution w/ the DFT n Procedure (N = L + M - 1):

Linear convolution w/ the DFT n Procedure (N = L + M - 1): n pad L-pt g[n] with (at least) M-1 zeros N-pt DFT G[k], k = 0. . N-1 pad M-pt h[n] with (at least) L-1 zeros N-pt DFT H[k], k = 0. . N-1 Y[k] = G[k]·H[k], k = 0. . N-1 n IDFT{Y[k]} n n Dan Ellis 2003 -09 -16 g[n] h[n] L n n M yc[n] Nn 57

Overlap-Add convolution n n Very long g[n] break up into segments, convolve piecewise, overlap

Overlap-Add convolution n n Very long g[n] break up into segments, convolve piecewise, overlap bound size of DFT, processing delay Make * n * Called Overlap-Add (OLA) convolution. . . Dan Ellis 2003 -09 -16 58

Overlap-Add convolution h[n] g[n] n n h[n] * g 0[n] n g 1[n] n

Overlap-Add convolution h[n] g[n] n n h[n] * g 0[n] n g 1[n] n g 2[n] N Dan Ellis 2 N h[n] * g 1[n] 2003 -09 -16 n h[n] * g 2[n] n 3 N h[n] * g[n] n valid OLA sum N 2 N 3 N 59 n n