arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
InputMixer< T > Class Template Reference

MixerStream is mixing the input from Multiple Input Streams. All streams must have the same audo format (sample rate, channels, bits per sample). More...

#include <AudioStreams.h>

Inheritance diagram for InputMixer< T >:
AudioStream BaseStream AudioInfoSupport AudioInfoSource Stream Print

Public Member Functions

 InputMixer ()=default
 
int add (Stream &in, int weight=100)
 Adds a new input stream and returns it's actual index position.
 
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
 
virtual bool begin ()
 
virtual bool begin (AudioInfo info)
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
void end () override
 Remove all input streams.
 
virtual void flush () override
 
int indexOf (Stream &stream)
 Provides the actual index of the stream.
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
int nextEmptyIndex ()
 Provides you the index of the next empty stream. -1 when none is found.
 
virtual operator bool ()
 
Streamoperator[] (int idx)
 Provides the stream pointer at the indicated index.
 
size_t readBytes (uint8_t *data, size_t len) override
 Provides the data from all streams mixed together.
 
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
 
bool remove ()
 Removes all streams which have no data available.
 
bool remove (int idx)
 Removes a stream by index position.
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
bool set (int index, Stream &in)
 Replaces a stream at the indicated index.
 
virtual void setAudioInfo (AudioInfo newInfo) override
 Defines the input AudioInfo.
 
void setLimitToAvailableData (bool flag)
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
void setRetryCount (int retry)
 
void setWeight (int index, int weight)
 
void setWriteBufferSize (int size)
 
int size ()
 Number of stremams to which are mixed together.
 
virtual size_t write (const uint8_t *data, size_t len) override
 
virtual size_t write (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
 

Protected Member Functions

int availableBytes ()
 Provides the available bytes from the first stream with data.
 
virtual int not_supported (int out, const char *msg="")
 
void notifyAudioChange (AudioInfo info)
 
int readBytesVector (T *p_data, int byteCount)
 mixing using a vector of samples
 
void recalculateWeights ()
 Recalculate the weights.
 
void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
 
void resultAdd (float fact)
 
void resultClear ()
 

Protected Attributes

int _timeout = 10
 
Vector< Tcurrent_vect
 
int frame_size = 4
 
AudioInfo info
 
bool is_notify_active = true
 
bool limit_available_data = false
 
Vector< AudioInfoSupport * > notify_vector
 
Vector< intresult_vect
 
int retry_count = 5
 
Vector< Stream * > streams {0}
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
int total_weights = 0
 
Vector< intweights {0}
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

template<typename T>
class audio_tools::InputMixer< T >

MixerStream is mixing the input from Multiple Input Streams. All streams must have the same audo format (sample rate, channels, bits per sample).

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ InputMixer()

template<typename T >
InputMixer ( )
default

Member Function Documentation

◆ add()

template<typename T >
int add ( Stream in,
int  weight = 100 
)
inline

Adds a new input stream and returns it's actual index position.

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ available()

virtual int available ( )
inlineoverridevirtualinherited

◆ availableBytes()

template<typename T >
int availableBytes ( )
inlineprotected

Provides the available bytes from the first stream with data.

◆ availableForWrite()

virtual int availableForWrite ( )
inlineoverridevirtualinherited

◆ begin() [1/2]

virtual bool begin ( )
inlinevirtualinherited

◆ begin() [2/2]

template<typename T >
virtual bool begin ( AudioInfo  info)
inlinevirtual

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ end()

template<typename T >
void end ( )
inlineoverridevirtual

Remove all input streams.

Reimplemented from BaseStream.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ indexOf()

template<typename T >
int indexOf ( Stream stream)
inline

Provides the actual index of the stream.

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ nextEmptyIndex()

template<typename T >
int nextEmptyIndex ( )
inline

Provides you the index of the next empty stream. -1 when none is found.

◆ not_supported()

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

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

◆ operator[]()

template<typename T >
Stream * operator[] ( int  idx)
inline

Provides the stream pointer at the indicated index.

◆ readBytes()

template<typename T >
size_t readBytes ( uint8_t data,
size_t  len 
)
inlineoverridevirtual

Provides the data from all streams mixed together.

Reimplemented from AudioStream.

◆ readBytesVector()

template<typename T >
int readBytesVector ( T p_data,
int  byteCount 
)
inlineprotected

mixing using a vector of samples

◆ readSilence()

virtual size_t readSilence ( uint8_t buffer,
size_t  length 
)
inlinevirtualinherited

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

◆ recalculateWeights()

template<typename T >
void recalculateWeights ( )
inlineprotected

Recalculate the weights.

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

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

◆ remove() [1/2]

template<typename T >
bool remove ( )
inline

Removes all streams which have no data available.

◆ remove() [2/2]

template<typename T >
bool remove ( int  idx)
inline

Removes a stream by index position.

◆ removeNotifyAudioChange()

virtual bool removeNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

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

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ resultAdd()

template<typename T >
void resultAdd ( float  fact)
inlineprotected

◆ resultClear()

template<typename T >
void resultClear ( )
inlineprotected

◆ set()

template<typename T >
bool set ( int  index,
Stream in 
)
inline

Replaces a stream at the indicated index.

◆ setAudioInfo()

virtual void setAudioInfo ( AudioInfo  info)
inlineoverridevirtualinherited

◆ setLimitToAvailableData()

template<typename T >
void setLimitToAvailableData ( bool  flag)
inline

Limit the copy to the available data of all streams: stops to provide data when any stream has ended

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

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

◆ setRetryCount()

template<typename T >
void setRetryCount ( int  retry)
inline

Defines the maximum number of retrys to get data from an input before we abort the read and provide empty data

◆ setWeight()

template<typename T >
void setWeight ( int  index,
int  weight 
)
inline

Dynamically update the new weight for the indicated channel: If you set it to 0 it is muted (and the stream is not read any more). We recommend to use values between 1 and 100

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ size()

template<typename T >
int size ( )
inline

Number of stremams to which are mixed together.

◆ write() [1/2]

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

◆ 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

◆ current_vect

template<typename T >
Vector<T> current_vect
protected

◆ frame_size

template<typename T >
int frame_size = 4
protected

◆ info

AudioInfo info
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ limit_available_data

template<typename T >
bool limit_available_data = false
protected

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ result_vect

template<typename T >
Vector<int> result_vect
protected

◆ retry_count

template<typename T >
int retry_count = 5
protected

◆ streams

template<typename T >
Vector<Stream *> streams {0}
protected

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ total_weights

template<typename T >
int total_weights = 0
protected

◆ weights

template<typename T >
Vector<int> weights {0}
protected

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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