List of usage examples for javax.sound.midi SysexMessage getData
public byte[] getData()
From source file:com.rockhoppertech.music.midi.js.MIDIEvent.java
/** * Create a MIDIEvent from a JavaSound MidiMessage instance. * //from ww w . ja 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. * /*from ww w.ja va 2 s . 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()); }