-
Notifications
You must be signed in to change notification settings - Fork 0
/
theremin.html
272 lines (259 loc) · 12.6 KB
/
theremin.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Handmate MIDI</title>
<link rel="stylesheet" type="text/css" href="appstyle.css">
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]/camera_utils.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]/control_utils.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]/drawing_utils.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]/hands.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/webmidi@next/dist/iife/webmidi.iife.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tone/14.8.31/Tone.js"></script>
</head>
<body>
<div class="container">
<video class="input_video"></video>
<div class="canvas-container">
<canvas class="output_canvas" width="1280px" height="720px"></canvas>
</div>
</div>
<div class="view">
<button onclick="toggleControl()" id="controlButton">Hide controls</button>
</div>
<div class="control-panel">
<br><br>
Selfie view<input id="selfie" type="checkbox" checked="checked">
Show tracking <input id="showTracking" type="checkbox" checked="checked">
Fps <span id="fps"></span>
<hr>
<div class="select">
<label for="videoSource">Camera </label><select id="videoSource"></select>
</div>
<div id="dropdown">
MIDI out device
<select id="device" onchange="changeDevice()">
</select>
</div>
<hr>
<!--Automate bpm<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">Control bpm with movement, range between 20 - 500</span>
</div>
<input id="autoBpm" type="checkbox">
<label class="label"
for="bpmControlInput"></label>
<select name="bpmControlInput" id="bpmControlInput">
<option value="leftIndexX">Left index x</option>
<option value="leftIndexY">Left index y</option>
<option value="leftClosed">Left hand closed</option>
<option value="rightIndexX" selected>Right index x</option>
<option value="rightIndexY">Right index y</option>
<option value="rightClosed">Right hand closed</option>
<option value="indexDistance">Index distance</option>
</select><br>-->
<b>Send midi notes<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">Check box to send continous stream of midi notes</span>
</div></b><input id="sendMidi" type="checkbox"><br>
BPM<input type="range" id="bpm" name="bpm" min="20" max="500" step="1" value="120">
<label for="bpm"></label>
<span id="bpmValue" class="rangeValue">120</span><br>
<label for="channel">Channel:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">1-16 channels</span>
</div>
</label>
<input type="number" id="midiChannel" min="1" max="16" value="1"/><br>
Note pitch<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">Control note pitch with movement. If none selected, note will not be generated</span>
</div>
<label class="label"
for="midiControlInput"></label>
<select name="midiControlInput" id="midiControlInput">
<option value="nil" selected>----</option>
<option value="leftIndexX">Left index x</option>
<option value="leftIndexY">Left index y</option>
<option value="leftClosed">Left hand closed</option>
<option value="rightIndexX">Right index x</option>
<option value="rightIndexY">Right index y</option>
<option value="rightClosed">Right hand closed</option>
<option value="indexDistance">Index distance</option>
</select><br>
Note velocity<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">Control note velocity with movement. If none selected, note velocity is maximum</span>
</div>
<label class="label"
for="midiVelInput"></label>
<select name="midiVelInput" id="midiVelInput">
<option value="nil" selected>----</option>
<option value="leftIndexX">Left index x</option>
<option value="leftIndexY">Left index y</option>
<option value="leftClosed">Left hand closed</option>
<option value="rightIndexX">Right index x</option>
<option value="rightIndexY">Right index y</option>
<option value="rightClosed">Right hand closed</option>
<option value="indexDistance">Index distance</option>
</select><br>
<hr>
<b>Continous controls<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">Send midi CC</span>
</div></b><br>
Pitchbend
<label class="label"
for="pitchBendInput"></label>
<select name="pitchBendInput" id="pitchBendInput">
<option value="nil" selected>----</option>
<option value="leftIndexX">Left index x</option>
<option value="leftIndexY">Left index y</option>
<option value="leftClosed">Left hand closed</option>
<option value="rightIndexX">Right index x</option>
<option value="rightIndexY">Right index y</option>
<option value="rightClosed">Right hand closed</option>
<option value="indexDistance">Index distance</option>
</select><br>
Aftertouch
<label class="label"
for="aftertouchInput"></label>
<select name="aftertouchInput" id="aftertouchInput">
<option value="nil" selected>----</option>
<option value="leftIndexX">Left index x</option>
<option value="leftIndexY">Left index y</option>
<option value="leftClosed">Left hand closed</option>
<option value="rightIndexX">Right index x</option>
<option value="rightIndexY">Right index y</option>
<option value="rightClosed">Right hand closed</option>
<option value="indexDistance">Index distance</option>
</select><br>
<label for="cc1Channel">Chan:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">1-16 channels</span>
</div>
</label>
<input type="number" id="cc1Channel" min="1" max="16" value="1"/>
<label for="cc1Controller">CC:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">0-127</span>
</div>
</label>
<input type="number" id="cc1Controller" min="0" max="127" value="1"/>
<label class="label"
for="cc1Input"></label>
<select name="cc1Input" id="cc1Input">
<option value="nil" selected>----</option>
<option value="leftIndexX">Left index x</option>
<option value="leftIndexY">Left index y</option>
<option value="leftClosed">Left hand closed</option>
<option value="rightIndexX">Right index x</option>
<option value="rightIndexY">Right index y</option>
<option value="rightClosed">Right hand closed</option>
<option value="indexDistance">Index distance</option>
</select><br>
<label for="cc2Channel">Chan:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">1-16 channels</span>
</div>
</label>
<input type="number" id="cc2Channel" min="1" max="16" value="2"/>
<label for="cc2Controller">CC:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">0-127</span>
</div>
</label>
<input type="number" id="cc2Controller" min="0" max="127" value="2"/>
<label class="label"
for="cc2Input"></label>
<select name="cc2Input" id="cc2Input">
<option value="nil" selected>----</option>
<option value="leftIndexX">Left index x</option>
<option value="leftIndexY">Left index y</option>
<option value="leftClosed">Left hand closed</option>
<option value="rightIndexX">Right index x</option>
<option value="rightIndexY">Right index y</option>
<option value="rightClosed">Right hand closed</option>
<option value="indexDistance">Index distance</option>
</select><br>
<label for="cc3Channel">Chan:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">1-16 channels</span>
</div>
</label>
<input type="number" id="cc3Channel" min="1" max="16" value="3"/>
<label for="cc3Controller">CC:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">0-127</span>
</div>
</label>
<input type="number" id="cc3Controller" min="0" max="127" value="3"/>
<label class="label"
for="cc3Input"></label>
<select name="cc3Input" id="cc3Input">
<option value="nil" selected>----</option>
<option value="leftIndexX">Left index x</option>
<option value="leftIndexY">Left index y</option>
<option value="leftClosed">Left hand closed</option>
<option value="rightIndexX">Right index x</option>
<option value="rightIndexY">Right index y</option>
<option value="rightClosed">Right hand closed</option>
<option value="indexDistance">Index distance</option>
</select><br>
<label for="cc4Channel">Chan:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">1-16 channels</span>
</div>
</label>
<input type="number" id="cc4Channel" min="1" max="16" value="4"/>
<label for="cc4Controller">CC:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">0-127</span>
</div>
</label>
<input type="number" id="cc4Controller" min="0" max="127" value="4"/>
<label class="label"
for="cc4Input"></label>
<select name="cc4Input" id="cc4Input">
<option value="nil" selected>----</option>
<option value="leftIndexX">Left index x</option>
<option value="leftIndexY">Left index y</option>
<option value="leftClosed">Left hand closed</option>
<option value="rightIndexX">Right index x</option>
<option value="rightIndexY">Right index y</option>
<option value="rightClosed">Right hand closed</option>
<option value="indexDistance">Index distance</option>
</select><br>
<hr>
<b>Gesture Recognition<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">Check box to start gesture recognition to trigger Midi notes</span>
</div></b><input id="gesture" type="checkbox"><br>
<label for="channel">Channel:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">1-16 channels</span>
</div>
</label>
<input type="number" id="trigger1Channel" min="1" max="16" />
<label for="midi1NoteInput">Midi note:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">0-127</span>
</div>
</label>
<input type="number" id="midi1NoteInput" min="0" max="127" value="60"/>
<span style='font-size: 25px;'>👉👈</span><div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">index fingers touching</span>
</div><br>
<label for="channel">Channel:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">1-16 channels</span>
</div>
</label>
<input type="number" id="trigger2Channel" min="1" max="16" />
<label for="midi2NoteInput">Midi note:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">0-127</span>
</div>
</label>
<input type="number" id="midi2NoteInput" min="0" max="127" value="60"/>
<span class="flipH">✋</span><div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">back of left hand facing screen</span>
</div><br>
<label for="channel">Channel:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">1-16 channels</span>
</div>
</label>
<input type="number" id="trigger3Channel" min="1" max="16" />
<label for="midi3NoteInput">Midi note:<div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">0-127</span>
</div>
</label>
<input type="number" id="midi3NoteInput" min="0" max="127" value="60"/>
<span style='font-size: 25px;'>✋</span><div class="tooltip circle"><sup><i>i</i></sup>
<span class="tooltiptext">back of right hand facing screen</span>
</div><br>
</div>
<script type="text/javascript" src="script.js"></script>
</body>
</html>