Skip to content

Instantly share code, notes, and snippets.

@marcduiker
Last active May 25, 2023 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcduiker/77bd668314b500f3dcabe758a7973135 to your computer and use it in GitHub Desktop.
Save marcduiker/77bd668314b500f3dcabe758a7973135 to your computer and use it in GitHub Desktop.
WebMidi API
<!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