forked from iBundin/Open-Web-Piano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
92 lines (85 loc) · 2.33 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
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
<style type="text/css">
body {
width: 100%;
height: 100%;
margin: 3% 0;
font-family: "Open Sans";
font-size: 18px;
font-style: normal;
font-variant: normal;
font-weight: bold;
line-height: 30.6px;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */
}
h1 {
font-family: "Open Sans";
font-size: 64px;
font-style: normal;
font-variant: normal;
font-weight: bold;
line-height: 30.6px;
text-align: center;
margin-bottom: 10%;
cursor: pointer;
}
select {
font-family: "Open Sans";
font-size: 16px;
font-style: normal;
font-variant: normal;
line-height: 30.6px;
}
.content {
margin: 0 auto;
display: flex;
flex-direction: column;
justify-content: center;
width: 200px;
height: 200px;
}
</style>
</head>
<body>
<h1>Open Web Piano</h1>
<div class="content">
<label>Select MIDI input</label>
<select id="midiIn">
<option value="">No Devices Detected</option>
<option value="">Can't detect your MIDI device? Try restarting your browser.</option>
</select>
<br>
<label style="display: none;">Select MIDI output</label>
<select id="midiOut" style="display: none;">
<option value="">No Devices Detected</option>
<option value="">Can't detect your MIDI device? Try restarting your browser.</option>
</select>
</div>
<script type="module">
import * as owp from './OpenWebPiano.js';
let initialized = false;
async function clickBody(event) {
if (!initialized) {
initialized = true;
await owp.init(new AudioContext());
}
var newNoteNum = 27 + (88 * event.clientX) / window.innerWidth;
var velocity = (1 - event.clientY / window.innerHeight) * 127;
console.log(velocity);
owp.noteOn(newNoteNum, velocity);
}
document.addEventListener("click", clickBody);
</script>
<script src="midi.js"></script>
</body>
</html>