PageSourceSearch

https://asym-co.de/Asym_files/asymMaitreGnome.js

js asym-co.de collected 2026-10-02 01:51:19 UTC 144,234 bytes, 3,117 lines download raw bytes

1// Osc INIT
2var audioCtx = new (window.AudioContext || window.webkitAudioContext)(),
3    SubAudioCtx = new (window.AudioContext || window.webkitAudioContext)(),
4    volume = audioCtx.createGain(),
5    subvolume = SubAudioCtx.createGain(),
6    noteFlag = 0, bangTot = 1, bangSub = 1, nod = 0, stamp = 2,
7    curtime = 0.0,
8    timer,
9    delta = 0; 
10    
11    var context = new AudioContext();
12    
13    var beas = new Array(1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,  
14                              1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,
15                              1000,1000,1000,1000,1000,1000,1000,1000,1000,1000 );
16    var acc = new Array(1.0, .8, .4, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
17                             1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
18                             1.0, 1.0, 1.0, 1.0, 1.0);
19    var bee = new Array(300, 75, 150, 300, 300, 300,300, 300, 300,300, 300, 
20    						 300,300, 300,300, 300, 300, 300, 300, 300, 300,
21    						 300, 300, 300, 300, 300, 300);
22    var tile = new Array(1.0, 2.0, 2.5, 2.75, 3.0, 2.9, 2.88, 2.87, 2.9, 3.1, 3.3, 
23                              3.6, 4.0, 4.3, 4.7, 4.8, 5.4, 5.5, 5.8, 6.4, 6.6, 6.8,
24                              6.8, 7.8, 8.0, 8.0);
25    var bangFlag = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
26                                11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24);
27    var meas = new Array(60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60);
28    var btVal = new Array(60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60);
29    var gnom = new Array("bw_lf","bw_rt","wb_lf","wb_rt","plain");
30    var drag = new Array(.5, .5, .5, .5, .5, .5, .5, .5, .5, .5, .5, 
31                             .5, .5, .5, .5, .5, .5, .5, .5, .5, .5,
32                             .5, .5, .5, .5, .5);   
33    var dg = 0.5, totMs, subMs; var sg1, sg2, sg3;
34    
35    var acar = {'!*x': 0, '!*>': 1, '!>': 2, '!*': 3,  '*': 5,'!': 3, '.': 5, '>': 6, 'x': 7,  'X': 7,'^': 8, '0': 9, '4':4, 's': 6, 'h': 7, '!s': 2, '!ks': 1, '!kh': 0, 'k': 5, 'n': 8, 'o': 9, '#': 4, 'S': 6, 'H': 7, '!S': 2, '!K': 3, '!KS': 1, '!KH': 0, 'K': 5, 'N': 8, 'O': 9, '!k': 3};
36    var pcL = new Array(44,44,44,44,44,40,40,40,42,36,37,
37                           39,38,38,38,38,38,38,38,38,38,
38                           38,38,38,38);
39    var acR = new Array(10,16,18,20,22,20,20,22,20,20,18,
40                           21,18,20,20,20,21,20,22,20,20,
41                           20,18,18,18);
42
43    var dotHt = new Array; var dotRd = new Array; var dotty;
44    
45var ctx0 = new (window.AudioContext || window.webkitAudioContext)();
46var ctx1 = new (window.AudioContext || window.webkitAudioContext)();
47var ctx2 = new (window.AudioContext || window.webkitAudioContext)();
48var ctx4 = new (window.AudioContext || window.webkitAudioContext)();
49var fiddle = "acoustic_grand_piano";
50
51function timbre() {
52fiddle = document.getElementById('tmbr').value;
53}
54
55
56function clap() { tom.play(); testIt.innerHTML = "clap";}
57
58// Elements INIT
59var tempo = 60000 / (document.getElementById('t').value),
60    tempo_rge = document.getElementById('t'),
61    tempo_disp = document.getElementById('tempo-disp'),
62    flxOn = document.getElementById('flexCheck'),
63    flxT = tempo_rge.value,
64    meterOn = document.getElementById('meter'),
65    plus = document.getElementById('plus'),
66    minus = document.getElementById('minus'),
67    extraPlus = document.getElementById('extraPlus'),
68    extraMinus = document.getElementById('extraMinus'),
69    beatPlus = document.getElementById('beatPlus'),
70    beatMinus = document.getElementById('beatMinus'),
71    start = document.getElementById('start'),
72    stop = document.getElementById('stop'),
73    tap = document.getElementById('tap'),
74    beatFlag = document.getElementById('beatFlag'),
75    beatNbr = document.getElementById('beatNbr'),
76    beatCount = document.getElementById('beatCount'),
77    digitalDisplayContainer = document.getElementById('digitalDisplayContainer'),  
78    dotTarget = document.getElementById('dotTarget'),
79    dotsDisplay = document.getElementById('dotsDisplay'),    
80    digitalDisplay = document.getElementById('digitalDisplay'),
81    bothDisplay = document.getElementById('bothDisplay'),
82    beatDots = document.getElementsByClassName('beat'),
83    pr1 = document.getElementById('pr1'),
84    pr2 = document.getElementById('pr2'),
85    pr3 = document.getElementById('pr3'),
86    pr4 = document.getElementById('pr4'),
87    pr5 = document.getElementById('pr5'),
88    pr6 = document.getElementById('pr6'),
89    pr7 = document.getElementById('pr7'),
90    pr8 = document.getElementById('pr8'),
91    pr9 = document.getElementById('pr9'),
92    pr10 = document.getElementById('pr10'),
93    pr11 = document.getElementById('pr11'),
94    pr12 = document.getElementById('pr12'),
95    pr13 = document.getElementById('pr13'),
96    pr14 = document.getElementById('pr14'),
97    pr15 = document.getElementById('pr15'),
98    pr16 = document.getElementById('pr16'),
99    pr17 = document.getElementById('pr17'),
100    pr18 = document.getElementById('pr18'),
101    pr19 = document.getElementById('pr19'),
102    pr20 = document.getElementById('pr20'),
103    pr21 = document.getElementById('pr21'),
104    pr22 = document.getElementById('pr22'),
105    pr23 = document.getElementById('pr23'),
106    pr24 = document.getElementById('pr24'),
107    b1v = document.getElementById('len1').value,
108    b2v = document.getElementById('len2').value,
109    b3v = document.getElementById('len3').value,
110    b4v = document.getElementById('len4').value,
111    b5v = document.getElementById('len5').value,
112    b6v = document.getElementById('len6').value,
113    b7v = document.getElementById('len7').value,
114    b8v = document.getElementById('len8').value,
115    b9v = document.getElementById('len9').value,
116    b10v = document.getElementById('len10').value,
117    b11v = document.getElementById('len11').value,
118    b12v = document.getElementById('len12').value,
119    b13v = document.getElementById('len13').value,
120    b14v = document.getElementById('len14').value,
121    b15v = document.getElementById('len15').value,
122    b16v = document.getElementById('len16').value,
123    b17v = document.getElementById('len17').value,
124    b18v = document.getElementById('len18').value,
125    b19v = document.getElementById('len19').value,
126    b20v = document.getElementById('len20').value,
127    b21v = document.getElementById('len21').value,
128    b22v = document.getElementById('len22').value,
129    b23v = document.getElementById('len23').value,
130    b24v = document.getElementById('len24').value,
131    bAllv = 100, bts=beatCount.value,
132    bangNum = 0,
133    testIt1 = document.getElementById('testIt1'),
134    testIt2 = document.getElementById('testIt2'),
135    testIt3 = document.getElementById('testIt3'),
136        testIt4 = document.getElementById('testIt4'),
137    testIt5 = document.getElementById('testIt5'),
138    testIt6 = document.getElementById('testIt6'),
139        testIt7 = document.getElementById('testIt7'),
140    testIt8 = document.getElementById('testIt8'),
141    testIt9 = document.getElementById('testIt9'),
142    beep = 0, space = 0, ak = 1.0, accented = 1, subMute = 0,
143    flex, core = Number(tempo_rge.value);
144    var tapCount = beatCount*3 - 1, android = 0, onOff = 0;
145    var first = 0, mute = 1;
146    
147    var dumpIn; var dumpAll; var dStr = new Array; var setQ, dmpQ, setTot, dmpTot, dumpOn;
148    
149    btVal[0]=Number(b1v); var bToTAvg = 1;
150    btVal[1]=Number(b2v);
151    
152function temp(v){
153  tempo_disp.innerHTML = v; 
154  core = Number(v);
155  beatCount = document.getElementById('beatCount');
156  bts = beatCount.value;
157  
158  totMs = Math.round((60/core)*bts*1000);
159  document.getElementById('mills').innerHTML = "["+totMs+" ms]";
160    subMs = Math.round(totMs/bangTot);
161  document.getElementById('subMs').innerHTML = "{"+subMs+" ms}";
162    var ogTemp = 60000 / (document.getElementById('t').value)
163  var newTemp = 60000*bangTot/(ogTemp*bts);
164  if (meterOn.checked) {
165   if (bangTot==1)
166    {document.getElementById('bangTot').innerHTML = bangTot+ " beat @";}
167   else {document.getElementById('bangTot').innerHTML = bangTot+ " beats @";}
168  document.getElementById('bangTemp').innerHTML = "~"+Math.round(newTemp)+" bpm";
169
170  }
171}
172
173function btWts(){
174  b1v = Number(document.getElementById('len1').value); btVal[0]=Number(b1v);
175  b2v = Number(document.getElementById('len2').value); btVal[1]=Number(b2v);
176  b3v = Number(document.getElementById('len3').value); btVal[2]=Number(b3v);
177  b4v = Number(document.getElementById('len4').value); btVal[3]=Number(b4v);
178  b5v = Number(document.getElementById('len5').value); btVal[4]=Number(b5v);
179  b6v = Number(document.getElementById('len6').value); btVal[5]=Number(b6v);
180  b7v = Number(document.getElementById('len7').value); btVal[6]=Number(b7v);
181  b8v = Number(document.getElementById('len8').value); btVal[7]=Number(b8v);
182  b9v = Number(document.getElementById('len9').value); btVal[8]=Number(b9v);
183  b10v = Number(document.getElementById('len10').value); btVal[9]=Number(b10v);
184  b11v = Number(document.getElementById('len11').value); btVal[10]=Number(b11v);
185  b12v = Number(document.getElementById('len12').value); btVal[11]=Number(b12v);
186  b13v = Number(document.getElementById('len13').value); btVal[12]=Number(b13v);
187  b14v = Number(document.getElementById('len14').value); btVal[13]=Number(b14v);
188  b15v = Number(document.getElementById('len15').value); btVal[14]=Number(b15v);
189  b16v = Number(document.getElementById('len16').value); btVal[15]=Number(b16v);
190  b17v = Number(document.getElementById('len17').value); btVal[16]=Number(b17v);
191  b18v = Number(document.getElementById('len18').value); btVal[17]=Number(b18v);
192  b19v = Number(document.getElementById('len19').value); btVal[18]=Number(b19v);
193  b20v = Number(document.getElementById('len20').value); btVal[19]=Number(b20v);
194  b21v = Number(document.getElementById('len21').value); btVal[20]=Number(b21v);
195  b22v = Number(document.getElementById('len22').value); btVal[21]=Number(b22v);
196  b23v = Number(document.getElementById('len23').value); btVal[22]=Number(b23v);
197  b24v = Number(document.getElementById('len24').value); btVal[23]=Number(b24v);
198
199  bAllv = Number(b1v) +Number(b2v) +Number(b3v)+ Number(b4v) +Number(b5v)+Number(b6v) + Number(b7v) +Number(b8v) +Number(b9v)+ Number(b10v) +Number(b11v)+Number(b12v)+Number(b13v)+Number(b14v)+Number(b15v)+Number(b16v)
200  + Number(b17v) +Number(b18v) +Number(b19v)+ Number(b20v) +Number(b21v)+Number(b22v)+Number(b23v)+Number(b24v);
201  bts=beatCount.value;
202  bTotAvg= Math.round(bAllv/bts);
203t_rV = document.getElementById('t').value;
204drag[0] = (60.0 / t_rV )*bts*(b1v/bAllv);
205drag[1] = (60.0 / t_rV )*bts*(b2v/bAllv);
206drag[2] = (60.0 / t_rV )*bts*(b3v/bAllv);
207drag[3] = (60.0 / t_rV )*bts*(b4v/bAllv);
208drag[4] = (60.0 / t_rV )*bts*(b5v/bAllv);
209drag[5] = (60.0 / t_rV )*bts*(b6v/bAllv);
210drag[6] = (60.0 / t_rV )*bts*(b7v/bAllv);
211drag[7] = (60.0 / t_rV )*bts*(b8v/bAllv);
212drag[8] = (60.0 / t_rV )*bts*(b9v/bAllv);
213drag[9] = (60.0 / t_rV )*bts*(b10v/bAllv);
214drag[10] = (60.0 / t_rV )*bts*(b11v/bAllv);
215drag[11] = (60.0 / t_rV )*bts*(b12v/bAllv);
216drag[12] = (60.0 / t_rV )*bts*(b13v/bAllv);
217drag[13] = (60.0 / t_rV )*bts*(b14v/bAllv);
218drag[14] = (60.0 / t_rV )*bts*(b15v/bAllv);
219drag[15] = (60.0 / t_rV )*bts*(b16v/bAllv);
220drag[16] = (60.0 / t_rV )*bts*(b17v/bAllv);
221drag[17] = (60.0 / t_rV )*bts*(b18v/bAllv);
222drag[18] = (60.0 / t_rV )*bts*(b19v/bAllv);
223drag[19] = (60.0 / t_rV )*bts*(b20v/bAllv);
224drag[20] = (60.0 / t_rV )*bts*(b21v/bAllv);
225drag[21] = (60.0 / t_rV )*bts*(b22v/bAllv);
226drag[22] = (60.0 / t_rV )*bts*(b23v/bAllv);
227drag[23] = (60.0 / t_rV )*bts*(b24v/bAllv);
228
229     pr1.value = Math.round(100*(b1v/bAllv))+"%";
230     pr2.value = Math.round(100*(b2v/bAllv))+"%";
231     pr3.value = Math.round(100*(b3v/bAllv))+"%";
232     pr4.value = Math.round(100*(b4v/bAllv))+"%";
233     pr5.value = Math.round(100*(b5v/bAllv))+"%";
234     pr6.value = Math.round(100*(b6v/bAllv))+"%";
235     pr7.value = Math.round(100*(b7v/bAllv))+"%";
236     pr8.value = Math.round(100*(b8v/bAllv))+"%";
237     pr9.value = Math.round(100*(b9v/bAllv))+"%";
238     pr10.value = Math.round(100*(b10v/bAllv))+"%";
239     pr11.value = Math.round(100*(b11v/bAllv))+"%";
240     pr12.value = Math.round(100*(b12v/bAllv))+"%";
241     pr13.value = Math.round(100*(b13v/bAllv))+"%";
242     pr14.value = Math.round(100*(b14v/bAllv))+"%";
243     pr15.value = Math.round(100*(b15v/bAllv))+"%";
244     pr16.value = Math.round(100*(b16v/bAllv))+"%";
245     pr17.value = Math.round(100*(b17v/bAllv))+"%";
246     pr18.value = Math.round(100*(b18v/bAllv))+"%";
247     pr19.value = Math.round(100*(b19v/bAllv))+"%";
248     pr20.value = Math.round(100*(b20v/bAllv))+"%";
249     pr21.value = Math.round(100*(b21v/bAllv))+"%";
250     pr22.value = Math.round(100*(b22v/bAllv))+"%";
251     pr23.value = Math.round(100*(b23v/bAllv))+"%";
252     pr24.value = Math.round(100*(b24v/bAllv))+"%";
253
254     document.getElementById('color1').width = tile[bts]*Math.round(100*(b1v/bAllv));
255     document.getElementById('color2').width = tile[bts]*Math.round(100*(b2v/bAllv));
256     document.getElementById('color3').width = tile[bts]*Math.round(100*(b3v/bAllv)); 
257     document.getElementById('color4').width = tile[bts]*Math.round(100*(b4v/bAllv)); 
258     document.getElementById('color5').width = tile[bts]*Math.round(100*(b5v/bAllv)); 
259     document.getElementById('color6').width = tile[bts]*Math.round(100*(b6v/bAllv)); 
260     document.getElementById('color7').width = tile[bts]*Math.round(100*(b7v/bAllv));
261     document.getElementById('color8').width = tile[bts]*Math.round(100*(b8v/bAllv));
262     document.getElementById('color9').width = tile[bts]*Math.round(100*(b9v/bAllv)); 
263     document.getElementById('color10').width = tile[bts]*Math.round(100*(b10v/bAllv)); 
264     document.getElementById('color11').width = tile[bts]*Math.round(100*(b11v/bAllv)); 
265     document.getElementById('color12').width = tile[bts]*Math.round(100*(b12v/bAllv)); 
266     document.getElementById('color13').width = tile[bts]*Math.round(100*(b13v/bAllv));
267     document.getElementById('color14').width = tile[bts]*Math.round(100*(b14v/bAllv)); 
268     document.getElementById('color15').width = tile[bts]*Math.round(100*(b15v/bAllv)); 
269     document.getElementById('color16').width = tile[bts]*Math.round(100*(b16v/bAllv)); 
270     document.getElementById('color17').width = tile[bts]*Math.round(100*(b17v/bAllv));
271     document.getElementById('color18').width = tile[bts]*Math.round(100*(b18v/bAllv));
272     document.getElementById('color19').width = tile[bts]*Math.round(100*(b19v/bAllv)); 
273     document.getElementById('color20').width = tile[bts]*Math.round(100*(b20v/bAllv)); 
274     document.getElementById('color21').width = tile[bts]*Math.round(100*(b21v/bAllv)); 
275     document.getElementById('color22').width = tile[bts]*Math.round(100*(b22v/bAllv)); 
276     document.getElementById('color23').width = tile[bts]*Math.round(100*(b23v/bAllv));
277     document.getElementById('color24').width = tile[bts]*Math.round(100*(b24v/bAllv)); 
278      
279  var tpo = document.getElementById('t').value;
280 noteFlag = 0;  
281 // noteFlag = bts-1;
282  tapCount=bts*3 -1;
283  tapping.innerHTML = "               ";
284  temp(tpo); 
285 sg1 = 100*(b1v/bAllv);
286 sg2 = 100*(b2v/bAllv);
287sg3 = 100*(b3v/bAllv);
288  if (bts==3){
289signs(sg1, sg2,sg3); }
290else { document.getElementById('sign').className = "hidden";
291//document.getElementById('sign').width = "1";
292 }
293  isop();  
294} // end btWts()
295
296function signs(a, b, c) {
297var wf = 3; var sig = "ooo";
298var ab = Math.abs(a-b); var ac = Math.abs(a-c); var bc = Math.abs(b-c);
299if (ab<wf && ac<wf && bc<wf) { sig = "ooo"; } //
300
301else if (ab<wf && ac>wf && c<a & c<b) { 
302     if (a/c>=2) {sig = "ooe";} //
303     else {sig = "oos";} //
304     }
305else if (ab<wf && ac>wf && c>a & c>b) { 
306     if (c/a>=2 && c>=50) {sig = "eel";} //
307     else if (c/a>=2) {sig = "eeo";} //
308     else {sig = "ool";} //
309}
310else if (bc<wf && ab>wf && a<b && a<c) { 
311     if (b/a>=2) {sig = "eoo";} //
312     else {sig = "soo";} //
313}
314else if (bc<wf && a>b && a>c) { 
315    if (a/b>=2 && a>=50) {sig = "lee";} //
316    else if (a/b>=2) {sig = "oee";} //
317    else {sig = "loo";} //
318    }
319else if (ac<wf && b<a && b<c) { 
320     if (a/b>=2) {sig = "oeo";} //
321     else {sig = "oso";} //
322}
323else if (ac<wf && b>a && b>c) { 
324     if (b/a>=2 && b>=50) {sig = "ele";} //
325     else if (b/a>=2) {sig = "eoe";} //
326     else {sig = "olo";}//
327}
328
329else if (a>b && b>c) { 
330    if (a/c>=2 && a/b>=2) {sig = "leg";} //
331    else if (a/c>=2 && a>50) {sig = "loe";} //
332    else if (a/c>=2) {sig = "ose";} //
333    else {sig = "los";} //
334  }
335else if (a>c && c>b) { 
336    if (a/b>=2 && a/c>=2) {sig = "lge";} //missing
337    else if (a/b>=2 && a>50) {sig = "leo";} //missing
338    else if (a/b>=2) {sig = "oes";} //missing
339    else {sig = "lso";} //
340}
341else if (b>a && a>c) { 
342    if (b/c>=2 && b/a>=2) {sig = "elg";} //
343    else if (b/c>=2 && b>50) {sig = "ole";} //
344    else if (b/c>=2) {sig = "soe";} //
345    else {sig = "ols";} //
346}
347else if (b>c && c>a) { 
348    if (b/a>=2 && b/c>=2) {sig = "gle";} //
349    else if (b/a>=2 && b>50) {sig = "elo";} //
350    else if (b/a>=2) {sig = "eos";} //
351    else {sig = "slo";} //
352}
353else if (c>b && b>a) { 
354    if (c/a>=2 && c/b>=2) {sig = "gel";} //
355    else if (c/a>=2 && c>50) {sig = "eol";} //
356    else if (c/a>=2) {sig = "eso";} //
357    else {sig = "sol";} //
358}
359else if (c>a && a>b) { 
360    if (c/a>=2 && c/b>=2) {sig = "egl";} //
361    else if (c/b>=2 && c>50) {sig = "oel";} //
362    else if (c/b>=2) {sig = "seo";} //
363    else {sig = "osl";} //
364 }
365  document.getElementById('sign').className = "";
366  document.getElementById('sign').width = "60";
367  document.getElementById("sign").src="signs/"+sig+".png";
368} // end signs()
369
370function level() {
371bangTot = 0; bangSub = 0; 
372beatCount = document.getElementById('beatCount');
373bts = beatCount.value;
374dotty = document.querySelectorAll('#dotTarget li');  
375 
376 
377
378  core = Number(document.getElementById('t').value); 
379  totMs = Math.round((60/core)*bts*1000);
380  
381var ak1 = document.getElementById('ac1').value;
382var ak2 = document.getElementById('ac2').value;
383var ak3 = document.getElementById('ac3').value;
384var ak4 = document.getElementById('ac4').value;
385var ak5 = document.getElementById('ac5').value;
386var ak6 = document.getElementById('ac6').value;
387var ak7 = document.getElementById('ac7').value;
388var ak8 = document.getElementById('ac8').value;
389var ak9 = document.getElementById('ac9').value;
390var ak10 = document.getElementById('ac10').value;
391var ak11 = document.getElementById('ac11').value;
392var ak12 = document.getElementById('ac12').value;
393var ak13 = document.getElementById('ac13').value;
394var ak14 = document.getElementById('ac14').value;
395var ak15 = document.getElementById('ac15').value;
396var ak16 = document.getElementById('ac16').value;
397var ak17 = document.getElementById('ac17').value;
398var ak18 = document.getElementById('ac18').value;
399var ak19 = document.getElementById('ac19').value;
400var ak20 = document.getElementById('ac20').value;
401var ak21 = document.getElementById('ac21').value;
402var ak22 = document.getElementById('ac22').value;
403var ak23 = document.getElementById('ac23').value;
404var ak24 = document.getElementById('ac24').value;
405
406acc[0]=ak1; acc[1]=ak2; acc[2]=ak3; acc[3]=ak4; acc[4]=ak5; acc[5]=ak6;
407acc[6]=ak7; acc[7]=ak8; acc[8]=ak9; acc[9]=ak10; acc[10]=ak11; acc[11]=ak12;
408acc[12]=ak13; acc[13]=ak14; acc[14]=ak15; acc[15]=ak16;
409acc[16]=ak17; acc[17]=ak18; acc[18]=ak19; acc[19]=ak20;
410acc[20]=ak21; acc[21]=ak22; acc[22]=ak23; acc[23]=ak24; 
411bee[0]=ak1*300; bee[1]=ak2*300; bee[2]=ak3*300; bee[3]=ak4*300; bee[4]=ak5*300; bee[5]=ak6*300;
412bee[6]=ak7*300; bee[7]=ak8*300; bee[8]=ak9*300; bee[9]=ak10*300;
412 bee[10]=ak11*300; bee[11]=ak12*300; bee[12]=ak13*300; bee[13]=ak14*300; bee[14]=ak15*300; bee[15]=ak16*300;
413bee[16]=ak17*300; bee[17]=ak18*300; bee[18]=ak19*300; bee[19]=ak20*300;
414bee[20]=ak21*300; bee[21]=ak22*300; bee[22]=ak23*300; bee[23]=ak24*300;
415for (var i=0; i<bts;i++) {
416   if (bee[i]==30) {bee[i]=75;}
417   if (acc[i]> 1.0){
418   bangTot = bangTot + 1; bangSub=.1; 
419   meterOn.checked = true;
420dotHt[i]="40px"; dotRd[i]="5px";
421    dotty[i].style.height=dotHt[i];
422  dotty[i].style.borderRadius=dotRd[i];  
423 
424
425   }
426   else {bangSub=bangSub+.1; 
427 dotHt[i]="30px"; dotRd[i]="16px";
428    }
429
430  // var bangDec = Math.round();
431  
432   bangFlag[i]=bangTot+ Math.round(bangSub*10)/10;
433  }
434  if (bangTot==0) {meterOn.checked = false; meterIt();}
435  var ogTemp = 60000 / (document.getElementById('t').value)
436  var newTemp = 60000*bangTot/(ogTemp*bts);
437  if (meterOn.checked){
438  document.getElementById('bangTemp').className = "min-btn";
439    document.getElementById('subMs').className = "min-btn";
440    document.getElementById('subMs').innerHTML = "{"+Math.round(totMs/bangTot)+"ms}";
441     if (bangTot==1)
442    {document.getElementById('bangTot').innerHTML = bangTot+ " beat @";}
443   else {document.getElementById('bangTot').innerHTML = bangTot+ " beats @";}
444  document.getElementById('bangTemp').innerHTML = "~"+Math.round(newTemp)+" bpm";
445
446  }
447  else {document.getElementById('bangTemp').className = "min-btn hidden";
448    document.getElementById('subMs').className = "min-btn hidden";
449  }
450
451
452} // end level()
453
454
455function vol(l){
456  volume.gain.setValueAtTime(l, audioCtx.currentTime);
457}
458
459function schedule(){
460  while(curtime < audioCtx.currentTime + 0.1){
461    if(noteFlag >= beatCount.value){
462      noteFlag = 0;
463    }
464    
465//document.getElementById('testIt1').innerHTML = "schedule";
466   // if (dmpQ == dmpTot && dumpOn==1) {
467     //  setQ++; 
468      // if (setQ==setTot) {setQ=0;}
469    //dumping(setQ);
470      // }
471    playNote(curtime); 
472    console.log(curtime);
473    console.log(curtime);
474    updateTime();
475
476    var child = document.querySelectorAll('#dotTarget li');   
477  
478  child[noteFlag].style.height=dotHt[noteFlag];
479  child[noteFlag].style.borderRadius=dotRd[noteFlag];
480  if (meterOn.checked) {child[noteFlag].innerHTML=bangFlag[noteFlag].toString();}
481  else {var bFlg = noteFlag+1;
482  child[noteFlag].innerHTML=bFlg.toString();}
483    if(noteFlag === 0){
484
485      child[0].className += " on-temp";
486      child[0].style.background="blue";
487      child[0].style.color="white";
488      child[child.length - 1].classList.remove("on-temp");
489      for (y=1;y<child.length;y++) {
490      child[y].style.background="grey";
491      child[y].style.color="grey";
492      }
493    }
494    else if (noteFlag === 1){
495      child[1].className += " on-temp";
496      child[1].style.background="goldenrod";
497      child[1].style.color="black";
498      child[0].classList.remove("on-temp");
499      child[0].style.background="grey";
500      child[0].style.color="grey";
501    }
502     else if (noteFlag === 2){
503      child[2].className += " on-temp";
504      child[2].style.background="red";
505      child[2].style.color="black";
506      child[1].classList.remove("on-temp");
507      child[1].style.background="grey";
508      child[1].style.color="grey";
509    }
510      else if (noteFlag === 3){
511      child[3].className += " on-temp";
512      child[3].style.background="mediumpurple";
513      child[3].style.color="black";
514      child[2].classList.remove("on-temp");
515      child[2].style.background="grey";
516      child[2].style.color="grey";
517    }
518      else if (noteFlag === 4){
519      child[4].className += " on-temp";
520      child[4].style.background="limeGreen";
521      child[4].style.color="black";
522      child[3].classList.remove("on-temp");
523      child[3].style.background="grey";
524      child[3].style.color="grey";
525    }
526       else if (noteFlag === 5){
527      child[5].className += " on-temp";
528      child[5].style.background="darkorange";
529      child[5].style.color="black";
530      child[4].classList.remove("on-temp");
531      child[4].style.background="grey";
532      child[4].style.color="grey";
533    }
534           else if (noteFlag === 6){
535      child[6].className += " on-temp";
536      child[6].style.background="turquoise";
537      child[6].style.color="black";
538      child[5].classList.remove("on-temp");
539      child[5].style.background="grey";
540      child[5].style.color="grey";
541    }
542           else if (noteFlag === 7){
543      child[7].className += " on-temp";
544      child[7].style.background="green";
545      child[7].style.color="white";
546      child[6].classList.remove("on-temp");
547      child[6].style.background="grey";
548      child[6].style.color="grey";
549    }
550           else if (noteFlag === 8){
551      child[8].className += " on-temp";
552      child[8].style.background="deepPink";
553      child[8].style.color="black";
554      child[7].classList.remove("on-temp");
555      child[7].style.background="grey";
556      child[7].style.color="grey";
557    }
558           else if (noteFlag === 9){
559      child[9].className += " on-temp";
560      child[9].style.background="darkSlateGrey";
561      child[9].style.color="white";
562      child[8].classList.remove("on-temp");
563      child[8].style.background="grey";
564      child[8].style.color="grey";
565    }
566           else if (noteFlag === 10){
567      child[10].className += " on-temp";
568      child[10].style.background="yellowGreen";
569      child[10].style.color="black";
570      child[9].classList.remove("on-temp");
571      child[9].style.background="grey";
572      child[9].style.color="grey";
573    }
574           else if (noteFlag === 11){
575      child[11].className += " on-temp";
576      child[11].style.background="maroon";
577      child[11].style.color="white";
578      child[10].classList.remove("on-temp");
579      child[10].style.background="grey";
580      child[10].style.color="grey";
581    }
582             else if (noteFlag === 12){
583      child[12].className += " on-temp";
584      child[12].style.background="dodgerBlue";
585      child[12].style.color="black";
586      child[11].classList.remove("on-temp");
587      child[11].style.background="grey";
588      child[11].style.color="grey";
589    }
590                else if (noteFlag === 13){
591      child[13].className += " on-temp";
592      child[13].style.background="gold";
593      child[13].style.color="black";
594      child[12].classList.remove("on-temp");
595      child[12].style.background="grey";
596      child[12].style.color="grey";
597    }
598                else if (noteFlag === 14){
599      child[14].className += " on-temp";
600      child[14].style.background="fuchsia";
601      child[14].style.color="black";
602      child[13].classList.remove("on-temp");
603      child[13].style.background="grey";
604      child[13].style.color="grey";
605    }
606                else if (noteFlag === 15){
607      child[15].className += " on-temp";
608      child[15].style.background="olive";
609      child[15].style.color="black";
610      child[14].classList.remove("on-temp");
611      child[14].style.background="grey";
612      child[14].style.color="grey";
613    }
614          else if (noteFlag === 16){
615      child[16].className += " on-temp";
616      child[16].style.background="limeGreen";
617      child[16].style.color="black";
618      child[15].classList.remove("on-temp");
619      child[15].style.background="grey";
620      child[15].style.color="grey";
621    }
622       else if (noteFlag === 17){
623      child[17].className += " on-temp";
624      child[17].style.background="darkorange";
625      child[17].style.color="black";
626      child[16].classList.remove("on-temp");
627      child[16].style.background="grey";
628      child[16].style.color="grey";
629    }
630           else if (noteFlag === 18){
631      child[18].className += " on-temp";
632      child[18].style.background="turquoise";
633      child[18].style.color="black";
634      child[17].classList.remove("on-temp");
635      child[17].style.background="grey";
636      child[17].style.color="grey";
637    }
638           else if (noteFlag === 19){
639      child[19].className += " on-temp";
640      child[19].style.background="green";
641      child[19].style.color="white";
642      child[18].classList.remove("on-temp");
643      child[18].style.background="grey";
644      child[18].style.color="grey";
645    }
646               else if (noteFlag === 20){
647      child[20].className += " on-temp";
648      child[20].style.background="deepPink";
649      child[20].style.color="black";
650      child[19].classList.remove("on-temp");
651      child[19].style.background="grey";
652      child[19].style.color="grey";
653    }
654           else if (noteFlag === 21){
655      child[21].className += " on-temp";
656      child[21].style.background="darkSlateGrey";
657      child[21].style.color="white";
658      child[20].classList.remove("on-temp");
659      child[20].style.background="grey";
660      child[20].style.color="grey";
661    }
662           else if (noteFlag === 22){
663      child[22].className += " on-temp";
664      child[22].style.background="yellowGreen";
665      child[22].style.color="black";
666      child[21].classList.remove("on-temp");
667      child[21].style.background="grey";
668      child[21].style.color="grey";
669    }
670           else if (noteFlag === 23){
671      child[23].className += " on-temp";
672      child[23].style.background="maroon";
673      child[23].style.color="white";
674      child[22].classList.remove("on-temp");
675      child[22].style.background="grey";
676      child[22].style.color="grey";
677    }
678    else {
679      child[noteFlag].className += " on-temp";
680      child[noteFlag - 1].classList.remove("on-temp");
681    }
682   if (nod == 0) { nod=1;}
683  else if (nod == 1) { nod = 0;}
684
685
686  // document.getElementById('mg').src="colors/mg_bw_rt.png";}
687    //if (bangTot==0) {
688   // document.getElementById('bangFlag').innerHTML = Math.round(10*bangFlag[noteFlag]);
689   // }
690   // else {document.getElementById('bangFlag').innerHTML = bangFlag[noteFlag];}
691   var remain = bangFlag[noteFlag] - Math.floor(bangFlag[noteFlag]);
692 // testIt4.innerHTML = remain; 
693    if (meterOn.checked) { 
694    beatFlag.innerHTML = bangFlag[noteFlag];
695    if (stamp==0 && remain<.15) {stamp=2;}
696    else if (stamp==2 && remain<.15) {stamp=0;}
697    }
698    else {
699    beatFlag.innerHTML = noteFlag+1; 
700         if (stamp==0 && noteFlag==0) {stamp=2;}
701     else if (stamp==2 && noteFlag==0) {stamp=0;}
702     }
703     document.getElementById('mg').src="colors/mg_"+gnom[nod+stamp]+".png";
704     
705    noteFlag++;
706      dmpQ++; // $$ trying to implement dump-sets $$
707       
708    if (noteFlag==1) {beatFlag.style.color="blue"; }
709    else if (noteFlag==2) {beatFlag.style.color="goldenRod";}
710    else if (noteFlag==3) {beatFlag.style.color="red";}
711    else if (noteFlag==4) {beatFlag.style.color="mediumpurple";}
712    else if (noteFlag==5) {beatFlag.style.color="limeGreen";}
713    else if (noteFlag==6) {beatFlag.style.color="darkorange";}
714    else if (noteFlag==7) {beatFlag.style.color="turquoise";}
715    else if (noteFlag==8) {beatFlag.style.color="green";}
716    else if (noteFlag==9) {beatFlag.style.color="deepPink";}
717    else if (noteFlag==10) {beatFlag.style.color="darkSlateGrey";}
718    else if (noteFlag==11) {beatFlag.style.color="yellowGreen";}
719    else if (noteFlag==12) {beatFlag.style.color="maroon";}
720    else if (noteFlag==13) {beatFlag.style.color="dodgerBlue";}
721    else if (noteFlag==14) {beatFlag.style.color="goldenRod";}
722    else if (noteFlag==15) {beatFlag.style.color="fuchsia";}
723    else if (noteFlag==16) {beatFlag.style.color="olive";}
724    else if (noteFlag==17) {beatFlag.style.color="chartreuse";}
725    else if (noteFlag==18) {beatFlag.style.color="darkorange";}
726    else if (noteFlag==19) {beatFlag.style.color="turquoise";}
727    else if (noteFlag==20) {beatFlag.style.color="green";}
728    else if (noteFlag==21) {beatFlag.style.color="deepPink";}
729    else if (noteFlag==22) {beatFlag.style.color="darkSlateGrey";}
730    else if (noteFlag==23) {beatFlag.style.color="yellowGreen";}
731    else if (noteFlag==24) {beatFlag.style.color="maroon";}
732    else  {beatFlag.style.color="black";}
733  }
734  timer = window.setTimeout(schedule, 0.1);
735  
736
737}
738
739function updateTime(){
740  //   dmpQ++; // $$ trying to implement dump-sets $$
741//document.getElementById('testIt2').innerHTML = "update 1";
742
743  b1v = document.getElementById('len1').value;  btVal[0]=Number(b1v);
744  b2v = document.getElementById('len2').value; btVal[1]=Number(b2v);
745  b3v = document.getElementById('len3').value; btVal[2]=Number(b3v);
746  b4v = document.getElementById('len4').value; btVal[3]=Number(b4v);
747  b5v = document.getElementById('len5').value; btVal[4]=Number(b5v);
748  b6v = document.getElementById('len6').value; btVal[5]=Number(b6v);
749  b7v = document.getElementById('len7').value; btVal[6]=Number(b7v);
750  b8v = document.getElementById('len8').value; btVal[7]=Number(b8v);
751  b9v = document.getElementById('len9').value; btVal[8]=Number(b9v);
752  b10v = document.getElementById('len10').value; btVal[9]=Number(b10v);
753  b11v = document.getElementById('len11').value; btVal[10]=Number(b11v);
754  b12v = document.getElementById('len12').value; btVal[11]=Number(b12v);
755  b13v = document.getElementById('len13').value; btVal[12]=Number(b13v);
756  b14v = document.getElementById('len14').value; btVal[13]=Number(b14v);
757  b15v = document.getElementById('len15').value; btVal[14]=Number(b15v);
758  b16v = document.getElementById('len16').value; btVal[15]=Number(b16v);
759  b17v = document.getElementById('len17').value; btVal[16]=Number(b17v);
760  b18v = document.getElementById('len18').value; btVal[17]=Number(b18v);
761  b19v = document.getElementById('len19').value; btVal[18]=Number(b19v);
762  b20v = document.getElementById('len20').value; btVal[19]=Number(b20v);
763  b21v = document.getElementById('len21').value; btVal[20]=Number(b21v);
764  b22v = document.getElementById('len22').value; btVal[21]=Number(b22v);
765  b23v = document.getElementById('len23').value; btVal[22]=Number(b23v);
766  b24v = document.getElementById('len24').value; btVal[23]=Number(b24v);
767  bts = document.getElementById('beatCount').value;
768  bAllv = Number(b1v) +Number(b2v)+Number(b3v)+Number(b4v)+Number(b5v)   +Number(b6v)+Number(b7v) +Number(b8v) +Number(b9v)+Number(b10v)+ Number(b11v)+Number(b12v)+Number(b13v)+Number(b14v)+Number(b15v)+Number(b16v)
769  +Number(b17v) +Number(b18v) +Number(b19v)+Number(b20v) +Number(b21v)+Number(b22v)+Number(b23v)+Number(b24v);
770  var stp = 0; var rnge = Number(0); var rng; var odds= 0;
771  var mov = 0; var dir = 0; var pik = 0; var amt = 0; var pMov;
772  var top; var bot;
773  var pot = new Array(1,1,2,1,2,3,1,2,3,4,1,2,3,4,5,1,2,3,4,5,6,1,2,3,4,5,6,7,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,11,1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12,13,1,2,3,4,5,6,7,8,9,10,11,12,13,14,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21);
774  var sz = new Array(0,1,3,6,10,15,21,28,36,45,55,66,78,91,105,120,136,153,171,190,210);
775  if (flxOn.checked) {
776  stp = Number(document.getElementById('flxStp').value);
777  rng = Number(document.getElementById('flxRng').value);
778  odds = Number(document.getElementById('flxOds').value);
779
780 mov = Math.floor(Math.random() * (odds+1) );
781  if (mov == odds) {mov = 1;}
782  else {mov = 0;}
783  dir = Math.floor(Math.random() * 2);
784
785  if (flxT == top) {dir = -1; }
786  else if (flxT == bot) {dir = 1;}
787  else if (dir == 0) {dir= -1;}
788
789  pik = Math.floor(Math.random() * sz[stp]);
790  amt = pot[pik];
791  //var dbD = 3 + stp*2;
792  //flex = (Math.floor((Math.random() * dbD ))- (stp+1))% (stp+1);
793  }
794
795  flex = mov * dir * amt;
796rnge = Math.round((rng*.01)*core);
797
798
799  flxT = parseInt(tempo_rge.value, 10)+flex;  
800  top = core + rnge;
801  bot = core - rnge;
802  if ( flxT > (core + rnge)) {flxT = (core + rnge); }
803  else if (flxT < (core - rnge)) {flxT = core - rnge;}
804  
805
806  tempo_rge.value = flxT;
807  tempo_disp.innerHTML = flxT;
808    totMs = Math.round((60/flxT)*bts*1000);
809  document.getElementById('mills').innerHTML = "["+totMs+" ms]";
810    subMs = Math.round(totMs/bangTot);
811  document.getElementById('subMs').innerHTML = "{"+subMs+" ms}";
812  var newTemp = 60000*bangTot/(flxT*bts);
813  document.getElementById('bangTemp').innerHTML = "~"+Math.round(newTemp)+" bpm";
814
815
816//document.getElementById('testIt1').innerHTML = "r% "+rng;
817//document.getElementById('testIt2').innerHTML = "c "+core;
818//document.getElementById('testIt3').innerHTML = "r "+rnge;
819//document.getElementById('testIt4').innerHTML = "m "+mov;
820//document.getElementById('testIt5').innerHTML = "d "+dir;
821//document.getElementById('testIt6').innerHTML = "a "+amt;
822//document.getElementById('testIt7').innerHTML = "f "+flex;
823//document.getElementById('testIt8').innerHTML = "t "+flxT;
824
825
826if (noteFlag==0)
827  {drag[0] = (60.0 / flxT)*bts*(b1v/bAllv); curtime += drag[0];}
828  else if (noteFlag==1)
829  {drag[1] = (60.0 / flxT)*bts*(b2v/bAllv); curtime += drag[1];}
830    else if (noteFlag==2)
831  {drag[2] = (60.0 / flxT)*bts*(b3v/bAllv); curtime += drag[2];}
832     else if (noteFlag==3)
833  {drag[3] = (60.0 / flxT)*bts*(b4v/bAllv); curtime += drag[3];}
834     else if (noteFlag==4)
835  {drag[4] = (60.0 / flxT)*bts*(b5v/bAllv); curtime += drag[4];}
836     else if (noteFlag==5)
837  {drag[5] = (60.0 / flxT)*bts*(b6v/bAllv); curtime += drag[5];}
838    else if (noteFlag==6)
839  {drag[6] = (60.0 / flxT)*bts*(b7v/bAllv); curtime += drag[6];}
840    else if (noteFlag==7)
841  {drag[7] = (60.0 / flxT)*bts*(b8v/bAllv); curtime += drag[7];}
842     else if (noteFlag==8)
843  {drag[8] = (60.0 / flxT)*bts*(b9v/bAllv); curtime += drag[8];}
844     else if (noteFlag==9)
845  {drag[9] = (60.0 / flxT)*bts*(b10v/bAllv); curtime += drag[9];}
846     else if (noteFlag==10)
847  {drag[10] = (60.0 / flxT)*bts*(b11v/bAllv); curtime += drag[10];}
848    else if (noteFlag==11)
849  {drag[11] = (60.0 / flxT)*bts*(b12v/bAllv); curtime += drag[11];}
850      else if (noteFlag==12)
851  {drag[12] = (60.0 / flxT)*bts*(b13v/bAllv); curtime += drag[12];}
852       else if (noteFlag==13)
853  {drag[13] = (60.0 / flxT)*bts*(b14v/bAllv); curtime += drag[13];}
854       else if (noteFlag==14)
855  {drag[14] = (60.0 / flxT)*bts*(b15v/bAllv); curtime += drag[14];}
856       else if (noteFlag==15)
857  {drag[15] = (60.0 / flxT)*bts*(b16v/bAllv); curtime += drag[15];}
858      else if (noteFlag==16)
859  {drag[16] = (60.0 / flxT)*bts*(b17v/bAllv); curtime += drag[16];}
860    else if (noteFlag==17)
861  {drag[17] = (60.0 / flxT)*bts*(b18v/bAllv); curtime += drag[17];}
862     else if (noteFlag==18)
863  {drag[18] = (60.0 / flxT)*bts*(b19v/bAllv); curtime += drag[18];}
864     else if (noteFlag==19)
865  {drag[19] = (60.0 / flxT)*bts*(b20v/bAllv); curtime += drag[19];}
866       else if (noteFlag==20)
867  {drag[20] = (60.0 / flxT)*bts*(b21v/bAllv); curtime += drag[20];}
868    else if (noteFlag==21)
869  {drag[21] = (60.0 / flxT)*bts*(b22v/bAllv); curtime += drag[21];}
870      else if (noteFlag==22)
871  {drag[22] = (60.0 / flxT)*bts*(b23v/bAllv); curtime += drag[22];}
872       else if (noteFlag==23)
873  {drag[23] = (60.0 / flxT)*bts*(b24v/bAllv); curtime += drag[23];}
874      else 
875  {curtime += 60.0 / flxT;}
876  
877//document.getElementById('testIt1').innerHTML = "b1 "+(60.0 / flxT)*bts*(b1v/bAllv);
878//document.getElementById('testIt2').innerHTML = " b2 "+(60.0 / flxT)*bts*(b2v/bAllv);
879//document.getElementById('testIt3').innerHTML = " b3 "+(60.0 / flxT)*bts*(b3v/bAllv);
880}
881
882function playNote(t){
883  //if (beepIt.checked)  {beep=1;}
884  //else {beep=0;}
885
886  var note = audioCtx.createOscillator();
887  //var dg = 0.9;
888  note.connect(volume);
889  volume.connect(audioCtx.destination);
890  volume.gain.setValueAtTime(beep, audioCtx.currentTime);
891  //hand.play();
892  note.type = 'triangle';
893  var fiddle;
894    soundfont(ctx0, fiddle).then(function(instrument) {
895     fiddle = instrument;
896      });
897
898  if(accented){
899  
900      note.frequency.setValueAtTime(bee[noteFlag], audioCtx.currentTime); 
901      if (beep==0) {
902        if (acc[noteFlag]==.1 && subMute==0) {snare2(.1, drag[noteFlag]*.07);}
903        else if (acc[noteFlag]==.1 && subMute ==1) {snare2(0, drag[noteFlag]*dg);}
904        else if (acc[noteFlag]==.2 && subMute==0) {snare2(.2, drag[noteFlag]*dg);}
905        else if (acc[noteFlag]==.2 && subMute ==1) {snare2(0, drag[noteFlag]*dg);}
906        else if (acc[noteFlag]==.4 && subMute==0) {hihat(drag[noteFlag]*dg);}
907        else if (acc[noteFlag]==.4 && subMute ==1) {hihat2(0, drag[noteFlag]*dg);}
908        else if (acc[noteFlag]==.8 && subMute==0) {snare2(.8, drag[noteFlag]*dg);}
909        else if (acc[noteFlag]==.8 && subMute ==1) {snare2(0, drag[noteFlag]*dg);}
910        else if (acc[noteFlag]==1.0 && subMute==0) { kick(drag[noteFlag]*dg);}
911        else if (acc[noteFlag]==1.0 && subMute ==1) {snare2(0, drag[noteFlag]*dg);}
912        else if (acc[noteFlag]==1.5) { kick(drag[noteFlag]*dg);}
913        else if (acc[noteFlag]==2.0){  snare2(.8, drag[noteFlag]*dg);}
914        else if (acc[noteFlag]==3.0) {   
915                kick(drag[noteFlag]*dg); snare2(.7,drag[noteFlag]*dg); }
916       else if (acc[noteFlag]==4.0)       { 
917                 kick(drag[noteFlag]*dg);
917 hihat(drag[noteFlag]*dg);}
918       else {snare2(0, drag[noteFlag]*dg); } // fontItTest();
919        }  
920       else if (beep==4) {
921       if (noteFlag==0) {fiddle.play('C4').stop(t + 0.1);}
922       else if (noteFlag==1) {fiddle.play('E4').stop(t + 0.1);}
923       else if (noteFlag==2) {fiddle.play('G4').stop(t + 0.1); }
924      }  // end else IF
925  } // firstBeating.Checked  
926  
927  else{
928      for(var i=0; i < beatDots.length; i++){    
929        if(beatDots[noteFlag].className == "beat active"){
930          note.frequency.setValueAtTime(800, audioCtx.currentTime);
931        }
932        else{
933          note.frequency.setValueAtTime(400, audioCtx.currentTime);
934          if (beep==0) {
935          snare(); //stik.play(); 
936          }      
937        }
938      } 
939    }
940   // drag[noteFlag]*.9
941  // fontItTest();
942  
943note.start(t); note.stop(t + .2); 
944 
945//document.getElementById('testIt1').innerHTML = "playNote";
946
947}
948
949function playSubNote(nt){
950  var subnote = SubAudioCtx.createOscillator();
951  
952  subvolume.connect(SubAudioCtx.destination);
953  subvolume.gain.setValueAtTime(0.2, SubAudioCtx.currentTime);   
954  
955  subnote.connect(subvolume);
956  subnote.type = 'triangle';
957  subnote.frequency.setValueAtTime(400, SubAudioCtx.currentTime);  
958  
959  subnote.start(nt);
960  subnote.stop(nt + 0.04); 
961}
962
963function clickDots(){
964  for(u = 0; u < beatDots.length; u++){
965    beatDots[u].addEventListener('click', function(){
966      if(this.className === "beat active"){
967         this.className = "beat";
968      }
969      else{
970        this.className += " active";     
971      }
972    });
973  }  
974}
975//clickDots()
976
977function spOn(){ 
978space = 1; tapping.innerHTML = "&nbsp;&nbsp;&nbsp;[spacebar]&nbsp;&nbsp;"; tapCount=bts*3 -1;
979document.getElementById('play').style.backgroundColor ="#90ee90";
980document.getElementById('tap').style.backgroundColor ="#d4d4d4";
981document.getElementById('tap').innerHTML ="&nbsp;&nbsp;Tap Tile&nbsp;&nbsp;";
982}
983function spOff() {
984space = 0;  tapping.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; tapCount=bts*3 -1;
985document.getElementById('play').style.backgroundColor ="#d4d4d4";
986document.getElementById('tap').style.backgroundColor ="#d4d4d4";
987document.getElementById('tap').innerHTML ="&nbsp;&nbsp;Tap Tile&nbsp;&nbsp;";
988}
989
990function meterIt(){
991if (meterOn.checked) {
992   document.getElementById('bangTemp').className = "min-btn";
993   document.getElementById('bangTot').className = "min-btn";
994   document.getElementById('subMs').className = "min-btn";
995   document.getElementById('bangTot').style.color = "blue";
996   document.getElementById('ac1').value = "3.0"; level();
997   document.getElementById('btNm').innerHTML = "tpm";
998}
999else {
1000  document.getElementById('bangTemp').className = "min-btn hidden";
1001     document.getElementById('subMs').className = "min-btn hidden";
1002  document.getElementById('bangTot').style.color = "black";
1003  document.getElementById('bangTot').innerHTML = "Sub";
1004     document.getElementById('btNm').innerHTML = "bpm";
1005  //document.getElementById('ac1').value = "1.0"; level();
1006}
1007} // meterIt()
1008
1009function soundIt() {
1010  var snd = document.getElementById('sound').value;
1011  if (snd=="0") {beep=0; accented=0; subMute=0;}
1012  else if (snd=="1") {accented=1; beep=0; subMute=0;}
1013  else if (snd=="2") {accented=1; beep=0; subMute=1;}
1014  else if (snd=="3") {accented=1; beep=1; subMute=0;}
1015  else if (snd=="4") {beep=1; accented=0 ;subMute=0;}
1016  // else if (snd=="4") {beep=4; accented=1;}
1017document.getElementById('testIt1').innerHTML = " accent "+accented;
1018document.getElementById('testIt2').innerHTML = " beep "+beep;
1019}// end soundIt()
1020
1021function dragIt() {
1022dg = document.getElementById('sus').value;
1023}
1024
1025
1026function isop() {
1027var isIos = navigator.userAgent.toLowerCase().match(/(iphone|ipad)/i);
1028document.getElementById('testIt9').innerHTML = navigator.userAgent;
1029if (isIos) {
1030document.getElementById('ac23').style.color ="purple";
1031document.getElementById('iosSp').width ="10";
1032document.getElementById('ac1').style.marginRight ="1px"; 
1033document.getElementById('ac2').style.marginRight ="1px"; 
1034document.getElementById('ac3').style.marginRight ="1px"; 
1035document.getElementById('ac4').style.marginRight ="1px"; 
1036document.getElementById('ac5').style.marginRight ="1px"; 
1037document.getElementById('ac6').style.marginRight ="1px"; 
1038document.getElementById('ac7').style.marginRight ="1px"; 
1039document.getElementById('ac8').style.marginRight ="1px"; 
1040document.getElementById('ac9').style.marginRight ="1px"; 
1041document.getElementById('ac10').style.marginRight ="1px"; 
1042document.getElementById('ac11').style.marginRight ="1px"; 
1043document.getElementById('ac12').style.marginRight ="1px"; 
1044document.getElementById('ac13').style.marginRight ="1px"; 
1045document.getElementById('ac14').style.marginRight ="1px"; 
1046document.getElementById('ac15').style.marginRight ="1px"; 
1047document.getElementById('ac16').style.marginRight ="1px"; 
1048document.getElementById('ac17').style.marginRight ="1px"; 
1049document.getElementById('ac18').style.marginRight ="1px"; 
1050document.getElementById('ac19').style.marginRight ="1px"; 
1051document.getElementById('ac20').style.marginRight ="1px"; 
1052document.getElementById('ac21').style.marginRight ="1px"; 
1053document.getElementById('ac22').style.marginRight ="1px"; 
1054document.getElementById('ac23').style.marginRight ="1px"; 
1055document.getElementById('ac24').style.marginRight ="1px"; 
1056}
1057else {//document.getElementById('ac2').style.marginRight ="40px";
1058document.getElementById('ac24').style.color ="purple";}
1059} // end dark()
1060
1061
1062function startIt() {
1063  curtime = audioCtx.currentTime;
1064  onOff = 1;
1065if (first==0){
1066  core = Number(document.getElementById('t').value);  first=1;
1067 }
1068    tempo_rge.value = core;
1069  tempo_disp.innerHTML = core;
1070  schedule(); 
1071  start.style.display = "none";
1072  stop.style.display = "block";
1073   tapCount=bts*3 - 1; 
1074   if (bts==3) {  document.getElementById('sign').className = "";}
1075   else{  document.getElementById('sign').className = "hidden";}
1076   spOff();
1077}
1078
1079function stopIt(){
1080 document.getElementById('mg').src="colors/mg_plain.png";
1081  window.clearInterval(timer);
1082  noteFlag = 0;  tapCount=bts*3 - 1; onOff=0;
1083  beatFlag.innerHTML = "";
1084  tempo_rge.value = core;
1085  tempo_disp.innerHTML = core;
1086 
1087var child = document.querySelectorAll('#dotTarget li');      
1088      for (y=1;y<child.length;y++) {
1089      child[y].classList.remove("on-temp");
1090      child[y].style.background="grey";
1091      child[y].style.color="grey";
1092      }
1093
1094  stop.style.display = "none";
1095  start.style.display = "block";
1096}
1097// § start button §
1098start.addEventListener('click', function(){
1099  curtime = audioCtx.currentTime;
1100  onOff=1;
1101    tempo_rge.value = core;
1102  tempo_disp.innerHTML = core;
1103  schedule(); 
1104  this.style.display = "none";
1105  stop.style.display = "block";
1106   tapCount=bts*3 - 1; 
1107      if (bts==3) {  document.getElementById('sign').className = "";}
1108   else{  document.getElementById('sign').className = "hidden";}
1109   spOff();
1110   tapping.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
1111});
1112
1113// § stop button §
1114stop.addEventListener('click', function(){
1115  window.clearInterval(timer);
1116  noteFlag = 0;  tapCount=bts*3 -1; onOff=0;
1117    tempo_rge.value = core;
1118  tempo_disp.innerHTML = core;
1119  beatFlag.innerHTML = "";
1120
1121  var child = document.querySelectorAll('#dotTarget li');      
1122      for (y=1;y<child.length;y++) {
1123      child[y].classList.remove("on-temp");
1124      child[y].style.background="grey";
1125      child[y].style.color="grey";
1126      }
1127  this.style.display = "none";
1128  start.style.display = "block";
1129});
1130
1131// § takt tap function §
1132tap.addEventListener('click', function(){
1133 
1134    var isAndroid = navigator.userAgent.toLowerCase().match(/android/i); 
1135  if (isAndroid) {  android=1; }
1136  else { android=0;}
1137 document.getElementById('tap').innerHTML = "&nbsp;&nbsp;Tap Tile&nbsp;&nbsp;" ;
1138 document.getElementById('tap').style.backgroundColor ="#90ee90";
1139 document.getElementById('play').style.backgroundColor ="#d4d4d4";
1140 var dt = new Date();  // THIS is the d
1141  var temp = dt.getTime();
1142  if ((temp/delta)/1000 > 2) {
1143  tapCount=bts*3 -1 ; 
1144  for (y=0; y<bts*3;y++){  // THIS is the i
1145   meas[y]=60;
1146   beas[y]=1000;
1147}
1148  }
1149  var tap_avg,b_tot;
1150  var b1_avg, b2_avg, b3_avg, b4_avg, b5_avg, b6_avg, b7_avg, b8_avg, b9_avg, b10_avg,  
1151     b11_avg, b12_avg, b13_avg, b14_avg, b15_avg, b16_avg, b17_avg, b18_avg, b19_avg, b20_avg , b21_avg, b22_avg, b23_avg, b24_avg;
1152  var tap_temp = Math.round(60000 / (temp - delta));
1153  meas[tapCount] = Math.round(60000 / (temp - delta));
1154  beas[tapCount] = temp - delta;
1155
1156if (bts==1) {
1157  b1_avg = Math.round( (beas[0]+beas[1]+beas[2])/3 );
1158  b_tot = b1_avg;}
1159  
1160else if (bts==2) {
1161  b1_avg = Math.round( (beas[0]+beas[2]+beas[4])/3 );
1162  b2_avg = Math.round((beas[1]+beas[3]+beas[5])/(3));
1163  b_tot = b1_avg + b2_avg;}
1164  
1165else if (bts==3) {
1166  b1_avg = Math.round( (beas[0]+beas[3]+beas[6])/3 );
1167  b2_avg = Math.round((beas[1]+beas[4]+beas[7])/(3));
1168  b3_avg = Math.round((beas[2]+beas[5]+beas[8])/(3));
1169  b_tot = b1_avg + b2_avg + b3_avg;}
1170else if (bts==4) {
1171  b1_avg = Math.round( (beas[0]+beas[4]+beas[8])/3 );
1172  b2_avg = Math.round((beas[1]+beas[5]+beas[9])/(3));
1173  b3_avg = Math.round((beas[2]+beas[6]+beas[10])/(3));
1174  b4_avg = Math.round((beas[3]+beas[7]+beas[11])/(3));
1175  b_tot = b1_avg + b2_avg + b3_avg + b4_avg;}
1176  
1177else if (bts==5) {
1178  b1_avg = Math.round( (beas[0]+beas[5]+beas[10])/3 );
1179  b2_avg = Math.round((beas[1]+beas[6]+beas[11])/(3));
1180  b3_avg = Math.round((beas[2]+beas[7]+beas[12])/(3));
1181  b4_avg = Math.round((beas[3]+beas[8]+beas[13])/(3));
1182  b5_avg = Math.round((beas[4]+beas[9]+beas[14])/(3));
1183  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg;}
1184  
1185else if (bts==6) {
1186  b1_avg = Math.round( (beas[0]+beas[6]+beas[12])/3 );
1187  b2_avg = Math.round((beas[1]+beas[7]+beas[13])/(3));
1188  b3_avg = Math.round((beas[2]+beas[8]+beas[14])/(3));
1189  b4_avg = Math.round((beas[3]+beas[9]+beas[15])/(3));
1190  b5_avg = Math.round((beas[4]+beas[10]+beas[16])/(3));
1191  b6_avg = Math.round((beas[5]+beas[11]+beas[17])/(3));
1192  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg;}
1193  
1194else if (bts==7) {
1195  b1_avg = Math.round( (beas[0]+beas[7]+beas[14])/3 );
1196  b2_avg = Math.round((beas[1]+beas[8]+beas[15])/(3));
1197  b3_avg = Math.round((beas[2]+beas[9]+beas[16])/(3));
1198  b4_avg = Math.round((beas[3]+beas[10]+beas[17])/(3));
1199  b5_avg = Math.round((beas[4]+beas[11]+beas[18])/(3));
1200  b6_avg = Math.round((beas[5]+beas[12]+beas[19])/(3));
1201  b7_avg = Math.round((beas[6]+beas[13]+beas[20])/(3));
1202  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg + b7_avg;}
1203  
1204  else if (bts==8) {
1205  b1_avg = Math.round( (beas[0]+beas[8]+beas[16])/3 );
1206  b2_avg = Math.round((beas[1]+beas[9]+beas[17])/(3));
1207  b3_avg = Math.round((beas[2]+beas[10]+beas[18])/(3));
1208  b4_avg = Math.round((beas[3]+beas[11]+beas[19])/(3));
1209  b5_avg = Math.round((beas[4]+beas[12]+beas[20])/(3));
1210  b6_avg = Math.round((beas[5]+beas[13]+beas[21])/(3));
1211  b7_avg = Math.round((beas[6]+beas[14]+beas[22])/(3));
1212  b8_avg = Math.round((beas[7]+beas[15]+beas[23])/(3));
1213  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1214   + b7_avg + b8_avg;}
1215   
1216  else if (bts==9) {
1217  b1_avg = Math.round( (beas[0]+beas[9]+beas[18])/3 );
1218  b2_avg = Math.round((beas[1]+beas[10]+beas[19])/(3));
1219  b3_avg = Math.round((beas[2]+beas[11]+beas[20])/(3));
1220  b4_avg = Math.round((beas[3]+beas[12]+beas[21])/(3));
1221  b5_avg = Math.round((beas[4]+beas[13]+beas[22])/(3));
1222  b6_avg = Math.round((beas[5]+beas[14]+beas[23])/(3));
1223  b7_avg = Math.round((beas[6]+beas[15]+beas[24])/(3));
1224  b8_avg = Math.round((beas[7]+beas[16]+beas[25])/(3));
1225  b9_avg = Math.round((beas[8]+beas[17]+beas[26])/(3));
1226  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1227   + b7_avg + b8_avg + b9_avg;}
1228
1229  else if (bts==10) {
1230  b1_avg = Math.round( (beas[0]+beas[10]+beas[20])/3 );
1231  b2_avg = Math.round((beas[1]+beas[11]+beas[21])/(3));
1232  b3_avg = Math.round((beas[2]+beas[12]+beas[22])/(3));
1233  b4_avg = Math.round((beas[3]+beas[13]+beas[23])/(3));
1234  b5_avg = Math.round((beas[4]+beas[14]+beas[24])/(3));
1235  b6_avg = Math.round((beas[5]+beas[15]+beas[25])/(3));
1236  b7_avg = Math.round((beas[6]+beas[16]+beas[26])/(3));
1237  b8_avg = Math.round((beas[7]+beas[17]+beas[27])/(3));
1238  b9_avg = Math.round((beas[8]+beas[18]+beas[28])/(3));
1239  b10_avg = Math.round((beas[9]+beas[19]+beas[29])/(3));
1240  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1241   + b7_avg + b8_avg + b9_avg + b10_avg;}
1242   
1243     else if (bts==11) {
1244  b1_avg = Math.round( (beas[0]+beas[11]+beas[22])/3 );
1245  b2_avg = Math.round((beas[1]+beas[12]+beas[23])/(3));
1246  b3_avg = Math.round((beas[2]+beas[13]+beas[24])/(3));
1247  b4_avg = Math.round((beas[3]+beas[14]+beas[25])/(3));
1248  b5_avg = Math.round((beas[4]+beas[15]+beas[26])/(3));
1249  b6_avg = Math.round((beas[5]+beas[16]+beas[27])/(3));
1250  b7_avg = Math.round((beas[6]+beas[17]+beas[28])/(3));
1251  b8_avg = Math.round((beas[7]+beas[18]+beas[29])/(3));
1252  b9_avg = Math.round((beas[8]+beas[19]+beas[30])/(3));
1253  b10_avg = Math.round((beas[9]+beas[20]+beas[31])/(3));
1254  b11_avg = Math.round((beas[10]+beas[21]+beas[32])/(3));
1255  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1256   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg;}
1257   
1258 else if (bts==12) {
1259  b1_avg = Math.round( (beas[0]+beas[12]+beas[24])/3 );
1260  b2_avg = Math.round((beas[1]+beas[13]+beas[25])/(3));
1261  b3_avg = Math.round((beas[2]+beas[14]+beas[26])/(3));
1262  b4_avg = Math.round((beas[3]+beas[15]+beas[27])/(3));
1263  b5_avg = Math.round((beas[4]+beas[16]+beas[28])/(3));
1264  b6_avg = Math.round((beas[5]+beas[17]+beas[29])/(3));
1265  b7_avg = Math.round((beas[6]+beas[18]+beas[30])/(3));
1266  b8_avg = Math.round((beas[7]+beas[19]+beas[31])/(3));
1267  b9_avg = Math.round((beas[8]+beas[20]+beas[32])/(3));
1268  b10_avg = Math.round((beas[9]+beas[21]+beas[33])/(3));
1269  b11_avg = Math.round((beas[10]+beas[22]+beas[34])/(3));
1270  b12_avg = Math.round((beas[11]+beas[23]+beas[35])/(3));
1271  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1272   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg; }
1273   
1274  else if (bts==13) {
1275  b1_avg = Math.round( (beas[0]+beas[13]+beas[26])/3 );
1276  b2_avg = Math.round((beas[1]+beas[14]+beas[27])/(3));
1277  b3_avg = Math.round((beas[2]+beas[15]+beas[28])/(3));
1278  b4_avg = Math.round((beas[3]+beas[16]+beas[29])/(3));
1279  b5_avg = Math.round((beas[4]+beas[17]+beas[30])/(3));
1280  b6_avg = Math.round((beas[5]+beas[18]+beas[31])/(3));
1281  b7_avg = Math.round((beas[6]+beas[19]+beas[32])/(3));
1282  b8_avg = Math.round((beas[7]+beas[20]+beas[33])/(3));
1283  b9_avg = Math.round((beas[8]+beas[21]+beas[34])/(3));
1284  b10_avg = Math.round((beas[9]+beas[22]+beas[35])/(3));
1285  b11_avg = Math.round((beas[10]+beas[23]+beas[36])/(3));
1286  b12_avg = Math.round((beas[11]+beas[24]+beas[37])/(3));
1287  b13_avg = Math.round((beas[12]+beas[25]+beas[38])/(3));
1288  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1289   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg + b13_avg; }
1290   
1291 else if (bts==14) {
1292  b1_avg = Math.round( (beas[0]+beas[14]+beas[28])/3 );
1293  b2_avg = Math.round((beas[1]+beas[15]+beas[29])/(3));
1294  b3_avg = Math.round((beas[2]+beas[16]+beas[30])/(3));
1295  b4_avg = Math.round((beas[3]+beas[17]+beas[31])/(3));
1296  b5_avg = Math.round((beas[4]+beas[18]+beas[32])/(3));
1297  b6_avg = Math.round((beas[5]+beas[19]+beas[33])/(3));
1298  b7_avg = Math.round((beas[6]+beas[20]+beas[34])/(3));
1299  b8_avg = Math.round((beas[7]+beas[21]+beas[35])/(3));
1300  b9_avg = Math.round((beas[8]+beas[22]+beas[36])/(3));
1301  b10_avg = Math.round((beas[9]+beas[23]+beas[37])/(3));
1302  b11_avg = Math.round((beas[10]+beas[24]+beas[38])/(3));
1303  b12_avg = Math.round((beas[11]+beas[25]+beas[39])/(3));
1304  b13_avg = Math.round((beas[12]+beas[26]+beas[40])/(3));
1305  b14_avg = Math.round((beas[13]+beas[27]+beas[41])/(3));
1306  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1307   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1308   + b13_avg + b14_avg; }
1309   
1310  else if (bts==15) {
1311  b1_avg = Math.round( (beas[0]+beas[15]+beas[30])/3 );
1312  b2_avg = Math.round((beas[1]+beas[16]+beas[31])/(3));
1313  b3_avg = Math.round((beas[2]+beas[17]+beas[32])/(3));
1314  b4_avg = Math.round((beas[3]+beas[18]+beas[33])/(3));
1315  b5_avg = Math.round((beas[4]+beas[19]+beas[34])/(3));
1316  b6_avg = Math.round((beas[5]+beas[20]+beas[35])/(3));
1317  b7_avg = Math.round((beas[6]+beas[21]+beas[36])/(3));
1318  b8_avg = Math.round((beas[7]+beas[22]+beas[37])/(3));
1319  b9_avg = Math.round((beas[8]+beas[23]+beas[38])/(3));
1320  b10_avg = Math.round((beas[9]+beas[24]+beas[39])/(3));
1321  b11_avg = Math.round((beas[10]+beas[25]+beas[40])/(3));
1322  b12_avg = Math.round((beas[11]+beas[26]+beas[41])/(3));
1323  b13_avg = Math.round((beas[12]+beas[27]+beas[42])/(3));
1324  b14_avg = Math.round((beas[13]+beas[28]+beas[43])/(3));
1325  b15_avg = Math.round((beas[14]+beas[29]+beas[44])/(3));
1326  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1327   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1328   + b13_avg + b14_avg + b15_avg; }
1329   
1330  else if (bts==16) {
1331  b1_avg = Math.round( (beas[0]+beas[16]+beas[32])/3 );
1332  b2_avg = Math.round((beas[1]+beas[17]+beas[33])/(3));
1333  b3_avg = Math.round((beas[2]+beas[18]+beas[34])/(3));
1334  b4_avg = Math.round((beas[3]+beas[19]+beas[35])/(3));
1335  b5_avg = Math.round((beas[4]+beas[20]+beas[36])/(3));
1336  b6_avg = Math.round((beas[5]+beas[21]+beas[37])/(3));
1337  b7_avg = Math.round((beas[6]+beas[22]+beas[38])/(3));
1338  b8_avg = Math.round((beas[7]+beas[23]+beas[39])/(3));
1339  b9_avg = Math.round((beas[8]+beas[24]+beas[40])/(3));
1340  b10_avg = Math.round((beas[9]+beas[25]+beas[41])/(3));
1341  b11_avg = Math.round((beas[10]+beas[26]+beas[42])/(3));
1342  b12_avg = Math.round((beas[11]+beas[27]+beas[43])/(3));
1343  b13_avg = Math.round((beas[12]+beas[28]+beas[44])/(3));
1344  b14_avg = Math.round((beas[13]+beas[29]+beas[45])/(3));
1345  b15_avg = Math.round((beas[14]+beas[30]+beas[46])/(3));
1346  b16_avg = Math.round((beas[15]+beas[31]+beas[47])/(3));
1347  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1348   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1349   + b13_avg + b14_avg + b15_avg + b16_avg; }
1350
1351  else if (bts==17) {
1352  b1_avg = Math.round( (beas[0]+beas[17]+beas[34])/3 );
1353  b2_avg = Math.round((beas[1]+beas[18]+beas[35])/(3));
1354  b3_avg = Math.round((beas[2]+beas[19]+beas[36])/(3));
1355  b4_avg = Math.round((beas[3]+beas[20]+beas[37])/(3));
1356  b5_avg = Math.round((beas[4]+beas[21]+beas[38])/(3));
1357  b6_avg = Math.round((beas[5]+beas[22]+beas[39])/(3));
1358  b7_avg = Math.round((beas[6]+beas[23]+beas[40])/(3));
1359  b8_avg = Math.round((beas[7]+beas[24]+beas[41])/(3));
1360  b9_avg = Math.round((beas[8]+beas[25]+beas[42])/(3));
1361  b10_avg = Math.round((beas[9]+beas[26]+beas[43])/(3));
1362  b11_avg = Math.round((beas[10]+beas[27]+beas[44])/(3));
1363  b12_avg = Math.round((beas[11]+beas[28]+beas[45])/(3));
1364  b13_avg = Math.round((beas[12]+beas[29]+beas[46])/(3));
1365  b14_avg = Math.round((beas[13]+beas[30]+beas[47])/(3));
1366  b15_avg = Math.round((beas[14]+beas[31]+beas[48])/(3));
1367  b16_avg = Math.round((beas[15]+beas[32]+beas[49])/(3));
1368  b17_avg = Math.round((beas[16]+beas[33]+beas[50])/(3));
1369  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1370   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1371   + b13_avg + b14_avg + b15_avg + b16_avg + b17_avg; }
1372
1373  else if (bts==18) {
1374  b1_avg = Math.round( (beas[0]+beas[18]+beas[36])/3 );
1375  b2_avg = Math.round((beas[1]+beas[19]+beas[37])/(3));
1376  b3_avg = Math.round((beas[2]+beas[20]+beas[38])/(3));
1377  b4_avg = Math.round((beas[3]+beas[21]+beas[39])/(3));
1378  b5_avg = Math.round((beas[4]+beas[22]+beas[40])/(3));
1379  b6_avg = Math.round((beas[5]+beas[23]+beas[41])/(3));
1380  b7_avg = Math.round((beas[6]+beas[24]+beas[42])/(3));
1381  b8_avg = Math.round((beas[7]+beas[25]+beas[43])/(3));
1382  b9_avg = Math.round((beas[8]+beas[26]+beas[44])/(3));
1383  b10_avg = Math.round((beas[9]+beas[27]+beas[45])/(3));
1384  b11_avg = Math.round((beas[10]+beas[28]+beas[46])/(3));
1385  b12_avg = Math.round((beas[11]+beas[29]+beas[47])/(3));
1386  b13_avg = Math.round((beas[12]+beas[30]+beas[48])/(3));
1387  b14_avg = Math.round((beas[13]+beas[31]+beas[49])/(3));
1388  b15_avg = Math.round((beas[14]+beas[32]+beas[50])/(3));
1389  b16_avg = Math.round((beas[15]+beas[33]+beas[51])/(3));
1390  b17_avg = Math.round((beas[16]+beas[34]+beas[52])/(3));
1391  b18_avg = Math.round((beas[17]+beas[35]+beas[53])/(3));
1392  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1393   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1394   + b13_avg + b14_avg + b15_avg + b16_avg + b17_avg + b18_avg; }
1395
1396  else if (bts==19) {
1397  b1_avg = Math.round( (beas[0]+beas[19]+beas[38])/3 );
1398  b2_avg = Math.round((beas[1]+beas[20]+beas[39])/(3));
1399  b3_avg = Math.round((beas[2]+beas[21]+beas[40])/(3));
1400  b4_avg = Math.round((beas[3]+beas[22]+beas[41])/(3));
1401  b5_avg = Math.round((beas[4]+beas[23]+beas[42])/(3));
1402  b6_avg = Math.round((beas[5]+beas[24]+beas[43])/(3));
1403  b7_avg = Math.round((beas[6]+beas[25]+beas[44])/(3));
1404  b8_avg = Math.round((beas[7]+beas[26]+beas[45])/(3));
1405  b9_avg = Math.round((beas[8]+beas[27]+beas[46])/(3));
1406  b10_avg = Math.round((beas[9]+beas[28]+beas[47])/(3));
1407  b11_avg = Math.round((beas[10]+beas[29]+beas[48])/(3));
1408  b12_avg = Math.round((beas[11]+beas[30]+beas[49])/(3));
1409  b13_avg = Math.round((beas[12]+beas[31]+beas[50])/(3));
1410  b14_avg = Math.round((beas[13]+beas[32]+beas[51])/(3));
1411  b15_avg = Math.round((beas[14]+beas[33]+beas[52])/(3));
1412  b16_avg = Math.round((beas[15]+beas[34]+beas[53])/(3));
1413  b17_avg = Math.round((beas[16]+beas[35]+beas[54])/(3));
1414  b18_avg = Math.round((beas[17]+beas[36]+beas[55])/(3));
1415  b19_avg = Math.round((beas[18]+beas[37]+beas[56])/(3));
1416  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1417   + b7_avg + b
14178_avg + b9_avg + b10_avg + b11_avg + b12_avg
1418   + b13_avg + b14_avg + b15_avg + b16_avg + b17_avg + b18_avg
1419   + b19_avg; }
1420
1421  else if (bts==20) {
1422  b1_avg = Math.round( (beas[0]+beas[20]+beas[40])/3 );
1423  b2_avg = Math.round((beas[1]+beas[21]+beas[41])/(3));
1424  b3_avg = Math.round((beas[2]+beas[22]+beas[42])/(3));
1425  b4_avg = Math.round((beas[3]+beas[23]+beas[43])/(3));
1426  b5_avg = Math.round((beas[4]+beas[24]+beas[44])/(3));
1427  b6_avg = Math.round((beas[5]+beas[25]+beas[45])/(3));
1428  b7_avg = Math.round((beas[6]+beas[26]+beas[46])/(3));
1429  b8_avg = Math.round((beas[7]+beas[27]+beas[47])/(3));
1430  b9_avg = Math.round((beas[8]+beas[28]+beas[48])/(3));
1431  b10_avg = Math.round((beas[9]+beas[29]+beas[49])/(3));
1432  b11_avg = Math.round((beas[10]+beas[30]+beas[50])/(3));
1433  b12_avg = Math.round((beas[11]+beas[31]+beas[51])/(3));
1434  b13_avg = Math.round((beas[12]+beas[32]+beas[52])/(3));
1435  b14_avg = Math.round((beas[13]+beas[33]+beas[53])/(3));
1436  b15_avg = Math.round((beas[14]+beas[34]+beas[54])/(3));
1437  b16_avg = Math.round((beas[15]+beas[35]+beas[55])/(3));
1438  b17_avg = Math.round((beas[16]+beas[36]+beas[56])/(3));
1439  b18_avg = Math.round((beas[17]+beas[37]+beas[57])/(3));
1440  b19_avg = Math.round((beas[18]+beas[38]+beas[58])/(3));
1441  b20_avg = Math.round((beas[19]+beas[39]+beas[59])/(3));
1442  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1443   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1444   + b13_avg + b14_avg + b15_avg + b16_avg + b17_avg + b18_avg
1445   + b19_avg  + b20_avg; }
1446   
1447  else if (bts==21) {
1448  b1_avg = Math.round( (beas[0]+beas[21]+beas[42])/3 );
1449  b2_avg = Math.round((beas[1]+beas[22]+beas[43])/(3));
1450  b3_avg = Math.round((beas[2]+beas[23]+beas[44])/(3));
1451  b4_avg = Math.round((beas[3]+beas[24]+beas[45])/(3));
1452  b5_avg = Math.round((beas[4]+beas[25]+beas[46])/(3));
1453  b6_avg = Math.round((beas[5]+beas[26]+beas[47])/(3));
1454  b7_avg = Math.round((beas[6]+beas[27]+beas[48])/(3));
1455  b8_avg = Math.round((beas[7]+beas[28]+beas[49])/(3));
1456  b9_avg = Math.round((beas[8]+beas[29]+beas[50])/(3));
1457  b10_avg = Math.round((beas[9]+beas[30]+beas[51])/(3));
1458  b11_avg = Math.round((beas[10]+beas[31]+beas[52])/(3));
1459  b12_avg = Math.round((beas[11]+beas[32]+beas[53])/(3));
1460  b13_avg = Math.round((beas[12]+beas[33]+beas[54])/(3));
1461  b14_avg = Math.round((beas[13]+beas[34]+beas[55])/(3));
1462  b15_avg = Math.round((beas[14]+beas[35]+beas[56])/(3));
1463  b16_avg = Math.round((beas[15]+beas[36]+beas[57])/(3));
1464  b17_avg = Math.round((beas[16]+beas[37]+beas[58])/(3));
1465  b18_avg = Math.round((beas[17]+beas[38]+beas[59])/(3));
1466  b19_avg = Math.round((beas[18]+beas[39]+beas[60])/(3));
1467  b20_avg = Math.round((beas[19]+beas[40]+beas[61])/(3));
1468  b21_avg = Math.round((beas[20]+beas[41]+beas[62])/(3));
1469  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1470   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1471   + b13_avg + b14_avg + b15_avg + b16_avg + b17_avg + b18_avg
1472   + b19_avg  + b20_avg+ b21_avg; }  
1473     
1474  else if (bts==22) {
1475  b1_avg = Math.round( (beas[0]+beas[22]+beas[44])/3 );
1476  b2_avg = Math.round((beas[1]+beas[23]+beas[45])/(3));
1477  b3_avg = Math.round((beas[2]+beas[24]+beas[46])/(3));
1478  b4_avg = Math.round((beas[3]+beas[25]+beas[47])/(3));
1479  b5_avg = Math.round((beas[4]+beas[26]+beas[48])/(3));
1480  b6_avg = Math.round((beas[5]+beas[27]+beas[49])/(3));
1481  b7_avg = Math.round((beas[6]+beas[28]+beas[50])/(3));
1482  b8_avg = Math.round((beas[7]+beas[29]+beas[51])/(3));
1483  b9_avg = Math.round((beas[8]+beas[30]+beas[52])/(3));
1484  b10_avg = Math.round((beas[9]+beas[31]+beas[53])/(3));
1485  b11_avg = Math.round((beas[10]+beas[32]+beas[54])/(3));
1486  b12_avg = Math.round((beas[11]+beas[33]+beas[55])/(3));
1487  b13_avg = Math.round((beas[12]+beas[34]+beas[56])/(3));
1488  b14_avg = Math.round((beas[13]+beas[35]+beas[57])/(3));
1489  b15_avg = Math.round((beas[14]+beas[36]+beas[58])/(3));
1490  b16_avg = Math.round((beas[15]+beas[37]+beas[59])/(3));
1491  b17_avg = Math.round((beas[16]+beas[38]+beas[60])/(3));
1492  b18_avg = Math.round((beas[17]+beas[39]+beas[61])/(3));
1493  b19_avg = Math.round((beas[18]+beas[40]+beas[62])/(3));
1494  b20_avg = Math.round((beas[19]+beas[41]+beas[63])/(3));
1495  b21_avg = Math.round((beas[20]+beas[42]+beas[64])/(3));
1496  b22_avg = Math.round((beas[21]+beas[43]+beas[62])/(3));
1497  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + 65+ b6_avg
1498   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1499   + b13_avg + b14_avg + b15_avg + b16_avg + b17_avg + b18_avg
1500   + b19_avg  + b20_avg + b21_avg + b22_avg; } 
1501// testIt4.innerHTML = b1_avg; testIt5.innerHTML = b2_avg; testIt6.innerHTML =b3_avg;
1502//  testIt7.innerHTML = b1_avg/b_tot; testIt8.innerHTML = b2_avg/b_tot; testIt9.innerHTML = b3_avg/b_tot;
1503     pr1.value = Math.round(100*(b1_avg/b_tot))+"% ";
1504     pr2.value = Math.round(100*(b2_avg/b_tot))+"% ";
1505     pr3.value = Math.round(100*(b3_avg/b_tot))+"% ";
1506     pr4.value = Math.round(100*(b4_avg/b_tot))+"% ";
1507     pr5.value = Math.round(100*(b5_avg/b_tot))+"% ";
1508     pr6.value = Math.round(100*(b6_avg/b_tot))+"% ";
1509     pr7.value = Math.round(100*(b7_avg/b_tot))+"% ";
1510     pr8.value = Math.round(100*(b8_avg/b_tot))+"% ";
1511     pr9.value = Math.round(100*(b9_avg/b_tot))+"% ";
1512     pr10.value = Math.round(100*(b10_avg/b_tot))+"% ";
1513     pr11.value = Math.round(100*(b11_avg/b_tot))+"% ";
1514     pr12.value = Math.round(100*(b12_avg/b_tot))+"% ";
1515     pr13.value = Math.round(100*(b13_avg/b_tot))+"% ";
1516     pr14.value = Math.round(100*(b14_avg/b_tot))+"% ";
1517     pr15.value = Math.round(100*(b15_avg/b_tot))+"% ";
1518     pr16.value = Math.round(100*(b16_avg/b_tot))+"% ";  
1519     pr17.value = Math.round(100*(b17_avg/b_tot))+"% ";
1520     pr18.value = Math.round(100*(b18_avg/b_tot))+"% ";
1521     pr19.value = Math.round(100*(b19_avg/b_tot))+"% ";
1522     pr20.value = Math.round(100*(b20_avg/b_tot))+"% ";
1523     pr21.value = Math.round(100*(b21_avg/b_tot))+"% ";
1524     pr22.value = Math.round(100*(b22_avg/b_tot))+"% ";
1525     pr23.value = Math.round(100*(b23_avg/b_tot))+"% ";
1526     pr24.value = Math.round(100*(b24_avg/b_tot))+"% ";   
1527     document.getElementById('color1').width = 3*Math.round(100*(b1_avg/b_tot));
1528     document.getElementById('color2').width = 3*Math.round(100*(b2_avg/b_tot));
1529     document.getElementById('color3').width = 3*Math.round(100*(b3_avg/b_tot));
1530     document.getElementById('color4').width = 3*Math.round(100*(b4_avg/b_tot));
1531     document.getElementById('color5').width = 3*Math.round(100*(b5_avg/b_tot));
1532     document.getElementById('color6').width = 3*Math.round(100*(b6_avg/b_tot));
1533     document.getElementById('color7').width = 3*Math.round(100*(b7_avg/b_tot));
1534     document.getElementById('color8').width = 3*Math.round(100*(b8_avg/b_tot));
1535     document.getElementById('color9').width = 3*Math.round(100*(b9_avg/b_tot));
1536     document.getElementById('color10').width = 3*Math.round(100*(b10_avg/b_tot));
1537     document.getElementById('color11').width = 3*Math.round(100*(b11_avg/b_tot));
1538     document.getElementById('color12').width = 3*Math.round(100*(b12_avg/b_tot));
1539     document.getElementById('color13').width = 3*Math.round(100*(b13_avg/b_tot));
1540     document.getElementById('color14').width = 3*Math.round(100*(b14_avg/b_tot));
1541     document.getElementById('color15').width = 3*Math.round(100*(b15_avg/b_tot));
1542     document.getElementById('color16').width = 3*Math.round(100*(b16_avg/b_tot));
1543     document.getElementById('color17').width = 3*Math.round(100*(b17_avg/b_tot));
1544     document.getElementById('color18').width = 3*Math.round(100*(b18_avg/b_tot));
1545     document.getElementById('color19').width = 3*Math.round(100*(b19_avg/b_tot));
1546     document.getElementById('color20').width = 3*Math.round(100*(b20_avg/b_tot));
1547     document.getElementById('color21').width = 3*Math.round(100*(b21_avg/b_tot));
1548     document.getElementById('color22').width = 3*Math.round(100*(b22_avg/b_tot));
1549     document.getElementById('color23').width = 3*Math.round(100*(b23_avg/b_tot));
1550     document.getElementById('color24').width = 3*Math.round(100*(b24_avg/b_tot));
1551     len1.value = Math.round(1000*(b1_avg/b_tot));
1552     len2.value = Math.round(1000*(b2_avg/b_tot));
1553     len3.value = Math.round(1000*(b3_avg/b_tot));
1554     len4.value = Math.round(1000*(b4_avg/b_tot));
1555     len5.value = Math.round(1000*(b5_avg/b_tot));
1556     len6.value = Math.round(1000*(b6_avg/b_tot));
1557     len7.value = Math.round(1000*(b7_avg/b_tot));
1558     len8.value = Math.round(1000*(b8_avg/b_tot));
1559     len9.value = Math.round(1000*(b9_avg/b_tot));
1560     len10.value = Math.round(1000*(b10_avg/b_tot));
1561     len11.value = Math.round(1000*(b11_avg/b_tot));
1562     len12.value = Math.round(1000*(b12_avg/b_tot));
1563     len13.value = Math.round(1000*(b13_avg/b_tot));
1564     len14.value = Math.round(1000*(b14_avg/b_tot));
1565     len15.value = Math.round(1000*(b15_avg/b_tot));
1566     len16.value = Math.round(1000*(b16_avg/b_tot));
1567     len17.value = Math.round(1000*(b17_avg/b_tot));
1568     len18.value = Math.round(1000*(b18_avg/b_tot));
1569     len19.value = Math.round(1000*(b19_avg/b_tot));
1570     len20.value = Math.round(1000*(b20_avg/b_tot));
1571     len21.value = Math.round(1000*(b21_avg/b_tot));
1572     len22.value = Math.round(1000*(b22_avg/b_tot));
1573     len23.value = Math.round(1000*(b23_avg/b_tot));
1574     len24.value = Math.round(1000*(b24_avg/b_tot));
1575
1576sg1 = 100*(b1_avg/b_tot);
1577 sg2 = 100*(b2_avg/b_tot);
1578sg3 = 100*(b3_avg/b_tot);
1579  if (bts==3){
1580signs(sg1, sg2,sg3); }
1581   else{  document.getElementById('sign').className = "hidden";}
1582
1583  tap_avg = Math.round(60000 / b_tot)*bts;
1584  tempo_disp.innerHTML = tap_avg; 
1585  tempo_rge.value = tap_avg;
1586  core = tap_avg;
1587  delta = temp;
1588  tapCount = (tapCount + 1)%(bts*3);
1589tapping.innerHTML = "&nbsp;&nbsp;Tapping #&nbsp;&nbsp;"+(tapCount%bts + 1);
1590
1591  var totMs = Math.round((60/core)*bts*1000);
1592  document.getElementById('mills').innerHTML = "["+totMs+" ms]";
1593  //  subMs = Math.round(totMs/bangTot);
1594 // document.getElementById('subMs').innerHTML = "{"+subMs+" ms}";
1595  
1596
1597if (mute==0 && android==0) {
1598hihat(drag[noteFlag]*.1); }
1599  
1600  if(tap_avg > 800){
1601    tempo_disp.innerHTML = 800;
1602    tempo_rge.value = 800;
1603  } 
1604});
1605
1606// § keydown tap function §
1607document.addEventListener('keydown', (event) => {
1608 var theKey = event.key; 
1609 
1610 var isAndroid = navigator.userAgent.toLowerCase().match(/android/i); 
1611  if (isAndroid) {  android=1; 
1612    var textIn1 = document.getElementById('play').value;
1613   var len = textIn1.length;
1614    var last1 = textIn1.substr(len-1,1);
1615    if (last1=="," || last1==".") {theKey="."; }
1616     }
1617  else { android=0;}
1618if ((theKey=="\\") && onOff==0) {startIt();}
1619else if ((theKey=="\\") && onOff==1) {stopIt();} 
1620//  if (theKey=="Control") { testIt1.innerHTML = "ctrl";}
1621if ((theKey==" " || theKey==".") && space==1) { 
1622// testIt2.innerHTML = "space";
1623 var dt = new Date();  // THIS is the d
1624  var temp = dt.getTime();
1625  if ((temp/delta)/1000 > 2) {
1626  tapCount=bts*3 -1 ; 
1627  for (y=0; y<bts*3;y++){  // THIS is the i
1628   meas[y]=60;
1629   beas[y]=1000;
1630}
1631  }
1632  var tap_avg,b_tot;
1633  var b1_avg, b2_avg, b3_avg, b4_avg, b5_avg, b6_avg, b7_avg, b8_avg, b9_avg, b10_avg,  
1634     b11_avg, b12_avg, b13_avg, b14_avg, b15_avg, b16_avg, b17_avg, b18_avg, b19_avg, b20_avg , b21_avg, b22_avg, b23_avg, b24_avg;
1635  var tap_temp = Math.round(60000 / (temp - delta));
1636  meas[tapCount] = Math.round(60000 / (temp - delta));
1637  beas[tapCount] = temp - delta;
1638
1639if (bts==1) {
1640  b1_avg = Math.round( (beas[0]+beas[1]+beas[2])/3 );
1641  b_tot = b1_avg;}
1642  
1643else if (bts==2) {
1644  b1_avg = Math.round( (beas[0]+beas[2]+beas[4])/3 );
1645  b2_avg = Math.round((beas[1]+beas[3]+beas[5])/(3));
1646  b_tot = b1_avg + b2_avg;}
1647  
1648else if (bts==3) {
1649  b1_avg = Math.round( (beas[0]+beas[3]+beas[6])/3 );
1650  b2_avg = Math.round((beas[1]+beas[4]+beas[7])/(3));
1651  b3_avg = Math.round((beas[2]+beas[5]+beas[8])/(3));
1652  b_tot = b1_avg + b2_avg + b3_avg;}
1653else if (bts==4) {
1654  b1_avg = Math.round( (beas[0]+beas[4]+beas[8])/3 );
1655  b2_avg = Math.round((beas[1]+beas[5]+beas[9])/(3));
1656  b3_avg = Math.round((beas[2]+beas[6]+beas[10])/(3));
1657  b4_avg = Math.round((beas[3]+beas[7]+beas[11])/(3));
1658  b_tot = b1_avg + b2_avg + b3_avg + b4_avg;}
1659  
1660else if (bts==5) {
1661  b1_avg = Math.round( (beas[0]+beas[5]+beas[10])/3 );
1662  b2_avg = Math.round((beas[1]+beas[6]+beas[11])/(3));
1663  b3_avg = Math.round((beas[2]+beas[7]+beas[12])/(3));
1664  b4_avg = Math.round((beas[3]+beas[8]+beas[13])/(3));
1665  b5_avg = Math.round((beas[4]+beas[9]+beas[14])/(3));
1666  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg;}
1667  
1668else if (bts==6) {
1669  b1_avg = Math.round( (beas[0]+beas[6]+beas[12])/3 );
1670  b2_avg = Math.round((beas[1]+beas[7]+beas[13])/(3));
1671  b3_avg = Math.round((beas[2]+beas[8]+beas[14])/(3));
1672  b4_avg = Math.round((beas[3]+beas[9]+beas[15])/(3));
1673  b5_avg = Math.round((beas[4]+beas[10]+beas[16])/(3));
1674  b6_avg = Math.round((beas[5]+beas[11]+beas[17])/(3));
1675  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg;}
1676  
1677else if (bts==7) {
1678  b1_avg = Math.round( (beas[0]+beas[7]+beas[14])/3 );
1679  b2_avg = Math.round((beas[1]+beas[8]+beas[15])/(3));
1680  b3_avg = Math.round((beas[2]+beas[9]+beas[16])/(3));
1681  b4_avg = Math.round((beas[3]+beas[10]+beas[17])/(3));
1682  b5_avg = Math.round((beas[4]+beas[11]+beas[18])/(3));
1683  b6_avg = Math.round((beas[5]+beas[12]+beas[19])/(3));
1684  b7_avg = Math.round((beas[6]+beas[13]+beas[20])/(3));
1685  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg + b7_avg;}
1686  
1687  else if (bts==8) {
1688  b1_avg = Math.round( (beas[0]+beas[8]+beas[16])/3 );
1689  b2_avg = Math.round((beas[1]+beas[9]+beas[17])/(3));
1690  b3_avg = Math.round((beas[2]+beas[10]+beas[18])/(3));
1691  b4_avg = Math.round((beas[3]+beas[11]+beas[19])/(3));
1692  b5_avg = Math.round((beas[4]+beas[12]+beas[20])/(3));
1693  b6_avg = Math.round((beas[5]+beas[13]+beas[21])/(3));
1694  b7_avg = Math.round((beas[6]+beas[14]+beas[22])/(3));
1695  b8_avg = Math.round((beas[7]+beas[15]+beas[23])/(3));
1696  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1697   + b7_avg + b8_avg;}
1698   
1699  else if (bts==9) {
1700  b1_avg = Math.round( (beas[0]+beas[9]+beas[18])/3 );
1701  b2_avg = Math.round((beas[1]+beas[10]+beas[19])/(3));
1702  b3_avg = Math.round((beas[2]+beas[11]+beas[20])/(3));
1703  b4_avg = Math.round((beas[3]+beas[12]+beas[21])/(3));
1704  b5_avg = Math.round((beas[4]+beas[13]+beas[22])/(3));
1705  b6_avg = Math.round((beas[5]+beas[14]+beas[23])/(3));
1706  b7_avg = Math.round((beas[6]+beas[15]+beas[24])/(3));
1707  b8_avg = Math.round((beas[7]+beas[16]+beas[25])/(3));
1708  b9_avg = Math.round((beas[8]+beas[17]+beas[26])/(3));
1709  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1710   + b7_avg + b8_avg + b9_avg;}
1711
1712  else if (bts==10) {
1713  b1_avg = Math.round( (beas[0]+beas[10]+beas[20])/3 );
1714  b2_avg = Math.round((beas[1]+beas[11]+beas[21])/(3));
1715  b3_avg = Math.round((beas[2]+beas[12]+beas[22])/(3));
1716  b4_avg = Math.round((beas[3]+beas[13]+beas[23])/(3));
1717  b5_avg = Math.round((beas[4]+beas[14]+beas[24])/(3));
1718  b6_avg = Math.round((beas[5]+beas[15]+beas[25])/(3));
1719  b7_avg = Math.round((beas[6]+beas[16]+beas[26])/(3));
1720  b8_avg = Math.round((beas[7]+beas[17]+beas[27])/(3));
1721  b9_avg = Math.round((beas[8]+beas[18]+beas[28])/(3));
1722  b10_avg = Math.round((beas[9]+beas[19]+beas[29])/(3));
1723  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1724   + b7_avg + b8_avg + b9_avg + b10_avg;}
1725   
1726     else if (bts==11) {
1727  b1_avg = Math.round( (beas[0]+beas[11]+beas[22])/3 );
1728  b2_avg = Math.round((beas[1]+beas[12]+beas[23])/(3));
1729  b3_avg = Math.round((beas[2]+beas[13]+beas[24])/(3));
1730  b4_avg = Math.round((beas[3]+beas[14]+beas[25])/(3));
1731  b5_avg = Math.round((beas[4]+beas[15]+beas[26])/(3));
1732  b6_avg = Math.round((beas[5]+beas[16]+beas[27])/(3));
1733  b7_avg = Math.round((beas[6]+beas[17]+beas[28])/(3));
1734  b8_avg = Math.round((beas[7]+beas[18]+beas[29])/(3));
1735  b9_avg = Math.round((beas[8]+beas[19]+beas[30])/(3));
1736  b10_avg = Math.round((beas[9]+beas[20]+beas[31])/(3));
1737  b11_avg = Math.round((beas[10]+beas[21]+beas[32])/(3));
1738  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1739   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg;}
1740   
1741 else if (bts==12) {
1742  b1_avg = Math.round( (beas[0]+beas[12]+beas[24])/3 );
1743  b2_avg = Math.round((beas[1]+beas[13]+beas[25])/(3));
1744  b3_avg = Math.round((beas[2]+beas[14
1744]+beas[26])/(3));
1745  b4_avg = Math.round((beas[3]+beas[15]+beas[27])/(3));
1746  b5_avg = Math.round((beas[4]+beas[16]+beas[28])/(3));
1747  b6_avg = Math.round((beas[5]+beas[17]+beas[29])/(3));
1748  b7_avg = Math.round((beas[6]+beas[18]+beas[30])/(3));
1749  b8_avg = Math.round((beas[7]+beas[19]+beas[31])/(3));
1750  b9_avg = Math.round((beas[8]+beas[20]+beas[32])/(3));
1751  b10_avg = Math.round((beas[9]+beas[21]+beas[33])/(3));
1752  b11_avg = Math.round((beas[10]+beas[22]+beas[34])/(3));
1753  b12_avg = Math.round((beas[11]+beas[23]+beas[35])/(3));
1754  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1755   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg;}
1756   
1757  else if (bts==13) {
1758  b1_avg = Math.round( (beas[0]+beas[13]+beas[26])/3 );
1759  b2_avg = Math.round((beas[1]+beas[14]+beas[27])/(3));
1760  b3_avg = Math.round((beas[2]+beas[15]+beas[28])/(3));
1761  b4_avg = Math.round((beas[3]+beas[16]+beas[29])/(3));
1762  b5_avg = Math.round((beas[4]+beas[17]+beas[30])/(3));
1763  b6_avg = Math.round((beas[5]+beas[18]+beas[31])/(3));
1764  b7_avg = Math.round((beas[6]+beas[19]+beas[32])/(3));
1765  b8_avg = Math.round((beas[7]+beas[20]+beas[33])/(3));
1766  b9_avg = Math.round((beas[8]+beas[21]+beas[34])/(3));
1767  b10_avg = Math.round((beas[9]+beas[22]+beas[35])/(3));
1768  b11_avg = Math.round((beas[10]+beas[23]+beas[36])/(3));
1769  b12_avg = Math.round((beas[11]+beas[24]+beas[37])/(3));
1770  b13_avg = Math.round((beas[12]+beas[25]+beas[38])/(3));
1771  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1772   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg + b13_avg;}
1773   
1774    else if (bts==14) {
1775  b1_avg = Math.round( (beas[0]+beas[14]+beas[28])/3 );
1776  b2_avg = Math.round((beas[1]+beas[15]+beas[29])/(3));
1777  b3_avg = Math.round((beas[2]+beas[16]+beas[30])/(3));
1778  b4_avg = Math.round((beas[3]+beas[17]+beas[31])/(3));
1779  b5_avg = Math.round((beas[4]+beas[18]+beas[32])/(3));
1780  b6_avg = Math.round((beas[5]+beas[19]+beas[33])/(3));
1781  b7_avg = Math.round((beas[6]+beas[20]+beas[34])/(3));
1782  b8_avg = Math.round((beas[7]+beas[21]+beas[35])/(3));
1783  b9_avg = Math.round((beas[8]+beas[22]+beas[36])/(3));
1784  b10_avg = Math.round((beas[9]+beas[23]+beas[37])/(3));
1785  b11_avg = Math.round((beas[10]+beas[24]+beas[38])/(3));
1786  b12_avg = Math.round((beas[11]+beas[25]+beas[39])/(3));
1787  b13_avg = Math.round((beas[12]+beas[26]+beas[40])/(3));
1788  b14_avg = Math.round((beas[13]+beas[27]+beas[41])/(3));
1789  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1790   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1791   + b13_avg + b14_avg; }
1792   
1793  else if (bts==15) {
1794  b1_avg = Math.round( (beas[0]+beas[15]+beas[30])/3 );
1795  b2_avg = Math.round((beas[1]+beas[16]+beas[31])/(3));
1796  b3_avg = Math.round((beas[2]+beas[17]+beas[32])/(3));
1797  b4_avg = Math.round((beas[3]+beas[18]+beas[33])/(3));
1798  b5_avg = Math.round((beas[4]+beas[19]+beas[34])/(3));
1799  b6_avg = Math.round((beas[5]+beas[20]+beas[35])/(3));
1800  b7_avg = Math.round((beas[6]+beas[21]+beas[36])/(3));
1801  b8_avg = Math.round((beas[7]+beas[22]+beas[37])/(3));
1802  b9_avg = Math.round((beas[8]+beas[23]+beas[38])/(3));
1803  b10_avg = Math.round((beas[9]+beas[24]+beas[39])/(3));
1804  b11_avg = Math.round((beas[10]+beas[25]+beas[40])/(3));
1805  b12_avg = Math.round((beas[11]+beas[26]+beas[41])/(3));
1806  b13_avg = Math.round((beas[12]+beas[27]+beas[42])/(3));
1807  b14_avg = Math.round((beas[13]+beas[28]+beas[43])/(3));
1808  b15_avg = Math.round((beas[14]+beas[29]+beas[44])/(3));
1809  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1810   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1811   + b13_avg + b14_avg + b15_avg; }
1812   
1813  else if (bts==16) {
1814  b1_avg = Math.round( (beas[0]+beas[16]+beas[32])/3 );
1815  b2_avg = Math.round((beas[1]+beas[17]+beas[33])/(3));
1816  b3_avg = Math.round((beas[2]+beas[18]+beas[34])/(3));
1817  b4_avg = Math.round((beas[3]+beas[19]+beas[35])/(3));
1818  b5_avg = Math.round((beas[4]+beas[20]+beas[36])/(3));
1819  b6_avg = Math.round((beas[5]+beas[21]+beas[37])/(3));
1820  b7_avg = Math.round((beas[6]+beas[22]+beas[38])/(3));
1821  b8_avg = Math.round((beas[7]+beas[23]+beas[39])/(3));
1822  b9_avg = Math.round((beas[8]+beas[24]+beas[40])/(3));
1823  b10_avg = Math.round((beas[9]+beas[25]+beas[41])/(3));
1824  b11_avg = Math.round((beas[10]+beas[26]+beas[42])/(3));
1825  b12_avg = Math.round((beas[11]+beas[27]+beas[43])/(3));
1826  b13_avg = Math.round((beas[12]+beas[28]+beas[44])/(3));
1827  b14_avg = Math.round((beas[13]+beas[29]+beas[45])/(3));
1828  b15_avg = Math.round((beas[14]+beas[30]+beas[46])/(3));
1829  b16_avg = Math.round((beas[15]+beas[31]+beas[47])/(3));
1830  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1831   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1832   + b13_avg + b14_avg + b15_avg + b16_avg; }
1833
1834  else if (bts==17) {
1835  b1_avg = Math.round( (beas[0]+beas[17]+beas[34])/3 );
1836  b2_avg = Math.round((beas[1]+beas[18]+beas[35])/(3));
1837  b3_avg = Math.round((beas[2]+beas[19]+beas[36])/(3));
1838  b4_avg = Math.round((beas[3]+beas[20]+beas[37])/(3));
1839  b5_avg = Math.round((beas[4]+beas[21]+beas[38])/(3));
1840  b6_avg = Math.round((beas[5]+beas[22]+beas[39])/(3));
1841  b7_avg = Math.round((beas[6]+beas[23]+beas[40])/(3));
1842  b8_avg = Math.round((beas[7]+beas[24]+beas[41])/(3));
1843  b9_avg = Math.round((beas[8]+beas[25]+beas[42])/(3));
1844  b10_avg = Math.round((beas[9]+beas[26]+beas[43])/(3));
1845  b11_avg = Math.round((beas[10]+beas[27]+beas[44])/(3));
1846  b12_avg = Math.round((beas[11]+beas[28]+beas[45])/(3));
1847  b13_avg = Math.round((beas[12]+beas[29]+beas[46])/(3));
1848  b14_avg = Math.round((beas[13]+beas[30]+beas[47])/(3));
1849  b15_avg = Math.round((beas[14]+beas[31]+beas[48])/(3));
1850  b16_avg = Math.round((beas[15]+beas[32]+beas[49])/(3));
1851  b17_avg = Math.round((beas[16]+beas[33]+beas[50])/(3));
1852  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1853   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1854   + b13_avg + b14_avg + b15_avg + b16_avg + b17_avg; }
1855
1856  else if (bts==18) {
1857  b1_avg = Math.round( (beas[0]+beas[18]+beas[36])/3 );
1858  b2_avg = Math.round((beas[1]+beas[19]+beas[37])/(3));
1859  b3_avg = Math.round((beas[2]+beas[20]+beas[38])/(3));
1860  b4_avg = Math.round((beas[3]+beas[21]+beas[39])/(3));
1861  b5_avg = Math.round((beas[4]+beas[22]+beas[40])/(3));
1862  b6_avg = Math.round((beas[5]+beas[23]+beas[41])/(3));
1863  b7_avg = Math.round((beas[6]+beas[24]+beas[42])/(3));
1864  b8_avg = Math.round((beas[7]+beas[25]+beas[43])/(3));
1865  b9_avg = Math.round((beas[8]+beas[26]+beas[44])/(3));
1866  b10_avg = Math.round((beas[9]+beas[27]+beas[45])/(3));
1867  b11_avg = Math.round((beas[10]+beas[28]+beas[46])/(3));
1868  b12_avg = Math.round((beas[11]+beas[29]+beas[47])/(3));
1869  b13_avg = Math.round((beas[12]+beas[30]+beas[48])/(3));
1870  b14_avg = Math.round((beas[13]+beas[31]+beas[49])/(3));
1871  b15_avg = Math.round((beas[14]+beas[32]+beas[50])/(3));
1872  b16_avg = Math.round((beas[15]+beas[33]+beas[51])/(3));
1873  b17_avg = Math.round((beas[16]+beas[34]+beas[52])/(3));
1874  b18_avg = Math.round((beas[17]+beas[35]+beas[53])/(3));
1875  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1876   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1877   + b13_avg + b14_avg + b15_avg + b16_avg + b17_avg + b18_avg; }
1878
1879  else if (bts==19) {
1880  b1_avg = Math.round( (beas[0]+beas[19]+beas[38])/3 );
1881  b2_avg = Math.round((beas[1]+beas[20]+beas[39])/(3));
1882  b3_avg = Math.round((beas[2]+beas[21]+beas[40])/(3));
1883  b4_avg = Math.round((beas[3]+beas[22]+beas[41])/(3));
1884  b5_avg = Math.round((beas[4]+beas[23]+beas[42])/(3));
1885  b6_avg = Math.round((beas[5]+beas[24]+beas[43])/(3));
1886  b7_avg = Math.round((beas[6]+beas[25]+beas[44])/(3));
1887  b8_avg = Math.round((beas[7]+beas[26]+beas[45])/(3));
1888  b9_avg = Math.round((beas[8]+beas[27]+beas[46])/(3));
1889  b10_avg = Math.round((beas[9]+beas[28]+beas[47])/(3));
1890  b11_avg = Math.round((beas[10]+beas[29]+beas[48])/(3));
1891  b12_avg = Math.round((beas[11]+beas[30]+beas[49])/(3));
1892  b13_avg = Math.round((beas[12]+beas[31]+beas[50])/(3));
1893  b14_avg = Math.round((beas[13]+beas[32]+beas[51])/(3));
1894  b15_avg = Math.round((beas[14]+beas[33]+beas[52])/(3));
1895  b16_avg = Math.round((beas[15]+beas[34]+beas[53])/(3));
1896  b17_avg = Math.round((beas[16]+beas[35]+beas[54])/(3));
1897  b18_avg = Math.round((beas[17]+beas[36]+beas[55])/(3));
1898  b19_avg = Math.round((beas[18]+beas[37]+beas[56])/(3));
1899  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1900   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1901   + b13_avg + b14_avg + b15_avg + b16_avg + b17_avg + b18_avg
1902   + b19_avg; }
1903
1904  else if (bts==20) {
1905  b1_avg = Math.round( (beas[0]+beas[20]+beas[40])/3 );
1906  b2_avg = Math.round((beas[1]+beas[21]+beas[41])/(3));
1907  b3_avg = Math.round((beas[2]+beas[22]+beas[42])/(3));
1908  b4_avg = Math.round((beas[3]+beas[23]+beas[43])/(3));
1909  b5_avg = Math.round((beas[4]+beas[24]+beas[44])/(3));
1910  b6_avg = Math.round((beas[5]+beas[25]+beas[45])/(3));
1911  b7_avg = Math.round((beas[6]+beas[26]+beas[46])/(3));
1912  b8_avg = Math.round((beas[7]+beas[27]+beas[47])/(3));
1913  b9_avg = Math.round((beas[8]+beas[28]+beas[48])/(3));
1914  b10_avg = Math.round((beas[9]+beas[29]+beas[49])/(3));
1915  b11_avg = Math.round((beas[10]+beas[30]+beas[50])/(3));
1916  b12_avg = Math.round((beas[11]+beas[31]+beas[51])/(3));
1917  b13_avg = Math.round((beas[12]+beas[32]+beas[52])/(3));
1918  b14_avg = Math.round((beas[13]+beas[33]+beas[53])/(3));
1919  b15_avg = Math.round((beas[14]+beas[34]+beas[54])/(3));
1920  b16_avg = Math.round((beas[15]+beas[35]+beas[55])/(3));
1921  b17_avg = Math.round((beas[16]+beas[36]+beas[56])/(3));
1922  b18_avg = Math.round((beas[17]+beas[37]+beas[57])/(3));
1923  b19_avg = Math.round((beas[18]+beas[38]+beas[58])/(3));
1924  b20_avg = Math.round((beas[19]+beas[39]+beas[59])/(3));
1925  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1926   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1927   + b13_avg + b14_avg + b15_avg + b16_avg + b17_avg + b18_avg
1928   + b19_avg  + b20_avg; }
1929
1930  else if (bts==21) {
1931  b1_avg = Math.round( (beas[0]+beas[21]+beas[42])/3 );
1932  b2_avg = Math.round((beas[1]+beas[22]+beas[43])/(3));
1933  b3_avg = Math.round((beas[2]+beas[23]+beas[44])/(3));
1934  b4_avg = Math.round((beas[3]+beas[24]+beas[45])/(3));
1935  b5_avg = Math.round((beas[4]+beas[25]+beas[46])/(3));
1936  b6_avg = Math.round((beas[5]+beas[26]+beas[47])/(3));
1937  b7_avg = Math.round((beas[6]+beas[27]+beas[48])/(3));
1938  b8_avg = Math.round((beas[7]+beas[28]+beas[49])/(3));
1939  b9_avg = Math.round((beas[8]+beas[29]+beas[50])/(3));
1940  b10_avg = Math.round((beas[9]+beas[30]+beas[51])/(3));
1941  b11_avg = Math.round((beas[10]+beas[31]+beas[52])/(3));
1942  b12_avg = Math.round((beas[11]+beas[32]+beas[53])/(3));
1943  b13_avg = Math.round((beas[12]+beas[33]+beas[54])/(3));
1944  b14_avg = Math.round((beas[13]+beas[34]+beas[55])/(3));
1945  b15_avg = Math.round((beas[14]+beas[35]+beas[56])/(3));
1946  b16_avg = Math.round((beas[15]+beas[36]+beas[57])/(3));
1947  b17_avg = Math.round((beas[16]+beas[37]+beas[58])/(3));
1948  b18_avg = Math.round((beas[17]+beas[38]+beas[59])/(3));
1949  b19_avg = Math.round((beas[18]+beas[39]+beas[60])/(3));
1950  b20_avg = Math.round((beas[19]+beas[40]+beas[61])/(3));
1951  b21_avg = Math.round((beas[20]+beas[41]+beas[62])/(3));
1952  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + b5_avg+ b6_avg
1953   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1954   + b13_avg + b14_avg + b15_avg + b16_avg + b17_avg + b18_avg
1955   + b19_avg  + b20_avg+ b21_avg; }
1956   
1957  else if (bts==22) {
1958  b1_avg = Math.round( (beas[0]+beas[22]+beas[44])/3 );
1959  b2_avg = Math.round((beas[1]+beas[23]+beas[45])/(3));
1960  b3_avg = Math.round((beas[2]+beas[24]+beas[46])/(3));
1961  b4_avg = Math.round((beas[3]+beas[25]+beas[47])/(3));
1962  b5_avg = Math.round((beas[4]+beas[26]+beas[48])/(3));
1963  b6_avg = Math.round((beas[5]+beas[27]+beas[49])/(3));
1964  b7_avg = Math.round((beas[6]+beas[28]+beas[50])/(3));
1965  b8_avg = Math.round((beas[7]+beas[29]+beas[51])/(3));
1966  b9_avg = Math.round((beas[8]+beas[30]+beas[52])/(3));
1967  b10_avg = Math.round((beas[9]+beas[31]+beas[53])/(3));
1968  b11_avg = Math.round((beas[10]+beas[32]+beas[54])/(3));
1969  b12_avg = Math.round((beas[11]+beas[33]+beas[55])/(3));
1970  b13_avg = Math.round((beas[12]+beas[34]+beas[56])/(3));
1971  b14_avg = Math.round((beas[13]+beas[35]+beas[57])/(3));
1972  b15_avg = Math.round((beas[14]+beas[36]+beas[58])/(3));
1973  b16_avg = Math.round((beas[15]+beas[37]+beas[59])/(3));
1974  b17_avg = Math.round((beas[16]+beas[38]+beas[60])/(3));
1975  b18_avg = Math.round((beas[17]+beas[39]+beas[61])/(3));
1976  b19_avg = Math.round((beas[18]+beas[40]+beas[62])/(3));
1977  b20_avg = Math.round((beas[19]+beas[41]+beas[63])/(3));
1978  b21_avg = Math.round((beas[20]+beas[42]+beas[64])/(3));
1979  b22_avg = Math.round((beas[21]+beas[43]+beas[62])/(3));
1980  b_tot = b1_avg + b2_avg + b3_avg + b4_avg + 65+ b6_avg
1981   + b7_avg + b8_avg + b9_avg + b10_avg + b11_avg + b12_avg
1982   + b13_avg + b14_avg + b15_avg + b16_avg + b17_avg + b18_avg
1983   + b19_avg  + b20_avg + b21_avg + b22_avg; }
1984// testIt4.innerHTML = b1_avg; testIt5.innerHTML = b2_avg; testIt6.innerHTML =b3_avg;
1985//  testIt7.innerHTML = b1_avg/b_tot; testIt8.innerHTML = b2_avg/b_tot; testIt9.innerHTML = b3_avg/b_tot;
1986     pr1.value = Math.round(100*(b1_avg/b_tot))+"% ";
1987     pr2.value = Math.round(100*(b2_avg/b_tot))+"% ";
1988     pr3.value = Math.round(100*(b3_avg/b_tot))+"% ";
1989     pr4.value = Math.round(100*(b4_avg/b_tot))+"% ";
1990     pr5.value = Math.round(100*(b5_avg/b_tot))+"% ";
1991     pr6.value = Math.round(100*(b6_avg/b_tot))+"% ";
1992     pr7.value = Math.round(100*(b7_avg/b_tot))+"% ";
1993     pr8.value = Math.round(100*(b8_avg/b_tot))+"% ";
1994     pr9.value = Math.round(100*(b9_avg/b_tot))+"% ";
1995     pr10.value = Math.round(100*(b10_avg/b_tot))+"% ";
1996     pr11.value = Math.round(100*(b11_avg/b_tot))+"% ";
1997     pr12.value = Math.round(100*(b12_avg/b_tot))+"% ";
1998     pr13.value = Math.round(100*(b13_avg/b_tot))+"% ";
1999     pr14.value = Math.round(100*(b14_avg/b_tot))+"% ";
2000     pr15.value = Math.round(100*(b15_avg/b_tot))+"% ";
2001     pr16.value = Math.round(100*(b16_avg/b_tot))+"% ";  
2002     pr17.value = Math.round(100*(b17_avg/b_tot))+"% ";
2003     pr18.value = Math.round(100*(b18_avg/b_tot))+"% ";
2004     pr19.value = Math.round(100*(b19_avg/b_tot))+"% ";
2005     pr20.value = Math.round(100*(b20_avg/b_tot))+"% ";
2006     pr21.value = Math.round(100*(b21_avg/b_tot))+"% ";
2007     pr22.value = Math.round(100*(b22_avg/b_tot))+"% ";
2008     pr23.value = Math.round(100*(b23_avg/b_tot))+"% ";
2009     pr24.value = Math.round(100*(b24_avg/b_tot))+"% ";   
2010     document.getElementById('color1').width = 3*Math.round(100*(b1_avg/b_tot));
2011     document.getElementById('color2').width = 3*Math.round(100*(b2_avg/b_tot));
2012     document.getElementById('color3').width = 3*Math.round(100*(b3_avg/b_tot));
2013     document.getElementById('color4').width = 3*Math.round(100*(b4_avg/b_tot));
2014     document.getElementById('color5').width = 3*Math.round(100*(b5_avg/b_tot));
2015     document.getElementById('color6').width = 3*Math.round(100*(b6_avg/b_tot));
2016     document.getElementById('color7').width = 3*Math.round(100*(b7_avg/b_tot));
2017     document.getElementById('color8').width = 3*Math.round(100*(b8_avg/b_tot));
2018     document.getElementById('color9').width = 3*Math.round(100*(b9_avg/b_tot));
2019     document.getElementById('color10').width = 3*Math.round(100*(b10_avg/b_tot));
2020     document.getElementById('color11').width = 3*Math.round(100*(b11_avg/b_tot));
2021     document.getElementById('color12').width = 3*Math.round(100*(b12_avg/b_tot));
2022     document.getElementById('color13').width = 3*Math.round(100*(b13_avg/b_tot));
2023     document.getElementById('color14').width = 3*Math.round(100*(b14_avg/b_tot));
2024     document.getElementById('color15').width = 3*Math.round(100*(b15_avg/b_tot));
2025     document.getElementById('color16').width = 3*Math.round(100*(b16_avg/b_tot));
2026     document.getElementById('color17').width = 3*Math.round(100*(b17_avg/b_tot));
2027     document.getElementById('color18').width = 3*Math.round(100*(b18_avg/b_tot));
2028     document.getElementById('color19').width = 3*Math.round(100*(b19_avg/b_tot));
2029     document.getElementById('color20').width = 3*Math.round(100*(b20_avg/b_tot));
2030     document.getElementById('color21').width = 3*Math.round(100*(b21_avg/b_tot));
2031     document.getElementById('color22').width = 3*Math.round(100*(b22_avg/b_tot));
2032     document.getElementById('color23').width = 3*Math.round(100*(b23_avg/b_tot));
2032
2033     document.getElementById('color24').width = 3*Math.round(100*(b24_avg/b_tot));
2034     len1.value = Math.round(1000*(b1_avg/b_tot));
2035     len2.value = Math.round(1000*(b2_avg/b_tot));
2036     len3.value = Math.round(1000*(b3_avg/b_tot));
2037     len4.value = Math.round(1000*(b4_avg/b_tot));
2038     len5.value = Math.round(1000*(b5_avg/b_tot));
2039     len6.value = Math.round(1000*(b6_avg/b_tot));
2040     len7.value = Math.round(1000*(b7_avg/b_tot));
2041     len8.value = Math.round(1000*(b8_avg/b_tot));
2042     len9.value = Math.round(1000*(b9_avg/b_tot));
2043     len10.value = Math.round(1000*(b10_avg/b_tot));
2044     len11.value = Math.round(1000*(b11_avg/b_tot));
2045     len12.value = Math.round(1000*(b12_avg/b_tot));
2046     len13.value = Math.round(1000*(b13_avg/b_tot));
2047     len14.value = Math.round(1000*(b14_avg/b_tot));
2048     len15.value = Math.round(1000*(b15_avg/b_tot));
2049     len16.value = Math.round(1000*(b16_avg/b_tot));
2050     len17.value = Math.round(1000*(b17_avg/b_tot));
2051     len18.value = Math.round(1000*(b18_avg/b_tot));
2052     len19.value = Math.round(1000*(b19_avg/b_tot));
2053     len20.value = Math.round(1000*(b20_avg/b_tot));
2054     len21.value = Math.round(1000*(b21_avg/b_tot));
2055     len22.value = Math.round(1000*(b22_avg/b_tot));
2056     len23.value = Math.round(1000*(b23_avg/b_tot));
2057     len24.value = Math.round(1000*(b24_avg/b_tot));
2058
2059
2060sg1 = 100*(b1_avg/b_tot);
2061 sg2 = 100*(b2_avg/b_tot);
2062sg3 = 100*(b3_avg/b_tot);
2063  if (bts==3){
2064signs(sg1, sg2,sg3); } 
2065   else{  document.getElementById('sign').className = "hidden";}
2066
2067  tap_avg = Math.round(60000 / b_tot)*bts;
2068  tempo_disp.innerHTML = tap_avg; 
2069  tempo_rge.value = tap_avg;
2070  core = tap_avg;
2071  delta = temp;
2072  tapCount = (tapCount + 1)%(bts*3);
2073tapping.innerHTML = "&nbsp;&nbsp;Tapping #&nbsp;&nbsp;"+(tapCount%bts + 1);
2074if(mute==0) {hihat(drag[noteFlag]*.1);}
2075  
2076  var totMs = Math.round((60/core)*bts*1000);
2077  document.getElementById('mills').innerHTML = "["+totMs+" ms]";
2078  //  subMs = Math.round(totMs/bangTot);
2079 // document.getElementById('subMs').innerHTML = "{"+subMs+" ms}";
2080  
2081  if(tap_avg > 800){
2082    tempo_disp.innerHTML = 800;
2083    tempo_rge.value = 800;
2084  } }
2085  
2086}, false);
2087
2088    // make noise, filter it (we only want the high frequencies) and add it to a low-frequency triangular wave
2089    var snare1 = function(time)
2090    {
2091        var context = new AudioContext();
2092        var noise = context.createBufferSource();
2093        noise.buffer = noiseBuffer;
2094        var noiseFilter = context.createBiquadFilter();
2095        noiseFilter.type = 'highpass';
2096        noiseFilter.frequency.value = 1000;
2097        noise.connect(noiseFilter);
2098        var noiseEnvelope = context.createGain();
2099        noiseFilter.connect(noiseEnvelope);
2100        noiseEnvelope.connect(context.destination);
2101        var osc = context.createOscillator();
2102        osc.type = 'triangle';
2103        var oscEnvelope = context.createGain();
2104        osc.connect(oscEnvelope);
2105        oscEnvelope.connect(context.destination);
2106        noiseEnvelope.gain.setValueAtTime(1, time);
2107        noiseEnvelope.gain.exponentialRampToValueAtTime(0.01, time + 0.2);
2108        noise.start(time);
2109        osc.frequency.setValueAtTime(100, time);
2110        oscEnvelope.gain.setValueAtTime(0.7, time);
2111        oscEnvelope.gain.exponentialRampToValueAtTime(0.01, time + 0.1);
2112        osc.start(time);
2113        osc.stop(time + 0.2);
2114        noise.stop(time + 0.2);
2115    }
2116
2117plus.addEventListener('click', function(){
2118    tempo_rge.value +++ 1;
2119    core = tempo_rge.value;
2120    tempo_disp.innerHTML = tempo_rge.value;
2121    var ogTemp = 60000 / (document.getElementById('t').value)
2122  var newTemp = 60000*bangTot/(ogTemp*bts);
2123    totMs = Math.round((60/core)*bts*1000);
2124  document.getElementById('mills').innerHTML = "["+totMs+" ms]";
2125      subMs = Math.round(totMs/bangTot);
2126  document.getElementById('subMs').innerHTML = "{"+subMs+" ms}";
2127  if (meterOn.clicked) {
2128       if (bangTot==1)
2129    {document.getElementById('bangTot').innerHTML = bangTot+ " beat @";}
2130   else {document.getElementById('bangTot').innerHTML = bangTot+ " beats @";}
2131  document.getElementById('bangTemp').innerHTML = "~"+Math.round(newTemp)+" bpm";
2132  }
2133});
2134
2135extraPlus.addEventListener('click', function(){
2136    tempo_rge.value = tempo_rge.value +++ 5;
2137    tempo_disp.innerHTML = tempo_rge.value;
2138});
2139
2140// § add beats §
2141beatPlus.addEventListener('click', function(){
2142  bAllv = Number(b1v) +Number(b2v) +Number(b3v)+ Number(b4v) +Number(b5v)+Number(b6v) + Number(b7v) +Number(b8v) +Number(b9v)+ Number(b10v) +Number(b11v)+Number(b12v)+Number(b13v)+ Number(b14v) +Number(b15v)+Number(b16v)
2143  + Number(b17v) +Number(b18v) +Number(b19v)+ Number(b20v)
2144  +Number(b21v)+Number(b22v)+Number(b23v)+ Number(b24v);
2145  bts=Number(beatCount.value);
2146  bTotAvg= Math.round(bAllv/bts);
2147var aLf = new Array (1,8,8,4,1,)
2148    beatCount.value = beatCount.value +++ 1;
2149    noteFlag = 0;  tapCount=bts*3 -1;
2150    
2151    
2152var acNam, leNam, prNam;
2153var lfNum = pcL[bts];
2154var rtNum = acR[bts];
2155acNam= "ac"+bts.toString();
2156leNam= "len"+bts.toString();
2157prNam= "pr"+bts.toString();
2158      
2159    if (beatCount.value==2) {
2160       document.getElementById('len2').className="";
2161       document.getElementById('ac2').className="";
2162       document.getElementById('pr2').className="bx";
2163       document.getElementById('pcLfSp').width=lfNum;
2164       document.getElementById('acRtSp').width=rtNum;
2165      if (document.getElementById('len2').value == 0)   { 
2166         document.getElementById('len2').value=bTotAvg; }
2167    }
2168    
2169    else if (beatCount.value==3) {   
2170       document.getElementById('len3').className="";
2171       document.getElementById('ac3').className="";
2172       document.getElementById('pr3').className="bx";
2173       document.getElementById('pcLfSp').width=lfNum;
2174       document.getElementById('acRtSp').width=rtNum;
2175       if (document.getElementById('len3').value == 0) {document.getElementById('len3').value=bTotAvg;btWts();
2176       }
2177
2178    }
2179    else if (beatCount.value==4) {
2180       document.getElementById('len4').className="";
2181       document.getElementById('ac4').className="";
2182       document.getElementById('pr4').className="bx";
2183       document.getElementById('pcLfSp').width=lfNum;
2184       document.getElementById('pcRtSp').width="1";
2185              document.getElementById('acLfSp').width="1";
2186       document.getElementById('acRtSp').width=rtNum;
2187      if (document.getElementById('len4').value == 0) {document.getElementById('len4').value=bTotAvg;btWts();
2188      }
2189      }
2190    else if (beatCount.value==5) {
2191        document.getElementById('len5').className="";
2192       document.getElementById('ac5').className="";
2193       document.getElementById('pr5').className="bx";
2194       document.getElementById('pcLfSp').width="40";
2195       document.getElementById('pcRtSp').width="1";
2196              document.getElementById('acLfSp').width="1";
2197       document.getElementById('acRtSp').width="20";
2198       if (document.getElementById('len5').value == 0) {document.getElementById('len5').value=bTotAvg;btWts();}
2199     }
2200      else if (beatCount.value==6) {
2201        document.getElementById('len6').className="";
2202       document.getElementById('ac6').className="";
2203       document.getElementById('pr6').className="bx";
2204       document.getElementById('pcLfSp').width="40";
2205       document.getElementById('pcRtSp').width="1";
2206              document.getElementById('acLfSp').width="1";
2207       document.getElementById('acRtSp').width="20";
2208       if (document.getElementById('len6').value == 0) {document.getElementById('len6').value=bTotAvg;btWts();}
2209     }  
2210        else if (beatCount.value==7) {
2211        document.getElementById('len7').className="";
2212       document.getElementById('ac7').className="";
2213       document.getElementById('pr7').className="bx";
2214       document.getElementById('pcLfSp').width="40";
2215       document.getElementById('pcRtSp').width="1";
2216              document.getElementById('acLfSp').width="1";
2217       document.getElementById('acRtSp').width="22";
2218       if (document.getElementById('len7').value == 0) {document.getElementById('len7').value=bTotAvg;btWts();}
2219     }
2220         else if (beatCount.value==8) {
2221        document.getElementById('len8').className="";
2222       document.getElementById('ac8').className="";
2223       document.getElementById('pr8').className="bx";
2224       document.getElementById('pcLfSp').width="42";
2225       document.getElementById('pcRtSp').width="1";
2226              document.getElementById('acLfSp').width="1";
2227       document.getElementById('acRtSp').width="20";
2228       if (document.getElementById('len8').value == 0) {document.getElementById('len8').value=bTotAvg;btWts();}
2229       }
2230         else if (beatCount.value==9) {
2231        document.getElementById('len9').className="";
2232       document.getElementById('ac9').className="";
2233       document.getElementById('pr9').className="bx";
2234       document.getElementById('pcLfSp').width="36";
2235       document.getElementById('pcRtSp').width="1";
2236              document.getElementById('acLfSp').width="1";
2237       document.getElementById('acRtSp').width="20";
2238       if (document.getElementById('len9').value == 0) {document.getElementById('len9').value=bTotAvg;btWts();}
2239       }
2240     else if (beatCount.value==10) {
2241        document.getElementById('len10').className="";
2242       document.getElementById('ac10').className="";
2243       document.getElementById('pr10').className="bx";
2244       document.getElementById('pcLfSp').width="37";
2245       document.getElementById('pcRtSp').width="1";
2246              document.getElementById('acLfSp').width="1";
2247       document.getElementById('acRtSp').width="18";
2248       if (document.getElementById('len10').value == 0) {document.getElementById('len10').value=bTotAvg;btWts();}
2249       }
2250       else if (beatCount.value==11) {
2251        document.getElementById('len11').className="";
2252       document.getElementById('ac11').className="";
2253       document.getElementById('pr11').className="bx";
2254       document.getElementById('pcLfSp').width="39";
2255       document.getElementById('pcRtSp').width="1";
2256              document.getElementById('acLfSp').width="1";
2257       document.getElementById('acRtSp').width="21";
2258       if (document.getElementById('len11').value == 0) {document.getElementById('len11').value=bTotAvg;btWts();}
2259       }
2260       else if (beatCount.value==12) {
2261        document.getElementById('len12').className="";
2262       document.getElementById('ac12').className="";
2263       document.getElementById('pr12').className="bx";
2264       document.getElementById('pcLfSp').width="38";
2265       document.getElementById('pcRtSp').width="1";
2266              document.getElementById('acLfSp').width="1";
2267       document.getElementById('acRtSp').width="18";
2268       if (document.getElementById('len12').value == 0) {document.getElementById('len12').value=bTotAvg;btWts();}
2269     }
2270     
2271      else if (beatCount.value==13) {
2272        document.getElementById('len13').className="";
2273       document.getElementById('ac13').className="";
2274       document.getElementById('pr13').className="bx";
2275       document.getElementById('pcLfSp').width="38";
2276       document.getElementById('pcRtSp').width="1";
2277              document.getElementById('acLfSp').width="1";
2278       document.getElementById('acRtSp').width="20";
2279       if (document.getElementById('len13').value == 0) {document.getElementById('len13').value=bTotAvg;btWts();}
2280     }
2281     
2282           else if (beatCount.value==14) {
2283        document.getElementById('len14').className="";
2284       document.getElementById('ac14').className="";
2285       document.getElementById('pr14').className="bx";
2286       document.getElementById('pcLfSp').width="38";
2287       document.getElementById('pcRtSp').width="1";
2288              document.getElementById('acLfSp').width="1";
2289       document.getElementById('acRtSp').width="20";
2290       if (document.getElementById('len14').value == 0) {document.getElementById('len14').value=bTotAvg;btWts();}
2291     }
2292     
2293           else if (beatCount.value==15) {
2294        document.getElementById('len15').className="";
2295       document.getElementById('ac15').className="";
2296       document.getElementById('pr15').className="bx";
2297       document.getElementById('pcLfSp').width="38";
2298       document.getElementById('pcRtSp').width="1";
2299              document.getElementById('acLfSp').width="1";
2300       document.getElementById('acRtSp').width="20";
2301       if (document.getElementById('len15').value == 0) {document.getElementById('len15').value=bTotAvg;btWts();}
2302     }
2303     
2304           else if (beatCount.value==16) {
2305        document.getElementById('len16').className="";
2306       document.getElementById('ac16').className="";
2307       document.getElementById('pr16').className="bx";
2308       document.getElementById('pcLfSp').width="38";
2309       document.getElementById('pcRtSp').width="1";
2310              document.getElementById('acLfSp').width="1";
2311       document.getElementById('acRtSp').width="21";
2312       if (document.getElementById('len16').value == 0) {document.getElementById('len16').value=bTotAvg;btWts();}
2313     }
2314     else if (beatCount.value==17) {
2315        document.getElementById('len17').className="";
2316       document.getElementById('ac17').className="";
2317       document.getElementById('pr17').className="bx";
2318       document.getElementById('pcLfSp').width="38";
2319       document.getElementById('pcRtSp').width="1";
2320              document.getElementById('acLfSp').width="1";
2321       document.getElementById('acRtSp').width="20";
2322       if (document.getElementById('len17').value == 0) {document.getElementById('len17').value=bTotAvg;btWts();}
2323     }
2324      else if (beatCount.value==18) {
2325        document.getElementById('len18').className="";
2326       document.getElementById('ac18').className="";
2327       document.getElementById('pr18').className="bx";
2328       document.getElementById('pcLfSp').width="38";
2329       document.getElementById('pcRtSp').width="1";
2330              document.getElementById('acLfSp').width="1";
2331       document.getElementById('acRtSp').width="22";
2332       if (document.getElementById('len18').value == 0) {document.getElementById('len18').value=bTotAvg;btWts();}
2333     }
2334     else if (beatCount.value==19) {
2335        document.getElementById('len19').className="";
2336       document.getElementById('ac19').className="";
2337       document.getElementById('pr19').className="bx";
2338       document.getElementById('pcLfSp').width="38";
2339       document.getElementById('pcRtSp').width="1";
2340              document.getElementById('acLfSp').width="1";
2341       document.getElementById('acRtSp').width="20";
2342       if (document.getElementById('len19').value == 0) {document.getElementById('len19').value=bTotAvg;btWts();}
2343     }
2344      else if (beatCount.value==20) {
2345        document.getElementById('len20').className="";
2346       document.getElementById('ac20').className="";
2347       document.getElementById('pr20').className="bx";
2348       document.getElementById('pcLfSp').width="38";
2349       document.getElementById('pcRtSp').width="1";
2350              document.getElementById('acLfSp').width="1";
2351       document.getElementById('acRtSp').width="20";
2352       if (document.getElementById('len20').value == 0) {document.getElementById('len20').value=bTotAvg;btWts();}
2353     }   
2354           else if (beatCount.value==21) {
2355        document.getElementById('len21').className="";
2356       document.getElementById('ac21').className="";
2357       document.getElementById('pr21').className="bx";
2358       document.getElementById('pcLfSp').width="38";
2359       document.getElementById('pcRtSp').width="1";
2360              document.getElementById('acLfSp').width="1";
2361       document.getElementById('acRtSp').width="20";
2362       if (document.getElementById('len21').value == 0) {document.getElementById('len21').value=bTotAvg;btWts();}
2363     }     
2364           else if (beatCount.value==22) {
2365        document.getElementById('len22').className="";
2366       document.getElementById('ac22').className="";
2367       document.getElementById('pr22').className="bx";
2368       document.getElementById('pcLfSp').width="38";
2369       document.getElementById('pcRtSp').width="1";
2370              document.getElementById('acLfSp').width="1";
2371       document.getElementById('acRtSp').width="18";
2372  
2372     if (document.getElementById('len22').value == 0) {document.getElementById('len22').value=bTotAvg;btWts();}
2373     }     
2374           else if (beatCount.value==23) {
2375        document.getElementById('len23').className="";
2376       document.getElementById('ac23').className="";
2377       document.getElementById('pr23').className="bx";
2378       document.getElementById('pcLfSp').width="38";
2379       document.getElementById('pcRtSp').width="1";
2380              document.getElementById('acLfSp').width="1";
2381       document.getElementById('acRtSp').width="18";
2382       if (document.getElementById('len23').value == 0) {document.getElementById('len23').value=bTotAvg;btWts();}
2383     }     
2384           else if (beatCount.value==24) {
2385        document.getElementById('len24').className="";
2386       document.getElementById('ac24').className="";
2387       document.getElementById('pr24').className="bx";
2388       document.getElementById('pcLfSp').width="38";
2389       document.getElementById('pcRtSp').width="1";
2390              document.getElementById('acLfSp').width="1";
2391       document.getElementById('acRtSp').width="18";
2392       if (document.getElementById('len24').value == 0) {document.getElementById('len24').value=bTotAvg;btWts();}
2393     }     
2394       
2395    if( beatCount.value > 24){ beatCount.value = 24;}
2396    btWts(); level();
2397    beatNbr.innerHTML =  "/"+beatCount.value;
2398    var i = 0,
2399    target = document.getElementById('dotTarget');
2400    target.innerHTML = "";
2401    while(i < beatCount.value){
2402      var dot = document.createElement("li");
2403      dot.className = "beat";  
2404      target.append(dot);  
2405      var bd = i+1;
2406     target.childNodes[i].innerHTML=bd.toString();
2407     target.childNodes[i].style.height=dotHt[i];
2408     target.childNodes[i].style.borderRadius=dotRd[i];
2409
2410      i++;
2411    }
2412    clickDots();
2413});
2414 // end btPlus()
2415
2416//minus.addEventListener('click', function(){
2417  //  tempo_rge.value --- 1;
2418 //   tempo_disp.innerHTML = tempo_rge.value;
2419 //   core = tempo_rge.value;
2420//});
2421
2422function minusTemp(){
2423    tempo_rge.value --- 1;
2424    tempo_disp.innerHTML = tempo_rge.value;
2425    core = tempo_rge.value;
2426    totMs = Math.round((60/core)*bts*1000);
2427  
2428    var ogTemp = 60000 / (document.getElementById('t').value)
2429  var newTemp = 60000*bangTot/(ogTemp*bts);
2430    totMs = Math.round((60/core)*bts*1000);
2431  document.getElementById('mills').innerHTML = "["+totMs+" ms]";
2432      subMs = Math.round(totMs/bangTot);
2433  document.getElementById('subMs').innerHTML = "{"+subMs+" ms}";
2434  if (meterOn.clicked) {
2435       if (bangTot==1)
2436    {document.getElementById('bangTot').innerHTML = bangTot+ " beat @";}
2437   else {document.getElementById('bangTot').innerHTML = bangTot+ " beats @";}
2438  document.getElementById('bangTemp').innerHTML = "~"+Math.round(newTemp)+" bpm";
2439  }
2440  
2441  
2442  
2443}
2444
2445
2446extraMinus.addEventListener('click', function(){
2447    tempo_rge.value = tempo_rge.value --- 5;
2448    tempo_disp.innerHTML = tempo_rge.value;
2449});
2450
2451// § subtract beats §
2452beatMinus.addEventListener('click', function(){
2453    beatCount.value = beatCount.value --- 1;
2454     if (beatCount.value==1) { 
2455    document.getElementById('len2').className ="hidden";
2456    document.getElementById('ac2').className="hidden";
2457    document.getElementById('pr2').className="hidden";
2458    document.getElementById('len2').value =0;
2459           document.getElementById('pcLfSp').width="38";
2460       document.getElementById('pcRtSp').width="1";
2461              document.getElementById('acLfSp').width="1";
2462       document.getElementById('acRtSp').width="17";
2463    
2464    }
2465    else if (beatCount.value==2) { 
2466    document.getElementById('len3').className ="hidden";
2467    document.getElementById('ac3').className="hidden";
2468    document.getElementById('pr3').className="hidden";
2469    document.getElementById('len3').value =0;
2470       document.getElementById('pcLfSp').width="44";
2471       document.getElementById('pcRtSp').width="6";
2472              document.getElementById('acLfSp').width="1";
2473       document.getElementById('acRtSp').width="18";
2474    }
2475    else if (beatCount.value==3) { 
2476    document.getElementById('len4').className ="hidden";
2477    document.getElementById('ac4').className="hidden";
2478    document.getElementById('pr4').className="hidden";
2479    document.getElementById('len4').value =0;
2480       document.getElementById('pcLfSp').width="44";
2481       document.getElementById('pcRtSp').width="4";
2482              document.getElementById('acLfSp').width="1";
2483       document.getElementById('acRtSp').width="20";
2484    }
2485    else if (beatCount.value==4) { 
2486        document.getElementById('len5').className ="hidden";
2487    document.getElementById('ac5').className="hidden";
2488    document.getElementById('pr5').className="hidden";
2489    document.getElementById('len5').value =0;
2490       document.getElementById('pcLfSp').width="42";
2491       document.getElementById('pcRtSp').width="1";
2492              document.getElementById('acLfSp').width="1";
2493       document.getElementById('acRtSp').width="20";    }
2494       
2495    else if (beatCount.value==5) { 
2496        document.getElementById('len6').className ="hidden";
2497    document.getElementById('ac6').className="hidden";
2498    document.getElementById('pr6').className="hidden";
2499    document.getElementById('len6').value =0;
2500       document.getElementById('pcLfSp').width="40";
2501       document.getElementById('pcRtSp').width="1";
2502              document.getElementById('acLfSp').width="1";
2503       document.getElementById('acRtSp').width="20";    }
2504       
2505    else if (beatCount.value==6) { 
2506      document.getElementById('len7').className ="hidden";
2507      document.getElementById('ac7').className="hidden";
2508      document.getElementById('pr7').className="hidden";
2509      document.getElementById('len7').value =0;
2510       document.getElementById('pcLfSp').width="40";
2511       document.getElementById('pcRtSp').width="1";
2512              document.getElementById('acLfSp').width="1";
2513       document.getElementById('acRtSp').width="20";    }
2514       
2515        else if (beatCount.value==7) { 
2516      document.getElementById('len8').className ="hidden";
2517      document.getElementById('ac8').className="hidden";
2518      document.getElementById('pr8').className="hidden";
2519      document.getElementById('len8').value =0;
2520       document.getElementById('pcLfSp').width="40";
2521       document.getElementById('pcRtSp').width="1";
2522              document.getElementById('acLfSp').width="1";
2523       document.getElementById('acRtSp').width="22";    }
2524        else if (beatCount.value==8) { 
2525      document.getElementById('len9').className ="hidden";
2526      document.getElementById('ac9').className="hidden";
2527      document.getElementById('pr9').className="hidden";
2528      document.getElementById('len9').value =0;
2529       document.getElementById('pcLfSp').width="42";
2530       document.getElementById('pcRtSp').width="1";
2531              document.getElementById('acLfSp').width="1";
2532       document.getElementById('acRtSp').width="20";    }
2533       
2534        else if (beatCount.value==9) { 
2535      document.getElementById('len10').className ="hidden";
2536      document.getElementById('ac10').className="hidden";
2537      document.getElementById('pr10').className="hidden";
2538      document.getElementById('len10').value =0;
2539       document.getElementById('pcLfSp').width="34";
2540       document.getElementById('pcRtSp').width="1";       
2541       document.getElementById('acLfSp').width="1";
2542       document.getElementById('acRtSp').width="20";    }
2543       
2544        else if (beatCount.value==10) { 
2545      document.getElementById('len11').className ="hidden";
2546      document.getElementById('ac11').className="hidden";
2547      document.getElementById('pr11').className="hidden";
2548      document.getElementById('len11').value =0;
2549       document.getElementById('pcLfSp').width="33";
2550       document.getElementById('pcRtSp').width="1";       
2551       document.getElementById('acLfSp').width="1";
2552       document.getElementById('acRtSp').width="18";    }
2553       
2554        else if (beatCount.value==11) { 
2555      document.getElementById('len12').className ="hidden";
2556      document.getElementById('ac12').className="hidden";
2557      document.getElementById('pr12').className="hidden";
2558      document.getElementById('len12').value =0;
2559       document.getElementById('pcLfSp').width="32";
2560       document.getElementById('pcRtSp').width="1";
2561              document.getElementById('acLfSp').width="1";
2562       document.getElementById('acRtSp').width="21";    }
2563       
2564       else if (beatCount.value==12) { 
2565      document.getElementById('len13').className ="hidden";
2566      document.getElementById('ac13').className="hidden";
2567      document.getElementById('pr13').className="hidden";
2568      document.getElementById('len13').value =0;
2569       document.getElementById('pcLfSp').width="32";
2570       document.getElementById('pcRtSp').width="1";
2571              document.getElementById('acLfSp').width="1";
2572       document.getElementById('acRtSp').width="18";    }
2573       
2574           else if (beatCount.value==13) { 
2575      document.getElementById('len14').className ="hidden";
2576      document.getElementById('ac14').className="hidden";
2577      document.getElementById('pr14').className="hidden";
2578      document.getElementById('len14').value =0;
2579       document.getElementById('pcLfSp').width="32";
2580       document.getElementById('pcRtSp').width="1";
2581              document.getElementById('acLfSp').width="1";
2582       document.getElementById('acRtSp').width="20";    }
2583       
2584           else if (beatCount.value==14) { 
2585      document.getElementById('len15').className ="hidden";
2586      document.getElementById('ac15').className="hidden";
2587      document.getElementById('pr15').className="hidden";
2588      document.getElementById('len15').value =0;
2589       document.getElementById('pcLfSp').width="32";
2590       document.getElementById('pcRtSp').width="1";
2591              document.getElementById('acLfSp').width="4";
2592       document.getElementById('acRtSp').width="20";    }
2593       
2594           else if (beatCount.value==15) { 
2595      document.getElementById('len16').className ="hidden";
2596      document.getElementById('ac16').className="hidden";
2597      document.getElementById('pr16').className="hidden";
2598      document.getElementById('len16').value =0;
2599       document.getElementById('pcLfSp').width="32";
2600       document.getElementById('pcRtSp').width="1";
2601              document.getElementById('acLfSp').width="1";
2602       document.getElementById('acRtSp').width="20";    }
2603       else if (beatCount.value==16) { 
2604      document.getElementById('len17').className ="hidden";
2605      document.getElementById('ac17').className="hidden";
2606      document.getElementById('pr17').className="hidden";
2607      document.getElementById('len17').value =0;
2608       document.getElementById('pcLfSp').width="32";
2609       document.getElementById('pcRtSp').width="1";
2610              document.getElementById('acLfSp').width="1";
2611       document.getElementById('acRtSp').width="21";    }
2612           else if (beatCount.value==17) { 
2613      document.getElementById('len18').className ="hidden";
2614      document.getElementById('ac18').className="hidden";
2615      document.getElementById('pr18').className="hidden";
2616      document.getElementById('len18').value =0;
2617       document.getElementById('pcLfSp').width="32";
2618       document.getElementById('pcRtSp').width="1";
2619              document.getElementById('acLfSp').width="1";
2620       document.getElementById('acRtSp').width="20";    }
2621           else if (beatCount.value==18) { 
2622      document.getElementById('len19').className ="hidden";
2623      document.getElementById('ac19').className="hidden";
2624      document.getElementById('pr19').className="hidden";
2625      document.getElementById('len19').value =0;
2626       document.getElementById('pcLfSp').width="32";
2627       document.getElementById('pcRtSp').width="1";
2628              document.getElementById('acLfSp').width="1";
2629       document.getElementById('acRtSp').width="22";    }
2630      else if (beatCount.value==19) { 
2631      document.getElementById('len20').className ="hidden";
2632      document.getElementById('ac20').className="hidden";
2633      document.getElementById('pr20').className="hidden";
2634      document.getElementById('len20').value =0;
2635       document.getElementById('pcLfSp').width="32";
2636       document.getElementById('pcRtSp').width="1";
2637              document.getElementById('acLfSp').width="1";
2638       document.getElementById('acRtSp').width="20";    }
2639            else if (beatCount.value==20) { 
2640      document.getElementById('len21').className ="hidden";
2641      document.getElementById('ac21').className="hidden";
2642      document.getElementById('pr21').className="hidden";
2643      document.getElementById('len21').value =0;
2644       document.getElementById('pcLfSp').width="32";
2645       document.getElementById('pcRtSp').width="1";
2646              document.getElementById('acLfSp').width="1";
2647       document.getElementById('acRtSp').width="20";    }
2648            else if (beatCount.value==21) { 
2649      document.getElementById('len22').className ="hidden";
2650      document.getElementById('ac22').className="hidden";
2651      document.getElementById('pr22').className="hidden";
2652      document.getElementById('len22').value =0;
2653       document.getElementById('pcLfSp').width="32";
2654       document.getElementById('pcRtSp').width="1";
2655              document.getElementById('acLfSp').width="1";
2656       document.getElementById('acRtSp').width="20";    }
2657            else if (beatCount.value==22) { 
2658      document.getElementById('len23').className ="hidden";
2659      document.getElementById('ac23').className="hidden";
2660      document.getElementById('pr23').className="hidden";
2661      document.getElementById('len23').value =0;
2662       document.getElementById('pcLfSp').width="32";
2663       document.getElementById('pcRtSp').width="1";
2664              document.getElementById('acLfSp').width="1";
2665       document.getElementById('acRtSp').width="18";    }
2666            else if (beatCount.value==23) { 
2667      document.getElementById('len24').className ="hidden";
2668      document.getElementById('ac24').className="hidden";
2669      document.getElementById('pr24').className="hidden";
2670      document.getElementById('len24').value =0;
2671       document.getElementById('pcLfSp').width="32";
2672       document.getElementById('pcRtSp').width="1";
2673              document.getElementById('acLfSp').width="1";
2674       document.getElementById('acRtSp').width="18";    }
2675       
2676    if( beatCount.value < 1){ beatCount.value = 1; }
2677    btWts();
2678    beatNbr.innerHTML =  "/"+beatCount.value;
2679    var i = 0,
2680    target = document.getElementById('dotTarget');
2681    target.innerHTML = "";
2682    while(i < beatCount.value){
2683      var dot = document.createElement("li");
2684      dot.className = "beat";  
2685      target.append(dot);  
2686            var bd = i+1;
2687      target.childNodes[i].innerHTML=bd.toString();
2688     target.childNodes[i].style.height=dotHt[i];
2689     target.childNodes[i].style.borderRadius=dotRd[i];
2690      i++;
2691    }
2692    clickDots(); level();
2693});
2694
2695dotsDisplay.addEventListener('click', function(){
2696    dotsDisplay.className = 'header-btn button-active';
2697    if(digitalDisplay.className == 'header-btn button-active' || bothDisplay.className == 'header-btn button-active'){
2698      digitalDisplay.classList.remove('button-active');
2699      bothDisplay.classList.remove('button-active');
2700    }
2701    dotTarget.style.display = 'flex';
2702    digitalDisplayContainer.style.display = 'none';
2703});
2704
2705digitalDisplay.addEventListener('click', function(){
2706    digitalDisplay.className = 'header-btn button-active';
2707    if(dotsDisplay.className == 'header-btn button-active' || bothDisplay.className == 'header-btn button-active'){
2708      dotsDisplay.classList.remove('button-active');
2709      bothDisplay.classList.remove('button-active');
2710    }
2711    digitalDisplayContainer.style.display = 'flex';
2712    dotTarget.style.display = 'none';
2713});
2714
2715bothDisplay.addEventListener('click', function(){
2716    bothDisplay.className = 'header-btn button-active';
2717    if(dotsDisplay.className == 'header-btn button-active' || digitalDisplay.className == 'header-btn button-active'){
2718      dotsDisplay.classList.remove('button-active');
2719      digitalDisplay.classList.remove('button-active');
2720    }
2721    dotTarget.style.display = 'flex';
2722    digitalDisplayContainer.style.display = 'flex';
2723});
2724
2725function dumpIt() {
2726dumpAll = document.getElementById("dump").value;
2727dStr = dumpAll.split("$ ");
2728dumpOn = 1;
2729setQ = 0; setTot = dStr.length;
2730//document.getElementById('testIt4').innerHTML = "0th= " + dStr[0];
2731//document.getElementById('testIt5').innerHTML = " last= "+ dStr[dStr.length - 1];
2732dumping(setQ);
2733//dumping(1);
2734
2735}
2736
2737function dumping(dQ) {
2738//dumpIn = document.getElementById("dump").value;
2739noteFlag=0;
2740dumpIn = dStr[dQ];
2741if (dumpIn.substr(dumpIn.length - 1) == " ") {
2742dumpIn = dumpIn.substr(0, dumpIn.length - 1)
2743}
2744var bdz, td, lName, aName, pName, cName, slot;
2745var bln = new Array; var blnTot = 0;
2746var sym = "^";
2747var dmp = dumpIn.split(" "); 
2748td = Number(dmp[0]);
2749bdz = Number((dmp.length - 1)/2);
2750dmpQ = 0; dmpTot = bdz;
2751
2752if ( bdz != Math.round(bdz) || Number.isNaN(td) ) {
2753document.getElementById("dump").style.backgroundColor = "red";
2754document.getElementById("dump").style.color = "yellow";
2755   }
2756else if (dumpIn!="") {
2757document.getElementById("dump").style.backgroundColor = "white";
2758document.getElementById("dump").style.color = "black";
2759document.getElementById('t').value = td;
2760document.getElementById('tempo-disp').innerHTML = td;
2761 	
2762if (dmp.length>1){
2763document.getElementById('beatCount').value = bdz;
2764document.getElementById('beatNbr').innerHTML =  "/"+bdz;
2765
2766for (i=1;i<dmp.length;i+= 2) {
2767slot = (i+1)/2; 
2768var test = Number(dmp[i+1]);
2769if ( Number.isNaN(test) ) {
2770document.getElementById("dump").style.backgroundColor = "red";
2771document.getElementById("dump").style.color = "yellow";
2772   }
2773//sym = dmp[i+1];
2774sym = dmp[i];
2775if (acar[sym]=== void 0) {sym = "4";}
2776lName = "len"+slot.toString();
2777//document.getElementById(lName).value = dmp[i];
2778document.getElementById(lName).value = dmp[i+1];
2779//bln[slot] = Number(dmp[i]); 
2780bln[slot] = Number(dmp[i+1]); 
2781blnTot = bln[slot]+blnTot;
2782aName = "ac"+slot.toString();
2783document.getElementById(aName).selectedIndex = acar[sym];	
2784	}
2785	
2786for (j=1;j<bln.length;j++) {
2787   pName = "pr"+j.toString();
2788   document.getElementById(pName).value = Math.round(100*(bln[j]/blnTot))+"% ";
2789 
2790   cName = "color"+j.toString();
2791   document.getElementById(cName).width = tile[bdz]*Math.round(100*(bln[j]/blnTot));
2792 } // end for j
2793
2794} //end  bdz>0
2795
2796bdz = document.getElementById('beatCount').value;
2797redraw(bdz);
2798
2799var totMs = Math.round((60/dmp[0])*bdz*1000);
2800  document.getElementById('mills').innerHTML = "["+totMs+" ms]";
2801  
2802 // INSERTED BELOW FOR BANGTOT 
2803  bangTot = 0; bangSub = 0;
2804  dotty = document.querySelectorAll('#dotTarget li');  
2805  for (var i=0; i<bdz;i++) {
2806   if (acar[i]> 1.0){
2807   bangTot = bangTot + 1; bangSub=.1; 
2808   meterOn.checked = true;
2809   }
2810   else {bangSub=bangSub+.1;  }
2811  
2812   bangFlag[i]=bangTot+ Math.round(bangSub*10)/10;
2813  }
2814  if (bangTot==0) {meterOn.checked = false; meterIt();}
2815  var ogTemp = 60000 / (document.getElementById('t').value)
2816  var newTemp = 60000*bangTot/(ogTemp*bts);
2817  if (meterOn.checked){
2818
2819  document.getElementById('bangTemp').className = "min-btn";
2820document.getElementById('subMs').className = "min-btn";
2821    document.getElementById('subMs').innerHTML = "{"+Math.round(totMs/bangTot)+"ms}";
2822 //     document.getElementById('testIt4').innerHTML = "sub?";
2823     if (bangTot==1)
2824    {document.getElementById('bangTot').innerHTML = bangTot+ " beat @";}
2825   else {document.getElementById('bangTot').innerHTML = bangTot+ " beats @";}
2826  document.getElementById('bangTemp').innerHTML = "~"+Math.round(newTemp)+" bpm";
2827
2828  }
2829  else {document.getElementById('bangTemp').className = "min-btn hidden";}
2830  
2831  // INSERTED AVBOVE FOR BANGTOT  
2832  
2833 sg1 = 100*(bln[1]/blnTot);
2834 sg2 = 100*(bln[2]/blnTot);
2835sg3 = 100*(bln[3]/blnTot);
2836  if (bdz==3){
2837signs(sg1, sg2,sg3); document.getElementById('sign').className = "";} 
2838   else{  document.getElementById('sign').className = "hidden";}
2839  
2840   //document.getElementById('subMs').innerHTML = "{"+Math.round(totMs/bangTot)+"ms}";  
2841temp(dmp[0]);
2842clickDots();
2843level();
2844isop();
2845btwts();
2846startIt();
2847
2848} // end !error
2849} // dumpIt()
2850
2851function redraw(btIn) {
2852var bdz = btIn;
2853var lNam, aNam, pNam, cNam;
2854lArr = new Array ("zero", "one", "two", "three", "four", "five", "six");
2855for (k=bdz; k<25; k++) {
2856var jam = k;
2857if (jam>bdz && bdz!=0) {
2858lNam = "len"+jam.toString();
2859 aNam="ac"+jam.toString(); 
2860 pNam="pr"+jam.toString();
2861 cNam="color"+jam.toString();
2862    document.getElementById(lNam).className ="hidden";
2863    document.getElementById(lNam).value = 0;
2864    document.getElementById(aNam).className="hidden";
2865    document.getElementById(pNam).className="hidden";
2866    document.getElementById(cNam).width=0;
2867}
2868    lArr[k] = lNam;
2869}
2870
2871
2872  //  document.getElementById('len5').className ="hidden";
2873   // document.getElementById('ac5').className="hidden";
2874
2875 if (bdz>1){
2876       document.getElementById('len2').className="";
2877       document.getElementById('ac2').className="";
2878       document.getElementById('pr2').className="bx";
2879       document.getElementById('pcLfSp').width="44";
2880       document.getElementById('pcRtSp').width="1";
2881              document.getElementById('acLfSp').width="8";
2882       document.getElementById('acRtSp').width="1";
2883       }
2884 
2885  if (bdz>2){
2886       document.getElementById('len3').className="";
2887       document.getElementById('ac3').className="";
2888       document.getElementById('pr3').className="bx";
2889       document.getElementById('pcLfSp').width="44";
2890       document.getElementById('pcRtSp').width="1";
2891              document.getElementById('acLfSp').width="4";
2892       document.getElementById('acRtSp').width="1";
2893       }
2894 
2895     if (bdz>3){
2896      document.getElementById('len4').className="";
2897       document.getElementById('ac4').className="";
2898       document.getElementById('pr4').className="bx";
2899       document.getElementById('pcLfSp').width="42";
2900       document.getElementById('pcRtSp').width="1";
2901              document.getElementById('acLfSp').width="1";
2902       document.getElementById('acRtSp').width="1";
2903       }
2904 if (bdz>4){
2905       document.getElementById('len5').className="";
2906       document.getElementById('ac5').className="";
2907       document.getElementById('pr5').className="bx";
2908       document.getElementById('pcLfSp').width="40";
2909       document.getElementById('pcRtSp').width="1";
2910              document.getElementById('acLfSp').width="1";
2911       document.getElementById('acRtSp').width="1";
2912       }
2913  if (bdz>5){
2914        document.getElementById('len6').className="";
2915       document.getElementById('ac6').className="";
2916       document.getElementById('pr6').className="bx";
2917       document.getElementById('pcLfSp').width="40";
2918       document.getElementById('pcRtSp').width="1";
2919              document.getElementById('acLfSp').width="1";
2920       document.getElementById('acRtSp').width="1";
2921       }
2922    if (bdz>6){
2923        document.getElementById('len7').className="";
2924       document.getElementById('ac7').className="";
2925       document.getElementById('pr7').className="bx";
2926       document.getElementById('pcLfSp').width="40";
2927       document.getElementById('pcRtSp').width="1";
2928              document.getElementById('acLfSp').width="1";
2929       document.getElementById('acRtSp').width="1";
2930       }
2931
2932     if (bdz>7){
2933        document.getElementById('len8').className="";
2934       document.getElementById('ac8').className="";
2935       document.getElementById('pr8').className="bx";
2936       document.getElementById('pcLfSp').width="42";
2937       document.getElementById('pcRtSp').width="1";
2938              document.getElementById('acLfSp').width="1";
2939       document.getElementById('acRtSp').width="12";
2940       }
2941 
2942       if (bdz>8) {
2943               document.getElementById('len9').className="";
2944       document.getElementById('ac9').className="";
2945       document.getElementById('pr9').className="bx";
2946       document.getElementById('pcLfSp').width="36";
2947       document.getElementById('pcRtSp').width="1";
2948              document.getElementById('acLfSp').width="1";
2949       document.getElementById('acRtSp').width="12";
2950       }
2951       
2952        if (bdz>9) {
2953        document.getElementById('len10').className="";
2954       document.getElementById('ac10').className="";
2955       document.getElementById('pr10').className="bx";
2956       document.getElementById('pcLfSp').width="37";
2957       document.getElementById('pcRtSp').width="1";
2958              document.getElementById('acLfSp').width="1";
2959       document.getElementById('acRtSp').width="12";
2960       }
2961       
2962      if (bdz>10) {
2963        document.getElementById('len11').className="";
2964       document.getElementById('ac11').className="";
2965       document.getElementById('pr11').className="bx";
2966       document.getElementById('pcLfSp').width="39";
2967       document.getElementById('pcRtSp').width="1";
2968              document.getElementById('acLfSp').width="1";
2969       document.getElementById('acRtSp').width="15";
2970       }
2971       
2972       if (bdz>11) {
2973        document.getElementById('len12').className="";
2974       document.getElementById('ac12').className="";
2975       document.getElementById('pr12').className="bx";
2976       document.getElementById('pcLfSp').width="38";
2977       document.getElementById('pcRtSp').width="1";
2978              document.getElementById('acLfSp').width="1";
2979       document.getElementById('acRtSp').width="15";
2980       }
2981  if (bdz>12) {
2982        document.getElementById('len13').className="";
2983       document.getElementById('ac13').className="";
2984       document.getElementById('pr13').className="bx";
2985       document.getElementById('pcLfSp').width="38";
2986       document.getElementById('pcRtSp').width="1";
2987              document.getElementById('acLfSp').width="1";
2988       document.getElementById('acRtSp').width="15";
2989       }
2990     if (bdz>13) {
2991        document.getElementById('len14').className="";
2992       document.getElementById('ac14').className="";
2993       document.getElementById('pr14').className="bx";
2994       document.getElementById('pcLfSp').width="38";
2995       document.getElementById('pcRtSp').width="1";
2996              document.getElementById('acLfSp').width="1";
2997       document.getElementById('acRtSp').width="12";
2998       }
2999      if (bdz>14) {
3000        document.getElementById('len15').className="";
3001       document.getElementById('ac15').className="";
3002       document.getElementById('pr15').className="bx";
3003       document.getElementById('pcLfSp').width="38";
3004       document.getElementById('pcRtSp').width="1";
3005              document.getElementById('acLfSp').width="1";
3006       document.getElementById('acRtSp').width="13";
3007       }
3008       if (bdz>15) {
3009        document.getElementById('len16').className="";
3010       document.getElementById('ac16').className="";
3011       document.getElementById('pr16').className="bx";
3012       document.getElementById('pcLfSp').width="38";
3013       document.getElementById('pcRtSp').width="1";
3014              document.getElementById('acLfSp').width="1";
3015       document.getElementById('acRtSp').width="16";
3016       }     
3017        if (bdz>16)  {
3018        document.getElementById('len17').className="";
3019       document.getElementById('ac17').className="";
3020       document.getElementById('pr17').className="bx";
3021       document.getElementById('pcLfSp').width="38";
3022       document.getElementById('pcRtSp').width="1";
3023              document.getElementById('acLfSp').width="1";
3024       document.getElementById('acRtSp').width="16";
3025     }
3026      if (bdz>17)  {
3027        document.getElementById('len18').className="";
3028       document.getElementById('ac18').className="";
3029       document.getElementById('pr18').className="bx";
3030       document.getElementById('pcLfSp').width="38";
3031       document.getElementById('pcRtSp').width="1";
3032              document.getElementById('acLfSp').width="1";
3033       document.getElementById('acRtSp').width="16";
3034     }
3035    if (bdz>18)  {
3036        document.getElementById('len19').className="";
3037       document.getElementById('ac19').className="";
3038       document.getElementById('pr19').className="bx";
3039       document.getElementById('pcLfSp').width="38";
3040       document.getElementById('pcRtSp').width="1";
3041              document.getElementById('acLfSp').width="1";
3042       document.getElementById('acRtSp').width="16";
3043     }
3044     if (bdz>19)  {
3045        document.getElementById('len20').className="";
3046       document.getElementById('ac20').className="";
3047       document.getElementById('pr20').className="bx";
3048       document.getElementById('pcLfSp').width="38";
3049       document.getElementById('pcRtSp').width="1";
3050              document.getElementById('acLfSp').width="1";
3051       document.getElementById('acRtSp').width="16";
3052     }   
3053      if (bdz>20)  {
3054        document.getElementById('len21').className="";
3055       document.getElementById('ac21').className="";
3056       document.getElementById('pr21').className="bx";
3057       document.getElementById('pcLfSp').width="38";
3058       document.getElementById('pcRtSp').width="1";
3059              document.getElementById('acLfSp').width="1";
3060       document.getElementById('acRtSp').width="16";
3061     }     
3062       if (bdz>21)  {
3063        document.getElementById('len22').className="";
3064       document.getElementById('ac22').className="";
3065       document.getElementById('pr22').className="bx";
3066       document.getElementById('pcLfSp').width="38";
3067       document.getElementById('pcRtSp').width="1";
3068              document.getElementById('acLfSp').width="1";
3069       document.getElementById('acRtSp').width="16";
3070     }     
3071       if (bdz>22)  {
3072        document.getElementById('len23').className="";
3073       document.getElementById('ac23').className="";
3074       document.getElementById('pr23').className="bx";
3075       document.getElementById('pcLfSp').width="38";
3076       document.getElementById('pcRtSp').width="1";
3077              document.getElementById('acLfSp').width="1";
3078       document.getElementById('acRtSp').width="16";
3079     }     
3080     if (bdz>23)  {
3081        document.getElementById('len24').className="";
3082       document.getElementById('ac24').className="";
3083       document.getElementById('pr24').className="bx";
3084       document.getElementById('pcLfSp').width="38";
3085       document.getElementById('pcRtSp').width="1";
3086              document.getElementById('acLfSp').width="1";
3087       document.getElementById('acRtSp').width="16";
3088     } 
3089       
3090            var j = 0;
3091    target = document.getElementById('dotTarget');
3092    target.innerHTML = "";
3093    while(j < bdz){
3094      var dot = document.createElement("li");
3095      dot.className = "beat";  
3096      target.append(dot);  
3097      var bd = j+1;
3098     target.childNodes[j].innerHTML=bd.toString();
3099      j++;
3100    }
3101    
3102    var beatDotz = document.getElementsByClassName('beat');
3103
3104   for(u = 0; u < beatDotz.length; u++){
3105    beatDotz[u].addEventListener('click', function(){
3106      if(this.className === "beat active"){
3107         this.className = "beat"; }
3108      else{ this.className += " active";}
3109    });
3110  } // end for u++
3111
3112       
3113} // end redraw()
3114function muteIt(){
3115if (mute==0){mute=1;}
3116else if (mute==1) {mute=0;}
3117}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.