Decodes WAVdata to PCM audio data. More...
#include <WavDecoder.hpp>
Public Member Functions | |
WavDecoder (const std::string &path) | |
WavDecoder constructor for decoding WAV from file path. | |
~WavDecoder () | |
const uint | getSampleRate () const |
Get the sample rate of the audio. | |
const uint | getNumberOfChannels () const |
Get the number of channels of the audio. | |
const uint | getNumberOfFrames () const |
Get the number of frames of the audio. | |
const bool | read (float *outputBuffer, const uint frameIndex, const uint numberOfFrames) |
Gets the next available chunk of audio. | |
Static Public Member Functions | |
static bool | decode (const std::vector< uint8 > &inputData, std::vector< float > &outputData, uint &sampleRate, uint &numberOfChannels) |
Decode input WAV byte data to PCM data. | |
Decodes WAVdata to PCM audio data.
WavDecoder class.
switchboard::WavDecoder::WavDecoder | ( | const std::string & | path | ) |
WavDecoder constructor for decoding WAV from file path.
This constructor throws std::runtime_error if loading the audio file fails.
path | The path the audio file to load. |
|
default |
WavDecoder destructor.
|
static |
Decode input WAV byte data to PCM data.
inputData | The vector that contains the WAV byte data. |
outputData | The vector that will contain the decoded PCM data. |
sampleRate | In-out parameter that will contain the decoded WAV data sample rate. |
numberOfChannels | In-out parameter that will contain the decoded WAV data number of channels. |
const uint switchboard::WavDecoder::getNumberOfChannels | ( | ) | const |
Get the number of channels of the audio.
const uint switchboard::WavDecoder::getNumberOfFrames | ( | ) | const |
Get the number of frames of the audio.
const uint switchboard::WavDecoder::getSampleRate | ( | ) | const |
Get the sample rate of the audio.
const bool switchboard::WavDecoder::read | ( | float * | outputBuffer, |
const uint | frameIndex, | ||
const uint | numberOfFrames | ||
) |
Gets the next available chunk of audio.
Returns false in case the frame index overflows.
Pads the end with zeros if there is not enough frames to read.
outputBuffer | The buffer that will contain the output samples. |
frameIndex | Reading starts at this frame index. |
numberOfFrames | The number of frames to put in the output buffer. |