Using AVAudioPlayer alongside AVAudioEngine

Are there any problems with using AVAudioPlayer alongside AVAudioEngine? Not interacting in any way, but simply playing a sound file with AVAudioPlayer while also playing sounds using AVAudioEngine.


The reason for the question is that I'd like to use AVAudioEngine for sound effects, but use AVAudioPlayer for music to take advantage of its volume metering feature. I know AVAudioEngine has taps, but to the best of my knowledge there are no guarantees regarding the tap callback rate, so it seems it's not really appropriate for real-time analysis.


Empirically it's working fine, but of course that's no guarantee it always will.


Can AVAudioPlayer be safely used alongside AVAudioEngine in this way?

Accepted Answer

This shouldn't be a problem at all. These APIs are NOT mutually exclusive. Under the hood AVAudioPlayer wraps the AudioQueue C API giving you a nice easy to use high level object while AVAudioPlayerNode makes use of the ScheduledSoundPlayer audio unit if you want to read up on that. So, basically both standing on the shoulders of APIs that have been on the system for years.

Great, that's good to know - thank you.

Using AVAudioPlayer alongside AVAudioEngine
 
 
Q