public void writeToFilePath() {
   try {
     DataOutputStream dataOutputStream =
         new DataOutputStream(new BufferedOutputStream(new FileOutputStream(this.filePath)));
     DataOutputStreamLittleEndian writer;
     writer = new DataOutputStreamLittleEndian(dataOutputStream);
     this.writeToFilePath_WriteChunks(writer);
     writer.close();
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
 private void writeToFilePath_WriteChunks_Data(DataOutputStreamLittleEndian writer)
     throws IOException {
   writer.writeString("data");
   int numberOfBytesInSamples =
       (int)
           (this.samplesForChannels[0].length
               * this.samplingInfo.numberOfChannels
               * this.samplingInfo.bitsPerSample
               / WavFile.BitsPerByte);
   writer.writeInt(numberOfBytesInSamples);
   byte[] samplesAsBytes = Sample.convertManyToBytes(this.samplesForChannels, this.samplingInfo);
   writer.writeBytes(samplesAsBytes);
 }
 private void writeToFilePath_WriteChunks(DataOutputStreamLittleEndian writer) throws IOException {
   int numberOfBytesInSamples =
       (int)
           (this.samplesForChannels[0].length
               * this.samplingInfo.numberOfChannels
               * this.samplingInfo.bitsPerSample
               / WavFile.BitsPerByte);
   writer.writeString("RIFF");
   writer.writeInt(
       (int) (numberOfBytesInSamples + WavFile.NumberOfBytesInRiffWaveAndFormatChunks));
   writer.writeString("WAVE");
   this.writeToFilePath_WriteChunks_Format(writer);
   this.writeToFilePath_WriteChunks_Data(writer);
 }
 private void writeToFilePath_WriteChunks_Format(DataOutputStreamLittleEndian writer)
     throws IOException {
   writer.writeString("fmt ");
   writer.writeInt(this.samplingInfo.chunkSizeInBytes);
   writer.writeShort(this.samplingInfo.formatCode);
   writer.writeShort((short) this.samplingInfo.numberOfChannels);
   writer.writeInt((int) this.samplingInfo.samplesPerSecond);
   writer.writeInt((int) this.samplingInfo.bytesPerSecond());
   writer.writeShort(
       (short)
           (this.samplingInfo.numberOfChannels
               * this.samplingInfo.bitsPerSample
               / WavFile.BitsPerByte));
   writer.writeShort((short) this.samplingInfo.bitsPerSample);
 }