No description, website, or topics provided.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.babelrc
.eslintrc
.gitignore
.travis.yml
README.md
package.json

README.md

web-midi-emitter

Build Status NPM Version License

easy Web MIDI message handler

Installation

npm install --save web-midi-emitter

API

WebMIDIEmitter

  • constructor(access, deviceNameMatcher)
    • access: MIDIAccess
    • deviceNameMatcher: string or RegExp

Instance methods

  • send(data: number[], [ timestamp: number ]): void
    • send midi data to the midi device
  • clear(): void

Events

  • statechange
    • emitted when change the state of the midi device
  • midimessage
    • emitted when receive midi data from the midi device

How to use

const WebMIDIEmitter = require("web-midi-emitter");

window.navigator.requestMIDIAccess().then((access) => {
  const device = new WebMIDIEmitter(access, "Launch Control");

  device.on("statechange", (e) => {
    console.log(e);
  });

  device.on("midimessage", (e) => {
    console.log(e.data);
  });

  device.send([ 0x90, 0x64, 0x7f ]);
});

License

MIT