jeff Bondy
jeff Bondy

Reputation: 41

recording stereo with AudioRecord in android

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

Upvotes: 4

Views: 6535

Answers (1)

Hartmut Pfitzinger
Hartmut Pfitzinger

Reputation: 2306

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.

Upvotes: 4

Related Questions