List of usage examples for javax.sound.midi MidiDevice open
void open() throws MidiUnavailableException;
From source file:de.ailis.midi4js.Midi4JS.java
/** * Opens the specified MIDI device.// w ww. j a v a 2 s . c o m * * @param deviceHandle * The device handle. * @throws MidiUnavailableException * When MIDI device is not available. */ public void openMidiDevice(final int deviceHandle) throws MidiUnavailableException { final MidiDevice device = resolveDeviceHandle(deviceHandle); device.open(); }
From source file:org.monome.pages.Configuration.java
/** * Called when a MIDI output device is selected or de-selected from the MIDI menu * /* w ww . ja va 2 s . com*/ * @param midiOutDevice The MIDI output device to select or de-select */ public void toggleMidiOutDevice(MidiDevice midiOutDevice) { // check if the device is already enabled, if so disable it for (int i = 0; i < this.midiOutDevices.size(); i++) { if (this.midiOutDevices.get(i).equals(midiOutDevice)) { System.out.println( "closing midi out device " + i + " / " + this.midiOutDevices.get(i).getDeviceInfo()); MidiDevice outDevice = this.midiOutDevices.get(i); this.midiOutReceivers.remove(i); this.midiOutDevices.remove(i); outDevice.close(); outDevice.close(); return; } } // try to enable the device try { midiOutDevice.open(); Receiver recv = midiOutDevice.getReceiver(); this.midiOutDevices.add(midiOutDevice); this.midiOutReceivers.add(recv); } catch (MidiUnavailableException e) { e.printStackTrace(); } }
From source file:org.monome.pages.Configuration.java
/** * Enables a MIDI in device to receive MIDI clock. * /*from w w w. j a v a2 s . c o m*/ * @param midiInDevice The MIDI input device to enable */ public void toggleMidiInDevice(MidiDevice midiInDevice) { // close the currently open device if we have one for (int i = 0; i < this.midiInDevices.size(); i++) { if (this.midiInDevices.get(i).equals(midiInDevice)) { MidiDevice inDevice = this.midiInDevices.get(i); System.out .println("closing midi in device " + i + " / " + this.midiInDevices.get(i).getDeviceInfo()); Transmitter transmitter = this.midiInTransmitters.get(i); this.midiInTransmitters.remove(i); this.midiInDevices.remove(i); transmitter.close(); inDevice.close(); return; } } // try to open the new midi in device try { midiInDevice.open(); Transmitter transmitter = midiInDevice.getTransmitter(); transmitter.setReceiver(this); this.midiInDevices.add(midiInDevice); this.midiInTransmitters.add(transmitter); } catch (MidiUnavailableException e) { e.printStackTrace(); } }