0

I am developing an Android application which uses a MediaRecorder instance that records audio from the microphone. The output format is set to MediaRecorder.OutputFormat.AAC_ADTS, the audio encoder is MediaRecorder.AudioEncoder.AAC, and the audio channels are set to 2.

The recorded sound is saved into a file. To read the PCM data, I use the JAAD library. I save the PCM data in a 2D array called channels: channels[0] holds the data from channel 1, and channels[1] from channel 2. The data from the two 1D arrays are 100% equal.

I am wondering why that happens. Does this happen always, i.e. it's not phone-depended?

P.S. I also tried opening the file with the pydub library. I got the same results.

Jonas
  • 121,568
  • 97
  • 310
  • 388
George
  • 194
  • 2
  • 5
  • 13
  • 1
    Is your microphone a stereo microphone? If not, what differences, exactly, do you expect to see in the two channels? – greeble31 Dec 10 '19 at 15:48
  • @greeble31 I have no idea. I searched on the Internet, but I didn't find any information. However, according to the Docs, the method `setAudioChannels(int numOfChannels)` should be called before `prepare()` (which I do), because "Prepare() may perform additional checks on the parameter to make sure whether the specified number of audio channels are applicable." During processing, I call a method from the JAAD library, which returns the number of channels, and the number is 2. (Source: https://developer.android.com/reference/android/media/MediaRecorder#setAudioChannels(int)) – George Dec 10 '19 at 16:17
  • 1
    Well, then the answer is "no". It's a mono microphone. So you've asked the `MediaRecorder` to give you stereo channels from a mono microphone, and it did something reasonable: It dup'd the single track into both tracks. Your question is, "does this happen always"? Well, given certain basic assumptions, yes. Assuming your device doesn't have a stereo microphone. If it does, I would expect to see different data in each channel. – greeble31 Dec 10 '19 at 16:21
  • @greeble31 Yes, it's a mono microphone. I recorded an .mp3 with the built-in Voice Recorder app, then checked the waveform. 2 channels, same waveform. I suppose I can't get the information about whether a microphone is stereo or mono programmatically, right? – George Dec 10 '19 at 16:25
  • I'm not sure; see [this question](https://stackoverflow.com/questions/21810773/how-to-enable-stereo-recording-on-tablets-smartphones-yielding-only-mono-albeit). – greeble31 Dec 10 '19 at 16:31

0 Answers0