SoDaRadio-5.0.3-master:8901fb5
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SoDa::ReSampler Class Reference

Rational Resampler. More...

#include <ReSampler.hxx>

Public Member Functions

 ReSampler (unsigned int interp_ratio, unsigned int decim_ratio, unsigned int _inlen, unsigned int filter_len)
 Constructor. More...
 
unsigned int apply (std::complex< float > *in, std::complex< float > *out, float gain=1.0)
 apply the resampler to a buffer of IQ samples. More...
 
unsigned int apply (float *in, float *out, float gain=1.0)
 apply the resampler to a buffer of scalar samples. More...
 

Private Member Functions

void CreateFilter (unsigned int filter_len)
 create a filter bank for a polyphase resampler. More...
 

Private Attributes

int filter_len
 the length of the polyphase filter that we're using. More...
 
unsigned int iM
 
unsigned int dN
 
unsigned int Q
 
unsigned int tail_index
 
unsigned int inlen
 
unsigned int M
 
unsigned int N
 
std::complex< float > ** c_filt
 filter bank for interp/deci filter More...
 
std::complex< float > * filt_fft
 the filtered image of the input stream More...
 
std::complex< float > * interp_res
 the interpolation result More...
 
std::complex< float > * in_fft
 the result of the first fft stage More...
 
std::complex< float > * inbuf
 the fft input buffer More...
 
float transform_gain
 
float gain_correction
 
fftwf_plan in_fft_plan
 
fftwf_plan mid_ifft_plan
 

Detailed Description

Rational Resampler.

Create a resampler that upsamples by an interpolation rate and downsamples by a decimation rate.

Definition at line 41 of file ReSampler.hxx.

Constructor & Destructor Documentation

◆ ReSampler()

SoDa::ReSampler::ReSampler ( unsigned int  interp_ratio,
unsigned int  decim_ratio,
unsigned int  _inlen,
unsigned int  filter_len 
)

Constructor.

Parameters
interp_ratioupsample rate
decim_ratiodownsample rate
_inlenthe input buffer length (output buffer will be _inlin * interp_ratio / decimation_ratio)
filter_lenthe minimum length of the antialiasing filter

Definition at line 82 of file ReSampler.cxx.

References c_filt, CreateFilter(), dN, filt_fft, filter_len, iM, in_fft, in_fft_plan, inbuf, inlen, interp_res, ipow(), M, mid_ifft_plan, N, Q, tail_index, and transform_gain.

Member Function Documentation

◆ apply() [1/2]

unsigned int SoDa::ReSampler::apply ( std::complex< float > *  in,
std::complex< float > *  out,
float  gain = 1.0 
)

apply the resampler to a buffer of IQ samples.

Parameters
ininput buffer
outoutput buffer
gain– multiply output by gain

Definition at line 272 of file ReSampler.cxx.

References c_filt, dN, filt_fft, iM, in_fft, in_fft_plan, inbuf, interp_res, M, mid_ifft_plan, N, Q, tail_index, and transform_gain.

Referenced by SoDa::ReSample48to625::apply(), SoDa::ReSample625to48::apply(), and main().

◆ apply() [2/2]

unsigned int SoDa::ReSampler::apply ( float *  in,
float *  out,
float  gain = 1.0 
)

apply the resampler to a buffer of scalar samples.

Parameters
ininput buffer
outoutput buffer
gain– multiply output by gain

Definition at line 322 of file ReSampler.cxx.

References c_filt, dN, filt_fft, iM, in_fft, in_fft_plan, inbuf, interp_res, M, mid_ifft_plan, N, Q, tail_index, and transform_gain.

◆ CreateFilter()

void SoDa::ReSampler::CreateFilter ( unsigned int  filter_len)
private

create a filter bank for a polyphase resampler.

(Though we do it in the frequency domain.)

Parameters
filter_lenthe minimum length of the anti-alias filter

Definition at line 171 of file ReSampler.cxx.

References c_filt, dN, filter_len, iM, and N.

Referenced by ReSampler().

Member Data Documentation

◆ c_filt

std::complex<float>** SoDa::ReSampler::c_filt
private

filter bank for interp/deci filter

Definition at line 87 of file ReSampler.hxx.

Referenced by apply(), CreateFilter(), and ReSampler().

◆ dN

unsigned int SoDa::ReSampler::dN
private

Definition at line 85 of file ReSampler.hxx.

Referenced by apply(), CreateFilter(), and ReSampler().

◆ filt_fft

std::complex<float>* SoDa::ReSampler::filt_fft
private

the filtered image of the input stream

Definition at line 88 of file ReSampler.hxx.

Referenced by apply(), and ReSampler().

◆ filter_len

int SoDa::ReSampler::filter_len
private

the length of the polyphase filter that we're using.

Definition at line 83 of file ReSampler.hxx.

Referenced by CreateFilter(), and ReSampler().

◆ gain_correction

float SoDa::ReSampler::gain_correction
private

Definition at line 95 of file ReSampler.hxx.

◆ iM

unsigned int SoDa::ReSampler::iM
private

Definition at line 85 of file ReSampler.hxx.

Referenced by apply(), CreateFilter(), and ReSampler().

◆ in_fft

std::complex<float>* SoDa::ReSampler::in_fft
private

the result of the first fft stage

Definition at line 90 of file ReSampler.hxx.

Referenced by apply(), and ReSampler().

◆ in_fft_plan

fftwf_plan SoDa::ReSampler::in_fft_plan
private

Definition at line 98 of file ReSampler.hxx.

Referenced by apply(), and ReSampler().

◆ inbuf

std::complex<float>* SoDa::ReSampler::inbuf
private

the fft input buffer

Definition at line 91 of file ReSampler.hxx.

Referenced by apply(), and ReSampler().

◆ inlen

unsigned int SoDa::ReSampler::inlen
private

Definition at line 86 of file ReSampler.hxx.

Referenced by ReSampler().

◆ interp_res

std::complex<float>* SoDa::ReSampler::interp_res
private

the interpolation result

Definition at line 89 of file ReSampler.hxx.

Referenced by apply(), and ReSampler().

◆ M

unsigned int SoDa::ReSampler::M
private

Definition at line 86 of file ReSampler.hxx.

Referenced by apply(), and ReSampler().

◆ mid_ifft_plan

fftwf_plan SoDa::ReSampler::mid_ifft_plan
private

Definition at line 99 of file ReSampler.hxx.

Referenced by apply(), and ReSampler().

◆ N

unsigned int SoDa::ReSampler::N
private

Definition at line 86 of file ReSampler.hxx.

Referenced by apply(), CreateFilter(), and ReSampler().

◆ Q

unsigned int SoDa::ReSampler::Q
private

Definition at line 85 of file ReSampler.hxx.

Referenced by apply(), and ReSampler().

◆ tail_index

unsigned int SoDa::ReSampler::tail_index
private

Definition at line 85 of file ReSampler.hxx.

Referenced by apply(), and ReSampler().

◆ transform_gain

float SoDa::ReSampler::transform_gain
private

Definition at line 94 of file ReSampler.hxx.

Referenced by apply(), and ReSampler().


The documentation for this class was generated from the following files: