-
Notifications
You must be signed in to change notification settings - Fork 30
/
index.html
424 lines (424 loc) · 22.5 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
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
<html lang="en">
<head>
<title>Hum2Song</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<link id="favicon" rel="icon" href="assets/images/favicon.ico" type="image/x-icon">
<script src='assets/libs/midijs/midi.js'></script>
<script src='assets/libs/jquery@3.3.1/jquery.js'></script>
<script src='assets/libs/lodash@4.17.4/lodash.min.js'></script>
<script src='assets/libs/webmidi@2.0.0/webmidi.min.js'></script>
<script src="assets/libs/midiconvert@0.4.7/MidiConvert.js"></script>
<script src='assets/libs/tonejs/Tone.js'></script>
<script src="assets/libs/@magenta/music@1.2.3"></script>
<script src='assets/libs/tonal/dist/tonal.min.js'></script>
<script src="assets/libs/FileSaver@1.3.8/FileSaver.min.js" defer></script>
<script src='assets/libs/synthjs/synth.js'></script>
<script src="./index.js" defer></script>
<link rel="stylesheet" href="./index.css">
</head>
<body class="colorScheme1">
<div id="mainContainer">
<div id="topbar">
<div id="topleft">
<object type="image/svg+xml" data="assets/images/logo.svg" class="logo" height="42"></object>
</div>
<div id="topcenter">
<div id="levels">
<button id="btnSimpleMode" class="button player active" onclick="setActiveLevel(event, false)" id="pianoBtn">Simple</button>
<button id="btnAdvanceMode" class="button player" onclick="setActiveLevel(event, true)">Advanced</button>
</div>
</div>
</div>
<div id="workspace">
<div id="modelLoading">
<span>Loading ...</span>
</div>
<div id="simple">
<div class="box">
<div class="top">
<h1>SIMPLE MODE</h1>
</div>
<div class="middle">
<center>
<hr>
<div class="section">
INSTRUCTIONS
</div>
<hr>
<br>
<div class="instructions">
<b>Hum2Song!</b> is an <b>AI-powered</b> web application that is able to <b>compose</b> the musical <b>accompaniment</b> of a <b>melody</b> produced by a human <b>voice</b>. Once the site has loaded, you only need to <b>click</b> on the "<b>Record Audio</b>" button, start <b>humming</b>/singing (<b>from 2 to 8 seconds</b>) and click on the "<b>Stop</b>" button to start the <b>conversion</b> process. <b>Google Chrome</b> in a desktop browser is recommended.
<br><br>
This is a <b>client-side</b> only application, this means that all the <b>files</b> are stored <b>locally</b> and the <b>processing</b> happens in your <b>browser</b>. The <b>first time</b> you load this website, it <b>downloads ~100Mb</b> in models and sounds, that <b>takes in average ~1 minute</b> depending on your internet connection. <b>Please be patient</b>.
<br><br>
</div>
<hr>
<div class="section">
INPUT
</div>
<hr>
<button class="button" id="btnRecordSimple" disabled>
<span class="text">Record audio</span>
<span class="loading">Processing...</span>
</button>
</center>
</div>
<div id="modelReadySimple" hidden>
<div class="middle">
<center>
<div id="songOptions" hidden>
<hr>
<div class="section">
OUTPUT
</div>
<hr>
<div class="playIcon" id="playIconSimple">
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24">
<path xmlns="http://www.w3.org/2000/svg" d="M8 5v14l11-7z"/>
<path xmlns="http://www.w3.org/2000/svg" d="M0 0h24v24H0z" fill="none"/>
</svg>
</div>
<div class="stopIcon" id="stopIconSimple">
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24">
<path xmlns="http://www.w3.org/2000/svg" d="M0 0h24v24H0z" fill="none"/>
<path xmlns="http://www.w3.org/2000/svg" d="M6 6h12v12H6z"/>
</svg>
</div>
<button class="button" id="btnSaveScore">Download</button>
<!--
<button class="button" id="btnSaveSong">Download Song</button>
-->
<button class="button" id="btnLoadSimple">Edit</button>
<hr>
<br>
We appreciate your feedback, you can find the contact information <a target="_blank" href="http://www.carlostoxtli.com/#hum2song">here</a>.
<br>
</div>
</center>
</div>
</div>
<div class="bottom">
<center>
<div class="bottomSection">
<div class="theme" id="theme_0"></div><div class="theme" id="theme_1"></div><div class="theme" id="theme_2"></div><div class="theme" id="theme_3"></div><div class="theme" id="theme_4"></div><div class="theme" id="theme_5"></div>
</div>
<div class="bottomSection">
This work was based and inspired on <a target="_blank" href="https://magenta.tensorflow.org/oaf-js">piano-scribe</a>
<br>
Made with <a target="_blank" href="http://js.tensorflow.org" class="img-link"><img src="assets/images/tensorflow.png" height="35" class="aligned"></a> <b>Tensorflow.js</b> and <a target="_blank" href="http://magenta.tensorflow.org/js" class="img-link">
<img src="assets/images/magenta.png" height="42" class="aligned"></a> <b>Magenta.js</b> .
See the code on <a target="_blank" href="https://github.com/toxtli/hum2song">GitHub</a>. <a target="_blank" href="http://www.carlostoxtli.com/#hum2song">Contact us</a>.
</div>
</center>
</div>
</div>
</div>
<div id="advance">
<div class="box">
<div class="top">
<h1>ADVANCED MODE</h1>
</div>
<div class="middle">
<center>
<hr>
<div class="section">
INSTRUCTIONS
</div>
<hr>
<br>
<div class="instructions">
<b>Hum2Song!</b> is an <b>AI-powered</b> web application that is able to <b>compose</b> the musical <b>accompaniment</b> of a <b>melody</b> produced by a human <b>voice</b>. Once the site has loaded, you only need to <b>click</b> on the "<b>Record Audio</b>" button, start <b>humming</b>/singing (<b>from 2 to 8 seconds</b>) and click on the "<b>Stop</b>" button to start the <b>conversion</b> process. <b>Google Chrome</b> in a desktop browser is recommended.
<br><br>
This is a <b>client-side</b> only application, this means that all the <b>files</b> are stored <b>locally</b> and the <b>processing</b> happens in your <b>browser</b>. The <b>first time</b> you load this website, it <b>downloads ~100Mb</b> in models and sounds, that <b>takes in average ~1 minute</b> depending on your internet connection. <b>Please be patient</b>.
<br><br>
</div>
<hr>
<div class="section">
INPUT
</div>
<hr>
<div id="buttons">
<button class="button" id="btnRecord" disabled>
<span class="text">Record audio</span>
<span class="loading">Processing...</span>
</button>
<span>or</span>
<label class="button" id="btnUpload" disabled>
<span class="text">Upload file<input type="file" id="fileInput"></span>
<span class="loading">Processing...</span>
</label>
<span>or</span>
<button class="button" id="startStreamBtn" disabled>
<span class="text">MIDI keyboard</span>
<span class="loading">Processing...</span>
</button>
</div>
</center>
</div>
<div id="modelReady" hidden>
<div class="middle">
<center>
<div id="songOptionsAdvanced" hidden>
<div id="newContent">
<hr>
<div class="section">
OUTPUT
</div>
<hr>
<div class="playIcon" id="playIconAdvanced">
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24">
<path xmlns="http://www.w3.org/2000/svg" d="M8 5v14l11-7z"/>
<path xmlns="http://www.w3.org/2000/svg" d="M0 0h24v24H0z" fill="none"/>
</svg>
</div>
<div class="stopIcon" id="stopIconAdvanced">
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24">
<path xmlns="http://www.w3.org/2000/svg" d="M0 0h24v24H0z" fill="none"/>
<path xmlns="http://www.w3.org/2000/svg" d="M6 6h12v12H6z"/>
</svg>
</div>
<button class="button" id="btnSave">Download</button>
<!--
<button class="button" id="btnSaveSongAdvanced">Download Song</button>
-->
<button class="button" id="btnLoad">Edit</button>
<hr>
<div class="section">
STEP BY STEP
</div>
<div id="step0">
<hr>
<span class="instructions">
Step 0.- We store locally the recorded sound.
</span>
<br>
<br>
<audio id="audioControl" controls></audio>
<br>
</div>
<hr>
<span class="instructions">
Step 1.- The audio is transcribed to notes by using a RNN model. You can find more information about this model <a target="_blank" href="https://magenta.tensorflow.org/oaf-js">here</a>.
</span>
<br>
<br>
<div class="playCanvas" id="play_0"></div>
<div class="downloadCanvas" id="download_0"></div>
<div class="editCanvas" id="edit_0"></div>
<div class="container" id="container_0">
<canvas id="canvas0"></canvas>
</div>
<hr>
<span class="instructions">
Step 2.- The notes are normalized, cleaned and adjusted to 4/4
</span>
<br>
<br>
<div class="playCanvas" id="play_1"></div>
<div class="downloadCanvas" id="download_1"></div>
<div class="editCanvas" id="edit_1"></div>
<div class="container" id="container_1">
<canvas id="canvas1"></canvas>
</div>
<hr>
<span class="instructions">
Step 3.- Now we use a DNN model to predict the most likely genre from the melody. You can find more information about this model <a target="_blank" href="https://medium.com/@carlostoxtli/7a777445550b">here</a>.
</span>
<span class="results">
<h4>The predicted genre is:</h4>
<h1><span id="refGenre">GENRE</span></h1>
The scores are:
<br>
<h3 class="inline">ROCK: <span id="refRock">0.0</span></h3>
<h3 class="inline">DANCE: <span id="refDance">0.0</span></h3>
<h3 class="inline">JAZZ: <span id="refJazz">0.0</span></h3>
</span>
<hr>
<span class="instructions">
Step 4.- The melody is adapted to an instrument that is typically used in the predicted genre.
</span>
<br>
<br>
<div class="playCanvas" id="play_2"></div>
<div class="downloadCanvas" id="download_2"></div>
<div class="editCanvas" id="edit_2"></div>
<div class="container" id="container_2">
<canvas id="canvas2"></canvas>
</div>
<hr>
<span class="instructions">
Step 5.- A temporal drum is generated.
</span>
<br>
<br>
<div class="playCanvas" id="play_3"></div>
<div class="downloadCanvas" id="download_3"></div>
<div class="editCanvas" id="edit_3"></div>
<div class="container" id="container_3">
<canvas id="canvas3"></canvas>
</div>
<hr>
<span class="instructions">
Step 6.- A temporal bass is generated by expanding and joining the transcribed melody.
</span>
<br>
<br>
<div class="playCanvas" id="play_4"></div>
<div class="downloadCanvas" id="download_4"></div>
<div class="editCanvas" id="edit_4"></div>
<div class="container" id="container_4">
<canvas id="canvas4"></canvas>
</div>
<hr>
<span class="instructions">
Step 7.- We need to form a trio that is the combinaton of MELODY + BASS + DRUMS. This is needed to predict a sequence. This is the current trio.
</span>
<br>
<br>
<div class="playCanvas" id="play_5"></div>
<div class="downloadCanvas" id="download_5"></div>
<div class="editCanvas" id="edit_5"></div>
<div class="container" id="container_5">
<canvas id="canvas5"></canvas>
</div>
<hr>
<span class="instructions">
Step 8.- We use a RNN model that generates a trio that is the progression of the current trio. You can find more information about this model <a target="_blank" href="https://magenta.tensorflow.org/js-announce">here</a>.
</span>
<br>
<br>
<div class="playCanvas" id="play_6"></div>
<div class="downloadCanvas" id="download_6"></div>
<div class="editCanvas" id="edit_6"></div>
<div class="container" id="container_6">
<canvas id="canvas6"></canvas>
</div>
<hr>
<span class="instructions">
Step 9.- We use the original melody, the generated bass and the random drum to generate a base trio.
</span>
<br>
<br>
<div class="playCanvas" id="play_7"></div>
<div class="downloadCanvas" id="download_7"></div>
<div class="editCanvas" id="edit_7"></div>
<div class="container" id="container_7">
<canvas id="canvas7"></canvas>
</div>
<hr>
<span class="instructions">
Step 10.- Now we define the harmony, the first step is to calculate the musical scale from the melody.
</span>
<span class="results">
<h4>The tonal scale that fits better is:</h4>
<h1><span id="refScale">A</span></h1>
</span>
<hr>
<span class="instructions">
Step 11.- From that scale we choose a chord progression that fits better to the melody.
</span>
<span class="results">
<h4>The chord progression that fits better is:</h4>
<h1><span id="refChord">A, A, A, A</span></h1>
</span>
<hr>
<span class="instructions">
Step 12.- Now we use a RNN model that is able to generate an accompaniment for our main trio, adapted to the chord progression. You can find more information about this model <a target="_blank" href="https://magenta.tensorflow.org/multitrack">here</a>.
</span>
<br>
<br>
<div class="playCanvas" id="play_8"></div>
<div class="downloadCanvas" id="download_8"></div>
<div class="editCanvas" id="edit_8"></div>
<div class="container" id="container_8">
<canvas id="canvas8"></canvas>
</div>
<hr>
<span class="instructions">
Step 13.- We also generate random accompaniment that fits to the chosen chord progression.
</span>
<br>
<br>
<div class="playCanvas" id="play_9"></div>
<div class="downloadCanvas" id="download_9"></div>
<div class="editCanvas" id="edit_9"></div>
<div class="container" id="container_9">
<canvas id="canvas9"></canvas>
</div>
<hr>
<span class="instructions">
Step 14.- Finally, we create an interpolation of 6 steps between the chords adapted trio and random sequence. We use a RNN model that can be found <a target="_blank" href="https://magenta.tensorflow.org/multitrack">here</a>.
</span>
<br>
<br>
<div class="playCanvas" id="play_10"></div>
<div class="downloadCanvas" id="download_10"></div>
<div class="editCanvas" id="edit_10"></div>
<div class="container" id="container_10">
<canvas id="canvas10"></canvas>
</div>
<hr>
<br>
We appreciate your feedback, you can find the contact information <a target="_blank" href="http://www.carlostoxtli.com/#hum2song">here</a>.
<br>
</div>
</div>
</center>
</div>
</div>
<div class="bottom">
<center>
<div class="bottomSection">
<br>
<div class="theme" id="theme_0"></div><div class="theme" id="theme_1"></div><div class="theme" id="theme_2"></div><div class="theme" id="theme_3"></div><div class="theme" id="theme_4"></div><div class="theme" id="theme_5"></div>
</div>
<div class="bottomSection">
This work was based and inspired on <a target="_blank" href="https://magenta.tensorflow.org/oaf-js">piano-scribe</a>
<br>
Made with <a target="_blank" href="http://js.tensorflow.org" class="img-link"><img src="assets/images/tensorflow.png" height="35" class="aligned"></a> <b>Tensorflow.js</b> and <a target="_blank" href="http://magenta.tensorflow.org/js" class="img-link">
<img src="assets/images/magenta.png" height="42" class="aligned"></a> <b>Magenta.js</b> .
See the code on <a target="_blank" href="https://github.com/toxtli/hum2song">GitHub</a>. <a target="_blank" href="http://www.carlostoxtli.com/#hum2song">Contact us</a>.
</div>
</center>
</div>
</div>
</div>
</div>
</div>
<!-- Google Analytics -->
<script>
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-90861913-1', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
<!-- Default Statcounter code for Carlos Toxtli Website
http://www.carlostoxtli.com -->
<script type="text/javascript">
var sc_project=11706293;
var sc_invisible=1;
var sc_security="d809fc4a";
</script>
<script type="text/javascript"
src="https://www.statcounter.com/counter/counter.js"
async></script>
<noscript><div class="statcounter"><a title="web statistics"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="//c.statcounter.com/11706293/0/d809fc4a/1/" alt="web
statistics"></a></div></noscript>
<!-- End of Statcounter Code -->
</body>
</html>