arduino-audio-tools
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
VS1053Stream Class Reference

Output Interface which processes PCM data by default using a VS1053 audio module. If you want to write encoded data set is_encoded_data = true in the configuration. Many VS1053 modules also have a built in microphone that can be used for recording: set the mode to RX_MODE to use this. More...

#include <VS1053Stream.h>

Inheritance diagram for VS1053Stream:
AudioStream VolumeSupport BaseStream AudioInfoSupport AudioInfoSource Stream Print

Public Member Functions

 VS1053Stream ()=default
 
 ~VS1053Stream ()
 
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 ()
 
virtual int available () override
 
virtual int availableForWrite () override
 
float balance ()
 Get the currenet balance setting (-1.0..1.0)
 
bool begin ()
 Starts with the default config or restarts.
 
bool begin (VS1053Config cfg)
 Starts with the indicated configuration.
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
VS1053Config defaultConfig (RxTxMode mode=TX_MODE)
 Provides the default configuration for the indicated mod.
 
void end ()
 Stops the processing and releases the memory.
 
virtual void flush () override
 
VS1053getVS1053 ()
 returns the VS1053 object
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
virtual operator bool ()
 
virtual 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.
 
void setAudioInfo (AudioInfo c)
 Updates the AudioInfo (sample rate, bits, channels)
 
void setAudioInfo (VS1053Config c)
 defines the default configuration that is used with the next begin()
 
void setBalance (float bal)
 
bool setEncoder (AudioEncoder *enc)
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
bool setVolume (float vol) override
 value from 0 to 1.0
 
void setWriteBufferSize (int size)
 
float volume () override
 provides the volume
 
virtual size_t write (const uint8_t *data, size_t len) override
 Write audio 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 beginTx ()
 
void logError (const char *str)
 
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
 
VS1053Config cfg
 
CopyEncoder copy
 
AudioInfo info
 
bool is_notify_active = true
 
Vector< AudioInfoSupport * > notify_vector
 
AudioEncoderp_encoder = &wav
 
EncodedAudioStreamp_out = nullptr
 
VS1053p_vs1053 = nullptr
 
VS1053StreamOut * p_vs1053_out = nullptr
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
float volume_value = 1.0f
 
WAVEncoder wav
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

Output Interface which processes PCM data by default using a VS1053 audio module. If you want to write encoded data set is_encoded_data = true in the configuration. Many VS1053 modules also have a built in microphone that can be used for recording: set the mode to RX_MODE to use this.

Depends on https://github.com/pschatzmann/arduino-vs1053

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ VS1053Stream()

VS1053Stream ( )
default

◆ ~VS1053Stream()

~VS1053Stream ( )
inline

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ available()

virtual int available ( )
inlineoverridevirtualinherited

◆ availableForWrite()

virtual int availableForWrite ( )
inlineoverridevirtualinherited

◆ balance()

float balance ( )
inline

Get the currenet balance setting (-1.0..1.0)

◆ begin() [1/2]

bool begin ( )
inlinevirtual

Starts with the default config or restarts.

Reimplemented from BaseStream.

◆ begin() [2/2]

bool begin ( VS1053Config  cfg)
inline

Starts with the indicated configuration.

◆ beginTx()

bool beginTx ( )
inlineprotected

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ defaultConfig()

VS1053Config defaultConfig ( RxTxMode  mode = TX_MODE)
inline

Provides the default configuration for the indicated mod.

◆ end()

void end ( )
inlinevirtual

Stops the processing and releases the memory.

Reimplemented from BaseStream.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ getVS1053()

VS1053 & getVS1053 ( )
inline

returns the VS1053 object

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ logError()

void logError ( const char str)
inlineprotected

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

virtual size_t readBytes ( uint8_t data,
size_t  len 
)
inlineoverridevirtualinherited

◆ 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() [1/2]

void setAudioInfo ( AudioInfo  c)
inlinevirtual

Updates the AudioInfo (sample rate, bits, channels)

Reimplemented from AudioStream.

◆ setAudioInfo() [2/2]

void setAudioInfo ( VS1053Config  c)
inline

defines the default configuration that is used with the next begin()

◆ setBalance()

void setBalance ( float  bal)
inline

Adjusting the left and right volume balance, higher to enhance the right side, lower to enhance the left side.

◆ setEncoder()

bool setEncoder ( AudioEncoder enc)
inline

Defines an alternative encoder that will be used (e.g. MP3Encoder). It must be allocated on the heap!

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

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

◆ setVolume()

bool setVolume ( float  vol)
inlineoverridevirtual

value from 0 to 1.0

Reimplemented from VolumeSupport.

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ volume()

float volume ( )
inlineoverridevirtual

provides the volume

Reimplemented from VolumeSupport.

◆ write() [1/2]

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

Write audio data.

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

◆ cfg

VS1053Config cfg
protected

◆ copy

CopyEncoder copy
protected

◆ info

AudioInfo info
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ p_encoder

AudioEncoder* p_encoder = &wav
protected

◆ p_out

EncodedAudioStream* p_out = nullptr
protected

◆ p_vs1053

VS1053* p_vs1053 = nullptr
protected

◆ p_vs1053_out

VS1053StreamOut* p_vs1053_out = nullptr
protected

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ volume_value

float volume_value = 1.0f
protectedinherited

◆ wav

WAVEncoder wav
protected

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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