Implementing AEBlockFilter for Fading Out (Best Practices and Design Patterns)

I think I may need a paradigm shift. The following is just one example that touches on a greater question.

I've created a method that instantiates AEBlockFilter to create a simple fade out effect. It's working great, audibly-speaking, the only exception is trying to figure out how best to communicate "up the stack" that the fade out effect has completed. I've used Observers & Notifications to handle this in the past (using AEAudioControllerSendAsynchronousMessageToMainThread), but ran into a problem trying to do that here (multiple observers firing, audio glitches, etc). I'm wondering if there is some other design pattern to implement (like a Protocol/Delegate).

For example purposes, say I have a single AEBlockChannel that is unmuted and playing (e.g. self.myBlockChannel). Ideally, once the filter calculates a buffer value of 0 (signifying the end of the fade out) it would populate the remaining requested frames with 0 and simply set self.myBlockChannel.channelIsPlaying = NO, halting all audio smoothly.

So what's a good direction to look here?

Thanks in advance!


  • You're probably on the right track; you'll need to keep the filter outputting silent frames after the frame is ended, and then use a delegate/notification/etc from the main thread (using AEAudioController's AEMessageQueue instance) to trigger the appropriate response to stop the channel playing.

Sign In or Register to comment.