private void sysex() { byte[] testMsg = {(byte) 0xf0, 0x00, 0x20, 0x29, 0x02, 0x10, 0x0b, 0x63, 0x00, 0x00, 0x3f, (byte) 0xf7 }; try { SysexMessage message = new SysexMessage(); message.setMessage(testMsg, testMsg.length); receiver.send(message, -1); } catch (InvalidMidiDataException e) { System.err.println(e); } }
public String decodeMessage(SysexMessage message) { byte[] abData = message.getData(); String strMessage = null; // System.out.println("sysex status: " + message.getStatus()); if (message.getStatus() == SysexMessage.SYSTEM_EXCLUSIVE) { strMessage = "Sysex message: F0" + MidiMessageExtractor.getHexString(abData); } else if (message.getStatus() == SysexMessage.SPECIAL_SYSTEM_EXCLUSIVE) { strMessage = "Continued Sysex message F7" + MidiMessageExtractor.getHexString(abData); seByteCount--; // do not count the F7 } seByteCount += abData.length + 1; seCount++; // for the status byte return strMessage; }
/** * Creates a SYSEX message from the received (potentially partial) messages. This function is called when F7 was * detected in the most recent message gathered, indicating the end of the SYSEX. * * @return The constructed SYSEX message * * @throws InvalidMidiDataException if the data is not properly formed * */ private SysexMessage constructSysexMessage() throws InvalidMidiDataException { // Create the array to hold the constructed message and reset the index (where the data will be copied) byte data[] = new byte[sysexMessageLength]; int index = 0; // Iterate through the partial messages for (byte[] sourceData : sysexMessageData) { // Get the partial message // Copy the partial message into the array System.arraycopy(sourceData, 0, data, index, sourceData.length); // Point the index to where the next partial message needs to be copied. index += sourceData.length; } // We are done with the message fragments, so allow them to be garbage collected sysexMessageData = null; // Create and return the new SYSYEX Message return new SysexMessage(data, sysexMessageLength); }
/** * Sets the MIDI SysexMessage data. * * @param data the MIDI SysexMessage data. */ public void setData(byte[] data) { try { getMessage().setMessage(data, data.length); } catch (InvalidMidiDataException e) { throw SpongeUtils.wrapException(e); } }
/** * Returns the MIDI SysexMessage data. * * @return the MIDI SysexMessage data. */ public byte[] getData() { return getMessage().getData(); }
private void sendSysExMessage(byte[] data) throws InvalidMidiDataException { SysexMessage message = new SysexMessage(); message.setMessage(data, data.length); send(message); }
private void sysex() { byte[] testMsg = {(byte) 0xf0, 0x00, 0x20, 0x29, 0x02, 0x10, 0x0b, 0x63, 0x00, 0x00, 0x3f, (byte) 0xf7 }; try { SysexMessage message = new SysexMessage(); message.setMessage(testMsg, testMsg.length); receiver.send(message, -1); } catch (InvalidMidiDataException e) { System.err.println(e); } }
abSysexData[i] = (byte) nDataByte; SysexMessage sysexMessage = new SysexMessage(); sysexMessage.setMessage(nStatusByte, abSysexData, nSysexDataLength); message = sysexMessage; break;