6 Multirate signal processing Motivation for multirate signal processing: high sampling rate in digital domain distributes the quantization noise power over a wider spectrum. • less bits are needed in the ADC • less noise in the interesting band • trading word length against sampling rate is possible Basic concepts necessary for understanding multirate processing structures and attractive filter designs that provide for computational benefits such as filter banks, CIC and Farrow filters. • Downsampling/Upsampling • Noble identities • Polyphase representation 1 6.1 Downsampling Downsampling = Decimation = reduction of sampling rate. The stages of decimation: Explanation: • the signal (sampling rate Fs ) is first low pass filtered using a digital filter • important: after the filtering the sampling rate is still Fs • decimation by M : every M th sample is selected from the signal • the final sampling rate is Fs /M • the original interesting band was Fs /(2M ) At this point we realize that the filter is needed to prevent the propagation of input signal frequencies that exceed the new Nyquist frequency Fs /(2M ). Otherwise aliasing occurs after downsampling. (Can you illustrate why?) 2 Operations in the time domain: example on downsampling by factor 3. 3 The process in the frequency domain: example on downsampling by factor 3. The dashed lines illustrate imaging frequencies. 4 6.2 Upsampling Upsampling = Interpolation = increasing the sampling rate; signal reconstruction by interpolating additional samples. The stages of interpolation: Explanation: • the signal sample rate Fs is increased by L by adding L − 1 zeros between each two original samples; the original samples and their timings do not change • the new sample rate is LFs • the resulting signal is low pass filtered to eliminate imaging components • notice: the original interesting band Fs /2 is still the same What could be the eventual word length effects from upsampling: the energy of the original samples is distributed to the new samples. 5 The process in the time domain: example on upsampling by factor 3. • the energy of samples is spread to L times the original samples • gain of L can be used for compensation 6 The process in the frequency domain: example on upsampling by factor 3, the dashed lines illustrate imaging frequencies . 7 6.3 Interpolation by a rational factor In many cases sampling rate conversion by a non-integer factor is needed. The classic example (now hopelessly outdated; DAT should probably be changed to 24 bit 96 kHz audio that would not change much in the presentation): • the sample rates of CD and DAT audio are 44.1 kHz and 48 kHz, respectively In practice, the conversion by factor L/M between audio formats is done by 1. interpolation of the input signal by L; anti-imaging filtering by H1 (z) 2. and then decimating by factor M ; anti-aliasing-filtering by H2 (z) The process is shown in the figure below. Important: interpolation must be done before decimation as otherwise desired frequency components could be lost. 8 The classic example continues: the conversion factor from CD to DAT is 48/44.1, • L/M = 160/147 (with the 96kHz format L/M = 320/147) • in other words, the CD signal sample rate is first umpsampled to 160*44.1kHz = 7056 kHz (to 14102 kHz with 96kHz) • then it needs to be downsampled by 147 to 48 kHz. Important observation: the cascaded low pass filters h1 (k) and h2 (k) have the same sample rate, and can be combined: The passband specifications of the filters h1 (k) and h2 (k) are the same if the interesting band is not touched in the process. 9 Let us consider interpolation by a rational factor 3/2 • we first upsample by factor 3 and then downsample by 2 • the process in time domain below 10 The process in the frequency domain below: initially the sample rate of x(n) is 2 kHz 11 6.4 Efficient implementations Efficient designs for many DSP tasks can be derived via multirate solutions, such as • noble identities • polyphase representation • filter banks two channel filter banks: perfect reconstruction, QMF some M-channel filter banks (tree and parallel structured: complex and cosine modulated) • To avoid aliasing, before down-sampling, the bandwidth of the signal should be limited to the Nyquist rate of the reduced sampling frequency • To get rid of the spectral images, after up-sampling, the band width of the increased sample rate signal should be limited to the original Nyquist rate These solutions are undesirable, as the filters in both cases operate • at higher of the sampling rates - higher computational costs • steeper transition bands - longer filters, even higher computational cost Fortunately, computationally efficient multirate techniques exist! 12 6.5 Noble identities Noble identities show us ways for changing the order of operations in signal flow graphs, when a downsampling or upsampling operation appears in the graph. When a down- or up-sampling operations are employed; then • in down-sampling the anti-alias filtering can be done at sub-sampled rate • in up-sampling the anti-imaging filtering can be done at the lower rate There are total of six identities. First three identities are related to the downsampling operation. The first identity says that if multiplication and/or addition operations are followed by a downsampling operation as illustrated in Fig.1a, then the order of these operations can be changed (Fig.1b). We observe that it is wasteful to down-sample after the arithmetic operations as only every 1/M th result is kept: it is better to reduce the sample rate first. Figure 1: Noble identity 1. The structures shown give the same output, but the rate of arithmetic operations in case (b) is M times lower. The second identity considers delaying of signals. Delay of M units before downsampling is equal to a one unit delay after downsampling (Fig.2). Implementation of M -unit delay requires FIFO of M storage units, and thus application of the second identity can lead to reduced memory costs. The third identity shown in Fig. 3 combines the ideas from the identities 1 and 2. For example, if the output of a system having a transfer function A(z) = a0 + a1 z −2 + a2 z −4 is downsampled by 2, we can do the downsampling first (Noble identity 1) and then filter with the system B(z) = a0 + a1 z −1 + a2 z −2 . We notice that A(z) = B(z 2 ) The identities 4-6 are related to the upsampling operation, and they are explained in Figs. 4-6. 13 Figure 2: Noble identity 2. Figure 3: Noble identity 3. Noble identity 4 reduces the number of arithmetic operations. Figure 4: Noble identity 4. Upsamplings in (a) inserts zeros to the signal, but it is wasteful to multiply and add those zeros. Those operations are avoided in (b). Up-sampling by factor L inserts zeros into the input sequences, and multiplying them is wasteful. Up-sampling later avoids this stupidity and produces an equivalent result. Noble identity 5 saves memory by eliminating the need to store zeros in the delay line. Noble identity 6 is a combination of identities 4 and 5 and avoids both the processing of samples to be discarded and storing of zeros. 14 Figure 5: Noble identity 5. If a structure shown in (a) appears in a signal flow graph, it can be replaced by a memory-saving structure (b). Figure 6: Noble identity 6. The structure shown in (b) avoids processing of zeros. To summarize, the preference is to perform arithmetic operations at a lower sample rate, which leads to lower computational complexity and savings in memory. Noble identities show us ways to achieve this goal. 15 6.6 Polyphase representation Polyphase filters or filter banks are not filter types but filter implementations. These implementations take advantage of zero coefficients in the filter to cut the computational cost. Due to their extremely attractive properties, the algorithm and system designers try to aim at polyphase formulations of filltering solutions, favoring • filters that have zeros in the impulse response at regular intervals (Nyquist, half band, third band etc M th band filters that are special multirate FIR filters. Their every M th coefficient is zero, except for the middle coefficient) • and above all: formulating the filters in polyphase form The basic formulation of a digital FIR filter in the z-plane can be derived by starting from H(z) = M−1 X h(k)z −k = h(0) + h(1)z −1 + ... + h(N − 1)z N −1 (1) k=0 This can be written in an equivalent polyphase form (for simplicity, M = LN where L is the length of each polyphase component Ek (z)) H(z) = N −1 X z −k Ek (z N ) (2) z −k Ek (z N ) (3) k=0 In the polyphase form of a digital filter H(z) = N −1 X k=0 The polyphase components Ek (z) correspond to time domain sequences ek (n) = h(nN + k), 0 ≤ k ≤ L − 1 FIR and IIR filters can be written into the polyphase form. 16 (4) Looking at the formulation, we realize that it matches the potential of the noble identities. In the polyphase formulations H(z) = N −1 X z −k Ek (z N ) (5) k=0 the polynomial Ek (z) are the z-transforms of sequences ek (n) ek (n) = h(nN + k), 0 ≤ k ≤ L − 1 (6) This means that: • we have grouped of the impulse response h(n) into N subsequences ek (n) • the k:th subsequence ek (n) is obtained from the original impulse response h(n) by starting at h(n+k) and then down-sampling by factor N • we have down-sampled the impulse response, and not the input sequence Below we see an outcome: polyphase formulation of a filter (non-multirate). Odd and even samples from a sequence can be fed in parallel to a filter at the intervals of two sample times = the operating frequency is cut. Notice that there has been no sample rate change. 17 Let us consider the following simple FIR filter H(z) = 1 + 2z −1 + 3z −2 + 4z −3 (7) The realization of this filter can be presented in transversal form (tapped delay line) and filter can be expressed as two polyphase components (N = 2) H(z) = z −0 (1 + 3z −2 ) + z −1 (2 + 4z −2 ) = E0 (z 2 ) + z −1 E1 (z 2 ) = 1 X z −k Ek (z 2 ) k=0 We see that E0 and E1 contain the odd and even coefficients of the filter, respectively (E0 (z 2 )) = 1, 0, 3 and z −1 (E1 (z 2 )) = 2, 0, 4 18 (8) The same filter with four polyphase components (N=4) can be written as H(z) = 1 + 2z −1 + 3z −2 + 4z −3 = 1z −0 +z −1 (2z −0 )+z −2 (3z −0 )+z −3 (4z −0 )= 3 X z −k Ek (z 4 ) (9) k=0 Understanding the idea of reformulating the filter to exploit noble identities is easier by considering a little longer filter H(z) = 1 + 2z −1 + 3z −2 + 4z −3 + 5z −4 + 6z −5 + 7z −6 (10) H(z) = E0 (z 4 ) + z −1 E1 (z 4 ) + z −2 E2 (z 4 ) + z −3 E3 (z 4 ) = (1 + 5z −4 ) + z −1 (2 + 6z −4 ) + z −2 (3 + 7z −4 ) + z −3 (4z −4 ) (11) The polyphase form this can be written as We see that the first three polyphase components are filters that contain several zeros, as seen below for the very first one (E0 ((1 + 5z −4 ))) E0 (z 4 ) = (1 + 5z −4 ) = 1z −0 + 0z −1 + 0z −2 + 0z −3 + 5z −4 (12) E0 (z) = (1 + 5z −1 ) (13) and The decomposition can also be done in a hierarchical fashion, by dividing h(n) first into two N/2 long filters that are in turn decomposed into N/4 long ones, etc. 19 6.6.1 Polyphase representation examples The polyphase decomposition IIR-filters is also possible. For example, the IIR filter 1 1 − bz −1 (14) 1 bz −1 + 1 − b2 z −2 1 − b2 z −2 (15) H(z) = can easily be written into form H(z) = so its polyphase components are E0 (z 2 ) = 1 b and E1 (z 2 ) = 1 − b2 z −1 1 − b2 z −1 (16) As a more realistic example consider a 5th order Butterworth low-pass filter with 3dB point of at π/2. H(z) = 0.0528 + 0.2639z −1 + 0.5279z −2 + 0.5279z −3 + 0.2639z −4 + 0.0528z −5 (1 + 0.1056z −2)(1 + 0.5279z −2) (17) This can be factored (e.g., using the method of residues) into H(z) = E0 (z 2 ) + z −1 E1 (z 2 ) = −2 1 0.1056 + z −2 −1 0.5279 + z [ + z ] 2 1 + 0.1056z −2 1 + 0.5279z −2 The blocks of this this decomposition are all-pass filters with different phase responses. 20 (18) 6.6.2 Efficient down and up-sampling examples We need to down-sample a signal by M with a N=9 FIR antialiasing filter below: H(z) = 8 X h(n)z −n (19) n=0 The decomposition of the filter into four polyphase components is H(z) = E0 (z 4 ) + z −1 E1 (z 4 ) + z −2 E2 (z 4 ) + z −3 E3 (z 4 ) (20) in which the polyphase components are E0 (z) = h(0) + h(4)z −1 + h(8)z −2 E1 (z) = h(1) + h(5)z −1 E2 (z) = h(2) + h(6)z −1 E3 (z) = h(3) + h(7)z −1 Notice, that these are now presented in form Ek (z) in which the zero coefficients are been eliminated; the total number of coefficients is still the same as in the original filter. The computational benefits can come only from lower rate operation. 21 The direct implementation of the polyphase decomposition of the filter H(z) = E0 (z 4 ) + z −1 E1 (z 4 ) + z −2 E2 (z 4 ) + z −3 E3 (z 4 ) (21) results in the structure (here we have already used noble identity 1 to cut the additions): This implementation wastes memory, because each of the polyphase component Ek (z 4 ) has a delay line, for instance E0 (z 4 ) = h(0) + h(4)z −4 + h(8)z −8 = h(0) + 0z −1 + 0z −2 + 0z −3 + h(4)z −4 + ... + h(8)z −8 Although most of the multipliers are zero, we still need memory for every unit delay. 22 (22) We now employ the noble identity with the polyphase components and change our structure into a format that performs exactly the same filtering with less memory and computational resources: The arithmetic operations are reduced to about 1/4th • the down-sampler is before the filters making them operate at lower rate • the memory requirements are also reduced approximately to 1/4h the delay lines of every polyphase component is now shorter: Ek (z) vs Ek (z 4 ) 23 In up-sampling the imaging components need to be suppressed after sample rate change See below for a linear phase FIR filter of length N=9 to be used in up-sampling by L=3 H(z) = h(0) + h(1)z −1 + h(2)z −2 + h(3)z −3 + h(4)z −4 + h(3)z −5 + h(2)z −6 + h(1)z −7 + h(0)z −8 This can be written in polyphase form H(z) = 2 X z −k Ek (z 3 ) (23) (24) k=0 Where the three polyphase components are E0 (z) = h(0) + h(3)z −1 + h(2)z −2 , E1 (z) = h(1) + h(4)z −1 + h(1)z −2 and E2 (z) = h(2) + h(3)z −1 + h(0)z −2 We notice that E1 (z) is symmetric, while E0 (z) and E2 (z) are mirror images of each other • these characteristics can be efficiently exploited in implementations • as well as the benefits from polyphase formulation 24 (25) The noble identity to change the order of the filtering in up-sampling is. Below we see the changes in the actual filter structure: (1) long delay lines and higher rate filters and (2) with short delay lines and filtering at lower rate In the above solutions the polyphase decomposition does not provide any extra advantage compared to the noble identity based solution • as a final operation, only the sum of the filtered polyphase components is used • in filter bank applications the polyphase decomposition is useful 25