arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
audio_tools::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 setOutputStream() before the begin and copy() in the loop. Validated with http://www.2l.no/hires/. More...

#include <CodecFLAC.h>

Inheritance diagram for audio_tools::FLACDecoder:
audio_tools::StreamingDecoder

Public Member Functions

 FLACDecoder (bool isFLAC=false)
 
AudioBaseInfo audioInfo ()
 Provides the last available MP3FrameInfo. More...
 
void begin ()
 Starts the processing. More...
 
bool copy ()
 Stream Interface: Process a single frame - only relevant when input stream has been defined. More...
 
void end ()
 Releases the reserved memory. More...
 
void flush ()
 Process all data in the buffer.
 
 operator bool ()
 checks if the class is active More...
 
void setInputStream (Stream &input)
 
void setNotifyAudioChange (AudioBaseInfoDependent &bi)
 Register Output Stream to be notified about changes. More...
 
void setOgg (bool isOgg)
 
virtual void setOutputStream (Print &out_stream)
 Defines the output Stream. More...
 
void setTimeout (uint64_t readTimeout=FLAC_READ_TIMEOUT_MS)
 
- Public Member Functions inherited from audio_tools::StreamingDecoder
virtual AudioBaseInfo audioInfo ()=0
 Provides the last available MP3FrameInfo. More...
 
virtual void begin ()=0
 Starts the processing. More...
 
virtual bool copy ()=0
 Process a single read operation - to be called in the loop. More...
 
virtual void end ()=0
 Releases the reserved memory. More...
 
virtual operator bool ()=0
 checks if the class is active More...
 
virtual void setInputStream (Stream &inStream)=0
 Defines the input data stream. More...
 
virtual void setNotifyAudioChange (AudioBaseInfoDependent &bi)=0
 Register Output Stream to be notified about changes. More...
 
virtual void setOutputStream (AudioPrint &out_stream)
 Defines the output streams and register to be notified.
 
virtual void setOutputStream (AudioStream &out_stream)
 Defines the output streams and register to be notified.
 
virtual void setOutputStream (Print &outStream)=0
 Defines the output Stream. More...
 

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.
 
size_t readBytes (uint8_t *buffer, size_t len) override
 
virtual size_t readBytes (uint8_t *buffer, size_t len)=0
 

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
 
AudioBaseInfo info
 
FLAC__StreamDecoderInitStatus init_status
 
bool is_active = false
 
bool is_ogg = false
 
Streamp_input = nullptr
 
AudioBaseInfoDependentp_notify = nullptr
 
Printp_print = nullptr
 
uint64_t read_timeout_ms = FLAC_READ_TIMEOUT_MS
 
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 setOutputStream() before the begin and copy() in the loop. Validated with http://www.2l.no/hires/.

Author
Phil Schatzmann

Member Function Documentation

◆ audioInfo()

AudioBaseInfo audio_tools::FLACDecoder::audioInfo ( )
inlinevirtual

Provides the last available MP3FrameInfo.

Implements audio_tools::StreamingDecoder.

◆ begin()

void audio_tools::FLACDecoder::begin ( )
inlinevirtual

Starts the processing.

Implements audio_tools::StreamingDecoder.

◆ copy()

bool audio_tools::FLACDecoder::copy ( )
inlinevirtual

Stream Interface: Process a single frame - only relevant when input stream has been defined.

Implements audio_tools::StreamingDecoder.

◆ end()

void audio_tools::FLACDecoder::end ( )
inlinevirtual

Releases the reserved memory.

Implements audio_tools::StreamingDecoder.

◆ operator bool()

audio_tools::FLACDecoder::operator bool ( )
inlinevirtual

checks if the class is active

Implements audio_tools::StreamingDecoder.

◆ readBytes()

size_t audio_tools::FLACDecoder::readBytes ( uint8_t *  buffer,
size_t  len 
)
inlineoverrideprotectedvirtual

◆ setInputStream()

void audio_tools::FLACDecoder::setInputStream ( Stream input)
inlinevirtual

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

Implements audio_tools::StreamingDecoder.

◆ setNotifyAudioChange()

void audio_tools::FLACDecoder::setNotifyAudioChange ( AudioBaseInfoDependent bi)
inlinevirtual

Register Output Stream to be notified about changes.

Implements audio_tools::StreamingDecoder.

◆ setOutputStream()

virtual void audio_tools::FLACDecoder::setOutputStream ( Print outStream)
inlinevirtual

Defines the output Stream.

Implements audio_tools::StreamingDecoder.


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