rresamp_rrrf

Variants: rresamp_cccf, rresamp_crcf, rresamp_rrrf

Rational rate resampler, implemented as a polyphase filterbank

Public Functions

rresamp_rrrf rresamp_rrrf_create(unsigned int _interp, unsigned int _decim, unsigned int _m, float * _h)
rresamp_rrrf rresamp_rrrf_create_kaiser(unsigned int _interp, unsigned int _decim, unsigned int _m, float _bw, float _as)
rresamp_rrrf rresamp_rrrf_create_prototype(int _type, unsigned int _interp, unsigned int _decim, unsigned int _m, float _beta)
rresamp_rrrf rresamp_rrrf_create_default(unsigned int _interp, unsigned int _decim)
rresamp_rrrf rresamp_rrrf_copy(rresamp_rrrf _q)
int rresamp_rrrf_destroy(rresamp_rrrf _q)
int rresamp_rrrf_print(rresamp_rrrf _q)
int rresamp_rrrf_reset(rresamp_rrrf _q)
int rresamp_rrrf_set_scale(rresamp_rrrf _q, float _scale)
int rresamp_rrrf_get_scale(rresamp_rrrf _q, float * _scale)
unsigned int rresamp_rrrf_get_delay(rresamp_rrrf _q)
unsigned int rresamp_rrrf_get_P(rresamp_rrrf _q)
unsigned int rresamp_rrrf_get_interp(rresamp_rrrf _q)
unsigned int rresamp_rrrf_get_Q(rresamp_rrrf _q)
unsigned int rresamp_rrrf_get_decim(rresamp_rrrf _q)
unsigned int rresamp_rrrf_get_block_len(rresamp_rrrf _q)
float rresamp_rrrf_get_rate(rresamp_rrrf _q)
int rresamp_rrrf_write(rresamp_rrrf _q, float * _buf)
int rresamp_rrrf_execute(rresamp_rrrf _q, float * _x, float * _y)
int rresamp_rrrf_execute_block(rresamp_rrrf _q, float * _x, unsigned int _n, float * _y)

Interfaces

rresamp_rrrf rresamp_rrrf_create(unsigned int _interp, unsigned int _decim, unsigned int _m, float * _h)

Create rational-rate resampler object from external coefficients to resample at an exact rate \(P/Q\) = interp/decim. Note that to preserve the input filter coefficients, the greatest common divisor (gcd) is not removed internally from interp and decim when this method is called.

  • _interp : interpolation factor, 0 < _interp
  • _decim : decimation factor, 0 < _decim
  • _m : filter semi-length (delay), 0 < _m
  • _h : filter coefficients, shape: (2*_interp*_m, 1)

rresamp_rrrf rresamp_rrrf_create_kaiser(unsigned int _interp, unsigned int _decim, unsigned int _m, float _bw, float _as)

the resampler is configured as an interpolator a value of 0.5 (critically filtered) or less is recommended. When the resampler is configured as a decimator, the critical bandwidth is 0.5*_interp/_decim. When _bw < 0, the object will use the appropriate critical bandwidth (interpolation or decimation), 0 < _bw <= 0.5

  • _interp :
  • _decim :
  • _m :
  • _bw :
  • _as : filter stop-band attenuation [dB], 0 < _as

rresamp_rrrf rresamp_rrrf_create_prototype(int _type, unsigned int _interp, unsigned int _decim, unsigned int _m, float _beta)

Create rational-rate resampler object from filter prototype to resample at an exact rate \(P/Q\) = interp/decim. Note that because the filter coefficients are computed internally here, the greatest common divisor (gcd) from _interp and _decim is internally removed to improve speed.

  • _type : filter type (e.g. LIQUID_FIRFILT_RCOS)
  • _interp : interpolation factor, 0 < _interp
  • _decim : decimation factor, 0 < _decim
  • _m : filter semi-length (delay), 0 < _m
  • _beta : excess bandwidth factor, 0 <= _beta <= 1

rresamp_rrrf rresamp_rrrf_create_default(unsigned int _interp, unsigned int _decim)

Create rational resampler object with a specified resampling rate of exactly interp/decim with default parameters. This is a simplified method to provide a basic resampler with a baseline set of parameters abstracting away some of the complexities with the filterbank design. The default parameters are m = 12 (filter semi-length), bw = 0.5 (filter bandwidth), and as = 60 dB (filter stop-band attenuation)

  • _interp : interpolation factor, 0 < _interp
  • _decim : decimation factor, 0 < _decim

rresamp_rrrf rresamp_rrrf_copy(rresamp_rrrf _q)

Copy object including all internal objects and state

int rresamp_rrrf_destroy(rresamp_rrrf _q)

Destroy resampler object, freeing all internal memory

int rresamp_rrrf_print(rresamp_rrrf _q)

Print resampler object internals to stdout

int rresamp_rrrf_reset(rresamp_rrrf _q)

Reset resampler object internals

int rresamp_rrrf_set_scale(rresamp_rrrf _q, float _scale)

Set output scaling for filter, default: \( 2 w \sqrt{P/Q} \)

  • _q : resampler object
  • _scale : scaling factor to apply to each output sample

int rresamp_rrrf_get_scale(rresamp_rrrf _q, float * _scale)

Get output scaling for filter

  • _q : resampler object
  • _scale : scaling factor to apply to each output sample

unsigned int rresamp_rrrf_get_delay(rresamp_rrrf _q)

Get resampler delay (filter semi-length \(m\))

unsigned int rresamp_rrrf_get_P(rresamp_rrrf _q)

Get original interpolation factor when object was created, before removing greatest common divisor

unsigned int rresamp_rrrf_get_interp(rresamp_rrrf _q)

Get internal interpolation factor of resampler, \(P\), after removing greatest common divisor

unsigned int rresamp_rrrf_get_Q(rresamp_rrrf _q)

Get original decimation factor \(Q\) when object was created before removing greatest common divisor

unsigned int rresamp_rrrf_get_decim(rresamp_rrrf _q)

Get internal decimation factor of resampler, \(Q\), after removing greatest common divisor

unsigned int rresamp_rrrf_get_block_len(rresamp_rrrf _q)

Get block length (e.g. greatest common divisor) between original interpolation rate \(P\) and decimation rate \(Q\) values

float rresamp_rrrf_get_rate(rresamp_rrrf _q)

Get rate of resampler, \(r = P/Q\) = interp/decim

int rresamp_rrrf_write(rresamp_rrrf _q, float * _buf)

Write \(Q\) input samples (after removing greatest common divisor) into buffer, but do not compute output. This effectively updates the internal state of the resampler.

  • _q : resamp object
  • _buf : input sample array, shape: (decim, 1)

int rresamp_rrrf_execute(rresamp_rrrf _q, float * _x, float * _y)

Execute rational-rate resampler on a block of input samples and store the resulting samples in the output array. Note that the size of the input and output buffers correspond to the values of the interpolation and decimation rates (\(P\) and \(Q\), respectively) passed when the object was created, even if they share a common divisor. Internally the rational resampler reduces \(P\) and \(Q\) by their greatest common denominator to reduce processing; however sometimes it is convenient to create the object based on expected output/input block sizes. This expectation is preserved. So if an object is created with an interpolation rate \(P=80\) and a decimation rate \(Q=72\), the object will internally set \(P=10\) and \(Q=9\) (with a g.c.d of 8); however when "execute" is called the resampler will still expect an input buffer of 72 and an output buffer of 80.

  • _q : resamp object
  • _x : input sample array, shape: (decim, 1)
  • _y : output sample array, shape: (interp, 1)

int rresamp_rrrf_execute_block(rresamp_rrrf _q, float * _x, unsigned int _n, float * _y)

Execute on a block of samples

  • _q : resamp object
  • _x : input sample array, shape: (decim*n, 1)
  • _n : block size
  • _y : output sample array, shape: (interp*n, 1)