List of usage examples for javax.sound.midi MidiMessage getStatus
public int getStatus()
From source file:de.ailis.midi4js.MessageReceiver.java
/** * @see javax.sound.midi.Receiver#send(javax.sound.midi.MidiMessage, long) *//* w ww .ja v a 2s.c o m*/ @Override public void send(final MidiMessage message, final long timeStamp) { try { final JSONStringer json = new JSONStringer(); json.object(); json.key("status").value(message.getStatus()); json.key("message"); json.array(); final byte[] data = message.getMessage(); final int max = Math.min(data.length, message.getLength()); for (int i = 0; i < max; i++) json.value(data[i] & 0xff); json.endArray(); if (message instanceof ShortMessage) processShortMessage((ShortMessage) message, json); else if (message instanceof MetaMessage) processMetaMessage((MetaMessage) message, json); else if (message instanceof SysexMessage) processSysexMessage((SysexMessage) message, json); json.endObject(); this.applet.execJSMethod("messageReceived", System.identityHashCode(this), json.toString(), timeStamp); } catch (final JSONException e) { throw new RuntimeException(e.toString(), e); } }
From source file:com.rockhoppertech.music.midi.js.MIDIEvent.java
/** * Create a MIDIEvent from a JavaSound MidiMessage instance. * // w w w. j a v a2 s. c o m * @param mm * a JavaSound message * @param tick * the tick this occurs */ public MIDIEvent(MidiMessage mm, long tick) { this.tick = tick; startBeat = this.tick * division; if (mm instanceof ShortMessage) { // ShortMessage se = (ShortMessage) mm; bytes = new byte[2]; bytes[0] = bytes[0]; bytes[1] = bytes[1]; } else if (mm instanceof SysexMessage) { SysexMessage sex = (SysexMessage) mm; bytes = sex.getData(); } else if (mm instanceof MetaMessage) { MetaMessage meta = (MetaMessage) mm; bytes = meta.getData(); } status = mm.getStatus(); if (mm instanceof MetaMessage) { metaMessageType = ((MetaMessage) mm).getType(); bytes = ((MetaMessage) mm).getData(); // or getMessage which has the status. nah. } if (mm instanceof SysexMessage) { bytes = ((SysexMessage) mm).getData(); } }
From source file:com.rockhoppertech.music.midi.js.MIDIEvent.java
/** * Creates a new <code>MIDIEvent</code> instance from JavaSound's MidiEvent. * /* w w w . ja v a 2s . co 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()); }