public final class MidiSystem extends Object
Modifier and Type | Class and Description |
---|---|
static class |
MidiSystem.MidiSystemUtils
Utilities for
MidiSystem |
Modifier and Type | Method and Description |
---|---|
static void |
addMidiDevice(MidiDevice midiDevice)
Add a
MidiDevice to the MidiSystem |
static void |
addSynthesizer(Synthesizer synthesizer)
Add a
Synthesizer to the MidiSystem |
static MidiDevice |
getMidiDevice(MidiDevice.Info info)
Get
MidiDevice by device information |
static MidiDevice.Info[] |
getMidiDeviceInfo()
Get all connected
MidiDevice.Info as array |
static MidiFileFormat |
getMidiFileFormat(File file)
Get the
MidiFileFormat information of the specified File. |
static MidiFileFormat |
getMidiFileFormat(InputStream stream)
Get the
MidiFileFormat information in the specified input stream. |
static MidiFileFormat |
getMidiFileFormat(URL url)
Get the
MidiFileFormat information in the specified URL. |
static int[] |
getMidiFileTypes()
Get the set of SMF types that the library can write
|
static int[] |
getMidiFileTypes(Sequence sequence)
Get the set of SMF types that the library can write from the
Sequence |
static Receiver |
getReceiver()
Get the first detected Receiver
|
static Sequence |
getSequence(File file)
Get a
Sequence from the specified File. |
static Sequence |
getSequence(InputStream stream)
Get a
Sequence from the specified input stream. |
static Sequence |
getSequence(URL url)
Get a
Sequence from the specified URL. |
static Sequencer |
getSequencer()
Get the default
Sequencer , connected to a default device. |
static Sequencer |
getSequencer(boolean connected)
Get the default
Sequencer , optionally connected to a default device. |
static Soundbank |
getSoundbank(File file)
Obtain
Soundbank from Filenot implemented. |
static Soundbank |
getSoundbank(InputStream stream)
Obtain
Soundbank from InputStreamnot implemented. |
static Soundbank |
getSoundbank(URL url)
Obtain
Soundbank from URLnot implemented. |
static Synthesizer |
getSynthesizer()
Obtain
Synthesizer registered by registerSynthesizer(Synthesizer) |
static Transmitter |
getTransmitter()
Get the first detected Transmitter
|
static boolean |
isFileTypeSupported(int fileType)
Check if the specified SMF fileType is available
|
static boolean |
isFileTypeSupported(int fileType,
Sequence sequence)
Check if the specified SMF fileType is available from the
Sequence |
static void |
registerSynthesizer(Synthesizer synthesizer)
Register the
Synthesizer instance to the MidiSystem . |
static void |
removeMidiDevice(MidiDevice midiDevice)
Remove a
MidiDevice from the MidiSystem |
static void |
removeSynthesizer(Synthesizer synthesizer)
Remove a
Synthesizer from the MidiSystem |
static int |
write(Sequence sequence,
int fileType,
File file)
Write sequence to the specified
File as SMF |
static int |
write(Sequence sequence,
int fileType,
OutputStream outputStream)
Write sequence to the specified
OutputStream as SMF |
public static void addMidiDevice(@NonNull MidiDevice midiDevice)
MidiDevice
to the MidiSystem
midiDevice
- the device to addpublic static void removeMidiDevice(@NonNull MidiDevice midiDevice)
MidiDevice
from the MidiSystem
midiDevice
- the device to removepublic static void addSynthesizer(@NonNull Synthesizer synthesizer)
Synthesizer
to the MidiSystem
synthesizer
- the device to addpublic static void removeSynthesizer(@NonNull Synthesizer synthesizer)
Synthesizer
from the MidiSystem
synthesizer
- the device to remove@NonNull public static MidiDevice.Info[] getMidiDeviceInfo()
MidiDevice.Info
as array@NonNull public static MidiDevice getMidiDevice(@NonNull MidiDevice.Info info) throws MidiUnavailableException, IllegalArgumentException
MidiDevice
by device informationinfo
- the device informationMidiDevice
MidiUnavailableException
IllegalArgumentException
- if the device not found.@Nullable public static Receiver getReceiver() throws MidiUnavailableException
Receiver
MidiUnavailableException
@Nullable public static Transmitter getTransmitter() throws MidiUnavailableException
Transmitter
MidiUnavailableException
@NonNull public static Sequence getSequence(@NonNull File file) throws InvalidMidiDataException, IOException
Sequence
from the specified File.file
- the SMFSequence
InvalidMidiDataException
IOException
@NonNull public static Sequence getSequence(@NonNull InputStream stream) throws InvalidMidiDataException, IOException
Sequence
from the specified input stream.stream
- the input stream of SMFSequence
InvalidMidiDataException
IOException
@NonNull public static Sequence getSequence(@NonNull URL url) throws InvalidMidiDataException, IOException
Sequence
from the specified URL.url
- the URL of SMFSequence
InvalidMidiDataException
IOException
@NonNull public static Sequencer getSequencer() throws MidiUnavailableException
Sequencer
, connected to a default device.Sequencer
must call the MidiDevice.open()
method.MidiUnavailableException
@NonNull public static Sequencer getSequencer(boolean connected) throws MidiUnavailableException
Sequencer
, optionally connected to a default device.connected
- ignoredSequencer
must call the MidiDevice.open()
method.MidiUnavailableException
@NonNull public static Soundbank getSoundbank(@NonNull File file) throws InvalidMidiDataException, IOException
Soundbank
from Filefile
- the Soundbank fileSoundbank
InvalidMidiDataException
IOException
@NonNull public static Soundbank getSoundbank(@NonNull InputStream stream) throws InvalidMidiDataException, IOException
Soundbank
from InputStreamstream
- the input stream of SoundbankSoundbank
InvalidMidiDataException
IOException
@NonNull public static Soundbank getSoundbank(@NonNull URL url) throws InvalidMidiDataException, IOException
Soundbank
from URLurl
- the URL of SoundbankSoundbank
InvalidMidiDataException
IOException
@Nullable public static Synthesizer getSynthesizer() throws MidiUnavailableException
Synthesizer
registered by registerSynthesizer(Synthesizer)
MidiUnavailableException
public static void registerSynthesizer(@NonNull Synthesizer synthesizer)
Synthesizer
instance to the MidiSystem
.synthesizer
- the Synthesizer
instance@NonNull public static MidiFileFormat getMidiFileFormat(@NonNull File file) throws InvalidMidiDataException, IOException
MidiFileFormat
information of the specified File.file
- the SMFMidiFileFormat
informationInvalidMidiDataException
IOException
@NonNull public static MidiFileFormat getMidiFileFormat(@NonNull InputStream stream) throws InvalidMidiDataException, IOException
MidiFileFormat
information in the specified input stream.stream
- the the input stream of SMFMidiFileFormat
informationInvalidMidiDataException
IOException
@NonNull public static MidiFileFormat getMidiFileFormat(@NonNull URL url) throws InvalidMidiDataException, IOException
MidiFileFormat
information in the specified URL.url
- the URL of SMFMidiFileFormat
informationInvalidMidiDataException
IOException
@NonNull public static int[] getMidiFileTypes()
@NonNull public static int[] getMidiFileTypes(@NonNull Sequence sequence)
Sequence
sequence
- the Sequence
public static boolean isFileTypeSupported(int fileType)
fileType
- the fileType of SMFpublic static boolean isFileTypeSupported(int fileType, @NonNull Sequence sequence)
Sequence
public static int write(@NonNull Sequence sequence, int fileType, @NonNull File file) throws IOException
File
as SMFsequence
- the Sequence
fileType
- the fileType of Sequence
file
- the File
to writeIOException
public static int write(@NonNull Sequence sequence, int fileType, @NonNull OutputStream outputStream) throws IOException
OutputStream
as SMFsequence
- the Sequence
fileType
- the fileType of Sequence
outputStream
- the OutputStream
to writeIOException