-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
93 lines (68 loc) · 2.08 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Music: Keyboard Practice</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/iife/webmidi.iife.js"></script>
<script type="module">
// Enable WebMidi.js and trigger the onEnabled() function when ready.
WebMidi
.enable()
.then(onEnabled)
.catch(err => alert(err));
function onEnabled() {
if (WebMidi.inputs.length < 1) {
document.getElementById("keyboard").text = "No device detected.";
} else {
WebMidi.inputs.forEach((device, index) => {
document.getElementById("keyboard").innerText = `${device.name}`;
});
}
const mySynth = WebMidi.inputs[0];
mySynth.channels[1].addListener("noteon", e => {
document.getElementById("key").innerText = e.note.identifier;
});
}
</script>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<div className="container">
<Head>
<title>Music: Keyboard Practice</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<div id="keyboard">
No device detected.
</div>
<main>
<div class="vexbox">
<div id="output">Placeholder</div>
</div>
<h1 id="key" className="title">
Press any key
</h1>
</main>
<!-- <footer>
<pre>test</pre>
</footer> -->
<!-- VexFlow -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/cjs/vexflow.js"></script>
<script>
const { Factory } = Vex.Flow;
// Create a VexFlow renderer attached to the DIV element with id="output".
const vf = new Factory({ renderer: { elementId: 'output' } });
const score = vf.EasyScore();
const system = vf.System();
// Create a 4/4 treble stave and add two parallel voices.
system.addStave({
voices: [
// Top voice has 4 quarter notes with stems up.
score.voice(score.notes('C#5/q, B4, A4, G#4', { stem: 'up' }))
]
}).addClef('treble').addTimeSignature('4/4');
// Draw it!
vf.draw();
</script>
</body>
</html>