Created
January 24, 2018 11:23
-
-
Save hugohil/e23445631daed60c33c02c074674321f to your computer and use it in GitHub Desktop.
test of webmidi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WebMidi = require('webmidi') | |
const name = 'LPD8 MIDI 1' | |
WebMidi.enable((err) => { | |
err && console.warn(err) | |
WebMidi.inputs.forEach((input) => { | |
console.info(`${input.manufacturer} '${input.name}' ${input.state}`) | |
}) | |
WebMidi.outputs.forEach((output) => { | |
console.info(`${output.manufacturer} '${output.name}' ${output.state}`) | |
}) | |
const input = WebMidi.getInputByName(name) | |
if (input) { | |
input.addListener('controlchange', 'all', (e) => { | |
console.log(e.data[1], e.data[2]) // channel, value | |
}) | |
input.addListener('noteon', 'all', (e) => { | |
console.log(e.data[1], e.data[2]) // channel, value | |
}) | |
} else { | |
console.warn(`no '${name}' input found`) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment