arduino-audio-tools
Loading...
Searching...
No Matches
AnalogAudioStream Class Reference

ESP32: A very fast ADC and DAC using the ESP32 I2S interface. For all other architectures we support reading of audio only using analog input with a timer. More...

#include <AnalogAudioStream.h>

Inheritance diagram for AnalogAudioStream:
AudioStream BaseStream AudioInfoSupport AudioInfoSource BaseStream AudioInfoSupport AudioInfoSource Stream Stream Stream Stream Print Print Print Print Print Print Print Print

Public Member Functions

 AnalogAudioStream ()=default
 Default constructor.
 AnalogAudioStream (AnalogDriverBase &driver)
 Constructor with alternative driver.
virtual ~AnalogAudioStream ()
 Destructor.
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
virtual AudioInfo audioInfoOut ()
virtual AudioInfo audioInfoOut ()
int available () override
int availableForWrite () override
bool begin () override
 Reopen with last config.
bool begin (AnalogConfig cfg)
 starts the DAC
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
AnalogConfig & config ()
AnalogConfig defaultConfig (RxTxMode mode=TX_MODE)
 Provides the default configuration.
AnalogDriverBase * driver ()
 Provides access to the driver.
void end () override
 stops the I2S and unistalls the analog
virtual void flush () override
virtual void flush () override
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
virtual operator bool ()
virtual operator bool ()
size_t readBytes (uint8_t *data, size_t len) override
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
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.
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
virtual void setAudioInfo (AudioInfo info)
 updates the sample rate dynamically
virtual void setAudioInfo (AudioInfo newInfo) override
 Defines the input AudioInfo.
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active).
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active).
void setWriteBufferSize (int size)
void setWriteBufferSize (int size)
size_t write (const uint8_t *data, size_t len) override
 ESP32 only: writes the data to the I2S interface.
virtual size_t write (uint8_t ch) override
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).

Protected Member Functions

virtual int not_supported (int out, const char *msg="")
virtual int not_supported (int out, const char *msg="")
void notifyAudioChange (AudioInfo info)
void notifyAudioChange (AudioInfo info)
void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().
void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().

Protected Attributes

int _timeout = 10
AnalogConfig adc_config
AnalogDriver analog_driver
AudioInfo info
bool is_notify_active = true
Vector< AudioInfoSupport * > notify_vector
AnalogDriverBase * p_driver = &analog_driver
RingBuffer< uint8_t > tmp_in {0}
RingBuffer< uint8_t > tmp_out {0}
int write_buffer_size = 8

Detailed Description

ESP32: A very fast ADC and DAC using the ESP32 I2S interface. For all other architectures we support reading of audio only using analog input with a timer.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ AnalogAudioStream() [1/2]

AnalogAudioStream ( )
default

Default constructor.

◆ AnalogAudioStream() [2/2]

AnalogAudioStream ( AnalogDriverBase & driver)
inline

Constructor with alternative driver.

◆ ~AnalogAudioStream()

virtual ~AnalogAudioStream ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ addNotifyAudioChange() [1/2]

virtual void addNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Adds target to be notified about audio changes.

Reimplemented in CodecNOP, CodecNOP, EncodedAudioOutput, and EncodedAudioStream.

◆ addNotifyAudioChange() [2/2]

virtual void addNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Adds target to be notified about audio changes.

Reimplemented in CodecNOP, CodecNOP, EncodedAudioOutput, and EncodedAudioStream.

◆ audioInfo() [1/2]

◆ audioInfo() [2/2]

◆ audioInfoOut() [1/2]

◆ audioInfoOut() [2/2]

◆ available()

int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite()

int availableForWrite ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ begin() [1/2]

bool begin ( )
inlineoverridevirtual

Reopen with last config.

Reimplemented from BaseStream.

◆ begin() [2/2]

bool begin ( AnalogConfig cfg)
inline

starts the DAC

◆ clearNotifyAudioChange() [1/2]

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

◆ clearNotifyAudioChange() [2/2]

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

◆ config()

AnalogConfig & config ( )
inline

◆ defaultConfig()

AnalogConfig defaultConfig ( RxTxMode mode = TX_MODE)
inline

Provides the default configuration.

◆ driver()

AnalogDriverBase * driver ( )
inline

Provides access to the driver.

◆ end()

void end ( )
inlineoverridevirtual

stops the I2S and unistalls the analog

Reimplemented from BaseStream.

◆ flush() [1/2]

◆ flush() [2/2]

◆ isNotifyActive() [1/2]

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ isNotifyActive() [2/2]

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ not_supported() [1/2]

virtual int not_supported ( int out,
const char * msg = "" )
inlineprotectedvirtualinherited

◆ not_supported() [2/2]

virtual int not_supported ( int out,
const char * msg = "" )
inlineprotectedvirtualinherited

◆ notifyAudioChange() [1/2]

void notifyAudioChange ( AudioInfo info)
inlineprotectedinherited

◆ notifyAudioChange() [2/2]

void notifyAudioChange ( AudioInfo info)
inlineprotectedinherited

◆ operator bool() [1/2]

◆ operator bool() [2/2]

◆ readBytes()

size_t readBytes ( uint8_t * data,
size_t len )
inlineoverridevirtual

Reimplemented from AudioStream.

◆ readSilence() [1/2]

virtual size_t readSilence ( uint8_t * buffer,
size_t length )
inlinevirtualinherited

Source to generate silence: just sets the buffer to 0.

◆ readSilence() [2/2]

virtual size_t readSilence ( uint8_t * buffer,
size_t length )
inlinevirtualinherited

Source to generate silence: just sets the buffer to 0.

◆ refillReadBuffer() [1/2]

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().

◆ refillReadBuffer() [2/2]

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().

◆ removeNotifyAudioChange() [1/2]

virtual bool removeNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

◆ removeNotifyAudioChange() [2/2]

virtual bool removeNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

◆ setAudioInfo() [1/2]

virtual void setAudioInfo ( AudioInfo info)
inlinevirtual

updates the sample rate dynamically

◆ setAudioInfo() [2/2]

◆ setNotifyActive() [1/2]

void setNotifyActive ( bool flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active).

◆ setNotifyActive() [2/2]

void setNotifyActive ( bool flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active).

◆ setWriteBufferSize() [1/2]

void setWriteBufferSize ( int size)
inlineinherited

◆ setWriteBufferSize() [2/2]

void setWriteBufferSize ( int size)
inlineinherited

◆ write() [1/2]

size_t write ( const uint8_t * data,
size_t len )
inlineoverridevirtual

ESP32 only: writes the data to the I2S interface.

Reimplemented from AudioStream.

◆ write() [2/2]

◆ writeSilence() [1/2]

virtual void writeSilence ( size_t len)
inlinevirtualinherited

Writes len bytes of silence (=0).

◆ writeSilence() [2/2]

virtual void writeSilence ( size_t len)
inlinevirtualinherited

Writes len bytes of silence (=0).

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ adc_config

AnalogConfig adc_config
protected

◆ analog_driver

AnalogDriver analog_driver
protected

◆ info

AudioInfo info
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ notify_vector

Vector< AudioInfoSupport * > notify_vector
protectedinherited

◆ p_driver

AnalogDriverBase* p_driver = &analog_driver
protected

◆ tmp_in

RingBuffer< uint8_t > tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer< uint8_t > tmp_out {0}
protectedinherited

◆ write_buffer_size

int write_buffer_size = 8
protectedinherited

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