Class: StereoMixer
Overview
Mixes up to 4 stereo inputs. From the traditional mixer hardware point of view, every input and the output has dedicated metering, gain and pan controls.
One instance allocates just a few bytes of memory. Combining multiple instances of the StereoMixer is the recommended way to support more than 4 channels.
How to implement
// Constructor. Has no additional parameters.let mixer = new Superpowered.StereoMixer();// Gain per input channel, 8 values (2 per input). Default value for all: 1. Changes between consecutive process() calls are automatically smoothed.mixer.inputGain[2] = 0.5; // left side of the second inputmixer.inputGain[3] = 0.5; // right side of the second input// Output gain. Default value for all: 1. Changes between consecutive process() calls are automatically smoothed.mixer.outputGain[0] = 0.9; // left sidemixer.outputGain[1] = 0.8; // right side// Processes the audio. Has no return value.mixer.process(input0, // Pointer to floating point numbers. 32-bit interleaved stereo input buffer for the first input. Can be null.input1, // Pointer to floating point numbers. 32-bit interleaved stereo input buffer for the second input. Can be null.input2, // Pointer to floating point numbers. 32-bit interleaved stereo input buffer for the third input. Can be null.input3, // Pointer to floating point numbers. 32-bit interleaved stereo input buffer for the fourth input. Can be null.output, // Pointer to floating point numbers. 32-bit interleaved stereo output buffer.128 // Number of frames to process. Must be an even number.);// The peak absolute audio volume per input channel, updated after every process() call, measured before any gain.let second_input_left_side = mixer.inputPeak[2];let second_input_right_side = mixer.inputPeak[3];// The peak absolute audio volume for the output, updated after every process() call.let output_left_side = mixer.outputPeak[0];let output_right_side = mixer.outputPeak[1];// Destructor (to free up memory).mixer.destruct();
#include "SuperpoweredMixer.h"void initMixer() {mixer = new Superpowered::StereoMixer();// Gain per input channel, 8 values (2 per input). Default value for all: 1. Changes between consecutive process() calls are automatically smoothed.mixer->inputGain[2] = 0.5;mixer->inputGain[3] = 0.5;// Output gain. Default value for all: 1. Changes between consecutive process() calls are automatically smoothed.mixer->outputGain[0] = 0.9; // left sidemixer->outputGain[1] = 0.8; // right side}void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames) {mixer->process(input0, input1, input2, input3, interleavedOutput, numberOfFrames);// The peak absolute audio volume per input channel, updated after every process() call, measured before any gain.float second_input_left_side = mixer->inputPeak[2];float second_input_right_side = mixer->inputPeak[3];// The peak absolute audio volume for the output, updated after every process() call.float output_left_side = mixer->outputPeak[0];float output_right_side = mixer->outputPeak[1];}
Properties
inputGain
PROPERTYGain per input channel. Array of eight numbers. Default value for all: 1. Changes between consecutive process() calls are automatically smoothed.
Type | Min | Max | Default | Array[8] |
---|
inputGain
PROPERTYGain per input channel. Array of eight numbers. Default value for all: 1. Changes between consecutive process() calls are automatically smoothed.
Type | Min | Max | Default | float[8] |
---|
inputPeak
PROPERTYThe peak absolute audio volume per input channel, updated after every process() call, measured before any gain. Example: inputPeak[0] = input 0 left, inputPeak[1] = input 0 right, inputPeak[2] = input 1 left, ...
Type | Min | Max | Default | Array[8] |
---|
inputPeak
PROPERTYThe peak absolute audio volume per input channel, updated after every process() call, measured before any gain. Example: inputPeak[0] = input 0 left, inputPeak[1] = input 0 right, inputPeak[2] = input 1 left, ...
Type | Min | Max | Default | float[8] |
---|
outputGain
PROPERTYGain for the output. Default value for all: 1. Changes between consecutive process() calls are automatically smoothed.
Type | Min | Max | Default | Array[2] |
---|
outputGain
PROPERTYGain for the output. Default value for all: 1. Changes between consecutive process() calls are automatically smoothed.
Type | Min | Max | Default | float[2] |
---|
outputPeak
PROPERTYThe peak absolute audio volume for the output, updated after every process() call. [0] is left side, [1] is right side.
Type | Min | Max | Default | Array[2] |
---|
outputPeak
PROPERTYThe peak absolute audio volume for the output, updated after every process() call. [0] is left side, [1] is right side.
Type | Min | Max | Default | float[2] |
---|
Methods
constructor
METHODCreates a StereoMixer instance.ParametersNoneReturnsType Description Superpowered.StereoMixer
The constructed instance. constructor
METHODCreates a StereoMixer instance.ParametersNoneReturnsType Description Superpowered::StereoMixer
The constructed instance. destruct
METHODDestructor to free Linear Memory.ParametersNoneReturnsNoneprocess
METHODMixes up to 4 mono inputs into a stereo output.ParametersReturnsName Type Description input0 Number (pointer in Linear Memory)
32-bit input buffer for the first stereo input. Can be 0. input1 Number (pointer in Linear Memory)
32-bit input buffer for the second stereo input. Can be 0. input2 Number (pointer in Linear Memory)
32-bit input buffer for the third stereo input. Can be 0. input3 Number (pointer in Linear Memory)
32-bit input buffer for the fourth stereo input. Can be 0. output Number (pointer in Linear Memory)
32-bit output buffer. numberOfFrames Number
Number of frames to process. Must be a multiple of 4. Noneprocess
METHODMixes up to 4 mono inputs into a stereo output.ParametersReturnsName Type Default Description input0 float *
32-bit input buffer for the first stereo input. Can be NULL. input1 float *
32-bit input buffer for the second stereo input. Can be NULL. input2 float *
32-bit input buffer for the third stereo input. Can be NULL. input3 float *
32-bit input buffer for the fourth stereo input. Can be NULL. output float *
32-bit output buffer. numberOfFrames unsigned int
Number of frames to process. Must be a multiple of 4. None