I’m new to Android Studio, and trying to create my first app I need to record stereo audio. I’m using the AudioRecord class with the following statements :
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate,
AudioFormat.CHANNEL_IN_STEREO,
AudioFormat.ENCODING_PCM_16BIT,bufferSize);
I’m using 2 external mics wired to a soundcard which is plugged into the phone through its usb plug. The stereo recording works fine when using the same soundcard with audacity on my computer.
But in the app the problem appears when using Java’s method recorder.read(sData, 0 , Elements2Rec)
: I get two identical channels. sData
looks like [1,1,8,8,0,0,-9,-9, etc]
with identical samples in each frame.
The only signal the app gets actually corresponds to the signal that one of the microphones records, but I’ve found no solution to get the signal from the second microphone. The same question was asked a long time ago on this link, or on that link, or on thaat link but I couldn’t solve my problem with them.
Would anyone have a clue about what I could do please ?
Here is additional information, in case that might help : My app needs to save the audio in a pcm file, that i’m writing byte after byte using the output of the recorder.read() method.
My target API is 15, i’m testing the app on a Samsung Galaxy A3.
I’ve declared audio permission in the manifest, but nothing more about how to handle the mics, because I don’t know if it is necessary nor how to do it. I’m using WM-4000PTV2 mics and Behringer UCA222 soundcard.