Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
test of webmidi
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