Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
switchboard::AudioPlayer Class Reference

Plays the loaded audio file. More...

#include <AudioPlayer.hpp>

Public Member Functions

 AudioPlayer ()
 AudioPlayer constructor.
 
virtual ~AudioPlayer ()=default
 AudioPlayer destructor.
 
virtual void process (float *outputBuffer, const uint numberOfFrames, const uint numberOfChannels, const uint sampleRate)
 Gets the next available buffer to play from the recoded audio buffer.
 
bool load (const std::string &path, Codec format)
 Loads the file on the give path to the playback buffer. Stops playback.
 
bool load (const std::vector< uint8_t > &inputData, Codec format)
 Loads the input data to the playback buffer. Stops playback.
 
void flush ()
 Clear any buffered audio data and stop playback.
 
void play ()
 Starts the audio playback.
 
void pause ()
 Pauses the audio playback.
 
void stop ()
 Stops the audio playback.
 
bool isPlaying ()
 
bool isLoopingEnabled ()
 
void setLoopingEnabled (bool enabled)
 

Protected Attributes

std::atomic< bool > playing
 
bool loopingEnabled
 
std::unique_ptr< switchboard::Resamplerresampler
 
std::unique_ptr< RingBuffer< float > > ringBuffer
 
AudioData< float > audioChunk
 
AudioData< float > resampledAudioChunk
 
uint currentOutputSampleRate
 
std::unique_ptr< AudioPlayerSourcecurrentSource
 

Detailed Description

Plays the loaded audio file.

AudioPlayer class.

Member Function Documentation

◆ isLoopingEnabled()

bool switchboard::AudioPlayer::isLoopingEnabled ( )

Indicates whether looping of the audio file is enabled.

Returns
True when it is enabled, false when it is not.

◆ isPlaying()

bool switchboard::AudioPlayer::isPlaying ( )

Indicates whether the system is currently playing.

Returns
True when it is playing, false when it is not.

◆ load() [1/2]

bool switchboard::AudioPlayer::load ( const std::string &  path,
Codec  format 
)

Loads the file on the give path to the playback buffer. Stops playback.

Parameters
pathThe path the audio file to load.
formatThe audio recording format.
Returns
True when loading of the file was successful.

◆ load() [2/2]

bool switchboard::AudioPlayer::load ( const std::vector< uint8_t > &  inputData,
Codec  format 
)

Loads the input data to the playback buffer. Stops playback.

Parameters
inputDataVector containing the input data.
formatThe audio recording format.
Returns
True when the load was successful.

◆ process()

void switchboard::AudioPlayer::process ( float *  outputBuffer,
const uint  numberOfFrames,
const uint  numberOfChannels,
const uint  sampleRate 
)
virtual

Gets the next available buffer to play from the recoded audio buffer.

Parameters
outputBufferThe buffer that will contain the output samples.
numberOfFramesThe number of frames to put in the output buffer.
numberOfChannelsThe number of channels to put in the output channels.
sampleRateThe sample rate in which to play the recording.

◆ setLoopingEnabled()

void switchboard::AudioPlayer::setLoopingEnabled ( bool  enabled)

Enables or disables the looping of the loaded audio file.

Parameters
loopingEnabledTrue when it is enabled, false when it is not.

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