Last active
May 7, 2020 20:21
-
-
Save jschloer/b365453eb3b2a27b6a122537cc81cebc to your computer and use it in GitHub Desktop.
Quick midi access
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
navigator.requestMIDIAccess().then( | |
(midiAccess) => { | |
for(var input of midiAccess.inputs.values()){ | |
input.onmidimessage = (msg) => { | |
// weed out the timing messages | |
if (msg.data.length > 0 && msg.data[0] !== 248){ | |
console.log(msg) | |
} | |
} | |
// real quick, send a midi message | |
let message = [0x9f,0x0c,0x7f] | |
midiAccess.outputs.forEach(output => { | |
console.log(output); | |
}) | |
console.log('sending extended mode message') | |
midiAccess.outputs.get("1665052422").send(message) | |
message = [0xBF, 0x03, 0x02] | |
console.log('sending session mode message') | |
midiAccess.outputs.get("1665052422").send(message) | |
message = [0x92, 0x63, 0x48] | |
console.log('sending flash pad message') | |
midiAccess.outputs.get("1665052422").send(message) | |
console.log('well we sent it...') | |
} | |
}, | |
()=> {} | |
) |
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
navigator.requestMIDIAccess().then( | |
(midiAccess) => { | |
for(var input of midiAccess.inputs.values()){ | |
input.onmidimessage = (msg) => { | |
// weed out the timing messages | |
if (msg.data.length > 0 && msg.data[0] !== 248){ | |
console.log(msg) | |
} | |
} | |
} | |
}, | |
()=> {} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment