Question

What is the difference between OpenAL and AVAudioPlayer on the iPhone? It seems that both can be used for playing/recording audio. When would you use either? What advantages/features does each provide?

Thanks! -MT

Was it helpful?

Solution

OpenAL is an advanced audio playback engine. You have to get a lot more "down-and-dirty" with it than you do with AVAudio player.

OpenAL is often used in games. OpenAL provides 3D sound positioning which is where things like distance related parameters come into play. It is a C based API while AVAudio is Objective C. If you don't know medium to advanced C programing than you are going to struggle with OpenAL programming.

AVAudioPlayer is best if you just need basic playback and recording. If you need more control than OpenAL or Audio Queues is the way to go (though Audio Queues are also a C-based API). Many people seem to prefer OpenAL over Audio Queues as it's a cross platform library and works similar to OpenGL which game programers already are quite familiar with.

In most caes outside of gaming or advanced audio synchronization situations, AVAudio is the way to go and works great. Even in games, I'm often seeing people use a combination of OpenAL (for sound effects) and AVAudio (for music playback).

OTHER TIPS

OpenAL provides more control if you want to change the audio parameters like distance related, patter-based playback. AVAudioPlayer is a pretty basic one, but you can achieve similar with AudioQueues and AudioUnit using low level api's. In a nutshell, OpenAL does few things with snap of finger but then again it needs what you are looking at? Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top