Difference between revisions of "Polyphase Arbitrary Resampler"

From GNU Radio
Jump to: navigation, search
(Created page with "Category:Block Docs Category:Stub Docs This is the template for the "Page-per-block Docs". This first section should describe what the block...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
[[Category:Block Docs]]
 
[[Category:Block Docs]]
[[Category:Stub Docs]]
+
Polyphase filterbank arbitrary resampler.
This is the template for the [[:Category:Block_Docs|"Page-per-block Docs"]]. This first section should describe what the block does and how to use it, using however many paragraphs necessary. Note that the title of the wiki page should match the block's name in GRC, i.e. the one defined in the block's .grc file. Look at the [[FFT]] Block for a good example.
+
 
 +
This takes in a signal stream and performs arbitrary resampling. The resampling rate can be any real number r. The resampling is done by constructing N filters where N is the interpolation rate. We then calculate D where D = floor(N/r).
 +
 
 +
Using N and D, we can perform rational resampling where N/D is a rational number close to the input rate r where we have N filters and we cycle through them as a polyphase filterbank with a stride of D so that i+1 = (i + D) % N.
 +
 
 +
To get the arbitrary rate, we want to interpolate between two points. For each value out, we take an output from the current filter, i, and the next filter i+1 and then linearly interpolate between the two based on the real resampling rate we want.
 +
 
 +
The linear interpolation only provides us with an approximation to the real sampling rate specified. The error is a quantization error between the two filters we used as our interpolation points. To this end, the number of filters, N, used determines the quantization error; the larger N, the smaller the noise. You can design for a specified noise floor by setting the filter size (parameters filter_size). The size defaults to 32 filters, which is about as good as most implementations need.
 +
 
 +
The trick with designing this filter is in how to specify the taps of the prototype filter. Like the PFB interpolator, the taps are specified using the interpolated filter rate. In this case, that rate is the input sample rate multiplied by the number of filters in the filterbank, which is also the interpolation rate. All other values should be relative to this rate.
 +
 
 +
For example, for a 32-filter arbitrary resampler and using the GNU Radio's firdes utility to build the filter, we build a low-pass filter with a sampling rate of fs, a 3-dB bandwidth of BW and a transition bandwidth of TB. We can also specify the out-of-band attenuation to use, ATT, and the filter window function (a Blackman-harris window in this case). The first input is the gain of the filter, which we specify here as the interpolation rate (32).
 +
 
 +
    self._taps = filter.firdes.low_pass_2(32, 32*fs, BW, TB, attenuation_dB=ATT, window=filter.firdes.WIN_BLACKMAN_hARRIS)
 +
 
 +
The theory behind this block can be found in Chapter 7.5 of the following book:
 +
 
 +
    f. harris, "Multirate Signal Processing for Communication Systems", Upper Saddle River, NJ: Prentice Hall, Inc. 2004.
  
As this is a basic template, it's also in the [[:Category:Stub_Docs|"Stub Docs category"]]. Please improve it.
 
  
 
== Parameters ==
 
== Parameters ==
 
(''R''): <span class="plainlinks">[https://wiki.gnuradio.org/index.php/GNURadioCompanion#Variable_Controls ''Run-time adjustable'']</span>
 
(''R''): <span class="plainlinks">[https://wiki.gnuradio.org/index.php/GNURadioCompanion#Variable_Controls ''Run-time adjustable'']</span>
  
; Param 1 (''R'')
+
; Resampling Rate (''R'')
: Description of parameter, provide any tips or recommended values.  Note that the name of the parameter above should match the param's label that shows up in grc (e.g. Sample Rate).
+
: Specifies the resampling rate to use
 +
 
 +
; Taps (''R'')
 +
: (vector/list of floats) The prototype filter to populate the filterbank. The taps should be generated at the filter_size sampling rate.  
  
; Param 2
+
; Number of Filters
: blah blah blah
+
: (unsigned int) The number of filters in the filter bank. This is directly related to quantization noise introduced during the resampling.
 +
 
 +
; Stop-band Attenuation
 +
:
 +
 
 +
; Sample Delay
 +
:  
  
 
== Example Flowgraph ==
 
== Example Flowgraph ==
Line 27: Line 52:
  
 
; Public header files
 
; Public header files
: [https://github.com/gnuradio/gnuradio TODO]
+
: [https://github.com/gnuradio/gnuradio/blob/master/gr-filter/include/gnuradio/filter/pfb_arb_resampler_ccc.h Complex input and taps]
 +
: [https://github.com/gnuradio/gnuradio/blob/master/gr-filter/include/gnuradio/filter/pfb_arb_resampler_ccf.h Complex input and float taps]
 +
: [https://github.com/gnuradio/gnuradio/blob/master/gr-filter/include/gnuradio/filter/pfb_arb_resampler_fff.h Float input and taps]
 +
: [https://github.com/gnuradio/gnuradio/blob/master/gr-filter/include/gnuradio/filter/pfb_arb_resampler.h Base]
  
 
; Block definition
 
; Block definition
: [https://github.com/gnuradio/gnuradio TODO]
+
: [https://github.com/gnuradio/gnuradio/blob/master/gr-filter/grc/filter_pfb_arb_resampler.block.yml]

Latest revision as of 15:40, 11 September 2019

Polyphase filterbank arbitrary resampler.

This takes in a signal stream and performs arbitrary resampling. The resampling rate can be any real number r. The resampling is done by constructing N filters where N is the interpolation rate. We then calculate D where D = floor(N/r).

Using N and D, we can perform rational resampling where N/D is a rational number close to the input rate r where we have N filters and we cycle through them as a polyphase filterbank with a stride of D so that i+1 = (i + D) % N.

To get the arbitrary rate, we want to interpolate between two points. For each value out, we take an output from the current filter, i, and the next filter i+1 and then linearly interpolate between the two based on the real resampling rate we want.

The linear interpolation only provides us with an approximation to the real sampling rate specified. The error is a quantization error between the two filters we used as our interpolation points. To this end, the number of filters, N, used determines the quantization error; the larger N, the smaller the noise. You can design for a specified noise floor by setting the filter size (parameters filter_size). The size defaults to 32 filters, which is about as good as most implementations need.

The trick with designing this filter is in how to specify the taps of the prototype filter. Like the PFB interpolator, the taps are specified using the interpolated filter rate. In this case, that rate is the input sample rate multiplied by the number of filters in the filterbank, which is also the interpolation rate. All other values should be relative to this rate.

For example, for a 32-filter arbitrary resampler and using the GNU Radio's firdes utility to build the filter, we build a low-pass filter with a sampling rate of fs, a 3-dB bandwidth of BW and a transition bandwidth of TB. We can also specify the out-of-band attenuation to use, ATT, and the filter window function (a Blackman-harris window in this case). The first input is the gain of the filter, which we specify here as the interpolation rate (32).

    self._taps = filter.firdes.low_pass_2(32, 32*fs, BW, TB, attenuation_dB=ATT, window=filter.firdes.WIN_BLACKMAN_hARRIS)

The theory behind this block can be found in Chapter 7.5 of the following book:

    f. harris, "Multirate Signal Processing for Communication Systems", Upper Saddle River, NJ: Prentice Hall, Inc. 2004.


Parameters

(R): Run-time adjustable

Resampling Rate (R)
Specifies the resampling rate to use
Taps (R)
(vector/list of floats) The prototype filter to populate the filterbank. The taps should be generated at the filter_size sampling rate.
Number of Filters
(unsigned int) The number of filters in the filter bank. This is directly related to quantization noise introduced during the resampling.
Stop-band Attenuation
Sample Delay

Example Flowgraph

Insert description of flowgraph here, then show a screenshot of the flowgraph and the output if there is an interesting GUI. Currently we have no standard method of uploading the actual flowgraph to the wiki or git repo, unfortunately. The plan is to have an example flowgraph showing how the block might be used, for every block, and the flowgraphs will live in the git repo.

Source Files

C++ files
TODO
Header files
TODO
Public header files
Complex input and taps
Complex input and float taps
Float input and taps
Base
Block definition
[1]