markman的笔记 https://bbs.21ic.com/?86789 [收藏] [复制] [RSS]

日志

多速率滤波器Part 4

已有 836 次阅读2005-11-15 19:35 |个人分类:数字滤波器专题|系统分类:网上好文

 Part 4: Resampling

4.1 Basics
4.1.1 What is "resampling"?
"Resampling" means combining interpolation and decimation to change the sampling rate by a rational factor.

4.1.2 Why resample?
Resampling is usually done to interface two systems which have different sampling rates. If the ratio of two system's rates happens to be an integer, decimation or interpolation can be used to change the sampling rate (depending on whether the rate is being decreased or increased); otherwise, interpolation and decimation must be used together to change the rate

A practical and well-known example results from the fact that professional audio equipment uses a sampling rate of 48 kHz, but consumer audio equipment uses a rate of 44.1 kHz. Therefore, to transfer music from a professional recording tape to a CD, the sampling rate must be changed by a factor of:

44100 / 48000=441 / 480=147 / 160

There are no common factors in 147 and 160, so we must stop factoring at that point. Therefore, in this example, we would interpolate by a factor of 147 then decimate by a factor of 160.

4.1.3 What is the "resampling factor"?
The interpolation factor is simply the ratio of the output rate to the input rate. Given that the interpolation factor is L and the decimation factor is M, the resampling factor is L / M. In the above example, the resampling factor is 147 / 160=0.91875

4.1.4 Is there a restriction on the resampling factor I can use?
Yes. As always, the Nyquist criteria must be met relative to the resulting output sampling rate, or aliasing will result. In other words, the output rate cannot be less than twice the highest frequency (of interest) of the input signal.

4.1.5 When resampling, do I always need to a filter?
Yes. Since resampling includes interpolation, you need an interpolation filter. Otherwise, the images created by the zero-stuffing part of interpolation will remain, and the interpolated signal will not be "the same" as the original.

Likewise, since resampling includes decimation, you seemingly need a decimation filter. Or do you? Since the interpolation filter is in-line with the decimation filter, you could just combine the two filters by convolving their coefficients into a single filter to use for decimation. Better yet, since both are lowpass filters, just use whichever filter has the lowest cutoff frequency as the interpolation filter.

4.1.6 How do I design the resampling filter?
As hinted at above:

Determine the cutoff frequency of the decimation filter (as explained in Part 2: Decimation.)
Determine the cutoff frequency of the interpolation filter (as explained in Part 3: Interpolation)
Use the lower of the two cutoff frequencies to design the resampling filter.
4.2 Multistage
4.2.1 Can I resample in multiple stages?
Yes, but there are a couple of restrictions:

If either the interpolation or decimation factors are prime numbers, you won't be able to decompose those parts of the resampler into stages.
You must preserve the Nyquist criteria at each stage or else aliasing will result. That is, no stage can have an output rate which is less than twice the highest frequency of interest.
4.2.2 Cool. But why bother with all that?
Just as with interpolation and decimation, the computational and/or memory requirements of the resampling filtering can sometimes be greatly reduced by using multiple stages.

4.3 Implementation
4.3.1 How do I implement resampling?
The straight-forward implementation of resampling is to do interpolation by a factor of L, then decimation by a factor of M. (You must do it in that order; otherwise, the decimator would remove part of the desired signal--which the interpolator could not restore.)

4.3.2 Is that straight-forward implementation efficient?
No. The problem is that for resampling factors close to 1.0, the interpolation factor can be quite large. For example, in the case described above of changing from the sampling rate from 48 kHz to 44.1 kHz, the ratio is only 0.91875, yet the interpolation factor is 147!

Also, you are filtering the signal twice: once in the interpolator and once in the decimator. However, one of the filters has a larger bandwidth than the other, so the larger-bandwidth filter is redundant.

4.3.3 So what's the cure?
Just combine the computational and memory advantages that FIR interpolator and decimator implementations can provide. (If you don't already understand those, be sure to read and understand Part 2: Decimation, and Part 3: Interpolation before continuing.)

First, let's briefly review what makes FIR interpolation and decimation efficient:

When interpolating by a factor of L, you only have to actually calculate 1/L of the FIR taps per interpolator output.
When decimating by a factor of M, you only have to calculate one output for every M decimator inputs.
So, combining these ideas, we will calculate only the outputs we actually need, using only a subset of the interpolation coefficients to calculate each output. That makes it possible to efficiently implement even FIR resamplers which have large interpolation and/or decimation factors.

The tricky part is figuring out which polyphase filters to apply to which inputs, to calculate the desired outputs, as a function of L and M. There are various ways of doing that, but they're all beyond our scope here.

4.3.4 Where can I get source code to implement a FIR decimator in C?
Right here. Our "multirate_algs" package includes a resampling routine. You can download it from dspGuru's DSP Algorithm Library.

4.3.5 How do I test a FIR resampler?
The most obvious method is to put in a sine whose frequency is within the resampler's passband. If an undistorted sine comes out, that's a good sign. Note, however, that there will typically be a "ramp up" at the beginning of the sine, due to the filter's delay line filling with samples. Therefore, if you analyze the spectral content of the sine, be sure to skip past the ramp-up portion.
Depending on the resampling factor, resampling can be thought of as a general case of other types of multirate filtering. It can be:
Interpolation: The interpolation factor, L, is greater than one, and the decimation factor, M, is one.
Decimation: The interpolation factor, L, is one, but the decimation factor, M, is greater than one.
"Ordinary" Filtering: The interpolation and decimation factors, L and M, are both one.

Therefore, if you successfully test it with all these cases (using the methods appropriate for each case), it probably is correct.


路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)