Hi i’m trying to map a mono sound of a character to stero by panning. I have a class that filters a stream of bytes, i can get the sample of the mono sound but i’m having problems in creating the stereo samples. Its hard for me to explain so ill paste some code here its from the class Soundfilter.
This is the method i use to get the sample from bytes and works fine.
public static short getSample(byte[] buffer, int position) {
return (short)(
((buffer[position+1] & 0xff) << 8) |
(buffer[position] & 0xff));
}
But if i want to put it back with a new left and right sample in new byte array of samples i have this method:
public static void setSample(byte[] buffer, int pos, short leftSample, short rightSample) {
buffer[pos]= (byte)(leftSample & 0xff);
buffer[pos + 1] = (byte)((leftSample >> 8) & 0xff);
buffer[pos + 2] = (byte)(rightSample & 0xff);
buffer[pos + 3] = (byte)((rightSample >> 8) & 0xff);
}
Is the left and right sample in the correct position? In a 16bit sample of stereo sound does the first 2 bytes represent left sample and the next 2 bytes represent right sample?