Class AudioFileFormat
public class AudioFileFormat extends Object
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 |
- Since:
- 1.3
- See Also:
Nested Class Summary
Modifier and Type | Class | Description |
---|---|---|
static class |
AudioFileFormat.Type |
An instance of the Type class represents one of the standard types of audio file. |
Constructor Summary
Modifier | Constructor | Description |
---|---|---|
protected |
Constructs an audio file format object. |
|
Constructs an audio file format object. |
||
Construct an audio file format object with a set of defined properties. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
int |
getByteLength() |
Obtains the size in bytes of the entire audio file (not just its audio data). |
AudioFormat |
getFormat() |
Obtains the format of the audio data contained in the audio file. |
int |
getFrameLength() |
Obtains the length of the audio data contained in the file, expressed in sample frames. |
Object |
getProperty |
Obtain the property value specified by the key. |
AudioFileFormat.Type |
getType() |
Obtains the audio file type, such as WAVE or AU . |
Map<String, |
properties() |
Obtain an unmodifiable map of properties. |
String |
toString() |
Returns a string representation of the audio file format. |
Constructor Details
AudioFileFormat
protected AudioFileFormat(AudioFileFormat.Type type, int byteLength, AudioFormat format, int frameLength)
- Parameters:
-
type
- the type of the audio file -
byteLength
- the length of the file in bytes, orAudioSystem.NOT_SPECIFIED
-
format
- the format of the audio data contained in the file -
frameLength
- the audio data length in sample frames, orAudioSystem.NOT_SPECIFIED
- See Also:
AudioFileFormat
public AudioFileFormat(AudioFileFormat.Type type, AudioFormat format, int frameLength)
- 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, orAudioSystem.NOT_SPECIFIED
AudioFileFormat
public AudioFileFormat(AudioFileFormat.Type type, AudioFormat format, int frameLength, Map<String,Object> properties)
- 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, orAudioSystem.NOT_SPECIFIED
-
properties
- aMap<String, Object>
object with properties - Since:
- 1.5
Method Details
getType
public AudioFileFormat.Type getType()
WAVE
or AU
.- Returns:
- the audio file type
- See Also:
getByteLength
public int getByteLength()
- Returns:
- the audio file length in bytes
- See Also:
getFormat
public AudioFormat getFormat()
- Returns:
- the audio data format
getFrameLength
public int getFrameLength()
- Returns:
- the number of sample frames of audio data in the file
- See Also:
properties
public Map<String,Object> properties()
class description
.- Returns:
- a
Map<String, Object>
object containing all properties. If no properties are recognized, an empty map is returned. - Since:
- 1.5
- See Also:
getProperty
public Object getProperty(String key)
class description
. If the specified property is not defined for a particular file format, this method returns null
.
- Parameters:
-
key
- the key of the desired property - Returns:
- the value of the property with the specified key, or
null
if the property does not exist - Since:
- 1.5
- See Also:
toString
public String toString()
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/sound/sampled/AudioFileFormat.html