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

This class can be used to turn variable sized audio buffer stream into a stabilized constant length audio buffer stream. More...

#include <BufferRegulator.hpp>

Public Member Functions

 BufferRegulator (const uint outputBufferMs, const AudioCallbackFunction audioCallback)
 Creates a BufferRegulator instance.
 
void reset ()
 Resets the buffer regulator's internal state.
 
bool process (float **buffers, const uint inputChannels, const uint outputChannels, const uint numberOfFrames, const uint sampleRate, void *userPointer)
 The audio process function.
 

Detailed Description

This class can be used to turn variable sized audio buffer stream into a stabilized constant length audio buffer stream.

BufferRegulator class.

The BufferRegulator's process function can receive any number of frames, but the callback function is always called with outputBufferMs long buffers.

Constructor & Destructor Documentation

◆ BufferRegulator()

switchboard::BufferRegulator::BufferRegulator ( const uint outputBufferMs,
const AudioCallbackFunction audioCallback )

Creates a BufferRegulator instance.

Parameters
outputBufferMsBuffer duration that is received by the callback function.
audioCallbackThe callback function that receives the duration regulated audio buffers.

Member Function Documentation

◆ process()

bool switchboard::BufferRegulator::process ( float ** buffers,
const uint inputChannels,
const uint outputChannels,
const uint numberOfFrames,
const uint sampleRate,
void * userPointer )

The audio process function.

When sample rate changes, the BufferRegulator resets its state and clears its internal buffers.

Parameters
buffers[inout] The audio buffer.
inputChannelsNumber of input channels.
outputChannelsNumber of output channels.
sampleRateSample rate of audio data.
userPointerCustom pointer that is passed to the callback function.
Returns
true if audio data has been written to buffer, false otherwise.