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

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

#include <AudioPlayerMemorySource.hpp>

Inheritance diagram for switchboard::AudioPlayerMemorySource:
switchboard::AudioPlayerSource

Public Member Functions

 AudioPlayerMemorySource (const std::string &path, Codec format)
 AudioPlayerMemorySource constructor for loading audio from file path.
 
 AudioPlayerMemorySource (const std::vector< uint8 > &inputData, Codec format)
 AudioPlayerMemorySource constructor for loading audio from encoded data.
 
const uint getSampleRate () const override
 Get the sample rate of the audio.
 
const uint getNumberOfChannels () const override
 Get the number of channels of the audio.
 
const uint getNumberOfFrames () const override
 Get the number of frames of the audio.
 
const bool isFinished () const override
 Check if the provided audio has reached its end.
 
const uint read (float *outputBuffer, const uint numberOfSamples) override
 Gets the next available chunk of audio.
 
void rewind () override
 Sets the audio position back to its start.
 
- Public Member Functions inherited from switchboard::AudioPlayerSource
virtual ~AudioPlayerSource ()=default
 Default destructor.
 
virtual const uint getSampleRate () const =0
 Get the sample rate of the audio.
 
virtual const uint getNumberOfChannels () const =0
 Get the number of channels of the audio.
 
virtual const uint getNumberOfFrames () const =0
 Get the number of frames of the audio.
 
virtual const bool isFinished () const =0
 Check if the provided audio has reached its end.
 
const bool isLoopingEnabled () const
 
void setLoopingEnabled (bool enabled)
 
virtual const uint read (float *outputBuffer, const uint numberOfSamples)=0
 Gets the next available chunk of audio.
 
virtual void rewind ()=0
 Sets the audio position back to its start.
 

Additional Inherited Members

- Protected Attributes inherited from switchboard::AudioPlayerSource
bool loopingEnabled { false }
 

Detailed Description

Provides audio data from an encoded audio file.

AudioPlayerMemorySource class.

This source loads the entire decoded audio data in memory.

Constructor & Destructor Documentation

◆ AudioPlayerMemorySource() [1/2]

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

AudioPlayerMemorySource 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.

◆ AudioPlayerMemorySource() [2/2]

switchboard::AudioPlayerMemorySource::AudioPlayerMemorySource ( const std::vector< uint8 > &  inputData,
Codec  format 
)

AudioPlayerMemorySource constructor for loading audio from encoded data.

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

Parameters
inputDataVector containing the input data.
formatThe audio recording format.

Member Function Documentation

◆ getNumberOfChannels()

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

Get the number of channels of the audio.

Returns
The number of channels of the audio.

Implements switchboard::AudioPlayerSource.

◆ getNumberOfFrames()

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

Get the number of frames of the audio.

Returns
The number of frames of the audio.

Implements switchboard::AudioPlayerSource.

◆ getSampleRate()

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

Get the sample rate of the audio.

Returns
The sample rate of the audio.

Implements switchboard::AudioPlayerSource.

◆ isFinished()

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

Check if the provided audio has reached its end.

Returns
True if the provided audio has reached its end.

Implements switchboard::AudioPlayerSource.

◆ read()

const uint switchboard::AudioPlayerMemorySource::read ( float *  outputBuffer,
const uint  numberOfSamples 
)
overridevirtual

Gets the next available chunk of audio.

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

Implements switchboard::AudioPlayerSource.

◆ rewind()

void switchboard::AudioPlayerMemorySource::rewind ( )
overridevirtual

Sets the audio position back to its start.

Implements switchboard::AudioPlayerSource.


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