arduino-audio-tools
|
Decoder for FLAC. Depends on https://github.com/pschatzmann/arduino-libflac. We support an efficient streaming API and an very memory intensitiv standard interface. So you should prefer the streaming interface where you call setOutput() before the begin and copy() in the loop. Validated with http://www.2l.no/hires/. More...
#include <CodecFLAC.h>
Public Member Functions | |
FLACDecoder (bool isOgg=false) | |
Default Constructor. | |
~FLACDecoder () | |
Destructor - calls end();. | |
virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
Adds target to be notified about audio changes. | |
AudioInfo | audioInfo () |
Provides the audio information for the current stream. | |
virtual AudioInfo | audioInfoOut () |
bool | begin () |
Starts the processing. | |
virtual void | clearNotifyAudioChange () |
Deletes all change notify subscriptions. | |
bool | copy () |
Stream Interface: Process a single frame - only relevant when input stream has been defined. | |
bool | copyAll () |
Process all available data. | |
void | end () |
Releases the reserved memory. | |
void | flush () |
Process all data in the buffer. | |
bool | isNotifyActive () |
Checks if the automatic AudioInfo update is active. | |
bool | isOgg () const |
returns true of the stream is ogg | |
const char * | mime () override |
Provides "audio/flac" or "audio/ogg". | |
operator bool () | |
Checks if the class is active. | |
virtual bool | removeNotifyAudioChange (AudioInfoSupport &bi) |
Removes a target in order not to be notified about audio changes. | |
void | setInput (Stream &inStream) |
Stream Interface: Decode directly by taking data from the stream. | |
void | setMD5 (bool flag) |
Activate/deactivate md5 checking: call this before calling begin() | |
void | setNotifyActive (bool flag) |
Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
void | setOgg (bool isOgg) |
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. | |
virtual void | setOutput (Print &out_stream) |
Defines the output Stream. | |
void | setTimeout (uint64_t readTimeout=10000) |
Protected Member Functions | |
bool | isEof (int bytes) |
We return eof when we were subsequently getting 0 bytes for the timeout period. | |
bool | isInputFromStream () |
Check if input is directly from stream - instead of writes. | |
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 | |
FLAC__StreamDecoder * | decoder = nullptr |
AudioInfo | info |
FLAC__StreamDecoderInitStatus | init_status |
bool | is_active = false |
bool | is_md5_checing = false |
bool | is_notify_active = true |
bool | is_ogg = false |
Vector< AudioInfoSupport * > | notify_vector |
Stream * | p_input = nullptr |
Input stream for encoded audio data. | |
Print * | p_print = nullptr |
Output stream for decoded PCM data. | |
uint64_t | read_timeout_ms = 10000 |
uint64_t | time_last_read = 0 |
Decoder for FLAC. Depends on https://github.com/pschatzmann/arduino-libflac. We support an efficient streaming API and an very memory intensitiv standard interface. So you should prefer the streaming interface where you call setOutput() before the begin and copy() in the loop. Validated with http://www.2l.no/hires/.
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, MP3DecoderHelix, MP3DecoderMAD, OggContainerDecoder, Pipeline, and Pipeline::ModifyingStreamAdapter.
|
inlinevirtual |
Provides the audio information for the current stream.
Returns audio format information such as sample rate, channels, and bits per sample that was determined from the decoded audio stream.
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 >.
|
inlinevirtual |
Starts the processing.
Initializes the decoder and prepares it for processing audio data. Must be called before any copy() operations.
Implements StreamingDecoder.
|
inlinevirtual |
Stream Interface: Process a single frame - only relevant when input stream has been defined.
Implements StreamingDecoder.
|
inlineinherited |
Process all available data.
Convenience method that calls copy() repeatedly until all available data has been processed.
|
inlinevirtual |
Releases the reserved memory.
Cleans up any resources allocated by the decoder and stops processing.
Implements StreamingDecoder.
|
inlineoverridevirtual |
Provides "audio/flac" or "audio/ogg".
Implements StreamingDecoder.
|
inlinevirtual |
Checks if the class is active.
Implements StreamingDecoder.
|
inlineoverrideprotectedvirtual |
Reads bytes from the input stream.
Derived classes must implement this to read data from their input source.
data | Buffer to store the read data |
len | Maximum number of bytes to read |
Implements StreamingDecoder.
|
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.
|
inlinevirtualinherited |
Defines the output Stream.
Sets where the decoded PCM audio data will be written to.
out_stream | The Print stream to write decoded audio data to |
Reimplemented in StreamingDecoderAdapter, and MultiStreamingDecoder.