Multi-Stage Arbitrary Resampler (msresamp)

API Keywords: msresamp resample

The msresamp object implements a multi-stage arbitrary resampler use for efficient interpolation and decimation. By using a combination of half-band interpolators/decimators ([ref:section-filter-resamp2] ) and an arbitrary resampler ([ref:section-filter-resamp] ) the msresamp object can efficiently realize any arbitrary resampling rate desired.





Figure [fig-filter-msresamp_diagram]. msresamp (multi-stage resampler) block diagram showing both interpolation and decimation modes

[ref:fig-filter-msresamp_diagram] depicts how the multi-stage resampler operates for both interpolation and decimation modes. The half-band resamplers efficiently handle the majority of the work, leaving the arbitrary resampler to operate at the lowest sample rate possible.

Listed below is the full interface to the msresamp family of objects. While each method is listed for msresamp_crcf , the same functionality applies to msresamp_rrrf and msresamp_cccf .

  • msresamp_crcf_create(r,As) creates a msresamp object with a resampling rate \(r\) and a target stop-band suppression of \(A_s\) dB.
  • msresamp_crcf_destroy(q) destroys the resampler, freeing all internally-allocated memory.
  • msresamp_crcf_print(q) prints the internal properties of the resampler to the standard output.
  • msresamp_crcf_reset(q) clears the internal resampler buffers.
  • msresamp_crcf_filter_execute(q,*x,nx,*y,*ny) executes the msresamp object on a sample buffer \(x\) of length\(n_x\) , storing the output in \(y\) and specifying the number of output elements in \(n_y\) .
  • msresamp_crcf_get_delay(q) returns the number of samples of delay in the output (can be a non-integer value).

Below is a code example demonstrating the msresamp interface.

#include <liquid/liquid.h>

int main() {
    // options
    float r=0.117f;     // resampling rate (output/input)
    float As=60.0f;     // resampling filter stop-band attenuation [dB]

    // create multi-stage arbitrary resampler object
    msresamp_crcf q = msresamp_crcf_create(r,As);

    unsigned int nx = 400;          // input size
    unsigned int ny = ceilf(nx*r);  // expected output size
    float complex x[nx];            // input buffer
    float complex y[ny];            // output buffer
    unsigned int num_written;       // number of values written to buffer

    // ... initialize input ...

    // execute resampler, storing result in output buffer
    msresamp_crcf_execute(q, x, nx, y, &num_written);

    // ... repeat as necessary ...

    // clean up allocated objects




Figure [fig-filter-msresamp_crcf]. msresamp_crcf (multi-stage resampler) interpolator demonstration with a stop-band suppression \(A_s=60\) dB at the irrational rate \(r = \sqrt{19} \approx 4.359\) .

[ref:fig-filter-msresamp_crcf] gives a graphical depiction in both the time and frequency domains of the multi-stage resampler acting as an interpolator. The time series has been aligned (shifted by the filter delay and scaled by the resampling rate) to show equivalence. For a more detailed example, refer to examples/msresamp_crcf_example.c located in the main liquid project source directory.