0
votes

Since the system sound player in iOS can only play one sound at a time I am using AVAudioPlayer. However, if I try to play two of the same sound, using two separate AVAudioPlayers with the same sound file, it sounds noisy.

I want to be able to play a certain sound in rapid succession if the user taps, and have it sound pleasant, with no noise.

Is it recommended to create two AVAudioPlayer instances for the same sound, or just stop the playing sound? If I stop the sound I still hear a static feedback sound when I tap the button rapidly. If I wait for silence, then tap the button once it is clear, but when I keep tapping it it gets overloaded or something.

Anyway, just trying to get a VERY simple sound to play in rapid succession and sound okay.

Any feedback is appreciated.

1
I think they are related. I recall that the problem existed on the device as well and perhaps worse. It appeared as if the sound level would max out and make it cutoff abruptly. I will add an answer below. - Christopher
I'm still testing, but I have taken to deactivating the session and reactivating between clips. I have not had the problem on the device since. So I further suspect, in my instance, it is either the simulator or the data stream somehow. - stephenhouser

1 Answers

0
votes

I solved this problem (as a work-around) by creating 2-3 AVAudioPlayer with the same sound file. In each "play" method I check to see if the first sound is still playing. If so, then play the second version, and so on. This appears to work well to my ears.

- (void)playUndo
{
    if ([self isSoundMuted]) return;

    if ([[self undoPlayer] isPlaying])
    {
        [[self undoPlayerTwo] play];
    }
    else
    {
        [[self undoPlayer] play];
    }
}