Digital Signal Processing Week 1: Introduction 1. 2. 3. 4. Course overview Digital Signal Processing Basic operations & block diagrams Classes of sequences Based on: http://www.ee.columbia.edu/~dpwe/e4810/ By: Dan Ellis Saeid Rahati 1 1. Course overview Grading structure Homeworks (and small project): 10% Midterm: 20% Presentation (Max. 20 minutes): 10% One paper related to course topics Final exam: 30% One session One session Project: 30% Saeid Rahati 2 1. Course overview Course project Goal: hands-on experience with DSP Practical implementation Work in pairs or alone Brief report, optional presentation Recommend MATLAB Ideas on DSP_Pack CD or past class or internet Saeid Rahati 3 MATLAB Interactive system for numerical computation Extensive signal processing library Focus on algorithm, not implementation Saeid Rahati 4 2. Digital Signal Processing Signals: Information-bearing function E.g. sound: air pressure variation at a point as a function of time p(t) Dimensionality: Sound: 1-Dimension Grayscale image i(x,y) : 2-D Video: 3 x 3-D: {r(x,y,t) g(x,y,t) b(x,y,t)} Saeid Rahati 5 Example signals Noise - all domains Spread-spectrum phone - radio ECG - biological Music Image/video - compression …. Saeid Rahati 6 Signal processing Modify a signal to extract/enhance/ rearrange the information Origin in analog electronics e.g. radar Examples… Noise reduction Data compression Representation for recognition/classification… Saeid Rahati 7 Digital Signal Processing DSP = signal processing on a computer Two effects: discrete-time, discrete level Saeid Rahati 8 DSP vs. analog SP Conventional signal processing: p(t) p(t) Processor q(t) Digital SP system: A/D Saeid Rahati p[n] Processor q[n] D/A q(t) 9 Digital vs. analog Pros Noise performance - quantized signal Use a general computer - flexibility, upgrade Stability/duplicability Novelty Cons Limitations of A/D & D/A Baseline complexity / power consumption Saeid Rahati 10 DSP example Speech time-scale modification: extend duration without altering pitch M Saeid Rahati 11 3. Operations on signals Discrete time signal often obtained by sampling a continuous-time signal Sequence {x[n]} = xa(nT), n=…-1,0,1,2… T= sampling period; 1/T= sampling frequency Saeid Rahati 12 Sequences Can write a sequence by listing values: {x[n]} {, 0.2, 2.2,1.1, 0.2, 3.7, 2.9,} Arrow indicates where n=0 Thus, x[ 1] 0.2, x[0] 2.2, x[1] 1.1, Saeid Rahati 13 Left- and right-sided x[n] may be defined only for certain n: N1 ≤ n ≤ N2: Finite length (length = …) N1 ≤ n: Right-sided (Causal if N1 ≥ 0) n ≤ N2: Left-sided (Anticausal) Can always extend with zero-padding Left-sided Saeid Rahati Right-sided 14 3. Basic Operations on sequences Addition operation: x[n] Adder y[n] y[n] x[n] w[n] w[n] Multiplication operation A Multiplier x[n] Saeid Rahati y[n] y[n] A x[n] 15 More operations Product (modulation) operation: y[n] x[n] Modulator w[n] y[n] x[n] w[n] E.g. Windowing: multiplying an infinitelength sequence by a finite-length window sequence to extract a region Saeid Rahati 16 Time shifting Time-shifting operation: y[n] x[n N ] where N is an integer If N > 0, it is delaying operation Unit delay x[n] z 1 y[n] y[n] x[n 1] If N < 0, it is an advance operation Unit advance x[n] Saeid Rahati z y[n] y[n] x[n 1] 17 Combination of basic operations Example 1 x[n] 2 x[n 1] y[n] 3 x[n 2] 4 x[n 3] Saeid Rahati 18 Up- and down-sampling Certain operations change the effective sampling rate of sequences by adding or removing samples Up-sampling = adding more samples = interpolation Down-sampling = discarding samples = decimation Saeid Rahati 19 Down-sampling In down-sampling by an integer factor M > 1, every M-th samples of the input sequence are kept and M - 1 in-between samples are removed: xd [n] x[nM ] x[n] M xd [n] Saeid Rahati 20 Down-sampling An example of down-sampling Input Sequence 1 0.5 Amplitude Amplitude 0.5 0 -0.5 -1 Output sequence down-sampled by 3 1 0 -0.5 0 10 20 30 Time index n x[n] Saeid Rahati 40 -1 50 3 0 10 20 30 Time index n 40 y[n] x[3n] 21 50 Up-sampling Up-sampling is the converse of downsampling: L-1 zero values are inserted between each pair of original values. x[n / L], n 0, L, 2 L, xu [n] otherwise 0, x[n] Saeid Rahati L xu [n] 22 Up-sampling An example of up-sampling Input Sequence 1 0.5 Amplitude Amplitude 0.5 0 0 -0.5 -0.5 -1 Output sequence up-sampled by 3 1 0 10 20 30 Time index n x[n] 40 -1 50 0 10 20 30 Time index n 40 50 xu [n] 3 not inverse of downsampling! Saeid Rahati 23 Complex numbers .. a mathematical convenience that lead to simple expressions A second “imaginary” dimension (j√-1) is added to all values. Rectangular form: x = xre + j·xim where magnitude |x| = √(xre2 + xim2) and phase q = tan-1(xim/xre) Polar form: x = |x| ejq = |x|cosq + j· |x|sinq jq ( e cos q j sin q ) Saeid Rahati 24 Complex math When adding, real and imaginary parts add: (a+jb) + (c+jd) = (a+c) + j(b+d) When multiplying, magnitudes multiply and phases add: rejq·sejf = rsej(q+f) Phases modulo 2 Saeid Rahati 25 Complex conjugate Flips imaginary part / negates phase: conjugate x* = xre – j·xim = |x| ej(–q) Useful in resolving to real quantities: x + x* = xre + j·xim + xre – j·xim = 2xre x·x* = |x| ej(q) |x| ej(–q) = |x|2 Saeid Rahati 26 4. Classes of sequences Useful to define broad categories… Finite/infinite (extent in n) Real/complex: x[n] = xre[n] + j·xim[n] Saeid Rahati 27 Classification by symmetry Conjugate symmetric sequence: xcs[n] = xcs*[-n] = xre[-n] – j·xim[-n] Conjugate antisymmetric: xca[n] = –xca*[-n] = –xre[-n] + j·xim[-n] Saeid Rahati 28 Conjugate symmetric decomposition Any sequence can be expressed as conjugate symmetric (CS) / antisymmetric (CA) parts: x[n] = xcs[n] + xca[n] where: xcs[n] = 1/2(x[n] + x*[-n]) = xcs *[-n] xca[n] = 1/2(x[n] – x*[-n]) = -xca *[-n] When signals are real, CS Even (xre[n] = xre[-n]), CA Odd Saeid Rahati 29 Basic sequences 1, n 0 d [ n] 0, n 0 Unit sample sequence: Shift in time: d[n - k] Can express any sequence with d: {0,1,2..}0d[n] + 1d[n-1] + 2d[n-2].. Saeid Rahati 30 More basic sequences Unit step sequence: Relate to unit sample: d[n] [n] [n 1] 1, n 0 [ n] 0, n 0 [n] k d[k] n Saeid Rahati 31 Exponential sequences Exponential sequences= eigenfunctions General form: x[n] = A·n If A and are real: = 0.9 = 1.2 20 50 15 Amplitude Amplitude 40 30 20 5 10 0 10 0 5 10 15 20 Time index n || > 1 Saeid Rahati 25 30 0 0 5 10 15 20 Time index n 25 || < 1 32 30 Complex exponentials x[n] = A·n Constants A, can be complex : A = |A|ejf ; = e(s + jw) x[n] = |A| esn ej(wn + f) scale varying magnitud e Saeid Rahati varying phase 33 Complex exponentials Complex exponential sequence can ‘project down’ onto real & imaginary axes to give sinusoidal sequences q 1 e x[n] exp( 12 j 6 )n Imaginary part cos q j sin q j Real part 1 xre[n] 0.5 Amplitude 0.5 Amplitude 1 0 -0.5 -1 xim[n] 0 -0.5 0 10 20 Time index n 30 40 -1 0 10 20 Time index n n/12 xre[n] = en/12cos(n/6) xim[n] = e Saeid Rahati 30 sin(n/6)M 34 40 Periodic sequences x [n] satisfying ~ A sequence ~ x [ n] ~ x [n kN ], is called a periodic sequence with a period N where N is a positive integer and k is any integer. x [ n] ~ x [n kN ] Smallest value of N satisfying ~ is called the fundamental period Saeid Rahati 35 Periodic exponentials Sinusoidal sequence A cos(wo n f ) and complex exponential sequence B exp( jwo n) are periodic sequences of period N only if w o N 2 r with N & r positive integers Smallest value of N satisfying wo N 2 r is the fundamental period of the sequence r = 1 one sinusoid cycle per N samples r > 1 r cycles per N samples M Saeid Rahati 36 Symmetry of periodic sequences An N-point finite-length sequence xf[n] defines a periodic sequence: “n modulo N” x[n] = xf[<n>N] Symmetry of xf [n] is not defined because xf [n] is undefined for n < 0 Define Periodic Conjugate Symmetric: xpcs [n] = 1/2(x[n] + x*[<-n >N]) = 1/2(x[n] + x*[N – n]) 0 ≤ n < N Saeid Rahati 37 Sampling sinusoids Sampling a sinusoid is ambiguous: x1 [n] = sin(w0n) x2 [n] = sin((w0+2)n) = sin(w0n) = x1 [n] Saeid Rahati 38 Aliasing E.g. for cos(wn), w = 2r ± w0 all r appear the same after sampling We say that a larger w appears aliased to a lower frequency Principal value for discrete-time frequency: 0 ≤ w0 ≤ i.e. less than one-half cycle per sample Saeid Rahati 39