-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
488 lines (467 loc) · 14.2 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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
<!DOCTYPE html>
<html>
<body>
<center>
<div id="case">
<h1>Virtual Note</h1>
<h3>Have you ever wondered how music is actually created? Have you ever wanted to create music, easily? Virtual Note is an online virtual staff and piano that allows you to create small bit of music at the tip of your fingertips. If you don't know how a staff and notes work in music check out an article I found down below, or if you just want a refresher. If you want to know how to use this site, check out the post. Alright then, happy composing! I can't wait to see what you make! If you like what you did screen shot your work and post it in the comments below for others to see!</h3>
</div>
<canvas id="myCanvas" width = 900 height=240></canvas>
</br>
<ul id="parent">
<select id="select-style">
<option value="e1">E</option>
<option value="f">F</option>
<option value="g">G</option>
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
<option value="d">D</option>
<option value="e2">E</option>
<option value="na">Rest</option>
</select>
<button id = "add" onclick="Note()">+♩</button>
<button style="font-size:35px" onclick="play()"> Play</button>
<button style="font-size:35px" onclick="del()">reset</button>
</ul>
<div class="slidecontainer">
<input type="range" min="1" max="100" value="50" class="slider" id="myRange">
<p>Volume: <span id="demo"></span></p>
</div>
</center>
<audio id="sound0">
<source src="sounds/doLow.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<audio id="sound1">
<source src="sounds/re.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<audio id="sound2">
<source src="sounds/mi.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<audio id="sound3">
<source src="sounds/fa.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<audio id="sound4">
<source src="sounds/so.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<audio id="sound5">
<source src="sounds/si.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<audio id="sound6">
<source src="sounds/la.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<audio id="sound7">
<source src="sounds/doHigh.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</br></br></br></br>
<h4>The following is an article from allaboutmusictheory.com - How The Staff Works</h4>
<p>
A normal staff has 5 horizontal parallel lines, spaced evenly, that run across the page. In between these 5 lines are 4 spaces. These spaces aren’t just useless, empty areas; they’re just as much an important part of the staff as the lines. So this is the basic working area we have when writing music. A note can be placed on either a line or a space on the staff.
</br></br>
A musical staff
Each line or space on the staff corresponds with a particular musical note. For instance, a particular line or space could represent the note C4, or A5, or E2, etc. (See Organizing Note Names for a refresher on how to name notes by their octave.)
</br></br>
Notes shown on lines and spaces of the staff
Up and Down
The vertical “dimension” of the staff (in other words, how high or low a note is placed) represents pitch:
</br></br>
The higher the line or space is on the staff, the higher the note it represents. The lower the line or space, the lower the note it represents. No tricks here.
</br></br>
The vertical dimension of the staff
Even more convenient, the lines and spaces go in order of the musical notes they represent. For example, let’s say a particular line represents the note C5 – the space directly above it would then represent the next note up, D5. The next line up from there would be E5. The space above that, F5. And so on. (And it works the same way going downward, each successive line or space represents the next-lowest letter name.)
</br></br>
The concept itself is really not too difficult. The hard part is memorizing which note corresponds to which line or space. But have no fear! Together, we’re going to take it step by step, until we reach our goal. All you have to do is stick with it, and you will learn how to read music.
</br></br>
The great thing about the musical staff is that with practice, we can (eventually) get to the point where we instantly recognize which notes we’re looking at. Great sight readers, like top-notch studio musicians, can see some sheet music for the very first time, and play it as if they’ve been playing it their whole lives (just like reading one’s native language).</p>
<style>
body{
background-color:indianred;
}
#case{
width: 800px;
}
canvas {
background-color: lightgoldenrodyellow;
}
button {
background-color: #4CAF50; /* Green */
border-color: #ccc;
border-radius: 12px;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 30px;
margin: 4px 2px;
cursor: pointer;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
}
button:hover{
background-color: darkgreen; /* Green */
}
#add {
background-color: gray; /* Green */
border-color: #ccc;
border-radius: 12px;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 30px;
margin: 4px 2px;
cursor: pointer;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
}
#add:hover{
background-color: lightgray; /* Green */
}
canvas{
border:5px solid black;
}
h1{
color:white;
font-family: Arial, Helvetica, sans-serif;
}
h3{
color:white;
font-family: Arial, Helvetica, sans-serif;
}
p{
color:white;
font-family: Arial, Helvetica, sans-serif;
}
h4{
color:white;
font-family: Arial, Helvetica, sans-serif;
}
#select-style {
border: 3px solid #ccc;
width: 120px;
height:70px;
border-radius: 3px;
overflow: hidden;
background: #fafafa;
font-size:30px;
}
#select-style select {
padding: 5px 8px;
width: 130%;
border: none;
box-shadow: none;
background: transparent;
background-image: none;
-webkit-appearance: none;
}
#select-style select:focus {
outline: none;
}
.slidecontainer {
width: 100%;
}
.slider {
-webkit-appearance: none;
width: 500px;
height: 15px;
border-radius: 5px;
background: #d3d3d3;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
}
.slider:hover {
opacity: 1;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 25px;
height: 25px;
border-radius: 50%;
background: #4CAF50;
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 25px;
height: 25px;
border-radius: 50%;
background: #4CAF50;
cursor: pointer;
}
</style>
<script>
var slider = document.getElementById("myRange");
var output = document.getElementById("demo");
output.innerHTML = slider.value;
slider.oninput = function() {
output.innerHTML = this.value;
a1 = document.getElementById("sound0")
a2 = document.getElementById("sound1")
a3 = document.getElementById("sound2")
a4 = document.getElementById("sound3")
a5 = document.getElementById("sound4")
a6 = document.getElementById("sound5")
a7 = document.getElementById("sound6")
a8 = document.getElementById("sound7")
a1.volume = this.value/100
a2.volume = this.value/100
a3.volume = this.value/100
a4.volume = this.value/100
a5.volume = this.value/100
a6.volume = this.value/100
a7.volume = this.value/100
a8.volume = this.value/100
}
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.moveTo(20, 40);
ctx.lineTo(880, 40);
ctx.moveTo(20, 80);
ctx.lineTo(880, 80);
ctx.moveTo(20, 120);
ctx.lineTo(880, 120);
ctx.moveTo(20, 160);
ctx.lineTo(880, 160);
ctx.moveTo(20, 200);
ctx.lineTo(880, 200);
ctx.strokeStyle = "black";
ctx.stroke();
ctx.font = "80px Arial";
var x= 0
var notes =[]
var start=[]
function sleep(delay) {
delay = 100
start = new Date().getTime();
while (new Date().getTime() < start + delay);
}
function Note(){
x+=40
if (x == 880){
alert("You cannot create more music on the staff, you can reopen the site and continue or leave it as it is.")
}
var note = document.getElementById("select-style")
.value
if (note == "e1"){
ctx.font = "80px Arial";
ctx.fillText("♩",x,210);
var p = document.getElementById("sound0");
p.play()
notes.push("e")
}
if (note == "f"){
ctx.font = "80px Arial";
ctx.fillText("♩",x,190);
var p = document.getElementById("sound1");
p.play()
notes.push("f")
}
if (note == "g"){
ctx.font = "80px Arial";
ctx.fillText("♩",x,170);
var p = document.getElementById("sound2");
p.play()
notes.push("g")
}
if (note == "a"){
ctx.font = "80px Arial";
ctx.fillText("♩",x,150);
var p = document.getElementById("sound3");
p.play()
notes.push("a")
}
if (note == "b"){
ctx.font = "80px Arial";
ctx.fillText("♩",x,130);
var p = document.getElementById("sound4");
p.play()
notes.push("b")
}
if (note == "c"){
ctx.font = "80px Arial";
ctx.fillText("♩",x,110);
var p = document.getElementById("sound5");
p.play()
notes.push("c")
}
if (note == "d"){
ctx.font = "80px Arial";
ctx.fillText("♩",x,90);
var p = document.getElementById("sound6");
p.play()
notes.push("d")
}
if (note == "e2"){
ctx.font = "80px Arial";
ctx.fillText("♩",x,70);
var p = document.getElementById("sound7");
p.play()
notes.push("E")
}
if (note == "na"){
ctx.font = "80px Arial";
ctx.fillText("-",x,70);
sleep(0.5);
notes.push("r")
}
}
var p;
var i;
function play(){
for (i = 0; i <= notes.length; i++) {
//alert(notes[i])
//sleep(100)
if (notes[i] == "e"){
document.getElementById("sound0").play();
sleep(100);
}
if (notes[i] == "f"){
p = document.getElementById("sound1");
p.play();
sleep(100);
}
if (notes[i] == "g"){
p = document.getElementById("sound2");
p.play();
sleep(100);
}
if (notes[i] == "a"){
p = document.getElementById("sound3");
p.play();
sleep(100);
}
if (notes[i] == "b"){
p = document.getElementById("sound4");
p.play();
sleep(100);
}
if (notes[i] == "c"){
p = document.getElementById("sound5");
p.play();
sleep(100);
}
if (notes[i] == "d"){
var p = document.getElementById("sound6");
p.play();
sleep(100);
}
if (notes[i] == "e"){
p = document.getElementById("sound7");
p.play();
sleep(100);
}
if (notes[i] == "r"){
sleep(250);
}
}
}
function del(){
last = notes[notes.length-1]
ctx.clearRect(0,0,900,240)
ctx.beginPath();
ctx.moveTo(20, 40);
ctx.lineTo(880, 40);
ctx.moveTo(20, 80);
ctx.lineTo(880, 80);
ctx.moveTo(20, 120);
ctx.lineTo(880, 120);
ctx.moveTo(20, 160);
ctx.lineTo(880, 160);
ctx.moveTo(20, 200);
ctx.lineTo(880, 200);
ctx.strokeStyle = "black";
ctx.stroke();
ctx.font = "80px Arial";
x= 0
notes =[]
}
window.addEventListener('keydown', function (e) {
e = e || window.event;
if (e.keyCode == '69') {
x+=40
ctx.font = "80px Arial";
ctx.fillText("♩",x,210);
var p = document.getElementById("sound0");
p.play()
notes.push("e")
}
if (e.keyCode == '70') {
x+=40
ctx.font = "80px Arial";
ctx.fillText("♩",x,190);
var p = document.getElementById("sound1");
p.play()
notes.push("f")
}
if (e.keyCode == '71') {
x+=40
ctx.font = "80px Arial";
ctx.fillText("♩",x,170);
var p = document.getElementById("sound2");
p.play()
notes.push("g")
}
if (e.keyCode == '65') {
x+=40
ctx.font = "80px Arial";
ctx.fillText("♩",x,150);
var p = document.getElementById("sound3");
p.play()
notes.push("a")
}
if (e.keyCode == '66') {
x+=40
ctx.font = "80px Arial";
ctx.fillText("♩",x,130);
var p = document.getElementById("sound4");
p.play()
notes.push("b")
}
if (e.keyCode == '67') {
x+=40
ctx.font = "80px Arial";
ctx.fillText("♩",x,110);
var p = document.getElementById("sound5");
p.play()
notes.push("c")
}
if (e.keyCode == '68') {
x+=40
ctx.font = "80px Arial";
ctx.fillText("♩",x,90);
var p = document.getElementById("sound6");
p.play()
notes.push("d")
}
if (e.keyCode == '32') {
x+=40
ctx.font = "80px Arial";
ctx.fillText("♩",x,70);
var p = document.getElementById("sound7");
p.play()
notes.push("E")
}
if (e.keyCode == '82') {
x+=40
ctx.font = "80px Arial";
ctx.fillText("-",x,70);
sleep(0.5);
notes.push("r")
}
})
</script>
</body>
</html>