Listen for and interpret MIDI device input
Switch branches/tags
Clone or download
Permalink
Failed to load latest commit information.
.vscode Initial commit! Dec 3, 2016
source Refactor listener for multiple consumers Jan 12, 2017
.gitignore Initial commit! Dec 3, 2016
.npmignore Initial commit! Dec 3, 2016
changelog.md
license Initial commit! Dec 3, 2016
package.json Refactor listener for multiple consumers Jan 12, 2017
readme.md Refactor listener for multiple consumers Jan 12, 2017
tsconfig.json Refactor listener for multiple consumers Jan 12, 2017

readme.md

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.

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)
  })
})()