|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.sound.sampled.AudioSystem
The AudioSystem
class acts as the entry point to the
sampled-audio system resources. This class lets you query and
access the mixers that are installed on the system.
AudioSystem
includes a number of
methods for converting audio data between different formats, and for
translating between audio files and streams. It also provides a method
for obtaining a
directly from the
Line
AudioSystem
without dealing explicitly
with mixers.
AudioFormat
,
AudioInputStream
,
Mixer
,
Line
,
Line.Info
Field Summary | |
static int |
NOT_SPECIFIED
An integer that stands for an unknown numeric value. |
Method Summary | |
static AudioFileFormat |
getAudioFileFormat(File file)
Obtains the audio file format of the specified File . |
static AudioFileFormat |
getAudioFileFormat(InputStream stream)
Obtains the audio file format of the provided input stream. |
static AudioFileFormat |
getAudioFileFormat(URL url)
Obtains the audio file format of the specified URL. |
static AudioFileFormat.Type[] |
getAudioFileTypes()
Obtains the file types for which file writing support is provided by the system. |
static AudioFileFormat.Type[] |
getAudioFileTypes(AudioInputStream stream)
Obtains the file types that the system can write from the audio input stream specified. |
static AudioInputStream |
getAudioInputStream(AudioFormat.Encoding targetEncoding,
AudioInputStream sourceStream)
Obtains an audio input stream of the indicated encoding, by converting the provided audio input stream. |
static AudioInputStream |
getAudioInputStream(AudioFormat targetFormat,
AudioInputStream sourceStream)
Obtains an audio input stream of the indicated format, by converting the provided audio input stream. |
static AudioInputStream |
getAudioInputStream(File file)
Obtains an audio input stream from the provided File . |
static AudioInputStream |
getAudioInputStream(InputStream stream)
Obtains an audio input stream from the provided input stream. |
static AudioInputStream |
getAudioInputStream(URL url)
Obtains an audio input stream from the URL provided. |
static Line |
getLine(Line.Info info)
Obtains a line that matches the description in the specified Line.Info object. |
static Mixer |
getMixer(Mixer.Info info)
Obtains the requested audio mixer. |
static Mixer.Info[] |
getMixerInfo()
Obtains an array of mixer info objects that represents the set of audio mixers that are currently installed on the system. |
static Line.Info[] |
getSourceLineInfo(Line.Info info)
Obtains information about source lines of a particular type that are supported by any installed mixer. |
static AudioFormat.Encoding[] |
getTargetEncodings(AudioFormat.Encoding sourceEncoding)
Obtains the encodings that the system can obtain from an audio input stream with the specified encoding using the set of installed format converters. |
static AudioFormat.Encoding[] |
getTargetEncodings(AudioFormat sourceFormat)
Obtains the encodings that the system can obtain from an audio input stream with the specified format using the set of installed format converters. |
static AudioFormat[] |
getTargetFormats(AudioFormat.Encoding targetEncoding,
AudioFormat sourceFormat)
Obtains the formats that have a particular encoding and that the system can obtain from a stream of the specified format using the set of installed format converters. |
static Line.Info[] |
getTargetLineInfo(Line.Info info)
Obtains information about target lines of a particular type that are supported by any installed mixer. |
static boolean |
isConversionSupported(AudioFormat.Encoding targetEncoding,
AudioFormat sourceFormat)
Indicates whether an audio input stream of the specified encoding can be obtained from an audio input stream that has the specified format. |
static boolean |
isConversionSupported(AudioFormat targetFormat,
AudioFormat sourceFormat)
Indicates whether an audio input stream of a specified format can be obtained from an audio input stream of another specified format. |
static boolean |
isFileTypeSupported(AudioFileFormat.Type fileType)
Indicates whether file writing support for the specified file type is provided by the system. |
static boolean |
isFileTypeSupported(AudioFileFormat.Type fileType,
AudioInputStream stream)
Indicates whether an audio file of the specified file type can be written from the indicated audio input stream. |
static boolean |
isLineSupported(Line.Info info)
Indicates whether the the system supports any lines that match the specified Line.Info object. |
static int |
write(AudioInputStream stream,
AudioFileFormat.Type fileType,
File out)
Writes a stream of bytes representing an audio file of the specified file type to the external file provided. |
static int |
write(AudioInputStream stream,
AudioFileFormat.Type fileType,
OutputStream out)
Writes a stream of bytes representing an audio file of the specified file type to the output stream provided. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int NOT_SPECIFIED
NOT_SPECIFIED
for such parameters. Other
methods may also accept or return this value, as documented.Method Detail |
public static Mixer.Info[] getMixerInfo()
getMixer(javax.sound.sampled.Mixer.Info)
public static Mixer getMixer(Mixer.Info info)
info
- a Mixer.Info
object representing the desired
mixer, or null
for the system default mixerSecurityException
- if the requested mixer
is unavailable because of security restrictionsIllegalArgumentException
- if the info object does not represent
a mixer installed on the systemgetMixerInfo()
public static Line.Info[] getSourceLineInfo(Line.Info info)
info
- a Line.Info
object that specifies the kind of
lines about which information is requestedLine.Info
objects describing source lines matching
the type requested. If no matching source lines are supported, an array of length 0
is returned.Mixer.getSourceLineInfo(Line.Info)
public static Line.Info[] getTargetLineInfo(Line.Info info)
info
- a Line.Info
object that specifies the kind of
lines about which information is requestedLine.Info
objects describing target lines matching
the type requested. If no matching target lines are supported, an array of length 0
is returned.Mixer.getTargetLineInfo(Line.Info)
public static boolean isLineSupported(Line.Info info)
Line.Info
object. A line is supported if
any installed mixer supports it.info
- a Line.Info
object describing the line for which support is queriedtrue
if at least one matching line is
supported, otherwise false
Mixer.isLineSupported(Line.Info)
public static Line getLine(Line.Info info) throws LineUnavailableException
Line.Info
object.info
- a Line.Info
object describing the desired kind of lineLineUnavailableException
- if a matching line
is not available due to resource restrictionsSecurityException
- if a matching line
is not available due to security restrictionsIllegalArgumentException
- if the system does not
support at least one line matching the specified Line.Info
object
through any installed mixerpublic static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding sourceEncoding)
sourceEncoding
- the encoding for which conversion support
is queriedpublic static AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat)
sourceFormat
- the audio format for which conversion
is queriedpublic static boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat)
targetEncoding
- the desired encoding after conversionsourceFormat
- the audio format before conversiontrue
if the conversion is supported,
otherwise false
public static AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream)
targetEncoding
- the desired encoding after conversionsourceStream
- the stream to be convertedIllegalArgumentException
- if the conversion is not supportedgetTargetEncodings(AudioFormat.Encoding)
,
getTargetEncodings(AudioFormat)
,
isConversionSupported(AudioFormat.Encoding, AudioFormat)
,
getAudioInputStream(AudioFormat, AudioInputStream)
public static AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat)
targetEncoding
- the desired encoding after conversionsourceFormat
- the audio format before conversionpublic static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat)
targetFormat
- the desired audio format after conversionsourceFormat
- the audio format before conversiontrue
if the conversion is supported,
otherwise false
public static AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)
targetFormat
- the desired audio format after conversionsourceStream
- the stream to be convertedIllegalArgumentException
- if the conversion is not supported
#see #getTargetEncodings(AudioFormat)getTargetFormats(AudioFormat.Encoding, AudioFormat)
,
isConversionSupported(AudioFormat, AudioFormat)
,
getAudioInputStream(AudioFormat.Encoding, AudioInputStream)
public static AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException
IOException
.stream
- the input stream from which file format information should be
extractedAudioFileFormat
object describing the stream's audio file formatUnsupportedAudioFileException
- if the stream does not point to valid audio
file data recognized by the systemIOException
- if an input/output exception occursInputStream.markSupported()
,
InputStream.mark(int)
public static AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException
url
- the URL from which file format information should be
extractedAudioFileFormat
object describing the audio file formatUnsupportedAudioFileException
- if the URL does not point to valid audio
file data recognized by the systemIOException
- if an input/output exception occurspublic static AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException
File
. The File
must
point to valid audio file data.file
- the File
from which file format information should be
extractedAudioFileFormat
object describing the audio file formatUnsupportedAudioFileException
- if the File
does not point to valid audio
file data recognized by the systemIOException
- if an I/O exception occurspublic static AudioInputStream getAudioInputStream(InputStream stream) throws UnsupportedAudioFileException, IOException
IOException
.stream
- the input stream from which the AudioInputStream
should be
constructedAudioInputStream
object based on the audio file data contained
in the input stream.UnsupportedAudioFileException
- if the stream does not point to valid audio
file data recognized by the systemIOException
- if an I/O exception occursInputStream.markSupported()
,
InputStream.mark(int)
public static AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException
url
- the URL for which the AudioInputStream
should be
constructedAudioInputStream
object based on the audio file data pointed
to by the URLUnsupportedAudioFileException
- if the URL does not point to valid audio
file data recognized by the systemIOException
- if an I/O exception occurspublic static AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException
File
. The File
must
point to valid audio file data.file
- the File
for which the AudioInputStream
should be
constructedAudioInputStream
object based on the audio file data pointed
to by the File
UnsupportedAudioFileException
- if the File
does not point to valid audio
file data recognized by the systemIOException
- if an I/O exception occurspublic static AudioFileFormat.Type[] getAudioFileTypes()
public static boolean isFileTypeSupported(AudioFileFormat.Type fileType)
fileType
- the file type for which write capabilities are queriedtrue
if the file type is supported,
otherwise false
public static AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream)
stream
- the audio input stream for which audio file type support
is queriedpublic static boolean isFileTypeSupported(AudioFileFormat.Type fileType, AudioInputStream stream)
fileType
- the file type for which write capabilities are queriedstream
- the stream for which file-writing support is queriedtrue
if the file type is supported for this audio input stream,
otherwise false
public static int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException
AudioSystem.NOT_SPECIFIED
.stream
- the audio input stream containing audio data to be
written to the filefileType
- the kind of audio file to writeout
- the stream to which the file data should be writtenIOException
- if an input/output exception occursIllegalArgumentException
- if the file type is not supported by
the systemisFileTypeSupported(javax.sound.sampled.AudioFileFormat.Type)
,
getAudioFileTypes()
public static int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException
stream
- the audio input stream containing audio data to be
written to the filefileType
- the kind of audio file to writeout
- the external file to which the file data should be writtenIOException
- if an I/O exception occursIllegalArgumentException
- if the file type is not supported by
the systemisFileTypeSupported(javax.sound.sampled.AudioFileFormat.Type)
,
getAudioFileTypes()
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.