AEAudioUnitFilter not working in 1.4.8 and above

Hi guys,

I'm rebuilding an app from the ground up that used TAAE in the past. I've spent the day working on reverb, and couldn't get it to work. During debug watched weird scenarios come through, like description of audio not support. That lead me to another thread describing an issue that was just fixed in AEAudioUnitFilter, but it doesn't fix my issue.

The following code works in 1.4.6 but not in anything above, including the latest master commit.

NSError *error = nil;
audioController = [[AEAudioController alloc]
                   initWithAudioDescription:[AEAudioController nonInterleaved16BitStereoAudioDescription]
                   inputEnabled:YES]; 
                   
[audioController start:&error];

audioPlayThroughChannel = [[AEPlaythroughChannel alloc] initWithAudioController:audioController];
[audioController addInputReceiver:audioPlayThroughChannel];
[audioController addChannels:@[audioPlayThroughChannel]];

AudioComponentDescription component = AEAudioComponentDescriptionMake(kAudioUnitManufacturer_Apple, kAudioUnitType_Effect, kAudioUnitSubType_Reverb2);
audioReverb = [[AEAudioUnitFilter alloc] initWithComponentDescription:component];
AudioUnitSetParameter(audioReverb.audioUnit,kReverb2Param_DryWetMix,kAudioUnitScope_Global,0,100.f,0);

[audioController addFilter:audioReverb toChannel:audioPlayThroughChannel];

I'm going to step through the debug in both old and new and compare to see if I can see where things go astray. Nobody else has noticed this?

Comments

  • edited October 2015

    Hey @everlasting1,

    That's no longer working because audio units are now set up when they're added to AEAudioController, not beforehand. At the point you're calling AudioUnitSetParameter, the audio unit is NULL (I recommend wrapping all Core Audio C calls in AECheckOSStatus so you get warned about this sort of thing, btw). To set parameters and such, you have three options. In order of recommended-ness:

    1. Use the new Objective-C wrappers for the built-in audio units, like AEReverbFilter, and use the Obj-C properties to assign values
    2. Create an AEAudioUnitFilter as previously, and use the setParameterValue:forId: method to have the AEAudioUnitFilter class take care of setting the value for you once the audio unit is created
    3. Create an AEAudioUnitFilter as previously, using the preInitializeBlock initialiser to supply a block to perform immediately after the audio unit is created and before it's initialised - in that block, you may use AudioUnitSetParameter, etc.

    This change was necessary in order to correctly facilitate re-creating the rendering resources, which needs to happen during a media server restart (in iOS itself), or when switching properties like the sample rate or whether input/output is enabled.

  • Thank you so much Michael. I had read some stuff on that, but the home page has demo code at the bottom that was updated to remove the need to pass in audiocontroller but used the old style of AEAudioUnitFilter so I figure I was confused. ;)

    I'll switch over to the AEReverbFilter instead of doing all that ol' work. :) Hopefully there is one for the compressor too!

    Thanks again.

  • edited October 2015

    When will AEReverbFilter be in the pod? I used :head but it still didn't pull it down (which I honestly thought it would)?

    Edit: modules isn't recursive in the podspec json at the moment. Not sure if it is supposed to be or not.

    (Modules/*.{h,m,c}")

    Edit2: for now, I went with solution number two until the modules/filters are the in pod, since I don't want to have to remember to manage those files.

    For others in the same boat as I was, use AEReverbFilter or just replace this:

    AudioUnitSetParameter(audioReverb.audioUnit,kReverb2Param_DryWetMix,kAudioUnitScope_Global,0,100.f,0);
    

    with this:

    [audioReverb setParameterValue:100.f forId:kReverb2Param_DryWetMix];
    

    From my example code above.

  • Edit: modules isn't recursive in the podspec json at the moment. Not sure if it is supposed to be or not.

    Whoops! That's definitely a mistake - thanks for catching it!

  • Oh yes, and the site examples need updating! I'll do that now.

  • Thanks a lot for the 1.5.2 update, including that AEReverbFilter fix ! it solved my last issue in my SpringSound update (tested on iPhone 6S) ! Thanks for all your hard work on TAAE !

  • Great! And you're welcome =)

Sign In or Register to comment.