Example usage for javax.sound.midi SysexMessage setMessage

List of usage examples for javax.sound.midi SysexMessage setMessage

Introduction

In this page you can find the example usage for javax.sound.midi SysexMessage setMessage.

Prototype

@Override
public void setMessage(byte[] data, int length) throws InvalidMidiDataException 

Source Link

Document

Sets the data for the system exclusive message.

Usage

From source file:com.rockhoppertech.music.midi.js.MIDIEvent.java

/**
 * Create a JavaSound MidiMessage from this instance.
 * //from ww  w .  j a v  a  2s  .c  o  m
 * @param mm
 * @return
 */
private MidiMessage createMidiMessage() {
    MidiMessage mm = null;
    if (MIDIUtils.isChannelMessage(status)) {
        logger.debug("isChannelMessage for " + Integer.toHexString(status));
        mm = MIDIUtils.createShortMessage(status, bytes);

    } else if (MIDIUtils.isMetaMessage(status)) {
        logger.debug("MetaMessage: " + Integer.toHexString(status));
        MetaMessage meta = new MetaMessage();
        try {
            meta.setMessage(metaMessageType, bytes, bytes.length);
        } catch (InvalidMidiDataException e) {
            e.printStackTrace();
        }
        mm = meta;

    } else if (MIDIUtils.isSysexMessage(status)) {
        logger.debug("Sysex message: " + Integer.toHexString(status));
        SysexMessage sex = new SysexMessage();
        try {
            sex.setMessage(bytes, bytes.length);
        } catch (InvalidMidiDataException e) {
            e.printStackTrace();
        }
        mm = sex;
    } else {
        logger.debug("Unknown status " + Integer.toHexString(status));
    }
    return mm;
}