arduino-audio-tools
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
FLACDecoder Class Reference

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>

Inheritance diagram for FLACDecoder:
StreamingDecoder AudioInfoSource

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 last available MP3FrameInfo.
 
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.
 
void end ()
 Releases the reserved memory.
 
void flush ()
 Process all data in the buffer.
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
 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)
 
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
 

Static Protected Member Functions

static void error_callback (const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
 Error callback.
 
static FLAC__StreamDecoderReadStatus read_callback (const FLAC__StreamDecoder *decoder, FLAC__byte result_buffer[], size_t *bytes, void *client_data)
 Callback which reads from stream.
 
static FLAC__StreamDecoderWriteStatus write_callback (const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data)
 Output decoded result to final output stream.
 

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
 
Streamp_input = nullptr
 
Printp_print = nullptr
 
uint64_t read_timeout_ms = 10000
 
uint64_t time_last_read = 0
 

Detailed Description

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/.

Author
Phil Schatzmann

Member Function Documentation

◆ setInput()

void setInput ( Stream inStream)
inlineinherited

Stream Interface: Decode directly by taking data from the stream. This is more efficient then feeding the decoder with write: just call copy() in the loop


The documentation for this class was generated from the following file: