Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.sound.sampled.AudioSystem
public class AudioSystem
extends Object
Field Summary | |
static int |
|
Method Summary | |
static AudioFileFormat |
|
static AudioFileFormat |
|
static AudioFileFormat |
|
static AudioFileFormat.Type[] |
|
static AudioFileFormat.Type[] |
|
static AudioInputStream |
|
static AudioInputStream |
|
static AudioInputStream |
|
static AudioInputStream |
|
static AudioInputStream |
|
static Clip |
|
static Clip |
|
static Line | |
static Mixer |
|
static Mixer.Info[] |
|
static SourceDataLine |
|
static SourceDataLine |
|
static Line.Info[] |
|
static TargetDataLine |
|
static TargetDataLine |
|
static AudioFormat.Encoding[] |
|
static AudioFormat.Encoding[] |
|
static AudioFormat[] |
|
static Line.Info[] |
|
static boolean |
|
static boolean |
|
static boolean |
|
static boolean |
|
static boolean |
|
static int |
|
static int |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final int NOT_SPECIFIED
A constant which can be passed to a number of methods in this package, to indicate an unspecified value.
- Field Value:
- -1
public static AudioFileFormat getAudioFileFormat(File f) throws UnsupportedAudioFileException, IOException
Return the file format of a given File.
- Parameters:
f
- the file to check
- Returns:
- the format of the file
- Throws:
UnsupportedAudioFileException
- if the file's format is not recognizedIOException
- if there is an I/O error reading the file
public static AudioFileFormat getAudioFileFormat(InputStream is) throws UnsupportedAudioFileException, IOException
Return the file format of a given input stream.
- Parameters:
is
- the input stream to check
- Returns:
- the format of the stream
- Throws:
UnsupportedAudioFileException
- if the stream's format is not recognizedIOException
- if there is an I/O error reading the stream
public static AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException
Return the file format of a given URL.
- Parameters:
url
- the URL to check
- Returns:
- the format of the URL
- Throws:
UnsupportedAudioFileException
- if the URL's format is not recognizedIOException
- if there is an I/O error reading the URL
public static AudioFileFormat.Type[] getAudioFileTypes()
Return an array of all the supported AudioFileFormat types.
- Returns:
- an array of unique types
public static AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream ais)
Return an array of all the supported AudioFileFormat types which match the given audio input stream
- Parameters:
ais
- the audio input stream
- Returns:
- an array of unique types
public static AudioInputStream getAudioInputStream(File f) throws UnsupportedAudioFileException, IOException
Return an audio input stream for the file.
- Parameters:
f
- the file to read
- Returns:
- an audio input stream for the file
- Throws:
UnsupportedAudioFileException
- if the file's audio format is not recognizedIOException
- if there is an error while reading the file
public static AudioInputStream getAudioInputStream(InputStream is) throws UnsupportedAudioFileException, IOException
Return an audio input stream given an input stream.
- Parameters:
is
- the input stream
- Returns:
- an audio input stream
- Throws:
UnsupportedAudioFileException
- if the input stream's audio format is not supported by any of the installed providersIOException
- if there is an error while reading the input stream
public static AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException
Return an audio input stream for the given URL.
- Parameters:
url
- the URL
- Returns:
- an audio input stream
- Throws:
UnsupportedAudioFileException
- if the URL's audio format is not supported by any of the installed providersIOException
- if there is an error while reading the URL
public static AudioInputStream getAudioInputStream(AudioFormat targ, AudioInputStream ais)
Given an audio input stream, this will try to create a new audio input stream whose format matches the given target format. If no provider offers this conversion, an exception is thrown.
- Parameters:
targ
- the target formatais
- the original audio stream
- Returns:
- a new audio stream
- Throws:
IllegalArgumentException
- if the conversion cannot be made
public static AudioInputStream getAudioInputStream(AudioFormat.Encoding targ, AudioInputStream ais)
Given an audio input stream, this will try to create a new audio input stream whose encoding matches the given target encoding. If no provider offers this conversion, an exception is thrown.
- Parameters:
targ
- the target encodingais
- the original audio stream
- Returns:
- a new audio stream
- Throws:
IllegalArgumentException
- if the conversion cannot be made
public static Clip getClip() throws LineUnavailableException
Return a new clip which can be used for playing back an audio stream.
- Throws:
LineUnavailableException
- if a clip is not available for some reasonSecurityException
- if a clip cannot be made for security reasons
- Since:
- 1.5
public static Clip getClip(Mixer.Info info) throws LineUnavailableException
Return a new clip which can be used for playing back an audio stream. The clip is obtained from the indicated mixer.
- Parameters:
info
- the mixer to use
- Throws:
LineUnavailableException
- if a clip is not available for some reasonSecurityException
- if a clip cannot be made for security reasons
- Since:
- 1.5
public static Line getLine(Line.Info info) throws LineUnavailableException
Return a line matching the provided description. All the providers on the system are searched for a matching line.
- Parameters:
info
- description of the line
- Returns:
- the matching line
- Throws:
LineUnavailableException
- if no provider supplies a matching line
public static Mixer getMixer(Mixer.Info info)
Return a mixer matching the provided description. All the providers on the system are searched for a matching mixer.
- Parameters:
info
- description of the mixer
- Returns:
- the matching mixer
- Throws:
IllegalArgumentException
- if no provider supplies a matching mixer
public static Mixer.Info[] getMixerInfo()
Return an array of descriptions of all the mixers provided on the system.
public static SourceDataLine getSourceDataLine(AudioFormat fmt) throws LineUnavailableException
Return a source data line matching the given audio format.
- Parameters:
fmt
- the audio format
- Throws:
LineUnavailableException
- if no source data line matching this format is available
- Since:
- 1.5
public static SourceDataLine getSourceDataLine(AudioFormat fmt, Mixer.Info mixer) throws LineUnavailableException
Return a target data line matching the given audio format.
- Parameters:
fmt
- the audio format
- Throws:
LineUnavailableException
- if no target data line matching this format is available
- Since:
- 1.5
public static Line.Info[] getSourceLineInfo(Line.Info info)
Return an array of descriptions of all the source lines matching the given line description.
- Parameters:
info
- description of the lines to match
public static TargetDataLine getTargetDataLine(AudioFormat fmt) throws LineUnavailableException
Find and return a target data line matching the given audio format.
- Parameters:
fmt
- the format to match
- Throws:
LineUnavailableException
- if no matching line was found
- Since:
- 1.5
public static TargetDataLine getTargetDataLine(AudioFormat fmt, Mixer.Info mixer) throws LineUnavailableException
Return a target data line matching the given audio format and mixer.
- Parameters:
fmt
- the audio formatmixer
- the mixer description
- Returns:
- a target data line
- Throws:
LineUnavailableException
- if no matching target data line was found
- Since:
- 1.5
public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat source)
Given a source format, return an array of all the target encodings to which data in this format can be converted.
- Parameters:
source
- the source format
public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding source)
Given a source encoding, return an array of all target encodings to which data in this form can be converted.
- Parameters:
source
- the source encoding
public static AudioFormat[] getTargetFormats(AudioFormat.Encoding encoding, AudioFormat sourceFmt)
Given a target encoding and a source audio format, return an array of all matching audio formats to which data in this source format can be converted.
- Parameters:
encoding
- the target encodingsourceFmt
- the source format
public static Line.Info[] getTargetLineInfo(Line.Info info)
Given a line description, return an array of descriptions of all the matching target lines.
- Parameters:
info
- the line description
public static boolean isConversionSupported(AudioFormat targ, AudioFormat source)
Return true if the currently installed providers are able to convert the given source format to the given target format.
- Parameters:
targ
- the target formatsource
- the source format
public static boolean isConversionSupported(AudioFormat.Encoding targ, AudioFormat source)
Return true if the currently installed providers are able to convert data from the given source format to the given target encoding.
- Parameters:
targ
- the target encodingsource
- the source format
public static boolean isFileTypeSupported(AudioFileFormat.Type type)
Return true if the given audio file format is supported by one of the providers installed on the system.
- Parameters:
type
- the audio file format type
public static boolean isFileTypeSupported(AudioFileFormat.Type type, AudioInputStream ais)
Return true if the given audio file format is supported for the given audio input stream by one of the providers installed on the system.
- Parameters:
type
- the audio file format typeais
- the audio input stream
public static boolean isLineSupported(Line.Info info)
Return true if some provider on the system supplies a line matching the argument.
- Parameters:
info
- the line to match
public static int write(AudioInputStream ais, AudioFileFormat.Type type, File out) throws IOException
Write an audio input stream to the given file, using the specified audio file format. All the providers installed on the system will be searched to find one that supports this operation.
- Parameters:
ais
- the audio input stream to writetype
- the desired audio file format typeout
- the file to write to
- Returns:
- the number of bytes written
- Throws:
IOException
- if an I/O error occurs while writingIllegalArgumentException
- if the file type is not supported
public static int write(AudioInputStream ais, AudioFileFormat.Type type, OutputStream os) throws IOException
Write an audio input stream to the given output stream, using the specified audio file format. All the providers installed on the system will be searched to find one that supports this operation.
- Parameters:
ais
- the audio input stream to writetype
- the desired audio file format typeos
- the output stream to write to
- Returns:
- the number of bytes written
- Throws:
IOException
- if an I/O error occurs while writingIllegalArgumentException
- if the file type is not supported