-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
37 lines (29 loc) · 884 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>WebMidi.js Quick Start</title>
<script src="https://cdn.jsdelivr.net/npm/webmidi@latest/dist/iife/webmidi.iife.js"></script>
</head>
<body>
<h1>WebMidi.js Quick Start</h1>
</body>
<script type="module">
// Enable WEBMIDI.js and trigger the onEnabled() function when ready
WebMidi
.enable()
.then(onEnabled)
.catch(err => alert(err));
// Function triggered when WEBMIDI.js is ready
function onEnabled() {
// Display available MIDI input devices
if (WebMidi.inputs.length < 1) {
document.body.innerHTML += "No device detected.";
} else {
WebMidi.inputs.forEach((device, index) => {
document.body.innerHTML += `${index}: ${device.name} <br>`;
});
}
}
</script>
</html>