Your comments say that the code assumes big-endian.
Technically, you are actually outputting to little-endian, however it does not matter, because thanks to a fortunate quirk, your highest byte is always 0.
EDIT: , - 127, (0x00, 0x7f), (0x7f, 0x00) 32512. 16- 32767, 8 . 32767 , 8 , .
, 16- 8 . , -, .
, , . , , 8 .
, , , , , :
int samples = 2 << 19;
byte audioBuffer[] = new byte[samples * channels * sampleSizeInBytes];
for ( int i = 0, j = 0; i < samples; ++i )
{
int wave = (int)(32767.0 * Math.sin(2.0 * Math.PI * frequency * i / sampleRate));
byte msb = (byte)(wave >>> 8);
byte lsb = (byte) wave;
for (int c = 0; c < channels; ++c) {
audioBuffer[j++] = msb;
if (sampleSizeInBytes > 1) {
audioBuffer[j++] = lsb;
}
}
}