iOS Audio Study

AudioKit vs OpenAL and Swift vs Objective-C

On developing a Drum Loops & Metronome App, we need to investigate the quickest solution for producing Audio. The drum loops are made up of a programmable set of individual sound files, all converted to the recommended iOS format of .caf. So there's 1 for a High Hat, 1 for a Kick drum. The sound engine will need to be able to play these in a loop without any lag. To compare against the possible solutions, the look and feel of the app, the model will stay the same. The only thing differing is the Audio library and the programming language. The version of Swift used is 5. One constant takeaway we get from meetings with other developers, Google and Apple employees is that don't accept a recommendation from anyone. But test it out yourself to see whether it is the best for you. So that's what we've done.

1. Swift and AudioServices.
AudioServices used AudioServicesPlaySystemSound(soundId); to play.

Too slow. We will need a framework. AudioKit seems the most recommended, most widely used and is very rich. We will next try this.

2. Swift and AudioKit.
The great tutorial on AudioKit Playgrounds provides the base for the code.

Suprisingly this is too slow. We were expecting more from AudioKit. We will try a lighter framework openAL next. AudioKit is easy to use and rich in functionality but may not be the fastest.

3. Swift and openAL.
A bit more compicated to set up.

Suprisingly this is still too slow. We have tried the 2 most recommended audio libaries on the recommended iOS programming language Swift and it's not good enough. Perhaps it is Swift which is too slow. It's a good language to program but maybe it's not low level enough.

4. Objective-C and AudioKit.
Most of AudioKit's examples are in Swift, so pretty much just translated from the Playground examples.

This is a lot better but still doesn't sound right. We had to try a different loop from Arctic Monkeys where there is a lot going on. Perhaps AudioKit is just too heavy weight and doesn't have low enough latency. Need to try openAL with objective-C.

5. Objective-C and OpenAL.
Again testing on Arctic Monkeys loop.

This sounds smooth! We will go with this solution. Objective-C and OpenAL is the best one for the job!

6. Objective-C AudioEngine.
OpenAL is now deprecated. Is the alternative as good?

This still sounds smooth and handles the fast bpm very well. The recording is taken at a different date as the previous ones and by a different device, so the tone came across different, but live on the iPhone is great.