views:

31

answers:

1

I'm trying to play a very small audio file - it's roughly 0.05s in length, and it's an uncompressed .wav file.

Rgiht now, I'm using AVAudioPlayer to play the sound.

I intend to play the sound with high rapidity alongside a spinner, a la The Price Is Right or Wheel of Fortune. If I instantiate the AVAudioPlayer with a loop count of 100, it does indeed play the sound very rapidly as I'd expect.

If I execute [audioPlayer play] on each 'tick' of the spinner, however, the audio falls terribly behind. My guess is that, unlike setting a high loop count, [audioPlayer play] requires complete setup and teardown of the audio clip's memory for each playback.

Is there any way to force the clip to remain set up in memory for a longer duration? It's a very frequent sound, and as such would also be okay with keeping it up during the entire app run.

A: 

If you depend on more precise timing, you might want to try using one of the other sound APIs. Audio Unit RemoteIO is complicated, but allows the most precise timing of playing uncompressed sounds. OpenAL and Audio Queues are two other options.

hotpaw2
Do you have any thoughts on the pros/cons of those three?
MikeyWard
RemoteIO is the underlying API for all built-in sound IO, and will give you the lowest latency, but is the most complex API. Audio Queues are easier to set up and use, but have higher latency. OpenAL is a higher level API with more features (3D panning, etc.), but still with suitable control for game sounds.
hotpaw2
Thank you for that info. Right now I'm looking into RemoteIO and AudioQueues, and will post back here which one I use and why/how.
MikeyWard