Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::audio::Mixer Class Reference

Mixer. Mixes multiple input streams into one output stream. More...

#include <mixer.h>

Inheritance diagram for roc::audio::Mixer:
Collaboration diagram for roc::audio::Mixer:

Public Member Functions

 Mixer (FrameFactory &frame_factory, const SampleSpec &sample_spec, bool enable_timestamps)
 Initialize. buffer_factory is used to allocate a temporary buffer for mixing. enable_timestamps defines whether to enable calculation of capture timestamps. More...
 
bool is_valid () const
 Check if the mixer was succefully constructed. More...
 
void add_input (IFrameReader &)
 Add input reader. More...
 
void remove_input (IFrameReader &)
 Remove input reader. More...
 
virtual bool read (Frame &frame)
 Read audio frame. More...
 
- Public Member Functions inherited from roc::core::ListNode< Tag >
ListDatalist_data () const
 Get pointer to internal data. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from roc::core::ListNode< Tag >
static ListNodelist_node (ListData *data)
 Get pointer to parent node from pointer to internal data. More...
 

Detailed Description

Mixer. Mixes multiple input streams into one output stream.

For example, these two input streams:

1, 2, 3, ...
4, 5, 6, ...

are transformed into this output stream:

5, 7, 9, ...

If timestamps are enabled, mixer computes capture timestamp of output frame as the average capture timestamps of all mixed input frames. This makes sense only when all inputs are synchronized and their timestamps are close to each other.

Definition at line 46 of file mixer.h.

Constructor & Destructor Documentation

◆ Mixer()

roc::audio::Mixer::Mixer ( FrameFactory frame_factory,
const SampleSpec sample_spec,
bool  enable_timestamps 
)

Initialize. buffer_factory is used to allocate a temporary buffer for mixing. enable_timestamps defines whether to enable calculation of capture timestamps.

Member Function Documentation

◆ add_input()

void roc::audio::Mixer::add_input ( IFrameReader )

Add input reader.

◆ is_valid()

bool roc::audio::Mixer::is_valid ( ) const

Check if the mixer was succefully constructed.

◆ read()

virtual bool roc::audio::Mixer::read ( Frame frame)
virtual

Read audio frame.

Remarks
Reads samples from every input reader, mixes them, and fills frame with the result.

Implements roc::audio::IFrameReader.

◆ remove_input()

void roc::audio::Mixer::remove_input ( IFrameReader )

Remove input reader.


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