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

Stream that provides audio information that was generated using the Mozzi API using the updateControl() and updateAudio() methods. More...

#include <MozziStream.h>

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

Public Member Functions

 MozziStream ()=default
 
 MozziStream (Stream &in)
 
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
 
AudioInfo audioInfo ()
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 
int audioRate ()
 
virtual int available () override
 
virtual int availableForWrite () override
 
bool begin ()
 
bool begin (MozziConfig cfg)
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
MozziConfig defaultConfig ()
 
void end ()
 
virtual void flush () override
 
int getAudioInput ()
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
virtual operator bool ()
 
size_t readBytes (uint8_t *data, size_t len)
 Provides the data filled by calling updateAudio()
 
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 info)
 Defines the input AudioInfo.
 
void setInput (Stream &in)
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
virtual bool setVolume (float volume)
 define the actual volume in the range of 0.0f to 1.0f
 
bool setVolume (int16_t vol)
 Defines the multiplication factor to scale the Mozzi value range to int16_t.
 
void setWriteBufferSize (int size)
 
virtual float volume ()
 provides the actual volume in the range of 0.0f to 1.0f
 
size_t write (const uint8_t *data, size_t len)
 Write data to buffer so that we can access them by calling getAudioInput()
 
virtual size_t write (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
 

Protected Member Functions

int16_t avg (int16_t *values)
 
int16_t nextSample ()
 
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
 
bool active = false
 
RingBuffer< uint8_tbuffer {0}
 
MozziConfig cfg
 
int control_counter
 
int control_counter_max
 
AudioInfo info
 
int input_max = -32768
 
int input_min = 32767
 
bool is_notify_active = true
 
Vector< AudioInfoSupport * > notify_vector
 
Streamp_input = nullptr
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
float volume_value = 1.0f
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

Stream that provides audio information that was generated using the Mozzi API using the updateControl() and updateAudio() methods.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ MozziStream() [1/2]

MozziStream ( )
default

◆ MozziStream() [2/2]

MozziStream ( Stream in)
inline

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ audioInfo()

AudioInfo audioInfo ( )
inlinevirtual

provides the actual input AudioInfo

Reimplemented from AudioStream.

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ audioRate()

int audioRate ( )
inline

◆ available()

virtual int available ( )
inlineoverridevirtualinherited

◆ availableForWrite()

virtual int availableForWrite ( )
inlineoverridevirtualinherited

◆ avg()

int16_t avg ( int16_t values)
inlineprotected

◆ begin() [1/2]

bool begin ( )
inlinevirtual

Reimplemented from BaseStream.

◆ begin() [2/2]

bool begin ( MozziConfig  cfg)
inline

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ defaultConfig()

MozziConfig defaultConfig ( )
inline

◆ end()

void end ( )
inlinevirtual

Reimplemented from BaseStream.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ getAudioInput()

int getAudioInput ( )
inline

Gets the next audio value either from the assigned Input Stream or the buffer that was filled by write(). The data range is defined in MozziConfig

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ nextSample()

int16_t nextSample ( )
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()

size_t readBytes ( uint8_t data,
size_t  len 
)
inlinevirtual

Provides the data filled by calling updateAudio()

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

void setAudioInfo ( AudioInfo  info)
inlinevirtual

Defines the input AudioInfo.

Reimplemented from AudioStream.

◆ setInput()

void setInput ( Stream in)
inline

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

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

◆ setVolume() [1/2]

virtual bool setVolume ( float  volume)
inlinevirtualinherited

define the actual volume in the range of 0.0f to 1.0f

Reimplemented in Maximilian, I2SCodecStream, VS1053Stream, VolumeStream, A2DPStream, and AudioPlayer.

◆ setVolume() [2/2]

bool setVolume ( int16_t  vol)
inline

Defines the multiplication factor to scale the Mozzi value range to int16_t.

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ volume()

virtual float volume ( )
inlinevirtualinherited

provides the actual volume in the range of 0.0f to 1.0f

Reimplemented in I2SCodecStream, VS1053Stream, AudioPlayer, and VolumeStream.

◆ write() [1/2]

size_t write ( const uint8_t data,
size_t  len 
)
inlinevirtual

Write data to buffer so that we can access them by calling getAudioInput()

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

◆ active

bool active = false
protected

◆ buffer

RingBuffer<uint8_t> buffer {0}
protected

◆ cfg

MozziConfig cfg
protected

◆ control_counter

int control_counter
protected

◆ control_counter_max

int control_counter_max
protected

◆ info

AudioInfo info
protectedinherited

◆ input_max

int input_max = -32768
protected

◆ input_min

int input_min = 32767
protected

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ p_input

Stream* p_input = 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

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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