List of usage examples for javax.sound.midi MidiDevice getTransmitter
Transmitter getTransmitter() throws MidiUnavailableException;
From source file:de.ailis.midi4js.Midi4JS.java
/** * Returns MIDI IN transmitter for the specified device. A transmitter must * be closed when no longer needed.//from w ww. ja v a2s . c o m * * @param deviceHandle * The handle of the MIDI device. * @return The handle of the transmitter. * @throws MidiUnavailableException * When MIDI device is unavailable. */ public int getTransmitter(final int deviceHandle) throws MidiUnavailableException { final MidiDevice device = resolveDeviceHandle(deviceHandle); final Transmitter transmitter = device.getTransmitter(); final int transmitterHandle = System.identityHashCode(transmitter); this.transmitterMap.put(transmitterHandle, transmitter); return transmitterHandle; }
From source file:org.monome.pages.Configuration.java
/** * Enables a MIDI in device to receive MIDI clock. * //from w w w . j av a2 s .com * @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(); } }