As I understand, the audio byte array that I am using (PCM Stereo 16bit) is 4 bytes per sample. I noticed that when you invert the Byte value (ie. -128 to 128 and 128 to -128) it does not put the sound in the surround channel. It sounds the same (front audio). I experimented with inverting every other byte (every 2 bytes) rather than all of the bytes and got something like surround sound, but it's very dirty and choppy. How exactly do I manipulate a regular PCM 16bit Stereo WAV file (in byte array form) so that the audio is placed in the surround channels?
My Code:
public byte[] putInSurround(byte[] audio) {
for (int i = 0; i < audio.length; i += 4) {
int i0 = audio[i + 0];
int i1 = audio[i + 1];
int i2 = audio[i + 2];
int i3 = audio[i + 3];
if (0 > audio[i + 0]) {
i0 = Math.abs(audio[i + 0]);
}
if (0 < audio[i + 0]) {
i0 = 0 - audio[i + 0];
}
if (0 > audio[i + 1]) {
i1 = Math.abs(audio[i + 1]);
}
if (0 < audio[i + 1]) {
i1 = 0 - audio[i + 1];
}
if (0 > audio[i + 2]) {
i2 = Math.abs(audio[i + 2]);
}
if (0 < audio[i + 2]) {
i2 = 0 - audio[i + 2];
}
if (0 > audio[i + 3]) {
i3 = Math.abs(audio[i + 3]);
}
if (0 < audio[i + 3]) {
i3 = 0 - audio[i + 3];
}
audio[i + 0] = (byte) i0;
//audio[i + 1] = (byte) i1; <-- Commented Out For Every Other Byte.
//audio[i + 2] = (byte) i2; <-- Commented Out For Every Other Byte.
audio[i + 3] = (byte) i3;
}
return audio;
}