arduino-audio-tools
|
Adapter class which allows the AudioDecoder API on a StreamingDecoder. More...
#include <StreamingDecoder.h>
Public Member Functions | |
DecoderAdapter (StreamingDecoder &dec, int bufferSize) | |
Constructor. | |
virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
Adds target to be notified about audio changes. | |
AudioInfo | audioInfo () override |
provides the actual input AudioInfo | |
virtual AudioInfo | audioInfoOut () |
bool | begin () override |
Starts the processing. | |
virtual bool | begin (AudioInfo info) override |
virtual void | clearNotifyAudioChange () |
Deletes all change notify subscriptions. | |
void | end () override |
Stops the processing. | |
Print * | getOutput () |
StreamingDecoder * | getStreamingDecoder () |
Gets the wrapped StreamingDecoder. | |
bool | isNotifyActive () |
Checks if the automatic AudioInfo update is active. | |
virtual bool | isResultPCM () |
Returns true to indicate that the decoding result is PCM data. | |
operator bool () override | |
Checks if the adapter is active. | |
virtual bool | removeNotifyAudioChange (AudioInfoSupport &bi) |
Removes a target in order not to be notified about audio changes. | |
void | resize (int size) |
Resizes the internal buffer. | |
void | setAudioInfo (AudioInfo from) override |
for most decoders this is not needed | |
virtual bool | setCodecConfig (const uint8_t *data, size_t len) |
Some decoders need e.g. a magic cookie to provide the relevant info for decoding. | |
void | setInput (Stream &in) |
Sets the input stream for the wrapped decoder. | |
void | setNotifyActive (bool flag) |
Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
virtual void | setOutput (AudioOutput &out_stream) |
Defines where the decoded result is written to. | |
virtual void | setOutput (AudioStream &out_stream) |
Defines where the decoded result is written to. | |
void | setOutput (Print &out) override |
Defines the output Stream. | |
size_t | write (const uint8_t *data, size_t len) override |
Writes encoded audio data to be decoded. | |
Public Attributes | |
int | id |
custom id to be used by application | |
Protected Member Functions | |
void | notifyAudioChange (AudioInfo info) |
void | setupLazy () |
Performs lazy initialization of the ring buffer. | |
void | writeBlocking (Print *out, uint8_t *data, size_t len) |
Protected Attributes | |
bool | active = false |
Whether the adapter is active. | |
int | buffer_size |
Size of the ring buffer. | |
AudioInfo | info |
bool | is_notify_active = true |
bool | is_setup = false |
Whether lazy setup has been performed. | |
Vector< AudioInfoSupport * > | notify_vector |
StreamingDecoder * | p_dec = nullptr |
Wrapped StreamingDecoder instance. | |
Print * | p_print = nullptr |
QueueStream< uint8_t > | queue {rbuffer} |
Stream interface to the ring buffer. | |
RingBuffer< uint8_t > | rbuffer {0} |
Ring buffer for data storage. | |
Adapter class which allows the AudioDecoder API on a StreamingDecoder.
This adapter provides the reverse functionality of StreamingDecoderAdapter: it allows you to use a StreamingDecoder with the write-based AudioDecoder API. It uses a ring buffer and queue to convert write() calls into a stream that the StreamingDecoder can read from.
|
inline |
Constructor.
dec | The StreamingDecoder to wrap |
bufferSize | Size of the internal ring buffer for data transfer |
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, MP3DecoderHelix, MP3DecoderMAD, OggContainerDecoder, Pipeline, and Pipeline::ModifyingStreamAdapter.
|
inlineoverridevirtualinherited |
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in CodecNOP, GGWaveDecoder, DecoderBasic, DSFDecoder, MP3DecoderHelix, MP3DecoderMAD, OpusAudioDecoder, WAVDecoder, WavIMADecoder, and OggContainerDecoder.
|
inlinevirtualinherited |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in PureDataStream, PWMAudioOutput, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
|
inlineoverridevirtual |
Starts the processing.
Initializes the wrapped StreamingDecoder and marks this adapter as active.
Reimplemented from AudioDecoder.
|
inlineoverridevirtualinherited |
Reimplemented from AudioWriter.
|
inlineoverridevirtual |
Stops the processing.
Marks this adapter as inactive. The wrapped StreamingDecoder is not explicitly stopped to allow continued use.
Reimplemented from AudioDecoder.
|
inline |
Gets the wrapped StreamingDecoder.
Provides direct access to the underlying StreamingDecoder for advanced use cases.
|
inlinevirtualinherited |
Returns true to indicate that the decoding result is PCM data.
Reimplemented in CopyDecoder, DecoderNetworkFormat, GGWaveDecoder, and ContainerM4A.
|
inlineoverridevirtual |
Checks if the adapter is active.
Implements AudioWriter.
|
inline |
Resizes the internal buffer.
Changes the size of the ring buffer used for data transfer. The buffer is only allocated when first needed (lazy setup).
size | New buffer size in bytes |
|
inlineoverridevirtualinherited |
for most decoders this is not needed
Implements AudioWriter.
Reimplemented in GGWaveDecoder, DecoderALAC, CodecChain, DSFDecoder, DecoderL8, OpusAudioDecoder, CodecNOP, and G7xxDecoder.
|
inlinevirtualinherited |
Some decoders need e.g. a magic cookie to provide the relevant info for decoding.
Reimplemented in DecoderALAC, and MultiDecoder.
|
inline |
Sets the input stream for the wrapped decoder.
in | The input stream containing encoded audio data |
|
inlinevirtualinherited |
Defines where the decoded result is written to.
Reimplemented in ADTSDecoder, CodecChain, MTSDecoder, MTSDecoderTSDemux, and MetaDataFilterDecoder.
|
inlinevirtualinherited |
Defines where the decoded result is written to.
Reimplemented in ADTSDecoder, CodecChain, MTSDecoder, MTSDecoderTSDemux, and MetaDataFilterDecoder.
|
inlineoverridevirtual |
Defines the output Stream.
Sets the output stream for the wrapped StreamingDecoder.
out | The output stream for decoded audio data |
Reimplemented from AudioDecoder.
|
inlineprotected |
Performs lazy initialization of the ring buffer.
The ring buffer is only allocated when first needed to save memory.
|
inlineoverridevirtual |
Writes encoded audio data to be decoded.
The data is written to an internal queue, which is then processed by calling copy() on the wrapped StreamingDecoder.
data | Buffer containing encoded audio data |
len | Number of bytes to write |
Implements AudioWriter.