Provides audio data from an encoded audio file.
More...
#include <AudioPlayerMemorySource.hpp>
Provides audio data from an encoded audio file.
AudioPlayerMemorySource class.
This source loads the entire decoded audio data in memory.
◆ AudioPlayerMemorySource() [1/3]
switchboard::AudioPlayerMemorySource::AudioPlayerMemorySource |
( |
const std::string & | filePath, |
|
|
Codec | format ) |
AudioPlayerMemorySource constructor for loading encoded audio from file path.
This constructor throws std::runtime_error if loading the audio file fails.
- Parameters
-
filePath | The path the audio file to load. |
format | The audio recording format. |
- Exceptions
-
std::runtime_error | Thrown if path is not readable or audio data could not be decoded. |
◆ AudioPlayerMemorySource() [2/3]
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
-
inputData | Vector containing the encoded audio data. |
format | The audio recording format. |
- Exceptions
-
std::runtime_error | Thrown if audio data could not be decoded. |
◆ AudioPlayerMemorySource() [3/3]
switchboard::AudioPlayerMemorySource::AudioPlayerMemorySource |
( |
AudioBuffer< float > & | audioBuffer, |
|
|
bool | copyData ) |
AudioPlayerMemorySource constructor for loading audio from an AudioBuffer instance.
- Parameters
-
audioBuffer | The audio buffer containing the audio data. |
copyData | When set to true, the audio data from the audio buffer will be copied and stored in the AudioPlayerMemorySource instance. |
◆ getDuration()
const double switchboard::AudioPlayerMemorySource::getDuration |
( |
| ) |
const |
|
overridevirtual |
◆ getEndPosition()
double switchboard::AudioPlayerMemorySource::getEndPosition |
( |
| ) |
const |
|
overridevirtual |
◆ getNumberOfChannels()
const uint switchboard::AudioPlayerMemorySource::getNumberOfChannels |
( |
| ) |
const |
|
overridevirtual |
◆ getNumberOfFrames()
const uint switchboard::AudioPlayerMemorySource::getNumberOfFrames |
( |
| ) |
const |
|
overridevirtual |
◆ getPosition()
const double switchboard::AudioPlayerMemorySource::getPosition |
( |
| ) |
const |
|
overridevirtual |
◆ getSampleRate()
const uint switchboard::AudioPlayerMemorySource::getSampleRate |
( |
| ) |
const |
|
overridevirtual |
◆ getStartPosition()
double switchboard::AudioPlayerMemorySource::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::AudioPlayerMemorySource::isFinished |
( |
| ) |
const |
|
overridevirtual |
◆ isLoopingEnabled()
const bool switchboard::AudioPlayerMemorySource::isLoopingEnabled |
( |
| ) |
const |
|
overridevirtual |
◆ read()
const uint switchboard::AudioPlayerMemorySource::read |
( |
float * | outputBuffer, |
|
|
const uint | numberOfFrames ) |
|
overridevirtual |
Gets the next available chunk of audio.
- Parameters
-
outputBuffer | The buffer that will contain the output samples. |
numberOfFrames | The 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::AudioPlayerMemorySource::setEndPosition |
( |
double | endPosition | ) |
|
|
overridevirtual |
◆ setLoopingEnabled()
void switchboard::AudioPlayerMemorySource::setLoopingEnabled |
( |
bool | enabled | ) |
|
|
overridevirtual |
Enables or disables the looping of the loaded audio.
- Parameters
-
enabled | True when it is enabled, false when it is not. |
Implements switchboard::AudioPlayerSource.
◆ setPosition()
void switchboard::AudioPlayerMemorySource::setPosition |
( |
double | position | ) |
|
|
overridevirtual |
◆ setStartPosition()
void switchboard::AudioPlayerMemorySource::setStartPosition |
( |
double | startPosition | ) |
|
|
overridevirtual |