arduino-audio-tools
|
Converts any AudioDecoder to a StreamingDecoder. More...
#include <StreamingDecoder.h>
Public Member Functions | |
StreamingDecoderAdapter (AudioDecoder &decoder, const char *mimeStr, int copySize=DEFAULT_BUFFER_SIZE) | |
Constructor. | |
virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
Adds target to be notified about audio changes. | |
AudioInfo | audioInfo () override |
Provides the audio information. | |
virtual AudioInfo | audioInfoOut () |
bool | begin () override |
Starts the processing. | |
virtual void | clearNotifyAudioChange () |
Deletes all change notify subscriptions. | |
virtual bool | copy () override |
Process a single read operation - to be called in the loop. | |
bool | copyAll () |
Process all available data. | |
void | end () override |
Releases the reserved memory. | |
bool | isNotifyActive () |
Checks if the automatic AudioInfo update is active. | |
const char * | mime () override |
Provides the MIME type. | |
virtual | operator bool () override |
Checks if the class is active. | |
virtual bool | removeNotifyAudioChange (AudioInfoSupport &bi) |
Removes a target in order not to be notified about audio changes. | |
void | resize (int bufferSize) |
Adjust the buffer size. | |
void | setInput (Stream &inStream) |
Stream Interface: Decode directly by taking data from the stream. | |
void | setNotifyActive (bool flag) |
Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
virtual void | setOutput (AudioOutput &out_stream) |
Defines the output streams and register to be notified. | |
virtual void | setOutput (AudioStream &out_stream) |
Defines the output streams and register to be notified. | |
void | setOutput (Print &out_stream) override |
Defines the output Stream. | |
Protected Member Functions | |
void | notifyAudioChange (AudioInfo info) |
size_t | readBytes (uint8_t *data, size_t len) override |
Reads bytes from the input stream. | |
void | setAudioInfo (AudioInfo newInfo) override |
Defines the input AudioInfo. | |
Protected Attributes | |
Vector< uint8_t > | buffer {0} |
Internal buffer for data transfer. | |
AudioInfo | info |
bool | is_notify_active = true |
const char * | mime_str = nullptr |
MIME type string. | |
Vector< AudioInfoSupport * > | notify_vector |
AudioDecoder * | p_decoder = nullptr |
Wrapped AudioDecoder instance. | |
Stream * | p_input = nullptr |
Input stream for encoded audio data. | |
Print * | p_print = nullptr |
Output stream for decoded PCM data. | |
Converts any AudioDecoder to a StreamingDecoder.
This adapter class allows you to use any existing AudioDecoder with the StreamingDecoder interface. It handles the conversion between the write-based AudioDecoder API and the stream-based StreamingDecoder API by using an internal buffer.
|
inline |
Constructor.
decoder | The AudioDecoder to wrap |
mimeStr | The MIME type string for this decoder |
copySize | Buffer size for data transfer (default: DEFAULT_BUFFER_SIZE) |
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, MP3DecoderHelix, MP3DecoderMAD, OggContainerDecoder, Pipeline, and Pipeline::ModifyingStreamAdapter.
|
inlineoverridevirtual |
Provides the audio information.
Delegates to the wrapped decoder's audioInfo() method.
Implements StreamingDecoder.
|
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 decoder.
Implements StreamingDecoder.
|
inlineoverridevirtual |
Process a single read operation - to be called in the loop.
Reads data from the input stream into the internal buffer, then feeds it to the wrapped AudioDecoder for processing.
Implements StreamingDecoder.
|
inlineinherited |
Process all available data.
Convenience method that calls copy() repeatedly until all available data has been processed.
|
inlineoverridevirtual |
Releases the reserved memory.
Calls end() on the wrapped decoder to clean up resources.
Implements StreamingDecoder.
|
inlineoverridevirtual |
Provides the MIME type.
Returns the MIME type that was defined in the constructor.
Implements StreamingDecoder.
|
inlineoverridevirtual |
Checks if the class is active.
Implements StreamingDecoder.
|
inlineoverrideprotectedvirtual |
Reads bytes from the input stream.
data | Buffer to store the read data |
len | Maximum number of bytes to read |
Implements StreamingDecoder.
|
inline |
Adjust the buffer size.
Changes the internal buffer size. The existing content of the buffer is lost!
bufferSize | New buffer size in bytes |
|
inlineoverrideprotectedvirtualinherited |
Defines the input AudioInfo.
Implements AudioInfoSupport.
|
inlineinherited |
|
inlinevirtualinherited |
Defines the output streams and register to be notified.
Sets the output stream and registers for audio info change notifications.
out_stream | The AudioOutput to write decoded audio data to |
Reimplemented in MultiStreamingDecoder.
|
inlinevirtualinherited |
Defines the output streams and register to be notified.
Sets the output stream and registers for audio info change notifications.
out_stream | The AudioStream to write decoded audio data to |
Reimplemented in MultiStreamingDecoder.
|
inlineoverridevirtual |
Defines the output Stream.
Sets the output stream for the wrapped decoder.
out_stream | The output stream for decoded audio data |
Reimplemented from StreamingDecoder.