-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmidi.js
24 lines (19 loc) · 796 Bytes
/
midi.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var midi = null; // global MIDIAccess object
function midiInit(onMIDISuccess,onMIDIFailure) {
navigator.requestMIDIAccess().then( onMIDISuccess, onMIDIFailure );
}
function listInputsAndOutputs( midiAccess ) {
for (var input in midiAccess.inputs) {
console.log( "Input port [type:'" + input.type + "'] id:'" + input.id +
"' manufacturer:'" + input.manufacturer + "' name:'" + input.name +
"' version:'" + input.version + "'" );
}
for (var output in midiAccess.outputs) {
console.log( "Output port [type:'" + output.type + "'] id:'" + output.id +
"' manufacturer:'" + output.manufacturer + "' name:'" + output.name +
"' version:'" + output.version + "'" );
}
}
function listenForMIDI( midiAccess, input, handler ) {
input.onmidimessage = handler;
}