Provides audio data from an encoded audio file.
More...
#include <AudioPlayerFileSource.hpp>
|
| 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.
|
|
virtual | ~AudioPlayerSource ()=default |
| Default destructor.
|
|
Provides audio data from an encoded audio file.
AudioPlayerFileSource class.
This source streams only the relevant data to the memory.
◆ 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
-
path | The path the audio file to load. |
format | The audio recording format. |
- Exceptions
-
std::runtime_error | Thrown when the audio file could not be read or decoded. |
◆ ~AudioPlayerFileSource()
switchboard::AudioPlayerFileSource::~AudioPlayerFileSource |
( |
| ) |
|
◆ getDuration()
const double switchboard::AudioPlayerFileSource::getDuration |
( |
| ) |
const |
|
overridevirtual |
◆ getEndPosition()
double switchboard::AudioPlayerFileSource::getEndPosition |
( |
| ) |
const |
|
overridevirtual |
◆ getNumberOfChannels()
const uint switchboard::AudioPlayerFileSource::getNumberOfChannels |
( |
| ) |
const |
|
overridevirtual |
◆ getNumberOfFrames()
const uint switchboard::AudioPlayerFileSource::getNumberOfFrames |
( |
| ) |
const |
|
overridevirtual |
◆ getPosition()
const double switchboard::AudioPlayerFileSource::getPosition |
( |
| ) |
const |
|
overridevirtual |
◆ getSampleRate()
const uint switchboard::AudioPlayerFileSource::getSampleRate |
( |
| ) |
const |
|
overridevirtual |
◆ 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 |
◆ isLoopingEnabled()
const bool switchboard::AudioPlayerFileSource::isLoopingEnabled |
( |
| ) |
const |
|
overridevirtual |
◆ read()
const uint switchboard::AudioPlayerFileSource::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::AudioPlayerFileSource::setEndPosition |
( |
double | endPosition | ) |
|
|
overridevirtual |
◆ setLoopingEnabled()
void switchboard::AudioPlayerFileSource::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::AudioPlayerFileSource::setPosition |
( |
double | position | ) |
|
|
overridevirtual |
◆ setStartPosition()
void switchboard::AudioPlayerFileSource::setStartPosition |
( |
double | startPosition | ) |
|
|
overridevirtual |