Awesome
midimessage
Simple MIDI Message Parser for JavaScript. This parser takes in a MIDIMessageEvent and returns a plain Javascript Object with propties indicating the data in the MIDI message.
Installation
npm install midimessage
Usage
var MIDIMessage = require('midimessage');
midiInput.onmidimessage = function(event){
var midiMessage = MIDIMessage(event);
console.log("Parsed", midiMessage);
}
API
MIDIMessage
: Function - Takes a MIDIMessageEvent as the only argument and decodes the data in the MIDIMessageEvent. Returns a MIDIMessage Object which has various properties set to values based on the MIDIMessage.
These properties are based off the MIDI Message Standard as defined in the MIDI Spec
These are some of the properties that may be exposed (based on the incoming MIDI message) :
channel
: Number (0-127) - MIDI Channel Number.messageType
: String - Type of message. Possible values defined below.key
: Number (0-127) - The key (note) number. Defined on -noteon
,noteoff
,keypressure
messages.velocity
: Number (0-127) - Velocity. Defined onnoteon
,noteoff
messages.controllerNumber
: Number (0-127) - Controller Number. Controller numbers 120-127 are reserved as "Channel Mode Messages".controllerValue
: Number (0-127) Controller Value. Has various meanings based oncontrollerNumber
.channelModeMessage
: String - Channel Mode Message. Specific messages for Channel Modes based oncontrollerNumber
. Possible values defined below.pressure
: Number (0-127) - Pressure value.pitchBend
: Number (0-16383) - Pitch Bend value. Center (no pitch change) is 8192.
Possible values of messageType
property.
[
'noteon', // Note On event.
'noteoff', // Note Off event.
'keypressure', // Polyphonic Key Pressure (Aftertouch).
'controlchange', // Control Change.
'programchange', // Program Change.
'channelpressure', // Channel Pressure (After-touch).
'pitchbendchange', // Pitch Bend Change.
]
Possible values of channelModeMessage
property.
[
'allsoundoff', // All Sound Off.
'resetallcontrollers', // Reset All Controllers.
'localcontroloff', // Local Control Off.
'localcontrolon', // Local Control On.
'allnotesoff', // All Notes Off.
'omnimodeoff', // Omni Mode Off.
'omnimodeon', // Omni Mode On.
'monomodeon', // Mono Mode On (Poly Off).
'polymodeon' // Poly Mode On (Mono Off)
]
License
MIT
See License file