List of usage examples for javax.sound.midi ShortMessage getData1
public int getData1()
From source file:de.ailis.midi4js.MessageReceiver.java
/** * Processes a short message.//from ww w .ja va2 s . c o m * * @param message * The message to process. * @param json * The JSON stringer. * @throws JSONException * When JSON output fails. */ private void processShortMessage(final ShortMessage message, final JSONStringer json) throws JSONException { json.key("class").value("ShortMessage"); json.key("channel").value(message.getChannel()); json.key("command").value(message.getCommand()); json.key("data1").value(message.getData1()); json.key("data2").value(message.getData2()); }
From source file:com.rockhoppertech.music.midi.js.MIDIEvent.java
/** * Creates a new <code>MIDIEvent</code> instance from JavaSound's MidiEvent. * //from w w w . jav a 2 s.c o m * @param e * a <code>MidiEvent</code> object. */ public MIDIEvent(MidiEvent e) { tick = e.getTick(); startBeat = (double) (tick) / (double) (division); MidiMessage mm = e.getMessage(); byte[] ba = mm.getMessage(); logger.debug("Original message: " + ba.length); for (byte element : ba) { logger.debug(Integer.toHexString(element & 0xf0) + " "); } if (mm instanceof ShortMessage) { logger.debug("Is short message"); ShortMessage se = (ShortMessage) mm; bytes = new byte[2]; bytes[0] = (byte) se.getData1(); bytes[1] = (byte) se.getData2(); } else if (mm instanceof SysexMessage) { logger.debug("is sysex message"); SysexMessage sex = (SysexMessage) mm; bytes = sex.getData(); } else if (mm instanceof MetaMessage) { logger.debug("is meta message"); MetaMessage meta = (MetaMessage) mm; bytes = meta.getData(); } status = mm.getStatus(); logger.debug("Status: " + Integer.toHexString(status)); if (mm instanceof MetaMessage) { metaMessageType = ((MetaMessage) mm).getType(); } logger.debug("Constructed: " + toString()); }
From source file:org.monome.pages.MIDITriggersPage.java
public void send(MidiMessage message, long timeStamp) { ShortMessage msg = (ShortMessage) message; int x = msg.getData1() - 12; int y = msg.getChannel(); if (x >= 0 && x < this.monome.sizeX && y >= 0 && y < this.monome.sizeY) { int velocity = msg.getData2(); if (velocity == 127) { this.toggleValues[x][y] = 1; } else {//from ww w .ja v a 2 s . c om this.toggleValues[x][y] = 0; } this.redrawMonome(); } return; }
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. * /*w w w. j a va2 s . co m*/ * @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); } } } }