Upsampling and Downsampling
Total Page:16
File Type:pdf, Size:1020Kb
Upsampling and Downsampling MUS421/EE367B Lecture 9 Multirate, Polyphase, and Wavelet Filter Banks For the DFT, we have the Stretch Theorem (Repeat Theorem) which relates upsampling (“stretch”) to Julius O. Smith III ([email protected]) , Scott Levine and Harvey Thornburg spectral copies (“images”) in the DFT context (length N Center for Computer Research in Music and Acoustics (CCRMA) signals and spectra). Department of Music, Stanford University Stanford, California 94305 We also have the Downsampling Theorem (Aliasing Theorem) for DFTs which relates downsampling to June 2, 2020 aliasing for finite length signals and spectra. We now look at these relationships in the DTFT case. Outline Thus, the signal length N is extended to infinity, and the Upsampling and Downsampling spectrum becomes defined continuously over the unit • circle in the z plane. Polyphase Filtering • Critically Sampled Perfect Reconstruction Filter Banks • Perfect Reconstruction Filter Banks • Paraunitary (Orthogonal) Filter Banks • Multirate Analysis of Filter Banks • DFT Filter Banks • Cosine Modulated Filter Banks • Wavelet Filter Banks • 1 2 Upsampling (Stretch) Downsampling (Decimation) Diagram: Diagram: • • xN y xN y Basic Idea: To upsample by the integer factor N, Basic Idea: Take every N th sample. • • insert N 1 zeros between x[n] and x[n +1] for all n. Downsample − Time Domain: y = N (x), i.e., Time Domain: y = Stretch (x), i.e., • • N y[n]= x[Nn], n Z ∈ x[n/N],N divides n y[n]= Frequency Domain: Y = AliasN (X), i.e., ( 0, otherwise. • N 1 1 − 1 jm2π Frequency Domain: Y = Repeat (X), i.e., Y (z)= X z N e− N , z C N N ∈ • m=0 Y (z)= X(zN ), z C X ∈ Thus, the frequency axis is expanded by factor N, Plugging in z = ejω, we see that the spectrum on wrapping N times around the unit circle and adding. • [ π,π) contracts by the factor N, and N images For N =2, two partial spectra are summed, as appear− around the unit circle. For N =2, this is indicated below: depicted below: 1/Ν −π π −π π −π π −π π 3 4 Twiddle Factor Notation Proof of Downsampling/Aliasing Relationship 1 k Downsample Alias In FFT terminology, W denotes the kth “twiddle N (x) N (X) N ↔ N factor,” where WN is a primitive Nth root of unity: N 1 ∆ j2π/N − WN = e− . or x(nN) 1 X ej2πm/N z1/N ↔ N m=0 The aliasing expression can therefore be written as X N 1 From the DFT case, we know this is true when x and X 1 − 1 jm2π Y (z) = X z N e− N , z C are each complex sequences of length N , in which case y N ∈ s m=0 and Y are length N /N. Thus, X s N 1 1 − N 1 m 1/N 1 − 2π Ns = X(WN z ). x(nN) Y (ω N)= X ω + m , k 0, N ↔ k N k N ∈ N m=0 m=0 X X where we have chosen to keep frequency samples ωk in terms of the original frequency axis prior to downsampling, i.e., ωk =2πk/Ns for both X and Y . This choice allows us to easily take the limit as N s →∞ by simply replacing ωk by ω: N 1 1 − 2π 2π x(nN) Y (ωN)= X ω + m , ω 0, ↔ N N ∈ N m=0 X Replacing ω by ω′ = ωN and converting to z-transform notation X(z) instead of Fourier transform notation X(ω), with z = ejω′, yields the final result. 5 6 Example: Downsampling by 2 Filtering and Downsampling As an example, when N =2, y[n]= x[2n], and Because downsampling by N will cause aliasing for any ∆ j2π/2 (since W2 = e− = 1) frequencies in the original signal above ω > π/N, the − input signal must first be lowpass filtered.| | 1 Y (z) = X W 0z1/2 + X W 1z1/2 2 2 2 h i H(z) N 1 j2π0/2 1/2 j2π1/2 1/2 = X e− z + X e− z 2 1 h i = X z1/2 + X z1/2 The lowpass filter h[n] is an FIR filter of length M with a 2 − cutoff frequency of π/N. Let’s draw the FIR filter h in 1 h i = [Stretch (X)+ Stretch (Shift (X))] direct form: 2 2 2 π x[n] h(0) y[n] N Example: Upsampling by 2 z-1 h(1) z-1 When N =2, y =[x0, 0,x1, 0,...], and h(2) 2 Y (z)= X(z )= Repeat2(X) -1 z h(M-1) 7 8 Note that we do not need N 1 out of every N Interpretation: • − • samples due to the N :1 downsampler. – serial to parallel conversion Commute the downsampler through the adders inside from a stream of scalar samples x[n] • the FIR filter: to a sequence of length M buffers every N samples, followed by x[n] h(0) y[n] N – a dot product of each buffer with h(0 : M 1) − z-1 h(1) For N = M, the overall system is equivalent to a N • round-robin demultiplexor, with a different gain h(m) z-1 for each output, followed by an M-sample summer h(2) N which adds the “de-interleaved” signals together: x[n] h(0) -1 z h(M-1) N h(1) Length M y[n] running sum The multipliers are now running at 1/N times the • sampling frequency of the input signal, x[n]. This reduces the computation requirements by 1/N. The downsampler outputs are called polyphase signals h(M 1) • − This is a summed polyphase filter bank in which each • “subphase filter” is a constant scale factor h(m). 9 10 Polyphase Processing (Anti-Aliasing Filter) Polyphase Filtering In multirate signal processing, it is often fruitful to split a Subphase 0, • signal or filter into its polyphase components. x(nN) ∞ =[x ,x ,x ,...] |n=0 0 N 2N Let’s look at the case N =2: is scaled by h(0) Begin with the filter Subphase 1, • • ∞ n x(nN + 1) ∞ =[x1,xN+1,x2N+1,...] H(z)= h(n)z |n=0 − n= is scaled by h(1) X−∞ Separate the even and odd terms: • •··· Subphase m, ∞ 2n 1 ∞ 2n • H(z)= h(2n)z− + z− h(2n + 1)z− n= n= x(nN + m) ∞ =[x ,x ,x ,...] |n=0 m N+m 2N+m X−∞ X−∞ Define the polyphase component filters: is scaled by h(m). • ∞ n E0(z) = h(2n)z− n= X−∞ ∞ n E1(z) = h(2n + 1)z− n= X−∞ E0(z) and E1(z) are the polyphase components of the polyphase decomposition of H(z) for N =2. 11 12 Now write H(z) as the sum of the odd and even e0 • e1 terms: e2 2 1 2 -6-5 -4 -3 -2 -1 0 1 2 3 4 5 6 H(z)= E0(z )+ z− E1(z ) Example Polyphase Decomposition into 2 Channels The polyphase decomposition into N channels is given by N 1 − H(z)= z lE (zN ) As a simple example, consider − l l=0 1 2 3 X H(z)=1+2z− +3z− +4z− . where the subphase filters are Then the even and odd terms are, respectively, ∞ n 1 El(z)= el(n)z− , l =0, 1,...,N 1, E0(z) = 1+3z− − n= 1 X−∞ E1(z) = 2+4z− with And so H(z) can be written as the sum of the following ∆ el(n) = h(Nn + l). (lth subphase filter) two polyphase components: 2 2 The signal e (n) can be obtained by passing h(n) E0(z ) = 1+3z− l 1 2 1 3 through an advance of l samples, followed by z− E1(z )=2z− +4z− downsampling by the factor N: Polyphase Decomposition into N Channels h(n) el(n) zl N For the general case of arbitrary N, the basic idea is to decompose x[n] into its periodically interleaved subsequences: 13 14 Three-Channel Polyphase Decomposition and Filtering and Downsampling, Revisited Reconstruction As another example of polyphase filtering, we return to For N =3, we have the following system diagram: the previous example about downsampling and filtering. 1 3 E0(z) 3 1 This time, E (z) 1 H(z) z3 1 3 z− H(z) Let the FIR lowpass filter h[n] be of length • Z 2 E (z) 2 M = LN, L z 3 2 3 z− ∈ The N polyphase filters, el[n], are each length L. Type II Polyphase Decomposition • N 1 N 2 N Recall, H(z)= E0(z )+ z− E1(z )+ z− E2(z )+ • (N 1) N The preceding polyphase decomposition of H(z) into N + z− − EN 1(z ): ··· − channels N 1 x[n] y[n] E (zN) N − l N 0 H(z)= z− El(z ) z-1 l=0 X E (zN) can be termed a “Type I” polyphase decomposition. 1 z-1 In the “Type II”, or reverse polyphase decomposition, the E (zN) powers of z progress in the opposite direction: 2 N 1 − (N l 1) N H(z)= z− − − Rl(z ). -1 l=0 z N X EM-1(z ) We will see later that we need Type I for analysis filters and Type II for synthesis filters in a “perfect reconstruction filter bank”. 15 16 Now commute the N :1 downsampler through the Multirate Noble Identities • adders and through the upsampled polyphase filters, N El(z ): Downsamplers and upsamplers are linear, time-varying x[n] y[n] operators.