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