Skip to content

Instantly share code, notes, and snippets.

@brett-miller
Created September 19, 2016 00:23
Show Gist options
  • Save brett-miller/e2ad48f36855d1fda89154dbc834c345 to your computer and use it in GitHub Desktop.
Save brett-miller/e2ad48f36855d1fda89154dbc834c345 to your computer and use it in GitHub Desktop.
Chrome MIDI API
navigator.requestMIDIAccess().then(
onMIDIInit,
onMIDISystemError );
var count = 0;
var data = [];
function logIt(it){
if (count < 100 && it.data.length > 1) {
console.log(it.data);
count++;
}
}
function onMIDIInit( midi ) {
for (midiInput of midi.inputs.values()){
midiInput.log(it)
midiInput.onmidimessage = logIt;
}
}
function onMIDISystemError( error ) {
console.log(error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment