From 214188eae215056fb72dacb4049f0ec07833e392 Mon Sep 17 00:00:00 2001 From: Bruno Daniel Date: Tue, 27 May 2014 21:20:54 -0300 Subject: [PATCH 1/2] Change camera to Ortographic projection --- public/build.js | 4 ++-- public/bundle.js | 24 ++++++++++++++---------- public/bundle.min.js | 4 ++-- src/Visuals/Scene.js | 8 +++++--- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/public/build.js b/public/build.js index 1d50ed0..cfbbabc 100644 --- a/public/build.js +++ b/public/build.js @@ -1248,8 +1248,8 @@ var Detector = { } }; -!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g0&&0===f-e)g[h]=d.ascMoveFormula(i,j,a,b);else if(b-a>=0&&0>f-e&&1!==f)g[h]=d.ascMoveFormula(i,j,a,b,e,f);else if(0>b-a&&f-e>0&&1!==e)g[h]=d.ascMoveFormula(i,j,a,b,e,f);else if(b-a>=0&&0>f-e&&1===f)g[h]=d.ascThumbCost(i,j,a,b,e,f);else if(0>b-a&&1===e&&1!==f)g[h]=d.descThumbCost(i,j,a,b,e,f);else{var k=d.fingerStretch(e,f),l=Math.abs(i-j)/k;g[h]=l>c.moveCutoff?d.descMoveFormula(i,j,a,b,e,f):d.ascDescNoCrossCost(i,j,l,a,b,e,f)}};b.exports.createCostDatabase=function(){for(var a={},b=1;5>=b;b++)for(var c=21;109>c;c++)for(var d=1;5>=d;d++)for(var f=21;109>f;f++)e(c,f,b,d,a);return a}},{"./CostAlgorithmHelpers.js":2,"./CostAlgorithmParameters.js":3}],2:[function(a,b){var c=a("./CostAlgorithmParameters.js"),d=b.exports,e=function(a){return.0002185873295*Math.pow(a,7)-.008611946279*Math.pow(a,6)+.1323250066*Math.pow(a,5)-1.002729677*Math.pow(a,4)+3.884106308*Math.pow(a,3)-6.723075747*Math.pow(a,2)+1.581196785*a+7.711241722},f=function(a,b,d,e,f){if("White"===c.color[a%12]&&"Black"===c.color[b%12]){if(5===e||1===e)return 4;if(0===f)return 4}if("Black"===c.color[a%12]&&"White"===c.color[b%12]){if(5===d||1===d)return 4;if(0===f)return-1}return 0},g=d.ascMoveFormula=function(a,b,d,e,g,h){var i,j=Math.ceil(a+b);return j>24?c.moveHash[24]+(j-24)/5:(i=c.moveHash[j],i+=f(d,e,g,h,b))};d.descMoveFormula=function(a,b,d,e,g,h){var i,j=Math.ceil(a-b);return j>24?c.moveHash[24]+(j-24)/5:(i=c.moveHash[j],i+=f(d,e,g,h,b))},d.fingerDistance=function(a,b){var d=a.toString()+","+b.toString();return c.fingDistance[d]},d.ascThumbCost=function(a,b,d,f,h,j){var k=i(h,j),l=(a+b)/k;if(l>10)return g(a,b);var m=e(l);return"White"===c.color[d%12]&&"Black"===c.color[f%12]&&(m+=8),m},d.descThumbCost=function(a,b,d,f,i,j){var k=h(i,j),l=(a+b)/k;if(l>10)return g(a,b);var m=e(l);return"Black"===c.color[d%12]&&"White"===c.color[f%12]&&(m+=8),m};var h=d.descThumbStretch=function(a,b){var d=a.toString()+","+b.toString();return c.descThumbStretchVals[d]},i=d.ascThumbStretch=function(a,b){var d=a.toString()+","+b.toString();return c.ascThumbStretchVals[d]};d.fingerStretch=function(a,b){var d=a.toString()+","+b.toString();return c.fingStretch[d]},d.ascDescNoCrossCost=function(a,b,d,e,g,h,i){var j,k=function(a){return-6.589793725e-7*Math.pow(a,10)-2336381414e-15*Math.pow(a,9)+9925769823e-14*Math.pow(a,8)+.0001763353131*Math.pow(a,7)-.004660305277*Math.pow(a,6)-.004290746384*Math.pow(a,5)+.06855725903*Math.pow(a,4)+.03719817227*Math.pow(a,3)+.4554696705*Math.pow(a,2)-.08305450359*a+.3020594956};return d>6.8&&d<=c.moveCutoff?k(6.8)+3*(d-6.8):(j=k(d),j+=f(e,g,h,i))}},{"./CostAlgorithmParameters.js":3}],3:[function(a,b){var c=b.exports;c.moveCutoff=7.5,c.color={0:"White",1:"Black",2:"White",3:"Black",4:"White",5:"White",6:"Black",7:"White",8:"Black",9:"White",10:"Black",11:"White"},c.fingDistance={"1,1":0,"1,2":2,"1,3":3.5,"1,4":5,"1,5":7,"2,1":2,"2,2":0,"2,3":2,"2,4":3.5,"2,5":5,"3,1":3.5,"3,2":2,"3,3":0,"3,4":2,"3,5":3.5,"4,1":5,"4,2":3.5,"4,3":2,"4,4":0,"4,5":2,"5,1":7,"5,2":5,"5,3":3.5,"5,4":2,"5,5":0};var d=c.makeMoveHash=function(a){var b={1:0,2:.5,3:1.8,4:3,5:5,6:7,7:8,8:8.9,9:9.7,10:10.5,11:11,12:11.4,13:11.8,14:12.2,15:12.5,16:12.8,17:13.1,18:13.4,19:13.7,20:14,21:14.3,22:14.6,23:14.9,24:15.2};for(var c in b)b[c]+=a;return b};c.moveHash=d(4),c.descThumbStretchVals={"1,2":1,"1,3":1,"1,4":.9,"1,5":.95},c.ascThumbStretchVals={"2,1":.95,"3,1":1,"4,1":.95,"5,1":.95},c.fingStretch={"1,1":.8,"1,2":1.15,"1,3":1.4,"1,4":1.45,"1,5":1.6,"2,1":1.15,"2,2":.6,"2,3":.9,"2,4":1.15,"2,5":1.3,"3,1":1.4,"3,2":.9,"3,3":.6,"3,4":.9,"3,5":1.15,"4,1":1.45,"4,2":1.15,"4,3":.9,"4,4":.7,"4,5":.7,"5,1":1.6,"5,2":1.3,"5,3":1.15,"5,4":.8,"5,5":.6}},{}],4:[function(a,b){var c=a("./FingeringAlgorithmHelpers.js");b.exports.FingeringAlgorithm=function(a){for(var b=c.addStartTimes(a),d=0;d0)for(var r=2,s=l;0===q.notes.length;){var t=s.bestPrev,u=f[g-r][t];q=c.getSplitData(u).right,r++,s=u}var v=n.left,w=o.left;if(v.notes.length>0)for(var r=2,s=l;0===w.notes.length;){var t=s.bestPrev,u=f[g-r][t];w=c.getSplitData(u).left,r++,s=u}var x=c.calcCost(p,q,v,"RH"),y=c.calcCost(v,w,p,"LH");m+=x+y,i>m&&(i=m,k.nodeScore=m,k.bestPrev=j)}for(var z=c.findMin(f[f.length-1]),A={},B=f.length-1;B>0;B--){for(var C=f[B][z],D=C.fingers,E=C.notes,F=0;F=h;h++)g[h]=f(h);var i=[{notes:["e","e"],fingers:[1,-1]}],j=function(a,b){this.notes=a,this.fingers=b,this.nodeScore=0,this.bestPrev=void 0},k=function(a){for(var b=a.sort(function(a,b){return a[0]-b[0]}),c=[],d=g[b.length],e=0;e0?h:0},n=function(a,b,c,e){if("e"===a||"e"===b)return 0;c=Math.abs(c),e=Math.abs(e);var f=a+","+b+","+c+","+e,g=d[f],h=b-60;return g+=h>0?h:0};e.findMin=function(a){for(var b,c=1/0,d=0;d0?(b.right.fingers.push(a.fingers[c]),b.right.notes.push(a.notes[c])):(b.left.fingers.push(a.fingers[c]),b.left.notes.push(a.notes[c]));return b},e.calcCost=function(a,b,c,d){for(var e="RH"===d?m:n,f=0,g=0;g0&&0===f-e)g[h]=d.ascMoveFormula(i,j,a,b);else if(0>=b-a&&0>f-e&&1!==f)g[h]=d.ascMoveFormula(i,j);else if(b-a>0&&f-e>0&&1!==e)g[h]=d.ascMoveFormula(i,j);else if(0>=b-a&&0>f-e&&1===f)g[h]=d.ascThumbCost(i,j,a,b,e,f);else if(b-a>=0&&1===e&&1!==f)g[h]=d.descThumbCost(i,j,a,b,e,f);else{var k=d.fingerStretch(e,f),l=Math.abs(i-j)/k;g[h]=l>c.moveCutoff?d.descMoveFormula(i,j):d.ascDescNoCrossCost(i,j,l,a,b,e,f)}};b.exports.createLHCostDatabase=function(){for(var a={},b=1;5>=b;b++)for(var c=21;109>c;c++)for(var d=1;5>=d;d++)for(var f=21;109>f;f++)e(c,f,b,d,a);return a}},{"./CostAlgorithmHelpers.js":2,"./CostAlgorithmParameters.js":3}],7:[function(a,b){var c=a("./Visuals/Piano/KeyboardDesign.js").KeyboardDesign,d=a("./Visuals/Piano/Keyboard.js").Keyboard,e=a("./Visuals/Hands/Right/RightHand.js").RightHand,f=a("./Visuals/Hands/Left/LeftHand.js").LeftHand,g=a("./Visuals/Scene.js").Scene;a("./Algorithms/CostAlgorithm").createCostDatabase;var h=a("./Algorithms/FingeringAlgorithm.js").FingeringAlgorithm,i=a("./PlayControls.js").PlayControls;b.exports.App=function(){this.keyboardDesign=new c,this.keyboard=new d(this.keyboardDesign),this.rightHand=new e(this.keyboard),this.leftHand=new f(this.keyboard),this.player=MIDI.Player;var a=this;this.player.addListener(function(b){var c=a.rightHand,d=a.leftHand,e=144,f=128,g=b.note,h=b.message,i=b.finger;h===e?(a.keyboard.press(g),i>0?c.press(i,g):d.press(i,g)):h===f&&(a.keyboard.release(g),i>0?c.release(i):d.release(i))}),this.player.setAnimation({delay:20,callback:function(b){var c=b.now,d=b.end;a.playControls.displayProgress(c,d)}}),this.loadMidiFile=function(a,b){var c=this;this.player.loadFile(a,function(){c.playControls.setCurrentTime(b)})},this.upload=function(a){var b=this,c=new FileReader;c.onload=function(a){var c=a.target.result;b.loadMidiFile(c)},c.readAsDataURL(a)},this.initScene=function(){var a=this;this.scene=new g("#canvas"),this.scene.add(this.keyboard.model),this.scene.add(this.rightHand.model),this.scene.add(this.leftHand.model),this.scene.animate(function(){a.keyboard.update(),a.rightHand.update(),a.leftHand.update(),TWEEN.update()})},this.initMIDI=function(a){MIDI.loadPlugin(function(){MIDI.channels[9].mute=!0,"function"==typeof a&&a()})},this.initPlayControls=function(b,c){a.playControls=new i(b,c)},this.fingeringAlgorithm=function(){h(a.player.data)}}},{"./Algorithms/CostAlgorithm":1,"./Algorithms/FingeringAlgorithm.js":4,"./PlayControls.js":9,"./Visuals/Hands/Left/LeftHand.js":14,"./Visuals/Hands/Right/RightHand.js":20,"./Visuals/Piano/Keyboard.js":26,"./Visuals/Piano/KeyboardDesign.js":27,"./Visuals/Scene.js":29}],8:[function(a){var b=a("./App.js").App;$(document).on("ready",function(){var a=window.app=new b;a.initMIDI(function(){a.initScene(),$.ajax({url:"/getAllPaths",dataType:"json",success:function(b){a.preComputed=b,a.initPlayControls($(".main-container"),a),$($(".player-songList > li")[0]).trigger("click")}})})})},{"./App.js":7}],9:[function(a,b){b.exports.PlayControls=function(a,b){$(a),$(".player-songListContainer"),$(".player-controls");var c=$(".player-progress-container"),d=$(".player-progress-bar");$(".player-progress-text");var e=$(".player-songList");$(".song");var f=$(".tempo-changer"),g=$(".player-playBtn"),h=$(".player-pauseBtn"),i=$(".current-song"),j=this;this.play=function(){g.hide(),h.show(),j.playing=!0,b.player.resume()},this.playHandler=function(){j.playing===!1?j.resume():j.play()},this.pauseHandler=function(){j.pause()},this.songListHandler=function(a){var c=$(a.target),d=c.text();i.text(d),j.playing=!1,b.currentSong=d,$.ajax({url:"/songs/"+d,dataType:"text",success:function(a){b.loadMidiFile(a,0)}})},this.resume=function(){g.hide(),h.show(),b.player.currentTime+=1e-6,j.playing=!0,b.player.resume()},this.stop=function(){b.player.stop(),j.playing=!1},this.progressHandler=function(a){var b=(a.clientX-c.offset().left)/c.width();j.setCurrentTime(b)},this.tempoHandler=function(a){var e=$(a.target),f=e.find("input").attr("data-timeWarp");b.player.timeWarp=f;var g=b.currentSong;$.ajax({url:"/songs/"+g,dataType:"text",success:function(a){var e=d.width()/c.width();b.loadMidiFile(a,e)}})},this.pause=function(){j.playing=!1,g.show(),h.hide(),b.player.pause(),j.resume()},this.getEndTime=function(){return b.player.endTime},this.displayProgress=function(a,b){var e=a/b,f=Math.floor(e*c.width());d.width(f)},this.setCurrentTime=function(a){var c=b.player.endTime*a;b.player.currentTime=c,setTimeout(j.resume,10),b.player.pause()},g.on("click",j.playHandler),h.on("click",j.pauseHandler),e.on("click",j.songListHandler),c.on("click",j.progressHandler),f.on("click",j.tempoHandler)}},{}],10:[function(a,b){b.exports.Dummy=function(){var a=new THREE.CubeGeometry(1,1,1),b=new THREE.MeshLambertMaterial({color:0}),c=new THREE.Vector3(0,0,0);this.model=new THREE.Mesh(a,b),this.model.position.copy(c),this.model.visible=!1}},{}],11:[function(a,b){var c=a("./FingerMoveParams.js").params;b.exports.Finger=function(a){var b=.6;this.originalY=.2,this.pressedY=this.originalY-b,this.releaseSpeed=.05,this.moveSpeed=.1;var d=a;this.distances=c(d),this.press=function(a){this.moveToNote(a),this.model.position.y=this.pressedY,this.isPressed=!0},this.release=function(){this.isPressed=!1},this.moveToNote=function(a){this.currentPos.x=this.model.position.x,this.currentPos.y=this.model.position.y,this.currentPos.z=this.model.position.z;var b=this.model.parent.children[this.number+1].currentNote,c=this.model.parent.children[this.number-1].currentNote;a>this.model.currentNote?this.model.currentNote=b===a?a-1:a:a=f;f++)f===c?b.fingers[f].press(d):b.fingers[f].moveAsNeeded(c,e,d)},this.release=function(a){a=Math.abs(a),b.fingers[a].release()},this.update=function(){for(var a=b.fingers,c=1;c=f.get(c,c-8)&&a<=f.get(c,c-4)||this.moveToNote(d+5)},this.ringRules=function(a,b,c,d){a>=f.get(c,c-6)&&a<=f.get(c,c-4)||this.moveToNote(d+3)},this.middleRules=function(a,b,c,d){a>=f.get(c,c-5)&&a<=f.get(c,c-1)||this.moveToNote(d+4)},this.thumbRules=function(a,b,c,d){if(!(a>0&&a<=f.get(c,c+4)))if(a>f.get(c,c-3)&&0>a){var e=this;setTimeout(e.moveToNote(d-2),100)}else this.moveToNote(d-2)}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],16:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftMiddle=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.middleFingerWidth,a.middleFingerHeight,a.middleFingerLength),d=new THREE.MeshLambertMaterial({color:a.middleFingerColor}),e=new THREE.Vector3(0,.2,.4);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=3;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 5:this.pinkyRules(e,d,f,c);break;case 4:this.ringRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c);break;case 1:this.thumbRules(e,d,f,c)}},this.pinkyRules=function(a,b,c,d){a>f.get(c,c-5)&&af.get(c,c-4)&&a0&&a0&&af.get(c,c-4)&&0>a){var e=this;setTimeout(e.moveToNote(d-3),100)}else this.moveToNote(d-3)}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],17:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftPinky=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.pinkyWidth,a.pinkyHeight,a.pinkyLength),d=new THREE.MeshLambertMaterial({color:a.pinkyColor}),e=new THREE.Vector3(0,.2,.54);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=5;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 4:this.ringRules(e,d,f,c);break;case 3:this.middleRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c);break;case 1:this.thumbRules(e,d,f,c)}},this.ringRules=function(a,b,c,d){a>0&&a<=f.get(c,c+3)||this.moveToNote(d-2)},this.middleRules=function(a,b,c,d){a>0&&a<=f.get(c,c+5)||this.moveToNote(d-3)},this.indexRules=function(a,b,c,d){a>0&&a<=f.get(c,c+7)||this.moveToNote(d-5)},this.thumbRules=function(a,b,c,d){if(!(a>0&&a<=f.get(c,c+12)))if(a>0&&a<=f.get(c,c+1)){var e=this;setTimeout(e.moveToNote(d-7),100)}else this.moveToNote(d-7)},this.setUpNewTween=function(){var a=this,b=function(){a.model.position.x=a.currentPos.x,a.model.position.y=a.currentPos.y+.1,a.model.position.z=a.currentPos.z+.1},c=TWEEN.Easing.Quadratic.Out,d=new TWEEN.Tween(this.currentPos).to(this.newPos,150).easing(c).onUpdate(b);d.start()}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],18:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftRing=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.ringFingerWidth,a.ringFingerHeight,a.ringFingerLength),d=new THREE.MeshLambertMaterial({color:a.ringFingerColor}),e=new THREE.Vector3(0,.2,.45);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=4;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 5:this.pinkyRules(e,d,f,c);break;case 3:this.middleRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c);break;case 1:this.thumbRules(e,d,f,c)}},this.pinkyRules=function(a,b,c,d){a>f.get(c,c-3)&&a0&&a0&&a0&&af.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-5),100)}else this.moveToNote(d-5)}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],19:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftThumb=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.thumbWidth,a.thumbHeight,a.thumbLength),d=new THREE.MeshLambertMaterial({color:a.thumbColor}),e=new THREE.Vector3(0,.3,.6);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=1;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 5:this.pinkyRules(e,d,f,c);break;case 4:this.ringRules(e,d,f,c);break;case 3:this.middleRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c)}},this.pinkyRules=function(a,b,c,d){if(!(a>=f.get(c,c-12)&&a<=f.get(c,c-5)))if(a>0&&a=f.get(c,c-9)&&a<=f.get(c,c-4)))if(a>0&&a=f.get(c,c-7)&&a<=f.get(c,c-2)))if(a>0&&a=f.get(c,c-4)&&0>a))if(a>0&&a=f;f++)f===c?b.fingers[f].press(d):b.fingers[f].moveAsNeeded(c,e,d)},this.release=function(a){b.fingers[a].release()},this.update=function(){for(var a=b.fingers,c=1;cf.get(c,c+4)&&af.get(c,c+3)&&af.get(c,c+2)&&af.get(c,c-3)&&0>a))if(a>0&&a=f.get(c,c+3)&&a<=f.get(c,c+5)||this.moveToNote(d-3)},this.ringRules=function(a,b,c,d){a>=f.get(c,c+1)&&a<=f.get(c,c+4)||this.moveToNote(d-2)},this.indexRules=function(a,b,c,d){a>=f.get(c,c-3)&&a<=f.get(c,c-1)||this.moveToNote(d+2)},this.thumbRules=function(a,b,c,d){if(!(a>=f.get(c,c-6)&&0>a))if(a>0&&af.get(c,c-3)&&0>a||this.moveToNote(d+2)},this.middleRules=function(a,b,c,d){a>f.get(c,c-5)&&0>a||this.moveToNote(d+3)},this.indexRules=function(a,b,c,d){a>f.get(c,c-7)&&0>a||this.moveToNote(d+5)},this.thumbRules=function(a,b,c,d){if(!(a>f.get(c,c-12)&&0>a))if(a>0&&af.get(c,c+2)&&af.get(c,c-3)&&0>a||this.moveToNote(d+2)},this.indexRules=function(a,b,c,d){a>f.get(c,c-5)&&0>a||this.moveToNote(d+3)},this.thumbRules=function(a,b,c,d){if(!(a>f.get(c,c-8)&&0>a))if(a>0&&a=f.get(c,c+5)&&a=f.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-7),100)}else this.moveToNote(d-7)},this.ringRules=function(a,b,c,d){if(!(a>=f.get(c,c+4)&&a<=f.get(c,c+9)))if(a>f.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-5),100)}else this.moveToNote(d-5)},this.middleRules=function(a,b,c,d){if(!(a>=f.get(c,c+2)&&a<=f.get(c,c+7)))if(a>f.get(c,c-3)&&0>a){var e=this;setTimeout(e.moveToNote(d-4),100)}else this.moveToNote(d-4)},this.indexRules=function(a,b,c,d){if(!(a>0&&a<=f.get(c,c+4)))if(a>f.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-2),100)}else this.moveToNote(d-2)},this.setUpNewTween=function(){var a=this,b=function(){a.model.position.x=a.currentPos.x,a.model.position.y=a.currentPos.y+.1,a.model.position.z=a.currentPos.z+.2},c=TWEEN.Easing.Quadratic.Out,d=new TWEEN.Tween(this.currentPos).to(this.newPos,150).easing(c).onUpdate(b);d.start()}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],26:[function(a,b){var c=a("./PianoKey.js").PianoKey;b.exports.Keyboard=function(a){this.model=new THREE.Object3D,this.keys=[];for(var b=this,d=0;d20&&109>d&&this.model.add(e.model)}this.model.position.y-=a.whiteKeyHeight/2,this.model.traverse(function(a){a.position.x-=4.45}),this.press=function(a){b.keys[a].press()},this.release=function(a){b.keys[a].release()},this.update=function(){for(var a=this,b=a.keys,c=0;cb;b++){var c={};a.keyInfo.push(c)}},d=function(){for(var b=a.KeyType,c=a.keyInfo,d=0;10>d;d++){var e=12*d;c[e+0].keyType=b.WhiteC,c[e+1].keyType=b.Black,c[e+2].keyType=b.WhiteD,c[e+3].keyType=b.Black,c[e+4].keyType=b.WhiteE,c[e+5].keyType=b.WhiteF,c[e+6].keyType=b.Black,c[e+7].keyType=b.WhiteG,c[e+8].keyType=b.Black,c[e+9].keyType=b.WhiteA,c[e+10].keyType=b.Black,c[e+11].keyType=b.WhiteD}},e=function(){var b=a.keyInfo,c=a.KeyType,d=c.WhiteB,e=0,f=0,g=c.Black;for(b[e].keyCenterPosX=f,d=b[e].keyType,e=1;e0&&f-e===0)g[h]=d.ascMoveFormula(i,j,a,b);else if(b-a>=0&&0>f-e&&1!==f)g[h]=d.ascMoveFormula(i,j,a,b,e,f);else if(0>b-a&&f-e>0&&1!==e)g[h]=d.ascMoveFormula(i,j,a,b,e,f);else if(b-a>=0&&0>f-e&&1===f)g[h]=d.ascThumbCost(i,j,a,b,e,f);else if(0>b-a&&1===e&&1!==f)g[h]=d.descThumbCost(i,j,a,b,e,f);else{var k=d.fingerStretch(e,f),l=Math.abs(i-j)/k;g[h]=l>c.moveCutoff?d.descMoveFormula(i,j,a,b,e,f):d.ascDescNoCrossCost(i,j,l,a,b,e,f)}};b.exports.createCostDatabase=function(){for(var a={},b=1;5>=b;b++)for(var c=21;109>c;c++)for(var d=1;5>=d;d++)for(var f=21;109>f;f++)e(c,f,b,d,a);return a}}},{"./CostAlgorithmHelpers.js":2,"./CostAlgorithmParameters.js":3}],2:[function(a,b){var c=a("./CostAlgorithmParameters.js"),d=b.exports,e=function(a){return.0002185873295*Math.pow(a,7)-.008611946279*Math.pow(a,6)+.1323250066*Math.pow(a,5)-1.002729677*Math.pow(a,4)+3.884106308*Math.pow(a,3)-6.723075747*Math.pow(a,2)+1.581196785*a+7.711241722},f=function(a,b,d,e,f){if("White"===c.color[a%12]&&"Black"===c.color[b%12]){if(5===e||1===e)return 4;if(0===f)return 4}if("Black"===c.color[a%12]&&"White"===c.color[b%12]){if(5===d||1===d)return 4;if(0===f)return-1}return 0},g=d.ascMoveFormula=function(a,b,d,e,g,h){var i,j=Math.ceil(a+b);return j>24?c.moveHash[24]+(j-24)/5:(i=c.moveHash[j],i+=f(d,e,g,h,b))};d.descMoveFormula=function(a,b,d,e,g,h){var i,j=Math.ceil(a-b);return j>24?c.moveHash[24]+(j-24)/5:(i=c.moveHash[j],i+=f(d,e,g,h,b))},d.fingerDistance=function(a,b){var d=a.toString()+","+b.toString();return c.fingDistance[d]},d.ascThumbCost=function(a,b,d,f,h,j){var k=i(h,j),l=(a+b)/k;if(l>10)return g(a,b);var m=e(l);return"White"===c.color[d%12]&&"Black"===c.color[f%12]&&(m+=8),m},d.descThumbCost=function(a,b,d,f,i,j){var k=h(i,j),l=(a+b)/k;if(l>10)return g(a,b);var m=e(l);return"Black"===c.color[d%12]&&"White"===c.color[f%12]&&(m+=8),m};var h=d.descThumbStretch=function(a,b){var d=a.toString()+","+b.toString();return c.descThumbStretchVals[d]},i=d.ascThumbStretch=function(a,b){var d=a.toString()+","+b.toString();return c.ascThumbStretchVals[d]};d.fingerStretch=function(a,b){var d=a.toString()+","+b.toString();return c.fingStretch[d]},d.ascDescNoCrossCost=function(a,b,d,e,g,h,i){var j,k=function(a){return-6.589793725e-7*Math.pow(a,10)-2336381414e-15*Math.pow(a,9)+9925769823e-14*Math.pow(a,8)+.0001763353131*Math.pow(a,7)-.004660305277*Math.pow(a,6)-.004290746384*Math.pow(a,5)+.06855725903*Math.pow(a,4)+.03719817227*Math.pow(a,3)+.4554696705*Math.pow(a,2)-.08305450359*a+.3020594956};return d>6.8&&d<=c.moveCutoff?k(6.8)+3*(d-6.8):(j=k(d),j+=f(e,g,h,i))}},{"./CostAlgorithmParameters.js":3}],3:[function(a,b){var c=b.exports;c.moveCutoff=7.5,c.color={0:"White",1:"Black",2:"White",3:"Black",4:"White",5:"White",6:"Black",7:"White",8:"Black",9:"White",10:"Black",11:"White"},c.fingDistance={"1,1":0,"1,2":2,"1,3":3.5,"1,4":5,"1,5":7,"2,1":2,"2,2":0,"2,3":2,"2,4":3.5,"2,5":5,"3,1":3.5,"3,2":2,"3,3":0,"3,4":2,"3,5":3.5,"4,1":5,"4,2":3.5,"4,3":2,"4,4":0,"4,5":2,"5,1":7,"5,2":5,"5,3":3.5,"5,4":2,"5,5":0};var d=c.makeMoveHash=function(a){var b={1:0,2:.5,3:1.8,4:3,5:5,6:7,7:8,8:8.9,9:9.7,10:10.5,11:11,12:11.4,13:11.8,14:12.2,15:12.5,16:12.8,17:13.1,18:13.4,19:13.7,20:14,21:14.3,22:14.6,23:14.9,24:15.2};for(var c in b)b[c]+=a;return b};c.moveHash=d(4),c.descThumbStretchVals={"1,2":1,"1,3":1,"1,4":.9,"1,5":.95},c.ascThumbStretchVals={"2,1":.95,"3,1":1,"4,1":.95,"5,1":.95},c.fingStretch={"1,1":.8,"1,2":1.15,"1,3":1.4,"1,4":1.45,"1,5":1.6,"2,1":1.15,"2,2":.6,"2,3":.9,"2,4":1.15,"2,5":1.3,"3,1":1.4,"3,2":.9,"3,3":.6,"3,4":.9,"3,5":1.15,"4,1":1.45,"4,2":1.15,"4,3":.9,"4,4":.7,"4,5":.7,"5,1":1.6,"5,2":1.3,"5,3":1.15,"5,4":.8,"5,5":.6}},{}],4:[function(a,b){var c=a("./FingeringAlgorithmHelpers.js");b.exports.FingeringAlgorithm=function(a){for(var b=c.addStartTimes(a),d=0;d0)for(var r=2,s=l;0===q.notes.length;){var t=s.bestPrev,u=f[g-r][t];q=c.getSplitData(u).right,r++,s=u}var v=n.left,w=o.left;if(v.notes.length>0)for(var r=2,s=l;0===w.notes.length;){var t=s.bestPrev,u=f[g-r][t];w=c.getSplitData(u).left,r++,s=u}var x=c.calcCost(p,q,v,"RH"),y=c.calcCost(v,w,p,"LH");m+=x+y,i>m&&(i=m,k.nodeScore=m,k.bestPrev=j)}for(var z=c.findMin(f[f.length-1]),A={},B=f.length-1;B>0;B--){for(var C=f[B][z],D=C.fingers,E=C.notes,F=0;F=h;h++)g[h]=f(h);var i=[{notes:["e","e"],fingers:[1,-1]}],j=function(a,b){this.notes=a,this.fingers=b,this.nodeScore=0,this.bestPrev=void 0},k=function(a){for(var b=a.sort(function(a,b){return a[0]-b[0]}),c=[],d=g[b.length],e=0;e0?h:0},n=function(a,b,c,e){if("e"===a||"e"===b)return 0;c=Math.abs(c),e=Math.abs(e);var f=a+","+b+","+c+","+e,g=d[f],h=b-60;return g+=h>0?h:0};e.findMin=function(a){for(var b,c=1/0,d=0;d0?(b.right.fingers.push(a.fingers[c]),b.right.notes.push(a.notes[c])):(b.left.fingers.push(a.fingers[c]),b.left.notes.push(a.notes[c]));return b},e.calcCost=function(a,b,c,d){for(var e="RH"===d?m:n,f=0,g=0;g0&&f-e===0)g[h]=d.ascMoveFormula(i,j,a,b);else if(0>=b-a&&0>f-e&&1!==f)g[h]=d.ascMoveFormula(i,j);else if(b-a>0&&f-e>0&&1!==e)g[h]=d.ascMoveFormula(i,j);else if(0>=b-a&&0>f-e&&1===f)g[h]=d.ascThumbCost(i,j,a,b,e,f);else if(b-a>=0&&1===e&&1!==f)g[h]=d.descThumbCost(i,j,a,b,e,f);else{var k=d.fingerStretch(e,f),l=Math.abs(i-j)/k;g[h]=l>c.moveCutoff?d.descMoveFormula(i,j):d.ascDescNoCrossCost(i,j,l,a,b,e,f)}};b.exports.createLHCostDatabase=function(){for(var a={},b=1;5>=b;b++)for(var c=21;109>c;c++)for(var d=1;5>=d;d++)for(var f=21;109>f;f++)e(c,f,b,d,a);return a}}},{"./CostAlgorithmHelpers.js":2,"./CostAlgorithmParameters.js":3}],7:[function(a,b){var c=a("./Visuals/Piano/KeyboardDesign.js").KeyboardDesign,d=a("./Visuals/Piano/Keyboard.js").Keyboard,e=a("./Visuals/Hands/Right/RightHand.js").RightHand,f=a("./Visuals/Hands/Left/LeftHand.js").LeftHand,g=a("./Visuals/Scene.js").Scene,h=(a("./Algorithms/CostAlgorithm").createCostDatabase,a("./Algorithms/FingeringAlgorithm.js").FingeringAlgorithm),i=a("./PlayControls.js").PlayControls;b.exports.App=function(){this.keyboardDesign=new c,this.keyboard=new d(this.keyboardDesign),this.rightHand=new e(this.keyboard),this.leftHand=new f(this.keyboard),this.player=MIDI.Player;var a=this;this.player.addListener(function(b){var c=a.rightHand,d=a.leftHand,e=144,f=128,g=b.note,h=b.message,i=b.finger;h===e?(a.keyboard.press(g),i>0?c.press(i,g):d.press(i,g)):h===f&&(a.keyboard.release(g),i>0?c.release(i):d.release(i))}),this.player.setAnimation({delay:20,callback:function(b){var c=b.now,d=b.end;a.playControls.displayProgress(c,d)}}),this.loadMidiFile=function(a,b){var c=this;this.player.loadFile(a,function(){c.playControls.setCurrentTime(b)})},this.upload=function(a){var b=this,c=new FileReader;c.onload=function(a){var c=a.target.result;b.loadMidiFile(c)},c.readAsDataURL(a)},this.initScene=function(){var a=this;this.scene=new g("#canvas"),this.scene.add(this.keyboard.model),this.scene.add(this.rightHand.model),this.scene.add(this.leftHand.model),this.scene.animate(function(){a.keyboard.update(),a.rightHand.update(),a.leftHand.update(),TWEEN.update()})},this.initMIDI=function(a){MIDI.loadPlugin(function(){MIDI.channels[9].mute=!0,"function"==typeof a&&a()})},this.initPlayControls=function(b,c){a.playControls=new i(b,c)},this.fingeringAlgorithm=function(){h(a.player.data)}}},{"./Algorithms/CostAlgorithm":1,"./Algorithms/FingeringAlgorithm.js":4,"./PlayControls.js":9,"./Visuals/Hands/Left/LeftHand.js":14,"./Visuals/Hands/Right/RightHand.js":20,"./Visuals/Piano/Keyboard.js":26,"./Visuals/Piano/KeyboardDesign.js":27,"./Visuals/Scene.js":29}],8:[function(a){var b=a("./App.js").App;$(document).on("ready",function(){var a=window.app=new b;a.initMIDI(function(){a.initScene(),$.ajax({url:"/getAllPaths",dataType:"json",success:function(b){a.preComputed=b,a.initPlayControls($(".main-container"),a),$($(".player-songList > li")[0]).trigger("click")}})})})},{"./App.js":7}],9:[function(a,b){b.exports.PlayControls=function(a,b){var c=($(a),$(".player-songListContainer"),$(".player-controls"),$(".player-progress-container")),d=$(".player-progress-bar"),e=($(".player-progress-text"),$(".player-songList")),f=($(".song"),$(".tempo-changer")),g=$(".player-playBtn"),h=$(".player-pauseBtn"),i=$(".current-song"),j=this;this.play=function(){g.hide(),h.show(),j.playing=!0,b.player.resume()},this.playHandler=function(){j.playing===!1?j.resume():j.play()},this.pauseHandler=function(){j.pause()},this.songListHandler=function(a){var c=$(a.target),d=c.text();i.text(d),j.playing=!1,b.currentSong=d,$.ajax({url:"/songs/"+d,dataType:"text",success:function(a){b.loadMidiFile(a,0)}})},this.resume=function(){g.hide(),h.show(),b.player.currentTime+=1e-6,j.playing=!0,b.player.resume()},this.stop=function(){b.player.stop(),j.playing=!1},this.progressHandler=function(a){var b=(a.clientX-c.offset().left)/c.width();j.setCurrentTime(b)},this.tempoHandler=function(a){var e=$(a.target),f=e.find("input").attr("data-timeWarp");b.player.timeWarp=f;var g=b.currentSong;$.ajax({url:"/songs/"+g,dataType:"text",success:function(a){var e=d.width()/c.width();b.loadMidiFile(a,e)}})},this.pause=function(){j.playing=!1,g.show(),h.hide(),b.player.pause(),j.resume()},this.getEndTime=function(){return b.player.endTime},this.displayProgress=function(a,b){var e=a/b,f=Math.floor(e*c.width());d.width(f)},this.setCurrentTime=function(a){var c=b.player.endTime*a;b.player.currentTime=c,setTimeout(j.resume,10),b.player.pause()},g.on("click",j.playHandler),h.on("click",j.pauseHandler),e.on("click",j.songListHandler),c.on("click",j.progressHandler),f.on("click",j.tempoHandler)}},{}],10:[function(a,b){b.exports.Dummy=function(){var a=new THREE.CubeGeometry(1,1,1),b=new THREE.MeshLambertMaterial({color:0}),c=new THREE.Vector3(0,0,0);this.model=new THREE.Mesh(a,b),this.model.position.copy(c),this.model.visible=!1}},{}],11:[function(a,b){var c=a("./FingerMoveParams.js").params;b.exports.Finger=function(a){var b=.6;this.originalY=.2,this.pressedY=this.originalY-b,this.releaseSpeed=.05,this.moveSpeed=.1;var d=a;this.distances=c(d),this.press=function(a){this.moveToNote(a),this.model.position.y=this.pressedY,this.isPressed=!0},this.release=function(){this.isPressed=!1},this.moveToNote=function(a){this.currentPos.x=this.model.position.x,this.currentPos.y=this.model.position.y,this.currentPos.z=this.model.position.z;var b=this.model.parent.children[this.number+1].currentNote,c=this.model.parent.children[this.number-1].currentNote;a>this.model.currentNote?this.model.currentNote=b===a?a-1:a:a=f;f++)f===c?b.fingers[f].press(d):b.fingers[f].moveAsNeeded(c,e,d)},this.release=function(a){a=Math.abs(a),b.fingers[a].release()},this.update=function(){for(var a=b.fingers,c=1;c=f.get(c,c-8)&&a<=f.get(c,c-4)||this.moveToNote(d+5)},this.ringRules=function(a,b,c,d){a>=f.get(c,c-6)&&a<=f.get(c,c-4)||this.moveToNote(d+3)},this.middleRules=function(a,b,c,d){a>=f.get(c,c-5)&&a<=f.get(c,c-1)||this.moveToNote(d+4)},this.thumbRules=function(a,b,c,d){if(!(a>0&&a<=f.get(c,c+4)))if(a>f.get(c,c-3)&&0>a){var e=this;setTimeout(e.moveToNote(d-2),100)}else this.moveToNote(d-2)}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],16:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftMiddle=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.middleFingerWidth,a.middleFingerHeight,a.middleFingerLength),d=new THREE.MeshLambertMaterial({color:a.middleFingerColor}),e=new THREE.Vector3(0,.2,.4);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=3;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 5:this.pinkyRules(e,d,f,c);break;case 4:this.ringRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c);break;case 1:this.thumbRules(e,d,f,c)}},this.pinkyRules=function(a,b,c,d){a>f.get(c,c-5)&&af.get(c,c-4)&&a0&&a0&&af.get(c,c-4)&&0>a){var e=this;setTimeout(e.moveToNote(d-3),100)}else this.moveToNote(d-3)}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],17:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftPinky=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.pinkyWidth,a.pinkyHeight,a.pinkyLength),d=new THREE.MeshLambertMaterial({color:a.pinkyColor}),e=new THREE.Vector3(0,.2,.54);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=5;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 4:this.ringRules(e,d,f,c);break;case 3:this.middleRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c);break;case 1:this.thumbRules(e,d,f,c)}},this.ringRules=function(a,b,c,d){a>0&&a<=f.get(c,c+3)||this.moveToNote(d-2)},this.middleRules=function(a,b,c,d){a>0&&a<=f.get(c,c+5)||this.moveToNote(d-3)},this.indexRules=function(a,b,c,d){a>0&&a<=f.get(c,c+7)||this.moveToNote(d-5)},this.thumbRules=function(a,b,c,d){if(!(a>0&&a<=f.get(c,c+12)))if(a>0&&a<=f.get(c,c+1)){var e=this;setTimeout(e.moveToNote(d-7),100)}else this.moveToNote(d-7)},this.setUpNewTween=function(){var a=this,b=function(){a.model.position.x=a.currentPos.x,a.model.position.y=a.currentPos.y+.1,a.model.position.z=a.currentPos.z+.1},c=TWEEN.Easing.Quadratic.Out,d=new TWEEN.Tween(this.currentPos).to(this.newPos,150).easing(c).onUpdate(b);d.start()}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],18:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftRing=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.ringFingerWidth,a.ringFingerHeight,a.ringFingerLength),d=new THREE.MeshLambertMaterial({color:a.ringFingerColor}),e=new THREE.Vector3(0,.2,.45);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=4;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 5:this.pinkyRules(e,d,f,c);break;case 3:this.middleRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c);break;case 1:this.thumbRules(e,d,f,c)}},this.pinkyRules=function(a,b,c,d){a>f.get(c,c-3)&&a0&&a0&&a0&&af.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-5),100)}else this.moveToNote(d-5)}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],19:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftThumb=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.thumbWidth,a.thumbHeight,a.thumbLength),d=new THREE.MeshLambertMaterial({color:a.thumbColor}),e=new THREE.Vector3(0,.3,.6);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=1;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 5:this.pinkyRules(e,d,f,c);break;case 4:this.ringRules(e,d,f,c);break;case 3:this.middleRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c)}},this.pinkyRules=function(a,b,c,d){if(!(a>=f.get(c,c-12)&&a<=f.get(c,c-5)))if(a>0&&a=f.get(c,c-9)&&a<=f.get(c,c-4)))if(a>0&&a=f.get(c,c-7)&&a<=f.get(c,c-2)))if(a>0&&a=f.get(c,c-4)&&0>a))if(a>0&&a=f;f++)f===c?b.fingers[f].press(d):b.fingers[f].moveAsNeeded(c,e,d)},this.release=function(a){b.fingers[a].release()},this.update=function(){for(var a=b.fingers,c=1;cf.get(c,c+4)&&af.get(c,c+3)&&af.get(c,c+2)&&af.get(c,c-3)&&0>a))if(a>0&&a=f.get(c,c+3)&&a<=f.get(c,c+5)||this.moveToNote(d-3)},this.ringRules=function(a,b,c,d){a>=f.get(c,c+1)&&a<=f.get(c,c+4)||this.moveToNote(d-2)},this.indexRules=function(a,b,c,d){a>=f.get(c,c-3)&&a<=f.get(c,c-1)||this.moveToNote(d+2)},this.thumbRules=function(a,b,c,d){if(!(a>=f.get(c,c-6)&&0>a))if(a>0&&af.get(c,c-3)&&0>a||this.moveToNote(d+2)},this.middleRules=function(a,b,c,d){a>f.get(c,c-5)&&0>a||this.moveToNote(d+3)},this.indexRules=function(a,b,c,d){a>f.get(c,c-7)&&0>a||this.moveToNote(d+5)},this.thumbRules=function(a,b,c,d){if(!(a>f.get(c,c-12)&&0>a))if(a>0&&af.get(c,c+2)&&af.get(c,c-3)&&0>a||this.moveToNote(d+2)},this.indexRules=function(a,b,c,d){a>f.get(c,c-5)&&0>a||this.moveToNote(d+3)},this.thumbRules=function(a,b,c,d){if(!(a>f.get(c,c-8)&&0>a))if(a>0&&a=f.get(c,c+5)&&a=f.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-7),100)}else this.moveToNote(d-7)},this.ringRules=function(a,b,c,d){if(!(a>=f.get(c,c+4)&&a<=f.get(c,c+9)))if(a>f.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-5),100)}else this.moveToNote(d-5)},this.middleRules=function(a,b,c,d){if(!(a>=f.get(c,c+2)&&a<=f.get(c,c+7)))if(a>f.get(c,c-3)&&0>a){var e=this;setTimeout(e.moveToNote(d-4),100)}else this.moveToNote(d-4)},this.indexRules=function(a,b,c,d){if(!(a>0&&a<=f.get(c,c+4)))if(a>f.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-2),100)}else this.moveToNote(d-2)},this.setUpNewTween=function(){var a=this,b=function(){a.model.position.x=a.currentPos.x,a.model.position.y=a.currentPos.y+.1,a.model.position.z=a.currentPos.z+.2},c=TWEEN.Easing.Quadratic.Out,d=new TWEEN.Tween(this.currentPos).to(this.newPos,150).easing(c).onUpdate(b);d.start()}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],26:[function(a,b){var c=a("./PianoKey.js").PianoKey;b.exports.Keyboard=function(a){this.model=new THREE.Object3D,this.keys=[];for(var b=this,d=0;d20&&109>d&&this.model.add(e.model)}this.model.position.y-=a.whiteKeyHeight/2,this.model.traverse(function(a){a.position.x-=4.45}),this.press=function(a){b.keys[a].press()},this.release=function(a){b.keys[a].release()},this.update=function(){for(var a=this,b=a.keys,c=0;cb;b++){var c={};a.keyInfo.push(c)}},d=function(){for(var b=a.KeyType,c=a.keyInfo,d=0;10>d;d++){var e=12*d;c[e+0].keyType=b.WhiteC,c[e+1].keyType=b.Black,c[e+2].keyType=b.WhiteD,c[e+3].keyType=b.Black,c[e+4].keyType=b.WhiteE,c[e+5].keyType=b.WhiteF,c[e+6].keyType=b.Black,c[e+7].keyType=b.WhiteG,c[e+8].keyType=b.Black,c[e+9].keyType=b.WhiteA,c[e+10].keyType=b.Black,c[e+11].keyType=b.WhiteD}},e=function(){var b=a.keyInfo,c=a.KeyType,d=c.WhiteB,e=0,f=0,g=c.Black;for(b[e].keyCenterPosX=f,d=b[e].keyType,e=1;e0&&0===f-e)g[h]=d.ascMoveFormula(i,j,a,b);else if(b-a>=0&&0>f-e&&1!==f)g[h]=d.ascMoveFormula(i,j,a,b,e,f);else if(0>b-a&&f-e>0&&1!==e)g[h]=d.ascMoveFormula(i,j,a,b,e,f);else if(b-a>=0&&0>f-e&&1===f)g[h]=d.ascThumbCost(i,j,a,b,e,f);else if(0>b-a&&1===e&&1!==f)g[h]=d.descThumbCost(i,j,a,b,e,f);else{var k=d.fingerStretch(e,f),l=Math.abs(i-j)/k;g[h]=l>c.moveCutoff?d.descMoveFormula(i,j,a,b,e,f):d.ascDescNoCrossCost(i,j,l,a,b,e,f)}};b.exports.createCostDatabase=function(){for(var a={},b=1;5>=b;b++)for(var c=21;109>c;c++)for(var d=1;5>=d;d++)for(var f=21;109>f;f++)e(c,f,b,d,a);return a}},{"./CostAlgorithmHelpers.js":2,"./CostAlgorithmParameters.js":3}],2:[function(a,b){var c=a("./CostAlgorithmParameters.js"),d=b.exports,e=function(a){return.0002185873295*Math.pow(a,7)-.008611946279*Math.pow(a,6)+.1323250066*Math.pow(a,5)-1.002729677*Math.pow(a,4)+3.884106308*Math.pow(a,3)-6.723075747*Math.pow(a,2)+1.581196785*a+7.711241722},f=function(a,b,d,e,f){if("White"===c.color[a%12]&&"Black"===c.color[b%12]){if(5===e||1===e)return 4;if(0===f)return 4}if("Black"===c.color[a%12]&&"White"===c.color[b%12]){if(5===d||1===d)return 4;if(0===f)return-1}return 0},g=d.ascMoveFormula=function(a,b,d,e,g,h){var i,j=Math.ceil(a+b);return j>24?c.moveHash[24]+(j-24)/5:(i=c.moveHash[j],i+=f(d,e,g,h,b))};d.descMoveFormula=function(a,b,d,e,g,h){var i,j=Math.ceil(a-b);return j>24?c.moveHash[24]+(j-24)/5:(i=c.moveHash[j],i+=f(d,e,g,h,b))},d.fingerDistance=function(a,b){var d=a.toString()+","+b.toString();return c.fingDistance[d]},d.ascThumbCost=function(a,b,d,f,h,j){var k=i(h,j),l=(a+b)/k;if(l>10)return g(a,b);var m=e(l);return"White"===c.color[d%12]&&"Black"===c.color[f%12]&&(m+=8),m},d.descThumbCost=function(a,b,d,f,i,j){var k=h(i,j),l=(a+b)/k;if(l>10)return g(a,b);var m=e(l);return"Black"===c.color[d%12]&&"White"===c.color[f%12]&&(m+=8),m};var h=d.descThumbStretch=function(a,b){var d=a.toString()+","+b.toString();return c.descThumbStretchVals[d]},i=d.ascThumbStretch=function(a,b){var d=a.toString()+","+b.toString();return c.ascThumbStretchVals[d]};d.fingerStretch=function(a,b){var d=a.toString()+","+b.toString();return c.fingStretch[d]},d.ascDescNoCrossCost=function(a,b,d,e,g,h,i){var j,k=function(a){return-6.589793725e-7*Math.pow(a,10)-2336381414e-15*Math.pow(a,9)+9925769823e-14*Math.pow(a,8)+.0001763353131*Math.pow(a,7)-.004660305277*Math.pow(a,6)-.004290746384*Math.pow(a,5)+.06855725903*Math.pow(a,4)+.03719817227*Math.pow(a,3)+.4554696705*Math.pow(a,2)-.08305450359*a+.3020594956};return d>6.8&&d<=c.moveCutoff?k(6.8)+3*(d-6.8):(j=k(d),j+=f(e,g,h,i))}},{"./CostAlgorithmParameters.js":3}],3:[function(a,b){var c=b.exports;c.moveCutoff=7.5,c.color={0:"White",1:"Black",2:"White",3:"Black",4:"White",5:"White",6:"Black",7:"White",8:"Black",9:"White",10:"Black",11:"White"},c.fingDistance={"1,1":0,"1,2":2,"1,3":3.5,"1,4":5,"1,5":7,"2,1":2,"2,2":0,"2,3":2,"2,4":3.5,"2,5":5,"3,1":3.5,"3,2":2,"3,3":0,"3,4":2,"3,5":3.5,"4,1":5,"4,2":3.5,"4,3":2,"4,4":0,"4,5":2,"5,1":7,"5,2":5,"5,3":3.5,"5,4":2,"5,5":0};var d=c.makeMoveHash=function(a){var b={1:0,2:.5,3:1.8,4:3,5:5,6:7,7:8,8:8.9,9:9.7,10:10.5,11:11,12:11.4,13:11.8,14:12.2,15:12.5,16:12.8,17:13.1,18:13.4,19:13.7,20:14,21:14.3,22:14.6,23:14.9,24:15.2};for(var c in b)b[c]+=a;return b};c.moveHash=d(4),c.descThumbStretchVals={"1,2":1,"1,3":1,"1,4":.9,"1,5":.95},c.ascThumbStretchVals={"2,1":.95,"3,1":1,"4,1":.95,"5,1":.95},c.fingStretch={"1,1":.8,"1,2":1.15,"1,3":1.4,"1,4":1.45,"1,5":1.6,"2,1":1.15,"2,2":.6,"2,3":.9,"2,4":1.15,"2,5":1.3,"3,1":1.4,"3,2":.9,"3,3":.6,"3,4":.9,"3,5":1.15,"4,1":1.45,"4,2":1.15,"4,3":.9,"4,4":.7,"4,5":.7,"5,1":1.6,"5,2":1.3,"5,3":1.15,"5,4":.8,"5,5":.6}},{}],4:[function(a,b){var c=a("./FingeringAlgorithmHelpers.js");b.exports.FingeringAlgorithm=function(a){for(var b=c.addStartTimes(a),d=0;d0)for(var r=2,s=l;0===q.notes.length;){var t=s.bestPrev,u=f[g-r][t];q=c.getSplitData(u).right,r++,s=u}var v=n.left,w=o.left;if(v.notes.length>0)for(var r=2,s=l;0===w.notes.length;){var t=s.bestPrev,u=f[g-r][t];w=c.getSplitData(u).left,r++,s=u}var x=c.calcCost(p,q,v,"RH"),y=c.calcCost(v,w,p,"LH");m+=x+y,i>m&&(i=m,k.nodeScore=m,k.bestPrev=j)}for(var z=c.findMin(f[f.length-1]),A={},B=f.length-1;B>0;B--){for(var C=f[B][z],D=C.fingers,E=C.notes,F=0;F=h;h++)g[h]=f(h);var i=[{notes:["e","e"],fingers:[1,-1]}],j=function(a,b){this.notes=a,this.fingers=b,this.nodeScore=0,this.bestPrev=void 0},k=function(a){for(var b=a.sort(function(a,b){return a[0]-b[0]}),c=[],d=g[b.length],e=0;e0?h:0},n=function(a,b,c,e){if("e"===a||"e"===b)return 0;c=Math.abs(c),e=Math.abs(e);var f=a+","+b+","+c+","+e,g=d[f],h=b-60;return g+=h>0?h:0};e.findMin=function(a){for(var b,c=1/0,d=0;d0?(b.right.fingers.push(a.fingers[c]),b.right.notes.push(a.notes[c])):(b.left.fingers.push(a.fingers[c]),b.left.notes.push(a.notes[c]));return b},e.calcCost=function(a,b,c,d){for(var e="RH"===d?m:n,f=0,g=0;g0&&0===f-e)g[h]=d.ascMoveFormula(i,j,a,b);else if(0>=b-a&&0>f-e&&1!==f)g[h]=d.ascMoveFormula(i,j);else if(b-a>0&&f-e>0&&1!==e)g[h]=d.ascMoveFormula(i,j);else if(0>=b-a&&0>f-e&&1===f)g[h]=d.ascThumbCost(i,j,a,b,e,f);else if(b-a>=0&&1===e&&1!==f)g[h]=d.descThumbCost(i,j,a,b,e,f);else{var k=d.fingerStretch(e,f),l=Math.abs(i-j)/k;g[h]=l>c.moveCutoff?d.descMoveFormula(i,j):d.ascDescNoCrossCost(i,j,l,a,b,e,f)}};b.exports.createLHCostDatabase=function(){for(var a={},b=1;5>=b;b++)for(var c=21;109>c;c++)for(var d=1;5>=d;d++)for(var f=21;109>f;f++)e(c,f,b,d,a);return a}},{"./CostAlgorithmHelpers.js":2,"./CostAlgorithmParameters.js":3}],7:[function(a,b){var c=a("./Visuals/Piano/KeyboardDesign.js").KeyboardDesign,d=a("./Visuals/Piano/Keyboard.js").Keyboard,e=a("./Visuals/Hands/Right/RightHand.js").RightHand,f=a("./Visuals/Hands/Left/LeftHand.js").LeftHand,g=a("./Visuals/Scene.js").Scene;a("./Algorithms/CostAlgorithm").createCostDatabase;var h=a("./Algorithms/FingeringAlgorithm.js").FingeringAlgorithm,i=a("./PlayControls.js").PlayControls;b.exports.App=function(){this.keyboardDesign=new c,this.keyboard=new d(this.keyboardDesign),this.rightHand=new e(this.keyboard),this.leftHand=new f(this.keyboard),this.player=MIDI.Player;var a=this;this.player.addListener(function(b){var c=a.rightHand,d=a.leftHand,e=144,f=128,g=b.note,h=b.message,i=b.finger;h===e?(a.keyboard.press(g),i>0?c.press(i,g):d.press(i,g)):h===f&&(a.keyboard.release(g),i>0?c.release(i):d.release(i))}),this.player.setAnimation({delay:20,callback:function(b){var c=b.now,d=b.end;a.playControls.displayProgress(c,d)}}),this.loadMidiFile=function(a,b){var c=this;this.player.loadFile(a,function(){c.playControls.setCurrentTime(b)})},this.upload=function(a){var b=this,c=new FileReader;c.onload=function(a){var c=a.target.result;b.loadMidiFile(c)},c.readAsDataURL(a)},this.initScene=function(){var a=this;this.scene=new g("#canvas"),this.scene.add(this.keyboard.model),this.scene.add(this.rightHand.model),this.scene.add(this.leftHand.model),this.scene.animate(function(){a.keyboard.update(),a.rightHand.update(),a.leftHand.update(),TWEEN.update()})},this.initMIDI=function(a){MIDI.loadPlugin(function(){MIDI.channels[9].mute=!0,"function"==typeof a&&a()})},this.initPlayControls=function(b,c){a.playControls=new i(b,c)},this.fingeringAlgorithm=function(){h(a.player.data)}}},{"./Algorithms/CostAlgorithm":1,"./Algorithms/FingeringAlgorithm.js":4,"./PlayControls.js":9,"./Visuals/Hands/Left/LeftHand.js":14,"./Visuals/Hands/Right/RightHand.js":20,"./Visuals/Piano/Keyboard.js":26,"./Visuals/Piano/KeyboardDesign.js":27,"./Visuals/Scene.js":29}],8:[function(a){var b=a("./App.js").App;$(document).on("ready",function(){var a=window.app=new b;a.initMIDI(function(){a.initScene(),$.ajax({url:"/getAllPaths",dataType:"json",success:function(b){a.preComputed=b,a.initPlayControls($(".main-container"),a),$($(".player-songList > li")[0]).trigger("click")}})})})},{"./App.js":7}],9:[function(a,b){b.exports.PlayControls=function(a,b){$(a),$(".player-songListContainer"),$(".player-controls");var c=$(".player-progress-container"),d=$(".player-progress-bar");$(".player-progress-text");var e=$(".player-songList");$(".song");var f=$(".tempo-changer"),g=$(".player-playBtn"),h=$(".player-pauseBtn"),i=$(".current-song"),j=this;this.play=function(){g.hide(),h.show(),j.playing=!0,b.player.resume()},this.playHandler=function(){j.playing===!1?j.resume():j.play()},this.pauseHandler=function(){j.pause()},this.songListHandler=function(a){var c=$(a.target),d=c.text();i.text(d),j.playing=!1,b.currentSong=d,$.ajax({url:"/songs/"+d,dataType:"text",success:function(a){b.loadMidiFile(a,0)}})},this.resume=function(){g.hide(),h.show(),b.player.currentTime+=1e-6,j.playing=!0,b.player.resume()},this.stop=function(){b.player.stop(),j.playing=!1},this.progressHandler=function(a){var b=(a.clientX-c.offset().left)/c.width();j.setCurrentTime(b)},this.tempoHandler=function(a){var e=$(a.target),f=e.find("input").attr("data-timeWarp");b.player.timeWarp=f;var g=b.currentSong;$.ajax({url:"/songs/"+g,dataType:"text",success:function(a){var e=d.width()/c.width();b.loadMidiFile(a,e)}})},this.pause=function(){j.playing=!1,g.show(),h.hide(),b.player.pause(),j.resume()},this.getEndTime=function(){return b.player.endTime},this.displayProgress=function(a,b){var e=a/b,f=Math.floor(e*c.width());d.width(f)},this.setCurrentTime=function(a){var c=b.player.endTime*a;b.player.currentTime=c,setTimeout(j.resume,10),b.player.pause()},g.on("click",j.playHandler),h.on("click",j.pauseHandler),e.on("click",j.songListHandler),c.on("click",j.progressHandler),f.on("click",j.tempoHandler)}},{}],10:[function(a,b){b.exports.Dummy=function(){var a=new THREE.CubeGeometry(1,1,1),b=new THREE.MeshLambertMaterial({color:0}),c=new THREE.Vector3(0,0,0);this.model=new THREE.Mesh(a,b),this.model.position.copy(c),this.model.visible=!1}},{}],11:[function(a,b){var c=a("./FingerMoveParams.js").params;b.exports.Finger=function(a){var b=.6;this.originalY=.2,this.pressedY=this.originalY-b,this.releaseSpeed=.05,this.moveSpeed=.1;var d=a;this.distances=c(d),this.press=function(a){this.moveToNote(a),this.model.position.y=this.pressedY,this.isPressed=!0},this.release=function(){this.isPressed=!1},this.moveToNote=function(a){this.currentPos.x=this.model.position.x,this.currentPos.y=this.model.position.y,this.currentPos.z=this.model.position.z;var b=this.model.parent.children[this.number+1].currentNote,c=this.model.parent.children[this.number-1].currentNote;a>this.model.currentNote?this.model.currentNote=b===a?a-1:a:a=f;f++)f===c?b.fingers[f].press(d):b.fingers[f].moveAsNeeded(c,e,d)},this.release=function(a){a=Math.abs(a),b.fingers[a].release()},this.update=function(){for(var a=b.fingers,c=1;c=f.get(c,c-8)&&a<=f.get(c,c-4)||this.moveToNote(d+5)},this.ringRules=function(a,b,c,d){a>=f.get(c,c-6)&&a<=f.get(c,c-4)||this.moveToNote(d+3)},this.middleRules=function(a,b,c,d){a>=f.get(c,c-5)&&a<=f.get(c,c-1)||this.moveToNote(d+4)},this.thumbRules=function(a,b,c,d){if(!(a>0&&a<=f.get(c,c+4)))if(a>f.get(c,c-3)&&0>a){var e=this;setTimeout(e.moveToNote(d-2),100)}else this.moveToNote(d-2)}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],16:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftMiddle=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.middleFingerWidth,a.middleFingerHeight,a.middleFingerLength),d=new THREE.MeshLambertMaterial({color:a.middleFingerColor}),e=new THREE.Vector3(0,.2,.4);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=3;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 5:this.pinkyRules(e,d,f,c);break;case 4:this.ringRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c);break;case 1:this.thumbRules(e,d,f,c)}},this.pinkyRules=function(a,b,c,d){a>f.get(c,c-5)&&af.get(c,c-4)&&a0&&a0&&af.get(c,c-4)&&0>a){var e=this;setTimeout(e.moveToNote(d-3),100)}else this.moveToNote(d-3)}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],17:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftPinky=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.pinkyWidth,a.pinkyHeight,a.pinkyLength),d=new THREE.MeshLambertMaterial({color:a.pinkyColor}),e=new THREE.Vector3(0,.2,.54);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=5;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 4:this.ringRules(e,d,f,c);break;case 3:this.middleRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c);break;case 1:this.thumbRules(e,d,f,c)}},this.ringRules=function(a,b,c,d){a>0&&a<=f.get(c,c+3)||this.moveToNote(d-2)},this.middleRules=function(a,b,c,d){a>0&&a<=f.get(c,c+5)||this.moveToNote(d-3)},this.indexRules=function(a,b,c,d){a>0&&a<=f.get(c,c+7)||this.moveToNote(d-5)},this.thumbRules=function(a,b,c,d){if(!(a>0&&a<=f.get(c,c+12)))if(a>0&&a<=f.get(c,c+1)){var e=this;setTimeout(e.moveToNote(d-7),100)}else this.moveToNote(d-7)},this.setUpNewTween=function(){var a=this,b=function(){a.model.position.x=a.currentPos.x,a.model.position.y=a.currentPos.y+.1,a.model.position.z=a.currentPos.z+.1},c=TWEEN.Easing.Quadratic.Out,d=new TWEEN.Tween(this.currentPos).to(this.newPos,150).easing(c).onUpdate(b);d.start()}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],18:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftRing=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.ringFingerWidth,a.ringFingerHeight,a.ringFingerLength),d=new THREE.MeshLambertMaterial({color:a.ringFingerColor}),e=new THREE.Vector3(0,.2,.45);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=4;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 5:this.pinkyRules(e,d,f,c);break;case 3:this.middleRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c);break;case 1:this.thumbRules(e,d,f,c)}},this.pinkyRules=function(a,b,c,d){a>f.get(c,c-3)&&a0&&a0&&a0&&af.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-5),100)}else this.moveToNote(d-5)}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],19:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftThumb=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.thumbWidth,a.thumbHeight,a.thumbLength),d=new THREE.MeshLambertMaterial({color:a.thumbColor}),e=new THREE.Vector3(0,.3,.6);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=1;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 5:this.pinkyRules(e,d,f,c);break;case 4:this.ringRules(e,d,f,c);break;case 3:this.middleRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c)}},this.pinkyRules=function(a,b,c,d){if(!(a>=f.get(c,c-12)&&a<=f.get(c,c-5)))if(a>0&&a=f.get(c,c-9)&&a<=f.get(c,c-4)))if(a>0&&a=f.get(c,c-7)&&a<=f.get(c,c-2)))if(a>0&&a=f.get(c,c-4)&&0>a))if(a>0&&a=f;f++)f===c?b.fingers[f].press(d):b.fingers[f].moveAsNeeded(c,e,d)},this.release=function(a){b.fingers[a].release()},this.update=function(){for(var a=b.fingers,c=1;cf.get(c,c+4)&&af.get(c,c+3)&&af.get(c,c+2)&&af.get(c,c-3)&&0>a))if(a>0&&a=f.get(c,c+3)&&a<=f.get(c,c+5)||this.moveToNote(d-3)},this.ringRules=function(a,b,c,d){a>=f.get(c,c+1)&&a<=f.get(c,c+4)||this.moveToNote(d-2)},this.indexRules=function(a,b,c,d){a>=f.get(c,c-3)&&a<=f.get(c,c-1)||this.moveToNote(d+2)},this.thumbRules=function(a,b,c,d){if(!(a>=f.get(c,c-6)&&0>a))if(a>0&&af.get(c,c-3)&&0>a||this.moveToNote(d+2)},this.middleRules=function(a,b,c,d){a>f.get(c,c-5)&&0>a||this.moveToNote(d+3)},this.indexRules=function(a,b,c,d){a>f.get(c,c-7)&&0>a||this.moveToNote(d+5)},this.thumbRules=function(a,b,c,d){if(!(a>f.get(c,c-12)&&0>a))if(a>0&&af.get(c,c+2)&&af.get(c,c-3)&&0>a||this.moveToNote(d+2)},this.indexRules=function(a,b,c,d){a>f.get(c,c-5)&&0>a||this.moveToNote(d+3)},this.thumbRules=function(a,b,c,d){if(!(a>f.get(c,c-8)&&0>a))if(a>0&&a=f.get(c,c+5)&&a=f.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-7),100)}else this.moveToNote(d-7)},this.ringRules=function(a,b,c,d){if(!(a>=f.get(c,c+4)&&a<=f.get(c,c+9)))if(a>f.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-5),100)}else this.moveToNote(d-5)},this.middleRules=function(a,b,c,d){if(!(a>=f.get(c,c+2)&&a<=f.get(c,c+7)))if(a>f.get(c,c-3)&&0>a){var e=this;setTimeout(e.moveToNote(d-4),100)}else this.moveToNote(d-4)},this.indexRules=function(a,b,c,d){if(!(a>0&&a<=f.get(c,c+4)))if(a>f.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-2),100)}else this.moveToNote(d-2)},this.setUpNewTween=function(){var a=this,b=function(){a.model.position.x=a.currentPos.x,a.model.position.y=a.currentPos.y+.1,a.model.position.z=a.currentPos.z+.2},c=TWEEN.Easing.Quadratic.Out,d=new TWEEN.Tween(this.currentPos).to(this.newPos,150).easing(c).onUpdate(b);d.start()}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],26:[function(a,b){var c=a("./PianoKey.js").PianoKey;b.exports.Keyboard=function(a){this.model=new THREE.Object3D,this.keys=[];for(var b=this,d=0;d20&&109>d&&this.model.add(e.model)}this.model.position.y-=a.whiteKeyHeight/2,this.model.traverse(function(a){a.position.x-=4.45}),this.press=function(a){b.keys[a].press()},this.release=function(a){b.keys[a].release()},this.update=function(){for(var a=this,b=a.keys,c=0;cb;b++){var c={};a.keyInfo.push(c)}},d=function(){for(var b=a.KeyType,c=a.keyInfo,d=0;10>d;d++){var e=12*d;c[e+0].keyType=b.WhiteC,c[e+1].keyType=b.Black,c[e+2].keyType=b.WhiteD,c[e+3].keyType=b.Black,c[e+4].keyType=b.WhiteE,c[e+5].keyType=b.WhiteF,c[e+6].keyType=b.Black,c[e+7].keyType=b.WhiteG,c[e+8].keyType=b.Black,c[e+9].keyType=b.WhiteA,c[e+10].keyType=b.Black,c[e+11].keyType=b.WhiteD}},e=function(){var b=a.keyInfo,c=a.KeyType,d=c.WhiteB,e=0,f=0,g=c.Black;for(b[e].keyCenterPosX=f,d=b[e].keyType,e=1;e0&&f-e===0)g[h]=d.ascMoveFormula(i,j,a,b);else if(b-a>=0&&0>f-e&&1!==f)g[h]=d.ascMoveFormula(i,j,a,b,e,f);else if(0>b-a&&f-e>0&&1!==e)g[h]=d.ascMoveFormula(i,j,a,b,e,f);else if(b-a>=0&&0>f-e&&1===f)g[h]=d.ascThumbCost(i,j,a,b,e,f);else if(0>b-a&&1===e&&1!==f)g[h]=d.descThumbCost(i,j,a,b,e,f);else{var k=d.fingerStretch(e,f),l=Math.abs(i-j)/k;g[h]=l>c.moveCutoff?d.descMoveFormula(i,j,a,b,e,f):d.ascDescNoCrossCost(i,j,l,a,b,e,f)}};b.exports.createCostDatabase=function(){for(var a={},b=1;5>=b;b++)for(var c=21;109>c;c++)for(var d=1;5>=d;d++)for(var f=21;109>f;f++)e(c,f,b,d,a);return a}}},{"./CostAlgorithmHelpers.js":2,"./CostAlgorithmParameters.js":3}],2:[function(a,b){var c=a("./CostAlgorithmParameters.js"),d=b.exports,e=function(a){return.0002185873295*Math.pow(a,7)-.008611946279*Math.pow(a,6)+.1323250066*Math.pow(a,5)-1.002729677*Math.pow(a,4)+3.884106308*Math.pow(a,3)-6.723075747*Math.pow(a,2)+1.581196785*a+7.711241722},f=function(a,b,d,e,f){if("White"===c.color[a%12]&&"Black"===c.color[b%12]){if(5===e||1===e)return 4;if(0===f)return 4}if("Black"===c.color[a%12]&&"White"===c.color[b%12]){if(5===d||1===d)return 4;if(0===f)return-1}return 0},g=d.ascMoveFormula=function(a,b,d,e,g,h){var i,j=Math.ceil(a+b);return j>24?c.moveHash[24]+(j-24)/5:(i=c.moveHash[j],i+=f(d,e,g,h,b))};d.descMoveFormula=function(a,b,d,e,g,h){var i,j=Math.ceil(a-b);return j>24?c.moveHash[24]+(j-24)/5:(i=c.moveHash[j],i+=f(d,e,g,h,b))},d.fingerDistance=function(a,b){var d=a.toString()+","+b.toString();return c.fingDistance[d]},d.ascThumbCost=function(a,b,d,f,h,j){var k=i(h,j),l=(a+b)/k;if(l>10)return g(a,b);var m=e(l);return"White"===c.color[d%12]&&"Black"===c.color[f%12]&&(m+=8),m},d.descThumbCost=function(a,b,d,f,i,j){var k=h(i,j),l=(a+b)/k;if(l>10)return g(a,b);var m=e(l);return"Black"===c.color[d%12]&&"White"===c.color[f%12]&&(m+=8),m};var h=d.descThumbStretch=function(a,b){var d=a.toString()+","+b.toString();return c.descThumbStretchVals[d]},i=d.ascThumbStretch=function(a,b){var d=a.toString()+","+b.toString();return c.ascThumbStretchVals[d]};d.fingerStretch=function(a,b){var d=a.toString()+","+b.toString();return c.fingStretch[d]},d.ascDescNoCrossCost=function(a,b,d,e,g,h,i){var j,k=function(a){return-6.589793725e-7*Math.pow(a,10)-2336381414e-15*Math.pow(a,9)+9925769823e-14*Math.pow(a,8)+.0001763353131*Math.pow(a,7)-.004660305277*Math.pow(a,6)-.004290746384*Math.pow(a,5)+.06855725903*Math.pow(a,4)+.03719817227*Math.pow(a,3)+.4554696705*Math.pow(a,2)-.08305450359*a+.3020594956};return d>6.8&&d<=c.moveCutoff?k(6.8)+3*(d-6.8):(j=k(d),j+=f(e,g,h,i))}},{"./CostAlgorithmParameters.js":3}],3:[function(a,b){var c=b.exports;c.moveCutoff=7.5,c.color={0:"White",1:"Black",2:"White",3:"Black",4:"White",5:"White",6:"Black",7:"White",8:"Black",9:"White",10:"Black",11:"White"},c.fingDistance={"1,1":0,"1,2":2,"1,3":3.5,"1,4":5,"1,5":7,"2,1":2,"2,2":0,"2,3":2,"2,4":3.5,"2,5":5,"3,1":3.5,"3,2":2,"3,3":0,"3,4":2,"3,5":3.5,"4,1":5,"4,2":3.5,"4,3":2,"4,4":0,"4,5":2,"5,1":7,"5,2":5,"5,3":3.5,"5,4":2,"5,5":0};var d=c.makeMoveHash=function(a){var b={1:0,2:.5,3:1.8,4:3,5:5,6:7,7:8,8:8.9,9:9.7,10:10.5,11:11,12:11.4,13:11.8,14:12.2,15:12.5,16:12.8,17:13.1,18:13.4,19:13.7,20:14,21:14.3,22:14.6,23:14.9,24:15.2};for(var c in b)b[c]+=a;return b};c.moveHash=d(4),c.descThumbStretchVals={"1,2":1,"1,3":1,"1,4":.9,"1,5":.95},c.ascThumbStretchVals={"2,1":.95,"3,1":1,"4,1":.95,"5,1":.95},c.fingStretch={"1,1":.8,"1,2":1.15,"1,3":1.4,"1,4":1.45,"1,5":1.6,"2,1":1.15,"2,2":.6,"2,3":.9,"2,4":1.15,"2,5":1.3,"3,1":1.4,"3,2":.9,"3,3":.6,"3,4":.9,"3,5":1.15,"4,1":1.45,"4,2":1.15,"4,3":.9,"4,4":.7,"4,5":.7,"5,1":1.6,"5,2":1.3,"5,3":1.15,"5,4":.8,"5,5":.6}},{}],4:[function(a,b){var c=a("./FingeringAlgorithmHelpers.js");b.exports.FingeringAlgorithm=function(a){for(var b=c.addStartTimes(a),d=0;d0)for(var r=2,s=l;0===q.notes.length;){var t=s.bestPrev,u=f[g-r][t];q=c.getSplitData(u).right,r++,s=u}var v=n.left,w=o.left;if(v.notes.length>0)for(var r=2,s=l;0===w.notes.length;){var t=s.bestPrev,u=f[g-r][t];w=c.getSplitData(u).left,r++,s=u}var x=c.calcCost(p,q,v,"RH"),y=c.calcCost(v,w,p,"LH");m+=x+y,i>m&&(i=m,k.nodeScore=m,k.bestPrev=j)}for(var z=c.findMin(f[f.length-1]),A={},B=f.length-1;B>0;B--){for(var C=f[B][z],D=C.fingers,E=C.notes,F=0;F=h;h++)g[h]=f(h);var i=[{notes:["e","e"],fingers:[1,-1]}],j=function(a,b){this.notes=a,this.fingers=b,this.nodeScore=0,this.bestPrev=void 0},k=function(a){for(var b=a.sort(function(a,b){return a[0]-b[0]}),c=[],d=g[b.length],e=0;e0?h:0},n=function(a,b,c,e){if("e"===a||"e"===b)return 0;c=Math.abs(c),e=Math.abs(e);var f=a+","+b+","+c+","+e,g=d[f],h=b-60;return g+=h>0?h:0};e.findMin=function(a){for(var b,c=1/0,d=0;d0?(b.right.fingers.push(a.fingers[c]),b.right.notes.push(a.notes[c])):(b.left.fingers.push(a.fingers[c]),b.left.notes.push(a.notes[c]));return b},e.calcCost=function(a,b,c,d){for(var e="RH"===d?m:n,f=0,g=0;g0&&f-e===0)g[h]=d.ascMoveFormula(i,j,a,b);else if(0>=b-a&&0>f-e&&1!==f)g[h]=d.ascMoveFormula(i,j);else if(b-a>0&&f-e>0&&1!==e)g[h]=d.ascMoveFormula(i,j);else if(0>=b-a&&0>f-e&&1===f)g[h]=d.ascThumbCost(i,j,a,b,e,f);else if(b-a>=0&&1===e&&1!==f)g[h]=d.descThumbCost(i,j,a,b,e,f);else{var k=d.fingerStretch(e,f),l=Math.abs(i-j)/k;g[h]=l>c.moveCutoff?d.descMoveFormula(i,j):d.ascDescNoCrossCost(i,j,l,a,b,e,f)}};b.exports.createLHCostDatabase=function(){for(var a={},b=1;5>=b;b++)for(var c=21;109>c;c++)for(var d=1;5>=d;d++)for(var f=21;109>f;f++)e(c,f,b,d,a);return a}}},{"./CostAlgorithmHelpers.js":2,"./CostAlgorithmParameters.js":3}],7:[function(a,b){var c=a("./Visuals/Piano/KeyboardDesign.js").KeyboardDesign,d=a("./Visuals/Piano/Keyboard.js").Keyboard,e=a("./Visuals/Hands/Right/RightHand.js").RightHand,f=a("./Visuals/Hands/Left/LeftHand.js").LeftHand,g=a("./Visuals/Scene.js").Scene,h=(a("./Algorithms/CostAlgorithm").createCostDatabase,a("./Algorithms/FingeringAlgorithm.js").FingeringAlgorithm),i=a("./PlayControls.js").PlayControls;b.exports.App=function(){this.keyboardDesign=new c,this.keyboard=new d(this.keyboardDesign),this.rightHand=new e(this.keyboard),this.leftHand=new f(this.keyboard),this.player=MIDI.Player;var a=this;this.player.addListener(function(b){var c=a.rightHand,d=a.leftHand,e=144,f=128,g=b.note,h=b.message,i=b.finger;h===e?(a.keyboard.press(g),i>0?c.press(i,g):d.press(i,g)):h===f&&(a.keyboard.release(g),i>0?c.release(i):d.release(i))}),this.player.setAnimation({delay:20,callback:function(b){var c=b.now,d=b.end;a.playControls.displayProgress(c,d)}}),this.loadMidiFile=function(a,b){var c=this;this.player.loadFile(a,function(){c.playControls.setCurrentTime(b)})},this.upload=function(a){var b=this,c=new FileReader;c.onload=function(a){var c=a.target.result;b.loadMidiFile(c)},c.readAsDataURL(a)},this.initScene=function(){var a=this;this.scene=new g("#canvas"),this.scene.add(this.keyboard.model),this.scene.add(this.rightHand.model),this.scene.add(this.leftHand.model),this.scene.animate(function(){a.keyboard.update(),a.rightHand.update(),a.leftHand.update(),TWEEN.update()})},this.initMIDI=function(a){MIDI.loadPlugin(function(){MIDI.channels[9].mute=!0,"function"==typeof a&&a()})},this.initPlayControls=function(b,c){a.playControls=new i(b,c)},this.fingeringAlgorithm=function(){h(a.player.data)}}},{"./Algorithms/CostAlgorithm":1,"./Algorithms/FingeringAlgorithm.js":4,"./PlayControls.js":9,"./Visuals/Hands/Left/LeftHand.js":14,"./Visuals/Hands/Right/RightHand.js":20,"./Visuals/Piano/Keyboard.js":26,"./Visuals/Piano/KeyboardDesign.js":27,"./Visuals/Scene.js":29}],8:[function(a){var b=a("./App.js").App;$(document).on("ready",function(){var a=window.app=new b;a.initMIDI(function(){a.initScene(),$.ajax({url:"/getAllPaths",dataType:"json",success:function(b){a.preComputed=b,a.initPlayControls($(".main-container"),a),$($(".player-songList > li")[0]).trigger("click")}})})})},{"./App.js":7}],9:[function(a,b){b.exports.PlayControls=function(a,b){var c=($(a),$(".player-songListContainer"),$(".player-controls"),$(".player-progress-container")),d=$(".player-progress-bar"),e=($(".player-progress-text"),$(".player-songList")),f=($(".song"),$(".tempo-changer")),g=$(".player-playBtn"),h=$(".player-pauseBtn"),i=$(".current-song"),j=this;this.play=function(){g.hide(),h.show(),j.playing=!0,b.player.resume()},this.playHandler=function(){j.playing===!1?j.resume():j.play()},this.pauseHandler=function(){j.pause()},this.songListHandler=function(a){var c=$(a.target),d=c.text();i.text(d),j.playing=!1,b.currentSong=d,$.ajax({url:"/songs/"+d,dataType:"text",success:function(a){b.loadMidiFile(a,0)}})},this.resume=function(){g.hide(),h.show(),b.player.currentTime+=1e-6,j.playing=!0,b.player.resume()},this.stop=function(){b.player.stop(),j.playing=!1},this.progressHandler=function(a){var b=(a.clientX-c.offset().left)/c.width();j.setCurrentTime(b)},this.tempoHandler=function(a){var e=$(a.target),f=e.find("input").attr("data-timeWarp");b.player.timeWarp=f;var g=b.currentSong;$.ajax({url:"/songs/"+g,dataType:"text",success:function(a){var e=d.width()/c.width();b.loadMidiFile(a,e)}})},this.pause=function(){j.playing=!1,g.show(),h.hide(),b.player.pause(),j.resume()},this.getEndTime=function(){return b.player.endTime},this.displayProgress=function(a,b){var e=a/b,f=Math.floor(e*c.width());d.width(f)},this.setCurrentTime=function(a){var c=b.player.endTime*a;b.player.currentTime=c,setTimeout(j.resume,10),b.player.pause()},g.on("click",j.playHandler),h.on("click",j.pauseHandler),e.on("click",j.songListHandler),c.on("click",j.progressHandler),f.on("click",j.tempoHandler)}},{}],10:[function(a,b){b.exports.Dummy=function(){var a=new THREE.CubeGeometry(1,1,1),b=new THREE.MeshLambertMaterial({color:0}),c=new THREE.Vector3(0,0,0);this.model=new THREE.Mesh(a,b),this.model.position.copy(c),this.model.visible=!1}},{}],11:[function(a,b){var c=a("./FingerMoveParams.js").params;b.exports.Finger=function(a){var b=.6;this.originalY=.2,this.pressedY=this.originalY-b,this.releaseSpeed=.05,this.moveSpeed=.1;var d=a;this.distances=c(d),this.press=function(a){this.moveToNote(a),this.model.position.y=this.pressedY,this.isPressed=!0},this.release=function(){this.isPressed=!1},this.moveToNote=function(a){this.currentPos.x=this.model.position.x,this.currentPos.y=this.model.position.y,this.currentPos.z=this.model.position.z;var b=this.model.parent.children[this.number+1].currentNote,c=this.model.parent.children[this.number-1].currentNote;a>this.model.currentNote?this.model.currentNote=b===a?a-1:a:a=f;f++)f===c?b.fingers[f].press(d):b.fingers[f].moveAsNeeded(c,e,d)},this.release=function(a){a=Math.abs(a),b.fingers[a].release()},this.update=function(){for(var a=b.fingers,c=1;c=f.get(c,c-8)&&a<=f.get(c,c-4)||this.moveToNote(d+5)},this.ringRules=function(a,b,c,d){a>=f.get(c,c-6)&&a<=f.get(c,c-4)||this.moveToNote(d+3)},this.middleRules=function(a,b,c,d){a>=f.get(c,c-5)&&a<=f.get(c,c-1)||this.moveToNote(d+4)},this.thumbRules=function(a,b,c,d){if(!(a>0&&a<=f.get(c,c+4)))if(a>f.get(c,c-3)&&0>a){var e=this;setTimeout(e.moveToNote(d-2),100)}else this.moveToNote(d-2)}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],16:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftMiddle=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.middleFingerWidth,a.middleFingerHeight,a.middleFingerLength),d=new THREE.MeshLambertMaterial({color:a.middleFingerColor}),e=new THREE.Vector3(0,.2,.4);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=3;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 5:this.pinkyRules(e,d,f,c);break;case 4:this.ringRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c);break;case 1:this.thumbRules(e,d,f,c)}},this.pinkyRules=function(a,b,c,d){a>f.get(c,c-5)&&af.get(c,c-4)&&a0&&a0&&af.get(c,c-4)&&0>a){var e=this;setTimeout(e.moveToNote(d-3),100)}else this.moveToNote(d-3)}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],17:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftPinky=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.pinkyWidth,a.pinkyHeight,a.pinkyLength),d=new THREE.MeshLambertMaterial({color:a.pinkyColor}),e=new THREE.Vector3(0,.2,.54);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=5;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 4:this.ringRules(e,d,f,c);break;case 3:this.middleRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c);break;case 1:this.thumbRules(e,d,f,c)}},this.ringRules=function(a,b,c,d){a>0&&a<=f.get(c,c+3)||this.moveToNote(d-2)},this.middleRules=function(a,b,c,d){a>0&&a<=f.get(c,c+5)||this.moveToNote(d-3)},this.indexRules=function(a,b,c,d){a>0&&a<=f.get(c,c+7)||this.moveToNote(d-5)},this.thumbRules=function(a,b,c,d){if(!(a>0&&a<=f.get(c,c+12)))if(a>0&&a<=f.get(c,c+1)){var e=this;setTimeout(e.moveToNote(d-7),100)}else this.moveToNote(d-7)},this.setUpNewTween=function(){var a=this,b=function(){a.model.position.x=a.currentPos.x,a.model.position.y=a.currentPos.y+.1,a.model.position.z=a.currentPos.z+.1},c=TWEEN.Easing.Quadratic.Out,d=new TWEEN.Tween(this.currentPos).to(this.newPos,150).easing(c).onUpdate(b);d.start()}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],18:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftRing=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.ringFingerWidth,a.ringFingerHeight,a.ringFingerLength),d=new THREE.MeshLambertMaterial({color:a.ringFingerColor}),e=new THREE.Vector3(0,.2,.45);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=4;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 5:this.pinkyRules(e,d,f,c);break;case 3:this.middleRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c);break;case 1:this.thumbRules(e,d,f,c)}},this.pinkyRules=function(a,b,c,d){a>f.get(c,c-3)&&a0&&a0&&a0&&af.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-5),100)}else this.moveToNote(d-5)}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],19:[function(a,b){var c=a("../Finger.js").Finger,d=b.exports.LeftThumb=function(a){c.call(this,a.keyboard);var b=new THREE.CubeGeometry(a.thumbWidth,a.thumbHeight,a.thumbLength),d=new THREE.MeshLambertMaterial({color:a.thumbColor}),e=new THREE.Vector3(0,.3,.6);this.model=new THREE.Mesh(b,d),this.model.position.copy(e),this.originalY=e.y,this.number=1;var f=this.distances;this.moveAsNeeded=function(a,b,c){var d=this.currentPos.x,e=b-d,f=this.model.currentNote;switch(a){case 5:this.pinkyRules(e,d,f,c);break;case 4:this.ringRules(e,d,f,c);break;case 3:this.middleRules(e,d,f,c);break;case 2:this.indexRules(e,d,f,c)}},this.pinkyRules=function(a,b,c,d){if(!(a>=f.get(c,c-12)&&a<=f.get(c,c-5)))if(a>0&&a=f.get(c,c-9)&&a<=f.get(c,c-4)))if(a>0&&a=f.get(c,c-7)&&a<=f.get(c,c-2)))if(a>0&&a=f.get(c,c-4)&&0>a))if(a>0&&a=f;f++)f===c?b.fingers[f].press(d):b.fingers[f].moveAsNeeded(c,e,d)},this.release=function(a){b.fingers[a].release()},this.update=function(){for(var a=b.fingers,c=1;cf.get(c,c+4)&&af.get(c,c+3)&&af.get(c,c+2)&&af.get(c,c-3)&&0>a))if(a>0&&a=f.get(c,c+3)&&a<=f.get(c,c+5)||this.moveToNote(d-3)},this.ringRules=function(a,b,c,d){a>=f.get(c,c+1)&&a<=f.get(c,c+4)||this.moveToNote(d-2)},this.indexRules=function(a,b,c,d){a>=f.get(c,c-3)&&a<=f.get(c,c-1)||this.moveToNote(d+2)},this.thumbRules=function(a,b,c,d){if(!(a>=f.get(c,c-6)&&0>a))if(a>0&&af.get(c,c-3)&&0>a||this.moveToNote(d+2)},this.middleRules=function(a,b,c,d){a>f.get(c,c-5)&&0>a||this.moveToNote(d+3)},this.indexRules=function(a,b,c,d){a>f.get(c,c-7)&&0>a||this.moveToNote(d+5)},this.thumbRules=function(a,b,c,d){if(!(a>f.get(c,c-12)&&0>a))if(a>0&&af.get(c,c+2)&&af.get(c,c-3)&&0>a||this.moveToNote(d+2)},this.indexRules=function(a,b,c,d){a>f.get(c,c-5)&&0>a||this.moveToNote(d+3)},this.thumbRules=function(a,b,c,d){if(!(a>f.get(c,c-8)&&0>a))if(a>0&&a=f.get(c,c+5)&&a=f.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-7),100)}else this.moveToNote(d-7)},this.ringRules=function(a,b,c,d){if(!(a>=f.get(c,c+4)&&a<=f.get(c,c+9)))if(a>f.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-5),100)}else this.moveToNote(d-5)},this.middleRules=function(a,b,c,d){if(!(a>=f.get(c,c+2)&&a<=f.get(c,c+7)))if(a>f.get(c,c-3)&&0>a){var e=this;setTimeout(e.moveToNote(d-4),100)}else this.moveToNote(d-4)},this.indexRules=function(a,b,c,d){if(!(a>0&&a<=f.get(c,c+4)))if(a>f.get(c,c-2)&&0>a){var e=this;setTimeout(e.moveToNote(d-2),100)}else this.moveToNote(d-2)},this.setUpNewTween=function(){var a=this,b=function(){a.model.position.x=a.currentPos.x,a.model.position.y=a.currentPos.y+.1,a.model.position.z=a.currentPos.z+.2},c=TWEEN.Easing.Quadratic.Out,d=new TWEEN.Tween(this.currentPos).to(this.newPos,150).easing(c).onUpdate(b);d.start()}};d.prototype=Object.create(c.prototype),d.prototype.constructor=d},{"../Finger.js":11}],26:[function(a,b){var c=a("./PianoKey.js").PianoKey;b.exports.Keyboard=function(a){this.model=new THREE.Object3D,this.keys=[];for(var b=this,d=0;d20&&109>d&&this.model.add(e.model)}this.model.position.y-=a.whiteKeyHeight/2,this.model.traverse(function(a){a.position.x-=4.45}),this.press=function(a){b.keys[a].press()},this.release=function(a){b.keys[a].release()},this.update=function(){for(var a=this,b=a.keys,c=0;cb;b++){var c={};a.keyInfo.push(c)}},d=function(){for(var b=a.KeyType,c=a.keyInfo,d=0;10>d;d++){var e=12*d;c[e+0].keyType=b.WhiteC,c[e+1].keyType=b.Black,c[e+2].keyType=b.WhiteD,c[e+3].keyType=b.Black,c[e+4].keyType=b.WhiteE,c[e+5].keyType=b.WhiteF,c[e+6].keyType=b.Black,c[e+7].keyType=b.WhiteG,c[e+8].keyType=b.Black,c[e+9].keyType=b.WhiteA,c[e+10].keyType=b.Black,c[e+11].keyType=b.WhiteD}},e=function(){var b=a.keyInfo,c=a.KeyType,d=c.WhiteB,e=0,f=0,g=c.Black;for(b[e].keyCenterPosX=f,d=b[e].keyType,e=1;e Date: Tue, 27 May 2014 21:27:11 -0300 Subject: [PATCH 2/2] Fix formatting and grammer in the README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5c286c9..cea9341 100644 --- a/README.md +++ b/README.md @@ -7,19 +7,19 @@ See it in action at http://www.performer.io/ Performer takes any MIDI file and determines the best piano fingering to use for that particular song. It then visualizes two virtual hands performing the piece in 3D. ##How it works --Performer has sophisticated cost algorithms to determine the "price" of any of the ~200k piano movement options. That is, it answers the question, "What does it 'cost' to move from note A with finger X to note B with finger Y." +- Performer has sophisticated cost algorithms to determine the "price" of any of the ~200k piano movement options. That is, it answers the question, "What does it 'cost' to move from note A with finger X to note B with finger Y." --When a MIDI file is uploaded, it parses the file to know what notes are in the song. +- When a MIDI file is uploaded, it parses the file to know what notes are in the song. --It then uses **Viterbi's algorithm** to determine the lowest cost path among the trillions of possible fingering choices. Thanks to Viterbi's, this process runs in linear time as a function of the number of notes in a song. +- It then uses **Viterbi's algorithm** to determine the lowest cost path among the trillions of possible fingering choices. Thanks to Viterbi's, this process runs in linear time as a function of the number of notes in a song. --Once the path has been determined, the data is processed and used to orchestrate the 'fingers' moving in sync with the audio playback +- Once the path has been determined, the data is processed and used to orchestrate the 'fingers' moving in sync with the audio playback ##The tech behind it --**JavaScript** powered all the algorithms. +- **JavaScript** powered all the algorithms --MIDI file parsing and playback is done with the help of a slightly modified version of the **MIDI.js** library +- MIDI file parsing and playback is done with the help of a slightly modified version of the **MIDI.js** library --**Three.js** in conjunction with Tween.js was used for creating and animating the 3D hands and piano +- **Three.js** in conjunction with **Tween.js** to create and animate the 3D hands and piano --The backend was doing using **Node**, **Express**, and **MongoDB**. +- The backend was done doing using **Node**, **Express**, and **MongoDB**