node-easymidi
node-easymidi is a simple event-based MIDI messaging wrapper for node-midi.
Installation
Install with NPM:
npm install easymidi
Usage Overview
The module can interface with existing MIDI inputs/outputs or create virtual inputs/outputs. Here's a simple example to listen for note on events from an existing MIDI input:
var easymidi = ;var input = 'MIDI Input Name';input;Here's an example of sending a note on message to an existing MIDI output:
var easymidi = ;var output = 'MIDI Output Name';output;The Input and Output objects are EventEmitters and you can use the EventEmitter functions such as once(), removeListener(), and removeAllListeners() as well.
Virtual Devices
Virtual devices can be created by passing a true argument to the Input or Output constructors:
var virtualInput = 'Virtual input name' true;var virtualOutput = 'Virtual output name' true;Device Lists
You can get an array of existing MIDI input or output names using the getInputs() and getOutputs functions:
var inputs = easymidi;var outputs = easymidi;Closing Devices
When you're finished with a MIDI device you can close() it:
var input = 'My input' true;input; var output = 'My output' true;output;Message Reference
The following table describes the MIDI message types that are supported and the parameters of each:
| Type | Parameter | Parameter | Parameter |
|---|---|---|---|
| noteon | note [0-127] | velocity [0-127] | channel [0-15] |
| noteoff | note [0-127] | velocity [0-127] | channel [0-15] |
| poly aftertouch | note [0-127] | velocity [0-127] | channel [0-15] |
| cc | controller [0-127] | value [0-127] | channel [0-15] |
| program | number [0-127] | channel [0-15] | |
| channel aftertouch | pressure [0-127] | channel [0-15] | |
| pitch | value [0-16384] | channel [0-15] | |
| position | value [0-16384] | ||
| mtc | type [0-7] | value [0-15] | |
| select | song [0-127] | ||
| clock | |||
| start | |||
| continue | |||
| stop | |||
| activesense | |||
| reset | |||
| sysex | bytes (variable length array) |
Examples
Receive a noteon message:
input;Send a control change message:
outputListen for midi clock messages:
input;Send a sysex message.
Throws an error if array does not start with 0xf0 (240) and end with 0xf7 (247).
output;See the example programs for more examples.