Skip to main content

Message

The Message class represents a single MIDI message. It has several properties that make it easy to make sense of the binary data it contains.

Since: 3.0.0

Constructorโ€‹

Creates a new Message object from raw MIDI data.

Parameters

new Message(data)

ParameterTypeDefaultDescription
dataUint8Array
The raw data of the MIDI message as a Uint8Array of integers between 0 and 255.

Propertiesโ€‹

.channelโ€‹

Type: number
Attributes: read-only

The MIDI channel number (1 - 16) that the message is targeting. This is only for channel-specific messages. For system messages, this will be left undefined.

.commandโ€‹

Type: number
Attributes: read-only

An integer identifying the MIDI command. For channel-specific messages, the value is 4-bit and will be between 8 and 14. For system messages, the value will be between 240 and 255.

.dataโ€‹

Type: Array.<number>
Attributes: read-only

An array containing all the bytes of the MIDI message. Each byte is an integer between 0 and 255.

.dataBytesโ€‹

Type: Array.<number>
Attributes: read-only

An array of the the data byte(s) of the MIDI message (as opposed to the status byte). When the message is a system exclusive message (sysex), dataBytes explicitly excludes the manufacturer ID and the sysex end byte so only the actual data is included.

.isChannelMessageโ€‹

Type: boolean
Attributes: read-only

A boolean indicating whether the MIDI message is a channel-specific message.

.isSystemMessageโ€‹

Type: boolean
Attributes: read-only

A boolean indicating whether the MIDI message is a system message (not specific to a channel).

.manufacturerIdโ€‹

Type: Array.<number>
Attributes: read-only

When the message is a system exclusive message (sysex), this property contains an array with either 1 or 3 entries that identify the manufacturer targeted by the message.

To know how to translate these entries into manufacturer names, check out the official list: https://www.midi.org/specifications-old/item/manufacturer-id-numbers

.rawDataโ€‹

Type: Uint8Array
Attributes: read-only

A Uint8Array containing the bytes of the MIDI message. Each byte is an integer between 0 and 255.

.rawDataBytesโ€‹

Type: Uint8Array
Attributes: read-only

A Uint8Array of the data byte(s) of the MIDI message. When the message is a system exclusive message (sysex), rawDataBytes explicitly excludes the manufacturer ID and the sysex end byte so only the actual data is included.

.statusByteโ€‹

Type: number
Attributes: read-only

The MIDI status byte of the message as an integer between 0 and 255.

.typeโ€‹

Type: string
Attributes: read-only

The type of message as a string ("noteon", "controlchange", "sysex", etc.)