Playing UI sound effects while TAAE is running

Do any of you play app sound effects while TAAE is running? If so how do you do it?

I've been trying to add some UI sounds to my app using SAMSoundEffect, which uses AVAudioPlayer to play effects, but if TAAE is running (with outputEnabled or not) the sound effects don't play. If i set [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil]; before playing the effects, they play, but TAAE gets borked.

Is there a better way to play effects that won't interfere? AudioServicesPlaySystemSound(...) is out of the question since it can't overlap sounds (from things like quick button presses).

Comments

  • Why don't you create a separate group in TAAE for your sound effects?

    Here is what I did:

    _fxGroup = [_audio createChannelGroup];
    _buttonSound1 = [AEAudioFilePlayer audioFilePlayerWithURL:ResourceURL(@"sounds/button-1.wav") error:nil];
    _buttonSound2 = [AEAudioFilePlayer audioFilePlayerWithURL:ResourceURL(@"sounds/button-2.wav") error:nil];
    _buttonSound1.channelIsPlaying = _buttonSound2.channelIsPlaying = NO;
    [_audio addChannels:@[_buttonSound1, _buttonSound2] toChannelGroup:_fxGroup];
    

    then somewhere in the button1 event:

    _buttonSound1.currentTime = 0;
    _buttonSound1.channelIsPlaying = YES;
    
  • Thanks crontab!

    Using your advice I ended up building a simple little singleton for triggering all my UI sounds. Works like a charm!
    Hopefully it can help someone else in the future :)
    https://gist.github.com/warpling/6b6807ee16ba6f097e02

  • @warpling, I'm sorry for the repeated comment, but I recommend using the AUSampler for playing sound effects all within TAAE:

    http://forum.theamazingaudioengine.com/discussion/comment/1873/#Comment_1873

  • No need to apologize, I might have missed it otherwise! What are the main advantages besides being able to adjust volume, pitch, pan, etc?

  • You don't need to juggle with other audio frameworks, and it works flawlessly with Audiobus.

  • But in my example I'm not using other frameworks I'm just using TAAE. I guess I'm asking what is the difference between using AEAudioFilePlayers and using AUSamplers?

  • @warpling, I originally implemented my drum sounds with AEAudioFilePlayers, but was experiencing clicks and stuttering upon playback. It isn't ideal or optimized for rapid-fire triggering, which is necessary for fast drumming. Of course, it all depends what you're to do in your app, and it may be a non-issue for you. Here's the thread:

    http://forum.theamazingaudioengine.com/discussion/172/clicking-sound-of-samples

  • Whoops I definitely missed that thread in my search! Maybe I haven't experienced the stuttering since I create all my AEAudioFilePlayers before playing them and then reuse them? I'm going to try this though. Thank you for helping me out :)

  • With the new AEAudioFilePlayer that's going to be much less of an issue now, by the way. AUSampler is still the best choice for rapid triggering of stuff though, especially for musical applications.

  • Could someone explain what the reason of clicking is with AEAudioFilePlayer, and why it's not suitable for rapid triggering?

  • Previously, AEAudioFilePlayer would load the audio file into memory, and play it from there. Creating an instance caused the load to happen, which would cause a delay. The stuttering, I can't explain without seeing it, though - that shouldn't really happen.

    But either way, AEAudioFilePlayer is completely new, now, and better at that sort of thing. If you keep the same instance around, and just tell it to play when necessary, it should be great at fast triggering.

    But for applications like a drum pad app, for example, AUSampler's built for that use case and may be more optimised.

  • @Michael, Thanks for the AEAudioFilePlayer explanation. @warpling, Thanks for sharing your gist. Very efficient and helpful!

  • No problem! Thank you to you both. Knowing that I'm going to stick with AEAudioFilePlayers for now :)

Sign In or Register to comment.