0.4.0 • Published 8 years ago

web-midi-emitter v0.4.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

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