Package SoundRecorder

Class WavFileStorage

java.lang.Object
SoundRecorder.WavFileStorage
All Implemented Interfaces:
RecorderStorage

public class WavFileStorage extends Object implements RecorderStorage
Bespoke system for storing wav files. Am too sick of the complicated piped system required to use the standard Java libraries.
Author:
dg50
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    addData(long dataTimeMillis, double[][] newData)
    Adds data to the store.
    boolean
    Closes the storage (and stops recording).
    long
    Get the number of frames in the current file.
    long
    Get the file length in milliseconds
    Gets the store file name.
    long
    Get the file size in bytes/ Note that this is the physical size of the file which may not relate to the file length if a compressed recording system is used.
    long
    Get the time the current file started at.
    long
    Get the absolute maximum file size in bytes for this type of storage
    boolean
    openStorage(AudioFileFormat.Type fileType, long recordingStart, float sampleRate, int nChannels, int bitDepth)
    Open audio file storage
    boolean
    reOpenStorage(long recordingStart)
    Reopens the recording storage in a new file (if appropriate) This is done in the RecorderStorage class rather than as separate calls to closeStorage and openStorage in

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • openStorage

      public boolean openStorage(AudioFileFormat.Type fileType, long recordingStart, float sampleRate, int nChannels, int bitDepth)
      Description copied from interface: RecorderStorage
      Open audio file storage
      Specified by:
      openStorage in interface RecorderStorage
      Parameters:
      fileType - Type of file storage (e.g. AU, AIFF, WAVE)
      recordingStart - Start time of recording in milliseconds. The storage system should base a file name on the time
      sampleRate - Sample rate for the recording
      nChannels - Number of channels in the recording
      bitDepth - Number of bits (e.g. 8, 16, 24)
      Returns:
      true if OK
    • reOpenStorage

      public boolean reOpenStorage(long recordingStart)
      Description copied from interface: RecorderStorage
      Reopens the recording storage in a new file (if appropriate) This is done in the RecorderStorage class rather than as separate calls to closeStorage and openStorage in
      Specified by:
      reOpenStorage in interface RecorderStorage
      Parameters:
      recordingStart - new recording start time in milliseconds
      Returns:
      true if OK/
    • addData

      public boolean addData(long dataTimeMillis, double[][] newData)
      Description copied from interface: RecorderStorage
      Adds data to the store. Data are in a double array newData[channels][samples]. The number of channels must match the number of channels in the call to openStorage and the number of samples must be the same for all channels.
      Specified by:
      addData in interface RecorderStorage
      Parameters:
      dataTimeMillis - the time of the data
      newData - array of arrays of double data arranged by channel and sample
      Returns:
      true if OK.
    • closeStorage

      public boolean closeStorage()
      Description copied from interface: RecorderStorage
      Closes the storage (and stops recording). The input and output data streams are flushed and closed. This automatically causes the write thread to terminate.
      Specified by:
      closeStorage in interface RecorderStorage
      Returns:
      true if OK
    • getFileName

      public String getFileName()
      Description copied from interface: RecorderStorage
      Gets the store file name. The file name must be set to null when the file is closed.
      Specified by:
      getFileName in interface RecorderStorage
      Returns:
      file name (or name of other store type)
    • getFileSizeBytes

      public long getFileSizeBytes()
      Description copied from interface: RecorderStorage
      Get the file size in bytes/ Note that this is the physical size of the file which may not relate to the file length if a compressed recording system is used.
      Specified by:
      getFileSizeBytes in interface RecorderStorage
      Returns:
      file size in bytes
    • getFileFrames

      public long getFileFrames()
      Description copied from interface: RecorderStorage
      Get the number of frames in the current file.
      Specified by:
      getFileFrames in interface RecorderStorage
      Returns:
      the number of frames in the current file.
    • getFileMilliSeconds

      public long getFileMilliSeconds()
      Description copied from interface: RecorderStorage
      Get the file length in milliseconds
      Specified by:
      getFileMilliSeconds in interface RecorderStorage
      Returns:
      the file length in milliseconds.
    • getFileStartTime

      public long getFileStartTime()
      Description copied from interface: RecorderStorage
      Get the time the current file started at.
      Specified by:
      getFileStartTime in interface RecorderStorage
      Returns:
      time file started at or -1 if no current file.
    • getMaxFileSizeBytes

      public long getMaxFileSizeBytes()
      Description copied from interface: RecorderStorage
      Get the absolute maximum file size in bytes for this type of storage
      Specified by:
      getMaxFileSizeBytes in interface RecorderStorage
      Returns:
      Maximum size. Return Long.MAX_VALUE if it's indefinite.