Recording stereo audio with a Motorola Moto G (or Moto X)

会有一股神秘感。 提交于 2019-12-19 03:42:29

问题


I hope someone could help me with this issue.

Some time ago I developed an application in order to record simultaneously the sound captured by the front mic and the back one in a smartphone. Basically, I make the next object like this:

AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.CAMCORDER, frequency, AudioFormat.CHANNEL_IN_STEREO, audio encoding, buffer size);

It worked perfectly for a Sony Xperia Neo V but not for a Motorola Moto G (or Moto X I guess). Taking a look at the documentation I saw the next for the CAMCORDER flag:

Microphone audio source with same orientation as camera if available, the main device microphone otherwise.

Motorola Moto G does not have a camera mic but one in the top (Sony Xperia has one mic in the back or camera mic). In fact, with Moto G I got the same signal (the one captured by the front mic) twice, which is correct according to the documentation.

Can anybody help me?


回答1:


I had the same problem, and I got it to work using a sample rate of 48000 Hz. I figured it would work since the video recordings made with the default camera app worked in stereo and had this sampling rate. This frequency must also be considered when using the function getMinBufferSize().

Here are my settings:

private static final int RECORDER_BPP = 16;
private static final int RECORDER_SAMPLERATE = 48000;
private static final int RECORDER_CHANNELS = AudioFormat.CHANNEL_IN_STEREO;
private static final int RECORDER_AUDIO_ENCODING = AudioFormat.ENCODING_PCM_16BIT;

and then I create the AudioRecord object with:

recorder = new AudioRecord(MediaRecorder.AudioSource.CAMCORDER,
                                            RECORDER_SAMPLERATE, RECORDER_CHANNELS,RECORDER_AUDIO_ENCODING, bufferSize);

I am using the Moto G, with KitKat installed.



来源:https://stackoverflow.com/questions/20563483/recording-stereo-audio-with-a-motorola-moto-g-or-moto-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!