How to use an AU3DMixer with The Amazing Audio Engine?

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, eg 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.


    After fiddling around a couple of more unproductive hours, I decided to completely move over to just using AudioUnits and getting rid of the Amazing Audio Engine (with the nice side effect that my whole project also got smaller and easier to handle).

    It turned out to be not that complicated: connecting a couple of AudioUnits in an AUGraph is pretty straightforward, when you look at it from the AUGraph API perspective (no rendering buffer handlers and such).

    It's basically as easy as:

  • Creating an AUGraph
  • Creating several AUNodes in this graph (all AudioUnits):
  • The RemoteIO AudioUnit (the output)
  • 3D AudioUnit Mixer
  • An AudioUnit FilePlayer
  • Connecting the mixer to the output
  • Connecting the filePlayer to the mixer
  • These links and documents were very helpful (in this order):

  • Audio Unit Hosting Guide for iOS
  • How do I connect an audiofileplayer audio unit to a 3dmixer
  • Using the 3D Audio Mixer Unit
  • 链接地址: http://www.djcxy.com/p/78156.html

    上一篇: 如何使用The Amazing Audio Engine保存文件应用音频过滤器?

    下一篇: 如何在Amazing Audio Engine中使用AU3DMixer?