I had a render callback with 20 buses synchronized and routed to a same mixer but now I need to apply effects to some of these 20 buses, so now, they are divided into groups of 5.
So now, I have 20 buses divided into 4 groups.
Buses 0-4 -routed to - Mixer1
AUGraphSetNodeInputCallback (processingGraph,mixer1Node,
input, //0-4
&inputCallbackStruct
);
Buses 5-9 -routed to - Mixer2
AUGraphSetNodeInputCallback (processingGraph,mixer2Node,
input, //0-4
&inputCallbackStruct
);
Buses 10-14 -routed to - Mixer3 ...
Buses 15-19 -routed to - Mixer4 ...
Now, my issue is every of these groups are getting [0] to [4] inBusNumber, with the same data in the render callback. So the old inBusNumber [5] now is [0] of Mixer2, with the same render data of bus [0] of Mixer1. All the variables are now shared with buses of the other Mixers.
Now my complex render code is useless .... I need independent variables on each bus.
Any ideas how to deal with it ?
I made it with kAudioUnitSubType_MatrixMixer. It allows to have any number of inputs and any number of outputs. So I'm setting buses 0-4 to output 0, buses 0-9 to output 1... etc. It's possible to set volume from any input to any output of the Matrix Mixer in this way:
UInt32 element = (inputChannel<<16) | outputChannel;
AudioUnitSetParameter(mixerMatrix, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, gain, 0);
With this method, all the buses are routed to the same mixer (MatrixMixer) and I can share variables in the render callback.