1

I'm interesting in accessing both microphone on a phone using the Android Oboe library. Most phones have a dual-mic configuration and I'd like to read data from both at the same time. I've extended the "LiveAffect" sample from Oboe, and tried the following:

  1. Having two oboe::AudioStream, one for each microphone on my phone (Note 9 and Pixel 1). Running only one of the streams works fine, I'm able to read the data and play it back/save to file. But starting both streams doesn't work (I get the following error when attempting to start the second stream via stream->requestStart(): E/AUDIO-APP: Error starting stream. ErrorInvalidState). Apparently starting two input streams is an Android limitation as discussed in this SO question: Android Oboe Library: 2 streams recording from 2 recording devices possible?

  2. Having one stream but with 2 channels. The two mics on my Note 9 are part of the same group, yet when I open a stream with either of them with 2 channels (->setChannelCount(oboe::ChannelCount::Stereo);), I get duplicate data in both channels for only one microphone. I've tried playing around with AudioStreamBuilder settings, for example setting ->setInputPreset(oboe::InputPreset::Camcorder). None of the InputPresets settings fixed it, still mirrored data in both channels.

Both attempts did not work using OpenSL backend either.

Artash
  • 569
  • 6
  • 11
  • "The two mics on my Note 9 are part of the same group" - what do you mean by "same group"? – donturner May 05 '19 at 12:17
  • The number returned from MicrophoneInfo.getGroup() (https://developer.android.com/reference/android/media/MicrophoneInfo). – Artash May 06 '19 at 03:17

2 Answers2

1

I'm fairly sure this is a problem with that particular device. A user reported an identical issue on the JUCE forum here. I have filed a bug internally (id: 133143785) and will attempt to route this to Samsung for further investigation.

donturner
  • 17,867
  • 8
  • 59
  • 81
1

The only way I could get a stereo input of both microphones (either AAUDIO or SLES ) on a Samsung S8 was to set:

builder->setDeviceId(0) // mandatory ! if set to the microphone id you get only one mic!
builder->setDirection(oboe::Direction::Input) // obvious
builder->setChannelCount(2) // obvious
builder->setFormat(oboe::AudioFormat::I16) // with oboe converter float should work to
builder->setInputPreset(oboe::InputPreset::Generic) // or oboe::InputPreset::Camcorder
builder->setUsage(oboe::Usage::Media) // unsure if this is ness.

Odd thing I noticed, androids AudioManager.getDevices (AudioManager.GET_DEVICES_ALL) on this device returns a different list after you used the audio in mono ( 2 x TYPE_BUILTIN_MIC ) or stereo ( 1x TYPE_BUILTIN_MIC ) all having AudioDeviceInfo.getChannelCounts() list = [1,2] !

jeanC
  • 56
  • 3
  • Unfortunately this is the only configuration that gave me stereo mics as well. As soon as a specific mic ID is specified, I get a duplicated mono signal. – Artash Jul 13 '20 at 19:32