New Interface for pfb_arb_resampler_ccf

It seems like there are more and more reasons to use the arbitrary resampler, and it has had a rather difficult interface. Until now, as the title of this post might suggest.

In the previous interface, you had to specify your own filter taps to the resampler block, which had this interface:

    resamp = blks2.pfb_arb_resampler_ccf(rate, taps, flt_size=32)

The rate and taps were required arguments, where rate sets the resampling rate of the filter and taps is a vector of filter taps. You could also specify the number of filters to use in the filterbank if you really wanted to. It defaults to 32, which gives excellent performance with very little quantization error. Increasing this to 64 or 128 provides very little benefit here (and powers of 2 are not necessary; I just tend to think this way).

The problem is, you had to know how to create the taps for your resampler, and often, you are not interested in actually filtering the signal. You just want to change its rate. Even still, you had to design a set of filter taps, and this is not necessarily intuitive if you don't know how the resampler works. In fact, to get a lowpass filter of bandwidth B, you would do something like:

    taps = gr.firdes.low_pass(32, 32*fs, B, W)

Where W is the transition band of the filter. So why is the gain 32 and the sample rate 32*fs? Simple, because that's the rate that the filter runs at, of course. What, you didn't know that? That's what I mean about needed to know how the filter works. And actually, that 32 should really be flt_size if you are using something besides the default.

See, the filter really runs at an interpolating rate of the filter size (e.g., 32), so you have to design the filter prototype thinking this way. If you've never worked with these kinds of filters before at all, even this might not have made much sense to you.

So the new way you can use the resampler is to basically ignore that it's a filter at all. You can just give it a resampling rate and let it go at that. Inside, the block will design a filter that covers the bandwidth of the input signal, and that's all. You can still specify the number of filters to use with flt_size, and the out-of-band attenuation with atten. By default, flt_size=32 and atten=80. There's probably very few times you'll want to change these values. So the new interface is:

    resamp = blks2.pfb_arb_resampler_ccf(rate, taps=None, flt_size=32, atten=80)

You can play with the new interface by looking at gnuradio-examples/python/pfb/ in the git:master branch. This change should make it into the next version release (3.3.1) of GNU Radio.

As a note, the filter design is done in the Python world, which is why you have to use the blks2 wrapper version of the resampler and not gr.pfb_arb_resampler_ccf. Eventually, the filter design might make its way into the C++ code, but it's just so much easier to do this stuff in Python that I just put it there.