List of usage examples for javax.sound.midi MidiDevice getDeviceInfo
Info getDeviceInfo();
From source file:de.ailis.midi4js.Midi4JS.java
/** * Returns the device info of the specified device. * * @param deviceHandle/*from w ww . ja va 2s . c om*/ * The device handle. * @return The device info as a JSON string. * @throws JSONException * When JSON output fails. */ public String getMidiDeviceInfo(final int deviceHandle) throws JSONException { final MidiDevice device = resolveDeviceHandle(deviceHandle); final JSONStringer json = new JSONStringer(); deviceInfo(json, device.getDeviceInfo()); return json.toString(); }
From source file:org.monome.pages.configuration.MonomeConfiguration.java
/** * Called every time a MIDI clock sync 'reset' is received, this triggers each page's handleReset() method. *//*from w ww .ja v a 2 s . c o m*/ public void reset(MidiDevice device) { for (int i = 0; i < this.numPages; i++) { for (int j = 0; j < this.midiInDevices[i].length; j++) { if (this.midiInDevices[i][j] == null) { continue; } if (this.midiInDevices[i][j].compareTo(device.getDeviceInfo().getName()) == 0) { this.pages.get(i).handleReset(); this.patternBanks.get(i).handleReset(); } } } this.tickNum = 0; }
From source file:org.monome.pages.configuration.MonomeConfiguration.java
/** * Called every time a MIDI clock sync 'tick' is received, this triggers each page's handleTick() method *//*from www .j a va 2 s . com*/ public synchronized void tick(MidiDevice device) { for (int i = 0; i < this.numPages; i++) { for (int j = 0; j < this.midiInDevices[i].length; j++) { if (this.midiInDevices[i][j] == null) { continue; } if (this.midiInDevices[i][j].compareTo(device.getDeviceInfo().getName()) == 0) { ArrayList<Press> presses = patternBanks.get(i).getRecordedPresses(); if (presses != null) { for (int k = 0; k < presses.size(); k++) { int[] press = presses.get(k).getPress(); for (int pb = 0; pb < this.pressesInPlayback.size(); pb++) { if (pressesInPlayback.get(pb) == null) continue; int[] pbPress = pressesInPlayback.get(pb).getPress(); if (press[0] == pbPress[0] && press[1] == pbPress[1] && press[2] == 0) { pressesInPlayback.remove(pb); } } if (press[2] == 1) { pressesInPlayback.add(presses.get(k)); } this.pages.get(i).handleRecordedPress(press[0], press[1], press[2], presses.get(k).getPatternNum()); } } this.patternBanks.get(i).handleTick(); this.pages.get(i).handleTick(device); } } } if (this.pageChangeMode == 1 && this.tickNum % 12 == 0) { this.drawPatternState(); } this.tickNum++; if (this.tickNum == 96) { this.tickNum = 0; } }
From source file:org.monome.pages.configuration.Configuration.java
/** * Enables or disables a MIDI input device * /*w ww. j a v a 2 s.co m*/ * @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 * //from www . java2s .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(); } } }
From source file:org.monome.pages.configuration.MonomeConfiguration.java
/** * Called every time a MIDI message is received, the messages are passed along to each page. * /* ww w .ja v a 2 s. c om*/ * @param message The MIDI message received * @param timeStamp The timestamp of the MIDI message */ public synchronized void send(MidiDevice device, MidiMessage message, long timeStamp) { if (this.useMIDIPageChanging) { if (message instanceof ShortMessage) { ShortMessage msg = (ShortMessage) message; int velocity = msg.getData1(); if (msg.getCommand() == ShortMessage.NOTE_ON && velocity > 0) { int channel = msg.getChannel(); int note = msg.getData1(); for (int j = 0; j < this.pageChangeMidiInDevices.length; j++) { if (this.pageChangeMidiInDevices[j] == null) { continue; } if (this.pageChangeMidiInDevices[j].compareTo(device.getDeviceInfo().getName()) == 0) { for (int i = 0; i < this.midiPageChangeRules.size(); i++) { MIDIPageChangeRule mpcr = this.midiPageChangeRules.get(i); if (mpcr.checkNoteRule(note, channel) == true) { int switchToPageIndex = mpcr.getPageIndex(); Page page = this.pages.get(switchToPageIndex); this.switchPage(page, switchToPageIndex, true); } } } } } if (msg.getCommand() == ShortMessage.CONTROL_CHANGE) { int cc = msg.getData1(); int ccVal = msg.getData2(); int channel = msg.getChannel(); for (int j = 0; j < this.pageChangeMidiInDevices.length; j++) { if (this.pageChangeMidiInDevices[j] == null) { continue; } if (this.pageChangeMidiInDevices[j].compareTo(device.getDeviceInfo().getName()) == 0) { for (int i = 0; i < this.midiPageChangeRules.size(); i++) { MIDIPageChangeRule mpcr = this.midiPageChangeRules.get(i); if (mpcr.checkCCRule(cc, ccVal, channel) == true) { int switchToPageIndex = mpcr.getPageIndex(); Page page = this.pages.get(switchToPageIndex); this.switchPage(page, switchToPageIndex, true); } } } } } } } for (int i = 0; i < this.numPages; i++) { for (int j = 0; j < this.midiInDevices[i].length; j++) { if (this.midiInDevices[i][j] == null) { continue; } if (this.midiInDevices[i][j].compareTo(device.getDeviceInfo().getName()) == 0) { this.pages.get(i).send(message, timeStamp); } } } }