Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
node-easymidi is a simple event-based MIDI messaging wrapper for node-midi.
Install with NPM:
npm install easymidi
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 = require('easymidi');
var input = new easymidi.Input('MIDI Input Name');
input.on('noteon', function (msg) {
// do something with msg
});
Here's an example of sending a note on message to an existing MIDI output:
var easymidi = require('easymidi');
var output = new easymidi.Output('MIDI Output Name');
output.send('noteon', {
note: 64,
velocity: 127,
channel: 3
});
The Input and Output objects are EventEmitters and you can use the EventEmitter functions such as once()
, removeListener()
, and removeAllListeners()
as well.
Virtual devices can be created by passing a true
argument to the Input or Output constructors:
var virtualInput = new easymidi.Input('Virtual input name', true);
var virtualOutput = new easymidi.Output('Virtual output name', true);
You can get an array of existing MIDI input or output names using the getInputs()
and getOutputs
functions:
var inputs = easymidi.getInputs();
var outputs = easymidi.getOutputs();
When you're finished with a MIDI device you can close()
it:
var input = new easymidi.Input('My input', true);
input.close();
var output = new easymidi.Output('My output', true);
output.close();
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) |
Receive a noteon message:
input.on('noteon', function (params) {
// params = {note: ..., velocity: ..., channel: ...}
});
Send a control change message:
output.send('cc', {
controller: 37,
value: 80,
channel: 0
})
Listen for midi clock messages:
input.on('clock', function () {
// do something on every clock tick
});
Send a sysex message.
Throws an error if array does not start with 0xf0 (240) and end with 0xf7 (247).
output.send('sysex',[240, 126, 1, 6, 1, 247]);
See the example programs for more examples.
FAQs
Simple event-based MIDI messaging
The npm package easymidi receives a total of 37 weekly downloads. As such, easymidi popularity was classified as not popular.
We found that easymidi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.