Class Audio.Mixer

implements Audio.Source Audio.Sink

An audio mixer. The mixer can contain any number of inputs and outputs. Independent gain values can be set for each input/output pair and these gains can be controlled via scheduled events.
Note that gain values are specified as a gain factor applied to the digital sample values. Thus a value of 1.0 means unity gain and a value of 0.0 is equivalent to negative infinity decibels.

Constructors

Mixer(integer inputs, integer outputs, array gains) create a new audio mixer

Properties

input Audio.Connector inputs as an array
output Audio.Connection outputs as an array

Methods

add(Audio.Connection connection, array gain) connect the given Audio.Connection to the next unused input
add(Audio.Connection connection, float gain) connect the given Audio.Connection to the next unused input
add(Audio.Source source, array gains) connect the given Audio.Source to the next unused inputs of this mixer
add(Audio.Source source, float gain) connect the given Audio.Source to the next unused inputs of this mixer
gain(integer input, array gains) change the gain between an input and output
gain(integer input, integer output, float gain) change the gain between an input and output
play(Audio.Buffer buffer) immediately play an audio buffer
play(Audio.Clip clip) immediately play an audio clip
schedule(Audio.Buffer buffer, float measure, Time.Clock clock) schedule an audio buffer to play
schedule(Audio.Clip clip, float measure, Time.Clock clock) schedule an audio clip to play
schedule(Audio.MixerGain gain, float measure, Time.Clock clock) schedule a gain change between a given input and output

Constructor Documentation


Mixer(integer inputs, integer outputs, array gains)

Create a new audio mixer. Initial gains may be set by an optional gains array argument. If this argument is omitted initial gains will be set as follows:
* The first input channel connects to the first output channel with unity gain, all other outputs are not connected
* Each subsequent input connects to the next output channel, or back to the first output channel if they run out
* Continue until all input channels are each connected to one output channel (output channels may not all be connected)

Parameters

Property Documentation


array input

Audio.Connector inputs as an array. Adding or removing elements to this array has no effect on the underlying audio component.


array output

Audio.Connection outputs as an array. Adding or removing elements to this array has no effect on the underlying audio component.

Method Documentation


void add(Audio.Connection connection, array gain)

Connect the given Audio.Connection to the next unused input

Parameters


void add(Audio.Connection connection, float gain)

Connect the given Audio.Connection to the next unused input. If an optional gain value is given this input will be connected to every output with that gain factor.

Parameters


void add(Audio.Source source, array gains)

Connect the given Audio.Source to the next unused inputs of this mixer. An array of values can be given to set gains on the newly connected input.
An exception will be thrown if not enough free inputs are available.

Parameters


void add(Audio.Source source, float gain)

Connect the given Audio.Source to the next unused inputs of this mixer. If an optional gain value is given the newly connected inputs will have gains set as follows:
* The first input from the audio source will connect to the first output channel of the mixer. All other output channels will have gain 0.0 (disconnected)
* Each subsequent input will connect to the next output channel, or back to the first if they run out
An exception will be thrown if not enough free inputs are available.

Parameters


void gain(integer input, array gains)

Change the gain between an input and output

Parameters


void gain(integer input, integer output, float gain)

Change the gain between an input and output

Parameters


void play(Audio.Buffer buffer)

Immediately play an audio buffer.

Parameters


void play(Audio.Clip clip)

Immediately play an audio clip.

Parameters


void schedule(Audio.Buffer buffer, float measure, Time.Clock clock)

Schedule an audio buffer to play.

Parameters


void schedule(Audio.Clip clip, float measure, Time.Clock clock)

Schedule an audio clip to play.

Parameters


void schedule(Audio.MixerGain gain, float measure, Time.Clock clock)

Schedule a gain change between a given input and output.

Parameters



Creative Commons Logo This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.