javax.sound.sampled
public class: AudioFileFormat [javadoc |
source]
java.lang.Object
javax.sound.sampled.AudioFileFormat
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 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" |
Long |
playback duration of the file in microseconds |
"author" |
String |
name of the author of this file |
"title" |
String |
title of this file |
"copyright" |
String |
copyright message |
"date" |
Date |
date of the recording or release |
"comment" |
String |
an arbitrary text |
Also see:
- AudioInputStream
- author:
David
- Rivas
- author:
Kara
- Kytle
- author:
Florian
- Bomers
- since:
1.3
-
Nested Class Summary: |
---|
public static class | AudioFileFormat.Type | An instance of the Type class represents one of the
standard types of audio file. Static instances are provided for the
common types. |
Constructor: |
public AudioFileFormat(Type type,
AudioFormat format,
int frameLength) {
this(type,AudioSystem.NOT_SPECIFIED,format,frameLength);
}
Constructs an audio file format object.
This public constructor may be used by applications to describe the
properties of a requested audio file. Parameters:
type - the type of the audio file
format - the format of the audio data contained in the file
frameLength - the audio data length in sample frames, or AudioSystem.NOT_SPECIFIED
|
protected AudioFileFormat(Type type,
int byteLength,
AudioFormat format,
int frameLength) {
this.type = type;
this.byteLength = byteLength;
this.format = format;
this.frameLength = frameLength;
this.properties = null;
}
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. Parameters:
type - the type of the audio file
byteLength - the length of the file in bytes, or AudioSystem.NOT_SPECIFIED
format - the format of the audio data contained in the file
frameLength - the audio data length in sample frames, or AudioSystem.NOT_SPECIFIED
Also see:
- getType
|
public AudioFileFormat(Type type,
AudioFormat format,
int frameLength,
Map<String, Object> properties) {
this(type,AudioSystem.NOT_SPECIFIED,format,frameLength);
this.properties = new HashMap< String, Object >(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. Parameters:
type - the type of the audio file
format - the format of the audio data contained in the file
frameLength - the audio data length in sample frames, or
AudioSystem.NOT_SPECIFIED
properties - a Map<String,Object> object
with properties
- since:
1.5 -
|
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from javax.sound.sampled.AudioFileFormat Detail: |
public int getByteLength() {
return byteLength;
}
Obtains the size in bytes of the entire audio file (not just its audio data). |
public AudioFormat getFormat() {
return format;
}
Obtains the format of the audio data contained in the audio file. |
public int getFrameLength() {
return frameLength;
}
Obtains the length of the audio data contained in the file, expressed in sample frames. |
public Object getProperty(String key) {
if (properties == null) {
return null;
}
return properties.get(key);
}
Obtain the property value specified by the key.
The concept of properties is further explained in
the class description .
If the specified property is not defined for a
particular file format, this method returns
null . |
public Type getType() {
return type;
}
Obtains the audio file type, such as WAVE or AU . |
public Map<String, Object> properties() {
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);
}
Obtain an unmodifiable map of properties.
The concept of properties is further explained in
the class description . |
public String toString() {
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);
}
Provides a string representation of the file format. |