Switchboard SDK
Loading...
Searching...
No Matches
switchboard::ResamplingFIFO Class Reference

Resampling class for audio streams that uses a FIFO buffer to store the resampled frames. More...

#include <ResamplingFIFO.hpp>

Public Member Functions

 ResamplingFIFO (int numberOfChannels, int maxNumberOfFrames)
 Constructor for ResamplingFIFO.
 
 ~ResamplingFIFO ()
 Destructor for ResamplingFIFO.
 
int getNumberOfChannels () const
 Gets the number of channels.
 
int getMaxNumberOfFrames () const
 Gets the maximum number of frames that can be stored in the FIFO buffer.
 
int getInputSampleRate () const
 Gets the input sample rate.
 
int getOutputSampleRate () const
 Gets the output sample rate.
 
void setRatio (int inputSampleRate, int outputSampleRate)
 Sets the input and output sample rates that is used for resampling.
 
long pushBuffer (const float *buffer, int numFrames)
 Pushes audio into the resampler and puts the resampled frames into the FIFO buffer.
 
int getNumberOfFramesReady () const
 Gets the number of frames that are ready to be popped from the FIFO buffer.
 
void popBuffer (float *buffer, int numFrames)
 Pops audio from the FIFO buffer.
 
void reset ()
 Resets the internal state of the resampling FIFO.
 

Detailed Description

Resampling class for audio streams that uses a FIFO buffer to store the resampled frames.

Constructor & Destructor Documentation

◆ ResamplingFIFO()

switchboard::ResamplingFIFO::ResamplingFIFO ( int numberOfChannels,
int maxNumberOfFrames )

Constructor for ResamplingFIFO.

Parameters
numberOfChannelsThe channel count of the audio stream. Cannot change after creation.
maxNumberOfFramesThe maximum number of frames that can be stored in the FIFO buffer to store the output frames.

Member Function Documentation

◆ getInputSampleRate()

int switchboard::ResamplingFIFO::getInputSampleRate ( ) const

Gets the input sample rate.

Returns
The input sample rate.

◆ getMaxNumberOfFrames()

int switchboard::ResamplingFIFO::getMaxNumberOfFrames ( ) const

Gets the maximum number of frames that can be stored in the FIFO buffer.

Returns
The maximum number of frames.

◆ getNumberOfChannels()

int switchboard::ResamplingFIFO::getNumberOfChannels ( ) const

Gets the number of channels.

Returns
The number of channels.

◆ getNumberOfFramesReady()

int switchboard::ResamplingFIFO::getNumberOfFramesReady ( ) const

Gets the number of frames that are ready to be popped from the FIFO buffer.

Returns
The number of frames ready to be popped.

◆ getOutputSampleRate()

int switchboard::ResamplingFIFO::getOutputSampleRate ( ) const

Gets the output sample rate.

Returns
The output sample rate.

◆ popBuffer()

void switchboard::ResamplingFIFO::popBuffer ( float * buffer,
int numFrames )

Pops audio from the FIFO buffer.

Before pulling audio from the FIFO buffer, check if there are enough frames ready to be popped with the getNumberOfFramesReady call.

Parameters
bufferThe output audio buffer.
numFramesThe number of frames to pop.

◆ pushBuffer()

long switchboard::ResamplingFIFO::pushBuffer ( const float * buffer,
int numFrames )

Pushes audio into the resampler and puts the resampled frames into the FIFO buffer.

Parameters
bufferThe input audio buffer.
numFramesThe number of frames in the input buffer.
Returns
The number of frames that were used from the input buffer.

The returned value can indicate a problem when the output buffer is full.

◆ setRatio()

void switchboard::ResamplingFIFO::setRatio ( int inputSampleRate,
int outputSampleRate )

Sets the input and output sample rates that is used for resampling.

Parameters
inputSampleRateThe input sample rate.
outputSampleRateThe output sample rate.