|
252 | 252 | max = parseInt(min) + parseInt(degRange);
|
253 | 253 | valRange = maxVal- minVal;
|
254 | 254 | rosetta = degRange / valRange;
|
255 |
| - startingValue = node.getAttribute("value"); |
| 255 | + startingValue = node.getAttribute("value"); |
256 | 256 |
|
257 | 257 |
|
258 | 258 | var parent = node.parentNode;
|
|
267 | 267 | rotate(face, min);
|
268 | 268 |
|
269 | 269 |
|
270 |
| - var label = document.createElement("label"); |
271 |
| - label.className = "knobInput-label"; |
272 |
| - var progress = document.createElement("canvas"); |
273 |
| - |
274 |
| - progress.className = "knob-progress"; |
275 |
| - label.innerHTML = node.value; |
276 |
| - knob.setAttribute("data-original-element", node.id); |
277 |
| - knob.setAttribute("data-rosetta", rosetta); |
278 |
| - knob.setAttribute("min", minVal); |
279 |
| - var hand = document.createElement(tagBase + "-hand"); |
280 |
| - |
281 |
| - knob.appendChild(face); |
282 |
| - knob.appendChild(progress); |
283 |
| - knob.appendChild(label); |
284 |
| - face.appendChild(hand); |
285 |
| - knob.appendChild(node); |
| 270 | + var label = document.createElement("label"); |
| 271 | + label.className = "knobInput-label"; |
| 272 | + var progress = document.createElement("canvas"); |
| 273 | + |
| 274 | + progress.className = "knob-progress"; |
| 275 | + label.innerHTML = node.value; |
| 276 | + knob.setAttribute("data-original-element", node.id); |
| 277 | + knob.setAttribute("data-rosetta", rosetta); |
| 278 | + knob.setAttribute("min", minVal); |
| 279 | + var hand = document.createElement(tagBase + "-hand"); |
| 280 | + |
| 281 | + knob.appendChild(face); |
| 282 | + knob.appendChild(progress); |
| 283 | + knob.appendChild(label); |
| 284 | + face.appendChild(hand); |
| 285 | + knob.appendChild(node); |
286 | 286 |
|
287 | 287 |
|
288 |
| - if(sibling){ |
289 |
| - parent.insertBefore(knob, sibling) |
290 |
| - } else{ |
291 |
| - parent.appendChild(knob); |
292 |
| - } |
| 288 | + if(sibling){ |
| 289 | + parent.insertBefore(knob, sibling) |
| 290 | + } else{ |
| 291 | + parent.appendChild(knob); |
| 292 | + } |
293 | 293 |
|
294 | 294 |
|
295 |
| - if(startingValue){ |
296 |
| - var degrees = (startingValue - minVal) * rosetta; |
297 |
| - degrees = parseInt(degrees) + parseInt(min); |
298 |
| - rotate(face, degrees); |
| 295 | + if(startingValue){ |
| 296 | + var degrees = (startingValue - minVal) * rosetta; |
| 297 | + degrees = parseInt(degrees) + parseInt(min); |
| 298 | + rotate(face, degrees); |
299 | 299 |
|
300 |
| - var rad = parseInt(getCSS(face, "width"))/ 2; |
| 300 | + var rad = parseInt(getCSS(face, "width"))/ 2; |
301 | 301 |
|
302 | 302 | }
|
303 | 303 |
|
304 | 304 |
|
305 |
| - knob.addEventListener("mousedown", function(e){ |
306 |
| - focused = this; |
307 |
| - mouse.clickPos = e.pageY; |
308 |
| - mouse.lastPos = e.pageY; |
309 |
| - document.body.className += "noSelection"; |
| 305 | + knob.addEventListener("mousedown", function(e){ |
| 306 | + focused = this; |
| 307 | + mouse.clickPos = e.pageY; |
| 308 | + mouse.lastPos = e.pageY; |
| 309 | + document.body.className += "noSelection"; |
310 | 310 | });
|
311 | 311 |
|
312 |
| - document.addEventListener("mousemove", function(e){ |
| 312 | + document.addEventListener("mousemove", function(e){ |
313 | 313 | if(focused){
|
314 | 314 | if(!mouse.lastPos){
|
315 | 315 | mouse.lastPos = mouse.clickPos;
|
|
386 | 386 |
|
387 | 387 | }
|
388 | 388 |
|
389 |
| - function clearCanvas(canvas){ |
| 389 | + function clearCanvas(canvas){ |
390 | 390 | var ctx = canvas.getContext("2d");
|
391 | 391 | ctx.clearRect ( 0 , 0 , canvas.width, canvas.height );
|
392 | 392 | }
|
393 | 393 |
|
394 |
| - function drawArc(canvas, radius, deg, min, lw, col){ |
| 394 | + function drawArc(canvas, radius, deg, min, lw, col){ |
395 | 395 | //console.log(canvas, radius, deg, min, lw, col);
|
396 | 396 | var ctx = canvas.getContext("2d");
|
397 | 397 | clearCanvas(canvas);
|
|
402 | 402 | ctx.stroke();
|
403 | 403 | }
|
404 | 404 |
|
405 |
| - function simulateEvent(ev, elm) { |
| 405 | +function simulateEvent(ev, elm) { |
406 | 406 | var event = new Event('input', {
|
407 | 407 | 'view': window
|
408 | 408 | });
|
409 | 409 | var cb = elm;
|
410 | 410 | cb.dispatchEvent(event);
|
411 | 411 | }
|
412 | 412 |
|
413 |
| - function toRad(deg){ |
| 413 | + function toRad(deg){ |
414 | 414 | var rad = deg / (180 / Math.PI);
|
415 | 415 | return rad;
|
416 | 416 | }
|
417 | 417 |
|
418 | 418 |
|
419 |
| - function rotate(elm, deg){ |
| 419 | + function rotate(elm, deg){ |
420 | 420 | elm.style.transform = "rotate("+ deg +"deg)";
|
421 | 421 | }
|
422 | 422 |
|
423 |
| - function getCSS(elm, prop){ |
| 423 | + function getCSS(elm, prop){ |
424 | 424 | return window.getComputedStyle(elm, prop).getPropertyValue(prop);
|
425 | 425 | }
|
426 | 426 |
|
427 | 427 |
|
428 |
| - rangeKnob(document.querySelectorAll('.blue'), 20, "#525AD9"); |
| 428 | +rangeKnob(document.querySelectorAll('.blue'), 20, "#525AD9"); |
429 | 429 |
|
430 |
| - rangeKnob([document.getElementById('pink')], 30, "#D952AC"); |
| 430 | +rangeKnob([document.getElementById('pink')], 30, "#D952AC"); |
431 | 431 |
|
432 | 432 |
|
433 | 433 | // nk
|
434 | 434 |
|
435 |
| - function loop(){window.setInterval(updateKnob,100)} |
436 |
| - function updateKnob(){ |
437 |
| - var yop = (document.getElementById('key_data').innerHTML.slice(64,67).replace(']',''))*2.83464 |
438 |
| - document.getElementById('knob01').value = yop |
439 |
| - document.getElementsByClassName('knobInput-face')[0].style.transform = "rotate("+document.getElementById('knob01').value+"deg)" |
440 |
| - document.getElementsByClassName('knobInput-label')[0].innerHTML = document.getElementById('knob01').value |
441 |
| - document.getElementById('knob01').value = yop |
442 |
| - document.getElementsByClassName('knobInput-face')[1].style.transform = "rotate("+yop+"deg)" |
443 |
| - document.getElementsByClassName('knobInput-label')[1].innerHTML = yop |
| 435 | + function loop(){window.setInterval(updateKnob,100)} |
| 436 | + |
| 437 | + function updateKnob(){ |
| 438 | + var yop = (document.getElementById('key_data').innerHTML.slice(64,67).replace(']',''))*2.83464 |
| 439 | + document.getElementById('knob01').value = yop |
| 440 | + document.getElementsByClassName('knobInput-face')[0].style.transform = "rotate("+document.getElementById('knob01').value+"deg)" |
| 441 | + document.getElementsByClassName('knobInput-label')[0].innerHTML = document.getElementById('knob01').value |
| 442 | + document.getElementById('knob01').value = yop |
| 443 | + document.getElementsByClassName('knobInput-face')[1].style.transform = "rotate("+yop+"deg)" |
| 444 | + document.getElementsByClassName('knobInput-label')[1].innerHTML = yop |
444 | 445 | }
|
445 | 446 |
|
446 |
| - function randomColor() { |
| 447 | + function randomColor() { |
447 | 448 | return [
|
448 | 449 | Math.floor(Math.random() * 255),
|
449 | 450 | Math.floor(Math.random() * 255),
|
450 | 451 | Math.floor(Math.random() * 255)];
|
451 | 452 | }
|
452 | 453 |
|
453 |
| - function upBck(){ |
| 454 | + function upBck(){ |
454 | 455 | document.body.style.backgroundColor = 'rgb('+randomColor()+')'
|
455 | 456 | document.getElementsByClassName('button')[0].style.backgroundColor = 'rgb('+randomColor()+')'
|
456 | 457 | document.getElementsByClassName('button')[1].style.backgroundColor = 'rgb('+randomColor()+')'
|
|
461 | 462 |
|
462 | 463 | // OOooOOO
|
463 | 464 |
|
464 |
| - (function(){ |
| 465 | +(function(){ |
465 | 466 | var log = console.log.bind(console), keyData = document.getElementById('key_data'),
|
466 | 467 | deviceInfoInputs = document.getElementById('inputs'), deviceInfoOutputs = document.getElementById('outputs'), midi;
|
467 | 468 | var AudioContext = AudioContext || webkitAudioContext; // for ios/safari
|
|
0 commit comments