public abstract class MidiUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
close(MidiDevice device)
Closes the MIDI device.
|
static void |
close(Receiver receiver)
Closes the MIDI receiver.
|
static void |
close(Transmitter transmitter)
Closes the MIDI transmitter.
|
static void |
closeTransmitters(MidiDevice device)
Closes all transmitter of the device.
|
static ShortMessage |
createShortMessage(int command,
int channel,
int data1,
int data2)
Creates a new MIDI short message.
|
static MidiShortMessageEvent |
createShortMessageEvent(MidiPlugin midiPlugin,
ShortMessage message)
Create a new Sponge MIDI event.
|
static MidiShortMessageEvent |
createShortMessageEvent(MidiPlugin midiPlugin,
ShortMessage message,
long timeStamp)
Create a new Sponge MIDI event.
|
static MidiChannel |
getChannel(Synthesizer synthesizer,
int channel,
boolean required)
Returns the MIDI channel.
|
static MidiDevice |
getDefaultInputDevice()
Returns the default input MIDI device.
|
static MidiDevice |
getDevice(Predicate<? super MidiDevice> predicate)
Searches for a MIDI device by a predicate.
|
static MidiDevice |
getDeviceByName(String name)
Returns the MIDI device by name.
|
static Map<MidiDevice.Info,MidiDevice> |
getDeviceMap()
Returns the map of all available MIDI devices.
|
static List<MidiDevice> |
getDevices()
Returns all available MIDI devices.
|
static int |
getFirstSupportedMidiFileType(Sequence sequence)
Returns the first supported MIDI file type.
|
static Instrument |
getInstrument(Synthesizer synthesizer,
int channel)
Returns the MIDI instrument.
|
static List<Instrument> |
getInstruments(Synthesizer synthesizer)
Returns the synthesizer loaded instruments.
|
static String |
getKeyNote(int key)
Returns the note representation for the given MIDI key.
|
static boolean |
loadAllInstruments(Synthesizer synthesizer)
Loads all instruments to the synthesizer from the default soundbank.
|
static boolean |
loadAllInstruments(Synthesizer synthesizer,
Soundbank soundbank)
Loads all instruments to the synthesizer from the soundbank.
|
static Instrument |
loadInstrument(Synthesizer synthesizer,
String instrumentName)
Loads a MIDI instrument by name.
|
static void |
open(MidiDevice device)
Opens the MIDI device.
|
static Instrument |
setInstrument(Synthesizer synthesizer,
int channel,
int instrument)
Sets the synthesizer instrument from the currently selected bank of instruments.
|
static Instrument |
setInstrument(Synthesizer synthesizer,
int channel,
String instrumentName)
Sets the synthesizer instrument from the currently selected bank of instruments.
|
static void |
setMute(Sequencer sequencer,
Sequence sequence,
boolean mute)
Sets the mute flag for all tracks in the sequence.
|
public static List<MidiDevice> getDevices()
public static MidiDevice getDefaultInputDevice()
null if not found.public static MidiDevice getDeviceByName(String name)
name - the MIDI device name.null if not found.public static MidiDevice getDevice(Predicate<? super MidiDevice> predicate)
predicate - the predicate.null if not found.public static Map<MidiDevice.Info,MidiDevice> getDeviceMap()
public static void open(MidiDevice device)
device - the MIDI device.public static void close(MidiDevice device)
device - the MIDI device.public static void close(Transmitter transmitter)
transmitter - the MIDI transmitter.public static void close(Receiver receiver)
receiver - the MIDI receiver.public static ShortMessage createShortMessage(int command, int channel, int data1, int data2)
command - the MIDI short message command.channel - the MIDI short message channel.data1 - the MIDI short message data1.data2 - the MIDI short message data2.public static void setMute(Sequencer sequencer, Sequence sequence, boolean mute)
sequencer - the sequencer.sequence - the sequence.mute - the mute flag.public static MidiShortMessageEvent createShortMessageEvent(MidiPlugin midiPlugin, ShortMessage message, long timeStamp)
midiPlugin - the MIDI plugin.message - the MIDI short message.timeStamp - the MIDI timestamp.public static MidiShortMessageEvent createShortMessageEvent(MidiPlugin midiPlugin, ShortMessage message)
midiPlugin - the MIDI plugin.message - the MIDI short message.public static String getKeyNote(int key)
key - the MIDI key.public static Instrument loadInstrument(Synthesizer synthesizer, String instrumentName)
synthesizer - the synthesizer.instrumentName - the instrument name.null if the instrument couldn't be loaded.public static MidiChannel getChannel(Synthesizer synthesizer, int channel, boolean required)
synthesizer - the synthesizer.channel - the channel number.required - if true then throws exception when not found or not available. Otherwise returns null.public static Instrument getInstrument(Synthesizer synthesizer, int channel)
synthesizer - the synthesizer.channel - the channel number.public static Instrument setInstrument(Synthesizer synthesizer, int channel, int instrument)
synthesizer - the synthesizer.channel - the channel.instrument - the instrument number.public static Instrument setInstrument(Synthesizer synthesizer, int channel, String instrumentName)
synthesizer - the synthesizer.channel - the channel.instrumentName - the instrument name.public static boolean loadAllInstruments(Synthesizer synthesizer, Soundbank soundbank)
synthesizer - the synthesizer.soundbank - the soundbank.true on success.public static boolean loadAllInstruments(Synthesizer synthesizer)
synthesizer - the synthesizer.true on success.public static List<Instrument> getInstruments(Synthesizer synthesizer)
synthesizer - the synthesizer.public static void closeTransmitters(MidiDevice device)
device - the MIDI device.public static int getFirstSupportedMidiFileType(Sequence sequence)
sequence - the sequence;Copyright © 2016–2020 Softelnet. All rights reserved.