В качестве отправной точки у меня есть метод, который работает. Но, похоже, слишком много строк или перекрывающихся действий. Если вы мастер аудио, вы сразу же увидите, как все это сделать. Так как же это свести?
public static byte[] float16toDualByte(byte[] twoPlaces, float f_val) {
short val_as_short = (short) (f_val * 32768);//signed short.16bit.
twoPlaces[0] = (byte) (val_as_short >>> 8);
twoPlaces[1] = (byte) val_as_short;
ByteBuffer buf = ByteBuffer.wrap(twoPlaces);
buf.order(ByteOrder.LITTLE_ENDIAN);
short turned = buf.asShortBuffer().get(0);
twoPlaces[0] = (byte) (turned >>> 8);
twoPlaces[1] = (byte) turned;
return twoPlaces;
}