I am using the (indeed!) Amazing Audio Engine to play some tracks (with an AUFilePlayer
, each in a separate AEAudioChannel
), which works quite nicely.
Now, I would like to add the 3D Mixer Audio Unit kAudioUnitSubType_AU3DMixerEmbedded
, but after searching high and low, I can't find any information about how this could be done.
- Should I create and add a 3D Mixer as a filter to each channel? (tried this, but the sound is always panned 50/50%, nevertheless of any property I set.
- Or should I hack TAAE and change the internal Multi Channel Mixer (doesn't sound like a good idea)
- Or is this not possible at all and should I just use Core Audio directly without TAAE?
I have also a basic understanding of how the 3D mixer should work and followed all examples I could find, e.g. Apple's TN2112
Here's how I'm trying to add the 3D Mixer to a channel:
- (BOOL)add3DMixerToTrack:(NSURL*)track {
NSError *err;
AudioComponentDescription spatialMixerDescription = AEAudioComponentDescriptionMake(kAudioUnitManufacturer_Apple, kAudioUnitType_Mixer, kAudioUnitSubType_AU3DMixerEmbedded);
AEAudioUnitFilter *mixer = [[AEAudioUnitFilter alloc]
initWithComponentDescription:spatialMixerDescription
audioController:self.audioController
useDefaultInputFormat:YES
error:&err];
AudioUnitSetParameter(mixer.audioUnit, k3DMixerParam_Azimuth, kAudioUnitScope_Input, 1, 90, 0);
AudioUnitSetParameter(mixer.audioUnit, k3DMixerParam_Distance, kAudioUnitScope_Input, 1, 10, 0);
AEAudioUnitChannel *channel = [self getChannelForTrack:track];
if(channel) {
if(![self.audioController.channels containsObject:channel]) {
[self.audioController addChannels:@[channel]];
}
[self.audioController addFilter:mixer toChannel:channel];
return YES;
} else {
return NO;
}
}
The audio is playing (so I assume everything is set up okay-ish). However, none of the parameters seem to do something. An azimuth of 90° and a distance of 10 m should definitely result in a panned output.