Java Utililty Methods Byte Array to Short

List of utility methods to do Byte Array to Short

Description

The list of methods to do Byte Array to Short are organized into topic(s).

Method

short[]byteToShort(byte[] data, int length, boolean reduceStereo)
Converts audio data in 'byte' format (little-endian 16-bit) to short array
if (reduceStereo) {
    short[] shortData = new short[length / 4];
    for (int i = 0; i < shortData.length; i++) {
        short val1 = (short) ((data[i * 4 + 1] << 8) | (data[i * 4] & 0xff));
        short val2 = (short) ((data[i * 4 + 3] << 8) | (data[i * 4 + 2] & 0xff));
        shortData[i] = (short) (((int) val1 + (int) val2) / 2);
    return shortData;
...