xamarin-macios
xamarin-macios copied to clipboard
AVAudioEngine InputNode's InputBusFormat and OutputBusFormat return null in iOS Simulator
I'm developing a mobile app for iPhone which needs to record audio from microphone. I'm trying to use AVAudioEngine but it seems I can't use the InputNode's InputBusFormat and OutputBusFormat. Because they are both null, when I try to use them to setup a recorder no audio is actually recorded.
Steps to Reproduce
- Create a Xamarin.iOS project targeting iOS 15
- Start the app on the simulator
- Try to get InputNode or the OutputNode from AVAudioEngine
Expected Behavior
Get InputNode's InputBusFormat or OutputBusFormat from AVAudioEngine
Actual Behavior
Getting InputNode and OutputNode using
var inputFormat = _audioEngine.InputNode.GetBusInputFormat(0); var outputFormat = _audioEngine.InputNode.GetBusOutputFormat(0);
return null for both.
By the way, in the exact same enviornment, via Swift it is possible to get them using
let inputFormat = self.audioEngine.inputNode.inputFormat(forBus: 0) let outputFormat = self.audioEngine.outputNode.outputFormat(forBus: 0)
In both cases there is a info.plist with NSMicrophoneUsageDescription and NSSpeechRecognitionUsageDescription.
Environment
Version information
Xamarin.iOS version 15.10.0.5
Build Logs
Example Project (If Possible)
Hello!
Any chance you can provide a sample app in order to reproduce this? This would avoid any guesses or misconfigurations on my side.
Thank you!
Hi @vadd98. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Sure! This is a repro https://github.com/vadd98/MauiIosAudioRepro Clicking on the button "Start Recording" makes the service start. In the IosRecorderService there is a method named RecognizeAudioFromMicrophoneInBackground. In that method there is the call to the input node which returns null
Hi, is there any news about this issue?
The sample seems to work fine for me, InputNode isn't null:

I got a few permission dialogs in the beginning, and accepted all of them. Could it be that you said No to any of those permission dialogs by accident? You should be able to check this by changing the bundle identifier if your app slightly, so that iOS thinks it's a completely different app, and will show the dialogs again.
Hi @vadd98. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
In the latest versions it indeed works, I think it started working in the late 2022 but I forgot to update this thread
OK, I'll close this then, thanks!