arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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 Stream Print

Public Member Functions

 AnalogAudioStream ()=default
 Default constructor.
 
 AnalogAudioStream (AnalogDriverBase &driver)
 Constructor to define a custom driver.
 
virtual ~AnalogAudioStream ()
 Destructor.
 
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
 
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
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.
 
AnalogConfigconfig ()
 
AnalogConfig defaultConfig (RxTxMode mode=TX_MODE)
 Provides the default configuration.
 
AnalogDriverBasedriver ()
 Provides access to the driver.
 
void end () override
 stops the I2S and unistalls the analog
 
virtual void flush () override
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
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 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
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
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).
 

Protected Member Functions

virtual int not_supported (int out, const char *msg="")
 
void notifyAudioChange (AudioInfo info)
 
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 default_analog
 
AudioInfo info
 
bool is_notify_active = true
 
Vector< AudioInfoSupport * > notify_vector
 
AnalogDriverBasep_analog = &default_analog
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
int write_buffer_size = MAX_SINGLE_CHARS
 

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 to define a custom driver.

◆ ~AnalogAudioStream()

virtual ~AnalogAudioStream ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ 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()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ 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()

virtual void flush ( )
inlineoverridevirtualinherited

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ not_supported()

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

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

◆ readBytes()

size_t readBytes ( uint8_t data,
size_t  len 
)
inlineoverridevirtual

Reimplemented from AudioStream.

◆ readSilence()

virtual size_t readSilence ( uint8_t buffer,
size_t  length 
)
inlinevirtualinherited

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

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

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

◆ removeNotifyAudioChange()

virtual bool removeNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

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

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ setAudioInfo()

virtual void setAudioInfo ( AudioInfo  info)
inlinevirtual

updates the sample rate dynamically

Reimplemented from AudioStream.

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

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

◆ setWriteBufferSize()

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]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

◆ writeSilence()

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

◆ default_analog

AnalogDriver default_analog
protected

◆ info

AudioInfo info
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ p_analog

AnalogDriverBase* p_analog = &default_analog
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 = MAX_SINGLE_CHARS
protectedinherited

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