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)
Parameter | Type | Default | Description |
---|---|---|---|
data | Uint8Array | 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.)