xamarin-macios icon indicating copy to clipboard operation
xamarin-macios copied to clipboard

AVAudioEngine InputNode's InputBusFormat and OutputBusFormat return null in iOS Simulator

Open vadd98 opened this issue 2 years ago • 3 comments

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

  1. Create a Xamarin.iOS project targeting iOS 15
  2. Start the app on the simulator
  3. 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)

vadd98 avatar Jun 15 '22 19:06 vadd98

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!

dalexsoto avatar Jun 30 '22 13:06 dalexsoto

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.

msftbot[bot] avatar Jun 30 '22 13:06 msftbot[bot]

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

vadd98 avatar Jul 01 '22 13:07 vadd98

Hi, is there any news about this issue?

vadd98 avatar Aug 25 '22 10:08 vadd98

The sample seems to work fine for me, InputNode isn't null:

Screen Shot 2023-01-20 at 11 48 26

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.

rolfbjarne avatar Jan 20 '23 10:01 rolfbjarne

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.

msftbot[bot] avatar Jan 20 '23 10:01 msftbot[bot]

In the latest versions it indeed works, I think it started working in the late 2022 but I forgot to update this thread

vadd98 avatar Jan 20 '23 11:01 vadd98

OK, I'll close this then, thanks!

rolfbjarne avatar Jan 20 '23 11:01 rolfbjarne