| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
File file = …;
AudioFileFormat aff = AudioSystem.getAudioFileFormat(file);
Based on 13 examples
public class AudioFileFormat extends Object
An instance of the AudioFileFormat
class describes
an audio file, including the file type, the file's length in bytes,
the length in sample frames of the audio data contained in the file,
and the format of the audio data.
The {@link AudioSystem}
class includes methods for determining the format
of an audio file, obtaining an audio input stream from an audio file, and
writing an audio file from an audio input stream.
An AudioFileFormat
object can
include a set of properties. A property is a pair of key and value:
the key is of type String
, the associated property
value is an arbitrary object.
Properties specify additional informational
meta data (like a author, copyright, or file duration).
Properties are optional information, and file reader and file
writer implementations are not required to provide or
recognize properties.
The following table lists some common properties that should be used in implementations:
Property key | Value type | Description |
---|---|---|
"duration" | {@link java.lang.Long Long} | playback duration of the file in microseconds |
"author" | {@link java.lang.String String} | name of the author of this file |
"title" | {@link java.lang.String String} | title of this file |
"copyright" | {@link java.lang.String String} | copyright message |
"date" | {@link java.util.Date Date} | date of the recording or release |
"comment" | {@link java.lang.String String} | an arbitrary text |
Nested Class Summary | |
---|---|
static class |
An instance of the Type class represents one of the
standard types of audio file. |
Constructor Summary | |
---|---|
AudioFileFormat(AudioFileFormat.Type type, AudioFormat format, int frameLength) Constructs an audio file format object. |
|
AudioFileFormat(AudioFileFormat.Type type, AudioFormat format, int frameLength, Map properties) Construct an audio file format object with a set of defined properties. |
|
protected |
AudioFileFormat(AudioFileFormat.Type type, int byteLength, AudioFormat format, int frameLength) Constructs an audio file format object. |
Method Summary | |
---|---|
int |
Obtains the size in bytes of the entire audio file (not just its audio data). |
AudioFormat |
Obtains the format of the audio data contained in the audio file. |
int |
Obtains the length of the audio data contained in the file, expressed in sample frames. |
Object |
getProperty(String key) Obtain the property value specified by the key. |
AudioFileFormat.Type |
getType() Obtains the audio file type, such as WAVE or AU .
|
Map |
Obtain an unmodifiable map of properties. |
String |
toString() Provides a string representation of the file format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AudioFileFormat(AudioFileFormat.Type type, AudioFormat format, int frameLength)
type
- the type of the audio fileformat
- the format of the audio data contained in the fileframeLength
- the audio data length in sample frames, or AudioSystem.NOT_SPECIFIED
public AudioFileFormat(AudioFileFormat.Type type, AudioFormat format, int frameLength, Map properties)
type
- the type of the audio fileformat
- the format of the audio data contained in the fileframeLength
- the audio data length in sample frames, or
AudioSystem.NOT_SPECIFIED
properties
- a Map<String,Object>
object
with propertiesprotected AudioFileFormat(AudioFileFormat.Type type, int byteLength, AudioFormat format, int frameLength)
type
- the type of the audio filebyteLength
- the length of the file in bytes, or AudioSystem.NOT_SPECIFIED
format
- the format of the audio data contained in the fileframeLength
- the audio data length in sample frames, or AudioSystem.NOT_SPECIFIED
Method Detail |
---|
public int getByteLength()
public AudioFormat getFormat()
public int getFrameLength()
public Object getProperty(String key)
If the specified property is not defined for a
particular file format, this method returns
null
.
key
- the key of the desired propertynull
if the property does not exist.public AudioFileFormat.Type getType()
WAVE
or AU
.
public Map properties()
Map<String,Object>
object containing
all properties. If no properties are recognized, an empty map is
returned.public String toString()
toString
in class Object
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |