Skip to content

Instantly share code, notes, and snippets.

@NHQ NHQ/index.js Secret
Created Mar 9, 2015

Embed
What would you like to do?
web midi, if it ever works
midi = null
port = null
getMidi(function(e, m){
midi = m
console.log(midi)
var iter = midi.inputs.values()
port = iter.next()
console.log(port)
port.value.onmidimessage = function(e,d){
console.log(e, d)
}
})
function getMidi(cb){
if (midi){
process.nextTick(function(){
cb(null, midi)
})
} else if (window.navigator.requestMIDIAccess) {
window.navigator.requestMIDIAccess().then(function(res){
midi = res
cb(null, midi)
}, cb)
} else {
process.nextTick(function(){
cb('Web MIDI API not available')
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.