I am using audacity to play back the raw stereo 16-bit linear PCM (dumped in Android HAL) which is the output of Android audio flinger. Total buffer is 960 bytes.
What is the right way of converting stereo to individual mono channels (left and right channel in individual buffers) from the audio_flinger_buf (given by audioflinger)?
My library needs separated out left and right channel as input.
I have below code which i thought will do aforementioned:
channels = 2
for (i=0;i<channels;i++) {
int j;
for (j=0;j<240;j++) {
seperate_buf[240*i+j] = ((int16_t *)audio_flinger_buf)[j*DSM_CHANNELS+i];
}
}
so seperate_buf[0..239] will have left sample and seperate_buf[240...479] will have right sample.
seperate_buf[0...239] is shown below:
seperate_buf[240....479] is shown below:
Why do i see stereo output here in both the above buffers?
Is my code correct for separating out left and right from a stereo buffer? I see that the audacity also does something similar (https://goo.gl/GZh7fg).