UNPKG

crossbrowdy

Version:

A Multimedia JavaScript framework to create real cross-platform and hybrid game engines, games, emulators, multimedia libraries and apps.

3 lines 145 kB
var _timbreJSInitializer=function(){//CrossBrowdy modification to be able to initialize the library after an user-driven event (as onClick, etc.). !function(a){"use strict";var b=function(){return r.apply(null,arguments)},c=Array.prototype.slice,d=0,e=1,f=2,g=3,h=[8e3,11025,12e3,16e3,22050,24e3,32e3,44100,48e3],i=[32,64,128,256],j="14.10.12",k=null,l={},m={},n="undefined"!=typeof window?"browser":"undefined"!=typeof module&&module.exports?"node":"unknown",o="browser"===n&&/(iPhone|iPad|iPod|Android)/i.test(navigator.userAgent),p=!1,q=120,r=function(){var b,d,e=c.call(arguments),f=e[0];switch(typeof f){case"string":l[f]?b=new l[f](e.slice(1)):m[f]?b=m[f](e.slice(1)):(d=/^(.+?)(?:\.(ar|kr))?$/.exec(f),d&&(f=d[1],l[f]?b=new l[f](e.slice(1)):m[f]&&(b=m[f](e.slice(1))),b&&d[2]&&b[d[2]]()));break;case"number":b=new D(e);break;case"boolean":b=new E(e);break;case"function":b=new F(e);break;case"object":if(null!==f){if(f instanceof A)return f;if(f.context instanceof A)return f.context;v(f)?b=new H(e):u(f)&&(b=new G(e))}}b===a&&(b=new C(e.slice(1)),console.warn('T("'+f+'") is not defined.'));var g=b._;return g.originkey=f,g.meta=s(b),g.emit("init"),b},s=function(a){for(var b,c,d=a._.meta,e=a;null!==e&&e.constructor!==Object;){b=Object.getOwnPropertyNames(e);for(var f=0,g=b.length;g>f;++f)d[b[f]]||(/^(constructor$|process$|_)/.test(b[f])?d[b[f]]="ignore":(c=Object.getOwnPropertyDescriptor(e,b[f]),"function"==typeof c.value?d[b[f]]="function":(c.get||c.set)&&(d[b[f]]="property")));e=Object.getPrototypeOf(e)}return d};Object.defineProperties(b,{version:{value:j},envtype:{value:n},envmobile:{value:o},env:{get:function(){return k.impl.env}},samplerate:{get:function(){return k.samplerate}},channels:{get:function(){return k.channels}},cellsize:{get:function(){return k.cellsize}},currentTime:{get:function(){return k.currentTime}},isPlaying:{get:function(){return k.status===e}},isRecording:{get:function(){return k.status===g}},amp:{set:function(a){"number"==typeof a&&(k.amp=a)},get:function(){return k.amp}},bpm:{set:function(a){"number"==typeof a&&a>=5&&300>=a&&(q=a)},get:function(){return q}}}),b.bind=function(a,c){return k.bind(a,c),b},b.setup=function(a){return k.setup(a),b},b.play=function(){return k.play(),b},b.pause=function(){return k.pause(),b},b.reset=function(){return k.reset(),k.events.emit("reset"),b},b.on=b.addListener=function(a,c){return k.on(a,c),b},b.once=function(a,c){return k.once(a,c),b},b.off=b.removeListener=function(a,c){return k.off(a,c),b},b.removeAllListeners=function(a){return k.removeAllListeners(a),b},b.listeners=function(a){return k.listeners(a)},b.rec=function(){return k.rec.apply(k,arguments)},b.timevalue=function(){var a=function(a){var b,c=q;return(b=/^bpm(\d+(?:\.\d+)?)/i.exec(a))&&(c=Math.max(5,Math.min(300,+(b[1]||0)))),c};return function(c){var d,e,f;if(d=/^(\d+(?:\.\d+)?)Hz$/i.exec(c))return 0===+d[1]?0:1e3/+d[1];if(d=/L(\d+)?(\.*)$/i.exec(c))return e=60/a(c)*(4/(d[1]||4))*1e3,e*=[1,1.5,1.75,1.875][(d[2]||"").length]||1;if(d=/^(\d+(?:\.\d+)?|\.(?:\d+))(min|sec|m)s?$/i.exec(c))switch(d[2]){case"min":return 60*+(d[1]||0)*1e3;case"sec":return 1e3*+(d[1]||0);case"m":return+(d[1]||0)}return(d=/^(?:([0-5]?[0-9]):)?(?:([0-5]?[0-9]):)(?:([0-5]?[0-9]))(?:\.([0-9]{1,3}))?$/.exec(c))?(f=3600*(d[1]||0)+60*(d[2]||0)+(d[3]||0),f=1e3*f+(0|((d[4]||"")+"00").substr(0,3))):(d=/(\d+)\.(\d+)\.(\d+)$/i.exec(c))?(f=480*(4*d[1]+ +d[2])+ +d[3],60/a(c)*(f/480)*1e3):(d=/(\d+)ticks$/i.exec(c))?60/a(c)*(d[1]/480)*1e3:(d=/^(\d+)samples(?:\/(\d+)Hz)?$/i.exec(c))?1e3*d[1]/(d[2]||b.samplerate):0}}();var t=b.fn={SignalArray:Float32Array,currentTimeIncr:0,emptycell:null,FINISHED_STATE:d,PLAYING_STATE:e,UNSCHEDULED_STATE:f,SCHEDULED_STATE:g},u=t.isArray=Array.isArray,v=t.isDictionary=function(a){return"object"==typeof a&&a.constructor===Object};t.nop=function(){return this},t.isSignalArray=function(a){return a instanceof t.SignalArray?!0:Array.isArray(a)&&a.__klass&&2===a.__klass.type?!0:!1},t.extend=function(a,b){function c(){this.constructor=a}b=b||A;for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},t.constructorof=function(a,b){for(var c=a&&a.prototype;c;){if(c===b.prototype)return!0;c=Object.getPrototypeOf(c)}return!1},t.register=function(a,b){t.constructorof(b,A)?l[a]=b:m[a]=b},t.alias=function(a,b){l[b]?l[a]=l[b]:m[b]&&(m[a]=m[b])},t.getClass=function(a){return l[a]},t.pointer=function(a,b,c){return b=a.byteOffset+b*a.constructor.BYTES_PER_ELEMENT,"number"==typeof c?new a.constructor(a.buffer,b,c):new a.constructor(a.buffer,b)},t.nextTick=function(a){return k.nextTick(a),b},t.fixAR=function(a){a._.ar=!0,a._.aronly=!0},t.fixKR=function(a){a._.ar=!1,a._.kronly=!0},t.changeWithValue=function(){var a=this._,b=a.value*a.mul+a.add;isNaN(b)&&(b=0);for(var c=this.cells[0],d=0,e=c.length;e>d;++d)c[d]=b},t.changeWithValue.unremovable=!0,t.clone=function(a){var b=new a.constructor([]);return b._.ar=a._.ar,b._.mul=a._.mul,b._.add=a._.add,b._.bypassed=a._.bypassed,b},t.timer=function(){var a=function(a){return function(){-1===k.timers.indexOf(a)&&(k.timers.push(a),k.events.emit("addObject"),a._.emit("start"),t.buddies_start(a))}},b=function(a){return function(){var b=k.timers.indexOf(a);-1!==b&&(k.timers.splice(b,1),a._.emit("stop"),k.events.emit("removeObject"),t.buddies_stop(a))}};return function(c){var d=a(c),e=b(c);return c.nodeType=A.TIMER,c.start=function(){return k.nextTick(d),c},c.stop=function(){return k.nextTick(e),c},c}}(),t.listener=function(){var a=function(a){return function(){-1===k.listeners.indexOf(a)&&(k.listeners.push(a),k.events.emit("addObject"),a._.emit("listen"),t.buddies_start(a))}},b=function(a){return function(){var b=k.listeners.indexOf(a);-1!==b&&(k.listeners.splice(b,1),a._.emit("unlisten"),k.events.emit("removeObject"),t.buddies_stop(a))}};return function(c){var d=a(c),e=b(c);return c.nodeType=A.LISTENER,c.listen=function(){return arguments.length&&c.append.apply(c,arguments),c.nodes.length&&k.nextTick(d),c},c.unlisten=function(){return arguments.length&&c.remove.apply(c,arguments),c.nodes.length||k.nextTick(e),c},c}}(),t.make_onended=function(a,b){return function(){if(a.playbackState=d,"number"==typeof b)for(var c=a.cells[0],e=a.cells[1],f=a.cells[2],g=0,h=e.length;h>g;++g)c[0]=e[g]=f[g]=b;a._.emit("ended")}},t.inputSignalAR=function(a){var b,c,d,f,g,h,i=a.cells[0],j=a.cells[1],k=a.cells[2],l=a.nodes,m=l.length,n=i.length,o=a.tickID;if(2===a.numChannels){if(d=!0,0!==m){for(b=0;m>b;++b)if(l[b].playbackState===e){l[b].process(o),j.set(l[b].cells[1]),k.set(l[b].cells[2]),d=!1,++b;break}for(;m>b;++b)if(l[b].playbackState===e)for(l[b].process(o),g=l[b].cells[1],h=l[b].cells[2],c=n;c;)c-=8,j[c]+=g[c],k[c]+=h[c],j[c+1]+=g[c+1],k[c+1]+=h[c+1],j[c+2]+=g[c+2],k[c+2]+=h[c+2],j[c+3]+=g[c+3],k[c+3]+=h[c+3],j[c+4]+=g[c+4],k[c+4]+=h[c+4],j[c+5]+=g[c+5],k[c+5]+=h[c+5],j[c+6]+=g[c+6],k[c+6]+=h[c+6],j[c+7]+=g[c+7],k[c+7]+=h[c+7]}d&&(j.set(t.emptycell),k.set(t.emptycell))}else{if(d=!0,0!==m){for(b=0;m>b;++b)if(l[b].playbackState===e){l[b].process(o),i.set(l[b].cells[0]),d=!1,++b;break}for(;m>b;++b)if(l[b].playbackState===e)for(f=l[b].process(o).cells[0],c=n;c;)c-=8,i[c]+=f[c],i[c+1]+=f[c+1],i[c+2]+=f[c+2],i[c+3]+=f[c+3],i[c+4]+=f[c+4],i[c+5]+=f[c+5],i[c+6]+=f[c+6],i[c+7]+=f[c+7]}d&&i.set(t.emptycell)}},t.inputSignalKR=function(a){var b,c=a.nodes,d=c.length,f=a.tickID,g=0;for(b=0;d>b;++b)c[b].playbackState===e&&(g+=c[b].process(f).cells[0][0]);return g},t.outputSignalAR=function(a){var b,c=a.cells[0],d=a.cells[1],e=a.cells[2],f=a._.mul,g=a._.add;if(2===a.numChannels)for(b=c.length;b;)b-=8,d[b]=d[b]*f+g,e[b]=e[b]*f+g,d[b+1]=d[b+1]*f+g,e[b+1]=e[b+1]*f+g,d[b+2]=d[b+2]*f+g,e[b+2]=e[b+2]*f+g,d[b+3]=d[b+3]*f+g,e[b+3]=e[b+3]*f+g,d[b+4]=d[b+4]*f+g,e[b+4]=e[b+4]*f+g,d[b+5]=d[b+5]*f+g,e[b+5]=e[b+5]*f+g,d[b+6]=d[b+6]*f+g,e[b+6]=e[b+6]*f+g,d[b+7]=d[b+7]*f+g,e[b+7]=e[b+7]*f+g,c[b]=.5*(d[b]+e[b]),c[b+1]=.5*(d[b+1]+e[b+1]),c[b+2]=.5*(d[b+2]+e[b+2]),c[b+3]=.5*(d[b+3]+e[b+3]),c[b+4]=.5*(d[b+4]+e[b+4]),c[b+5]=.5*(d[b+5]+e[b+5]),c[b+6]=.5*(d[b+6]+e[b+6]),c[b+7]=.5*(d[b+7]+e[b+7]);else if(1!==f||0!==g)for(b=c.length;b;)b-=8,c[b]=c[b]*f+g,c[b+1]=c[b+1]*f+g,c[b+2]=c[b+2]*f+g,c[b+3]=c[b+3]*f+g,c[b+4]=c[b+4]*f+g,c[b+5]=c[b+5]*f+g,c[b+6]=c[b+6]*f+g,c[b+7]=c[b+7]*f+g},t.outputSignalKR=function(a){var b,c=a.cells[0],d=a.cells[1],e=a.cells[2],f=a._.mul,g=a._.add,h=c[0]*f+g;if(2===a.numChannels)for(b=c.length;b;)b-=8,c[b]=c[b+1]=c[b+2]=c[b+3]=c[b+4]=c[b+5]=c[b+6]=c[b+7]=d[b]=d[b+1]=d[b+2]=d[b+3]=d[b+4]=d[b+5]=d[b+6]=d[b+7]=e[b]=e[b+1]=e[b+2]=e[b+3]=e[b+4]=e[b+5]=e[b+6]=e[b+7]=h;else for(b=c.length;b;)b-=8,c[b]=c[b+1]=c[b+2]=c[b+3]=c[b+4]=c[b+5]=c[b+6]=c[b+7]=h},t.buddies_start=function(a){var b,c,d,e=a._.buddies;for(c=0,d=e.length;d>c;++c)switch(b=e[c],b.nodeType){case A.DSP:b.play();break;case A.TIMER:b.start();break;case A.LISTENER:b.listen()}},t.buddies_stop=function(a){var b,c,d,e=a._.buddies;for(c=0,d=e.length;d>c;++c)switch(b=e[c],b.nodeType){case A.DSP:b.pause();break;case A.TIMER:b.stop();break;case A.LISTENER:b.unlisten()}},t.fix_iOS6_1_problem=function(a){k.fix_iOS6_1_problem(a)};var w,x=b.modules={},y=x.EventEmitter=function(){function a(a){this.context=a,this.events={}}var b=a.prototype;return b.emit=function(a){var b=this.events[a];if(!b)return!1;var d;if("function"==typeof b){switch(arguments.length){case 1:b.call(this.context);break;case 2:b.call(this.context,arguments[1]);break;case 3:b.call(this.context,arguments[1],arguments[2]);break;default:d=c.call(arguments,1),b.apply(this.context,d)}return!0}if(u(b)){d=c.call(arguments,1);for(var e=b.slice(),f=0,g=e.length;g>f;++f)e[f]instanceof A?e[f].bang.apply(e[f],d):e[f].apply(this.context,d);return!0}return b instanceof A?(d=c.call(arguments,1),void b.bang.apply(b,d)):!1},b.on=function(a,b){if("function"!=typeof b&&!(b instanceof A))throw new Error("addListener takes instances of Function or timbre.Object");var c=this.events;return c[a]?u(c[a])?c[a].push(b):c[a]=[c[a],b]:c[a]=b,this},b.once=function(a,b){var c,d=this;if("function"==typeof b)c=function(){d.off(a,c),b.apply(d.context,arguments)};else{if(!(b instanceof A))throw new Error("once takes instances of Function or timbre.Object");c=function(){d.off(a,c),b.bang.apply(b,arguments)}}return c.listener=b,d.on(a,c),this},b.off=function(a,b){if("function"!=typeof b&&!(b instanceof A))throw new Error("removeListener takes instances of Function or timbre.Object");var c=this.events;if(!c[a])return this;var d=c[a];if(u(d)){for(var e=-1,f=0,g=d.length;g>f;++f)if(d[f]===b||d[f].listener&&d[f].listener===b){e=f;break}if(0>e)return this;d.splice(e,1),0===d.length&&(c[a]=null)}else(d===b||d.listener&&d.listener===b)&&(c[a]=null);return this},b.removeAllListeners=function(a){var b=this.events,c=!1,d=b[a];if(u(d))for(var e=d.length;e--;){var f=d[e];f.unremovable?c=!0:this.off(a,f)}else d&&(d.unremovable?c=!0:this.off(a,d));return c||(b[a]=null),this},b.listeners=function(a){var b,c=this.events;if(!c[a])return[];if(c=c[a],!u(c))return c.unremovable?[]:[c];c=c.slice(),b=[];for(var d=0,e=c.length;e>d;++d)c[d].unremovable||b.push(c[d]);return b},a}(),z=x.Deferred=function(){function a(a){this.context=a||this,this._state="pending",this._doneList=[],this._failList=[],this._promise=new b(this)}function b(a){this.context=a.context,this.then=a.then,this.done=function(){return a.done.apply(a,arguments),this},this.fail=function(){return a.fail.apply(a,arguments),this},this.pipe=function(){return a.pipe.apply(a,arguments)},this.always=function(){return a.always.apply(a,arguments),this},this.promise=function(){return this},this.isResolved=function(){return a.isResolved()},this.isRejected=function(){return a.isRejected()}}var d=a.prototype,e=function(a,b,c,d){if("pending"===this._state){this._state=a;for(var e=0,f=b.length;f>e;++e)b[e].apply(c,d);this._doneList=this._failList=null}},f=function(a){return a&&"function"==typeof a.promise};return d.resolve=function(){var a=c.call(arguments,0);return e.call(this,"resolved",this._doneList,this.context||this,a),this},d.resolveWith=function(a){var b=c.call(arguments,1);return e.call(this,"resolved",this._doneList,a,b),this},d.reject=function(){var a=c.call(arguments,0);return e.call(this,"rejected",this._failList,this.context||this,a),this},d.rejectWith=function(a){var b=c.call(arguments,1);return e.call(this,"rejected",this._failList,a,b),this},d.promise=function(){return this._promise},d.done=function(){for(var a=c.call(arguments),b="resolved"===this._state,d="pending"===this._state,e=this._doneList,f=0,g=a.length;g>f;++f)"function"==typeof a[f]&&(b?a[f]():d&&e.push(a[f]));return this},d.fail=function(){for(var a=c.call(arguments),b="rejected"===this._state,d="pending"===this._state,e=this._failList,f=0,g=a.length;g>f;++f)"function"==typeof a[f]&&(b?a[f]():d&&e.push(a[f]));return this},d.always=function(){return this.done.apply(this,arguments),this.fail.apply(this,arguments),this},d.then=function(a,b){return this.done(a).fail(b)},d.pipe=function(b,d){var e=this,g=new a(this.context);return this.done(function(){var a=b.apply(e.context,arguments);f(a)?a.then(function(){var b=c.call(arguments);g.resolveWith.apply(g,[a].concat(b))}):g.resolveWith(e,a)}),this.fail(function(){if("function"==typeof d){var a=d.apply(e.context,arguments);f(a)&&a.fail(function(){var b=c.call(arguments);g.rejectWith.apply(g,[a].concat(b))})}else g.reject.apply(g,arguments)}),g.promise()},d.isResolved=function(){return"resolved"===this._state},d.isRejected=function(){return"rejected"===this._state},d.state=function(){return this._state},a.when=function(b){var d=0,e=c.call(arguments),g=e.length,h=g;1!==g||f(b)||(h=0);var i=1===h?b:new a,j=function(a,b){return function(d){b[a]=arguments.length>1?c.call(arguments):d,--h||i.resolve.apply(i,b)}};if(g>1)for(var k=new Array(g),l=function(){i.reject()};g>d;++d)e[d]&&f(e[d])?e[d].promise().done(j(d,k)).fail(l):(k[d]=e[d],--h);return h||i.resolve.apply(i,e),i.promise()},a}(),A=b.Object=function(){function d(a,c){this._={};var f=this._.events=new y(this);if(this._.emit=function(){return f.emit.apply(f,arguments)},v(c[0])){var g=c.shift(),h=g["in"];this.once("init",function(){this.set(g),h&&(u(h)?this.append.apply(this,h):h instanceof d&&this.append(h))})}switch(this.tickID=-1,this.nodes=c.map(b),this.cells=[],this.numChannels=a,a){case 0:this.L=this.R=new B(null),this.cells[0]=this.cells[1]=this.cells[2]=this.L.cell;break;case 1:this.L=this.R=new B(this),this.cells[0]=this.cells[1]=this.cells[2]=this.L.cell;break;case 2:this.L=new B(this),this.R=new B(this),this.cells[0]=new t.SignalArray(k.cellsize),this.cells[1]=this.L.cell,this.cells[2]=this.R.cell}this.playbackState=e,this.nodeType=d.DSP,this._.ar=!0,this._.mul=1,this._.add=0,this._.dac=null,this._.bypassed=!1,this._.meta={},this._.samplerate=k.samplerate,this._.cellsize=k.cellsize,this._.buddies=[]}d.DSP=1,d.TIMER=2,d.LISTENER=3;var f=d.prototype;return Object.defineProperties(f,{isAr:{get:function(){return this._.ar}},isKr:{get:function(){return!this._.ar}},isBypassed:{get:function(){return this._.bypassed}},isEnded:{get:function(){return!(1&this.playbackState)}},mul:{set:function(a){"number"==typeof a&&(this._.mul=a,this._.emit("setMul",a))},get:function(){return this._.mul}},add:{set:function(a){"number"==typeof a&&(this._.add=a,this._.emit("setAdd",a))},get:function(){return this._.add}},buddies:{set:function(a){u(a)||(a=[a]),this._.buddies=a.filter(function(a){return a instanceof d})},get:function(){return this._.buddies}}}),f.toString=function(){return this.constructor.name},f.valueOf=function(){return k.tickID!==this.tickID&&this.process(k.tickID),this.cells[0][0]},f.append=function(){if(arguments.length>0){var a=c.call(arguments).map(b);this.nodes=this.nodes.concat(a),this._.emit("append",a)}return this},f.appendTo=function(a){return a.append(this),this},f.remove=function(){if(arguments.length>0){for(var a,b=this.nodes,c=[],d=0,e=arguments.length;e>d;++d)-1!==(a=b.indexOf(arguments[d]))&&(c.push(b[a]),b.splice(a,1));c.length>0&&this._.emit("remove",c)}return this},f.removeFrom=function(a){return a.remove(this),this},f.removeAll=function(){var a=this.nodes.slice();return this.nodes=[],a.length>0&&this._.emit("remove",a),this},f.removeAtIndex=function(a){var b=this.nodes[a];return b&&(this.nodes.splice(a,1),this._.emit("remove",[b])),this},f.postMessage=function(a){return this._.emit("message",a),this},f.to=function(a){if(a instanceof d)a.append(this);else{var b=c.call(arguments);v(b[1])?b.splice(2,0,this):b.splice(1,0,this),a=r.apply(null,b)}return a},f.splice=function(a,b,c){var e;return b?b instanceof d&&(e=b.nodes.indexOf(c),-1!==e&&b.nodes.splice(e,1),a instanceof d?(a.nodes.push(this),b.nodes.push(a)):b.nodes.push(this)):this._.dac&&(a instanceof d?c instanceof d?c._.dac&&(c._.dac._.node=a,a._.dac=c._.dac,c._.dac=null,a.nodes.push(this)):this._.dac&&(this._.dac._.node=a,a._.dac=this._.dac,this._.dac=null,a.nodes.push(this)):c instanceof d&&c._.dac&&(c._.dac._.node=this,this._.dac=c._.dac,c._.dac=null)),this},f.on=f.addListener=function(a,b){return this._.events.on(a,b),this},f.once=function(a,b){return this._.events.once(a,b),this},f.off=f.removeListener=function(a,b){return this._.events.off(a,b),this},f.removeAllListeners=function(a){return this._.events.removeAllListeners(a),this},f.listeners=function(a){return this._.events.listeners(a)},f.set=function(a,b){var c,d,e=this._.meta;switch(typeof a){case"string":switch(e[a]){case"property":this[a]=b;break;case"function":this[a](b);break;default:for(c=this;null!==c;)d=Object.getOwnPropertyDescriptor(c,a),d&&("function"==typeof d.value?(e[a]="function",this[a](b)):(d.get||d.set)&&(e[a]="property",this[a]=b)),c=Object.getPrototypeOf(c)}break;case"object":for(c in a)this.set(c,a[c])}return this},f.get=function(a){return"property"===this._.meta[a]?this[a]:void 0},f.bang=function(){return this._.emit.apply(this,["bang"].concat(c.call(arguments))),this},f.process=t.nop,f.bypass=function(){return this._.bypassed=0===arguments.length?!0:!!arguments[0],this},f.play=function(){var a=this._.dac;return null===a&&(a=this._.dac=new I(this)),a.play()&&this._.emit.apply(this,["play"].concat(c.call(arguments))),t.buddies_start(this),this},f.pause=function(){var a=this._.dac;return a&&a.playbackState===e&&(a.pause(),this._.dac=null,this._.emit("pause")),t.buddies_stop(this),this},f.start=f.stop=f.listen=f.unlisten=function(){return this},f.ar=function(){return(0===arguments.length?0:!arguments[0])?this.kr(!0):this._.kronly||(this._.ar=!0,this._.emit("ar",!0)),this},f.kr=function(){return(0===arguments.length?0:!arguments[0])?this.ar(!0):this._.aronly||(this._.ar=!1,this._.emit("ar",!1)),this},f.plot="browser"===n?function(b){var c=this._,d=b.target;if(!d)return this;var e,f=b.width||d.width||320,g=b.height||d.height||240,h=(b.x||0)+.5,i=b.y||0,j=d.getContext("2d");e=b.foreground!==a?b.foreground:c.plotForeground||"rgb( 0, 128, 255)";var k;k=b.background!==a?b.background:c.plotBackground||"rgb(255, 255, 255)";var l,m,n,o,p,q=b.lineWidth||c.plotLineWidth||1,r=!!c.plotCyclic,s=c.plotData||this.cells[0],t=b.range||c.plotRange||[-1.2,1.2],u=t[0],v=g/(t[1]-u),w=f/s.length,x=s.length;if(j.save(),j.rect(h,i,f,g),null!==k&&(j.fillStyle=k,j.fillRect(h,i,f,g)),c.plotBefore&&c.plotBefore.call(this,j,h,i,f,g),c.plotBarStyle)for(j.fillStyle=e,l=0,p=0;x>p;++p)n=(s[p]-u)*v,m=g-n,j.fillRect(l+h,m+i,w,n),l+=w;else{for(j.strokeStyle=e,j.lineWidth=q,j.beginPath(),l=0,o=g-(s[0]-u)*v,j.moveTo(l+h,o+i),p=1;x>p;++p)l+=w,m=g-(s[p]-u)*v,j.lineTo(l+h,m+i);r?j.lineTo(l+w+h,o+i):j.lineTo(l+w+h,m+i),j.stroke()}c.plotAfter&&c.plotAfter.call(this,j,h,i,f,g);var y=b.border||c.plotBorder;return y&&(j.strokeStyle="string"==typeof y?y:"#000",j.lineWidth=1,j.strokeRect(h,i,f,g)),j.restore(),this}:t.nop,d}(),B=b.ChannelObject=function(){function a(a){b.Object.call(this,-1,[]),t.fixAR(this),this._.parent=a,this.cell=new t.SignalArray(k.cellsize),this.L=this.R=this,this.cells[0]=this.cells[1]=this.cells[2]=this.cell,this.numChannels=1}return t.extend(a),a.prototype.process=function(a){return this.tickID!==a&&(this.tickID=a,this._.parent&&this._.parent.process(a)),this},a}(),C=function(){function a(a){A.call(this,2,a)}return t.extend(a),a.prototype.process=function(a){var b=this._;return this.tickID!==a&&(this.tickID=a,b.ar?(t.inputSignalAR(this),t.outputSignalAR(this)):(this.cells[0][0]=t.inputSignalKR(this),t.outputSignalKR(this))),this},t.register("+",a),a}(),D=function(){function a(a){if(A.call(this,1,[]),t.fixKR(this),this.value=a[0],v(a[1])){var b=a[1];this.once("init",function(){this.set(b)})}this.on("setAdd",t.changeWithValue),this.on("setMul",t.changeWithValue)}t.extend(a);var b=a.prototype;return Object.defineProperties(b,{value:{set:function(a){"number"==typeof a&&(this._.value=isNaN(a)?0:a,t.changeWithValue.call(this))},get:function(){return this._.value}}}),a}(),E=function(){function a(a){if(A.call(this,1,[]),t.fixKR(this),this.value=a[0],v(a[1])){var b=a[1];this.once("init",function(){this.set(b)})}this.on("setAdd",t.changeWithValue),this.on("setMul",t.changeWithValue)}t.extend(a);var b=a.prototype;return Object.defineProperties(b,{value:{set:function(a){this._.value=a?1:0,t.changeWithValue.call(this)},get:function(){return!!this._.value}}}),a}(),F=function(){function a(a){if(A.call(this,1,[]),t.fixKR(this),this.func=a[0],this._.value=0,v(a[1])){var b=a[1];this.once("init",function(){this.set(b)})}this.on("setAdd",t.changeWithValue),this.on("setMul",t.changeWithValue)}t.extend(a);var b=a.prototype;return Object.defineProperties(b,{func:{set:function(a){"function"==typeof a&&(this._.func=a)},get:function(){return this._.func}},args:{set:function(a){this._.args=u(a)?a:[a]},get:function(){return this._.args}}}),b.bang=function(){var a=this._,b=c.call(arguments).concat(a.args),d=a.func.apply(this,b);return"number"==typeof d&&(a.value=d,t.changeWithValue.call(this)),this._.emit("bang"),this},a}(),G=function(){function a(a){A.call(this,1,[]);var b,c;for(b=0,c=a[0].length;c>b;++b)this.append(a[0][b]);if(v(a[1])){var d=a[1];this.once("init",function(){this.set(d)})}}t.extend(a);var b=a.prototype;return Object.defineProperties(b,{}),b.bang=function(){var a,b,d=["bang"].concat(c.call(arguments)),e=this.nodes;for(a=0,b=e.length;b>a;++a)e[a].bang.apply(e[a],d);return this},b.postMessage=function(a){var b,c,d=this.nodes;for(b=0,c=d.length;c>b;++b)d[b].postMessage(a);return this},b.process=function(a){var b=this._;return this.tickID!==a&&(this.tickID=a,b.ar?(t.inputSignalAR(this),t.outputSignalAR(this)):(this.cells[0][0]=t.inputSignalKR(this),t.outputSignalKR(this))),this},a}(),H=function(){function a(a){if(A.call(this,1,[]),t.fixKR(this),v(a[1])){var b=a[1];this.once("init",function(){this.set(b)})}}t.extend(a);var b=a.prototype;return Object.defineProperties(b,{}),a}(),I=function(){function a(a){A.call(this,2,[]),this.playbackState=d;var e=this._;e.node=a,e.onplay=b(this),e.onpause=c(this)}t.extend(a);var b=function(a){return function(){-1===k.inlets.indexOf(a)&&(k.inlets.push(a),k.events.emit("addObject"),a.playbackState=e,a._.emit("play"))}},c=function(a){return function(){var b=k.inlets.indexOf(a);-1!==b&&(k.inlets.splice(b,1),a.playbackState=d,a._.emit("pause"),k.events.emit("removeObject"))}},f=a.prototype;return f.play=function(){return k.nextTick(this._.onplay),-1===k.inlets.indexOf(this)},f.pause=function(){k.nextTick(this._.onpause)},f.process=function(a){var b=this._.node;1&b.playbackState?(b.process(a),this.cells[1].set(b.cells[1]),this.cells[2].set(b.cells[2])):(this.cells[1].set(t.emptycell),this.cells[2].set(t.emptycell))},a}(),J=function(){function a(){this.context=this,this.tickID=0,this.impl=null,this.amp=.8,this.status=d,this.samplerate=44100,this.channels=2,this.cellsize=64,this.streammsec=20,this.streamsize=0,this.currentTime=0,this.nextTicks=[],this.inlets=[],this.timers=[],this.listeners=[],this.deferred=null,this.recStart=0,this.recBuffers=null,this.delayProcess=b(this),this.events=null,t.currentTimeIncr=1e3*this.cellsize/this.samplerate,t.emptycell=new t.SignalArray(this.cellsize),this.reset(!0)}var b=function(a){return function(){a.recStart=Date.now(),a.process()}},f=a.prototype;f.bind=function(a,b){if("function"==typeof a){var c=new a(this,b);this.impl=c,this.impl.defaultSamplerate&&(this.samplerate=this.impl.defaultSamplerate)}return this},f.setup=function(a){return"object"==typeof a&&(-1!==h.indexOf(a.samplerate)&&(this.samplerate=a.samplerate<=this.impl.maxSamplerate?a.samplerate:this.impl.maxSamplerate),-1!==i.indexOf(a.cellsize)&&(this.cellsize=a.cellsize),"undefined"!=typeof Float64Array&&"undefined"!=typeof a.f64&&(p=!!a.f64,t.SignalArray=p?Float64Array:Float32Array)),t.currentTimeIncr=1e3*this.cellsize/this.samplerate,t.emptycell=new t.SignalArray(this.cellsize),this},f.getAdjustSamples=function(a){var b,c;return a=a||this.samplerate,b=this.streammsec/1e3*a,c=Math.ceil(Math.log(b)*Math.LOG2E),c=8>c?8:c>14?14:c,1<<c},f.play=function(){return this.status===d&&(this.status=e,this.streamsize=this.getAdjustSamples(),this.strmL=new t.SignalArray(this.streamsize),this.strmR=new t.SignalArray(this.streamsize),this.impl.play(),this.events.emit("play")),this},f.pause=function(){return this.status===e&&(this.status=d,this.impl.pause(),this.events.emit("pause")),this},f.reset=function(a){return a&&(this.events=new y(this).on("addObject",function(){this.status===d&&this.play()}).on("removeObject",function(){this.status===e&&this.inlets.length+this.timers.length+this.listeners.length===0&&this.pause()})),this.currentTime=0,this.nextTicks=[],this.inlets=[],this.timers=[],this.listeners=[],this},f.process=function(){var a,b,c,d,e,f,h,i,j=this.tickID,k=this.strmL,l=this.strmR,m=this.amp,n=this.streamsize,o=0,p=this.cellsize,q=this.streamsize/this.cellsize,r=this.timers,s=this.inlets,u=this.listeners,v=t.currentTimeIncr;for(d=0;n>d;++d)k[d]=l[d]=0;for(;q--;){for(++j,e=0,f=r.length;f>e;++e)1&r[e].playbackState&&r[e].process(j);for(e=0,f=s.length;f>e;++e)if(a=s[e],a.process(j),1&a.playbackState)for(b=a.cells[1],c=a.cells[2],h=0,d=o;p>h;++h,++d)k[d]+=b[h],l[d]+=c[h];for(o+=p,e=0,f=u.length;f>e;++e)1&u[e].playbackState&&u[e].process(j);for(this.currentTime+=v,i=this.nextTicks.splice(0),e=0,f=i.length;f>e;++e)i[e]()}for(d=0;n>d;++d)a=k[d]*m,-1>a?a=-1:a>1&&(a=1),k[d]=a,a=l[d]*m,-1>a?a=-1:a>1&&(a=1),l[d]=a;this.tickID=j;var w=this.currentTime;if(this.status===g){if(2===this.recCh)this.recBuffers.push(new t.SignalArray(k)),this.recBuffers.push(new t.SignalArray(l));else{var x=new t.SignalArray(k.length);for(d=0,n=x.length;n>d;++d)x[d]=.5*(k[d]+l[d]);this.recBuffers.push(x)}if(w>=this.maxDuration)this.deferred.sub.reject();else if(w>=this.recDuration)this.deferred.sub.resolve();else{var y=Date.now();y-this.recStart>20?setTimeout(this.delayProcess,10):this.process()}}},f.nextTick=function(a){this.status===d?a():this.nextTicks.push(a)},f.rec=function(){t.fix_iOS6_1_problem(!0);var a=new z(this);if(this.deferred)return console.warn("rec deferred is exists??"),a.reject().promise();if(this.status!==d)return console.log("status is not none",this.status),a.reject().promise();var b=0,e=arguments,f=v(e[b])?e[b++]:{},h=e[b];if("function"!=typeof h)return console.warn("no function"),a.reject().promise();this.deferred=a,this.status=g,this.reset();var i=new r("+"),k=new z(this),l={done:function(){k.resolve.apply(k,c.call(arguments))},send:function(){i.append.apply(i,arguments)}},m=this;return k.then(j,function(){t.fix_iOS6_1_problem(!1),j.call(m,!0)}),this.deferred.sub=k,this.savedSamplerate=this.samplerate,this.samplerate=f.samplerate||this.samplerate,this.recDuration=f.recDuration||1/0,this.maxDuration=f.maxDuration||6e5,this.recCh=f.ch||1,2!==this.recCh&&(this.recCh=1),this.recBuffers=[],this.streamsize=this.getAdjustSamples(),this.strmL=new t.SignalArray(this.streamsize),this.strmR=new t.SignalArray(this.streamsize),this.inlets.push(i),h(l),setTimeout(this.delayProcess,10),a.promise()};var j=function(){this.status=d,this.reset();var a,b=this.recBuffers,c=this.samplerate,e=this.streamsize;this.samplerate=this.savedSamplerate,a=1/0!==this.recDuration?this.recDuration*c*.001|0:(b.length>>this.recCh-1)*e;var f,g,h=a/e|0,i=0,j=0,k=a;if(2===this.recCh){var l=new t.SignalArray(a),m=new t.SignalArray(a),n=new t.SignalArray(a);for(g=0;h>g;++g)if(l.set(b[i++],j),m.set(b[i++],j),j+=e,k-=e,k>0&&e>k){l.set(b[i++].subarray(0,k),j),m.set(b[i++].subarray(0,k),j);break}for(g=0,h=a;h>g;++g)n[g]=.5*(l[g]+m[g]);f={samplerate:c,channels:2,buffer:[n,l,m]}}else{var o=new t.SignalArray(a);for(g=0;h>g;++g)if(o.set(b[i++],j),j+=e,k-=e,k>0&&e>k){o.set(b[i++].subarray(0,k),j);break}f={samplerate:c,channels:1,buffer:[o]}}var p=[].concat.apply([f],arguments);this.deferred.resolve.apply(this.deferred,p),this.deferred=null};return f.on=function(a,b){this.events.on(a,b)},f.once=function(a,b){this.events.once(a,b)},f.off=function(a,b){this.events.off(a,b)},f.removeAllListeners=function(a){this.events.removeListeners(a)},f.listeners=function(a){return this.events.listeners(a)},f.fix_iOS6_1_problem=function(a){this.impl.fix_iOS6_1_problem&&this.impl.fix_iOS6_1_problem(a)},a}(),K=null;"undefined"!=typeof window&&(w=window.AudioContext||window.webkitAudioContext),K="undefined"!=typeof w?function(a){var b,c,d=new w;t._audioContext=d,this.maxSamplerate=d.sampleRate,this.defaultSamplerate=d.sampleRate,this.env="webkit";var e=navigator.userAgent;if(e.match(/linux/i)?a.streammsec*=8:e.match(/win(dows)?\s*(nt 5\.1|xp)/i)&&(a.streammsec*=4),this.play=function(){var e,f,g,h=a.getAdjustSamples(d.sampleRate),i=a.streamsize;a.samplerate===d.sampleRate?e=function(b){var c=b.outputBuffer;a.process(),c.getChannelData(0).set(a.strmL),c.getChannelData(1).set(a.strmR)}:2*a.samplerate===d.sampleRate?e=function(b){var c,d,e=a.strmL,f=a.strmR,g=b.outputBuffer,h=g.getChannelData(0),i=g.getChannelData(1),j=g.length;for(a.process(),c=d=0;j>c;c+=2,++d)h[c]=h[c+1]=e[d],i[c]=i[c+1]=f[d]}:(f=i,g=a.samplerate/d.sampleRate,e=function(b){var c,d=a.strmL,e=a.strmR,h=b.outputBuffer,j=h.getChannelData(0),k=h.getChannelData(1),l=h.length;for(c=0;l>c;++c)f>=i&&(a.process(),f-=i),j[c]=d[0|f],k[c]=e[0|f],f+=g}),b=d.createBufferSource(),c=d.createScriptProcessor(h,2,a.channels),c.onaudioprocess=e,b.noteOn&&b.noteOn(0),b.connect(c),c.connect(d.destination)},this.pause=function(){b.disconnect(),c.disconnect()},o){var f=0,g=d.createBufferSource();this.fix_iOS6_1_problem=function(a){f+=a?1:-1,1===f&&g.noteOn?(g.noteOn(0),g.connect(d.destination)):0===f&&g.disconnect()}}}:function(){this.maxSamplerate=48e3,this.defaultSamplerate=44100,this.env="nop",this.play=function(){},this.pause=function(){}},k=(new J).bind(K);var L=b;"node"===n||"undefined"!=typeof module&&module.exports?module.exports=global.timbre=L:"browser"===n&&(L.noConflict=function(){var a=window.timbre,b=window.T;return function(c){return window.T===L&&(window.T=b),c&&window.timbre===L&&(window.timbre=a),L}}(),window.timbre=window.T=L),function(){function a(a){try{return b.plugins&&b.mimeTypes&&b.mimeTypes.length?b.plugins["Shockwave Flash"].description.match(/([0-9]+)/)[a]:new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version").match(/([0-9]+)/)[a]}catch(c){return-1}}if("nop"===k.impl.env&&"browser"===n&&!o){var b=navigator;if(!(a(0)<10)){var c,d="TimbreFlashPlayerDiv",e=function(){var a=document.getElementsByTagName("script");if(a&&a.length)for(var b,c=0,d=a.length;d>c;++c)if(b=/^(.*\/)timbre(?:\.dev)?\.js$/i.exec(a[c].src))return b[1]+"timbre.swf"}();window.timbrejs_flashfallback_init=function(){function a(a){var b=0;this.maxSamplerate=44100,this.defaultSamplerate=44100,this.env="flash",this.play=function(){var d,f=new Array(a.streamsize*a.channels),g=a.streammsec,h=0,i=a.streamsize/a.samplerate*1e3,j=Date.now();d=function(){if(!(h>Date.now()-j)){var b=a.strmL,d=a.strmR,e=f.length,g=b.length;for(a.process();g--;)f[--e]=32768*d[g]|0,f[--e]=32768*b[g]|0;c.writeAudio(f.join(" ")),h+=i}},c.setup?(c.setup(a.channels,a.samplerate),b=setInterval(d,g)):console.warn("Cannot find "+e)},this.pause=function(){0!==b&&(c.cancel(),clearInterval(b),b=0)}}k.bind(a),delete window.timbrejs_flashfallback_init};var f,g,h=e,i=h+"?"+ +new Date,j="TimbreFlashPlayer",l=document.createElement("div");l.id=d,l.style.display="inline",l.width=l.height=1,b.plugins&&b.mimeTypes&&b.mimeTypes.length?(f=document.createElement("object"),f.id=j,f.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",f.width=f.height=1,f.setAttribute("data",i),f.setAttribute("type","application/x-shockwave-flash"),g=document.createElement("param"),g.setAttribute("name","allowScriptAccess"),g.setAttribute("value","always"),f.appendChild(g),l.appendChild(f)):l.innerHTML='<object id="'+j+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1" height="1"><param name="movie" value="'+i+'" /><param name="bgcolor" value="#FFFFFF" /><param name="quality" value="high" /><param name="allowScriptAccess" value="always" /></object>',document.body.appendChild(l),c=document[j] }}}()}(),function(a){"use strict";function b(a){this.samplerate=a,this.frequency=340,this.Q=1,this.gain=0,this.x1L=this.x2L=this.y1L=this.y2L=0,this.x1R=this.x2R=this.y1R=this.y2R=0,this.b0=this.b1=this.b2=this.a1=this.a2=0,this.setType("lpf")}var c=b.prototype;c.process=function(a,b){var c,d,e,f,g,h,i=this.x1L,j=this.x2L,k=this.y1L,l=this.y2L,m=this.x1R,n=this.x2R,o=this.y1R,p=this.y2R,q=this.b0,r=this.b1,s=this.b2,t=this.a1,u=this.a2;for(g=0,h=a.length;h>g;++g)c=a[g],e=q*c+r*i+s*j-t*k-u*l,j=i,i=c,l=k,k=e,d=b[g],f=q*d+r*m+s*n-t*o-u*p,n=m,m=d,p=o,o=f,a[g]=e,b[g]=f;this.x1L=i,this.x2L=j,this.y1L=k,this.y2L=l,this.x1R=m,this.x2R=n,this.y1R=o,this.y2R=p},c.setType=function(a){var b;(b=d[a])&&(this.type=a,b.call(this,this.frequency,this.Q,this.gain))},c.setParams=function(a,b,c){this.frequency=a,this.Q=b,this.gain=c;var e=d[this.type];return e&&e.call(this,a,b,c),this};var d={lowpass:function(a,b){if(a/=.5*this.samplerate,a>=1)this.b0=1,this.b1=this.b2=this.a1=this.a2=0;else if(0>=a)this.b0=this.b1=this.b2=this.a1=this.a2=0;else{b=0>b?0:b;var c=Math.pow(10,.05*b),d=Math.sqrt(.5*(4-Math.sqrt(16-16/(c*c)))),e=Math.PI*a,f=.5*d*Math.sin(e),g=.5*(1-f)/(1+f),h=(.5+g)*Math.cos(e),i=.25*(.5+g-h);this.b0=2*i,this.b1=4*i,this.b2=this.b0,this.a1=2*-h,this.a2=2*g}},highpass:function(a,b){if(a/=.5*this.samplerate,a>=1)this.b0=this.b1=this.b2=this.a1=this.a2=0;else if(0>=a)this.b0=1,this.b1=this.b2=this.a1=this.a2=0;else{b=0>b?0:b;var c=Math.pow(10,.05*b),d=Math.sqrt((4-Math.sqrt(16-16/(c*c)))/2),e=Math.PI*a,f=.5*d*Math.sin(e),g=.5*(1-f)/(1+f),h=(.5+g)*Math.cos(e),i=.25*(.5+g+h);this.b0=2*i,this.b1=-4*i,this.b2=this.b0,this.a1=2*-h,this.a2=2*g}},bandpass:function(a,b){if(a/=.5*this.samplerate,a>0&&1>a)if(b>0){var c=Math.PI*a,d=Math.sin(c)/(2*b),e=Math.cos(c),f=1/(1+d);this.b0=d*f,this.b1=0,this.b2=-d*f,this.a1=-2*e*f,this.a2=(1-d)*f}else this.b0=this.b1=this.b2=this.a1=this.a2=0;else this.b0=this.b1=this.b2=this.a1=this.a2=0},lowshelf:function(a,b,c){a/=.5*this.samplerate;var d=Math.pow(10,c/40);if(a>=1)this.b0=d*d,this.b1=this.b2=this.a1=this.a2=0;else if(0>=a)this.b0=1,this.b1=this.b2=this.a1=this.a2=0;else{var e=Math.PI*a,f=1,g=.5*Math.sin(e)*Math.sqrt((d+1/d)*(1/f-1)+2),h=Math.cos(e),i=2*Math.sqrt(d)*g,j=d+1,k=d-1,l=1/(j+k*h+i);this.b0=d*(j-k*h+i)*l,this.b1=2*d*(k-j*h)*l,this.b2=d*(j-k*h-i)*l,this.a1=-2*(k+j*h)*l,this.a2=(j+k*h-i)*l}},highshelf:function(a,b,c){a/=.5*this.samplerate;var d=Math.pow(10,c/40);if(a>=1)this.b0=1,this.b1=this.b2=this.a1=this.a2=0;else if(0>=a)this.b0=d*d,this.b1=this.b2=this.a1=this.a2=0;else{var e=Math.PI*a,f=1,g=.5*Math.sin(e)*Math.sqrt((d+1/d)*(1/f-1)+2),h=Math.cos(e),i=2*Math.sqrt(d)*g,j=d+1,k=d-1,l=1/(j-k*h+i);this.b0=d*(j+k*h+i)*l,this.b1=-2*d*(k+j*h)*l,this.b2=d*(j+k*h-i)*l,this.a1=2*(k-j*h)*l,this.a2=(j-k*h-i)*l}},peaking:function(a,b,c){if(a/=.5*this.samplerate,a>0&&1>a){var d=Math.pow(10,c/40);if(b>0){var e=Math.PI*a,f=Math.sin(e)/(2*b),g=Math.cos(e),h=1/(1+f/d);this.b0=(1+f*d)*h,this.b1=-2*g*h,this.b2=(1-f*d)*h,this.a1=this.b1,this.a2=(1-f/d)*h}else this.b0=d*d,this.b1=this.b2=this.a1=this.a2=0}else this.b0=1,this.b1=this.b2=this.a1=this.a2=0},notch:function(a,b){if(a/=.5*this.samplerate,a>0&&1>a)if(b>0){var c=Math.PI*a,d=Math.sin(c)/(2*b),e=Math.cos(c),f=1/(1+d);this.b0=f,this.b1=-2*e*f,this.b2=f,this.a1=this.b1,this.a2=(1-d)*f}else this.b0=this.b1=this.b2=this.a1=this.a2=0;else this.b0=1,this.b1=this.b2=this.a1=this.a2=0},allpass:function(a,b){if(a/=.5*this.samplerate,a>0&&1>a)if(b>0){var c=Math.PI*a,d=Math.sin(c)/(2*b),e=Math.cos(c),f=1/(1+d);this.b0=(1-d)*f,this.b1=-2*e*f,this.b2=(1+d)*f,this.a1=this.b1,this.a2=this.b0}else this.b0=-1,this.b1=this.b2=this.a1=this.a2=0;else this.b0=1,this.b1=this.b2=this.a1=this.a2=0}};d.lpf=d.lowpass,d.hpf=d.highpass,d.bpf=d.bandpass,d.bef=d.notch,d.brf=d.notch,d.apf=d.allpass,a.modules.Biquad=b}(timbre),function(a){"use strict";function b(b){this.samplerate=b;var c=Math.round(Math.log(.1*b)*Math.LOG2E);this.buffersize=1<<c,this.bufferL=new a.fn.SignalArray(this.buffersize+1),this.bufferR=new a.fn.SignalArray(this.buffersize+1),this.wave=null,this._wave=null,this.writeIndex=this.buffersize>>1,this.readIndex=0,this.delayTime=20,this.rate=4,this.depth=20,this.feedback=.2,this.wet=.5,this.phase=0,this.phaseIncr=0,this.phaseStep=4,this.setWaveType("sin"),this.setDelayTime(this.delayTime),this.setRate(this.rate)}var c=b.prototype,d=[];d[0]=function(){for(var a=new Float32Array(512),b=0;512>b;++b)a[b]=Math.sin(2*Math.PI*(b/512));return a}(),d[1]=function(){for(var a,b=new Float32Array(512),c=0;512>c;++c)a=c/512-.25,b[c]=1-4*Math.abs(Math.round(a)-a);return b}(),c.setWaveType=function(a){"sin"===a?(this.wave=a,this._wave=d[0]):"tri"===a&&(this.wave=a,this._wave=d[1])},c.setDelayTime=function(a){this.delayTime=a;for(var b=this.writeIndex-(a*this.samplerate*.001|0);0>b;)b+=this.buffersize;this.readIndex=b},c.setRate=function(a){this.rate=a,this.phaseIncr=512*this.rate/this.samplerate*this.phaseStep},c.process=function(a,b){var c,d,e,f,g,h=this.bufferL,i=this.bufferR,j=this.buffersize,k=j-1,l=this._wave,m=this.phase,n=this.phaseIncr,o=this.writeIndex,p=this.readIndex,q=this.depth,r=this.feedback,s=this.wet,t=1-s,u=a.length,v=this.phaseStep;for(f=0;u>f;){for(e=l[0|m]*q,m+=n;m>512;)m-=512;for(g=0;v>g;++g,++f)d=p+j+e&k,c=.5*(h[d]+h[d+1]),h[o]=a[f]-c*r,a[f]=a[f]*t+c*s,c=.5*(i[d]+i[d+1]),i[o]=b[f]-c*r,b[f]=b[f]*t+c*s,o=o+1&k,p=p+1&k}this.phase=m,this.writeIndex=o,this.readIndex=p},a.modules.Chorus=b}(timbre),function(a){"use strict";function b(b,d){this.samplerate=b,this.channels=d,this.lastPreDelayFrames=0,this.preDelayReadIndex=0,this.preDelayWriteIndex=e,this.ratio=-1,this.slope=-1,this.linearThreshold=-1,this.dbThreshold=-1,this.dbKnee=-1,this.kneeThreshold=-1,this.kneeThresholdDb=-1,this.ykneeThresholdDb=-1,this.K=-1,this.attackTime=.003,this.releaseTime=.25,this.preDelayTime=.006,this.dbPostGain=0,this.effectBlend=1,this.releaseZone1=.09,this.releaseZone2=.16,this.releaseZone3=.42,this.releaseZone4=.98,this.detectorAverage=0,this.compressorGain=1,this.meteringGain=1,this.delayBufferL=new a.fn.SignalArray(c),this.delayBufferR=2===d?new a.fn.SignalArray(c):this.delayBufferL,this.preDelayTime=6,this.preDelayReadIndex=0,this.preDelayWriteIndex=e,this.maxAttackCompressionDiffDb=-1,this.meteringReleaseK=1-Math.exp(-1/(.325*this.samplerate)),this.setAttackTime(this.attackTime),this.setReleaseTime(this.releaseTime),this.setPreDelayTime(this.preDelayTime),this.setParams(-24,30,12)}var c=1024,d=c-1,e=256,f=5,g=b.prototype;g.clone=function(){var a=new b(this.samplerate,this.channels);return a.setAttackTime(this.attackTime),a.setReleaseTime(this.releaseTime),a.setPreDelayTime(this.preDelayTime),a.setParams(this.dbThreshold,this.dbKnee,this.ratio),a},g.setAttackTime=function(a){this.attackTime=Math.max(.001,a),this._attackFrames=this.attackTime*this.samplerate},g.setReleaseTime=function(a){this.releaseTime=Math.max(.001,a);var b=this.releaseTime*this.samplerate,c=.0025;this._satReleaseFrames=c*this.samplerate;var d=b*this.releaseZone1,e=b*this.releaseZone2,f=b*this.releaseZone3,g=b*this.releaseZone4;this._kA=.9999999999999998*d+1.8432219684323923e-16*e-1.9373394351676423e-16*f+8.824516011816245e-18*g,this._kB=-1.5788320352845888*d+2.3305837032074286*e-.9141194204840429*f+.1623677525612032*g,this._kC=.5334142869106424*d-1.272736789213631*e+.9258856042207512*f-.18656310191776226*g,this._kD=.08783463138207234*d-.1694162967925622*e+.08588057951595272*f-.00429891410546283*g,this._kE=-.042416883008123074*d+.1115693827987602*e-.09764676325265872*f+.028494263462021576*g},g.setPreDelayTime=function(a){this.preDelayTime=a;var b=a*this.samplerate;if(b>c-1&&(b=c-1),this.lastPreDelayFrames!==b){this.lastPreDelayFrames=b;for(var d=0,e=this.delayBufferL.length;e>d;++d)this.delayBufferL[d]=this.delayBufferR[d]=0;this.preDelayReadIndex=0,this.preDelayWriteIndex=b}},g.setParams=function(a,b,c){this._k=this.updateStaticCurveParameters(a,b,c);var d=this.saturate(1,this._k),e=1/d;e=Math.pow(e,.6),this._masterLinearGain=Math.pow(10,.05*this.dbPostGain)*e},g.kneeCurve=function(a,b){return a<this.linearThreshold?a:this.linearThreshold+(1-Math.exp(-b*(a-this.linearThreshold)))/b},g.saturate=function(a,b){var c;if(a<this.kneeThreshold)c=this.kneeCurve(a,b);else{var d=a?20*Math.log(a)*Math.LOG10E:-1e3,e=this.ykneeThresholdDb+this.slope*(d-this.kneeThresholdDb);c=Math.pow(10,.05*e)}return c},g.slopeAt=function(a,b){if(a<this.linearThreshold)return 1;var c=1.001*a,d=a?20*Math.log(a)*Math.LOG10E:-1e3,e=c?20*Math.log(c)*Math.LOG10E:-1e3,f=this.kneeCurve(a,b),g=this.kneeCurve(c,b),h=f?20*Math.log(f)*Math.LOG10E:-1e3,i=g?20*Math.log(g)*Math.LOG10E:-1e3;return(i-h)/(e-d)},g.kAtSlope=function(a){for(var b=this.dbThreshold+this.dbKnee,c=Math.pow(10,.05*b),d=.1,e=1e4,f=5,g=0;15>g;++g){var h=this.slopeAt(c,f);a>h?e=f:d=f,f=Math.sqrt(d*e)}return f},g.updateStaticCurveParameters=function(a,b,c){this.dbThreshold=a,this.linearThreshold=Math.pow(10,.05*a),this.dbKnee=b,this.ratio=c,this.slope=1/this.ratio,this.kneeThresholdDb=a+b,this.kneeThreshold=Math.pow(10,.05*this.kneeThresholdDb);var d=this.kAtSlope(1/this.ratio),e=this.kneeCurve(this.kneeThreshold,d);return this.ykneeThresholdDb=e?20*Math.log(e)*Math.LOG10E:-1e3,this._k=d,this._k},g.process=function(a,b){for(var c=1-this.effectBlend,e=this.effectBlend,g=this._k,h=this._masterLinearGain,i=this._satReleaseFrames,j=this._kA,k=this._kB,l=this._kC,m=this._kD,n=this._kE,o=64,p=a.length/o,q=0,r=this.detectorAverage,s=this.compressorGain,t=this.maxAttackCompressionDiffDb,u=1/this._attackFrames,v=this.preDelayReadIndex,w=this.preDelayWriteIndex,x=this.detectorAverage,y=this.delayBufferL,z=this.delayBufferR,A=this.meteringGain,B=this.meteringReleaseK,C=0;p>C;++C){var D,E=Math.asin(r)/(.5*Math.PI),F=E>s,G=s/E,H=G?20*Math.log(G)*Math.LOG10E:-1e3;if((1/0===H||isNaN(H))&&(H=-1),F){t=-1,G=H,G=-12>G?0:G>0?3:.25*(G+12);var I=G*G,J=I*G,K=I*I,L=j+k*G+l*I+m*J+n*K,M=f/L;D=Math.pow(10,.05*M)}else{(-1===t||H>t)&&(t=H);var N=Math.max(.5,t);G=.25/N,D=1-Math.pow(G,u)}for(var O=o;O--;){var P=0,Q=.5*(a[q]+b[q]);y[w]=a[q],z[w]=b[q],0>Q&&(Q*=-1),Q>P&&(P=Q);var R=P;0>R&&(R*=-1);var S=this.saturate(R,g),T=1e-4>=R?1:S/R,U=T?-20*Math.log(T)*Math.LOG10E:1e3;2>U&&(U=2);var V=U/i,W=Math.pow(10,.05*V)-1,X=T>x,Y=X?W:1;x+=(T-x)*Y,x>1&&(x=1),1>D?s+=(E-s)*D:(s*=D,s>1&&(s=1));var Z=Math.sin(.5*Math.PI*s),$=c+e*h*Z,_=20*Math.log(Z)*Math.LOG10E;A>_?A=_:A+=(_-A)*B,a[q]=y[v]*$,b[q]=z[v]*$,q++,v=v+1&d,w=w+1&d}1e-6>x&&(x=1e-6),1e-6>s&&(s=1e-6)}this.preDelayReadIndex=v,this.preDelayWriteIndex=w,this.detectorAverage=x,this.compressorGain=s,this.maxAttackCompressionDiffDb=t,this.meteringGain=A},g.reset=function(){this.detectorAverage=0,this.compressorGain=1,this.meteringGain=1;for(var a=0,b=this.delayBufferL.length;b>a;++a)this.delayBufferL[a]=this.delayBufferR[a]=0;this.preDelayReadIndex=0,this.preDelayWriteIndex=e,this.maxAttackCompressionDiffDb=-1},a.modules.Compressor=b}(timbre),function(a){"use strict";function b(){}b.prototype.decode=function(a,c,d){if("string"==typeof a){if(/\.wav$/.test(a))return b.wav_decode(a,c,d);if(b.ogg_decode&&/\.ogg$/.test(a))return b.ogg_decode(a,c,d);if(b.mp3_decode&&/\.mp3$/.test(a))return b.mp3_decode(a,c,d)}else if("object"==typeof a){if("wav"===a.type)return b.wav_decode(a.data,c,d);if(b.ogg_decode&&"ogg"===a.type)return b.ogg_decode(a.data,c,d);if(b.mp3_decode&&"mp3"===a.type)return b.mp3_decode(a.data,c,d)}return b.webkit_decode?"object"==typeof a?b.webkit_decode(a.data||a,c,d):b.webkit_decode(a,c,d):b.moz_decode?b.moz_decode(a,c,d):void c(!1)},a.modules.Decoder=b,b.getBinaryWithPath="browser"===a.envtype?function(b,c){a.fn.fix_iOS6_1_problem(!0);var d=new XMLHttpRequest;d.open("GET",b),d.responseType="arraybuffer",d.onreadystatechange=function(){4===d.readyState&&(d.response?c(new Uint8Array(d.response)):void 0!==d.responseBody&&c(new Uint8Array(VBArray(d.responseBody).toArray())),a.fn.fix_iOS6_1_problem(!1))},d.send()}:function(a,b){b("no support")};var c=function(a){for(var b,c,d,e,f,g=new Int32Array(a.length/3),h=0,i=a.length,j=0;i>h;)b=a[h++],c=a[h++],d=a[h++],e=b+(c<<8)+(d<<16),f=8388608&e?e-16777216:e,g[j++]=f;return g};b.wav_decode=function(){var a=function(a,b,d){if("RIFF"!==String.fromCharCode(a[0],a[1],a[2],a[3]))return b(!1);var e=a[4]+(a[5]<<8)+(a[6]<<16)+(a[7]<<24);if(e+8!==a.length)return b(!1);if("WAVE"!==String.fromCharCode(a[8],a[9],a[10],a[11]))return b(!1);if("fmt "!==String.fromCharCode(a[12],a[13],a[14],a[15]))return b(!1);for(var f=a[22]+(a[23]<<8),g=a[24]+(a[25]<<8)+(a[26]<<16)+(a[27]<<24),h=a[34]+(a[35]<<8),i=36;i<a.length&&"data"!==String.fromCharCode(a[i],a[i+1],a[i+2],a[i+3]);)i+=1;if(i>=a.length)return b(!1);i+=4;var j=a[i]+(a[i+1]<<8)+(a[i+2]<<16)+(a[i+3]<<24),k=(j/f>>1)/g;if(i+=4,j>a.length-i)return b(!1);var l,m,n;l=new Float32Array(k*g|0),2===f&&(m=new Float32Array(l.length),n=new Float32Array(l.length)),b({samplerate:g,channels:f,buffer:[l,m,n],duration:k}),8===h?a=new Int8Array(a.buffer,i):16===h?a=new Int16Array(a.buffer,i):32===h?a=new Int32Array(a.buffer,i):24===h&&(a=c(new Uint8Array(a.buffer,i)));var o,p,q,r=1/((1<<h-1)-1);if(2===f)for(i=p=0,o=l.length;o>i;++i)q=m[i]=a[p++]*r,q+=n[i]=a[p++]*r,l[i]=.5*q;else for(i=0,o=l.length;o>i;++i)l[i]=a[i]*r;d()};return function(c,d,e){"string"==typeof c?b.getBinaryWithPath(c,function(b){a(b,d,e)}):a(c,d,e)}}(),b.webkit_decode=function(){if("undefined"!=typeof a.fn._audioContext){var c=a.fn._audioContext,d=function(a,b,d){var e,f,g,h,i;if("string"==typeof a)return d(!1);var j;try{j=c.createBuffer(a.buffer,!1)}catch(k){return b(!1)}e=c.sampleRate,f=j.numberOfChannels,2===f?(g=j.getChannelData(0),h=j.getChannelData(1)):g=h=j.getChannelData(0),i=g.length/e;for(var l=new Float32Array(g),m=0,n=l.length;n>m;++m)l[m]=.5*(l[m]+h[m]);b({samplerate:e,channels:f,buffer:[l,g,h],duration:i}),d()};return function(a,c,e){if(a instanceof File){var f=new FileReader;f.onload=function(a){d(new Uint8Array(a.target.result),c,e)},f.readAsArrayBuffer(a)}else"string"==typeof a?b.getBinaryWithPath(a,function(a){d(a,c,e)}):d(a,c,e)}}}(),b.moz_decode=function(){return"function"==typeof Audio&&"function"==typeof(new Audio).mozSetup?function(a,b,c){var d,e,f,g,h,i,j=0,k=new Audio(a);k.volume=0,k.addEventListener("loadedmetadata",function(){d=k.mozSampleRate,e=k.mozChannels,i=k.duration,f=new Float32Array(k.duration*d|0),2===e&&(g=new Float32Array(k.duration*d|0),h=new Float32Array(k.duration*d|0)),2===e?k.addEventListener("MozAudioAvailable",function(a){for(var b,c=a.frameBuffer,d=0,e=c.length;e>d;d+=2)b=g[j]=c[d],b+=h[j]=c[d+1],f[j]=.5*b,j+=1},!1):k.addEventListener("MozAudioAvailable",function(a){for(var b=a.frameBuffer,c=0,d=b.length;d>c;++c)f[c]=b[c],j+=1},!1),k.play(),setTimeout(function(){b({samplerate:d,channels:e,buffer:[f,g,h],duration:i})},1e3)},!1),k.addEventListener("ended",function(){c()},!1),k.load()}:void 0}()}(timbre),function(a){"use strict";function b(a){this.samplerate=a||44100,this.value=d,this.status=m,this.curve="linear",this.step=1,this.releaseNode=null,this.loopNode=null,this.emit=null,this._envValue=new c(a),this._table=[],this._initValue=d,this._curveValue=0,this._defaultCurveType=f,this._index=0,this._counter=0}function c(a){this.samplerate=a,this.value=d,this.step=1,this._curveType=f,this._curveValue=0,this._grow=0,this._a2=0,this._b1=0,this._y1=0,this._y2=0}var d=b.ZERO=1e-6,e=b.CurveTypeSet=0,f=b.CurveTypeLin=1,g=b.CurveTypeExp=2,h=b.CurveTypeSin=3,i=b.CurveTypeWel=4,j=b.CurveTypeCurve=5,k=b.CurveTypeSqr=6,l=b.CurveTypeCub=7,m=b.StatusWait=0,n=b.StatusGate=1,o=b.StatusSustain=2,p=b.StatusRelease=3,q=b.StatusEnd=4,r={set:e,lin:f,linear:f,exp:g,exponential:g,sin:h,sine:h,wel:i,welch:i,sqr:k,squared:k,cub:l,cubed:l};b.CurveTypeDict=r;var s=b.prototype;s.clone=function(){var a=new b(this.samplerate);return a._table=this._table,a._initValue=this._initValue,a.setCurve(this.curve),null!==this.releaseNode&&a.setReleaseNode(this.releaseNode+1),null!==this.loopNode&&a.setLoopNode(this.loopNode+1),a.setStep(this.step),a.reset(),a},s.setTable=function(a){this._initValue=a[0],this._table=a.slice(1),this.value=this._envValue.value=this._initValue,this._index=0,this._counter=0,this.status=m},s.setCurve=function(a){"number"==typeof a?(this._defaultCurveType=j,this._curveValue=a,this.curve=a):(this._defaultCurveType=r[a]||null,this.curve=a)},s.setReleaseNode=function(a){"number"==typeof a&&a>0&&(this.releaseNode=a-1)},s.setLoopNode=function(a){"number"==typeof a&&a>0&&(this.loopNode=a-1)},s.setStep=function(a){this.step=this._envValue.step=a},s.reset=function(){this.value=this._envValue.value=this._initValue,this._index=0,this._counter=0,this.status=m},s.release=function(){null!==this.releaseNode&&this._index<=this.releaseNode&&(this._counter=0,this._index=this.releaseNode,this.status=p)},s.getInfo=function(a){var b,c,d=this._table,e=0,f=1/0,g=1/0,h=!1;for(b=0,c=d.length;c>b;++b){this.loopNode===b&&(f=e),this.releaseNode===b&&(a>e?e+=a:e=a,g=e);var i=d[b];Array.isArray(i)&&(e+=i[1])}return 1/0!==f&&1/0===g&&(e+=a,h=!0),{totalDuration:e,loopBeginTime:f,releaseBeginTime:g,isEndlessLoop:h}},s.calcStatus=function(){var a,b,c,d,g=this.status,h=this._table,i=this._index,k=t