<commit_before>/*! ramda 2014-11-19 */
function simulate(a,b,c,d,e){var f=b-a+c,g=0;if(f<e.lockupLimit){var h=Math.floor(f/e.stepSize);g=f-h*e.stepSize,R.forEach(function(a){for(var b=h;b--;)a.state=rk4Integrate(pendulumEoms,a.config.timeScale*e.stepSize,a.state);a.trajectory=R.take(a.config.trajectoryLength,R.prepend(jointCoordinates(a.state)[3],a.trajectory))},d)}R.forEach(function(a){a.justHit&&(a.pads[a.note].className="pad padAnimate");var b=checkNotes(a);a.note=b.note,a.justHit=b.justHit,a.justHit&&(hitNote(a.synth,a.note),a.pads[a.note].className="pad"),drawPendulum(a.ctx,a.canvasWidth,a.state,a.trajectory)},d),window.requestAnimationFrame(function(a){simulate(b,a,g,d,e)})}function checkNotes(a){var b=a.config,c=a.state,d=(a.pads,a.synth),e=jointCoordinates(c)[3];if(e.y>b.kbdHeight-3)return{note:null,justHit:!1};var f=Math.floor(d.notes.length*(b.kbdWidth/2+e.x)/b.kbdWidth);return f=Math.max(Math.min(f,d.notes.length-1),0),{note:f,justHit:a.note!==f}}function toCanvasCoords(a,b,c){return{x:a+b*c.x,y:a-b*c.y}}function drawPendulum(a,b,c,d){var e=(Math.sin,Math.cos,.015*b),f=b/6-e,g=b/2,h=R.lPartial(toCanvasCoords,g,f);a.clearRect(0,0,b,b),a.lineWidth=1,a.globalAlpha=.6,a.strokeStyle="#268bd2",a.beginPath();var i=R.map(h,d);a.moveTo(i[0].x,i[0].y),R.forEach(function(b){a.lineTo(b.x,b.y)},R.tail(i)),a.stroke();var j=R.tail(R.map(h,jointCoordinates(c)));a.globalAlpha=1,a.lineWidth=.01*b,a.strokeStyle="black",a.beginPath(),a.moveTo(g,g),R.forEach(function(b){a.lineTo(b.x,b.y)},j),a.stroke(),R.zipWith(function(b,c){a.fillStyle=c,circle(a,b.x,b.y,e)},j,["#dc322f","#dc322f","#b58900"])}function circle(a,b,c,d){a.beginPath(),a.arc(b,c,d,0,2*Math.PI),a.fill()}function setupCanvas(a){var b=a.offsetWidth;a.width=b,a.height=b;var c=a.getContext("2d");return c.strokeStyle="black",c.lineJoin="round",{ctx:c,width:b}}function createPads(a,b,c,d,e){function f(a){return 100*a/6+"%"}var g=document.createElement("div");g.className="padContainer",g.style.width=f(b),g.style.height=f(c),g.style.left=f(d);var h=100/e,i=R.map(function(a){var b=document.createElement("div");return b.className="pad",b.style.width=h+"%",b.style.left=a*h+"%",g.appendChild(b),b},R.range(0,e));return a.appendChild(g),i}function pendulumEoms(a){var b=Math.sin,c=Math.cos,d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=g*g,k=h*h,l=i*i,m=e-d,n=f-e,o=f-d,p=1/(2*c(2*n)+4*c(2*m)-10);return[g,h,i,-(b(2*n+d)-b(2*n-d)-2*l*b(f-2*e+d)+2*l*b(o)+4*b(2*e-d)+4*j*b(2*m)+8*k*b(m)-10*b(d))*p,-(2*j*b(2*f-e-d)+b(2*o-e)+b(2*f-e)+2*k*b(2*n)-2*l*b(f+e-2*d)+6*l*b(n)-4*k*b(2*m)-14*j*b(m)-7*b(e-2*d)-7*b(e))*p,2*(l*b(2*n)+4*k*b(n)+b(f-2*e+2*d)+2*j*b(f-2*e+d)+b(f-2*e)+2*j*b(o)+b(f-2*d)+b(f))*p]}function totalEnergy(a){var b=-cos(a[0]),c=b-cos(a[1]),d=c-cos(a[2]),e=a[3]*cos(a[0]),f=e+a[4]*cos(a[1]),g=f+a[5]*cos(a[2]),h=a[3]*sin(a[0]),i=h+a[4]*sin(a[1]),j=i+a[5]*sin(a[2]);return(e*e+f*f+g*g+h*h+i*i+j*j)/2+b+c+d}function maximumVelocity(a){return Math.sqrt(2*totalEnergy(a)+12)}function jointCoordinates(a){var b=R.scanl(function(a,b){return[a[0]+Math.sin(b),a[1]-Math.cos(b)]},[0,0],R.take(3,a));return R.map(function(a){return{x:a[0],y:a[1]}},b)}function createSynth(a,b,c,d,e){var f=Math.pow(2,1/12),g=a.createGain(),h=R.map(R.divide(void 0,R.sum(d)+1),R.prepend(1,d)),i=R.map(function(c){return createNote(b*Math.pow(f,c),h,a)},c);return R.forEach(function(a){a.connect(g)},i),{master:g,notes:i,envelope:e,ctx:a}}function createNote(a,b,c){var d=c.createGain();d.gain.value=0;return R.forEach(function(b){if(0!==b[1]){var e=c.createOscillator(),f=c.createGain();f.gain.value=b[0],e.frequency.value=a*b[1],e.connect(f),f.connect(d),e.start()}},R.zip(b,R.range(1,b.length+1))),d}function hitNote(a,b){if(!(b>=a.notes.length)){var c=a.ctx.currentTime,d=a.notes[b].gain;d.cancelScheduledValues(c),d.setValueAtTime(0,c),d.linearRampToValueAtTime(1,c+a.envelope.attack),d.linearRampToValueAtTime(0,c+a.envelope.attack+a.envelope.release)}}function startNote(a,b){if(!(b>=a.notes.length)){var c=a.ctx.currentTime,d=a.notes[b].gain;d.cancelScheduledValues(c),d.setValueAtTime(0,c),d.linearRampToValueAtTime(1,c+a.envelope.attack)}}function killNote(a,b){if(!(b>=a.notes.length)){var c=a.ctx.currentTime,d=a.notes[b].gain;d.cancelScheduledValues(c),d.linearRampToValueAtTime(0,c+a.envelope.release)}}function killAllNotes(a){var b=a.ctx.currentTime;R.forEach(function(c){c.gain.cancelScheduledValues(b),c.gain.linearRampToValueAtTime(0,b+a.envelope.release)},a.notes)}function rk4Integrate(a,b,c){var d=R.multiply(b/2),e=R.multiply(b/3),f=R.multiply(b/6),g=a(c),h=a(vecAdd(c,g.map(d))),i=a(vecAdd(c,h.map(d))),j=a(vecAdd(c,i.map(R.multiply(b))));return R.reduce(vecAdd,c,[g.map(f),h.map(e),i.map(e),j.map(f)])}!function(a){"object"==typeof exports?module.exports=a(this):"function"==typeof define&&define.amd?define(a):this.R=a(this)}(function(){"use strict";function a(){return new TypeError("Function called with no arguments")}function b(c,d,e){switch(arguments.length){case 0:throw a();case 1:return b(c,0,c.length);case 2:return b(c,d,c.length);default:for(var f=Math.max(0,e-d),g=new Array(f),h=-1;++h<f;)g[h]=c[d+h];return g}}function c(a,b){a=a||[],b=b||[];var c,d=a.length,e=b.length,f=new Array(d+e);for(c=-1;++c<d;)f[c]=a[c];for(c=-1;++c<e;)f[d+c]=b[c];return f}function d(b){return function(c,d){switch(arguments.length){case 0:throw a();case 1:return function(a){return b(c,a)};default:return b(c,d)}}}function e(b){return function(c,e,f){switch(arguments.length){case 0:throw a();case 1:return d(function(a,d){return b(c,a,d)});case 2:return function(a){return b(c,e,a)};default:return b(c,e,f)}}}function f(a,b){return null!=b&&!T(b)&&"function"==typeof b[a]}function g(a,b){return function(c,d,e){var f=arguments.length,g=arguments[f-1],h=g&&!T(g)&&"function"==typeof g[a];switch(arguments.length){case 0:return b();case 1:return h?g[a]():b(c);case 2:return h?g[a](c):b(c,d);case 3:return h?g[a](c,d):b(c,d,e)}}}function h(a,b){for(var c=-1,d=b.length;++c<d;)a(b[c]);return b}function i(a,b,c){switch(a&&S.call(a)){case"[object Object]":return j(a,{},b,c);case"[object Array]":return j(a,[],b,c);case"[object Function]":return a;case"[object Date]":return new Date(a);default:return a}}function j(a,b,c,d){for(var e=c.length,f=-1;++f<e;)if(a===c[f])return d[f];c.push(a),d.push(b);for(var g in a)b[g]=i(a[g],c,d);return b}function k(a,b){return c([a],b)}function l(a,b){return c(b,[a])}function m(a,b){return function(){return a.call(this,b.apply(this,arguments))}}function n(a,b){return function(){var c=this,d=b.apply(this,arguments);return o(d)?d.then(function(b){return a.call(c,b)}):a.call(this,d)}}function o(a){return null!=a&&a===Object(a)&&a.then&&"function"==typeof a.then}function p(b){return function(){switch(arguments.length){case 0:throw a();case 1:return arguments[0];default:for(var c=arguments.length-1,d=arguments[c],e=d.length;c--;)d=b(arguments[c],d);return bb(e,d)}}}function q(a){return function(c){var d=b(arguments,1);return bb(Math.max(0,c.length-d.length),function(){return c.apply(this,a(d,arguments))})}}function r(a,b){for(var c=-1,d=b.length,e=new Array(d);++c<d;)e[c]=a(b[c]);return e}function s(a,b){for(var c=-1,d=b.length,e=[];++c<d;)a(b[c])&&e.push(b[c]);return e}function t(a,b){for(var c=-1,d=b.length,e=[];++c<d;)a(b[c],c,b)&&e.push(b[c]);return e}function u(a,b){for(var c=-1;++c<b.length;)if(!a(b[c]))return!1;return!0}function v(a,b){for(var c=-1;++c<b.length;)if(a(b[c]))return!0;return!1}function w(a,b,c){var d=0,e=a.length;for("number"==typeof c&&(d=0>c?Math.max(0,e+c):c);e>d;){if(a[d]===b)return d;++d}return-1}function x(a,b,c){var d=a.length;for("number"==typeof c&&(d=0>c?d+c+1:Math.min(d,c+1));--d>=0;)if(a[d]===b)return d;return-1}function y(a,b){return w(b,a)>=0}function z(a,b,c){for(var d=-1,e=c.length;++d<e;)if(a(b,c[d]))return!0;return!1}function A(a){return function b(c){for(var d,e,f,g=[],h=-1,i=c.length;++h<i;)if(U(c[h]))for(d=a?b(c[h]):c[h],e=-1,f=d.length;++e<f;)g.push(d[e]);else g.push(c[h]);return g}}function B(a){return function(b){return r(function(a){return[a,b[a]]},a(b))}}function C(a,b){for(var c,d={},e=Pb(b),f=e.length,g=-1;++g<f;)c=e[g],a(b[c],c,b)&&(d[c]=b[c]);return d}function D(a,b){var c={};return h(function(a){c[a]=b[a]},a),c}function E(a,b){for(var c=Ob(b),d=-1,e=c.length;++d<e;)a[c[d]]=b[c[d]];return a}function F(a,b,c){if(a===c)return!0;if(null==c)return!1;b.fn=b.fn||[],b.obj=b.obj||[];for(var d,e,f=-1,g=b.fn.length,h=-1,i=b.obj.length;++f<g;){if(d=b.fn[f],e=a[d],!(d in c))return!1;if(!e(c[d],c))return!1}for(;++h<i;)if(d=b.obj[h],a[d]!==c[d])return!1;return!0}function G(a){return function(c){var d=function(){var b=arguments;return a(function(a){return a.apply(null,b)},c)};return arguments.length>1?d.apply(null,b(arguments,1)):bb(Wb(Eb("length",c)),d)}}function H(a,b){return a+b}function I(a,b){return a*b}function J(a,b){return b>a}function K(a,b){return a>b}function L(b,c){return function(d){if(0===arguments.length)throw a();for(var e,f=-1,g=c;++f<d.length;)e=+d[f],b(e,g)&&(g=e);return g}}function M(a){return function(b,c){if(c&&c.length>0){for(var d,e=0,f=c[e],g=b(f);++e<c.length;)d=b(c[e]),a(d,g)&&(g=d,f=c[e]);return f}}}function N(a,b){var c,d=-1,e=a.length;if(null!=b){for(c=b;null!=c&&++d<e;)c=c[a[d]];return c}}function O(a,b){return r(function(b){return{key:a(b),val:b}},b)}function P(a){return function(b){return s(function(a){return"function"==typeof b[a]},a(b))}}var Q,R={version:"0.8.0"},S=Object.prototype.toString,T=Array.isArray||function(a){return null!=a&&a.length>=0&&"[object Array]"===S.call(a)},U=R.isArrayLike=function(a){return T(a)?!0:a?"object"!=typeof a?!1:a instanceof String?!1:1===a.nodeType?!!a.length:0===a.length?!0:a.length>0?a.hasOwnProperty(0)&&a.hasOwnProperty(a.length-1):!1:!1};try{Object.defineProperty(R,"__",{writable:!1,value:Q})}catch(V){R.__=Q}var W=R.op=function(b){var c=b.length;if(2!==c)throw new Error("Expected binary function.");return function d(c,e){switch(arguments.length){case 0:throw a();case 1:return c===Q?ab(Z(d)):_(pb(b,c));default:return c===Q?_(qb(b,e)):b(c,e)}}},X=R.curryN=function(b,d){return function e(f){return bb(Math.max(b-(f&&f.length||0),0),function(){if(0===arguments.length)throw a();var g=c(f,arguments);return g.length>=b?d.apply(this,g):e(g)})}([])},Y=R.curry=function(a){return X(a.length,a)},Z=R.flip=function(d){return function(e,f){switch(arguments.length){case 0:throw a();case 1:return function(a){return d.apply(this,[a,e].concat(b(arguments,1)))};default:return d.apply(this,c([f,e],b(arguments,2)))}}},$=R.nAry=function(a,b){switch(a){case 0:return function(){return b.call(this)};case 1:return function(a){return b.call(this,a)};case 2:return function(a,c){return b.call(this,a,c)};case 3:return function(a,c,d){return b.call(this,a,c,d)};case 4:return function(a,c,d,e){return b.call(this,a,c,d,e)};case 5:return function(a,c,d,e,f){return b.call(this,a,c,d,e,f)};case 6:return function(a,c,d,e,f,g){return b.call(this,a,c,d,e,f,g)};case 7:return function(a,c,d,e,f,g,h){return b.call(this,a,c,d,e,f,g,h)};case 8:return function(a,c,d,e,f,g,h,i){return b.call(this,a,c,d,e,f,g,h,i)};case 9:return function(a,c,d,e,f,g,h,i,j){return b.call(this,a,c,d,e,f,g,h,i,j)};case 10:return function(a,c,d,e,f,g,h,i,j,k){return b.call(this,a,c,d,e,f,g,h,i,j,k)};default:return b}},_=R.unary=function(a){return $(1,a)},ab=R.binary=function(a){return $(2,a)},bb=R.arity=function(a,b){switch(a){case 0:return function(){return b.apply(this,arguments)};case 1:return function(){return b.apply(this,arguments)};case 2:return function(){return b.apply(this,arguments)};case 3:return function(){return b.apply(this,arguments)};case 4:return function(){return b.apply(this,arguments)};case 5:return function(){return b.apply(this,arguments)};case 6:return function(){return b.apply(this,arguments)};case 7:return function(){return b.apply(this,arguments)};case 8:return function(){return b.apply(this,arguments)};case 9:return function(){return b.apply(this,arguments)};case 10:return function(){return b.apply(this,arguments)};default:return b}},cb=R.invokerN=function(a,c){var d=b(arguments,2),e=a-d.length;return X(e+1,function(){var a=arguments[e],f=d.concat(b(arguments,0,e));return a[c].apply(a,f)})},db=R.useWith=function(a){var c=b(arguments,1),d=c.length;return Y(bb(d,function(){for(var e=[],f=-1;++f<d;)e.push(c[f](arguments[f]));return a.apply(this,e.concat(b(arguments,d)))}))};R.forEach=d(h),R.forEach.idx=d(function(a,b){for(var c=-1,d=b.length;++c<d;)a(b[c],c,b);return b});var eb=R.clone=function(a){return b(a)};R.cloneDeep=function(a){return i(a,[],[])};var fb=R.isEmpty=function(a){return null==a||0===a.length},gb=R.prepend=d(k);R.cons=gb,R.prependTo=Z(k);var hb=R.nth=d(function(a,b){return 0>a?b[b.length+a]:b[a]}),ib=R.head=hb(0);R.car=ib,R.last=hb(-1);var jb=R.tail=g("tail",function(a){return b(a,1)});R.cdr=jb;var kb=R.append=d(l);R.push=kb,R.appendTo=Z(l),R.concat=d(function(a,b){if(T(b))return c(a,b);if(f("concat",a))return a.concat(b);throw new TypeError("can't concat "+typeof a)});var lb=R.identity=function(a){return a};R.I=lb,R.argN=function(a){return function(){return arguments[a]}};var mb=R.times=d(function(a,b){for(var c=new Array(b),d=-1;++d<b;)c[d]=a(d);return c});R.repeatN=d(function(a,b){return mb(Nb(a),b)}),R.apply=d(function(a,b){return a.apply(this,b)}),R.unapply=function(c){if(0===arguments.length)throw a();return function(){return c(b(arguments))}};var nb=R.compose=p(m),ob=R.pCompose=p(n);R.pipe=function(){return nb.apply(this,Ib(arguments))},R.pPipe=function(){return ob.apply(this,Ib(arguments))};var pb=R.lPartial=q(c),qb=R.rPartial=q(Z(c));R.memoize=function(a){if(!a.length)return rb(a);var c={};return function(){if(arguments.length){var d=tb(function(a,b){return a[b]||(a[b]={})},c,b(arguments,0,arguments.length-1)),e=arguments[arguments.length-1];return d[e]||(d[e]=a.apply(this,arguments))}}};var rb=R.once=function(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments))}};R.wrap=function(a,b){return bb(a.length,function(){return b.apply(this,c([a],arguments))})};var sb=R.constructN=d(function(a,b){var c=function(){var a,c,d=function(){};return d.prototype=b.prototype,a=new d,c=b.apply(a,arguments),Object(c)===c?c:a};return a>1?Y($(a,c)):c});R.construct=function(a){return sb(a.length,a)},R.converge=function(a){var c=b(arguments,1);return function(){var b=arguments;return a.apply(this,r(function(a){return a.apply(this,b)},c))}};var tb=R.reduce=e(function(a,b,c){for(var d=-1,e=c.length;++d<e;)b=a(b,c[d]);return b});R.foldl=tb,R.reduce.idx=e(function(a,b,c){for(var d=-1,e=c.length;++d<e;)b=a(b,c[d],d,c);return b}),R.foldl.idx=tb.idx;var ub=R.reduceRight=e(g("reduceRight",function(a,b,c){for(var d=c.length;d--;)b=a(b,c[d]);return b}));R.foldr=ub,R.reduceRight.idx=e(function(a,b,c){for(var d=c.length;d--;)b=a(b,c[d],d,c);return b}),R.foldr.idx=ub.idx,R.unfoldr=d(function(a,b){for(var c=a(b),d=[];c&&c.length;)d.push(c[0]),c=a(c[1]);return d});var vb=R.map=d(g("map",r));R.map.idx=d(function(a,b){for(var c=-1,d=b.length,e=new Array(d);++c<d;)e[c]=a(b[c],c,b);return e}),R.mapObj=d(function(a,b){return tb(function(c,d){return c[d]=a(b[d]),c},{},Ob(b))}),R.mapObj.idx=d(function(a,b){return tb(function(c,d){return c[d]=a(b[d],d,b),c},{},Ob(b))}),R.scanl=e(function(a,b,c){var d=0,e=c.length+1,f=new Array(e);for(f[d]=b;++d<e;)b=a(b,c[d-1]),f[d]=b;return f});var wb=R.liftN=d(function(c,d){var e=X(c,d);if(0===arguments.length)throw a();return X(c,function(){return tb(xb,r(e,arguments[0]),b(arguments,1))})});R.lift=function(b){if(0===arguments.length)throw a();return wb(b.length,b)};var xb=R.ap=d(function(a,b){return f("ap",a)?a.ap(b):tb(function(a,d){return c(a,r(d,b))},[],a)});R.of=function(a,b){return f("of",b)?b.of(a):[a]},R.empty=function(a){return f("empty",a)?a.empty():[]},R.chain=d(g("chain",function(a,b){return Fb(r(a,b))}));var yb=R.commuteMap=e(function(a,b,c){function d(b,c){return xb(vb(kb,a(c)),b)}return tb(d,b([]),c)});R.commute=yb(vb(lb));var zb=R.size=function(a){return a.length};R.length=zb,R.filter=d(g("filter",s)),R.filter.idx=d(t);var Ab=function(a,b){return s(Tb(a),b)};R.reject=d(Ab),R.reject.idx=d(function(a,b){return t(Tb(a),b)}),R.takeWhile=d(g("takeWhile",function(a,c){for(var d=-1,e=c.length;++d<e&&a(c[d]););return b(c,0,d)})),R.take=d(g("take",function(a,c){return b(c,0,Math.min(a,c.length))})),R.skipUntil=d(function(a,c){for(var d=-1,e=c.length;++d<e&&!a(c[d]););return b(c,d)}),R.skip=d(g("skip",function(a,c){return a<c.length?b(c,a):[]})),R.find=d(function(a,b){for(var c=-1,d=b.length;++c<d;)if(a(b[c]))return b[c]}),R.findIndex=d(function(a,b){for(var c=-1,d=b.length;++c<d;)if(a(b[c]))return c;return-1}),R.findLast=d(function(a,b){for(var c=b.length;c--;)if(a(b[c]))return b[c]}),R.findLastIndex=d(function(a,b){for(var c=b.length;c--;)if(a(b[c]))return c;return-1}),R.every=d(u),R.some=d(v),R.indexOf=d(function(a,b){return w(b,a)}),R.indexOf.from=e(function(a,b,c){return w(c,a,b)}),R.lastIndexOf=d(function(a,b){return x(b,a)}),R.lastIndexOf.from=e(function(a,b,c){return x(c,a,b)}),R.contains=d(y);var Bb=R.containsWith=e(z),Cb=R.uniq=function(a){for(var b,c=-1,d=a.length,e=[];++c<d;)b=a[c],y(b,e)||e.push(b);return e};R.isSet=function(a){for(var b=a.length,c=-1;++c<b;)if(w(a,a[c],c+1)>=0)return!1;return!0};var Db=R.uniqWith=d(function(a,b){for(var c,d=-1,e=b.length,f=[];++d<e;)c=b[d],z(a,c,f)||f.push(c);return f}),Eb=R.pluck=d(function(a,b){return r(Lb(a),b)});R.flatten=A(!0);var Fb=R.unnest=A(!1);R.zipWith=e(function(a,b,c){for(var d=[],e=-1,f=Math.min(b.length,c.length);++e<f;)d[e]=a(b[e],c[e]);return d}),R.zip=d(function(a,b){for(var c=[],d=-1,e=Math.min(a.length,b.length);++d<e;)c[d]=[a[d],b[d]];return c}),R.zipObj=d(function(a,b){for(var c=-1,d=a.length,e={};++c<d;)e[a[c]]=b[c];return e});var Gb=R.fromPairs=function(a){for(var b=-1,c=a.length,d={};++b<c;)T(a[b])&&a[b].length&&(d[a[b][0]]=a[b][1]);return d},Hb=R.createMapEntry=d(function(a,b){var c={};return c[a]=b,c});R.lens=d(function(a,b){var c=function(b){return a(b)};return c.set=b,c.map=function(c,d){return b(c(a(d)),d)},c}),R.xprod=d(function(a,b){if(fb(a)||fb(b))return[];for(var c,d=-1,e=a.length,f=b.length,g=[];++d<e;)for(c=-1;++c<f;)g.push([a[d],b[c]]);return g});var Ib=R.reverse=function(a){for(var b=-1,c=a.length,d=c,e=new Array(c);++b<c;)e[--d]=a[b];return e};R.range=d(function(a,b){if(a>=b)return[];for(var c=0,d=new Array(Math.floor(b)-Math.ceil(a));b>a;)d[c++]=a++;return d}),R.join=cb(1,"join"),R.slice=cb(2,"slice"),R.slice.from=d(function(a,b){return b.slice(a,b.length)}),R.remove=e(function(a,d,e){return c(b(e,0,Math.min(a,e.length)),b(e,Math.min(e.length,a+d)))}),R.insert=e(function(a,d,e){return a=a<e.length&&a>=0?a:e.length,c(l(d,b(e,0,a)),b(e,a))}),R.insert.all=e(function(a,d,e){return a=a<e.length&&a>=0?a:e.length,c(c(b(e,0,a),d),b(e,a))});var Jb=R.comparator=function(a){return function(b,c){return a(b,c)?-1:a(c,b)?1:0}};R.sort=d(function(a,b){return eb(b).sort(a)});var Kb=R.groupBy=d(function(a,b){return tb(function(b,c){var d=a(c);return b[d]=l(c,b[d]||(b[d]=[])),b},{},b)});R.partition=d(function(a,b){return tb(function(b,c){return b[a(c)?0:1].push(c),b},[[],[]],b)}),R.tap=d(function(a,b){return a(b),b}),R.eq=d(function(a,b){return a===b});var Lb=R.prop=function(b,c){switch(arguments.length){case 0:throw a();case 1:return function(a){return a[b]}}return c[b]};R.get=Lb,R.propOf=Z(Lb),R.props=d(function(a,b){for(var c=a.length,d=new Array(c),e=-1;++e<c;)d[e]=b[a[e]];return d});var Mb=Object.prototype.hasOwnProperty;R.propOr=e(function(a,b,c){return Mb.call(c,a)?c[a]:b}),R.has=d(function(a,b){return Mb.call(b,a)}),R.hasIn=d(function(a,b){return a in b}),R.func=function(c,d){switch(arguments.length){case 0:throw a();case 1:return function(a){return a[c].apply(a,b(arguments,1))};default:return d[c].apply(d,b(arguments,2))}};var Nb=R.always=function(a){return function(){return a}};R.bind=d(function(a,b){return function(){return a.apply(b,arguments)}});var Ob=R.keys=function(){var a=!{toString:null}.propertyIsEnumerable("toString"),b=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];return function(c){if(Object(c)!==c)return[];if(Object.keys)return Object.keys(c);var d,e,f=[];for(d in c)Mb.call(c,d)&&f.push(d);if(a)for(e=b.length;e--;)d=b[e],Mb.call(c,d)&&!y(d,f)&&f.push(d);return f}}(),Pb=R.keysIn=function(a){var b,c=[];for(b in a)c.push(b);return c};R.toPairs=B(Ob),R.toPairsIn=B(Pb),R.values=function(a){for(var b=Ob(a),c=b.length,d=new Array(c),e=-1;++e<c;)d[e]=a[b[e]];return d},R.valuesIn=function(a){var b,c=[];for(b in a)c.push(a[b]);return c},R.pick=d(function(a,b){return C(function(b,c){return y(c,a)},b)}),R.omit=d(function(a,b){return C(function(b,c){return!y(c,a)},b)}),R.pickBy=d(C);var Qb=R.pickAll=d(D);R.mixin=d(function(a,b){return E(E({},a),b)}),R.cloneObj=function(a){return E({},a)},R.eqProps=e(function(a,b,c){return b[a]===c[a]}),R.where=function(b,c){var d=Kb(function(a){return"function"==typeof b[a]?"fn":"obj"},Ob(b));switch(arguments.length){case 0:throw a();case 1:return function(a){return F(b,d,a)}}return F(b,d,c)};var Rb=R.assoc=e(function(a,b,c){return E(Gb(r(function(a){return[a,c[a]]},Pb(c))),Hb(a,b))});R.assocPath=function(){var c=function(a,d,e){if(1===a.length)return Rb(a[0],d,e);var f=e[a[0]];return Rb(a[0],c(b(a,1),d,Sb(Object,f)?f:{}),e)};return function(b,e,f){var g=arguments.length;if(0===g)throw a();var h=Yb(".",b),i=d(function(a,b){return c(h,a,b)});switch(g){case 1:return i;case 2:return i(e);default:return i(e,f)}}}(),R.installTo=function(a){return E(a,R)};var Sb=R.is=d(function(a,b){return null!=b&&b.constructor===a||b instanceof a});R.type=function(a){return null===a?"Null":void 0===a?"Undefined":S.call(a).slice(8,-1)},R.alwaysZero=Nb(0),R.alwaysFalse=Nb(!1),R.alwaysTrue=Nb(!0),R.and=d(function(a,b){return function(){return a.apply(this,arguments)&&b.apply(this,arguments)}}),R.or=d(function(a,b){return function(){return a.apply(this,arguments)||b.apply(this,arguments)}});var Tb=R.not=function(a){return function(){return!a.apply(this,arguments)}};R.allPredicates=G(u),R.anyPredicates=G(v);var Ub=R.ifElse=e(function(a,b,c){return function(){return a.apply(this,arguments)?b.apply(this,arguments):c.apply(this,arguments)}});R.if=Ub,R.cond=function(){var a=arguments;return function(){for(var b=-1;++b<a.length;)if(a[b][0].apply(this,arguments))return a[b][1].apply(this,arguments)}},R.add=d(H),R.multiply=d(I),R.subtract=W(function(a,b){return a-b}),R.divide=W(function(a,b){return a/b}),R.modulo=W(function(a,b){return a%b});var Vb=Number.isInteger||function(a){return a<<0===a};R.mathMod=W(function(a,b){return Vb(a)?!Vb(b)||1>b?0/0:(a%b+b)%b:0/0}),R.sum=tb(H,0),R.product=tb(I,1),R.lt=W(J),R.lte=W(function(a,b){return b>=a}),R.gt=W(K),R.gte=W(function(a,b){return a>=b});var Wb=R.max=L(K,-1/0);R.maxBy=d(M(K)),R.min=L(J,1/0),R.minBy=d(M(J));var Xb=R.substring=cb(2,"substring");R.substringFrom=Z(Xb)(void 0),R.substringTo=Xb(0),R.charAt=cb(1,"charAt"),R.charCodeAt=cb(1,"charCodeAt"),R.match=cb(1,"match"),R.replace=e(function(a,b,c){return c.replace(a,b)}),R.strIndexOf=d(function(a,b){return b.indexOf(a)}),R.strLastIndexOf=d(function(a,b){return b.lastIndexOf(a)}),R.toUpperCase=cb(0,"toUpperCase"),R.toLowerCase=cb(0,"toLowerCase"),R.trim=function(){var a="	\n
\f\r   ᠎             　\u2028\u2029",b="​",c="function"==typeof String.prototype.trim;return c&&!a.trim()&&b.trim()?function(a){return a.trim()}:function(b){var c=new RegExp("^["+a+"]["+a+"]*"),d=new RegExp("["+a+"]["+a+"]*$");return b.replace(c,"").replace(d,"")}}();var Yb=R.split=cb(1,"split"),Zb=R.pathOn=e(function(a,b,c){return N(b.split(a),c)});R.path=Zb("."),R.pathEq=e(function(a,b,c){return N(a.split("."),c)===b}),R.project=db(r,Qb,lb),R.propEq=e(function(a,b,c){return c[a]===b}),R.union=nb(Cb,c),R.unionWith=e(function(a,b,d){return Db(a,c(b,d))}),R.difference=d(function(a,b){for(var c=[],d=-1,e=a.length;++d<e;)y(a[d],b)||y(a[d],c)||c.push(a[d]);return c}),R.differenceWith=e(function(a,b,c){for(var d=[],e=-1,f=b.length,g=Bb(a);++e<f;)g(b[e],c)||g(b[e],d)||d.push(b[e]);return d}),R.intersection=d(function(a,b){return Cb(s(Z(y)(a),b))}),R.intersectionWith=e(function(a,b,c){for(var d=[],e=-1;++e<b.length;)z(a,b[e],c)&&(d[d.length]=b[e]);return Db(a,d)});var $b=Jb(function(a,b){return a.key<b.key});return R.sortBy=d(function(a,b){return Eb("val",O(a,b).sort($b))}),R.countBy=d(function(a,b){return tb(function(a,b){return a[b.key]=(a[b.key]||0)+1,a},{},O(a,b))}),R.functions=P(Ob),R.functionsIn=P(Pb),R}),window.addEventListener("load",function(){function a(){R.forEach(function(a){var b=setupCanvas(a.canvas);a.ctx=b.ctx,a.canvasWidth=b.width},c)}var b=new window.AudioContext,c=R.map(function(a){var c=document.getElementById(a.container),d=c.getElementsByTagName("canvas")[0],e=createPads(c,a.kbdWidth,a.kbdHeight,3-a.kbdWidth/2,a.synthParams.tuning.length),f=a.synthParams,g=createSynth(b,f.baseFreq,f.tuning,f.harmonics,f.envelope);g.master.gain.value=f.gain,g.master.connect(b.destination);var h=R.zipWith(function(a,b){return a+b*(2*Math.random()-1)},a.initialState.means,a.initialState.deltas);return{config:a,canvas:d,pads:e,synth:g,state:h,note:null,justHit:!1,trajectory:[]}},config.pendulums);a(),window.addEventListener("resize",a),window.requestAnimationFrame(function(a){simulate(a,a,0,c,{lockupLimit:config.lockupLimit,stepSize:config.stepSize})})});var halfPi=Math.PI/2,config={stepSize:10,lockupLimit:500,pendulums:[{container:"melodyContainer",initialState:{means:[halfPi+.3,halfPi+.3,halfPi+.3,0,0,0],deltas:[.1,.2,.3,0,0,0]},timeScale:.003,trajectoryLength:70,kbdWidth:5.7,kbdHeight:2,synthParams:{gain:.2,baseFreq:440,tuning:[0,2,4,7,9,12],envelope:{attack:.015,release:.35},harmonics:[.3,.1,.3,.1,.3]}},{container:"bassContainer",initialState:{means:[halfPi,halfPi,halfPi,0,0,0],deltas:[.1,.2,.3,0,0,0]},timeScale:.002,trajectoryLength:70,kbdWidth:5.7,kbdHeight:2.5,synthParams:{gain:.2,baseFreq:110,tuning:[0,5,7,12],envelope:{attack:.03,release:.7},harmonics:[.2,.3,.2,.15,.1]}}]},vecAdd=R.zipWith(R.add);<commit_msg>Update build<commit_after>/*! ramda 2014-11-19 */
function simulate(a,b,c,d,e){var f=b-a+c,g=0;if(f<e.lockupLimit){var h=Math.floor(f/e.stepSize);g=f-h*e.stepSize,R.forEach(function(a){for(var b=h;b--;)a.state=rk4Integrate(pendulumEoms,a.config.timeScale*e.stepSize,a.state);a.trajectory=R.take(a.config.trajectoryLength,R.prepend(jointCoordinates(a.state)[3],a.trajectory))},d)}R.forEach(function(a){a.justHit&&(a.pads[a.note].className="pad padAnimate");var b=checkNotes(a);a.note=b.note,a.justHit=b.justHit,a.justHit&&(hitNote(a.synth,a.note),a.pads[a.note].className="pad"),drawPendulum(a.ctx,a.canvasWidth,a.state,a.trajectory)},d),window.requestAnimationFrame(function(a){simulate(b,a,g,d,e)})}function checkNotes(a){var b=a.config,c=a.state,d=(a.pads,a.synth),e=jointCoordinates(c)[3];if(e.y>b.kbdHeight-3)return{note:null,justHit:!1};var f=Math.floor(d.notes.length*(b.kbdWidth/2+e.x)/b.kbdWidth);return f=Math.max(Math.min(f,d.notes.length-1),0),{note:f,justHit:a.note!==f}}function toCanvasCoords(a,b,c){return{x:a+b*c.x,y:a-b*c.y}}function drawPendulum(a,b,c,d){var e=(Math.sin,Math.cos,.015*b),f=b/6-e,g=b/2,h=R.lPartial(toCanvasCoords,g,f);a.clearRect(0,0,b,b),a.lineWidth=1,a.globalAlpha=.6,a.strokeStyle="#268bd2",a.beginPath();var i=R.map(h,d);a.moveTo(i[0].x,i[0].y),R.forEach(function(b){a.lineTo(b.x,b.y)},R.tail(i)),a.stroke();var j=R.tail(R.map(h,jointCoordinates(c)));a.globalAlpha=1,a.lineWidth=.01*b,a.strokeStyle="black",a.beginPath(),a.moveTo(g,g),R.forEach(function(b){a.lineTo(b.x,b.y)},j),a.stroke(),R.zipWith(function(b,c){a.fillStyle=c,circle(a,b.x,b.y,e)},j,["#dc322f","#dc322f","#b58900"])}function circle(a,b,c,d){a.beginPath(),a.arc(b,c,d,0,2*Math.PI),a.fill()}function setupCanvas(a){var b=a.offsetWidth;a.width=b,a.height=b;var c=a.getContext("2d");return c.strokeStyle="black",c.lineJoin="round",{ctx:c,width:b}}function createPads(a,b,c,d,e){function f(a){return 100*a/6+"%"}var g=document.createElement("div");g.className="padContainer",g.style.width=f(b),g.style.height=f(c),g.style.left=f(d);var h=100/e,i=R.map(function(a){var b=document.createElement("div");return b.className="pad",b.style.width=h+"%",b.style.left=a*h+"%",g.appendChild(b),b},R.range(0,e));return a.appendChild(g),i}function pendulumEoms(a){var b=Math.sin,c=Math.cos,d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=g*g,k=h*h,l=i*i,m=e-d,n=f-e,o=f-d,p=1/(2*c(2*n)+4*c(2*m)-10);return[g,h,i,-(b(2*n+d)-b(2*n-d)-2*l*b(f-2*e+d)+2*l*b(o)+4*b(2*e-d)+4*j*b(2*m)+8*k*b(m)-10*b(d))*p,-(2*j*b(2*f-e-d)+b(2*o-e)+b(2*f-e)+2*k*b(2*n)-2*l*b(f+e-2*d)+6*l*b(n)-4*k*b(2*m)-14*j*b(m)-7*b(e-2*d)-7*b(e))*p,2*(l*b(2*n)+4*k*b(n)+b(f-2*e+2*d)+2*j*b(f-2*e+d)+b(f-2*e)+2*j*b(o)+b(f-2*d)+b(f))*p]}function totalEnergy(a){var b=-cos(a[0]),c=b-cos(a[1]),d=c-cos(a[2]),e=a[3]*cos(a[0]),f=e+a[4]*cos(a[1]),g=f+a[5]*cos(a[2]),h=a[3]*sin(a[0]),i=h+a[4]*sin(a[1]),j=i+a[5]*sin(a[2]);return(e*e+f*f+g*g+h*h+i*i+j*j)/2+b+c+d}function maximumVelocity(a){return Math.sqrt(2*totalEnergy(a)+12)}function jointCoordinates(a){var b=R.scanl(function(a,b){return[a[0]+Math.sin(b),a[1]-Math.cos(b)]},[0,0],R.take(3,a));return R.map(function(a){return{x:a[0],y:a[1]}},b)}function createSynth(a,b,c,d,e){var f=Math.pow(2,1/12),g=a.createGain(),h=R.map(R.divide(void 0,R.sum(d)+1),R.prepend(1,d)),i=R.map(function(c){return createNote(b*Math.pow(f,c),h,a)},c);return R.forEach(function(a){a.connect(g)},i),{master:g,notes:i,envelope:e,ctx:a}}function createNote(a,b,c){var d=c.createGain();d.gain.value=0;return R.forEach(function(b){if(0!==b[1]){var e=c.createOscillator(),f=c.createGain();f.gain.value=b[0],e.frequency.value=a*b[1],e.connect(f),f.connect(d),e.start()}},R.zip(b,R.range(1,b.length+1))),d}function hitNote(a,b){if(!(b>=a.notes.length)){var c=a.ctx.currentTime,d=a.notes[b].gain;d.cancelScheduledValues(c),d.setValueAtTime(0,c),d.linearRampToValueAtTime(1,c+a.envelope.attack),d.linearRampToValueAtTime(0,c+a.envelope.attack+a.envelope.release)}}function startNote(a,b){if(!(b>=a.notes.length)){var c=a.ctx.currentTime,d=a.notes[b].gain;d.cancelScheduledValues(c),d.setValueAtTime(0,c),d.linearRampToValueAtTime(1,c+a.envelope.attack)}}function killNote(a,b){if(!(b>=a.notes.length)){var c=a.ctx.currentTime,d=a.notes[b].gain;d.cancelScheduledValues(c),d.linearRampToValueAtTime(0,c+a.envelope.release)}}function killAllNotes(a){var b=a.ctx.currentTime;R.forEach(function(c){c.gain.cancelScheduledValues(b),c.gain.linearRampToValueAtTime(0,b+a.envelope.release)},a.notes)}function rk4Integrate(a,b,c){var d=R.multiply(b/2),e=R.multiply(b/3),f=R.multiply(b/6),g=a(c),h=a(vecAdd(c,g.map(d))),i=a(vecAdd(c,h.map(d))),j=a(vecAdd(c,i.map(R.multiply(b))));return R.reduce(vecAdd,c,[g.map(f),h.map(e),i.map(e),j.map(f)])}!function(a){"object"==typeof exports?module.exports=a(this):"function"==typeof define&&define.amd?define(a):this.R=a(this)}(function(){"use strict";function a(){return new TypeError("Function called with no arguments")}function b(c,d,e){switch(arguments.length){case 0:throw a();case 1:return b(c,0,c.length);case 2:return b(c,d,c.length);default:for(var f=Math.max(0,e-d),g=new Array(f),h=-1;++h<f;)g[h]=c[d+h];return g}}function c(a,b){a=a||[],b=b||[];var c,d=a.length,e=b.length,f=new Array(d+e);for(c=-1;++c<d;)f[c]=a[c];for(c=-1;++c<e;)f[d+c]=b[c];return f}function d(b){return function(c,d){switch(arguments.length){case 0:throw a();case 1:return function(a){return b(c,a)};default:return b(c,d)}}}function e(b){return function(c,e,f){switch(arguments.length){case 0:throw a();case 1:return d(function(a,d){return b(c,a,d)});case 2:return function(a){return b(c,e,a)};default:return b(c,e,f)}}}function f(a,b){return null!=b&&!T(b)&&"function"==typeof b[a]}function g(a,b){return function(c,d,e){var f=arguments.length,g=arguments[f-1],h=g&&!T(g)&&"function"==typeof g[a];switch(arguments.length){case 0:return b();case 1:return h?g[a]():b(c);case 2:return h?g[a](c):b(c,d);case 3:return h?g[a](c,d):b(c,d,e)}}}function h(a,b){for(var c=-1,d=b.length;++c<d;)a(b[c]);return b}function i(a,b,c){switch(a&&S.call(a)){case"[object Object]":return j(a,{},b,c);case"[object Array]":return j(a,[],b,c);case"[object Function]":return a;case"[object Date]":return new Date(a);default:return a}}function j(a,b,c,d){for(var e=c.length,f=-1;++f<e;)if(a===c[f])return d[f];c.push(a),d.push(b);for(var g in a)b[g]=i(a[g],c,d);return b}function k(a,b){return c([a],b)}function l(a,b){return c(b,[a])}function m(a,b){return function(){return a.call(this,b.apply(this,arguments))}}function n(a,b){return function(){var c=this,d=b.apply(this,arguments);return o(d)?d.then(function(b){return a.call(c,b)}):a.call(this,d)}}function o(a){return null!=a&&a===Object(a)&&a.then&&"function"==typeof a.then}function p(b){return function(){switch(arguments.length){case 0:throw a();case 1:return arguments[0];default:for(var c=arguments.length-1,d=arguments[c],e=d.length;c--;)d=b(arguments[c],d);return bb(e,d)}}}function q(a){return function(c){var d=b(arguments,1);return bb(Math.max(0,c.length-d.length),function(){return c.apply(this,a(d,arguments))})}}function r(a,b){for(var c=-1,d=b.length,e=new Array(d);++c<d;)e[c]=a(b[c]);return e}function s(a,b){for(var c=-1,d=b.length,e=[];++c<d;)a(b[c])&&e.push(b[c]);return e}function t(a,b){for(var c=-1,d=b.length,e=[];++c<d;)a(b[c],c,b)&&e.push(b[c]);return e}function u(a,b){for(var c=-1;++c<b.length;)if(!a(b[c]))return!1;return!0}function v(a,b){for(var c=-1;++c<b.length;)if(a(b[c]))return!0;return!1}function w(a,b,c){var d=0,e=a.length;for("number"==typeof c&&(d=0>c?Math.max(0,e+c):c);e>d;){if(a[d]===b)return d;++d}return-1}function x(a,b,c){var d=a.length;for("number"==typeof c&&(d=0>c?d+c+1:Math.min(d,c+1));--d>=0;)if(a[d]===b)return d;return-1}function y(a,b){return w(b,a)>=0}function z(a,b,c){for(var d=-1,e=c.length;++d<e;)if(a(b,c[d]))return!0;return!1}function A(a){return function b(c){for(var d,e,f,g=[],h=-1,i=c.length;++h<i;)if(U(c[h]))for(d=a?b(c[h]):c[h],e=-1,f=d.length;++e<f;)g.push(d[e]);else g.push(c[h]);return g}}function B(a){return function(b){return r(function(a){return[a,b[a]]},a(b))}}function C(a,b){for(var c,d={},e=Pb(b),f=e.length,g=-1;++g<f;)c=e[g],a(b[c],c,b)&&(d[c]=b[c]);return d}function D(a,b){var c={};return h(function(a){c[a]=b[a]},a),c}function E(a,b){for(var c=Ob(b),d=-1,e=c.length;++d<e;)a[c[d]]=b[c[d]];return a}function F(a,b,c){if(a===c)return!0;if(null==c)return!1;b.fn=b.fn||[],b.obj=b.obj||[];for(var d,e,f=-1,g=b.fn.length,h=-1,i=b.obj.length;++f<g;){if(d=b.fn[f],e=a[d],!(d in c))return!1;if(!e(c[d],c))return!1}for(;++h<i;)if(d=b.obj[h],a[d]!==c[d])return!1;return!0}function G(a){return function(c){var d=function(){var b=arguments;return a(function(a){return a.apply(null,b)},c)};return arguments.length>1?d.apply(null,b(arguments,1)):bb(Wb(Eb("length",c)),d)}}function H(a,b){return a+b}function I(a,b){return a*b}function J(a,b){return b>a}function K(a,b){return a>b}function L(b,c){return function(d){if(0===arguments.length)throw a();for(var e,f=-1,g=c;++f<d.length;)e=+d[f],b(e,g)&&(g=e);return g}}function M(a){return function(b,c){if(c&&c.length>0){for(var d,e=0,f=c[e],g=b(f);++e<c.length;)d=b(c[e]),a(d,g)&&(g=d,f=c[e]);return f}}}function N(a,b){var c,d=-1,e=a.length;if(null!=b){for(c=b;null!=c&&++d<e;)c=c[a[d]];return c}}function O(a,b){return r(function(b){return{key:a(b),val:b}},b)}function P(a){return function(b){return s(function(a){return"function"==typeof b[a]},a(b))}}var Q,R={version:"0.8.0"},S=Object.prototype.toString,T=Array.isArray||function(a){return null!=a&&a.length>=0&&"[object Array]"===S.call(a)},U=R.isArrayLike=function(a){return T(a)?!0:a?"object"!=typeof a?!1:a instanceof String?!1:1===a.nodeType?!!a.length:0===a.length?!0:a.length>0?a.hasOwnProperty(0)&&a.hasOwnProperty(a.length-1):!1:!1};try{Object.defineProperty(R,"__",{writable:!1,value:Q})}catch(V){R.__=Q}var W=R.op=function(b){var c=b.length;if(2!==c)throw new Error("Expected binary function.");return function d(c,e){switch(arguments.length){case 0:throw a();case 1:return c===Q?ab(Z(d)):_(pb(b,c));default:return c===Q?_(qb(b,e)):b(c,e)}}},X=R.curryN=function(b,d){return function e(f){return bb(Math.max(b-(f&&f.length||0),0),function(){if(0===arguments.length)throw a();var g=c(f,arguments);return g.length>=b?d.apply(this,g):e(g)})}([])},Y=R.curry=function(a){return X(a.length,a)},Z=R.flip=function(d){return function(e,f){switch(arguments.length){case 0:throw a();case 1:return function(a){return d.apply(this,[a,e].concat(b(arguments,1)))};default:return d.apply(this,c([f,e],b(arguments,2)))}}},$=R.nAry=function(a,b){switch(a){case 0:return function(){return b.call(this)};case 1:return function(a){return b.call(this,a)};case 2:return function(a,c){return b.call(this,a,c)};case 3:return function(a,c,d){return b.call(this,a,c,d)};case 4:return function(a,c,d,e){return b.call(this,a,c,d,e)};case 5:return function(a,c,d,e,f){return b.call(this,a,c,d,e,f)};case 6:return function(a,c,d,e,f,g){return b.call(this,a,c,d,e,f,g)};case 7:return function(a,c,d,e,f,g,h){return b.call(this,a,c,d,e,f,g,h)};case 8:return function(a,c,d,e,f,g,h,i){return b.call(this,a,c,d,e,f,g,h,i)};case 9:return function(a,c,d,e,f,g,h,i,j){return b.call(this,a,c,d,e,f,g,h,i,j)};case 10:return function(a,c,d,e,f,g,h,i,j,k){return b.call(this,a,c,d,e,f,g,h,i,j,k)};default:return b}},_=R.unary=function(a){return $(1,a)},ab=R.binary=function(a){return $(2,a)},bb=R.arity=function(a,b){switch(a){case 0:return function(){return b.apply(this,arguments)};case 1:return function(){return b.apply(this,arguments)};case 2:return function(){return b.apply(this,arguments)};case 3:return function(){return b.apply(this,arguments)};case 4:return function(){return b.apply(this,arguments)};case 5:return function(){return b.apply(this,arguments)};case 6:return function(){return b.apply(this,arguments)};case 7:return function(){return b.apply(this,arguments)};case 8:return function(){return b.apply(this,arguments)};case 9:return function(){return b.apply(this,arguments)};case 10:return function(){return b.apply(this,arguments)};default:return b}},cb=R.invokerN=function(a,c){var d=b(arguments,2),e=a-d.length;return X(e+1,function(){var a=arguments[e],f=d.concat(b(arguments,0,e));return a[c].apply(a,f)})},db=R.useWith=function(a){var c=b(arguments,1),d=c.length;return Y(bb(d,function(){for(var e=[],f=-1;++f<d;)e.push(c[f](arguments[f]));return a.apply(this,e.concat(b(arguments,d)))}))};R.forEach=d(h),R.forEach.idx=d(function(a,b){for(var c=-1,d=b.length;++c<d;)a(b[c],c,b);return b});var eb=R.clone=function(a){return b(a)};R.cloneDeep=function(a){return i(a,[],[])};var fb=R.isEmpty=function(a){return null==a||0===a.length},gb=R.prepend=d(k);R.cons=gb,R.prependTo=Z(k);var hb=R.nth=d(function(a,b){return 0>a?b[b.length+a]:b[a]}),ib=R.head=hb(0);R.car=ib,R.last=hb(-1);var jb=R.tail=g("tail",function(a){return b(a,1)});R.cdr=jb;var kb=R.append=d(l);R.push=kb,R.appendTo=Z(l),R.concat=d(function(a,b){if(T(b))return c(a,b);if(f("concat",a))return a.concat(b);throw new TypeError("can't concat "+typeof a)});var lb=R.identity=function(a){return a};R.I=lb,R.argN=function(a){return function(){return arguments[a]}};var mb=R.times=d(function(a,b){for(var c=new Array(b),d=-1;++d<b;)c[d]=a(d);return c});R.repeatN=d(function(a,b){return mb(Nb(a),b)}),R.apply=d(function(a,b){return a.apply(this,b)}),R.unapply=function(c){if(0===arguments.length)throw a();return function(){return c(b(arguments))}};var nb=R.compose=p(m),ob=R.pCompose=p(n);R.pipe=function(){return nb.apply(this,Ib(arguments))},R.pPipe=function(){return ob.apply(this,Ib(arguments))};var pb=R.lPartial=q(c),qb=R.rPartial=q(Z(c));R.memoize=function(a){if(!a.length)return rb(a);var c={};return function(){if(arguments.length){var d=tb(function(a,b){return a[b]||(a[b]={})},c,b(arguments,0,arguments.length-1)),e=arguments[arguments.length-1];return d[e]||(d[e]=a.apply(this,arguments))}}};var rb=R.once=function(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments))}};R.wrap=function(a,b){return bb(a.length,function(){return b.apply(this,c([a],arguments))})};var sb=R.constructN=d(function(a,b){var c=function(){var a,c,d=function(){};return d.prototype=b.prototype,a=new d,c=b.apply(a,arguments),Object(c)===c?c:a};return a>1?Y($(a,c)):c});R.construct=function(a){return sb(a.length,a)},R.converge=function(a){var c=b(arguments,1);return function(){var b=arguments;return a.apply(this,r(function(a){return a.apply(this,b)},c))}};var tb=R.reduce=e(function(a,b,c){for(var d=-1,e=c.length;++d<e;)b=a(b,c[d]);return b});R.foldl=tb,R.reduce.idx=e(function(a,b,c){for(var d=-1,e=c.length;++d<e;)b=a(b,c[d],d,c);return b}),R.foldl.idx=tb.idx;var ub=R.reduceRight=e(g("reduceRight",function(a,b,c){for(var d=c.length;d--;)b=a(b,c[d]);return b}));R.foldr=ub,R.reduceRight.idx=e(function(a,b,c){for(var d=c.length;d--;)b=a(b,c[d],d,c);return b}),R.foldr.idx=ub.idx,R.unfoldr=d(function(a,b){for(var c=a(b),d=[];c&&c.length;)d.push(c[0]),c=a(c[1]);return d});var vb=R.map=d(g("map",r));R.map.idx=d(function(a,b){for(var c=-1,d=b.length,e=new Array(d);++c<d;)e[c]=a(b[c],c,b);return e}),R.mapObj=d(function(a,b){return tb(function(c,d){return c[d]=a(b[d]),c},{},Ob(b))}),R.mapObj.idx=d(function(a,b){return tb(function(c,d){return c[d]=a(b[d],d,b),c},{},Ob(b))}),R.scanl=e(function(a,b,c){var d=0,e=c.length+1,f=new Array(e);for(f[d]=b;++d<e;)b=a(b,c[d-1]),f[d]=b;return f});var wb=R.liftN=d(function(c,d){var e=X(c,d);if(0===arguments.length)throw a();return X(c,function(){return tb(xb,r(e,arguments[0]),b(arguments,1))})});R.lift=function(b){if(0===arguments.length)throw a();return wb(b.length,b)};var xb=R.ap=d(function(a,b){return f("ap",a)?a.ap(b):tb(function(a,d){return c(a,r(d,b))},[],a)});R.of=function(a,b){return f("of",b)?b.of(a):[a]},R.empty=function(a){return f("empty",a)?a.empty():[]},R.chain=d(g("chain",function(a,b){return Fb(r(a,b))}));var yb=R.commuteMap=e(function(a,b,c){function d(b,c){return xb(vb(kb,a(c)),b)}return tb(d,b([]),c)});R.commute=yb(vb(lb));var zb=R.size=function(a){return a.length};R.length=zb,R.filter=d(g("filter",s)),R.filter.idx=d(t);var Ab=function(a,b){return s(Tb(a),b)};R.reject=d(Ab),R.reject.idx=d(function(a,b){return t(Tb(a),b)}),R.takeWhile=d(g("takeWhile",function(a,c){for(var d=-1,e=c.length;++d<e&&a(c[d]););return b(c,0,d)})),R.take=d(g("take",function(a,c){return b(c,0,Math.min(a,c.length))})),R.skipUntil=d(function(a,c){for(var d=-1,e=c.length;++d<e&&!a(c[d]););return b(c,d)}),R.skip=d(g("skip",function(a,c){return a<c.length?b(c,a):[]})),R.find=d(function(a,b){for(var c=-1,d=b.length;++c<d;)if(a(b[c]))return b[c]}),R.findIndex=d(function(a,b){for(var c=-1,d=b.length;++c<d;)if(a(b[c]))return c;return-1}),R.findLast=d(function(a,b){for(var c=b.length;c--;)if(a(b[c]))return b[c]}),R.findLastIndex=d(function(a,b){for(var c=b.length;c--;)if(a(b[c]))return c;return-1}),R.every=d(u),R.some=d(v),R.indexOf=d(function(a,b){return w(b,a)}),R.indexOf.from=e(function(a,b,c){return w(c,a,b)}),R.lastIndexOf=d(function(a,b){return x(b,a)}),R.lastIndexOf.from=e(function(a,b,c){return x(c,a,b)}),R.contains=d(y);var Bb=R.containsWith=e(z),Cb=R.uniq=function(a){for(var b,c=-1,d=a.length,e=[];++c<d;)b=a[c],y(b,e)||e.push(b);return e};R.isSet=function(a){for(var b=a.length,c=-1;++c<b;)if(w(a,a[c],c+1)>=0)return!1;return!0};var Db=R.uniqWith=d(function(a,b){for(var c,d=-1,e=b.length,f=[];++d<e;)c=b[d],z(a,c,f)||f.push(c);return f}),Eb=R.pluck=d(function(a,b){return r(Lb(a),b)});R.flatten=A(!0);var Fb=R.unnest=A(!1);R.zipWith=e(function(a,b,c){for(var d=[],e=-1,f=Math.min(b.length,c.length);++e<f;)d[e]=a(b[e],c[e]);return d}),R.zip=d(function(a,b){for(var c=[],d=-1,e=Math.min(a.length,b.length);++d<e;)c[d]=[a[d],b[d]];return c}),R.zipObj=d(function(a,b){for(var c=-1,d=a.length,e={};++c<d;)e[a[c]]=b[c];return e});var Gb=R.fromPairs=function(a){for(var b=-1,c=a.length,d={};++b<c;)T(a[b])&&a[b].length&&(d[a[b][0]]=a[b][1]);return d},Hb=R.createMapEntry=d(function(a,b){var c={};return c[a]=b,c});R.lens=d(function(a,b){var c=function(b){return a(b)};return c.set=b,c.map=function(c,d){return b(c(a(d)),d)},c}),R.xprod=d(function(a,b){if(fb(a)||fb(b))return[];for(var c,d=-1,e=a.length,f=b.length,g=[];++d<e;)for(c=-1;++c<f;)g.push([a[d],b[c]]);return g});var Ib=R.reverse=function(a){for(var b=-1,c=a.length,d=c,e=new Array(c);++b<c;)e[--d]=a[b];return e};R.range=d(function(a,b){if(a>=b)return[];for(var c=0,d=new Array(Math.floor(b)-Math.ceil(a));b>a;)d[c++]=a++;return d}),R.join=cb(1,"join"),R.slice=cb(2,"slice"),R.slice.from=d(function(a,b){return b.slice(a,b.length)}),R.remove=e(function(a,d,e){return c(b(e,0,Math.min(a,e.length)),b(e,Math.min(e.length,a+d)))}),R.insert=e(function(a,d,e){return a=a<e.length&&a>=0?a:e.length,c(l(d,b(e,0,a)),b(e,a))}),R.insert.all=e(function(a,d,e){return a=a<e.length&&a>=0?a:e.length,c(c(b(e,0,a),d),b(e,a))});var Jb=R.comparator=function(a){return function(b,c){return a(b,c)?-1:a(c,b)?1:0}};R.sort=d(function(a,b){return eb(b).sort(a)});var Kb=R.groupBy=d(function(a,b){return tb(function(b,c){var d=a(c);return b[d]=l(c,b[d]||(b[d]=[])),b},{},b)});R.partition=d(function(a,b){return tb(function(b,c){return b[a(c)?0:1].push(c),b},[[],[]],b)}),R.tap=d(function(a,b){return a(b),b}),R.eq=d(function(a,b){return a===b});var Lb=R.prop=function(b,c){switch(arguments.length){case 0:throw a();case 1:return function(a){return a[b]}}return c[b]};R.get=Lb,R.propOf=Z(Lb),R.props=d(function(a,b){for(var c=a.length,d=new Array(c),e=-1;++e<c;)d[e]=b[a[e]];return d});var Mb=Object.prototype.hasOwnProperty;R.propOr=e(function(a,b,c){return Mb.call(c,a)?c[a]:b}),R.has=d(function(a,b){return Mb.call(b,a)}),R.hasIn=d(function(a,b){return a in b}),R.func=function(c,d){switch(arguments.length){case 0:throw a();case 1:return function(a){return a[c].apply(a,b(arguments,1))};default:return d[c].apply(d,b(arguments,2))}};var Nb=R.always=function(a){return function(){return a}};R.bind=d(function(a,b){return function(){return a.apply(b,arguments)}});var Ob=R.keys=function(){var a=!{toString:null}.propertyIsEnumerable("toString"),b=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];return function(c){if(Object(c)!==c)return[];if(Object.keys)return Object.keys(c);var d,e,f=[];for(d in c)Mb.call(c,d)&&f.push(d);if(a)for(e=b.length;e--;)d=b[e],Mb.call(c,d)&&!y(d,f)&&f.push(d);return f}}(),Pb=R.keysIn=function(a){var b,c=[];for(b in a)c.push(b);return c};R.toPairs=B(Ob),R.toPairsIn=B(Pb),R.values=function(a){for(var b=Ob(a),c=b.length,d=new Array(c),e=-1;++e<c;)d[e]=a[b[e]];return d},R.valuesIn=function(a){var b,c=[];for(b in a)c.push(a[b]);return c},R.pick=d(function(a,b){return C(function(b,c){return y(c,a)},b)}),R.omit=d(function(a,b){return C(function(b,c){return!y(c,a)},b)}),R.pickBy=d(C);var Qb=R.pickAll=d(D);R.mixin=d(function(a,b){return E(E({},a),b)}),R.cloneObj=function(a){return E({},a)},R.eqProps=e(function(a,b,c){return b[a]===c[a]}),R.where=function(b,c){var d=Kb(function(a){return"function"==typeof b[a]?"fn":"obj"},Ob(b));switch(arguments.length){case 0:throw a();case 1:return function(a){return F(b,d,a)}}return F(b,d,c)};var Rb=R.assoc=e(function(a,b,c){return E(Gb(r(function(a){return[a,c[a]]},Pb(c))),Hb(a,b))});R.assocPath=function(){var c=function(a,d,e){if(1===a.length)return Rb(a[0],d,e);var f=e[a[0]];return Rb(a[0],c(b(a,1),d,Sb(Object,f)?f:{}),e)};return function(b,e,f){var g=arguments.length;if(0===g)throw a();var h=Yb(".",b),i=d(function(a,b){return c(h,a,b)});switch(g){case 1:return i;case 2:return i(e);default:return i(e,f)}}}(),R.installTo=function(a){return E(a,R)};var Sb=R.is=d(function(a,b){return null!=b&&b.constructor===a||b instanceof a});R.type=function(a){return null===a?"Null":void 0===a?"Undefined":S.call(a).slice(8,-1)},R.alwaysZero=Nb(0),R.alwaysFalse=Nb(!1),R.alwaysTrue=Nb(!0),R.and=d(function(a,b){return function(){return a.apply(this,arguments)&&b.apply(this,arguments)}}),R.or=d(function(a,b){return function(){return a.apply(this,arguments)||b.apply(this,arguments)}});var Tb=R.not=function(a){return function(){return!a.apply(this,arguments)}};R.allPredicates=G(u),R.anyPredicates=G(v);var Ub=R.ifElse=e(function(a,b,c){return function(){return a.apply(this,arguments)?b.apply(this,arguments):c.apply(this,arguments)}});R.if=Ub,R.cond=function(){var a=arguments;return function(){for(var b=-1;++b<a.length;)if(a[b][0].apply(this,arguments))return a[b][1].apply(this,arguments)}},R.add=d(H),R.multiply=d(I),R.subtract=W(function(a,b){return a-b}),R.divide=W(function(a,b){return a/b}),R.modulo=W(function(a,b){return a%b});var Vb=Number.isInteger||function(a){return a<<0===a};R.mathMod=W(function(a,b){return Vb(a)?!Vb(b)||1>b?0/0:(a%b+b)%b:0/0}),R.sum=tb(H,0),R.product=tb(I,1),R.lt=W(J),R.lte=W(function(a,b){return b>=a}),R.gt=W(K),R.gte=W(function(a,b){return a>=b});var Wb=R.max=L(K,-1/0);R.maxBy=d(M(K)),R.min=L(J,1/0),R.minBy=d(M(J));var Xb=R.substring=cb(2,"substring");R.substringFrom=Z(Xb)(void 0),R.substringTo=Xb(0),R.charAt=cb(1,"charAt"),R.charCodeAt=cb(1,"charCodeAt"),R.match=cb(1,"match"),R.replace=e(function(a,b,c){return c.replace(a,b)}),R.strIndexOf=d(function(a,b){return b.indexOf(a)}),R.strLastIndexOf=d(function(a,b){return b.lastIndexOf(a)}),R.toUpperCase=cb(0,"toUpperCase"),R.toLowerCase=cb(0,"toLowerCase"),R.trim=function(){var a="	\n
\f\r   ᠎             　\u2028\u2029",b="​",c="function"==typeof String.prototype.trim;return c&&!a.trim()&&b.trim()?function(a){return a.trim()}:function(b){var c=new RegExp("^["+a+"]["+a+"]*"),d=new RegExp("["+a+"]["+a+"]*$");return b.replace(c,"").replace(d,"")}}();var Yb=R.split=cb(1,"split"),Zb=R.pathOn=e(function(a,b,c){return N(b.split(a),c)});R.path=Zb("."),R.pathEq=e(function(a,b,c){return N(a.split("."),c)===b}),R.project=db(r,Qb,lb),R.propEq=e(function(a,b,c){return c[a]===b}),R.union=nb(Cb,c),R.unionWith=e(function(a,b,d){return Db(a,c(b,d))}),R.difference=d(function(a,b){for(var c=[],d=-1,e=a.length;++d<e;)y(a[d],b)||y(a[d],c)||c.push(a[d]);return c}),R.differenceWith=e(function(a,b,c){for(var d=[],e=-1,f=b.length,g=Bb(a);++e<f;)g(b[e],c)||g(b[e],d)||d.push(b[e]);return d}),R.intersection=d(function(a,b){return Cb(s(Z(y)(a),b))}),R.intersectionWith=e(function(a,b,c){for(var d=[],e=-1;++e<b.length;)z(a,b[e],c)&&(d[d.length]=b[e]);return Db(a,d)});var $b=Jb(function(a,b){return a.key<b.key});return R.sortBy=d(function(a,b){return Eb("val",O(a,b).sort($b))}),R.countBy=d(function(a,b){return tb(function(a,b){return a[b.key]=(a[b.key]||0)+1,a},{},O(a,b))}),R.functions=P(Ob),R.functionsIn=P(Pb),R}),window.addEventListener("load",function(){function a(){R.forEach(function(a){var b=setupCanvas(a.canvas);a.ctx=b.ctx,a.canvasWidth=b.width},c)}var b=new window.AudioContext,c=R.map(function(a){var c=document.getElementById(a.container),d=c.getElementsByTagName("canvas")[0],e=createPads(c,a.kbdWidth,a.kbdHeight,3-a.kbdWidth/2,a.synthParams.tuning.length),f=a.synthParams,g=createSynth(b,f.baseFreq,f.tuning,f.harmonics,f.envelope);g.master.gain.value=f.gain,g.master.connect(b.destination);var h=R.zipWith(function(a,b){return a+b*(2*Math.random()-1)},a.initialState.means,a.initialState.deltas);return{config:a,canvas:d,pads:e,synth:g,state:h,note:null,justHit:!1,trajectory:[]}},config.pendulums);a(),window.addEventListener("resize",a),window.requestAnimationFrame(function(a){simulate(a,a,0,c,{lockupLimit:config.lockupLimit,stepSize:config.stepSize})})});var halfPi=Math.PI/2,config={stepSize:10,lockupLimit:500,pendulums:[{container:"melodyContainer",initialState:{means:[halfPi+.3,halfPi+.3,halfPi+.3,0,0,0],deltas:[.1,.2,.3,0,0,0]},timeScale:.003,trajectoryLength:70,kbdWidth:5.7,kbdHeight:2,synthParams:{gain:.2,baseFreq:440,tuning:[0,1,3,5,7,8,10,12],envelope:{attack:.015,release:.35},harmonics:[.3,.1,.3,.1,.3]}},{container:"bassContainer",initialState:{means:[halfPi,halfPi,halfPi,0,0,0],deltas:[.1,.2,.3,0,0,0]},timeScale:.002,trajectoryLength:70,kbdWidth:5.7,kbdHeight:2.5,synthParams:{gain:.2,baseFreq:110,tuning:[0,5,7,12],envelope:{attack:.03,release:.7},harmonics:[.2,.3,.2,.15,.1]}}]},vecAdd=R.zipWith(R.add);
{'fraction_non_alphanumeric': 0.30329475990926913, 'fraction_numerical': 0.019280304486563378, 'mean_word_length': 14.98740012292563, 'pattern_counts': {'":': 14, '<': 111, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7172506', 'n_tokens_mistral': 25107, 'n_tokens_neox': 24693, 'n_words': 1364}