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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@midival/core

v0.2.0

Published

`midival` is the library to handle MIDI messages in JavaScript (TypeScript) with ease. It provides simple programming interface to interact with both MIDI IN and MIDI OUT.

Downloads

654

Readme

@midival/core

midival is the library to handle MIDI messages in JavaScript (TypeScript) with ease. It provides simple programming interface to interact with both MIDI IN and MIDI OUT.

The library is currently in alpha state. Feel free to contribute, post bug reports, comments and ideas.

More information: midival.github.io

Installation

yarn add @midival/core

Getting started

To get started you need to initialise the library and ask for available devices:

import { MIDIVal } from "@midival/core";

MIDIVal.connect().then((accessObject) => {
  console.log("Inputs", accessObject.inputs);
  console.log("Outputs", accessObject.outputs);
});

Listening to devices

You can also listen to new devices and react when they are connected:

import { MIDIVal } from "@midival/core";

MIDIVal.onDeviceConnected((device) => {
  console.log("Device", device);
});

You can also listen to disconnect events:

import { MIDIVal } from "@midival/core";

MIDIVal.onDeviceDisconnected((device) => {
  console.log("Device", device);
});

Once you obtain reference to device, you can use it by creating MIDIValInput / MIDIValOutput object from it:

MIDIVal.connect().then((accessObject) => {
  const input = new MIDIValInput(accessObject.inputs[0]);
});

MIDI Inputs

Once you obtain access to the MIDI Input you can interact with it.

Note On

You can subscribe to note on.

input.onAllNoteOn(({ note, velocity }) => {
  console.log("Note On:", note, "velocity:", velocity);
});

You can also subscribe to a specific key:

input.onNoteOn(60, ({ velocity }) => {
  console.log("C pressed with velocity", velocity);
});

Note Off

You can subscribe to note off. The note off takes into account both Note Off message as well as Note On with Velocity 0.

input.onAllNoteOff(({ note }) => {
  console.log("Note Off:", note);
});

You can also subscribe to a specific key:

input.onNoteOff(60, ({ velocity }) => {
  console.log("C depressed with velocity", velocity); // velocity should be 0.
});

Control Change

To listen to Control Change (MIDI CC) messages like modulation, synth parameter change and more, you can do the following:

input.onAllControlChange(({ control, value }) => {
  console.log(`Param: ${control}, value: ${value}`);
});

You can also listen to the single control parameter (like Modulation wheel, Volume or Pan only). The full table with MIDI CC messages can be found in the official MIDI CC documentation.

input.onControlChange(7, ({value}) => {
    console.log('Volume change to value:', value));
});

input.onControlChange(1, ({value}) => {
    console.log('Modulation Wheel value changed to:', value);
})

Program Change

You can listen to program change messages:

input.onAllProgramChange(({ program, value }) => {
  console.log(`Program ${program} changed to: ${value}`);
});

You can also listen to a single program channel:

input.onProgramChange(1, ({ value }) => {
  console.log(`Program 1 changed to:`, value);
});

Poly Key Pressure

You can listen to Poly Key Pressure:

input.onAllPolyKeyPressure((midiMessage) => {});

you can listen to a specific key:

input.onPolyKeyPressure(5, (midiMessage) => {});

Systex

You can listen to systex message:

input.onSysex((midiMessage) => {});

All Sounds Off

You can listen to all sounds off message

input.onAllSoundsOff(() => {});

Reset All Controllers

You can listen to the signal to reset all controllers

input.onResetAllControllers(() => {});

Local Control Change

Under construction

All Notes Off

You can listen to all notes off

input.onAllNotesOff(() => {});

MIDI Clock

You can listen to MIDI Clock messages:

  • onClockStart
  • onClockStop
  • onClockContinue
  • onClockPulse - sent 24 times every quarternote.

To Be Added

The following features are planned to be added to MIDI Input:

  • Better support for sysex
  • Better documentation

Disconnect

If you want to stop listening to all the messages and unregister all callbacks simply call:

input.disconnect();

Changelog and migration guide

For changelog see CHANGELOG.md.

For migration guide see MIGRATION.md.

Community

Join our Discord Community to ask questions or discuss all MIDI related topics!