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 input
mixer.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 side
mixer.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 side
mixer->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

PROPERTY
Gain per input channel. Array of eight numbers. Default value for all: 1. Changes between consecutive process() calls are automatically smoothed.
TypeMinMaxDefault
Array[8]

inputGain

PROPERTY
Gain per input channel. Array of eight numbers. Default value for all: 1. Changes between consecutive process() calls are automatically smoothed.
TypeMinMaxDefault
float[8]

inputPeak

PROPERTY
The 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, ...
TypeMinMaxDefault
Array[8]

inputPeak

PROPERTY
The 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, ...
TypeMinMaxDefault
float[8]

outputGain

PROPERTY
Gain for the output. Default value for all: 1. Changes between consecutive process() calls are automatically smoothed.
TypeMinMaxDefault
Array[2]

outputGain

PROPERTY
Gain for the output. Default value for all: 1. Changes between consecutive process() calls are automatically smoothed.
TypeMinMaxDefault
float[2]

outputPeak

PROPERTY
The peak absolute audio volume for the output, updated after every process() call. [0] is left side, [1] is right side.
TypeMinMaxDefault
Array[2]

outputPeak

PROPERTY
The peak absolute audio volume for the output, updated after every process() call. [0] is left side, [1] is right side.
TypeMinMaxDefault
float[2]

Methods

  • constructor

    METHOD
    Creates a StereoMixer instance.
    Parameters
    None
    Returns
    TypeDescription
    Superpowered.StereoMixerThe constructed instance.
  • constructor

    METHOD
    Creates a StereoMixer instance.
    Parameters
    None
    Returns
    TypeDescription
    Superpowered::StereoMixerThe constructed instance.
  • destruct

    METHOD
    Destructor to free Linear Memory.
    Parameters
    None
    Returns
    None
  • process

    METHOD
    Mixes up to 4 mono inputs into a stereo output.
    Parameters
    NameTypeDescription
    input0Number (pointer in Linear Memory)32-bit input buffer for the first stereo input. Can be 0.
    input1Number (pointer in Linear Memory)32-bit input buffer for the second stereo input. Can be 0.
    input2Number (pointer in Linear Memory)32-bit input buffer for the third stereo input. Can be 0.
    input3Number (pointer in Linear Memory)32-bit input buffer for the fourth stereo input. Can be 0.
    outputNumber (pointer in Linear Memory)32-bit output buffer.
    numberOfFramesNumberNumber of frames to process. Must be a multiple of 4.
    Returns
    None
  • process

    METHOD
    Mixes up to 4 mono inputs into a stereo output.
    Parameters
    NameTypeDefaultDescription
    input0float *32-bit input buffer for the first stereo input. Can be NULL.
    input1float *32-bit input buffer for the second stereo input. Can be NULL.
    input2float *32-bit input buffer for the third stereo input. Can be NULL.
    input3float *32-bit input buffer for the fourth stereo input. Can be NULL.
    outputfloat *32-bit output buffer.
    numberOfFramesunsigned intNumber of frames to process. Must be a multiple of 4.
    Returns
    None
v1.0.6