Hi all, this is my first post on a series dedicated to the implementation of a simple platform independent game oriented audio engine, with  low latency and performance in mind.

First of all let me state that I’m not an audio expert, and all my audio knowledge comes from the need to implement an audio engine when nobody else was there to do it.

Also I am a mobile/handheld developer with a PC/Console background, but this will be mobile related.

The beginning…

So you are about to start adding audio to you shinny new mobile game engine, and off course your first platform is iPhone then we have some options:

  • Use ObjetiveC and Audio player functionality, this is not going to be a good option if you aim low latency and performance.
  • OpenAL, iPhone was the first mobile device that implemented OpenAL, and it looks like a good option as there is a windows ans macos implementation out of the box.

So we are done, lets use OpenAL :-)

Not so fast…

So whats wrong with using OpenAL ans why this wasn’t an option for us.

  • Availability, at the end I found that my only real target platform with support for OpenAL was iOS, Android, Bada, Maemo/Meego, XperiaPlay, etc… were out.
  • Performance and formats, OpenAL uses buffers you can create on your desired sample-rate and bits per sample, you have to deal with potential bad performance if mixing different sample-rate/bits buffers or if you buffer format is not “compatible” with the underlying device preferred format.
  • File formats not solved any way, on iOS you can use OS to load samples into OpenAL buffers but you can’t access to the samples and you have to implement all you sample loading code in ObjetiveC, if you have your own compressed pakfile, this gets complicated for every platform you potentially want to be in.

A look outside iOS…

Well I’m not convinced with OpenAl on iOS, but outside is not better in any case, most of other platforms offer “hi-level” audio players,  great to play an mp3 on the background, but with high latencies and usually big stalls when stop/pause/resume.

On Android on previous versions on ndk (that we support) there was not even access to any audio api from the ndk.

But there is one option I have found on every single platform, a simple PCM audio stream.

Closing…

So whats my bet?

  • Very lightweight platform independent PCM audio out (less that 300 platform dependent loc)
  • A fast re-sampling integer based software mixer with panning and pitch.
  • Some basic audio file parsers.
  • Hi level audio engine with 3d simulation using panning and pitch.

So that’s all for today, next post we will go into details,  and any thing that comes out from the comments…

Please share your opinion and suggestions on your audio engines.

Unai.