4

I'm looking for a definitive answer on getting audioRecord to use both the top mounted and bottom mounted microphones so I don't have 2 identical (mono) channels. I'd like to know what polling I could do before hand to ensure that a gadget will provide a good stream.

I'm working on a galaxy nexus 5, and can't get that to work so I'm no way near getting it stable across all the devices.

I've tried all the MediaRecorder.AudioSource.

AudioRecord audioInputStream1 = new AudioRecord(Media.Recorder.CAMCORDER,
    sampleRate, AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT,
    samplesPerBuffer * bytesPerSample)

and also instantiating two records:

AudioRecord audioInputStream1 = new AudioRecord(Media.Recorder.MIC,
    sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT,
    samplesPerBuffer * bytesPerSample)

AudioRecord audioInputStream2 = new AudioRecord(Media.Recorder.CAMCORDER,
    sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT,
    samplesPerBuffer * bytesPerSample)

If anyone did get stereo recording on a nexus 5 I'd greatly appreciate the help. Should I move to alsa or tinyAlsa?

thanks, j

Hartmut Pfitzinger
  • 2,304
  • 3
  • 28
  • 48
jeff Bondy
  • 41
  • 1
  • 2
  • On many of the devices I've worked with, the `CAMCORDER` audio source corresponds to a secondary mic (often located at the back of the phone), so it would implicitly be a mono source. I think your best bet for getting stereo recording is to use the `MIC` audio source in combination with `CHANNEL_IN_STEREO` (but keep in mind that some devices simply do not support stereo recording). Trying to use two mono recorders in parallel will probably not work at all on most devices. – Michael Sep 23 '14 at 09:33
  • Thanks @Michael, do you have experience with a gadget that allows stereo recording with 'MIC' and 'CHANNEL_IN_STEREO' ? – jeff Bondy Sep 23 '14 at 13:17
  • You've got a serious spelling flaw in your source codes: You mistakenly used `Media.Recorder.` instead of `MediaRecorder.AudioSource.` – Hartmut Pfitzinger Jan 20 '15 at 17:25

1 Answers1

4

Your question is closely related to my question and it seems the answer is device-dependent:

1) For some devices (e.g. Samsung S2 Plus GT-I9105P, HTC One M7, HTC One M8, G3 LG-D855, Nexus 5, ...) there is simply no way to activate real stereo recordings via the built-in microphone capsules. Although in some cases the camcorder app of the manufacturer produces real stereo you won't find any other app which is able to do that.

2) For some other devices, only few specific combinations of MediaRecorder.AudioSource and e.g. sample rate (or other basic settings) enable real stereo recording (e.g. Motorola Moto G needs MediaRecorder.AudioSource.CAMCORDER and 48kHz sample rate).

3) On most devices with two microphone capsules AudioFormat.CHANNEL_IN_STEREO is sufficient to activate real stereo recording.

Unfortunately, Alsa or tinyAlsa will most probably not solve the problem without rooting the device.

Community
  • 1
  • 1
Hartmut Pfitzinger
  • 2,304
  • 3
  • 28
  • 48