npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@guillaumearm/easymidi

v2.0.3

Published

Simple event-based MIDI messaging

Downloads

6

Readme

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 = 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

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);

Device Lists

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();

Closing Devices

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();

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.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.