forked from montulli/GrooveScribe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestAllTimeSigs.html
101 lines (75 loc) · 2.45 KB
/
TestAllTimeSigs.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
<!DOCTYPE html>
<html>
<head>
<title>Test all 16th note combinations</title>
<script src="./js/groove_display.js"></script>
</head>
<body id='body' onload="onLoadScript();">
<h2>Choose a subdivision
<select id='divisionSelect' onChange='onDivisionChange()'>
<option name='' value='4'>1/4 notes
<option name='' value='8'>8th notes
<option name='' value='16' selected>16th notes
<option name='' value='32'>32th notes
</select>
</h2>
<script>
window.GrooveDisplayUniqueCounter = 1;
function AddEveryTimeSig(division) {
// write out a hi-hat grove in every time signature for a given division
top_time_sigs = [2,3,4,5,6,7,8,9,10,11,12,13,14,15];
bottom_time_sigs = [4,8,16];
for(var top_sig_idx in top_time_sigs) {
top_sig = top_time_sigs[top_sig_idx];
for(var btm_sig_idx in bottom_time_sigs) {
btm_sig = bottom_time_sigs[btm_sig_idx];
if(btm_sig > division)
continue;
// time sig
options = '?TimeSig=' + top_sig + '/' + btm_sig;
// title
options += '&Title=' + top_sig + '/' + btm_sig;
// div
options += '&Div=' + division;
// Tempo
options += '&Tempo=80';
// Measures
options += '&Measures=1';
// Kick
options += '&K=-';
// Snare
options += '&S=-';
// Hihat
num_notes = top_sig * (division/btm_sig)
hh_line = ''
for(var i=0; i < num_notes; i++)
hh_line += 'x'
options+= '&H=' + hh_line;
console.log(options)
window.GrooveDisplayUniqueCounter++;
// add an html Element to hold the grooveDisplay
var HTMLElementID = 'GrooveDisplay' + window.GrooveDisplayUniqueCounter;
var GrooveDisplayElement = document.createElement("div");
GrooveDisplayElement.class = "GrooveDisplay";
GrooveDisplayElement.id = HTMLElementID;
document.getElementsByTagName("body")[0].appendChild(GrooveDisplayElement);
GrooveDisplay.AddGrooveDisplayToElementId(HTMLElementID, options, false, false);
window.GrooveDisplayUniqueCounter += 1;
}
}
}
function onLoadScript() {
AddEveryTimeSig(16);
}
function onDivisionChange() {
var divs = document.getElementsByTagName("div");
for(var i = 0; i < divs.length; i++){
//do something to each div like
divs[i].innerHTML = '';
}
element = document.getElementById('divisionSelect');
newDivision = element.options[element.selectedIndex].value;
AddEveryTimeSig(newDivision);
}
</script>
</body>