public static ByteBuffer convertToSigned16BitSamples(float[] samples){
  ByteBuffer converted=ByteBuffer.allocate(samples.length * 2);
  converted.order(ByteOrder.LITTLE_ENDIAN);
  for (  float sample : samples) {
    converted.putShort((short)(sample * Short.MAX_VALUE));
  }
  return converted;
}

public static ByteBuffer convertToSigned16BitSamples ( float [ ] samples ) { ByteBuffer converted = ByteBuffer . allocate ( samples . length * 2 ) ; converted . order ( ByteOrder . LITTLE_ENDIAN ) ; for ( float sample : samples ) { converted . putShort ( ( short ) ( sample * Short . MAX_VALUE ) ) ; } return converted ; }
converts the float samples into a little - endian 16 - bit sample byte buffer .
