I am trying to use CoreAudio/AudioToolbox to play multiple MIDI files using different MIDISynth nodes. I have the samplers wired into a MultiChanelMixer which is in turn wired into the IO unit. I want to be able to change the different input volumes independently of one another. I'm attempting this with this line:
AudioUnitSetParameter(mixerUnit, kMultiChannelMixerParam_Volume, kAudioUnitScope_Input, UInt32(trackIndex), volume, 0)
The problem is that adjusting trackIndex
0 adjusts every input coming into the mixer, not just the one bus like I'm expecting it to.
Here is the output from CAShow
of the master graph
AudioUnitGraph 0xC590003:
Member Nodes:
node 1: 'auou' 'rioc' 'appl', instance 0x60000002d580 O I
node 2: 'aumx' 'mcmx' 'appl', instance 0x60000002d680 O I
node 3: 'aumu' 'msyn' 'appl', instance 0x60000002db60 O I
node 4: 'aumu' 'msyn' 'appl', instance 0x60000002ef20 O I
node 5: 'aumu' 'msyn' 'appl', instance 0x60000002df00 O I
node 6: 'aumu' 'msyn' 'appl', instance 0x60800022d820 O I
Connections:
node 2 bus 0 => node 1 bus 0 [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 3 bus 0 => node 2 bus 0 [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 4 bus 0 => node 2 bus 1 [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 5 bus 0 => node 2 bus 2 [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 6 bus 0 => node 2 bus 3 [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
CurrentState:
mLastUpdateError=0, eventsToProcess=F, isInitialized=T, isRunning=T (2)
Here is the class I wrote to control all of this: https://gist.github.com/jadar/26d9625c875ce91dd2ad0ad63dfd8f80
Mixers are difficult because in a way the channels break the audio stream paradigm that core audio sets up, plus its different for the crosspoints than the input/output masters, and different for the global master.
Based on the code you provided, and assuming you're passing 0 for trackIndex
, I would look at the volumes by using the property kAudioUnitProperty_MatrixLevels
(which can be tricky to use, so let me know if you need help with that). It's possible that the crosspoint levels are not set correctly and that lowering trackIndex
0 (which is actually bus 0 channel 0) it's affecting everything you hear.
In case it's not clear, the way that the bus/channel paradigm works is it's a contiguous within the mixer itself. So if you have 4 busses with stereo channels and wanted to affect the right channel of bus 0, that would be mixer channel 7.
User contributions licensed under CC BY-SA 3.0