Search code examples
ioscore-audioavaudioplayeraudiounit

Play sound file together with AudioUnit


i have an app which uses an AudioUnit with subtype kAudioUnitSubType_VoiceProcessingIO. The input comes from a network stream. That works fine, but now i want to play a simple sound from file (alert sound after receiving a push notification). That does not work while the AudioUnit is in action, only when it's not started yet or already disposed. I can even stop the AudioUnit while the sound file stills plays to hear the final samples, so the playback seems to work, but it's silent.

I tried AudioServicesPlaySystemSound and AVAudioPlayer without success on a real device (might work in simulator).

Is there a simple solution to this simple task or do i need to manually mix in the file based audio content?

Thanks in advance!


Solution

  • You can build AUGraph with Audio Units and play audio file through kAudioUnitSubType_AudioFilePlayer unit.