【发布时间】:2016-12-29 02:39:02
【问题描述】:
我正在尝试使用 CoreAudio/AudioToolbox 使用不同的 MIDISynth 节点播放多个 MIDI 文件。我将采样器连接到 MultiChanelMixer,然后再连接到 IO 单元。我希望能够相互独立地更改不同的输入音量。我正在尝试使用这一行:
AudioUnitSetParameter(mixerUnit, kMultiChannelMixerParam_Volume, kAudioUnitScope_Input, UInt32(trackIndex), volume, 0)
问题在于调整trackIndex 0 会调整每个输入进入混音器,而不是像我期望的那样只调整一个总线。
这是主图 CAShow 的输出
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)
这是我为控制所有这些而编写的类:https://gist.github.com/jadar/26d9625c875ce91dd2ad0ad63dfd8f80
【问题讨论】:
-
我看到你在课堂上使用 kMultiChannelMixerParam_Volume 的唯一地方是使用 kAudioUnitScope_Input。除了将每个采样器的音量设置到混音器之外,您还可以使用 kAudioUnitScope_Output 将混音器的输出设置为一个整体。
标签: core-audio midi audiotoolbox coremidi