private static ByteBuffer generateWavHeader(int sampleCount){
  final int numDataBytes=sampleCount * NUM_CHANNELS * BITS_PER_SAMPLE / 8;
  ByteBuffer buf=ByteBuffer.allocate(44);
  buf.order(ByteOrder.LITTLE_ENDIAN);
  buf.putInt(0x46464952);
  buf.putInt(36 + numDataBytes);
  buf.putInt(0x45564157);
  buf.putInt(0x20746d66);
  buf.putInt(16);
  buf.putShort((short)1);
  buf.putShort((short)NUM_CHANNELS);
  buf.putInt(SAMPLE_RATE);
  buf.putInt(SAMPLE_RATE * NUM_CHANNELS * BITS_PER_SAMPLE / 8);
  buf.putShort((short)(NUM_CHANNELS * BITS_PER_SAMPLE / 8));
  buf.putShort((short)BITS_PER_SAMPLE);
  buf.putInt(0x61746164);
  buf.putInt(numDataBytes);
  buf.position(0);
  return buf;
}

private static ByteBuffer generateWavHeader ( int sampleCount ) { final int numDataBytes = sampleCount * NUM_CHANNELS * BITS_PER_SAMPLE / 8 ; ByteBuffer buf = ByteBuffer . allocate ( 44 ) ; buf . order ( ByteOrder . LITTLE_ENDIAN ) ; buf . putInt ( 0x46464952 ) ; buf . putInt ( 36 + numDataBytes ) ; buf . putInt ( 0x45564157 ) ; buf . putInt ( 0x20746d66 ) ; buf . putInt ( 16 ) ; buf . putShort ( ( short ) 1 ) ; buf . putShort ( ( short ) NUM_CHANNELS ) ; buf . putInt ( SAMPLE_RATE ) ; buf . putInt ( SAMPLE_RATE * NUM_CHANNELS * BITS_PER_SAMPLE / 8 ) ; buf . putShort ( ( short ) ( NUM_CHANNELS * BITS_PER_SAMPLE / 8 ) ) ; buf . putShort ( ( short ) BITS_PER_SAMPLE ) ; buf . putInt ( 0x61746164 ) ; buf . putInt ( numDataBytes ) ; buf . position ( 0 ) ; return buf ; }
generates the 44 - byte wav file header .
