- java.lang.Object
-
- javax.sound.sampled.AudioFileFormat
-
public class AudioFileFormat extends Object
An instance of theAudioFileFormat
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
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.AudioSystem
An
AudioFileFormat
object can include a set of properties. A property is a pair of key and value: the key is of typeString
, 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:
AudioInputStream
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
AudioFileFormat.Type
An instance of theType
class represents one of the standard types of audio file.
-
Constructor Summary
Constructors Modifier Constructor and Description AudioFileFormat(AudioFileFormat.Type type, AudioFormat format, int frameLength)
Constructs an audio file format object.AudioFileFormat(AudioFileFormat.Type type, AudioFormat format, int frameLength, Map<String,Object> properties)
Construct an audio file format object with a set of defined properties.protected
AudioFileFormat(AudioFileFormat.Type type, int byteLength, AudioFormat format, int frameLength)
Constructs an audio file format object.
-
Method Summary
Methods Modifier and Type Method and 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(String key)
Obtain the property value specified by the key.AudioFileFormat.Type
getType()
Obtains the audio file type, such asWAVE
orAU
.Map<String,Object>
properties()
Obtain an unmodifiable map of properties.String
toString()
Provides a string representation of the file format.
-
-
-
Constructor Detail
-
AudioFileFormat
protected AudioFileFormat(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.- Parameters:
type
- the type of the audio filebyteLength
- the length of the file in bytes, orAudioSystem.NOT_SPECIFIED
format
- the format of the audio data contained in the fileframeLength
- the audio data length in sample frames, orAudioSystem.NOT_SPECIFIED
- See Also:
getType()
-
AudioFileFormat
public AudioFileFormat(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.- Parameters:
type
- the type of the audio fileformat
- the format of the audio data contained in the fileframeLength
- the audio data length in sample frames, orAudioSystem.NOT_SPECIFIED
-
AudioFileFormat
public AudioFileFormat(AudioFileFormat.Type type, AudioFormat format, int frameLength, Map<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 fileformat
- the format of the audio data contained in the fileframeLength
- the audio data length in sample frames, orAudioSystem.NOT_SPECIFIED
properties
- aMap<String,Object>
object with properties- Since:
- 1.5
-
-
Method Detail
-
getType
public AudioFileFormat.Type getType()
Obtains the audio file type, such asWAVE
orAU
.- Returns:
- the audio file type
- See Also:
AudioFileFormat.Type.WAVE
,AudioFileFormat.Type.AU
,AudioFileFormat.Type.AIFF
,AudioFileFormat.Type.AIFC
,AudioFileFormat.Type.SND
-
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
-
getFormat
public AudioFormat getFormat()
Obtains the format of the audio data contained in the audio file.- Returns:
- the audio data format
-
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
-
properties
public Map<String,Object> properties()
Obtain an unmodifiable map of properties. The concept of properties is further explained in theclass 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(String)
-
getProperty
public Object getProperty(String key)
Obtain the property value specified by the key. The concept of properties is further explained in theclass 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:
properties()
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
18/12/2024 17:10:36 Cette version de la page est en cache (à la date du 18/12/2024 17:10:36) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 31/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/sound/sampled/audiofileformat.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.