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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-midi

v0.0.3

Published

A USB/Bluetooth midi driver for React Native

Readme

react-native-midi

NPM

React-native module for accessing USB midi controllers (on Android). Plans to include Bluetooth and iOS support eventually.

Getting started

$ npm install react-native-midi --save

Installation

Add USB feature in android/src/main/AndroidManifest:

<manifest>

    <uses-feature android:name="android.hardware.usb.host" /> <!-- HERE!-->
    <uses-feature android:name="android.software.midi" android:required="true"/> <!-- HERE!-->

    <application>
      ...
    </application>
</manifest>

Usage

The library is mostly event driven, with a few helper functions for getting the current state of the midi controllers.

Example
import Midi from 'react-native-midi';

// Register for some common events:
Midi.on(Midi.INPUT_DEVICE_ATTACHED, device => {
  console.log(`Device "${device.id}" connected`);
});

Midi.on(Midi.INPUT_DEVICE_DETACHED, device => {
  console.log(`Device "${device.id}" disconnected`);
});

Midi.on(Midi.NOTE_ON, event => {
  console.log(`Device "${event.device}" started note: ${event.note}`);
});

Midi.on(Midi.NOTE_OFF, event => {
  console.log(`Device "${event.device}" stopped note: ${event.note}`);
});

// Stop listening to note events
Midi.off(Midi.NOTE_ON);
Midi.off(Midi.NOTE_OFF);

// Getters
const devices = await Midi.getDevices(); // Currently attached devices
const deviceCount = await Midi.getDeviceCount(); // Number of devices currently attached
const device = await Midi.getDevice(123); // Get device with id '123'

Functions

| Function | Arguments | Returns | Description | |----------|-----------------|---------|-----------------------------| | on | Event, callback | | Registers listener for Event. Invokes callback until unregistered | | off | Event | | Unregisters listener | | getDevices | | Promise<Device> | Gets connected devices | | getDeviceCount | | Promise<Number> | Gets number of connected devices | | getDevice | deviceId | Promise<Device> | Gets connected device by id |

Events

Device Attach/Detach Events

  • DEVICE_ATTACHED
  • DEVICE_DETACHED
  • INPUT_DEVICE_ATTACHED
  • INPUT_DEVICE_DETACHED
  • OUTPUT_DEVICE_ATTACHED
  • OUTPUT_DEVICE_DETACHED

All of these attach/detach events invoke the callback with the following Device object:

{
  id, // Id matches the 'device' property of midi events
  protocol,
  subclass,
  name,
  productId,
  vendorId,
  interfaces,
  configurations, // >= Android "Lollipop"
  serialNumber, // >= Android "Lollipop"
  version, // >= Android "M"
  deviceAddress, // I/O device only
  manufacturerName, // I/O device only
  productName // I/O device only
}
Example
Midi.on(Midi.INPUT_DEVICE_ATTACHED, device => {
  console.log(`Device "${device.name}" by ${device.vendorId} has attached`);
});

Midi Events

All midi event listeners invoke the callback with an object containing a device (int) and cable (int) property, in addition to those properties listed below:

  • MISC_FUNCTION_CODES
    • codes (byte[])
  • CABLE_EVENTS
    • events (byte[])
  • SYSTEM_COMMON_MESSAGE
    • message (string)
  • SYSTEM_EXCLUSIVE
    • message (string)
  • NOTE_ON
    • channel (int)
    • note (int)
    • velocity (int)
  • NOTE_OFF
    • channel (int)
    • note (int)
    • velocity (int)
  • POLYPHONIC_AFTERTOUCH
    • channel (int)
    • note (int)
    • pressure (int)
  • CONTROL_CHANGE
    • channel (int)
    • function (int)
    • value (int)
  • PROGRAM_CHANGE
    • channel (int)
    • program (int)
  • CHANNEL_AFTERTOUCH
    • channel (int)
    • pressure (int)
  • PITCH_WHEEL
    • channel (int)
    • amount (int)
  • SINGLE_BYTE
    • byte (byte)
  • TIME_CODE_QUARTER_FRAME
    • timing (int)
  • SONG_SELECT
    • song (int)
  • SONG_POSITION_POINTER
    • position (int)
  • TUNE_REQUEST
  • TIMING_CLOCK
  • START
  • CONTINUE
  • STOP
  • ACTIVE_SENSING
  • RESET
Example
Midi.on(Midi.NOTE_ON, event => {
  console.log(`Device "${event.device}" started note: ${event.note}`);
});

Contributing

Open to pull requests! I'm looking for someone to take on the iOS support in particular as I'm lacking devices to develop on.

TODO

  • iOS support
  • Bluetooth support
  • ~~Document event bodies~~