The class for decoding compressed audio file to PCM buffer.
More...
#include <AudioDecoder.h>
Inherited by AudioDecoderEXT, AudioDecoderMp3, AudioDecoderOgg, and AudioDecoderWav.
|
virtual bool | open (std::string_view path)=0 |
| Opens an audio file specified by a file path.
|
|
virtual bool | isOpened () const |
| Checks whether decoder has opened file successfully.
|
|
virtual void | close ()=0 |
| Closes opened audio file.
|
|
virtual uint32_t | read (uint32_t framesToRead, char *pcmBuf)=0 |
| Reads audio frames of PCM format.
|
|
virtual uint32_t | readFixedFrames (uint32_t framesToRead, char *pcmBuf) |
| Reads fixed audio frames of PCM format.
|
|
virtual bool | seek (uint32_t frameOffset)=0 |
| Sets frame offest to be read.
|
|
virtual uint32_t | getTotalFrames () const |
| Gets total frames of current audio.
|
|
virtual uint32_t | framesToBytes (uint32_t frames) const |
| The helper function for convert frames to bytes.
|
|
virtual uint32_t | bytesToFrames (uint32_t bytes) const |
| The helper function for convert bytes to frames.
|
|
virtual uint32_t | getSampleRate () const |
| Gets sample rate of current audio.
|
|
virtual uint32_t | getChannelCount () const |
| Gets the channel count of current audio.
|
|
The class for decoding compressed audio file to PCM buffer.
◆ open()
virtual bool open |
( |
std::string_view | path | ) |
|
|
pure virtual |
◆ isOpened()
virtual bool isOpened |
( |
| ) |
const |
|
virtual |
Checks whether decoder has opened file successfully.
- Returns
- true if succeed, otherwise false.
◆ close()
◆ read()
virtual uint32_t read |
( |
uint32_t | framesToRead, |
|
|
char * | pcmBuf ) |
|
pure virtual |
Reads audio frames of PCM format.
- Parameters
-
framesToRead | The number of frames excepted to be read. |
pcmBuf | The buffer to hold the frames to be read, its size should be >= |framesToRead| / samplesPerBlock * _bytesPerBlock. |
- Returns
- The number of frames actually read, it's probably less than 'framesToRead'. Returns 0 means reach the end of file.
Implemented in AudioDecoderEXT, AudioDecoderMp3, AudioDecoderOgg, and AudioDecoderWav.
◆ readFixedFrames()
virtual uint32_t readFixedFrames |
( |
uint32_t | framesToRead, |
|
|
char * | pcmBuf ) |
|
virtual |
Reads fixed audio frames of PCM format.
- Parameters
-
framesToRead | The number of frames excepted to be read. |
pcmBuf | The buffer to hold the frames to be read, its size should be >= |framesToRead| / samplesPerBlock * _bytesPerBlock. |
- Returns
- The number of frames actually read, it's probably less than |framesToRead|. Returns 0 means reach the end of file.
- Note
- The different between |read| and |readFixedFrames| is |readFixedFrames| will do multiple reading operations if |framesToRead| frames isn't filled entirely, while |read| just does reading operation once whatever |framesToRead| is or isn't filled entirely. If current position reaches the end of frames, the return value may smaller than |framesToRead| and the remaining buffer in |pcmBuf| will be set with silence data (0x00).
◆ seek()
virtual bool seek |
( |
uint32_t | frameOffset | ) |
|
|
pure virtual |
◆ getChannelCount()
virtual uint32_t getChannelCount |
( |
| ) |
const |
|
virtual |
Gets the channel count of current audio.
- Note
- Currently we only support 1 or 2 channels.
The documentation for this class was generated from the following file: