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

A more natural Stream class to process encoded data (aac, wav, mp3...) which also supports the decoding by calling readBytes(). More...

#include <AudioEncoded.h>

Inheritance diagram for EncodedAudioStream:
EncodedAudioOutput AudioStream Stream AudioInfoSupport AudioInfoSource Print

Public Member Functions

 EncodedAudioStream (AudioDecoder *decoder)
 
 EncodedAudioStream (AudioOutput *outputStream, AudioDecoder *decoder)
 
 EncodedAudioStream (AudioStream *ioStream, AudioDecoder *decoder)
 
 EncodedAudioStream (Print *outputStream, AudioDecoder *decoder)
 
 EncodedAudioStream (Print *outputStream, AudioEncoder *encoder)
 
 EncodedAudioStream (Stream *ioStream, AudioDecoder *decoder)
 
void addNotifyAudioChange (AudioInfoSupport &bi) override
 Define object which need to be notified if the basinfo is changing.
 
virtual AudioInfo audioInfo () override
 
int available () override
 
int availableForWrite () override
 
bool begin () override
 Starts the processing - sets the status to active.
 
virtual bool begin (AudioInfo cfg)
 Starts the processing - sets the status to active.
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
AudioDecoderdecoder ()
 Provides the initialized decoder.
 
AudioInfo defaultConfig ()
 
AudioEncoderencoder ()
 Provides the initialized encoder.
 
void end () override
 Ends the processing.
 
virtual void flush () override
 
AudioDecodergetDecoder ()
 
AudioEncodergetEncoder ()
 
bool isCheckAvailableForWrite ()
 Is Available for Write check activated ?
 
 operator bool ()
 Returns true if status is active and we still have data to be processed.
 
size_t readBytes (uint8_t *buffer, size_t length) override
 
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
void resize ()
 setup default size for buffer
 
void resize (int size)
 Defines the buffer size.
 
virtual void setAudioInfo (AudioInfo info) override
 
void setDecoder (AudioDecoder *decoder)
 
void setEncoder (AudioEncoder *encoder)
 
void setFrameSize (int size)
 defines the size of the decoded frame in bytes
 
void setInput (Stream *ioStream)
 Same as setStream()
 
void setLogLevel (AudioLogger::LogLevel level)
 Defines the class specific custom log level.
 
virtual void setNotifyAudioChange (AudioInfoSupport &bi)
 Obsolete: Use addNotifyAudioChange.
 
void setOutput (Print *outputStream)
 Defines the output.
 
void setStream (Print *outputStream)
 The same as setOutput.
 
void setStream (Stream *ioStream)
 Defines the input/output stream for decoding.
 
virtual size_t write (const uint8_t *data, size_t len) override
 encodeor decode the data
 
virtual size_t write (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
 

Protected Member Functions

bool contains (AudioInfoSupport &bi)
 
void decode (int requestedBytes)
 
virtual int not_supported (int out, const char *msg="")
 
void notifyAudioChange (AudioInfo info)
 
void refillReadBuffer ()
 
void setupOnce ()
 

Protected Attributes

int _timeout = 10
 
bool active = false
 
bool check_available_for_write = false
 
Vector< uint8_t > copy_buffer {DEFAULT_BUFFER_SIZE}
 
CustomLogLevel custom_log_level
 
RingBuffer< uint8_t > decoded_buffer {0}
 
AudioDecoderdecoder_ptr = CodecNOP::instance()
 
AudioEncoderencoder_ptr = CodecNOP::instance()
 
int frame_size = DEFAULT_BUFFER_SIZE
 
AudioInfo info
 
bool is_setup = false
 
int max_read_count = 5
 
Vector< AudioInfoSupport * > notify_vector
 
Streamp_stream = nullptr
 
AudioWriterp_write = nullptr
 
Printptr_out = nullptr
 
QueueStream< uint8_t > queue_stream {decoded_buffer}
 
int reqested_bytes = DEFAULT_BUFFER_SIZE
 
RingBuffer< uint8_t > tmp_in {0}
 
RingBuffer< uint8_t > tmp_out {0}
 
AudioWriterwriter_ptr = nullptr
 

Detailed Description

A more natural Stream class to process encoded data (aac, wav, mp3...) which also supports the decoding by calling readBytes().

Author
Phil Schatzmann

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