Mixer object question

Hi. Another noob middle layer question (trying to make a faster / improved version of this in Lua).

Can anyone please point me at the direction of any examples / hints on how to use the Mixer object (the one with dynamically allocated inputs and outputs)? I could not find it used anywhere, I’d love to try and avoid chaining sum objects for my specific use case (i need to have 8 sine oscillators simultaneously audible, attenuated with bumpmaps), i think using the mixer object would be way more elegant solution.

the .h file is here (thanks tomf!)

many thanks!

2 Likes

When you create a Mixer object, it requires as input the number of channels. Then for each channel it creates “InX” Inlets and “GainX” Parameters, where X is the channel number.

Here is sketch of using the Mixer object to mix 10 streams to 1 stream (i.e. to mono):

local numMixerChannels = 10
local myMixer = self:addObject("myMixer", app.Mixer(numMixerChannels))

-- Connect mixer inputs
connect(someObject1, "someOutlet", myMixer, "In1")
connect(someObject2, "someOutlet", myMixer, "In2")
.
.
.
connect(someObject10, "someOutlet", myMixer, "In10")

-- Set the gain parameters
myMixer:hardSet("Gain1", 0.1)
myMixer:hardSet("Gain2", 0.1)
.
.
.
myMixer:hardSet("Gain10", 0.1)

-- Route mixer output to the unit output
connect(myMixer, "Out", self, "Out1")

I just hard coded all the gains to 0.1 but you can also connect up a Fader Control or use a ParameterAdapter Object with a GainBias Control to control them via sub-chain.

3 Likes

Thanks! Excellent, this is incredibly helpful!

A post was split to a new topic: Purpose of the ParameterAdapter