0.4.0 • Published 9 years ago
web-midi-emitter v0.4.0
web-midi-emitter
easy Web MIDI message handler
Installation
npm install --save web-midi-emitterAPI
WebMIDIEmitter
constructor(access, deviceNameMatcher)access: MIDIAccessdeviceNameMatcher: 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