Interrupt-driven WAV decoder. Generates a full frame of samples each cycle and uses the RawBuffer to safely hand data from the app to the decompressor.
More...
#include <BackgroundAudioWAV.h>
|
| BackgroundAudioWAVClass (AudioOutputBase &d) |
| Construct an AAC decoder with a given AudioOutputBase.
|
|
bool | setDevice (AudioOutputBase *d) |
| Configure the output device before begin
|
|
void | setGain (float scale) |
| Set the gain multiplier (volume) for the stream. Takes effect immediately.
|
|
bool | begin () |
| Starts the background WAV decoder/player. Will initialize the output device and start sending silence immediately.
|
|
void | end () |
| Stops the WAV decoder process and the calls the output device's end to shut it down, too.
|
|
bool | playing () |
| Determines if the WAV decoder has been started.
|
|
size_t | write (const void *data, size_t len) |
| Writes a block of raw data to the decoder's buffer.
|
|
size_t | availableForWrite () |
| Gets number of bytes available to write to raw buffer.
|
|
size_t | available () |
| Gets number of bytes already in the raw buffer.
|
|
bool | done () |
| Determine if no more WAV file is present in the buffer.
|
|
uint32_t | frames () |
| Get number of "frames" processed by decoder.
|
|
uint32_t | shifts () |
| Get the number of input data shifts processed by decoder since begin
|
|
uint32_t | underflows () |
| Get the number of times the WAV decoder has underflowed waiting on raw data since begin
|
|
uint32_t | errors () |
| Get the number of decoder errors since begin
|
|
uint32_t | dumps () |
| Get the number of full buffer dumps (catastrophic data error) since begin
|
|
void | flush () |
| Flushes any existing WAV data, resets the processor to start a new WAV.
|
|
void | pause () |
| Pause the decoder. Won't process raw input data and will transmit silence.
|
|
bool | paused () |
| Determine if the WAV playback is paused.
|
|
void | unpause () |
| Unpause previously paused WAV playback. Will start processing input data again.
|
|
template<class DataBuffer>
class BackgroundAudioWAVClass< DataBuffer >
Interrupt-driven WAV decoder. Generates a full frame of samples each cycle and uses the RawBuffer to safely hand data from the app to the decompressor.
- Template Parameters
-
◆ BackgroundAudioWAVClass()
template<class DataBuffer >
Construct an AAC decoder with a given AudioOutputBase.
- Parameters
-
[in] | d | AudioOutputBase device (MixerInput or I2S or PWM, etc.) to decode tp |
◆ available()
template<class DataBuffer >
Gets number of bytes already in the raw buffer.
- Returns
- Bytes of raw data in the buffer
◆ availableForWrite()
template<class DataBuffer >
Gets number of bytes available to write to raw buffer.
For ROM buffers, this is always 0 after a write has happened. Because ROM buffers don't actually allocate any RAM for buffering and simply store the pointer passed in from write
there is no real space available for an app to write
to. An app can simply flush
and write
a new complete buffer if needed ignoring availableForWrite
in the ROM case.
- Returns
- Bytes that can be written
◆ begin()
template<class DataBuffer >
Starts the background WAV decoder/player. Will initialize the output device and start sending silence immediately.
- Returns
- True on success, false if already started.
◆ done()
template<class DataBuffer >
Determine if no more WAV file is present in the buffer.
- Returns
- True if no raw WAV data is still left to process
◆ dumps()
template<class DataBuffer >
Get the number of full buffer dumps (catastrophic data error) since begin
- Returns
- Number of complete buffer throw-aways
◆ errors()
template<class DataBuffer >
Get the number of decoder errors since begin
- Returns
- Number of decode errors encountered
◆ flush()
template<class DataBuffer >
Flushes any existing WAV data, resets the processor to start a new WAV.
This is only needed if the current WAV file was corrupted or to stop playing one WAV file and immediately start on a new one.
◆ frames()
template<class DataBuffer >
Get number of "frames" processed by decoder.
- Returns
- Number of frames, where frames are
framelen
stereo samples in size
◆ paused()
template<class DataBuffer >
Determine if the WAV playback is paused.
- Returns
- True of WAV playback has been paused
◆ playing()
template<class DataBuffer >
Determines if the WAV decoder has been started.
- Returns
- True if running
◆ setDevice()
template<class DataBuffer >
Configure the output device before begin
- Returns
- True if successful
◆ setGain()
template<class DataBuffer >
Set the gain multiplier (volume) for the stream. Takes effect immediately.
- Parameters
-
[in] | scale | Floating point value from 0.0....16.0 to multiply all audio data by |
◆ shifts()
template<class DataBuffer >
Get the number of input data shifts processed by decoder since begin
- Returns
- Number of times data has been shifted in the raw input buffer
◆ underflows()
template<class DataBuffer >
Get the number of times the WAV decoder has underflowed waiting on raw data since begin
- Returns
- Number of frames of underflow data have occurred
◆ write()
template<class DataBuffer >
Writes a block of raw data to the decoder's buffer.
Copies up to len
bytes into the raw buffer for the object. Can be called before begin
, and can write less fewer than the number of bytes requested if there is not enough space. Will not block.
For ROM buffers this does not actually copy data, only the pointer. Therefore, for ROM buffers you cannot concatenate data by calling multiple writes because the second write will throw out all the data from the first one. Use flush
and write
when ready for a completely new buffer.
- Parameters
-
[in] | data | Uncompressed input data |
[in] | len | Number of bytes to write |
- Returns
- Number of bytes written
The documentation for this class was generated from the following file: