AudioFileFormatpublic 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 |
|
Fields Summary |
---|
private Type | typeFile type. | private int | byteLengthFile length in bytes | private AudioFormat | formatFormat of the audio data contained in the file. | private int | frameLengthAudio data length in sample frames | private HashMap | propertiesThe set of properties |
Constructors Summary |
---|
protected AudioFileFormat(Type type, int byteLength, AudioFormat format, int frameLength)Constructs an audio file format object.
This protected constructor is intended for use by providers of file-reading
services when returning information about an audio file or about supported audio file
formats.
this.type = type;
this.byteLength = byteLength;
this.format = format;
this.frameLength = frameLength;
this.properties = null;
| public AudioFileFormat(Type type, AudioFormat format, int frameLength)Constructs an audio file format object.
This public constructor may be used by applications to describe the
properties of a requested audio file.
this(type,AudioSystem.NOT_SPECIFIED,format,frameLength);
| public AudioFileFormat(Type type, AudioFormat format, int frameLength, Map properties)Construct an audio file format object with a set of
defined properties.
This public constructor may be used by applications to describe the
properties of a requested audio file. The properties map
will be copied to prevent any changes to it.
this(type,AudioSystem.NOT_SPECIFIED,format,frameLength);
this.properties = new HashMap<String, Object>(properties);
|
Methods Summary |
---|
public int | getByteLength()Obtains the size in bytes of the entire audio file (not just its audio data).
return byteLength;
| public javax.sound.sampled.AudioFormat | getFormat()Obtains the format of the audio data contained in the audio file.
return format;
| public int | getFrameLength()Obtains the length of the audio data contained in the file, expressed in sample frames.
return frameLength;
| public java.lang.Object | getProperty(java.lang.String key)Obtain the property value specified by the key.
The concept of properties is further explained in
the {@link AudioFileFormat class description}.
If the specified property is not defined for a
particular file format, this method returns
null .
if (properties == null) {
return null;
}
return properties.get(key);
| public javax.sound.sampled.AudioFileFormat$Type | getType()Obtains the audio file type, such as WAVE or AU .
return type;
| public java.util.Map | properties()Obtain an unmodifiable map of properties.
The concept of properties is further explained in
the {@link AudioFileFormat class description}.
Map<String,Object> ret;
if (properties == null) {
ret = new HashMap<String,Object>(0);
} else {
ret = (Map<String,Object>) (properties.clone());
}
return (Map<String,Object>) Collections.unmodifiableMap(ret);
| public java.lang.String | toString()Provides a string representation of the file format.
StringBuffer buf = new StringBuffer();
//$$fb2002-11-01: fix for 4672864: AudioFileFormat.toString() throws unexpected NullPointerException
if (type != null) {
buf.append(type.toString() + " (." + type.getExtension() + ") file");
} else {
buf.append("unknown file format");
}
if (byteLength != AudioSystem.NOT_SPECIFIED) {
buf.append(", byte length: " + byteLength);
}
buf.append(", data format: " + format);
if (frameLength != AudioSystem.NOT_SPECIFIED) {
buf.append(", frame length: " + frameLength);
}
return new String(buf);
|
|