List of usage examples for javax.sound.midi MidiSystem getMidiDeviceInfo
public static MidiDevice.Info[] getMidiDeviceInfo()
From source file:de.ailis.midi4js.Midi4JS.java
/** * Returns an array of information objects representing the set of all MIDI * devices available on the system./*from w w w .j av a 2s . co m*/ * * @return The array of information objects about all available MIDI * devices. * @throws JSONException * When JSON string could not be constructed. */ public String getMidiDeviceInfo() throws JSONException { final JSONStringer js = new JSONStringer(); js.array(); for (final Info info : MidiSystem.getMidiDeviceInfo()) { js.object(); js.key("name").value(info.getName()); js.key("description").value(info.getDescription()); js.key("vendor").value(info.getVendor()); js.key("version").value(info.getVersion()); js.endObject(); } js.endArray(); return js.toString(); }
From source file:de.ailis.midi4js.Midi4JS.java
/** * Returns the handle for the midi device with the specified index. The * device must be released by calling the releaseMidiDevice() method! * * @param index/*from w ww.j a va 2 s. c om*/ * The device index. * @return The device handle. * @throws MidiUnavailableException * If the midi device is not available. */ public int getMidiDevice(final int index) throws MidiUnavailableException { final Info[] infos = MidiSystem.getMidiDeviceInfo(); final MidiDevice device = MidiSystem.getMidiDevice(infos[index]); final int handle = System.identityHashCode(device); this.deviceMap.put(handle, device); return handle; }
From source file:org.monome.pages.configuration.Configuration.java
/** * Enables or disables a MIDI input device * // w w w .j av a 2 s .c om * @param sMidiDevice The name of the MIDI device to toggle */ public void actionAddMidiInput(String sMidiDevice) { Info[] midiInfo = MidiSystem.getMidiDeviceInfo(); MidiDevice midiDevice; for (int i = 0; i < midiInfo.length; i++) { try { midiDevice = MidiSystem.getMidiDevice(midiInfo[i]); if (sMidiDevice.compareTo(midiDevice.getDeviceInfo().toString()) == 0) { if (midiDevice.getMaxTransmitters() != 0) { MidiDeviceFactory.toggleMidiInDevice(midiDevice); } } } catch (MidiUnavailableException e) { e.printStackTrace(); } } }
From source file:org.monome.pages.configuration.Configuration.java
/** * Enables or disables a MIDI output device * // ww w . j a v a 2 s .c o m * @param sMidiDevice The MIDI output device to enable or disable */ public void actionAddMidiOutput(String sMidiDevice) { Info[] midiInfo = MidiSystem.getMidiDeviceInfo(); MidiDevice midiDevice; for (int i = 0; i < midiInfo.length; i++) { try { midiDevice = MidiSystem.getMidiDevice(midiInfo[i]); if (sMidiDevice.compareTo(midiDevice.getDeviceInfo().toString()) == 0) { if (midiDevice.getMaxReceivers() != 0) { MidiDeviceFactory.toggleMidiOutDevice(midiDevice); } } } catch (MidiUnavailableException e) { e.printStackTrace(); } } }