Example usage for javax.sound.midi MetaMessage getLength

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

Introduction

In this page you can find the example usage for javax.sound.midi MetaMessage 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 meta message./* www.j ava2s.c  o  m*/
 *
 * @param message
 *            The message to process.
 * @param json
 *            The JSON stringer.
 * @throws JSONException
 *             When JSON output fails.
 */
private void processMetaMessage(final MetaMessage message, final JSONStringer json) throws JSONException {
    json.key("class").value("MetaMessage");
    json.key("type").value(message.getType());
    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();
}