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

AudioPlayerSource that plays audio data from a queue of AudioBuffer instances. More...

#include <AudioPlayerBufferQueueSource.hpp>

Inheritance diagram for switchboard::AudioPlayerBufferQueueSource:
switchboard::AudioPlayerSource

Public Member Functions

 AudioPlayerBufferQueueSource (const uint sampleRate, const uint numberOfChannels)
 AudioPlayerBufferQueueSource constructor.
 
 ~AudioPlayerBufferQueueSource ()
 AudioPlayerBufferQueueSource destructor.
 
bool enqueue (AudioBuffer< float > &audioBuffer)
 Enqueues an AudioBuffer instance to the queue.
 
const uint getSampleRate () const override
 Gets the sample rate of the audio.
 
const uint getNumberOfChannels () const override
 Gets the number of channels of the audio.
 
const uint getNumberOfFrames () const override
 Gets the number of frames of the audio.
 
const double getDuration () const override
 Gets the duration of the currently playing media.
 
const bool isFinished () const override
 Checks if the provided audio has reached its end.
 
const double getPosition () const override
 Indicates the current position of the playhead.
 
void setPosition (double position) override
 Sets the playhead to the desired position.
 
const bool isLoopingEnabled () const override
 Indicates whether looping of the audio is enabled.
 
void setLoopingEnabled (bool enabled) override
 Enables or disables the looping of the loaded audio.
 
double getStartPosition () const override
 
void setStartPosition (double startPosition) override
 
double getEndPosition () const override
 
void setEndPosition (double endPosition) override
 
const uint read (float *outputBuffer, const uint numberOfFrames) override
 Gets the next available chunk of audio.
 
- Public Member Functions inherited from switchboard::AudioPlayerSource
virtual ~AudioPlayerSource ()=default
 Default destructor.
 

Detailed Description

AudioPlayerSource that plays audio data from a queue of AudioBuffer instances.

AudioPlayerBufferQueueSource class.

Constructor & Destructor Documentation

◆ AudioPlayerBufferQueueSource()

switchboard::AudioPlayerBufferQueueSource::AudioPlayerBufferQueueSource ( const uint sampleRate,
const uint numberOfChannels )

AudioPlayerBufferQueueSource constructor.

Parameters
sampleRateThe sample rate of the audio data.
numberOfChannelsThe number of channels of the audio data.

Member Function Documentation

◆ enqueue()

bool switchboard::AudioPlayerBufferQueueSource::enqueue ( AudioBuffer< float > & audioBuffer)

Enqueues an AudioBuffer instance to the queue.

Parameters
audioBufferThe audio buffer to enqueue.
Returns
True if the audio buffer was successfully enqueued, false otherwise.

◆ getDuration()

const double switchboard::AudioPlayerBufferQueueSource::getDuration ( ) const
overridevirtual

Gets the duration of the currently playing media.

Returns
The duration of the media in seconds.

Implements switchboard::AudioPlayerSource.

◆ getEndPosition()

double switchboard::AudioPlayerBufferQueueSource::getEndPosition ( ) const
overridevirtual

Indicates the current end position of the playback.

Returns
Returns the current end position in seconds.

Implements switchboard::AudioPlayerSource.

◆ getNumberOfChannels()

const uint switchboard::AudioPlayerBufferQueueSource::getNumberOfChannels ( ) const
overridevirtual

Gets the number of channels of the audio.

Returns
The number of channels of the audio.

Implements switchboard::AudioPlayerSource.

◆ getNumberOfFrames()

const uint switchboard::AudioPlayerBufferQueueSource::getNumberOfFrames ( ) const
overridevirtual

Gets the number of frames of the audio.

Returns
The number of frames of the audio.

Implements switchboard::AudioPlayerSource.

◆ getPosition()

const double switchboard::AudioPlayerBufferQueueSource::getPosition ( ) const
overridevirtual

Indicates the current position of the playhead.

Returns
Returns the elapsed time in seconds.

Implements switchboard::AudioPlayerSource.

◆ getSampleRate()

const uint switchboard::AudioPlayerBufferQueueSource::getSampleRate ( ) const
overridevirtual

Gets the sample rate of the audio.

Returns
The sample rate of the audio.

Implements switchboard::AudioPlayerSource.

◆ getStartPosition()

double switchboard::AudioPlayerBufferQueueSource::getStartPosition ( ) const
overridevirtual

Indicates the current start position of the playback.

Returns
Returns the current start position in seconds.

Implements switchboard::AudioPlayerSource.

◆ isFinished()

const bool switchboard::AudioPlayerBufferQueueSource::isFinished ( ) const
overridevirtual

Checks if the provided audio has reached its end.

Returns
True if the provided audio has reached its end.

Implements switchboard::AudioPlayerSource.

◆ isLoopingEnabled()

const bool switchboard::AudioPlayerBufferQueueSource::isLoopingEnabled ( ) const
overridevirtual

Indicates whether looping of the audio is enabled.

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

Implements switchboard::AudioPlayerSource.

◆ read()

const uint switchboard::AudioPlayerBufferQueueSource::read ( float * outputBuffer,
const uint numberOfFrames )
overridevirtual

Gets the next available chunk of audio.

Parameters
outputBufferThe buffer that will contain the output samples.
numberOfFramesThe number of samples to put in the output buffer.
Returns
The number of "useful" audio frames put in outputBuffer.

Implements switchboard::AudioPlayerSource.

◆ setEndPosition()

void switchboard::AudioPlayerBufferQueueSource::setEndPosition ( double endPosition)
overridevirtual

Sets the ending position of the playback.

Parameters
endPositionThe desired position in seconds.

Implements switchboard::AudioPlayerSource.

◆ setLoopingEnabled()

void switchboard::AudioPlayerBufferQueueSource::setLoopingEnabled ( bool enabled)
overridevirtual

Enables or disables the looping of the loaded audio.

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

Implements switchboard::AudioPlayerSource.

◆ setPosition()

void switchboard::AudioPlayerBufferQueueSource::setPosition ( double position)
overridevirtual

Sets the playhead to the desired position.

Parameters
positionThe desired position in seconds.

Implements switchboard::AudioPlayerSource.

◆ setStartPosition()

void switchboard::AudioPlayerBufferQueueSource::setStartPosition ( double startPosition)
overridevirtual

Sets the starting position of the playback.

Parameters
startPositionThe desired position in seconds.

Implements switchboard::AudioPlayerSource.