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

Provides audio data from an encoded audio file. More...

#include <AudioPlayerFileSource.hpp>

Inheritance diagram for switchboard::AudioPlayerFileSource:
switchboard::AudioPlayerSource

Public Member Functions

 AudioPlayerFileSource (const std::string &path, Codec format)
 AudioPlayerFileSource constructor for loading audio from file path.
 
 ~AudioPlayerFileSource ()
 
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.
 
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 bool isFinished () const override
 Checks if the provided audio has reached its end.
 
const double getDuration () const override
 Gets the duration of the currently playing media.
 
const double getPosition () const override
 Indicates the current position of the playhead.
 
void setPosition (double position) override
 Sets the playhead to the desired position.
 
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

Provides audio data from an encoded audio file.

AudioPlayerFileSource class.

This source streams only the relevant data to the memory.

Constructor & Destructor Documentation

◆ AudioPlayerFileSource()

switchboard::AudioPlayerFileSource::AudioPlayerFileSource ( const std::string & path,
Codec format )

AudioPlayerFileSource constructor for loading audio from file path.

This constructor throws std::runtime_error if loading the audio file fails.

Parameters
pathThe path the audio file to load.
formatThe audio recording format.
Exceptions
std::runtime_errorThrown when the audio file could not be read or decoded.

◆ ~AudioPlayerFileSource()

switchboard::AudioPlayerFileSource::~AudioPlayerFileSource ( )

AudioPlayerFileSource destructor.

Member Function Documentation

◆ getDuration()

const double switchboard::AudioPlayerFileSource::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::AudioPlayerFileSource::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::AudioPlayerFileSource::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::AudioPlayerFileSource::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::AudioPlayerFileSource::getPosition ( ) const
overridevirtual

Indicates the current position of the playhead.

Returns
Returns the elapsed time in seconds.

Implements switchboard::AudioPlayerSource.

◆ getSampleRate()

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

Gets the sample rate of the audio.

Returns
The sample rate of the audio.

Implements switchboard::AudioPlayerSource.

◆ getStartPosition()

double switchboard::AudioPlayerFileSource::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::AudioPlayerFileSource::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::AudioPlayerFileSource::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::AudioPlayerFileSource::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 frames to put in the output buffer.
Returns
The number of "useful" audio frames put in outputBuffer.

Implements switchboard::AudioPlayerSource.

◆ setEndPosition()

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

Sets the ending position of the playback.

Parameters
endPositionThe desired position in seconds.

Implements switchboard::AudioPlayerSource.

◆ setLoopingEnabled()

void switchboard::AudioPlayerFileSource::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::AudioPlayerFileSource::setPosition ( double position)
overridevirtual

Sets the playhead to the desired position.

Parameters
positionThe desired position in seconds.

Implements switchboard::AudioPlayerSource.

◆ setStartPosition()

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

Sets the starting position of the playback.

Parameters
startPositionThe desired position in seconds.

Implements switchboard::AudioPlayerSource.