I just submitted iDjembe 2.0 to the app store. I decided to change the version number to 2.0 because I did a major rewrite of the audio player code.
For the first version, I just wanted to make something quick that hopefully would cash in on the app craze and make some money. This time I’m serious about making it good.
The major new feature is Virtual Drum Circle, which lets you connect to other players on the local network and broadcast your beats to them.
The major under the hood change is that it now uses OpenAL instead of the simple audio player (which pretty much sucked). I tried several sound APIs including Audio Queue and AVAudioPlayer, but I found that OpenAL is the most straightforward and gives the best performance.
Unfortunately Apple’s iPhone developer documentation doesn’t cover OpenAL, although there are several code samples that use it. I found the best information to be at Ben Britten’s blog and the official OpenAL site.
After some experimentation, I determined the best strategy is to use a pool of OpenAL sources and prepare a buffer for each sound. Instead of using a single source for each sound, when I need to play a sound, I get the next available source, and add the desired sound buffer to it. As a result, it can now play more than one sound at a time and can play the same one repeatedly without a click.