public void export(String fileName,int sampleRate,short[] samples) throws IOException {
  nBytesPerSample=2;
  buf=new byte[samples.length * 2];
  for (int i=0; i < samples.length; i++) {
    buf[2 * i]=(byte)((samples[i] & 0xff00) >>> 8);
    buf[2 * i + 1]=(byte)((samples[i] & 0x00ff));
  }
  doWrite(fileName,sampleRate);
}

public void export ( String fileName , int sampleRate , short [ ] samples ) throws IOException { nBytesPerSample = 2 ; buf = new byte [ samples . length * 2 ] ; for ( int i = 0 ; i < samples . length ; i ++ ) { buf [ 2 * i ] = ( byte ) ( ( samples [ i ] & 0xff00 ) > > > 8 ) ; buf [ 2 * i + 1 ] = ( byte ) ( ( samples [ i ] & 0x00ff ) ) ; } doWrite ( fileName , sampleRate ) ; }
export an array of shorts to a wav file .
