android 横向音频,android – 立体声音频录制在左右声道中提供相同的数据

  • Post author:
  • Post category:其他


使用此配置:

private int audioSource = MediaRecorder.AudioSource.MIC;

private static int sampleRateInHz = 48000;

private static int channelConfig = AudioFormat.CHANNEL_IN_STEREO;

private static int audioFormat = AudioFormat.ENCODING_PCM_16BIT;

音频数据中的数据如下.

leftChannel data: [0,1],[4,5]…

rightChannel data: [2,3],[6,7]…

所以你需要分开数据.

readSize = audioRecord.read(audioShortData, 0, bufferSizeInBytes);

for(int i = 0; i < readSize/2; i = i + 2)

{

leftChannelAudioData[i] = audiodata[2*i];

leftChannelAudioData[i+1] = audiodata[2*i+1];

rightChannelAudioData[i] = audiodata[2*i+2];

rightChannelAudioData[i+1] = audiodata[2*i+3];

}

希望这有用.