Package ca.phon.audio
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 TypeMethodDescriptionvoid
close()
long
getFile()
int
float
int
long
double
int
readSamples
(double[][] buffer) Read buffer[0].length samples from buffer.length channels starting from the current positionint
readSamples
(double[][] buffer, int offset, int numSamples) Read length samples from buffer.length channels Data will be inserted into buffer[channel] starting at offsetint
sampleIndexForTime
(float time) void
seekToSample
(long sample) void
seekToTime
(float time) float
timeForSampleIndex
(long sample)
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in 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
-