# easymidi

> Simple event-based MIDI messaging

Latest version **3.2.0** (published 2026-03-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install easymidi
pnpm add easymidi
yarn add easymidi
bun add easymidi
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.2.0 |
| Published | 2026-03-05 |
| First published | 2015-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=18.0.0 |
| Dependencies | 1 |
| Unpacked size | 23 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 196 |
| Author | Tom Dinchak |
| Maintainers | dinchak |
| Keywords | midi |

## Links

- npm: https://www.npmjs.com/package/easymidi
- Repository: https://github.com/dinchak/node-easymidi
- Issues: https://github.com/dinchak/node-easymidi/issues
- npm.io page: https://npm.io/package/easymidi

## Dependencies (1)

- [@julusian/midi](https://npm.io/package/@julusian/midi.md) ^3.6.1

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 3.2.0 (latest) — 2026-03-05
- 3.1.0 — 2023-07-19
- 3.0.1 — 2022-10-26
- 2.1.1 — 2022-09-30
- 2.1.0 — 2021-10-16
- 2.0.5 — 2021-05-28
- 2.0.4 — 2021-04-29
- 2.0.3 — 2021-04-07
- 2.0.2 — 2021-03-12
- 2.0.1 — 2020-09-15
- 2.0.0 — 2020-07-09
- 1.1.2 — 2020-05-09
- 1.1.1 — 2020-05-08
- 1.1.0 — 2020-05-06
- 1.0.3 — 2019-11-25
- … 8 more at https://npm.io/package/easymidi/versions

## README

# node-easymidi
node-easymidi is a simple event-based MIDI messaging wrapper for [node-midi](https://github.com/justinlatimer/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:

```javascript
const easymidi = require('easymidi');
const 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:

```javascript
const easymidi = require('easymidi');
const output = new easymidi.Output('MIDI Output Name');
output.send('noteon', {
  note: 64,
  velocity: 127,
  channel: 3
});
```

The Input and Output objects are [EventEmitters](http://nodejs.org/api/events.html#events_class_events_eventemitter) 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:

```javascript
const virtualInput = new easymidi.Input('Virtual input name', true);
const 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:

```javascript
const inputs = easymidi.getInputs();
const outputs = easymidi.getOutputs();
```

# Closing Devices
When you're finished with a MIDI device you can `close()` it:

```javascript
const input = new easymidi.Input('My input', true);
input.close();

const 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:

```javascript
input.on('noteon', function (params) {
  // params = {note: ..., velocity: ..., channel: ...}
});
```

Send a control change message:

```javascript
output.send('cc', {
  controller: 37,
  value: 80,
  channel: 0
})
```

Listen for midi clock messages:

```javascript
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).
```javascript
output.send('sysex',[240, 126, 1, 6, 1, 247]);
```

See the [example programs](https://github.com/dinchak/node-easymidi/tree/master/examples) for more examples.

---
_Source: https://npm.io/package/easymidi · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
