The AudioFile
allows reading and writing
of sound files. It can operate both on a RandomAccessFile
created from a File
instance, or on
an kind of InputStream
(not every codec will
support this though, and functionality might be limited, for example
seeking is not possible with a plain InputStream
).
The codecs are registered with AudioFileType
.
The codecs that come with AudioFile are found in the impl
package.
Reading and writing data requires a user-buffer which holds de-interleaved
floating point data, that is a two dimensional Array
which
holds Double
data. A type alias Frames
is provided
for this, and two helper methods buffer
: one static to
construct an arbitrary user-buffer, one in class AudioFile
which creates a buffer with the appropriate channel number.
- See also:
AudioFileType
- Todo:
the copyTo method uses a user-buffer. it should check for the possibility to directly transfer data if input and output are compatible.
- Companion:
- class
Type members
Types
Value members
Concrete methods
Opens an audio file for asynchronous reading.
Opens an audio file for asynchronous reading.
- Value parameters:
- uri
the path name of the file
- Returns:
a future
AsyncAudioFile
object whose header is already parsed when the future completes, and that can be obtained through thespec
method.- Throws:
- java.io.IOException
if the file was not found, could not be reader or has an unknown or unsupported format
Note that this method advances in the provided input stream, its previous position is not reset.
Note that this method advances in the provided input stream, its previous position is not reset.
Inherited methods
Determines the type of audio file.
Determines the type of audio file.
- Value parameters:
- f
the pathname of the file
- Returns:
the type code as defined in
AudioFileInfo
, e.g.TYPE_AIFF
. ReturnsTYPE_UNKNOWN
if the file could not be identified.- Throws:
- java.io.IOException
if the file could not be reader
- Inherited from:
- AudioFilePlatform
Opens an audio file for reading.
Opens an audio file for reading.
- Value parameters:
- f
the path name of the file
- Returns:
a new
AudioFile
object whose header is already parsed and can be obtained through thespec
method.- Throws:
- java.io.IOException
if the file was not found, could not be reader or has an unknown or unsupported format
- Inherited from:
- AudioFilePlatform
Opens an audio file for reading/writing. The pathname
is determined by the file
field of the provided AudioFileInfo
.
If a file denoted by this path already exists, it will be
deleted before opening.
Opens an audio file for reading/writing. The pathname
is determined by the file
field of the provided AudioFileInfo
.
If a file denoted by this path already exists, it will be
deleted before opening.
Note that the initial audio file header is written immediately.
Special tags for the header thus need to be set in the AudioFileInfo
before calling this method, including markers and regions. It is not
possible to writer markers and regions after the file has been opened
(since the header size has to be constant).
- Value parameters:
- f
the path name of the file.
- spec
format and resolution of the new audio file. the header is immediately written to the hard-disc
- Throws:
- java.io.IOException
if the file could not be created or the format is unsupported
- Inherited from:
- AudioFilePlatform
Concrete fields
System property key. The boolean property can be set to true
or false
.
It will only be read once, the first time a buffer is allocated. The default is false
.
When true
, ByteBuffer.allocateDirect
is used instead of allocate
, possibly using faster
direct memory.
System property key. The boolean property can be set to true
or false
.
It will only be read once, the first time a buffer is allocated. The default is false
.
When true
, ByteBuffer.allocateDirect
is used instead of allocate
, possibly using faster
direct memory.