javax.sound.sampled
Class AudioFileFormat

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.sound.sampled.AudioFileFormat

public class AudioFileFormat
extends Object sample code for java.lang.Object definition code for java.lang.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 AudioSystem sample code for javax.sound.sampled.AudioSystem definition code for javax.sound.sampled.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 sample code for java.lang.Long definition code for java.lang.Long playback duration of the file in microseconds
"author" String sample code for java.lang.String definition code for java.lang.String name of the author of this file
"title" String sample code for java.lang.String definition code for java.lang.String title of this file
"copyright" String sample code for java.lang.String definition code for java.lang.String copyright message
"date" Date sample code for java.util.Date definition code for java.util.Date date of the recording or release
"comment" String sample code for java.lang.String definition code for java.lang.String an arbitrary text

Since:
1.3
See Also:
AudioInputStream sample code for javax.sound.sampled.AudioInputStream definition code for javax.sound.sampled.AudioInputStream

Nested Class Summary
static class AudioFileFormat.Type sample code for javax.sound.sampled.AudioFileFormat.Type definition code for javax.sound.sampled.AudioFileFormat.Type
          An instance of the Type class represents one of the standard types of audio file.
 
Constructor Summary
  AudioFileFormat sample code for javax.sound.sampled.AudioFileFormat.AudioFileFormat(javax.sound.sampled.AudioFileFormat.Type, javax.sound.sampled.AudioFormat, int) definition code for javax.sound.sampled.AudioFileFormat.AudioFileFormat(javax.sound.sampled.AudioFileFormat.Type, javax.sound.sampled.AudioFormat, int) (AudioFileFormat.Type sample code for javax.sound.sampled.AudioFileFormat.Type definition code for javax.sound.sampled.AudioFileFormat.Type  type, AudioFormat sample code for javax.sound.sampled.AudioFormat definition code for javax.sound.sampled.AudioFormat  format, int frameLength)
          Constructs an audio file format object.
  AudioFileFormat sample code for javax.sound.sampled.AudioFileFormat.AudioFileFormat(javax.sound.sampled.AudioFileFormat.Type, javax.sound.sampled.AudioFormat, int, java.util.Map) definition code for javax.sound.sampled.AudioFileFormat.AudioFileFormat(javax.sound.sampled.AudioFileFormat.Type, javax.sound.sampled.AudioFormat, int, java.util.Map) (AudioFileFormat.Type sample code for javax.sound.sampled.AudioFileFormat.Type definition code for javax.sound.sampled.AudioFileFormat.Type  type, AudioFormat sample code for javax.sound.sampled.AudioFormat definition code for javax.sound.sampled.AudioFormat  format, int frameLength, Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,Object sample code for java.lang.Object definition code for java.lang.Object > properties)
          Construct an audio file format object with a set of defined properties.
protected AudioFileFormat sample code for javax.sound.sampled.AudioFileFormat.AudioFileFormat(javax.sound.sampled.AudioFileFormat.Type, int, javax.sound.sampled.AudioFormat, int) definition code for javax.sound.sampled.AudioFileFormat.AudioFileFormat(javax.sound.sampled.AudioFileFormat.Type, int, javax.sound.sampled.AudioFormat, int) (AudioFileFormat.Type sample code for javax.sound.sampled.AudioFileFormat.Type definition code for javax.sound.sampled.AudioFileFormat.Type  type, int byteLength, AudioFormat sample code for javax.sound.sampled.AudioFormat definition code for javax.sound.sampled.AudioFormat  format, int frameLength)
          Constructs an audio file format object.
 
Method Summary
 int getByteLength sample code for javax.sound.sampled.AudioFileFormat.getByteLength() definition code for javax.sound.sampled.AudioFileFormat.getByteLength() ()
          Obtains the size in bytes of the entire audio file (not just its audio data).
 AudioFormat sample code for javax.sound.sampled.AudioFormat definition code for javax.sound.sampled.AudioFormat getFormat sample code for javax.sound.sampled.AudioFileFormat.getFormat() definition code for javax.sound.sampled.AudioFileFormat.getFormat() ()
          Obtains the format of the audio data contained in the audio file.
 int getFrameLength sample code for javax.sound.sampled.AudioFileFormat.getFrameLength() definition code for javax.sound.sampled.AudioFileFormat.getFrameLength() ()
          Obtains the length of the audio data contained in the file, expressed in sample frames.
 Object sample code for java.lang.Object definition code for java.lang.Object getProperty sample code for javax.sound.sampled.AudioFileFormat.getProperty(java.lang.String) definition code for javax.sound.sampled.AudioFileFormat.getProperty(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  key)
          Obtain the property value specified by the key.
 AudioFileFormat.Type sample code for javax.sound.sampled.AudioFileFormat.Type definition code for javax.sound.sampled.AudioFileFormat.Type getType sample code for javax.sound.sampled.AudioFileFormat.getType() definition code for javax.sound.sampled.AudioFileFormat.getType() ()
          Obtains the audio file type, such as WAVE or AU.
 Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,Object sample code for java.lang.Object definition code for java.lang.Object > properties sample code for javax.sound.sampled.AudioFileFormat.properties() definition code for javax.sound.sampled.AudioFileFormat.properties() ()
          Obtain an unmodifiable map of properties.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for javax.sound.sampled.AudioFileFormat.toString() definition code for javax.sound.sampled.AudioFileFormat.toString() ()
          Provides a string representation of the file format.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

AudioFileFormat sample code for javax.sound.sampled.AudioFileFormat(javax.sound.sampled.AudioFileFormat.Type, int, javax.sound.sampled.AudioFormat, int) definition code for javax.sound.sampled.AudioFileFormat(javax.sound.sampled.AudioFileFormat.Type, int, javax.sound.sampled.AudioFormat, int)

protected AudioFileFormat(AudioFileFormat.Type sample code for javax.sound.sampled.AudioFileFormat.Type definition code for javax.sound.sampled.AudioFileFormat.Type  type,
                          int byteLength,
                          AudioFormat sample code for javax.sound.sampled.AudioFormat definition code for javax.sound.sampled.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.

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
See Also:
getType() sample code for javax.sound.sampled.AudioFileFormat.getType() definition code for javax.sound.sampled.AudioFileFormat.getType()

AudioFileFormat sample code for javax.sound.sampled.AudioFileFormat(javax.sound.sampled.AudioFileFormat.Type, javax.sound.sampled.AudioFormat, int) definition code for javax.sound.sampled.AudioFileFormat(javax.sound.sampled.AudioFileFormat.Type, javax.sound.sampled.AudioFormat, int)

public AudioFileFormat(AudioFileFormat.Type sample code for javax.sound.sampled.AudioFileFormat.Type definition code for javax.sound.sampled.AudioFileFormat.Type  type,
                       AudioFormat sample code for javax.sound.sampled.AudioFormat definition code for javax.sound.sampled.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.

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

AudioFileFormat sample code for javax.sound.sampled.AudioFileFormat(javax.sound.sampled.AudioFileFormat.Type, javax.sound.sampled.AudioFormat, int, java.util.Map<java.lang.String, java.lang.Object>) definition code for javax.sound.sampled.AudioFileFormat(javax.sound.sampled.AudioFileFormat.Type, javax.sound.sampled.AudioFormat, int, java.util.Map<java.lang.String, java.lang.Object>)

public AudioFileFormat(AudioFileFormat.Type sample code for javax.sound.sampled.AudioFileFormat.Type definition code for javax.sound.sampled.AudioFileFormat.Type  type,
                       AudioFormat sample code for javax.sound.sampled.AudioFormat definition code for javax.sound.sampled.AudioFormat  format,
                       int frameLength,
                       Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,Object sample code for java.lang.Object definition code for java.lang.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
Method Detail

getType sample code for javax.sound.sampled.AudioFileFormat.getType() definition code for javax.sound.sampled.AudioFileFormat.getType()

public AudioFileFormat.Type sample code for javax.sound.sampled.AudioFileFormat.Type definition code for javax.sound.sampled.AudioFileFormat.Type  getType()
Obtains the audio file type, such as WAVE or AU.

Returns:
the audio file type
See Also:
AudioFileFormat.Type.WAVE sample code for javax.sound.sampled.AudioFileFormat.Type.WAVE definition code for javax.sound.sampled.AudioFileFormat.Type.WAVE , AudioFileFormat.Type.AU sample code for javax.sound.sampled.AudioFileFormat.Type.AU definition code for javax.sound.sampled.AudioFileFormat.Type.AU , AudioFileFormat.Type.AIFF sample code for javax.sound.sampled.AudioFileFormat.Type.AIFF definition code for javax.sound.sampled.AudioFileFormat.Type.AIFF , AudioFileFormat.Type.AIFC sample code for javax.sound.sampled.AudioFileFormat.Type.AIFC definition code for javax.sound.sampled.AudioFileFormat.Type.AIFC , AudioFileFormat.Type.SND sample code for javax.sound.sampled.AudioFileFormat.Type.SND definition code for javax.sound.sampled.AudioFileFormat.Type.SND

getByteLength sample code for javax.sound.sampled.AudioFileFormat.getByteLength() definition code for javax.sound.sampled.AudioFileFormat.getByteLength()

public int getByteLength()
Obtains the size in bytes of the entire audio file (not just its audio data).

Returns:
the audio file length in bytes
See Also:
AudioSystem.NOT_SPECIFIED sample code for javax.sound.sampled.AudioSystem.NOT_SPECIFIED definition code for javax.sound.sampled.AudioSystem.NOT_SPECIFIED

getFormat sample code for javax.sound.sampled.AudioFileFormat.getFormat() definition code for javax.sound.sampled.AudioFileFormat.getFormat()

public AudioFormat sample code for javax.sound.sampled.AudioFormat definition code for javax.sound.sampled.AudioFormat  getFormat()
Obtains the format of the audio data contained in the audio file.

Returns:
the audio data format

getFrameLength sample code for javax.sound.sampled.AudioFileFormat.getFrameLength() definition code for javax.sound.sampled.AudioFileFormat.getFrameLength()

public int getFrameLength()
Obtains the length of the audio data contained in the file, expressed in sample frames.

Returns:
the number of sample frames of audio data in the file
See Also:
AudioSystem.NOT_SPECIFIED sample code for javax.sound.sampled.AudioSystem.NOT_SPECIFIED definition code for javax.sound.sampled.AudioSystem.NOT_SPECIFIED

properties sample code for javax.sound.sampled.AudioFileFormat.properties() definition code for javax.sound.sampled.AudioFileFormat.properties()

public Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,Object sample code for java.lang.Object definition code for java.lang.Object > properties()
Obtain an unmodifiable map of properties. The concept of properties is further explained in the class description sample code for javax.sound.sampled.AudioFileFormat definition code for javax.sound.sampled.AudioFileFormat .

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(String) sample code for javax.sound.sampled.AudioFileFormat.getProperty(java.lang.String) definition code for javax.sound.sampled.AudioFileFormat.getProperty(java.lang.String)

getProperty sample code for javax.sound.sampled.AudioFileFormat.getProperty(java.lang.String) definition code for javax.sound.sampled.AudioFileFormat.getProperty(java.lang.String)

public Object sample code for java.lang.Object definition code for java.lang.Object  getProperty(String sample code for java.lang.String definition code for java.lang.String  key)
Obtain the property value specified by the key. The concept of properties is further explained in the class description sample code for javax.sound.sampled.AudioFileFormat definition code for javax.sound.sampled.AudioFileFormat .

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:
properties sample code for javax.sound.sampled.AudioFileFormat.properties definition code for javax.sound.sampled.AudioFileFormat.properties

toString sample code for javax.sound.sampled.AudioFileFormat.toString() definition code for javax.sound.sampled.AudioFileFormat.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Provides a string representation of the file format.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
the file format as a string