views:

185

answers:

1

I have trouble choosing the right audio playback technology. There's a ton of technologies to use on the iPhone, it's so confusing.

What I need to do is this:

  • start playing short sounds ranging between 0.1 and 2 seconds

  • high quality playback, no crackle (I heard some of the iPhone audio playback technologies do a crackle sound on start or end, which is bad!)

  • ability to start playback of a sound, while there's already another one playing right now (two, three or more sounds at the same time)

What would you suggest here, and why? Thanks :-)

+4  A: 

There are basically four options for playing audio on the iPhone:

  1. Audio Toolbox. Easy, but only good for playing sound effects in applications (sample code).

  2. Audio Queue Services. Very powerful, can do anything. C API, pretty messy to work with. Callbacks, buckets, pain.

  3. AVAudioPlayer. About the easiest option. Can play compressed audio, with a simple wrapper you can easily play multiple instances of the same sample at once (non-compressed audio only, as there is only one HW audio decoder). Starting to play a sound with AVAudioPlayer seems to lag about 20 ms, could be a problem.

  4. OpenAL. Decent compromise between complexity and features. Sounds do not lag, you can play multiple sounds just fine, but you have to do a lot of the work yourself. I’ve written a sound engine called Finch that can help you.

Don’t know much about cracking, never experienced it. I think there were some issues with playing seamless compressed loops with AVAudioPlayer, can be overcome by saving the loop without compression.

zoul
Finch looks great! Thanks for sharing your hard work with us. Which sound file format should I prefer with Finch? Which bitrate? Would be happe about some more advice on that. Thanks again! Really great. You saved my day.
dontWatchMyProfile
Right now Finch should support mono and stereo little-endian WAV and CAF files sampled at 44.1 kHz. I’m not sure if all the combinations are tested, plain stereo WAVs at 44.1 kHz work for sure.
zoul
would you prefer CAF over WAV? What does little-endian mean?
dontWatchMyProfile
I don’t know much about CAF, except that it’s a format that Apple uses. I use WAV. Little-endian is a way of storing the bytes inside the file, see http://en.wikipedia.org/wiki/Endianity.
zoul
Finch uses Audio Queue Services, right? Thanks a lot. Going to have a look at it.
dontWatchMyProfile
Finch is a simple wrapper around OpenAL; the PCM decoder uses some functions from Audio Toolbox.
zoul