    private void writeWaveHeader() throws IOException {
        RandomAccessFile file = new RandomAccessFile(this.output, "rw");
        file.seek(0);
        int bytesPerSec = (sampleBits + 7) / 8;
        file.writeBytes("RIFF"); 
        file.writeInt(Integer.reverseBytes(bytesWritten + 36)); 
        file.writeBytes("WAVEfmt ");
        file.writeInt(Integer.reverseBytes(16)); 
        file.writeShort(Short.reverseBytes((short) 1)); 
        file.writeShort(Short.reverseBytes((short) channels)); 
        file.writeInt(Integer.reverseBytes(sampleRate)); 
        file
                .writeInt(Integer.reverseBytes(sampleRate * channels
                        * bytesPerSec)); 
        file.writeShort(Short.reverseBytes((short) (channels * bytesPerSec))); 
        file.writeShort(Short.reverseBytes((short) sampleBits)); 
        file.writeBytes("data"); 
        file.writeInt(Integer.reverseBytes(bytesWritten)); 
        file.close();
        file = null;
    }

    private void writeWaveHeader() throws IOException {
        RandomAccessFile file = new RandomAccessFile(this.output, "rw");
        file.seek(0);
        int bytesPerSec = (sampleBits + 7) / 8;
        file.writeBytes("RIFF"); 
        file.writeInt(Integer.reverseBytes(bytesWritten + 36)); 
        file.writeBytes("WAVEfmt ");
        file.writeInt(Integer.reverseBytes(16)); 
        file.writeShort(Short.reverseBytes((short) 1)); 
        file.writeShort(Short.reverseBytes((short) channels)); 
        file.writeInt(Integer.reverseBytes(sampleRate)); 
        file.writeInt(Integer.reverseBytes(sampleRate * channels * bytesPerSec));   
        file.writeShort(Short.reverseBytes((short) (channels * bytesPerSec))); 
        file.writeShort(Short.reverseBytes((short) sampleBits)); 
        file.writeBytes("data"); 
        file.writeInt(Integer.reverseBytes(bytesWritten)); 
        file.close();
        file = null;
    }
