Package ca.phon.audio

Class AudioFile

java.lang.Object
ca.phon.audio.AudioFile
All Implemented Interfaces:
Closeable, AutoCloseable

public final class AudioFile extends Object implements AutoCloseable, Closeable
An audio file. For a list of supported file types see AudioFileType. For a list of supported encodings see AudioFileEncoding. This class encapsulates a memory mapped audio file and should be closed when no longer needed. Use AudioIO.openAudioFile(File) to create a new AudioFile object from a file on disk.
  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • getFile

      public File getFile()
    • getNumberOfChannels

      public int getNumberOfChannels()
    • getDataOffset

      public long getDataOffset()
    • getSampleRate

      public double getSampleRate()
    • getNumberOfSamples

      public long getNumberOfSamples()
    • getAudioFileType

      public AudioFileType getAudioFileType()
    • getAudioFileEncoding

      public AudioFileEncoding getAudioFileEncoding()
    • sampleIndexForTime

      public int sampleIndexForTime(float time)
    • timeForSampleIndex

      public float timeForSampleIndex(long sample)
    • getLength

      public float getLength()
    • getFrameSize

      public int getFrameSize()
    • seekToTime

      public void seekToTime(float time)
    • seekToSample

      public void seekToSample(long sample)
    • readSamples

      public int readSamples(double[][] buffer) throws IOException
      Read buffer[0].length samples from buffer.length channels starting from the current position
      Parameters:
      buffer -
      Throws:
      IOException
    • readSamples

      public int readSamples(double[][] buffer, int offset, int numSamples) throws IOException
      Read length samples from buffer.length channels Data will be inserted into buffer[channel] starting at offset
      Parameters:
      buffer -
      offset -
      length -
      Throws:
      IOException