Class AudioFile
java.lang.Object
ca.phon.audio.AudioFile
- All Implemented Interfaces:
Closeable,AutoCloseable
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 Summary
Modifier and TypeMethodDescriptionvoidclose()longgetFile()intfloatintlongdoubleintreadSamples(double[][] buffer) Read buffer[0].length samples from buffer.length channels starting from the current positionintreadSamples(double[][] buffer, int offset, int numSamples) Read length samples from buffer.length channels Data will be inserted into buffer[channel] starting at offsetintsampleIndexForTime(float time) voidseekToSample(long sample) voidseekToTime(float time) floattimeForSampleIndex(long sample)
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getFile
-
getNumberOfChannels
public int getNumberOfChannels() -
getDataOffset
public long getDataOffset() -
getSampleRate
public double getSampleRate() -
getNumberOfSamples
public long getNumberOfSamples() -
getAudioFileType
-
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
Read buffer[0].length samples from buffer.length channels starting from the current position- Parameters:
buffer-- Throws:
IOException
-
readSamples
Read length samples from buffer.length channels Data will be inserted into buffer[channel] starting at offset- Parameters:
buffer-offset-length-- Throws:
IOException
-