arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
OutputMixer< T > Class Template Reference

Mixing of multiple outputs to one final output. By default a RingBuffer is used as buffer type. More...

#include <AudioOutput.h>

Inheritance diagram for OutputMixer< T >:
Print

Public Member Functions

 OutputMixer (Print &finalOutput, int outputStreamCount)
 
int available (int idx)
 Provides the available bytes in the buffer.
 
int availableForWrite () override
 Provides the bytes available to write for the current stream buffer.
 
int availableForWrite (int idx)
 Provides the bytes available to write for the indicated stream index.
 
int availablePercent (int idx)
 Provides the % fill level of the buffer for the indicated index.
 
int availableSamples ()
 
bool begin (int copy_buffer_size_bytes=DEFAULT_BUFFER_SIZE)
 Starts the processing.
 
void end ()
 Remove all input streams.
 
virtual void flush ()
 
void flushMixer ()
 Force output to final destination.
 
BaseBuffer< T > * getBuffer (int idx)
 Provides the write buffer for the indicated index.
 
void next ()
 Moves to the next mixing index.
 
void resize (int size)
 Resizes the buffer to the indicated number of bytes.
 
void setAutoIndex (bool flag)
 Automatically increment mixing index after each write.
 
void setCreateBufferCallback (BaseBuffer< T > *(*cb)(int size))
 Define callback to allocate custum buffer types.
 
void setIndex (int idx)
 Sets the Output Stream index.
 
void setOutput (Print &finalOutput)
 
void setOutputCount (int count)
 
void setWeight (int channel, float weight)
 
int size ()
 Number of stremams to which are mixed together.
 
size_t write (const uint8_t *data, size_t len) override
 
size_t write (int idx, const uint8_t *buffer_c, size_t bytes)
 Write the data for an individual stream idx which will be mixed together.
 
size_t write (uint8_t) override
 
size_t writeSilence (int idx, size_t bytes)
 
size_t writeSilence (size_t bytes)
 

Protected Member Functions

void allocate_buffers (int size)
 
void free_buffers ()
 
void update_total_weights ()
 

Static Protected Member Functions

static BaseBuffer< T > * create_buffer (int size)
 

Protected Attributes

int _timeout = 10
 
Vector< BaseBuffer< T > * > buffers {0}
 
BaseBuffer< T > *(* create_buffer_cb )(int size) = create_buffer
 
bool is_active = false
 
bool is_auto_index = true
 
Vector< T > output {0}
 
int output_count = 0
 
Printp_final_output = nullptr
 
void * p_memory = nullptr
 
int size_bytes = 0
 
int stream_idx = 0
 
float total_weights = 0.0
 
Vector< float > weights {0}
 

Detailed Description

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

Mixing of multiple outputs to one final output. By default a RingBuffer is used as buffer type.

Author
Phil Schatzmann
Template Parameters
T

Member Function Documentation

◆ availableForWrite()

template<typename T >
int availableForWrite ( )
inlineoverridevirtual

Provides the bytes available to write for the current stream buffer.

Reimplemented from Print.

◆ flush()

virtual void flush ( )
inlinevirtualinherited

◆ setWeight()

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

Defines a new weight for the indicated channel: If you set it to 0.0 it is muted. The initial value is 1.0

◆ write()

template<typename T >
size_t write ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Write the data from a simgle stream which will be mixed together (the stream idx is increased)

Reimplemented from Print.


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