Last active
May 25, 2023 21:53
-
-
Save marcduiker/77bd668314b500f3dcabe758a7973135 to your computer and use it in GitHub Desktop.
WebMidi API
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>onmidimessage</title> | |
<script type="module"> | |
navigator.requestMIDIAccess().then((midiAccess) => { | |
Array.from(midiAccess.inputs).forEach((input) => { | |
input[1].onmidimessage = (msg) => { | |
console.log(msg); | |
document.getElementById("midi").innerHTML += `${msg.data[0]}-${msg.data[1]}-${msg.data[2]}<br>`; | |
}; | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>WebMidiAPI</h1> | |
<p>Check the console for the full messages.</p> | |
<div id="midi"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment