AVAudioEngine offline render: Silent output only when headphones connected
Asked Answered
A

1

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

Andesite answered 7/12, 2015 at 22:24 Comment(1)
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 #28331961Andesite
E
0

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

Eyla answered 7/12, 2015 at 22:35 Comment(5)
Ok, this sounds promising, I will try tonight and see where I get. ThanksAndesite
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.Andesite
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.Eyla
I think the problem is a misuse of AVAudioEngine which might not have been designed to work in this mannerAndesite
So is there no way to offline render with avaudioengine?Pyromancy

© 2022 - 2024 — McMap. All rights reserved.