midi-listener
v0.2.0
Published
Listen for and interpret MIDI device input
Downloads
2
Readme
MIDI LISTENER
This project is early WIP pre-release code. Open to suggestions or comments, please submit an issue!
Listen for and interpret MIDI device input.
- Simply listens to all connected MIDI devices simultaneously
- Written in TypeScript
- Inspired by the stack overflow post
- Published as an npm package
- Usage example: the CSM repository
Basic usage with your TypeScript project:
Install midi-listener:
npm install --save midi-listener
Reference the Web MIDI API declarations:
/// <reference path="../node_modules/midi-listener/source/web-midi.d.ts"/>
Import into your code and use
import MidiListener from "midi-listener"
(async () => {
// Create the midi listener.
const midiListener = new MidiListener({
access: await navigator.requestMIDIAccess()
})
// Subscribe to the midi listener's events with callbacks.
midiListener.subscribe({
onInputChange: report => console.log("MIDI Input Change:", report.inputNames),
onMessage: report => console.log("MIDI Message:", report),
onNote: report => console.log(" - Note:", report),
onPad: report => console.log(" - Pad:", report),
onPitchBend: report => console.log(" - Pitch bend:", report),
onModWheel: report => console.log(" - Mod wheel:", report)
})
})()