-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtonetest.html
More file actions
236 lines (226 loc) · 9.5 KB
/
Copy pathtonetest.html
File metadata and controls
236 lines (226 loc) · 9.5 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
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
<html>
<head>
<style>
.horizontalcontainer {
display: flex;
}
.guess {
width:
}
#playagain {
}
.spoilerouter {
background-color: black;
border: 3px solid black;
width: 200px;
}
.inner {
width: 100%;
height: 100%px;
background-color: white;
visibility: visible;
filter: alpha(opacity=0);
text-align: center;
color: black;
vertical-align: middle;
}
.cheating {
vertical-align: bottom;
}
#spoiler {
background-color: black;
}
.testNote {
border: 2px solid black;
}
</style>
<!-- stealin ur styles -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"/>
</head>
<body>
<h1>Interval Quiz</h1>
<div>
<div class="horizontalcontainer">
<div class="spoilerouter">
<div class="inner" id="spoiler">Interval: -</div>
</div>
<button id="playagain">Start!</button>
<button id="next">Next</button>
</div>
<div class="horizontalcontainer">
<button id="0" class="guess" data-guess=0>0</button>
<button id="1" class="guess" data-guess=1>1</button>
<button id="2" class="guess" data-guess=2>2</button>
<button id="3" class="guess" data-guess=3>3</button>
<button id="4" class="guess" data-guess=4>4</button>
<button id="5" class="guess" data-guess=5>5</button>
<button id="6" class="guess" data-guess=6>6</button>
<button id="7" class="guess" data-guess=7>7</button>
<button id="8" class="guess" data-guess=8>8</button>
<button id="9" class="guess" data-guess=9>9</button>
<button id="10" class="guess" data-guess=10>10</button>
<button id="11" class="guess" data-guess=11>11</button>
<button id="12" class="guess" data-guess=12>12</button>
</div>
<div id="score">Score: -</div>
<div id="streak">Streak -</div>
<div id="cheating">
<div>Here are some test notes, it's kinda cheating: </div>
<div class="horizontalcontainer">
<button id="playagain1" class="testNote">Replay 1st Tone</button>
<button id="playagain2" class="testNote">Replay 2nd Tone</button>
</div>
<div class="horizontalcontainer">
<button id="tn0" class="testNote" data-guess=0>0</button>
<button id="tn1" class="testNote" data-guess=1>1</button>
<button id="tn2" class="testNote" data-guess=2>2</button>
<button id="tn3" class="testNote" data-guess=3>3</button>
<button id="tn4" class="testNote" data-guess=4>4</button>
<button id="tn5" class="testNote" data-guess=5>5</button>
<button id="tn6" class="testNote" data-guess=6>6</button>
<button id="tn7" class="testNote" data-guess=7>7</button>
<button id="tn8" class="testNote" data-guess=8>8</button>
<button id="tn9" class="testNote" data-guess=9>9</button>
<button id="tn10" class="testNote" data-guess=10>10</button>
<button id="tn11" class="testNote" data-guess=11>11</button>
<button id="tn12" class="testNote" data-guess=12>12</button>
</div>
</div>
<div id="notes">
<div class="horizontalcontainer">
<ol>
<li>minor second</li>
<li>major second</li>
<li>minor third</li>
<li>major third</li>
<li>perfect fourth</li>
<li>tritone (augmented 4th, diminished 5th)</li>
<li>perfect fifth</li>
<li>minor sixth</li>
<li>major sixth</li>
<li>minor 7th</li>
<li>major 7th</li>
<li>octave</li>
</ol>
<ol>
<li>duh-nuh from jaws</li>
<li>happy birthday</li>
<li>>greensleeves</li>
<li>when the saints go marching in, swing low sweet chariot</li>
<li>amazing grace</li>
<li>(the simp) - sooooons (sons is another half step up)</li>
<li>twinkle twinkle little star</li>
<li>entertainer, we are young: set the world on (fiii-yerrrr)</li>
<li>my bonny lies over the ocean, NBC</li>
<li>star trek original theme "oooo aaaaa" part, willy wonka "(COME) with (ME)" (0-3-10)</li>
<li>take on me "(take MEEEEE) on!"</li>
<li>octave</li>
</ol>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tone/13.0.1/Tone.min.js"></script>
<script>
(function () {
// Membrane Synth https://tonejs.github.io/docs/r12/MembraneSynth
//const synth = new Tone.MembraneSynth().toMaster();
var synth = new Tone.Synth({
"oscillator": {
"type": "sine",
"modulationFrequency": 0.2
},
"envelope": {
"attack": 0.02,
"decay": 0.1,
"sustain": 0.2,
"release": 0.2,
}
}).toMaster();
//var polySynth = new Tone.PolySynth(4, synth).toMaster();
// Create an array of every piano key (88 halftones starting at 27.5 and increasing by 2^1/12 ratios).
// var notes = [27.5];
//for (halfStep = 1; halfStep < 88; ++halfStep) {
// notes.push(notes[halfStep - 1] * Math.pow(2, 1 / 12));
//}
var notes = [220];
for (halfStep = 1; halfStep <= 12; ++halfStep) {
notes.push(notes[halfStep - 1] * Math.pow(2, 1 / 12));
}
var firstNote = 0;
var secondNote = 0;
var correctCount = 0;
var total = 0;
var streak = 0;
// any key in the octave?
var maxRange = 12;
function playIntervalSequence(firstNote, secondNote) {
synth.triggerAttackRelease(notes[firstNote], ".3");
synth.triggerAttackRelease(notes[secondNote], ".3", "+.5");
}
function playInterval() {
playIntervalSequence(firstNote, secondNote);
$('#spoiler').html("Interval: " + (secondNote - firstNote));
console.log("Interval" + (secondNote - firstNote));
// synth.triggerAttackRelease([firstNote, secondNote], 1);
// console.log(notes[firstNote] + " " + notes[secondNote]);
}
function setInterval() {
firstNote = Math.random() * notes.length | 0;
secondNote = Math.random() * notes.length | 0;
if (firstNote > secondNote)
{
temp = secondNote;
secondNote = firstNote;
firstNote = temp;
}
total++;
}
/**
* Play Controls
*/
$("#playagain").click(function () {
if (total == 0) {
setInterval();
$(this).html("Repeat Tone");
}
playInterval();
});
$("#next").click(function () {
$("#spoiler").css({ backgroundColor: 'black' })
$(".spoilerouter").css({ border: "3px solid black" });
$("#tn" + firstNote).css({ border: "2px solid black" });
$("#tn" + secondNote).css({ border: "2px solid black" });
setInterval();
playInterval();
});
$(".guess").click(function () {1
guess = $(this).data("guess");
correct = guess == secondNote - firstNote;
if (total > 0) {
if (correct) {
correctCount++;
streak++;
} else {
streak = 0;
}
}
$(".spoilerouter").css({ border: "3px solid " + (correct ? "green" : "red") });
$("#spoiler").css({ backgroundColor: 'white' })
$('#score').html("Score: " + correctCount + "/" + total);
$('#streak').html("Streak: " + streak);
$("#tn" + firstNote).css({ border: "2px solid " + (correct ? "green" : "red") });
$("#tn" + secondNote).css({ border: "2px solid " + (correct ? "green" : "red") });
});
$(".testNote").click(function () {
synth.triggerAttackRelease(notes[$(this).data("guess")], ".3");
});
$("#playagain1").click(function () {
synth.triggerAttackRelease(notes[firstNote], ".3");
});
$("#playagain2").click(function () {
synth.triggerAttackRelease(notes[secondNote], ".3");
});
})();
</script>
</body>
</html>