Example usage for javax.sound.midi SysexMessage getLength

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

Introduction

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

Prototype

public int getLength() 

Source Link

Document

Obtains the total length of the MIDI message in bytes.

Usage

From source file:de.ailis.midi4js.MessageReceiver.java

/**
 * Processes a sysex message./*from www.  j a  v  a  2 s .c  om*/
 *
 * @param message
 *            The message to process.
 * @param json
 *            The JSON stringer.
 * @throws JSONException
 *             When JSON output fails.
 */
private void processSysexMessage(final SysexMessage message, final JSONStringer json) throws JSONException {
    json.key("class").value("SysexMessage");
    json.key("data");
    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();
}