The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
MHAFilter::blockprocessing_polyphase_resampling_t Class Reference

A class that does polyphase resampling and takes into account block processing. More...

Public Member Functions

 blockprocessing_polyphase_resampling_t (float source_srate, unsigned source_fragsize, float target_srate, unsigned target_fragsize, float nyquist_ratio, float irslen, unsigned nchannels, bool add_delay)
 Contructs a polyphase resampling filter that can be used for blockprocessing with the given parameters. More...
 
virtual ~blockprocessing_polyphase_resampling_t ()
 
void write (mha_wave_t &signal)
 Write signal to the ringbuffer. More...
 
void read (mha_wave_t &signal)
 Read resampled signal. More...
 
bool can_read () const
 Checks if the resampling ring buffer can produce another output signal block. More...
 

Private Attributes

polyphase_resampling_tresampling
 
unsigned fragsize_in
 
unsigned fragsize_out
 
unsigned num_channels
 

Detailed Description

A class that does polyphase resampling and takes into account block processing.

Constructor & Destructor Documentation

◆ blockprocessing_polyphase_resampling_t()

MHAFilter::blockprocessing_polyphase_resampling_t::blockprocessing_polyphase_resampling_t ( float  source_srate,
unsigned  source_fragsize,
float  target_srate,
unsigned  target_fragsize,
float  nyquist_ratio,
float  irslen,
unsigned  nchannels,
bool  add_delay 
)

Contructs a polyphase resampling filter that can be used for blockprocessing with the given parameters.

Parameters
source_srateSource sampling rate / Hz
source_fragsizeFragment size of incoming audio blocks / frames at source_srate
target_srateTarget sampling rate / Hz
target_fragsizeFragment size of produced audio blocks / frames at target_srate
nyquist_ratioLow pass filter cutoff frequency relative to the nyquist frequency of the smaller of the two sampling rates. Example values: 0.8, 0.9
irslenImpulse response length used for low pass filtering / s
nchannelsNumber of audio channels
add_delayTo avoid underruns, a delay is generally necessary for round trip block size adaptations. It is only necessary to add this delay to one of the two resampling chains. Set this parameter to true for the first resampling object of a round trip pair. It will add the necessary delay, and calculate the size of the ring buffer appropriately, When set to false, only the ringbuffer size will be set sufficiently.

◆ ~blockprocessing_polyphase_resampling_t()

virtual MHAFilter::blockprocessing_polyphase_resampling_t::~blockprocessing_polyphase_resampling_t ( )
inlinevirtual

Member Function Documentation

◆ write()

void MHAFilter::blockprocessing_polyphase_resampling_t::write ( mha_wave_t signal)

Write signal to the ringbuffer.

Parameters
signalinput signal in original sampling rate
Exceptions
MHA_ErrorRaises exception if there is not enough room, if the number of channels does not match, or if the number of frames is not equal to the number specified in the constructor

◆ read()

void MHAFilter::blockprocessing_polyphase_resampling_t::read ( mha_wave_t signal)

Read resampled signal.

Will perform the resampling and remove no longer needed samples from the input buffer.

Parameters
signalbuffer to write the resampled signal to.
Exceptions
MHA_ErrorRaises exception if there is not enough input signal, if the number of channels of frames does not match.

◆ can_read()

bool MHAFilter::blockprocessing_polyphase_resampling_t::can_read ( ) const
inline

Checks if the resampling ring buffer can produce another output signal block.

Member Data Documentation

◆ resampling

polyphase_resampling_t* MHAFilter::blockprocessing_polyphase_resampling_t::resampling
private

◆ fragsize_in

unsigned MHAFilter::blockprocessing_polyphase_resampling_t::fragsize_in
private

◆ fragsize_out

unsigned MHAFilter::blockprocessing_polyphase_resampling_t::fragsize_out
private

◆ num_channels

unsigned MHAFilter::blockprocessing_polyphase_resampling_t::num_channels
private

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