0

I've been working on an app that makes an audio pipeline through AVAudioEngine and then renders to a file.

I've been using this code example's approach, adapted for my own needs. The problem is that if headphones are connected to the device, the output audio file is silent. You can observe this by running that project with headphones connected.

The only idea I have is that maybe iPhone usually has a mono outputNode, but headphones give it a stereo format. I find this stuff quite hard to debug, so any pointers are appreciated.

I got that sample code from here, which may give further context on the problem.

Thanks

Community
  • 1
  • 1
skattyadz
  • 330
  • 2
  • 9
  • This user saw a similar behaviour, of audio that didn't work with headphones connected (although in their case it crashed). I've tried changing the format definitions to all the `inputFormatForBus` and `outputFormatForBus` possibilities and still haven't had any luck http://stackoverflow.com/questions/28331461/connect-avaudioinputnode-to-avaudiouniteffect-using-avaudioengine – skattyadz Dec 08 '15 at 20:41

1 Answers1

0

Looks like the session is set for playback. Try setting it to AVAudioSessionCategoryAudioProcessing.

Gene De Lisa
  • 3,628
  • 1
  • 21
  • 36
  • Ok, this sounds promising, I will try tonight and see where I get. Thanks – skattyadz Dec 08 '15 at 11:43
  • I'm afraid that using `AVAudioSessionCategoryAudioProcessing` gives a error as soon as you try to access the engine's input or output nodes. I need an output node in order to access its audio unit to pull data. – skattyadz Dec 08 '15 at 20:41
  • Thanks for checking it out. The docs say "The category for using an audio hardware codec or signal processor while not playing or recording audio. Use this category, for example, when performing offline audio format conversion." I thought that would fit your situation. Let us know what you end up doing. – Gene De Lisa Dec 09 '15 at 16:58
  • I think the problem is a misuse of AVAudioEngine which might not have been designed to work in this manner – skattyadz Dec 10 '15 at 17:32
  • 2
    So is there no way to offline render with avaudioengine? – KorinW Mar 22 '16 at 08:37