For the app I’m currently developing I would like to choose or at least know about the direction the phone records audio from (best case: mic at the bottom of the phone). This would be useful to show the user how to hold the phone while recording his/her voice and in a difficult scenario like a crowded room one could lower the level of noise and other speakers (not of interest) recorded by the app.

Currently the app uses the Google Oboe library. During the initialisation of the audio stream the library gives the option for one of multiple InputPresets you can choose from (like AAudio does). These InputPresets have influence on which mic is used for the audio recording. Therefore i had hoped i could use this option to get similar behavior on all phones.

Since I would prefer to get unprocessed audio, in the first setup I tested a mono input steam with IP(InputPreset)9: Unprocessed. With this setup most of the phones in my test were not doing any processing as the InputPreset intends and provided input from the bottom mic. But a few phones including Huawei P20lite and Xiaomi Redmi Note Pro 11 were activating 2 mics (bottom + top) and in the audio callback the app received a pre-mixed mono audio signal of both inputs. This is a problem because if someone else in the room is talking next to the user, it can become hard to get a speech signal clean enough for further processing.

I tried to test with the variety of InputPresets but their behaviour is not consistent trough the phone manufacturers (OnePlus 8 Nord uses bottom mic for IP9 and top mic for IP6 while a Xiaomi Mi 10T does it in reverse and Samsung devices stay with the bottom mic for both…). The Huawei P20lite only provided the top mic or top and bottom pre-mixed depending on the InputPreset.

I managed find a way to get the bottom mic signal from the P20 by opening a stereo stream and only processing the first channel. But this is just a hack which does not work reliably on all the phones either (I.e. does not work with Pixel 3a).

I also tried to list available devices with AudioManager.GET_DEVICES_INPUTS and then use the device IDs on audio stream start. But as example, for the Huawei phone you are able to choose from the input devices “build-in microphone" and "telephony" so it does not differentiate between single build-in microphones and both options will give you 2 active and pre-mixed mics in InputPreset 9: Unprocessed.

setPreferredMicrophoneDirection does not seem to be able to do more then the inputPresets already do.

The audio processing is done in C++. It would be nice if the app could remain using Google Oboe but I am interested if there is any possible solution.

Is it possible to programmatically ask the OS to provide the input of only 1 mic (not a mono mix of 2 mics)? And if so, could one ask for a preferred mic/direction (i.e. bottom / towards user) which is consistent through all Android phones?

0

There are 0 answers