What is DSP? Input Signal Digital Speech Processing— Lecture 2 Analog-toDigital Conversion Computer Output Signal Digital-toAnalog Conversion Digital • Method to represent a quantity, a phenomenon or an event • Why digital? Signal • What is a signal? Review of DSP Fundamentals – something (e.g., a sound, gesture, or object) that carries information – a detectable physical quantity (e.g., a voltage, current, or magnetic field strength) by which messages or information can be transmitted • What are we interested in, particularly when the signal is speech? Processing • What kind of processing do we need and encounter almost everyday? • Special effects? 1 Common Forms of Computing 2 Advantages of Digital Representations • Text processing – handling of text, tables, basic arithmetic and logic operations (i.e., calculator functions) – – – – Input Signal Word processing Language processing Spreadsheet processing Presentation processing • Signal Processing – a more general form of information processing, including handling of speech, audio, image, video, etc. – Filtering/spectral analysis – Analysis, recognition, synthesis and coding of real world signals – Detection and estimation of signals in the presence of noise or interference A-to-D Converter Signal Processor D-to-A Converter Output Signal • Permanence and robustness of signal representations; zerodistortion reproduction may be achievable • Advanced IC technology works well for digital systems • Virtually infinite flexibility with digital systems – Multi-functionality – Multi-input/multi-output • Indispensable in telecommunications which is virtually all digital at the present time 3 Digital Processing of Analog Signals xc(t) A-to-D x[n] Computer y[n] D-to-A yc(t) 4 Discrete-Time Signals A sequence of numbers Mathematical representation: x = {x[n ]}, − ∞ < n < ∞ Sampled from an analog signal, xa (t ), at time t = nT , • A-to-D conversion: bandwidth control, sampling and quantization • Computational processing: implemented on computers or ASICs with finite-precision arithmetic – basic numerical processing: add, subtract, multiply (scaling, amplification, attenuation), mute, … – algorithmic numerical processing: convolution or linear filtering, non-linear filtering (e.g., median filtering), difference equations, DFT, inverse filtering, MAX/MIN, … • D-to-A conversion: re-quantification* and filtering (or interpolation) for reconstruction x[n ] = xa (nT ), −∞ < n < ∞ T is called the sampling period, and its reciprocal, FS = 1/ T , is called the sampling frequency FS = 8000 Hz ↔ T = 1/ 8000 = 125 μ sec FS = 10000 Hz ↔ T = 1/10000 = 100 μ sec FS = 16000 Hz ↔ T = 1/16000 = 62.5 μ sec FS = 20000 Hz ↔ T = 1/ 20000 = 50 μ sec 5 6 1 Varying Sampling Rates Speech Waveform Display plot( ); Fs=8000 Hz Fs=6000 Hz stem( ); Fs=10000 Hz 7 8 Quantization Varying Sampling Rates x[ n] can be quantized to one of a finite set of values which is then represented digitally in bits, hence a truly digital signal; the course material mostly deals with discrete-time signals (discrete-value only when noted). Fs=8000 Hz out Fs=6000 Hz 7 2.4 6 1.8 5 1.2 4 0.6 3 Fs=10000 Hz • Transforming a continuouslyvalued input into a representation that assumes one out of a finite set of values 0.3 0.9 1.5 2.1 2 1 in • The finite set of output values is indexed; e.g., the value 1.8 has an index of 6, or (110)2 in binary representation • Storage or transmission uses binary representation; a quantization table is needed 0 9 Quantization: A 3-bit uniform quantizer Discrete Signals Sinewave Spectrum 6 sample 2 y quantize Sampled Sinusoid 5sin(2πnT) 4 0 6 4 -6 2 0 5 10 15 20 25 30 35 40 n y 0 -2 6 -4 4 -6 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0 -2 Quantized sinusoid round[5sin(2πx)] 2 0 Discrete sinusoid round[5sin(2πnT)] 4 -4 -4 -6 1 x y y 2 6 -2 Analog sinusoid, 5sin(2πx) 0 5 10 15 20 25 30 35 40 n 0 -2 quantize sample -4 -6 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 SNR is a function of B, the number of bits in the quantizer 1 x 11 12 2 The Sampling Theorem Issues with Discrete Signals Sampled 1000 Hz and 7000 Hz Cosine Waves; Fs = 8000 Hz • what sampling rate is appropriate – 6.4 kHz (telephone bandwidth), 8 kHz (extended telephone BW), 10 kHz (extended bandwidth), 16 kHz (hi-fi speech) • how many quantization levels are necessary at each bit rate (bits/sample) amplitude 1 0.5 0 -0.5 -1 0 – 16, 12, 8, … => ultimately determines the S/N ratio of the speech – speech coding is concerned with answering this question in an optimal manner 0.2 0.4 0.6 time in ms 0.8 1 1.2 • A bandlimited signal can be reconstructed exactly from samples taken with sampling frequency 1 = Fs ≥ 2fmax T or 2π = ωs ≥ 2ωmax T 13 Discrete-Time (DT) Signals are Sequences Demo Examples 1. 2. 3. 5 kHz analog bandwidth — sampled at 10, 5, 2.5, 1.25 kHz (notice the aliasing that arises when the sampling rate is below 10 kHz) quantization to various levels — 12,9,4,2, and 1 bit quantization (notice the distortion introduced when the number of bits is too low) music quantization — 16 bit audio quantized to various levels: Maple Rag: 16 bits, 12 bits, 10 bits, 8 bits, 14 T • • 15 6 bits, 4 bits; x[n] denotes the “sequence value at ‘time’ n” Sources of sequences: – Sampling a continuous-time signal x[n] = xc(nT) = xc(t)|t=nT – Mathematical formulas – generative system e.g., x[n] = 0.3 • x[n-1] -1; x[0] = 40 16 Noise: 10 12 bits Impulse Representation of Sequences x[ n ] = A sequence, a function ∞ ∑ Value of the function at k x[k ]δ [n − k ] k =−∞ a−3δ [n + 3] a2δ [n − 2] Some Useful Sequences ⎧1, n = 0 ⎩0, n ≠ 0 unit sample δ [n] = ⎨ real exponential x[n] = α n a1δ [n − 1] a7δ [n − 7] x[n ] = a−3δ [n + 3] + a1δ [n − 1] + a2δ [n − 2] + a7δ [n − 7] 17 ⎧1, n ≥ 0 unit step u[n] = ⎨ ⎩0, n < 0 sine wave x[n] = A cos(ω 0 n + φ ) 18 3 Complex Signal Variants on Discrete-Time Step Function u[n] x[n ] = (0.65 + 0.5 j )n u[n ] u[n-n0] u[n0-n] n → −n ⇔ signal flips around 0 19 20 Complex Signal Complex DT Sinusoid x [n ] = A e jω n x [n ] = (α + j β )n u[n ] = (re jθ )n u[n ] • Frequency ω is in radians (per sample), or just radians r = α2 + β2 θ = tan−1( β / α ) β – once sampled, x[n] is a sequence that relates to time only through the sampling period T r θ • Important property: periodic in ω with period 2π: j ( ω 0 + 2 π r )n jω 0n α x [n ] = r e n jθ n u [n ] Ae n r is a dying exponential = Ae – Only unique frequencies are 0 to 2π (or –π to +π) – Same applies to real sinusoids e jθ n is a linear phase term 22 21 Sampled Speech Waveform Signal Processing xa(t) MATLAB: plot MATLAB: stem • Transform digital signal into more desirable form x[n] xa(nT),x(n) x[n] y[n]=T[x[n]] single input—single output x[n] y[n] single input—multiple output, e.g., filter bank analysis, sinusoidal sum analysis, etc. T=0.125 msec, fS=8 kHz Trap #1: loss of sampling time index 23 24 4 LTI Discrete-Time Systems x[n] Example: y[n] LTI System δ [n] LTI Discrete-Time Systems Is system y [n ] = x[n ] + 2 x[n + 1] + 3 linear? h[n] x1[n ] ↔ y1[n ] = x1[n ] + 2 x1[n + 1] + 3 x2 [n ] ↔ y 2 [n ] = x2 [n ] + 2 x2 [n + 1] + 3 • Linearity (superposition): x1[n ] + x2 [n ] ↔ y 3 [n ] = x1[n ] + x2 [n ] + 2 x1[n + 1] + 2x2 [n + 1] + 3 Τ{ax1[n] + bx2 [n]} = aΤ{x1[n]} + bΤ {x2 [n]} ≠ y1[n ] + y 2 [n ] ⇒ Not a linear system! Is system y [n] = x[n ] + 2 x[n + 1] + 3 time/shift invariant? • Time-Invariance (shift-invariance): x1[n] = x[n − nd ] ⇒ y1[n] = y[n − nd ] y [n ] = x[n ] + 2x [n + 1] + 3 y [n − n0 ] = x [n − n0 ] + 2 x [n − n0 + 1] + 3 ⇒ System is time invariant! Is system y [n ] = x [n ] + 2 x [n + 1] + 3 causal? • LTI implies discrete convolution: ∞ y [n ] depends on x[n + 1], a sample in the future y[n] = ∑ x[k]h[n − k] = x[n]∗ h[n] = h[n]∗ x[n] k =−∞ 25 h[n] Convolution Example ⎧1 x[n] = ⎨ ⎩0 0≤n≤3 otherwise ⎧1 h[n ] = ⎨ ⎩0 0≤n≤3 otherwise 26 ⇒ System is not causal! x[n] n 01234 5 x[n],h[n] n=0 01234 5 n=1 n n=2 What is y [n ] for this system? Solution : 01234 5 n 01234 5 ∞ ∑ h[m] x[n − m] y [n ] = x [n ] * h[n ] = m 01234 5 m n=4 n=3 01234 5 m n=5 m =−∞ ⎧ n ⎪ ∑ 1⋅ 1 = (n + 1) ⎪ m =0 ⎪ 3 = ⎨ ∑ 1⋅ 1 = (7 − n ) ⎪ m = n −3 ⎪0 ⎪ ⎩ 0≤n≤3 y[n] 01234 5 4≤n≤6 m n=6 n ≤ 0, n ≥ 7 01234 567 01234 5 m n=7 01234 5 m n=8 n 27 01234 56 m 01234 567 m 01234 5678 m 28 Convolution Example Convolution Example The impulse response of an LTI system is of the form: h[n ] = a n u[n ] | a |< 1 and the input to the system is of the form: x [ n ] = b n u [n ] | b |< 1, b ≠ a Determine the output of the system using the formula for discrete convolution. SOLUTION: y [n ] = ∞ ∑a m u[ m ] b n − m u[ n − m ] m =−∞ = bn n ∑a m =0 m b − m u [n ] = b n n ∑ (a / b ) m u [n ] m =0 ⎡1 − (a / b )n +1 ⎤ ⎡ b n +1 − a n +1 ⎤ = bn ⎢ ⎥=⎢ ⎥ u [n ] ⎣ 1 − (a / b ) ⎦ ⎣ b − a ⎦ 29 30 5 Convolution Example Linear Time-Invariant Systems Consider a digital system with input x [n ] = 1 for n = 0,1,2,3 and 0 everywhere else, and with impulse • • • • response h[n ] = a u[n ], | a |< 1. Determine the n response y [n ] of this linear system. SOLUTION: easiest to understand easiest to manipulate powerful processing capabilities characterized completely by their response to unit sample, h(n), via convolution relationship ∞ ∞ k =−∞ k =−∞ ∑ x[k ] h[n − k ] = ∑ h[k ] x[n − k ] We recognize that x [n ] can be written as the difference between two y [n ] = x[n ] ∗ h[n ] = step functions, i.e., x [n ] = u[n ] − u[n − 4]. Hence we can solve for y [n ] as the difference between the output of the linear system with a step input y [n ] = h[n ] ∗ x[n ], where ∗ denotes discrete convolution x[n] and the output of the linear system with a delayed step input. Thus we solve for the response to a unit step as: ⎡ a n − a −1 ⎤ u [n − m ] = ⎢ u[n ] −1 ⎥ ⎣ 1− a ⎦ y [n ] = y1[n ] − y1[n − 4] y 1[ n ] = ∞ ∑ u[m] a • used as models for speech production (source convolved with system) 31 Signal Processing Operations x[n] x[n] 32 Equivalent LTI Systems x1[n] h1[n] h2[n] h1[n] y[n] x[n] x[n] x2[n] x[n] h2[n] h1[n] x[n-1] x[n] h1[n]*h2[n] h2[n] y[n] y[n] x[n] x[n] * h[n] • basis for linear filtering n −m m =−∞ x1[n]+x2[n] y[n]=x[n] h[n] h1[n]+h2[n] y[n] y[n] h1[n]*h2[n]= h2[n]*h1[n] h1[n]+h2[n]= h2[n]+h1[n] D is a delay of 1-sample Can replace D with delay element z −1 33 34 More Complex Filter Interconnections Network View of Filtering (FIR Filter) h2[n] x[n] y[n] h1[n] h3[n] h4[n] D (Delay Element) ⇔ z −1 y [n ] = b0 x [n ] + b1x [n − 1] + ... + bM −1x [n − M + 1] + bM x [n − M ] y [n ] = x [n ] * hc [n ] hc [n ] = h1[n ] * (h2 [n ] + h3 [n ]) + h4 [n ] 35 36 6 Network View of Filtering (IIR Filter) x[n] z-Transform Representations y[n] y [n ] = −a1y [n − 1] + b0 x[n ] + b1x [n − 1] 37 Transform Representations −1 infinite power series in z , with x[n] as coefficients of −n term in z ∞ ∑ x[n]z −n 1 2π j • partial fraction expansion of X(z) ∫ X (z)z n −1dz C 0.8 0.7 0.6 0.5 0.4 X (z ) = z − n0 − − converges for | z |> 0, n0 > 0; • direct evaluation using residue theorem n =−∞ x[ n ] = 1 0.9 1. x[n ] = δ [n − n0 ] -- delayed impulse 0.3 0.2 0.1 0 0 1 2. x[n ] = u[n ] − u[n − N ] -- box pulse 6 7 8 9 0.8 1 − z −N -- converges for 0 <| z |< ∞ 1 − z −1 n =0 • all finite length sequences converge in the region 0 <| z |< ∞ • X(z) converges (is finite) only for certain values of z: 4 5 sample number 1 N-1 • power series expansion 3 0.9 X(z) = ∑ (1)z − n = • long division 2 | z |< ∞, n0 < 0; ∀z, n0 = 0 0.7 0.6 amplitude x[n ] ←⎯ → X (z) X (z) = Examples of Convergence Regions am plitude • z-transform: 38 0.5 0.4 0.3 0.2 0.1 0 0 1 2 3 4 5 sample number 6 7 8 9 3. x[n ] = a nu[n ] (a < 1) 1 ∑ | x[n] | | z −n |<∞ ∞ - sufficient condition for convergence n =−∞ • region of convergence: R1 < |z| < R2 1 --converges for | a |<| z | 1 − az −1 n =0 • all infinite duration sequences which are non-zero for n ≥ 0 X (z ) = ∑ a n z − n = 0.9 0.8 0.7 0.6 amplitude ∞ 0.5 0.4 0.3 0.2 0.1 0 0 5 10 15 20 25 30 sample number 35 40 45 50 converge in a region | z |> R1 39 40 Examples of Convergence Regions Example 0 -0.1 -0.2 -0.3 amplitude -0.4 -0.5 -0.6 If x [n ] has z-transform X ( z ) with ROC of ri <| z |< ro , find the z -transform, Y ( z ), and -0.7 4. x[n ] = −b nu[ −n − 1] −1 -0.8 -0.9 -1 -50 -45 -40 -35 -30 -25 -20 sample number -15 -10 -5 0 1 X ( z ) = ∑ −b z = --converges for | z |<| b | 1 − bz −1 n =−∞ • all infinite duration sequences which are non-zero for n < 0 n −n the region of convergence for the sequence y [n ] = a n x [n ] in terms of X ( z ) converge in a region | z |< R2 Solution: 5. x[n ] non-zero for − ∞ < n < ∞ can be viewed as a combination of 3 and 4,giving a convergence region of the form R1 <| z |< R2 • sub-sequence for n ≥ 0 => | z |> R1 • sub-sequence for n < 0 => | z |< R2 X (z) = ∞ ∑ x [ n ]z −n n =−∞ Y (z) = R2 ∞ ∑ y [ n ]z −n = n =−∞ R1 = ∞ ∑ x[n](z / a) ∞ ∑a n x [ n ]z − n n =−∞ −n = X (z / a) n =−∞ • total sequence => R1 <| z |< R2 41 ROC: | a | ri <| z |<| a | ro 42 7 z-Transform Property Inverse z-Transform The sequence x [n ] has z-transform X ( z ). Show that the sequence nx[n ] has z-transform −z x[ n ] = dX ( z ) . dz X (z) = ∫ X ( z )z n −1 dz C where C is a closed contour that encircles the origin Solution: ∞ 1 2π j ∑ x [ n ]z of the z-plane and lies inside the region of convergence −n n =−∞ ∞ dX ( z ) = − ∑ nx[n ]z − n −1 dz n =−∞ for X(z) rational, can use a partial fraction expansion for finding inverse transforms C 1 ∞ = − ∑ nx[n ]z − n z n =−∞ 1 = − Z (nx[n ]) z R2 R1 43 Partial Fraction Expansion H (z) = 44 Example of Partial Fractions Find the inverse z-transform of H (z ) = b0 z M + b1z M −1 + ... + bM z N + a1z N −1 + ... + aN A A A H (z ) z2 + z + 1 = = 0+ 1 + 2 z z (z + 1)(z + 2) z z + 1 z + 2 b z M + b1z M −1 + ... + bM = 0 ; (N ≥ M ) (z − p1 )(z − p2 )...(z − pN ) A1 A2 AN + + ... + H (z) = z − p1 z − p2 z − pN A0 = z2 + z + 1 1 = (z + 1)(z + 2) z =0 2 A0 H (z) A1 A2 AN = + + + ... + ; p0 = 0 z z − p0 z − p1 z − p2 z − pN A2 = z2 + z + 1 3 = z(z + 1) z =−2 2 Ai = (z − pi ) z2 + z + 1 1 <| z |< 2 (z 2 + 3z + 2) A1 = z2 + z + 1 = −1 z(z + 2) z =−1 1 z (3 / 2)z − + 1 <| z |< 2 2 z +1 z + 2 1 3 h[n ] = δ [n ] − (−1)n u[n ] − (−2)n u[−n − 1] 2 2 H (z ) = H (z ) i = 0,1,..., N z z = pi 45 46 Transform Properties Linearity Shift Exponential Weighting Linear Weighting Time Reversal Convolution ax1[n]+bx2[n] x[n-n0] anx[n] n x[n] x[-n] non-causal, need x[N0-n] to be causal for finite length sequence x[n] * h[n] Multiplication of x[n] w[n] Sequences aX1(z)+bX2(z) z − n0 X ( z) X(a-1z) -z dX(z)/dz X(z-1) X(z) H(z) 1 2π j ∫ X (v )W (z / v )v −1 dv C circular convolution in the frequency DiscreteTime Fourier Transform (DTFT) domain 47 48 8 Simple DTFTs Discrete-Time Fourier Transform X (e jω ) = X (z ) |z =e jω = ∞ ∑ x[n]e − jωn n =−∞ z = e jω ; | z |= 1, arg(z ) = j ω x[ n ] = 1 2π π ∫π X (e jω )e jωn dω x[n ] = δ [n ], Delayed impulse x[n ] = δ [n − n0 ], X (e jω ) = e − jωn0 Step function x[n ] = u[n ], Rectangular window − • evaluation of X(z) on the unit circle in the z-plane Exponential • sufficient condition for existence of Fourier transform is: ∞ ∑ | x[n] | | z n =−∞ −n |= ∞ ∑ | x[n] |< ∞, since | z |= 1 n =−∞ Backward exponential 49 X (e j ω ) = 1 Impulse 1 1 − e − jω 1 − e − jωN x[n ] = u[n ] − u[n − N ], X (e jω ) = 1 − e − jω 1 x[n ] = a n u[n ], X (e j ω ) = , a <1 1 − ae − jω 1 , b >1 x[n ] = −b n u[ −n − 1], X (e jω ) = 1 − be − jω X (e j ω ) = 50 DTFT Examples DTFT Examples x[n ] = β nu[n ] β = 0.9 1 X (e jω ) = | β |< 1 1 − β e − jω x [n ] = cos(ω0 n ), jω X (e ) = −∞ < n < ∞ ∞ ∑ [πδ (ω − ω k =−∞ 0 + 2π k ) + πδ (ω + ω0 + 2π k )] Within interval − π < ω < π , X (e jω ) is comprised of a pair of impulses at ± ω0 x[n ] = cos(ω0 n ) 51 DTFT Examples 52 DTFT Examples x[n ] = rect M [n ] h[n ] 53 54 9 Fourier Transform Properties Periodic DT Signals 0.25, π/2, FS/ 4, π FS/ 2 • periodicity in ω 0. 5, π, FS/ 2, π FS 0,0,0,0 1, 2π, FS, 2π FS X (e jω ) = X (e j (ω + 2π n ) ) f, ω, f • period of 2π corresponds to once around 0.75, 3π/2, 3FS/ 4, π 3FS/ 2 D, ωD • normalized frequency: f, 0Æ0.5Æ1 (independent of FS) • normalized radian frequency: ω, 0Æ πÆ2 π (independent of FS) – e.g., ωk = 2π k/N, • digital frequency: fD= f *FS, 0ÆFS/2ÆFS k=0,1,…,N-1 55 56 Periodic DT Signals Periodic DT Signals Example 1: Example 2: Fs = 11059 Hz; Is the signal Fs = 10, 000 Hz Is the signal x[n] = cos(2π ⋅100n / Fs ) a periodic signal? x[n] = cos(2π ⋅100n / Fs ) periodic? If so, what is the period. If so, what is the period. Solution: Solution: If the signal is periodic with period N , then we have: x [ n ] = x[ n + N ] If the signal is periodic with period N , then we have: x[ n] = x[ n + N ] cos(2π ⋅ 100n / Fs ) = cos(2π ⋅ 100( n + N ) / Fs ) cos(2π ⋅100n / Fs ) = cos(2π ⋅100( n + N ) / Fs ) 2π ⋅ 100 N = 2π ⋅ k ( k an integer ) Fs 2π ⋅100 N = 2π ⋅ k (k an integer ) Fs k= 100 N 100 N N = = 10, 000 100 Fs For k an integer we get N = 100k = 100 (for k = 1) Thus x[ n] is periodic of period 100 samples. = Ae which requires ω0N = 2π k for some integer k • Thus, not all DT sinusoids are periodic! • Consequence: there are N distinguishable frequencies with period N Units of Frequency (Digital Domain) (Trap #2 - loss of FS) k= = Ae Ae unit circle in the z -plane • digital radian frequency: ωD= ω *FS, 0Æ πFSÆ2πFS • A signal is periodic with period N if x[n] = x[n+N] for all n • For the complex exponential this condition becomes j (ω0 n +ω0 N ) jω0 n jω0 ( n + N ) 100 N 100 N = 11, 059 Fs 11059 k which is not an integer 100 Thus x[n ] is not periodic at this sampling rate. For k an integer we get N = 57 58 Periodic Sequences?? Periodic DT Signals Example 3: Fs = 10, 000 Hz Is the signal x[n] = cos(2π ⋅101n / Fs ) a periodic signal? If so, what is the period. Solution: If the signal is periodic with period N , then we have: x[ n] = x[ n + N ] cos(2π ⋅101n / Fs ) = cos(2π ⋅101(n + N ) / Fs ) 2π ⋅101N = 2π ⋅ k ( k an integer ) Fs k= 101N 101N = which is not an integer 10, 000 Fs Thus x[ n] is not periodic at this sampling rate. 59 60 10 Discrete Fourier Transform • consider a periodic signal with period N (samples) x%[n ] = x%[n + N ], − ∞ < n < ∞ x%[n ] can be represented exactly by a discrete The DFT – Discrete Fourier Transform sum of sinusoids N −1 X% [k ] = ∑ x%[n ]e − j 2π kn / N • N sequence values n =0 x%[n ] = 61 N −1 1 ∑ X% [k ]e j 2π kn / N N k =0 • N DFT coefficients • exact representation of the discrete periodic sequence DFT Unit Vectors (N=8) 62 DFT Examples k = 0; e − j 2π k /8 = 1 2 (1 − j ) 2 =−j k = 1; e − j 2π k /8 = k = 2; e − j 2π k /8 δ [ n] 2 k = 3; e = (−1 − j ) 2 − j 2π k /8 k = 4; e = −1 DFT{δ [n]} − j 2π k /8 k = 5; e − j 2π k /8 = 1 2 ( −1 + j ) 2 1 n k k = 6; e − j 2π k /8 = j k = 7; e − j 2π k /8 = 2 (1 + j ) 2 63 DFT Examples DFT Examples x[n] 64 x%[n ] = (0.9)n 0 ≤ n ≤ 31 (N = 32) X [k] 65 66 11 Circularly Shifting Sequences Review DTFT of sequence { x[n ], − ∞ < n < ∞} x[n-2] x[n] x((n-2)) X (e jω ) = ∞ ∑ x [n ] e − j ωn n =−∞ 1 π X (e jω ) e jωn 2π ∫−π DFT of periodic sequence { x% [n], 0 ≤ n ≤ N − 1} x[n ] = x[n-1] x((n-1)) x[-n] x((-n)) N −1 X% [k ] = ∑ x% [n ] e − j 2π nk / N , 0 ≤ k ≤ N − 1 n =0 1 N −1 x% [n ] = ∑ X% [k ] e j 2π nk / N , 0 ≤ n ≤ N − 1 N k =0 67 68 Finite Length Sequences • consider a finite length (but not periodic) sequence, x[n], that is zero outside the interval 0 ≤ n ≤ N −1 DFT for Finite Length Sequences N −1 X (z ) = ∑ x[n ]z − n n =0 • evaluate X(z) at N equally spaced points on the unit circle, zk = e j 2π k / N 69 Relation to Periodic Sequence Periodic and Finite Length Sequences 0.8 0.7 r =−∞ amplitude ∑ x [n + r N ] ~ 0.5 j 2π k /N ~ x[n] 0.4 0.3 X[k] 0.2 periodic signal => line spectrum in frequency 0.1 0 0 2 4 6 8 10 s ample number 12 14 16 18 - the Fourier coefficients, X% [k ], are then identical to the values of X (e N −1 1 0.6 x% (n ) = )= 0.9 sequence of replicas of x[n] ∞ j 2π k / N ∑ x[n ]e− j 2π kn /N , k =0,1,...,N −1 n =0 70 --looks like DFT of periodic sequence! X [k ]=X (e -consider a periodic sequence, x% [n ], consisting of an infinite , k = 0,1, ..., N − 1 n k ) for the finite duration sequence => a sequence of length N can be exactly represented by a DFT representation x[n] of the form: N −1 − j 2π nk / N X [k ] = ∑ x[n ]e , k = 0,1,..., N − 1 n=0 1 N −1 j 2π kn / N , n = 0,1,..., N − 1 x[ n ] = ∑ X [k ]e Nk =0 Works for both finite sequence and for periodic sequence 71 X(ejω) n ω finite duration => continuous spectrum in frequency 72 12 Sampling in Frequency (Time Domain Aliasing) Consider a finite duration sequence: x[n ] ≠ 0 for 0 ≤ n ≤ L − 1 S(e ) i.e., an L − point sequence, with discrete time Fourier transform . . . If the duration of the finite duration signal satisfies the relation L −1 X (e jω ) = ∑ x[n ] e − jωn 0 ≤ ω ≤ 2π 0 1 2 3 4 n =0 Consider sampling the discrete time Fourier transform by multiplying it by a signal that is defined as: N −1 S (e ) = ∑ δ [ω − 2π k / N ] jω N-1 k ω=2πk/N s[n] . . . . . . k =0 with time-domain representation s[n ] = Sampling in Frequency (Time Domain Aliasing) jω -N ∞ ∑ δ [n − rN ] 0 N 2N n r =−∞ N ≥ L, then only the first term in the infinite summation affects the interval 0 ≤ n ≤ L − 1 and there is no time domain aliasing, i.e., x%[n ] = x[n ] 0 ≤ n ≤ L − 1 If N < L, i.e., the number of frequency samples is smaller than the duration of the finite duration signal, then there is time domain aliasing and the resulting aliased signal (over the interval 0 ≤ n ≤ L − 1) satisfies the aliasing relation: x%[n ] = x[n ] + x[n + N ] + x[n − N ] 0 ≤ n ≤ N − 1 Thus we form the spectral sequence X% (e jω ) = X (e jω ) ⋅S (e jω ) which transforms in the time domain to the convolution ∞ x% [n ] = x[n ]∗ s[n ] = x[n ] ∗ ∑ δ [n − rN ] = r =−∞ ∞ ∑ x[n − rN ] r =−∞ x%[n ] = x[n ] + x[n − N ] + x[n + N ] + ... 73 74 Time Domain Aliasing Example DFT Properties Consider the finite duration sequence Periodic Sequence 4 x[n ] = ∑ (m + 1) δ [n − m] = δ [n ] + 2δ [n − 1] + 3δ [n − 2] + 4δ [n − 3] + 5δ [n − 4] m =0 DFT defined for all k -2 -1 0 1 2 3 4 5 6 7 8 Finite Sequence Period=N Length=N Sequence defined for all n Sequence defined for n=0,1,…,N-1 DTFT defined for all ω n The discrete time Fourier transform of x[n] is computed and sampled at N frequencies around the unit circle. The resulting sampled Fourier transform is inverse transformed back to the time domain. What is the resulting time domain signal, x%[n], (over the interval 0 ≤ n ≤ L − 1) for the cases N = 11, N = 5 and N = 4. SOLUTION: For the cases N = 11 and N = 5, we have no aliasing (since N ≥ L) and we get x%[n ] = x[n ] over the interval 0 ≤ n ≤ L − 1. For the case N = 4, the n = 0 value is aliased, giving x%[0] = 6 (as opposed to 1 for x[0]) with the remaining values unchanged. • when using DFT representation, all sequences behave as if they were infinitely periodic => DFT is really the representation of the extended periodic function, x%[n ] = • alternative (equivalent) view is that all sequence indices must be interpreted modulo N x%[n ] = 75 ∞ ∑ x[n + rN ] = x[n modulo N ] = x ([n]) r =−∞ 77 N 76 DFT Properties DFT Properties for Finite Sequences • X[k], the DFT of the finite sequence x[n], can be viewed as a sampled version of the z-transform (or Fourier transform) of the finite sequence (used to design finite length filters via frequency sampling method) • the DFT has properties very similar to those of the z-transform and the Fourier transform • the N values of X[k] can be computed very efficiently (time proportional to N log N) using the set of FFT methods • DFT used in computing spectral estimates, correlation functions, and in implementing digital filters via convolutional methods ∞ ∑ x[n + rN ] r =−∞ N-point DFT N-point sequences 1. Linearity 2. Shift ax1[n ] + bx2 [n ] aX1[k ] + bX 2 [k ] e − j 2π kn0 / N X [k ] x( [n − n0 ])N X ∗ [k ] 3. Time Reversal x ([−n ])N 4. Convolution N −1 ∑ x[m] h([n − m]) m =0 5. Multiplication x[n ] w [n ] N X [k ] H [k ] 1 N −1 ∑ X [r ]W ([k − r ])N N r =0 78 13 Key Transform Properties Sampling Function y [n ] = x1[n ] ∗ x2 [n ] ⇔ Y (e jω ) = X1(e jω ) ⋅ X 2 (e jω ) convolution multiplication jω jω x[n] y [n ] = x1[n ] ⋅ x2 [n ] ⇔ Y (e ) = X1(e ) ⊗ X 2 (e ) multiplication circular convolution M 0 Special Case: x2 [n ] = impulse train of period M samples x2 [ n ] = ... ... jω X 2 [k ] = ∑ δ [n ] e n X [k] ∞ ∑ δ [k − nM ] ... k =−∞ M −1 2M − j 2π nk / M = 1, k = 0,1,..., M − 1 0 1 n =0 1 M −1 1 M −1 x2 [n ] = ∑ X 2 [k ] e j 2π nk / M = ∑ e j 2π nk / M sampling function M k =0 M k =0 2 3 4 0 2π 4π 6π ω M M M 5 M-1 k (M-1)2π M 79 80 Summary of DSP-Part 1 • speech signals are inherently bandlimited => must sample appropriately in time and amplitude • LTI systems of most interest in speech processing; can characterize them completely by impulse response, h(n) • the z-transform and Fourier transform representations enable us to efficiently process signals in both the time and frequency domains • both periodic and time-limited digital signals can be represented in terms of their Discrete Fourier transforms • sampling in time leads to aliasing in frequency; sampling in frequency leads to aliasing in time => when processing time-limited signals, must be careful to sample in frequency at a sufficiently high rate to avoid time-aliasing Digital Filters 81 82 Digital Filters Digital Filters • digital filter is a discrete-time linear, shift invariant system with input-output relation: y [n ] = x[n ] ∗ h[n ] = ∞ ∑ x[m] h[n − m] m =−∞ Y (z ) = X (z) ⋅ H (z) • H (z) is the system function with H (e jω ) as the complex frequency response H (e jω ) = Hr (e jω ) + jHi (e jω ) H (e jω ) =| H (e jω ) | e j arg|H ( e jω )| H (e j ω ) real, imaginary representation ∞ ∑ | h[n] |< ∞ magnitude, phase representation log H (e jω ) = log | H (e jω ) | + j arg | H (e jω ) | n =−∞ log | H (e jω ) |= Re ⎡⎣log H (e jω ) ⎤⎦ j arg | H (e jω ) |= Im ⎡⎣ log H (e jω ) ⎤⎦ • causal linear shift-invariant => h[n]=0 for n<0 • stable system => every bounded input produces a bounded output => a necessary and sufficient condition for stability and for the existence of 83 84 14 Digital Filter Implementation Digital Filters • input and output satisfy linear difference equation of the form: N M k =1 r =0 −1 • H(z) is a rational function in z y [n ] − ∑ ak y [n − k ] = ∑ br x[n − r ] • evaluating O z-transforms of both sides gives: N M k =1 r =0 M H (z) = Y (z) − ∑ ak z − kY (z ) = ∑ br z − r X (z) N M k =1 r =0 M ∑b z r =0 N −r r 1 − ∑ ak z − k r =1 N ∏ (1 − dk z −1 ) O => M zeros, N poles • converges for | z |> R1 , with R1 < 1 for stability canonic form showing poles and zeros k =1 X O k =1 Y (z) (1 − ∑ ak z − k ) = X (z)∑ br z − r Y (z ) H (z) = = X (z) A∏ (1 − cr z ) −1 X X X O => all poles of H (z ) inside the unit circle for a stable, causal system 85 86 Ideal Filter Responses FIR Systems • if ak=0, all k, then M y [n ] = ∑ br x[n − r ] = b0 x[n ] + b1 x[n − 1] + ... + bM x[n − M ] => r =0 1. h[n ] = bn 0 ≤ n ≤ M =0 M otherwise 2. H (z ) = ∑ bn z − n => n =0 M −1 ∏ (1 − c m =0 m z −1 ) => M zeros 3. if h[n ] = ± h[M − n ] (symmetric, antisymmetric) H(e jω ) = A(e jω )e − jωM / 2 , A(e jω ) = real (symmetric), imaginary (anti-symmetric) • linear phase filter => no signal dispersion because of non-linear phase => precise time alignment of events in signal 87 FIR Filters event at t0 FIR Linear Phase Filter event at t0 + fixed delay 88 Window Designed Filters • cost of linear phase filter designs – can theoretically approximate any desired response to any degree of accuracy – requires longer filters than non-linear phase designs Windowed impulse response h[n ] = hI [n ] ⋅w [n ] In the frequency domain we get • FIR filter design methods – window design => analytical, closed form method – frequency sampling => optimization method – minimax error design => optimal method H (e jω ) = HI (e jω ) ∗W (e jω ) 89 90 15 LPF Example Using RW LPF Example Using RW 0 0.2 π 0.4 π 0.6 π 0.8 π π 0.6 π 0.8 π π Frequency 91 0 0.2 π 0.4 π 92 Frequency LPF Example Using RW Common Windows (Time) 0≤n≤M ⎧1 1. Rectangular w [n ] = ⎨ ⎩0 2. Bartlett 3. Blackman 0 0.25 π 0.5 π 0.75 π π Frequency 4. Hamming 0 0.25 π 0.5 π 0.75 π π 2|n −M / 2| M ⎛ 2π n ⎞ ⎛ 4π n ⎞ w [n ] = 0.42 − 0.5cos ⎜ ⎟ + 0.08cos ⎜ ⎟ ⎝ M ⎠ ⎝ M ⎠ w [n ] = 1 − ⎛ 2π n ⎞ w [n ] = 0.54 − 0.46 cos ⎜ ⎟ ⎝ M ⎠ 5. Hanning ⎛ 2π n ⎞ w [n ] = 0.5 − 0.5cos ⎜ ⎟ ⎝ M ⎠ 6. Kaiser w [n ] = { I0 β 1 − ((n − M / 2) / (M / 2)) 2 93 Frequency Common Windows (Frequency) Window otherwise Sidelobe Width Attenuation − 13 dB − 27 dB Hanning Hamming 8π /M 8π /M − 32 dB − 43 dB Blackman 12π /M − 58dB } 94 Window LPF Example Mainlobe Rectangular 4π / M Bartlett 8π /M I0 {β } 0 0.2 π 0.4 π 0.6 π 0.8 π π 0.6 π 0.8 π π Frequency 95 0 0.2 π 0.4 π 96 Frequency 16 Equiripple Design Specifications Optimal FIR Filter Design • Equiripple in each defined band (passband and stopband for lowpass filter, high and low stopband and passband for bandpass filter, etc.) • Optimal in sense that the cost function π 1 ( ) | H (ω) − H (ω) | dω E= β ω 2π ∫π is minimized. Solution via well known iterative algorithm based on the alternation theorem of Chebyshev approximation. 2 d − ωp = normalized edge of passband frequency ωs = normalized edge of stopband frequency δ p = peak ripple in passband δ s = peak ripple in stopband Δω =ωs − ωp = normalized transition bandwidth 97 Remez Lowpass Filter Design MATLAB FIR Design 1. Use fdatool to design digital filters 2. Use firpm to design FIR filters 3. • B=firpm(N,F,A) • N+1 point linear phase, FIR design • B=filter coefficients (numerator polynomial) • F=ideal frequency response band edges (in pairs) (normalized to 1.0) • A=ideal amplitude response values (in pairs) Use freqz to convert to frequency response (complex) • 4. 98 [H,W]=freqz(B,den,NF) • H=complex frequency response • W=set of radian frequencies at which FR is evaluated (0 to pi) • B=numerator polynomial=set of FIR filter coefficients • den=denominator polynomial=[1] for FIR filter • NF=number of frequencies at which FR is evaluated N=30 F=[0 0.4 0.5 1]; A=[1 1 0 0]; B=firpm(N,F,A) NF=512; number of frequency points [H,W]=freqz(B,1,NF); Use plot to evaluate log magnitude response • plot(W/pi, 20log10(abs(H))) 99 100 plot(W/pi,20log10(abs(H))); Remez Bandpass Filter Design FIR Implementation % bandpass_filter_design N=input('Filter Length in Samples:'); F=[0 0.18 .2 .4 .42 1]; A=[0 0 1 1 0 0]; B=firpm(N,F,A); NF=1024; [H,W]=freqz(B,1,NF); x[n] figure,orient landscape; stitle=sprintf('bandpass fir design, N:%d,f: %4.2f %4.2f %4.2f %4.2f %4.2f %4.2f',N,F); n=0:N; subplot(211),plot(n,B,'r','LineWidth',2); axis tight,grid on,title(stitle); xlabel('Time in Samples'),ylabel('Amplitude'); legend('Impulse Response'); subplot(212),plot(W/pi,20*log10(abs(H)),'b','LineWidth',2); axis ([0 1 -60 0]), grid on; xlabel('Normalized Frequency'),ylabel('Log Magnitude (dB)'); legend('Frequency Response'); x[ n − 1] x[n − 2] x[n − 3] x[n − M ] y[n] • linear phase filters can be implemented with half the multiplications (because of the symmetry of the coefficients) 101 102 17 IIR Systems N M k =1 r =0 IIR Design Methods y [n ] = ∑ ak y [n − k ] + ∑ br x[n − r ] • y [n ] depends on y [n − 1], y [n − 2],..., y [n − N ] as well as x[n ], x[n − 1],..., x[n − M ] • for M < N M H (z ) = ∑b z r =0 N −r r 1 − ∑ ak z N −k =∑ k =1 Ak - partial fraction expansion 1 − dk z −1 k =1 N h[n ] = ∑ Ak (d k )n u[n ] - for causal systems k =1 h[n ] is an infinite duration impulse response 103 • Impulse invariant transformation – match the analog impulse response by sampling; resulting frequency response is aliased version of analog frequency response • Bilinear transformation – use a transformation to map an analog filter to a digital filter by warping the analog frequency scale (0 to infinity) to the digital frequency scale (0 to pi); use frequency pre-warping to preserve critical frequencies of transformation (i.e., filter cutoff frequencies) 104 IIR Filter Design Butterworth Design 0 0.2 π 0.4 π 0.6 π 0.8 π π 0.6 π 0.8 π π Frequency 105 0 0.2 π 0.4 π Frequency Chebyshev Type I Design 106 Chebyshev BPF Design 0 0.2 π 0.4 π 0.6 π 0.8 π π 0.6 π 0.8 π ππ Frequency 107 0 0.2 π 0.4 π Frequency 108 18 Chebyshev Type II Design 0 0.2 π 0.4 π 0.6 π 0.8 π Elliptic BPF Design π 0 0.2 π Frequency 0 0.2 π 0.4 π 0.4 π 0.6 π 0.8 π π 0.6 π 0.8 π π 110 Frequency 0.6 π 0.8 π π 109 0 Frequency 0.2 π 0.4 π Frequency IIR Filters Matlab Elliptic Filter Design • IIR filter issues: • use ellip to design elliptic filter – efficient implementations in terms of computations – can approximate any desired magnitude response with arbitrarily small error – non-linear phase => time dispersion of waveform • IIR design methods – Butterworth designs-maximally flat amplitude – Bessel designs-maximally flat group delay – Chebyshev designs-equi-ripple in either passband or stopband – Elliptic designs-equi-ripple in both passband and stopband – – – – – – – [B,A]=ellip(N,Rp,Rs,Wn) B=numerator polynomial—N+1 coefficients A=denominator polynomial—N+1 coefficients N=order of polynomial for both numerator and denominator Rp=maximum in-band (passband) approximation error (dB) Rs=out-of-band (stopband) ripple (dB) Wp=end of passband (normalized radian frequency) • use filter to generate impulse response – y=filter(B,A,x) – y=filter impulse response – x=filter input (impulse) • use zplane to generate pole-zero plot – zplane(B,A) 111 Matlab Elliptic Lowpass Filter 112 IIR Filter Implementation M=N=4 N M k =1 r =0 y [n ] = ∑ ak y [n − k ] + ∑ br x[n − r ] N w [n ] = ∑ ak w [n − k ] + x[n ] k =1 M y [n ] = ∑ br w [n − r ] r =0 [b,a]=ellip(6,0.1,40,0.45); [h,w]=freqz(b,a,512); x=[1,zeros(1,511)]; y=filter(b,a,x); zplane(b,a); appropriate plotting commands; 113 114 19 IIR Filter Implementations IIR Filter Implementations c0 k + c1k z −1 , parallel system −1 − a2 k z −2 k =1 1 − a1k z K N H (z) = A∏ (1 − cr z −1 ) r =1 N ∏ (1 − d z k =1 k −1 H (z) = ∑ - zeros at z = cr , poles at z = d k ) c01 - since ak and br are real, poles and zeros occur in complex conjugate pairs => −1 −2 b0k + b1k z + b2 k z ⎡ N + 1⎤ , K =⎢ 1 − a1k z −1 − a2k z −2 ⎣ 2 ⎥⎦ - cascade of second order systems K H(z) = A∏ Common form for speech synthesizer implementation k =1 a21 Used in formant synthesis systems based on ABS methods c02 a12 c12 115 DSP in Speech Processing Sampling of Waveforms • filtering — speech coding, post filters, pre-filters, noise reduction • spectral analysis — vocoding, speech synthesis, speech recognition, speaker recognition, speech enhancement • implementation structures — speech synthesis, analysis-synthesis systems, audio encoding/decoding for MP3 and AAC • sampling rate conversion — audio, speech – – – – 116 DAT — 48 kHz CD — 44.06 kHz Speech — 6, 8, 10, 16 kHz Cellular — TDMA, GSM, CDMA transcoding xa(t) x[n],x(nT) Sampler and Quantizer Period, T x[n ] = xa (nT ), − ∞ < n < ∞ T = 1/ 8000 sec =125 μ sec for 8kHz sampling rate T = 1/10000 sec = 100 μ sec for 10 kHz sampling rate T = 1/16000 sec = 67 μ sec for 16 kHz sampling rate T = 1/ 20000 sec = 50 μ sec for 20 kHz sampling rate 117 The Sampling Theorem 118 Sampling Theorem Equations If a signal xa(t) has a bandlimited Fourier transform Xa(jΩ) such that Xa(jΩ)=0 for Ω≥2πFN, then xa(t) can be uniquely reconstructed from equally spaced samples xa(nT), -∞<n<∞, if 1/T≥2 FN (FS≥2FN) (A-D or C/D converter) ∞ xa (t ) ←⎯ → X a ( j Ω) = a (t ) e − j Ωt dt −∞ xa(t) x[n ] ←⎯ → X (e j ΩT ) = ∞ ∑x n =−∞ xa(nT) 1 X (e j ΩT ) = T xa(nT) = xa(t) uT(nT), where uT(nT) is a periodic pulse train of period T, with periodic spectrum of period 2π/T ∫x 119 ∞ ∑X k =−∞ a a (nT )e − j ΩnT ( j Ω + j 2π k / T ) 120 20 Sampling Rates Sampling Theorem Interpretation To avoid aliasing need: 2π / T − ΩN > ΩN • FN = Nyquist frequency (highest frequency with significant spectral level in signal) • must sample at at least twice the Nyquist frequency to prevent aliasing (frequency overlap) – – – – ⇒ 2π / T > 2 ΩN ⇒ Fs = 1/ T > 2FN case where 1 / T < 2FN , aliasing occurs telephone speech (300-3200 Hz) => FS=6400 Hz wideband speech (100-7200 Hz) => FS=14400 Hz audio signal (50-21000 Hz) => FS=42000 Hz AM broadcast (100-7500 Hz) => FS=15000 Hz • can always sample at rates higher than twice the Nyquist frequency (but that is wasteful of processing) 121 122 Decimation and Interpolation of Sampled Waveforms Recovery from Sampled Signal • If 1/T > 2 FN the Fourier transform of the sequence of samples is proportional to the Fourier transform of the original signal in the baseband, i.e., X (e j ΩT ) = 1 π X a ( j Ω), | Ω | < T T • can show that the original signal can be recovered from the sampled signal by interpolation using an ideal LPF of bandwidth π /T, i.e., x a (t ) = ⎡ sin(π (t − nT ) / T ) ⎤ ∑ xa (nT ) ⎢ π (t − nT ) / T ⎥ n =−∞ ⎣ ⎦ ∞ bandlimited sample interpolation—perfect at every sample point, perfect in-between samples via interpolation • CD rate (44.06 kHz) to DAT rate (48 kHz)—media conversion • Wideband (16 kHz) to narrowband speech rates (8kHz, 6.67 kHz)—storage • oversampled to correctly sampled rates--coding x[n ] = xa (nT ), X a ( j Ω) = 0 for | Ω |> 2π FN if 1/ T > 2FN (adequate sampling) then X(e j ΩT ) = • digital-to-analog converter π 1 X a ( j Ω), | Ω |< T T 123 124 Decimation and Interpolation Decimation Standard Sampling: begin with digitized signal: x[ n] = xa (nT ) ↔ X a ( jΩ) = 0, | Ω |≥ 2π FN ( a) 1 ≥ 2 FN T π 1 X (e ) = X a ( jΩ), | Ω |< T T X (e jΩT ) = 0, 2π FN ≤| Ω |≤ 2π ( Fs − FN ) Fs = j ΩT Decimation, M=2 => T’=2T (b) can achieve perfect recovery of xa (t ) from digitized samples under these conditions Interpolation, L=2 => T’=T/2 125 126 21 Decimation Decimation want to reduce sampling rate of sampled signal by factor of M ≥ 2 want to compute new signal xd [n] with sampling rate Fs ' = 1/ T ' = 1( MT ) = Fs / M such that xd [n] = xa (nT '' ) with no aliasing need Fs ' ≥ 2 FN one solution is to downsample x[n] = xa (nT ) by retaining one out of every M samples of x[n], giving xd [n] = x[nM ] to avoid aliasing for M = 2 when Fs ' < 2 FN (c ) we get aliasing for M = 2 (d ) 127 128 Decimation Decimation to decimate by factor of M with no aliasing, need to ensure that the highest frequency in x[n] is no greater than Fs / (2M ) DTFTs of x[n] and xd [n] related by aliasing relationship: thus we need to filter x[n] using an ideal lowpass 1 M −1 ∑ X (e j (ω −2π k )/ M ) M k =0 or equivalently (in terms of analog frequency): X d (e jω ) = X d (e j ΩT ' 1 )= M M −1 ∑ X (e j ( ΩT ' − 2π k )/ M filter with response: | ω |< π / M ⎧1 H d (e jω ) = ⎨ ⎩0 π / M <| ω |≤ π using the appropriate lowpass filter, we can down- ) k =0 1 ≥ 2 FN , (i.e., no aliasing) we get: MT 1 1 1 1 j ΩT ' jΩT '/ M )= X d (e ) = X (e X (e jΩT ) = X a ( jΩ) M M MT 1 π π = X a ( jΩ), − < Ω < T' T' T' sample the reuslting lowpass-filtered signal by a factor of M without aliasing assuming Fs ' = 129 130 Decimation Interpolation using a lowpass filter gives: 1 π π Wd (e jΩT ' ) = H d (e jΩT ) X a ( jΩ), − < Ω < T' T' T' if filter is used, the down-sampled signal, wd [ n], assume we have x[n] = xa ( nT ), (no aliasing) and we wish to increase the sampling rate by the integer factor of L we need to compute a new sequence of samples of xa (t ) with period T '' = T / L, i.e., xi [ n] = xa (nT '') = xa ( nT / L) no longer represents the original analog signal, It is clear that we can create the signal xi [ n] = x[ n / L] for n = 0, ± L, ±2 L,... xa (t ), but instead the lowpass filtered version of but we need to fill in the unknown samples by an interpolation process can readily show that what we want is: xa (t ) the combined operations of lowpass filtering and downsampling are called decimation. ⎡ sin[π (nT ''− kT ) / T ] ⎤ ⎥ ⎣ [π ( nT ''− kT ) / T ] ⎦ equivalently with T '' = T / L, x[n] = xa ( nT ) we get xi [ n] = xa (nT '') = xi [ n] = xa (nT '') = 131 ∞ ∑ x (kT ) ⎢ k =−∞ a ∞ ⎡ sin[π (n − k ) / L] ⎤ ⎥ ⎣ [π ( n − k ) / L] ⎦ ∑ x (k ) ⎢ k =−∞ a which relates xi [ n] to x[ n] directly 132 22 Interpolation Interpolation implementing the previous equation by filtering the upsampled sequence ⎧ x [n / L] n = 0, ± L, ±2 L,... xu [ n] = ⎨ otherwise ⎩ 0 xu [ n] has the correct samples for n = 0, ± L, ±2 L,..., but it has zero-valued (a ) Plot of X ( e jΩT ) (b) Plot of X u (e jΩT '' ) showing double periodicity for L = 2, T '' = T / 2 samples in between (from the upsampling operation) The Fourier transform of xu [n] is simply: (c ) DTFT of desired signal with | Ω |≤ 2π FN ⎧(2 / T ) X a ( jΩ) X i ( e jΩT '' ) = ⎨ 0 2π FN <| Ω |≤ π / T '' ⎩ can obtain results of ( c) by applying ideal X u (e jω ) = X (e jω L ) X u (e j ΩT '' ) = X (e j ΩT '' L ) = X (e j ΩT ) lowpass filter with gain L (to restore amplitude) Thus X u (e jΩT '' ) is periodic with two periods, namely and cutoff frequency 2π FN = π / T , giving: with period 2π / L, due to upsampling) and 2π due to being a digital signal ⎧(1 / T '') X (e jω L ) 0 ≤| ω |< π / L X i ( e jω ) = ⎨ 0 π / L ≤| ω |≤ π ⎩ | ω |< π / L ⎧L H i ( e jω ) = ⎨ ⎩ 0 π / L ≤| ω |≤ π 133 134 SR Conversion by Non-Integer Factors Interpolation • T’=MT/L => convert rate by factor of M/L • need to interpolate by L, then decimate by M (why can’t it be done in the reverse order?) Original signal, x[n], at sampling period, T , is first upsampled to give signal xu [n] with sampling period T '' = T / L lowpass filter removes images of original spectrum giving: Lowpass Filter xi [ n] = xa (nT '') = xa ( nT / L) Interpolation LPF Decimation LPF need to combine specifications of both LPFs and implement in a single stage of lowpass filtering • can approximate almost any rate conversion with appropriate values of L and M 135 • for large values of L, or M, or both, can implement in stages, i.e., L=1024, use L1=32 followed by L2=32 136 Summary of DSP-Part II • digital filtering provides a convenient way of processing signals in the time and frequency domains • can approximate arbitrary spectral characteristics via either IIR or FIR filters, with various levels of approximation • can realize digital filters with a variety of structures, including direct forms, serial and parallel forms • once a digital signal has been obtain via appropriate sampling methods, its sampling rate can be changed digitally (either up or down) via appropriate filtering and decimation or interpolation 137 23