Targeting iOS, I want to playback two .caf audio files simultaneously.
I've created a simple AUGraph comprised of two "Generator" Audio Units (subtype kAudioUnitSubType_AudioFilePlayer) connected to a multichannel mixer AU which is connected to the remote IO (output scope).
I can successfully play back one of the files with just one filePlayer AU connected to the mixer. To play back the two files I'm simply creating another instance of a filePlayer AU and configuring it in the same way as the first filePlayer.
I'm opening the audio files and then passing them into the Generator units using the kAudioUnitProperty_ScheduledFileIDs
property, and the kAudioUnitProperty_ScheduledFileRegion
property.
I'm checking for errors all along the way with all AU calls and nothing is returning an error. When I start the graph I get nothing but silence.
Here's the snapshot of my graph after pressing "Play":
AudioUnitGraph 0xF7DA000:
Member Nodes:
node 1: 'auou' 'rioc' 'appl', instance 0xf18e3e0 O I
node 2: 'aumx' 'mcmx' 'appl', instance 0x9d72f50 O I
node 3: 'augn' 'afpl' 'appl', instance 0x9db6ee0 O I
node 4: 'augn' 'afpl' 'appl', instance 0x9db6fd0 O I
Connections:
node 3 bus 0 => node 2 bus 1 [ 1 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 4 bus 0 => node 2 bus 2 [ 1 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 2 bus 0 => node 1 bus 0 [ 2 ch, 44100 Hz, 'lpcm' (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved]
CurrentState:
mLastUpdateError=0, eventsToProcess=F, isRunning=T (3)
Is there a nuance to using multiple filePlayer Audio Units that I'm missing? Is what I'm attempting to do possible in this way? Or do I instead need to create audio buffers and feed those to the filePlayer units manually?
What you have should work, but there's a couple gotchas which might have surfaced:
Did you set the volume parameter to be something > 0 on each bus, as well as the output? (kMultiChannelMixerParam_Volume
on the Input & Output scopes).This is what I'd think the problem would be, since I believe the mixer starts with all volumes at 0.
Did you set the input bus count to be 2 or more by setting the kAudioUnitProperty_ElementCount
property on the Input scope? (Note: since you're using elements 1 & 2 you'll need to set the element count to 3, or use elements 0 & 1 instead).
Not sure you ever fixed this.
It looks as if you're connecting your file players to the mixer before connecting your mixer to the remoteIO.
Always connect your graph up "backwards" i.e. starting with the remoteIO then working back through the chain to your generators. I think connecting forwards doesn't work because of the pull architecture used in AUGraphs
User contributions licensed under CC BY-SA 3.0