Skip to content

Instantly share code, notes, and snippets.

@drodsou
Last active July 30, 2016 08:57
Show Gist options
  • Save drodsou/6526447 to your computer and use it in GitHub Desktop.
Save drodsou/6526447 to your computer and use it in GitHub Desktop.
[algorithm] Reading audio buffer
int divider = 1;
if (output.getSampleFrequency() < 44100) divider *= 2;
if (output.getChannelCount() == 1) divider *= 2;
short[] pcm = output.getBuffer();
for (int i=0; i < pcm.length/divider; i+=1) {
outStream.write(pcm[i] & 0xff);
outStream.write((pcm[i] >> 8 ) & 0xff);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment