Manually cranking filters in TAAE 1.5?

Hi guys, I'm updating from 1.4.8 to 1.5 and my filters have stopped working!

In my app I manually instantiate three different filters in the following manner:

  AEAudioUnitFilter *lpf = [[AEAudioUnitFilter alloc] initWithComponentDescription:AEAudioComponentDescriptionMake(kAudioUnitManufacturer_Apple, kAudioUnitType_Effect, kAudioUnitSubType_LowPassFilter)];
  [lpf setupWithAudioController:audioController];

Rather than using the more conventional route of adding the filter to the input or to a channel, I instead manually crank one of the three filters using something like the following:

THIS->_chosenFilterCallback(THIS->_chosenFilter,
                              THIS->_audioController,
                              THIS->_chosenFilterProducer,
                              (__bridge void *)(THIS),
                              time,
                              frames,
                              fxBufferList);

This allows for the user to switch between the three different filters with only one filter ever using CPU cycles. It also allows me to crank the handle in the middle of my signal path and then manually merge the result back into my main stream.

With the changes in commit:

Use AUGraph for AEAudioUnit* classes

https://github.com/TheAmazingAudioEngine/TheAmazingAudioEngine/commit/e28fb2ee883d0e9892d54d1079d3758912dfc8bd

this manual cranking no longer works. There don't appear to be any console errors, but the audio stream coming out of the filter is garbled - almost as if there's some incorrect format conversion going on now.

I've started digging into to why this is, but I thought I'd ask on here in case anyone else has faced similar and solved the problem!

Thanks in advance!

Comments

  • How strange! I've no idea why that commit would introduce any changes in the signal path itself...Nothing really constructive to add, I'm afraid.

  • Curiously, I converted my code to use the more conventional addFilter:toChannel: and I experienced the same problem.

    I had been using interleaved16BitStereoAudioDescription for my audioController and then using vDSP_vflt16 and vDSP_vfixr16 so I switched to using an AEFloatConverter.

    That allowed me to switch the audioDescription to nonInterleavedFloatStereoAudioDescription, at which point the filters starting working perfectly.

    That led me to make a standalone test case that reproduces the problem:

      self.audioController = [[AEAudioController alloc] initWithAudioDescription:[AEAudioController interleaved16BitStereoAudioDescription]
                                                                    inputEnabled:YES];
    
      AEPlaythroughChannel *playthrough = [[AEPlaythroughChannel alloc] initWithAudioController:_audioController];
    
      [_audioController addChannels:@[playthrough]];
      [_audioController addInputReceiver:playthrough];
    
      AEAudioUnitFilter *lpf = [[AEAudioUnitFilter alloc] initWithComponentDescription:AEAudioComponentDescriptionMake(kAudioUnitManufacturer_Apple, kAudioUnitType_Effect, kAudioUnitSubType_LowPassFilter)];
    
      [_audioController addFilter:lpf toChannel:playthrough];
    
      [_audioController start:nil];
    

    Stick that in your app delegate and your debug log will fill with:

    AEAudioController.m:482: AudioConverterFillComplexBuffer: 'insz' (1768846202)
    

    Switch to nonInterleaved16BitStereoAudioDescription and you'll get no errors but watch out for your ears.

    Finally, switch to nonInterleavedFloatStereoAudioDescription and all is well.

    Overall, I'd guess that in the commit that I mentioned at the start of the thread, the code in the AEAudioUnitFilter that detects kAudioUnitErr_FormatNotSupported and creates _inConverterNode and _outConverterNode's gets broken somehow. Most people aren't noticing it because, I imagine, nonInterleavedFloatStereoAudioDescription is the most popular format.

  • Whew. Right you are. Fixed in the latest couple of commits - thanks for finding this!

  • OMG I have to learn to check the forum before spending the morning troubleshooting my code. Well done guys, thanks.

    Do I have to pull this from github myself then? I'm using Cocoapods normally.

  • edited October 2015

    I pulled down the latest git. Before this (running 1.5.1) I got no sound on anything that I applied a filter to. Now, I get no filter. Can someone just quickly look at this and make sure I'm not missing something stupid and obvious?

    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];
    
  • edited October 2015

    .

  • I just confirmed that my code (at least, in my app) which is above, works with 1.4.6 but nothing above. I'll open a new thread.

  • Cheers Michael. 1.5.2 has fixed it :)

Sign In or Register to comment.