Package wavFiles

Class WavFileWriter

java.lang.Object
wavFiles.WavFile
wavFiles.WavFileWriter

public class WavFileWriter extends WavFile
  • Constructor Details

  • Method Details

    • writeSingleChannel

      public static boolean writeSingleChannel(String file, AudioFormat format, double[] doubleArray)
      Writes an array of double values to a WAV file. This method only writes single channel data.
      Parameters:
      format - AudioFormat object describing the desired file
      doubleArray - the array of double values to save
      Returns:
      boolean indicating success or failure of the write
    • write

      public boolean write(double[][] doubleArray)
      Writes an array of double values to an existing WAV file. This method writes single and multi-channel data. This method writes the data with any bit depth, depending on how the wav file object was created using an AudioFormat.
      Parameters:
      doubleArray - the array of double values to save. Note that this is defined as a 2D array. If a single-channel 1D vector is passed, it doesn't seem to be a problem.
      Returns:
      boolean indicating success or failure of the write
    • append

      public boolean append(double[][] rawData)
      Append data to a file which may or may not be closed already.
      If the file is still open then this simply calls the write function, otherwise it has to reopen the file.
      Parameters:
      rawData - Raw data to write. Must match audio format file was opened with.
      Returns:
      true if write was OK.
    • write

      public static boolean write(String fileName, float sampleRate, double[][] doubleArray)
      Writes an array of double values to a WAV file. This method writes single and multi-channel data. This method always writes the data as 16-bit. It shoul dbe used only for one off writing of short files.
      Parameters:
      sampleRate - The sample rate of the raw acoustic data
      doubleArray - the array of double values to save. Note that this is defined as a 2D array. If a single-channel 1D vector is passed, it doesn't seem to be a problem.
      numChannels - The number of channels to save
      Returns:
      boolean indicating success or failure of the write
    • close

      public void close()
      Overrides:
      close in class WavFile
    • getFileFrames

      public long getFileFrames()