-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
95 lines (88 loc) · 1.78 KB
/
Copy pathscript.js
File metadata and controls
95 lines (88 loc) · 1.78 KB
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
const synth = new Tone.FMSynth().toMaster()
let noteArray=[];
let timeArray=[];
let note;
let i=0;
function readNote(){
document.querySelector('tone-keyboard').addEventListener('noteon', e => {
switch (e.detail.name){
case "C3":
note=48;
break;
case "C#3":
note=49;
break;
case "D3":
note=50;
break;
case "D#3":
note=51;
break;
case "E3":
note=52;
break;
case "F3":
note=53;
break;
case "F#3":
note=54;
case "G3":
note=55;
case "G#3":
note=56;
case "A3":
note=57;
case "A#3":
note=58;
case "B3":
note=59;
case "C4":
note=60;
break;
case "C#4":
note=61;
break;
case "D4":
note=62;
break;
case "D#4":
note=63;
break;
case "E4":
note=64;
break;
case "F4":
note=65;
break;
case "F#4":
note=66;
case "G4":
note=67;
case "G#4":
note=68;
case "A4":
note=69;
case "A#4":
note=70;
case "B4":
note=71;
}
synth.triggerAttack(e.detail.name)
})
document.querySelector('tone-keyboard').addEventListener('noteoff', e => {
synth.triggerRelease()
if (note !=null){
noteArray[i] = [note]
timeArray[i] = [e.timeStamp/1000]
console.log(noteArray[i])
i++;
console.log(i);
}
if (i==20){
i=0;
console.log("ciao")
alert("Generazione Risposta...")
melodysequence();
}
})
}