Switchboard SDK
Loading...
Searching...
No Matches
switchboard::AudioPlayerSource Struct Referenceabstract

Provides an interface to provide audio data in chunks. More...

#include <AudioPlayerSource.hpp>

Inheritance diagram for switchboard::AudioPlayerSource:
switchboard::AudioPlayerBufferQueueSource switchboard::AudioPlayerFileSource switchboard::AudioPlayerMemorySource

Public Member Functions

virtual ~AudioPlayerSource ()=default
 Default destructor.
 
virtual const uint getSampleRate () const =0
 Gets the sample rate of the audio.
 
virtual const uint getNumberOfChannels () const =0
 Gets the number of channels of the audio.
 
virtual const uint getNumberOfFrames () const =0
 Gets the number of frames of the audio.
 
virtual const bool isFinished () const =0
 Checks if the provided audio has reached its end.
 
virtual const bool isLoopingEnabled () const =0
 Indicates whether looping of the audio is enabled.
 
virtual void setLoopingEnabled (bool enabled)=0
 Enables or disables the looping of the loaded audio.
 
virtual const double getDuration () const =0
 Gets the duration of the currently playing media.
 
virtual const double getPosition () const =0
 Indicates the current position of the playhead.
 
virtual void setPosition (double position)=0
 Sets the playhead to the desired position.
 
virtual double getStartPosition () const =0
 
virtual void setStartPosition (double startPosition)=0
 
virtual double getEndPosition () const =0
 
virtual void setEndPosition (double endPosition)=0
 
virtual const uint read (float *outputBuffer, const uint numberOfFrames)=0
 Gets the next available chunk of audio.
 

Detailed Description

Provides an interface to provide audio data in chunks.

AudioPlayerSource interface.

It can be used to implement audio streaming.

Member Function Documentation

◆ getDuration()

virtual const double switchboard::AudioPlayerSource::getDuration ( ) const
pure virtual

Gets the duration of the currently playing media.

Returns
The duration of the media in seconds.

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ getEndPosition()

virtual double switchboard::AudioPlayerSource::getEndPosition ( ) const
pure virtual

Indicates the current end position of the playback.

Returns
Returns the current end position in seconds.

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ getNumberOfChannels()

virtual const uint switchboard::AudioPlayerSource::getNumberOfChannels ( ) const
pure virtual

Gets the number of channels of the audio.

Returns
The number of channels of the audio.

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ getNumberOfFrames()

virtual const uint switchboard::AudioPlayerSource::getNumberOfFrames ( ) const
pure virtual

Gets the number of frames of the audio.

Returns
The number of frames of the audio.

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ getPosition()

virtual const double switchboard::AudioPlayerSource::getPosition ( ) const
pure virtual

Indicates the current position of the playhead.

Returns
Returns the elapsed time in seconds.

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ getSampleRate()

virtual const uint switchboard::AudioPlayerSource::getSampleRate ( ) const
pure virtual

Gets the sample rate of the audio.

Returns
The sample rate of the audio.

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ getStartPosition()

virtual double switchboard::AudioPlayerSource::getStartPosition ( ) const
pure virtual

Indicates the current start position of the playback.

Returns
Returns the current start position in seconds.

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ isFinished()

virtual const bool switchboard::AudioPlayerSource::isFinished ( ) const
pure virtual

Checks if the provided audio has reached its end.

Returns
True if the provided audio has reached its end.

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ isLoopingEnabled()

virtual const bool switchboard::AudioPlayerSource::isLoopingEnabled ( ) const
pure virtual

Indicates whether looping of the audio is enabled.

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

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ read()

virtual const uint switchboard::AudioPlayerSource::read ( float * outputBuffer,
const uint numberOfFrames )
pure virtual

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.

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ setEndPosition()

virtual void switchboard::AudioPlayerSource::setEndPosition ( double endPosition)
pure virtual

Sets the ending position of the playback.

Parameters
endPositionThe desired position in seconds.

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ setLoopingEnabled()

virtual void switchboard::AudioPlayerSource::setLoopingEnabled ( bool enabled)
pure virtual

Enables or disables the looping of the loaded audio.

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

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ setPosition()

virtual void switchboard::AudioPlayerSource::setPosition ( double position)
pure virtual

Sets the playhead to the desired position.

Parameters
positionThe desired position in seconds.

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.

◆ setStartPosition()

virtual void switchboard::AudioPlayerSource::setStartPosition ( double startPosition)
pure virtual

Sets the starting position of the playback.

Parameters
startPositionThe desired position in seconds.

Implemented in switchboard::AudioPlayerBufferQueueSource, switchboard::AudioPlayerFileSource, and switchboard::AudioPlayerMemorySource.