|
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.midi.MidiSystem
The MidiSystem
class provides access to the installed MIDI
system resources, including devices such as synthesizers, sequencers, and
MIDI input and output ports. A typical simple MIDI application might
begin by invoking one or more MidiSystem
methods to learn
what devices are installed and to obtain the ones needed in that
application.
The class also has methods for reading files, streams, and URLs that
contain standard MIDI file data or soundbanks. You can query the
MidiSystem
for the format of a specified MIDI file.
You cannot instantiate a MidiSystem
; all the methods are
static.
Method Summary | |
static MidiDevice |
getMidiDevice(MidiDevice.Info info)
Obtains the requested MIDI device. |
static MidiDevice.Info[] |
getMidiDeviceInfo()
Obtains an array of information objects representing the set of all MIDI devices available on the system. |
static MidiFileFormat |
getMidiFileFormat(File file)
Obtains the MIDI file format of the specified File . |
static MidiFileFormat |
getMidiFileFormat(InputStream stream)
Obtains the MIDI file format of the data in the specified input stream. |
static MidiFileFormat |
getMidiFileFormat(URL url)
Obtains the MIDI file format of the data in the specified URL. |
static int[] |
getMidiFileTypes()
Obtains the set of MIDI file types for which file writing support is provided by the system. |
static int[] |
getMidiFileTypes(Sequence sequence)
Obtains the set of MIDI file types that the system can write from the sequence specified. |
static Receiver |
getReceiver()
Obtains a MIDI receiver from an external MIDI port or other default source. |
static Sequence |
getSequence(File file)
Obtains a MIDI sequence from the specified File . |
static Sequence |
getSequence(InputStream stream)
Obtains a MIDI sequence from the specified input stream. |
static Sequence |
getSequence(URL url)
Obtains a MIDI sequence from the specified URL. |
static Sequencer |
getSequencer()
Obtains the default sequencer. |
static Soundbank |
getSoundbank(File file)
Constructs a Soundbank by reading it from the specified
File . |
static Soundbank |
getSoundbank(InputStream stream)
Constructs a MIDI sound bank by reading it from the specified stream. |
static Soundbank |
getSoundbank(URL url)
Constructs a Soundbank by reading it from the specified URL. |
static Synthesizer |
getSynthesizer()
Obtains the default synthesizer. |
static Transmitter |
getTransmitter()
Obtains a MIDI transmitter from an external MIDI port or other default source. |
static boolean |
isFileTypeSupported(int fileType)
Indicates whether file writing support for the specified MIDI file type is provided by the system. |
static boolean |
isFileTypeSupported(int fileType,
Sequence sequence)
Indicates whether a MIDI file of the file type specified can be written from the sequence indicated. |
static int |
write(Sequence in,
int type,
File out)
Writes a stream of bytes representing a file of the MIDI file type indicated to the external file provided. |
static int |
write(Sequence in,
int fileType,
OutputStream out)
Writes a stream of bytes representing a file of the MIDI file type indicated to the output stream provided. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static MidiDevice.Info[] getMidiDeviceInfo()
getMidiDevice
.MidiDevice.Info
objects, one
for each installed MIDI device. If no such devices are installed,
an array of length 0 is returned.public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException
info
- a device information object representing the desired device.MidiUnavailableException
- if the requested device is not available
due to resource restrictionsIllegalArgumentException
- if the info object does not represent
a MIDI device installed on the systemgetMidiDeviceInfo()
public static Receiver getReceiver() throws MidiUnavailableException
MidiUnavailableException
- if the default receiver is not
available due to resource restrictionspublic static Transmitter getTransmitter() throws MidiUnavailableException
MidiUnavailableException
- if the default transmitter is not
available due to resource restrictionspublic static Synthesizer getSynthesizer() throws MidiUnavailableException
MidiUnavailableException
- if the synthesizer is not
available due to resource restrictionspublic static Sequencer getSequencer() throws MidiUnavailableException
MidiUnavailableException
- if the sequencer is not
available due to resource restrictionspublic static Soundbank getSoundbank(InputStream stream) throws InvalidMidiDataException, IOException
stream
- the source of the sound bank data.InvalidMidiDataException
- if the stream does not point to
valid MIDI soundbank data recognized by the systemIOException
- if an I/O error occurred when loading the soundbankInputStream.markSupported()
,
InputStream.mark(int)
public static Soundbank getSoundbank(URL url) throws InvalidMidiDataException, IOException
Soundbank
by reading it from the specified URL.
The URL must point to a valid MIDI soundbank file.url
- the source of the sound bank dataInvalidMidiDataException
- if the URL does not point to valid MIDI
soundbank data recognized by the systemIOException
- if an I/O error occurred when loading the soundbankpublic static Soundbank getSoundbank(File file) throws InvalidMidiDataException, IOException
Soundbank
by reading it from the specified
File
.
The File
must point to a valid MIDI soundbank file.file
- the source of the sound bank dataInvalidMidiDataException
- if the File
does not
point to valid MIDI soundbank data recognized by the systemIOException
- if an I/O error occurred when loading the soundbankpublic static MidiFileFormat getMidiFileFormat(InputStream stream) throws InvalidMidiDataException, IOException
This method and/or the code it invokes may need to read some data from
the stream to determine whether its data format is supported. The
implementation may therefore
need to mark the stream, read enough data to determine whether it is in
a supported format, and reset the stream's read pointer to its original
position. If the input stream does not permit this set of operations,
this method may fail with an IOException
.
This operation can only succeed for files of a type which can be parsed by an installed file reader. It may fail with an InvalidMidiDataException even for valid files if no compatible file reader is installed. It will also fail with an InvalidMidiDataException if a compatible file reader is installed, but encounters errors while determining the file format.
stream
- the input stream from which file format information
should be extractedMidiFileFormat
object describing the MIDI file
formatInvalidMidiDataException
- if the stream does not point to valid
MIDI file data recognized by the systemIOException
- if an I/O exception occurs while accessing the
streamgetMidiFileFormat(URL)
,
getMidiFileFormat(File)
,
InputStream.markSupported()
,
InputStream.mark(int)
public static MidiFileFormat getMidiFileFormat(URL url) throws InvalidMidiDataException, IOException
This operation can only succeed for files of a type which can be parsed by an installed file reader. It may fail with an InvalidMidiDataException even for valid files if no compatible file reader is installed. It will also fail with an InvalidMidiDataException if a compatible file reader is installed, but encounters errors while determining the file format.
url
- the URL from which file format information should be
extractedMidiFileFormat
object describing the MIDI file
formatInvalidMidiDataException
- if the URL does not point to valid MIDI
file data recognized by the systemIOException
- if an I/O exception occurs while accessing the URLgetMidiFileFormat(InputStream)
,
getMidiFileFormat(File)
public static MidiFileFormat getMidiFileFormat(File file) throws InvalidMidiDataException, IOException
File
. The
File
must point to valid MIDI file data for a file type
recognized by the system.
This operation can only succeed for files of a type which can be parsed by an installed file reader. It may fail with an InvalidMidiDataException even for valid files if no compatible file reader is installed. It will also fail with an InvalidMidiDataException if a compatible file reader is installed, but encounters errors while determining the file format.
file
- the File
from which file format information
should be extractedMidiFileFormat
object describing the MIDI file
formatInvalidMidiDataException
- if the File
does not point
to valid MIDI file data recognized by the systemIOException
- if an I/O exception occurs while accessing the filegetMidiFileFormat(InputStream)
,
getMidiFileFormat(URL)
public static Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException
This method and/or the code it invokes may need to read some data
from the stream to determine whether
its data format is supported. The implementation may therefore
need to mark the stream, read enough data to determine whether it is in
a supported format, and reset the stream's read pointer to its original
position. If the input stream does not permit this set of operations,
this method may fail with an IOException
.
This operation can only succeed for files of a type which can be parsed
by an installed file reader. It may fail with an InvalidMidiDataException
even for valid files if no compatible file reader is installed. It
will also fail with an InvalidMidiDataException if a compatible file reader
is installed, but encounters errors while constructing the Sequence
object from the file data.
stream
- the input stream from which the Sequence
should be constructedSequence
object based on the MIDI file data
contained in the input streamInvalidMidiDataException
- if the stream does not point to
valid MIDI file data recognized by the systemIOException
- if an I/O exception occurs while accessing the
streamInputStream.markSupported()
,
InputStream.mark(int)
public static Sequence getSequence(URL url) throws InvalidMidiDataException, IOException
This operation can only succeed for files of a type which can be parsed
by an installed file reader. It may fail with an InvalidMidiDataException
even for valid files if no compatible file reader is installed. It
will also fail with an InvalidMidiDataException if a compatible file reader
is installed, but encounters errors while constructing the Sequence
object from the file data.
url
- the URL from which the Sequence
should be
constructedSequence
object based on the MIDI file data
pointed to by the URLInvalidMidiDataException
- if the URL does not point to valid MIDI
file data recognized by the systemIOException
- if an I/O exception occurs while accessing the URLpublic static Sequence getSequence(File file) throws InvalidMidiDataException, IOException
File
.
The File
must point to valid MIDI file data
for a file type recognized by the system.
This operation can only succeed for files of a type which can be parsed
by an installed file reader. It may fail with an InvalidMidiDataException
even for valid files if no compatible file reader is installed. It
will also fail with an InvalidMidiDataException if a compatible file reader
is installed, but encounters errors while constructing the Sequence
object from the file data.
file
- the File
from which the Sequence
should be constructedSequence
object based on the MIDI file data
pointed to by the FileInvalidMidiDataException
- if the File does not point to valid MIDI
file data recognized by the systemIOException
- if an I/O exception occurspublic static int[] getMidiFileTypes()
public static boolean isFileTypeSupported(int fileType)
fileType
- the file type for which write capabilities are queriedtrue
if the file type is supported,
otherwise false
public static int[] getMidiFileTypes(Sequence sequence)
sequence
- the sequence for which MIDI file type support
is queriedpublic static boolean isFileTypeSupported(int fileType, Sequence sequence)
fileType
- the file type for which write capabilities
are queriedsequence
- the sequence for which file writing support is queriedtrue
if the file type is supported for this
sequence, otherwise false
public static int write(Sequence in, int fileType, OutputStream out) throws IOException
in
- sequence containing MIDI data to be written to the filefileType
- the file type of the file to be written to the output streamout
- stream to which the file data should be writtenIOException
- if an I/O exception occursIllegalArgumentException
- if the file format is not supported by
the systemisFileTypeSupported(int, Sequence)
,
getMidiFileTypes(Sequence)
public static int write(Sequence in, int type, File out) throws IOException
in
- sequence containing MIDI data to be written to the filefileType
- the file type of the file to be written to the output streamout
- 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(int, Sequence)
,
getMidiFileTypes(Sequence)
|
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.