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 |
AudioInputStream
Modifier and Type | Class and Description |
---|---|
public static class | AudioFileFormat.
An instance of the |
Modifier and Type | Field and Description |
---|---|
private final int | byteLength
File length in bytes. |
private final AudioFormat | format
Format of the audio data contained in the file. |
private final int | frameLength
Audio data length in sample frames. |
private HashMap | properties
The set of properties. |
private final AudioFileFormat. | type
File type. |
Access | Constructor and Description |
---|---|
protected | AudioFileFormat(AudioFileFormat.
the type of the audio file type,the length of the file in bytes, or
byteLength, AudioFormat AudioSystem.NOT_SPECIFIED the format of the audio data contained in the file format, int the audio data length in sample frames, or
frameLength)AudioSystem.NOT_SPECIFIED Constructs an audio file format object. |
public | AudioFileFormat(AudioFileFormat.
the type of the audio file type,the format of the audio data contained in the file format, int the audio data length in sample frames, or
frameLength)AudioSystem.NOT_SPECIFIED Constructs an audio file format object. |
public | AudioFileFormat(AudioFileFormat.
the type of the audio file type,the format of the audio data contained in the file format, int the audio data length in sample frames, or
frameLength, Map<String, Object> AudioSystem.NOT_SPECIFIED a properties)Map<String, Object> object with propertiesConstruct an audio file format object with a set of defined properties. |
Modifier and Type | Method and Description |
---|---|
public int | Returns: the audio file length in bytesObtains the size in bytes of the entire audio file (not just its audio data). |
public AudioFormat | Returns: the audio data formatObtains the format of the audio data contained in the audio file. |
public int | Returns: the number of sample frames of audio data in the fileObtains the length of the audio data contained in the file, expressed in sample frames. |
public Object | Returns: the value of the property with the specified key, ornull
if the property does not existthe key of the desired property key)Obtain the property value specified by the key. |
public AudioFileFormat. | |
public Map | Returns: aMap<String, Object> object containing all properties.
If no properties are recognized, an empty map is returned.Obtain an unmodifiable map of properties. |
public String | Returns: a string representation of the audio file formatOverrides java. Returns a string representation of the audio file format. |
byteLength | back to summary |
---|---|
private final int byteLength File length in bytes. |
format | back to summary |
---|---|
private final AudioFormat format Format of the audio data contained in the file. |
frameLength | back to summary |
---|---|
private final int frameLength Audio data length in sample frames. |
properties | back to summary |
---|---|
private HashMap<String, Object> properties The set of properties. |
type | back to summary |
---|---|
private final AudioFileFormat. File type. |
AudioFileFormat | back to summary |
---|---|
protected AudioFileFormat(AudioFileFormat. 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.
|
AudioFileFormat | back to summary |
---|---|
public AudioFileFormat(AudioFileFormat. Constructs an audio file format object. This public constructor may be used by applications to describe the properties of a requested audio file.
|
AudioFileFormat | back to summary |
---|---|
public AudioFileFormat(AudioFileFormat. 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.
|
getByteLength | back to summary |
---|---|
public int getByteLength() Obtains the size in bytes of the entire audio file (not just its audio data).
|
getFormat | back to summary |
---|---|
public AudioFormat getFormat() Obtains the format of the audio data contained in the audio file.
|
getFrameLength | back to summary |
---|---|
public int getFrameLength() Obtains the length of the audio data contained in the file, expressed in sample frames.
|
getProperty | back to summary |
---|---|
public Object getProperty(String key) Obtain the property value specified by the key. The concept of properties
is further explained in the
If the specified property is not defined for a particular file format,
this method returns
|
getType | back to summary |
---|---|
public AudioFileFormat. Obtains the audio file type, such as |
properties | back to summary |
---|---|
public Map Obtain an unmodifiable map of properties. The concept of properties is
further explained in the
|
toString | back to summary |
---|---|
public String toString() Overrides java. Returns a string representation of the audio file format. |
Type
class represents one of the standard
types of audio file. Static instances are provided for the common types.
Modifier and Type | Field and Description |
---|---|
public static final AudioFileFormat. | AIFC
Specifies an AIFF-C file. |
public static final AudioFileFormat. | AIFF
Specifies an AIFF file. |
public static final AudioFileFormat. | AU
Specifies an AU file. |
private final String | extension
File type extension. |
private final String | name
File type name. |
public static final AudioFileFormat. | SND
Specifies a SND file. |
public static final AudioFileFormat. | WAVE
Specifies a WAVE file. |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public final boolean | Returns: true if the specified object is equal to this file
type; false otherwisethe reference object with which to compare obj)Overrides java. Indicates whether the specified object is equal to this file type,
returning |
public String | Returns: file type extensionObtains the common file name extension for this file type. |
public final int | Returns: a hash code value for this file typeOverrides java. Returns a hash code value for this file type. |
public final String | Returns: a string representation of the file typeOverrides java. Returns type's name as the string representation of the file type. |
AIFC | back to summary |
---|---|
public static final AudioFileFormat. Specifies an AIFF-C file. |
AIFF | back to summary |
---|---|
public static final AudioFileFormat. Specifies an AIFF file. |
AU | back to summary |
---|---|
public static final AudioFileFormat. Specifies an AU file. |
extension | back to summary |
---|---|
private final String extension File type extension. |
name | back to summary |
---|---|
private final String name File type name. |
SND | back to summary |
---|---|
public static final AudioFileFormat. Specifies a SND file. |
WAVE | back to summary |
---|---|
public static final AudioFileFormat. Specifies a WAVE file. |
Type | back to summary |
---|---|
public Type(final String name, final String extension) Constructs a file type. |
equals | back to summary |
---|---|
public final boolean equals(final Object obj) Overrides java. Indicates whether the specified object is equal to this file type,
returning |
getExtension | back to summary |
---|---|
public String getExtension() Obtains the common file name extension for this file type.
|
hashCode | back to summary |
---|---|
public final int hashCode() Overrides java. Returns a hash code value for this file type.
|
toString | back to summary |
---|---|
public final String toString() Overrides java. Returns type's name as the string representation of the file type. |