diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-08-09 15:40:39 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-08-09 15:40:39 +0200 |
| commit | 795e1064ed498457dfc122b5ef91f4b2496a62e1 (patch) | |
| tree | bbb023463b355358db7c693bb23378feb045d244 | |
| parent | 659fb94ff54578357280cfc165c60a729c6fd2b2 (diff) | |
woo it generates midi
| -rw-r--r-- | bundle.js | 33901 | ||||
| -rw-r--r-- | bundle.js.map | 2 | ||||
| -rw-r--r-- | client/index.js | 32 | ||||
| -rw-r--r-- | img/imBreak_1340193016_tumblr_m5vynpMYYg1qiluqao1_500_.png | bin | 0 -> 25538 bytes | |||
| -rw-r--r-- | index.html | 64 | ||||
| -rw-r--r-- | package-lock.json | 4190 | ||||
| -rw-r--r-- | package.json | 11 |
7 files changed, 38157 insertions, 43 deletions
@@ -1,21 +1,33912 @@ -!function(t){function e(s){if(i[s])return i[s].exports;var n=i[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var i={};e.m=t,e.c=i,e.i=function(t){return t},e.d=function(t,i,s){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:s})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=15)}([function(t,e,i){(function(t,s){function n(t,i){var s={seen:[],stylize:r};return arguments.length>=3&&(s.depth=arguments[2]),arguments.length>=4&&(s.colors=arguments[3]),y(i)?s.showHidden=i:i&&e._extend(s,i),b(s.showHidden)&&(s.showHidden=!1),b(s.depth)&&(s.depth=2),b(s.colors)&&(s.colors=!1),b(s.customInspect)&&(s.customInspect=!0),s.colors&&(s.stylize=o),h(s,t,s.depth)}function o(t,e){var i=n.styles[e];return i?"["+n.colors[i][0]+"m"+t+"["+n.colors[i][1]+"m":t}function r(t,e){return t}function a(t){var e={};return t.forEach(function(t,i){e[t]=!0}),e}function h(t,i,s){if(t.customInspect&&i&&P(i.inspect)&&i.inspect!==e.inspect&&(!i.constructor||i.constructor.prototype!==i)){var n=i.inspect(s,t);return g(n)||(n=h(t,n,s)),n}var o=l(t,i);if(o)return o;var r=Object.keys(i),y=a(r);if(t.showHidden&&(r=Object.getOwnPropertyNames(i)),k(i)&&(r.indexOf("message")>=0||r.indexOf("description")>=0))return c(i);if(0===r.length){if(P(i)){var _=i.name?": "+i.name:"";return t.stylize("[Function"+_+"]","special")}if(x(i))return t.stylize(RegExp.prototype.toString.call(i),"regexp");if(T(i))return t.stylize(Date.prototype.toString.call(i),"date");if(k(i))return c(i)}var m="",v=!1,w=["{","}"];if(f(i)&&(v=!0,w=["[","]"]),P(i)){m=" [Function"+(i.name?": "+i.name:"")+"]"}if(x(i)&&(m=" "+RegExp.prototype.toString.call(i)),T(i)&&(m=" "+Date.prototype.toUTCString.call(i)),k(i)&&(m=" "+c(i)),0===r.length&&(!v||0==i.length))return w[0]+m+w[1];if(s<0)return x(i)?t.stylize(RegExp.prototype.toString.call(i),"regexp"):t.stylize("[Object]","special");t.seen.push(i);var b;return b=v?u(t,i,s,y,r):r.map(function(e){return p(t,i,s,y,e,v)}),t.seen.pop(),d(b,m,w)}function l(t,e){if(b(e))return t.stylize("undefined","undefined");if(g(e)){var i="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(i,"string")}return v(e)?t.stylize(""+e,"number"):y(e)?t.stylize(""+e,"boolean"):_(e)?t.stylize("null","null"):void 0}function c(t){return"["+Error.prototype.toString.call(t)+"]"}function u(t,e,i,s,n){for(var o=[],r=0,a=e.length;r<a;++r)q(e,String(r))?o.push(p(t,e,i,s,String(r),!0)):o.push("");return n.forEach(function(n){n.match(/^\d+$/)||o.push(p(t,e,i,s,n,!0))}),o}function p(t,e,i,s,n,o){var r,a,l;if(l=Object.getOwnPropertyDescriptor(e,n)||{value:e[n]},l.get?a=l.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):l.set&&(a=t.stylize("[Setter]","special")),q(s,n)||(r="["+n+"]"),a||(t.seen.indexOf(l.value)<0?(a=_(i)?h(t,l.value,null):h(t,l.value,i-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),b(r)){if(o&&n.match(/^\d+$/))return a;r=JSON.stringify(""+n),r.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(r=r.substr(1,r.length-2),r=t.stylize(r,"name")):(r=r.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),r=t.stylize(r,"string"))}return r+": "+a}function d(t,e,i){var s=0;return t.reduce(function(t,e){return s++,e.indexOf("\n")>=0&&s++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?i[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+i[1]:i[0]+e+" "+t.join(", ")+" "+i[1]}function f(t){return Array.isArray(t)}function y(t){return"boolean"==typeof t}function _(t){return null===t}function m(t){return null==t}function v(t){return"number"==typeof t}function g(t){return"string"==typeof t}function w(t){return"symbol"==typeof t}function b(t){return void 0===t}function x(t){return S(t)&&"[object RegExp]"===A(t)}function S(t){return"object"==typeof t&&null!==t}function T(t){return S(t)&&"[object Date]"===A(t)}function k(t){return S(t)&&("[object Error]"===A(t)||t instanceof Error)}function P(t){return"function"==typeof t}function O(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t}function A(t){return Object.prototype.toString.call(t)}function M(t){return t<10?"0"+t.toString(10):t.toString(10)}function I(){var t=new Date,e=[M(t.getHours()),M(t.getMinutes()),M(t.getSeconds())].join(":");return[t.getDate(),U[t.getMonth()],e].join(" ")}function q(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.format=function(t){if(!g(t)){for(var e=[],i=0;i<arguments.length;i++)e.push(n(arguments[i]));return e.join(" ")}for(var i=1,s=arguments,o=s.length,r=String(t).replace(/%[sdj%]/g,function(t){if("%%"===t)return"%";if(i>=o)return t;switch(t){case"%s":return String(s[i++]);case"%d":return Number(s[i++]);case"%j":try{return JSON.stringify(s[i++])}catch(t){return"[Circular]"}default:return t}}),a=s[i];i<o;a=s[++i])_(a)||!S(a)?r+=" "+a:r+=" "+n(a);return r},e.deprecate=function(i,n){function o(){if(!r){if(s.throwDeprecation)throw new Error(n);s.traceDeprecation?console.trace(n):console.error(n),r=!0}return i.apply(this,arguments)}if(b(t.process))return function(){return e.deprecate(i,n).apply(this,arguments)};if(!0===s.noDeprecation)return i;var r=!1;return o};var E,F={};e.debuglog=function(t){if(b(E)&&(E=s.env.NODE_DEBUG||""),t=t.toUpperCase(),!F[t])if(new RegExp("\\b"+t+"\\b","i").test(E)){var i=s.pid;F[t]=function(){var s=e.format.apply(e,arguments);console.error("%s %d: %s",t,i,s)}}else F[t]=function(){};return F[t]},e.inspect=n,n.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},n.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=f,e.isBoolean=y,e.isNull=_,e.isNullOrUndefined=m,e.isNumber=v,e.isString=g,e.isSymbol=w,e.isUndefined=b,e.isRegExp=x,e.isObject=S,e.isDate=T,e.isError=k,e.isFunction=P,e.isPrimitive=O,e.isBuffer=i(53);var U=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];e.log=function(){console.log("%s - %s",I(),e.format.apply(e,arguments))},e.inherits=i(52),e._extend=function(t,e){if(!e||!S(e))return t;for(var i=Object.keys(e),s=i.length;s--;)t[i[s]]=e[i[s]];return t}}).call(e,i(55),i(51))},function(module,exports,__webpack_require__){var EventEmitter=__webpack_require__(6).EventEmitter,util=__webpack_require__(0),domUtils=__webpack_require__(7),drawingUtils=__webpack_require__(3),timingUtils=__webpack_require__(8),transmit=__webpack_require__(9),widget=module.exports=function(t){if(EventEmitter.apply(this),this.preClick=this.preClick.bind(this),this.preMove=this.preMove.bind(this),this.preRelease=this.preRelease.bind(this),this.preTouch=this.preTouch.bind(this),this.preTouchMove=this.preTouchMove.bind(this),this.preTouchRelease=this.preTouchRelease.bind(this),this.canvasID=t,this.oscPath="/"+t,!document.getElementById(t)){var e=document.createElement("canvas");e.id=t,document.body.appendChild(e)}if(this.type=void 0,this.canvas=document.getElementById(t),this.context=this.canvas.getContext("2d"),this.checkPercentage(),this.canvas.className=this.canvas.className?this.canvas.className+=" nx":"nx",this.canvas.height=window.getComputedStyle(document.getElementById(t),null).getPropertyValue("height").replace("px",""),this.canvas.width=window.getComputedStyle(document.getElementById(t),null).getPropertyValue("width").replace("px",""),this.height=parseInt(window.getComputedStyle(document.getElementById(t),null).getPropertyValue("height").replace("px","")),this.width=parseInt(window.getComputedStyle(document.getElementById(t),null).getPropertyValue("width").replace("px","")),this.defaultSize||(this.defaultSize={width:100,height:100}),this.label=!1,this.labelSize=30,this.labelAlign="center",this.labelFont="'Open Sans'",null!=this.canvas.getAttribute("label")&&(this.label=this.canvas.getAttribute("label"),this.origDefaultHeight=this.defaultSize.height),this.label&&(this.defaultSize.height+=this.labelSize),300==this.width&&150==this.height)this.canvas.width=2*this.defaultSize.width,this.canvas.height=2*this.defaultSize.height,this.width=this.defaultSize.width,this.height=this.defaultSize.height;else{var i=this.width,s=this.height;this.canvas.width=2*i,this.canvas.height=2*s,this.width=i,this.height=s}this.canvas.style.width=this.canvas.width/2+"px",this.canvas.style.height=this.canvas.height/2+"px",this.context.scale(2,2),this.makeRoomForLabel(),this.offset=domUtils.findPosition(this.canvas),this.center={x:this.GUI.w/2,y:this.GUI.h/2},this.lineWidth=2,this.context.lineWidth=this.lineWidth,this.colors=new Object;for(var n in nx.colors)this.colors[n]=nx.colors[n];this.clickPos={x:0,y:0},this.clickPos.touches=new Array,this.clicked=!1,this.value=0,this.val=new Object,this.pval=new Object,this.nodePos=new Array,this.deltaMove=new Object,this.throttlePeriod=nx.throttlePeriod,this.throttle=timingUtils.throttle,this.hasMoved=!1,this.isRecording=!1,this.tapeNum=0,this.recorder=null,transmit&&(this.sendsTo=transmit.setWidgetTransmit,this.destination="js"),this.events=new Object,nx.isTouchDevice?(this.canvas.ontouchstart=this.preTouch,this.canvas.ontouchmove=this.preTouchMove,this.canvas.ontouchend=this.preTouchRelease):this.canvas.addEventListener("mousedown",this.preClick,!1),this.fontSize=nx.fontSize,this.fontWeight=nx.fontWeight,this.font=nx.font,this.clickCB=!1,this.releaseCB=!1,this.actuated=!0};util.inherits(widget,EventEmitter),widget.prototype.transmit=nx.transmit,widget.prototype.makeOSC=function(t,e){if(this.action=t,"object"==typeof e&&null!==e)for(var i in e)if("object"==typeof e[i]&&null!==e[i])for(var s in e[i])this.action(i+"/"+s,e[i][s]);else this.action(i,e[i]);else"number"!=typeof e&&"string"!=typeof e||this.action("value",e)},widget.prototype.getOffset=function(){this.offset=domUtils.findPosition(this.canvas)},widget.prototype.preClick=function(t){this.actuated=!0,this.offset=domUtils.findPosition(this.canvas),this.clickPos=domUtils.getCursorPosition(t,this.offset),document.addEventListener("mousemove",this.preMove,!1),document.addEventListener("mouseup",this.preRelease,!1),this.clicked=!0,this.deltaMove.x=0,this.deltaMove.y=0,this.hasMoved=!1,this.clickCB&&this.clickCB(),this.click(t),document.body.style.userSelect="none",document.body.style.mozUserSelect="none",document.body.style.webkitUserSelect="none",document.body.style.cursor="pointer"},widget.prototype.preMove=function(t){this.actuated=!0;var e=domUtils.getCursorPosition(t,this.offset);this.deltaMove.y=e.y-this.clickPos.y,this.deltaMove.x=e.x-this.clickPos.x,this.clickPos=e,this.hasMoved=!0,this.move(t)},widget.prototype.preRelease=function(t){this.actuated=!0,document.removeEventListener("mousemove",this.preMove,!1),document.removeEventListener("mouseup",this.preRelease,!1),this.clicked=!1,this.releaseCB&&this.releaseCB(),this.release(),document.body.style.userSelect="text",document.body.style.mozUserSelect="text",document.body.style.webkitUserSelect="text",document.body.style.cursor="default"},widget.prototype.preTouch=function(t){this.actuated=!0,this.clickPos=domUtils.getTouchPosition(t,this.offset),this.clicked=!0,this.deltaMove.x=0,this.deltaMove.y=0,this.hasMoved=!1,this.touch(t)},widget.prototype.preTouchMove=function(t){if(this.clicked){this.actuated=!0;var e=domUtils.getTouchPosition(t,this.offset);this.deltaMove.y=e.y-this.clickPos.y,this.deltaMove.x=e.x-this.clickPos.x,this.clickPos=e,this.hasMoved=!0,this.touchMove(t)}},widget.prototype.preTouchRelease=function(t){if(this.actuated=!0,t.targetTouches.length>=1){var e=domUtils.getTouchPosition(t,this.offset);this.clickPos=e}else this.clicked=!1;this.touchRelease()},widget.prototype.draw=function(){},widget.prototype.click=function(){},widget.prototype.move=function(){},widget.prototype.release=function(){},widget.prototype.touch=function(){this.click()},widget.prototype.touchMove=function(){this.move()},widget.prototype.touchRelease=function(){this.release()},widget.prototype.adjustSizeIfDefault=function(){300==this.width&&150==this.height&&(this.canvas.width=this.defaultSize.width,this.canvas.height=this.defaultSize.height,this.width=this.defaultSize.width,this.height=this.defaultSize.height)},widget.prototype.makeRoundedBG=function(){this.bgLeft=this.lineWidth,this.bgRight=this.width-this.lineWidth,this.bgTop=this.lineWidth,this.bgBottom=this.height-this.lineWidth,this.bgHeight=this.bgBottom-this.lineWidth,this.bgWidth=this.bgRight-this.lineWidth,drawingUtils.makeRoundRect(this.context,this.bgLeft,this.bgTop,this.bgWidth,this.bgHeight)},widget.prototype.erase=function(){this.context.clearRect(0,0,this.width,this.height)},widget.prototype.hideCursor=function(){this.canvas.style.cursor="none"},widget.prototype.showCursor=function(){this.canvas.style.cursor="auto"},widget.prototype.getName=function(){return"deprecated -- use widget.type instead"},widget.prototype.set=function(t,e){if(this.actuated=!1,"object"==typeof this.val&&"null"!==this.val){if("object"==typeof t&&"null"!==t)for(var i in t)this.val[i]=t[i]}else"string"!=typeof this.val&&"number"!=typeof this.val||("object"==typeof t&&"null"!==t?(this.val=t.value,this.draw()):"string"!=typeof t&&"number"!=typeof t||(this.val=t));this.draw(),e&&this.transmit(this.val,!0)},widget.prototype.destroy=function(){var t=nx.elemTypeArr.indexOf(this.getName());nx.elemTypeArr.splice(t,1),this.canvas.ontouchmove=null,this.canvas.ontouchend=null,this.canvas.onclick=null,this.canvas.onmousemove=null,this.canvas.onmouseoff=null,document.removeEventListener("mousemove",this.preMove,!1),document.removeEventListener("mouseup",this.preRelease,!1);var e=document.getElementById(this.canvasID);e&&e.parentNode.removeChild(e),this.customDestroy();var i=this.canvasID;delete nx.widgets[i],delete window[i]},widget.prototype.customDestroy=function(){},widget.prototype.wrapText=function(t,e,i,s,n){if(t){for(var o=t.split(" "),r="",a=0;a<o.length;a++){var h=r+o[a]+" ";this.context.measureText(h).width>s&&a>0?(this.context.fillText(r,e,i),r=o[a]+" ",i+=n):r=h}this.context.fillText(r,e,i)}},widget.prototype.drawLabel=function(){if(this.label)with(this.context)fillStyle=this.colors.black,textAlign="center",textBaseline="middle",font=this.labelSize/2.8+"px "+this.labelFont+" normal",fillText(this.label,this.width/2,this.labelY)},widget.prototype.saveCanv=function(){var t=this.canvas.toDataURL("image/png").replace("image/png","image/octet-stream");window.location.href=t},widget.prototype.setFont=function(){with(this.context)textAlign="center",font=this.fontWeight+" "+this.fontSize+"px "+this.font,fillStyle=this.colors.black,globalAlpha=1},widget.prototype.checkPercentage=function(){var t=this.canvas.style.width,e=this.canvas.style.height;(t.indexOf("%")>=0||e.indexOf("%")>=0)&&(this.percent={w:t.indexOf("%")>=0&&t.replace("%",""),h:e.indexOf("%")>=0&&e.replace("%","")},this.stretch())},widget.prototype.stretch=function(){window.addEventListener("resize",function(t){if(this.percent.w){var e=window.getComputedStyle(this.canvas.parentNode,null).getPropertyValue("width").replace("px","");e*=this.percent.w/100}else var e=!1;if(this.percent.h){var i=window.getComputedStyle(this.canvas.parentNode,null).getPropertyValue("height").replace("px","");i*=this.percent.h/100}else var i=!1;this.resize(e,i)}.bind(this))},widget.prototype.resize=function(t,e){this.canvas.width=t?2*t:this.canvas.width,this.canvas.height=e?2*e:this.canvas.height,this.width=t||this.width,this.height=e||this.height,this.canvas.style.width=this.width+"px",this.canvas.style.height=this.height+"px",this.context.scale(2,2),this.center={x:this.GUI.w/2,y:this.GUI.h/2},this.makeRoomForLabel(),this.init(),this.draw()},widget.prototype.normalize=function(t){return nx.scale(t,this.min,this.max,0,1)},widget.prototype.rangify=function(t){return nx.scale(t,0,1,this.min,this.max)},widget.prototype.makeRoomForLabel=function(){this.GUI={w:this.width,h:this.label?this.height-this.labelSize:this.height},this.labelY=this.height-this.labelSize/2}},function(t,e){e.toPolar=function(t,e){var i=Math.sqrt(t*t+e*e),s=Math.atan2(e,t);return s<0&&(s+=2*Math.PI),{radius:i,angle:s}},e.toCartesian=function(t,e){return{x:t*Math.cos(e),y:t*Math.sin(e)*-1}},e.clip=function(t,e,i){return Math.min(i,Math.max(e,t))},e.prune=function(t,e){if("number"==typeof t)t=parseFloat(t.toFixed(e));else if(t instanceof Array)for(var i=0;i<t.length;i++)"number"==typeof t[i]&&(t[i]=parseFloat(t[i].toFixed(e)));return t},e.scale=function(t,e,i,s,n){return(t-e)*(n-s)/(i-e)+s},e.invert=function(t){return e.scale(t,1,0,0,1)},e.bounce=function(t,e,i,s){return t>e&&t<i?s:t<=e?Math.abs(s):t>=i?-1*Math.abs(s):void 0},e.mtof=function(t){return 440*Math.pow(2,(t-69)/12)},e.random=function(t){return Math.floor(Math.random()*t)},e.interp=function(t,e,i){return t*(i-e)+e},e.lphistory={},e.lp=function(t,e,i){this.lphistory[t]||(this.lphistory[t]=[]);var s=0;this.lphistory[t].push(e),this.lphistory[t].length>i&&this.lphistory[t].splice(0,1);for(var n=0;n<this.lphistory[t].length;n++)s+=this.lphistory[t][n];return s/this.lphistory[t].length},e.lp2=function(t,e){for(var i=0,s=0;s<this.lphistory.length;s++)i+=this.lphistory[s];i+=t;var n=i/(this.lphistory.length+1);return this.lphistory.push(n),this.lphistory.length>e&&this.lphistory.splice(0,1),n},e.lp3=function(t,e,i){var s=t+e*i;return newvalue=s/(i+1),newvalue}},function(module,exports,__webpack_require__){var math=__webpack_require__(2);exports.randomColor=function(){return"rgb("+math.random(250)+","+math.random(250)+","+math.random(250)+")"},exports.hexToRgb=function(t,e){t=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,i,s){return e+e+i+i+s+s});var i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e||(e=.5),"rgba("+parseInt(i[1],16)+","+parseInt(i[2],16)+","+parseInt(i[3],16)+","+e+")"},exports.isInside=function(t,e){return t.x>e.x&&t.x<e.x+e.w&&t.y>e.y&&t.y<e.y+e.h},exports.makeRoundRect=function(t,e,i,s,n,o){var r=e,a=i,h=s+r,l=n+a;o||(o=2),t.beginPath(),t.moveTo(r+o,a),t.lineTo(h-o,a),t.quadraticCurveTo(h,a,h,a+o),t.lineTo(h,l-o),t.quadraticCurveTo(h,l,h-o,l),t.lineTo(r+o,l),t.quadraticCurveTo(r,l,r,l-o),t.lineTo(r,a+o),t.quadraticCurveTo(r,a,r+o,a),t.closePath()},exports.text=function(context,text,position){with(position||(position=[10,10]),context)beginPath(),font="bold 12px sans-serif",fillText(text,position[0],position[1]),closePath()},exports.shadeBlendConvert=function(t,e,i){if("number"!=typeof t||t<-1||t>1||"string"!=typeof e||"r"!=e[0]&&"#"!=e[0]||"string"!=typeof i&&void 0!==i)return null;this.sbcRip=function(t){var e=t.length,i=new Object;if(e>9){if(t=t.split(","),t.length<3||t.length>4)return null;i[0]=s(t[0].slice(4)),i[1]=s(t[1]),i[2]=s(t[2]),i[3]=t[3]?parseFloat(t[3]):-1}else{switch(e){case 8:case 6:case 3:case 2:case 1:return null}e<6&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(e>4?t[4]+""+t[4]:"")),t=s(t.slice(1),16),i[0]=t>>16&255,i[1]=t>>8&255,i[2]=255&t,i[3]=9==e||5==e?n((t>>24&255)/255*1e4)/1e4:-1}return i};var s=parseInt,n=Math.round,o=e.length>9,o="string"==typeof i?i.length>9||"c"==i&&!o:o,r=t<0,t=r?-1*t:t,i=i&&"c"!=i?i:r?"#000000":"#FFFFFF",a=this.sbcRip(e),h=this.sbcRip(i);return a&&h?o?"rgb("+n((h[0]-a[0])*t+a[0])+","+n((h[1]-a[1])*t+a[1])+","+n((h[2]-a[2])*t+a[2])+(a[3]<0&&h[3]<0?")":","+(a[3]>-1&&h[3]>-1?n(1e4*((h[3]-a[3])*t+a[3]))/1e4:h[3]<0?a[3]:h[3])+")"):"#"+(4294967296+16777216*(a[3]>-1&&h[3]>-1?n(255*((h[3]-a[3])*t+a[3])):h[3]>-1?n(255*h[3]):a[3]>-1?n(255*a[3]):255)+65536*n((h[0]-a[0])*t+a[0])+256*n((h[1]-a[1])*t+a[1])+n((h[2]-a[2])*t+a[2])).toString(16).slice(a[3]>-1||h[3]>-1?1:3):null}},function(t,e,i){var s;!function(n,o){void 0!==(s=function(){return o()}.call(e,i,e,t))&&(t.exports=s)}(0,function(){"use strict";function t(t){t(e)}var e;/** +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 16); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; +}; + + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global.process)) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; + } + + if (process.noDeprecation === true) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +}; + + +var debugs = {}; +var debugEnviron; +exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; + } else { + debugs[set] = function() {}; + } + } + return debugs[set]; +}; + + +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; + + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; + + +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } +} + + +function stylizeNoColor(str, styleType) { + return str; +} + + +function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; +} + + +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = __webpack_require__(54); + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = __webpack_require__(53); + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(56), __webpack_require__(52))) + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +var EventEmitter = __webpack_require__(6).EventEmitter; +var util = __webpack_require__(0); +var domUtils = __webpack_require__(7); +var drawingUtils = __webpack_require__(3); +var timingUtils = __webpack_require__(8); +var transmit = __webpack_require__(9); + + + +var widget = module.exports = function (target) { + EventEmitter.apply(this) + this.preClick = this.preClick.bind(this) + this.preMove = this.preMove.bind(this) + this.preRelease = this.preRelease.bind(this) + this.preTouch = this.preTouch.bind(this) + this.preTouchMove = this.preTouchMove.bind(this) + this.preTouchRelease = this.preTouchRelease.bind(this) + +/** + + @class widget + All NexusUI interface widgets inherit from the widget class. The properties and methods of the widget class are usable by any NexusUI interface. + +*/ + + /** @property {string} canvasID ID attribute of the interface's HTML5 canvas */ + this.canvasID = target; + /** @property {string} oscPath OSC prefix for this interface. By default this is populated using the canvas ID (i.e. an ID of dial1 has OSC path /dial1) */ + this.oscPath = "/"+target; + if (!document.getElementById(target)) { + var newcanv = document.createElement("canvas") + newcanv.id = target; + document.body.appendChild(newcanv) + } + /** + * @property {string} type The type of NexusUI widget (i.e. "dial", "toggle", "slider"). Set automatically at creation. + */ + this.type = undefined; + /** @property {DOM element} canvas The widget's HTML5 canvas */ + this.canvas = document.getElementById(target); + /** @property {HTML5 drawing context} context The canvas's drawing context */ + this.context = this.canvas.getContext("2d"); + + this.checkPercentage(); + this.canvas.className = this.canvas.className ? this.canvas.className += " nx" : "nx" + + this.canvas.height = window.getComputedStyle(document.getElementById(target), null).getPropertyValue("height").replace("px",""); + this.canvas.width = window.getComputedStyle(document.getElementById(target), null).getPropertyValue("width").replace("px",""); + /** @property {integer} height The widget canvas's computed height in pixels */ + this.height = parseInt(window.getComputedStyle(document.getElementById(target), null).getPropertyValue("height").replace("px","")); + /** @property {integer} width The widget canvas's computed width in pixels */ + this.width = parseInt(window.getComputedStyle(document.getElementById(target), null).getPropertyValue("width").replace("px","")); + if (!this.defaultSize) { + /** @property {object} defaultSize The widget's default size if not defined with HTML/CSS style. (Has properties 'width' and 'height', both in pixels) */ + this.defaultSize = { width: 100, height: 100 }; + } + + /** @property {boolean} label Whether or not to draw a text label this widget. */ + this.label = false + this.labelSize = 30 + this.labelAlign = "center" + this.labelFont = "'Open Sans'" + + if (this.canvas.getAttribute("label")!=null) { + this.label = this.canvas.getAttribute("label") + this.origDefaultHeight = this.defaultSize.height + } + if (this.label) { + this.defaultSize.height += this.labelSize + } + + if (this.width==300 && this.height==150) { + this.canvas.width = this.defaultSize.width*2; + this.canvas.height = this.defaultSize.height*2; + this.width = this.defaultSize.width; + this.height = this.defaultSize.height; + } else { + var proxyw = this.width; + var proxyh = this.height; + this.canvas.width = proxyw*2; + this.canvas.height = proxyh*2; + this.width = proxyw; + this.height = proxyh; + } + this.canvas.style.width = this.canvas.width/2+"px"; + this.canvas.style.height = this.canvas.height/2+"px"; + this.context.scale(2,2) + + + this.makeRoomForLabel() + + /** @property {object} offset The widget's computed offset from the top left of the document. (Has properties 'top' and 'left', both in pixels) */ + this.offset = domUtils.findPosition(this.canvas); + /** @property {object} center The center of the widget's canvas. A 100x100 widget would have a center at 50x50. (Has properties 'x' and 'y', both in pixels) */ + this.center = { + x: this.GUI.w/2, + y: this.GUI.h/2 + }; + //drawing + /** @property {integer} lineWidth The default line width for drawing (default is 2 pixels). In many widgets, this is overwritten to suite the widget. However it does dictate the border width on most widgets. */ + this.lineWidth = 2; + this.context.lineWidth = this.lineWidth; + /** @property {object} colors A widget's individual color scheme. Inherited from nx.colors. (Has properties "accent", "fill", "border", "black", and "white") */ + this.colors = new Object(); + // define colors individually so they are not pointers to nx.colors + // this way each object can have its own color scheme + for (var key in nx.colors) { + this.colors[key] = nx.colors[key] + } + /*this.colors.accent = nx.colors.accent; + this.colors.fill = nx.colors.fill; + this.colors.border = nx.colors.border; + this.colors.accentborder = nx.colors.accentborder; + this.colors.black = nx.colors.black; + this.colors.white = nx.colors.white; + this.colors.highlight = nx.colors.highlight; */ + //interaction + /** @property {object} clickPos The most recent mouse/touch position when interating with a widget. (Has properties x and y) */ + this.clickPos = {x: 0, y: 0}; + /** @property {array} clickPos.touches If multitouch, an array of touch positions */ + this.clickPos.touches = new Array(); + /** @property {boolean} clicked Whether or not the widget is currently clicked */ + this.clicked = false; + this.value = 0; + /** + @property {object} val An object containing the core interactive values of the widget, which are also the widget's data output. + */ + this.val = new Object(); + this.pval = new Object(); + this.nodePos = new Array(); + /** @property {object} deltaMove Difference between the current touch/mouse position and the previous touch/mouse position, in pixels. */ + this.deltaMove = new Object(); + this.throttlePeriod = nx.throttlePeriod; + this.throttle = timingUtils.throttle; + this.hasMoved = false; + //recording + /** @property {boolean} isRecording Whether or not this widget's output is being recorded to a "remix" widget */ + this.isRecording = false; + this.tapeNum = 0; + this.recorder = null; + //transmission + if (transmit) { + /** @method sendsTo + Set the transmission protocol for this widget individually + @param {string or function} [destination] Protocol for transmitting data from this widget (i.e. "js", "ajax", "ios", "max", or "node"). Also accepts custom functions. + ```js + dial1.sendsTo("ajax") + + // or + + dial1.sendsTo(function(data) { + //define a custom transmission function + }) + ``` + */ + this.sendsTo = transmit.setWidgetTransmit; + this.destination = "js"; + } + this.events = new Object(); + + // Setup interaction + if (nx.isTouchDevice) { + this.canvas.ontouchstart = this.preTouch; + this.canvas.ontouchmove = this.preTouchMove; + this.canvas.ontouchend = this.preTouchRelease; + } else { +// if ('onmousedown' in document.documentElement) { + this.canvas.addEventListener('mousedown', this.preClick, false); + } + + this.fontSize = nx.fontSize; + this.fontWeight = nx.fontWeight; + this.font = nx.font; + + this.clickCB = false; + this.releaseCB = false; + + this.actuated = true; + + + +} +util.inherits(widget, EventEmitter) + +/** @method transmit + The "output" instructions for sending the widget's data to another application or to a JS callback. Inherited from nx.transmit and executed when each widget is interacted with or during animation. Set using .sendsTo() to use our built-in transmission defintions. + @param {object} [data] The data to be transmitted. Each property of the object will become its own OSC message if sending via "ajax" or "max7" protocols. (This works with objects nested to up to 2 levels). +*/ +widget.prototype.transmit = nx.transmit; + +/** @method makeOSC + Loops through an object (i.e. a widget's data), creates OSC path/value pairs, and executes a callback function with these two arguments. + @param {function} [callback] A function defining the action to be taken with each OSC path/value pair. This function should have two parameters, path (string) and data (type depends on widget data type). + @param {object} [data] The data as an object, to be broken into individual OSC messages. +*/ +widget.prototype.makeOSC = function(action, data) { + this.action = action; + if ((typeof data == "object") && (data !== null)) { + for (var key in data) { + if ((typeof data[key] == "object") && (data[key] !== null)) { + for (var key2 in data[key]) { + this.action(key+"/"+key2, data[key][key2]) + } + } else { + this.action(key, data[key]) + } + } + } else if (typeof data == "number" || typeof data == "string") { + this.action('value', data) + } +} + +// getoffset is useful as an API for others +// otherwise they would have to write +// dial1.offset = utils.findPosition() +// now it is simply: +// dial1.getOffset() + +/** @method getOffset + Recalculate the computed offset of the widget's canvas and store it in widget.offset. This is useful if a widget has been moved after being created. + */ +widget.prototype.getOffset = function() { + this.offset = domUtils.findPosition(this.canvas) +} + +widget.prototype.preClick = function(e) { + this.actuated = true; + this.offset = domUtils.findPosition(this.canvas) + this.clickPos = domUtils.getCursorPosition(e, this.offset); + // need something like: + // if (this.clickPos.y < this.GUI.h) { + document.addEventListener("mousemove", this.preMove, false); + document.addEventListener("mouseup", this.preRelease, false); + this.clicked = true; + this.deltaMove.x = 0; + this.deltaMove.y = 0; + this.hasMoved = false; + this.clickCB ? this.clickCB() : null; + this.click(e); + document.body.style.userSelect = "none"; + document.body.style.mozUserSelect = "none"; + document.body.style.webkitUserSelect = "none"; + document.body.style.cursor = "pointer"; +} + +widget.prototype.preMove = function(e) { + this.actuated = true; + var newClickPos = domUtils.getCursorPosition(e, this.offset); + this.deltaMove.y = newClickPos.y - this.clickPos.y; + this.deltaMove.x = newClickPos.x - this.clickPos.x; + this.clickPos = newClickPos; + this.hasMoved = true; + this.move(e); +} + +widget.prototype.preRelease = function(e) { + this.actuated = true; + document.removeEventListener("mousemove", this.preMove, false); + document.removeEventListener("mouseup", this.preRelease, false); + this.clicked = false; + this.releaseCB ? this.releaseCB() : null; + this.release(); + document.body.style.userSelect = "text"; + document.body.style.mozUserSelect = "text"; + document.body.style.webkitUserSelect = "text"; + document.body.style.cursor = "default"; +} + +widget.prototype.preTouch = function(e) { + this.actuated = true; + this.clickPos = domUtils.getTouchPosition(e, this.offset); + this.clicked = true; + this.deltaMove.x = 0; + this.deltaMove.y = 0; + this.hasMoved = false; + this.touch(e); +} + +widget.prototype.preTouchMove = function(e) { + if (this.clicked) { + this.actuated = true; + var newClickPos = domUtils.getTouchPosition(e, this.offset); + this.deltaMove.y = newClickPos.y - this.clickPos.y; + this.deltaMove.x = newClickPos.x - this.clickPos.x; + this.clickPos = newClickPos; + this.hasMoved = true; + this.touchMove(e); + } +} + +widget.prototype.preTouchRelease = function(e) { + this.actuated = true; + if (e.targetTouches.length>=1) { + var newClickPos = domUtils.getTouchPosition(e, this.offset); + this.clickPos = newClickPos; + } else { + this.clicked = false; + } + this.touchRelease(); +} + + +/** @method init + Initialize or re-initialize the widget. Defined separately within each widget. + */ + +/** @method draw + Draw the widget onto the canvas. + */ +widget.prototype.draw = function() { +} + + +/** @method click + Executes when the widget is clicked on + */ +widget.prototype.click = function() { +} + + +/** @method move + Executes on drag (mouse moves while clicked). + */ +widget.prototype.move = function() { +} + + +/** @method release + Executes when the mouse releases after having clicked on the widget. + */ +widget.prototype.release = function() { +} + +/** @method touch + Executes when the widget is touched on a touch device. + */ +widget.prototype.touch = function() { + this.click(); +} + +/** @method touchMove + Executes on drag (touch then move) on a touch device + */ +widget.prototype.touchMove = function() { + this.move(); +} + +/** @method touchRelease + Executes when the touch releases after having touched the widget. + */ +widget.prototype.touchRelease = function() { + this.release(); +} + +widget.prototype.adjustSizeIfDefault = function() { + if (this.width==300 && this.height==150) { + this.canvas.width = this.defaultSize.width; + this.canvas.height = this.defaultSize.height; + this.width = this.defaultSize.width; + this.height = this.defaultSize.height; + } +} + +widget.prototype.makeRoundedBG = function() { + this.bgLeft = this.lineWidth; + this.bgRight = this.width - this.lineWidth; + this.bgTop = this.lineWidth; + this.bgBottom = this.height - this.lineWidth; + this.bgHeight = this.bgBottom - this.lineWidth; + this.bgWidth = this.bgRight - this.lineWidth; + + drawingUtils.makeRoundRect(this.context, this.bgLeft, this.bgTop, this.bgWidth, this.bgHeight); +} + +/** @method erase + Erase the widget's canvas. + */ +widget.prototype.erase = function() { + this.context.clearRect(0,0,this.width,this.height); +} + +widget.prototype.hideCursor = function() { + this.canvas.style.cursor = "none"; +} + +widget.prototype.showCursor = function() { + this.canvas.style.cursor = "auto"; +} + +// allow us to get the constructor function name programatically +//i.e. if element is a dial, this function will return "dial" +//deprecated +widget.prototype.getName = function() { + return "deprecated -- use widget.type instead" +} + +/** @method set +Manually set a widget's value (that is, set any properties of a widget's .val). See widget.val or the .val property of individual widgets for more info. +@param {object} [data] Parameter/value pairs in object notation. +@param {boolean} [transmit] (optional) Whether or not to transmit new value after being set. +Sets the value of an object. + +```js + position1.set({ + x: 100, + y: 250 + }) +``` + +An optional second argument decides whether the object then transmits its new value. +```js + button1.set({ + press: 100 + }, true) +``` +*/ +widget.prototype.set = function(data, transmit) { + + this.actuated = false; + + if (typeof this.val == "object" && this.val !== "null") { + if (typeof data == "object" && data !== "null") { + for (var key in data) { + this.val[key] = data[key]; + } + } + } else if (typeof this.val == "string" || typeof this.val == "number") { + if (typeof data == "object" && data !== "null") { + this.val = data["value"]; + this.draw(); + } else if (typeof data == "string" || typeof data == "number") { + this.val = data; + } + } + this.draw(); + + if (transmit) { + this.transmit(this.val,true) + } +} + +/** @method destroy + Remove the widget object, canvas, and all related event listeners from the document. + */ +widget.prototype.destroy = function() { + var type = nx.elemTypeArr.indexOf(this.getName()) + nx.elemTypeArr.splice(type,1) + + this.canvas.ontouchmove = null; + this.canvas.ontouchend = null; + this.canvas.onclick = null; + this.canvas.onmousemove = null; + this.canvas.onmouseoff = null; + document.removeEventListener("mousemove", this.preMove, false); + document.removeEventListener("mouseup", this.preRelease, false); + + var elemToKill = document.getElementById(this.canvasID) + if (elemToKill) { + elemToKill.parentNode.removeChild(elemToKill); + } + + this.customDestroy(); + + var id = this.canvasID + delete nx.widgets[id]; + delete window[id]; + +} + +widget.prototype.customDestroy = function() { + +} + +widget.prototype.wrapText = function(text, x, y, maxWidth, lineHeight) { + if (text) { + var words = text.split(' '); + var line = ''; + + for(var n = 0; n < words.length; n++) { + var testLine = line + words[n] + ' '; + var metrics = this.context.measureText(testLine); + var testWidth = metrics.width; + if (testWidth > maxWidth && n > 0) { + this.context.fillText(line, x, y); + line = words[n] + ' '; + y += lineHeight; + } + else { + line = testLine; + } + } + this.context.fillText(line, x, y); + } +} + +widget.prototype.drawLabel = function() { + if (this.label) { + with(this.context) { + fillStyle = this.colors.black; + textAlign = "center" + textBaseline = "middle"; + font = (this.labelSize/2.8) + "px "+this.labelFont+" normal" + fillText(this.label,this.width/2,this.labelY); + } + } +} + +/** @method saveCanv + Download the widget's current graphical state as an image (png). + */ +widget.prototype.saveCanv = function() { + var data = this.canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"); + window.location.href = data +} + +widget.prototype.setFont = function() { + with (this.context) { + textAlign = "center"; + font = this.fontWeight+" "+this.fontSize+"px "+this.font; + fillStyle = this.colors.black; + globalAlpha = 1; + } +} + + +/* Percentage width support */ + + +widget.prototype.checkPercentage = function() { + var wstr = this.canvas.style.width; + var hstr = this.canvas.style.height; + if (wstr.indexOf("%") >= 0 || hstr.indexOf("%") >= 0) { + this.percent = { + w: (wstr.indexOf("%") >= 0) ? wstr.replace("%","") : false, + h: (hstr.indexOf("%") >= 0) ? hstr.replace("%","") : false + } + this.stretch(); + } +} + +widget.prototype.stretch = function() { + window.addEventListener("resize", function(e) { + if (this.percent.w) { + var newWidth = window.getComputedStyle(this.canvas.parentNode, null).getPropertyValue("width").replace("px",""); + newWidth *= this.percent.w/100 + } else { + var newWidth = false; + } + if (this.percent.h) { + var newHeight = window.getComputedStyle(this.canvas.parentNode, null).getPropertyValue("height").replace("px",""); + newHeight *= this.percent.h/100 + } else { + var newHeight = false; + } + this.resize(newWidth,newHeight); + }.bind(this)) +} + +widget.prototype.resize = function(w,h) { + + this.canvas.width = w ? w*2 : this.canvas.width; + this.canvas.height = h ? h*2 : this.canvas.height; + this.width = w ? w : this.width; + this.height = h ? h : this.height; + this.canvas.style.width = this.width+"px"; + this.canvas.style.height = this.height+"px"; + this.context.scale(2,2) + + this.center = { + x: this.GUI.w/2, + y: this.GUI.h/2 + }; + + this.makeRoomForLabel() + + this.init(); + this.draw(); + +} + +widget.prototype.normalize = function(value) { + return nx.scale(value,this.min,this.max,0,1) +} +widget.prototype.rangify = function(value) { + return nx.scale(value,0,1,this.min,this.max) +} + + +widget.prototype.makeRoomForLabel = function() { + this.GUI = { + w: this.width, + h: this.label ? this.height - this.labelSize : this.height + } + this.labelY = this.height - this.labelSize/2; + // must add the above code to widget.resize +} + + +/***/ }), +/* 2 */ +/***/ (function(module, exports) { + + + +/** @method toPolar + Receives cartesian coordinates and returns polar coordinates as an object with 'radius' and 'angle' properties. + @param {float} [x] + @param {float} [y] + ```js + var ImOnACircle = nx.toPolar({ x: 20, y: 50 }}) + ``` +*/ +exports.toPolar = function(x,y) { + var r = Math.sqrt(x*x + y*y); + + var theta = Math.atan2(y,x); + if (theta < 0.) { + theta = theta + (2 * Math.PI); + } + return {radius: r, angle: theta}; +} + +/** @method toCartesian + Receives polar coordinates and returns cartesian coordinates as an object with 'x' and 'y' properties. + @param {float} [radius] + @param {float} [angle] +*/ +exports.toCartesian = function(radius, angle){ + var cos = Math.cos(angle); + var sin = Math.sin(angle); + return {x: radius*cos, y: radius*sin*-1}; +} + + +/** @method clip + Limits a number to within low and high values. + @param {float} [input value] + @param {float} [low limit] + @param {float} [high limit] + ```js + nx.clip(5,0,10) // returns 5 + nx.clip(15,0,10) // returns 10 + nx.clip(-1,0,10) // returns 0 + ``` +*/ +exports.clip = function(value, low, high) { + return Math.min(high, Math.max(low, value)); +} + +/** @method prune + Limits a float to within a certain number of decimal places + @param {float} [input value] + @param {integer} [max decimal places] + ```js + nx.prine(1.2345, 3) // returns 1.234 + nx.prune(1.2345, 1) // returns 1.2 + ``` +*/ + +exports.prune = function(data, scale) { + if (typeof data === "number") { + data = parseFloat(data.toFixed(scale)); + } else if (data instanceof Array) { + for (var i=0;i<data.length;i++) { + if (typeof data[i]=="number") { + data[i] = parseFloat(data[i].toFixed(scale)); + } + } + } + return data; +} + + +/** @method scale + Scales an input number to a new range of numbers + @param {float} [input value] + @param {float} [low1] input range (low) + @param {float} [high1] input range (high) + @param {float} [low2] output range (low) + @param {float} [high2] output range (high) + ```js + nx.scale(5,0,10,0,100) // returns 50 + nx.scale(5,0,10,1,2) // returns 1.5 + ``` +*/ +exports.scale = function(inNum, inMin, inMax, outMin, outMax) { + return (((inNum - inMin) * (outMax - outMin)) / (inMax - inMin)) + outMin; +} + +/** @method invert + Equivalent to nx.scale(input,0,1,1,0). Inverts a normalized (0-1) number. + @param {float} [input value] + ```js + nx.invert(0.25) // returns 0.75 + nx.invert(0) // returns 1 + ``` +*/ +exports.invert = function (inNum) { + return exports.scale(inNum, 1, 0, 0, 1); +} + +exports.bounce = function(posIn, borderMin, borderMax, delta) { + if (posIn > borderMin && posIn < borderMax) { + return delta; + } else if (posIn <= borderMin) { + return Math.abs(delta); + } else if (posIn >= borderMax) { + return Math.abs(delta) * (-1); + } +} + + +/** @method mtof + MIDI to frequency conversion. Returns frequency in Hz. + @param {float} [MIDI] MIDI value to convert + ```js + nx.mtof(69) // returns 440 + ``` +*/ +exports.mtof = function(midi) { + return Math.pow(2, ((midi-69)/12)) * 440; +} + + +/** @method random + Returns a random integer between 0 a given scale parameter. + @param {float} [scale] Upper limit of random range. + ```js + nx.random(10) // returns a random number from 0 to 9. + ``` +*/ +exports.random = function(scale) { + return Math.floor(Math.random() * scale); +} + + +exports.interp = function(loc,min,max) { + return loc * (max - min) + min; +} + +exports.lphistory = {} + + +exports.lp = function(tag,value,limit) { + + if (!this.lphistory[tag]) { + this.lphistory[tag] = [] + } + + var total = 0; + + this.lphistory[tag].push(value) + + if (this.lphistory[tag].length>limit) { + this.lphistory[tag].splice(0,1) + } + + for (var i=0;i<this.lphistory[tag].length;i++) { + total += this.lphistory[tag][i] + } + + var newvalue = total / this.lphistory[tag].length; + + return newvalue; +} + + +exports.lp2 = function(value,limit) { + + var total = 0; + for (var i=0;i<this.lphistory.length;i++) { + total += this.lphistory[i] + } + total += value; + + var newvalue = total / ( this.lphistory.length + 1 ) + + this.lphistory.push(newvalue) + + if (this.lphistory.length>limit) { + this.lphistory.splice(0,1) + } + + return newvalue; +} + + +exports.lp3 = function(value,pvalue,limit) { + + var total = value + pvalue * limit; + newvalue = total / (limit + 1) + + return newvalue; +} + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2) + +/** @method randomColor + Returns a random color string in rgb format +*/ +exports.randomColor = function() { + return "rgb(" + math.random(250) + "," + math.random(250) + "," + math.random(250) + ")"; +} + +/** @method hexToRgb + Converts a hex color code to rgb format + @param {color code} [hex] Input color code in hex format + @param {float} [alpha] Color alpha level +*/ +exports.hexToRgb = function(hex, a) { + // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") + var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; + hex = hex.replace(shorthandRegex, function(m, r, g, b) { + return r + r + g + g + b + b; + }); + + var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); + if (!a) { + a = 0.5; + } + + var r = parseInt(result[1], 16); + var g = parseInt(result[2], 16); + var b = parseInt(result[3], 16); + + return "rgba(" + r + "," + g + "," + b + "," + a + ")"; +} + +exports.isInside = function(clickedNode,currObject) { + if (clickedNode.x > currObject.x && clickedNode.x < (currObject.x+currObject.w) && clickedNode.y > currObject.y && clickedNode.y < (currObject.y+currObject.h)) { + return true; + } else { + return false; + } +} + +exports.makeRoundRect = function(ctx,xpos,ypos,wid,hgt,depth) { + var x1 = xpos; + var y1 = ypos; + var x2 = wid+x1; + var y2 = hgt+y1; + if (!depth) { + depth = 2; + } + + ctx.beginPath(); + ctx.moveTo(x1+depth, y1); //TOP LEFT + ctx.lineTo(x2-depth, y1); //TOP RIGHT + ctx.quadraticCurveTo(x2, y1, x2, y1+depth); + ctx.lineTo(x2, y2-depth); //BOTTOM RIGHT + ctx.quadraticCurveTo(x2, y2, x2-depth, y2); + ctx.lineTo(x1+depth, y2); //BOTTOM LEFT + ctx.quadraticCurveTo(x1, y2, x1, y2-depth); + ctx.lineTo(x1, y1+depth); //TOP LEFT + ctx.quadraticCurveTo(x1, y1, x1+depth, y1); + ctx.closePath(); +} + +exports.text = function(context, text, position) { + if (!position) { + position = [10 , 10]; + } + with(context) { + beginPath(); + font = "bold 12px sans-serif"; + fillText(text,position[0],position[1]); + closePath(); + } +} + +exports.shadeBlendConvert = function(p, from, to) { + if(typeof(p)!="number"||p<-1||p>1||typeof(from)!="string"||(from[0]!='r'&&from[0]!='#')||(typeof(to)!="string"&&typeof(to)!="undefined"))return null; //ErrorCheck + this.sbcRip=function(d){ + var l=d.length,RGB=new Object(); + if(l>9){ + d=d.split(","); + if(d.length<3||d.length>4)return null;//ErrorCheck + RGB[0]=i(d[0].slice(4)),RGB[1]=i(d[1]),RGB[2]=i(d[2]),RGB[3]=d[3]?parseFloat(d[3]):-1; + }else{ + switch(l){case 8:case 6:case 3:case 2:case 1:return null;} //ErrorCheck + if(l<6)d="#"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3]+(l>4?d[4]+""+d[4]:""); //3 digit + d=i(d.slice(1),16),RGB[0]=d>>16&255,RGB[1]=d>>8&255,RGB[2]=d&255,RGB[3]=l==9||l==5?r(((d>>24&255)/255)*10000)/10000:-1; + } + return RGB;} + var i=parseInt,r=Math.round,h=from.length>9,h=typeof(to)=="string"?to.length>9?true:to=="c"?!h:false:h,b=p<0,p=b?p*-1:p,to=to&&to!="c"?to:b?"#000000":"#FFFFFF",f=this.sbcRip(from),t=this.sbcRip(to); + if(!f||!t)return null; //ErrorCheck + if(h)return "rgb("+r((t[0]-f[0])*p+f[0])+","+r((t[1]-f[1])*p+f[1])+","+r((t[2]-f[2])*p+f[2])+(f[3]<0&&t[3]<0?")":","+(f[3]>-1&&t[3]>-1?r(((t[3]-f[3])*p+f[3])*10000)/10000:t[3]<0?f[3]:t[3])+")"); + else return "#"+(0x100000000+(f[3]>-1&&t[3]>-1?r(((t[3]-f[3])*p+f[3])*255):t[3]>-1?r(t[3]*255):f[3]>-1?r(f[3]*255):255)*0x1000000+r((t[0]-f[0])*p+f[0])*0x10000+r((t[1]-f[1])*p+f[1])*0x100+r((t[2]-f[2])*p+f[2])).toString(16).slice(f[3]>-1||t[3]>-1?1:3); +} + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory){ + + //UMD + if ( true ) { + !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { + return factory(); + }.call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof module === "object") { + module.exports = factory(); + } else { + root.Tone = factory(); + } + +}(this, function(){ + + "use strict"; + + var Tone; + //constructs the main Tone object + function Main(func){ + Tone = func(); + } + //invokes each of the modules with the main Tone object as the argument + function Module(func){ + func(Tone); + } /** * Tone.js * @author Yotam Mann * @license http://opensource.org/licenses/MIT MIT License - * @copyright 2014-2017 Yotam Mann + * @copyright 2014-2018 Yotam Mann */ -return function(t){e=t()}(function(){var t=function(t,e){this.isUndef(t)||1===t?this.input=this.context.createGain():t>1&&(this.input=new Array(t)),this.isUndef(e)||1===e?this.output=this.context.createGain():e>1&&(this.output=new Array(t))};t.prototype.set=function(e,i,s){if(this.isObject(e))s=i;else if(this.isString(e)){var n={};n[e]=i,e=n}t:for(var o in e){i=e[o];var r=this;if(-1!==o.indexOf(".")){for(var a=o.split("."),h=0;h<a.length-1;h++)if((r=r[a[h]])instanceof t){a.splice(0,h+1);var l=a.join(".");r.set(l,i);continue t}o=a[a.length-1]}var c=r[o];this.isUndef(c)||(t.Signal&&c instanceof t.Signal||t.Param&&c instanceof t.Param?c.value!==i&&(this.isUndef(s)?c.value=i:c.rampTo(i,s)):c instanceof AudioParam?c.value!==i&&(c.value=i):c instanceof t?c.set(i):c!==i&&(r[o]=i))}return this},t.prototype.get=function(e){this.isUndef(e)?e=this._collectDefaults(this.constructor):this.isString(e)&&(e=[e]);for(var i={},s=0;s<e.length;s++){var n=e[s],o=this,r=i;if(-1!==n.indexOf(".")){for(var a=n.split("."),h=0;h<a.length-1;h++){var l=a[h];r[l]=r[l]||{},r=r[l],o=o[l]}n=a[a.length-1]}var c=o[n];this.isObject(e[n])?r[n]=c.get():t.Signal&&c instanceof t.Signal?r[n]=c.value:t.Param&&c instanceof t.Param?r[n]=c.value:c instanceof AudioParam?r[n]=c.value:c instanceof t?r[n]=c.get():this.isFunction(c)||this.isUndef(c)||(r[n]=c)}return i},t.prototype._collectDefaults=function(t){var e=[];if(this.isUndef(t.defaults)||(e=Object.keys(t.defaults)),!this.isUndef(t._super))for(var i=this._collectDefaults(t._super),s=0;s<i.length;s++)-1===e.indexOf(i[s])&&e.push(i[s]);return e},t.prototype.toString=function(){for(var e in t){var i=e[0].match(/^[A-Z]$/),s=t[e]===this.constructor;if(this.isFunction(t[e])&&i&&s)return e}return"Tone"},Object.defineProperty(t.prototype,"numberOfInputs",{get:function(){return this.input?this.isArray(this.input)?this.input.length:1:0}}),Object.defineProperty(t.prototype,"numberOfOutputs",{get:function(){return this.output?this.isArray(this.output)?this.output.length:1:0}}),t.prototype.dispose=function(){return this.isUndef(this.input)||(this.input instanceof AudioNode&&this.input.disconnect(),this.input=null),this.isUndef(this.output)||(this.output instanceof AudioNode&&this.output.disconnect(),this.output=null),this},t.prototype.connect=function(t,e,i){return Array.isArray(this.output)?(e=this.defaultArg(e,0),this.output[e].connect(t,0,i)):this.output.connect(t,e,i),this},t.prototype.disconnect=function(t,e,i){this.isArray(this.output)?this.isNumber(t)?this.output[t].disconnect():(e=this.defaultArg(e,0),this.output[e].disconnect(t,0,i)):this.output.disconnect.apply(this.output,arguments)},t.prototype.connectSeries=function(){if(arguments.length>1)for(var t=arguments[0],e=1;e<arguments.length;e++){var i=arguments[e];t.connect(i),t=i}return this},t.prototype.chain=function(){if(arguments.length>0)for(var t=this,e=0;e<arguments.length;e++){var i=arguments[e];t.connect(i),t=i}return this},t.prototype.fan=function(){if(arguments.length>0)for(var t=0;t<arguments.length;t++)this.connect(arguments[t]);return this},AudioNode.prototype.chain=t.prototype.chain,AudioNode.prototype.fan=t.prototype.fan,t.prototype.defaultArg=function(t,e){if(this.isObject(t)&&this.isObject(e)){var i={};for(var s in t)i[s]=this.defaultArg(e[s],t[s]);for(var n in e)i[n]=this.defaultArg(t[n],e[n]);return i}return this.isUndef(t)?e:t},t.prototype.optionsObject=function(t,e,i){var s={};if(1===t.length&&this.isObject(t[0]))s=t[0];else for(var n=0;n<e.length;n++)s[e[n]]=t[n];return this.isUndef(i)?s:this.defaultArg(s,i)},t.prototype.isUndef=function(t){return void 0===t},t.prototype.isFunction=function(t){return"function"==typeof t},t.prototype.isNumber=function(t){return"number"==typeof t},t.prototype.isObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)&&t.constructor===Object},t.prototype.isBoolean=function(t){return"boolean"==typeof t},t.prototype.isArray=function(t){return Array.isArray(t)},t.prototype.isString=function(t){return"string"==typeof t},t.noOp=function(){},t.prototype._readOnly=function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)this._readOnly(t[e]);else Object.defineProperty(this,t,{writable:!1,enumerable:!0})},t.prototype._writable=function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)this._writable(t[e]);else Object.defineProperty(this,t,{writable:!0})},t.State={Started:"started",Stopped:"stopped",Paused:"paused"},t.prototype.equalPowerScale=function(t){var e=.5*Math.PI;return Math.sin(t*e)},t.prototype.dbToGain=function(t){return Math.pow(2,t/6)},t.prototype.gainToDb=function(t){return Math.log(t)/Math.LN10*20},t.prototype.intervalToFrequencyRatio=function(t){return Math.pow(2,t/12)},t.prototype.now=function(){return t.context.now()},t.now=function(){return t.context.now()},t.extend=function(e,i){function s(){}t.prototype.isUndef(i)&&(i=t),s.prototype=i.prototype,e.prototype=new s,e.prototype.constructor=e,e._super=i};var e;return Object.defineProperty(t,"context",{get:function(){return e},set:function(i){e=t.Context&&i instanceof t.Context?i:new t.Context(i),t.Context&&t.Context.emit("init",e)}}),Object.defineProperty(t.prototype,"context",{get:function(){return t.context}}),t.setContext=function(e){t.context=e},Object.defineProperty(t.prototype,"blockTime",{get:function(){return 128/this.context.sampleRate}}),Object.defineProperty(t.prototype,"sampleTime",{get:function(){return 1/this.context.sampleRate}}),Object.defineProperty(t,"supported",{get:function(){var t=window.hasOwnProperty("AudioContext")||window.hasOwnProperty("webkitAudioContext"),e=window.hasOwnProperty("Promise"),i=window.hasOwnProperty("Worker");return t&&e&&i}}),t.version="r10",window.TONE_SILENCE_VERSION_LOGGING||console.log("%c * Tone.js "+t.version+" * ","background: #000; color: #fff"),t}),t(function(t){return t.SignalBase=function(){},t.extend(t.SignalBase),t.SignalBase.prototype.connect=function(e,i,s){return t.Signal&&t.Signal===e.constructor||t.Param&&t.Param===e.constructor||t.TimelineSignal&&t.TimelineSignal===e.constructor?(e._param.cancelScheduledValues(0),e._param.value=0,e.overridden=!0):e instanceof AudioParam&&(e.cancelScheduledValues(0),e.value=0),t.prototype.connect.call(this,e,i,s),this},t.SignalBase}),t(function(t){return t.WaveShaper=function(t,e){this._shaper=this.input=this.output=this.context.createWaveShaper(),this._curve=null,Array.isArray(t)?this.curve=t:isFinite(t)||this.isUndef(t)?this._curve=new Float32Array(this.defaultArg(t,1024)):this.isFunction(t)&&(this._curve=new Float32Array(this.defaultArg(e,1024)),this.setMap(t))},t.extend(t.WaveShaper,t.SignalBase),t.WaveShaper.prototype.setMap=function(t){for(var e=0,i=this._curve.length;e<i;e++){var s=e/(i-1)*2-1;this._curve[e]=t(s,e)}return this._shaper.curve=this._curve,this},Object.defineProperty(t.WaveShaper.prototype,"curve",{get:function(){return this._shaper.curve},set:function(t){this._curve=new Float32Array(t),this._shaper.curve=this._curve}}),Object.defineProperty(t.WaveShaper.prototype,"oversample",{get:function(){return this._shaper.oversample},set:function(t){if(-1===["none","2x","4x"].indexOf(t))throw new RangeError("Tone.WaveShaper: oversampling must be either 'none', '2x', or '4x'");this._shaper.oversample=t}}),t.WaveShaper.prototype.dispose=function(){return t.prototype.dispose.call(this),this._shaper.disconnect(),this._shaper=null,this._curve=null,this},t.WaveShaper}),t(function(t){return t.TimeBase=function(e,i){if(!(this instanceof t.TimeBase))return new t.TimeBase(e,i);if(this._expr=this._noOp,e instanceof t.TimeBase)this.copy(e);else if(!this.isUndef(i)||this.isNumber(e)){i=this.defaultArg(i,this._defaultUnits);var s=this._primaryExpressions[i].method;this._expr=s.bind(this,e)}else this.isString(e)?this.set(e):this.isUndef(e)&&(this._expr=this._defaultExpr())},t.extend(t.TimeBase),t.TimeBase.prototype.set=function(t){return this._expr=this._parseExprString(t),this},t.TimeBase.prototype.clone=function(){var t=new this.constructor;return t.copy(this),t},t.TimeBase.prototype.copy=function(t){var e=t._expr();return this.set(e)},t.TimeBase.prototype._primaryExpressions={n:{regexp:/^(\d+)n/i,method:function(t){return t=parseInt(t),1===t?this._beatsToUnits(this._timeSignature()):this._beatsToUnits(4/t)}},t:{regexp:/^(\d+)t/i,method:function(t){return t=parseInt(t),this._beatsToUnits(8/(3*parseInt(t)))}},m:{regexp:/^(\d+)m/i,method:function(t){return this._beatsToUnits(parseInt(t)*this._timeSignature())}},i:{regexp:/^(\d+)i/i,method:function(t){return this._ticksToUnits(parseInt(t))}},hz:{regexp:/^(\d+(?:\.\d+)?)hz/i,method:function(t){return this._frequencyToUnits(parseFloat(t))}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method:function(t,e,i){var s=0;return t&&"0"!==t&&(s+=this._beatsToUnits(this._timeSignature()*parseFloat(t))),e&&"0"!==e&&(s+=this._beatsToUnits(parseFloat(e))),i&&"0"!==i&&(s+=this._beatsToUnits(parseFloat(i)/4)),s}},s:{regexp:/^(\d+(?:\.\d+)?s)/,method:function(t){return this._secondsToUnits(parseFloat(t))}},samples:{regexp:/^(\d+)samples/,method:function(t){return parseInt(t)/this.context.sampleRate}},default:{regexp:/^(\d+(?:\.\d+)?)/,method:function(t){return this._primaryExpressions[this._defaultUnits].method.call(this,t)}}},t.TimeBase.prototype._binaryExpressions={"+":{regexp:/^\+/,precedence:2,method:function(t,e){return t()+e()}},"-":{regexp:/^\-/,precedence:2,method:function(t,e){return t()-e()}},"*":{regexp:/^\*/,precedence:1,method:function(t,e){return t()*e()}},"/":{regexp:/^\//,precedence:1,method:function(t,e){return t()/e()}}},t.TimeBase.prototype._unaryExpressions={neg:{regexp:/^\-/,method:function(t){return-t()}}},t.TimeBase.prototype._syntaxGlue={"(":{regexp:/^\(/},")":{regexp:/^\)/}},t.TimeBase.prototype._tokenize=function(t){for(var e=-1,i=[];t.length>0;){t=t.trim();var s=function(t,e){for(var i=["_binaryExpressions","_unaryExpressions","_primaryExpressions","_syntaxGlue"],s=0;s<i.length;s++){var n=e[i[s]];for(var o in n){var r=n[o],a=r.regexp,h=t.match(a);if(null!==h)return{method:r.method,precedence:r.precedence,regexp:r.regexp,value:h[0]}}}throw new SyntaxError("Tone.TimeBase: Unexpected token "+t)}(t,this);i.push(s),t=t.substr(s.value.length)}return{next:function(){return i[++e]},peek:function(){return i[e+1]}}},t.TimeBase.prototype._matchGroup=function(t,e,i){if(!this.isUndef(t))for(var s in e){var n=e[s];if(n.regexp.test(t.value)){if(this.isUndef(i))return n;if(n.precedence===i)return n}}return!1},t.TimeBase.prototype._parseBinary=function(t,e){this.isUndef(e)&&(e=2);var i;i=e<0?this._parseUnary(t):this._parseBinary(t,e-1);for(var s=t.peek();s&&this._matchGroup(s,this._binaryExpressions,e);)s=t.next(),i=s.method.bind(this,i,this._parseBinary(t,e-1)),s=t.peek();return i},t.TimeBase.prototype._parseUnary=function(t){var e,i;e=t.peek();var s=this._matchGroup(e,this._unaryExpressions);return s?(e=t.next(),i=this._parseUnary(t),s.method.bind(this,i)):this._parsePrimary(t)},t.TimeBase.prototype._parsePrimary=function(t){var e,i;if(e=t.peek(),this.isUndef(e))throw new SyntaxError("Tone.TimeBase: Unexpected end of expression");if(this._matchGroup(e,this._primaryExpressions)){e=t.next();var s=e.value.match(e.regexp);return e.method.bind(this,s[1],s[2],s[3])}if(e&&"("===e.value){if(t.next(),i=this._parseBinary(t),!(e=t.next())||")"!==e.value)throw new SyntaxError("Expected )");return i}throw new SyntaxError("Tone.TimeBase: Cannot process token "+e.value)},t.TimeBase.prototype._parseExprString=function(t){this.isString(t)||(t=t.toString());var e=this._tokenize(t);return this._parseBinary(e)},t.TimeBase.prototype._noOp=function(){return 0},t.TimeBase.prototype._defaultExpr=function(){return this._noOp},t.TimeBase.prototype._defaultUnits="s",t.TimeBase.prototype._frequencyToUnits=function(t){return 1/t},t.TimeBase.prototype._beatsToUnits=function(e){return 60/t.Transport.bpm.value*e},t.TimeBase.prototype._secondsToUnits=function(t){return t},t.TimeBase.prototype._ticksToUnits=function(e){return e*(this._beatsToUnits(1)/t.Transport.PPQ)},t.TimeBase.prototype._timeSignature=function(){return t.Transport.timeSignature},t.TimeBase.prototype._pushExpr=function(e,i,s){return e instanceof t.TimeBase||(e=new this.constructor(e,s)),this._expr=this._binaryExpressions[i].method.bind(this,this._expr,e._expr),this},t.TimeBase.prototype.add=function(t,e){return this._pushExpr(t,"+",e)},t.TimeBase.prototype.sub=function(t,e){return this._pushExpr(t,"-",e)},t.TimeBase.prototype.mult=function(t,e){return this._pushExpr(t,"*",e)},t.TimeBase.prototype.div=function(t,e){return this._pushExpr(t,"/",e)},t.TimeBase.prototype.valueOf=function(){return this._expr()},t.TimeBase.prototype.dispose=function(){this._expr=null},t.TimeBase}),t(function(t){return t.Time=function(e,i){if(!(this instanceof t.Time))return new t.Time(e,i);this._plusNow=!1,t.TimeBase.call(this,e,i)},t.extend(t.Time,t.TimeBase),t.Time.prototype._unaryExpressions=Object.create(t.TimeBase.prototype._unaryExpressions),t.Time.prototype._unaryExpressions.quantize={regexp:/^@/,method:function(e){return t.Transport.nextSubdivision(e())}},t.Time.prototype._unaryExpressions.now={regexp:/^\+/,method:function(t){return this._plusNow=!0,t()}},t.Time.prototype.quantize=function(t,e){return e=this.defaultArg(e,1),this._expr=function(t,e,i){return t=t(),e=e.toSeconds(),t+(Math.round(t/e)*e-t)*i}.bind(this,this._expr,new this.constructor(t),e),this},t.Time.prototype.addNow=function(){return this._plusNow=!0,this},t.Time.prototype._defaultExpr=function(){return this._plusNow=!0,this._noOp},t.Time.prototype.copy=function(e){return t.TimeBase.prototype.copy.call(this,e),this._plusNow=e._plusNow,this},t.Time.prototype.toNotation=function(){var t=this.toSeconds(),e=["1m","2n","4n","8n","16n","32n","64n","128n"],i=this._toNotationHelper(t,e),s=["1m","2n","2t","4n","4t","8n","8t","16n","16t","32n","32t","64n","64t","128n"],n=this._toNotationHelper(t,s);return n.split("+").length<i.split("+").length?n:i},t.Time.prototype._toNotationHelper=function(t,e){for(var i=this._notationToUnits(e[e.length-1]),s="",n=0;n<e.length;n++){var o=this._notationToUnits(e[n]),r=t/o;if(1-r%1<1e-6&&(r+=1e-6),(r=Math.floor(r))>0){if(s+=1===r?e[n]:r.toString()+"*"+e[n],(t-=r*o)<i)break;s+=" + "}}return""===s&&(s="0"),s},t.Time.prototype._notationToUnits=function(t){for(var e=this._primaryExpressions,i=[e.n,e.t,e.m],s=0;s<i.length;s++){var n=i[s],o=t.match(n.regexp);if(o)return n.method.call(this,o[1])}},t.Time.prototype.toBarsBeatsSixteenths=function(){var t=this._beatsToUnits(1),e=this.toSeconds()/t,i=Math.floor(e/this._timeSignature()),s=e%1*4;return e=Math.floor(e)%this._timeSignature(),s=s.toString(),s.length>3&&(s=parseFloat(s).toFixed(3)),[i,e,s].join(":")},t.Time.prototype.toTicks=function(){var e=this._beatsToUnits(1),i=this.valueOf()/e;return Math.floor(i*t.Transport.PPQ)},t.Time.prototype.toSamples=function(){return this.toSeconds()*this.context.sampleRate},t.Time.prototype.toFrequency=function(){return 1/this.toSeconds()},t.Time.prototype.toSeconds=function(){return this.valueOf()},t.Time.prototype.toMilliseconds=function(){return 1e3*this.toSeconds()},t.Time.prototype.valueOf=function(){return this._expr()+(this._plusNow?this.now():0)},t.Time}),t(function(t){t.Frequency=function(e,i){if(!(this instanceof t.Frequency))return new t.Frequency(e,i);t.TimeBase.call(this,e,i)},t.extend(t.Frequency,t.TimeBase),t.Frequency.prototype._primaryExpressions=Object.create(t.TimeBase.prototype._primaryExpressions),t.Frequency.prototype._primaryExpressions.midi={regexp:/^(\d+(?:\.\d+)?midi)/,method:function(t){return this.midiToFrequency(t)}},t.Frequency.prototype._primaryExpressions.note={regexp:/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,method:function(t,i){var s=e[t.toLowerCase()],n=s+12*(parseInt(i)+1);return this.midiToFrequency(n)}},t.Frequency.prototype._primaryExpressions.tr={regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method:function(t,e,i){var s=1;return t&&"0"!==t&&(s*=this._beatsToUnits(this._timeSignature()*parseFloat(t))),e&&"0"!==e&&(s*=this._beatsToUnits(parseFloat(e))),i&&"0"!==i&&(s*=this._beatsToUnits(parseFloat(i)/4)),s}},t.Frequency.prototype.transpose=function(t){return this._expr=function(t,e){return t()*this.intervalToFrequencyRatio(e)}.bind(this,this._expr,t),this},t.Frequency.prototype.harmonize=function(t){return this._expr=function(t,e){for(var i=t(),s=[],n=0;n<e.length;n++)s[n]=i*this.intervalToFrequencyRatio(e[n]);return s}.bind(this,this._expr,t),this},t.Frequency.prototype.toMidi=function(){return this.frequencyToMidi(this.valueOf())},t.Frequency.prototype.toNote=function(){var e=this.valueOf(),s=Math.log(e/t.Frequency.A4)/Math.LN2,n=Math.round(12*s)+57,o=Math.floor(n/12);return o<0&&(n+=-12*o),i[n%12]+o.toString()},t.Frequency.prototype.toSeconds=function(){return 1/this.valueOf()},t.Frequency.prototype.toFrequency=function(){return this.valueOf()},t.Frequency.prototype.toTicks=function(){var e=this._beatsToUnits(1),i=this.valueOf()/e;return Math.floor(i*t.Transport.PPQ)},t.Frequency.prototype._frequencyToUnits=function(t){return t},t.Frequency.prototype._ticksToUnits=function(e){return 1/(60*e/(t.Transport.bpm.value*t.Transport.PPQ))},t.Frequency.prototype._beatsToUnits=function(e){return 1/t.TimeBase.prototype._beatsToUnits.call(this,e)},t.Frequency.prototype._secondsToUnits=function(t){return 1/t},t.Frequency.prototype._defaultUnits="hz";var e={cbb:-2,cb:-1,c:0,"c#":1,cx:2,dbb:0,db:1,d:2,"d#":3,dx:4,ebb:2,eb:3,e:4,"e#":5,ex:6,fbb:3,fb:4,f:5,"f#":6,fx:7,gbb:5,gb:6,g:7,"g#":8,gx:9,abb:7,ab:8,a:9,"a#":10,ax:11,bbb:9,bb:10,b:11,"b#":12,bx:13},i=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];return t.Frequency.A4=440,t.Frequency.prototype.midiToFrequency=function(e){return t.Frequency.A4*Math.pow(2,(e-69)/12)},t.Frequency.prototype.frequencyToMidi=function(e){return 69+12*Math.log(e/t.Frequency.A4)/Math.LN2},t.Frequency}),t(function(t){return t.TransportTime=function(e,i){if(!(this instanceof t.TransportTime))return new t.TransportTime(e,i);t.Time.call(this,e,i)},t.extend(t.TransportTime,t.Time),t.TransportTime.prototype._unaryExpressions=Object.create(t.Time.prototype._unaryExpressions),t.TransportTime.prototype._unaryExpressions.quantize={regexp:/^@/,method:function(e){var i=this._secondsToTicks(e()),s=Math.ceil(t.Transport.ticks/i);return this._ticksToUnits(s*i)}},t.TransportTime.prototype._secondsToTicks=function(e){var i=this._beatsToUnits(1),s=e/i;return Math.round(s*t.Transport.PPQ)},t.TransportTime.prototype.valueOf=function(){return this._secondsToTicks(this._expr())+(this._plusNow?t.Transport.ticks:0)},t.TransportTime.prototype.toTicks=function(){return this.valueOf()},t.TransportTime.prototype.toSeconds=function(){return this._expr()+(this._plusNow?t.Transport.seconds:0)},t.TransportTime.prototype.toFrequency=function(){return 1/this.toSeconds()},t.TransportTime}),t(function(t){return t.Emitter=function(){this._events={}},t.extend(t.Emitter),t.Emitter.prototype.on=function(t,e){for(var i=t.split(/\W+/),s=0;s<i.length;s++){var n=i[s];this._events.hasOwnProperty(n)||(this._events[n]=[]),this._events[n].push(e)}return this},t.Emitter.prototype.off=function(e,i){for(var s=e.split(/\W+/),n=0;n<s.length;n++)if(e=s[n],this._events.hasOwnProperty(e))if(t.prototype.isUndef(i))this._events[e]=[];else for(var o=this._events[e],r=0;r<o.length;r++)o[r]===i&&o.splice(r,1);return this},t.Emitter.prototype.emit=function(t){if(this._events){var e=Array.apply(null,arguments).slice(1);if(this._events.hasOwnProperty(t))for(var i=this._events[t],s=0,n=i.length;s<n;s++)i[s].apply(this,e)}return this},t.Emitter.mixin=function(e){var i=["on","off","emit"];e._events={};for(var s=0;s<i.length;s++){var n=i[s],o=t.Emitter.prototype[n];e[n]=o}},t.Emitter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._events=null,this},t.Emitter}),t(function(t){return!window.hasOwnProperty("AudioContext")&&window.hasOwnProperty("webkitAudioContext")&&(window.AudioContext=window.webkitAudioContext),t.Context=function(e){t.Emitter.call(this),e||(e=new window.AudioContext),this._context=e;for(var i in this._context)this._defineProperty(this._context,i);this._latencyHint="interactive",this._lookAhead=.1,this._updateInterval=this._lookAhead/3,this._computedUpdateInterval=0,this._worker=this._createWorker(),this._constants={}},t.extend(t.Context,t.Emitter),t.Emitter.mixin(t.Context),t.Context.prototype._defineProperty=function(t,e){this.isUndef(this[e])&&Object.defineProperty(this,e,{get:function(){return"function"==typeof t[e]?t[e].bind(t):t[e]},set:function(i){t[e]=i}})},t.Context.prototype.now=function(){return this._context.currentTime},t.Context.prototype._createWorker=function(){window.URL=window.URL||window.webkitURL;var t=new Blob(["var timeoutTime = "+(1e3*this._updateInterval).toFixed(1)+";self.onmessage = function(msg){\ttimeoutTime = parseInt(msg.data);};function tick(){\tsetTimeout(tick, timeoutTime);\tself.postMessage('tick');}tick();"]),e=URL.createObjectURL(t),i=new Worker(e);return i.addEventListener("message",function(){this.emit("tick")}.bind(this)),i.addEventListener("message",function(){var t=this.now();if(this.isNumber(this._lastUpdate)){var e=t-this._lastUpdate;this._computedUpdateInterval=Math.max(e,.97*this._computedUpdateInterval)}this._lastUpdate=t}.bind(this)),i},t.Context.prototype.getConstant=function(t){if(this._constants[t])return this._constants[t];for(var e=this._context.createBuffer(1,128,this._context.sampleRate),i=e.getChannelData(0),s=0;s<i.length;s++)i[s]=t;var n=this._context.createBufferSource();return n.channelCount=1,n.channelCountMode="explicit",n.buffer=e,n.loop=!0,n.start(0),this._constants[t]=n,n},Object.defineProperty(t.Context.prototype,"lag",{get:function(){var t=this._computedUpdateInterval-this._updateInterval;return t=Math.max(t,0)}}),Object.defineProperty(t.Context.prototype,"lookAhead",{get:function(){return this._lookAhead},set:function(t){this._lookAhead=t}}),Object.defineProperty(t.Context.prototype,"updateInterval",{get:function(){return this._updateInterval},set:function(e){this._updateInterval=Math.max(e,t.prototype.blockTime),this._worker.postMessage(Math.max(1e3*e,1))}}),Object.defineProperty(t.Context.prototype,"latencyHint",{get:function(){return this._latencyHint},set:function(t){var e=t;if(this._latencyHint=t,this.isString(t))switch(t){case"interactive":e=.1,this._context.latencyHint=t;break;case"playback":e=.8,this._context.latencyHint=t;break;case"balanced":e=.25,this._context.latencyHint=t;break;case"fastest":e=.01}this.lookAhead=e,this.updateInterval=e/3}}),t.supported?(!function(){function e(e,i,n){if(e.input)Array.isArray(e.input)?(t.prototype.isUndef(n)&&(n=0),this.connect(e.input[n])):this.connect(e.input,i,n);else try{e instanceof AudioNode?s.call(this,e,i,n):s.call(this,e,i)}catch(t){throw new Error("error connecting to node: "+e+"\n"+t)}}function i(e,i,s){if(e&&e.input&&Array.isArray(e.input))t.prototype.isUndef(s)&&(s=0),this.disconnect(e.input[s],i,s);else if(e&&e.input)this.disconnect(e.input,i,s);else try{n.apply(this,arguments)}catch(t){throw new Error("error disconnecting node: "+e+"\n"+t)}}var s=AudioNode.prototype.connect,n=AudioNode.prototype.disconnect;AudioNode.prototype.connect!==e&&(AudioNode.prototype.connect=e,AudioNode.prototype.disconnect=i)}(),t.context=new t.Context):console.warn("This browser does not support Tone.js"),t.Context}),t(function(t){return t.Type={Default:"number",Time:"time",Frequency:"frequency",TransportTime:"transportTime",Ticks:"ticks",NormalRange:"normalRange",AudioRange:"audioRange",Decibels:"db",Interval:"interval",BPM:"bpm",Positive:"positive",Cents:"cents",Degrees:"degrees",MIDI:"midi",BarsBeatsSixteenths:"barsBeatsSixteenths",Samples:"samples",Hertz:"hertz",Note:"note",Milliseconds:"milliseconds",Seconds:"seconds",Notation:"notation"},t.prototype.toSeconds=function(e){return this.isNumber(e)?e:this.isUndef(e)?this.now():this.isString(e)?new t.Time(e).toSeconds():e instanceof t.TimeBase?e.toSeconds():void 0},t.prototype.toFrequency=function(e){return this.isNumber(e)?e:this.isString(e)||this.isUndef(e)?new t.Frequency(e).valueOf():e instanceof t.TimeBase?e.toFrequency():void 0},t.prototype.toTicks=function(e){return this.isNumber(e)||this.isString(e)?new t.TransportTime(e).toTicks():this.isUndef(e)?t.Transport.ticks:e instanceof t.TimeBase?e.toTicks():void 0},t}),t(function(t){return t.Param=function(){var e=this.optionsObject(arguments,["param","units","convert"],t.Param.defaults);this._param=this.input=e.param,this.units=e.units,this.convert=e.convert,this.overridden=!1,this._lfo=null,this.isObject(e.lfo)?this.value=e.lfo:this.isUndef(e.value)||(this.value=e.value)},t.extend(t.Param),t.Param.defaults={units:t.Type.Default,convert:!0,param:void 0},Object.defineProperty(t.Param.prototype,"value",{get:function(){return this._toUnits(this._param.value)},set:function(e){if(this.isObject(e)){if(this.isUndef(t.LFO))throw new Error("Include 'Tone.LFO' to use an LFO as a Param value.");this._lfo&&this._lfo.dispose(),this._lfo=new t.LFO(e).start(),this._lfo.connect(this.input)}else{var i=this._fromUnits(e);this._param.cancelScheduledValues(0),this._param.value=i}}}),t.Param.prototype._fromUnits=function(e){if(!this.convert&&!this.isUndef(this.convert))return e;switch(this.units){case t.Type.Time:return this.toSeconds(e);case t.Type.Frequency:return this.toFrequency(e);case t.Type.Decibels:return this.dbToGain(e);case t.Type.NormalRange:return Math.min(Math.max(e,0),1);case t.Type.AudioRange:return Math.min(Math.max(e,-1),1);case t.Type.Positive:return Math.max(e,0);default:return e}},t.Param.prototype._toUnits=function(e){if(!this.convert&&!this.isUndef(this.convert))return e;switch(this.units){case t.Type.Decibels:return this.gainToDb(e);default:return e}},t.Param.prototype._minOutput=1e-5,t.Param.prototype.setValueAtTime=function(t,e){return t=this._fromUnits(t),e=this.toSeconds(e),e<=this.now()+this.blockTime?this._param.value=t:this._param.setValueAtTime(t,e),this},t.Param.prototype.setRampPoint=function(t){t=this.defaultArg(t,this.now());var e=this._param.value;return 0===e&&(e=this._minOutput),this._param.setValueAtTime(e,t),this},t.Param.prototype.linearRampToValueAtTime=function(t,e){return t=this._fromUnits(t),this._param.linearRampToValueAtTime(t,this.toSeconds(e)),this},t.Param.prototype.exponentialRampToValueAtTime=function(t,e){return t=this._fromUnits(t),t=Math.max(this._minOutput,t),this._param.exponentialRampToValueAtTime(t,this.toSeconds(e)),this},t.Param.prototype.exponentialRampToValue=function(t,e,i){return i=this.toSeconds(i),this.setRampPoint(i),this.exponentialRampToValueAtTime(t,i+this.toSeconds(e)),this},t.Param.prototype.linearRampToValue=function(t,e,i){return i=this.toSeconds(i),this.setRampPoint(i),this.linearRampToValueAtTime(t,i+this.toSeconds(e)),this},t.Param.prototype.setTargetAtTime=function(t,e,i){return t=this._fromUnits(t),t=Math.max(this._minOutput,t),i=Math.max(this._minOutput,i),this._param.setTargetAtTime(t,this.toSeconds(e),i),this},t.Param.prototype.setValueCurveAtTime=function(t,e,i){for(var s=0;s<t.length;s++)t[s]=this._fromUnits(t[s]);return this._param.setValueCurveAtTime(t,this.toSeconds(e),this.toSeconds(i)),this},t.Param.prototype.cancelScheduledValues=function(t){return this._param.cancelScheduledValues(this.toSeconds(t)),this},t.Param.prototype.rampTo=function(e,i,s){return i=this.defaultArg(i,0),this.units===t.Type.Frequency||this.units===t.Type.BPM||this.units===t.Type.Decibels?this.exponentialRampToValue(e,i,s):this.linearRampToValue(e,i,s),this},Object.defineProperty(t.Param.prototype,"lfo",{get:function(){return this._lfo}}),t.Param.prototype.dispose=function(){return t.prototype.dispose.call(this),this._param=null,this._lfo&&(this._lfo.dispose(),this._lfo=null),this},t.Param}),t(function(t){return window.GainNode&&!AudioContext.prototype.createGain&&(AudioContext.prototype.createGain=AudioContext.prototype.createGainNode),t.Gain=function(){var e=this.optionsObject(arguments,["gain","units"],t.Gain.defaults);this.input=this.output=this._gainNode=this.context.createGain(),this.gain=new t.Param({param:this._gainNode.gain,units:e.units,value:e.gain,convert:e.convert}),this._readOnly("gain")},t.extend(t.Gain),t.Gain.defaults={gain:1,convert:!0},t.Gain.prototype.dispose=function(){t.Param.prototype.dispose.call(this),this._gainNode.disconnect(),this._gainNode=null,this._writable("gain"),this.gain.dispose(),this.gain=null},t.prototype.createInsOuts=function(e,i){1===e?this.input=new t.Gain:e>1&&(this.input=new Array(e)),1===i?this.output=new t.Gain:i>1&&(this.output=new Array(e))},t.Gain}),t(function(t){return t.Signal=function(){var e=this.optionsObject(arguments,["value","units"],t.Signal.defaults);this.output=this._gain=this.context.createGain(),e.param=this._gain.gain,t.Param.call(this,e),this.input=this._param=this._gain.gain,this.context.getConstant(1).chain(this._gain)},t.extend(t.Signal,t.Param),t.Signal.defaults={value:0,units:t.Type.Default,convert:!0},t.Signal.prototype.connect=t.SignalBase.prototype.connect,t.Signal.prototype.dispose=function(){return t.Param.prototype.dispose.call(this),this._param=null,this._gain.disconnect(),this._gain=null,this},t.Signal}),t(function(t){return t.Timeline=function(){var e=this.optionsObject(arguments,["memory"],t.Timeline.defaults);this._timeline=[],this._toRemove=[],this._iterating=!1,this.memory=e.memory},t.extend(t.Timeline),t.Timeline.defaults={memory:1/0},Object.defineProperty(t.Timeline.prototype,"length",{get:function(){return this._timeline.length}}),t.Timeline.prototype.add=function(t){if(this.isUndef(t.time))throw new Error("Tone.Timeline: events must have a time attribute");if(this._timeline.length){var e=this._search(t.time);this._timeline.splice(e+1,0,t)}else this._timeline.push(t);if(this.length>this.memory){var i=this.length-this.memory;this._timeline.splice(0,i)}return this},t.Timeline.prototype.remove=function(t){if(this._iterating)this._toRemove.push(t);else{var e=this._timeline.indexOf(t);-1!==e&&this._timeline.splice(e,1)}return this},t.Timeline.prototype.get=function(t){var e=this._search(t);return-1!==e?this._timeline[e]:null},t.Timeline.prototype.peek=function(){return this._timeline[0]},t.Timeline.prototype.shift=function(){return this._timeline.shift()},t.Timeline.prototype.getAfter=function(t){var e=this._search(t);return e+1<this._timeline.length?this._timeline[e+1]:null},t.Timeline.prototype.getBefore=function(t){var e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];var i=this._search(t);return i-1>=0?this._timeline[i-1]:null},t.Timeline.prototype.cancel=function(t){if(this._timeline.length>1){var e=this._search(t);if(e>=0)if(this._timeline[e].time===t){for(var i=e;i>=0&&this._timeline[i].time===t;i--)e=i;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else 1===this._timeline.length&&this._timeline[0].time>=t&&(this._timeline=[]);return this},t.Timeline.prototype.cancelBefore=function(t){if(this._timeline.length){var e=this._search(t);e>=0&&(this._timeline=this._timeline.slice(e+1))}return this},t.Timeline.prototype._search=function(t){var e=0,i=this._timeline.length,s=i;if(i>0&&this._timeline[i-1].time<=t)return i-1;for(;e<s;){var n=Math.floor(e+(s-e)/2),o=this._timeline[n],r=this._timeline[n+1];if(o.time===t){for(var a=n;a<this._timeline.length;a++){this._timeline[a].time===t&&(n=a)}return n}if(o.time<t&&r.time>t)return n;o.time>t?s=n:o.time<t&&(e=n+1)}return-1},t.Timeline.prototype._iterate=function(t,e,i){this._iterating=!0,e=this.defaultArg(e,0),i=this.defaultArg(i,this._timeline.length-1);for(var s=e;s<=i;s++)t(this._timeline[s]);if(this._iterating=!1,this._toRemove.length>0){for(var n=0;n<this._toRemove.length;n++){var o=this._timeline.indexOf(this._toRemove[n]);-1!==o&&this._timeline.splice(o,1)}this._toRemove=[]}},t.Timeline.prototype.forEach=function(t){return this._iterate(t),this},t.Timeline.prototype.forEachBefore=function(t,e){var i=this._search(t);return-1!==i&&this._iterate(e,0,i),this},t.Timeline.prototype.forEachAfter=function(t,e){var i=this._search(t);return this._iterate(e,i+1),this},t.Timeline.prototype.forEachFrom=function(t,e){for(var i=this._search(t);i>=0&&this._timeline[i].time>=t;)i--;return this._iterate(e,i+1),this},t.Timeline.prototype.forEachAtTime=function(t,e){var i=this._search(t);return-1!==i&&this._iterate(function(i){i.time===t&&e(i)},0,i),this},t.Timeline.prototype.dispose=function(){t.prototype.dispose.call(this),this._timeline=null,this._toRemove=null},t.Timeline}),t(function(t){return t.TimelineSignal=function(){var e=this.optionsObject(arguments,["value","units"],t.Signal.defaults);this._events=new t.Timeline(10),t.Signal.apply(this,e),e.param=this._param,t.Param.call(this,e),this._initial=this._fromUnits(this._param.value)},t.extend(t.TimelineSignal,t.Param),t.TimelineSignal.Type={Linear:"linear",Exponential:"exponential",Target:"target",Curve:"curve",Set:"set"},Object.defineProperty(t.TimelineSignal.prototype,"value",{get:function(){var t=this.now(),e=this.getValueAtTime(t);return this._toUnits(e)},set:function(t){var e=this._fromUnits(t);this._initial=e,this.cancelScheduledValues(),this._param.value=e}}),t.TimelineSignal.prototype.setValueAtTime=function(e,i){return e=this._fromUnits(e),i=this.toSeconds(i),this._events.add({type:t.TimelineSignal.Type.Set,value:e,time:i}),this._param.setValueAtTime(e,i),this},t.TimelineSignal.prototype.linearRampToValueAtTime=function(e,i){return e=this._fromUnits(e),i=this.toSeconds(i),this._events.add({type:t.TimelineSignal.Type.Linear,value:e,time:i}),this._param.linearRampToValueAtTime(e,i),this},t.TimelineSignal.prototype.exponentialRampToValueAtTime=function(e,i){i=this.toSeconds(i);var s=this._searchBefore(i);s&&0===s.value&&this.setValueAtTime(this._minOutput,s.time),e=this._fromUnits(e);var n=Math.max(e,this._minOutput);return this._events.add({type:t.TimelineSignal.Type.Exponential,value:n,time:i}),e<this._minOutput?(this._param.exponentialRampToValueAtTime(this._minOutput,i-this.sampleTime),this.setValueAtTime(0,i)):this._param.exponentialRampToValueAtTime(e,i),this},t.TimelineSignal.prototype.setTargetAtTime=function(e,i,s){return e=this._fromUnits(e),e=Math.max(this._minOutput,e),s=Math.max(this._minOutput,s),i=this.toSeconds(i),this._events.add({type:t.TimelineSignal.Type.Target,value:e,time:i,constant:s}),this._param.setTargetAtTime(e,i,s),this},t.TimelineSignal.prototype.setValueCurveAtTime=function(e,i,s,n){n=this.defaultArg(n,1);for(var o=new Array(e.length),r=0;r<o.length;r++)o[r]=this._fromUnits(e[r])*n;i=this.toSeconds(i),s=this.toSeconds(s),this._events.add({type:t.TimelineSignal.Type.Curve,value:o,time:i,duration:s}),this._param.setValueAtTime(o[0],i);for(var a=1;a<o.length;a++){var h=i+a/(o.length-1)*s;this._param.linearRampToValueAtTime(o[a],h)}return this},t.TimelineSignal.prototype.cancelScheduledValues=function(t){return t=this.toSeconds(t),this._events.cancel(t),this._param.cancelScheduledValues(t),this},t.TimelineSignal.prototype.setRampPoint=function(e){e=this.toSeconds(e);var i=this._toUnits(this.getValueAtTime(e)),s=this._searchBefore(e);if(s&&s.time===e)this.cancelScheduledValues(e+this.sampleTime);else if(s&&s.type===t.TimelineSignal.Type.Curve&&s.time+s.duration>e)this.cancelScheduledValues(e),this.linearRampToValueAtTime(i,e);else{var n=this._searchAfter(e);n&&(this.cancelScheduledValues(e),n.type===t.TimelineSignal.Type.Linear?this.linearRampToValueAtTime(i,e):n.type===t.TimelineSignal.Type.Exponential&&this.exponentialRampToValueAtTime(i,e)),this.setValueAtTime(i,e)}return this},t.TimelineSignal.prototype.linearRampToValueBetween=function(t,e,i){return this.setRampPoint(e),this.linearRampToValueAtTime(t,i),this},t.TimelineSignal.prototype.exponentialRampToValueBetween=function(t,e,i){return this.setRampPoint(e),this.exponentialRampToValueAtTime(t,i),this},t.TimelineSignal.prototype._searchBefore=function(t){return this._events.get(t)},t.TimelineSignal.prototype._searchAfter=function(t){return this._events.getAfter(t)},t.TimelineSignal.prototype.getValueAtTime=function(e){e=this.toSeconds(e);var i=this._searchAfter(e),s=this._searchBefore(e),n=this._initial;if(null===s)n=this._initial;else if(s.type===t.TimelineSignal.Type.Target){var o,r=this._events.getBefore(s.time);o=null===r?this._initial:r.value,n=this._exponentialApproach(s.time,o,s.value,s.constant,e)}else n=s.type===t.TimelineSignal.Type.Curve?this._curveInterpolate(s.time,s.value,s.duration,e):null===i?s.value:i.type===t.TimelineSignal.Type.Linear?this._linearInterpolate(s.time,s.value,i.time,i.value,e):i.type===t.TimelineSignal.Type.Exponential?this._exponentialInterpolate(s.time,s.value,i.time,i.value,e):s.value;return n},t.TimelineSignal.prototype.connect=t.SignalBase.prototype.connect,t.TimelineSignal.prototype._exponentialApproach=function(t,e,i,s,n){return i+(e-i)*Math.exp(-(n-t)/s)},t.TimelineSignal.prototype._linearInterpolate=function(t,e,i,s,n){return e+(n-t)/(i-t)*(s-e)},t.TimelineSignal.prototype._exponentialInterpolate=function(t,e,i,s,n){return(e=Math.max(this._minOutput,e))*Math.pow(s/e,(n-t)/(i-t))},t.TimelineSignal.prototype._curveInterpolate=function(t,e,i,s){var n=e.length;if(s>=t+i)return e[n-1];if(s<=t)return e[0];var o=(s-t)/i,r=Math.floor((n-1)*o),a=Math.ceil((n-1)*o),h=e[r],l=e[a];return a===r?h:this._linearInterpolate(r,h,a,l,o*(n-1))},t.TimelineSignal.prototype.dispose=function(){t.Signal.prototype.dispose.call(this),t.Param.prototype.dispose.call(this),this._events.dispose(),this._events=null},t.TimelineSignal}),t(function(t){return t.Pow=function(e){this._exp=this.defaultArg(e,1),this._expScaler=this.input=this.output=new t.WaveShaper(this._expFunc(this._exp),8192)},t.extend(t.Pow,t.SignalBase),Object.defineProperty(t.Pow.prototype,"value",{get:function(){return this._exp},set:function(t){this._exp=t,this._expScaler.setMap(this._expFunc(this._exp))}}),t.Pow.prototype._expFunc=function(t){return function(e){return Math.pow(Math.abs(e),t)}},t.Pow.prototype.dispose=function(){return t.prototype.dispose.call(this),this._expScaler.dispose(),this._expScaler=null,this},t.Pow}),t(function(t){return t.Envelope=function(){var e=this.optionsObject(arguments,["attack","decay","sustain","release"],t.Envelope.defaults);this.attack=e.attack,this.decay=e.decay,this.sustain=e.sustain,this.release=e.release,this._attackCurve="linear",this._releaseCurve="exponential",this._sig=this.output=new t.TimelineSignal,this._sig.setValueAtTime(0,0),this.attackCurve=e.attackCurve,this.releaseCurve=e.releaseCurve},t.extend(t.Envelope),t.Envelope.defaults={attack:.01,decay:.1,sustain:.5,release:1,attackCurve:"linear",releaseCurve:"exponential"},Object.defineProperty(t.Envelope.prototype,"value",{get:function(){return this.getValueAtTime(this.now())}}),Object.defineProperty(t.Envelope.prototype,"attackCurve",{get:function(){if(this.isString(this._attackCurve))return this._attackCurve;if(this.isArray(this._attackCurve)){for(var e in t.Envelope.Type)if(t.Envelope.Type[e].In===this._attackCurve)return e;return this._attackCurve}},set:function(e){if(t.Envelope.Type.hasOwnProperty(e)){var i=t.Envelope.Type[e];this.isObject(i)?this._attackCurve=i.In:this._attackCurve=i}else{if(!this.isArray(e))throw new Error("Tone.Envelope: invalid curve: "+e);this._attackCurve=e}}}),Object.defineProperty(t.Envelope.prototype,"releaseCurve",{get:function(){if(this.isString(this._releaseCurve))return this._releaseCurve;if(this.isArray(this._releaseCurve)){for(var e in t.Envelope.Type)if(t.Envelope.Type[e].Out===this._releaseCurve)return e;return this._releaseCurve}},set:function(e){if(t.Envelope.Type.hasOwnProperty(e)){var i=t.Envelope.Type[e];this.isObject(i)?this._releaseCurve=i.Out:this._releaseCurve=i}else{if(!this.isArray(e))throw new Error("Tone.Envelope: invalid curve: "+e);this._releaseCurve=e}}}),t.Envelope.prototype.triggerAttack=function(t,e){t=this.toSeconds(t);var i=this.toSeconds(this.attack),s=i,n=this.toSeconds(this.decay);e=this.defaultArg(e,1);var o=this.getValueAtTime(t);if(o>0){s=(1-o)/(1/s)}if("linear"===this._attackCurve)this._sig.linearRampToValue(e,s,t);else if("exponential"===this._attackCurve)this._sig.exponentialRampToValue(e,s,t);else if(s>0){this._sig.setRampPoint(t);var r=this._attackCurve;if(s<i){var a=1-s/i,h=Math.floor(a*this._attackCurve.length);r=this._attackCurve.slice(h),r[0]=o}this._sig.setValueCurveAtTime(r,t,s,e)}return this._sig.exponentialRampToValue(e*this.sustain,n,s+t),this},t.Envelope.prototype.triggerRelease=function(t){t=this.toSeconds(t);var e=this.getValueAtTime(t);if(e>0){var i=this.toSeconds(this.release);if("linear"===this._releaseCurve)this._sig.linearRampToValue(0,i,t);else if("exponential"===this._releaseCurve)this._sig.exponentialRampToValue(0,i,t);else{var s=this._releaseCurve;this.isArray(s)&&(this._sig.setRampPoint(t),this._sig.setValueCurveAtTime(s,t,i,e))}}return this},t.Envelope.prototype.getValueAtTime=function(t){return this._sig.getValueAtTime(t)},t.Envelope.prototype.triggerAttackRelease=function(t,e,i){return e=this.toSeconds(e),this.triggerAttack(e,i),this.triggerRelease(e+this.toSeconds(t)),this},t.Envelope.prototype.cancel=function(t){return this._sig.cancelScheduledValues(t),this},t.Envelope.prototype.connect=t.Signal.prototype.connect,function(){function e(t){for(var e=new Array(t.length),i=0;i<t.length;i++)e[i]=1-t[i];return e}var i,s,n=[];for(i=0;i<128;i++)n[i]=Math.sin(i/127*(Math.PI/2));var o=[];for(i=0;i<127;i++){s=i/127;var r=Math.sin(s*(2*Math.PI)*6.4-Math.PI/2)+1;o[i]=r/10+.83*s}o[127]=1;var a=[];for(i=0;i<128;i++)a[i]=Math.ceil(i/127*5)/5;var h=[];for(i=0;i<128;i++)s=i/127,h[i]=.5*(1-Math.cos(Math.PI*s));var l=[];for(i=0;i<128;i++){s=i/127;var c=4*Math.pow(s,3)+.2,u=Math.cos(c*Math.PI*2*s);l[i]=Math.abs(u*(1-s))}t.Envelope.Type={linear:"linear",exponential:"exponential",bounce:{In:e(l),Out:l},cosine:{In:n,Out:function(t){return t.slice(0).reverse()}(n)},step:{In:a,Out:e(a)},ripple:{In:o,Out:e(o)},sine:{In:h,Out:e(h)}}}(),t.Envelope.prototype.dispose=function(){return t.prototype.dispose.call(this),this._sig.dispose(),this._sig=null,this._attackCurve=null,this._releaseCurve=null,this},t.Envelope}),t(function(t){return t.AmplitudeEnvelope=function(){t.Envelope.apply(this,arguments),this.input=this.output=new t.Gain,this._sig.connect(this.output.gain)},t.extend(t.AmplitudeEnvelope,t.Envelope),t.AmplitudeEnvelope.prototype.dispose=function(){return this.input.dispose(),this.input=null,t.Envelope.prototype.dispose.call(this),this},t.AmplitudeEnvelope}),t(function(t){return window.AnalyserNode&&!AnalyserNode.prototype.getFloatTimeDomainData&&(AnalyserNode.prototype.getFloatTimeDomainData=function(t){var e=new Uint8Array(t.length);this.getByteTimeDomainData(e);for(var i=0;i<e.length;i++)t[i]=(e[i]-128)/128}),t.Analyser=function(){var e=this.optionsObject(arguments,["type","size"],t.Analyser.defaults);this._analyser=this.input=this.output=this.context.createAnalyser(),this._type=e.type,this._returnType=e.returnType,this._buffer=null,this.size=e.size,this.type=e.type,this.returnType=e.returnType,this.minDecibels=e.minDecibels,this.maxDecibels=e.maxDecibels},t.extend(t.Analyser),t.Analyser.defaults={size:1024,returnType:"byte",type:"fft",smoothing:.8,maxDecibels:-30,minDecibels:-100},t.Analyser.Type={Waveform:"waveform",FFT:"fft"},t.Analyser.ReturnType={Byte:"byte",Float:"float"},t.Analyser.prototype.analyse=function(){return this._type===t.Analyser.Type.FFT?this._returnType===t.Analyser.ReturnType.Byte?this._analyser.getByteFrequencyData(this._buffer):this._analyser.getFloatFrequencyData(this._buffer):this._type===t.Analyser.Type.Waveform&&(this._returnType===t.Analyser.ReturnType.Byte?this._analyser.getByteTimeDomainData(this._buffer):this._analyser.getFloatTimeDomainData(this._buffer)),this._buffer},Object.defineProperty(t.Analyser.prototype,"size",{get:function(){return this._analyser.frequencyBinCount},set:function(t){this._analyser.fftSize=2*t,this.type=this._type}}),Object.defineProperty(t.Analyser.prototype,"returnType",{get:function(){return this._returnType},set:function(e){if(e===t.Analyser.ReturnType.Byte)this._buffer=new Uint8Array(this._analyser.frequencyBinCount);else{if(e!==t.Analyser.ReturnType.Float)throw new TypeError("Tone.Analayser: invalid return type: "+e);this._buffer=new Float32Array(this._analyser.frequencyBinCount)}this._returnType=e}}),Object.defineProperty(t.Analyser.prototype,"type",{get:function(){return this._type},set:function(e){if(e!==t.Analyser.Type.Waveform&&e!==t.Analyser.Type.FFT)throw new TypeError("Tone.Analyser: invalid type: "+e);this._type=e}}),Object.defineProperty(t.Analyser.prototype,"smoothing",{get:function(){return this._analyser.smoothingTimeConstant},set:function(t){this._analyser.smoothingTimeConstant=t}}),Object.defineProperty(t.Analyser.prototype,"minDecibels",{get:function(){return this._analyser.minDecibels},set:function(t){this._analyser.minDecibels=t}}),Object.defineProperty(t.Analyser.prototype,"maxDecibels",{get:function(){return this._analyser.maxDecibels},set:function(t){this._analyser.maxDecibels=t}}),t.Analyser.prototype.dispose=function(){t.prototype.dispose.call(this),this._analyser.disconnect(),this._analyser=null,this._buffer=null},t.Analyser}),t(function(t){return t.Compressor=function(){var e=this.optionsObject(arguments,["threshold","ratio"],t.Compressor.defaults);this._compressor=this.input=this.output=this.context.createDynamicsCompressor(),this.threshold=new t.Param({param:this._compressor.threshold,units:t.Type.Decibels,convert:!1}),this.attack=new t.Param(this._compressor.attack,t.Type.Time),this.release=new t.Param(this._compressor.release,t.Type.Time),this.knee=new t.Param({param:this._compressor.knee,units:t.Type.Decibels,convert:!1}),this.ratio=new t.Param({param:this._compressor.ratio,convert:!1}),this._readOnly(["knee","release","attack","ratio","threshold"]),this.set(e)},t.extend(t.Compressor),t.Compressor.defaults={ratio:12,threshold:-24,release:.25,attack:.003,knee:30},t.Compressor.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable(["knee","release","attack","ratio","threshold"]),this._compressor.disconnect(),this._compressor=null,this.attack.dispose(),this.attack=null,this.release.dispose(),this.release=null,this.threshold.dispose(),this.threshold=null,this.ratio.dispose(),this.ratio=null,this.knee.dispose(),this.knee=null,this},t.Compressor}),t(function(t){return t.Add=function(e){this.createInsOuts(2,0),this._sum=this.input[0]=this.input[1]=this.output=new t.Gain,this._param=this.input[1]=new t.Signal(e),this._param.connect(this._sum)},t.extend(t.Add,t.Signal),t.Add.prototype.dispose=function(){return t.prototype.dispose.call(this),this._sum.dispose(),this._sum=null,this._param.dispose(),this._param=null,this},t.Add}),t(function(t){return t.Multiply=function(e){this.createInsOuts(2,0),this._mult=this.input[0]=this.output=new t.Gain,this._param=this.input[1]=this.output.gain,this._param.value=this.defaultArg(e,0)},t.extend(t.Multiply,t.Signal),t.Multiply.prototype.dispose=function(){return t.prototype.dispose.call(this),this._mult.dispose(),this._mult=null,this._param=null,this},t.Multiply}),t(function(t){return t.Negate=function(){this._multiply=this.input=this.output=new t.Multiply(-1)},t.extend(t.Negate,t.SignalBase),t.Negate.prototype.dispose=function(){return t.prototype.dispose.call(this),this._multiply.dispose(),this._multiply=null,this},t.Negate}),t(function(t){return t.Subtract=function(e){this.createInsOuts(2,0),this._sum=this.input[0]=this.output=new t.Gain,this._neg=new t.Negate,this._param=this.input[1]=new t.Signal(e),this._param.chain(this._neg,this._sum)},t.extend(t.Subtract,t.Signal),t.Subtract.prototype.dispose=function(){return t.prototype.dispose.call(this),this._neg.dispose(),this._neg=null,this._sum.disconnect(),this._sum=null,this._param.dispose(),this._param=null,this},t.Subtract}),t(function(t){return t.GreaterThanZero=function(){this._thresh=this.output=new t.WaveShaper(function(t){return t<=0?0:1},127),this._scale=this.input=new t.Multiply(1e4),this._scale.connect(this._thresh)},t.extend(t.GreaterThanZero,t.SignalBase),t.GreaterThanZero.prototype.dispose=function(){return t.prototype.dispose.call(this),this._scale.dispose(),this._scale=null,this._thresh.dispose(),this._thresh=null,this},t.GreaterThanZero}),t(function(t){return t.GreaterThan=function(e){this.createInsOuts(2,0),this._param=this.input[0]=new t.Subtract(e),this.input[1]=this._param.input[1],this._gtz=this.output=new t.GreaterThanZero,this._param.connect(this._gtz)},t.extend(t.GreaterThan,t.Signal),t.GreaterThan.prototype.dispose=function(){return t.prototype.dispose.call(this),this._param.dispose(),this._param=null,this._gtz.dispose(),this._gtz=null,this},t.GreaterThan}),t(function(t){return t.Abs=function(){this._abs=this.input=this.output=new t.WaveShaper(function(t){return 0===t?0:Math.abs(t)},127)},t.extend(t.Abs,t.SignalBase),t.Abs.prototype.dispose=function(){return t.prototype.dispose.call(this),this._abs.dispose(),this._abs=null,this},t.Abs}),t(function(t){return t.Modulo=function(e){this.createInsOuts(1,0),this._shaper=new t.WaveShaper(Math.pow(2,16)),this._multiply=new t.Multiply,this._subtract=this.output=new t.Subtract,this._modSignal=new t.Signal(e),this.input.fan(this._shaper,this._subtract),this._modSignal.connect(this._multiply,0,0),this._shaper.connect(this._multiply,0,1),this._multiply.connect(this._subtract,0,1),this._setWaveShaper(e)},t.extend(t.Modulo,t.SignalBase),t.Modulo.prototype._setWaveShaper=function(t){this._shaper.setMap(function(e){return Math.floor((e+1e-4)/t)})},Object.defineProperty(t.Modulo.prototype,"value",{get:function(){return this._modSignal.value},set:function(t){this._modSignal.value=t,this._setWaveShaper(t)}}),t.Modulo.prototype.dispose=function(){return t.prototype.dispose.call(this),this._shaper.dispose(),this._shaper=null,this._multiply.dispose(),this._multiply=null,this._subtract.dispose(),this._subtract=null,this._modSignal.dispose(),this._modSignal=null,this},t.Modulo}),t(function(t){return t.AudioToGain=function(){this._norm=this.input=this.output=new t.WaveShaper(function(t){return(t+1)/2})},t.extend(t.AudioToGain,t.SignalBase),t.AudioToGain.prototype.dispose=function(){return t.prototype.dispose.call(this),this._norm.dispose(),this._norm=null,this},t.AudioToGain}),t(function(t){function e(t,e,i){var s=new t;return i._eval(e[0]).connect(s,0,0),i._eval(e[1]).connect(s,0,1),s}function i(t,e,i){var s=new t;return i._eval(e[0]).connect(s,0,0),s}function s(t){return t?parseFloat(t):void 0}function n(t){return t&&t.args?parseFloat(t.args):void 0}return t.Expr=function(){var t=this._replacements(Array.prototype.slice.call(arguments)),e=this._parseInputs(t);this._nodes=[],this.input=new Array(e);for(var i=0;i<e;i++)this.input[i]=this.context.createGain();var s,n=this._parseTree(t);try{s=this._eval(n)}catch(e){throw this._disposeNodes(),new Error("Tone.Expr: Could evaluate expression: "+t)}this.output=s},t.extend(t.Expr,t.SignalBase),t.Expr._Expressions={value:{signal:{regexp:/^\d+\.\d+|^\d+/,method:function(e){return new t.Signal(s(e))}},input:{regexp:/^\$\d/,method:function(t,e){return e.input[s(t.substr(1))]}}},glue:{"(":{regexp:/^\(/},")":{regexp:/^\)/},",":{regexp:/^,/}},func:{abs:{regexp:/^abs/,method:i.bind(this,t.Abs)},mod:{regexp:/^mod/,method:function(e,i){var s=n(e[1]),o=new t.Modulo(s);return i._eval(e[0]).connect(o),o}},pow:{regexp:/^pow/,method:function(e,i){var s=n(e[1]),o=new t.Pow(s);return i._eval(e[0]).connect(o),o}},a2g:{regexp:/^a2g/,method:function(e,i){var s=new t.AudioToGain;return i._eval(e[0]).connect(s),s}}},binary:{"+":{regexp:/^\+/,precedence:1,method:e.bind(this,t.Add)},"-":{regexp:/^\-/,precedence:1,method:function(s,n){return 1===s.length?i(t.Negate,s,n):e(t.Subtract,s,n)}},"*":{regexp:/^\*/,precedence:0,method:e.bind(this,t.Multiply)}},unary:{"-":{regexp:/^\-/,method:i.bind(this,t.Negate)},"!":{regexp:/^\!/,method:i.bind(this,t.NOT)}}},t.Expr.prototype._parseInputs=function(t){var e=t.match(/\$\d/g),i=0;if(null!==e)for(var s=0;s<e.length;s++){var n=parseInt(e[s].substr(1))+1;i=Math.max(i,n)}return i},t.Expr.prototype._replacements=function(t){for(var e=t.shift(),i=0;i<t.length;i++)e=e.replace(/\%/i,t[i]);return e},t.Expr.prototype._tokenize=function(e){for(var i=-1,s=[];e.length>0;){e=e.trim();var n=function(e){for(var i in t.Expr._Expressions){var s=t.Expr._Expressions[i];for(var n in s){var o=s[n],r=o.regexp,a=e.match(r);if(null!==a)return{type:i,value:a[0],method:o.method}}}throw new SyntaxError("Tone.Expr: Unexpected token "+e)}(e);s.push(n),e=e.substr(n.value.length)}return{next:function(){return s[++i]},peek:function(){return s[i+1]}}},t.Expr.prototype._parseTree=function(e){function i(t,e){return!c(t)&&"glue"===t.type&&t.value===e}function s(e,i,s){var n=t.Expr._Expressions[i];if(!c(e))for(var o in n){var r=n[o];if(r.regexp.test(e.value)){if(c(s))return!0;if(r.precedence===s)return!0}}return!1}function n(t){c(t)&&(t=5);var e;e=t<0?o():n(t-1);for(var i=l.peek();s(i,"binary",t);)i=l.next(),e={operator:i.value,method:i.method,args:[e,n(t-1)]},i=l.peek();return e}function o(){var t,e;return t=l.peek(),s(t,"unary")?(t=l.next(),e=o(),{operator:t.value,method:t.method,args:[e]}):r()}function r(){var t,e;if(t=l.peek(),c(t))throw new SyntaxError("Tone.Expr: Unexpected termination of expression");if("func"===t.type)return t=l.next(),a(t);if("value"===t.type)return t=l.next(),{method:t.method,args:t.value};if(i(t,"(")){if(l.next(),e=n(),t=l.next(),!i(t,")"))throw new SyntaxError("Expected )");return e}throw new SyntaxError("Tone.Expr: Parse error, cannot process token "+t.value)}function a(t){var e,s=[];if(e=l.next(),!i(e,"("))throw new SyntaxError('Tone.Expr: Expected ( in a function call "'+t.value+'"');if(e=l.peek(),i(e,")")||(s=h()),e=l.next(),!i(e,")"))throw new SyntaxError('Tone.Expr: Expected ) in a function call "'+t.value+'"');return{method:t.method,args:s,name:name}}function h(){for(var t,e,s=[];;){if(e=n(),c(e))break;if(s.push(e),t=l.peek(),!i(t,","))break;l.next()}return s}var l=this._tokenize(e),c=this.isUndef.bind(this);return n()},t.Expr.prototype._eval=function(t){if(!this.isUndef(t)){var e=t.method(t.args,this);return this._nodes.push(e),e}},t.Expr.prototype._disposeNodes=function(){for(var t=0;t<this._nodes.length;t++){var e=this._nodes[t];this.isFunction(e.dispose)?e.dispose():this.isFunction(e.disconnect)&&e.disconnect(),e=null,this._nodes[t]=null}this._nodes=null},t.Expr.prototype.dispose=function(){t.prototype.dispose.call(this),this._disposeNodes()},t.Expr}),t(function(t){return t.EqualPowerGain=function(){this._eqPower=this.input=this.output=new t.WaveShaper(function(t){return Math.abs(t)<.001?0:this.equalPowerScale(t)}.bind(this),4096)},t.extend(t.EqualPowerGain,t.SignalBase),t.EqualPowerGain.prototype.dispose=function(){return t.prototype.dispose.call(this),this._eqPower.dispose(),this._eqPower=null,this},t.EqualPowerGain}),t(function(t){return t.CrossFade=function(e){this.createInsOuts(2,1),this.a=this.input[0]=new t.Gain,this.b=this.input[1]=new t.Gain,this.fade=new t.Signal(this.defaultArg(e,.5),t.Type.NormalRange),this._equalPowerA=new t.EqualPowerGain,this._equalPowerB=new t.EqualPowerGain,this._invert=new t.Expr("1 - $0"),this.a.connect(this.output),this.b.connect(this.output),this.fade.chain(this._equalPowerB,this.b.gain),this.fade.chain(this._invert,this._equalPowerA,this.a.gain),this._readOnly("fade")},t.extend(t.CrossFade),t.CrossFade.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable("fade"),this._equalPowerA.dispose(),this._equalPowerA=null,this._equalPowerB.dispose(),this._equalPowerB=null,this.fade.dispose(),this.fade=null,this._invert.dispose(),this._invert=null,this.a.dispose(),this.a=null,this.b.dispose(),this.b=null,this},t.CrossFade}),t(function(t){return t.Filter=function(){this.createInsOuts(1,1);var e=this.optionsObject(arguments,["frequency","type","rolloff"],t.Filter.defaults);this._filters=[],this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=new t.Signal(0,t.Type.Cents),this.gain=new t.Signal({value:e.gain,convert:!1}),this.Q=new t.Signal(e.Q),this._type=e.type,this._rolloff=e.rolloff,this.rolloff=e.rolloff,this._readOnly(["detune","frequency","gain","Q"])},t.extend(t.Filter),t.Filter.defaults={type:"lowpass",frequency:350,rolloff:-12,Q:1,gain:0},Object.defineProperty(t.Filter.prototype,"type",{get:function(){return this._type},set:function(t){if(-1===["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t))throw new TypeError("Tone.Filter: invalid type "+t);this._type=t;for(var e=0;e<this._filters.length;e++)this._filters[e].type=t}}),Object.defineProperty(t.Filter.prototype,"rolloff",{get:function(){return this._rolloff},set:function(t){t=parseInt(t,10);var e=[-12,-24,-48,-96],i=e.indexOf(t);if(-1===i)throw new RangeError("Tone.Filter: rolloff can only be -12, -24, -48 or -96");i+=1,this._rolloff=t,this.input.disconnect();for(var s=0;s<this._filters.length;s++)this._filters[s].disconnect(),this._filters[s]=null;this._filters=new Array(i);for(var n=0;n<i;n++){var o=this.context.createBiquadFilter();o.type=this._type,this.frequency.connect(o.frequency),this.detune.connect(o.detune),this.Q.connect(o.Q),this.gain.connect(o.gain),this._filters[n]=o}var r=[this.input].concat(this._filters).concat([this.output]);this.connectSeries.apply(this,r)}}),t.Filter.prototype.dispose=function(){t.prototype.dispose.call(this);for(var e=0;e<this._filters.length;e++)this._filters[e].disconnect(),this._filters[e]=null;return this._filters=null,this._writable(["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.frequency=null,this.Q=null,this.detune.dispose(),this.detune=null,this.gain.dispose(),this.gain=null,this},t.Filter}),t(function(t){return t.MultibandSplit=function(){var e=this.optionsObject(arguments,["lowFrequency","highFrequency"],t.MultibandSplit.defaults);this.input=new t.Gain,this.output=new Array(3),this.low=this.output[0]=new t.Filter(0,"lowpass"),this._lowMidFilter=new t.Filter(0,"highpass"),this.mid=this.output[1]=new t.Filter(0,"lowpass"),this.high=this.output[2]=new t.Filter(0,"highpass"),this.lowFrequency=new t.Signal(e.lowFrequency,t.Type.Frequency),this.highFrequency=new t.Signal(e.highFrequency,t.Type.Frequency),this.Q=new t.Signal(e.Q),this.input.fan(this.low,this.high),this.input.chain(this._lowMidFilter,this.mid),this.lowFrequency.connect(this.low.frequency),this.lowFrequency.connect(this._lowMidFilter.frequency),this.highFrequency.connect(this.mid.frequency),this.highFrequency.connect(this.high.frequency),this.Q.connect(this.low.Q),this.Q.connect(this._lowMidFilter.Q),this.Q.connect(this.mid.Q),this.Q.connect(this.high.Q),this._readOnly(["high","mid","low","highFrequency","lowFrequency"])},t.extend(t.MultibandSplit),t.MultibandSplit.defaults={lowFrequency:400,highFrequency:2500,Q:1},t.MultibandSplit.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable(["high","mid","low","highFrequency","lowFrequency"]),this.low.dispose(),this.low=null,this._lowMidFilter.dispose(),this._lowMidFilter=null,this.mid.dispose(),this.mid=null,this.high.dispose(),this.high=null,this.lowFrequency.dispose(),this.lowFrequency=null,this.highFrequency.dispose(),this.highFrequency=null,this.Q.dispose(),this.Q=null,this},t.MultibandSplit}),t(function(t){return t.EQ3=function(){var e=this.optionsObject(arguments,["low","mid","high"],t.EQ3.defaults);this.output=new t.Gain,this._multibandSplit=this.input=new t.MultibandSplit({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency}),this._lowGain=new t.Gain(e.low,t.Type.Decibels),this._midGain=new t.Gain(e.mid,t.Type.Decibels),this._highGain=new t.Gain(e.high,t.Type.Decibels),this.low=this._lowGain.gain,this.mid=this._midGain.gain,this.high=this._highGain.gain,this.Q=this._multibandSplit.Q,this.lowFrequency=this._multibandSplit.lowFrequency,this.highFrequency=this._multibandSplit.highFrequency,this._multibandSplit.low.chain(this._lowGain,this.output),this._multibandSplit.mid.chain(this._midGain,this.output),this._multibandSplit.high.chain(this._highGain,this.output),this._readOnly(["low","mid","high","lowFrequency","highFrequency"])},t.extend(t.EQ3),t.EQ3.defaults={low:0,mid:0,high:0,lowFrequency:400,highFrequency:2500},t.EQ3.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable(["low","mid","high","lowFrequency","highFrequency"]),this._multibandSplit.dispose(),this._multibandSplit=null,this.lowFrequency=null,this.highFrequency=null,this._lowGain.dispose(),this._lowGain=null,this._midGain.dispose(),this._midGain=null,this._highGain.dispose(),this._highGain=null,this.low=null,this.mid=null,this.high=null,this.Q=null,this},t.EQ3}),t(function(t){return t.Scale=function(e,i){this._outputMin=this.defaultArg(e,0),this._outputMax=this.defaultArg(i,1),this._scale=this.input=new t.Multiply(1),this._add=this.output=new t.Add(0),this._scale.connect(this._add),this._setRange()},t.extend(t.Scale,t.SignalBase),Object.defineProperty(t.Scale.prototype,"min",{get:function(){return this._outputMin},set:function(t){this._outputMin=t,this._setRange()}}),Object.defineProperty(t.Scale.prototype,"max",{get:function(){return this._outputMax},set:function(t){this._outputMax=t,this._setRange()}}),t.Scale.prototype._setRange=function(){this._add.value=this._outputMin,this._scale.value=this._outputMax-this._outputMin},t.Scale.prototype.dispose=function(){return t.prototype.dispose.call(this),this._add.dispose(),this._add=null,this._scale.dispose(),this._scale=null,this},t.Scale}),t(function(t){return t.ScaleExp=function(e,i,s){this._scale=this.output=new t.Scale(e,i),this._exp=this.input=new t.Pow(this.defaultArg(s,2)),this._exp.connect(this._scale)},t.extend(t.ScaleExp,t.SignalBase),Object.defineProperty(t.ScaleExp.prototype,"exponent",{get:function(){return this._exp.value},set:function(t){this._exp.value=t}}),Object.defineProperty(t.ScaleExp.prototype,"min",{get:function(){return this._scale.min},set:function(t){this._scale.min=t}}),Object.defineProperty(t.ScaleExp.prototype,"max",{get:function(){return this._scale.max},set:function(t){this._scale.max=t}}),t.ScaleExp.prototype.dispose=function(){return t.prototype.dispose.call(this),this._scale.dispose(),this._scale=null,this._exp.dispose(),this._exp=null,this},t.ScaleExp}),t(function(t){return window.DelayNode&&!AudioContext.prototype.createDelay&&(AudioContext.prototype.createDelay=AudioContext.prototype.createDelayNode),t.Delay=function(){var e=this.optionsObject(arguments,["delayTime","maxDelay"],t.Delay.defaults);this._delayNode=this.input=this.output=this.context.createDelay(this.toSeconds(e.maxDelay)),this.delayTime=new t.Param({param:this._delayNode.delayTime,units:t.Type.Time,value:e.delayTime}),this._readOnly("delayTime")},t.extend(t.Delay),t.Delay.defaults={maxDelay:1,delayTime:0},t.Delay.prototype.dispose=function(){return t.Param.prototype.dispose.call(this),this._delayNode.disconnect(),this._delayNode=null,this._writable("delayTime"),this.delayTime=null,this},t.Delay}),t(function(t){return t.FeedbackCombFilter=function(){var e=this.optionsObject(arguments,["delayTime","resonance"],t.FeedbackCombFilter.defaults);this._delay=this.input=this.output=new t.Delay(e.delayTime),this.delayTime=this._delay.delayTime,this._feedback=new t.Gain(e.resonance,t.Type.NormalRange),this.resonance=this._feedback.gain,this._delay.chain(this._feedback,this._delay),this._readOnly(["resonance","delayTime"])},t.extend(t.FeedbackCombFilter),t.FeedbackCombFilter.defaults={delayTime:.1,resonance:.5},t.FeedbackCombFilter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable(["resonance","delayTime"]),this._delay.dispose(),this._delay=null,this.delayTime=null,this._feedback.dispose(),this._feedback=null,this.resonance=null,this},t.FeedbackCombFilter}),t(function(t){return t.Follower=function(){this.createInsOuts(1,1);var e=this.optionsObject(arguments,["attack","release"],t.Follower.defaults);this._abs=new t.Abs,this._filter=this.context.createBiquadFilter(),this._filter.type="lowpass",this._filter.frequency.value=0,this._filter.Q.value=-100,this._frequencyValues=new t.WaveShaper,this._sub=new t.Subtract,this._delay=new t.Delay(this.blockTime),this._mult=new t.Multiply(1e4),this._attack=e.attack,this._release=e.release,this.input.chain(this._abs,this._filter,this.output),this._abs.connect(this._sub,0,1),this._filter.chain(this._delay,this._sub),this._sub.chain(this._mult,this._frequencyValues,this._filter.frequency),this._setAttackRelease(this._attack,this._release)},t.extend(t.Follower),t.Follower.defaults={attack:.05,release:.5},t.Follower.prototype._setAttackRelease=function(e,i){var s=this.blockTime;e=t.Time(e).toFrequency(),i=t.Time(i).toFrequency(),e=Math.max(e,s),i=Math.max(i,s),this._frequencyValues.setMap(function(t){return t<=0?e:i})},Object.defineProperty(t.Follower.prototype,"attack",{get:function(){return this._attack},set:function(t){this._attack=t,this._setAttackRelease(this._attack,this._release)}}),Object.defineProperty(t.Follower.prototype,"release",{get:function(){return this._release},set:function(t){this._release=t,this._setAttackRelease(this._attack,this._release)}}),t.Follower.prototype.connect=t.Signal.prototype.connect,t.Follower.prototype.dispose=function(){return t.prototype.dispose.call(this),this._filter.disconnect(),this._filter=null,this._frequencyValues.disconnect(),this._frequencyValues=null,this._delay.dispose(),this._delay=null,this._sub.disconnect(),this._sub=null,this._abs.dispose(),this._abs=null,this._mult.dispose(),this._mult=null,this._curve=null,this},t.Follower}),t(function(t){return t.ScaledEnvelope=function(){var e=this.optionsObject(arguments,["attack","decay","sustain","release"],t.Envelope.defaults);t.Envelope.call(this,e),e=this.defaultArg(e,t.ScaledEnvelope.defaults),this._exp=this.output=new t.Pow(e.exponent),this._scale=this.output=new t.Scale(e.min,e.max),this._sig.chain(this._exp,this._scale)},t.extend(t.ScaledEnvelope,t.Envelope),t.ScaledEnvelope.defaults={min:0,max:1,exponent:1},Object.defineProperty(t.ScaledEnvelope.prototype,"min",{get:function(){return this._scale.min},set:function(t){this._scale.min=t}}),Object.defineProperty(t.ScaledEnvelope.prototype,"max",{get:function(){return this._scale.max},set:function(t){this._scale.max=t}}),Object.defineProperty(t.ScaledEnvelope.prototype,"exponent",{get:function(){return this._exp.value},set:function(t){this._exp.value=t}}),t.ScaledEnvelope.prototype.dispose=function(){return t.Envelope.prototype.dispose.call(this),this._scale.dispose(),this._scale=null,this._exp.dispose(),this._exp=null,this},t.ScaledEnvelope}),t(function(t){return t.FrequencyEnvelope=function(){var e=this.optionsObject(arguments,["attack","decay","sustain","release"],t.Envelope.defaults);t.ScaledEnvelope.call(this,e),e=this.defaultArg(e,t.FrequencyEnvelope.defaults),this._octaves=e.octaves,this.baseFrequency=e.baseFrequency,this.octaves=e.octaves},t.extend(t.FrequencyEnvelope,t.Envelope),t.FrequencyEnvelope.defaults={baseFrequency:200,octaves:4,exponent:2},Object.defineProperty(t.FrequencyEnvelope.prototype,"baseFrequency",{get:function(){return this._scale.min},set:function(t){this._scale.min=this.toFrequency(t),this.octaves=this._octaves}}),Object.defineProperty(t.FrequencyEnvelope.prototype,"octaves",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._scale.max=this.baseFrequency*Math.pow(2,t)}}),Object.defineProperty(t.FrequencyEnvelope.prototype,"exponent",{get:function(){return this._exp.value},set:function(t){this._exp.value=t}}),t.FrequencyEnvelope.prototype.dispose=function(){return t.ScaledEnvelope.prototype.dispose.call(this),this},t.FrequencyEnvelope}),t(function(t){return t.Gate=function(){this.createInsOuts(1,1);var e=this.optionsObject(arguments,["threshold","attack","release"],t.Gate.defaults);this._follower=new t.Follower(e.attack,e.release),this._gt=new t.GreaterThan(this.dbToGain(e.threshold)),this.input.connect(this.output),this.input.chain(this._gt,this._follower,this.output.gain)},t.extend(t.Gate),t.Gate.defaults={attack:.1,release:.1,threshold:-40},Object.defineProperty(t.Gate.prototype,"threshold",{get:function(){return this.gainToDb(this._gt.value)},set:function(t){this._gt.value=this.dbToGain(t)}}),Object.defineProperty(t.Gate.prototype,"attack",{get:function(){return this._follower.attack},set:function(t){this._follower.attack=t}}),Object.defineProperty(t.Gate.prototype,"release",{get:function(){return this._follower.release},set:function(t){this._follower.release=t}}),t.Gate.prototype.dispose=function(){return t.prototype.dispose.call(this),this._follower.dispose(),this._gt.dispose(),this._follower=null,this._gt=null,this},t.Gate}),t(function(t){return t.TimelineState=function(e){t.Timeline.call(this),this._initial=e},t.extend(t.TimelineState,t.Timeline),t.TimelineState.prototype.getValueAtTime=function(t){var e=this.get(t);return null!==e?e.state:this._initial},t.TimelineState.prototype.setStateAtTime=function(t,e){this.add({state:t,time:e})},t.TimelineState}),t(function(t){return t.Clock=function(){t.Emitter.call(this);var e=this.optionsObject(arguments,["callback","frequency"],t.Clock.defaults);this.callback=e.callback,this._nextTick=0,this._lastState=t.State.Stopped,this.frequency=new t.TimelineSignal(e.frequency,t.Type.Frequency),this._readOnly("frequency"),this.ticks=0,this._state=new t.TimelineState(t.State.Stopped),this._boundLoop=this._loop.bind(this),this.context.on("tick",this._boundLoop)},t.extend(t.Clock,t.Emitter),t.Clock.defaults={callback:t.noOp,frequency:1,lookAhead:"auto"},Object.defineProperty(t.Clock.prototype,"state",{get:function(){return this._state.getValueAtTime(this.now())}}),t.Clock.prototype.start=function(e,i){return e=this.toSeconds(e),this._state.getValueAtTime(e)!==t.State.Started&&this._state.add({state:t.State.Started,time:e,offset:i}),this},t.Clock.prototype.stop=function(e){return e=this.toSeconds(e),this._state.cancel(e),this._state.setStateAtTime(t.State.Stopped,e),this},t.Clock.prototype.pause=function(e){return e=this.toSeconds(e),this._state.getValueAtTime(e)===t.State.Started&&this._state.setStateAtTime(t.State.Paused,e),this},t.Clock.prototype._loop=function(){for(var e=this.now(),i=this.context.lookAhead,s=this.context.updateInterval,n=2*this.context.lag,o=e+i+s+n;o>this._nextTick&&this._state;){var r=this._state.getValueAtTime(this._nextTick);if(r!==this._lastState){this._lastState=r;var a=this._state.get(this._nextTick);r===t.State.Started?(this._nextTick=a.time,this.isUndef(a.offset)||(this.ticks=a.offset),this.emit("start",a.time,this.ticks)):r===t.State.Stopped?(this.ticks=0,this.emit("stop",a.time)):r===t.State.Paused&&this.emit("pause",a.time)}var h=this._nextTick;this.frequency&&(this._nextTick+=1/this.frequency.getValueAtTime(this._nextTick),r===t.State.Started&&(this.callback(h),this.ticks++))}},t.Clock.prototype.getStateAtTime=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)},t.Clock.prototype.dispose=function(){t.Emitter.prototype.dispose.call(this),this.context.off("tick",this._boundLoop),this._writable("frequency"),this.frequency.dispose(),this.frequency=null,this._boundLoop=null,this._nextTick=1/0,this.callback=null,this._state.dispose(),this._state=null},t.Clock}),t(function(t){t.IntervalTimeline=function(){this._root=null,this._length=0},t.extend(t.IntervalTimeline),t.IntervalTimeline.prototype.add=function(t){if(this.isUndef(t.time)||this.isUndef(t.duration))throw new Error("Tone.IntervalTimeline: events must have time and duration parameters");var i=new e(t.time,t.time+t.duration,t);for(null===this._root?this._root=i:this._root.insert(i),this._length++;null!==i;)i.updateHeight(),i.updateMax(),this._rebalance(i),i=i.parent;return this},t.IntervalTimeline.prototype.remove=function(t){if(null!==this._root){var e=[];this._root.search(t.time,e);for(var i=0;i<e.length;i++){var s=e[i];if(s.event===t){this._removeNode(s),this._length--;break}}}return this},Object.defineProperty(t.IntervalTimeline.prototype,"length",{get:function(){return this._length}}),t.IntervalTimeline.prototype.cancel=function(t){return this.forEachAfter(t,function(t){this.remove(t)}.bind(this)),this},t.IntervalTimeline.prototype._setRoot=function(t){this._root=t,null!==this._root&&(this._root.parent=null)},t.IntervalTimeline.prototype._replaceNodeInParent=function(t,e){null!==t.parent?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)},t.IntervalTimeline.prototype._removeNode=function(t){if(null===t.left&&null===t.right)this._replaceNodeInParent(t,null);else if(null===t.right)this._replaceNodeInParent(t,t.left);else if(null===t.left)this._replaceNodeInParent(t,t.right);else{var e,i,s=t.getBalance();if(s>0)if(null===t.left.right)e=t.left,e.right=t.right,i=e;else{for(e=t.left.right;null!==e.right;)e=e.right;e.parent.right=e.left,i=e.parent,e.left=t.left,e.right=t.right}else if(null===t.right.left)e=t.right,e.left=t.left,i=e;else{for(e=t.right.left;null!==e.left;)e=e.left;e.parent=e.parent,e.parent.left=e.right,i=e.parent,e.left=t.left,e.right=t.right}null!==t.parent?t.isLeftChild()?t.parent.left=e:t.parent.right=e:this._setRoot(e),this._rebalance(i)}t.dispose()},t.IntervalTimeline.prototype._rotateLeft=function(t){var e=t.parent,i=t.isLeftChild(),s=t.right;t.right=s.left,s.left=t,null!==e?i?e.left=s:e.right=s:this._setRoot(s)},t.IntervalTimeline.prototype._rotateRight=function(t){var e=t.parent,i=t.isLeftChild(),s=t.left;t.left=s.right,s.right=t,null!==e?i?e.left=s:e.right=s:this._setRoot(s)},t.IntervalTimeline.prototype._rebalance=function(t){var e=t.getBalance();e>1?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))},t.IntervalTimeline.prototype.get=function(t){if(null!==this._root){var e=[];if(this._root.search(t,e),e.length>0){for(var i=e[0],s=1;s<e.length;s++)e[s].low>i.low&&(i=e[s]);return i.event}}return null},t.IntervalTimeline.prototype.forEach=function(t){if(null!==this._root){var e=[];null!==this._root&&this._root.traverse(function(t){e.push(t)});for(var i=0;i<e.length;i++){var s=e[i].event;s&&t(s)}}return this},t.IntervalTimeline.prototype.forEachAtTime=function(t,e){if(null!==this._root){var i=[];this._root.search(t,i);for(var s=i.length-1;s>=0;s--){var n=i[s].event;n&&e(n)}}return this},t.IntervalTimeline.prototype.forEachAfter=function(t,e){if(null!==this._root){var i=[];this._root.searchAfter(t,i);for(var s=i.length-1;s>=0;s--){var n=i[s].event;n&&e(n)}}return this},t.IntervalTimeline.prototype.dispose=function(){var t=[];null!==this._root&&this._root.traverse(function(e){t.push(e)});for(var e=0;e<t.length;e++)t[e].dispose();return t=null,this._root=null,this};var e=function(t,e,i){this.event=i,this.low=t,this.high=e,this.max=this.high,this._left=null,this._right=null,this.parent=null,this.height=0};return e.prototype.insert=function(t){t.low<=this.low?null===this.left?this.left=t:this.left.insert(t):null===this.right?this.right=t:this.right.insert(t)},e.prototype.search=function(t,e){t>this.max||(null!==this.left&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),this.low>t||null!==this.right&&this.right.search(t,e))},e.prototype.searchAfter=function(t,e){this.low>=t&&(e.push(this),null!==this.left&&this.left.searchAfter(t,e)),null!==this.right&&this.right.searchAfter(t,e)},e.prototype.traverse=function(t){t(this),null!==this.left&&this.left.traverse(t),null!==this.right&&this.right.traverse(t)},e.prototype.updateHeight=function(){null!==this.left&&null!==this.right?this.height=Math.max(this.left.height,this.right.height)+1:null!==this.right?this.height=this.right.height+1:null!==this.left?this.height=this.left.height+1:this.height=0},e.prototype.updateMax=function(){this.max=this.high,null!==this.left&&(this.max=Math.max(this.max,this.left.max)),null!==this.right&&(this.max=Math.max(this.max,this.right.max))},e.prototype.getBalance=function(){var t=0;return null!==this.left&&null!==this.right?t=this.left.height-this.right.height:null!==this.left?t=this.left.height+1:null!==this.right&&(t=-(this.right.height+1)),t},e.prototype.isLeftChild=function(){return null!==this.parent&&this.parent.left===this},Object.defineProperty(e.prototype,"left",{get:function(){return this._left},set:function(t){this._left=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}}),Object.defineProperty(e.prototype,"right",{get:function(){return this._right},set:function(t){this._right=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}}),e.prototype.dispose=function(){this.parent=null,this._left=null,this._right=null,this.event=null},t.IntervalTimeline}),t(function(t){t.Transport=function(){t.Emitter.call(this),this.loop=!1,this._loopStart=0,this._loopEnd=0,this._ppq=e.defaults.PPQ,this._clock=new t.Clock({callback:this._processTick.bind(this),frequency:0}),this._bindClockEvents(),this.bpm=this._clock.frequency,this.bpm._toUnits=this._toUnits.bind(this),this.bpm._fromUnits=this._fromUnits.bind(this),this.bpm.units=t.Type.BPM,this.bpm.value=e.defaults.bpm,this._readOnly("bpm"),this._timeSignature=e.defaults.timeSignature,this._scheduledEvents={},this._eventID=0,this._timeline=new t.Timeline,this._repeatedEvents=new t.IntervalTimeline,this._onceEvents=new t.Timeline,this._syncedSignals=[],this._swingTicks=e.defaults.PPQ/2,this._swingAmount=0},t.extend(t.Transport,t.Emitter),t.Transport.defaults={bpm:120,swing:0,swingSubdivision:"8n",timeSignature:4,loopStart:0,loopEnd:"4m",PPQ:192},t.Transport.prototype._processTick=function(e){var i=this._clock.ticks;if(this._swingAmount>0&&i%this._ppq!=0&&i%(2*this._swingTicks)!=0){var s=i%(2*this._swingTicks)/(2*this._swingTicks),n=Math.sin(s*Math.PI)*this._swingAmount;e+=t.Time(2*this._swingTicks/3,"i")*n}this.loop&&i===this._loopEnd&&(this.emit("loopEnd",e),this._clock.ticks=this._loopStart,i=this._loopStart,this.emit("loopStart",e,this.seconds),this.emit("loop",e)),this._onceEvents.forEachBefore(i,function(t){t.callback(e),delete this._scheduledEvents[t.id.toString()]}.bind(this)),this._onceEvents.cancelBefore(i),this._timeline.forEachAtTime(i,function(t){t.callback(e)}),this._repeatedEvents.forEachAtTime(i,function(t){(i-t.time)%t.interval==0&&t.callback(e)})},t.Transport.prototype.schedule=function(t,e){var i={time:this.toTicks(e),callback:t},s=this._eventID++;return this._scheduledEvents[s.toString()]={event:i,timeline:this._timeline},this._timeline.add(i),s},t.Transport.prototype.scheduleRepeat=function(t,e,i,s){if(e<=0)throw new Error("Tone.Transport: repeat events must have an interval larger than 0");var n={time:this.toTicks(i),duration:this.toTicks(this.defaultArg(s,1/0)),interval:this.toTicks(e),callback:t},o=this._eventID++;return this._scheduledEvents[o.toString()]={event:n,timeline:this._repeatedEvents},this._repeatedEvents.add(n),o},t.Transport.prototype.scheduleOnce=function(t,e){var i=this._eventID++,s={time:this.toTicks(e),callback:t,id:i};return this._scheduledEvents[i.toString()]={event:s,timeline:this._onceEvents},this._onceEvents.add(s),i},t.Transport.prototype.clear=function(t){if(this._scheduledEvents.hasOwnProperty(t)){var e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),delete this._scheduledEvents[t.toString()]}return this},t.Transport.prototype.cancel=function(t){return t=this.defaultArg(t,0),t=this.toTicks(t),this._timeline.cancel(t),this._onceEvents.cancel(t),this._repeatedEvents.cancel(t),this},t.Transport.prototype._bindClockEvents=function(){this._clock.on("start",function(e,i){i=t.Time(this._clock.ticks,"i").toSeconds(),this.emit("start",e,i)}.bind(this)),this._clock.on("stop",function(t){this.emit("stop",t)}.bind(this)),this._clock.on("pause",function(t){this.emit("pause",t)}.bind(this))},Object.defineProperty(t.Transport.prototype,"state",{get:function(){return this._clock.getStateAtTime(this.now())}}),t.Transport.prototype.start=function(t,e){return this.isUndef(e)||(e=this.toTicks(e)),this._clock.start(t,e),this},t.Transport.prototype.stop=function(t){return this._clock.stop(t),this},t.Transport.prototype.pause=function(t){return this._clock.pause(t),this},Object.defineProperty(t.Transport.prototype,"timeSignature",{get:function(){return this._timeSignature},set:function(t){this.isArray(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}}),Object.defineProperty(t.Transport.prototype,"loopStart",{get:function(){return t.TransportTime(this._loopStart,"i").toSeconds()},set:function(t){this._loopStart=this.toTicks(t)}}),Object.defineProperty(t.Transport.prototype,"loopEnd",{get:function(){return t.TransportTime(this._loopEnd,"i").toSeconds()},set:function(t){this._loopEnd=this.toTicks(t)}}),t.Transport.prototype.setLoopPoints=function(t,e){return this.loopStart=t,this.loopEnd=e,this},Object.defineProperty(t.Transport.prototype,"swing",{get:function(){return this._swingAmount},set:function(t){this._swingAmount=t}}),Object.defineProperty(t.Transport.prototype,"swingSubdivision",{get:function(){return t.Time(this._swingTicks,"i").toNotation()},set:function(t){this._swingTicks=this.toTicks(t)}}),Object.defineProperty(t.Transport.prototype,"position",{get:function(){return t.TransportTime(this.ticks,"i").toBarsBeatsSixteenths()},set:function(t){var e=this.toTicks(t);this.ticks=e}}),Object.defineProperty(t.Transport.prototype,"seconds",{get:function(){return t.TransportTime(this.ticks,"i").toSeconds()},set:function(t){var e=this.toTicks(t);this.ticks=e}}),Object.defineProperty(t.Transport.prototype,"progress",{get:function(){return this.loop?(this.ticks-this._loopStart)/(this._loopEnd-this._loopStart):0}}),Object.defineProperty(t.Transport.prototype,"ticks",{get:function(){return this._clock.ticks},set:function(e){if(this._clock.ticks!==e){var i=this.now();this.state===t.State.Started?(this.emit("stop",i),this._clock.ticks=e,this.emit("start",i,this.seconds)):this._clock.ticks=e}}}),Object.defineProperty(t.Transport.prototype,"PPQ",{get:function(){return this._ppq},set:function(t){var e=this.bpm.value;this._ppq=t,this.bpm.value=e}}),Object.defineProperty(t.Transport.prototype,"latencyHint",{get:function(){return t.Clock.latencyHint},set:function(e){t.Clock.latencyHint=e}}),t.Transport.prototype._fromUnits=function(t){return 1/(60/t/this.PPQ)},t.Transport.prototype._toUnits=function(t){return t/this.PPQ*60},t.Transport.prototype.nextSubdivision=function(e){e=this.toSeconds(e);var i;if(this.state!==t.State.Started)return 0;i=this._clock._nextTick;var s=t.Time(this.ticks,"i"),n=e-s%e;return 0===n&&(n=e),i+n},t.Transport.prototype.syncSignal=function(e,i){i||(i=0!==e._param.value?e._param.value/this.bpm._param.value:0);var s=new t.Gain(i);return this.bpm.chain(s,e._param),this._syncedSignals.push({ratio:s,signal:e,initial:e._param.value}),e._param.value=0,this},t.Transport.prototype.unsyncSignal=function(t){for(var e=this._syncedSignals.length-1;e>=0;e--){var i=this._syncedSignals[e];i.signal===t&&(i.ratio.dispose(),i.signal._param.value=i.initial,this._syncedSignals.splice(e,1))}return this},t.Transport.prototype.dispose=function(){return t.Emitter.prototype.dispose.call(this),this._clock.dispose(),this._clock=null,this._writable("bpm"),this.bpm=null,this._timeline.dispose(),this._timeline=null,this._onceEvents.dispose(),this._onceEvents=null,this._repeatedEvents.dispose(),this._repeatedEvents=null,this};var e=t.Transport;return t.Transport=new e,t.Context.on("init",function(i){i.Transport instanceof e?t.Transport=i.Transport:(t.Transport=new e,i.Transport=t.Transport)}),t.Transport}),t(function(t){return t.Volume=function(){var e=this.optionsObject(arguments,["volume"],t.Volume.defaults);this.output=this.input=new t.Gain(e.volume,t.Type.Decibels),this._unmutedVolume=e.volume,this.volume=this.output.gain,this._readOnly("volume"),this.mute=e.mute},t.extend(t.Volume),t.Volume.defaults={volume:0,mute:!1},Object.defineProperty(t.Volume.prototype,"mute",{get:function(){return this.volume.value===-1/0},set:function(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}}),t.Volume.prototype.dispose=function(){return this.input.dispose(),t.prototype.dispose.call(this),this._writable("volume"),this.volume.dispose(),this.volume=null,this},t.Volume}),t(function(t){t.Master=function(){this.createInsOuts(1,1),this._volume=this.output=new t.Volume,this.volume=this._volume.volume,this._readOnly("volume"),this.input.chain(this.output,this.context.destination)},t.extend(t.Master),t.Master.defaults={volume:0,mute:!1},Object.defineProperty(t.Master.prototype,"mute",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),t.Master.prototype.chain=function(){this.input.disconnect(),this.input.chain.apply(this.input,arguments),arguments[arguments.length-1].connect(this.output)},t.Master.prototype.dispose=function(){t.prototype.dispose.call(this),this._writable("volume"),this._volume.dispose(),this._volume=null,this.volume=null},t.prototype.toMaster=function(){return this.connect(t.Master),this},AudioNode.prototype.toMaster=function(){return this.connect(t.Master),this};var e=t.Master;return t.Master=new e,t.Context.on("init",function(i){i.Master instanceof e?t.Master=i.Master:t.Master=new e,i.Master=t.Master}),t.Master}),t(function(t){return t.Source=function(e){e=this.defaultArg(e,t.Source.defaults),this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._readOnly("volume"),this._state=new t.TimelineState(t.State.Stopped),this._state.memory=10,this._synced=!1,this._scheduled=[],this._volume.output.output.channelCount=2,this._volume.output.output.channelCountMode="explicit",this.mute=e.mute},t.extend(t.Source),t.Source.defaults={volume:0,mute:!1},Object.defineProperty(t.Source.prototype,"state",{get:function(){return this._synced?t.Transport.state===t.State.Started?this._state.getValueAtTime(t.Transport.seconds):t.State.Stopped:this._state.getValueAtTime(this.now())}}),Object.defineProperty(t.Source.prototype,"mute",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),t.Source.prototype._start=t.noOp,t.Source.prototype._stop=t.noOp,t.Source.prototype.start=function(e,i,s){if(e=this.isUndef(e)&&this._synced?t.Transport.seconds:this.toSeconds(e),this.retrigger||this._state.getValueAtTime(e)!==t.State.Started||this.stop(e),this._state.setStateAtTime(t.State.Started,e),this._synced){var n=this._state.get(e);n.offset=this.defaultArg(i,0),n.duration=s;var o=t.Transport.schedule(function(t){this._start(t,i,s)}.bind(this),e);this._scheduled.push(o)}else this._start.apply(this,arguments);return this},t.Source.prototype.stop=function(e){if(e=this.isUndef(e)&&this._synced?t.Transport.seconds:this.toSeconds(e),this._state.cancel(e),this._state.setStateAtTime(t.State.Stopped,e),this._synced){var i=t.Transport.schedule(this._stop.bind(this),e);this._scheduled.push(i)}else this._stop.apply(this,arguments);return this},t.Source.prototype.sync=function(){return this._synced=!0,t.Transport.on("start loopStart",function(e,i){if(i>0){var s=this._state.get(i);if(s&&s.state===t.State.Started&&s.time!==i){var n,o=i-this.toSeconds(s.time);s.duration&&(n=this.toSeconds(s.duration)-o),this._start(e,this.toSeconds(s.offset)+o,n)}}}.bind(this)),t.Transport.on("stop pause loopEnd",function(e){this._state.getValueAtTime(t.Transport.seconds)===t.State.Started&&this._stop(e)}.bind(this)),this},t.Source.prototype.unsync=function(){this._synced=!1,t.Transport.off("start stop pause loopEnd loopStart");for(var e=0;e<this._scheduled.length;e++){var i=this._scheduled[e];t.Transport.clear(i)}return this._scheduled=[],this._state.cancel(0),this},t.Source.prototype.dispose=function(){t.prototype.dispose.call(this),this.unsync(),this._scheduled=null,this._writable("volume"),this._volume.dispose(),this._volume=null,this.volume=null,this._state.dispose(),this._state=null},t.Source}),t(function(t){return window.OscillatorNode&&!OscillatorNode.prototype.start&&(OscillatorNode.prototype.start=OscillatorNode.prototype.noteOn,OscillatorNode.prototype.stop=OscillatorNode.prototype.noteOff,OscillatorNode.prototype.setPeriodicWave||(OscillatorNode.prototype.setPeriodicWave=OscillatorNode.prototype.setWaveTable),AudioContext.prototype.createPeriodicWave||(AudioContext.prototype.createPeriodicWave=AudioContext.prototype.createWaveTable)),t.Oscillator=function(){var e=this.optionsObject(arguments,["frequency","type"],t.Oscillator.defaults);t.Source.call(this,e),this._oscillator=null,this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this._wave=null,this._partials=this.defaultArg(e.partials,[1]),this._phase=e.phase,this._type=null,this.type=e.type,this.phase=this._phase,this._readOnly(["frequency","detune"])},t.extend(t.Oscillator,t.Source),t.Oscillator.defaults={type:"sine",frequency:440,detune:0,phase:0,partials:[]},t.Oscillator.Type={Sine:"sine",Triangle:"triangle",Sawtooth:"sawtooth",Square:"square",Custom:"custom"},t.Oscillator.prototype._start=function(t){this._oscillator=this.context.createOscillator(),this._oscillator.setPeriodicWave(this._wave),this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(this.toSeconds(t))},t.Oscillator.prototype._stop=function(t){return this._oscillator&&(this._oscillator.stop(this.toSeconds(t)),this._oscillator=null),this},t.Oscillator.prototype.syncFrequency=function(){return t.Transport.syncSignal(this.frequency),this},t.Oscillator.prototype.unsyncFrequency=function(){return t.Transport.unsyncSignal(this.frequency),this},Object.defineProperty(t.Oscillator.prototype,"type",{get:function(){return this._type},set:function(t){var e=this._getRealImaginary(t,this._phase),i=this.context.createPeriodicWave(e[0],e[1]);this._wave=i,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave),this._type=t}}),t.Oscillator.prototype._getRealImaginary=function(e,i){var s=2048,n=new Float32Array(s),o=new Float32Array(s),r=1;if(e===t.Oscillator.Type.Custom)r=this._partials.length+1,s=r;else{var a=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(e);a&&(r=parseInt(a[2])+1,e=a[1],r=Math.max(r,2),s=r)}for(var h=1;h<s;++h){var l,c=2/(h*Math.PI);switch(e){case t.Oscillator.Type.Sine:l=h<=r?1:0;break;case t.Oscillator.Type.Square:l=1&h?2*c:0;break;case t.Oscillator.Type.Sawtooth:l=c*(1&h?1:-1);break;case t.Oscillator.Type.Triangle:l=1&h?c*c*2*(h-1>>1&1?-1:1):0;break;case t.Oscillator.Type.Custom:l=this._partials[h-1];break;default:throw new TypeError("Tone.Oscillator: invalid type: "+e)}0!==l?(n[h]=-l*Math.sin(i*h),o[h]=l*Math.cos(i*h)):(n[h]=0,o[h]=0)}return[n,o]},t.Oscillator.prototype._inverseFFT=function(t,e,i){for(var s=0,n=t.length,o=0;o<n;o++)s+=t[o]*Math.cos(o*i)+e[o]*Math.sin(o*i);return s},t.Oscillator.prototype._getInitialValue=function(){for(var t=this._getRealImaginary(this._type,0),e=t[0],i=t[1],s=0,n=2*Math.PI,o=0;o<8;o++)s=Math.max(this._inverseFFT(e,i,o/8*n),s);return-this._inverseFFT(e,i,this._phase)/s},Object.defineProperty(t.Oscillator.prototype,"partials",{get:function(){return this._type!==t.Oscillator.Type.Custom?[]:this._partials},set:function(e){this._partials=e,this.type=t.Oscillator.Type.Custom}}),Object.defineProperty(t.Oscillator.prototype,"phase",{get:function(){return this._phase*(180/Math.PI)},set:function(t){this._phase=t*Math.PI/180,this.type=this._type}}),t.Oscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),null!==this._oscillator&&(this._oscillator.disconnect(),this._oscillator=null),this._wave=null,this._writable(["frequency","detune"]),this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this._partials=null,this},t.Oscillator}),t(function(t){return t.Zero=function(){this._gain=this.input=this.output=new t.Gain,this.context.getConstant(0).connect(this._gain)},t.extend(t.Zero),t.Zero.prototype.dispose=function(){return t.prototype.dispose.call(this),this._gain.dispose(),this._gain=null,this},t.Zero}),t(function(t){return t.LFO=function(){var e=this.optionsObject(arguments,["frequency","min","max"],t.LFO.defaults);this._oscillator=new t.Oscillator({frequency:e.frequency,type:e.type}),this.frequency=this._oscillator.frequency,this.amplitude=this._oscillator.volume,this.amplitude.units=t.Type.NormalRange,this.amplitude.value=e.amplitude,this._stoppedSignal=new t.Signal(0,t.Type.AudioRange),this._zeros=new t.Zero,this._stoppedValue=0,this._a2g=new t.AudioToGain,this._scaler=this.output=new t.Scale(e.min,e.max),this._units=t.Type.Default,this.units=e.units,this._oscillator.chain(this._a2g,this._scaler),this._zeros.connect(this._a2g),this._stoppedSignal.connect(this._a2g),this._readOnly(["amplitude","frequency"]),this.phase=e.phase},t.extend(t.LFO,t.Oscillator),t.LFO.defaults={type:"sine",min:0,max:1,phase:0,frequency:"4n",amplitude:1,units:t.Type.Default},t.LFO.prototype.start=function(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(0,t),this._oscillator.start(t),this},t.LFO.prototype.stop=function(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(this._stoppedValue,t),this._oscillator.stop(t),this},t.LFO.prototype.sync=function(){return this._oscillator.sync(),this._oscillator.syncFrequency(),this},t.LFO.prototype.unsync=function(){return this._oscillator.unsync(),this._oscillator.unsyncFrequency(),this},Object.defineProperty(t.LFO.prototype,"min",{get:function(){return this._toUnits(this._scaler.min)},set:function(t){t=this._fromUnits(t),this._scaler.min=t}}),Object.defineProperty(t.LFO.prototype,"max",{get:function(){return this._toUnits(this._scaler.max)},set:function(t){t=this._fromUnits(t),this._scaler.max=t}}),Object.defineProperty(t.LFO.prototype,"type",{get:function(){return this._oscillator.type},set:function(t){this._oscillator.type=t,this._stoppedValue=this._oscillator._getInitialValue(),this._stoppedSignal.value=this._stoppedValue}}),Object.defineProperty(t.LFO.prototype,"phase",{get:function(){return this._oscillator.phase},set:function(t){this._oscillator.phase=t,this._stoppedValue=this._oscillator._getInitialValue(),this._stoppedSignal.value=this._stoppedValue}}),Object.defineProperty(t.LFO.prototype,"units",{get:function(){return this._units},set:function(t){var e=this.min,i=this.max;this._units=t,this.min=e,this.max=i}}),Object.defineProperty(t.LFO.prototype,"mute",{get:function(){return this._oscillator.mute},set:function(t){this._oscillator.mute=t}}),Object.defineProperty(t.LFO.prototype,"state",{get:function(){return this._oscillator.state}}),t.LFO.prototype.connect=function(e){return e.constructor!==t.Signal&&e.constructor!==t.Param&&e.constructor!==t.TimelineSignal||(this.convert=e.convert,this.units=e.units),t.Signal.prototype.connect.apply(this,arguments),this},t.LFO.prototype._fromUnits=t.Param.prototype._fromUnits,t.LFO.prototype._toUnits=t.Param.prototype._toUnits,t.LFO.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable(["amplitude","frequency"]),this._oscillator.dispose(),this._oscillator=null,this._stoppedSignal.dispose(),this._stoppedSignal=null,this._zeros.dispose(),this._zeros=null,this._scaler.dispose(),this._scaler=null,this._a2g.dispose(),this._a2g=null,this.frequency=null,this.amplitude=null,this},t.LFO}),t(function(t){return t.Limiter=function(){var e=this.optionsObject(arguments,["threshold"],t.Limiter.defaults);this._compressor=this.input=this.output=new t.Compressor({attack:.001,decay:.001,threshold:e.threshold}),this.threshold=this._compressor.threshold,this._readOnly("threshold")},t.extend(t.Limiter),t.Limiter.defaults={threshold:-12},t.Limiter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._compressor.dispose(),this._compressor=null,this._writable("threshold"),this.threshold=null,this},t.Limiter}),t(function(t){return t.LowpassCombFilter=function(){this.createInsOuts(1,1);var e=this.optionsObject(arguments,["delayTime","resonance","dampening"],t.LowpassCombFilter.defaults);this._delay=this.input=new t.Delay(e.delayTime),this.delayTime=this._delay.delayTime,this._lowpass=this.output=this.context.createBiquadFilter(),this._lowpass.Q.value=-3.0102999566398125,this._lowpass.type="lowpass",this.dampening=new t.Param({param:this._lowpass.frequency,units:t.Type.Frequency,value:e.dampening}),this._feedback=new t.Gain(e.resonance,t.Type.NormalRange),this.resonance=this._feedback.gain,this._delay.chain(this._lowpass,this._feedback,this._delay),this._readOnly(["dampening","resonance","delayTime"])},t.extend(t.LowpassCombFilter),t.LowpassCombFilter.defaults={delayTime:.1,resonance:.5,dampening:3e3},t.LowpassCombFilter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable(["dampening","resonance","delayTime"]),this.dampening.dispose(),this.dampening=null,this.resonance.dispose(),this.resonance=null,this._delay.dispose(),this._delay=null,this.delayTime=null,this._lowpass.disconnect(),this._lowpass=null,this._feedback.disconnect(),this._feedback=null,this},t.LowpassCombFilter}),t(function(t){return t.Merge=function(){this.createInsOuts(2,0),this.left=this.input[0]=new t.Gain,this.right=this.input[1]=new t.Gain,this._merger=this.output=this.context.createChannelMerger(2),this.left.connect(this._merger,0,0),this.right.connect(this._merger,0,1),this.left.channelCount=1,this.right.channelCount=1,this.left.channelCountMode="explicit",this.right.channelCountMode="explicit"},t.extend(t.Merge),t.Merge.prototype.dispose=function(){return t.prototype.dispose.call(this),this.left.dispose(),this.left=null,this.right.dispose(),this.right=null,this._merger.disconnect(),this._merger=null,this},t.Merge}),t(function(t){return t.Meter=function(){var e=this.optionsObject(arguments,["type","smoothing"],t.Meter.defaults);this.type=e.type,this.input=this.output=this._analyser=new t.Analyser("waveform",512),this._analyser.returnType="float",this.smoothing=e.smoothing,this._lastValue=0},t.extend(t.Meter),t.Meter.Type={Level:"level",Signal:"signal"},t.Meter.defaults={smoothing:.8,type:t.Meter.Type.Level},Object.defineProperty(t.Meter.prototype,"value",{get:function(){var e=this._analyser.analyse();if(this.type===t.Meter.Type.Level){for(var i=0,s=0;s<e.length;s++)i+=Math.pow(e[s],2);var n=Math.sqrt(i/e.length);n=Math.max(n,this._lastValue*this.smoothing),this._lastValue=n;var o=n/.35;return Math.sqrt(o)}return e[0]}}),t.Meter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._analyser.dispose(),this._analyser=null,this},t.Meter}),t(function(t){return t.Split=function(){this.createInsOuts(0,2),this._splitter=this.input=this.context.createChannelSplitter(2),this.left=this.output[0]=new t.Gain,this.right=this.output[1]=new t.Gain,this._splitter.connect(this.left,0,0),this._splitter.connect(this.right,1,0)},t.extend(t.Split),t.Split.prototype.dispose=function(){return t.prototype.dispose.call(this),this._splitter.disconnect(),this.left.dispose(),this.left=null,this.right.dispose(),this.right=null,this._splitter=null,this},t.Split}),t(function(t){return t.MidSideSplit=function(){this.createInsOuts(0,2),this._split=this.input=new t.Split,this.mid=this.output[0]=new t.Expr("($0 + $1) * $2"),this.side=this.output[1]=new t.Expr("($0 - $1) * $2"),this._split.connect(this.mid,0,0),this._split.connect(this.mid,1,1),this._split.connect(this.side,0,0),this._split.connect(this.side,1,1),this.context.getConstant(Math.SQRT1_2).connect(this.mid,0,2),this.context.getConstant(Math.SQRT1_2).connect(this.side,0,2)},t.extend(t.MidSideSplit),t.MidSideSplit.prototype.dispose=function(){return t.prototype.dispose.call(this),this.mid.dispose(),this.mid=null,this.side.dispose(),this.side=null,this._split.dispose(),this._split=null,this},t.MidSideSplit}),t(function(t){return t.MidSideMerge=function(){this.createInsOuts(2,0),this.mid=this.input[0]=new t.Gain,this._left=new t.Expr("($0 + $1) * $2"),this.side=this.input[1]=new t.Gain,this._right=new t.Expr("($0 - $1) * $2"),this._merge=this.output=new t.Merge,this.mid.connect(this._left,0,0),this.side.connect(this._left,0,1),this.mid.connect(this._right,0,0),this.side.connect(this._right,0,1),this._left.connect(this._merge,0,0),this._right.connect(this._merge,0,1),this.context.getConstant(Math.SQRT1_2).connect(this._left,0,2),this.context.getConstant(Math.SQRT1_2).connect(this._right,0,2)},t.extend(t.MidSideMerge),t.MidSideMerge.prototype.dispose=function(){return t.prototype.dispose.call(this),this.mid.dispose(),this.mid=null,this.side.dispose(),this.side=null,this._left.dispose(),this._left=null,this._right.dispose(),this._right=null,this._merge.dispose(),this._merge=null,this},t.MidSideMerge}),t(function(t){return t.MidSideCompressor=function(e){e=this.defaultArg(e,t.MidSideCompressor.defaults),this._midSideSplit=this.input=new t.MidSideSplit,this._midSideMerge=this.output=new t.MidSideMerge,this.mid=new t.Compressor(e.mid),this.side=new t.Compressor(e.side),this._midSideSplit.mid.chain(this.mid,this._midSideMerge.mid),this._midSideSplit.side.chain(this.side,this._midSideMerge.side),this._readOnly(["mid","side"])},t.extend(t.MidSideCompressor),t.MidSideCompressor.defaults={mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},side:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10}},t.MidSideCompressor.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable(["mid","side"]),this.mid.dispose(),this.mid=null,this.side.dispose(),this.side=null,this._midSideSplit.dispose(),this._midSideSplit=null,this._midSideMerge.dispose(),this._midSideMerge=null,this},t.MidSideCompressor}),t(function(t){return t.Mono=function(){this.createInsOuts(1,0),this._merge=this.output=new t.Merge,this.input.connect(this._merge,0,0),this.input.connect(this._merge,0,1),this.input.gain.value=this.dbToGain(-10)},t.extend(t.Mono),t.Mono.prototype.dispose=function(){return t.prototype.dispose.call(this),this._merge.dispose(),this._merge=null,this},t.Mono}),t(function(t){return t.MultibandCompressor=function(e){e=this.defaultArg(arguments,t.MultibandCompressor.defaults),this._splitter=this.input=new t.MultibandSplit({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency}),this.lowFrequency=this._splitter.lowFrequency,this.highFrequency=this._splitter.highFrequency,this.output=new t.Gain,this.low=new t.Compressor(e.low),this.mid=new t.Compressor(e.mid),this.high=new t.Compressor(e.high),this._splitter.low.chain(this.low,this.output),this._splitter.mid.chain(this.mid,this.output),this._splitter.high.chain(this.high,this.output),this._readOnly(["high","mid","low","highFrequency","lowFrequency"])},t.extend(t.MultibandCompressor),t.MultibandCompressor.defaults={low:t.Compressor.defaults,mid:t.Compressor.defaults,high:t.Compressor.defaults,lowFrequency:250,highFrequency:2e3},t.MultibandCompressor.prototype.dispose=function(){return t.prototype.dispose.call(this),this._splitter.dispose(),this._writable(["high","mid","low","highFrequency","lowFrequency"]),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this._splitter=null,this.low=null,this.mid=null,this.high=null,this.lowFrequency=null,this.highFrequency=null,this},t.MultibandCompressor}),t(function(t){return t.Panner=function(e){this._hasStereoPanner?(this._panner=this.input=this.output=this.context.createStereoPanner(),this.pan=this._panner.pan):(this._crossFade=new t.CrossFade,this._merger=this.output=new t.Merge,this._splitter=this.input=new t.Split,this.pan=new t.Signal(0,t.Type.AudioRange),this._zero=new t.Zero,this._a2g=new t.AudioToGain,this._zero.connect(this._a2g),this.pan.chain(this._a2g,this._crossFade.fade),this._splitter.connect(this._crossFade,0,0),this._splitter.connect(this._crossFade,1,1),this._crossFade.a.connect(this._merger,0,0),this._crossFade.b.connect(this._merger,0,1)),this.pan.value=this.defaultArg(e,0),this._readOnly("pan")},t.extend(t.Panner),t.Panner.prototype._hasStereoPanner=t.prototype.isFunction(t.context.createStereoPanner),t.Panner.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable("pan"),this._hasStereoPanner?(this._panner.disconnect(),this._panner=null,this.pan=null):(this._zero.dispose(),this._zero=null,this._crossFade.dispose(),this._crossFade=null,this._splitter.dispose(),this._splitter=null,this._merger.dispose(),this._merger=null,this.pan.dispose(),this.pan=null,this._a2g.dispose(),this._a2g=null),this},t.Panner}),t(function(t){return t.Panner3D=function(){var e=this.optionsObject(arguments,["positionX","positionY","positionZ"],t.Panner3D.defaults);this._panner=this.input=this.output=this.context.createPanner(),this._panner.panningModel=e.panningModel,this._panner.maxDistance=e.maxDistance,this._panner.distanceModel=e.distanceModel,this._panner.coneOuterGain=e.coneOuterGain,this._panner.coneOuterAngle=e.coneOuterAngle,this._panner.coneInnerAngle=e.coneInnerAngle,this._panner.refDistance=e.refDistance,this._panner.rolloffFactor=e.rolloffFactor,this._orientation=[e.orientationX,e.orientationY,e.orientationZ],this._position=[e.positionX,e.positionY,e.positionZ],this.orientationX=e.orientationX,this.orientationY=e.orientationY,this.orientationZ=e.orientationZ,this.positionX=e.positionX,this.positionY=e.positionY,this.positionZ=e.positionZ},t.extend(t.Panner3D),t.Panner3D.defaults={positionX:0,positionY:0,positionZ:0,orientationX:0,orientationY:0,orientationZ:0,panningModel:"equalpower",maxDistance:1e4,distanceModel:"inverse",coneOuterGain:0,coneOuterAngle:360,coneInnerAngle:360,refDistance:1,rolloffFactor:1},t.Panner3D.prototype._rampTimeConstant=.01,t.Panner3D.prototype.setPosition=function(t,e,i){if(this._panner.positionX){var s=this.now();this._panner.positionX.setTargetAtTime(t,s,this._rampTimeConstant),this._panner.positionY.setTargetAtTime(e,s,this._rampTimeConstant),this._panner.positionZ.setTargetAtTime(i,s,this._rampTimeConstant)}else this._panner.setPosition(t,e,i);return this._position=Array.prototype.slice.call(arguments),this},t.Panner3D.prototype.setOrientation=function(t,e,i){if(this._panner.orientationX){var s=this.now();this._panner.orientationX.setTargetAtTime(t,s,this._rampTimeConstant),this._panner.orientationY.setTargetAtTime(e,s,this._rampTimeConstant),this._panner.orientationZ.setTargetAtTime(i,s,this._rampTimeConstant)}else this._panner.setOrientation(t,e,i);return this._orientation=Array.prototype.slice.call(arguments),this},Object.defineProperty(t.Panner3D.prototype,"positionX",{set:function(t){this._position[0]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[0]}}),Object.defineProperty(t.Panner3D.prototype,"positionY",{set:function(t){this._position[1]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[1]}}),Object.defineProperty(t.Panner3D.prototype,"positionZ",{set:function(t){this._position[2]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[2]}}),Object.defineProperty(t.Panner3D.prototype,"orientationX",{set:function(t){this._orientation[0]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[0]}}),Object.defineProperty(t.Panner3D.prototype,"orientationY",{set:function(t){this._orientation[1]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[1]}}),Object.defineProperty(t.Panner3D.prototype,"orientationZ",{set:function(t){this._orientation[2]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[2]}}),t.Panner3D._aliasProperty=function(e){Object.defineProperty(t.Panner3D.prototype,e,{set:function(t){this._panner[e]=t},get:function(){return this._panner[e]}})},t.Panner3D._aliasProperty("panningModel"),t.Panner3D._aliasProperty("refDistance"),t.Panner3D._aliasProperty("rolloffFactor"),t.Panner3D._aliasProperty("distanceModel"),t.Panner3D._aliasProperty("coneInnerAngle"),t.Panner3D._aliasProperty("coneOuterAngle"),t.Panner3D._aliasProperty("coneOuterGain"),t.Panner3D._aliasProperty("maxDistance"),t.Panner3D.prototype.dispose=function(){return this._panner.disconnect(),this._panner=null,this._orientation=null,this._position=null,this},t.Panner3D}),t(function(t){return t.PanVol=function(){var e=this.optionsObject(arguments,["pan","volume"],t.PanVol.defaults);this._panner=this.input=new t.Panner(e.pan),this.pan=this._panner.pan,this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._panner.connect(this._volume),this._readOnly(["pan","volume"])},t.extend(t.PanVol),t.PanVol.defaults={pan:.5,volume:0},t.PanVol.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable(["pan","volume"]),this._panner.dispose(),this._panner=null,this.pan=null,this._volume.dispose(),this._volume=null,this.volume=null,this},t.PanVol}),t(function(t){return t.CtrlInterpolate=function(){var e=this.optionsObject(arguments,["values","index"],t.CtrlInterpolate.defaults);this.values=e.values,this.index=e.index},t.extend(t.CtrlInterpolate),t.CtrlInterpolate.defaults={index:0,values:[]},Object.defineProperty(t.CtrlInterpolate.prototype,"value",{get:function(){var t=this.index;t=Math.min(t,this.values.length-1);var e=Math.floor(t),i=this.values[e],s=this.values[Math.ceil(t)];return this._interpolate(t-e,i,s)}}),t.CtrlInterpolate.prototype._interpolate=function(t,e,i){if(this.isArray(e)){for(var s=[],n=0;n<e.length;n++)s[n]=this._interpolate(t,e[n],i[n]);return s}if(this.isObject(e)){var o={};for(var r in e)o[r]=this._interpolate(t,e[r],i[r]);return o}return e=this._toNumber(e),i=this._toNumber(i),(1-t)*e+t*i},t.CtrlInterpolate.prototype._toNumber=function(t){return this.isNumber(t)?t:this.toSeconds(t)},t.CtrlInterpolate.prototype.dispose=function(){this.values=null},t.CtrlInterpolate}),t(function(t){return t.CtrlMarkov=function(t,e){this.values=this.defaultArg(t,{}),this.value=this.defaultArg(e,Object.keys(this.values)[0])},t.extend(t.CtrlMarkov),t.CtrlMarkov.prototype.next=function(){if(this.values.hasOwnProperty(this.value)){var t=this.values[this.value];if(this.isArray(t))for(var e=this._getProbDistribution(t),i=Math.random(),s=0,n=0;n<e.length;n++){var o=e[n];if(i>s&&i<s+o){var r=t[n];this.isObject(r)?this.value=r.value:this.value=r}s+=o}else this.value=t}return this.value},t.CtrlMarkov.prototype._getProbDistribution=function(t){for(var e=[],i=0,s=!1,n=0;n<t.length;n++){var o=t[n];this.isObject(o)?(s=!0,e[n]=o.probability):e[n]=1/t.length,i+=e[n]}if(s)for(var r=0;r<e.length;r++)e[r]=e[r]/i;return e},t.CtrlMarkov.prototype.dispose=function(){this.values=null},t.CtrlMarkov}),t(function(t){return t.CtrlPattern=function(){var e=this.optionsObject(arguments,["values","type"],t.CtrlPattern.defaults);this.values=e.values,this.index=0,this._type=null,this._shuffled=null,this._direction=null,this.type=e.type},t.extend(t.CtrlPattern),t.CtrlPattern.Type={Up:"up",Down:"down",UpDown:"upDown",DownUp:"downUp",AlternateUp:"alternateUp",AlternateDown:"alternateDown",Random:"random",RandomWalk:"randomWalk",RandomOnce:"randomOnce"},t.CtrlPattern.defaults={type:t.CtrlPattern.Type.Up,values:[]},Object.defineProperty(t.CtrlPattern.prototype,"value",{get:function(){if(0!==this.values.length){if(1===this.values.length)return this.values[0];this.index=Math.min(this.index,this.values.length-1);var e=this.values[this.index];return this.type===t.CtrlPattern.Type.RandomOnce&&(this.values.length!==this._shuffled.length&&this._shuffleValues(),e=this.values[this._shuffled[this.index]]),e}}}),Object.defineProperty(t.CtrlPattern.prototype,"type",{get:function(){return this._type},set:function(e){this._type=e,this._shuffled=null,this._type===t.CtrlPattern.Type.Up||this._type===t.CtrlPattern.Type.UpDown||this._type===t.CtrlPattern.Type.RandomOnce||this._type===t.CtrlPattern.Type.AlternateUp?this.index=0:this._type!==t.CtrlPattern.Type.Down&&this._type!==t.CtrlPattern.Type.DownUp&&this._type!==t.CtrlPattern.Type.AlternateDown||(this.index=this.values.length-1),this._type===t.CtrlPattern.Type.UpDown||this._type===t.CtrlPattern.Type.AlternateUp?this._direction=t.CtrlPattern.Type.Up:this._type!==t.CtrlPattern.Type.DownUp&&this._type!==t.CtrlPattern.Type.AlternateDown||(this._direction=t.CtrlPattern.Type.Down),this._type===t.CtrlPattern.Type.RandomOnce?this._shuffleValues():this._type===t.CtrlPattern.Random&&(this.index=Math.floor(Math.random()*this.values.length))}}),t.CtrlPattern.prototype.next=function(){var e=this.type;return e===t.CtrlPattern.Type.Up?++this.index>=this.values.length&&(this.index=0):e===t.CtrlPattern.Type.Down?--this.index<0&&(this.index=this.values.length-1):e===t.CtrlPattern.Type.UpDown||e===t.CtrlPattern.Type.DownUp?(this._direction===t.CtrlPattern.Type.Up?this.index++:this.index--,this.index<0?(this.index=1,this._direction=t.CtrlPattern.Type.Up):this.index>=this.values.length&&(this.index=this.values.length-2,this._direction=t.CtrlPattern.Type.Down)):e===t.CtrlPattern.Type.Random?this.index=Math.floor(Math.random()*this.values.length):e===t.CtrlPattern.Type.RandomWalk?Math.random()<.5?(this.index--,this.index=Math.max(this.index,0)):(this.index++,this.index=Math.min(this.index,this.values.length-1)):e===t.CtrlPattern.Type.RandomOnce?++this.index>=this.values.length&&(this.index=0,this._shuffleValues()):e===t.CtrlPattern.Type.AlternateUp?(this._direction===t.CtrlPattern.Type.Up?(this.index+=2,this._direction=t.CtrlPattern.Type.Down):(this.index-=1,this._direction=t.CtrlPattern.Type.Up),this.index>=this.values.length&&(this.index=0,this._direction=t.CtrlPattern.Type.Up)):e===t.CtrlPattern.Type.AlternateDown&&(this._direction===t.CtrlPattern.Type.Up?(this.index+=1,this._direction=t.CtrlPattern.Type.Down):(this.index-=2,this._direction=t.CtrlPattern.Type.Up),this.index<0&&(this.index=this.values.length-1,this._direction=t.CtrlPattern.Type.Down)),this.value},t.CtrlPattern.prototype._shuffleValues=function(){var t=[];this._shuffled=[];for(var e=0;e<this.values.length;e++)t[e]=e;for(;t.length>0;){var i=t.splice(Math.floor(t.length*Math.random()),1);this._shuffled.push(i[0])}},t.CtrlPattern.prototype.dispose=function(){this._shuffled=null,this.values=null},t.CtrlPattern}),t(function(t){return t.CtrlRandom=function(){var e=this.optionsObject(arguments,["min","max"],t.CtrlRandom.defaults);this.min=e.min,this.max=e.max,this.integer=e.integer},t.extend(t.CtrlRandom),t.CtrlRandom.defaults={min:0,max:1,integer:!1},Object.defineProperty(t.CtrlRandom.prototype,"value",{get:function(){var t=this.toSeconds(this.min),e=this.toSeconds(this.max),i=Math.random(),s=i*t+(1-i)*e;return this.integer&&(s=Math.floor(s)),s}}),t.CtrlRandom}),t(function(t){return window.AudioBuffer&&!AudioBuffer.prototype.copyToChannel&&(AudioBuffer.prototype.copyToChannel=function(t,e,i){var s=this.getChannelData(e);i=i||0;for(var n=0;n<s.length;n++)s[n+i]=t[n]},AudioBuffer.prototype.copyFromChannel=function(t,e,i){var s=this.getChannelData(e);i=i||0;for(var n=0;n<s.length;n++)t[n]=s[n+i]}),t.Buffer=function(){var e=this.optionsObject(arguments,["url","onload","onerror"],t.Buffer.defaults);this._buffer=null,this._reversed=e.reverse,this._xhr=null,e.url instanceof AudioBuffer||e.url instanceof t.Buffer?(this.set(e.url),e.onload&&e.onload(this)):this.isString(e.url)&&this.load(e.url,e.onload,e.onerror)},t.extend(t.Buffer),t.Buffer.defaults={url:void 0,reverse:!1},t.Buffer.prototype.set=function(e){return e instanceof t.Buffer?this._buffer=e.get():this._buffer=e,this},t.Buffer.prototype.get=function(){return this._buffer},t.Buffer.prototype.load=function(e,i,s){return new Promise(function(n,o){this._xhr=t.Buffer.load(e,function(t){this._xhr=null,this.set(t),n(this),i&&i(this)}.bind(this),function(t){this._xhr=null,o(t),s&&s(t)}.bind(this))}.bind(this))},t.Buffer.prototype.dispose=function(){return t.Emitter.prototype.dispose.call(this),this._buffer=null,this._xhr&&(t.Buffer._currentDownloads--,this._xhr.abort(),this._xhr=null),this},Object.defineProperty(t.Buffer.prototype,"loaded",{get:function(){return this.length>0}}),Object.defineProperty(t.Buffer.prototype,"duration",{get:function(){return this._buffer?this._buffer.duration:0}}),Object.defineProperty(t.Buffer.prototype,"length",{get:function(){return this._buffer?this._buffer.length:0}}),Object.defineProperty(t.Buffer.prototype,"numberOfChannels",{get:function(){return this._buffer?this._buffer.numberOfChannels:0}}),t.Buffer.prototype.fromArray=function(t){var e=t[0].length>0,i=e?t.length:1,s=e?t[0].length:t.length,n=this.context.createBuffer(i,s,this.context.sampleRate);e||1!==i||(t=[t]);for(var o=0;o<i;o++)n.copyToChannel(t[o],o);return this._buffer=n,this},t.Buffer.prototype.toMono=function(t){if(this.isNumber(t))this.fromArray(this.toArray(t));else{for(var e=new Float32Array(this.length),i=this.numberOfChannels,s=0;s<i;s++)for(var n=this.toArray(s),o=0;o<n.length;o++)e[o]+=n[o];e=e.map(function(t){return t/i}),this.fromArray(e)}return this},t.Buffer.prototype.toArray=function(t){if(this.isNumber(t))return this.getChannelData(t);if(1===this.numberOfChannels)return this.toArray(0);for(var e=[],i=0;i<this.numberOfChannels;i++)e[i]=this.getChannelData(i);return e},t.Buffer.prototype.getChannelData=function(t){return this._buffer.getChannelData(t)},t.Buffer.prototype.slice=function(e,i){i=this.defaultArg(i,this.duration);for(var s=Math.floor(this.context.sampleRate*this.toSeconds(e)),n=Math.floor(this.context.sampleRate*this.toSeconds(i)),o=[],r=0;r<this.numberOfChannels;r++)o[r]=this.toArray(r).slice(s,n);return(new t.Buffer).fromArray(o)},t.Buffer.prototype._reverse=function(){if(this.loaded)for(var t=0;t<this.numberOfChannels;t++)Array.prototype.reverse.call(this.getChannelData(t));return this},Object.defineProperty(t.Buffer.prototype,"reverse",{get:function(){return this._reversed},set:function(t){this._reversed!==t&&(this._reversed=t,this._reverse())}}),t.Emitter.mixin(t.Buffer),t.Buffer._downloadQueue=[],t.Buffer._currentDownloads=0,t.Buffer.baseUrl="",t.Buffer.load=function(e,i,s){function n(e){if(!s)throw new Error(e);s(e),t.Buffer.emit("error",e)}function o(){for(var e=0,i=0;i<t.Buffer._downloadQueue.length;i++)e+=t.Buffer._downloadQueue[i].progress;t.Buffer.emit("progress",e/t.Buffer._downloadQueue.length)}i=i||t.noOp;var r=new XMLHttpRequest;return r.open("GET",t.Buffer.baseUrl+e,!0),r.responseType="arraybuffer",r.progress=0,t.Buffer._currentDownloads++,t.Buffer._downloadQueue.push(r),r.addEventListener("load",function(){200===r.status?t.context.decodeAudioData(r.response,function(e){r.progress=1,o(),i(e),0===--t.Buffer._currentDownloads&&(t.Buffer._downloadQueue=[],t.Buffer.emit("load"))},function(){n("Tone.Buffer: could not decode audio data: "+e)}):n("Tone.Buffer: could not locate file: "+e)}),r.addEventListener("error",n),r.addEventListener("progress",function(t){t.lengthComputable&&(r.progress=t.loaded/t.total*.95,o())}),r.send(),r},t.Buffer.cancelDownloads=function(){return t.Buffer._downloadQueue.forEach(function(t){t.abort()}),t.Buffer._currentDownloads=0,t.Buffer},t.Buffer.supportsType=function(t){var e=t.split(".");return e=e[e.length-1],""!==document.createElement("audio").canPlayType("audio/"+e)},t.loaded=function(){function e(){t.Buffer.off("load",i),t.Buffer.off("error",s)}var i,s;return new Promise(function(e,n){i=function(){e()},s=function(){n()},t.Buffer.on("load",i),t.Buffer.on("error",s)}).then(e).catch(function(t){throw e(),new Error(t)})},t.Buffer}),t(function(t){return t.Buffers=function(t,e,i){this._buffers={},this.baseUrl=this.defaultArg(i,""),t=this._flattenUrls(t),this._loadingCount=0;for(var s in t)this._loadingCount++,this.add(s,t[s],this._bufferLoaded.bind(this,e))},t.extend(t.Buffers),t.Buffers.prototype.has=function(t){return this._buffers.hasOwnProperty(t)},t.Buffers.prototype.get=function(t){if(this.has(t))return this._buffers[t];throw new Error("Tone.Buffers: no buffer named "+t)},t.Buffers.prototype._bufferLoaded=function(t){0===--this._loadingCount&&t&&t(this)},Object.defineProperty(t.Buffers.prototype,"loaded",{get:function(){var t=!0;for(var e in this._buffers){var i=this.get(e);t=t&&i.loaded}return t}}),t.Buffers.prototype.add=function(e,i,s){return s=this.defaultArg(s,t.noOp),i instanceof t.Buffer?(this._buffers[e]=i,s(this)):i instanceof AudioBuffer?(this._buffers[e]=new t.Buffer(i),s(this)):this.isString(i)&&(this._buffers[e]=new t.Buffer(this.baseUrl+i,s)),this},t.Buffers.prototype._flattenUrls=function(t){var e={};for(var i in t)if(t.hasOwnProperty(i))if(this.isObject(t[i])){var s=this._flattenUrls(t[i]);for(var n in s)s.hasOwnProperty(n)&&(e[i+"."+n]=s[n])}else e[i]=t[i];return e},t.Buffers.prototype.dispose=function(){for(var t in this._buffers)this._buffers[t].dispose();return this._buffers=null,this},t.Buffers}),t(function(t){var e={};return t.prototype.send=function(i,s){e.hasOwnProperty(i)||(e[i]=this.context.createGain()),s=this.defaultArg(s,0);var n=new t.Gain(s,t.Type.Decibels);return this.output.chain(n,e[i]),n},t.prototype.receive=function(t,i){return e.hasOwnProperty(t)||(e[t]=this.context.createGain()),this.isUndef(i)&&(i=this.input),e[t].connect(i),this},t.Context.on("init",function(t){t.Buses?e=t.Buses:(e={},t.Buses=e)}),t}),t(function(t){return t.Draw=function(){this._events=new t.Timeline,this.expiration=.25,this.anticipation=.008,this._boundDrawLoop=this._drawLoop.bind(this)},t.extend(t.Draw),t.Draw.prototype.schedule=function(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),1===this._events.length&&requestAnimationFrame(this._boundDrawLoop),this},t.Draw.prototype.cancel=function(t){return this._events.cancel(this.toSeconds(t)),this},t.Draw.prototype._drawLoop=function(){for(var e=t.now();this._events.length&&this._events.peek().time-this.anticipation<=e;){var i=this._events.shift();e-i.time<=this.expiration&&i.callback()}this._events.length>0&&requestAnimationFrame(this._boundDrawLoop)},t.Draw=new t.Draw,t.Draw}),t(function(t){t.Listener=function(){var t=this.optionsObject(arguments,["positionX","positionY","positionZ"],e.defaults);this._orientation=[t.forwardX,t.forwardY,t.forwardZ,t.upX,t.upY,t.upZ],this._position=[t.positionX,t.positionY,t.positionZ],this.forwardX=t.forwardX,this.forwardY=t.forwardY,this.forwardZ=t.forwardZ,this.upX=t.upX,this.upY=t.upY,this.upZ=t.upZ,this.positionX=t.positionX,this.positionY=t.positionY,this.positionZ=t.positionZ},t.extend(t.Listener),t.Listener.defaults={positionX:0,positionY:0,positionZ:0,forwardX:0,forwardY:0,forwardZ:1,upX:0,upY:1,upZ:0},t.Listener.prototype._rampTimeConstant=.01,t.Listener.prototype.setPosition=function(t,e,i){if(this.context.listener.positionX){var s=this.now();this.context.listener.positionX.setTargetAtTime(t,s,this._rampTimeConstant),this.context.listener.positionY.setTargetAtTime(e,s,this._rampTimeConstant),this.context.listener.positionZ.setTargetAtTime(i,s,this._rampTimeConstant)}else this.context.listener.setPosition(t,e,i);return this._position=Array.prototype.slice.call(arguments),this},t.Listener.prototype.setOrientation=function(t,e,i,s,n,o){if(this.context.listener.forwardX){var r=this.now();this.context.listener.forwardX.setTargetAtTime(t,r,this._rampTimeConstant),this.context.listener.forwardY.setTargetAtTime(e,r,this._rampTimeConstant),this.context.listener.forwardZ.setTargetAtTime(i,r,this._rampTimeConstant),this.context.listener.upX.setTargetAtTime(s,r,this._rampTimeConstant),this.context.listener.upY.setTargetAtTime(n,r,this._rampTimeConstant),this.context.listener.upZ.setTargetAtTime(o,r,this._rampTimeConstant)}else this.context.listener.setOrientation(t,e,i,s,n,o);return this._orientation=Array.prototype.slice.call(arguments),this},Object.defineProperty(t.Listener.prototype,"positionX",{set:function(t){this._position[0]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[0]}}),Object.defineProperty(t.Listener.prototype,"positionY",{set:function(t){this._position[1]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[1]}}),Object.defineProperty(t.Listener.prototype,"positionZ",{set:function(t){this._position[2]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[2]}}),Object.defineProperty(t.Listener.prototype,"forwardX",{set:function(t){this._orientation[0]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[0]}}),Object.defineProperty(t.Listener.prototype,"forwardY",{set:function(t){this._orientation[1]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[1]}}),Object.defineProperty(t.Listener.prototype,"forwardZ",{set:function(t){this._orientation[2]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[2]}}),Object.defineProperty(t.Listener.prototype,"upX",{set:function(t){this._orientation[3]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[3]}}),Object.defineProperty(t.Listener.prototype,"upY",{set:function(t){this._orientation[4]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[4]}}),Object.defineProperty(t.Listener.prototype,"upZ",{set:function(t){this._orientation[5]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[5]}}),t.Listener.prototype.dispose=function(){return this._orientation=null,this._position=null,this};var e=t.Listener;return t.Listener=new e,t.Context.on("init",function(i){i.Listener instanceof e?t.Listener=i.Listener:t.Listener=new e,i.Listener=t.Listener}),t.Listener}),t(function(t){return!window.hasOwnProperty("OfflineAudioContext")&&window.hasOwnProperty("webkitOfflineAudioContext")&&(window.OfflineAudioContext=window.webkitOfflineAudioContext),t.OfflineContext=function(e,i,s){var n=new OfflineAudioContext(e,i*s,s);t.Context.call(this,n),this._duration=i,this._currentTime=0,this.lookAhead=this.blockTime,this.updateInterval=this.blockTime},t.extend(t.OfflineContext,t.Context),t.OfflineContext.prototype.now=function(){return this._currentTime},t.OfflineContext.prototype._createWorker=function(){return{postMessage:function(){}}},t.OfflineContext.prototype.render=function(){for(;this._duration-this._currentTime>=0;)this.emit("tick"),this._currentTime+=t.prototype.blockTime;return new Promise(function(t){this._context.oncomplete=function(e){t(e.renderedBuffer)},this._context.startRendering()}.bind(this))},t.OfflineContext}),t(function(t){return t.Offline=function(e,i){var s=t.context.sampleRate,n=t.context,o=new t.OfflineContext(2,i,s);t.context=o,e(t.Transport);var r=o.render();return t.context=n,r.then(function(e){return new t.Buffer(e)})},t.Offline}),t(function(t){return t.Effect=function(){this.createInsOuts(1,1);var e=this.optionsObject(arguments,["wet"],t.Effect.defaults);this._dryWet=new t.CrossFade(e.wet),this.wet=this._dryWet.fade,this.effectSend=new t.Gain,this.effectReturn=new t.Gain,this.input.connect(this._dryWet.a),this.input.connect(this.effectSend),this.effectReturn.connect(this._dryWet.b),this._dryWet.connect(this.output),this._readOnly(["wet"])},t.extend(t.Effect),t.Effect.defaults={wet:1},t.Effect.prototype.connectEffect=function(t){return this.effectSend.chain(t,this.effectReturn),this},t.Effect.prototype.dispose=function(){return t.prototype.dispose.call(this),this._dryWet.dispose(),this._dryWet=null,this.effectSend.dispose(),this.effectSend=null,this.effectReturn.dispose(),this.effectReturn=null,this._writable(["wet"]),this.wet=null,this},t.Effect}),t(function(t){return t.AutoFilter=function(){var e=this.optionsObject(arguments,["frequency","baseFrequency","octaves"],t.AutoFilter.defaults);t.Effect.call(this,e),this._lfo=new t.LFO({frequency:e.frequency,amplitude:e.depth}),this.depth=this._lfo.amplitude,this.frequency=this._lfo.frequency,this.filter=new t.Filter(e.filter),this._octaves=0,this.connectEffect(this.filter),this._lfo.connect(this.filter.frequency),this.type=e.type,this._readOnly(["frequency","depth"]),this.octaves=e.octaves,this.baseFrequency=e.baseFrequency},t.extend(t.AutoFilter,t.Effect),t.AutoFilter.defaults={frequency:1,type:"sine",depth:1,baseFrequency:200,octaves:2.6,filter:{type:"lowpass",rolloff:-12,Q:1}},t.AutoFilter.prototype.start=function(t){return this._lfo.start(t),this},t.AutoFilter.prototype.stop=function(t){return this._lfo.stop(t),this},t.AutoFilter.prototype.sync=function(t){return this._lfo.sync(t),this},t.AutoFilter.prototype.unsync=function(){return this._lfo.unsync(),this},Object.defineProperty(t.AutoFilter.prototype,"type",{get:function(){return this._lfo.type},set:function(t){this._lfo.type=t}}),Object.defineProperty(t.AutoFilter.prototype,"baseFrequency",{get:function(){return this._lfo.min},set:function(t){this._lfo.min=this.toFrequency(t),this.octaves=this._octaves}}),Object.defineProperty(t.AutoFilter.prototype,"octaves",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._lfo.max=this.baseFrequency*Math.pow(2,t)}}),t.AutoFilter.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._lfo.dispose(),this._lfo=null,this.filter.dispose(),this.filter=null,this._writable(["frequency","depth"]),this.frequency=null,this.depth=null,this},t.AutoFilter}),t(function(t){return t.AutoPanner=function(){var e=this.optionsObject(arguments,["frequency"],t.AutoPanner.defaults);t.Effect.call(this,e),this._lfo=new t.LFO({frequency:e.frequency,amplitude:e.depth,min:-1,max:1}),this.depth=this._lfo.amplitude,this._panner=new t.Panner,this.frequency=this._lfo.frequency,this.connectEffect(this._panner),this._lfo.connect(this._panner.pan),this.type=e.type,this._readOnly(["depth","frequency"])},t.extend(t.AutoPanner,t.Effect),t.AutoPanner.defaults={frequency:1,type:"sine",depth:1},t.AutoPanner.prototype.start=function(t){return this._lfo.start(t),this},t.AutoPanner.prototype.stop=function(t){return this._lfo.stop(t),this},t.AutoPanner.prototype.sync=function(t){return this._lfo.sync(t),this},t.AutoPanner.prototype.unsync=function(){return this._lfo.unsync(),this},Object.defineProperty(t.AutoPanner.prototype,"type",{get:function(){return this._lfo.type},set:function(t){this._lfo.type=t}}),t.AutoPanner.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._lfo.dispose(),this._lfo=null,this._panner.dispose(),this._panner=null,this._writable(["depth","frequency"]),this.frequency=null,this.depth=null,this},t.AutoPanner}),t(function(t){return t.AutoWah=function(){var e=this.optionsObject(arguments,["baseFrequency","octaves","sensitivity"],t.AutoWah.defaults);t.Effect.call(this,e),this.follower=new t.Follower(e.follower),this._sweepRange=new t.ScaleExp(0,1,.5),this._baseFrequency=e.baseFrequency,this._octaves=e.octaves,this._inputBoost=new t.Gain,this._bandpass=new t.Filter({rolloff:-48,frequency:0,Q:e.Q}),this._peaking=new t.Filter(0,"peaking"),this._peaking.gain.value=e.gain,this.gain=this._peaking.gain,this.Q=this._bandpass.Q,this.effectSend.chain(this._inputBoost,this.follower,this._sweepRange),this._sweepRange.connect(this._bandpass.frequency),this._sweepRange.connect(this._peaking.frequency),this.effectSend.chain(this._bandpass,this._peaking,this.effectReturn),this._setSweepRange(),this.sensitivity=e.sensitivity,this._readOnly(["gain","Q"])},t.extend(t.AutoWah,t.Effect),t.AutoWah.defaults={baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,follower:{attack:.3,release:.5}},Object.defineProperty(t.AutoWah.prototype,"octaves",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._setSweepRange()}}),Object.defineProperty(t.AutoWah.prototype,"baseFrequency",{get:function(){return this._baseFrequency},set:function(t){this._baseFrequency=t,this._setSweepRange()}}),Object.defineProperty(t.AutoWah.prototype,"sensitivity",{get:function(){return this.gainToDb(1/this._inputBoost.gain.value)},set:function(t){this._inputBoost.gain.value=1/this.dbToGain(t)}}),t.AutoWah.prototype._setSweepRange=function(){this._sweepRange.min=this._baseFrequency,this._sweepRange.max=Math.min(this._baseFrequency*Math.pow(2,this._octaves),this.context.sampleRate/2)},t.AutoWah.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this.follower.dispose(),this.follower=null,this._sweepRange.dispose(),this._sweepRange=null,this._bandpass.dispose(),this._bandpass=null,this._peaking.dispose(),this._peaking=null,this._inputBoost.dispose(),this._inputBoost=null,this._writable(["gain","Q"]),this.gain=null,this.Q=null,this},t.AutoWah}),t(function(t){return t.BitCrusher=function(){var e=this.optionsObject(arguments,["bits"],t.BitCrusher.defaults);t.Effect.call(this,e);var i=1/Math.pow(2,e.bits-1);this._subtract=new t.Subtract,this._modulo=new t.Modulo(i),this._bits=e.bits,this.effectSend.fan(this._subtract,this._modulo),this._modulo.connect(this._subtract,0,1),this._subtract.connect(this.effectReturn)},t.extend(t.BitCrusher,t.Effect),t.BitCrusher.defaults={bits:4},Object.defineProperty(t.BitCrusher.prototype,"bits",{get:function(){return this._bits},set:function(t){this._bits=t;var e=1/Math.pow(2,t-1);this._modulo.value=e}}),t.BitCrusher.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._subtract.dispose(),this._subtract=null,this._modulo.dispose(),this._modulo=null,this},t.BitCrusher}),t(function(t){return t.Chebyshev=function(){var e=this.optionsObject(arguments,["order"],t.Chebyshev.defaults);t.Effect.call(this,e),this._shaper=new t.WaveShaper(4096),this._order=e.order,this.connectEffect(this._shaper),this.order=e.order,this.oversample=e.oversample},t.extend(t.Chebyshev,t.Effect),t.Chebyshev.defaults={order:1,oversample:"none"},t.Chebyshev.prototype._getCoefficient=function(t,e,i){return i.hasOwnProperty(e)?i[e]:(i[e]=0===e?0:1===e?t:2*t*this._getCoefficient(t,e-1,i)-this._getCoefficient(t,e-2,i),i[e])},Object.defineProperty(t.Chebyshev.prototype,"order",{get:function(){return this._order},set:function(t){this._order=t;for(var e=new Array(4096),i=e.length,s=0;s<i;++s){var n=2*s/i-1;e[s]=0===n?0:this._getCoefficient(n,t,{})}this._shaper.curve=e}}),Object.defineProperty(t.Chebyshev.prototype,"oversample",{get:function(){return this._shaper.oversample},set:function(t){this._shaper.oversample=t}}),t.Chebyshev.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._shaper.dispose(),this._shaper=null,this},t.Chebyshev}),t(function(t){return t.StereoEffect=function(){this.createInsOuts(1,1);var e=this.optionsObject(arguments,["wet"],t.Effect.defaults);this._dryWet=new t.CrossFade(e.wet),this.wet=this._dryWet.fade,this._split=new t.Split,this.effectSendL=this._split.left,this.effectSendR=this._split.right,this._merge=new t.Merge,this.effectReturnL=this._merge.left,this.effectReturnR=this._merge.right,this.input.connect(this._split),this.input.connect(this._dryWet,0,0),this._merge.connect(this._dryWet,0,1),this._dryWet.connect(this.output),this._readOnly(["wet"])},t.extend(t.StereoEffect,t.Effect),t.StereoEffect.prototype.dispose=function(){return t.prototype.dispose.call(this),this._dryWet.dispose(),this._dryWet=null,this._split.dispose(),this._split=null,this._merge.dispose(),this._merge=null,this.effectSendL=null,this.effectSendR=null,this.effectReturnL=null,this.effectReturnR=null,this._writable(["wet"]),this.wet=null,this},t.StereoEffect}),t(function(t){return t.FeedbackEffect=function(){var e=this.optionsObject(arguments,["feedback"]);e=this.defaultArg(e,t.FeedbackEffect.defaults),t.Effect.call(this,e),this._feedbackGain=new t.Gain(e.feedback,t.Type.NormalRange),this.feedback=this._feedbackGain.gain,this.effectReturn.chain(this._feedbackGain,this.effectSend),this._readOnly(["feedback"])},t.extend(t.FeedbackEffect,t.Effect),t.FeedbackEffect.defaults={feedback:.125},t.FeedbackEffect.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._writable(["feedback"]),this._feedbackGain.dispose(),this._feedbackGain=null,this.feedback=null,this},t.FeedbackEffect}),t(function(t){return t.StereoXFeedbackEffect=function(){var e=this.optionsObject(arguments,["feedback"],t.FeedbackEffect.defaults);t.StereoEffect.call(this,e),this.feedback=new t.Signal(e.feedback,t.Type.NormalRange),this._feedbackLR=new t.Gain,this._feedbackRL=new t.Gain,this.effectReturnL.chain(this._feedbackLR,this.effectSendR),this.effectReturnR.chain(this._feedbackRL,this.effectSendL),this.feedback.fan(this._feedbackLR.gain,this._feedbackRL.gain),this._readOnly(["feedback"])},t.extend(t.StereoXFeedbackEffect,t.FeedbackEffect),t.StereoXFeedbackEffect.prototype.dispose=function(){return t.StereoEffect.prototype.dispose.call(this),this._writable(["feedback"]),this.feedback.dispose(),this.feedback=null,this._feedbackLR.dispose(),this._feedbackLR=null,this._feedbackRL.dispose(),this._feedbackRL=null,this},t.StereoXFeedbackEffect}),t(function(t){return t.Chorus=function(){var e=this.optionsObject(arguments,["frequency","delayTime","depth"],t.Chorus.defaults);t.StereoXFeedbackEffect.call(this,e),this._depth=e.depth,this._delayTime=e.delayTime/1e3,this._lfoL=new t.LFO({frequency:e.frequency,min:0,max:1}),this._lfoR=new t.LFO({frequency:e.frequency,min:0,max:1,phase:180}),this._delayNodeL=new t.Delay,this._delayNodeR=new t.Delay,this.frequency=this._lfoL.frequency,this.effectSendL.chain(this._delayNodeL,this.effectReturnL),this.effectSendR.chain(this._delayNodeR,this.effectReturnR),this.effectSendL.connect(this.effectReturnL),this.effectSendR.connect(this.effectReturnR),this._lfoL.connect(this._delayNodeL.delayTime),this._lfoR.connect(this._delayNodeR.delayTime),this._lfoL.start(),this._lfoR.start(),this._lfoL.frequency.connect(this._lfoR.frequency),this.depth=this._depth,this.frequency.value=e.frequency,this.type=e.type,this._readOnly(["frequency"]),this.spread=e.spread},t.extend(t.Chorus,t.StereoXFeedbackEffect),t.Chorus.defaults={frequency:1.5,delayTime:3.5,depth:.7,feedback:.1,type:"sine",spread:180},Object.defineProperty(t.Chorus.prototype,"depth",{get:function(){return this._depth},set:function(t){this._depth=t;var e=this._delayTime*t;this._lfoL.min=Math.max(this._delayTime-e,0),this._lfoL.max=this._delayTime+e,this._lfoR.min=Math.max(this._delayTime-e,0),this._lfoR.max=this._delayTime+e}}),Object.defineProperty(t.Chorus.prototype,"delayTime",{get:function(){return 1e3*this._delayTime},set:function(t){this._delayTime=t/1e3,this.depth=this._depth}}),Object.defineProperty(t.Chorus.prototype,"type",{get:function(){return this._lfoL.type},set:function(t){this._lfoL.type=t,this._lfoR.type=t}}),Object.defineProperty(t.Chorus.prototype,"spread",{get:function(){return this._lfoR.phase-this._lfoL.phase},set:function(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/2+90}}),t.Chorus.prototype.dispose=function(){return t.StereoXFeedbackEffect.prototype.dispose.call(this),this._lfoL.dispose(),this._lfoL=null,this._lfoR.dispose(),this._lfoR=null,this._delayNodeL.dispose(),this._delayNodeL=null,this._delayNodeR.dispose(),this._delayNodeR=null,this._writable("frequency"),this.frequency=null,this},t.Chorus}),t(function(t){return t.Convolver=function(){var e=this.optionsObject(arguments,["url","onload"],t.Convolver.defaults);t.Effect.call(this,e),this._convolver=this.context.createConvolver(),this._buffer=new t.Buffer,this.isString(e.url)?this._buffer.load(e.url,function(t){this.buffer=t,e.onload()}.bind(this)):e.url&&(this.buffer=e.url,e.onload()),this.connectEffect(this._convolver)},t.extend(t.Convolver,t.Effect),t.Convolver.defaults={onload:t.noOp},Object.defineProperty(t.Convolver.prototype,"buffer",{get:function(){return this._buffer.get()},set:function(t){this._buffer.set(t),this._convolver.buffer=this._buffer.get()}}),t.Convolver.prototype.load=function(t,e){return this._buffer.load(t,function(t){this.buffer=t,e&&e()}.bind(this))},t.Convolver.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._convolver.disconnect(),this._convolver=null,this._buffer.dispose(),this._buffer=null,this},t.Convolver}),t(function(t){return t.Distortion=function(){var e=this.optionsObject(arguments,["distortion"],t.Distortion.defaults);t.Effect.call(this,e),this._shaper=new t.WaveShaper(4096),this._distortion=e.distortion,this.connectEffect(this._shaper),this.distortion=e.distortion,this.oversample=e.oversample},t.extend(t.Distortion,t.Effect),t.Distortion.defaults={distortion:.4,oversample:"none"},Object.defineProperty(t.Distortion.prototype,"distortion",{get:function(){return this._distortion},set:function(t){this._distortion=t;var e=100*t,i=Math.PI/180;this._shaper.setMap(function(t){return Math.abs(t)<.001?0:(3+e)*t*20*i/(Math.PI+e*Math.abs(t))})}}),Object.defineProperty(t.Distortion.prototype,"oversample",{get:function(){return this._shaper.oversample},set:function(t){this._shaper.oversample=t}}),t.Distortion.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._shaper.dispose(),this._shaper=null,this},t.Distortion}),t(function(t){return t.FeedbackDelay=function(){var e=this.optionsObject(arguments,["delayTime","feedback"],t.FeedbackDelay.defaults);t.FeedbackEffect.call(this,e),this._delayNode=new t.Delay(e.delayTime),this.delayTime=this._delayNode.delayTime,this.connectEffect(this._delayNode),this._readOnly(["delayTime"])},t.extend(t.FeedbackDelay,t.FeedbackEffect),t.FeedbackDelay.defaults={delayTime:.25},t.FeedbackDelay.prototype.dispose=function(){return t.FeedbackEffect.prototype.dispose.call(this),this._delayNode.dispose(),this._delayNode=null,this._writable(["delayTime"]),this.delayTime=null,this},t.FeedbackDelay}),t(function(t){var e=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100],i=[225,556,441,341];return t.Freeverb=function(){var s=this.optionsObject(arguments,["roomSize","dampening"],t.Freeverb.defaults);t.StereoEffect.call(this,s),this.roomSize=new t.Signal(s.roomSize,t.Type.NormalRange),this.dampening=new t.Signal(s.dampening,t.Type.Frequency),this._combFilters=[],this._allpassFiltersL=[],this._allpassFiltersR=[];for(var n=0;n<i.length;n++){var o=this.context.createBiquadFilter();o.type="allpass",o.frequency.value=i[n],this._allpassFiltersL.push(o)}for(var r=0;r<i.length;r++){var a=this.context.createBiquadFilter();a.type="allpass",a.frequency.value=i[r],this._allpassFiltersR.push(a)}for(var h=0;h<e.length;h++){var l=new t.LowpassCombFilter(e[h]);h<e.length/2?this.effectSendL.chain(l,this._allpassFiltersL[0]):this.effectSendR.chain(l,this._allpassFiltersR[0]),this.roomSize.connect(l.resonance),this.dampening.connect(l.dampening),this._combFilters.push(l)}this.connectSeries.apply(this,this._allpassFiltersL),this.connectSeries.apply(this,this._allpassFiltersR),this._allpassFiltersL[this._allpassFiltersL.length-1].connect(this.effectReturnL),this._allpassFiltersR[this._allpassFiltersR.length-1].connect(this.effectReturnR),this._readOnly(["roomSize","dampening"])},t.extend(t.Freeverb,t.StereoEffect),t.Freeverb.defaults={roomSize:.7,dampening:3e3},t.Freeverb.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this);for(var e=0;e<this._allpassFiltersL.length;e++)this._allpassFiltersL[e].disconnect(),this._allpassFiltersL[e]=null;this._allpassFiltersL=null;for(var i=0;i<this._allpassFiltersR.length;i++)this._allpassFiltersR[i].disconnect(),this._allpassFiltersR[i]=null;this._allpassFiltersR=null;for(var s=0;s<this._combFilters.length;s++)this._combFilters[s].dispose(),this._combFilters[s]=null;return this._combFilters=null,this._writable(["roomSize","dampening"]),this.roomSize.dispose(),this.roomSize=null,this.dampening.dispose(),this.dampening=null,this},t.Freeverb}),t(function(t){var e=[.06748,.06404,.08212,.09004],i=[.773,.802,.753,.733],s=[347,113,37];return t.JCReverb=function(){var n=this.optionsObject(arguments,["roomSize"],t.JCReverb.defaults);t.StereoEffect.call(this,n),this.roomSize=new t.Signal(n.roomSize,t.Type.NormalRange),this._scaleRoomSize=new t.Scale(-.733,.197),this._allpassFilters=[],this._feedbackCombFilters=[];for(var o=0;o<s.length;o++){var r=this.context.createBiquadFilter();r.type="allpass",r.frequency.value=s[o],this._allpassFilters.push(r)}for(var a=0;a<e.length;a++){var h=new t.FeedbackCombFilter(e[a],.1);this._scaleRoomSize.connect(h.resonance),h.resonance.value=i[a],this._allpassFilters[this._allpassFilters.length-1].connect(h),a<e.length/2?h.connect(this.effectReturnL):h.connect(this.effectReturnR),this._feedbackCombFilters.push(h)}this.roomSize.connect(this._scaleRoomSize),this.connectSeries.apply(this,this._allpassFilters),this.effectSendL.connect(this._allpassFilters[0]),this.effectSendR.connect(this._allpassFilters[0]),this._readOnly(["roomSize"])},t.extend(t.JCReverb,t.StereoEffect),t.JCReverb.defaults={roomSize:.5},t.JCReverb.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this);for(var e=0;e<this._allpassFilters.length;e++)this._allpassFilters[e].disconnect(),this._allpassFilters[e]=null;this._allpassFilters=null;for(var i=0;i<this._feedbackCombFilters.length;i++)this._feedbackCombFilters[i].dispose(),this._feedbackCombFilters[i]=null;return this._feedbackCombFilters=null,this._writable(["roomSize"]),this.roomSize.dispose(),this.roomSize=null,this._scaleRoomSize.dispose(),this._scaleRoomSize=null,this},t.JCReverb}),t(function(t){return t.MidSideEffect=function(){t.Effect.apply(this,arguments),this._midSideSplit=new t.MidSideSplit,this._midSideMerge=new t.MidSideMerge,this.midSend=this._midSideSplit.mid,this.sideSend=this._midSideSplit.side,this.midReturn=this._midSideMerge.mid,this.sideReturn=this._midSideMerge.side,this.effectSend.connect(this._midSideSplit),this._midSideMerge.connect(this.effectReturn)},t.extend(t.MidSideEffect,t.Effect),t.MidSideEffect.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._midSideSplit.dispose(),this._midSideSplit=null,this._midSideMerge.dispose(),this._midSideMerge=null,this.midSend=null,this.sideSend=null,this.midReturn=null,this.sideReturn=null,this},t.MidSideEffect}),t(function(t){return t.Phaser=function(){var e=this.optionsObject(arguments,["frequency","octaves","baseFrequency"],t.Phaser.defaults);t.StereoEffect.call(this,e),this._lfoL=new t.LFO(e.frequency,0,1),this._lfoR=new t.LFO(e.frequency,0,1),this._lfoR.phase=180,this._baseFrequency=e.baseFrequency,this._octaves=e.octaves,this.Q=new t.Signal(e.Q,t.Type.Positive),this._filtersL=this._makeFilters(e.stages,this._lfoL,this.Q),this._filtersR=this._makeFilters(e.stages,this._lfoR,this.Q),this.frequency=this._lfoL.frequency,this.frequency.value=e.frequency,this.effectSendL.connect(this._filtersL[0]),this.effectSendR.connect(this._filtersR[0]),this._filtersL[e.stages-1].connect(this.effectReturnL),this._filtersR[e.stages-1].connect(this.effectReturnR),this._lfoL.frequency.connect(this._lfoR.frequency),this.baseFrequency=e.baseFrequency,this.octaves=e.octaves,this._lfoL.start(),this._lfoR.start(),this._readOnly(["frequency","Q"])},t.extend(t.Phaser,t.StereoEffect),t.Phaser.defaults={frequency:.5,octaves:3,stages:10,Q:10,baseFrequency:350},t.Phaser.prototype._makeFilters=function(t,e,i){for(var s=new Array(t),n=0;n<t;n++){var o=this.context.createBiquadFilter();o.type="allpass",i.connect(o.Q),e.connect(o.frequency),s[n]=o}return this.connectSeries.apply(this,s),s},Object.defineProperty(t.Phaser.prototype,"octaves",{get:function(){return this._octaves},set:function(t){this._octaves=t;var e=this._baseFrequency*Math.pow(2,t);this._lfoL.max=e,this._lfoR.max=e}}),Object.defineProperty(t.Phaser.prototype,"baseFrequency",{get:function(){return this._baseFrequency},set:function(t){this._baseFrequency=t,this._lfoL.min=t,this._lfoR.min=t,this.octaves=this._octaves}}),t.Phaser.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this),this._writable(["frequency","Q"]),this.Q.dispose(),this.Q=null,this._lfoL.dispose(),this._lfoL=null,this._lfoR.dispose(),this._lfoR=null;for(var e=0;e<this._filtersL.length;e++)this._filtersL[e].disconnect(),this._filtersL[e]=null;this._filtersL=null;for(var i=0;i<this._filtersR.length;i++)this._filtersR[i].disconnect(),this._filtersR[i]=null;return this._filtersR=null,this.frequency=null,this},t.Phaser}),t(function(t){return t.PingPongDelay=function(){var e=this.optionsObject(arguments,["delayTime","feedback"],t.PingPongDelay.defaults);t.StereoXFeedbackEffect.call(this,e),this._leftDelay=new t.Delay(0,e.maxDelayTime),this._rightDelay=new t.Delay(0,e.maxDelayTime),this._rightPreDelay=new t.Delay(0,e.maxDelayTime),this.delayTime=new t.Signal(e.delayTime,t.Type.Time),this.effectSendL.chain(this._leftDelay,this.effectReturnL),this.effectSendR.chain(this._rightPreDelay,this._rightDelay,this.effectReturnR),this.delayTime.fan(this._leftDelay.delayTime,this._rightDelay.delayTime,this._rightPreDelay.delayTime),this._feedbackLR.disconnect(),this._feedbackLR.connect(this._rightDelay),this._readOnly(["delayTime"])},t.extend(t.PingPongDelay,t.StereoXFeedbackEffect),t.PingPongDelay.defaults={delayTime:.25,maxDelayTime:1},t.PingPongDelay.prototype.dispose=function(){return t.StereoXFeedbackEffect.prototype.dispose.call(this),this._leftDelay.dispose(),this._leftDelay=null,this._rightDelay.dispose(),this._rightDelay=null,this._rightPreDelay.dispose(),this._rightPreDelay=null,this._writable(["delayTime"]),this.delayTime.dispose(),this.delayTime=null,this},t.PingPongDelay}),t(function(t){return t.PitchShift=function(){var e=this.optionsObject(arguments,["pitch"],t.PitchShift.defaults);t.FeedbackEffect.call(this,e),this._frequency=new t.Signal(0),this._delayA=new t.Delay(0,1),this._lfoA=new t.LFO({min:0,max:.1,type:"sawtooth"}).connect(this._delayA.delayTime),this._delayB=new t.Delay(0,1),this._lfoB=new t.LFO({min:0,max:.1,type:"sawtooth",phase:180}).connect(this._delayB.delayTime),this._crossFade=new t.CrossFade,this._crossFadeLFO=new t.LFO({min:0,max:1,type:"triangle",phase:90}).connect(this._crossFade.fade),this._feedbackDelay=new t.Delay(e.delayTime),this.delayTime=this._feedbackDelay.delayTime,this._readOnly("delayTime"),this._pitch=e.pitch,this._windowSize=e.windowSize,this._delayA.connect(this._crossFade.a),this._delayB.connect(this._crossFade.b),this._frequency.fan(this._lfoA.frequency,this._lfoB.frequency,this._crossFadeLFO.frequency),this.effectSend.fan(this._delayA,this._delayB),this._crossFade.chain(this._feedbackDelay,this.effectReturn);var i=this.now();this._lfoA.start(i),this._lfoB.start(i),this._crossFadeLFO.start(i),this.windowSize=this._windowSize},t.extend(t.PitchShift,t.FeedbackEffect),t.PitchShift.defaults={pitch:0,windowSize:.1,delayTime:0,feedback:0},Object.defineProperty(t.PitchShift.prototype,"pitch",{get:function(){return this._pitch},set:function(t){this._pitch=t;var e=0;t<0?(this._lfoA.min=0,this._lfoA.max=this._windowSize,this._lfoB.min=0,this._lfoB.max=this._windowSize,e=this.intervalToFrequencyRatio(t-1)+1):(this._lfoA.min=this._windowSize,this._lfoA.max=0,this._lfoB.min=this._windowSize,this._lfoB.max=0,e=this.intervalToFrequencyRatio(t)-1),this._frequency.value=e*(1.2/this._windowSize)}}),Object.defineProperty(t.PitchShift.prototype,"windowSize",{get:function(){return this._windowSize},set:function(t){this._windowSize=this.toSeconds(t),this.pitch=this._pitch}}),t.PitchShift.prototype.dispose=function(){return t.FeedbackEffect.prototype.dispose.call(this),this._frequency.dispose(),this._frequency=null,this._delayA.disconnect(),this._delayA=null,this._delayB.disconnect(),this._delayB=null,this._lfoA.dispose(),this._lfoA=null,this._lfoB.dispose(),this._lfoB=null,this._crossFade.dispose(),this._crossFade=null,this._crossFadeLFO.dispose(),this._crossFadeLFO=null,this._writable("delayTime"),this._feedbackDelay.dispose(),this._feedbackDelay=null,this.delayTime=null,this},t.PitchShift}),t(function(t){return t.StereoFeedbackEffect=function(){var e=this.optionsObject(arguments,["feedback"],t.FeedbackEffect.defaults);t.StereoEffect.call(this,e),this.feedback=new t.Signal(e.feedback,t.Type.NormalRange),this._feedbackL=new t.Gain,this._feedbackR=new t.Gain,this.effectReturnL.chain(this._feedbackL,this.effectSendL),this.effectReturnR.chain(this._feedbackR,this.effectSendR),this.feedback.fan(this._feedbackL.gain,this._feedbackR.gain),this._readOnly(["feedback"])},t.extend(t.StereoFeedbackEffect,t.FeedbackEffect),t.StereoFeedbackEffect.prototype.dispose=function(){return t.StereoEffect.prototype.dispose.call(this),this._writable(["feedback"]),this.feedback.dispose(),this.feedback=null,this._feedbackL.dispose(),this._feedbackL=null,this._feedbackR.dispose(),this._feedbackR=null,this},t.StereoFeedbackEffect}),t(function(t){return t.StereoWidener=function(){var e=this.optionsObject(arguments,["width"],t.StereoWidener.defaults);t.MidSideEffect.call(this,e),this.width=new t.Signal(e.width,t.Type.NormalRange),this._midMult=new t.Expr("$0 * ($1 * (1 - $2))"),this._sideMult=new t.Expr("$0 * ($1 * $2)"),this._two=new t.Signal(2),this._two.connect(this._midMult,0,1),this.width.connect(this._midMult,0,2),this._two.connect(this._sideMult,0,1),this.width.connect(this._sideMult,0,2),this.midSend.chain(this._midMult,this.midReturn),this.sideSend.chain(this._sideMult,this.sideReturn),this._readOnly(["width"])},t.extend(t.StereoWidener,t.MidSideEffect),t.StereoWidener.defaults={width:.5},t.StereoWidener.prototype.dispose=function(){return t.MidSideEffect.prototype.dispose.call(this),this._writable(["width"]),this.width.dispose(),this.width=null,this._midMult.dispose(),this._midMult=null,this._sideMult.dispose(),this._sideMult=null,this._two.dispose(),this._two=null,this},t.StereoWidener}),t(function(t){return t.Tremolo=function(){var e=this.optionsObject(arguments,["frequency","depth"],t.Tremolo.defaults);t.StereoEffect.call(this,e),this._lfoL=new t.LFO({phase:e.spread,min:1,max:0}),this._lfoR=new t.LFO({phase:e.spread,min:1,max:0}),this._amplitudeL=new t.Gain,this._amplitudeR=new t.Gain,this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.depth=new t.Signal(e.depth,t.Type.NormalRange),this._readOnly(["frequency","depth"]),this.effectSendL.chain(this._amplitudeL,this.effectReturnL),this.effectSendR.chain(this._amplitudeR,this.effectReturnR),this._lfoL.connect(this._amplitudeL.gain),this._lfoR.connect(this._amplitudeR.gain),this.frequency.fan(this._lfoL.frequency,this._lfoR.frequency),this.depth.fan(this._lfoR.amplitude,this._lfoL.amplitude),this.type=e.type,this.spread=e.spread},t.extend(t.Tremolo,t.StereoEffect),t.Tremolo.defaults={frequency:10,type:"sine",depth:.5,spread:180},t.Tremolo.prototype.start=function(t){return this._lfoL.start(t),this._lfoR.start(t),this},t.Tremolo.prototype.stop=function(t){return this._lfoL.stop(t),this._lfoR.stop(t),this},t.Tremolo.prototype.sync=function(t){return this._lfoL.sync(t),this._lfoR.sync(t),this},t.Tremolo.prototype.unsync=function(){return this._lfoL.unsync(),this._lfoR.unsync(),this},Object.defineProperty(t.Tremolo.prototype,"type",{get:function(){return this._lfoL.type},set:function(t){this._lfoL.type=t,this._lfoR.type=t}}),Object.defineProperty(t.Tremolo.prototype,"spread",{get:function(){return this._lfoR.phase-this._lfoL.phase},set:function(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/2+90}}),t.Tremolo.prototype.dispose=function(){return t.StereoEffect.prototype.dispose.call(this),this._writable(["frequency","depth"]),this._lfoL.dispose(),this._lfoL=null,this._lfoR.dispose(),this._lfoR=null,this._amplitudeL.dispose(),this._amplitudeL=null,this._amplitudeR.dispose(),this._amplitudeR=null,this.frequency=null,this.depth=null,this},t.Tremolo}),t(function(t){return t.Vibrato=function(){var e=this.optionsObject(arguments,["frequency","depth"],t.Vibrato.defaults);t.Effect.call(this,e),this._delayNode=new t.Delay(0,e.maxDelay),this._lfo=new t.LFO({type:e.type,min:0,max:e.maxDelay,frequency:e.frequency,phase:-90}).start().connect(this._delayNode.delayTime),this.frequency=this._lfo.frequency,this.depth=this._lfo.amplitude,this.depth.value=e.depth,this._readOnly(["frequency","depth"]),this.effectSend.chain(this._delayNode,this.effectReturn)},t.extend(t.Vibrato,t.Effect),t.Vibrato.defaults={maxDelay:.005,frequency:5,depth:.1,type:"sine"},Object.defineProperty(t.Vibrato.prototype,"type",{get:function(){return this._lfo.type},set:function(t){this._lfo.type=t}}),t.Vibrato.prototype.dispose=function(){t.Effect.prototype.dispose.call(this),this._delayNode.dispose(),this._delayNode=null,this._lfo.dispose(),this._lfo=null,this._writable(["frequency","depth"]),this.frequency=null,this.depth=null},t.Vibrato}),t(function(t){return t.Event=function(){var e=this.optionsObject(arguments,["callback","value"],t.Event.defaults);this._loop=e.loop,this.callback=e.callback,this.value=e.value,this._loopStart=this.toTicks(e.loopStart),this._loopEnd=this.toTicks(e.loopEnd),this._state=new t.TimelineState(t.State.Stopped),this._playbackRate=1,this._startOffset=0,this.probability=e.probability,this.humanize=e.humanize,this.mute=e.mute,this.playbackRate=e.playbackRate},t.extend(t.Event),t.Event.defaults={callback:t.noOp,loop:!1,loopEnd:"1m",loopStart:0,playbackRate:1,value:null,probability:1,mute:!1,humanize:!1},t.Event.prototype._rescheduleEvents=function(e){return e=this.defaultArg(e,-1),this._state.forEachFrom(e,function(e){var i;if(e.state===t.State.Started){this.isUndef(e.id)||t.Transport.clear(e.id);var s=e.time+Math.round(this.startOffset/this._playbackRate);if(this._loop){i=1/0,this.isNumber(this._loop)&&(i=this._loop*this._getLoopDuration());var n=this._state.getAfter(s);null!==n&&(i=Math.min(i,n.time-s)),i!==1/0&&(this._state.setStateAtTime(t.State.Stopped,s+i+1),i=t.Time(i,"i"));var o=t.Time(this._getLoopDuration(),"i");e.id=t.Transport.scheduleRepeat(this._tick.bind(this),o,t.TransportTime(s,"i"),i)}else e.id=t.Transport.schedule(this._tick.bind(this),s+"i")}}.bind(this)),this},Object.defineProperty(t.Event.prototype,"state",{get:function(){return this._state.getValueAtTime(t.Transport.ticks)}}),Object.defineProperty(t.Event.prototype,"startOffset",{get:function(){return this._startOffset},set:function(t){this._startOffset=t}}),t.Event.prototype.start=function(e){return e=this.toTicks(e),this._state.getValueAtTime(e)===t.State.Stopped&&(this._state.add({state:t.State.Started,time:e,id:void 0}),this._rescheduleEvents(e)),this},t.Event.prototype.stop=function(e){if(this.cancel(e),e=this.toTicks(e),this._state.getValueAtTime(e)===t.State.Started){this._state.setStateAtTime(t.State.Stopped,e);var i=this._state.getBefore(e),s=e;null!==i&&(s=i.time),this._rescheduleEvents(s)}return this},t.Event.prototype.cancel=function(e){return e=this.defaultArg(e,-1/0),e=this.toTicks(e),this._state.forEachFrom(e,function(e){t.Transport.clear(e.id)}),this._state.cancel(e),this},t.Event.prototype._tick=function(e){if(!this.mute&&this._state.getValueAtTime(t.Transport.ticks)===t.State.Started){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){var i=.02;this.isBoolean(this.humanize)||(i=this.toSeconds(this.humanize)),e+=(2*Math.random()-1)*i}this.callback(e,this.value)}},t.Event.prototype._getLoopDuration=function(){return Math.round((this._loopEnd-this._loopStart)/this._playbackRate)},Object.defineProperty(t.Event.prototype,"loop",{get:function(){return this._loop},set:function(t){this._loop=t,this._rescheduleEvents()}}),Object.defineProperty(t.Event.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._rescheduleEvents()}}),Object.defineProperty(t.Event.prototype,"loopEnd",{get:function(){return t.TransportTime(this._loopEnd,"i").toNotation()},set:function(t){this._loopEnd=this.toTicks(t),this._loop&&this._rescheduleEvents()}}),Object.defineProperty(t.Event.prototype,"loopStart",{get:function(){return t.TransportTime(this._loopStart,"i").toNotation()},set:function(t){this._loopStart=this.toTicks(t),this._loop&&this._rescheduleEvents()}}),Object.defineProperty(t.Event.prototype,"progress",{get:function(){if(this._loop){var e=t.Transport.ticks,i=this._state.get(e);if(null!==i&&i.state===t.State.Started){var s=this._getLoopDuration();return(e-i.time)%s/s}return 0}return 0}}),t.Event.prototype.dispose=function(){this.cancel(),this._state.dispose(),this._state=null,this.callback=null,this.value=null},t.Event}),t(function(t){return t.Loop=function(){var e=this.optionsObject(arguments,["callback","interval"],t.Loop.defaults);this._event=new t.Event({callback:this._tick.bind(this),loop:!0,loopEnd:e.interval,playbackRate:e.playbackRate,probability:e.probability}),this.callback=e.callback,this.iterations=e.iterations},t.extend(t.Loop),t.Loop.defaults={interval:"4n",callback:t.noOp,playbackRate:1,iterations:1/0,probability:!0,mute:!1},t.Loop.prototype.start=function(t){return this._event.start(t),this},t.Loop.prototype.stop=function(t){return this._event.stop(t),this},t.Loop.prototype.cancel=function(t){return this._event.cancel(t),this},t.Loop.prototype._tick=function(t){this.callback(t)},Object.defineProperty(t.Loop.prototype,"state",{get:function(){return this._event.state}}),Object.defineProperty(t.Loop.prototype,"progress",{get:function(){return this._event.progress}}),Object.defineProperty(t.Loop.prototype,"interval",{get:function(){return this._event.loopEnd},set:function(t){this._event.loopEnd=t}}),Object.defineProperty(t.Loop.prototype,"playbackRate",{get:function(){return this._event.playbackRate},set:function(t){this._event.playbackRate=t}}),Object.defineProperty(t.Loop.prototype,"humanize",{get:function(){return this._event.humanize},set:function(t){this._event.humanize=t}}),Object.defineProperty(t.Loop.prototype,"probability",{get:function(){return this._event.probability},set:function(t){this._event.probability=t}}),Object.defineProperty(t.Loop.prototype,"mute",{get:function(){return this._event.mute},set:function(t){this._event.mute=t}}),Object.defineProperty(t.Loop.prototype,"iterations",{get:function(){return!0===this._event.loop?1/0:this._event.loop},set:function(t){this._event.loop=t===1/0||t}}),t.Loop.prototype.dispose=function(){this._event.dispose(),this._event=null,this.callback=null},t.Loop}),t(function(t){return t.Part=function(){var e=this.optionsObject(arguments,["callback","events"],t.Part.defaults);this._loop=e.loop,this._loopStart=this.toTicks(e.loopStart),this._loopEnd=this.toTicks(e.loopEnd),this._playbackRate=e.playbackRate,this._probability=e.probability,this._humanize=e.humanize,this._startOffset=0,this._state=new t.TimelineState(t.State.Stopped),this._events=[],this.callback=e.callback,this.mute=e.mute;var i=this.defaultArg(e.events,[]);if(!this.isUndef(e.events))for(var s=0;s<i.length;s++)Array.isArray(i[s])?this.add(i[s][0],i[s][1]):this.add(i[s])},t.extend(t.Part,t.Event),t.Part.defaults={callback:t.noOp,loop:!1,loopEnd:"1m",loopStart:0,playbackRate:1,probability:1,humanize:!1,mute:!1},t.Part.prototype.start=function(e,i){var s=this.toTicks(e);return this._state.getValueAtTime(s)!==t.State.Started&&(i=this._loop?this.defaultArg(i,this._loopStart):this.defaultArg(i,0),i=this.toTicks(i),this._state.add({state:t.State.Started,time:s,offset:i}),this._forEach(function(t){this._startNote(t,s,i)})),this},t.Part.prototype._startNote=function(e,i,s){i-=s,this._loop?e.startOffset>=this._loopStart&&e.startOffset<this._loopEnd?(e.startOffset<s&&(i+=this._getLoopDuration()),e.start(t.TransportTime(i,"i"))):e.startOffset<this._loopStart&&e.startOffset>=s&&(e.loop=!1,e.start(t.TransportTime(i,"i"))):e.startOffset>=s&&e.start(t.TransportTime(i,"i"))},Object.defineProperty(t.Part.prototype,"startOffset",{get:function(){return this._startOffset},set:function(t){this._startOffset=t,this._forEach(function(t){t.startOffset+=this._startOffset})}}),t.Part.prototype.stop=function(e){var i=this.toTicks(e);return this._state.cancel(i),this._state.setStateAtTime(t.State.Stopped,i),this._forEach(function(t){t.stop(e)}),this},t.Part.prototype.at=function(e,i){e=t.TransportTime(e);for(var s=t.Time(1,"i").toSeconds(),n=0;n<this._events.length;n++){var o=this._events[n];if(Math.abs(e.toTicks()-o.startOffset)<s)return this.isUndef(i)||(o.value=i),o}return this.isUndef(i)?null:(this.add(e,i),this._events[this._events.length-1])},t.Part.prototype.add=function(e,i){e.hasOwnProperty("time")&&(i=e,e=i.time),e=this.toTicks(e);var s;return i instanceof t.Event?(s=i,s.callback=this._tick.bind(this)):s=new t.Event({callback:this._tick.bind(this),value:i}),s.startOffset=e,s.set({loopEnd:this.loopEnd,loopStart:this.loopStart,loop:this.loop,humanize:this.humanize,playbackRate:this.playbackRate,probability:this.probability}),this._events.push(s),this._restartEvent(s),this},t.Part.prototype._restartEvent=function(e){this._state.forEach(function(i){i.state===t.State.Started?this._startNote(e,i.time,i.offset):e.stop(t.TransportTime(i.time,"i"))}.bind(this))},t.Part.prototype.remove=function(e,i){e.hasOwnProperty("time")&&(i=e,e=i.time),e=this.toTicks(e);for(var s=this._events.length-1;s>=0;s--){var n=this._events[s];n instanceof t.Part?n.remove(e,i):n.startOffset===e&&(this.isUndef(i)||!this.isUndef(i)&&n.value===i)&&(this._events.splice(s,1),n.dispose())}return this},t.Part.prototype.removeAll=function(){return this._forEach(function(t){t.dispose()}),this._events=[],this},t.Part.prototype.cancel=function(t){return t=this.toTicks(t),this._forEach(function(e){e.cancel(t)}),this._state.cancel(t),this},t.Part.prototype._forEach=function(e,i){i=this.defaultArg(i,this);for(var s=this._events.length-1;s>=0;s--){var n=this._events[s];n instanceof t.Part?n._forEach(e,i):e.call(i,n)}return this},t.Part.prototype._setAll=function(t,e){this._forEach(function(i){i[t]=e})},t.Part.prototype._tick=function(t,e){this.mute||this.callback(t,e)},t.Part.prototype._testLoopBoundries=function(e){e.startOffset<this._loopStart||e.startOffset>=this._loopEnd?e.cancel(0):e.state===t.State.Stopped&&this._restartEvent(e)},Object.defineProperty(t.Part.prototype,"probability",{get:function(){return this._probability},set:function(t){this._probability=t,this._setAll("probability",t)}}),Object.defineProperty(t.Part.prototype,"humanize",{get:function(){return this._humanize},set:function(t){this._humanize=t,this._setAll("humanize",t)}}),Object.defineProperty(t.Part.prototype,"loop",{get:function(){return this._loop},set:function(t){this._loop=t,this._forEach(function(e){e._loopStart=this._loopStart,e._loopEnd=this._loopEnd,e.loop=t,this._testLoopBoundries(e)})}}),Object.defineProperty(t.Part.prototype,"loopEnd",{get:function(){return t.TransportTime(this._loopEnd,"i").toNotation()},set:function(t){this._loopEnd=this.toTicks(t),this._loop&&this._forEach(function(e){e.loopEnd=t,this._testLoopBoundries(e)})}}),Object.defineProperty(t.Part.prototype,"loopStart",{get:function(){return t.TransportTime(this._loopStart,"i").toNotation()},set:function(t){this._loopStart=this.toTicks(t),this._loop&&this._forEach(function(t){t.loopStart=this.loopStart,this._testLoopBoundries(t)})}}),Object.defineProperty(t.Part.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._setAll("playbackRate",t)}}),Object.defineProperty(t.Part.prototype,"length",{get:function(){return this._events.length}}),t.Part.prototype.dispose=function(){return this.removeAll(),this._state.dispose(),this._state=null,this.callback=null,this._events=null,this},t.Part}),t(function(t){return t.Pattern=function(){var e=this.optionsObject(arguments,["callback","values","pattern"],t.Pattern.defaults);t.Loop.call(this,e),this._pattern=new t.CtrlPattern({values:e.values,type:e.pattern,index:e.index})},t.extend(t.Pattern,t.Loop),t.Pattern.defaults={pattern:t.CtrlPattern.Type.Up,values:[]},t.Pattern.prototype._tick=function(t){this.callback(t,this._pattern.value),this._pattern.next()},Object.defineProperty(t.Pattern.prototype,"index",{get:function(){return this._pattern.index},set:function(t){this._pattern.index=t}}),Object.defineProperty(t.Pattern.prototype,"values",{get:function(){return this._pattern.values},set:function(t){this._pattern.values=t}}),Object.defineProperty(t.Pattern.prototype,"value",{get:function(){return this._pattern.value}}),Object.defineProperty(t.Pattern.prototype,"pattern",{get:function(){return this._pattern.type},set:function(t){this._pattern.type=t}}),t.Pattern.prototype.dispose=function(){t.Loop.prototype.dispose.call(this),this._pattern.dispose(),this._pattern=null},t.Pattern}),t(function(t){return t.Sequence=function(){var e=this.optionsObject(arguments,["callback","events","subdivision"],t.Sequence.defaults),i=e.events;if(delete e.events,t.Part.call(this,e),this._subdivision=this.toTicks(e.subdivision),this.isUndef(e.loopEnd)&&!this.isUndef(i)&&(this._loopEnd=i.length*this._subdivision),this._loop=!0,!this.isUndef(i))for(var s=0;s<i.length;s++)this.add(s,i[s])},t.extend(t.Sequence,t.Part),t.Sequence.defaults={subdivision:"4n"},Object.defineProperty(t.Sequence.prototype,"subdivision",{get:function(){return t.Time(this._subdivision,"i").toNotation()}}),t.Sequence.prototype.at=function(e,i){return this.isArray(i)&&this.remove(e),t.Part.prototype.at.call(this,this._indexTime(e),i)},t.Sequence.prototype.add=function(e,i){if(null===i)return this;if(this.isArray(i)){var s=Math.round(this._subdivision/i.length);i=new t.Sequence(this._tick.bind(this),i,t.Time(s,"i"))}return t.Part.prototype.add.call(this,this._indexTime(e),i),this},t.Sequence.prototype.remove=function(e,i){return t.Part.prototype.remove.call(this,this._indexTime(e),i),this},t.Sequence.prototype._indexTime=function(e){return e instanceof t.TransportTime?e:t.TransportTime(e*this._subdivision+this.startOffset,"i")},t.Sequence.prototype.dispose=function(){return t.Part.prototype.dispose.call(this),this},t.Sequence}),t(function(t){return t.PulseOscillator=function(){var e=this.optionsObject(arguments,["frequency","width"],t.Oscillator.defaults);t.Source.call(this,e),this.width=new t.Signal(e.width,t.Type.NormalRange),this._widthGate=new t.Gain,this._sawtooth=new t.Oscillator({frequency:e.frequency,detune:e.detune,type:"sawtooth",phase:e.phase}),this.frequency=this._sawtooth.frequency,this.detune=this._sawtooth.detune,this._thresh=new t.WaveShaper(function(t){return t<0?-1:1}),this._sawtooth.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),this._readOnly(["width","frequency","detune"])},t.extend(t.PulseOscillator,t.Oscillator),t.PulseOscillator.defaults={frequency:440,detune:0,phase:0,width:.2},t.PulseOscillator.prototype._start=function(t){t=this.toSeconds(t),this._sawtooth.start(t),this._widthGate.gain.setValueAtTime(1,t)},t.PulseOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._sawtooth.stop(t),this._widthGate.gain.setValueAtTime(0,t)},Object.defineProperty(t.PulseOscillator.prototype,"phase",{get:function(){return this._sawtooth.phase},set:function(t){this._sawtooth.phase=t}}),Object.defineProperty(t.PulseOscillator.prototype,"type",{get:function(){return"pulse"}}),Object.defineProperty(t.PulseOscillator.prototype,"partials",{get:function(){return[]}}),t.PulseOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._sawtooth.dispose(),this._sawtooth=null,this._writable(["width","frequency","detune"]),this.width.dispose(),this.width=null,this._widthGate.dispose(),this._widthGate=null,this._thresh.dispose(),this._thresh=null,this.frequency=null,this.detune=null,this},t.PulseOscillator}),t(function(t){return t.PWMOscillator=function(){var e=this.optionsObject(arguments,["frequency","modulationFrequency"],t.PWMOscillator.defaults);t.Source.call(this,e),this._pulse=new t.PulseOscillator(e.modulationFrequency),this._pulse._sawtooth.type="sine",this._modulator=new t.Oscillator({frequency:e.frequency,detune:e.detune,phase:e.phase}),this._scale=new t.Multiply(2),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this.modulationFrequency=this._pulse.frequency,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),this._readOnly(["modulationFrequency","frequency","detune"])},t.extend(t.PWMOscillator,t.Oscillator),t.PWMOscillator.defaults={frequency:440,detune:0,phase:0,modulationFrequency:.4},t.PWMOscillator.prototype._start=function(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)},t.PWMOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)},Object.defineProperty(t.PWMOscillator.prototype,"type",{get:function(){return"pwm"}}),Object.defineProperty(t.PWMOscillator.prototype,"partials",{get:function(){return[]}}),Object.defineProperty(t.PWMOscillator.prototype,"phase",{get:function(){return this._modulator.phase},set:function(t){this._modulator.phase=t}}),t.PWMOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._pulse.dispose(),this._pulse=null,this._scale.dispose(),this._scale=null,this._modulator.dispose(),this._modulator=null,this._writable(["modulationFrequency","frequency","detune"]),this.frequency=null,this.detune=null,this.modulationFrequency=null,this},t.PWMOscillator}),t(function(t){return t.FMOscillator=function(){var e=this.optionsObject(arguments,["frequency","type","modulationType"],t.FMOscillator.defaults);t.Source.call(this,e),this._carrier=new t.Oscillator(e.frequency,e.type),this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=this._carrier.detune,this.detune.value=e.detune,this.modulationIndex=new t.Multiply(e.modulationIndex),this.modulationIndex.units=t.Type.Positive,this._modulator=new t.Oscillator(e.frequency,e.modulationType),this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this._modulationNode=new t.Gain(0),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),this.phase=e.phase,this._readOnly(["modulationIndex","frequency","detune","harmonicity"])},t.extend(t.FMOscillator,t.Oscillator),t.FMOscillator.defaults={frequency:440,detune:0,phase:0,modulationIndex:2,modulationType:"square",harmonicity:1},t.FMOscillator.prototype._start=function(t){t=this.toSeconds(t),this._modulator.start(t),this._carrier.start(t)},t.FMOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._modulator.stop(t),this._carrier.stop(t)},Object.defineProperty(t.FMOscillator.prototype,"type",{get:function(){return this._carrier.type},set:function(t){this._carrier.type=t}}),Object.defineProperty(t.FMOscillator.prototype,"modulationType",{get:function(){return this._modulator.type},set:function(t){this._modulator.type=t}}),Object.defineProperty(t.FMOscillator.prototype,"phase",{get:function(){return this._carrier.phase},set:function(t){this._carrier.phase=t,this._modulator.phase=t}}),Object.defineProperty(t.FMOscillator.prototype,"partials",{get:function(){return this._carrier.partials},set:function(t){this._carrier.partials=t}}),t.FMOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._writable(["modulationIndex","frequency","detune","harmonicity"]),this.frequency.dispose(),this.frequency=null,this.detune=null,this.harmonicity.dispose(),this.harmonicity=null,this._carrier.dispose(),this._carrier=null,this._modulator.dispose(),this._modulator=null,this._modulationNode.dispose(),this._modulationNode=null,this.modulationIndex.dispose(),this.modulationIndex=null,this},t.FMOscillator}),t(function(t){return t.AMOscillator=function(){var e=this.optionsObject(arguments,["frequency","type","modulationType"],t.AMOscillator.defaults);t.Source.call(this,e),this._carrier=new t.Oscillator(e.frequency,e.type),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this.detune.value=e.detune,this._modulator=new t.Oscillator(e.frequency,e.modulationType),this._modulationScale=new t.AudioToGain,this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this._modulationNode=new t.Gain(0),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.detune.connect(this._modulator.detune),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),this.phase=e.phase,this._readOnly(["frequency","detune","harmonicity"])},t.extend(t.AMOscillator,t.Oscillator),t.AMOscillator.defaults={frequency:440,detune:0,phase:0,modulationType:"square",harmonicity:1},t.AMOscillator.prototype._start=function(t){t=this.toSeconds(t),this._modulator.start(t),this._carrier.start(t)},t.AMOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._modulator.stop(t),this._carrier.stop(t)},Object.defineProperty(t.AMOscillator.prototype,"type",{get:function(){return this._carrier.type},set:function(t){this._carrier.type=t}}),Object.defineProperty(t.AMOscillator.prototype,"modulationType",{get:function(){return this._modulator.type},set:function(t){this._modulator.type=t}}),Object.defineProperty(t.AMOscillator.prototype,"phase",{get:function(){return this._carrier.phase},set:function(t){this._carrier.phase=t,this._modulator.phase=t}}),Object.defineProperty(t.AMOscillator.prototype,"partials",{get:function(){return this._carrier.partials},set:function(t){this._carrier.partials=t}}),t.AMOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._writable(["frequency","detune","harmonicity"]),this.frequency=null,this.detune=null,this.harmonicity.dispose(),this.harmonicity=null,this._carrier.dispose(),this._carrier=null,this._modulator.dispose(),this._modulator=null,this._modulationNode.dispose(),this._modulationNode=null,this._modulationScale.dispose(),this._modulationScale=null,this},t.AMOscillator}),t(function(t){return t.FatOscillator=function(){var e=this.optionsObject(arguments,["frequency","type","spread"],t.FatOscillator.defaults);t.Source.call(this,e),this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this._oscillators=[],this._spread=e.spread,this._type=e.type,this._phase=e.phase,this._partials=this.defaultArg(e.partials,[]),this.count=e.count,this._readOnly(["frequency","detune"])},t.extend(t.FatOscillator,t.Oscillator),t.FatOscillator.defaults={frequency:440,detune:0,phase:0,spread:20,count:3,type:"sawtooth"},t.FatOscillator.prototype._start=function(t){t=this.toSeconds(t),this._forEach(function(e){e.start(t)})},t.FatOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._forEach(function(e){e.stop(t)})},t.FatOscillator.prototype._forEach=function(t){for(var e=0;e<this._oscillators.length;e++)t.call(this,this._oscillators[e],e)},Object.defineProperty(t.FatOscillator.prototype,"type",{get:function(){return this._type},set:function(t){this._type=t,this._forEach(function(e){e.type=t})}}),Object.defineProperty(t.FatOscillator.prototype,"spread",{get:function(){return this._spread},set:function(t){if(this._spread=t,this._oscillators.length>1){var e=-t/2,i=t/(this._oscillators.length-1);this._forEach(function(t,s){t.detune.value=e+i*s})}}}),Object.defineProperty(t.FatOscillator.prototype,"count",{get:function(){return this._oscillators.length},set:function(e){if(e=Math.max(e,1),this._oscillators.length!==e){this._forEach(function(t){t.dispose()}),this._oscillators=[];for(var i=0;i<e;i++){var s=new t.Oscillator;this.type===t.Oscillator.Type.Custom?s.partials=this._partials:s.type=this._type,s.phase=this._phase,s.volume.value=-6-e,this.frequency.connect(s.frequency),this.detune.connect(s.detune),s.connect(this.output),this._oscillators[i]=s}this.spread=this._spread,this.state===t.State.Started&&this._forEach(function(t){t.start()})}}}),Object.defineProperty(t.FatOscillator.prototype,"phase",{get:function(){return this._phase},set:function(t){this._phase=t,this._forEach(function(e){e.phase=t})}}),Object.defineProperty(t.FatOscillator.prototype,"partials",{get:function(){return this._partials},set:function(e){this._partials=e,this._type=t.Oscillator.Type.Custom,this._forEach(function(t){t.partials=e})}}),t.FatOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._writable(["frequency","detune"]),this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this._forEach(function(t){t.dispose()}),this._oscillators=null,this._partials=null,this},t.FatOscillator}),t(function(t){t.OmniOscillator=function(){var e=this.optionsObject(arguments,["frequency","type"],t.OmniOscillator.defaults);t.Source.call(this,e),this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this._sourceType=void 0,this._oscillator=null,this.type=e.type,this._readOnly(["frequency","detune"]),this.set(e)},t.extend(t.OmniOscillator,t.Oscillator),t.OmniOscillator.defaults={frequency:440,detune:0,type:"sine",phase:0};var e={Pulse:"PulseOscillator",PWM:"PWMOscillator",Osc:"Oscillator",FM:"FMOscillator",AM:"AMOscillator",Fat:"FatOscillator"};return t.OmniOscillator.prototype._start=function(t){this._oscillator.start(t)},t.OmniOscillator.prototype._stop=function(t){this._oscillator.stop(t)},Object.defineProperty(t.OmniOscillator.prototype,"type",{get:function(){var t="";return this._sourceType===e.FM?t="fm":this._sourceType===e.AM?t="am":this._sourceType===e.Fat&&(t="fat"),t+this._oscillator.type},set:function(t){"fm"===t.substr(0,2)?(this._createNewOscillator(e.FM),this._oscillator.type=t.substr(2)):"am"===t.substr(0,2)?(this._createNewOscillator(e.AM),this._oscillator.type=t.substr(2)):"fat"===t.substr(0,3)?(this._createNewOscillator(e.Fat),this._oscillator.type=t.substr(3)):"pwm"===t?this._createNewOscillator(e.PWM):"pulse"===t?this._createNewOscillator(e.Pulse):(this._createNewOscillator(e.Osc),this._oscillator.type=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"partials",{get:function(){return this._oscillator.partials},set:function(t){this._oscillator.partials=t}}),t.OmniOscillator.prototype.set=function(e,i){return"type"===e?this.type=i:this.isObject(e)&&e.hasOwnProperty("type")&&(this.type=e.type),t.prototype.set.apply(this,arguments),this},t.OmniOscillator.prototype._createNewOscillator=function(e){if(e!==this._sourceType){this._sourceType=e;var i=t[e],s=this.now()+this.blockTime;if(null!==this._oscillator){var n=this._oscillator;n.stop(s),setTimeout(function(){n.dispose(),n=null},1e3*this.blockTime)}this._oscillator=new i,this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this.state===t.State.Started&&this._oscillator.start(s)}},Object.defineProperty(t.OmniOscillator.prototype,"phase",{get:function(){return this._oscillator.phase},set:function(t){this._oscillator.phase=t}}),Object.defineProperty(t.OmniOscillator.prototype,"width",{get:function(){if(this._sourceType===e.Pulse)return this._oscillator.width}}),Object.defineProperty(t.OmniOscillator.prototype,"count",{get:function(){if(this._sourceType===e.Fat)return this._oscillator.count},set:function(t){this._sourceType===e.Fat&&(this._oscillator.count=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"spread",{get:function(){if(this._sourceType===e.Fat)return this._oscillator.spread},set:function(t){this._sourceType===e.Fat&&(this._oscillator.spread=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"modulationType",{get:function(){if(this._sourceType===e.FM||this._sourceType===e.AM)return this._oscillator.modulationType},set:function(t){this._sourceType!==e.FM&&this._sourceType!==e.AM||(this._oscillator.modulationType=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"modulationIndex",{get:function(){if(this._sourceType===e.FM)return this._oscillator.modulationIndex}}),Object.defineProperty(t.OmniOscillator.prototype,"harmonicity",{get:function(){if(this._sourceType===e.FM||this._sourceType===e.AM)return this._oscillator.harmonicity}}),Object.defineProperty(t.OmniOscillator.prototype,"modulationFrequency",{get:function(){if(this._sourceType===e.PWM)return this._oscillator.modulationFrequency}}),t.OmniOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._writable(["frequency","detune"]),this.detune.dispose(),this.detune=null,this.frequency.dispose(),this.frequency=null,this._oscillator.dispose(),this._oscillator=null,this._sourceType=null,this},t.OmniOscillator}),t(function(t){return t.Instrument=function(e){e=this.defaultArg(e,t.Instrument.defaults),this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._readOnly("volume")},t.extend(t.Instrument),t.Instrument.defaults={volume:0},t.Instrument.prototype.triggerAttack=t.noOp,t.Instrument.prototype.triggerRelease=t.noOp,t.Instrument.prototype.triggerAttackRelease=function(t,e,i,s){return i=this.isUndef(i)?this.now()+this.blockTime:this.toSeconds(i),e=this.toSeconds(e),this.triggerAttack(t,i,s),this.triggerRelease(i+e),this},t.Instrument.prototype.dispose=function(){return t.prototype.dispose.call(this),this._volume.dispose(),this._volume=null,this._writable(["volume"]),this.volume=null,this},t.Instrument}),t(function(t){return t.Monophonic=function(e){e=this.defaultArg(e,t.Monophonic.defaults),t.Instrument.call(this,e),this.portamento=e.portamento},t.extend(t.Monophonic,t.Instrument),t.Monophonic.defaults={portamento:0},t.Monophonic.prototype.triggerAttack=function(t,e,i){return e=this.isUndef(e)?this.now()+this.blockTime:this.toSeconds(e),this._triggerEnvelopeAttack(e,i),this.setNote(t,e),this},t.Monophonic.prototype.triggerRelease=function(t){return t=this.isUndef(t)?this.now()+this.blockTime:this.toSeconds(t),this._triggerEnvelopeRelease(t),this},t.Monophonic.prototype._triggerEnvelopeAttack=function(){},t.Monophonic.prototype._triggerEnvelopeRelease=function(){},t.Monophonic.prototype.setNote=function(t,e){if(e=this.toSeconds(e),this.portamento>0){var i=this.frequency.value;this.frequency.setValueAtTime(i,e);var s=this.toSeconds(this.portamento);this.frequency.exponentialRampToValueAtTime(t,e+s)}else this.frequency.setValueAtTime(t,e);return this},t.Monophonic}),t(function(t){return t.Synth=function(e){e=this.defaultArg(e,t.Synth.defaults),t.Monophonic.call(this,e),this.oscillator=new t.OmniOscillator(e.oscillator),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new t.AmplitudeEnvelope(e.envelope),this.oscillator.chain(this.envelope,this.output),this.oscillator.start(),this._readOnly(["oscillator","frequency","detune","envelope"])},t.extend(t.Synth,t.Monophonic),t.Synth.defaults={oscillator:{type:"triangle"},envelope:{attack:.005,decay:.1,sustain:.3,release:1}},t.Synth.prototype._triggerEnvelopeAttack=function(t,e){return this.envelope.triggerAttack(t,e),this},t.Synth.prototype._triggerEnvelopeRelease=function(t){return this.envelope.triggerRelease(t),this},t.Synth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable(["oscillator","frequency","detune","envelope"]),this.oscillator.dispose(),this.oscillator=null,this.envelope.dispose(),this.envelope=null,this.frequency=null,this.detune=null,this},t.Synth}),t(function(t){return t.AMSynth=function(e){e=this.defaultArg(e,t.AMSynth.defaults),t.Monophonic.call(this,e),this._carrier=new t.Synth,this._carrier.volume.value=-10,this.oscillator=this._carrier.oscillator,this.envelope=this._carrier.envelope.set(e.envelope),this._modulator=new t.Synth,this._modulator.volume.value=-10,this.modulation=this._modulator.oscillator.set(e.modulation),this.modulationEnvelope=this._modulator.envelope.set(e.modulationEnvelope),this.frequency=new t.Signal(440,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this._modulationScale=new t.AudioToGain,this._modulationNode=new t.Gain,this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),this._readOnly(["frequency","harmonicity","oscillator","envelope","modulation","modulationEnvelope","detune"])},t.extend(t.AMSynth,t.Monophonic),t.AMSynth.defaults={harmonicity:3,detune:0,oscillator:{type:"sine"},envelope:{attack:.01,decay:.01,sustain:1,release:.5},modulation:{type:"square"},modulationEnvelope:{attack:.5,decay:0,sustain:1,release:.5}},t.AMSynth.prototype._triggerEnvelopeAttack=function(t,e){return t=this.toSeconds(t),this.envelope.triggerAttack(t,e),this.modulationEnvelope.triggerAttack(t,e),this},t.AMSynth.prototype._triggerEnvelopeRelease=function(t){return this.envelope.triggerRelease(t),this.modulationEnvelope.triggerRelease(t),this},t.AMSynth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable(["frequency","harmonicity","oscillator","envelope","modulation","modulationEnvelope","detune"]),this._carrier.dispose(),this._carrier=null,this._modulator.dispose(),this._modulator=null,this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this.harmonicity.dispose(),this.harmonicity=null,this._modulationScale.dispose(),this._modulationScale=null,this._modulationNode.dispose(),this._modulationNode=null,this.oscillator=null,this.envelope=null,this.modulationEnvelope=null,this.modulation=null,this},t.AMSynth}),t(function(t){return t.MonoSynth=function(e){e=this.defaultArg(e,t.MonoSynth.defaults),t.Monophonic.call(this,e),this.oscillator=new t.OmniOscillator(e.oscillator),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new t.Filter(e.filter),this.filterEnvelope=new t.FrequencyEnvelope(e.filterEnvelope),this.envelope=new t.AmplitudeEnvelope(e.envelope),this.oscillator.chain(this.filter,this.envelope,this.output),this.oscillator.start(),this.filterEnvelope.connect(this.filter.frequency),this._readOnly(["oscillator","frequency","detune","filter","filterEnvelope","envelope"])},t.extend(t.MonoSynth,t.Monophonic),t.MonoSynth.defaults={frequency:"C4",detune:0,oscillator:{type:"square"},filter:{Q:6,type:"lowpass",rolloff:-24},envelope:{attack:.005,decay:.1,sustain:.9,release:1},filterEnvelope:{attack:.06,decay:.2,sustain:.5,release:2,baseFrequency:200,octaves:7,exponent:2}},t.MonoSynth.prototype._triggerEnvelopeAttack=function(t,e){return this.envelope.triggerAttack(t,e),this.filterEnvelope.triggerAttack(t),this},t.MonoSynth.prototype._triggerEnvelopeRelease=function(t){return this.envelope.triggerRelease(t),this.filterEnvelope.triggerRelease(t),this},t.MonoSynth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable(["oscillator","frequency","detune","filter","filterEnvelope","envelope"]),this.oscillator.dispose(),this.oscillator=null,this.envelope.dispose(),this.envelope=null,this.filterEnvelope.dispose(),this.filterEnvelope=null,this.filter.dispose(),this.filter=null,this.frequency=null,this.detune=null,this},t.MonoSynth}),t(function(t){return t.DuoSynth=function(e){e=this.defaultArg(e,t.DuoSynth.defaults),t.Monophonic.call(this,e),this.voice0=new t.MonoSynth(e.voice0),this.voice0.volume.value=-10,this.voice1=new t.MonoSynth(e.voice1),this.voice1.volume.value=-10,this._vibrato=new t.LFO(e.vibratoRate,-50,50),this._vibrato.start(),this.vibratoRate=this._vibrato.frequency,this._vibratoGain=new t.Gain(e.vibratoAmount,t.Type.Positive),this.vibratoAmount=this._vibratoGain.gain,this.frequency=new t.Signal(440,t.Type.Frequency),this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this.frequency.connect(this.voice0.frequency),this.frequency.chain(this.harmonicity,this.voice1.frequency),this._vibrato.connect(this._vibratoGain),this._vibratoGain.fan(this.voice0.detune,this.voice1.detune),this.voice0.connect(this.output),this.voice1.connect(this.output),this._readOnly(["voice0","voice1","frequency","vibratoAmount","vibratoRate"])},t.extend(t.DuoSynth,t.Monophonic),t.DuoSynth.defaults={vibratoAmount:.5,vibratoRate:5,harmonicity:1.5,voice0:{volume:-10,portamento:0,oscillator:{type:"sine"},filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}},voice1:{volume:-10,portamento:0,oscillator:{type:"sine"},filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}},t.DuoSynth.prototype._triggerEnvelopeAttack=function(t,e){return t=this.toSeconds(t),this.voice0.envelope.triggerAttack(t,e),this.voice1.envelope.triggerAttack(t,e),this.voice0.filterEnvelope.triggerAttack(t),this.voice1.filterEnvelope.triggerAttack(t),this},t.DuoSynth.prototype._triggerEnvelopeRelease=function(t){return this.voice0.triggerRelease(t),this.voice1.triggerRelease(t),this},t.DuoSynth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable(["voice0","voice1","frequency","vibratoAmount","vibratoRate"]),this.voice0.dispose(),this.voice0=null,this.voice1.dispose(),this.voice1=null,this.frequency.dispose(),this.frequency=null,this._vibratoGain.dispose(),this._vibratoGain=null,this._vibrato=null,this.harmonicity.dispose(),this.harmonicity=null,this.vibratoAmount.dispose(),this.vibratoAmount=null,this.vibratoRate=null,this},t.DuoSynth}),t(function(t){return t.FMSynth=function(e){e=this.defaultArg(e,t.FMSynth.defaults),t.Monophonic.call(this,e),this._carrier=new t.Synth(e.carrier),this._carrier.volume.value=-10,this.oscillator=this._carrier.oscillator,this.envelope=this._carrier.envelope.set(e.envelope),this._modulator=new t.Synth(e.modulator),this._modulator.volume.value=-10,this.modulation=this._modulator.oscillator.set(e.modulation),this.modulationEnvelope=this._modulator.envelope.set(e.modulationEnvelope),this.frequency=new t.Signal(440,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this.modulationIndex=new t.Multiply(e.modulationIndex),this.modulationIndex.units=t.Type.Positive,this._modulationNode=new t.Gain(0),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this._readOnly(["frequency","harmonicity","modulationIndex","oscillator","envelope","modulation","modulationEnvelope","detune"])},t.extend(t.FMSynth,t.Monophonic),t.FMSynth.defaults={harmonicity:3,modulationIndex:10,detune:0,oscillator:{type:"sine"},envelope:{attack:.01,decay:.01,sustain:1,release:.5},modulation:{type:"square"},modulationEnvelope:{attack:.5,decay:0,sustain:1,release:.5}},t.FMSynth.prototype._triggerEnvelopeAttack=function(t,e){return t=this.toSeconds(t),this.envelope.triggerAttack(t,e),this.modulationEnvelope.triggerAttack(t),this},t.FMSynth.prototype._triggerEnvelopeRelease=function(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this.modulationEnvelope.triggerRelease(t),this},t.FMSynth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable(["frequency","harmonicity","modulationIndex","oscillator","envelope","modulation","modulationEnvelope","detune"]),this._carrier.dispose(),this._carrier=null,this._modulator.dispose(),this._modulator=null,this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this.modulationIndex.dispose(),this.modulationIndex=null,this.harmonicity.dispose(),this.harmonicity=null,this._modulationNode.dispose(),this._modulationNode=null,this.oscillator=null,this.envelope=null,this.modulationEnvelope=null,this.modulation=null,this},t.FMSynth}),t(function(t){return t.MembraneSynth=function(e){e=this.defaultArg(e,t.MembraneSynth.defaults),t.Instrument.call(this,e),this.oscillator=new t.OmniOscillator(e.oscillator).start(),this.envelope=new t.AmplitudeEnvelope(e.envelope),this.octaves=e.octaves,this.pitchDecay=e.pitchDecay,this.oscillator.chain(this.envelope,this.output),this._readOnly(["oscillator","envelope"])},t.extend(t.MembraneSynth,t.Instrument),t.MembraneSynth.defaults={pitchDecay:.05,octaves:10,oscillator:{type:"sine"},envelope:{attack:.001,decay:.4,sustain:.01,release:1.4,attackCurve:"exponential"}},t.MembraneSynth.prototype.triggerAttack=function(t,e,i){e=this.toSeconds(e),t=this.toFrequency(t);var s=t*this.octaves;return this.oscillator.frequency.setValueAtTime(s,e),this.oscillator.frequency.exponentialRampToValueAtTime(t,e+this.toSeconds(this.pitchDecay)),this.envelope.triggerAttack(e,i),this},t.MembraneSynth.prototype.triggerRelease=function(t){return this.envelope.triggerRelease(t),this},t.MembraneSynth.prototype.dispose=function(){return t.Instrument.prototype.dispose.call(this),this._writable(["oscillator","envelope"]),this.oscillator.dispose(),this.oscillator=null,this.envelope.dispose(),this.envelope=null,this},t.MembraneSynth}),t(function(t){var e=[1,1.483,1.932,2.546,2.63,3.897];return t.MetalSynth=function(i){i=this.defaultArg(i,t.MetalSynth.defaults),t.Instrument.call(this,i),this.frequency=new t.Signal(i.frequency,t.Type.Frequency),this._oscillators=[],this._freqMultipliers=[],this._amplitue=new t.Gain(0).connect(this.output),this._highpass=new t.Filter({type:"highpass",Q:-3.0102999566398125}).connect(this._amplitue),this._octaves=i.octaves,this._filterFreqScaler=new t.Scale(i.resonance,7e3),this.envelope=new t.Envelope({attack:i.envelope.attack,attackCurve:"linear",decay:i.envelope.decay,sustain:0,release:i.envelope.release}).chain(this._filterFreqScaler,this._highpass.frequency),this.envelope.connect(this._amplitue.gain);for(var s=0;s<e.length;s++){var n=new t.FMOscillator({type:"square",modulationType:"square",harmonicity:i.harmonicity,modulationIndex:i.modulationIndex});n.connect(this._highpass).start(0),this._oscillators[s]=n;var o=new t.Multiply(e[s]);this._freqMultipliers[s]=o,this.frequency.chain(o,n.frequency)}this.octaves=i.octaves},t.extend(t.MetalSynth,t.Instrument),t.MetalSynth.defaults={frequency:200,envelope:{attack:.001,decay:1.4,release:.2},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1.5},t.MetalSynth.prototype.triggerAttack=function(t,e){return t=this.toSeconds(t),e=this.defaultArg(e,1),this.envelope.triggerAttack(t,e),this},t.MetalSynth.prototype.triggerRelease=function(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this},t.MetalSynth.prototype.triggerAttackRelease=function(t,e,i){return e=this.toSeconds(e),t=this.toSeconds(t),this.triggerAttack(e,i),this.triggerRelease(e+t),this},Object.defineProperty(t.MetalSynth.prototype,"modulationIndex",{get:function(){return this._oscillators[0].modulationIndex.value},set:function(t){for(var e=0;e<this._oscillators.length;e++)this._oscillators[e].modulationIndex.value=t}}),Object.defineProperty(t.MetalSynth.prototype,"harmonicity",{get:function(){return this._oscillators[0].harmonicity.value},set:function(t){for(var e=0;e<this._oscillators.length;e++)this._oscillators[e].harmonicity.value=t}}),Object.defineProperty(t.MetalSynth.prototype,"resonance",{get:function(){return this._filterFreqScaler.min},set:function(t){this._filterFreqScaler.min=t,this.octaves=this._octaves}}),Object.defineProperty(t.MetalSynth.prototype,"octaves",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._filterFreqScaler.max=this._filterFreqScaler.min*Math.pow(2,t)}}),t.MetalSynth.prototype.dispose=function(){t.Instrument.prototype.dispose.call(this);for(var e=0;e<this._oscillators.length;e++)this._oscillators[e].dispose(),this._freqMultipliers[e].dispose();this._oscillators=null,this._freqMultipliers=null,this.frequency.dispose(),this.frequency=null,this._filterFreqScaler.dispose(),this._filterFreqScaler=null,this._amplitue.dispose(),this._amplitue=null,this.envelope.dispose(),this.envelope=null,this._highpass.dispose(),this._highpass=null},t.MetalSynth}),t(function(t){return window.AudioBufferSourceNode&&!AudioBufferSourceNode.prototype.start&&(AudioBufferSourceNode.prototype.start=AudioBufferSourceNode.prototype.noteGrainOn,AudioBufferSourceNode.prototype.stop=AudioBufferSourceNode.prototype.noteOff),t.BufferSource=function(){var e=this.optionsObject(arguments,["buffer","onended"],t.BufferSource.defaults);this.onended=e.onended,this._startTime=-1,this._stopTime=-1,this._gainNode=this.output=new t.Gain,this._source=this.context.createBufferSource(),this._source.connect(this._gainNode),this.playbackRate=new t.Param(this._source.playbackRate,t.Type.Positive),this.fadeIn=e.fadeIn,this.fadeOut=e.fadeOut,this._gain=1,this._onendedTimeout=-1,this.isUndef(e.buffer)||(this.buffer=e.buffer),this.loop=e.loop},t.extend(t.BufferSource),t.BufferSource.defaults={onended:t.noOp,fadeIn:0,fadeOut:0},Object.defineProperty(t.BufferSource.prototype,"state",{get:function(){var e=this.now();return-1!==this._startTime&&e>=this._startTime&&e<this._stopTime?t.State.Started:t.State.Stopped}}),t.BufferSource.prototype.start=function(t,e,i,s,n){if(-1!==this._startTime)throw new Error("Tone.BufferSource: can only be started once.");return this.buffer&&(t=this.toSeconds(t),e=this.loop?this.defaultArg(e,this.loopStart):this.defaultArg(e,0),e=this.toSeconds(e),t=this.toSeconds(t),this._source.start(t,e),s=this.defaultArg(s,1),this._gain=s,n=this.isUndef(n)?this.toSeconds(this.fadeIn):this.toSeconds(n),n>0?(this._gainNode.gain.setValueAtTime(0,t),this._gainNode.gain.linearRampToValueAtTime(this._gain,t+n)):this._gainNode.gain.setValueAtTime(s,t),this._startTime=t+n,this.isUndef(i)||(i=this.defaultArg(i,this.buffer.duration-e),i=this.toSeconds(i),this.stop(t+i+n,n))),this},t.BufferSource.prototype.stop=function(t,e){return this.buffer&&(t=this.toSeconds(t),e=this.isUndef(e)?this.toSeconds(this.fadeOut):this.toSeconds(e),this._stopTime=t+e,this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),e>0?(this._gainNode.gain.setValueAtTime(this._gain,t),this._gainNode.gain.linearRampToValueAtTime(0,t+e),t+=e):this._gainNode.gain.setValueAtTime(0,t),this.isNumber(this._source.playbackState)&&2!==this._source.playbackState||this._source.stop(t),clearTimeout(this._onendedTimeout),this._onendedTimeout=setTimeout(this._onended.bind(this),1e3*(this._stopTime-this.now()))),this},t.BufferSource.prototype._onended=function(){this.onended(this),this.dispose()},Object.defineProperty(t.BufferSource.prototype,"loopStart",{get:function(){return this._source.loopStart},set:function(t){this._source.loopStart=this.toSeconds(t)}}),Object.defineProperty(t.BufferSource.prototype,"loopEnd",{get:function(){return this._source.loopEnd},set:function(t){this._source.loopEnd=this.toSeconds(t)}}),Object.defineProperty(t.BufferSource.prototype,"buffer",{get:function(){return this._source?this._source.buffer:null},set:function(e){e instanceof t.Buffer?this._source.buffer=e.get():this._source.buffer=e}}),Object.defineProperty(t.BufferSource.prototype,"loop",{get:function(){return this._source.loop},set:function(t){this._source.loop=t}}),t.BufferSource.prototype.dispose=function(){return this.onended=null,this._source&&(this._source.disconnect(),this._source=null),this._gainNode&&(this._gainNode.dispose(),this._gainNode=null),this._startTime=-1,this.playbackRate=null,this.output=null,clearTimeout(this._onendedTimeout),this},t.BufferSource}),t(function(t){function e(){for(var e in i)s[e]=(new t.Buffer).fromArray(i[e])}t.Noise=function(){var e=this.optionsObject(arguments,["type"],t.Noise.defaults);t.Source.call(this,e),this._source=null,this._type=e.type,this._playbackRate=e.playbackRate},t.extend(t.Noise,t.Source),t.Noise.defaults={type:"white",playbackRate:1},Object.defineProperty(t.Noise.prototype,"type",{get:function(){return this._type},set:function(e){if(this._type!==e){if(!(e in s))throw new TypeError("Tone.Noise: invalid type: "+e);if(this._type=e,this.state===t.State.Started){var i=this.now()+this.blockTime;this._stop(i),this._start(i)}}}}),Object.defineProperty(t.Noise.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}}),t.Noise.prototype._start=function(e){var i=s[this._type];this._source=new t.BufferSource(i).connect(this.output),this._source.loop=!0,this._source.playbackRate.value=this._playbackRate,this._source.start(this.toSeconds(e),Math.random()*(i.duration-.001))},t.Noise.prototype._stop=function(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)},t.Noise.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),null!==this._source&&(this._source.disconnect(),this._source=null),this._buffer=null,this};var i={pink:function(){for(var t=[],e=0;e<2;e++){var i=new Float32Array(220500);t[e]=i;var s,n,o,r,a,h,l;s=n=o=r=a=h=l=0;for(var c=0;c<220500;c++){var u=2*Math.random()-1;s=.99886*s+.0555179*u,n=.99332*n+.0750759*u,o=.969*o+.153852*u,r=.8665*r+.3104856*u,a=.55*a+.5329522*u,h=-.7616*h-.016898*u,i[c]=s+n+o+r+a+h+l+.5362*u,i[c]*=.11,l=.115926*u}}return t}(),brown:function(){for(var t=[],e=0;e<2;e++){var i=new Float32Array(220500);t[e]=i;for(var s=0,n=0;n<220500;n++){var o=2*Math.random()-1;i[n]=(s+.02*o)/1.02,s=i[n],i[n]*=3.5}}return t}(),white:function(){for(var t=[],e=0;e<2;e++){var i=new Float32Array(220500);t[e]=i;for(var s=0;s<220500;s++)i[s]=2*Math.random()-1}return t}()},s={};return e(),t.Context.on("init",e),t.Noise}),t(function(t){return t.NoiseSynth=function(e){e=this.defaultArg(e,t.NoiseSynth.defaults),t.Instrument.call(this,e),this.noise=new t.Noise,this.envelope=new t.AmplitudeEnvelope(e.envelope),this.noise.chain(this.envelope,this.output),this.noise.start(),this._readOnly(["noise","envelope"])},t.extend(t.NoiseSynth,t.Instrument),t.NoiseSynth.defaults={noise:{type:"white"},envelope:{attack:.005,decay:.1,sustain:0}},t.NoiseSynth.prototype.triggerAttack=function(t,e){return this.envelope.triggerAttack(t,e),this},t.NoiseSynth.prototype.triggerRelease=function(t){return this.envelope.triggerRelease(t),this},t.NoiseSynth.prototype.triggerAttackRelease=function(t,e,i){return e=this.toSeconds(e),t=this.toSeconds(t),this.triggerAttack(e,i),this.triggerRelease(e+t),this},t.NoiseSynth.prototype.dispose=function(){return t.Instrument.prototype.dispose.call(this),this._writable(["noise","envelope"]),this.noise.dispose(),this.noise=null,this.envelope.dispose(),this.envelope=null,this},t.NoiseSynth}),t(function(t){return t.PluckSynth=function(e){e=this.defaultArg(e,t.PluckSynth.defaults),t.Instrument.call(this,e),this._noise=new t.Noise("pink"),this.attackNoise=e.attackNoise,this._lfcf=new t.LowpassCombFilter({resonance:e.resonance,dampening:e.dampening}),this.resonance=this._lfcf.resonance,this.dampening=this._lfcf.dampening,this._noise.connect(this._lfcf),this._lfcf.connect(this.output),this._readOnly(["resonance","dampening"])},t.extend(t.PluckSynth,t.Instrument),t.PluckSynth.defaults={attackNoise:1,dampening:4e3,resonance:.9},t.PluckSynth.prototype.triggerAttack=function(t,e){t=this.toFrequency(t),e=this.toSeconds(e);var i=1/t;return this._lfcf.delayTime.setValueAtTime(i,e),this._noise.start(e),this._noise.stop(e+i*this.attackNoise),this},t.PluckSynth.prototype.dispose=function(){return t.Instrument.prototype.dispose.call(this),this._noise.dispose(),this._lfcf.dispose(),this._noise=null,this._lfcf=null,this._writable(["resonance","dampening"]),this.dampening=null,this.resonance=null,this},t.PluckSynth}),t(function(t){return t.PolySynth=function(){t.Instrument.call(this);var e=this.optionsObject(arguments,["polyphony","voice"],t.PolySynth.defaults);e=this.defaultArg(e,t.Instrument.defaults),e.polyphony=Math.min(t.PolySynth.MAX_POLYPHONY,e.polyphony),this.voices=new Array(e.polyphony),this._triggers=new Array(e.polyphony),this.detune=new t.Signal(e.detune,t.Type.Cents),this._readOnly("detune");for(var i=0;i<e.polyphony;i++){var s=new e.voice(arguments[2],arguments[3]);this.voices[i]=s,s.connect(this.output),s.hasOwnProperty("detune")&&this.detune.connect(s.detune),this._triggers[i]={release:-1,note:null,voice:s}}this.volume.value=e.volume},t.extend(t.PolySynth,t.Instrument),t.PolySynth.defaults={polyphony:4,volume:0,detune:0,voice:t.Synth},t.PolySynth.prototype.triggerAttack=function(t,e,i){Array.isArray(t)||(t=[t]),e=this.toSeconds(e);for(var s=0;s<t.length;s++){for(var n=t[s],o=this._triggers[0],r=1;r<this._triggers.length;r++)this._triggers[r].release<o.release&&(o=this._triggers[r],r);o.release=1/0,o.note=JSON.stringify(n),o.voice.triggerAttack(n,e,i)}return this},t.PolySynth.prototype.triggerAttackRelease=function(t,e,i,s){if(i=this.toSeconds(i),this.triggerAttack(t,i,s),this.isArray(e)&&this.isArray(t))for(var n=0;n<t.length;n++){var o=e[Math.min(n,e.length-1)];this.triggerRelease(t[n],i+this.toSeconds(o))}else this.triggerRelease(t,i+this.toSeconds(e));return this},t.PolySynth.prototype.triggerRelease=function(t,e){Array.isArray(t)||(t=[t]),e=this.toSeconds(e);for(var i=0;i<t.length;i++)for(var s=JSON.stringify(t[i]),n=0;n<this._triggers.length;n++){var o=this._triggers[n];o.note===s&&o.release>e&&(o.voice.triggerRelease(e),o.release=e)}return this},t.PolySynth.prototype.set=function(t,e,i){for(var s=0;s<this.voices.length;s++)this.voices[s].set(t,e,i);return this},t.PolySynth.prototype.get=function(t){return this.voices[0].get(t)},t.PolySynth.prototype.releaseAll=function(t){t=this.toSeconds(t);for(var e=0;e<this._triggers.length;e++){var i=this._triggers[e];i.release>t&&(i.release=t,i.voice.triggerRelease(t))}return this},t.PolySynth.prototype.dispose=function(){t.Instrument.prototype.dispose.call(this);for(var e=0;e<this.voices.length;e++)this.voices[e].dispose(),this.voices[e]=null;return this._writable("detune"),this.detune.dispose(),this.detune=null,this.voices=null,this._triggers=null,this},t.PolySynth.MAX_POLYPHONY=20,t.PolySynth}),t(function(t){return t.Player=function(e){var i;e instanceof t.Buffer?(e=e.get(),i=t.Player.defaults):i=this.optionsObject(arguments,["url","onload"],t.Player.defaults),t.Source.call(this,i),this._source=null,this.autostart=i.autostart,this._buffer=new t.Buffer({url:i.url,onload:this._onload.bind(this,i.onload),reverse:i.reverse}),e instanceof AudioBuffer&&this._buffer.set(e),this._loop=i.loop,this._loopStart=i.loopStart,this._loopEnd=i.loopEnd,this._playbackRate=i.playbackRate,this.retrigger=i.retrigger},t.extend(t.Player,t.Source),t.Player.defaults={onload:t.noOp,playbackRate:1,loop:!1,autostart:!1,loopStart:0,loopEnd:0,retrigger:!1,reverse:!1},t.Player.prototype.load=function(t,e){return this._buffer.load(t,this._onload.bind(this,e))},t.Player.prototype._onload=function(e){e=this.defaultArg(e,t.noOp),e(this),this.autostart&&this.start()},t.Player.prototype._start=function(e,i,s){if(!this._buffer.loaded)throw Error("Tone.Player: tried to start Player before the buffer was loaded");if(i=this._loop?this.defaultArg(i,this._loopStart):this.defaultArg(i,0),i=this.toSeconds(i),s=this.defaultArg(s,Math.max(this._buffer.duration-i,0)),s=this.toSeconds(s),e=this.toSeconds(e),this._source=this.context.createBufferSource(),this._source.buffer=this._buffer.get(),this._loop?(this._source.loop=this._loop,this._source.loopStart=this.toSeconds(this._loopStart),this._source.loopEnd=this.toSeconds(this._loopEnd)):this._synced||this._state.setStateAtTime(t.State.Stopped,e+s),this._source.playbackRate.value=this._playbackRate,this._source.connect(this.output),this._loop){var n=this._source.loopEnd||this._buffer.duration,o=this._source.loopStart,r=n-o;if(i>n)for(;i>n;)i-=r;this._source.start(e,i)}else this._source.start(e,i,s);return this},t.Player.prototype._stop=function(t){return this._source&&(this._source.stop(this.toSeconds(t)),this._source=null),this},t.Player.prototype.seek=function(e,i){return i=this.toSeconds(i),this._state.getValueAtTime(i)===t.State.Started&&(e=this.toSeconds(e),this._stop(i),this._start(i,e)),this},t.Player.prototype.setLoopPoints=function(t,e){return this.loopStart=t,this.loopEnd=e,this},Object.defineProperty(t.Player.prototype,"loopStart",{get:function(){return this._loopStart},set:function(t){this._loopStart=t,this._source&&(this._source.loopStart=this.toSeconds(t))}}),Object.defineProperty(t.Player.prototype,"loopEnd",{get:function(){return this._loopEnd},set:function(t){this._loopEnd=t,this._source&&(this._source.loopEnd=this.toSeconds(t))}}),Object.defineProperty(t.Player.prototype,"buffer",{get:function(){return this._buffer},set:function(t){this._buffer.set(t)}}),Object.defineProperty(t.Player.prototype,"loop",{get:function(){return this._loop},set:function(t){this._loop=t,this._source&&(this._source.loop=t)}}),Object.defineProperty(t.Player.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}}),Object.defineProperty(t.Player.prototype,"reverse",{get:function(){return this._buffer.reverse},set:function(t){this._buffer.reverse=t}}),t.Player.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),null!==this._source&&(this._source.disconnect(),this._source=null),this._buffer.dispose(),this._buffer=null,this},t.Player}),t(function(t){return t.Sampler=function(){var e=this.optionsObject(arguments,["url","onload"],t.Sampler.defaults);t.Instrument.call(this,e),this.player=new t.Player(e.url,e.onload),this.player.retrigger=!0,this.envelope=new t.AmplitudeEnvelope(e.envelope),this.player.chain(this.envelope,this.output),this._readOnly(["player","envelope"]),this.loop=e.loop,this.reverse=e.reverse},t.extend(t.Sampler,t.Instrument),t.Sampler.defaults={onload:t.noOp,loop:!1,reverse:!1,envelope:{attack:.001,decay:0,sustain:1,release:.1}},t.Sampler.prototype.triggerAttack=function(t,e,i){return e=this.toSeconds(e),t=this.defaultArg(t,0),this.player.playbackRate=this.intervalToFrequencyRatio(t),this.player.start(e),this.envelope.triggerAttack(e,i),this},t.Sampler.prototype.triggerRelease=function(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this.player.stop(this.toSeconds(this.envelope.release)+t),this},Object.defineProperty(t.Sampler.prototype,"loop",{get:function(){return this.player.loop},set:function(t){this.player.loop=t}}),Object.defineProperty(t.Sampler.prototype,"reverse",{get:function(){return this.player.reverse},set:function(t){this.player.reverse=t}}),Object.defineProperty(t.Sampler.prototype,"buffer",{get:function(){return this.player.buffer},set:function(t){this.player.buffer=t}}),t.Sampler.prototype.dispose=function(){return t.Instrument.prototype.dispose.call(this),this._writable(["player","envelope"]),this.player.dispose(),this.player=null,this.envelope.dispose(),this.envelope=null,this},t.Sampler}),t(function(t){return t.GainToAudio=function(){this._norm=this.input=this.output=new t.WaveShaper(function(t){return 2*Math.abs(t)-1})},t.extend(t.GainToAudio,t.SignalBase),t.GainToAudio.prototype.dispose=function(){return t.prototype.dispose.call(this),this._norm.dispose(),this._norm=null,this},t.GainToAudio}),t(function(t){return t.Normalize=function(e,i){this._inputMin=this.defaultArg(e,0),this._inputMax=this.defaultArg(i,1),this._sub=this.input=new t.Add(0),this._div=this.output=new t.Multiply(1),this._sub.connect(this._div),this._setRange()},t.extend(t.Normalize,t.SignalBase),Object.defineProperty(t.Normalize.prototype,"min",{get:function(){return this._inputMin},set:function(t){this._inputMin=t,this._setRange()}}),Object.defineProperty(t.Normalize.prototype,"max",{get:function(){return this._inputMax},set:function(t){this._inputMax=t,this._setRange()}}),t.Normalize.prototype._setRange=function(){this._sub.value=-this._inputMin,this._div.value=1/(this._inputMax-this._inputMin)},t.Normalize.prototype.dispose=function(){return t.prototype.dispose.call(this),this._sub.dispose(),this._sub=null,this._div.dispose(),this._div=null,this},t.Normalize}),t(function(t){return t.MultiPlayer=function(){var e=this.optionsObject(arguments,["urls","onload"],t.MultiPlayer.defaults);e.urls instanceof t.Buffers?this.buffers=e.urls:this.buffers=new t.Buffers(e.urls,e.onload),this._activeSources={},this.fadeIn=e.fadeIn,this.fadeOut=e.fadeOut,this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._readOnly("volume"),this._volume.output.output.channelCount=2,this._volume.output.output.channelCountMode="explicit",this.mute=e.mute},t.extend(t.MultiPlayer,t.Source),t.MultiPlayer.defaults={onload:t.noOp,fadeIn:0,fadeOut:0},t.MultiPlayer.prototype._makeSource=function(e){var i;this.isString(e)||this.isNumber(e)?i=this.buffers.get(e).get():e instanceof t.Buffer?i=e.get():e instanceof AudioBuffer&&(i=e);var s=new t.BufferSource(i).connect(this.output);return this._activeSources.hasOwnProperty(e)||(this._activeSources[e]=[]),this._activeSources[e].push(s),s},t.MultiPlayer.prototype.start=function(t,e,i,s,n,o){e=this.toSeconds(e);var r=this._makeSource(t);return r.start(e,i,s,this.defaultArg(o,1),this.fadeIn),s&&r.stop(e+this.toSeconds(s),this.fadeOut),n=this.defaultArg(n,0),r.playbackRate.value=this.intervalToFrequencyRatio(n),this},t.MultiPlayer.prototype.startLoop=function(t,e,i,s,n,o,r){e=this.toSeconds(e);var a=this._makeSource(t);return a.loop=!0,a.loopStart=this.toSeconds(this.defaultArg(s,0)),a.loopEnd=this.toSeconds(this.defaultArg(n,0)),a.start(e,i,void 0,this.defaultArg(r,1),this.fadeIn),o=this.defaultArg(o,0),a.playbackRate.value=this.intervalToFrequencyRatio(o),this},t.MultiPlayer.prototype.stop=function(t,e){if(!this._activeSources[t]||!this._activeSources[t].length)throw new Error("Tone.MultiPlayer: cannot stop a buffer that hasn't been started or is already stopped");return e=this.toSeconds(e),this._activeSources[t].shift().stop(e,this.fadeOut),this},t.MultiPlayer.prototype.stopAll=function(t){t=this.toSeconds(t);for(var e in this._activeSources)for(var i=this._activeSources[e],s=0;s<i.length;s++)i[s].stop(t);return this},t.MultiPlayer.prototype.add=function(t,e,i){return this.buffers.add(t,e,i),this},Object.defineProperty(t.MultiPlayer.prototype,"state",{get:function(){return this._activeSources.length>0?t.State.Started:t.State.Stopped}}),Object.defineProperty(t.MultiPlayer.prototype,"mute",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),t.MultiPlayer.prototype.dispose=function(){t.prototype.dispose.call(this),this._volume.dispose(),this._volume=null,this._writable("volume"),this.volume=null;for(var e in this._activeSources)this._activeSources[e].forEach(function(t){t.dispose()});return this.buffers.dispose(),this.buffers=null,this._activeSources=null,this},t.MultiPlayer}),t(function(t){return t.GrainPlayer=function(){var e=this.optionsObject(arguments,["url","onload"],t.GrainPlayer.defaults);t.Source.call(this),this.buffer=new t.Buffer(e.url,e.onload),this._player=(new t.MultiPlayer).connect(this.output),this._clock=new t.Clock(this._tick.bind(this),1),this._loopStart=0,this._loopEnd=0,this._playbackRate=e.playbackRate,this._grainSize=e.grainSize,this._overlap=e.overlap,this.detune=e.detune,this.drift=e.drift,this.overlap=e.overlap,this.loop=e.loop,this.playbackRate=e.playbackRate,this.grainSize=e.grainSize,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.reverse=e.reverse},t.extend(t.GrainPlayer,t.Source),t.GrainPlayer.defaults={onload:t.noOp,overlap:.1,grainSize:.2,drift:0,playbackRate:1,detune:0,loop:!1,loopStart:0,loopEnd:0,reverse:!1},t.GrainPlayer.prototype._start=function(t,e,i){e=this.defaultArg(e,0),e=this.toSeconds(e),t=this.toSeconds(t),this._offset=e,this._clock.start(t),this._player.volume.setValueAtTime(0,t),i&&this._stop(t+this.toSeconds(i))},t.GrainPlayer.prototype._stop=function(t){this._clock.stop(t),this._player.volume.cancelScheduledValues(t),this._player.volume.setValueAtTime(-1/0,t)},t.GrainPlayer.prototype._tick=function(t){var e=this.buffer.duration;this.loop&&this._loopEnd>0&&(e=this._loopEnd);var i=(2*Math.random()-1)*this.drift,s=this._offset-this._overlap+i,n=this.detune/100;s=Math.max(s,0),s=Math.min(s,e);var o=this._player.fadeIn;if(this.loop&&this._offset>e){var r=this._offset-e;this._player.start(this.buffer,t,s,r+this._overlap,n),s=this._offset%e,this._offset=this._loopStart,this._player.fadeIn=0,this._player.start(this.buffer,t+r,this._offset,s+this._overlap,n)}else this._offset>e?this.stop(t):(0===s&&(this._player.fadeIn=0),this._player.start(this.buffer,t,s,this.grainSize+this._overlap,n));this._player.fadeIn=o;var a=this._clock._nextTick-t;this._offset+=a*this._playbackRate},t.GrainPlayer.prototype.scrub=function(t,e){return this._offset=this.toSeconds(t),this._tick(this.toSeconds(e)),this},Object.defineProperty(t.GrainPlayer.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this.grainSize=this._grainSize}}),Object.defineProperty(t.GrainPlayer.prototype,"loopStart",{get:function(){return this._loopStart},set:function(t){this._loopStart=this.toSeconds(t)}}),Object.defineProperty(t.GrainPlayer.prototype,"loopEnd",{get:function(){return this._loopEnd},set:function(t){this._loopEnd=this.toSeconds(t)}}),Object.defineProperty(t.GrainPlayer.prototype,"reverse",{get:function(){return this.buffer.reverse},set:function(t){this.buffer.reverse=t}}),Object.defineProperty(t.GrainPlayer.prototype,"grainSize",{get:function(){return this._grainSize},set:function(t){this._grainSize=this.toSeconds(t),this._clock.frequency.value=this._playbackRate/this._grainSize}}),Object.defineProperty(t.GrainPlayer.prototype,"overlap",{get:function(){return this._overlap},set:function(t){t=this.toSeconds(t),this._overlap=t,this._overlap<0?(this._player.fadeIn=.01,this._player.fadeOut=.01):(this._player.fadeIn=t,this._player.fadeOut=t)}}),t.GrainPlayer.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this.buffer.dispose(),this.buffer=null,this._player.dispose(),this._player=null,this._clock.dispose(),this._clock=null,this},t.GrainPlayer}),t(function(t){return t.UserMedia=function(){var e=this.optionsObject(arguments,["volume"],t.UserMedia.defaults);this._mediaStream=null,this._stream=null,this._device=null,this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._readOnly("volume"),this.mute=e.mute},t.extend(t.UserMedia),t.UserMedia.defaults={volume:0,mute:!1},t.UserMedia.prototype.open=function(t){return t=this.defaultArg(t,"default"),this.enumerateDevices().then(function(e){var i;if(this.isNumber(t)?i=e[t]:(i=e.find(function(e){return e.label===t||e.deviceId===t}))||(i=e[0]),!i)throw new Error("Tone.UserMedia: no matching audio inputs.");this._device=i;var s={audio:{deviceId:i.deviceId,echoCancellation:!1,sampleRate:this.context.sampleRate}};return navigator.mediaDevices.getUserMedia(s).then(function(t){return this._stream||(this._stream=t,this._mediaStream=this.context.createMediaStreamSource(t),this._mediaStream.connect(this.output)),this}.bind(this))}.bind(this))},t.UserMedia.prototype.close=function(){return this._stream&&(this._stream.getAudioTracks().forEach(function(t){t.stop()}),this._stream=null,this._mediaStream.disconnect(),this._mediaStream=null),this._device=null,this},t.UserMedia.prototype.enumerateDevices=function(){return navigator.mediaDevices.enumerateDevices().then(function(t){return t.filter(function(t){return"audioinput"===t.kind})})},Object.defineProperty(t.UserMedia.prototype,"state",{get:function(){return this._stream&&this._stream.active?t.State.Started:t.State.Stopped}}),Object.defineProperty(t.UserMedia.prototype,"deviceId",{get:function(){if(this._device)return this._device.deviceId}}),Object.defineProperty(t.UserMedia.prototype,"groupId",{get:function(){if(this._device)return this._device.groupId}}),Object.defineProperty(t.UserMedia.prototype,"label",{get:function(){if(this._device)return this._device.label}}),Object.defineProperty(t.UserMedia.prototype,"mute",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),t.UserMedia.prototype.dispose=function(){return t.prototype.dispose.call(this),this.close(),this._writable("volume"),this._volume.dispose(),this._volume=null,this.volume=null,this},Object.defineProperty(t.UserMedia,"supported",{get:function(){return!t.prototype.isUndef(navigator.mediaDevices)&&t.prototype.isFunction(navigator.mediaDevices.getUserMedia)}}),t.UserMedia}),e})},function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}function n(t){return t[Math.floor(Math.random()*t.length)]}function o(t,e){return t-e*Math.floor(t/e)}function r(t){if(f){var e=document.createElement("div"),i=document.createElement("div");i.innerHTML="Tap to start - please unmute your phone",Object.assign(e.style,{position:"absolute",width:"100%",height:"100%",zIndex:"10000",top:"0px",left:"0px",backgroundColor:"rgba(0, 0, 0, 0.8)"}),Object.assign(i.style,{position:"absolute",left:"50%",top:"50%",padding:"20px",backgroundColor:"#7F33ED",color:"white",fontFamily:"monospace",borderRadius:"3px",transform:"translate3D(-50%,-50%,0)",textAlign:"center",lineHeight:"1.5"}),e.appendChild(i),document.body.appendChild(e),c.default.setContext(h.default.context),c.default.on(i),c.default.onStarted(function(i){e.remove(),t()})}else t()}Object.defineProperty(e,"__esModule",{value:!0}),e.requestAudioContext=e.browser=e.mod=e.choice=void 0;var a=i(4),h=s(a),l=i(17),c=s(l),u=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i),p=navigator.userAgent.match(/iPad/i),d=navigator.userAgent.match(/Android/i),f=u||p||d,y=!f;document.body.classList.add(f?"mobile":"desktop");var _={isIphone:u,isIpad:p,isMobile:f,isDesktop:y};e.choice=n,e.mod=o,e.browser=_,e.requestAudioContext=r},function(t,e){function i(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function s(t){return"function"==typeof t}function n(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function r(t){return void 0===t}t.exports=i,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._maxListeners=void 0,i.defaultMaxListeners=10,i.prototype.setMaxListeners=function(t){if(!n(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},i.prototype.emit=function(t){var e,i,n,a,h,l;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var c=new Error('Uncaught, unspecified "error" event. ('+e+")");throw c.context=e,c}if(i=this._events[t],r(i))return!1;if(s(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),i.apply(this,a)}else if(o(i))for(a=Array.prototype.slice.call(arguments,1),l=i.slice(),n=l.length,h=0;h<n;h++)l[h].apply(this,a);return!0},i.prototype.addListener=function(t,e){var n;if(!s(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,s(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(n=r(this._maxListeners)?i.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},i.prototype.on=i.prototype.addListener,i.prototype.once=function(t,e){function i(){this.removeListener(t,i),n||(n=!0,e.apply(this,arguments))}if(!s(e))throw TypeError("listener must be a function");var n=!1;return i.listener=e,this.on(t,i),this},i.prototype.removeListener=function(t,e){var i,n,r,a;if(!s(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(i=this._events[t],r=i.length,n=-1,i===e||s(i.listener)&&i.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(i)){for(a=r;a-- >0;)if(i[a]===e||i[a].listener&&i[a].listener===e){n=a;break}if(n<0)return this;1===i.length?(i.length=0,delete this._events[t]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},i.prototype.removeAllListeners=function(t){var e,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[t],s(i))this.removeListener(t,i);else if(i)for(;i.length;)this.removeListener(t,i[i.length-1]);return delete this._events[t],this},i.prototype.listeners=function(t){return this._events&&this._events[t]?s(this._events[t])?[this._events[t]]:this._events[t].slice():[]},i.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(s(e))return 1;if(e)return e.length}return 0},i.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e){e.findPosition=function(t){var e=document.body,i=document.defaultView,s=document.documentElement,n=document.createElement("div");n.style.paddingLeft=n.style.width="1px",e.appendChild(n);var o=2==n.offsetWidth;e.removeChild(n),n=t.getBoundingClientRect();var r=s.clientTop||e.clientTop||0,a=s.clientLeft||e.clientLeft||0,h=i.pageYOffset||o&&s.scrollTop||e.scrollTop,l=i.pageXOffset||o&&s.scrollLeft||e.scrollLeft;return{top:n.top+h-r,left:n.left+l-a}},e.getCursorPosition=function(t,e){var i,s;void 0!=t.pageX&&void 0!=t.pageY?(i=t.pageX,s=t.pageY):(i=t.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,s=t.clientY+document.body.scrollTop+document.documentElement.scrollTop),i-=e.left,s-=e.top;var n={x:i,y:s};return n.touches=[{x:i,y:s}],n},e.getTouchPosition=function(t,e){var i,s;i=t.targetTouches[0].pageX,s=t.targetTouches[0].pageY,i-=e.left,s-=e.top;var n={x:i,y:s};n.touches=new Array;for(var o=0;o<t.targetTouches.length;o++)n.touches.push({x:t.targetTouches[o].pageX-e.left,y:t.targetTouches[o].pageY-e.top});n.changed=new Array;for(var o=0;o<t.changedTouches.length;o++)n.changed.push({x:t.changedTouches[o].pageX-e.left,y:t.changedTouches[o].pageY-e.top});return n}},function(t,e){e.throttle=function(t,e){var i;return function(){var s=this,n=arguments;i||(i=setTimeout(function(){i=null;try{t.apply(s,n)}catch(t){console.log(t)}},e))}}},function(t,e){e.defineTransmit=function(t){if("function"==typeof t)return t;switch(t){case"js":return function(t,e){this.makeOSC(this.emit,t,e),this.emit("*",t,e)};case"ajax":return function(t){this.makeOSC(e.ajaxTransmit,t)};case"node":return function(t){this.makeOSC(e.nodeTransmit,t)};case"ios":return function(t){};case"max":return function(t){this.makeOSC(e.maxTransmit,t)};case"wc":return function(t,e){this.emit("internal",t,e)}}},e.setGlobalTransmit=function(t){var i=e.defineTransmit(t);this.transmit=i,this.destination=t;for(var s in nx.widgets)this.widgets[s].transmit=i,this.widgets[s].destination=t},e.setWidgetTransmit=function(t){var i=e.defineTransmit(t);this.transmit=i,this.destination=t},e.ajaxTransmit=function(t,e){var i="value"==t?this.oscPath:this.oscPath+"/"+t;xmlhttp=new XMLHttpRequest,xmlhttp.open("POST",nx.ajaxPath,!0),xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"),xmlhttp.send("oscName="+i+"&data="+e)},e.setAjaxPath=function(t){this.ajaxPath=t},e.nodeTransmit=function(t,e){var i={oscName:"value"==t?this.oscPath:this.oscPath+"/"+t,value:e};socket.emit("nx",i)},e.maxTransmit=function(t,e){var i="value"==t?this.oscPath:this.oscPath+"/"+t;window.max.outlet(i+" "+e)}},function(t,e,i){"use strict";function s(t,e,i,s,n,o,r){return e+i*Math.cos(2*Math.PI*(s*t+n))*r+o}function n(t,e,i){for(var n=void 0,o=void 0,a=void 0,h=void 0,l=[],c=0;c<3;c++)n=r[0][c],o=r[1][c],a=r[2][c],h=r[3][c],l[c]=Math.round(255*s(t,n,o,a,h,e,i));return"rgb("+l+")"}Object.defineProperty(e,"__esModule",{value:!0});var o=[[[.5,.5,.5],[.5,.5,.5],[1,1,1],[0,.33,.67]],[[.5,.5,.5],[.5,.5,.5],[1,1,1],[0,.1,.2]],[[.5,.5,.5],[.5,.5,.5],[1,1,1],[.3,.2,.2]],[[.5,.5,.5],[.5,.5,.5],[1,1,.5],[.8,.9,.3]],[[.5,.5,.5],[.5,.5,.5],[1,.7,.4],[0,.15,.2]],[[.5,.5,.5],[.5,.5,.5],[2,1,0],[.5,.2,.25]],[[.8,.5,.4],[.2,.4,.2],[2,1,1],[0,.25,.25]]],r=o[0];e.default=n},function(t,e,i){"use strict";function s(t){var e={sample:(0,r.choice)(l)};e.sample.index=(e.sample.index+1)%a;var i=e.sample.players[e.sample.index];i.playbackRate=t/e.sample.root,i.start()}Object.defineProperty(e,"__esModule",{value:!0});var n=i(4),o=function(t){return t&&t.__esModule?t:{default:t}}(n),r=i(5),a=2,h=new o.default.Compressor(-30,3).toMaster(),l=[{root:226,fn:"samples/380737__cabled-mess__sansula-01-a-raw.wav"},{root:267,fn:"samples/380736__cabled-mess__sansula-02-c-raw.wav"},{root:340,fn:"samples/380735__cabled-mess__sansula-03-e-raw.wav"},{root:452,fn:"samples/380733__cabled-mess__sansula-06-a-02-raw.wav"}];l.forEach(function(t){t.players=[],t.index=-1;for(var e=0;e<a;e++){var i=t.fn;window.location.href.match(/asdf.us/)&&(i="//asdf.us/kalimba/"+i);var s=new o.default.Player({url:i,retrigger:!0,playbackRate:1});s.connect(h),t.players.push(s)}}),e.default={play:s}},function(t,e,i){"use strict";function s(t){if(t.altKey||t.ctrlKey||t.metaKey)return void t.stopPropagation();if(document.activeElement instanceof HTMLInputElement&&t.keyCode in r)return void t.stopPropagation();if(t.keyCode in o){var e=o[t.keyCode];t.shiftKey&&(e+=a.length),e-=7,h(e)}}function n(t){h=t}Object.defineProperty(e,"__esModule",{value:!0});var o={},r={},a="zxcvbnmasdfghjklqwertyuiop",h=function(){};a.toUpperCase().split("").map(function(t,e){o[t.charCodeAt(0)]=e}),"1234567890".split("").map(function(t,e){o[t.charCodeAt(0)]=e+a.length,r[t.charCodeAt(0)]=!0}),window.addEventListener("keydown",s,!0),e.default={listen:n}},function(t,e,i){"use strict";function s(){c.forEach(function(t,e){t.heading=document.createElement("div"),t.heading.innerHTML=t.name,t.heading.classList.add("heading"),t.heading.addEventListener("click",function(){n(e)}),scale_list.appendChild(t.heading)}),n(0)}function n(t){u&&u.heading&&u.heading.classList.remove("selected"),u=c[t],u.heading&&u.heading.classList.add("selected"),p(u)}function o(){return u}function r(t){p=t}function a(){return c.map(function(t){return t.name})}Object.defineProperty(e,"__esModule",{value:!0});var h=i(16),l=function(t){return t&&t.__esModule?t:{default:t}}(h),c=[{intervals:"1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1",name:"harmonic scale"},{root:450,intervals:"1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1",name:"harmonic scale @ 450"},{tet:5},{tet:12},{tet:17},{intervals:"1/1 81/80 33/32 21/20 16/15 12/11 11/10 10/9 9/8 8/7 7/6 32/27 6/5 11/9 5/4 14/11 9/7 21/16 4/3 27/20 11/8 7/5 10/7 16/11 40/27 3/2 32/21 14/9 11/7 8/5 18/11 5/3 27/16 12/7 7/4 16/9 9/5 20/11 11/6 15/8 40/21 64/33 160/81 2/1",name:"harry partch scale"},{scl:"! young-lm_piano.scl\n!\nLaMonte Young's Well-Tempered Piano\n12\n!\n567/512\n9/8\n147/128\n21/16\n1323/1024\n189/128\n3/2\n49/32\n7/4\n441/256\n63/32\n2/1\n"},{scl:"! meanquar.scl\n!\n1/4-comma meantone scale. Pietro Aaron's temperament (1523)\n 12\n!\n 76.04900\n 193.15686\n 310.26471\n 5/4\n 503.42157\n 579.47057\n 696.57843\n 25/16\n 889.73529\n 1006.84314\n 1082.89214\n 2/1\n"},{scl:"! mavila12.scl\n!\nA 12-note mavila scale (for warping meantone-based music), 5-limit TOP\n 12\n!\n-30.99719\n 163.50770\n 358.01258\n 327.01540\n 521.52028\n 490.52310\n 685.02798\n 654.03080\n 848.53568\n 1043.04057\n 1012.04338\n 1206.54826\n"},{scl:"! carlos_alpha.scl\n!\nWendy Carlos' Alpha scale with perfect fifth divided in nine\n 18\n!\n 78.00000\n 156.00000\n 234.00000\n 312.00000\n 390.00000\n 468.00000\n 546.00000\n 624.00000\n 702.00000\n 780.00000\n 858.00000\n 936.00000\n 1014.00000\n 1092.00000\n 1170.00000\n 1248.00000\n 1326.00000\n 1404.00000\n"},{scl:"! colundi.scl\n!\nColundi scale\n10\n!\n9/8\n171/140\n137/112\n43/35\n3/2\n421/280\n213/140\n263/150\n66/35\n2/1\n"}].map(function(t){return new l.default(t)}),u=c[0],p=function(){};e.default={scales:c,current:o,build:s,pick:n,names:a,onChange:r}},function(t,e,s){var n=s(19),o=s(7),r=s(3),a=s(2),h=s(18),l=s(54);window.nx=new n,window.nx.onload=function(){},window.nx=h(window.nx,o),window.nx=h(window.nx,r),window.nx=h(window.nx,a),window.onload=function(){try{l.load({google:{families:["Open Sans"]}})}catch(t){console.log("font not loaded")}nx.addStylesheet();var t=document.getElementsByTagName("canvas");for(i=0;i<t.length;i++)nx.transform(t[i]);nx.isTouchDevice&&(document.addEventListener("touchmove",nx.blockMove,!0),document.addEventListener("touchstart",nx.blockMove,!0)),nx.onload(),nx.startPulse()}},function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}function n(){V=z.widgets.grid,V.sequenceMode=!0,V.bpm=1,V.col=D,V.row=B,V.init(),V.resize(N*D,N*B),V.draw(),z.widgets.scale.choices=j.default.names(),z.widgets.scale.init(),z.widgets.scale.on("*",function(t){return j.default.pick(t.value)}),j.default.onChange(function(t){a()}),a(),V.on("*",function(t){return"level"in t&&a()}),z.widgets.shiftUp.on("*",o(l)),z.widgets.shiftDown.on("*",o(c)),z.widgets.slideUp.on("*",o(u)),z.widgets.slideDown.on("*",o(p)),z.widgets.slideLeft.on("*",o(d)),z.widgets.slideRight.on("*",o(f)),z.widgets.rotateUp.on("*",o(function(){return v(-1)})),z.widgets.rotateDown.on("*",o(function(){return v(1)})),z.widgets.rotateLeft.on("*",o(function(){return m(-1)})),z.widgets.rotateRight.on("*",o(function(){return m(1)})),z.widgets.flip.on("*",o(y)),z.widgets.flop.on("*",o(_)),z.colorize("#f4d142"),X.start(),q.default.Transport.bpm.value=108,z.widgets.tempo.min=10,z.widgets.tempo.max=1e3,z.widgets.tempo.set({value:108}),z.widgets.tempo.on("*",function(t){return q.default.Transport.bpm.value=z.widgets.tempo.val.value}),q.default.Transport.start()}function o(t){return function(e){L.browser.isMobile?t():e.press&&t()}}function r(){V.draw(),a()}function a(){for(var t=document.querySelector("#labels"),e=j.default.current().scale.length,i=h(),s="",n=0;n<B;n++){var o=B-n-W,r=(0,L.mod)(o,e),a=r+1;i.includes(r)?s+="<b>"+a+"</b><br>":s+=a+"<br>"}t.innerHTML=s}function h(t){t=t||T();var e=j.default.current().scale.length;return t.reduce(function(t,i){var s=(0,L.mod)(B-i-W,e);return t.includes(s)||t.push(s),t},[]).sort()}function l(){var t=T(),e=h(t),i=j.default.current().scale.length;w(A(t,function(t){for(var s=B-t-W,n=(0,L.mod)(s,i),o=e.indexOf(n)+1,r=Math.floor(s/i);o>=e.length;)o-=e.length,r+=1;return B-W-(e[o]+r*i)}))}function c(){var t=T(),e=h(t),i=j.default.current().scale.length;w(A(t,function(t){for(var s=B-t-W,n=(0,L.mod)(s,i),o=e.indexOf(n)-1,r=Math.floor(s/i);o<0;)o+=e.length,r-=1;return B-W-(e[o]+r*i)}))}function u(){w(A(T(),function(t){return(t-1+B)%B}))}function p(){w(A(T(),function(t){return(t+1+B)%B}))}function d(){g(A(k(),function(t){return(t-1+D)%D}))}function f(){g(A(k(),function(t){return(t+1+D)%D}))}function y(){w(M(T()))}function _(){g(M(k()))}function m(t){g(P(k(),t))}function v(t){w(P(T(),t))}function g(t){if(t){var e=V.matrix,i=S();b(e,function(e,s,n){e in t&&(i[t[e]][s]=n)}),x(V.matrix,i),r()}}function w(t){if(t){var e=V.matrix,i=S();b(e,function(e,s,n){s in t&&(i[e][t[s]]=n)}),x(V.matrix,i),r()}}function b(t,e){for(var i=D,s=B,n=0;n<i;n++)for(var o=0;o<s;o++)e(n,o,t[n][o]);return t}function x(t,e){return b(e,function(i,s,n){return t[i][s]=e[i][s]})}function S(){for(var t=V.matrix.length,e=V.matrix[0].length,i=new Array(t),s=0;s<t;s++){i[s]=new Array(e);for(var n=0;n<e;n++)i[s][n]=0}return i}function T(){var t=new Array(B);return b(V.matrix,function(e,i,s){s&&(t[i]=1)}),t.reduce(function(t,e,i){return 1===e&&t.push(i),t},[])}function k(){return V.matrix.reduce(function(t,e,i){return e.some(function(t){return 1===t})&&t.push(i),t},[])}function P(t,e){if(t.length){for(var i={},s=O(t,e),n=0;n<s.length;n++)i[s[n]]=t[n];return i}}function O(t,e){var i=t.slice(0);return i.unshift.apply(i,i.splice(-e,i.length)),i}function A(t,e){if(t.length){for(var i={},s=0;s<t.length;s++)i[t[s]]=e(t[s]);return i}}function M(t){if(t.length){for(var e={},i=t.slice(0).reverse(),s=0;s<i.length;s++)e[i[s]]=t[s];return e}}var I=i(4),q=s(I);i(14);var E=i(12),F=s(E),U=i(10),G=(s(U),i(11)),R=s(G),C=i(13),j=s(C),L=i(5),z=window.nx,B=L.browser.isMobile?18:24,D=16,N=L.browser.isMobile?20:27,W=L.browser.isMobile?8:12,V=void 0,X=new q.default.Sequence(function(t,e){var i=V.matrix[e];V.jumpToCol(e);for(var s=0;s<B;s++)if(1===i[s]){var n=j.default.current().index(B-s-W);R.default.play(n)}},[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],"16n");z.onload=function(){return(0,L.requestAudioContext)(n)},F.default.listen(function(t){var e=j.default.current().index(t);R.default.play(e)})},function(t,e,i){"use strict";t.exports=function(){function t(t,e,i){return(t-e)/(i-e)}function e(t,e){return t-e*Math.floor(t/e)}var i=function(t){t=this.opt=Object.assign({name:"",root:440,octave:0,interval:2,tet:0,intervals:null},t||{}),this.generate()};i.prototype.generate=function(t){t=Object.assign(this.opt,t||{}),t.scl?this.generate_scl():t.tet?this.generate_tet():t.intervals&&this.generate_intervals()},i.prototype.generate_intervals=function(){var t=(this.opt.root,this.opt.intervals);"string"==typeof t&&(t=t.split(" ")),this.name=this.opt.name||"interval list",this.intervals=t,this.interval=this.opt.interval=s.call(this,t.pop()),this.scale=t.map(n.bind(this)).filter(function(t){return!!t})},i.prototype.generate_tet=function(){var t=this.scale=[],e=this.opt.root,i=this.opt.tet,s=this.interval=this.opt.interval,n=Math.pow(s,1/i),o=e;t.push(o);for(var r=0;r<i-1;r++)o*=n,t.push(o);this.name=this.opt.name||i+"-tone equal temperament",this.intervals=null},i.prototype.generate_scl=function(){var t=this.opt.root,e=this.parse_scl(this.opt.scl);this.intervals=e.notes,this.interval=e.notes.pop(),this.name=this.opt.name||e.description,this.scale=e.notes.map(function(e){return e*t})},i.prototype.parse_scl=function(t){var e={};return e.comments=[],e.notes=[],t.trim().split("\n").forEach(function(t){if(-1!==t.indexOf("!"))e.comments.push(t);else if("description"in e)if(e.notes.length){var i=t.replace(/^[^-\.0-9]+/,"").replace(/[^-\/\.0-9]+$/,"");i=-1!==i.indexOf(".")?Math.pow(2,parseFloat(i)/1200):s(i),i&&e.notes.push(i)}else e.notes.push(1);else e.description=t}),e},i.prototype.index=function(i,s){s=s||this.opt.octave;var n=this.scale[0|e(i,this.scale.length)],o=Math.floor(t(i,0,this.scale.length))+s;return n*=Math.pow(this.interval,o)},i.prototype.range=function(t,e){for(var i=[],s=t;s<e;s++)i.push(this.index(s));return i},i.prototype.set_root=function(t){this.opt.root=t,this.generate()},i.prototype.quantize_frequency=function(t){if(0==t)return 0;for(var e=t,i=0,s=this.interval,n=this.scale;e<root;)e*=s,i-=1;for(;e>root*s;)e/=s,i+=1;for(var o=0;o<n.length;o++)if(!(e>n[o])){e=n[o];break}return e*=Math.pow(2,i)},i.prototype.quantize_index=function(t){return 0|e(index-1,this.scale.length)};var s=i.prototype.parse_interval=function(t){if("number"==typeof t)return t;if(-1==!t.indexOf("/"))return parseInt(t);var e=t.split("/"),i=parseInt(e[0]),s=parseInt(e[1]);return isNaN(i)?1:isNaN(s)||0==s?i:i==s?1:i/s},n=i.prototype.parse_interval_string=function(t){return-1!==t.indexOf("/")?s(t)*this.opt.root:(t.indexOf("f"),parseFloat(t))};return i}()},function(t,e,i){"use strict";var s,n,o;"function"==typeof Symbol&&Symbol.iterator;/** + Main(function () { + + /////////////////////////////////////////////////////////////////////////// + // TONE + /////////////////////////////////////////////////////////////////////////// + /** + * @class Tone is the base class of all other classes. + * @constructor + */ + var Tone = function () { + if (!(this instanceof Tone)) { + throw new Error('constructor needs to be called with the \'new\' keyword'); + } + }; + /** + * @memberOf Tone# + * @returns {String} returns the name of the class as a string + */ + Tone.prototype.toString = function () { + for (var className in Tone) { + var isLetter = className[0].match(/^[A-Z]$/); + var sameConstructor = Tone[className] === this.constructor; + if (Tone.isFunction(Tone[className]) && isLetter && sameConstructor) { + return className; + } + } + return 'Tone'; + }; + /** + * @memberOf Tone# + * disconnect and dispose + * @returns {Tone} this + */ + Tone.prototype.dispose = function () { + return this; + }; + /////////////////////////////////////////////////////////////////////////// + // GET/SET + /////////////////////////////////////////////////////////////////////////// + /** + * Set the parameters at once. Either pass in an + * object mapping parameters to values, or to set a + * single parameter, by passing in a string and value. + * The last argument is an optional ramp time which + * will ramp any signal values to their destination value + * over the duration of the rampTime. + * @param {Object|String} params + * @param {Number=} value + * @param {Time=} rampTime + * @returns {Tone} this + * @memberOf Tone# + * @example + * //set values using an object + * filter.set({ + * "frequency" : 300, + * "type" : highpass + * }); + * @example + * filter.set("type", "highpass"); + * @example + * //ramp to the value 220 over 3 seconds. + * oscillator.set({ + * "frequency" : 220 + * }, 3); + */ + Tone.prototype.set = function (params, value, rampTime) { + if (Tone.isObject(params)) { + rampTime = value; + } else if (Tone.isString(params)) { + var tmpObj = {}; + tmpObj[params] = value; + params = tmpObj; + } + paramLoop: + for (var attr in params) { + value = params[attr]; + var parent = this; + if (attr.indexOf('.') !== -1) { + var attrSplit = attr.split('.'); + for (var i = 0; i < attrSplit.length - 1; i++) { + parent = parent[attrSplit[i]]; + if (parent instanceof Tone) { + attrSplit.splice(0, i + 1); + var innerParam = attrSplit.join('.'); + parent.set(innerParam, value); + continue paramLoop; + } + } + attr = attrSplit[attrSplit.length - 1]; + } + var param = parent[attr]; + if (Tone.isUndef(param)) { + continue; + } + if (Tone.Signal && param instanceof Tone.Signal || Tone.Param && param instanceof Tone.Param) { + if (param.value !== value) { + if (Tone.isUndef(rampTime)) { + param.value = value; + } else { + param.rampTo(value, rampTime); + } + } + } else if (param instanceof AudioParam) { + if (param.value !== value) { + param.value = value; + } + } else if (Tone.TimeBase && param instanceof Tone.TimeBase) { + parent[attr] = value; + } else if (param instanceof Tone) { + param.set(value); + } else if (param !== value) { + parent[attr] = value; + } + } + return this; + }; + /** + * Get the object's attributes. Given no arguments get + * will return all available object properties and their corresponding + * values. Pass in a single attribute to retrieve or an array + * of attributes. The attribute strings can also include a "." + * to access deeper properties. + * @memberOf Tone# + * @example + * osc.get(); + * //returns {"type" : "sine", "frequency" : 440, ...etc} + * @example + * osc.get("type"); + * //returns { "type" : "sine"} + * @example + * //use dot notation to access deep properties + * synth.get(["envelope.attack", "envelope.release"]); + * //returns {"envelope" : {"attack" : 0.2, "release" : 0.4}} + * @param {Array=|string|undefined} params the parameters to get, otherwise will return + * all available. + * @returns {Object} + */ + Tone.prototype.get = function (params) { + if (Tone.isUndef(params)) { + params = this._collectDefaults(this.constructor); + } else if (Tone.isString(params)) { + params = [params]; + } + var ret = {}; + for (var i = 0; i < params.length; i++) { + var attr = params[i]; + var parent = this; + var subRet = ret; + if (attr.indexOf('.') !== -1) { + var attrSplit = attr.split('.'); + for (var j = 0; j < attrSplit.length - 1; j++) { + var subAttr = attrSplit[j]; + subRet[subAttr] = subRet[subAttr] || {}; + subRet = subRet[subAttr]; + parent = parent[subAttr]; + } + attr = attrSplit[attrSplit.length - 1]; + } + var param = parent[attr]; + if (Tone.isObject(params[attr])) { + subRet[attr] = param.get(); + } else if (Tone.Signal && param instanceof Tone.Signal) { + subRet[attr] = param.value; + } else if (Tone.Param && param instanceof Tone.Param) { + subRet[attr] = param.value; + } else if (param instanceof AudioParam) { + subRet[attr] = param.value; + } else if (param instanceof Tone) { + subRet[attr] = param.get(); + } else if (!Tone.isFunction(param) && Tone.isDefined(param)) { + subRet[attr] = param; + } + } + return ret; + }; + /** + * collect all of the default attributes in one + * @private + * @param {Function} constr the constructor to find the defaults from + * @return {Array} all of the attributes which belong to the class + */ + Tone.prototype._collectDefaults = function (constr) { + var ret = []; + if (Tone.isDefined(constr.defaults)) { + ret = Object.keys(constr.defaults); + } + if (Tone.isDefined(constr._super)) { + var superDefs = this._collectDefaults(constr._super); + //filter out repeats + for (var i = 0; i < superDefs.length; i++) { + if (ret.indexOf(superDefs[i]) === -1) { + ret.push(superDefs[i]); + } + } + } + return ret; + }; + /////////////////////////////////////////////////////////////////////////// + // DEFAULTS + /////////////////////////////////////////////////////////////////////////// + /** + * @memberOf Tone + * @param {Array} values The arguments array + * @param {Array} keys The names of the arguments + * @param {Function|Object} constr The class constructor + * @return {Object} An object composed of the defaults between the class' defaults + * and the passed in arguments. + */ + Tone.defaults = function (values, keys, constr) { + var options = {}; + if (values.length === 1 && Tone.isObject(values[0])) { + options = values[0]; + } else { + for (var i = 0; i < keys.length; i++) { + options[keys[i]] = values[i]; + } + } + if (Tone.isDefined(constr.defaults)) { + return Tone.defaultArg(options, constr.defaults); + } else if (Tone.isObject(constr)) { + return Tone.defaultArg(options, constr); + } else { + return options; + } + }; + /** + * If the `given` parameter is undefined, use the `fallback`. + * If both `given` and `fallback` are object literals, it will + * return a deep copy which includes all of the parameters from both + * objects. If a parameter is undefined in given, it will return + * the fallback property. + * <br><br> + * WARNING: if object is self referential, it will go into an an + * infinite recursive loop. + * @memberOf Tone + * @param {*} given + * @param {*} fallback + * @return {*} + */ + Tone.defaultArg = function (given, fallback) { + if (Tone.isObject(given) && Tone.isObject(fallback)) { + var ret = {}; + //make a deep copy of the given object + for (var givenProp in given) { + ret[givenProp] = Tone.defaultArg(fallback[givenProp], given[givenProp]); + } + for (var fallbackProp in fallback) { + ret[fallbackProp] = Tone.defaultArg(given[fallbackProp], fallback[fallbackProp]); + } + return ret; + } else { + return Tone.isUndef(given) ? fallback : given; + } + }; + /////////////////////////////////////////////////////////////////////////// + // CONNECTIONS + /////////////////////////////////////////////////////////////////////////// + /** + * connect together all of the arguments in series + * @param {...AudioParam|Tone|AudioNode} nodes + * @returns {Tone} + * @memberOf Tone + * @static + */ + Tone.connectSeries = function () { + var currentUnit = arguments[0]; + for (var i = 1; i < arguments.length; i++) { + var toUnit = arguments[i]; + currentUnit.connect(toUnit); + currentUnit = toUnit; + } + return Tone; + }; + /////////////////////////////////////////////////////////////////////////// + // TYPE CHECKING + /////////////////////////////////////////////////////////////////////////// + /** + * Test if the arg is undefined + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is undefined + * @static + * @memberOf Tone + */ + Tone.isUndef = function (val) { + return typeof val === 'undefined'; + }; + /** + * Test if the arg is not undefined + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is undefined + * @static + * @memberOf Tone + */ + Tone.isDefined = function (val) { + return !Tone.isUndef(val); + }; + /** + * Test if the arg is a function + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is a function + * @static + * @memberOf Tone + */ + Tone.isFunction = function (val) { + return typeof val === 'function'; + }; + /** + * Test if the argument is a number. + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is a number + * @static + * @memberOf Tone + */ + Tone.isNumber = function (arg) { + return typeof arg === 'number'; + }; + /** + * Test if the given argument is an object literal (i.e. `{}`); + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is an object literal. + * @static + * @memberOf Tone + */ + Tone.isObject = function (arg) { + return Object.prototype.toString.call(arg) === '[object Object]' && arg.constructor === Object; + }; + /** + * Test if the argument is a boolean. + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is a boolean + * @static + * @memberOf Tone + */ + Tone.isBoolean = function (arg) { + return typeof arg === 'boolean'; + }; + /** + * Test if the argument is an Array + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is an array + * @static + * @memberOf Tone + */ + Tone.isArray = function (arg) { + return Array.isArray(arg); + }; + /** + * Test if the argument is a string. + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is a string + * @static + * @memberOf Tone + */ + Tone.isString = function (arg) { + return typeof arg === 'string'; + }; + /** + * Test if the argument is in the form of a note in scientific pitch notation. + * e.g. "C4" + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is a string + * @static + * @memberOf Tone + */ + Tone.isNote = function (arg) { + return Tone.isString(arg) && /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(arg); + }; + /** + * An empty function. + * @static + */ + Tone.noOp = function () { + }; + /** + * Make the property not writable. Internal use only. + * @private + * @param {String} property the property to make not writable + */ + Tone.prototype._readOnly = function (property) { + if (Array.isArray(property)) { + for (var i = 0; i < property.length; i++) { + this._readOnly(property[i]); + } + } else { + Object.defineProperty(this, property, { + writable: false, + enumerable: true + }); + } + }; + /** + * Make an attribute writeable. Interal use only. + * @private + * @param {String} property the property to make writable + */ + Tone.prototype._writable = function (property) { + if (Array.isArray(property)) { + for (var i = 0; i < property.length; i++) { + this._writable(property[i]); + } + } else { + Object.defineProperty(this, property, { writable: true }); + } + }; + /** + * Possible play states. + * @enum {String} + */ + Tone.State = { + Started: 'started', + Stopped: 'stopped', + Paused: 'paused' + }; + /////////////////////////////////////////////////////////////////////////// + // CONVERSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Equal power gain scale. Good for cross-fading. + * @param {NormalRange} percent (0-1) + * @return {Number} output gain (0-1) + * @static + * @memberOf Tone + */ + Tone.equalPowerScale = function (percent) { + var piFactor = 0.5 * Math.PI; + return Math.sin(percent * piFactor); + }; + /** + * Convert decibels into gain. + * @param {Decibels} db + * @return {Number} + * @static + * @memberOf Tone + */ + Tone.dbToGain = function (db) { + return Math.pow(10, db / 20); + }; + /** + * Convert gain to decibels. + * @param {Number} gain (0-1) + * @return {Decibels} + * @static + * @memberOf Tone + */ + Tone.gainToDb = function (gain) { + return 20 * (Math.log(gain) / Math.LN10); + }; + /** + * Convert an interval (in semitones) to a frequency ratio. + * @param {Interval} interval the number of semitones above the base note + * @return {Number} the frequency ratio + * @static + * @memberOf Tone + * @example + * tone.intervalToFrequencyRatio(0); // 1 + * tone.intervalToFrequencyRatio(12); // 2 + * tone.intervalToFrequencyRatio(-12); // 0.5 + */ + Tone.intervalToFrequencyRatio = function (interval) { + return Math.pow(2, interval / 12); + }; + /////////////////////////////////////////////////////////////////////////// + // TIMING + /////////////////////////////////////////////////////////////////////////// + /** + * Return the current time of the AudioContext clock. + * @return {Number} the currentTime from the AudioContext + * @memberOf Tone# + */ + Tone.prototype.now = function () { + return Tone.context.now(); + }; + /** + * Return the current time of the AudioContext clock. + * @return {Number} the currentTime from the AudioContext + * @static + * @memberOf Tone + */ + Tone.now = function () { + return Tone.context.now(); + }; + /////////////////////////////////////////////////////////////////////////// + // INHERITANCE + /////////////////////////////////////////////////////////////////////////// + /** + * have a child inherit all of Tone's (or a parent's) prototype + * to inherit the parent's properties, make sure to call + * Parent.call(this) in the child's constructor + * + * based on closure library's inherit function + * + * @memberOf Tone + * @static + * @param {Function} child + * @param {Function=} parent (optional) parent to inherit from + * if no parent is supplied, the child + * will inherit from Tone + */ + Tone.extend = function (child, parent) { + if (Tone.isUndef(parent)) { + parent = Tone; + } + function TempConstructor() { + } + TempConstructor.prototype = parent.prototype; + child.prototype = new TempConstructor(); + /** @override */ + child.prototype.constructor = child; + child._super = parent; + }; + /////////////////////////////////////////////////////////////////////////// + // CONTEXT + /////////////////////////////////////////////////////////////////////////// + /** + * Private reference to the global AudioContext + * @type {AudioContext} + * @private + */ + var audioContext = null; + /** + * A static pointer to the audio context accessible as Tone.context. + * @type {Tone.Context} + * @name context + * @memberOf Tone + */ + Object.defineProperty(Tone, 'context', { + get: function () { + return audioContext; + }, + set: function (context) { + if (Tone.Context && context instanceof Tone.Context) { + audioContext = context; + } else { + audioContext = new Tone.Context(context); + } + //initialize the new audio context + Tone.Context.emit('init', audioContext); + } + }); + /** + * The AudioContext + * @type {Tone.Context} + * @name context + * @memberOf Tone# + * @readOnly + */ + Object.defineProperty(Tone.prototype, 'context', { + get: function () { + return Tone.context; + } + }); + /** + * Tone automatically creates a context on init, but if you are working + * with other libraries which also create an AudioContext, it can be + * useful to set your own. If you are going to set your own context, + * be sure to do it at the start of your code, before creating any objects. + * @static + * @param {AudioContext} ctx The new audio context to set + */ + Tone.setContext = function (ctx) { + Tone.context = ctx; + }; + /////////////////////////////////////////////////////////////////////////// + // ATTRIBUTES + /////////////////////////////////////////////////////////////////////////// + /** + * The number of seconds of 1 processing block (128 samples) + * @type {Number} + * @name blockTime + * @memberOf Tone + * @static + * @readOnly + */ + Object.defineProperty(Tone.prototype, 'blockTime', { + get: function () { + return 128 / this.context.sampleRate; + } + }); + /** + * The duration in seconds of one sample. + * @type {Number} + * @name sampleTime + * @memberOf Tone + * @static + * @readOnly + */ + Object.defineProperty(Tone.prototype, 'sampleTime', { + get: function () { + return 1 / this.context.sampleRate; + } + }); + /** + * Whether or not all the technologies that Tone.js relies on are supported by the current browser. + * @type {Boolean} + * @name supported + * @memberOf Tone + * @readOnly + * @static + */ + Object.defineProperty(Tone, 'supported', { + get: function () { + var hasAudioContext = window.hasOwnProperty('AudioContext') || window.hasOwnProperty('webkitAudioContext'); + var hasPromises = window.hasOwnProperty('Promise'); + var hasWorkers = window.hasOwnProperty('Worker'); + return hasAudioContext && hasPromises && hasWorkers; + } + }); + /** + * Boolean value if the audio context has been initialized. + * @type {Boolean} + * @memberOf Tone + * @static + * @name initialized + */ + Object.defineProperty(Tone, 'initialized', { + get: function () { + return audioContext !== null; + } + }); + /** + * Get the context when it becomes available + * @param {Function} resolve Callback when the context is initialized + * @return {Tone} + */ + Tone.getContext = function (resolve) { + if (Tone.initialized) { + resolve(Tone.context); + } else { + var resCallback = function () { + resolve(Tone.context); + Tone.Context.off('init', resCallback); + }; + Tone.Context.on('init', resCallback); + } + return Tone; + }; + /** + * The version number + * @type {String} + * @static + */ + Tone.version = 'r12'; + return Tone; + }); + Module(function (Tone) { + + /** + * @class Tone.Emitter gives classes which extend it + * the ability to listen for and emit events. + * Inspiration and reference from Jerome Etienne's [MicroEvent](https://github.com/jeromeetienne/microevent.js). + * MIT (c) 2011 Jerome Etienne. + * + * @extends {Tone} + */ + Tone.Emitter = function () { + Tone.call(this); + /** + * Contains all of the events. + * @private + * @type {Object} + */ + this._events = {}; + }; + Tone.extend(Tone.Emitter); + /** + * Bind a callback to a specific event. + * @param {String} event The name of the event to listen for. + * @param {Function} callback The callback to invoke when the + * event is emitted + * @return {Tone.Emitter} this + */ + Tone.Emitter.prototype.on = function (event, callback) { + //split the event + var events = event.split(/\W+/); + for (var i = 0; i < events.length; i++) { + var eventName = events[i]; + if (!this._events.hasOwnProperty(eventName)) { + this._events[eventName] = []; + } + this._events[eventName].push(callback); + } + return this; + }; + /** + * Bind a callback which is only invoked once + * @param {String} event The name of the event to listen for. + * @param {Function} callback The callback to invoke when the + * event is emitted + * @return {Tone.Emitter} this + */ + Tone.Emitter.prototype.once = function (event, callback) { + var boundCallback = function () { + //invoke the callback + callback.apply(this, arguments); + this.off(event, boundCallback); + }.bind(this); + this.on(event, boundCallback); + return this; + }; + /** + * Remove the event listener. + * @param {String} event The event to stop listening to. + * @param {Function=} callback The callback which was bound to + * the event with Tone.Emitter.on. + * If no callback is given, all callbacks + * events are removed. + * @return {Tone.Emitter} this + */ + Tone.Emitter.prototype.off = function (event, callback) { + var events = event.split(/\W+/); + for (var ev = 0; ev < events.length; ev++) { + event = events[ev]; + if (this._events.hasOwnProperty(event)) { + if (Tone.isUndef(callback)) { + this._events[event] = []; + } else { + var eventList = this._events[event]; + for (var i = 0; i < eventList.length; i++) { + if (eventList[i] === callback) { + eventList.splice(i, 1); + } + } + } + } + } + return this; + }; + /** + * Invoke all of the callbacks bound to the event + * with any arguments passed in. + * @param {String} event The name of the event. + * @param {*} args... The arguments to pass to the functions listening. + * @return {Tone.Emitter} this + */ + Tone.Emitter.prototype.emit = function (event) { + if (this._events) { + var args = Array.apply(null, arguments).slice(1); + if (this._events.hasOwnProperty(event)) { + var eventList = this._events[event].slice(0); + for (var i = 0, len = eventList.length; i < len; i++) { + eventList[i].apply(this, args); + } + } + } + return this; + }; + /** + * Add Emitter functions (on/off/emit) to the object + * @param {Object|Function} object The object or class to extend. + * @returns {Tone.Emitter} + */ + Tone.Emitter.mixin = function (object) { + var functions = [ + 'on', + 'once', + 'off', + 'emit' + ]; + object._events = {}; + for (var i = 0; i < functions.length; i++) { + var func = functions[i]; + var emitterFunc = Tone.Emitter.prototype[func]; + object[func] = emitterFunc; + } + return Tone.Emitter; + }; + /** + * Clean up + * @return {Tone.Emitter} this + */ + Tone.Emitter.prototype.dispose = function () { + Tone.prototype.dispose.call(this); + this._events = null; + return this; + }; + return Tone.Emitter; + }); + Module(function (Tone) { + + /** + * @class A Timeline class for scheduling and maintaining state + * along a timeline. All events must have a "time" property. + * Internally, events are stored in time order for fast + * retrieval. + * @extends {Tone} + * @param {Positive} [memory=Infinity] The number of previous events that are retained. + */ + Tone.Timeline = function () { + var options = Tone.defaults(arguments, ['memory'], Tone.Timeline); + Tone.call(this); + /** + * The array of scheduled timeline events + * @type {Array} + * @private + */ + this._timeline = []; + /** + * The memory of the timeline, i.e. + * how many events in the past it will retain + * @type {Positive} + */ + this.memory = options.memory; + }; + Tone.extend(Tone.Timeline); + /** + * the default parameters + * @static + * @const + */ + Tone.Timeline.defaults = { 'memory': Infinity }; + /** + * The number of items in the timeline. + * @type {Number} + * @memberOf Tone.Timeline# + * @name length + * @readOnly + */ + Object.defineProperty(Tone.Timeline.prototype, 'length', { + get: function () { + return this._timeline.length; + } + }); + /** + * Insert an event object onto the timeline. Events must have a "time" attribute. + * @param {Object} event The event object to insert into the + * timeline. + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.add = function (event) { + //the event needs to have a time attribute + if (Tone.isUndef(event.time)) { + throw new Error('Tone.Timeline: events must have a time attribute'); + } + event.time = event.time.valueOf(); + var index = this._search(event.time); + this._timeline.splice(index + 1, 0, event); + //if the length is more than the memory, remove the previous ones + if (this.length > this.memory) { + var diff = this.length - this.memory; + this._timeline.splice(0, diff); + } + return this; + }; + /** + * Remove an event from the timeline. + * @param {Object} event The event object to remove from the list. + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.remove = function (event) { + var index = this._timeline.indexOf(event); + if (index !== -1) { + this._timeline.splice(index, 1); + } + return this; + }; + /** + * Get the nearest event whose time is less than or equal to the given time. + * @param {Number} time The time to query. + * @param {String} comparator Which value in the object to compare + * @returns {Object} The event object set after that time. + */ + Tone.Timeline.prototype.get = function (time, comparator) { + comparator = Tone.defaultArg(comparator, 'time'); + var index = this._search(time, comparator); + if (index !== -1) { + return this._timeline[index]; + } else { + return null; + } + }; + /** + * Return the first event in the timeline without removing it + * @returns {Object} The first event object + */ + Tone.Timeline.prototype.peek = function () { + return this._timeline[0]; + }; + /** + * Return the first event in the timeline and remove it + * @returns {Object} The first event object + */ + Tone.Timeline.prototype.shift = function () { + return this._timeline.shift(); + }; + /** + * Get the event which is scheduled after the given time. + * @param {Number} time The time to query. + * @param {String} comparator Which value in the object to compare + * @returns {Object} The event object after the given time + */ + Tone.Timeline.prototype.getAfter = function (time, comparator) { + comparator = Tone.defaultArg(comparator, 'time'); + var index = this._search(time, comparator); + if (index + 1 < this._timeline.length) { + return this._timeline[index + 1]; + } else { + return null; + } + }; + /** + * Get the event before the event at the given time. + * @param {Number} time The time to query. + * @param {String} comparator Which value in the object to compare + * @returns {Object} The event object before the given time + */ + Tone.Timeline.prototype.getBefore = function (time, comparator) { + comparator = Tone.defaultArg(comparator, 'time'); + var len = this._timeline.length; + //if it's after the last item, return the last item + if (len > 0 && this._timeline[len - 1][comparator] < time) { + return this._timeline[len - 1]; + } + var index = this._search(time, comparator); + if (index - 1 >= 0) { + return this._timeline[index - 1]; + } else { + return null; + } + }; + /** + * Cancel events after the given time + * @param {Number} time The time to query. + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.cancel = function (after) { + if (this._timeline.length > 1) { + var index = this._search(after); + if (index >= 0) { + if (this._timeline[index].time === after) { + //get the first item with that time + for (var i = index; i >= 0; i--) { + if (this._timeline[i].time === after) { + index = i; + } else { + break; + } + } + this._timeline = this._timeline.slice(0, index); + } else { + this._timeline = this._timeline.slice(0, index + 1); + } + } else { + this._timeline = []; + } + } else if (this._timeline.length === 1) { + //the first item's time + if (this._timeline[0].time >= after) { + this._timeline = []; + } + } + return this; + }; + /** + * Cancel events before or equal to the given time. + * @param {Number} time The time to cancel before. + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.cancelBefore = function (time) { + var index = this._search(time); + if (index >= 0) { + this._timeline = this._timeline.slice(index + 1); + } + return this; + }; + /** + * Returns the previous event if there is one. null otherwise + * @param {Object} event The event to find the previous one of + * @return {Object} The event right before the given event + */ + Tone.Timeline.prototype.previousEvent = function (event) { + var index = this._timeline.indexOf(event); + if (index > 0) { + return this._timeline[index - 1]; + } else { + return null; + } + }; + /** + * Does a binary search on the timeline array and returns the + * nearest event index whose time is after or equal to the given time. + * If a time is searched before the first index in the timeline, -1 is returned. + * If the time is after the end, the index of the last item is returned. + * @param {Number} time + * @param {String} comparator Which value in the object to compare + * @return {Number} the index in the timeline array + * @private + */ + Tone.Timeline.prototype._search = function (time, comparator) { + if (this._timeline.length === 0) { + return -1; + } + comparator = Tone.defaultArg(comparator, 'time'); + var beginning = 0; + var len = this._timeline.length; + var end = len; + if (len > 0 && this._timeline[len - 1][comparator] <= time) { + return len - 1; + } + while (beginning < end) { + // calculate the midpoint for roughly equal partition + var midPoint = Math.floor(beginning + (end - beginning) / 2); + var event = this._timeline[midPoint]; + var nextEvent = this._timeline[midPoint + 1]; + if (event[comparator] === time) { + //choose the last one that has the same time + for (var i = midPoint; i < this._timeline.length; i++) { + var testEvent = this._timeline[i]; + if (testEvent[comparator] === time) { + midPoint = i; + } + } + return midPoint; + } else if (event[comparator] < time && nextEvent[comparator] > time) { + return midPoint; + } else if (event[comparator] > time) { + //search lower + end = midPoint; + } else { + //search upper + beginning = midPoint + 1; + } + } + return -1; + }; + /** + * Internal iterator. Applies extra safety checks for + * removing items from the array. + * @param {Function} callback + * @param {Number=} lowerBound + * @param {Number=} upperBound + * @private + */ + Tone.Timeline.prototype._iterate = function (callback, lowerBound, upperBound) { + lowerBound = Tone.defaultArg(lowerBound, 0); + upperBound = Tone.defaultArg(upperBound, this._timeline.length - 1); + this._timeline.slice(lowerBound, upperBound + 1).forEach(function (event) { + callback.call(this, event); + }.bind(this)); + }; + /** + * Iterate over everything in the array + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.forEach = function (callback) { + this._iterate(callback); + return this; + }; + /** + * Iterate over everything in the array at or before the given time. + * @param {Number} time The time to check if items are before + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.forEachBefore = function (time, callback) { + //iterate over the items in reverse so that removing an item doesn't break things + var upperBound = this._search(time); + if (upperBound !== -1) { + this._iterate(callback, 0, upperBound); + } + return this; + }; + /** + * Iterate over everything in the array after the given time. + * @param {Number} time The time to check if items are before + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.forEachAfter = function (time, callback) { + //iterate over the items in reverse so that removing an item doesn't break things + var lowerBound = this._search(time); + this._iterate(callback, lowerBound + 1); + return this; + }; + /** + * Iterate over everything in the array between the startTime and endTime. + * The timerange is inclusive of the startTime, but exclusive of the endTime. + * range = [startTime, endTime). + * @param {Number} startTime The time to check if items are before + * @param {Number} endTime The end of the test interval. + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.forEachBetween = function (startTime, endTime, callback) { + var lowerBound = this._search(startTime); + var upperBound = this._search(endTime); + if (lowerBound !== -1 && upperBound !== -1) { + if (this._timeline[lowerBound].time !== startTime) { + lowerBound += 1; + } + //exclusive of the end time + if (this._timeline[upperBound].time === endTime) { + upperBound -= 1; + } + this._iterate(callback, lowerBound, upperBound); + } else if (lowerBound === -1) { + this._iterate(callback, 0, upperBound); + } + return this; + }; + /** + * Iterate over everything in the array at or after the given time. Similar to + * forEachAfter, but includes the item(s) at the given time. + * @param {Number} time The time to check if items are before + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.forEachFrom = function (time, callback) { + //iterate over the items in reverse so that removing an item doesn't break things + var lowerBound = this._search(time); + //work backwards until the event time is less than time + while (lowerBound >= 0 && this._timeline[lowerBound].time >= time) { + lowerBound--; + } + this._iterate(callback, lowerBound + 1); + return this; + }; + /** + * Iterate over everything in the array at the given time + * @param {Number} time The time to check if items are before + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.forEachAtTime = function (time, callback) { + //iterate over the items in reverse so that removing an item doesn't break things + var upperBound = this._search(time); + if (upperBound !== -1) { + this._iterate(function (event) { + if (event.time === time) { + callback.call(this, event); + } + }, 0, upperBound); + } + return this; + }; + /** + * Clean up. + * @return {Tone.Timeline} this + */ + Tone.Timeline.prototype.dispose = function () { + Tone.prototype.dispose.call(this); + this._timeline = null; + return this; + }; + return Tone.Timeline; + }); + Module(function (Tone) { + if (Tone.supported) { + if (!window.hasOwnProperty('OfflineAudioContext') && window.hasOwnProperty('webkitOfflineAudioContext')) { + window.OfflineAudioContext = window.webkitOfflineAudioContext; + } + //returns promise? + var context = new OfflineAudioContext(1, 1, 44100); + var ret = context.startRendering(); + if (!(ret instanceof Promise)) { + OfflineAudioContext.prototype._native_startRendering = OfflineAudioContext.prototype.startRendering; + OfflineAudioContext.prototype.startRendering = function () { + return new Promise(function (done) { + this.oncomplete = function (e) { + done(e.renderedBuffer); + }; + this._native_startRendering(); + }.bind(this)); + }; + } + } + }); + Module(function (Tone) { + if (Tone.supported) { + if (!window.hasOwnProperty('AudioContext') && window.hasOwnProperty('webkitAudioContext')) { + window.AudioContext = window.webkitAudioContext; + } + //not functionally equivalent, but only an API placeholder + if (!AudioContext.prototype.close) { + AudioContext.prototype.close = function () { + if (Tone.isFunction(this.suspend)) { + this.suspend(); + } + return Promise.resolve(); + }; + } + //not functionally equivalent + if (!AudioContext.prototype.resume) { + AudioContext.prototype.resume = function () { + return Promise.resolve(); + }; + } + //createGain + if (!AudioContext.prototype.createGain && AudioContext.prototype.createGainNode) { + AudioContext.prototype.createGain = AudioContext.prototype.createGainNode; + } + //createDelay + if (!AudioContext.prototype.createDelay && AudioContext.prototype.createDelayNode) { + AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode; + } + //test decodeAudioData returns a promise + // https://github.com/mohayonao/web-audio-api-shim/blob/master/src/AudioContext.js + // MIT License (c) 2015 @mohayonao + var decodeAudioDataPromise = false; + var offlineContext = new OfflineAudioContext(1, 1, 44100); + var audioData = new Uint32Array([ + 1179011410, + 48, + 1163280727, + 544501094, + 16, + 131073, + 44100, + 176400, + 1048580, + 1635017060, + 8, + 0, + 0, + 0, + 0 + ]).buffer; + try { + var ret = offlineContext.decodeAudioData(audioData); + if (ret instanceof Promise) { + decodeAudioDataPromise = true; + } + } catch (e) { + decodeAudioDataPromise = false; + } + if (!decodeAudioDataPromise) { + AudioContext.prototype._native_decodeAudioData = AudioContext.prototype.decodeAudioData; + AudioContext.prototype.decodeAudioData = function (audioData) { + return new Promise(function (success, error) { + this._native_decodeAudioData(audioData, success, error); + }.bind(this)); + }; + } + } + }); + Module(function (Tone) { + /** + * @class Wrapper around the native AudioContext. + * @extends {Tone.Emitter} + * @param {AudioContext=} context optionally pass in a context + */ + Tone.Context = function () { + Tone.Emitter.call(this); + var options = Tone.defaults(arguments, ['context'], Tone.Context); + if (!options.context) { + options.context = new window.AudioContext(); + if (!options.context) { + throw new Error('could not create AudioContext. Possibly too many AudioContexts running already.'); + } + } + this._context = options.context; + // extend all of the methods + for (var prop in this._context) { + this._defineProperty(this._context, prop); + } + /** + * The default latency hint + * @type {String} + * @private + */ + this._latencyHint = options.latencyHint; + /** + * An object containing all of the constants AudioBufferSourceNodes + * @type {Object} + * @private + */ + this._constants = {}; + /////////////////////////////////////////////////////////////////////// + // WORKER + /////////////////////////////////////////////////////////////////////// + /** + * The amount of time events are scheduled + * into the future + * @type {Number} + */ + this.lookAhead = options.lookAhead; + /** + * A reference to the actual computed update interval + * @type {Number} + * @private + */ + this._computedUpdateInterval = 0; + /** + * A reliable callback method + * @private + * @type {Ticker} + */ + this._ticker = new Ticker(this.emit.bind(this, 'tick'), options.clockSource, options.updateInterval); + /////////////////////////////////////////////////////////////////////// + // TIMEOUTS + /////////////////////////////////////////////////////////////////////// + /** + * All of the setTimeout events. + * @type {Tone.Timeline} + * @private + */ + this._timeouts = new Tone.Timeline(); + /** + * The timeout id counter + * @private + * @type {Number} + */ + this._timeoutIds = 0; + this.on('tick', this._timeoutLoop.bind(this)); + }; + Tone.extend(Tone.Context, Tone.Emitter); + Tone.Emitter.mixin(Tone.Context); + /** + * defaults + * @static + * @type {Object} + */ + Tone.Context.defaults = { + 'clockSource': 'worker', + 'latencyHint': 'interactive', + 'lookAhead': 0.1, + 'updateInterval': 0.03 + }; + /** + * Define a property on this Tone.Context. + * This is used to extend the native AudioContext + * @param {AudioContext} context + * @param {String} prop + * @private + */ + Tone.Context.prototype._defineProperty = function (context, prop) { + if (Tone.isUndef(this[prop])) { + Object.defineProperty(this, prop, { + get: function () { + if (typeof context[prop] === 'function') { + return context[prop].bind(context); + } else { + return context[prop]; + } + }, + set: function (val) { + context[prop] = val; + } + }); + } + }; + /** + * The current audio context time + * @return {Number} + */ + Tone.Context.prototype.now = function () { + return this._context.currentTime + this.lookAhead; + }; + /** + * Promise which is invoked when the context is running. + * Tries to resume the context if it's not started. + * @return {Promise} + */ + Tone.Context.prototype.ready = function () { + return new Promise(function (done) { + if (this._context.state === 'running') { + done(); + } else { + this._context.resume().then(function () { + done(); + }); + } + }.bind(this)); + }; + /** + * Promise which is invoked when the context is running. + * Tries to resume the context if it's not started. + * @return {Promise} + */ + Tone.Context.prototype.close = function () { + return this._context.close().then(function () { + Tone.Context.emit('close', this); + }.bind(this)); + }; + /** + * Generate a looped buffer at some constant value. + * @param {Number} val + * @return {BufferSourceNode} + */ + Tone.Context.prototype.getConstant = function (val) { + if (this._constants[val]) { + return this._constants[val]; + } else { + var buffer = this._context.createBuffer(1, 128, this._context.sampleRate); + var arr = buffer.getChannelData(0); + for (var i = 0; i < arr.length; i++) { + arr[i] = val; + } + var constant = this._context.createBufferSource(); + constant.channelCount = 1; + constant.channelCountMode = 'explicit'; + constant.buffer = buffer; + constant.loop = true; + constant.start(0); + this._constants[val] = constant; + return constant; + } + }; + /** + * The private loop which keeps track of the context scheduled timeouts + * Is invoked from the clock source + * @private + */ + Tone.Context.prototype._timeoutLoop = function () { + var now = this.now(); + while (this._timeouts && this._timeouts.length && this._timeouts.peek().time <= now) { + this._timeouts.shift().callback(); + } + }; + /** + * A setTimeout which is gaurenteed by the clock source. + * Also runs in the offline context. + * @param {Function} fn The callback to invoke + * @param {Seconds} timeout The timeout in seconds + * @returns {Number} ID to use when invoking Tone.Context.clearTimeout + */ + Tone.Context.prototype.setTimeout = function (fn, timeout) { + this._timeoutIds++; + var now = this.now(); + this._timeouts.add({ + callback: fn, + time: now + timeout, + id: this._timeoutIds + }); + return this._timeoutIds; + }; + /** + * Clears a previously scheduled timeout with Tone.context.setTimeout + * @param {Number} id The ID returned from setTimeout + * @return {Tone.Context} this + */ + Tone.Context.prototype.clearTimeout = function (id) { + this._timeouts.forEach(function (event) { + if (event.id === id) { + this.remove(event); + } + }); + return this; + }; + /** + * How often the Web Worker callback is invoked. + * This number corresponds to how responsive the scheduling + * can be. Context.updateInterval + Context.lookAhead gives you the + * total latency between scheduling an event and hearing it. + * @type {Number} + * @memberOf Tone.Context# + * @name updateInterval + */ + Object.defineProperty(Tone.Context.prototype, 'updateInterval', { + get: function () { + return this._ticker.updateInterval; + }, + set: function (interval) { + this._ticker.updateInterval = interval; + } + }); + /** + * What the source of the clock is, either "worker" (Web Worker [default]), + * "timeout" (setTimeout), or "offline" (none). + * @type {String} + * @memberOf Tone.Context# + * @name clockSource + */ + Object.defineProperty(Tone.Context.prototype, 'clockSource', { + get: function () { + return this._ticker.type; + }, + set: function (type) { + this._ticker.type = type; + } + }); + /** + * The type of playback, which affects tradeoffs between audio + * output latency and responsiveness. + * + * In addition to setting the value in seconds, the latencyHint also + * accepts the strings "interactive" (prioritizes low latency), + * "playback" (prioritizes sustained playback), "balanced" (balances + * latency and performance), and "fastest" (lowest latency, might glitch more often). + * @type {String|Seconds} + * @memberOf Tone.Context# + * @name latencyHint + * @example + * //set the lookAhead to 0.3 seconds + * Tone.context.latencyHint = 0.3; + */ + Object.defineProperty(Tone.Context.prototype, 'latencyHint', { + get: function () { + return this._latencyHint; + }, + set: function (hint) { + var lookAhead = hint; + this._latencyHint = hint; + if (Tone.isString(hint)) { + switch (hint) { + case 'interactive': + lookAhead = 0.1; + this._context.latencyHint = hint; + break; + case 'playback': + lookAhead = 0.8; + this._context.latencyHint = hint; + break; + case 'balanced': + lookAhead = 0.25; + this._context.latencyHint = hint; + break; + case 'fastest': + this._context.latencyHint = 'interactive'; + lookAhead = 0.01; + break; + } + } + this.lookAhead = lookAhead; + this.updateInterval = lookAhead / 3; + } + }); + /** + * Unlike other dispose methods, this returns a Promise + * which executes when the context is closed and disposed + * @returns {Promise} this + */ + Tone.Context.prototype.dispose = function () { + return this.close().then(function () { + Tone.Emitter.prototype.dispose.call(this); + this._ticker.dispose(); + this._ticker = null; + this._timeouts.dispose(); + this._timeouts = null; + for (var con in this._constants) { + this._constants[con].disconnect(); + } + this._constants = null; + }.bind(this)); + }; + /** + * @class A class which provides a reliable callback using either + * a Web Worker, or if that isn't supported, falls back to setTimeout. + * @private + */ + var Ticker = function (callback, type, updateInterval) { + /** + * Either "worker" or "timeout" + * @type {String} + * @private + */ + this._type = type; + /** + * The update interval of the worker + * @private + * @type {Number} + */ + this._updateInterval = updateInterval; + /** + * The callback to invoke at regular intervals + * @type {Function} + * @private + */ + this._callback = Tone.defaultArg(callback, Tone.noOp); + //create the clock source for the first time + this._createClock(); + }; + /** + * The possible ticker types + * @private + * @type {Object} + */ + Ticker.Type = { + Worker: 'worker', + Timeout: 'timeout', + Offline: 'offline' + }; + /** + * Generate a web worker + * @return {WebWorker} + * @private + */ + Ticker.prototype._createWorker = function () { + //URL Shim + window.URL = window.URL || window.webkitURL; + var blob = new Blob([//the initial timeout time + 'var timeoutTime = ' + (this._updateInterval * 1000).toFixed(1) + ';' + //onmessage callback + 'self.onmessage = function(msg){' + '\ttimeoutTime = parseInt(msg.data);' + '};' + //the tick function which posts a message + //and schedules a new tick + 'function tick(){' + '\tsetTimeout(tick, timeoutTime);' + '\tself.postMessage(\'tick\');' + '}' + //call tick initially + 'tick();']); + var blobUrl = URL.createObjectURL(blob); + var worker = new Worker(blobUrl); + worker.onmessage = this._callback.bind(this); + this._worker = worker; + }; + /** + * Create a timeout loop + * @private + */ + Ticker.prototype._createTimeout = function () { + this._timeout = setTimeout(function () { + this._createTimeout(); + this._callback(); + }.bind(this), this._updateInterval * 1000); + }; + /** + * Create the clock source. + * @private + */ + Ticker.prototype._createClock = function () { + if (this._type === Ticker.Type.Worker) { + try { + this._createWorker(); + } catch (e) { + // workers not supported, fallback to timeout + this._type = Ticker.Type.Timeout; + this._createClock(); + } + } else if (this._type === Ticker.Type.Timeout) { + this._createTimeout(); + } + }; + /** + * @memberOf Ticker# + * @type {Number} + * @name updateInterval + * @private + */ + Object.defineProperty(Ticker.prototype, 'updateInterval', { + get: function () { + return this._updateInterval; + }, + set: function (interval) { + this._updateInterval = Math.max(interval, 128 / 44100); + if (this._type === Ticker.Type.Worker) { + this._worker.postMessage(Math.max(interval * 1000, 1)); + } + } + }); + /** + * The type of the ticker, either a worker or a timeout + * @memberOf Ticker# + * @type {Number} + * @name type + * @private + */ + Object.defineProperty(Ticker.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + this._disposeClock(); + this._type = type; + this._createClock(); + } + }); + /** + * Clean up the current clock source + * @private + */ + Ticker.prototype._disposeClock = function () { + if (this._timeout) { + clearTimeout(this._timeout); + this._timeout = null; + } + if (this._worker) { + this._worker.terminate(); + this._worker.onmessage = null; + this._worker = null; + } + }; + /** + * Clean up + * @private + */ + Ticker.prototype.dispose = function () { + this._disposeClock(); + this._callback = null; + }; + /** + * Shim all connect/disconnect and some deprecated methods which are still in + * some older implementations. + * @private + */ + Tone.getContext(function () { + var nativeConnect = AudioNode.prototype.connect; + var nativeDisconnect = AudioNode.prototype.disconnect; + //replace the old connect method + function toneConnect(B, outNum, inNum) { + if (B.input) { + inNum = Tone.defaultArg(inNum, 0); + if (Tone.isArray(B.input)) { + return this.connect(B.input[inNum]); + } else { + return this.connect(B.input, outNum, inNum); + } + } else { + try { + if (B instanceof AudioNode) { + nativeConnect.call(this, B, outNum, inNum); + return B; + } else { + nativeConnect.call(this, B, outNum); + return B; + } + } catch (e) { + throw new Error('error connecting to node: ' + B + '\n' + e); + } + } + } + //replace the old disconnect method + function toneDisconnect(B, outNum, inNum) { + if (B && B.input && Tone.isArray(B.input)) { + inNum = Tone.defaultArg(inNum, 0); + this.disconnect(B.input[inNum], outNum, 0); + } else if (B && B.input) { + this.disconnect(B.input, outNum, inNum); + } else { + try { + nativeDisconnect.apply(this, arguments); + } catch (e) { + throw new Error('error disconnecting node: ' + B + '\n' + e); + } + } + } + if (AudioNode.prototype.connect !== toneConnect) { + AudioNode.prototype.connect = toneConnect; + AudioNode.prototype.disconnect = toneDisconnect; + } + }); + // set the audio context initially, and if one is not already created + if (Tone.supported && !Tone.initialized) { + Tone.context = new Tone.Context(); + // log on first initialization + // allow optional silencing of this log + if (!window.TONE_SILENCE_VERSION_LOGGING) { + // eslint-disable-next-line no-console + console.log('%c * Tone.js ' + Tone.version + ' * ', 'background: #000; color: #fff'); + } + } else if (!Tone.supported) { + // eslint-disable-next-line no-console + console.warn('This browser does not support Tone.js'); + } + return Tone.Context; + }); + Module(function (Tone) { + /** + * @class Tone.AudioNode is the base class for classes which process audio. + * AudioNodes have inputs and outputs. + * @param {AudioContext=} context The audio context to use with the class + * @extends {Tone} + */ + Tone.AudioNode = function () { + Tone.call(this); + //use the default context if one is not passed in + var options = Tone.defaults(arguments, ['context'], { 'context': Tone.context }); + /** + * The AudioContext of this instance + * @private + * @type {AudioContext} + */ + this._context = options.context; + }; + Tone.extend(Tone.AudioNode); + /** + * Get the audio context belonging to this instance. + * @type {Tone.Context} + * @memberOf Tone.AudioNode# + * @name context + * @readOnly + */ + Object.defineProperty(Tone.AudioNode.prototype, 'context', { + get: function () { + return this._context; + } + }); + /** + * Create input and outputs for this object. + * @param {Number} [input=0] The number of inputs + * @param {Number} [outputs=0] The number of outputs + * @return {Tone.AudioNode} this + * @private + */ + Tone.AudioNode.prototype.createInsOuts = function (inputs, outputs) { + if (inputs === 1) { + this.input = this.context.createGain(); + } else if (inputs > 1) { + this.input = new Array(inputs); + } + if (outputs === 1) { + this.output = this.context.createGain(); + } else if (outputs > 1) { + this.output = new Array(outputs); + } + }; + /** + * channelCount is the number of channels used when up-mixing and down-mixing + * connections to any inputs to the node. The default value is 2 except for + * specific nodes where its value is specially determined. + * + * @memberof Tone.AudioNode# + * @type {Number} + * @name channelCount + * @readOnly + */ + Object.defineProperty(Tone.AudioNode.prototype, 'channelCount', { + get: function () { + return this.output.channelCount; + }, + set: function (c) { + return this.output.channelCount = c; + } + }); + /** + * channelCountMode determines how channels will be counted when up-mixing and + * down-mixing connections to any inputs to the node. + * The default value is "max". This attribute has no effect for nodes with no inputs. + * @memberof Tone.AudioNode# + * @type {String} + * @name channelCountMode + * @readOnly + */ + Object.defineProperty(Tone.AudioNode.prototype, 'channelCountMode', { + get: function () { + return this.output.channelCountMode; + }, + set: function (m) { + return this.output.channelCountMode = m; + } + }); + /** + * channelInterpretation determines how individual channels will be treated + * when up-mixing and down-mixing connections to any inputs to the node. + * The default value is "speakers". + * @memberof Tone.AudioNode# + * @type {String} + * @name channelInterpretation + * @readOnly + */ + Object.defineProperty(Tone.AudioNode.prototype, 'channelInterpretation', { + get: function () { + return this.output.channelInterpretation; + }, + set: function (i) { + return this.output.channelInterpretation = i; + } + }); + /** + * The number of inputs feeding into the AudioNode. + * For source nodes, this will be 0. + * @type {Number} + * @name numberOfInputs + * @memberof Tone.AudioNode# + * @readOnly + */ + Object.defineProperty(Tone.AudioNode.prototype, 'numberOfInputs', { + get: function () { + if (this.input) { + if (Tone.isArray(this.input)) { + return this.input.length; + } else { + return 1; + } + } else { + return 0; + } + } + }); + /** + * The number of outputs coming out of the AudioNode. + * @type {Number} + * @name numberOfOutputs + * @memberof Tone.AudioNode# + * @readOnly + */ + Object.defineProperty(Tone.AudioNode.prototype, 'numberOfOutputs', { + get: function () { + if (this.output) { + if (Tone.isArray(this.output)) { + return this.output.length; + } else { + return 1; + } + } else { + return 0; + } + } + }); + /** + * Called when an audio param connects to this node + * @private + */ + Tone.AudioNode.prototype._onConnect = function () { + }; + /** + * connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode + * @param {Tone | AudioParam | AudioNode} unit + * @param {number} [outputNum=0] optionally which output to connect from + * @param {number} [inputNum=0] optionally which input to connect to + * @returns {Tone.AudioNode} this + */ + Tone.AudioNode.prototype.connect = function (unit, outputNum, inputNum) { + if (unit._onConnect) { + unit._onConnect(this); + } + if (Tone.isArray(this.output)) { + outputNum = Tone.defaultArg(outputNum, 0); + this.output[outputNum].connect(unit, 0, inputNum); + } else { + this.output.connect(unit, outputNum, inputNum); + } + return this; + }; + /** + * disconnect the output + * @param {Number|AudioNode} output Either the output index to disconnect + * if the output is an array, or the + * node to disconnect from. + * @returns {Tone.AudioNode} this + */ + Tone.AudioNode.prototype.disconnect = function (destination, outputNum, inputNum) { + if (Tone.isArray(this.output)) { + if (Tone.isNumber(destination)) { + this.output[destination].disconnect(); + } else { + outputNum = Tone.defaultArg(outputNum, 0); + this.output[outputNum].disconnect(destination, 0, inputNum); + } + } else { + this.output.disconnect.apply(this.output, arguments); + } + }; + /** + * Connect the output of this node to the rest of the nodes in series. + * @example + * //connect a node to an effect, panVol and then to the master output + * node.chain(effect, panVol, Tone.Master); + * @param {...AudioParam|Tone|AudioNode} nodes + * @returns {Tone.AudioNode} this + * @private + */ + Tone.AudioNode.prototype.chain = function () { + var currentUnit = this; + for (var i = 0; i < arguments.length; i++) { + var toUnit = arguments[i]; + currentUnit.connect(toUnit); + currentUnit = toUnit; + } + return this; + }; + /** + * connect the output of this node to the rest of the nodes in parallel. + * @param {...AudioParam|Tone|AudioNode} nodes + * @returns {Tone.AudioNode} this + * @private + */ + Tone.AudioNode.prototype.fan = function () { + for (var i = 0; i < arguments.length; i++) { + this.connect(arguments[i]); + } + return this; + }; + if (window.AudioNode) { + //give native nodes chain and fan methods + AudioNode.prototype.chain = Tone.AudioNode.prototype.chain; + AudioNode.prototype.fan = Tone.AudioNode.prototype.fan; + } + /** + * Dispose and disconnect + * @return {Tone.AudioNode} this + */ + Tone.AudioNode.prototype.dispose = function () { + if (Tone.isDefined(this.input)) { + if (this.input instanceof AudioNode) { + this.input.disconnect(); + } + this.input = null; + } + if (Tone.isDefined(this.output)) { + if (this.output instanceof AudioNode) { + this.output.disconnect(); + } + this.output = null; + } + this._context = null; + return this; + }; + return Tone.AudioNode; + }); + Module(function (Tone) { + + /** + * @class Base class for all Signals. Used Internally. + * + * @constructor + * @extends {Tone} + */ + Tone.SignalBase = function () { + Tone.AudioNode.call(this); + }; + Tone.extend(Tone.SignalBase, Tone.AudioNode); + /** + * When signals connect to other signals or AudioParams, + * they take over the output value of that signal or AudioParam. + * For all other nodes, the behavior is the same as a default <code>connect</code>. + * + * @override + * @param {AudioParam|AudioNode|Tone.Signal|Tone} node + * @param {number} [outputNumber=0] The output number to connect from. + * @param {number} [inputNumber=0] The input number to connect to. + * @returns {Tone.SignalBase} this + */ + Tone.SignalBase.prototype.connect = function (node, outputNumber, inputNumber) { + //zero it out so that the signal can have full control + if (Tone.Signal && Tone.Signal === node.constructor || Tone.Param && Tone.Param === node.constructor) { + //cancel changes + node._param.cancelScheduledValues(0); + //reset the value + node._param.value = 0; + //mark the value as overridden + node.overridden = true; + } else if (node instanceof AudioParam) { + node.cancelScheduledValues(0); + node.value = 0; + } + Tone.AudioNode.prototype.connect.call(this, node, outputNumber, inputNumber); + return this; + }; + return Tone.SignalBase; + }); + Module(function (Tone) { + if (Tone.supported) { + //fixes safari only bug which is still present in 11 + var ua = navigator.userAgent.toLowerCase(); + var isSafari = ua.includes('safari') && !ua.includes('chrome'); + if (isSafari) { + var WaveShaperNode = function (context) { + this._internalNode = this.input = this.output = context._native_createWaveShaper(); + this._curve = null; + for (var prop in this._internalNode) { + this._defineProperty(this._internalNode, prop); + } + }; + Object.defineProperty(WaveShaperNode.prototype, 'curve', { + get: function () { + return this._curve; + }, + set: function (curve) { + this._curve = curve; + var array = new Float32Array(curve.length + 1); + array.set(curve, 1); + array[0] = curve[0]; + this._internalNode.curve = array; + } + }); + WaveShaperNode.prototype._defineProperty = function (context, prop) { + if (Tone.isUndef(this[prop])) { + Object.defineProperty(this, prop, { + get: function () { + if (typeof context[prop] === 'function') { + return context[prop].bind(context); + } else { + return context[prop]; + } + }, + set: function (val) { + context[prop] = val; + } + }); + } + }; + AudioContext.prototype._native_createWaveShaper = AudioContext.prototype.createWaveShaper; + AudioContext.prototype.createWaveShaper = function () { + return new WaveShaperNode(this); + }; + } + } + }); + Module(function (Tone) { + + /** + * @class Wraps the native Web Audio API + * [WaveShaperNode](http://webaudio.github.io/web-audio-api/#the-waveshapernode-interface). + * + * @extends {Tone.SignalBase} + * @constructor + * @param {function|Array|Number} mapping The function used to define the values. + * The mapping function should take two arguments: + * the first is the value at the current position + * and the second is the array position. + * If the argument is an array, that array will be + * set as the wave shaping function. The input + * signal is an AudioRange [-1, 1] value and the output + * signal can take on any numerical values. + * + * @param {Number} [bufferLen=1024] The length of the WaveShaperNode buffer. + * @example + * var timesTwo = new Tone.WaveShaper(function(val){ + * return val * 2; + * }, 2048); + * @example + * //a waveshaper can also be constructed with an array of values + * var invert = new Tone.WaveShaper([1, -1]); + */ + Tone.WaveShaper = function (mapping, bufferLen) { + Tone.SignalBase.call(this); + /** + * the waveshaper + * @type {WaveShaperNode} + * @private + */ + this._shaper = this.input = this.output = this.context.createWaveShaper(); + /** + * the waveshapers curve + * @type {Float32Array} + * @private + */ + this._curve = null; + if (Array.isArray(mapping)) { + this.curve = mapping; + } else if (isFinite(mapping) || Tone.isUndef(mapping)) { + this._curve = new Float32Array(Tone.defaultArg(mapping, 1024)); + } else if (Tone.isFunction(mapping)) { + this._curve = new Float32Array(Tone.defaultArg(bufferLen, 1024)); + this.setMap(mapping); + } + }; + Tone.extend(Tone.WaveShaper, Tone.SignalBase); + /** + * Uses a mapping function to set the value of the curve. + * @param {function} mapping The function used to define the values. + * The mapping function take two arguments: + * the first is the value at the current position + * which goes from -1 to 1 over the number of elements + * in the curve array. The second argument is the array position. + * @returns {Tone.WaveShaper} this + * @example + * //map the input signal from [-1, 1] to [0, 10] + * shaper.setMap(function(val, index){ + * return (val + 1) * 5; + * }) + */ + Tone.WaveShaper.prototype.setMap = function (mapping) { + var array = new Array(this._curve.length); + for (var i = 0, len = this._curve.length; i < len; i++) { + var normalized = i / (len - 1) * 2 - 1; + array[i] = mapping(normalized, i); + } + this.curve = array; + return this; + }; + /** + * The array to set as the waveshaper curve. For linear curves + * array length does not make much difference, but for complex curves + * longer arrays will provide smoother interpolation. + * @memberOf Tone.WaveShaper# + * @type {Array} + * @name curve + */ + Object.defineProperty(Tone.WaveShaper.prototype, 'curve', { + get: function () { + return this._shaper.curve; + }, + set: function (mapping) { + this._curve = new Float32Array(mapping); + this._shaper.curve = this._curve; + } + }); + /** + * Specifies what type of oversampling (if any) should be used when + * applying the shaping curve. Can either be "none", "2x" or "4x". + * @memberOf Tone.WaveShaper# + * @type {string} + * @name oversample + */ + Object.defineProperty(Tone.WaveShaper.prototype, 'oversample', { + get: function () { + return this._shaper.oversample; + }, + set: function (oversampling) { + if ([ + 'none', + '2x', + '4x' + ].includes(oversampling)) { + this._shaper.oversample = oversampling; + } else { + throw new RangeError('Tone.WaveShaper: oversampling must be either \'none\', \'2x\', or \'4x\''); + } + } + }); + /** + * Clean up. + * @returns {Tone.WaveShaper} this + */ + Tone.WaveShaper.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._shaper.disconnect(); + this._shaper = null; + this._curve = null; + return this; + }; + return Tone.WaveShaper; + }); + Module(function (Tone) { + /** + * @class Tone.TimeBase is a flexible encoding of time + * which can be evaluated to and from a string. + * @extends {Tone} + * @param {Time} val The time value as a number or string + * @param {String=} units Unit values + * @example + * Tone.TimeBase(4, "n") + * Tone.TimeBase(2, "t") + * Tone.TimeBase("2t") + * Tone.TimeBase("2t") + Tone.TimeBase("4n"); + */ + Tone.TimeBase = function (val, units) { + //allows it to be constructed with or without 'new' + if (this instanceof Tone.TimeBase) { + /** + * The value + * @type {Number|String|Tone.TimeBase} + * @private + */ + this._val = val; + /** + * The units + * @type {String?} + * @private + */ + this._units = units; + //test if the value is a string representation of a number + if (Tone.isUndef(this._units) && Tone.isString(this._val) && // eslint-disable-next-line eqeqeq + parseFloat(this._val) == this._val && this._val.charAt(0) !== '+') { + this._val = parseFloat(this._val); + this._units = this._defaultUnits; + } else if (val && val.constructor === this.constructor) { + //if they're the same type, just copy values over + this._val = val._val; + this._units = val._units; + } else if (val instanceof Tone.TimeBase) { + switch (this._defaultUnits) { + case 's': + this._val = val.toSeconds(); + break; + case 'i': + this._val = val.toTicks(); + break; + case 'hz': + this._val = val.toFrequency(); + break; + case 'midi': + this._val = val.toMidi(); + break; + default: + throw new Error('Unrecognized default units ' + this._defaultUnits); + } + } + } else { + return new Tone.TimeBase(val, units); + } + }; + Tone.extend(Tone.TimeBase); + /////////////////////////////////////////////////////////////////////////// + // ABSTRACT SYNTAX TREE PARSER + /////////////////////////////////////////////////////////////////////////// + /** + * All the primary expressions. + * @private + * @type {Object} + */ + Tone.TimeBase.prototype._expressions = { + 'n': { + regexp: /^(\d+)n(\.?)$/i, + method: function (value, dot) { + value = parseInt(value); + var scalar = dot === '.' ? 1.5 : 1; + if (value === 1) { + return this._beatsToUnits(this._getTimeSignature()) * scalar; + } else { + return this._beatsToUnits(4 / value) * scalar; + } + } + }, + 't': { + regexp: /^(\d+)t$/i, + method: function (value) { + value = parseInt(value); + return this._beatsToUnits(8 / (parseInt(value) * 3)); + } + }, + 'm': { + regexp: /^(\d+)m$/i, + method: function (value) { + return this._beatsToUnits(parseInt(value) * this._getTimeSignature()); + } + }, + 'i': { + regexp: /^(\d+)i$/i, + method: function (value) { + return this._ticksToUnits(parseInt(value)); + } + }, + 'hz': { + regexp: /^(\d+(?:\.\d+)?)hz$/i, + method: function (value) { + return this._frequencyToUnits(parseFloat(value)); + } + }, + 'tr': { + regexp: /^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/, + method: function (m, q, s) { + var total = 0; + if (m && m !== '0') { + total += this._beatsToUnits(this._getTimeSignature() * parseFloat(m)); + } + if (q && q !== '0') { + total += this._beatsToUnits(parseFloat(q)); + } + if (s && s !== '0') { + total += this._beatsToUnits(parseFloat(s) / 4); + } + return total; + } + }, + 's': { + regexp: /^(\d+(?:\.\d+)?)s$/, + method: function (value) { + return this._secondsToUnits(parseFloat(value)); + } + }, + 'samples': { + regexp: /^(\d+)samples$/, + method: function (value) { + return parseInt(value) / this.context.sampleRate; + } + }, + 'default': { + regexp: /^(\d+(?:\.\d+)?)$/, + method: function (value) { + return this._expressions[this._defaultUnits].method.call(this, value); + } + } + }; + /** + * The default units if none are given. + * @type {String} + * @private + */ + Tone.TimeBase.prototype._defaultUnits = 's'; + /////////////////////////////////////////////////////////////////////////// + // TRANSPORT FALLBACKS + /////////////////////////////////////////////////////////////////////////// + /** + * Return the bpm, or 120 if Transport is not available + * @type {Number} + * @private + */ + Tone.TimeBase.prototype._getBpm = function () { + if (Tone.Transport) { + return Tone.Transport.bpm.value; + } else { + return 120; + } + }; + /** + * Return the timeSignature or 4 if Transport is not available + * @type {Number} + * @private + */ + Tone.TimeBase.prototype._getTimeSignature = function () { + if (Tone.Transport) { + return Tone.Transport.timeSignature; + } else { + return 4; + } + }; + /** + * Return the PPQ or 192 if Transport is not available + * @type {Number} + * @private + */ + Tone.TimeBase.prototype._getPPQ = function () { + if (Tone.Transport) { + return Tone.Transport.PPQ; + } else { + return 192; + } + }; + /** + * Return the current time in whichever context is relevant + * @type {Number} + * @private + */ + Tone.TimeBase.prototype._now = function () { + return this.now(); + }; + /////////////////////////////////////////////////////////////////////////// + // UNIT CONVERSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Returns the value of a frequency in the current units + * @param {Frequency} freq + * @return {Number} + * @private + */ + Tone.TimeBase.prototype._frequencyToUnits = function (freq) { + return 1 / freq; + }; + /** + * Return the value of the beats in the current units + * @param {Number} beats + * @return {Number} + * @private + */ + Tone.TimeBase.prototype._beatsToUnits = function (beats) { + return 60 / this._getBpm() * beats; + }; + /** + * Returns the value of a second in the current units + * @param {Seconds} seconds + * @return {Number} + * @private + */ + Tone.TimeBase.prototype._secondsToUnits = function (seconds) { + return seconds; + }; + /** + * Returns the value of a tick in the current time units + * @param {Ticks} ticks + * @return {Number} + * @private + */ + Tone.TimeBase.prototype._ticksToUnits = function (ticks) { + return ticks * (this._beatsToUnits(1) / this._getPPQ()); + }; + /** + * With no arguments, return 'now' + * @return {Number} + * @private + */ + Tone.TimeBase.prototype._noArg = function () { + return this._now(); + }; + /////////////////////////////////////////////////////////////////////////// + // EXPRESSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Evaluate the time value. Returns the time + * in seconds. + * @return {Seconds} + */ + Tone.TimeBase.prototype.valueOf = function () { + if (Tone.isUndef(this._val)) { + return this._noArg(); + } else if (Tone.isString(this._val) && Tone.isUndef(this._units)) { + for (var units in this._expressions) { + if (this._expressions[units].regexp.test(this._val.trim())) { + this._units = units; + break; + } + } + } + if (Tone.isDefined(this._units)) { + var expr = this._expressions[this._units]; + var matching = this._val.toString().trim().match(expr.regexp); + if (matching) { + return expr.method.apply(this, matching.slice(1)); + } else { + return expr.method.call(this, parseFloat(this._val)); + } + } else { + return this._val; + } + }; + /** + * Return the value in seconds + * @return {Seconds} + */ + Tone.TimeBase.prototype.toSeconds = function () { + return this.valueOf(); + }; + /** + * Return the value in hertz + * @return {Frequency} + */ + Tone.TimeBase.prototype.toFrequency = function () { + return 1 / this.toSeconds(); + }; + /** + * Return the time in samples + * @return {Samples} + */ + Tone.TimeBase.prototype.toSamples = function () { + return this.toSeconds() * this.context.sampleRate; + }; + /** + * Return the time in milliseconds. + * @return {Milliseconds} + */ + Tone.TimeBase.prototype.toMilliseconds = function () { + return this.toSeconds() * 1000; + }; + /** + * Clean up + * @return {Tone.TimeBase} this + */ + Tone.TimeBase.prototype.dispose = function () { + this._val = null; + this._units = null; + }; + return Tone.TimeBase; + }); + Module(function (Tone) { + /** + * @class Tone.Frequency is a primitive type for encoding Frequency values. + * Eventually all time values are evaluated to hertz + * using the `eval` method. + * @constructor + * @extends {Tone.TimeBase} + * @param {String|Number} val The time value. + * @param {String=} units The units of the value. + * @example + * Tone.Frequency("C3") // 261 + * Tone.Frequency(38, "midi") // + * Tone.Frequency("C3").transpose(4); + */ + Tone.Frequency = function (val, units) { + if (this instanceof Tone.Frequency) { + Tone.TimeBase.call(this, val, units); + } else { + return new Tone.Frequency(val, units); + } + }; + Tone.extend(Tone.Frequency, Tone.TimeBase); + /////////////////////////////////////////////////////////////////////////// + // AUGMENT BASE EXPRESSIONS + /////////////////////////////////////////////////////////////////////////// + Tone.Frequency.prototype._expressions = Object.assign({}, Tone.TimeBase.prototype._expressions, { + 'midi': { + regexp: /^(\d+(?:\.\d+)?midi)/, + method: function (value) { + if (this._defaultUnits === 'midi') { + return value; + } else { + return Tone.Frequency.mtof(value); + } + } + }, + 'note': { + regexp: /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i, + method: function (pitch, octave) { + var index = noteToScaleIndex[pitch.toLowerCase()]; + var noteNumber = index + (parseInt(octave) + 1) * 12; + if (this._defaultUnits === 'midi') { + return noteNumber; + } else { + return Tone.Frequency.mtof(noteNumber); + } + } + }, + 'tr': { + regexp: /^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/, + method: function (m, q, s) { + var total = 1; + if (m && m !== '0') { + total *= this._beatsToUnits(this._getTimeSignature() * parseFloat(m)); + } + if (q && q !== '0') { + total *= this._beatsToUnits(parseFloat(q)); + } + if (s && s !== '0') { + total *= this._beatsToUnits(parseFloat(s) / 4); + } + return total; + } + } + }); + /////////////////////////////////////////////////////////////////////////// + // EXPRESSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Transposes the frequency by the given number of semitones. + * @param {Interval} interval + * @return {Tone.Frequency} A new transposed frequency + * @example + * Tone.Frequency("A4").transpose(3); //"C5" + */ + Tone.Frequency.prototype.transpose = function (interval) { + return new this.constructor(this.valueOf() * Tone.intervalToFrequencyRatio(interval)); + }; + /** + * Takes an array of semitone intervals and returns + * an array of frequencies transposed by those intervals. + * @param {Array} intervals + * @return {Array<Tone.Frequency>} Returns an array of Frequencies + * @example + * Tone.Frequency("A4").harmonize([0, 3, 7]); //["A4", "C5", "E5"] + */ + Tone.Frequency.prototype.harmonize = function (intervals) { + return intervals.map(function (interval) { + return this.transpose(interval); + }.bind(this)); + }; + /////////////////////////////////////////////////////////////////////////// + // UNIT CONVERSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Return the value of the frequency as a MIDI note + * @return {MIDI} + * @example + * Tone.Frequency("C4").toMidi(); //60 + */ + Tone.Frequency.prototype.toMidi = function () { + return Tone.Frequency.ftom(this.valueOf()); + }; + /** + * Return the value of the frequency in Scientific Pitch Notation + * @return {Note} + * @example + * Tone.Frequency(69, "midi").toNote(); //"A4" + */ + Tone.Frequency.prototype.toNote = function () { + var freq = this.toFrequency(); + var log = Math.log2(freq / Tone.Frequency.A4); + var noteNumber = Math.round(12 * log) + 57; + var octave = Math.floor(noteNumber / 12); + if (octave < 0) { + noteNumber += -12 * octave; + } + var noteName = scaleIndexToNote[noteNumber % 12]; + return noteName + octave.toString(); + }; + /** + * Return the duration of one cycle in seconds. + * @return {Seconds} + */ + Tone.Frequency.prototype.toSeconds = function () { + return 1 / Tone.TimeBase.prototype.toSeconds.call(this); + }; + /** + * Return the value in Hertz + * @return {Frequency} + */ + Tone.Frequency.prototype.toFrequency = function () { + return Tone.TimeBase.prototype.toFrequency.call(this); + }; + /** + * Return the duration of one cycle in ticks + * @return {Ticks} + */ + Tone.Frequency.prototype.toTicks = function () { + var quarterTime = this._beatsToUnits(1); + var quarters = this.valueOf() / quarterTime; + return Math.floor(quarters * Tone.Transport.PPQ); + }; + /////////////////////////////////////////////////////////////////////////// + // UNIT CONVERSIONS HELPERS + /////////////////////////////////////////////////////////////////////////// + /** + * With no arguments, return 0 + * @return {Number} + * @private + */ + Tone.Frequency.prototype._noArg = function () { + return 0; + }; + /** + * Returns the value of a frequency in the current units + * @param {Frequency} freq + * @return {Number} + * @private + */ + Tone.Frequency.prototype._frequencyToUnits = function (freq) { + return freq; + }; + /** + * Returns the value of a tick in the current time units + * @param {Ticks} ticks + * @return {Number} + * @private + */ + Tone.Frequency.prototype._ticksToUnits = function (ticks) { + return 1 / (ticks * 60 / (Tone.Transport.bpm.value * Tone.Transport.PPQ)); + }; + /** + * Return the value of the beats in the current units + * @param {Number} beats + * @return {Number} + * @private + */ + Tone.Frequency.prototype._beatsToUnits = function (beats) { + return 1 / Tone.TimeBase.prototype._beatsToUnits.call(this, beats); + }; + /** + * Returns the value of a second in the current units + * @param {Seconds} seconds + * @return {Number} + * @private + */ + Tone.Frequency.prototype._secondsToUnits = function (seconds) { + return 1 / seconds; + }; + /** + * The default units if none are given. + * @private + */ + Tone.Frequency.prototype._defaultUnits = 'hz'; + /////////////////////////////////////////////////////////////////////////// + // FREQUENCY CONVERSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Note to scale index + * @type {Object} + */ + var noteToScaleIndex = { + 'cbb': -2, + 'cb': -1, + 'c': 0, + 'c#': 1, + 'cx': 2, + 'dbb': 0, + 'db': 1, + 'd': 2, + 'd#': 3, + 'dx': 4, + 'ebb': 2, + 'eb': 3, + 'e': 4, + 'e#': 5, + 'ex': 6, + 'fbb': 3, + 'fb': 4, + 'f': 5, + 'f#': 6, + 'fx': 7, + 'gbb': 5, + 'gb': 6, + 'g': 7, + 'g#': 8, + 'gx': 9, + 'abb': 7, + 'ab': 8, + 'a': 9, + 'a#': 10, + 'ax': 11, + 'bbb': 9, + 'bb': 10, + 'b': 11, + 'b#': 12, + 'bx': 13 + }; + /** + * scale index to note (sharps) + * @type {Array} + */ + var scaleIndexToNote = [ + 'C', + 'C#', + 'D', + 'D#', + 'E', + 'F', + 'F#', + 'G', + 'G#', + 'A', + 'A#', + 'B' + ]; + /** + * The [concert pitch](https://en.wikipedia.org/wiki/Concert_pitch) + * A4's values in Hertz. + * @type {Frequency} + * @static + */ + Tone.Frequency.A4 = 440; + /** + * Convert a MIDI note to frequency value. + * @param {MIDI} midi The midi number to convert. + * @return {Frequency} the corresponding frequency value + * @static + * @example + * Tone.Frequency.mtof(69); // returns 440 + */ + Tone.Frequency.mtof = function (midi) { + return Tone.Frequency.A4 * Math.pow(2, (midi - 69) / 12); + }; + /** + * Convert a frequency value to a MIDI note. + * @param {Frequency} frequency The value to frequency value to convert. + * @returns {MIDI} + * @static + * @example + * Tone.Frequency.ftom(440); // returns 69 + */ + Tone.Frequency.ftom = function (frequency) { + return 69 + Math.round(12 * Math.log2(frequency / Tone.Frequency.A4)); + }; + return Tone.Frequency; + }); + Module(function (Tone) { + /** + * @class Tone.Time is a primitive type for encoding Time values. + * Tone.Time can be constructed with or without the `new` keyword. Tone.Time can be passed + * into the parameter of any method which takes time as an argument. + * @constructor + * @extends {Tone.TimeBase} + * @param {String|Number} val The time value. + * @param {String=} units The units of the value. + * @example + * var t = Tone.Time("4n");//a quarter note + */ + Tone.Time = function (val, units) { + if (this instanceof Tone.Time) { + Tone.TimeBase.call(this, val, units); + } else { + return new Tone.Time(val, units); + } + }; + Tone.extend(Tone.Time, Tone.TimeBase); + /** + * Extend the base expressions + */ + Tone.Time.prototype._expressions = Object.assign({}, Tone.TimeBase.prototype._expressions, { + 'quantize': { + regexp: /^@(.+)/, + method: function (capture) { + if (Tone.Transport) { + var quantTo = new this.constructor(capture); + return Tone.Transport.nextSubdivision(quantTo); + } else { + return 0; + } + } + }, + 'now': { + regexp: /^\+(.+)/, + method: function (capture) { + return this._now() + new this.constructor(capture); + } + } + }); + /** + * Quantize the time by the given subdivision. Optionally add a + * percentage which will move the time value towards the ideal + * quantized value by that percentage. + * @param {Number|Time} val The subdivision to quantize to + * @param {NormalRange} [percent=1] Move the time value + * towards the quantized value by + * a percentage. + * @return {Number} this + * @example + * Tone.Time(21).quantize(2) //returns 22 + * Tone.Time(0.6).quantize("4n", 0.5) //returns 0.55 + */ + Tone.Time.prototype.quantize = function (subdiv, percent) { + percent = Tone.defaultArg(percent, 1); + var subdivision = new this.constructor(subdiv); + var value = this.valueOf(); + var multiple = Math.round(value / subdivision); + var ideal = multiple * subdivision; + var diff = ideal - value; + return value + diff * percent; + }; + /////////////////////////////////////////////////////////////////////////// + // CONVERSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Convert a Time to Notation. The notation values are will be the + * closest representation between 1m to 128th note. + * @return {Notation} + * @example + * //if the Transport is at 120bpm: + * Tone.Time(2).toNotation();//returns "1m" + */ + Tone.Time.prototype.toNotation = function () { + var time = this.toSeconds(); + var testNotations = ['1m']; + for (var power = 1; power < 8; power++) { + var subdiv = Math.pow(2, power); + testNotations.push(subdiv + 'n.'); + testNotations.push(subdiv + 'n'); + testNotations.push(subdiv + 't'); + } + testNotations.push('0'); + //find the closets notation representation + var closest = testNotations[0]; + var closestSeconds = Tone.Time(testNotations[0]).toSeconds(); + testNotations.forEach(function (notation) { + var notationSeconds = Tone.Time(notation).toSeconds(); + if (Math.abs(notationSeconds - time) < Math.abs(closestSeconds - time)) { + closest = notation; + closestSeconds = notationSeconds; + } + }); + return closest; + }; + /** + * Return the time encoded as Bars:Beats:Sixteenths. + * @return {BarsBeatsSixteenths} + */ + Tone.Time.prototype.toBarsBeatsSixteenths = function () { + var quarterTime = this._beatsToUnits(1); + var quarters = this.valueOf() / quarterTime; + var measures = Math.floor(quarters / this._getTimeSignature()); + var sixteenths = quarters % 1 * 4; + quarters = Math.floor(quarters) % this._getTimeSignature(); + sixteenths = sixteenths.toString(); + if (sixteenths.length > 3) { + // the additional parseFloat removes insignificant trailing zeroes + sixteenths = parseFloat(parseFloat(sixteenths).toFixed(3)); + } + var progress = [ + measures, + quarters, + sixteenths + ]; + return progress.join(':'); + }; + /** + * Return the time in ticks. + * @return {Ticks} + */ + Tone.Time.prototype.toTicks = function () { + var quarterTime = this._beatsToUnits(1); + var quarters = this.valueOf() / quarterTime; + return Math.round(quarters * this._getPPQ()); + }; + /** + * Return the time in seconds. + * @return {Seconds} + */ + Tone.Time.prototype.toSeconds = function () { + return this.valueOf(); + }; + /** + * Return the value as a midi note. + * @return {Midi} + */ + Tone.Time.prototype.toMidi = function () { + return Tone.Frequency.ftom(this.toFrequency()); + }; + return Tone.Time; + }); + Module(function (Tone) { + /** + * @class Tone.TransportTime is a the time along the Transport's + * timeline. It is similar to Tone.Time, but instead of evaluating + * against the AudioContext's clock, it is evaluated against + * the Transport's position. See [TransportTime wiki](https://github.com/Tonejs/Tone.js/wiki/TransportTime). + * @constructor + * @param {Time} val The time value as a number or string + * @param {String=} units Unit values + * @extends {Tone.Time} + */ + Tone.TransportTime = function (val, units) { + if (this instanceof Tone.TransportTime) { + Tone.Time.call(this, val, units); + } else { + return new Tone.TransportTime(val, units); + } + }; + Tone.extend(Tone.TransportTime, Tone.Time); + /** + * Return the current time in whichever context is relevant + * @type {Number} + * @private + */ + Tone.TransportTime.prototype._now = function () { + return Tone.Transport.seconds; + }; + return Tone.TransportTime; + }); + Module(function (Tone) { + /////////////////////////////////////////////////////////////////////////// + // TYPES + /////////////////////////////////////////////////////////////////////////// + /** + * Units which a value can take on. + * @enum {String} + */ + Tone.Type = { + /** + * Default units + * @typedef {Default} + */ + Default: 'number', + /** + * Time can be described in a number of ways. Read more [Time](https://github.com/Tonejs/Tone.js/wiki/Time). + * + * * Numbers, which will be taken literally as the time (in seconds). + * * Notation, ("4n", "8t") describes time in BPM and time signature relative values. + * * TransportTime, ("4:3:2") will also provide tempo and time signature relative times + * in the form BARS:QUARTERS:SIXTEENTHS. + * * Frequency, ("8hz") is converted to the length of the cycle in seconds. + * * Now-Relative, ("+1") prefix any of the above with "+" and it will be interpreted as + * "the current time plus whatever expression follows". + * * Expressions, ("3:0 + 2 - (1m / 7)") any of the above can also be combined + * into a mathematical expression which will be evaluated to compute the desired time. + * * No Argument, for methods which accept time, no argument will be interpreted as + * "now" (i.e. the currentTime). + * + * @typedef {Time} + */ + Time: 'time', + /** + * Frequency can be described similar to time, except ultimately the + * values are converted to frequency instead of seconds. A number + * is taken literally as the value in hertz. Additionally any of the + * Time encodings can be used. Note names in the form + * of NOTE OCTAVE (i.e. C4) are also accepted and converted to their + * frequency value. + * @typedef {Frequency} + */ + Frequency: 'frequency', + /** + * TransportTime describes a position along the Transport's timeline. It is + * similar to Time in that it uses all the same encodings, but TransportTime specifically + * pertains to the Transport's timeline, which is startable, stoppable, loopable, and seekable. + * [Read more](https://github.com/Tonejs/Tone.js/wiki/TransportTime) + * @typedef {TransportTime} + */ + TransportTime: 'transportTime', + /** + * Ticks are the basic subunit of the Transport. They are + * the smallest unit of time that the Transport supports. + * @typedef {Ticks} + */ + Ticks: 'ticks', + /** + * Normal values are within the range [0, 1]. + * @typedef {NormalRange} + */ + NormalRange: 'normalRange', + /** + * AudioRange values are between [-1, 1]. + * @typedef {AudioRange} + */ + AudioRange: 'audioRange', + /** + * Decibels are a logarithmic unit of measurement which is useful for volume + * because of the logarithmic way that we perceive loudness. 0 decibels + * means no change in volume. -10db is approximately half as loud and 10db + * is twice is loud. + * @typedef {Decibels} + */ + Decibels: 'db', + /** + * Half-step note increments, i.e. 12 is an octave above the root. and 1 is a half-step up. + * @typedef {Interval} + */ + Interval: 'interval', + /** + * Beats per minute. + * @typedef {BPM} + */ + BPM: 'bpm', + /** + * The value must be greater than or equal to 0. + * @typedef {Positive} + */ + Positive: 'positive', + /** + * Gain is the ratio between input and output of a signal. + * A gain of 0 is the same as silencing the signal. A gain of + * 1, causes no change to the incoming signal. + * @typedef {Gain} + */ + Gain: 'gain', + /** + * A cent is a hundredth of a semitone. + * @typedef {Cents} + */ + Cents: 'cents', + /** + * Angle between 0 and 360. + * @typedef {Degrees} + */ + Degrees: 'degrees', + /** + * A number representing a midi note. + * @typedef {MIDI} + */ + MIDI: 'midi', + /** + * A colon-separated representation of time in the form of + * Bars:Beats:Sixteenths. + * @typedef {BarsBeatsSixteenths} + */ + BarsBeatsSixteenths: 'barsBeatsSixteenths', + /** + * Sampling is the reduction of a continuous signal to a discrete signal. + * Audio is typically sampled 44100 times per second. + * @typedef {Samples} + */ + Samples: 'samples', + /** + * Hertz are a frequency representation defined as one cycle per second. + * @typedef {Hertz} + */ + Hertz: 'hertz', + /** + * A frequency represented by a letter name, + * accidental and octave. This system is known as + * [Scientific Pitch Notation](https://en.wikipedia.org/wiki/Scientific_pitch_notation). + * @typedef {Note} + */ + Note: 'note', + /** + * One millisecond is a thousandth of a second. + * @typedef {Milliseconds} + */ + Milliseconds: 'milliseconds', + /** + * Seconds are the time unit of the AudioContext. In the end, + * all values need to be evaluated to seconds. + * @typedef {Seconds} + */ + Seconds: 'seconds', + /** + * A string representing a duration relative to a measure. + * * "4n" = quarter note + * * "2m" = two measures + * * "8t" = eighth-note triplet + * @typedef {Notation} + */ + Notation: 'notation' + }; + /////////////////////////////////////////////////////////////////////////// + // AUGMENT TONE's PROTOTYPE + /////////////////////////////////////////////////////////////////////////// + /** + * Convert Time into seconds. + * + * Unlike the method which it overrides, this takes into account + * transporttime and musical notation. + * + * Time : 1.40 + * Notation: 4n or 1m or 2t + * Now Relative: +3n + * Math: 3n+16n or even complicated expressions ((3n*2)/6 + 1) + * + * @param {Time} time + * @return {Seconds} + */ + Tone.prototype.toSeconds = function (time) { + if (Tone.isNumber(time)) { + return time; + } else if (Tone.isUndef(time)) { + return this.now(); + } else if (Tone.isString(time)) { + return new Tone.Time(time).toSeconds(); + } else if (time instanceof Tone.TimeBase) { + return time.toSeconds(); + } + }; + /** + * Convert a frequency representation into a number. + * @param {Frequency} freq + * @return {Hertz} the frequency in hertz + */ + Tone.prototype.toFrequency = function (freq) { + if (Tone.isNumber(freq)) { + return freq; + } else if (Tone.isString(freq) || Tone.isUndef(freq)) { + return new Tone.Frequency(freq).valueOf(); + } else if (freq instanceof Tone.TimeBase) { + return freq.toFrequency(); + } + }; + /** + * Convert a time representation into ticks. + * @param {Time} time + * @return {Ticks} the time in ticks + */ + Tone.prototype.toTicks = function (time) { + if (Tone.isNumber(time) || Tone.isString(time)) { + return new Tone.TransportTime(time).toTicks(); + } else if (Tone.isUndef(time)) { + return Tone.Transport.ticks; + } else if (time instanceof Tone.TimeBase) { + return time.toTicks(); + } + }; + return Tone; + }); + Module(function (Tone) { + + /** + * @class Tone.Param wraps the native Web Audio's AudioParam to provide + * additional unit conversion functionality. It also + * serves as a base-class for classes which have a single, + * automatable parameter. + * @extends {Tone.AudioNode} + * @param {AudioParam} param The parameter to wrap. + * @param {Tone.Type} units The units of the audio param. + * @param {Boolean} convert If the param should be converted. + */ + Tone.Param = function () { + var options = Tone.defaults(arguments, [ + 'param', + 'units', + 'convert' + ], Tone.Param); + Tone.AudioNode.call(this); + /** + * The native parameter to control + * @type {AudioParam} + * @private + */ + this._param = this.input = options.param; + /** + * The units of the parameter + * @type {Tone.Type} + */ + this.units = options.units; + /** + * If the value should be converted or not + * @type {Boolean} + */ + this.convert = options.convert; + /** + * True if the signal value is being overridden by + * a connected signal. + * @readOnly + * @type {boolean} + * @private + */ + this.overridden = false; + /** + * The timeline which tracks all of the automations. + * @type {Tone.Timeline} + * @private + */ + this._events = new Tone.Timeline(1000); + if (Tone.isDefined(options.value) && this._param) { + this.value = options.value; + } + }; + Tone.extend(Tone.Param, Tone.AudioNode); + /** + * Defaults + * @type {Object} + * @const + */ + Tone.Param.defaults = { + 'units': Tone.Type.Default, + 'convert': true, + 'param': undefined + }; + /** + * The current value of the parameter. + * @memberOf Tone.Param# + * @type {Number} + * @name value + */ + Object.defineProperty(Tone.Param.prototype, 'value', { + get: function () { + var now = this.now(); + return this._toUnits(this.getValueAtTime(now)); + }, + set: function (value) { + this._initialValue = this._fromUnits(value); + this.cancelScheduledValues(this.context.currentTime); + this.setValueAtTime(value, this.context.currentTime); + } + }); + /** + * The minimum output value of the parameter + * @memberOf Tone.Param# + * @type {Number} + * @name value + */ + Object.defineProperty(Tone.Param.prototype, 'minValue', { + get: function () { + if (this.units === Tone.Type.Time || this.units === Tone.Type.Frequency || this.units === Tone.Type.NormalRange || this.units === Tone.Type.Positive || this.units === Tone.Type.BPM) { + return 0; + } else if (this.units === Tone.Type.AudioRange) { + return -1; + } else if (this.units === Tone.Type.Decibels) { + return -Infinity; + } else { + return this._param.minValue; + } + } + }); + /** + * The maximum output value of the parameter + * @memberOf Tone.Param# + * @type {Number} + * @name value + */ + Object.defineProperty(Tone.Param.prototype, 'maxValue', { + get: function () { + if (this.units === Tone.Type.NormalRange || this.units === Tone.Type.AudioRange) { + return 1; + } else { + return this._param.maxValue; + } + } + }); + /** + * Convert the given value from the type specified by Tone.Param.units + * into the destination value (such as Gain or Frequency). + * @private + * @param {*} val the value to convert + * @return {number} the number which the value should be set to + */ + Tone.Param.prototype._fromUnits = function (val) { + if ((this.convert || Tone.isUndef(this.convert)) && !this.overridden) { + switch (this.units) { + case Tone.Type.Time: + return this.toSeconds(val); + case Tone.Type.Frequency: + return this.toFrequency(val); + case Tone.Type.Decibels: + return Tone.dbToGain(val); + case Tone.Type.NormalRange: + return Math.min(Math.max(val, 0), 1); + case Tone.Type.AudioRange: + return Math.min(Math.max(val, -1), 1); + case Tone.Type.Positive: + return Math.max(val, 0); + default: + return val; + } + } else { + return val; + } + }; + /** + * Convert the parameters value into the units specified by Tone.Param.units. + * @private + * @param {number} val the value to convert + * @return {number} + */ + Tone.Param.prototype._toUnits = function (val) { + if (this.convert || Tone.isUndef(this.convert)) { + switch (this.units) { + case Tone.Type.Decibels: + return Tone.gainToDb(val); + default: + return val; + } + } else { + return val; + } + }; + /** + * the minimum output value + * @type {Number} + * @private + */ + Tone.Param.prototype._minOutput = 0.00001; + /** + * The event types + * @enum {String} + * @private + */ + Tone.Param.AutomationType = { + Linear: 'linearRampToValueAtTime', + Exponential: 'exponentialRampToValueAtTime', + Target: 'setTargetAtTime', + SetValue: 'setValueAtTime' + }; + /** + * Schedules a parameter value change at the given time. + * @param {*} value The value to set the signal. + * @param {Time} time The time when the change should occur. + * @returns {Tone.Param} this + * @example + * //set the frequency to "G4" in exactly 1 second from now. + * freq.setValueAtTime("G4", "+1"); + */ + Tone.Param.prototype.setValueAtTime = function (value, time) { + time = this.toSeconds(time); + value = this._fromUnits(value); + this._events.add({ + 'type': Tone.Param.AutomationType.SetValue, + 'value': value, + 'time': time + }); + this._param.setValueAtTime(value, time); + return this; + }; + /** + * Get the signals value at the given time. Subsequent scheduling + * may invalidate the returned value. + * @param {Time} time When to get the value + * @returns {Number} The value at the given time + */ + Tone.Param.prototype.getValueAtTime = function (time) { + time = this.toSeconds(time); + var after = this._events.getAfter(time); + var before = this._events.get(time); + var initialValue = Tone.defaultArg(this._initialValue, this._param.defaultValue); + var value = initialValue; + //if it was set by + if (before === null) { + value = initialValue; + } else if (before.type === Tone.Param.AutomationType.Target) { + var previous = this._events.getBefore(before.time); + var previousVal; + if (previous === null) { + previousVal = initialValue; + } else { + previousVal = previous.value; + } + value = this._exponentialApproach(before.time, previousVal, before.value, before.constant, time); + } else if (after === null) { + value = before.value; + } else if (after.type === Tone.Param.AutomationType.Linear) { + value = this._linearInterpolate(before.time, before.value, after.time, after.value, time); + } else if (after.type === Tone.Param.AutomationType.Exponential) { + value = this._exponentialInterpolate(before.time, before.value, after.time, after.value, time); + } else { + value = before.value; + } + return value; + }; + /** + * Creates a schedule point with the current value at the current time. + * This is useful for creating an automation anchor point in order to + * schedule changes from the current value. + * + * @param {number=} now (Optionally) pass the now value in. + * @returns {Tone.Param} this + */ + Tone.Param.prototype.setRampPoint = function (time) { + time = this.toSeconds(time); + var currentVal = this.getValueAtTime(time); + this.cancelAndHoldAtTime(time); + if (currentVal === 0) { + currentVal = this._minOutput; + } + this.setValueAtTime(this._toUnits(currentVal), time); + return this; + }; + /** + * Schedules a linear continuous change in parameter value from the + * previous scheduled parameter value to the given value. + * + * @param {number} value + * @param {Time} endTime + * @returns {Tone.Param} this + */ + Tone.Param.prototype.linearRampToValueAtTime = function (value, endTime) { + value = this._fromUnits(value); + endTime = this.toSeconds(endTime); + this._events.add({ + 'type': Tone.Param.AutomationType.Linear, + 'value': value, + 'time': endTime + }); + this._param.linearRampToValueAtTime(value, endTime); + return this; + }; + /** + * Schedules an exponential continuous change in parameter value from + * the previous scheduled parameter value to the given value. + * + * @param {number} value + * @param {Time} endTime + * @returns {Tone.Param} this + */ + Tone.Param.prototype.exponentialRampToValueAtTime = function (value, endTime) { + value = this._fromUnits(value); + value = Math.max(this._minOutput, value); + endTime = this.toSeconds(endTime); + //store the event + this._events.add({ + 'type': Tone.Param.AutomationType.Exponential, + 'time': endTime, + 'value': value + }); + this._param.exponentialRampToValueAtTime(value, endTime); + return this; + }; + /** + * Schedules an exponential continuous change in parameter value from + * the current time and current value to the given value over the + * duration of the rampTime. + * + * @param {number} value The value to ramp to. + * @param {Time} rampTime the time that it takes the + * value to ramp from it's current value + * @param {Time} [startTime=now] When the ramp should start. + * @returns {Tone.Param} this + * @example + * //exponentially ramp to the value 2 over 4 seconds. + * signal.exponentialRampTo(2, 4); + */ + Tone.Param.prototype.exponentialRampTo = function (value, rampTime, startTime) { + startTime = this.toSeconds(startTime); + this.setRampPoint(startTime); + this.exponentialRampToValueAtTime(value, startTime + this.toSeconds(rampTime)); + return this; + }; + /** + * Schedules an linear continuous change in parameter value from + * the current time and current value to the given value over the + * duration of the rampTime. + * + * @param {number} value The value to ramp to. + * @param {Time} rampTime the time that it takes the + * value to ramp from it's current value + * @param {Time} [startTime=now] When the ramp should start. + * @returns {Tone.Param} this + * @example + * //linearly ramp to the value 4 over 3 seconds. + * signal.linearRampTo(4, 3); + */ + Tone.Param.prototype.linearRampTo = function (value, rampTime, startTime) { + startTime = this.toSeconds(startTime); + this.setRampPoint(startTime); + this.linearRampToValueAtTime(value, startTime + this.toSeconds(rampTime)); + return this; + }; + /** + * Start exponentially approaching the target value at the given time. Since it + * is an exponential approach it will continue approaching after the ramp duration. The + * rampTime is the time that it takes to reach over 99% of the way towards the value. + * @param {number} value The value to ramp to. + * @param {Time} rampTime the time that it takes the + * value to ramp from it's current value + * @param {Time} [startTime=now] When the ramp should start. + * @returns {Tone.Param} this + * @example + * //exponentially ramp to the value 2 over 4 seconds. + * signal.exponentialRampTo(2, 4); + */ + Tone.Param.prototype.targetRampTo = function (value, rampTime, startTime) { + startTime = this.toSeconds(startTime); + this.setRampPoint(startTime); + this.exponentialApproachValueAtTime(value, startTime, rampTime); + return this; + }; + /** + * Start exponentially approaching the target value at the given time. Since it + * is an exponential approach it will continue approaching after the ramp duration. The + * rampTime is the time that it takes to reach over 99% of the way towards the value. This methods + * is similar to setTargetAtTime except the third argument is a time instead of a 'timeConstant' + * @param {number} value The value to ramp to. + * @param {Time} time When the ramp should start. + * @param {Time} rampTime the time that it takes the + * value to ramp from it's current value + * @returns {Tone.Param} this + * @example + * //exponentially ramp to the value 2 over 4 seconds. + * signal.exponentialRampTo(2, 4); + */ + Tone.Param.prototype.exponentialApproachValueAtTime = function (value, time, rampTime) { + var timeConstant = Math.log(this.toSeconds(rampTime) + 1) / Math.log(200); + time = this.toSeconds(time); + return this.setTargetAtTime(value, time, timeConstant); + }; + /** + * Start exponentially approaching the target value at the given time with + * a rate having the given time constant. + * @param {number} value + * @param {Time} startTime + * @param {number} timeConstant + * @returns {Tone.Param} this + */ + Tone.Param.prototype.setTargetAtTime = function (value, startTime, timeConstant) { + value = this._fromUnits(value); + // The value will never be able to approach without timeConstant > 0. + if (timeConstant <= 0) { + throw new Error('timeConstant must be greater than 0'); + } + startTime = this.toSeconds(startTime); + this._events.add({ + 'type': Tone.Param.AutomationType.Target, + 'value': value, + 'time': startTime, + 'constant': timeConstant + }); + this._param.setTargetAtTime(value, startTime, timeConstant); + return this; + }; + /** + * Sets an array of arbitrary parameter values starting at the given time + * for the given duration. + * + * @param {Array} values + * @param {Time} startTime + * @param {Time} duration + * @param {NormalRange} [scaling=1] If the values in the curve should be scaled by some value + * @returns {Tone.Param} this + */ + Tone.Param.prototype.setValueCurveAtTime = function (values, startTime, duration, scaling) { + scaling = Tone.defaultArg(scaling, 1); + duration = this.toSeconds(duration); + startTime = this.toSeconds(startTime); + this.setValueAtTime(values[0] * scaling, startTime); + var segTime = duration / (values.length - 1); + for (var i = 1; i < values.length; i++) { + this.linearRampToValueAtTime(values[i] * scaling, startTime + i * segTime); + } + return this; + }; + /** + * Cancels all scheduled parameter changes with times greater than or + * equal to startTime. + * + * @param {Time} time + * @returns {Tone.Param} this + */ + Tone.Param.prototype.cancelScheduledValues = function (time) { + time = this.toSeconds(time); + this._events.cancel(time); + this._param.cancelScheduledValues(time); + return this; + }; + /** + * This is similar to [cancelScheduledValues](#cancelScheduledValues) except + * it holds the automated value at time until the next automated event. + * @param {Time} time + * @returns {Tone.Param} this + */ + Tone.Param.prototype.cancelAndHoldAtTime = function (time) { + var valueAtTime = this.getValueAtTime(time); + //if there is an event at the given time + //and that even is not a "set" + var before = this._events.get(time); + var after = this._events.getAfter(time); + if (before && before.time === time) { + //remove everything after + if (after) { + this._events.cancel(after.time); + } else { + this._events.cancel(time + 0.000001); + } + } else if (after) { + //cancel the next event(s) + this._events.cancel(after.time); + if (!this._param.cancelAndHoldAtTime) { + this._param.cancelScheduledValues(time); + } + if (after.type === Tone.Param.AutomationType.Linear) { + if (!this._param.cancelAndHoldAtTime) { + this.linearRampToValueAtTime(valueAtTime, time); + } else { + this._events.add({ + 'type': Tone.Param.AutomationType.Linear, + 'value': valueAtTime, + 'time': time + }); + } + } else if (after.type === Tone.Param.AutomationType.Exponential) { + if (!this._param.cancelAndHoldAtTime) { + this.exponentialRampToValueAtTime(valueAtTime, time); + } else { + this._events.add({ + 'type': Tone.Param.AutomationType.Exponential, + 'value': valueAtTime, + 'time': time + }); + } + } + } + //set the value at the given time + this._events.add({ + 'type': Tone.Param.AutomationType.SetValue, + 'value': valueAtTime, + 'time': time + }); + if (this._param.cancelAndHoldAtTime) { + this._param.cancelAndHoldAtTime(time); + } else { + this._param.setValueAtTime(valueAtTime, time); + } + return this; + }; + /** + * Ramps to the given value over the duration of the rampTime. + * Automatically selects the best ramp type (exponential or linear) + * depending on the `units` of the signal + * + * @param {number} value + * @param {Time} rampTime The time that it takes the + * value to ramp from it's current value + * @param {Time} [startTime=now] When the ramp should start. + * @returns {Tone.Param} this + * @example + * //ramp to the value either linearly or exponentially + * //depending on the "units" value of the signal + * signal.rampTo(0, 10); + * @example + * //schedule it to ramp starting at a specific time + * signal.rampTo(0, 10, 5) + */ + Tone.Param.prototype.rampTo = function (value, rampTime, startTime) { + rampTime = Tone.defaultArg(rampTime, 0.1); + if (this.units === Tone.Type.Frequency || this.units === Tone.Type.BPM || this.units === Tone.Type.Decibels) { + this.exponentialRampTo(value, rampTime, startTime); + } else { + this.linearRampTo(value, rampTime, startTime); + } + return this; + }; + /////////////////////////////////////////////////////////////////////////// + // AUTOMATION CURVE CALCULATIONS + // MIT License, copyright (c) 2014 Jordan Santell + /////////////////////////////////////////////////////////////////////////// + // Calculates the the value along the curve produced by setTargetAtTime + Tone.Param.prototype._exponentialApproach = function (t0, v0, v1, timeConstant, t) { + return v1 + (v0 - v1) * Math.exp(-(t - t0) / timeConstant); + }; + // Calculates the the value along the curve produced by linearRampToValueAtTime + Tone.Param.prototype._linearInterpolate = function (t0, v0, t1, v1, t) { + return v0 + (v1 - v0) * ((t - t0) / (t1 - t0)); + }; + // Calculates the the value along the curve produced by exponentialRampToValueAtTime + Tone.Param.prototype._exponentialInterpolate = function (t0, v0, t1, v1, t) { + return v0 * Math.pow(v1 / v0, (t - t0) / (t1 - t0)); + }; + /** + * Clean up + * @returns {Tone.Param} this + */ + Tone.Param.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._param = null; + this._events = null; + return this; + }; + return Tone.Param; + }); + Module(function (Tone) { + /** + * @class Wrapper around the OfflineAudioContext + * @extends {Tone.Context} + * @param {Number} channels The number of channels to render + * @param {Number} duration The duration to render in samples + * @param {Number} sampleRate the sample rate to render at + */ + Tone.OfflineContext = function (channels, duration, sampleRate) { + /** + * The offline context + * @private + * @type {OfflineAudioContext} + */ + var offlineContext = new OfflineAudioContext(channels, duration * sampleRate, sampleRate); + //wrap the methods/members + Tone.Context.call(this, { + 'context': offlineContext, + 'clockSource': 'offline', + 'lookAhead': 0, + 'updateInterval': 128 / sampleRate + }); + /** + * A private reference to the duration + * @private + * @type {Number} + */ + this._duration = duration; + /** + * An artificial clock source + * @type {Number} + * @private + */ + this._currentTime = 0; + }; + Tone.extend(Tone.OfflineContext, Tone.Context); + /** + * Override the now method to point to the internal clock time + * @return {Number} + */ + Tone.OfflineContext.prototype.now = function () { + return this._currentTime; + }; + /** + * Render the output of the OfflineContext + * @return {Promise} + */ + Tone.OfflineContext.prototype.render = function () { + while (this._duration - this._currentTime >= 0) { + //invoke all the callbacks on that time + this.emit('tick'); + //increment the clock + this._currentTime += this.blockTime; + } + return this._context.startRendering(); + }; + /** + * Close the context + * @return {Promise} + */ + Tone.OfflineContext.prototype.close = function () { + this._context = null; + return Promise.resolve(); + }; + return Tone.OfflineContext; + }); + Module(function (Tone) { + if (Tone.supported) { + var ua = navigator.userAgent.toLowerCase(); + var isMobileSafari = ua.includes('safari') && !ua.includes('chrome') && ua.includes('mobile'); + if (isMobileSafari) { + //mobile safari has a bizarre bug with the offline context + //when a BufferSourceNode is started, it starts the offline context + // + //deferring all BufferSource starts till the last possible moment + //reduces the likelihood of this happening + Tone.OfflineContext.prototype.createBufferSource = function () { + var bufferSource = this._context.createBufferSource(); + var _native_start = bufferSource.start; + bufferSource.start = function (time) { + this.setTimeout(function () { + _native_start.call(bufferSource, time); + }.bind(this), 0); + }.bind(this); + return bufferSource; + }; + } + } + }); + Module(function (Tone) { + + /** + * @class A thin wrapper around the Native Web Audio GainNode. + * The GainNode is a basic building block of the Web Audio + * API and is useful for routing audio and adjusting gains. + * @extends {Tone} + * @param {Number=} gain The initial gain of the GainNode + * @param {Tone.Type=} units The units of the gain parameter. + */ + Tone.Gain = function () { + var options = Tone.defaults(arguments, [ + 'gain', + 'units' + ], Tone.Gain); + Tone.AudioNode.call(this); + /** + * The GainNode + * @type {GainNode} + * @private + */ + this.input = this.output = this._gainNode = this.context.createGain(); + /** + * The gain parameter of the gain node. + * @type {Gain} + * @signal + */ + this.gain = new Tone.Param({ + 'param': this._gainNode.gain, + 'units': options.units, + 'value': options.gain, + 'convert': options.convert + }); + this._readOnly('gain'); + }; + Tone.extend(Tone.Gain, Tone.AudioNode); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.Gain.defaults = { + 'gain': 1, + 'convert': true + }; + /** + * Clean up. + * @return {Tone.Gain} this + */ + Tone.Gain.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._gainNode.disconnect(); + this._gainNode = null; + this._writable('gain'); + this.gain.dispose(); + this.gain = null; + }; + return Tone.Gain; + }); + Module(function (Tone) { + if (Tone.supported && !AudioContext.prototype.createConstantSource) { + var ConstantSourceNode = function (context) { + this.context = context; + var buffer = context.createBuffer(1, 128, context.sampleRate); + var arr = buffer.getChannelData(0); + for (var i = 0; i < arr.length; i++) { + arr[i] = 1; + } + this._bufferSource = context.createBufferSource(); + this._bufferSource.channelCount = 1; + this._bufferSource.channelCountMode = 'explicit'; + this._bufferSource.buffer = buffer; + this._bufferSource.loop = true; + var gainNode = this._output = context.createGain(); + this.offset = gainNode.gain; + this._bufferSource.connect(gainNode); + }; + ConstantSourceNode.prototype.start = function (time) { + this._bufferSource.start(time); + return this; + }; + ConstantSourceNode.prototype.stop = function (time) { + this._bufferSource.stop(time); + return this; + }; + ConstantSourceNode.prototype.connect = function () { + this._output.connect.apply(this._output, arguments); + return this; + }; + ConstantSourceNode.prototype.disconnect = function () { + this._output.disconnect.apply(this._output, arguments); + return this; + }; + AudioContext.prototype.createConstantSource = function () { + return new ConstantSourceNode(this); + }; + Tone.Context.prototype.createConstantSource = function () { + return new ConstantSourceNode(this); + }; + } + }); + Module(function (Tone) { + + /** + * @class A signal is an audio-rate value. Tone.Signal is a core component of the library. + * Unlike a number, Signals can be scheduled with sample-level accuracy. Tone.Signal + * has all of the methods available to native Web Audio + * [AudioParam](http://webaudio.github.io/web-audio-api/#the-audioparam-interface) + * as well as additional conveniences. Read more about working with signals + * [here](https://github.com/Tonejs/Tone.js/wiki/Signals). + * + * @constructor + * @extends {Tone.Param} + * @param {Number|AudioParam} [value] Initial value of the signal. If an AudioParam + * is passed in, that parameter will be wrapped + * and controlled by the Signal. + * @param {string} [units=Number] unit The units the signal is in. + * @example + * var signal = new Tone.Signal(10); + */ + Tone.Signal = function () { + var options = Tone.defaults(arguments, [ + 'value', + 'units' + ], Tone.Signal); + Tone.Param.call(this, options); + /** + * When a signal is connected to another signal or audio param, + * this signal becomes a proxy for it + * @type {Array} + * @private + */ + this._proxies = []; + /** + * Indicates if the constant source was started or not + * @private + * @type {Boolean} + */ + this._sourceStarted = false; + /** + * The constant source node which generates the signal + * @type {ConstantSourceNode} + * @private + */ + this._constantSource = this.context.createConstantSource(); + this._param = this._constantSource.offset; + this.value = options.value; + /** + * The node where the constant signal value is scaled. + * @type {GainNode} + * @private + */ + this.output = this._constantSource; + /** + * The node where the value is set. + * @type {Tone.Param} + * @private + */ + this.input = this._param = this.output.offset; + }; + Tone.extend(Tone.Signal, Tone.Param); + /** + * The default values + * @type {Object} + * @static + * @const + */ + Tone.Signal.defaults = { + 'value': 0, + 'units': Tone.Type.Default, + 'convert': true + }; + /** + * When signals connect to other signals or AudioParams, + * they take over the output value of that signal or AudioParam. + * For all other nodes, the behavior is the same as a default <code>connect</code>. + * + * @override + * @param {AudioParam|AudioNode|Tone.Signal|Tone} node + * @param {number} [outputNumber=0] The output number to connect from. + * @param {number} [inputNumber=0] The input number to connect to. + * @returns {Tone.Signal} this + * @method + */ + Tone.Signal.prototype.connect = function (node) { + //this is an optimization where this node will forward automations + //to connected nodes without any signal if possible. + if (this._isParam(node) && !this._sourceStarted) { + this._proxies.push(node); + node.overridden = true; + this._applyAutomations(node); + } else { + Tone.SignalBase.prototype.connect.apply(this, arguments); + if (!this._sourceStarted) { + this._sourceStarted = true; + this._constantSource.start(0); + } + } + return this; + }; + /** + * Takes a node as an argument and returns if it is a Param or AudioParam + * @param {*} node The node to test + * @return {Boolean} + * @private + */ + Tone.Signal.prototype._isParam = function (node) { + return Tone.Param && Tone.Param === node.constructor || node instanceof AudioParam; + }; + /** + * Discard the optimization and connect all of the proxies + * @private + */ + Tone.Signal.prototype._connectProxies = function () { + if (!this._sourceStarted) { + this._sourceStarted = true; + this._constantSource.start(0); + } + this._proxies.forEach(function (proxy) { + Tone.SignalBase.prototype.connect.call(this, proxy); + if (proxy._proxies) { + proxy._connectProxies(); + } + }.bind(this)); + }; + /** + * Invoked when a node is connected to this + * @param {AudioNode} from + * @private + */ + Tone.Signal.prototype._onConnect = function (from) { + if (!this._isParam(from)) { + //connect all the proxies + this._connectProxies(); + } + }; + /** + * Apply all the current automations to the given parameter + * @param {AudioParam} param + * @private + */ + Tone.Signal.prototype._applyAutomations = function (param) { + var now = this.context.currentTime; + param.cancelScheduledValues(now); + var currentVal = this.getValueAtTime(now); + param.setValueAtTime(currentVal, now); + this._events.forEachFrom(now, function (event) { + param[event.type](event.value, event.time, event.constant); + }); + }; + /** + * Disconnect from the given node or all nodes if no param is given. + * @param {AudioNode|AudioParam} node + * @return {Tone.Signal} this + */ + Tone.Signal.prototype.disconnect = function (node) { + if (this._proxies.includes(node)) { + var index = this._proxies.indexOf(node); + this._proxies.splice(index, 1); + } else if (!node) { + //no argument, disconnect everything + this._proxies = []; + } + return Tone.SignalBase.prototype.disconnect.apply(this, arguments); + }; + /** + * Return the current signal value at the given time. + * @param {Time} time When to get the signal value + * @return {Number} + */ + Tone.Signal.prototype.getValueAtTime = function (time) { + if (this._param.getValueAtTime) { + return this._param.getValueAtTime(time); + } else { + return Tone.Param.prototype.getValueAtTime.call(this, time); + } + }; + //wrap all of the automation methods + [ + 'setValueAtTime', + 'linearRampToValueAtTime', + 'exponentialRampToValueAtTime', + 'setTargetAtTime' + ].forEach(function (method) { + var previousMethod = Tone.Signal.prototype[method]; + Tone.Signal.prototype[method] = function () { + var args = arguments; + previousMethod.apply(this, arguments); + args[0] = this._fromUnits(args[0]); + args[1] = this.toSeconds(args[1]); + //apply it to the proxies + this._proxies.forEach(function (signal) { + signal[method].apply(signal, args); + }); + }; + }); + [ + 'cancelScheduledValues', + 'cancelAndHoldAtTime' + ].forEach(function (method) { + var previousMethod = Tone.Signal.prototype[method]; + Tone.Signal.prototype[method] = function () { + var args = arguments; + previousMethod.apply(this, arguments); + args[0] = this.toSeconds(args[0]); + //apply it to the proxies + this._proxies.forEach(function (signal) { + signal[method].apply(signal, args); + }); + }; + }); + /** + * dispose and disconnect + * @returns {Tone.Signal} this + */ + Tone.Signal.prototype.dispose = function () { + Tone.Param.prototype.dispose.call(this); + this._constantSource.disconnect(); + this._constantSource = null; + this._proxies = null; + return this; + }; + return Tone.Signal; + }); + Module(function (Tone) { + + /** + * @class Pow applies an exponent to the incoming signal. The incoming signal + * must be AudioRange. + * + * @extends {Tone.SignalBase} + * @constructor + * @param {Positive} exp The exponent to apply to the incoming signal, must be at least 2. + * @example + * var pow = new Tone.Pow(2); + * var sig = new Tone.Signal(0.5).connect(pow); + * //output of pow is 0.25. + */ + Tone.Pow = function (exp) { + Tone.SignalBase.call(this); + /** + * the exponent + * @private + * @type {number} + */ + this._exp = Tone.defaultArg(exp, 1); + /** + * @type {WaveShaperNode} + * @private + */ + this._expScaler = this.input = this.output = new Tone.WaveShaper(this._expFunc(this._exp), 8192); + }; + Tone.extend(Tone.Pow, Tone.SignalBase); + /** + * The value of the exponent. + * @memberOf Tone.Pow# + * @type {number} + * @name value + */ + Object.defineProperty(Tone.Pow.prototype, 'value', { + get: function () { + return this._exp; + }, + set: function (exp) { + this._exp = exp; + this._expScaler.setMap(this._expFunc(this._exp)); + } + }); + /** + * the function which maps the waveshaper + * @param {number} exp + * @return {function} + * @private + */ + Tone.Pow.prototype._expFunc = function (exp) { + return function (val) { + return Math.pow(Math.abs(val), exp); + }; + }; + /** + * Clean up. + * @returns {Tone.Pow} this + */ + Tone.Pow.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._expScaler.dispose(); + this._expScaler = null; + return this; + }; + return Tone.Pow; + }); + Module(function (Tone) { + + /** + * @class Tone.Envelope is an [ADSR](https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope) + * envelope generator. Tone.Envelope outputs a signal which + * can be connected to an AudioParam or Tone.Signal. + * <img src="https://upload.wikimedia.org/wikipedia/commons/e/ea/ADSR_parameter.svg"> + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Time} [attack] The amount of time it takes for the envelope to go from + * 0 to it's maximum value. + * @param {Time} [decay] The period of time after the attack that it takes for the envelope + * to fall to the sustain value. + * @param {NormalRange} [sustain] The percent of the maximum value that the envelope rests at until + * the release is triggered. + * @param {Time} [release] The amount of time after the release is triggered it takes to reach 0. + * @example + * //an amplitude envelope + * var gainNode = Tone.context.createGain(); + * var env = new Tone.Envelope({ + * "attack" : 0.1, + * "decay" : 0.2, + * "sustain" : 1, + * "release" : 0.8, + * }); + * env.connect(gainNode.gain); + */ + Tone.Envelope = function () { + //get all of the defaults + var options = Tone.defaults(arguments, [ + 'attack', + 'decay', + 'sustain', + 'release' + ], Tone.Envelope); + Tone.AudioNode.call(this); + /** + * When triggerAttack is called, the attack time is the amount of + * time it takes for the envelope to reach it's maximum value. + * @type {Time} + */ + this.attack = options.attack; + /** + * After the attack portion of the envelope, the value will fall + * over the duration of the decay time to it's sustain value. + * @type {Time} + */ + this.decay = options.decay; + /** + * The sustain value is the value + * which the envelope rests at after triggerAttack is + * called, but before triggerRelease is invoked. + * @type {NormalRange} + */ + this.sustain = options.sustain; + /** + * After triggerRelease is called, the envelope's + * value will fall to it's miminum value over the + * duration of the release time. + * @type {Time} + */ + this.release = options.release; + /** + * the next time the envelope is at standby + * @type {number} + * @private + */ + this._attackCurve = 'linear'; + /** + * the next time the envelope is at standby + * @type {number} + * @private + */ + this._releaseCurve = 'exponential'; + /** + * the signal + * @type {Tone.Signal} + * @private + */ + this._sig = this.output = new Tone.Signal(0); + //set the attackCurve initially + this.attackCurve = options.attackCurve; + this.releaseCurve = options.releaseCurve; + }; + Tone.extend(Tone.Envelope, Tone.AudioNode); + /** + * the default parameters + * @static + * @const + */ + Tone.Envelope.defaults = { + 'attack': 0.01, + 'decay': 0.1, + 'sustain': 0.5, + 'release': 1, + 'attackCurve': 'linear', + 'releaseCurve': 'exponential' + }; + /** + * Read the current value of the envelope. Useful for + * syncronizing visual output to the envelope. + * @memberOf Tone.Envelope# + * @type {Number} + * @name value + * @readOnly + */ + Object.defineProperty(Tone.Envelope.prototype, 'value', { + get: function () { + return this.getValueAtTime(this.now()); + } + }); + /** + * The shape of the attack. + * Can be any of these strings: + * <ul> + * <li>linear</li> + * <li>exponential</li> + * <li>sine</li> + * <li>cosine</li> + * <li>bounce</li> + * <li>ripple</li> + * <li>step</li> + * </ul> + * Can also be an array which describes the curve. Values + * in the array are evenly subdivided and linearly + * interpolated over the duration of the attack. + * @memberOf Tone.Envelope# + * @type {String|Array} + * @name attackCurve + * @example + * env.attackCurve = "linear"; + * @example + * //can also be an array + * env.attackCurve = [0, 0.2, 0.3, 0.4, 1] + */ + Object.defineProperty(Tone.Envelope.prototype, 'attackCurve', { + get: function () { + if (Tone.isString(this._attackCurve)) { + return this._attackCurve; + } else if (Tone.isArray(this._attackCurve)) { + //look up the name in the curves array + for (var type in Tone.Envelope.Type) { + if (Tone.Envelope.Type[type].In === this._attackCurve) { + return type; + } + } + //otherwise just return the array + return this._attackCurve; + } + }, + set: function (curve) { + //check if it's a valid type + if (Tone.Envelope.Type.hasOwnProperty(curve)) { + var curveDef = Tone.Envelope.Type[curve]; + if (Tone.isObject(curveDef)) { + this._attackCurve = curveDef.In; + } else { + this._attackCurve = curveDef; + } + } else if (Tone.isArray(curve)) { + this._attackCurve = curve; + } else { + throw new Error('Tone.Envelope: invalid curve: ' + curve); + } + } + }); + /** + * The shape of the release. See the attack curve types. + * @memberOf Tone.Envelope# + * @type {String|Array} + * @name releaseCurve + * @example + * env.releaseCurve = "linear"; + */ + Object.defineProperty(Tone.Envelope.prototype, 'releaseCurve', { + get: function () { + if (Tone.isString(this._releaseCurve)) { + return this._releaseCurve; + } else if (Tone.isArray(this._releaseCurve)) { + //look up the name in the curves array + for (var type in Tone.Envelope.Type) { + if (Tone.Envelope.Type[type].Out === this._releaseCurve) { + return type; + } + } + //otherwise just return the array + return this._releaseCurve; + } + }, + set: function (curve) { + //check if it's a valid type + if (Tone.Envelope.Type.hasOwnProperty(curve)) { + var curveDef = Tone.Envelope.Type[curve]; + if (Tone.isObject(curveDef)) { + this._releaseCurve = curveDef.Out; + } else { + this._releaseCurve = curveDef; + } + } else if (Tone.isArray(curve)) { + this._releaseCurve = curve; + } else { + throw new Error('Tone.Envelope: invalid curve: ' + curve); + } + } + }); + /** + * Trigger the attack/decay portion of the ADSR envelope. + * @param {Time} [time=now] When the attack should start. + * @param {NormalRange} [velocity=1] The velocity of the envelope scales the vales. + * number between 0-1 + * @returns {Tone.Envelope} this + * @example + * //trigger the attack 0.5 seconds from now with a velocity of 0.2 + * env.triggerAttack("+0.5", 0.2); + */ + Tone.Envelope.prototype.triggerAttack = function (time, velocity) { + time = this.toSeconds(time); + var originalAttack = this.toSeconds(this.attack); + var attack = originalAttack; + var decay = this.toSeconds(this.decay); + velocity = Tone.defaultArg(velocity, 1); + //check if it's not a complete attack + var currentValue = this.getValueAtTime(time); + if (currentValue > 0) { + //subtract the current value from the attack time + var attackRate = 1 / attack; + var remainingDistance = 1 - currentValue; + //the attack is now the remaining time + attack = remainingDistance / attackRate; + } + //attack + if (this._attackCurve === 'linear') { + this._sig.linearRampTo(velocity, attack, time); + } else if (this._attackCurve === 'exponential') { + this._sig.targetRampTo(velocity, attack, time); + } else if (attack > 0) { + this._sig.cancelAndHoldAtTime(time); + var curve = this._attackCurve; + //take only a portion of the curve + if (attack < originalAttack) { + var percentComplete = 1 - attack / originalAttack; + var sliceIndex = Math.floor(percentComplete * this._attackCurve.length); + curve = this._attackCurve.slice(sliceIndex); + //the first index is the current value + curve[0] = currentValue; + } + this._sig.setValueCurveAtTime(curve, time, attack, velocity); + } + //decay + if (decay) { + this._sig.targetRampTo(velocity * this.sustain, decay, attack + time); + } + return this; + }; + /** + * Triggers the release of the envelope. + * @param {Time} [time=now] When the release portion of the envelope should start. + * @returns {Tone.Envelope} this + * @example + * //trigger release immediately + * env.triggerRelease(); + */ + Tone.Envelope.prototype.triggerRelease = function (time) { + time = this.toSeconds(time); + var currentValue = this.getValueAtTime(time); + if (currentValue > 0) { + var release = this.toSeconds(this.release); + if (this._releaseCurve === 'linear') { + this._sig.linearRampTo(0, release, time); + } else if (this._releaseCurve === 'exponential') { + this._sig.targetRampTo(0, release, time); + } else { + var curve = this._releaseCurve; + if (Tone.isArray(curve)) { + this._sig.cancelAndHoldAtTime(time); + this._sig.setValueCurveAtTime(curve, time, release, currentValue); + } + } + } + return this; + }; + /** + * Get the scheduled value at the given time. This will + * return the unconverted (raw) value. + * @param {Number} time The time in seconds. + * @return {Number} The scheduled value at the given time. + */ + Tone.Envelope.prototype.getValueAtTime = function (time) { + return this._sig.getValueAtTime(time); + }; + /** + * triggerAttackRelease is shorthand for triggerAttack, then waiting + * some duration, then triggerRelease. + * @param {Time} duration The duration of the sustain. + * @param {Time} [time=now] When the attack should be triggered. + * @param {number} [velocity=1] The velocity of the envelope. + * @returns {Tone.Envelope} this + * @example + * //trigger the attack and then the release after 0.6 seconds. + * env.triggerAttackRelease(0.6); + */ + Tone.Envelope.prototype.triggerAttackRelease = function (duration, time, velocity) { + time = this.toSeconds(time); + this.triggerAttack(time, velocity); + this.triggerRelease(time + this.toSeconds(duration)); + return this; + }; + /** + * Cancels all scheduled envelope changes after the given time. + * @param {Time} after + * @returns {Tone.Envelope} this + */ + Tone.Envelope.prototype.cancel = function (after) { + this._sig.cancelScheduledValues(after); + return this; + }; + /** + * Borrows the connect method from Tone.Signal. + * @function + * @private + */ + Tone.Envelope.prototype.connect = Tone.SignalBase.prototype.connect; + /** + * Generate some complex envelope curves. + */ + (function _createCurves() { + var curveLen = 128; + var i, k; + //cosine curve + var cosineCurve = []; + for (i = 0; i < curveLen; i++) { + cosineCurve[i] = Math.sin(i / (curveLen - 1) * (Math.PI / 2)); + } + //ripple curve + var rippleCurve = []; + var rippleCurveFreq = 6.4; + for (i = 0; i < curveLen - 1; i++) { + k = i / (curveLen - 1); + var sineWave = Math.sin(k * (Math.PI * 2) * rippleCurveFreq - Math.PI / 2) + 1; + rippleCurve[i] = sineWave / 10 + k * 0.83; + } + rippleCurve[curveLen - 1] = 1; + //stairs curve + var stairsCurve = []; + var steps = 5; + for (i = 0; i < curveLen; i++) { + stairsCurve[i] = Math.ceil(i / (curveLen - 1) * steps) / steps; + } + //in-out easing curve + var sineCurve = []; + for (i = 0; i < curveLen; i++) { + k = i / (curveLen - 1); + sineCurve[i] = 0.5 * (1 - Math.cos(Math.PI * k)); + } + //a bounce curve + var bounceCurve = []; + for (i = 0; i < curveLen; i++) { + k = i / (curveLen - 1); + var freq = Math.pow(k, 3) * 4 + 0.2; + var val = Math.cos(freq * Math.PI * 2 * k); + bounceCurve[i] = Math.abs(val * (1 - k)); + } + /** + * Invert a value curve to make it work for the release + * @private + */ + function invertCurve(curve) { + var out = new Array(curve.length); + for (var j = 0; j < curve.length; j++) { + out[j] = 1 - curve[j]; + } + return out; + } + /** + * reverse the curve + * @private + */ + function reverseCurve(curve) { + return curve.slice(0).reverse(); + } + /** + * attack and release curve arrays + * @type {Object} + * @private + */ + Tone.Envelope.Type = { + 'linear': 'linear', + 'exponential': 'exponential', + 'bounce': { + In: invertCurve(bounceCurve), + Out: bounceCurve + }, + 'cosine': { + In: cosineCurve, + Out: reverseCurve(cosineCurve) + }, + 'step': { + In: stairsCurve, + Out: invertCurve(stairsCurve) + }, + 'ripple': { + In: rippleCurve, + Out: invertCurve(rippleCurve) + }, + 'sine': { + In: sineCurve, + Out: invertCurve(sineCurve) + } + }; + }()); + /** + * Disconnect and dispose. + * @returns {Tone.Envelope} this + */ + Tone.Envelope.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._sig.dispose(); + this._sig = null; + this._attackCurve = null; + this._releaseCurve = null; + return this; + }; + return Tone.Envelope; + }); + Module(function (Tone) { + + /** + * @class Tone.AmplitudeEnvelope is a Tone.Envelope connected to a gain node. + * Unlike Tone.Envelope, which outputs the envelope's value, Tone.AmplitudeEnvelope accepts + * an audio signal as the input and will apply the envelope to the amplitude + * of the signal. Read more about ADSR Envelopes on [Wikipedia](https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope). + * + * @constructor + * @extends {Tone.Envelope} + * @param {Time|Object} [attack] The amount of time it takes for the envelope to go from + * 0 to it's maximum value. + * @param {Time} [decay] The period of time after the attack that it takes for the envelope + * to fall to the sustain value. + * @param {NormalRange} [sustain] The percent of the maximum value that the envelope rests at until + * the release is triggered. + * @param {Time} [release] The amount of time after the release is triggered it takes to reach 0. + * @example + * var ampEnv = new Tone.AmplitudeEnvelope({ + * "attack": 0.1, + * "decay": 0.2, + * "sustain": 1.0, + * "release": 0.8 + * }).toMaster(); + * //create an oscillator and connect it + * var osc = new Tone.Oscillator().connect(ampEnv).start(); + * //trigger the envelopes attack and release "8t" apart + * ampEnv.triggerAttackRelease("8t"); + */ + Tone.AmplitudeEnvelope = function () { + Tone.Envelope.apply(this, arguments); + /** + * the input node + * @type {GainNode} + * @private + */ + this.input = this.output = new Tone.Gain(); + this._sig.connect(this.output.gain); + }; + Tone.extend(Tone.AmplitudeEnvelope, Tone.Envelope); + /** + * Clean up + * @return {Tone.AmplitudeEnvelope} this + */ + Tone.AmplitudeEnvelope.prototype.dispose = function () { + Tone.Envelope.prototype.dispose.call(this); + return this; + }; + return Tone.AmplitudeEnvelope; + }); + Module(function (Tone) { + /** + * AnalyserNode.getFloatTimeDomainData polyfill + * @private + */ + if (Tone.supported) { + if (!AnalyserNode.prototype.getFloatTimeDomainData) { + //referenced https://github.com/mohayonao/get-float-time-domain-data + AnalyserNode.prototype.getFloatTimeDomainData = function (array) { + var uint8 = new Uint8Array(array.length); + this.getByteTimeDomainData(uint8); + for (var i = 0; i < uint8.length; i++) { + array[i] = (uint8[i] - 128) / 128; + } + }; + } + } + }); + Module(function (Tone) { + + /** + * @class Wrapper around the native Web Audio's + * [AnalyserNode](http://webaudio.github.io/web-audio-api/#idl-def-AnalyserNode). + * Extracts FFT or Waveform data from the incoming signal. + * @extends {Tone.AudioNode} + * @param {String=} type The return type of the analysis, either "fft", or "waveform". + * @param {Number=} size The size of the FFT. Value must be a power of + * two in the range 32 to 32768. + */ + Tone.Analyser = function () { + var options = Tone.defaults(arguments, [ + 'type', + 'size' + ], Tone.Analyser); + Tone.AudioNode.call(this); + /** + * The analyser node. + * @private + * @type {AnalyserNode} + */ + this._analyser = this.input = this.output = this.context.createAnalyser(); + /** + * The analysis type + * @type {String} + * @private + */ + this._type = options.type; + /** + * The buffer that the FFT data is written to + * @type {TypedArray} + * @private + */ + this._buffer = null; + //set the values initially + this.size = options.size; + this.type = options.type; + }; + Tone.extend(Tone.Analyser, Tone.AudioNode); + /** + * The default values. + * @type {Object} + * @const + */ + Tone.Analyser.defaults = { + 'size': 1024, + 'type': 'fft', + 'smoothing': 0.8 + }; + /** + * Possible return types of analyser.getValue() + * @enum {String} + */ + Tone.Analyser.Type = { + Waveform: 'waveform', + FFT: 'fft' + }; + /** + * Run the analysis given the current settings and return the + * result as a TypedArray. + * @returns {TypedArray} + */ + Tone.Analyser.prototype.getValue = function () { + if (this._type === Tone.Analyser.Type.FFT) { + this._analyser.getFloatFrequencyData(this._buffer); + } else if (this._type === Tone.Analyser.Type.Waveform) { + this._analyser.getFloatTimeDomainData(this._buffer); + } + return this._buffer; + }; + /** + * The size of analysis. This must be a power of two in the range 32 to 32768. + * @memberOf Tone.Analyser# + * @type {Number} + * @name size + */ + Object.defineProperty(Tone.Analyser.prototype, 'size', { + get: function () { + return this._analyser.frequencyBinCount; + }, + set: function (size) { + this._analyser.fftSize = size * 2; + this._buffer = new Float32Array(size); + } + }); + /** + * The analysis function returned by analyser.getValue(), either "fft" or "waveform". + * @memberOf Tone.Analyser# + * @type {String} + * @name type + */ + Object.defineProperty(Tone.Analyser.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + if (type !== Tone.Analyser.Type.Waveform && type !== Tone.Analyser.Type.FFT) { + throw new TypeError('Tone.Analyser: invalid type: ' + type); + } + this._type = type; + } + }); + /** + * 0 represents no time averaging with the last analysis frame. + * @memberOf Tone.Analyser# + * @type {NormalRange} + * @name smoothing + */ + Object.defineProperty(Tone.Analyser.prototype, 'smoothing', { + get: function () { + return this._analyser.smoothingTimeConstant; + }, + set: function (val) { + this._analyser.smoothingTimeConstant = val; + } + }); + /** + * Clean up. + * @return {Tone.Analyser} this + */ + Tone.Analyser.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._analyser.disconnect(); + this._analyser = null; + this._buffer = null; + }; + return Tone.Analyser; + }); + Module(function (Tone) { + + /** + * @class Tone.Compressor is a thin wrapper around the Web Audio + * [DynamicsCompressorNode](http://webaudio.github.io/web-audio-api/#the-dynamicscompressornode-interface). + * Compression reduces the volume of loud sounds or amplifies quiet sounds + * by narrowing or "compressing" an audio signal's dynamic range. + * Read more on [Wikipedia](https://en.wikipedia.org/wiki/Dynamic_range_compression). + * + * @extends {Tone.AudioNode} + * @constructor + * @param {Decibels|Object} [threshold] The value above which the compression starts to be applied. + * @param {Positive} [ratio] The gain reduction ratio. + * @example + * var comp = new Tone.Compressor(-30, 3); + */ + Tone.Compressor = function () { + var options = Tone.defaults(arguments, [ + 'threshold', + 'ratio' + ], Tone.Compressor); + Tone.AudioNode.call(this); + /** + * the compressor node + * @type {DynamicsCompressorNode} + * @private + */ + this._compressor = this.input = this.output = this.context.createDynamicsCompressor(); + /** + * the threshold vaue + * @type {Decibels} + * @signal + */ + this.threshold = new Tone.Param({ + 'param': this._compressor.threshold, + 'units': Tone.Type.Decibels, + 'convert': false + }); + /** + * The attack parameter + * @type {Time} + * @signal + */ + this.attack = new Tone.Param(this._compressor.attack, Tone.Type.Time); + /** + * The release parameter + * @type {Time} + * @signal + */ + this.release = new Tone.Param(this._compressor.release, Tone.Type.Time); + /** + * The knee parameter + * @type {Decibels} + * @signal + */ + this.knee = new Tone.Param({ + 'param': this._compressor.knee, + 'units': Tone.Type.Decibels, + 'convert': false + }); + /** + * The ratio value + * @type {Number} + * @signal + */ + this.ratio = new Tone.Param({ + 'param': this._compressor.ratio, + 'convert': false + }); + //set the defaults + this._readOnly([ + 'knee', + 'release', + 'attack', + 'ratio', + 'threshold' + ]); + this.set(options); + }; + Tone.extend(Tone.Compressor, Tone.AudioNode); + /** + * @static + * @const + * @type {Object} + */ + Tone.Compressor.defaults = { + 'ratio': 12, + 'threshold': -24, + 'release': 0.25, + 'attack': 0.003, + 'knee': 30 + }; + /** + * clean up + * @returns {Tone.Compressor} this + */ + Tone.Compressor.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'knee', + 'release', + 'attack', + 'ratio', + 'threshold' + ]); + this._compressor.disconnect(); + this._compressor = null; + this.attack.dispose(); + this.attack = null; + this.release.dispose(); + this.release = null; + this.threshold.dispose(); + this.threshold = null; + this.ratio.dispose(); + this.ratio = null; + this.knee.dispose(); + this.knee = null; + return this; + }; + return Tone.Compressor; + }); + Module(function (Tone) { + + /** + * @class Add a signal and a number or two signals. When no value is + * passed into the constructor, Tone.Add will sum <code>input[0]</code> + * and <code>input[1]</code>. If a value is passed into the constructor, + * the it will be added to the input. + * + * @constructor + * @extends {Tone.Signal} + * @param {number=} value If no value is provided, Tone.Add will sum the first + * and second inputs. + * @example + * var signal = new Tone.Signal(2); + * var add = new Tone.Add(2); + * signal.connect(add); + * //the output of add equals 4 + * @example + * //if constructed with no arguments + * //it will add the first and second inputs + * var add = new Tone.Add(); + * var sig0 = new Tone.Signal(3).connect(add, 0, 0); + * var sig1 = new Tone.Signal(4).connect(add, 0, 1); + * //the output of add equals 7. + */ + Tone.Add = function (value) { + Tone.Signal.call(this); + this.createInsOuts(2, 0); + /** + * the summing node + * @type {GainNode} + * @private + */ + this._sum = this.input[0] = this.input[1] = this.output = new Tone.Gain(); + /** + * @private + * @type {Tone.Signal} + */ + this._param = this.input[1] = new Tone.Signal(value); + this._param.connect(this._sum); + }; + Tone.extend(Tone.Add, Tone.Signal); + /** + * Clean up. + * @returns {Tone.Add} this + */ + Tone.Add.prototype.dispose = function () { + Tone.Signal.prototype.dispose.call(this); + this._sum.dispose(); + this._sum = null; + return this; + }; + return Tone.Add; + }); + Module(function (Tone) { + + /** + * @class Multiply two incoming signals. Or, if a number is given in the constructor, + * multiplies the incoming signal by that value. + * + * @constructor + * @extends {Tone.Signal} + * @param {number=} value Constant value to multiple. If no value is provided, + * it will return the product of the first and second inputs + * @example + * var mult = new Tone.Multiply(); + * var sigA = new Tone.Signal(3); + * var sigB = new Tone.Signal(4); + * sigA.connect(mult, 0, 0); + * sigB.connect(mult, 0, 1); + * //output of mult is 12. + * @example + * var mult = new Tone.Multiply(10); + * var sig = new Tone.Signal(2).connect(mult); + * //the output of mult is 20. + */ + Tone.Multiply = function (value) { + Tone.Signal.call(this); + this.createInsOuts(2, 0); + /** + * the input node is the same as the output node + * it is also the GainNode which handles the scaling of incoming signal + * + * @type {GainNode} + * @private + */ + this._mult = this.input[0] = this.output = new Tone.Gain(); + /** + * the scaling parameter + * @type {AudioParam} + * @private + */ + this._param = this.input[1] = this.output.gain; + this.value = Tone.defaultArg(value, 0); + }; + Tone.extend(Tone.Multiply, Tone.Signal); + /** + * clean up + * @returns {Tone.Multiply} this + */ + Tone.Multiply.prototype.dispose = function () { + Tone.Signal.prototype.dispose.call(this); + this._mult.dispose(); + this._mult = null; + this._param = null; + return this; + }; + return Tone.Multiply; + }); + Module(function (Tone) { + + /** + * @class Negate the incoming signal. i.e. an input signal of 10 will output -10 + * + * @constructor + * @extends {Tone.SignalBase} + * @example + * var neg = new Tone.Negate(); + * var sig = new Tone.Signal(-2).connect(neg); + * //output of neg is positive 2. + */ + Tone.Negate = function () { + Tone.SignalBase.call(this); + /** + * negation is done by multiplying by -1 + * @type {Tone.Multiply} + * @private + */ + this._multiply = this.input = this.output = new Tone.Multiply(-1); + }; + Tone.extend(Tone.Negate, Tone.SignalBase); + /** + * clean up + * @returns {Tone.Negate} this + */ + Tone.Negate.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._multiply.dispose(); + this._multiply = null; + return this; + }; + return Tone.Negate; + }); + Module(function (Tone) { + + /** + * @class Subtract the signal connected to <code>input[1]</code> from the signal connected + * to <code>input[0]</code>. If an argument is provided in the constructor, the + * signals <code>.value</code> will be subtracted from the incoming signal. + * + * @extends {Tone.Signal} + * @constructor + * @param {number=} value The value to subtract from the incoming signal. If the value + * is omitted, it will subtract the second signal from the first. + * @example + * var sub = new Tone.Subtract(1); + * var sig = new Tone.Signal(4).connect(sub); + * //the output of sub is 3. + * @example + * var sub = new Tone.Subtract(); + * var sigA = new Tone.Signal(10); + * var sigB = new Tone.Signal(2.5); + * sigA.connect(sub, 0, 0); + * sigB.connect(sub, 0, 1); + * //output of sub is 7.5 + */ + Tone.Subtract = function (value) { + Tone.Signal.call(this); + this.createInsOuts(2, 0); + /** + * the summing node + * @type {GainNode} + * @private + */ + this._sum = this.input[0] = this.output = new Tone.Gain(); + /** + * negate the input of the second input before connecting it + * to the summing node. + * @type {Tone.Negate} + * @private + */ + this._neg = new Tone.Negate(); + /** + * the node where the value is set + * @private + * @type {Tone.Signal} + */ + this._param = this.input[1] = new Tone.Signal(value); + this._param.chain(this._neg, this._sum); + }; + Tone.extend(Tone.Subtract, Tone.Signal); + /** + * Clean up. + * @returns {Tone.SignalBase} this + */ + Tone.Subtract.prototype.dispose = function () { + Tone.Signal.prototype.dispose.call(this); + this._neg.dispose(); + this._neg = null; + this._sum.disconnect(); + this._sum = null; + return this; + }; + return Tone.Subtract; + }); + Module(function (Tone) { + + /** + * @class Convert an incoming signal between 0, 1 to an equal power gain scale. + * + * @extends {Tone.SignalBase} + * @constructor + * @example + * var eqPowGain = new Tone.EqualPowerGain(); + */ + Tone.EqualPowerGain = function () { + Tone.SignalBase.call(this); + /** + * @type {Tone.WaveShaper} + * @private + */ + this._eqPower = this.input = this.output = new Tone.WaveShaper(function (val) { + if (Math.abs(val) < 0.001) { + //should output 0 when input is 0 + return 0; + } else { + return Tone.equalPowerScale(val); + } + }.bind(this), 4096); + }; + Tone.extend(Tone.EqualPowerGain, Tone.SignalBase); + /** + * clean up + * @returns {Tone.EqualPowerGain} this + */ + Tone.EqualPowerGain.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._eqPower.dispose(); + this._eqPower = null; + return this; + }; + return Tone.EqualPowerGain; + }); + Module(function (Tone) { + + /** + * @class Tone.Crossfade provides equal power fading between two inputs. + * More on crossfading technique [here](https://en.wikipedia.org/wiki/Fade_(audio_engineering)#Crossfading). + * + * @constructor + * @extends {Tone.AudioNode} + * @param {NormalRange} [initialFade=0.5] + * @example + * var crossFade = new Tone.CrossFade(0.5); + * //connect effect A to crossfade from + * //effect output 0 to crossfade input 0 + * effectA.connect(crossFade, 0, 0); + * //connect effect B to crossfade from + * //effect output 0 to crossfade input 1 + * effectB.connect(crossFade, 0, 1); + * crossFade.fade.value = 0; + * // ^ only effectA is output + * crossFade.fade.value = 1; + * // ^ only effectB is output + * crossFade.fade.value = 0.5; + * // ^ the two signals are mixed equally. + */ + Tone.CrossFade = function (initialFade) { + Tone.AudioNode.call(this); + this.createInsOuts(2, 1); + /** + * Alias for <code>input[0]</code>. + * @type {Tone.Gain} + */ + this.a = this.input[0] = new Tone.Gain(); + /** + * Alias for <code>input[1]</code>. + * @type {Tone.Gain} + */ + this.b = this.input[1] = new Tone.Gain(); + /** + * The mix between the two inputs. A fade value of 0 + * will output 100% <code>input[0]</code> and + * a value of 1 will output 100% <code>input[1]</code>. + * @type {NormalRange} + * @signal + */ + this.fade = new Tone.Signal(Tone.defaultArg(initialFade, 0.5), Tone.Type.NormalRange); + /** + * equal power gain cross fade + * @private + * @type {Tone.EqualPowerGain} + */ + this._equalPowerA = new Tone.EqualPowerGain(); + /** + * equal power gain cross fade + * @private + * @type {Tone.EqualPowerGain} + */ + this._equalPowerB = new Tone.EqualPowerGain(); + /** + * invert the incoming signal + * @private + * @type {Tone} + */ + this._one = this.context.getConstant(1); + /** + * invert the incoming signal + * @private + * @type {Tone.Subtract} + */ + this._invert = new Tone.Subtract(); + //connections + this.a.connect(this.output); + this.b.connect(this.output); + this.fade.chain(this._equalPowerB, this.b.gain); + this._one.connect(this._invert, 0, 0); + this.fade.connect(this._invert, 0, 1); + this._invert.chain(this._equalPowerA, this.a.gain); + this._readOnly('fade'); + }; + Tone.extend(Tone.CrossFade, Tone.AudioNode); + /** + * clean up + * @returns {Tone.CrossFade} this + */ + Tone.CrossFade.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable('fade'); + this._equalPowerA.dispose(); + this._equalPowerA = null; + this._equalPowerB.dispose(); + this._equalPowerB = null; + this.fade.dispose(); + this.fade = null; + this._invert.dispose(); + this._invert = null; + this._one = null; + this.a.dispose(); + this.a = null; + this.b.dispose(); + this.b = null; + return this; + }; + return Tone.CrossFade; + }); + Module(function (Tone) { + + /** + * @class Tone.Filter is a filter which allows for all of the same native methods + * as the [BiquadFilterNode](http://webaudio.github.io/web-audio-api/#the-biquadfilternode-interface). + * Tone.Filter has the added ability to set the filter rolloff at -12 + * (default), -24 and -48. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Frequency|Object} [frequency] The cutoff frequency of the filter. + * @param {string=} type The type of filter. + * @param {number=} rolloff The drop in decibels per octave after the cutoff frequency. + * 3 choices: -12, -24, and -48 + * @example + * var filter = new Tone.Filter(200, "highpass"); + */ + Tone.Filter = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type', + 'rolloff' + ], Tone.Filter); + Tone.AudioNode.call(this); + this.createInsOuts(1, 1); + /** + * the filter(s) + * @type {Array} + * @private + */ + this._filters = []; + /** + * The cutoff frequency of the filter. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The detune parameter + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(0, Tone.Type.Cents); + /** + * The gain of the filter, only used in certain filter types + * @type {Number} + * @signal + */ + this.gain = new Tone.Signal({ + 'value': options.gain, + 'convert': false + }); + /** + * The Q or Quality of the filter + * @type {Positive} + * @signal + */ + this.Q = new Tone.Signal(options.Q); + /** + * the type of the filter + * @type {string} + * @private + */ + this._type = options.type; + /** + * the rolloff value of the filter + * @type {number} + * @private + */ + this._rolloff = options.rolloff; + //set the rolloff; + this.rolloff = options.rolloff; + this._readOnly([ + 'detune', + 'frequency', + 'gain', + 'Q' + ]); + }; + Tone.extend(Tone.Filter, Tone.AudioNode); + /** + * the default parameters + * + * @static + * @type {Object} + */ + Tone.Filter.defaults = { + 'type': 'lowpass', + 'frequency': 350, + 'rolloff': -12, + 'Q': 1, + 'gain': 0 + }; + /** + * The type of the filter. Types: "lowpass", "highpass", + * "bandpass", "lowshelf", "highshelf", "notch", "allpass", or "peaking". + * @memberOf Tone.Filter# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.Filter.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + var types = [ + 'lowpass', + 'highpass', + 'bandpass', + 'lowshelf', + 'highshelf', + 'notch', + 'allpass', + 'peaking' + ]; + if (types.indexOf(type) === -1) { + throw new TypeError('Tone.Filter: invalid type ' + type); + } + this._type = type; + for (var i = 0; i < this._filters.length; i++) { + this._filters[i].type = type; + } + } + }); + /** + * The rolloff of the filter which is the drop in db + * per octave. Implemented internally by cascading filters. + * Only accepts the values -12, -24, -48 and -96. + * @memberOf Tone.Filter# + * @type {number} + * @name rolloff + */ + Object.defineProperty(Tone.Filter.prototype, 'rolloff', { + get: function () { + return this._rolloff; + }, + set: function (rolloff) { + rolloff = parseInt(rolloff, 10); + var possibilities = [ + -12, + -24, + -48, + -96 + ]; + var cascadingCount = possibilities.indexOf(rolloff); + //check the rolloff is valid + if (cascadingCount === -1) { + throw new RangeError('Tone.Filter: rolloff can only be -12, -24, -48 or -96'); + } + cascadingCount += 1; + this._rolloff = rolloff; + //first disconnect the filters and throw them away + this.input.disconnect(); + for (var i = 0; i < this._filters.length; i++) { + this._filters[i].disconnect(); + this._filters[i] = null; + } + this._filters = new Array(cascadingCount); + for (var count = 0; count < cascadingCount; count++) { + var filter = this.context.createBiquadFilter(); + filter.type = this._type; + this.frequency.connect(filter.frequency); + this.detune.connect(filter.detune); + this.Q.connect(filter.Q); + this.gain.connect(filter.gain); + this._filters[count] = filter; + } + //connect them up + var connectionChain = [this.input].concat(this._filters).concat([this.output]); + Tone.connectSeries.apply(Tone, connectionChain); + } + }); + /** + * Clean up. + * @return {Tone.Filter} this + */ + Tone.Filter.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + for (var i = 0; i < this._filters.length; i++) { + this._filters[i].disconnect(); + this._filters[i] = null; + } + this._filters = null; + this._writable([ + 'detune', + 'frequency', + 'gain', + 'Q' + ]); + this.frequency.dispose(); + this.Q.dispose(); + this.frequency = null; + this.Q = null; + this.detune.dispose(); + this.detune = null; + this.gain.dispose(); + this.gain = null; + return this; + }; + return Tone.Filter; + }); + Module(function (Tone) { + + /** + * @class Split the incoming signal into three bands (low, mid, high) + * with two crossover frequency controls. + * + * @extends {Tone.AudioNode} + * @constructor + * @param {Frequency|Object} [lowFrequency] the low/mid crossover frequency + * @param {Frequency} [highFrequency] the mid/high crossover frequency + */ + Tone.MultibandSplit = function () { + var options = Tone.defaults(arguments, [ + 'lowFrequency', + 'highFrequency' + ], Tone.MultibandSplit); + Tone.AudioNode.call(this); + /** + * the input + * @type {Tone.Gain} + * @private + */ + this.input = new Tone.Gain(); + /** + * the outputs + * @type {Array} + * @private + */ + this.output = new Array(3); + /** + * The low band. Alias for <code>output[0]</code> + * @type {Tone.Filter} + */ + this.low = this.output[0] = new Tone.Filter(0, 'lowpass'); + /** + * the lower filter of the mid band + * @type {Tone.Filter} + * @private + */ + this._lowMidFilter = new Tone.Filter(0, 'highpass'); + /** + * The mid band output. Alias for <code>output[1]</code> + * @type {Tone.Filter} + */ + this.mid = this.output[1] = new Tone.Filter(0, 'lowpass'); + /** + * The high band output. Alias for <code>output[2]</code> + * @type {Tone.Filter} + */ + this.high = this.output[2] = new Tone.Filter(0, 'highpass'); + /** + * The low/mid crossover frequency. + * @type {Frequency} + * @signal + */ + this.lowFrequency = new Tone.Signal(options.lowFrequency, Tone.Type.Frequency); + /** + * The mid/high crossover frequency. + * @type {Frequency} + * @signal + */ + this.highFrequency = new Tone.Signal(options.highFrequency, Tone.Type.Frequency); + /** + * The quality of all the filters + * @type {Number} + * @signal + */ + this.Q = new Tone.Signal(options.Q); + this.input.fan(this.low, this.high); + this.input.chain(this._lowMidFilter, this.mid); + //the frequency control signal + this.lowFrequency.connect(this.low.frequency); + this.lowFrequency.connect(this._lowMidFilter.frequency); + this.highFrequency.connect(this.mid.frequency); + this.highFrequency.connect(this.high.frequency); + //the Q value + this.Q.connect(this.low.Q); + this.Q.connect(this._lowMidFilter.Q); + this.Q.connect(this.mid.Q); + this.Q.connect(this.high.Q); + this._readOnly([ + 'high', + 'mid', + 'low', + 'highFrequency', + 'lowFrequency' + ]); + }; + Tone.extend(Tone.MultibandSplit, Tone.AudioNode); + /** + * @private + * @static + * @type {Object} + */ + Tone.MultibandSplit.defaults = { + 'lowFrequency': 400, + 'highFrequency': 2500, + 'Q': 1 + }; + /** + * Clean up. + * @returns {Tone.MultibandSplit} this + */ + Tone.MultibandSplit.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'high', + 'mid', + 'low', + 'highFrequency', + 'lowFrequency' + ]); + this.low.dispose(); + this.low = null; + this._lowMidFilter.dispose(); + this._lowMidFilter = null; + this.mid.dispose(); + this.mid = null; + this.high.dispose(); + this.high = null; + this.lowFrequency.dispose(); + this.lowFrequency = null; + this.highFrequency.dispose(); + this.highFrequency = null; + this.Q.dispose(); + this.Q = null; + return this; + }; + return Tone.MultibandSplit; + }); + Module(function (Tone) { + + /** + * @class Tone.EQ3 is a three band EQ with control over low, mid, and high gain as + * well as the low and high crossover frequencies. + * + * @constructor + * @extends {Tone.AudioNode} + * + * @param {Decibels|Object} [lowLevel] The gain applied to the lows. + * @param {Decibels} [midLevel] The gain applied to the mid. + * @param {Decibels} [highLevel] The gain applied to the high. + * @example + * var eq = new Tone.EQ3(-10, 3, -20); + */ + Tone.EQ3 = function () { + var options = Tone.defaults(arguments, [ + 'low', + 'mid', + 'high' + ], Tone.EQ3); + Tone.AudioNode.call(this); + /** + * the output node + * @type {GainNode} + * @private + */ + this.output = new Tone.Gain(); + /** + * the multiband split + * @type {Tone.MultibandSplit} + * @private + */ + this._multibandSplit = this.input = new Tone.MultibandSplit({ + 'lowFrequency': options.lowFrequency, + 'highFrequency': options.highFrequency + }); + /** + * The gain for the lower signals + * @type {Tone.Gain} + * @private + */ + this._lowGain = new Tone.Gain(options.low, Tone.Type.Decibels); + /** + * The gain for the mid signals + * @type {Tone.Gain} + * @private + */ + this._midGain = new Tone.Gain(options.mid, Tone.Type.Decibels); + /** + * The gain in decibels of the high part + * @type {Tone.Gain} + * @private + */ + this._highGain = new Tone.Gain(options.high, Tone.Type.Decibels); + /** + * The gain in decibels of the low part + * @type {Decibels} + * @signal + */ + this.low = this._lowGain.gain; + /** + * The gain in decibels of the mid part + * @type {Decibels} + * @signal + */ + this.mid = this._midGain.gain; + /** + * The gain in decibels of the high part + * @type {Decibels} + * @signal + */ + this.high = this._highGain.gain; + /** + * The Q value for all of the filters. + * @type {Positive} + * @signal + */ + this.Q = this._multibandSplit.Q; + /** + * The low/mid crossover frequency. + * @type {Frequency} + * @signal + */ + this.lowFrequency = this._multibandSplit.lowFrequency; + /** + * The mid/high crossover frequency. + * @type {Frequency} + * @signal + */ + this.highFrequency = this._multibandSplit.highFrequency; + //the frequency bands + this._multibandSplit.low.chain(this._lowGain, this.output); + this._multibandSplit.mid.chain(this._midGain, this.output); + this._multibandSplit.high.chain(this._highGain, this.output); + this._readOnly([ + 'low', + 'mid', + 'high', + 'lowFrequency', + 'highFrequency' + ]); + }; + Tone.extend(Tone.EQ3, Tone.AudioNode); + /** + * the default values + */ + Tone.EQ3.defaults = { + 'low': 0, + 'mid': 0, + 'high': 0, + 'lowFrequency': 400, + 'highFrequency': 2500 + }; + /** + * clean up + * @returns {Tone.EQ3} this + */ + Tone.EQ3.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'low', + 'mid', + 'high', + 'lowFrequency', + 'highFrequency' + ]); + this._multibandSplit.dispose(); + this._multibandSplit = null; + this.lowFrequency = null; + this.highFrequency = null; + this._lowGain.dispose(); + this._lowGain = null; + this._midGain.dispose(); + this._midGain = null; + this._highGain.dispose(); + this._highGain = null; + this.low = null; + this.mid = null; + this.high = null; + this.Q = null; + return this; + }; + return Tone.EQ3; + }); + Module(function (Tone) { + + /** + * @class Performs a linear scaling on an input signal. + * Scales a NormalRange input to between + * outputMin and outputMax. + * + * @constructor + * @extends {Tone.SignalBase} + * @param {number} [outputMin=0] The output value when the input is 0. + * @param {number} [outputMax=1] The output value when the input is 1. + * @example + * var scale = new Tone.Scale(50, 100); + * var signal = new Tone.Signal(0.5).connect(scale); + * //the output of scale equals 75 + */ + Tone.Scale = function (outputMin, outputMax) { + Tone.SignalBase.call(this); + /** + * @private + * @type {number} + */ + this._outputMin = Tone.defaultArg(outputMin, 0); + /** + * @private + * @type {number} + */ + this._outputMax = Tone.defaultArg(outputMax, 1); + /** + * @private + * @type {Tone.Multiply} + * @private + */ + this._scale = this.input = new Tone.Multiply(1); + /** + * @private + * @type {Tone.Add} + * @private + */ + this._add = this.output = new Tone.Add(0); + this._scale.connect(this._add); + this._setRange(); + }; + Tone.extend(Tone.Scale, Tone.SignalBase); + /** + * The minimum output value. This number is output when + * the value input value is 0. + * @memberOf Tone.Scale# + * @type {number} + * @name min + */ + Object.defineProperty(Tone.Scale.prototype, 'min', { + get: function () { + return this._outputMin; + }, + set: function (min) { + this._outputMin = min; + this._setRange(); + } + }); + /** + * The maximum output value. This number is output when + * the value input value is 1. + * @memberOf Tone.Scale# + * @type {number} + * @name max + */ + Object.defineProperty(Tone.Scale.prototype, 'max', { + get: function () { + return this._outputMax; + }, + set: function (max) { + this._outputMax = max; + this._setRange(); + } + }); + /** + * set the values + * @private + */ + Tone.Scale.prototype._setRange = function () { + this._add.value = this._outputMin; + this._scale.value = this._outputMax - this._outputMin; + }; + /** + * Clean up. + * @returns {Tone.Scale} this + */ + Tone.Scale.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._add.dispose(); + this._add = null; + this._scale.dispose(); + this._scale = null; + return this; + }; + return Tone.Scale; + }); + Module(function (Tone) { + /** + * @class Performs an exponential scaling on an input signal. + * Scales a NormalRange value [0,1] exponentially + * to the output range of outputMin to outputMax. + * + * @constructor + * @extends {Tone.SignalBase} + * @param {number} [outputMin=0] The output value when the input is 0. + * @param {number} [outputMax=1] The output value when the input is 1. + * @param {number} [exponent=2] The exponent which scales the incoming signal. + * @example + * var scaleExp = new Tone.ScaleExp(0, 100, 2); + * var signal = new Tone.Signal(0.5).connect(scaleExp); + */ + Tone.ScaleExp = function (outputMin, outputMax, exponent) { + Tone.SignalBase.call(this); + /** + * scale the input to the output range + * @type {Tone.Scale} + * @private + */ + this._scale = this.output = new Tone.Scale(outputMin, outputMax); + /** + * @private + * @type {Tone.Pow} + * @private + */ + this._exp = this.input = new Tone.Pow(Tone.defaultArg(exponent, 2)); + this._exp.connect(this._scale); + }; + Tone.extend(Tone.ScaleExp, Tone.SignalBase); + /** + * Instead of interpolating linearly between the <code>min</code> and + * <code>max</code> values, setting the exponent will interpolate between + * the two values with an exponential curve. + * @memberOf Tone.ScaleExp# + * @type {number} + * @name exponent + */ + Object.defineProperty(Tone.ScaleExp.prototype, 'exponent', { + get: function () { + return this._exp.value; + }, + set: function (exp) { + this._exp.value = exp; + } + }); + /** + * The minimum output value. This number is output when + * the value input value is 0. + * @memberOf Tone.ScaleExp# + * @type {number} + * @name min + */ + Object.defineProperty(Tone.ScaleExp.prototype, 'min', { + get: function () { + return this._scale.min; + }, + set: function (min) { + this._scale.min = min; + } + }); + /** + * The maximum output value. This number is output when + * the value input value is 1. + * @memberOf Tone.ScaleExp# + * @type {number} + * @name max + */ + Object.defineProperty(Tone.ScaleExp.prototype, 'max', { + get: function () { + return this._scale.max; + }, + set: function (max) { + this._scale.max = max; + } + }); + /** + * Clean up. + * @returns {Tone.ScaleExp} this + */ + Tone.ScaleExp.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._scale.dispose(); + this._scale = null; + this._exp.dispose(); + this._exp = null; + return this; + }; + return Tone.ScaleExp; + }); + Module(function (Tone) { + + /** + * @class Wrapper around Web Audio's native [DelayNode](http://webaudio.github.io/web-audio-api/#the-delaynode-interface). + * @extends {Tone} + * @param {Time=} delayTime The delay applied to the incoming signal. + * @param {Time=} maxDelay The maximum delay time. + */ + Tone.Delay = function () { + var options = Tone.defaults(arguments, [ + 'delayTime', + 'maxDelay' + ], Tone.Delay); + Tone.AudioNode.call(this); + /** + * The maximum delay time initialized with the node + * @type {Number} + * @private + */ + this._maxDelay = Math.max(this.toSeconds(options.maxDelay), this.toSeconds(options.delayTime)); + /** + * The native delay node + * @type {DelayNode} + * @private + */ + this._delayNode = this.input = this.output = this.context.createDelay(this._maxDelay); + /** + * The amount of time the incoming signal is + * delayed. + * @type {Time} + * @signal + */ + this.delayTime = new Tone.Param({ + 'param': this._delayNode.delayTime, + 'units': Tone.Type.Time, + 'value': options.delayTime + }); + this._readOnly('delayTime'); + }; + Tone.extend(Tone.Delay, Tone.AudioNode); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.Delay.defaults = { + 'maxDelay': 1, + 'delayTime': 0 + }; + /** + * The maximum delay time. This cannot be changed. The value is passed into the constructor. + * @memberof Tone.Delay# + * @type {Time} + * @name maxDelay + * @readOnly + */ + Object.defineProperty(Tone.Delay.prototype, 'maxDelay', { + get: function () { + return this._maxDelay; + } + }); + /** + * Clean up. + * @return {Tone.Delay} this + */ + Tone.Delay.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._delayNode.disconnect(); + this._delayNode = null; + this._writable('delayTime'); + this.delayTime = null; + return this; + }; + return Tone.Delay; + }); + Module(function (Tone) { + + /** + * @class Comb filters are basic building blocks for physical modeling. Read more + * about comb filters on [CCRMA's website](https://ccrma.stanford.edu/~jos/pasp/Feedback_Comb_Filters.html). + * + * @extends {Tone.AudioNode} + * @constructor + * @param {Time|Object} [delayTime] The delay time of the filter. + * @param {NormalRange=} resonance The amount of feedback the filter has. + */ + Tone.FeedbackCombFilter = function () { + var options = Tone.defaults(arguments, [ + 'delayTime', + 'resonance' + ], Tone.FeedbackCombFilter); + Tone.AudioNode.call(this); + /** + * the delay node + * @type {DelayNode} + * @private + */ + this._delay = this.input = this.output = new Tone.Delay(options.delayTime); + /** + * The amount of delay of the comb filter. + * @type {Time} + * @signal + */ + this.delayTime = this._delay.delayTime; + /** + * the feedback node + * @type {GainNode} + * @private + */ + this._feedback = new Tone.Gain(options.resonance, Tone.Type.NormalRange); + /** + * The amount of feedback of the delayed signal. + * @type {NormalRange} + * @signal + */ + this.resonance = this._feedback.gain; + this._delay.chain(this._feedback, this._delay); + this._readOnly([ + 'resonance', + 'delayTime' + ]); + }; + Tone.extend(Tone.FeedbackCombFilter, Tone.AudioNode); + /** + * the default parameters + * @static + * @const + * @type {Object} + */ + Tone.FeedbackCombFilter.defaults = { + 'delayTime': 0.1, + 'resonance': 0.5 + }; + /** + * clean up + * @returns {Tone.FeedbackCombFilter} this + */ + Tone.FeedbackCombFilter.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'resonance', + 'delayTime' + ]); + this._delay.dispose(); + this._delay = null; + this.delayTime = null; + this._feedback.dispose(); + this._feedback = null; + this.resonance = null; + return this; + }; + return Tone.FeedbackCombFilter; + }); + Module(function (Tone) { + /** + * @class Get the current waveform data of the connected audio source. + * @extends {Tone.AudioNode} + * @param {Number=} size The size of the FFT. Value must be a power of + * two in the range 32 to 32768. + */ + Tone.FFT = function () { + var options = Tone.defaults(arguments, ['size'], Tone.FFT); + options.type = Tone.Analyser.Type.FFT; + Tone.AudioNode.call(this); + /** + * The analyser node. + * @private + * @type {Tone.Analyser} + */ + this._analyser = this.input = this.output = new Tone.Analyser(options); + }; + Tone.extend(Tone.FFT, Tone.AudioNode); + /** + * The default values. + * @type {Object} + * @const + */ + Tone.FFT.defaults = { 'size': 1024 }; + /** + * Gets the waveform of the audio source. Returns the waveform data + * of length [size](#size) as a Float32Array with values between -1 and 1. + * @returns {TypedArray} + */ + Tone.FFT.prototype.getValue = function () { + return this._analyser.getValue(); + }; + /** + * The size of analysis. This must be a power of two in the range 32 to 32768. + * @memberOf Tone.FFT# + * @type {Number} + * @name size + */ + Object.defineProperty(Tone.FFT.prototype, 'size', { + get: function () { + return this._analyser.size; + }, + set: function (size) { + this._analyser.size = size; + } + }); + /** + * Clean up. + * @return {Tone.FFT} this + */ + Tone.FFT.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._analyser.dispose(); + this._analyser = null; + }; + return Tone.FFT; + }); + Module(function (Tone) { + + /** + * @class Return the absolute value of an incoming signal. + * + * @constructor + * @extends {Tone.SignalBase} + * @example + * var signal = new Tone.Signal(-1); + * var abs = new Tone.Abs(); + * signal.connect(abs); + * //the output of abs is 1. + */ + Tone.Abs = function () { + Tone.SignalBase.call(this); + /** + * @type {Tone.LessThan} + * @private + */ + this._abs = this.input = this.output = new Tone.WaveShaper(function (val) { + if (Math.abs(val) < 0.001) { + return 0; + } else { + return Math.abs(val); + } + }, 1024); + }; + Tone.extend(Tone.Abs, Tone.SignalBase); + /** + * dispose method + * @returns {Tone.Abs} this + */ + Tone.Abs.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._abs.dispose(); + this._abs = null; + return this; + }; + return Tone.Abs; + }); + Module(function (Tone) { + + /** + * @class Tone.Follower is a crude envelope follower which will follow + * the amplitude of an incoming signal. + * Take care with small (< 0.02) attack or decay values + * as follower has some ripple which is exaggerated + * at these values. Read more about envelope followers (also known + * as envelope detectors) on [Wikipedia](https://en.wikipedia.org/wiki/Envelope_detector). + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Time|Object} [attack] The rate at which the follower rises. + * @param {Time=} release The rate at which the folower falls. + * @example + * var follower = new Tone.Follower(0.2, 0.4); + */ + Tone.Follower = function () { + var options = Tone.defaults(arguments, [ + 'attack', + 'release' + ], Tone.Follower); + Tone.AudioNode.call(this); + this.createInsOuts(1, 1); + /** + * @type {Tone.Abs} + * @private + */ + this._abs = new Tone.Abs(); + /** + * the lowpass filter which smooths the input + * @type {BiquadFilterNode} + * @private + */ + this._filter = this.context.createBiquadFilter(); + this._filter.type = 'lowpass'; + this._filter.frequency.value = 0; + this._filter.Q.value = -100; + /** + * @type {WaveShaperNode} + * @private + */ + this._frequencyValues = new Tone.WaveShaper(); + /** + * @type {Tone.Subtract} + * @private + */ + this._sub = new Tone.Subtract(); + /** + * @type {Tone.Delay} + * @private + */ + this._delay = new Tone.Delay(this.blockTime); + /** + * this keeps it far from 0, even for very small differences + * @type {Tone.Multiply} + * @private + */ + this._mult = new Tone.Multiply(10000); + /** + * @private + * @type {number} + */ + this._attack = options.attack; + /** + * @private + * @type {number} + */ + this._release = options.release; + //the smoothed signal to get the values + this.input.chain(this._abs, this._filter, this.output); + //the difference path + this._abs.connect(this._sub, 0, 1); + this._filter.chain(this._delay, this._sub); + //threshold the difference and use the thresh to set the frequency + this._sub.chain(this._mult, this._frequencyValues, this._filter.frequency); + //set the attack and release values in the table + this._setAttackRelease(this._attack, this._release); + }; + Tone.extend(Tone.Follower, Tone.AudioNode); + /** + * @static + * @type {Object} + */ + Tone.Follower.defaults = { + 'attack': 0.05, + 'release': 0.5 + }; + /** + * sets the attack and release times in the wave shaper + * @param {Time} attack + * @param {Time} release + * @private + */ + Tone.Follower.prototype._setAttackRelease = function (attack, release) { + var minTime = this.blockTime; + attack = Tone.Time(attack).toFrequency(); + release = Tone.Time(release).toFrequency(); + attack = Math.max(attack, minTime); + release = Math.max(release, minTime); + this._frequencyValues.setMap(function (val) { + if (val <= 0) { + return attack; + } else { + return release; + } + }); + }; + /** + * The attack time. + * @memberOf Tone.Follower# + * @type {Time} + * @name attack + */ + Object.defineProperty(Tone.Follower.prototype, 'attack', { + get: function () { + return this._attack; + }, + set: function (attack) { + this._attack = attack; + this._setAttackRelease(this._attack, this._release); + } + }); + /** + * The release time. + * @memberOf Tone.Follower# + * @type {Time} + * @name release + */ + Object.defineProperty(Tone.Follower.prototype, 'release', { + get: function () { + return this._release; + }, + set: function (release) { + this._release = release; + this._setAttackRelease(this._attack, this._release); + } + }); + /** + * Borrows the connect method from Signal so that the output can be used + * as a Tone.Signal control signal. + * @function + */ + Tone.Follower.prototype.connect = Tone.SignalBase.prototype.connect; + /** + * dispose + * @returns {Tone.Follower} this + */ + Tone.Follower.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._filter.disconnect(); + this._filter = null; + this._frequencyValues.disconnect(); + this._frequencyValues = null; + this._delay.dispose(); + this._delay = null; + this._sub.disconnect(); + this._sub = null; + this._abs.dispose(); + this._abs = null; + this._mult.dispose(); + this._mult = null; + this._curve = null; + return this; + }; + return Tone.Follower; + }); + Module(function (Tone) { + + /** + * @class Tone.ScaledEnvelop is an envelope which can be scaled + * to any range. It's useful for applying an envelope + * to a frequency or any other non-NormalRange signal + * parameter. + * + * @extends {Tone.Envelope} + * @constructor + * @param {Time|Object} [attack] the attack time in seconds + * @param {Time} [decay] the decay time in seconds + * @param {number} [sustain] a percentage (0-1) of the full amplitude + * @param {Time} [release] the release time in seconds + * @example + * var scaledEnv = new Tone.ScaledEnvelope({ + * "attack" : 0.2, + * "min" : 200, + * "max" : 2000 + * }); + * scaledEnv.connect(oscillator.frequency); + */ + Tone.ScaledEnvelope = function () { + //get all of the defaults + var options = Tone.defaults(arguments, [ + 'attack', + 'decay', + 'sustain', + 'release' + ], Tone.Envelope); + Tone.Envelope.call(this, options); + options = Tone.defaultArg(options, Tone.ScaledEnvelope.defaults); + /** + * scale the incoming signal by an exponent + * @type {Tone.Pow} + * @private + */ + this._exp = this.output = new Tone.Pow(options.exponent); + /** + * scale the signal to the desired range + * @type {Tone.Multiply} + * @private + */ + this._scale = this.output = new Tone.Scale(options.min, options.max); + this._sig.chain(this._exp, this._scale); + }; + Tone.extend(Tone.ScaledEnvelope, Tone.Envelope); + /** + * the default parameters + * @static + */ + Tone.ScaledEnvelope.defaults = { + 'min': 0, + 'max': 1, + 'exponent': 1 + }; + /** + * The envelope's min output value. This is the value which it + * starts at. + * @memberOf Tone.ScaledEnvelope# + * @type {number} + * @name min + */ + Object.defineProperty(Tone.ScaledEnvelope.prototype, 'min', { + get: function () { + return this._scale.min; + }, + set: function (min) { + this._scale.min = min; + } + }); + /** + * The envelope's max output value. In other words, the value + * at the peak of the attack portion of the envelope. + * @memberOf Tone.ScaledEnvelope# + * @type {number} + * @name max + */ + Object.defineProperty(Tone.ScaledEnvelope.prototype, 'max', { + get: function () { + return this._scale.max; + }, + set: function (max) { + this._scale.max = max; + } + }); + /** + * The envelope's exponent value. + * @memberOf Tone.ScaledEnvelope# + * @type {number} + * @name exponent + */ + Object.defineProperty(Tone.ScaledEnvelope.prototype, 'exponent', { + get: function () { + return this._exp.value; + }, + set: function (exp) { + this._exp.value = exp; + } + }); + /** + * clean up + * @returns {Tone.ScaledEnvelope} this + */ + Tone.ScaledEnvelope.prototype.dispose = function () { + Tone.Envelope.prototype.dispose.call(this); + this._scale.dispose(); + this._scale = null; + this._exp.dispose(); + this._exp = null; + return this; + }; + return Tone.ScaledEnvelope; + }); + Module(function (Tone) { + + /** + * @class Tone.FrequencyEnvelope is a Tone.ScaledEnvelope, but instead of `min` and `max` + * it's got a `baseFrequency` and `octaves` parameter. + * + * @extends {Tone.Envelope} + * @constructor + * @param {Time|Object} [attack] the attack time in seconds + * @param {Time} [decay] the decay time in seconds + * @param {number} [sustain] a percentage (0-1) of the full amplitude + * @param {Time} [release] the release time in seconds + * @example + * var freqEnv = new Tone.FrequencyEnvelope({ + * "attack" : 0.2, + * "baseFrequency" : "C2", + * "octaves" : 4 + * }); + * freqEnv.connect(oscillator.frequency); + */ + Tone.FrequencyEnvelope = function () { + var options = Tone.defaults(arguments, [ + 'attack', + 'decay', + 'sustain', + 'release' + ], Tone.Envelope); + Tone.ScaledEnvelope.call(this, options); + //merge it with the frequency envelope defaults + options = Tone.defaultArg(options, Tone.FrequencyEnvelope.defaults); + /** + * Stores the octave value + * @type {Positive} + * @private + */ + this._octaves = options.octaves; + //setup + this.baseFrequency = options.baseFrequency; + this.octaves = options.octaves; + }; + Tone.extend(Tone.FrequencyEnvelope, Tone.Envelope); + /** + * the default parameters + * @static + */ + Tone.FrequencyEnvelope.defaults = { + 'baseFrequency': 200, + 'octaves': 4, + 'exponent': 2 + }; + /** + * The envelope's mininum output value. This is the value which it + * starts at. + * @memberOf Tone.FrequencyEnvelope# + * @type {Frequency} + * @name baseFrequency + */ + Object.defineProperty(Tone.FrequencyEnvelope.prototype, 'baseFrequency', { + get: function () { + return this._scale.min; + }, + set: function (min) { + this._scale.min = this.toFrequency(min); + //also update the octaves + this.octaves = this._octaves; + } + }); + /** + * The number of octaves above the baseFrequency that the + * envelope will scale to. + * @memberOf Tone.FrequencyEnvelope# + * @type {Positive} + * @name octaves + */ + Object.defineProperty(Tone.FrequencyEnvelope.prototype, 'octaves', { + get: function () { + return this._octaves; + }, + set: function (octaves) { + this._octaves = octaves; + this._scale.max = this.baseFrequency * Math.pow(2, octaves); + } + }); + /** + * The envelope's exponent value. + * @memberOf Tone.FrequencyEnvelope# + * @type {number} + * @name exponent + */ + Object.defineProperty(Tone.FrequencyEnvelope.prototype, 'exponent', { + get: function () { + return this._exp.value; + }, + set: function (exp) { + this._exp.value = exp; + } + }); + /** + * clean up + * @returns {Tone.FrequencyEnvelope} this + */ + Tone.FrequencyEnvelope.prototype.dispose = function () { + Tone.ScaledEnvelope.prototype.dispose.call(this); + return this; + }; + return Tone.FrequencyEnvelope; + }); + Module(function (Tone) { + + /** + * @class GreaterThanZero outputs 1 when the input is strictly greater than zero + * + * @constructor + * @extends {Tone.SignalBase} + * @example + * var gt0 = new Tone.GreaterThanZero(); + * var sig = new Tone.Signal(0.01).connect(gt0); + * //the output of gt0 is 1. + * sig.value = 0; + * //the output of gt0 is 0. + */ + Tone.GreaterThanZero = function () { + Tone.SignalBase.call(this); + /** + * @type {Tone.WaveShaper} + * @private + */ + this._thresh = this.output = new Tone.WaveShaper(function (val) { + if (val <= 0) { + return 0; + } else { + return 1; + } + }, 127); + /** + * scale the first thresholded signal by a large value. + * this will help with values which are very close to 0 + * @type {Tone.Multiply} + * @private + */ + this._scale = this.input = new Tone.Multiply(10000); + //connections + this._scale.connect(this._thresh); + }; + Tone.extend(Tone.GreaterThanZero, Tone.SignalBase); + /** + * dispose method + * @returns {Tone.GreaterThanZero} this + */ + Tone.GreaterThanZero.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._scale.dispose(); + this._scale = null; + this._thresh.dispose(); + this._thresh = null; + return this; + }; + return Tone.GreaterThanZero; + }); + Module(function (Tone) { + + /** + * @class Output 1 if the signal is greater than the value, otherwise outputs 0. + * can compare two signals or a signal and a number. + * + * @constructor + * @extends {Tone.Signal} + * @param {number} [value=0] the value to compare to the incoming signal + * @example + * var gt = new Tone.GreaterThan(2); + * var sig = new Tone.Signal(4).connect(gt); + * //output of gt is equal 1. + */ + Tone.GreaterThan = function (value) { + Tone.Signal.call(this); + this.createInsOuts(2, 0); + /** + * subtract the amount from the incoming signal + * @type {Tone.Subtract} + * @private + */ + this._param = this.input[0] = new Tone.Subtract(value); + this.input[1] = this._param.input[1]; + /** + * compare that amount to zero + * @type {Tone.GreaterThanZero} + * @private + */ + this._gtz = this.output = new Tone.GreaterThanZero(); + //connect + this._param.connect(this._gtz); + }; + Tone.extend(Tone.GreaterThan, Tone.Signal); + /** + * dispose method + * @returns {Tone.GreaterThan} this + */ + Tone.GreaterThan.prototype.dispose = function () { + Tone.Signal.prototype.dispose.call(this); + this._gtz.dispose(); + this._gtz = null; + return this; + }; + return Tone.GreaterThan; + }); + Module(function (Tone) { + + /** + * @class Tone.Gate only passes a signal through when the incoming + * signal exceeds a specified threshold. To do this, Gate uses + * a Tone.Follower to follow the amplitude of the incoming signal. + * A common implementation of this class is a [Noise Gate](https://en.wikipedia.org/wiki/Noise_gate). + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Decibels|Object} [threshold] The threshold above which the gate will open. + * @param {Time=} attack The follower's attack time + * @param {Time=} release The follower's release time + * @example + * var gate = new Tone.Gate(-30, 0.2, 0.3).toMaster(); + * var mic = new Tone.UserMedia().connect(gate); + * //the gate will only pass through the incoming + * //signal when it's louder than -30db + */ + Tone.Gate = function () { + var options = Tone.defaults(arguments, [ + 'threshold', + 'attack', + 'release' + ], Tone.Gate); + Tone.AudioNode.call(this); + this.createInsOuts(1, 1); + /** + * @type {Tone.Follower} + * @private + */ + this._follower = new Tone.Follower(options.attack, options.release); + /** + * @type {Tone.GreaterThan} + * @private + */ + this._gt = new Tone.GreaterThan(Tone.dbToGain(options.threshold)); + //the connections + this.input.connect(this.output); + //the control signal + this.input.chain(this._gt, this._follower, this.output.gain); + }; + Tone.extend(Tone.Gate, Tone.AudioNode); + /** + * @const + * @static + * @type {Object} + */ + Tone.Gate.defaults = { + 'attack': 0.1, + 'release': 0.1, + 'threshold': -40 + }; + /** + * The threshold of the gate in decibels + * @memberOf Tone.Gate# + * @type {Decibels} + * @name threshold + */ + Object.defineProperty(Tone.Gate.prototype, 'threshold', { + get: function () { + return Tone.gainToDb(this._gt.value); + }, + set: function (thresh) { + this._gt.value = Tone.dbToGain(thresh); + } + }); + /** + * The attack speed of the gate + * @memberOf Tone.Gate# + * @type {Time} + * @name attack + */ + Object.defineProperty(Tone.Gate.prototype, 'attack', { + get: function () { + return this._follower.attack; + }, + set: function (attackTime) { + this._follower.attack = attackTime; + } + }); + /** + * The release speed of the gate + * @memberOf Tone.Gate# + * @type {Time} + * @name release + */ + Object.defineProperty(Tone.Gate.prototype, 'release', { + get: function () { + return this._follower.release; + }, + set: function (releaseTime) { + this._follower.release = releaseTime; + } + }); + /** + * Clean up. + * @returns {Tone.Gate} this + */ + Tone.Gate.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._follower.dispose(); + this._gt.dispose(); + this._follower = null; + this._gt = null; + return this; + }; + return Tone.Gate; + }); + Module(function (Tone) { + /** + * @class Tone.TickSignal extends Tone.Signal, but adds the capability + * to calculate the number of elapsed ticks. exponential and target curves + * are approximated with multiple linear ramps. + * + * Thank you Bruno Dias, H. Sofia Pinto, and David M. Matos, for your [WAC paper](https://smartech.gatech.edu/bitstream/handle/1853/54588/WAC2016-49.pdf) + * describing integrating timing functions for tempo calculations. + * + * @param {Number} value The initial value of the signal + * @extends {Tone.Signal} + */ + Tone.TickSignal = function (value) { + value = Tone.defaultArg(value, 1); + Tone.Signal.call(this, { + 'units': Tone.Type.Ticks, + 'value': value + }); + //extend the memory + this._events.memory = Infinity; + //clear the clock from the beginning + this.cancelScheduledValues(0); + //set an initial event + this._events.add({ + 'type': Tone.Param.AutomationType.SetValue, + 'time': 0, + 'value': value + }); + }; + Tone.extend(Tone.TickSignal, Tone.Signal); + /** + * Wraps Tone.Signal methods so that they also + * record the ticks. + * @param {Function} method + * @return {Function} + * @private + */ + function _wrapScheduleMethods(method) { + return function (value, time) { + time = this.toSeconds(time); + method.apply(this, arguments); + var event = this._events.get(time); + var previousEvent = this._events.previousEvent(event); + var ticksUntilTime = this._getTicksUntilEvent(previousEvent, time); + event.ticks = Math.max(ticksUntilTime, 0); + return this; + }; + } + Tone.TickSignal.prototype.setValueAtTime = _wrapScheduleMethods(Tone.Signal.prototype.setValueAtTime); + Tone.TickSignal.prototype.linearRampToValueAtTime = _wrapScheduleMethods(Tone.Signal.prototype.linearRampToValueAtTime); + /** + * Start exponentially approaching the target value at the given time with + * a rate having the given time constant. + * @param {number} value + * @param {Time} startTime + * @param {number} timeConstant + * @returns {Tone.TickSignal} this + */ + Tone.TickSignal.prototype.setTargetAtTime = function (value, time, constant) { + //aproximate it with multiple linear ramps + time = this.toSeconds(time); + this.setRampPoint(time); + value = this._fromUnits(value); + //start from previously scheduled value + var prevEvent = this._events.get(time); + var segments = Math.round(Math.max(1 / constant, 1)); + for (var i = 0; i <= segments; i++) { + var segTime = constant * i + time; + var rampVal = this._exponentialApproach(prevEvent.time, prevEvent.value, value, constant, segTime); + this.linearRampToValueAtTime(this._toUnits(rampVal), segTime); + } + return this; + }; + /** + * Schedules an exponential continuous change in parameter value from + * the previous scheduled parameter value to the given value. + * @param {number} value + * @param {Time} endTime + * @returns {Tone.TickSignal} this + */ + Tone.TickSignal.prototype.exponentialRampToValueAtTime = function (value, time) { + //aproximate it with multiple linear ramps + time = this.toSeconds(time); + value = this._fromUnits(value); + //start from previously scheduled value + var prevEvent = this._events.get(time); + if (prevEvent === null) { + prevEvent = { + 'value': this._initialValue, + 'time': 0 + }; + } + //approx 10 segments per second + var segments = Math.round(Math.max((time - prevEvent.time) * 10, 1)); + var segmentDur = (time - prevEvent.time) / segments; + for (var i = 0; i <= segments; i++) { + var segTime = segmentDur * i + prevEvent.time; + var rampVal = this._exponentialInterpolate(prevEvent.time, prevEvent.value, time, value, segTime); + this.linearRampToValueAtTime(this._toUnits(rampVal), segTime); + } + return this; + }; + /** + * Returns the tick value at the time. Takes into account + * any automation curves scheduled on the signal. + * @private + * @param {Time} time The time to get the tick count at + * @return {Ticks} The number of ticks which have elapsed at the time + * given any automations. + */ + Tone.TickSignal.prototype._getTicksUntilEvent = function (event, time) { + if (event === null) { + event = { + 'ticks': 0, + 'time': 0 + }; + } else if (Tone.isUndef(event.ticks)) { + var previousEvent = this._events.previousEvent(event); + event.ticks = this._getTicksUntilEvent(previousEvent, event.time); + } + var val0 = this.getValueAtTime(event.time); + var val1 = this.getValueAtTime(time); + //if it's right on the line, take the previous value + if (this._events.get(time).time === time && this._events.get(time).type === Tone.Param.AutomationType.SetValue) { + val1 = this.getValueAtTime(time - this.sampleTime); + } + return 0.5 * (time - event.time) * (val0 + val1) + event.ticks; + }; + /** + * Returns the tick value at the time. Takes into account + * any automation curves scheduled on the signal. + * @param {Time} time The time to get the tick count at + * @return {Ticks} The number of ticks which have elapsed at the time + * given any automations. + */ + Tone.TickSignal.prototype.getTicksAtTime = function (time) { + time = this.toSeconds(time); + var event = this._events.get(time); + return Math.max(this._getTicksUntilEvent(event, time), 0); + }; + /** + * Return the elapsed time of the number of ticks from the given time + * @param {Ticks} ticks The number of ticks to calculate + * @param {Time} time The time to get the next tick from + * @return {Seconds} The duration of the number of ticks from the given time in seconds + */ + Tone.TickSignal.prototype.getDurationOfTicks = function (ticks, time) { + time = this.toSeconds(time); + var currentTick = this.getTicksAtTime(time); + return this.getTimeOfTick(currentTick + ticks) - time; + }; + /** + * Given a tick, returns the time that tick occurs at. + * @param {Ticks} tick + * @return {Time} The time that the tick occurs. + */ + Tone.TickSignal.prototype.getTimeOfTick = function (tick) { + var before = this._events.get(tick, 'ticks'); + var after = this._events.getAfter(tick, 'ticks'); + if (before && before.ticks === tick) { + return before.time; + } else if (before && after && after.type === Tone.Param.AutomationType.Linear && before.value !== after.value) { + var val0 = this.getValueAtTime(before.time); + var val1 = this.getValueAtTime(after.time); + var delta = (val1 - val0) / (after.time - before.time); + var k = Math.sqrt(Math.pow(val0, 2) - 2 * delta * (before.ticks - tick)); + var sol1 = (-val0 + k) / delta; + var sol2 = (-val0 - k) / delta; + return (sol1 > 0 ? sol1 : sol2) + before.time; + } else if (before) { + if (before.value === 0) { + return Infinity; + } else { + return before.time + (tick - before.ticks) / before.value; + } + } else { + return tick / this._initialValue; + } + }; + /** + * Convert some number of ticks their the duration in seconds accounting + * for any automation curves starting at the given time. + * @param {Ticks} ticks The number of ticks to convert to seconds. + * @param {Time} [when=now] When along the automation timeline to convert the ticks. + * @return {Tone.Time} The duration in seconds of the ticks. + */ + Tone.TickSignal.prototype.ticksToTime = function (ticks, when) { + when = this.toSeconds(when); + return new Tone.Time(this.getDurationOfTicks(ticks, when)); + }; + /** + * The inverse of [ticksToTime](#tickstotime). Convert a duration in + * seconds to the corresponding number of ticks accounting for any + * automation curves starting at the given time. + * @param {Time} duration The time interval to convert to ticks. + * @param {Time} [when=now] When along the automation timeline to convert the ticks. + * @return {Tone.Ticks} The duration in ticks. + */ + Tone.TickSignal.prototype.timeToTicks = function (duration, when) { + when = this.toSeconds(when); + duration = this.toSeconds(duration); + var startTicks = this.getTicksAtTime(when); + var endTicks = this.getTicksAtTime(when + duration); + return new Tone.Ticks(endTicks - startTicks); + }; + return Tone.TickSignal; + }); + Module(function (Tone) { + + /** + * @class A Timeline State. Provides the methods: <code>setStateAtTime("state", time)</code> + * and <code>getValueAtTime(time)</code>. + * + * @extends {Tone.Timeline} + * @param {String} initial The initial state of the TimelineState. + * Defaults to <code>undefined</code> + */ + Tone.TimelineState = function (initial) { + Tone.Timeline.call(this); + /** + * The initial state + * @private + * @type {String} + */ + this._initial = initial; + }; + Tone.extend(Tone.TimelineState, Tone.Timeline); + /** + * Returns the scheduled state scheduled before or at + * the given time. + * @param {Number} time The time to query. + * @return {String} The name of the state input in setStateAtTime. + */ + Tone.TimelineState.prototype.getValueAtTime = function (time) { + var event = this.get(time); + if (event !== null) { + return event.state; + } else { + return this._initial; + } + }; + /** + * Add a state to the timeline. + * @param {String} state The name of the state to set. + * @param {Number} time The time to query. + * @returns {Tone.TimelineState} this + */ + Tone.TimelineState.prototype.setStateAtTime = function (state, time) { + //all state changes need to be >= the previous state time + //TODO throw error if time < the previous event time + this.add({ + 'state': state, + 'time': time + }); + return this; + }; + /** + * Return the event before the time with the given state + * @param {Tone.State} state The state to look for + * @param {Time} time When to check before + * @return {Object} The event with the given state before the time + */ + Tone.TimelineState.prototype.getLastState = function (state, time) { + time = this.toSeconds(time); + var index = this._search(time); + for (var i = index; i >= 0; i--) { + var event = this._timeline[i]; + if (event.state === state) { + return event; + } + } + }; + /** + * Return the event after the time with the given state + * @param {Tone.State} state The state to look for + * @param {Time} time When to check from + * @return {Object} The event with the given state after the time + */ + Tone.TimelineState.prototype.getNextState = function (state, time) { + time = this.toSeconds(time); + var index = this._search(time); + if (index !== -1) { + for (var i = index; i < this._timeline.length; i++) { + var event = this._timeline[i]; + if (event.state === state) { + return event; + } + } + } + }; + return Tone.TimelineState; + }); + Module(function (Tone) { + + /** + * @class Uses [Tone.TickSignal](TickSignal) to track elapsed ticks with + * complex automation curves. + * + * @constructor + * @param {Frequency} frequency The initial frequency that the signal ticks at + * @extends {Tone} + */ + Tone.TickSource = function () { + var options = Tone.defaults(arguments, ['frequency'], Tone.TickSource); + /** + * The frequency the callback function should be invoked. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.TickSignal(options.frequency, Tone.Type.Frequency); + this._readOnly('frequency'); + /** + * The state timeline + * @type {Tone.TimelineState} + * @private + */ + this._state = new Tone.TimelineState(Tone.State.Stopped); + this._state.setStateAtTime(Tone.State.Stopped, 0); + /** + * The offset values of the ticks + * @type {Tone.Timeline} + * @private + */ + this._tickOffset = new Tone.Timeline(); + //add the first event + this.setTicksAtTime(0, 0); + }; + Tone.extend(Tone.TickSource); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.TickSource.defaults = { 'frequency': 1 }; + /** + * Returns the playback state of the source, either "started", "stopped" or "paused". + * @type {Tone.State} + * @readOnly + * @memberOf Tone.TickSource# + * @name state + */ + Object.defineProperty(Tone.TickSource.prototype, 'state', { + get: function () { + return this._state.getValueAtTime(this.now()); + } + }); + /** + * Start the clock at the given time. Optionally pass in an offset + * of where to start the tick counter from. + * @param {Time=} time The time the clock should start + * @param {Ticks=0} offset The number of ticks to start the source at + * @return {Tone.TickSource} this + */ + Tone.TickSource.prototype.start = function (time, offset) { + time = this.toSeconds(time); + if (this._state.getValueAtTime(time) !== Tone.State.Started) { + this._state.setStateAtTime(Tone.State.Started, time); + if (Tone.isDefined(offset)) { + this.setTicksAtTime(offset, time); + } + } + return this; + }; + /** + * Stop the clock. Stopping the clock resets the tick counter to 0. + * @param {Time} [time=now] The time when the clock should stop. + * @returns {Tone.TickSource} this + * @example + * clock.stop(); + */ + Tone.TickSource.prototype.stop = function (time) { + time = this.toSeconds(time); + //cancel the previous stop + if (this._state.getValueAtTime(time) === Tone.State.Stopped) { + var event = this._state.get(time); + if (event.time > 0) { + this._tickOffset.cancel(event.time); + this._state.cancel(event.time); + } + } + this._state.cancel(time); + this._state.setStateAtTime(Tone.State.Stopped, time); + this.setTicksAtTime(0, time); + return this; + }; + /** + * Pause the clock. Pausing does not reset the tick counter. + * @param {Time} [time=now] The time when the clock should stop. + * @returns {Tone.TickSource} this + */ + Tone.TickSource.prototype.pause = function (time) { + time = this.toSeconds(time); + if (this._state.getValueAtTime(time) === Tone.State.Started) { + this._state.setStateAtTime(Tone.State.Paused, time); + } + return this; + }; + /** + * Cancel start/stop/pause and setTickAtTime events scheduled after the given time. + * @param {Time} [time=now] When to clear the events after + * @returns {Tone.TickSource} this + */ + Tone.TickSource.prototype.cancel = function (time) { + time = this.toSeconds(time); + this._state.cancel(time); + this._tickOffset.cancel(time); + return this; + }; + /** + * Get the elapsed ticks at the given time + * @param {Time} time When to get the tick value + * @return {Ticks} The number of ticks + */ + Tone.TickSource.prototype.getTicksAtTime = function (time) { + time = this.toSeconds(time); + var stopEvent = this._state.getLastState(Tone.State.Stopped, time); + //this event allows forEachBetween to iterate until the current time + var tmpEvent = { + state: Tone.State.Paused, + time: time + }; + this._state.add(tmpEvent); + //keep track of the previous offset event + var lastState = stopEvent; + var elapsedTicks = 0; + //iterate through all the events since the last stop + this._state.forEachBetween(stopEvent.time, time + this.sampleTime, function (e) { + var periodStartTime = lastState.time; + //if there is an offset event in this period use that + var offsetEvent = this._tickOffset.get(e.time); + if (offsetEvent.time >= lastState.time) { + elapsedTicks = offsetEvent.ticks; + periodStartTime = offsetEvent.time; + } + if (lastState.state === Tone.State.Started && e.state !== Tone.State.Started) { + elapsedTicks += this.frequency.getTicksAtTime(e.time) - this.frequency.getTicksAtTime(periodStartTime); + } + lastState = e; + }.bind(this)); + //remove the temporary event + this._state.remove(tmpEvent); + //return the ticks + return elapsedTicks; + }; + /** + * The number of times the callback was invoked. Starts counting at 0 + * and increments after the callback was invoked. Returns -1 when stopped. + * @memberOf Tone.TickSource# + * @name ticks + * @type {Ticks} + */ + Object.defineProperty(Tone.TickSource.prototype, 'ticks', { + get: function () { + return this.getTicksAtTime(this.now()); + }, + set: function (t) { + this.setTicksAtTime(t, this.now()); + } + }); + /** + * The time since ticks=0 that the TickSource has been running. Accounts + * for tempo curves + * @memberOf Tone.TickSource# + * @name seconds + * @type {Seconds} + */ + Object.defineProperty(Tone.TickSource.prototype, 'seconds', { + get: function () { + return this.getSecondsAtTime(this.now()); + }, + set: function (s) { + var now = this.now(); + var ticks = this.frequency.timeToTicks(s, now); + this.setTicksAtTime(ticks, now); + } + }); + /** + * Return the elapsed seconds at the given time. + * @param {Time} time When to get the elapsed seconds + * @return {Seconds} The number of elapsed seconds + */ + Tone.TickSource.prototype.getSecondsAtTime = function (time) { + time = this.toSeconds(time); + var stopEvent = this._state.getLastState(Tone.State.Stopped, time); + //this event allows forEachBetween to iterate until the current time + var tmpEvent = { + state: Tone.State.Paused, + time: time + }; + this._state.add(tmpEvent); + //keep track of the previous offset event + var lastState = stopEvent; + var elapsedSeconds = 0; + //iterate through all the events since the last stop + this._state.forEachBetween(stopEvent.time, time + this.sampleTime, function (e) { + var periodStartTime = lastState.time; + //if there is an offset event in this period use that + var offsetEvent = this._tickOffset.get(e.time); + if (offsetEvent.time >= lastState.time) { + elapsedSeconds = offsetEvent.seconds; + periodStartTime = offsetEvent.time; + } + if (lastState.state === Tone.State.Started && e.state !== Tone.State.Started) { + elapsedSeconds += e.time - periodStartTime; + } + lastState = e; + }.bind(this)); + //remove the temporary event + this._state.remove(tmpEvent); + //return the ticks + return elapsedSeconds; + }; + /** + * Set the clock's ticks at the given time. + * @param {Ticks} ticks The tick value to set + * @param {Time} time When to set the tick value + * @return {Tone.TickSource} this + */ + Tone.TickSource.prototype.setTicksAtTime = function (ticks, time) { + time = this.toSeconds(time); + this._tickOffset.cancel(time); + this._tickOffset.add({ + 'time': time, + 'ticks': ticks, + 'seconds': this.frequency.getDurationOfTicks(ticks, time) + }); + return this; + }; + /** + * Returns the scheduled state at the given time. + * @param {Time} time The time to query. + * @return {String} The name of the state input in setStateAtTime. + * @example + * source.start("+0.1"); + * source.getStateAtTime("+0.1"); //returns "started" + */ + Tone.TickSource.prototype.getStateAtTime = function (time) { + time = this.toSeconds(time); + return this._state.getValueAtTime(time); + }; + /** + * Get the time of the given tick. The second argument + * is when to test before. Since ticks can be set (with setTicksAtTime) + * there may be multiple times for a given tick value. + * @param {Ticks} ticks The tick number. + * @param {Time=} before When to measure the tick value from. + * @return {Time} The time of the tick + */ + Tone.TickSource.prototype.getTimeOfTick = function (tick, before) { + before = Tone.defaultArg(before, this.now()); + var offset = this._tickOffset.get(before); + var event = this._state.get(before); + var startTime = Math.max(offset.time, event.time); + var absoluteTicks = this.frequency.getTicksAtTime(startTime) + tick - offset.ticks; + return this.frequency.getTimeOfTick(absoluteTicks); + }; + /** + * Invoke the callback event at all scheduled ticks between the + * start time and the end time + * @param {Time} startTime The beginning of the search range + * @param {Time} endTime The end of the search range + * @param {Function<Time,Ticks>} callback The callback to invoke with each tick + * @return {Tone.TickSource} this + */ + Tone.TickSource.prototype.forEachTickBetween = function (startTime, endTime, callback) { + //only iterate through the sections where it is "started" + var lastStateEvent = this._state.get(startTime); + this._state.forEachBetween(startTime, endTime, function (event) { + if (lastStateEvent.state === Tone.State.Started && event.state !== Tone.State.Started) { + this.forEachTickBetween(Math.max(lastStateEvent.time, startTime), event.time - this.sampleTime, callback); + } + lastStateEvent = event; + }.bind(this)); + startTime = Math.max(lastStateEvent.time, startTime); + if (lastStateEvent.state === Tone.State.Started && this._state) { + //figure out the difference between the frequency ticks and the + var startTicks = this.frequency.getTicksAtTime(startTime); + var ticksAtStart = this.frequency.getTicksAtTime(lastStateEvent.time); + var diff = startTicks - ticksAtStart; + var offset = diff % 1; + if (offset !== 0) { + offset = 1 - offset; + } + var nextTickTime = this.frequency.getTimeOfTick(startTicks + offset); + var error = null; + while (nextTickTime < endTime && this._state) { + try { + callback(nextTickTime, Math.round(this.getTicksAtTime(nextTickTime))); + } catch (e) { + error = e; + break; + } + if (this._state) { + nextTickTime += this.frequency.getDurationOfTicks(1, nextTickTime); + } + } + } + if (error) { + throw error; + } + return this; + }; + /** + * Clean up + * @returns {Tone.TickSource} this + */ + Tone.TickSource.prototype.dispose = function () { + Tone.Param.prototype.dispose.call(this); + this._state.dispose(); + this._state = null; + this._tickOffset.dispose(); + this._tickOffset = null; + this._writable('frequency'); + this.frequency.dispose(); + this.frequency = null; + return this; + }; + return Tone.TickSource; + }); + Module(function (Tone) { + + /** + * @class A sample accurate clock which provides a callback at the given rate. + * While the callback is not sample-accurate (it is still susceptible to + * loose JS timing), the time passed in as the argument to the callback + * is precise. For most applications, it is better to use Tone.Transport + * instead of the Clock by itself since you can synchronize multiple callbacks. + * + * @constructor + * @extends {Tone.Emitter} + * @param {function} callback The callback to be invoked with the time of the audio event + * @param {Frequency} frequency The rate of the callback + * @example + * //the callback will be invoked approximately once a second + * //and will print the time exactly once a second apart. + * var clock = new Tone.Clock(function(time){ + * console.log(time); + * }, 1); + */ + Tone.Clock = function () { + var options = Tone.defaults(arguments, [ + 'callback', + 'frequency' + ], Tone.Clock); + Tone.Emitter.call(this); + /** + * The callback function to invoke at the scheduled tick. + * @type {Function} + */ + this.callback = options.callback; + /** + * The next time the callback is scheduled. + * @type {Number} + * @private + */ + this._nextTick = 0; + /** + * The tick counter + * @type {Tone.TickSource} + * @private + */ + this._tickSource = new Tone.TickSource(options.frequency); + /** + * The last time the loop callback was invoked + * @private + * @type {Number} + */ + this._lastUpdate = 0; + /** + * The rate the callback function should be invoked. + * @type {BPM} + * @signal + */ + this.frequency = this._tickSource.frequency; + this._readOnly('frequency'); + /** + * The state timeline + * @type {Tone.TimelineState} + * @private + */ + this._state = new Tone.TimelineState(Tone.State.Stopped); + //add an initial state + this._state.setStateAtTime(Tone.State.Stopped, 0); + /** + * The loop function bound to its context. + * This is necessary to remove the event in the end. + * @type {Function} + * @private + */ + this._boundLoop = this._loop.bind(this); + //bind a callback to the worker thread + this.context.on('tick', this._boundLoop); + }; + Tone.extend(Tone.Clock, Tone.Emitter); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.Clock.defaults = { + 'callback': Tone.noOp, + 'frequency': 1 + }; + /** + * Returns the playback state of the source, either "started", "stopped" or "paused". + * @type {Tone.State} + * @readOnly + * @memberOf Tone.Clock# + * @name state + */ + Object.defineProperty(Tone.Clock.prototype, 'state', { + get: function () { + return this._state.getValueAtTime(this.now()); + } + }); + /** + * Start the clock at the given time. Optionally pass in an offset + * of where to start the tick counter from. + * @param {Time=} time The time the clock should start + * @param {Ticks=} offset Where the tick counter starts counting from. + * @return {Tone.Clock} this + */ + Tone.Clock.prototype.start = function (time, offset) { + time = this.toSeconds(time); + if (this._state.getValueAtTime(time) !== Tone.State.Started) { + this._state.setStateAtTime(Tone.State.Started, time); + this._tickSource.start(time, offset); + if (time < this._lastUpdate) { + this.emit('start', time, offset); + } + } + return this; + }; + /** + * Stop the clock. Stopping the clock resets the tick counter to 0. + * @param {Time} [time=now] The time when the clock should stop. + * @returns {Tone.Clock} this + * @example + * clock.stop(); + */ + Tone.Clock.prototype.stop = function (time) { + time = this.toSeconds(time); + this._state.cancel(time); + this._state.setStateAtTime(Tone.State.Stopped, time); + this._tickSource.stop(time); + if (time < this._lastUpdate) { + this.emit('stop', time); + } + return this; + }; + /** + * Pause the clock. Pausing does not reset the tick counter. + * @param {Time} [time=now] The time when the clock should stop. + * @returns {Tone.Clock} this + */ + Tone.Clock.prototype.pause = function (time) { + time = this.toSeconds(time); + if (this._state.getValueAtTime(time) === Tone.State.Started) { + this._state.setStateAtTime(Tone.State.Paused, time); + this._tickSource.pause(time); + if (time < this._lastUpdate) { + this.emit('pause', time); + } + } + return this; + }; + /** + * The number of times the callback was invoked. Starts counting at 0 + * and increments after the callback was invoked. + * @type {Ticks} + */ + Object.defineProperty(Tone.Clock.prototype, 'ticks', { + get: function () { + return Math.ceil(this.getTicksAtTime(this.now())); + }, + set: function (t) { + this._tickSource.ticks = t; + } + }); + /** + * The time since ticks=0 that the Clock has been running. Accounts + * for tempo curves + * @type {Seconds} + */ + Object.defineProperty(Tone.Clock.prototype, 'seconds', { + get: function () { + return this._tickSource.seconds; + }, + set: function (s) { + this._tickSource.seconds = s; + } + }); + /** + * Return the elapsed seconds at the given time. + * @param {Time} time When to get the elapsed seconds + * @return {Seconds} The number of elapsed seconds + */ + Tone.Clock.prototype.getSecondsAtTime = function (time) { + return this._tickSource.getSecondsAtTime(time); + }; + /** + * Set the clock's ticks at the given time. + * @param {Ticks} ticks The tick value to set + * @param {Time} time When to set the tick value + * @return {Tone.Clock} this + */ + Tone.Clock.prototype.setTicksAtTime = function (ticks, time) { + this._tickSource.setTicksAtTime(ticks, time); + return this; + }; + /** + * Get the clock's ticks at the given time. + * @param {Time} time When to get the tick value + * @return {Ticks} The tick value at the given time. + */ + Tone.Clock.prototype.getTicksAtTime = function (time) { + return this._tickSource.getTicksAtTime(time); + }; + /** + * Get the time of the next tick + * @param {Ticks} ticks The tick number. + * @param {Time} before + * @return {Tone.Clock} this + */ + Tone.Clock.prototype.nextTickTime = function (offset, when) { + when = this.toSeconds(when); + var currentTick = this.getTicksAtTime(when); + return this._tickSource.getTimeOfTick(currentTick + offset, when); + }; + /** + * The scheduling loop. + * @private + */ + Tone.Clock.prototype._loop = function () { + var startTime = this._lastUpdate; + var endTime = this.now(); + this._lastUpdate = endTime; + if (startTime !== endTime) { + //the state change events + this._state.forEachBetween(startTime, endTime, function (e) { + switch (e.state) { + case Tone.State.Started: + var offset = this._tickSource.getTicksAtTime(e.time); + this.emit('start', e.time, offset); + break; + case Tone.State.Stopped: + if (e.time !== 0) { + this.emit('stop', e.time); + } + break; + case Tone.State.Paused: + this.emit('pause', e.time); + break; + } + }.bind(this)); + //the tick callbacks + this._tickSource.forEachTickBetween(startTime, endTime, function (time, ticks) { + this.callback(time, ticks); + }.bind(this)); + } + }; + /** + * Returns the scheduled state at the given time. + * @param {Time} time The time to query. + * @return {String} The name of the state input in setStateAtTime. + * @example + * clock.start("+0.1"); + * clock.getStateAtTime("+0.1"); //returns "started" + */ + Tone.Clock.prototype.getStateAtTime = function (time) { + time = this.toSeconds(time); + return this._state.getValueAtTime(time); + }; + /** + * Clean up + * @returns {Tone.Clock} this + */ + Tone.Clock.prototype.dispose = function () { + Tone.Emitter.prototype.dispose.call(this); + this.context.off('tick', this._boundLoop); + this._writable('frequency'); + this._tickSource.dispose(); + this._tickSource = null; + this.frequency = null; + this._boundLoop = null; + this._nextTick = Infinity; + this.callback = null; + this._state.dispose(); + this._state = null; + }; + return Tone.Clock; + }); + Module(function (Tone) { + + /** + * @class Similar to Tone.Timeline, but all events represent + * intervals with both "time" and "duration" times. The + * events are placed in a tree structure optimized + * for querying an intersection point with the timeline + * events. Internally uses an [Interval Tree](https://en.wikipedia.org/wiki/Interval_tree) + * to represent the data. + * @extends {Tone} + */ + Tone.IntervalTimeline = function () { + Tone.call(this); + /** + * The root node of the inteval tree + * @type {IntervalNode} + * @private + */ + this._root = null; + /** + * Keep track of the length of the timeline. + * @type {Number} + * @private + */ + this._length = 0; + }; + Tone.extend(Tone.IntervalTimeline); + /** + * The event to add to the timeline. All events must + * have a time and duration value + * @param {Object} event The event to add to the timeline + * @return {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.add = function (event) { + if (Tone.isUndef(event.time) || Tone.isUndef(event.duration)) { + throw new Error('Tone.IntervalTimeline: events must have time and duration parameters'); + } + event.time = event.time.valueOf(); + var node = new IntervalNode(event.time, event.time + event.duration, event); + if (this._root === null) { + this._root = node; + } else { + this._root.insert(node); + } + this._length++; + // Restructure tree to be balanced + while (node !== null) { + node.updateHeight(); + node.updateMax(); + this._rebalance(node); + node = node.parent; + } + return this; + }; + /** + * Remove an event from the timeline. + * @param {Object} event The event to remove from the timeline + * @return {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.remove = function (event) { + if (this._root !== null) { + var results = []; + this._root.search(event.time, results); + for (var i = 0; i < results.length; i++) { + var node = results[i]; + if (node.event === event) { + this._removeNode(node); + this._length--; + break; + } + } + } + return this; + }; + /** + * The number of items in the timeline. + * @type {Number} + * @memberOf Tone.IntervalTimeline# + * @name length + * @readOnly + */ + Object.defineProperty(Tone.IntervalTimeline.prototype, 'length', { + get: function () { + return this._length; + } + }); + /** + * Remove events whose time time is after the given time + * @param {Number} time The time to query. + * @returns {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.cancel = function (after) { + this.forEachFrom(after, function (event) { + this.remove(event); + }.bind(this)); + return this; + }; + /** + * Set the root node as the given node + * @param {IntervalNode} node + * @private + */ + Tone.IntervalTimeline.prototype._setRoot = function (node) { + this._root = node; + if (this._root !== null) { + this._root.parent = null; + } + }; + /** + * Replace the references to the node in the node's parent + * with the replacement node. + * @param {IntervalNode} node + * @param {IntervalNode} replacement + * @private + */ + Tone.IntervalTimeline.prototype._replaceNodeInParent = function (node, replacement) { + if (node.parent !== null) { + if (node.isLeftChild()) { + node.parent.left = replacement; + } else { + node.parent.right = replacement; + } + this._rebalance(node.parent); + } else { + this._setRoot(replacement); + } + }; + /** + * Remove the node from the tree and replace it with + * a successor which follows the schema. + * @param {IntervalNode} node + * @private + */ + Tone.IntervalTimeline.prototype._removeNode = function (node) { + if (node.left === null && node.right === null) { + this._replaceNodeInParent(node, null); + } else if (node.right === null) { + this._replaceNodeInParent(node, node.left); + } else if (node.left === null) { + this._replaceNodeInParent(node, node.right); + } else { + var balance = node.getBalance(); + var replacement, temp; + if (balance > 0) { + if (node.left.right === null) { + replacement = node.left; + replacement.right = node.right; + temp = replacement; + } else { + replacement = node.left.right; + while (replacement.right !== null) { + replacement = replacement.right; + } + replacement.parent.right = replacement.left; + temp = replacement.parent; + replacement.left = node.left; + replacement.right = node.right; + } + } else if (node.right.left === null) { + replacement = node.right; + replacement.left = node.left; + temp = replacement; + } else { + replacement = node.right.left; + while (replacement.left !== null) { + replacement = replacement.left; + } + replacement.parent = replacement.parent; + replacement.parent.left = replacement.right; + temp = replacement.parent; + replacement.left = node.left; + replacement.right = node.right; + } + if (node.parent !== null) { + if (node.isLeftChild()) { + node.parent.left = replacement; + } else { + node.parent.right = replacement; + } + } else { + this._setRoot(replacement); + } + // this._replaceNodeInParent(node, replacement); + this._rebalance(temp); + } + node.dispose(); + }; + /** + * Rotate the tree to the left + * @param {IntervalNode} node + * @private + */ + Tone.IntervalTimeline.prototype._rotateLeft = function (node) { + var parent = node.parent; + var isLeftChild = node.isLeftChild(); + // Make node.right the new root of this sub tree (instead of node) + var pivotNode = node.right; + node.right = pivotNode.left; + pivotNode.left = node; + if (parent !== null) { + if (isLeftChild) { + parent.left = pivotNode; + } else { + parent.right = pivotNode; + } + } else { + this._setRoot(pivotNode); + } + }; + /** + * Rotate the tree to the right + * @param {IntervalNode} node + * @private + */ + Tone.IntervalTimeline.prototype._rotateRight = function (node) { + var parent = node.parent; + var isLeftChild = node.isLeftChild(); + // Make node.left the new root of this sub tree (instead of node) + var pivotNode = node.left; + node.left = pivotNode.right; + pivotNode.right = node; + if (parent !== null) { + if (isLeftChild) { + parent.left = pivotNode; + } else { + parent.right = pivotNode; + } + } else { + this._setRoot(pivotNode); + } + }; + /** + * Balance the BST + * @param {IntervalNode} node + * @private + */ + Tone.IntervalTimeline.prototype._rebalance = function (node) { + var balance = node.getBalance(); + if (balance > 1) { + if (node.left.getBalance() < 0) { + this._rotateLeft(node.left); + } else { + this._rotateRight(node); + } + } else if (balance < -1) { + if (node.right.getBalance() > 0) { + this._rotateRight(node.right); + } else { + this._rotateLeft(node); + } + } + }; + /** + * Get an event whose time and duration span the give time. Will + * return the match whose "time" value is closest to the given time. + * @param {Object} event The event to add to the timeline + * @return {Object} The event which spans the desired time + */ + Tone.IntervalTimeline.prototype.get = function (time) { + if (this._root !== null) { + var results = []; + this._root.search(time, results); + if (results.length > 0) { + var max = results[0]; + for (var i = 1; i < results.length; i++) { + if (results[i].low > max.low) { + max = results[i]; + } + } + return max.event; + } + } + return null; + }; + /** + * Iterate over everything in the timeline. + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.forEach = function (callback) { + if (this._root !== null) { + var allNodes = []; + this._root.traverse(function (node) { + allNodes.push(node); + }); + for (var i = 0; i < allNodes.length; i++) { + var ev = allNodes[i].event; + if (ev) { + callback(ev); + } + } + } + return this; + }; + /** + * Iterate over everything in the array in which the given time + * overlaps with the time and duration time of the event. + * @param {Number} time The time to check if items are overlapping + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.forEachAtTime = function (time, callback) { + if (this._root !== null) { + var results = []; + this._root.search(time, results); + for (var i = results.length - 1; i >= 0; i--) { + var ev = results[i].event; + if (ev) { + callback(ev); + } + } + } + return this; + }; + /** + * Iterate over everything in the array in which the time is greater + * than or equal to the given time. + * @param {Number} time The time to check if items are before + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.forEachFrom = function (time, callback) { + if (this._root !== null) { + var results = []; + this._root.searchAfter(time, results); + for (var i = results.length - 1; i >= 0; i--) { + var ev = results[i].event; + callback(ev); + } + } + return this; + }; + /** + * Clean up + * @return {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.dispose = function () { + var allNodes = []; + if (this._root !== null) { + this._root.traverse(function (node) { + allNodes.push(node); + }); + } + for (var i = 0; i < allNodes.length; i++) { + allNodes[i].dispose(); + } + allNodes = null; + this._root = null; + return this; + }; + /////////////////////////////////////////////////////////////////////////// + // INTERVAL NODE HELPER + /////////////////////////////////////////////////////////////////////////// + /** + * Represents a node in the binary search tree, with the addition + * of a "high" value which keeps track of the highest value of + * its children. + * References: + * https://brooknovak.wordpress.com/2013/12/07/augmented-interval-tree-in-c/ + * http://www.mif.vu.lt/~valdas/ALGORITMAI/LITERATURA/Cormen/Cormen.pdf + * @param {Number} low + * @param {Number} high + * @private + */ + var IntervalNode = function (low, high, event) { + //the event container + this.event = event; + //the low value + this.low = low; + //the high value + this.high = high; + //the high value for this and all child nodes + this.max = this.high; + //the nodes to the left + this._left = null; + //the nodes to the right + this._right = null; + //the parent node + this.parent = null; + //the number of child nodes + this.height = 0; + }; + /** + * Insert a node into the correct spot in the tree + * @param {IntervalNode} node + */ + IntervalNode.prototype.insert = function (node) { + if (node.low <= this.low) { + if (this.left === null) { + this.left = node; + } else { + this.left.insert(node); + } + } else if (this.right === null) { + this.right = node; + } else { + this.right.insert(node); + } + }; + /** + * Search the tree for nodes which overlap + * with the given point + * @param {Number} point The point to query + * @param {Array} results The array to put the results + */ + IntervalNode.prototype.search = function (point, results) { + // If p is to the right of the rightmost point of any interval + // in this node and all children, there won't be any matches. + if (point > this.max) { + return; + } + // Search left children + if (this.left !== null) { + this.left.search(point, results); + } + // Check this node + if (this.low <= point && this.high > point) { + results.push(this); + } + // If p is to the left of the time of this interval, + // then it can't be in any child to the right. + if (this.low > point) { + return; + } + // Search right children + if (this.right !== null) { + this.right.search(point, results); + } + }; + /** + * Search the tree for nodes which are less + * than the given point + * @param {Number} point The point to query + * @param {Array} results The array to put the results + */ + IntervalNode.prototype.searchAfter = function (point, results) { + // Check this node + if (this.low >= point) { + results.push(this); + if (this.left !== null) { + this.left.searchAfter(point, results); + } + } + // search the right side + if (this.right !== null) { + this.right.searchAfter(point, results); + } + }; + /** + * Invoke the callback on this element and both it's branches + * @param {Function} callback + */ + IntervalNode.prototype.traverse = function (callback) { + callback(this); + if (this.left !== null) { + this.left.traverse(callback); + } + if (this.right !== null) { + this.right.traverse(callback); + } + }; + /** + * Update the height of the node + */ + IntervalNode.prototype.updateHeight = function () { + if (this.left !== null && this.right !== null) { + this.height = Math.max(this.left.height, this.right.height) + 1; + } else if (this.right !== null) { + this.height = this.right.height + 1; + } else if (this.left !== null) { + this.height = this.left.height + 1; + } else { + this.height = 0; + } + }; + /** + * Update the height of the node + */ + IntervalNode.prototype.updateMax = function () { + this.max = this.high; + if (this.left !== null) { + this.max = Math.max(this.max, this.left.max); + } + if (this.right !== null) { + this.max = Math.max(this.max, this.right.max); + } + }; + /** + * The balance is how the leafs are distributed on the node + * @return {Number} Negative numbers are balanced to the right + */ + IntervalNode.prototype.getBalance = function () { + var balance = 0; + if (this.left !== null && this.right !== null) { + balance = this.left.height - this.right.height; + } else if (this.left !== null) { + balance = this.left.height + 1; + } else if (this.right !== null) { + balance = -(this.right.height + 1); + } + return balance; + }; + /** + * @returns {Boolean} true if this node is the left child + * of its parent + */ + IntervalNode.prototype.isLeftChild = function () { + return this.parent !== null && this.parent.left === this; + }; + /** + * get/set the left node + * @type {IntervalNode} + */ + Object.defineProperty(IntervalNode.prototype, 'left', { + get: function () { + return this._left; + }, + set: function (node) { + this._left = node; + if (node !== null) { + node.parent = this; + } + this.updateHeight(); + this.updateMax(); + } + }); + /** + * get/set the right node + * @type {IntervalNode} + */ + Object.defineProperty(IntervalNode.prototype, 'right', { + get: function () { + return this._right; + }, + set: function (node) { + this._right = node; + if (node !== null) { + node.parent = this; + } + this.updateHeight(); + this.updateMax(); + } + }); + /** + * null out references. + */ + IntervalNode.prototype.dispose = function () { + this.parent = null; + this._left = null; + this._right = null; + this.event = null; + }; + /////////////////////////////////////////////////////////////////////////// + // END INTERVAL NODE HELPER + /////////////////////////////////////////////////////////////////////////// + return Tone.IntervalTimeline; + }); + Module(function (Tone) { + /** + * @class Tone.Ticks is a primitive type for encoding Time values. + * Tone.Ticks can be constructed with or without the `new` keyword. Tone.Ticks can be passed + * into the parameter of any method which takes time as an argument. + * @constructor + * @extends {Tone.TransportTime} + * @param {String|Number} val The time value. + * @param {String=} units The units of the value. + * @example + * var t = Tone.Ticks("4n");//a quarter note + */ + Tone.Ticks = function (val, units) { + if (this instanceof Tone.Ticks) { + Tone.TransportTime.call(this, val, units); + } else { + return new Tone.Ticks(val, units); + } + }; + Tone.extend(Tone.Ticks, Tone.TransportTime); + /** + * The default units if none are given. + * @type {String} + * @private + */ + Tone.Ticks.prototype._defaultUnits = 'i'; + /** + * Get the current time in the given units + * @return {Ticks} + * @private + */ + Tone.Ticks.prototype._now = function () { + return Tone.Transport.ticks; + }; + /** + * Return the value of the beats in the current units + * @param {Number} beats + * @return {Number} + * @private + */ + Tone.Ticks.prototype._beatsToUnits = function (beats) { + return this._getPPQ() * beats; + }; + /** + * Returns the value of a second in the current units + * @param {Seconds} seconds + * @return {Number} + * @private + */ + Tone.Ticks.prototype._secondsToUnits = function (seconds) { + return seconds / (60 / this._getBpm()) * this._getPPQ(); + }; + /** + * Returns the value of a tick in the current time units + * @param {Ticks} ticks + * @return {Number} + * @private + */ + Tone.Ticks.prototype._ticksToUnits = function (ticks) { + return ticks; + }; + /** + * Return the time in ticks + * @return {Ticks} + */ + Tone.Ticks.prototype.toTicks = function () { + return this.valueOf(); + }; + /** + * Return the time in ticks + * @return {Ticks} + */ + Tone.Ticks.prototype.toSeconds = function () { + return this.valueOf() / this._getPPQ() * (60 / this._getBpm()); + }; + return Tone.Ticks; + }); + Module(function (Tone) { + /** + * @class Tone.TransportEvent is an internal class used by (Tone.Transport)[Transport] + * to schedule events. Do no invoke this class directly, it is + * handled from within Tone.Transport. + * @extends {Tone} + * @param {Object} options + */ + Tone.TransportEvent = function (Transport, options) { + options = Tone.defaultArg(options, Tone.TransportEvent.defaults); + Tone.call(this); + /** + * Reference to the Transport that created it + * @type {Tone.Transport} + */ + this.Transport = Transport; + /** + * The unique id of the event + * @type {Number} + */ + this.id = Tone.TransportEvent._eventId++; + /** + * The time the event starts + * @type {Ticks} + */ + this.time = Tone.Ticks(options.time); + /** + * The callback to invoke + * @type {Function} + */ + this.callback = options.callback; + /** + * If the event should be removed after being created. + * @type {Boolean} + * @private + */ + this._once = options.once; + }; + Tone.extend(Tone.TransportEvent); + /** + * The defaults + * @static + * @type {Object} + */ + Tone.TransportEvent.defaults = { + 'once': false, + 'callback': Tone.noOp + }; + /** + * Current ID counter + * @private + * @static + * @type {Number} + */ + Tone.TransportEvent._eventId = 0; + /** + * Invoke the event callback. + * @param {Time} time The AudioContext time in seconds of the event + */ + Tone.TransportEvent.prototype.invoke = function (time) { + if (this.callback) { + this.callback(time); + if (this._once && this.Transport) { + this.Transport.clear(this.id); + } + } + }; + /** + * Clean up + * @return {Tone.TransportEvent} this + */ + Tone.TransportEvent.prototype.dispose = function () { + Tone.prototype.dispose.call(this); + this.Transport = null; + this.callback = null; + this.time = null; + return this; + }; + return Tone.TransportEvent; + }); + Module(function (Tone) { + /** + * @class Tone.TransportRepeatEvent is an internal class used by Tone.Transport + * to schedule repeat events. This class should not be instantiated directly. + * @extends {Tone.TransportEvent} + * @param {Object} options + */ + Tone.TransportRepeatEvent = function (Transport, options) { + Tone.TransportEvent.call(this, Transport, options); + options = Tone.defaultArg(options, Tone.TransportRepeatEvent.defaults); + /** + * When the event should stop repeating + * @type {Ticks} + * @private + */ + this.duration = Tone.Ticks(options.duration); + /** + * The interval of the repeated event + * @type {Ticks} + * @private + */ + this._interval = Tone.Ticks(options.interval); + /** + * The ID of the current timeline event + * @type {Number} + * @private + */ + this._currentId = -1; + /** + * The ID of the next timeline event + * @type {Number} + * @private + */ + this._nextId = -1; + /** + * The time of the next event + * @type {Ticks} + * @private + */ + this._nextTick = this.time; + /** + * a reference to the bound start method + * @type {Function} + * @private + */ + this._boundRestart = this._restart.bind(this); + this.Transport.on('start loopStart', this._boundRestart); + this._restart(); + }; + Tone.extend(Tone.TransportRepeatEvent, Tone.TransportEvent); + /** + * The defaults + * @static + * @type {Object} + */ + Tone.TransportRepeatEvent.defaults = { + 'duration': Infinity, + 'interval': 1 + }; + /** + * Invoke the callback. Returns the tick time which + * the next event should be scheduled at. + * @param {Number} time The AudioContext time in seconds of the event + */ + Tone.TransportRepeatEvent.prototype.invoke = function (time) { + //create more events if necessary + this._createEvents(time); + //call the super class + Tone.TransportEvent.prototype.invoke.call(this, time); + }; + /** + * Push more events onto the timeline to keep up with the position of the timeline + * @private + */ + Tone.TransportRepeatEvent.prototype._createEvents = function (time) { + // schedule the next event + var ticks = this.Transport.getTicksAtTime(time); + if (ticks >= this.time && ticks >= this._nextTick && this._nextTick + this._interval < this.time + this.duration) { + this._nextTick += this._interval; + this._currentId = this._nextId; + this._nextId = this.Transport.scheduleOnce(this.invoke.bind(this), Tone.Ticks(this._nextTick)); + } + }; + /** + * Push more events onto the timeline to keep up with the position of the timeline + * @private + */ + Tone.TransportRepeatEvent.prototype._restart = function (time) { + this.Transport.clear(this._currentId); + this.Transport.clear(this._nextId); + this._nextTick = this.time; + var ticks = this.Transport.getTicksAtTime(time); + if (ticks > this.time) { + this._nextTick = this.time + Math.ceil((ticks - this.time) / this._interval) * this._interval; + } + this._currentId = this.Transport.scheduleOnce(this.invoke.bind(this), Tone.Ticks(this._nextTick)); + this._nextTick += this._interval; + this._nextId = this.Transport.scheduleOnce(this.invoke.bind(this), Tone.Ticks(this._nextTick)); + }; + /** + * Clean up + * @return {Tone.TransportRepeatEvent} this + */ + Tone.TransportRepeatEvent.prototype.dispose = function () { + this.Transport.clear(this._currentId); + this.Transport.clear(this._nextId); + this.Transport.off('start loopStart', this._boundRestart); + this._boundCreateEvents = null; + Tone.TransportEvent.prototype.dispose.call(this); + this.duration = null; + this._interval = null; + return this; + }; + return Tone.TransportRepeatEvent; + }); + Module(function (Tone) { + + /** + * @class Transport for timing musical events. + * Supports tempo curves and time changes. Unlike browser-based timing (setInterval, requestAnimationFrame) + * Tone.Transport timing events pass in the exact time of the scheduled event + * in the argument of the callback function. Pass that time value to the object + * you're scheduling. <br><br> + * A single transport is created for you when the library is initialized. + * <br><br> + * The transport emits the events: "start", "stop", "pause", and "loop" which are + * called with the time of that event as the argument. + * + * @extends {Tone.Emitter} + * @singleton + * @example + * //repeated event every 8th note + * Tone.Transport.scheduleRepeat(function(time){ + * //do something with the time + * }, "8n"); + * @example + * //schedule an event on the 16th measure + * Tone.Transport.schedule(function(time){ + * //do something with the time + * }, "16:0:0"); + */ + Tone.Transport = function () { + Tone.Emitter.call(this); + Tone.getContext(function () { + /////////////////////////////////////////////////////////////////////// + // LOOPING + ////////////////////////////////////////////////////////////////////// + /** + * If the transport loops or not. + * @type {boolean} + */ + this.loop = false; + /** + * The loop start position in ticks + * @type {Ticks} + * @private + */ + this._loopStart = 0; + /** + * The loop end position in ticks + * @type {Ticks} + * @private + */ + this._loopEnd = 0; + /////////////////////////////////////////////////////////////////////// + // CLOCK/TEMPO + ////////////////////////////////////////////////////////////////////// + /** + * Pulses per quarter is the number of ticks per quarter note. + * @private + * @type {Number} + */ + this._ppq = TransportConstructor.defaults.PPQ; + /** + * watches the main oscillator for timing ticks + * initially starts at 120bpm + * @private + * @type {Tone.Clock} + */ + this._clock = new Tone.Clock({ + 'callback': this._processTick.bind(this), + 'frequency': 0 + }); + this._bindClockEvents(); + /** + * The Beats Per Minute of the Transport. + * @type {BPM} + * @signal + * @example + * Tone.Transport.bpm.value = 80; + * //ramp the bpm to 120 over 10 seconds + * Tone.Transport.bpm.rampTo(120, 10); + */ + this.bpm = this._clock.frequency; + this.bpm._toUnits = this._toUnits.bind(this); + this.bpm._fromUnits = this._fromUnits.bind(this); + this.bpm.units = Tone.Type.BPM; + this.bpm.value = TransportConstructor.defaults.bpm; + this._readOnly('bpm'); + /** + * The time signature, or more accurately the numerator + * of the time signature over a denominator of 4. + * @type {Number} + * @private + */ + this._timeSignature = TransportConstructor.defaults.timeSignature; + /////////////////////////////////////////////////////////////////////// + // TIMELINE EVENTS + ////////////////////////////////////////////////////////////////////// + /** + * All the events in an object to keep track by ID + * @type {Object} + * @private + */ + this._scheduledEvents = {}; + /** + * The scheduled events. + * @type {Tone.Timeline} + * @private + */ + this._timeline = new Tone.Timeline(); + /** + * Repeated events + * @type {Array} + * @private + */ + this._repeatedEvents = new Tone.IntervalTimeline(); + /** + * All of the synced Signals + * @private + * @type {Array} + */ + this._syncedSignals = []; + /////////////////////////////////////////////////////////////////////// + // SWING + ////////////////////////////////////////////////////////////////////// + /** + * The subdivision of the swing + * @type {Ticks} + * @private + */ + this._swingTicks = TransportConstructor.defaults.PPQ / 2; + //8n + /** + * The swing amount + * @type {NormalRange} + * @private + */ + this._swingAmount = 0; + }.bind(this)); + }; + Tone.extend(Tone.Transport, Tone.Emitter); + /** + * the defaults + * @type {Object} + * @const + * @static + */ + Tone.Transport.defaults = { + 'bpm': 120, + 'swing': 0, + 'swingSubdivision': '8n', + 'timeSignature': 4, + 'loopStart': 0, + 'loopEnd': '4m', + 'PPQ': 192 + }; + /////////////////////////////////////////////////////////////////////////////// + // TICKS + /////////////////////////////////////////////////////////////////////////////// + /** + * called on every tick + * @param {number} tickTime clock relative tick time + * @private + */ + Tone.Transport.prototype._processTick = function (tickTime, ticks) { + //handle swing + if (this._swingAmount > 0 && ticks % this._ppq !== 0 && //not on a downbeat + ticks % (this._swingTicks * 2) !== 0) { + //add some swing + var progress = ticks % (this._swingTicks * 2) / (this._swingTicks * 2); + var amount = Math.sin(progress * Math.PI) * this._swingAmount; + tickTime += Tone.Ticks(this._swingTicks * 2 / 3).toSeconds() * amount; + } + //do the loop test + if (this.loop) { + if (ticks >= this._loopEnd) { + this.emit('loopEnd', tickTime); + this._clock.setTicksAtTime(this._loopStart, tickTime); + ticks = this._loopStart; + this.emit('loopStart', tickTime, this._clock.getSecondsAtTime(tickTime)); + this.emit('loop', tickTime); + } + } + //invoke the timeline events scheduled on this tick + this._timeline.forEachAtTime(ticks, function (event) { + event.invoke(tickTime); + }); + }; + /////////////////////////////////////////////////////////////////////////////// + // SCHEDULABLE EVENTS + /////////////////////////////////////////////////////////////////////////////// + /** + * Schedule an event along the timeline. + * @param {Function} callback The callback to be invoked at the time. + * @param {TransportTime} time The time to invoke the callback at. + * @return {Number} The id of the event which can be used for canceling the event. + * @example + * //trigger the callback when the Transport reaches the desired time + * Tone.Transport.schedule(function(time){ + * envelope.triggerAttack(time); + * }, "128i"); + */ + Tone.Transport.prototype.schedule = function (callback, time) { + var event = new Tone.TransportEvent(this, { + 'time': Tone.TransportTime(time), + 'callback': callback + }); + return this._addEvent(event, this._timeline); + }; + /** + * Schedule a repeated event along the timeline. The event will fire + * at the `interval` starting at the `startTime` and for the specified + * `duration`. + * @param {Function} callback The callback to invoke. + * @param {Time} interval The duration between successive + * callbacks. Must be a positive number. + * @param {TransportTime=} startTime When along the timeline the events should + * start being invoked. + * @param {Time} [duration=Infinity] How long the event should repeat. + * @return {Number} The ID of the scheduled event. Use this to cancel + * the event. + * @example + * //a callback invoked every eighth note after the first measure + * Tone.Transport.scheduleRepeat(callback, "8n", "1m"); + */ + Tone.Transport.prototype.scheduleRepeat = function (callback, interval, startTime, duration) { + var event = new Tone.TransportRepeatEvent(this, { + 'callback': callback, + 'interval': Tone.Time(interval), + 'time': Tone.TransportTime(startTime), + 'duration': Tone.Time(Tone.defaultArg(duration, Infinity)) + }); + //kick it off if the Transport is started + return this._addEvent(event, this._repeatedEvents); + }; + /** + * Schedule an event that will be removed after it is invoked. + * Note that if the given time is less than the current transport time, + * the event will be invoked immediately. + * @param {Function} callback The callback to invoke once. + * @param {TransportTime} time The time the callback should be invoked. + * @returns {Number} The ID of the scheduled event. + */ + Tone.Transport.prototype.scheduleOnce = function (callback, time) { + var event = new Tone.TransportEvent(this, { + 'time': Tone.TransportTime(time), + 'callback': callback, + 'once': true + }); + return this._addEvent(event, this._timeline); + }; + /** + * Clear the passed in event id from the timeline + * @param {Number} eventId The id of the event. + * @returns {Tone.Transport} this + */ + Tone.Transport.prototype.clear = function (eventId) { + if (this._scheduledEvents.hasOwnProperty(eventId)) { + var item = this._scheduledEvents[eventId.toString()]; + item.timeline.remove(item.event); + item.event.dispose(); + delete this._scheduledEvents[eventId.toString()]; + } + return this; + }; + /** + * Add an event to the correct timeline. Keep track of the + * timeline it was added to. + * @param {Tone.TransportEvent} event + * @param {Tone.Timeline} timeline + * @returns {Number} the event id which was just added + * @private + */ + Tone.Transport.prototype._addEvent = function (event, timeline) { + this._scheduledEvents[event.id.toString()] = { + 'event': event, + 'timeline': timeline + }; + timeline.add(event); + return event.id; + }; + /** + * Remove scheduled events from the timeline after + * the given time. Repeated events will be removed + * if their startTime is after the given time + * @param {TransportTime} [after=0] Clear all events after + * this time. + * @returns {Tone.Transport} this + */ + Tone.Transport.prototype.cancel = function (after) { + after = Tone.defaultArg(after, 0); + after = this.toTicks(after); + this._timeline.forEachFrom(after, function (event) { + this.clear(event.id); + }.bind(this)); + this._repeatedEvents.forEachFrom(after, function (event) { + this.clear(event.id); + }.bind(this)); + return this; + }; + /////////////////////////////////////////////////////////////////////////////// + // START/STOP/PAUSE + /////////////////////////////////////////////////////////////////////////////// + /** + * Bind start/stop/pause events from the clock and emit them. + * @private + */ + Tone.Transport.prototype._bindClockEvents = function () { + this._clock.on('start', function (time, offset) { + offset = Tone.Ticks(offset).toSeconds(); + this.emit('start', time, offset); + }.bind(this)); + this._clock.on('stop', function (time) { + this.emit('stop', time); + }.bind(this)); + this._clock.on('pause', function (time) { + this.emit('pause', time); + }.bind(this)); + }; + /** + * Returns the playback state of the source, either "started", "stopped", or "paused" + * @type {Tone.State} + * @readOnly + * @memberOf Tone.Transport# + * @name state + */ + Object.defineProperty(Tone.Transport.prototype, 'state', { + get: function () { + return this._clock.getStateAtTime(this.now()); + } + }); + /** + * Start the transport and all sources synced to the transport. + * @param {Time} [time=now] The time when the transport should start. + * @param {TransportTime=} offset The timeline offset to start the transport. + * @returns {Tone.Transport} this + * @example + * //start the transport in one second starting at beginning of the 5th measure. + * Tone.Transport.start("+1", "4:0:0"); + */ + Tone.Transport.prototype.start = function (time, offset) { + //start the clock + if (Tone.isDefined(offset)) { + offset = this.toTicks(offset); + } + this._clock.start(time, offset); + return this; + }; + /** + * Stop the transport and all sources synced to the transport. + * @param {Time} [time=now] The time when the transport should stop. + * @returns {Tone.Transport} this + * @example + * Tone.Transport.stop(); + */ + Tone.Transport.prototype.stop = function (time) { + this._clock.stop(time); + return this; + }; + /** + * Pause the transport and all sources synced to the transport. + * @param {Time} [time=now] + * @returns {Tone.Transport} this + */ + Tone.Transport.prototype.pause = function (time) { + this._clock.pause(time); + return this; + }; + /** + * Toggle the current state of the transport. If it is + * started, it will stop it, otherwise it will start the Transport. + * @param {Time=} time The time of the event + * @return {Tone.Transport} this + */ + Tone.Transport.prototype.toggle = function (time) { + time = this.toSeconds(time); + if (this._clock.getStateAtTime(time) !== Tone.State.Started) { + this.start(time); + } else { + this.stop(time); + } + return this; + }; + /////////////////////////////////////////////////////////////////////////////// + // SETTERS/GETTERS + /////////////////////////////////////////////////////////////////////////////// + /** + * The time signature as just the numerator over 4. + * For example 4/4 would be just 4 and 6/8 would be 3. + * @memberOf Tone.Transport# + * @type {Number|Array} + * @name timeSignature + * @example + * //common time + * Tone.Transport.timeSignature = 4; + * // 7/8 + * Tone.Transport.timeSignature = [7, 8]; + * //this will be reduced to a single number + * Tone.Transport.timeSignature; //returns 3.5 + */ + Object.defineProperty(Tone.Transport.prototype, 'timeSignature', { + get: function () { + return this._timeSignature; + }, + set: function (timeSig) { + if (Tone.isArray(timeSig)) { + timeSig = timeSig[0] / timeSig[1] * 4; + } + this._timeSignature = timeSig; + } + }); + /** + * When the Tone.Transport.loop = true, this is the starting position of the loop. + * @memberOf Tone.Transport# + * @type {Time} + * @name loopStart + */ + Object.defineProperty(Tone.Transport.prototype, 'loopStart', { + get: function () { + return Tone.Ticks(this._loopStart).toSeconds(); + }, + set: function (startPosition) { + this._loopStart = this.toTicks(startPosition); + } + }); + /** + * When the Tone.Transport.loop = true, this is the ending position of the loop. + * @memberOf Tone.Transport# + * @type {Time} + * @name loopEnd + */ + Object.defineProperty(Tone.Transport.prototype, 'loopEnd', { + get: function () { + return Tone.Ticks(this._loopEnd).toSeconds(); + }, + set: function (endPosition) { + this._loopEnd = this.toTicks(endPosition); + } + }); + /** + * Set the loop start and stop at the same time. + * @param {TransportTime} startPosition + * @param {TransportTime} endPosition + * @returns {Tone.Transport} this + * @example + * //loop over the first measure + * Tone.Transport.setLoopPoints(0, "1m"); + * Tone.Transport.loop = true; + */ + Tone.Transport.prototype.setLoopPoints = function (startPosition, endPosition) { + this.loopStart = startPosition; + this.loopEnd = endPosition; + return this; + }; + /** + * The swing value. Between 0-1 where 1 equal to + * the note + half the subdivision. + * @memberOf Tone.Transport# + * @type {NormalRange} + * @name swing + */ + Object.defineProperty(Tone.Transport.prototype, 'swing', { + get: function () { + return this._swingAmount; + }, + set: function (amount) { + //scale the values to a normal range + this._swingAmount = amount; + } + }); + /** + * Set the subdivision which the swing will be applied to. + * The default value is an 8th note. Value must be less + * than a quarter note. + * + * @memberOf Tone.Transport# + * @type {Time} + * @name swingSubdivision + */ + Object.defineProperty(Tone.Transport.prototype, 'swingSubdivision', { + get: function () { + return Tone.Ticks(this._swingTicks).toNotation(); + }, + set: function (subdivision) { + this._swingTicks = this.toTicks(subdivision); + } + }); + /** + * The Transport's position in Bars:Beats:Sixteenths. + * Setting the value will jump to that position right away. + * @memberOf Tone.Transport# + * @type {BarsBeatsSixteenths} + * @name position + */ + Object.defineProperty(Tone.Transport.prototype, 'position', { + get: function () { + var now = this.now(); + var ticks = this._clock.getTicksAtTime(now); + return Tone.Ticks(ticks).toBarsBeatsSixteenths(); + }, + set: function (progress) { + var ticks = this.toTicks(progress); + this.ticks = ticks; + } + }); + /** + * The Transport's position in seconds + * Setting the value will jump to that position right away. + * @memberOf Tone.Transport# + * @type {Seconds} + * @name seconds + */ + Object.defineProperty(Tone.Transport.prototype, 'seconds', { + get: function () { + return this._clock.seconds; + }, + set: function (s) { + var now = this.now(); + var ticks = this.bpm.timeToTicks(s, now); + this.ticks = ticks; + } + }); + /** + * The Transport's loop position as a normalized value. Always + * returns 0 if the transport if loop is not true. + * @memberOf Tone.Transport# + * @name progress + * @type {NormalRange} + */ + Object.defineProperty(Tone.Transport.prototype, 'progress', { + get: function () { + if (this.loop) { + var now = this.now(); + var ticks = this._clock.getTicksAtTime(now); + return (ticks - this._loopStart) / (this._loopEnd - this._loopStart); + } else { + return 0; + } + } + }); + /** + * The transports current tick position. + * + * @memberOf Tone.Transport# + * @type {Ticks} + * @name ticks + */ + Object.defineProperty(Tone.Transport.prototype, 'ticks', { + get: function () { + return this._clock.ticks; + }, + set: function (t) { + if (this._clock.ticks !== t) { + var now = this.now(); + //stop everything synced to the transport + if (this.state === Tone.State.Started) { + this.emit('stop', now); + this._clock.setTicksAtTime(t, now); + //restart it with the new time + this.emit('start', now, this.seconds); + } else { + this._clock.setTicksAtTime(t, now); + } + } + } + }); + /** + * Get the clock's ticks at the given time. + * @param {Time} time When to get the tick value + * @return {Ticks} The tick value at the given time. + */ + Tone.Transport.prototype.getTicksAtTime = function (time) { + return Math.round(this._clock.getTicksAtTime(time)); + }; + /** + * Return the elapsed seconds at the given time. + * @param {Time} time When to get the elapsed seconds + * @return {Seconds} The number of elapsed seconds + */ + Tone.Transport.prototype.getSecondsAtTime = function (time) { + return this._clock.getSecondsAtTime(time); + }; + /** + * Pulses Per Quarter note. This is the smallest resolution + * the Transport timing supports. This should be set once + * on initialization and not set again. Changing this value + * after other objects have been created can cause problems. + * + * @memberOf Tone.Transport# + * @type {Number} + * @name PPQ + */ + Object.defineProperty(Tone.Transport.prototype, 'PPQ', { + get: function () { + return this._ppq; + }, + set: function (ppq) { + var bpm = this.bpm.value; + this._ppq = ppq; + this.bpm.value = bpm; + } + }); + /** + * Convert from BPM to frequency (factoring in PPQ) + * @param {BPM} bpm The BPM value to convert to frequency + * @return {Frequency} The BPM as a frequency with PPQ factored in. + * @private + */ + Tone.Transport.prototype._fromUnits = function (bpm) { + return 1 / (60 / bpm / this.PPQ); + }; + /** + * Convert from frequency (with PPQ) into BPM + * @param {Frequency} freq The clocks frequency to convert to BPM + * @return {BPM} The frequency value as BPM. + * @private + */ + Tone.Transport.prototype._toUnits = function (freq) { + return freq / this.PPQ * 60; + }; + /////////////////////////////////////////////////////////////////////////////// + // SYNCING + /////////////////////////////////////////////////////////////////////////////// + /** + * Returns the time aligned to the next subdivision + * of the Transport. If the Transport is not started, + * it will return 0. + * Note: this will not work precisely during tempo ramps. + * @param {Time} subdivision The subdivision to quantize to + * @return {Number} The context time of the next subdivision. + * @example + * Tone.Transport.start(); //the transport must be started + * Tone.Transport.nextSubdivision("4n"); + */ + Tone.Transport.prototype.nextSubdivision = function (subdivision) { + subdivision = this.toTicks(subdivision); + if (this.state !== Tone.State.Started) { + //if the transport's not started, return 0 + return 0; + } else { + var now = this.now(); + //the remainder of the current ticks and the subdivision + var transportPos = this.getTicksAtTime(now); + var remainingTicks = subdivision - transportPos % subdivision; + return this._clock.nextTickTime(remainingTicks, now); + } + }; + /** + * Attaches the signal to the tempo control signal so that + * any changes in the tempo will change the signal in the same + * ratio. + * + * @param {Tone.Signal} signal + * @param {number=} ratio Optionally pass in the ratio between + * the two signals. Otherwise it will be computed + * based on their current values. + * @returns {Tone.Transport} this + */ + Tone.Transport.prototype.syncSignal = function (signal, ratio) { + if (!ratio) { + //get the sync ratio + var now = this.now(); + if (signal.getValueAtTime(now) !== 0) { + ratio = signal.getValueAtTime(now) / this.bpm.getValueAtTime(now); + } else { + ratio = 0; + } + } + var ratioSignal = new Tone.Gain(ratio); + this.bpm.chain(ratioSignal, signal._param); + this._syncedSignals.push({ + 'ratio': ratioSignal, + 'signal': signal, + 'initial': signal.value + }); + signal.value = 0; + return this; + }; + /** + * Unsyncs a previously synced signal from the transport's control. + * See Tone.Transport.syncSignal. + * @param {Tone.Signal} signal + * @returns {Tone.Transport} this + */ + Tone.Transport.prototype.unsyncSignal = function (signal) { + for (var i = this._syncedSignals.length - 1; i >= 0; i--) { + var syncedSignal = this._syncedSignals[i]; + if (syncedSignal.signal === signal) { + syncedSignal.ratio.dispose(); + syncedSignal.signal.value = syncedSignal.initial; + this._syncedSignals.splice(i, 1); + } + } + return this; + }; + /** + * Clean up. + * @returns {Tone.Transport} this + * @private + */ + Tone.Transport.prototype.dispose = function () { + Tone.Emitter.prototype.dispose.call(this); + this._clock.dispose(); + this._clock = null; + this._writable('bpm'); + this.bpm = null; + this._timeline.dispose(); + this._timeline = null; + this._repeatedEvents.dispose(); + this._repeatedEvents = null; + return this; + }; + /////////////////////////////////////////////////////////////////////////////// + // INITIALIZATION + /////////////////////////////////////////////////////////////////////////////// + var TransportConstructor = Tone.Transport; + Tone.Transport = new TransportConstructor(); + Tone.Context.on('init', function (context) { + if (context.Transport instanceof TransportConstructor) { + Tone.Transport = context.Transport; + } else { + Tone.Transport = new TransportConstructor(); + } + //store the Transport on the context so it can be retrieved later + context.Transport = Tone.Transport; + }); + Tone.Context.on('close', function (context) { + if (context.Transport instanceof TransportConstructor) { + context.Transport.dispose(); + } + }); + return Tone.Transport; + }); + Module(function (Tone) { + + /** + * @class Tone.Volume is a simple volume node, useful for creating a volume fader. + * + * @extends {Tone.AudioNode} + * @constructor + * @param {Decibels} [volume=0] the initial volume + * @example + * var vol = new Tone.Volume(-12); + * instrument.chain(vol, Tone.Master); + */ + Tone.Volume = function () { + var options = Tone.defaults(arguments, ['volume'], Tone.Volume); + Tone.AudioNode.call(this); + /** + * the output node + * @type {GainNode} + * @private + */ + this.output = this.input = new Tone.Gain(options.volume, Tone.Type.Decibels); + /** + * The unmuted volume + * @type {Decibels} + * @private + */ + this._unmutedVolume = options.volume; + /** + * The volume control in decibels. + * @type {Decibels} + * @signal + */ + this.volume = this.output.gain; + this._readOnly('volume'); + //set the mute initially + this.mute = options.mute; + }; + Tone.extend(Tone.Volume, Tone.AudioNode); + /** + * Defaults + * @type {Object} + * @const + * @static + */ + Tone.Volume.defaults = { + 'volume': 0, + 'mute': false + }; + /** + * Mute the output. + * @memberOf Tone.Volume# + * @type {boolean} + * @name mute + * @example + * //mute the output + * volume.mute = true; + */ + Object.defineProperty(Tone.Volume.prototype, 'mute', { + get: function () { + return this.volume.value === -Infinity; + }, + set: function (mute) { + if (!this.mute && mute) { + this._unmutedVolume = this.volume.value; + //maybe it should ramp here? + this.volume.value = -Infinity; + } else if (this.mute && !mute) { + this.volume.value = this._unmutedVolume; + } + } + }); + /** + * clean up + * @returns {Tone.Volume} this + */ + Tone.Volume.prototype.dispose = function () { + this.input.dispose(); + Tone.AudioNode.prototype.dispose.call(this); + this._writable('volume'); + this.volume.dispose(); + this.volume = null; + return this; + }; + return Tone.Volume; + }); + Module(function (Tone) { + + /** + * @class A single master output which is connected to the + * AudioDestinationNode (aka your speakers). + * It provides useful conveniences such as the ability + * to set the volume and mute the entire application. + * It also gives you the ability to apply master effects to your application. + * <br><br> + * Like Tone.Transport, A single Tone.Master is created + * on initialization and you do not need to explicitly construct one. + * + * @constructor + * @extends {Tone} + * @singleton + * @example + * //the audio will go from the oscillator to the speakers + * oscillator.connect(Tone.Master); + * //a convenience for connecting to the master output is also provided: + * oscillator.toMaster(); + * //the above two examples are equivalent. + */ + Tone.Master = function () { + Tone.AudioNode.call(this); + Tone.getContext(function () { + this.createInsOuts(1, 0); + /** + * The private volume node + * @type {Tone.Volume} + * @private + */ + this._volume = this.output = new Tone.Volume(); + /** + * The volume of the master output. + * @type {Decibels} + * @signal + */ + this.volume = this._volume.volume; + this._readOnly('volume'); + //connections + this.input.chain(this.output, this.context.destination); + }.bind(this)); + }; + Tone.extend(Tone.Master, Tone.AudioNode); + /** + * @type {Object} + * @const + */ + Tone.Master.defaults = { + 'volume': 0, + 'mute': false + }; + /** + * Mute the output. + * @memberOf Tone.Master# + * @type {boolean} + * @name mute + * @example + * //mute the output + * Tone.Master.mute = true; + */ + Object.defineProperty(Tone.Master.prototype, 'mute', { + get: function () { + return this._volume.mute; + }, + set: function (mute) { + this._volume.mute = mute; + } + }); + /** + * Add a master effects chain. NOTE: this will disconnect any nodes which were previously + * chained in the master effects chain. + * @param {AudioNode|Tone} args... All arguments will be connected in a row + * and the Master will be routed through it. + * @return {Tone.Master} this + * @example + * //some overall compression to keep the levels in check + * var masterCompressor = new Tone.Compressor({ + * "threshold" : -6, + * "ratio" : 3, + * "attack" : 0.5, + * "release" : 0.1 + * }); + * //give a little boost to the lows + * var lowBump = new Tone.Filter(200, "lowshelf"); + * //route everything through the filter + * //and compressor before going to the speakers + * Tone.Master.chain(lowBump, masterCompressor); + */ + Tone.Master.prototype.chain = function () { + this.input.disconnect(); + this.input.chain.apply(this.input, arguments); + arguments[arguments.length - 1].connect(this.output); + }; + /** + * Clean up + * @return {Tone.Master} this + */ + Tone.Master.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable('volume'); + this._volume.dispose(); + this._volume = null; + this.volume = null; + }; + /////////////////////////////////////////////////////////////////////////// + // AUGMENT TONE's PROTOTYPE + /////////////////////////////////////////////////////////////////////////// + /** + * Connect 'this' to the master output. Shorthand for this.connect(Tone.Master) + * @returns {Tone.AudioNode} this + * @example + * //connect an oscillator to the master output + * var osc = new Tone.Oscillator().toMaster(); + */ + Tone.AudioNode.prototype.toMaster = function () { + this.connect(Tone.Master); + return this; + }; + if (window.AudioNode) { + // Also augment AudioNode's prototype to include toMaster as a convenience + AudioNode.prototype.toMaster = function () { + this.connect(Tone.Master); + return this; + }; + } + /** + * initialize the module and listen for new audio contexts + */ + var MasterConstructor = Tone.Master; + Tone.Master = new MasterConstructor(); + Tone.Context.on('init', function (context) { + // if it already exists, just restore it + if (context.Master instanceof MasterConstructor) { + Tone.Master = context.Master; + } else { + Tone.Master = new MasterConstructor(); + } + context.Master = Tone.Master; + }); + Tone.Context.on('close', function (context) { + if (context.Master instanceof MasterConstructor) { + context.Master.dispose(); + } + }); + return Tone.Master; + }); + Module(function (Tone) { + + /** + * @class Base class for sources. Sources have start/stop methods + * and the ability to be synced to the + * start/stop of Tone.Transport. + * + * @constructor + * @extends {Tone.AudioNode} + * @example + * //Multiple state change events can be chained together, + * //but must be set in the correct order and with ascending times + * + * // OK + * state.start().stop("+0.2"); + * // AND + * state.start().stop("+0.2").start("+0.4").stop("+0.7") + * + * // BAD + * state.stop("+0.2").start(); + * // OR + * state.start("+0.3").stop("+0.2"); + * + */ + Tone.Source = function (options) { + options = Tone.defaultArg(options, Tone.Source.defaults); + Tone.AudioNode.call(this); + /** + * The output volume node + * @type {Tone.Volume} + * @private + */ + this._volume = this.output = new Tone.Volume(options.volume); + /** + * The volume of the output in decibels. + * @type {Decibels} + * @signal + * @example + * source.volume.value = -6; + */ + this.volume = this._volume.volume; + this._readOnly('volume'); + /** + * Keep track of the scheduled state. + * @type {Tone.TimelineState} + * @private + */ + this._state = new Tone.TimelineState(Tone.State.Stopped); + this._state.memory = 100; + /** + * The synced `start` callback function from the transport + * @type {Function} + * @private + */ + this._synced = false; + /** + * Keep track of all of the scheduled event ids + * @type {Array} + * @private + */ + this._scheduled = []; + //make the output explicitly stereo + this._volume.output.output.channelCount = 2; + this._volume.output.output.channelCountMode = 'explicit'; + //mute initially + this.mute = options.mute; + }; + Tone.extend(Tone.Source, Tone.AudioNode); + /** + * The default parameters + * @static + * @const + * @type {Object} + */ + Tone.Source.defaults = { + 'volume': 0, + 'mute': false + }; + /** + * Returns the playback state of the source, either "started" or "stopped". + * @type {Tone.State} + * @readOnly + * @memberOf Tone.Source# + * @name state + */ + Object.defineProperty(Tone.Source.prototype, 'state', { + get: function () { + if (this._synced) { + if (Tone.Transport.state === Tone.State.Started) { + return this._state.getValueAtTime(Tone.Transport.seconds); + } else { + return Tone.State.Stopped; + } + } else { + return this._state.getValueAtTime(this.now()); + } + } + }); + /** + * Mute the output. + * @memberOf Tone.Source# + * @type {boolean} + * @name mute + * @example + * //mute the output + * source.mute = true; + */ + Object.defineProperty(Tone.Source.prototype, 'mute', { + get: function () { + return this._volume.mute; + }, + set: function (mute) { + this._volume.mute = mute; + } + }); + //overwrite these functions + Tone.Source.prototype._start = Tone.noOp; + Tone.Source.prototype.restart = Tone.noOp; + Tone.Source.prototype._stop = Tone.noOp; + /** + * Start the source at the specified time. If no time is given, + * start the source now. + * @param {Time} [time=now] When the source should be started. + * @returns {Tone.Source} this + * @example + * source.start("+0.5"); //starts the source 0.5 seconds from now + */ + Tone.Source.prototype.start = function (time, offset, duration) { + if (Tone.isUndef(time) && this._synced) { + time = Tone.Transport.seconds; + } else { + time = this.toSeconds(time); + } + //if it's started, stop it and restart it + if (this._state.getValueAtTime(time) === Tone.State.Started) { + this._state.cancel(time); + this._state.setStateAtTime(Tone.State.Started, time); + this.restart(time, offset, duration); + } else { + this._state.setStateAtTime(Tone.State.Started, time); + if (this._synced) { + // add the offset time to the event + var event = this._state.get(time); + event.offset = Tone.defaultArg(offset, 0); + event.duration = duration; + var sched = Tone.Transport.schedule(function (t) { + this._start(t, offset, duration); + }.bind(this), time); + this._scheduled.push(sched); + //if it's already started + if (Tone.Transport.state === Tone.State.Started) { + this._syncedStart(this.now(), Tone.Transport.seconds); + } + } else { + this._start.apply(this, arguments); + } + } + return this; + }; + /** + * Stop the source at the specified time. If no time is given, + * stop the source now. + * @param {Time} [time=now] When the source should be stopped. + * @returns {Tone.Source} this + * @example + * source.stop(); // stops the source immediately + */ + Tone.Source.prototype.stop = function (time) { + if (Tone.isUndef(time) && this._synced) { + time = Tone.Transport.seconds; + } else { + time = this.toSeconds(time); + } + if (!this._synced) { + this._stop.apply(this, arguments); + } else { + var sched = Tone.Transport.schedule(this._stop.bind(this), time); + this._scheduled.push(sched); + } + this._state.cancel(time); + this._state.setStateAtTime(Tone.State.Stopped, time); + return this; + }; + /** + * Sync the source to the Transport so that all subsequent + * calls to `start` and `stop` are synced to the TransportTime + * instead of the AudioContext time. + * + * @returns {Tone.Source} this + * @example + * //sync the source so that it plays between 0 and 0.3 on the Transport's timeline + * source.sync().start(0).stop(0.3); + * //start the transport. + * Tone.Transport.start(); + * + * @example + * //start the transport with an offset and the sync'ed sources + * //will start in the correct position + * source.sync().start(0.1); + * //the source will be invoked with an offset of 0.4 + * Tone.Transport.start("+0.5", 0.5); + */ + Tone.Source.prototype.sync = function () { + this._synced = true; + this._syncedStart = function (time, offset) { + if (offset > 0) { + // get the playback state at that time + var stateEvent = this._state.get(offset); + // listen for start events which may occur in the middle of the sync'ed time + if (stateEvent && stateEvent.state === Tone.State.Started && stateEvent.time !== offset) { + // get the offset + var startOffset = offset - this.toSeconds(stateEvent.time); + var duration; + if (stateEvent.duration) { + duration = this.toSeconds(stateEvent.duration) - startOffset; + } + this._start(time, this.toSeconds(stateEvent.offset) + startOffset, duration); + } + } + }.bind(this); + this._syncedStop = function (time) { + var seconds = Tone.Transport.getSecondsAtTime(Math.max(time - this.sampleTime, 0)); + if (this._state.getValueAtTime(seconds) === Tone.State.Started) { + this._stop(time); + } + }.bind(this); + Tone.Transport.on('start loopStart', this._syncedStart); + Tone.Transport.on('stop pause loopEnd', this._syncedStop); + return this; + }; + /** + * Unsync the source to the Transport. See Tone.Source.sync + * @returns {Tone.Source} this + */ + Tone.Source.prototype.unsync = function () { + if (this._synced) { + Tone.Transport.off('stop pause loopEnd', this._syncedStop); + Tone.Transport.off('start loopStart', this._syncedStart); + } + this._synced = false; + // clear all of the scheduled ids + for (var i = 0; i < this._scheduled.length; i++) { + var id = this._scheduled[i]; + Tone.Transport.clear(id); + } + this._scheduled = []; + this._state.cancel(0); + return this; + }; + /** + * Clean up. + * @return {Tone.Source} this + */ + Tone.Source.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this.unsync(); + this._scheduled = null; + this._writable('volume'); + this._volume.dispose(); + this._volume = null; + this.volume = null; + this._state.dispose(); + this._state = null; + }; + return Tone.Source; + }); + Module(function (Tone) { + /** + * AudioBuffer.copyTo/FromChannel polyfill + * @private + */ + if (Tone.supported) { + if (!AudioBuffer.prototype.copyToChannel) { + AudioBuffer.prototype.copyToChannel = function (src, chanNum, start) { + var channel = this.getChannelData(chanNum); + start = start || 0; + for (var i = 0; i < channel.length; i++) { + channel[i + start] = src[i]; + } + }; + AudioBuffer.prototype.copyFromChannel = function (dest, chanNum, start) { + var channel = this.getChannelData(chanNum); + start = start || 0; + for (var i = 0; i < dest.length; i++) { + dest[i] = channel[i + start]; + } + }; + } + } + }); + Module(function (Tone) { + + /** + * @class Buffer loading and storage. Tone.Buffer is used internally by all + * classes that make requests for audio files such as Tone.Player, + * Tone.Sampler and Tone.Convolver. + * + * Aside from load callbacks from individual buffers, Tone.Buffer + * provides events which keep track of the loading progress + * of _all_ of the buffers. These are Tone.Buffer.on("load" / "progress" / "error") + * + * @constructor + * @extends {Tone} + * @param {AudioBuffer|String} url The url to load, or the audio buffer to set. + * @param {Function=} onload A callback which is invoked after the buffer is loaded. + * It's recommended to use `Tone.Buffer.on('load', callback)` instead + * since it will give you a callback when _all_ buffers are loaded. + * @param {Function=} onerror The callback to invoke if there is an error + * @example + * var buffer = new Tone.Buffer("path/to/sound.mp3", function(){ + * //the buffer is now available. + * var buff = buffer.get(); + * }); + * @example + * //can load provide fallback extension types if the first type is not supported. + * var buffer = new Tone.Buffer("path/to/sound.[mp3|ogg|wav]"); + */ + Tone.Buffer = function () { + var options = Tone.defaults(arguments, [ + 'url', + 'onload', + 'onerror' + ], Tone.Buffer); + Tone.call(this); + /** + * stores the loaded AudioBuffer + * @type {AudioBuffer} + * @private + */ + this._buffer = null; + /** + * indicates if the buffer should be reversed or not + * @type {Boolean} + * @private + */ + this._reversed = options.reverse; + /** + * The XHR + * @type {XMLHttpRequest} + * @private + */ + this._xhr = null; + /** + * Private callback when the buffer is loaded. + * @type {Function} + * @private + */ + this._onload = Tone.noOp; + if (options.url instanceof AudioBuffer || options.url instanceof Tone.Buffer) { + this.set(options.url); + // invoke the onload callback + if (options.onload) { + if (this.loaded) { + options.onload(this); + } else { + this._onload = options.onload; + } + } + } else if (Tone.isString(options.url)) { + this.load(options.url).then(options.onload).catch(options.onerror); + } + }; + Tone.extend(Tone.Buffer); + /** + * the default parameters + * @type {Object} + */ + Tone.Buffer.defaults = { + 'url': undefined, + 'reverse': false, + 'onload': Tone.noOp, + 'onerror': Tone.noOp + }; + /** + * Pass in an AudioBuffer or Tone.Buffer to set the value + * of this buffer. + * @param {AudioBuffer|Tone.Buffer} buffer the buffer + * @returns {Tone.Buffer} this + */ + Tone.Buffer.prototype.set = function (buffer) { + if (buffer instanceof Tone.Buffer) { + if (buffer.loaded) { + this._buffer = buffer.get(); + } else { + buffer._onload = function () { + this.set(buffer); + this._onload(this); + }.bind(this); + } + } else { + this._buffer = buffer; + } + return this; + }; + /** + * @return {AudioBuffer} The audio buffer stored in the object. + */ + Tone.Buffer.prototype.get = function () { + return this._buffer; + }; + /** + * Makes an xhr reqest for the selected url then decodes + * the file as an audio buffer. Invokes + * the callback once the audio buffer loads. + * @param {String} url The url of the buffer to load. + * filetype support depends on the + * browser. + * @returns {Promise} returns a Promise which resolves with the Tone.Buffer + */ + Tone.Buffer.prototype.load = function (url, onload, onerror) { + var promise = new Promise(function (load, error) { + this._xhr = Tone.Buffer.load(url, //success + function (buff) { + this._xhr = null; + this.set(buff); + load(this); + this._onload(this); + if (onload) { + onload(this); + } + }.bind(this), //error + function (err) { + this._xhr = null; + error(err); + if (onerror) { + onerror(err); + } + }.bind(this)); + }.bind(this)); + return promise; + }; + /** + * dispose and disconnect + * @returns {Tone.Buffer} this + */ + Tone.Buffer.prototype.dispose = function () { + Tone.prototype.dispose.call(this); + this._buffer = null; + if (this._xhr) { + Tone.Buffer._removeFromDownloadQueue(this._xhr); + this._xhr.abort(); + this._xhr = null; + } + return this; + }; + /** + * If the buffer is loaded or not + * @memberOf Tone.Buffer# + * @type {Boolean} + * @name loaded + * @readOnly + */ + Object.defineProperty(Tone.Buffer.prototype, 'loaded', { + get: function () { + return this.length > 0; + } + }); + /** + * The duration of the buffer. + * @memberOf Tone.Buffer# + * @type {Number} + * @name duration + * @readOnly + */ + Object.defineProperty(Tone.Buffer.prototype, 'duration', { + get: function () { + if (this._buffer) { + return this._buffer.duration; + } else { + return 0; + } + } + }); + /** + * The length of the buffer in samples + * @memberOf Tone.Buffer# + * @type {Number} + * @name length + * @readOnly + */ + Object.defineProperty(Tone.Buffer.prototype, 'length', { + get: function () { + if (this._buffer) { + return this._buffer.length; + } else { + return 0; + } + } + }); + /** + * The number of discrete audio channels. Returns 0 if no buffer + * is loaded. + * @memberOf Tone.Buffer# + * @type {Number} + * @name numberOfChannels + * @readOnly + */ + Object.defineProperty(Tone.Buffer.prototype, 'numberOfChannels', { + get: function () { + if (this._buffer) { + return this._buffer.numberOfChannels; + } else { + return 0; + } + } + }); + /** + * Set the audio buffer from the array. To create a multichannel AudioBuffer, + * pass in a multidimensional array. + * @param {Float32Array} array The array to fill the audio buffer + * @return {Tone.Buffer} this + */ + Tone.Buffer.prototype.fromArray = function (array) { + var isMultidimensional = array[0].length > 0; + var channels = isMultidimensional ? array.length : 1; + var len = isMultidimensional ? array[0].length : array.length; + var buffer = this.context.createBuffer(channels, len, this.context.sampleRate); + if (!isMultidimensional && channels === 1) { + array = [array]; + } + for (var c = 0; c < channels; c++) { + buffer.copyToChannel(array[c], c); + } + this._buffer = buffer; + return this; + }; + /** + * Sums muliple channels into 1 channel + * @param {Number=} channel Optionally only copy a single channel from the array. + * @return {Array} + */ + Tone.Buffer.prototype.toMono = function (chanNum) { + if (Tone.isNumber(chanNum)) { + this.fromArray(this.toArray(chanNum)); + } else { + var outputArray = new Float32Array(this.length); + var numChannels = this.numberOfChannels; + for (var channel = 0; channel < numChannels; channel++) { + var channelArray = this.toArray(channel); + for (var i = 0; i < channelArray.length; i++) { + outputArray[i] += channelArray[i]; + } + } + //divide by the number of channels + outputArray = outputArray.map(function (sample) { + return sample / numChannels; + }); + this.fromArray(outputArray); + } + return this; + }; + /** + * Get the buffer as an array. Single channel buffers will return a 1-dimensional + * Float32Array, and multichannel buffers will return multidimensional arrays. + * @param {Number=} channel Optionally only copy a single channel from the array. + * @return {Array} + */ + Tone.Buffer.prototype.toArray = function (channel) { + if (Tone.isNumber(channel)) { + return this.getChannelData(channel); + } else if (this.numberOfChannels === 1) { + return this.toArray(0); + } else { + var ret = []; + for (var c = 0; c < this.numberOfChannels; c++) { + ret[c] = this.getChannelData(c); + } + return ret; + } + }; + /** + * Returns the Float32Array representing the PCM audio data for the specific channel. + * @param {Number} channel The channel number to return + * @return {Float32Array} The audio as a TypedArray + */ + Tone.Buffer.prototype.getChannelData = function (channel) { + return this._buffer.getChannelData(channel); + }; + /** + * Cut a subsection of the array and return a buffer of the + * subsection. Does not modify the original buffer + * @param {Time} start The time to start the slice + * @param {Time=} end The end time to slice. If none is given + * will default to the end of the buffer + * @return {Tone.Buffer} this + */ + Tone.Buffer.prototype.slice = function (start, end) { + end = Tone.defaultArg(end, this.duration); + var startSamples = Math.floor(this.context.sampleRate * this.toSeconds(start)); + var endSamples = Math.floor(this.context.sampleRate * this.toSeconds(end)); + var replacement = []; + for (var i = 0; i < this.numberOfChannels; i++) { + replacement[i] = this.toArray(i).slice(startSamples, endSamples); + } + var retBuffer = new Tone.Buffer().fromArray(replacement); + return retBuffer; + }; + /** + * Reverse the buffer. + * @private + * @return {Tone.Buffer} this + */ + Tone.Buffer.prototype._reverse = function () { + if (this.loaded) { + for (var i = 0; i < this.numberOfChannels; i++) { + Array.prototype.reverse.call(this.getChannelData(i)); + } + } + return this; + }; + /** + * Reverse the buffer. + * @memberOf Tone.Buffer# + * @type {Boolean} + * @name reverse + */ + Object.defineProperty(Tone.Buffer.prototype, 'reverse', { + get: function () { + return this._reversed; + }, + set: function (rev) { + if (this._reversed !== rev) { + this._reversed = rev; + this._reverse(); + } + } + }); + /////////////////////////////////////////////////////////////////////////// + // STATIC METHODS + /////////////////////////////////////////////////////////////////////////// + //statically inherits Emitter methods + Tone.Emitter.mixin(Tone.Buffer); + /** + * the static queue for all of the xhr requests + * @type {Array} + * @private + */ + Tone.Buffer._downloadQueue = []; + /** + * A path which is prefixed before every url. + * @type {String} + * @static + */ + Tone.Buffer.baseUrl = ''; + /** + * Create a Tone.Buffer from the array. To create a multichannel AudioBuffer, + * pass in a multidimensional array. + * @param {Float32Array} array The array to fill the audio buffer + * @return {Tone.Buffer} A Tone.Buffer created from the array + */ + Tone.Buffer.fromArray = function (array) { + return new Tone.Buffer().fromArray(array); + }; + /** + * Creates a Tone.Buffer from a URL, returns a promise + * which resolves to a Tone.Buffer + * @param {String} url The url to load. + * @return {Promise<Tone.Buffer>} A promise which resolves to a Tone.Buffer + */ + Tone.Buffer.fromUrl = function (url) { + var buffer = new Tone.Buffer(); + return buffer.load(url).then(function () { + return buffer; + }); + }; + /** + * Remove an xhr request from the download queue + * @private + */ + Tone.Buffer._removeFromDownloadQueue = function (request) { + var index = Tone.Buffer._downloadQueue.indexOf(request); + if (index !== -1) { + Tone.Buffer._downloadQueue.splice(index, 1); + } + }; + /** + * Loads a url using XMLHttpRequest. + * @param {String} url + * @param {Function} onload + * @param {Function} onerror + * @param {Function} onprogress + * @return {XMLHttpRequest} + */ + Tone.Buffer.load = function (url, onload, onerror) { + //default + onload = Tone.defaultArg(onload, Tone.noOp); + // test if the url contains multiple extensions + var matches = url.match(/\[(.+\|?)+\]$/); + if (matches) { + var extensions = matches[1].split('|'); + var extension = extensions[0]; + for (var i = 0; i < extensions.length; i++) { + if (Tone.Buffer.supportsType(extensions[i])) { + extension = extensions[i]; + break; + } + } + url = url.replace(matches[0], extension); + } + function onError(e) { + Tone.Buffer._removeFromDownloadQueue(request); + Tone.Buffer.emit('error', e); + if (onerror) { + onerror(e); + } else { + throw e; + } + } + function onProgress() { + //calculate the progress + var totalProgress = 0; + for (var i = 0; i < Tone.Buffer._downloadQueue.length; i++) { + totalProgress += Tone.Buffer._downloadQueue[i].progress; + } + Tone.Buffer.emit('progress', totalProgress / Tone.Buffer._downloadQueue.length); + } + var request = new XMLHttpRequest(); + request.open('GET', Tone.Buffer.baseUrl + url, true); + request.responseType = 'arraybuffer'; + //start out as 0 + request.progress = 0; + Tone.Buffer._downloadQueue.push(request); + request.addEventListener('load', function () { + if (request.status === 200) { + Tone.context.decodeAudioData(request.response).then(function (buff) { + request.progress = 1; + onProgress(); + onload(buff); + Tone.Buffer._removeFromDownloadQueue(request); + if (Tone.Buffer._downloadQueue.length === 0) { + //emit the event at the end + Tone.Buffer.emit('load'); + } + }).catch(function () { + Tone.Buffer._removeFromDownloadQueue(request); + onError('Tone.Buffer: could not decode audio data: ' + url); + }); + } else { + onError('Tone.Buffer: could not locate file: ' + url); + } + }); + request.addEventListener('error', onError); + request.addEventListener('progress', function (event) { + if (event.lengthComputable) { + //only go to 95%, the last 5% is when the audio is decoded + request.progress = event.loaded / event.total * 0.95; + onProgress(); + } + }); + request.send(); + return request; + }; + /** + * Stop all of the downloads in progress + * @return {Tone.Buffer} + * @static + */ + Tone.Buffer.cancelDownloads = function () { + Tone.Buffer._downloadQueue.slice().forEach(function (request) { + Tone.Buffer._removeFromDownloadQueue(request); + request.abort(); + }); + return Tone.Buffer; + }; + /** + * Checks a url's extension to see if the current browser can play that file type. + * @param {String} url The url/extension to test + * @return {Boolean} If the file extension can be played + * @static + * @example + * Tone.Buffer.supportsType("wav"); //returns true + * Tone.Buffer.supportsType("path/to/file.wav"); //returns true + */ + Tone.Buffer.supportsType = function (url) { + var extension = url.split('.'); + extension = extension[extension.length - 1]; + var response = document.createElement('audio').canPlayType('audio/' + extension); + return response !== ''; + }; + /** + * Returns a Promise which resolves when all of the buffers have loaded + * @return {Promise} + */ + Tone.loaded = function () { + var onload, onerror; + function removeEvents() { + //remove the events when it's resolved + Tone.Buffer.off('load', onload); + Tone.Buffer.off('error', onerror); + } + return new Promise(function (success, fail) { + onload = function () { + success(); + }; + onerror = function () { + fail(); + }; + //add the event listeners + Tone.Buffer.on('load', onload); + Tone.Buffer.on('error', onerror); + }).then(removeEvents).catch(function (e) { + removeEvents(); + throw new Error(e); + }); + }; + return Tone.Buffer; + }); + Module(function (Tone) { + /** + * @class Wrapper around the native fire-and-forget OscillatorNode. Adds the + * ability to reschedule the stop method. + * @extends {Tone.AudioNode} + * @param {AudioBuffer|Tone.Buffer} buffer The buffer to play + * @param {Function} onload The callback to invoke when the + * buffer is done playing. + */ + Tone.OscillatorNode = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type' + ], Tone.OscillatorNode); + Tone.AudioNode.call(this, options); + /** + * The callback to invoke after the + * buffer source is done playing. + * @type {Function} + */ + this.onended = options.onended; + /** + * The oscillator start time + * @type {Number} + * @private + */ + this._startTime = -1; + /** + * The oscillator stop time + * @type {Number} + * @private + */ + this._stopTime = -1; + /** + * The gain node which envelopes the OscillatorNode + * @type {Tone.Gain} + * @private + */ + this._gainNode = this.output = new Tone.Gain(); + this._gainNode.gain.setValueAtTime(0, this.context.currentTime); + /** + * The oscillator + * @type {OscillatorNode} + * @private + */ + this._oscillator = this.context.createOscillator(); + this._oscillator.connect(this._gainNode); + this.type = options.type; + /** + * The frequency of the oscillator + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Param(this._oscillator.frequency, Tone.Type.Frequency); + this.frequency.value = options.frequency; + /** + * The detune of the oscillator + * @type {Frequency} + * @signal + */ + this.detune = new Tone.Param(this._oscillator.detune, Tone.Type.Cents); + this.detune.value = options.detune; + /** + * The value that the buffer ramps to + * @type {Gain} + * @private + */ + this._gain = 1; + }; + Tone.extend(Tone.OscillatorNode, Tone.AudioNode); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.OscillatorNode.defaults = { + 'frequency': 440, + 'detune': 0, + 'type': 'sine', + 'onended': Tone.noOp + }; + /** + * Returns the playback state of the oscillator, either "started" or "stopped". + * @type {Tone.State} + * @readOnly + * @memberOf Tone.OscillatorNode# + * @name state + */ + Object.defineProperty(Tone.OscillatorNode.prototype, 'state', { + get: function () { + return this.getStateAtTime(this.now()); + } + }); + /** + * Get the playback state at the given time + * @param {Time} time The time to test the state at + * @return {Tone.State} The playback state. + */ + Tone.OscillatorNode.prototype.getStateAtTime = function (time) { + time = this.toSeconds(time); + if (this._startTime !== -1 && time >= this._startTime && (this._stopTime === -1 || time <= this._stopTime)) { + return Tone.State.Started; + } else { + return Tone.State.Stopped; + } + }; + /** + * Start the oscillator node at the given time + * @param {Time=} time When to start the oscillator + * @return {OscillatorNode} this + */ + Tone.OscillatorNode.prototype.start = function (time) { + if (this._startTime === -1) { + this._startTime = this.toSeconds(time); + this._oscillator.start(this._startTime); + var now = this.context.currentTime; + this._gainNode.gain.cancelScheduledValues(now); + this._gainNode.gain.setValueAtTime(0, now); + this._gainNode.gain.setValueAtTime(1, this._startTime); + } else { + throw new Error('cannot call OscillatorNode.start more than once'); + } + return this; + }; + /** + * Sets an arbitrary custom periodic waveform given a PeriodicWave. + * @param {PeriodicWave} periodicWave PeriodicWave should be created with context.createPeriodicWave + * @return {OscillatorNode} this + */ + Tone.OscillatorNode.prototype.setPeriodicWave = function (periodicWave) { + this._oscillator.setPeriodicWave(periodicWave); + return this; + }; + /** + * Stop the oscillator node at the given time + * @param {Time=} time When to stop the oscillator + * @return {OscillatorNode} this + */ + Tone.OscillatorNode.prototype.stop = function (time) { + //cancel the previous stop + this.cancelStop(); + //reschedule it + this._stopTime = this.toSeconds(time); + this._gainNode.gain.setValueAtTime(0, this._stopTime); + this.context.clearTimeout(this._timeout); + this._timeout = this.context.setTimeout(function () { + this._oscillator.stop(this.now()); + this.onended(); + }.bind(this), this._stopTime - this.now()); + return this; + }; + /** + * Cancel a scheduled stop event + * @return {Tone.OscillatorNode} this + */ + Tone.OscillatorNode.prototype.cancelStop = function () { + if (this._startTime !== -1) { + //cancel the stop envelope + this._gainNode.gain.cancelScheduledValues(this._startTime + this.sampleTime); + this._gainNode.gain.setValueAtTime(1, Math.max(this.now(), this._startTime)); + this.context.clearTimeout(this._timeout); + this._stopTime = -1; + } + return this; + }; + /** + * The oscillator type. Either 'sine', 'sawtooth', 'square', or 'triangle' + * @memberOf Tone.OscillatorNode# + * @type {Time} + * @name type + */ + Object.defineProperty(Tone.OscillatorNode.prototype, 'type', { + get: function () { + return this._oscillator.type; + }, + set: function (type) { + this._oscillator.type = type; + } + }); + /** + * Clean up. + * @return {Tone.OscillatorNode} this + */ + Tone.OscillatorNode.prototype.dispose = function () { + this.context.clearTimeout(this._timeout); + Tone.AudioNode.prototype.dispose.call(this); + this.onended = null; + this._oscillator.disconnect(); + this._oscillator = null; + this._gainNode.dispose(); + this._gainNode = null; + this.frequency.dispose(); + this.frequency = null; + this.detune.dispose(); + this.detune = null; + return this; + }; + return Tone.OscillatorNode; + }); + Module(function (Tone) { + + /** + * @class Tone.Oscillator supports a number of features including + * phase rotation, multiple oscillator types (see Tone.Oscillator.type), + * and Transport syncing (see Tone.Oscillator.syncFrequency). + * + * @constructor + * @extends {Tone.Source} + * @param {Frequency} [frequency] Starting frequency + * @param {string} [type] The oscillator type. Read more about type below. + * @example + * //make and start a 440hz sine tone + * var osc = new Tone.Oscillator(440, "sine").toMaster().start(); + */ + Tone.Oscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type' + ], Tone.Oscillator); + Tone.Source.call(this, options); + /** + * the main oscillator + * @type {OscillatorNode} + * @private + */ + this._oscillator = null; + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The detune control signal. + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(options.detune, Tone.Type.Cents); + /** + * the periodic wave + * @type {PeriodicWave} + * @private + */ + this._wave = null; + /** + * The partials of the oscillator + * @type {Array} + * @private + */ + this._partials = Tone.defaultArg(options.partials, [1]); + /** + * the phase of the oscillator + * between 0 - 360 + * @type {number} + * @private + */ + this._phase = options.phase; + /** + * the type of the oscillator + * @type {string} + * @private + */ + this._type = null; + //setup + this.type = options.type; + this.phase = this._phase; + this._readOnly([ + 'frequency', + 'detune' + ]); + }; + Tone.extend(Tone.Oscillator, Tone.Source); + /** + * the default parameters + * @type {Object} + */ + Tone.Oscillator.defaults = { + 'type': 'sine', + 'frequency': 440, + 'detune': 0, + 'phase': 0, + 'partials': [] + }; + /** + * The Oscillator types + * @enum {String} + */ + Tone.Oscillator.Type = { + Sine: 'sine', + Triangle: 'triangle', + Sawtooth: 'sawtooth', + Square: 'square', + Custom: 'custom' + }; + /** + * start the oscillator + * @param {Time} [time=now] + * @private + */ + Tone.Oscillator.prototype._start = function (time) { + //new oscillator with previous values + this._oscillator = new Tone.OscillatorNode(); + if (this._wave) { + this._oscillator.setPeriodicWave(this._wave); + } else { + this._oscillator.type = this._type; + } + //connect the control signal to the oscillator frequency & detune + this._oscillator.connect(this.output); + this.frequency.connect(this._oscillator.frequency); + this.detune.connect(this._oscillator.detune); + //start the oscillator + time = this.toSeconds(time); + this._oscillator.start(time); + }; + /** + * stop the oscillator + * @private + * @param {Time} [time=now] (optional) timing parameter + * @returns {Tone.Oscillator} this + */ + Tone.Oscillator.prototype._stop = function (time) { + if (this._oscillator) { + time = this.toSeconds(time); + this._oscillator.stop(time); + } + return this; + }; + /** + * Restart the oscillator. Does not stop the oscillator, but instead + * just cancels any scheduled 'stop' from being invoked. + * @param {Time=} time + * @return {Tone.Oscillator} this + */ + Tone.Oscillator.prototype.restart = function (time) { + this._oscillator.cancelStop(); + this._state.cancel(this.toSeconds(time)); + return this; + }; + /** + * Sync the signal to the Transport's bpm. Any changes to the transports bpm, + * will also affect the oscillators frequency. + * @returns {Tone.Oscillator} this + * @example + * Tone.Transport.bpm.value = 120; + * osc.frequency.value = 440; + * //the ration between the bpm and the frequency will be maintained + * osc.syncFrequency(); + * Tone.Transport.bpm.value = 240; + * // the frequency of the oscillator is doubled to 880 + */ + Tone.Oscillator.prototype.syncFrequency = function () { + Tone.Transport.syncSignal(this.frequency); + return this; + }; + /** + * Unsync the oscillator's frequency from the Transport. + * See Tone.Oscillator.syncFrequency + * @returns {Tone.Oscillator} this + */ + Tone.Oscillator.prototype.unsyncFrequency = function () { + Tone.Transport.unsyncSignal(this.frequency); + return this; + }; + /** + * The type of the oscillator: either sine, square, triangle, or sawtooth. Also capable of + * setting the first x number of partials of the oscillator. For example: "sine4" would + * set be the first 4 partials of the sine wave and "triangle8" would set the first + * 8 partials of the triangle wave. + * <br><br> + * Uses PeriodicWave internally even for native types so that it can set the phase. + * PeriodicWave equations are from the + * [Webkit Web Audio implementation](https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp&sq=package:chromium). + * + * @memberOf Tone.Oscillator# + * @type {string} + * @name type + * @example + * //set it to a square wave + * osc.type = "square"; + * @example + * //set the first 6 partials of a sawtooth wave + * osc.type = "sawtooth6"; + */ + Object.defineProperty(Tone.Oscillator.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + var isBasicType = [ + Tone.Oscillator.Type.Sine, + Tone.Oscillator.Type.Square, + Tone.Oscillator.Type.Triangle, + Tone.Oscillator.Type.Sawtooth + ].includes(type); + if (this._phase === 0 && isBasicType) { + this._wave = null; + //just go with the basic approach + if (this._oscillator !== null) { + this._oscillator.type === type; + } + } else { + var coefs = this._getRealImaginary(type, this._phase); + var periodicWave = this.context.createPeriodicWave(coefs[0], coefs[1]); + this._wave = periodicWave; + if (this._oscillator !== null) { + this._oscillator.setPeriodicWave(this._wave); + } + } + this._type = type; + } + }); + /** + * Returns the real and imaginary components based + * on the oscillator type. + * @returns {Array} [real, imaginary] + * @private + */ + Tone.Oscillator.prototype._getRealImaginary = function (type, phase) { + var fftSize = 4096; + var periodicWaveSize = fftSize / 2; + var real = new Float32Array(periodicWaveSize); + var imag = new Float32Array(periodicWaveSize); + var partialCount = 1; + if (type === Tone.Oscillator.Type.Custom) { + partialCount = this._partials.length + 1; + periodicWaveSize = partialCount; + } else { + var partial = /^(sine|triangle|square|sawtooth)(\d+)$/.exec(type); + if (partial) { + partialCount = parseInt(partial[2]) + 1; + type = partial[1]; + partialCount = Math.max(partialCount, 2); + periodicWaveSize = partialCount; + } + } + for (var n = 1; n < periodicWaveSize; ++n) { + var piFactor = 2 / (n * Math.PI); + var b; + switch (type) { + case Tone.Oscillator.Type.Sine: + b = n <= partialCount ? 1 : 0; + break; + case Tone.Oscillator.Type.Square: + b = n & 1 ? 2 * piFactor : 0; + break; + case Tone.Oscillator.Type.Sawtooth: + b = piFactor * (n & 1 ? 1 : -1); + break; + case Tone.Oscillator.Type.Triangle: + if (n & 1) { + b = 2 * (piFactor * piFactor) * (n - 1 >> 1 & 1 ? -1 : 1); + } else { + b = 0; + } + break; + case Tone.Oscillator.Type.Custom: + b = this._partials[n - 1]; + break; + default: + throw new TypeError('Tone.Oscillator: invalid type: ' + type); + } + if (b !== 0) { + real[n] = -b * Math.sin(phase * n); + imag[n] = b * Math.cos(phase * n); + } else { + real[n] = 0; + imag[n] = 0; + } + } + return [ + real, + imag + ]; + }; + /** + * Compute the inverse FFT for a given phase. + * @param {Float32Array} real + * @param {Float32Array} imag + * @param {NormalRange} phase + * @return {AudioRange} + * @private + */ + Tone.Oscillator.prototype._inverseFFT = function (real, imag, phase) { + var sum = 0; + var len = real.length; + for (var i = 0; i < len; i++) { + sum += real[i] * Math.cos(i * phase) + imag[i] * Math.sin(i * phase); + } + return sum; + }; + /** + * Returns the initial value of the oscillator. + * @return {AudioRange} + * @private + */ + Tone.Oscillator.prototype._getInitialValue = function () { + var coefs = this._getRealImaginary(this._type, 0); + var real = coefs[0]; + var imag = coefs[1]; + var maxValue = 0; + var twoPi = Math.PI * 2; + //check for peaks in 8 places + for (var i = 0; i < 8; i++) { + maxValue = Math.max(this._inverseFFT(real, imag, i / 8 * twoPi), maxValue); + } + return -this._inverseFFT(real, imag, this._phase) / maxValue; + }; + /** + * The partials of the waveform. A partial represents + * the amplitude at a harmonic. The first harmonic is the + * fundamental frequency, the second is the octave and so on + * following the harmonic series. + * Setting this value will automatically set the type to "custom". + * The value is an empty array when the type is not "custom". + * @memberOf Tone.Oscillator# + * @type {Array} + * @name partials + * @example + * osc.partials = [1, 0.2, 0.01]; + */ + Object.defineProperty(Tone.Oscillator.prototype, 'partials', { + get: function () { + if (this._type !== Tone.Oscillator.Type.Custom) { + return []; + } else { + return this._partials; + } + }, + set: function (partials) { + this._partials = partials; + this.type = Tone.Oscillator.Type.Custom; + } + }); + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.Oscillator# + * @type {Degrees} + * @name phase + * @example + * osc.phase = 180; //flips the phase of the oscillator + */ + Object.defineProperty(Tone.Oscillator.prototype, 'phase', { + get: function () { + return this._phase * (180 / Math.PI); + }, + set: function (phase) { + this._phase = phase * Math.PI / 180; + //reset the type + this.type = this._type; + } + }); + /** + * Dispose and disconnect. + * @return {Tone.Oscillator} this + */ + Tone.Oscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + if (this._oscillator !== null) { + this._oscillator.dispose(); + this._oscillator = null; + } + this._wave = null; + this._writable([ + 'frequency', + 'detune' + ]); + this.frequency.dispose(); + this.frequency = null; + this.detune.dispose(); + this.detune = null; + this._partials = null; + return this; + }; + return Tone.Oscillator; + }); + Module(function (Tone) { + + /** + * @class AudioToGain converts an input in AudioRange [-1,1] to NormalRange [0,1]. + * See Tone.GainToAudio. + * + * @extends {Tone.SignalBase} + * @constructor + * @example + * var a2g = new Tone.AudioToGain(); + */ + Tone.AudioToGain = function () { + Tone.SignalBase.call(this); + /** + * @type {WaveShaperNode} + * @private + */ + this._norm = this.input = this.output = new Tone.WaveShaper(function (x) { + return (x + 1) / 2; + }); + }; + Tone.extend(Tone.AudioToGain, Tone.SignalBase); + /** + * clean up + * @returns {Tone.AudioToGain} this + */ + Tone.AudioToGain.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._norm.dispose(); + this._norm = null; + return this; + }; + return Tone.AudioToGain; + }); + Module(function (Tone) { + /** + * @class Tone.Zero outputs 0's at audio-rate. The reason this has to be + * it's own class is that many browsers optimize out Tone.Signal + * with a value of 0 and will not process nodes further down the graph. + * @extends {Tone.SignalBase} + */ + Tone.Zero = function () { + Tone.SignalBase.call(this); + /** + * The gain node + * @type {Tone.Gain} + * @private + */ + this._gain = this.input = this.output = new Tone.Gain(); + this.context.getConstant(0).connect(this._gain); + }; + Tone.extend(Tone.Zero, Tone.SignalBase); + /** + * clean up + * @return {Tone.Zero} this + */ + Tone.Zero.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._gain.dispose(); + this._gain = null; + return this; + }; + return Tone.Zero; + }); + Module(function (Tone) { + + /** + * @class LFO stands for low frequency oscillator. Tone.LFO produces an output signal + * which can be attached to an AudioParam or Tone.Signal + * in order to modulate that parameter with an oscillator. The LFO can + * also be synced to the transport to start/stop and change when the tempo changes. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Frequency|Object} [frequency] The frequency of the oscillation. Typically, LFOs will be + * in the frequency range of 0.1 to 10 hertz. + * @param {number=} min The minimum output value of the LFO. + * @param {number=} max The maximum value of the LFO. + * @example + * var lfo = new Tone.LFO("4n", 400, 4000); + * lfo.connect(filter.frequency); + */ + Tone.LFO = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'min', + 'max' + ], Tone.LFO); + Tone.AudioNode.call(this); + /** + * The oscillator. + * @type {Tone.Oscillator} + * @private + */ + this._oscillator = new Tone.Oscillator({ + 'frequency': options.frequency, + 'type': options.type + }); + /** + * the lfo's frequency + * @type {Frequency} + * @signal + */ + this.frequency = this._oscillator.frequency; + /** + * The amplitude of the LFO, which controls the output range between + * the min and max output. For example if the min is -10 and the max + * is 10, setting the amplitude to 0.5 would make the LFO modulate + * between -5 and 5. + * @type {Number} + * @signal + */ + this.amplitude = this._oscillator.volume; + this.amplitude.units = Tone.Type.NormalRange; + this.amplitude.value = options.amplitude; + /** + * The signal which is output when the LFO is stopped + * @type {Tone.Signal} + * @private + */ + this._stoppedSignal = new Tone.Signal(0, Tone.Type.AudioRange); + /** + * Just outputs zeros. + * @type {Tone.Zero} + * @private + */ + this._zeros = new Tone.Zero(); + /** + * The value that the LFO outputs when it's stopped + * @type {AudioRange} + * @private + */ + this._stoppedValue = 0; + /** + * @type {Tone.AudioToGain} + * @private + */ + this._a2g = new Tone.AudioToGain(); + /** + * @type {Tone.Scale} + * @private + */ + this._scaler = this.output = new Tone.Scale(options.min, options.max); + /** + * the units of the LFO (used for converting) + * @type {Tone.Type} + * @private + */ + this._units = Tone.Type.Default; + this.units = options.units; + //connect it up + this._oscillator.chain(this._a2g, this._scaler); + this._zeros.connect(this._a2g); + this._stoppedSignal.connect(this._a2g); + this._readOnly([ + 'amplitude', + 'frequency' + ]); + this.phase = options.phase; + }; + Tone.extend(Tone.LFO, Tone.AudioNode); + /** + * the default parameters + * + * @static + * @const + * @type {Object} + */ + Tone.LFO.defaults = { + 'type': 'sine', + 'min': 0, + 'max': 1, + 'phase': 0, + 'frequency': '4n', + 'amplitude': 1, + 'units': Tone.Type.Default + }; + /** + * Start the LFO. + * @param {Time} [time=now] the time the LFO will start + * @returns {Tone.LFO} this + */ + Tone.LFO.prototype.start = function (time) { + time = this.toSeconds(time); + this._stoppedSignal.setValueAtTime(0, time); + this._oscillator.start(time); + return this; + }; + /** + * Stop the LFO. + * @param {Time} [time=now] the time the LFO will stop + * @returns {Tone.LFO} this + */ + Tone.LFO.prototype.stop = function (time) { + time = this.toSeconds(time); + this._stoppedSignal.setValueAtTime(this._stoppedValue, time); + this._oscillator.stop(time); + return this; + }; + /** + * Sync the start/stop/pause to the transport + * and the frequency to the bpm of the transport + * @returns {Tone.LFO} this + * @example + * lfo.frequency.value = "8n"; + * lfo.sync().start(0) + * //the rate of the LFO will always be an eighth note, + * //even as the tempo changes + */ + Tone.LFO.prototype.sync = function () { + this._oscillator.sync(); + this._oscillator.syncFrequency(); + return this; + }; + /** + * unsync the LFO from transport control + * @returns {Tone.LFO} this + */ + Tone.LFO.prototype.unsync = function () { + this._oscillator.unsync(); + this._oscillator.unsyncFrequency(); + return this; + }; + /** + * The miniumum output of the LFO. + * @memberOf Tone.LFO# + * @type {number} + * @name min + */ + Object.defineProperty(Tone.LFO.prototype, 'min', { + get: function () { + return this._toUnits(this._scaler.min); + }, + set: function (min) { + min = this._fromUnits(min); + this._scaler.min = min; + } + }); + /** + * The maximum output of the LFO. + * @memberOf Tone.LFO# + * @type {number} + * @name max + */ + Object.defineProperty(Tone.LFO.prototype, 'max', { + get: function () { + return this._toUnits(this._scaler.max); + }, + set: function (max) { + max = this._fromUnits(max); + this._scaler.max = max; + } + }); + /** + * The type of the oscillator: sine, square, sawtooth, triangle. + * @memberOf Tone.LFO# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.LFO.prototype, 'type', { + get: function () { + return this._oscillator.type; + }, + set: function (type) { + this._oscillator.type = type; + this._stoppedValue = this._oscillator._getInitialValue(); + this._stoppedSignal.value = this._stoppedValue; + } + }); + /** + * The phase of the LFO. + * @memberOf Tone.LFO# + * @type {number} + * @name phase + */ + Object.defineProperty(Tone.LFO.prototype, 'phase', { + get: function () { + return this._oscillator.phase; + }, + set: function (phase) { + this._oscillator.phase = phase; + this._stoppedValue = this._oscillator._getInitialValue(); + this._stoppedSignal.value = this._stoppedValue; + } + }); + /** + * The output units of the LFO. + * @memberOf Tone.LFO# + * @type {Tone.Type} + * @name units + */ + Object.defineProperty(Tone.LFO.prototype, 'units', { + get: function () { + return this._units; + }, + set: function (val) { + var currentMin = this.min; + var currentMax = this.max; + //convert the min and the max + this._units = val; + this.min = currentMin; + this.max = currentMax; + } + }); + /** + * Mute the output. + * @memberOf Tone.LFO# + * @type {Boolean} + * @name mute + */ + Object.defineProperty(Tone.LFO.prototype, 'mute', { + get: function () { + return this._oscillator.mute; + }, + set: function (mute) { + this._oscillator.mute = mute; + } + }); + /** + * Returns the playback state of the source, either "started" or "stopped". + * @type {Tone.State} + * @readOnly + * @memberOf Tone.LFO# + * @name state + */ + Object.defineProperty(Tone.LFO.prototype, 'state', { + get: function () { + return this._oscillator.state; + } + }); + /** + * Connect the output of the LFO to an AudioParam, AudioNode, or Tone Node. + * Tone.LFO will automatically convert to the destination units of the + * will get the units from the connected node. + * @param {Tone | AudioParam | AudioNode} node + * @param {number} [outputNum=0] optionally which output to connect from + * @param {number} [inputNum=0] optionally which input to connect to + * @returns {Tone.LFO} this + * @private + */ + Tone.LFO.prototype.connect = function (node) { + if (node.constructor === Tone.Signal || node.constructor === Tone.Param) { + this.convert = node.convert; + this.units = node.units; + } + Tone.SignalBase.prototype.connect.apply(this, arguments); + return this; + }; + /** + * private method borrowed from Param converts + * units from their destination value + * @function + * @private + */ + Tone.LFO.prototype._fromUnits = Tone.Param.prototype._fromUnits; + /** + * private method borrowed from Param converts + * units to their destination value + * @function + * @private + */ + Tone.LFO.prototype._toUnits = Tone.Param.prototype._toUnits; + /** + * disconnect and dispose + * @returns {Tone.LFO} this + */ + Tone.LFO.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'amplitude', + 'frequency' + ]); + this._oscillator.dispose(); + this._oscillator = null; + this._stoppedSignal.dispose(); + this._stoppedSignal = null; + this._zeros.dispose(); + this._zeros = null; + this._scaler.dispose(); + this._scaler = null; + this._a2g.dispose(); + this._a2g = null; + this.frequency = null; + this.amplitude = null; + return this; + }; + return Tone.LFO; + }); + Module(function (Tone) { + + /** + * @class Tone.Limiter will limit the loudness of an incoming signal. + * It is composed of a Tone.Compressor with a fast attack + * and release. Limiters are commonly used to safeguard against + * signal clipping. Unlike a compressor, limiters do not provide + * smooth gain reduction and almost completely prevent + * additional gain above the threshold. + * + * @extends {Tone.AudioNode} + * @constructor + * @param {number} threshold The theshold above which the limiting is applied. + * @example + * var limiter = new Tone.Limiter(-6); + */ + Tone.Limiter = function () { + var options = Tone.defaults(arguments, ['threshold'], Tone.Limiter); + Tone.AudioNode.call(this); + /** + * the compressor + * @private + * @type {Tone.Compressor} + */ + this._compressor = this.input = this.output = new Tone.Compressor({ + 'attack': 0.001, + 'decay': 0.001, + 'threshold': options.threshold + }); + /** + * The threshold of of the limiter + * @type {Decibel} + * @signal + */ + this.threshold = this._compressor.threshold; + this._readOnly('threshold'); + }; + Tone.extend(Tone.Limiter, Tone.AudioNode); + /** + * The default value + * @type {Object} + * @const + * @static + */ + Tone.Limiter.defaults = { 'threshold': -12 }; + /** + * Clean up. + * @returns {Tone.Limiter} this + */ + Tone.Limiter.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._compressor.dispose(); + this._compressor = null; + this._writable('threshold'); + this.threshold = null; + return this; + }; + return Tone.Limiter; + }); + Module(function (Tone) { + + /** + * @class Tone.Lowpass is a lowpass feedback comb filter. It is similar to + * Tone.FeedbackCombFilter, but includes a lowpass filter. + * + * @extends {Tone.AudioNode} + * @constructor + * @param {Time|Object} [delayTime] The delay time of the comb filter + * @param {NormalRange=} resonance The resonance (feedback) of the comb filter + * @param {Frequency=} dampening The cutoff of the lowpass filter dampens the + * signal as it is fedback. + */ + Tone.LowpassCombFilter = function () { + var options = Tone.defaults(arguments, [ + 'delayTime', + 'resonance', + 'dampening' + ], Tone.LowpassCombFilter); + Tone.AudioNode.call(this); + this.createInsOuts(1, 1); + /** + * the delay node + * @type {DelayNode} + * @private + */ + this._delay = this.input = new Tone.Delay(options.delayTime); + /** + * The delayTime of the comb filter. + * @type {Time} + * @signal + */ + this.delayTime = this._delay.delayTime; + /** + * the lowpass filter + * @type {BiquadFilterNode} + * @private + */ + this._lowpass = this.output = this.context.createBiquadFilter(); + this._lowpass.Q.value = -3.0102999566398125; + this._lowpass.type = 'lowpass'; + /** + * The dampening control of the feedback + * @type {Frequency} + * @signal + */ + this.dampening = new Tone.Param({ + 'param': this._lowpass.frequency, + 'units': Tone.Type.Frequency, + 'value': options.dampening + }); + /** + * the feedback gain + * @type {Tone.Gain} + * @private + */ + this._feedback = new Tone.Gain(options.resonance, Tone.Type.NormalRange); + /** + * The amount of feedback of the delayed signal. + * @type {NormalRange} + * @signal + */ + this.resonance = this._feedback.gain; + //connections + this._delay.chain(this._lowpass, this._feedback, this._delay); + this._readOnly([ + 'dampening', + 'resonance', + 'delayTime' + ]); + }; + Tone.extend(Tone.LowpassCombFilter, Tone.AudioNode); + /** + * the default parameters + * @static + * @const + * @type {Object} + */ + Tone.LowpassCombFilter.defaults = { + 'delayTime': 0.1, + 'resonance': 0.5, + 'dampening': 3000 + }; + /** + * Clean up. + * @returns {Tone.LowpassCombFilter} this + */ + Tone.LowpassCombFilter.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'dampening', + 'resonance', + 'delayTime' + ]); + this.dampening.dispose(); + this.dampening = null; + this.resonance.dispose(); + this.resonance = null; + this._delay.dispose(); + this._delay = null; + this.delayTime = null; + this._lowpass.disconnect(); + this._lowpass = null; + this._feedback.disconnect(); + this._feedback = null; + return this; + }; + return Tone.LowpassCombFilter; + }); + Module(function (Tone) { + + /** + * @class Tone.Merge brings two signals into the left and right + * channels of a single stereo channel. + * + * @constructor + * @extends {Tone.AudioNode} + * @example + * var merge = new Tone.Merge().toMaster(); + * //routing a sine tone in the left channel + * //and noise in the right channel + * var osc = new Tone.Oscillator().connect(merge.left); + * var noise = new Tone.Noise().connect(merge.right); + * //starting our oscillators + * noise.start(); + * osc.start(); + */ + Tone.Merge = function () { + Tone.AudioNode.call(this); + this.createInsOuts(2, 0); + /** + * The left input channel. + * Alias for <code>input[0]</code> + * @type {GainNode} + */ + this.left = this.input[0] = new Tone.Gain(); + /** + * The right input channel. + * Alias for <code>input[1]</code>. + * @type {GainNode} + */ + this.right = this.input[1] = new Tone.Gain(); + /** + * the merger node for the two channels + * @type {ChannelMergerNode} + * @private + */ + this._merger = this.output = this.context.createChannelMerger(2); + //connections + this.left.connect(this._merger, 0, 0); + this.right.connect(this._merger, 0, 1); + this.left.channelCount = 1; + this.right.channelCount = 1; + this.left.channelCountMode = 'explicit'; + this.right.channelCountMode = 'explicit'; + }; + Tone.extend(Tone.Merge, Tone.AudioNode); + /** + * Clean up. + * @returns {Tone.Merge} this + */ + Tone.Merge.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this.left.dispose(); + this.left = null; + this.right.dispose(); + this.right = null; + this._merger.disconnect(); + this._merger = null; + return this; + }; + return Tone.Merge; + }); + Module(function (Tone) { + + /** + * @class Tone.Meter gets the [RMS](https://en.wikipedia.org/wiki/Root_mean_square) + * of an input signal with some averaging applied. It can also get the raw + * value of the input signal. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Number} smoothing The amount of smoothing applied between frames. + * @example + * var meter = new Tone.Meter(); + * var mic = new Tone.UserMedia().open(); + * //connect mic to the meter + * mic.connect(meter); + * //the current level of the mic input in decibels + * var level = meter.getValue(); + */ + Tone.Meter = function () { + var options = Tone.defaults(arguments, ['smoothing'], Tone.Meter); + Tone.AudioNode.call(this); + /** + * The analyser node which computes the levels. + * @private + * @type {Tone.Analyser} + */ + this.input = this.output = this._analyser = new Tone.Analyser('waveform', 1024); + /** + * The amount of carryover between the current and last frame. + * Only applied meter for "level" type. + * @type {Number} + */ + this.smoothing = options.smoothing; + }; + Tone.extend(Tone.Meter, Tone.AudioNode); + /** + * The defaults + * @type {Object} + * @static + * @const + */ + Tone.Meter.defaults = { 'smoothing': 0.8 }; + /** + * Get the current decibel value of the incoming signal + * @returns {Decibels} + */ + Tone.Meter.prototype.getLevel = function () { + this._analyser.type = 'fft'; + var values = this._analyser.getValue(); + var offset = 28; + // normalizes most signal levels + // TODO: compute loudness from FFT + return Math.max.apply(this, values) + offset; + }; + /** + * Get the signal value of the incoming signal + * @returns {Number} + */ + Tone.Meter.prototype.getValue = function () { + this._analyser.type = 'waveform'; + var value = this._analyser.getValue(); + return value[0]; + }; + /** + * A value from 0 -> 1 where 0 represents no time averaging with the last analysis frame. + * @memberOf Tone.Meter# + * @type {Number} + * @name smoothing + * @readOnly + */ + Object.defineProperty(Tone.Meter.prototype, 'smoothing', { + get: function () { + return this._analyser.smoothing; + }, + set: function (val) { + this._analyser.smoothing = val; + } + }); + /** + * Clean up. + * @returns {Tone.Meter} this + */ + Tone.Meter.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._analyser.dispose(); + this._analyser = null; + return this; + }; + return Tone.Meter; + }); + Module(function (Tone) { + + /** + * @class Tone.Split splits an incoming signal into left and right channels. + * + * @constructor + * @extends {Tone.AudioNode} + * @example + * var split = new Tone.Split(); + * stereoSignal.connect(split); + */ + Tone.Split = function () { + Tone.AudioNode.call(this); + this.createInsOuts(0, 2); + /** + * @type {ChannelSplitterNode} + * @private + */ + this._splitter = this.input = this.context.createChannelSplitter(2); + this._splitter.channelCount = 2; + this._splitter.channelCountMode = 'explicit'; + /** + * Left channel output. + * Alias for <code>output[0]</code> + * @type {Tone.Gain} + */ + this.left = this.output[0] = new Tone.Gain(); + /** + * Right channel output. + * Alias for <code>output[1]</code> + * @type {Tone.Gain} + */ + this.right = this.output[1] = new Tone.Gain(); + //connections + this._splitter.connect(this.left, 0, 0); + this._splitter.connect(this.right, 1, 0); + }; + Tone.extend(Tone.Split, Tone.AudioNode); + /** + * Clean up. + * @returns {Tone.Split} this + */ + Tone.Split.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._splitter.disconnect(); + this.left.dispose(); + this.left = null; + this.right.dispose(); + this.right = null; + this._splitter = null; + return this; + }; + return Tone.Split; + }); + Module(function (Tone) { + + /** + * @class Mid/Side processing separates the the 'mid' signal + * (which comes out of both the left and the right channel) + * and the 'side' (which only comes out of the the side channels). <br><br> + * <code> + * Mid = (Left+Right)/sqrt(2); // obtain mid-signal from left and right<br> + * Side = (Left-Right)/sqrt(2); // obtain side-signal from left and righ<br> + * </code> + * + * @extends {Tone.AudioNode} + * @constructor + */ + Tone.MidSideSplit = function () { + Tone.AudioNode.call(this); + this.createInsOuts(0, 2); + /** + * split the incoming signal into left and right channels + * @type {Tone.Split} + * @private + */ + this._split = this.input = new Tone.Split(); + /** + * The mid send. Connect to mid processing. Alias for + * <code>output[0]</code> + * @type {Tone.Add} + */ + this._midAdd = new Tone.Add(); + /** + * Multiply the _midAdd by sqrt(1/2) + * @type {Tone.Multiply} + */ + this.mid = this.output[0] = new Tone.Multiply(Math.SQRT1_2); + /** + * The side output. Connect to side processing. Also Output 1 + * @type {Tone.Subtract} + */ + this._sideSubtract = new Tone.Subtract(); + /** + * Multiply the _midAdd by sqrt(1/2) + * @type {Tone.Multiply} + */ + this.side = this.output[1] = new Tone.Multiply(Math.SQRT1_2); + this._split.connect(this._midAdd, 0, 0); + this._split.connect(this._midAdd, 1, 1); + this._split.connect(this._sideSubtract, 0, 0); + this._split.connect(this._sideSubtract, 1, 1); + this._midAdd.connect(this.mid); + this._sideSubtract.connect(this.side); + }; + Tone.extend(Tone.MidSideSplit, Tone.AudioNode); + /** + * clean up + * @returns {Tone.MidSideSplit} this + */ + Tone.MidSideSplit.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this.mid.dispose(); + this.mid = null; + this.side.dispose(); + this.side = null; + this._midAdd.dispose(); + this._midAdd = null; + this._sideSubtract.dispose(); + this._sideSubtract = null; + this._split.dispose(); + this._split = null; + return this; + }; + return Tone.MidSideSplit; + }); + Module(function (Tone) { + + /** + * @class Mid/Side processing separates the the 'mid' signal + * (which comes out of both the left and the right channel) + * and the 'side' (which only comes out of the the side channels). + * MidSideMerge merges the mid and side signal after they've been seperated + * by Tone.MidSideSplit.<br><br> + * <code> + * Left = (Mid+Side)/sqrt(2); // obtain left signal from mid and side<br> + * Right = (Mid-Side)/sqrt(2); // obtain right signal from mid and side<br> + * </code> + * + * @extends {Tone.AudioNode} + * @constructor + */ + Tone.MidSideMerge = function () { + Tone.AudioNode.call(this); + this.createInsOuts(2, 0); + /** + * The mid signal input. Alias for + * <code>input[0]</code> + * @type {Tone.Gain} + */ + this.mid = this.input[0] = new Tone.Gain(); + /** + * recombine the mid/side into Left + * @type {Tone.Add} + * @private + */ + this._left = new Tone.Add(); + /** + * Multiply the left by sqrt(1/2) + * @type {Tone.Multiply} + */ + this._timesTwoLeft = new Tone.Multiply(Math.SQRT1_2); + /** + * The side signal input. Alias for + * <code>input[1]</code> + * @type {Tone.Gain} + */ + this.side = this.input[1] = new Tone.Gain(); + /** + * recombine the mid/side into Right + * @type {Tone.Subtract} + * @private + */ + this._right = new Tone.Subtract(); + /** + * Multiply the right by sqrt(1/2) + * @type {Tone.Multiply} + */ + this._timesTwoRight = new Tone.Multiply(Math.SQRT1_2); + /** + * Merge the left/right signal back into a stereo signal. + * @type {Tone.Merge} + * @private + */ + this._merge = this.output = new Tone.Merge(); + this.mid.connect(this._left, 0, 0); + this.side.connect(this._left, 0, 1); + this.mid.connect(this._right, 0, 0); + this.side.connect(this._right, 0, 1); + this._left.connect(this._timesTwoLeft); + this._right.connect(this._timesTwoRight); + this._timesTwoLeft.connect(this._merge, 0, 0); + this._timesTwoRight.connect(this._merge, 0, 1); + }; + Tone.extend(Tone.MidSideMerge, Tone.AudioNode); + /** + * clean up + * @returns {Tone.MidSideMerge} this + */ + Tone.MidSideMerge.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this.mid.dispose(); + this.mid = null; + this.side.dispose(); + this.side = null; + this._left.dispose(); + this._left = null; + this._timesTwoLeft.dispose(); + this._timesTwoLeft = null; + this._right.dispose(); + this._right = null; + this._timesTwoRight.dispose(); + this._timesTwoRight = null; + this._merge.dispose(); + this._merge = null; + return this; + }; + return Tone.MidSideMerge; + }); + Module(function (Tone) { + + /** + * @class Tone.MidSideCompressor applies two different compressors to the mid + * and side signal components. See Tone.MidSideSplit. + * + * @extends {Tone.AudioNode} + * @param {Object} options The options that are passed to the mid and side + * compressors. + * @constructor + */ + Tone.MidSideCompressor = function (options) { + Tone.AudioNode.call(this); + options = Tone.defaultArg(options, Tone.MidSideCompressor.defaults); + /** + * the mid/side split + * @type {Tone.MidSideSplit} + * @private + */ + this._midSideSplit = this.input = new Tone.MidSideSplit(); + /** + * the mid/side recombination + * @type {Tone.MidSideMerge} + * @private + */ + this._midSideMerge = this.output = new Tone.MidSideMerge(); + /** + * The compressor applied to the mid signal + * @type {Tone.Compressor} + */ + this.mid = new Tone.Compressor(options.mid); + /** + * The compressor applied to the side signal + * @type {Tone.Compressor} + */ + this.side = new Tone.Compressor(options.side); + this._midSideSplit.mid.chain(this.mid, this._midSideMerge.mid); + this._midSideSplit.side.chain(this.side, this._midSideMerge.side); + this._readOnly([ + 'mid', + 'side' + ]); + }; + Tone.extend(Tone.MidSideCompressor, Tone.AudioNode); + /** + * @const + * @static + * @type {Object} + */ + Tone.MidSideCompressor.defaults = { + 'mid': { + 'ratio': 3, + 'threshold': -24, + 'release': 0.03, + 'attack': 0.02, + 'knee': 16 + }, + 'side': { + 'ratio': 6, + 'threshold': -30, + 'release': 0.25, + 'attack': 0.03, + 'knee': 10 + } + }; + /** + * Clean up. + * @returns {Tone.MidSideCompressor} this + */ + Tone.MidSideCompressor.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'mid', + 'side' + ]); + this.mid.dispose(); + this.mid = null; + this.side.dispose(); + this.side = null; + this._midSideSplit.dispose(); + this._midSideSplit = null; + this._midSideMerge.dispose(); + this._midSideMerge = null; + return this; + }; + return Tone.MidSideCompressor; + }); + Module(function (Tone) { + + /** + * @class Tone.Mono coerces the incoming mono or stereo signal into a mono signal + * where both left and right channels have the same value. This can be useful + * for [stereo imaging](https://en.wikipedia.org/wiki/Stereo_imaging). + * + * @extends {Tone.AudioNode} + * @constructor + */ + Tone.Mono = function () { + Tone.AudioNode.call(this); + this.createInsOuts(1, 0); + /** + * merge the signal + * @type {Tone.Merge} + * @private + */ + this._merge = this.output = new Tone.Merge(); + this.input.connect(this._merge, 0, 0); + this.input.connect(this._merge, 0, 1); + }; + Tone.extend(Tone.Mono, Tone.AudioNode); + /** + * clean up + * @returns {Tone.Mono} this + */ + Tone.Mono.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._merge.dispose(); + this._merge = null; + return this; + }; + return Tone.Mono; + }); + Module(function (Tone) { + + /** + * @class A compressor with seperate controls over low/mid/high dynamics + * + * @extends {Tone.AudioNode} + * @constructor + * @param {Object} options The low/mid/high compressor settings. + * @example + * var multiband = new Tone.MultibandCompressor({ + * "lowFrequency" : 200, + * "highFrequency" : 1300 + * "low" : { + * "threshold" : -12 + * } + * }) + */ + Tone.MultibandCompressor = function (options) { + Tone.AudioNode.call(this); + options = Tone.defaultArg(arguments, Tone.MultibandCompressor.defaults); + /** + * split the incoming signal into high/mid/low + * @type {Tone.MultibandSplit} + * @private + */ + this._splitter = this.input = new Tone.MultibandSplit({ + 'lowFrequency': options.lowFrequency, + 'highFrequency': options.highFrequency + }); + /** + * low/mid crossover frequency. + * @type {Frequency} + * @signal + */ + this.lowFrequency = this._splitter.lowFrequency; + /** + * mid/high crossover frequency. + * @type {Frequency} + * @signal + */ + this.highFrequency = this._splitter.highFrequency; + /** + * the output + * @type {Tone.Gain} + * @private + */ + this.output = new Tone.Gain(); + /** + * The compressor applied to the low frequencies. + * @type {Tone.Compressor} + */ + this.low = new Tone.Compressor(options.low); + /** + * The compressor applied to the mid frequencies. + * @type {Tone.Compressor} + */ + this.mid = new Tone.Compressor(options.mid); + /** + * The compressor applied to the high frequencies. + * @type {Tone.Compressor} + */ + this.high = new Tone.Compressor(options.high); + //connect the compressor + this._splitter.low.chain(this.low, this.output); + this._splitter.mid.chain(this.mid, this.output); + this._splitter.high.chain(this.high, this.output); + this._readOnly([ + 'high', + 'mid', + 'low', + 'highFrequency', + 'lowFrequency' + ]); + }; + Tone.extend(Tone.MultibandCompressor, Tone.AudioNode); + /** + * @const + * @static + * @type {Object} + */ + Tone.MultibandCompressor.defaults = { + 'low': Tone.Compressor.defaults, + 'mid': Tone.Compressor.defaults, + 'high': Tone.Compressor.defaults, + 'lowFrequency': 250, + 'highFrequency': 2000 + }; + /** + * clean up + * @returns {Tone.MultibandCompressor} this + */ + Tone.MultibandCompressor.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._splitter.dispose(); + this._writable([ + 'high', + 'mid', + 'low', + 'highFrequency', + 'lowFrequency' + ]); + this.low.dispose(); + this.mid.dispose(); + this.high.dispose(); + this._splitter = null; + this.low = null; + this.mid = null; + this.high = null; + this.lowFrequency = null; + this.highFrequency = null; + return this; + }; + return Tone.MultibandCompressor; + }); + Module(function (Tone) { + if (Tone.supported && !window.StereoPannerNode) { + /** + * @class Shimmed StereoPannerNode + * @param {AudioContext} context + * @private + */ + var StereoPannerNode = function (context) { + /** + * The audio context + * @type {AudioContext} + */ + this.context = context; + /** + * The left/right panning. [-1, 1] + * @type {AudioRange} + * @signal + */ + this.pan = new Tone.Signal(0, Tone.Type.AudioRange); + /** + * Equal power scaling of the right gain + * @type {Tone.WaveShaper} + */ + var rightWaveShaper = new Tone.WaveShaper(function (val) { + return Tone.equalPowerScale((val + 1) / 2); + }, 4096); + /** + * Equal power scaling of the left gain + * @type {Tone.WaveShaper} + * @private + */ + var leftWaveShaper = new Tone.WaveShaper(function (val) { + return Tone.equalPowerScale(1 - (val + 1) / 2); + }, 4096); + /** + * The left gain value + * @type {Tone.Gain} + * @private + */ + var leftGain = new Tone.Gain(); + /** + * The right gain value + * @type {Tone.Gain} + * @private + */ + var rightGain = new Tone.Gain(); + /** + * Split the incoming signal + * @type {Tone.Split} + * @private + */ + var split = this.input = new Tone.Split(); + /** + * Keeps the waveshapers from optimizing 0s + * @type {Tone.Zero} + * @private + */ + var zero = new Tone.Zero(); + zero.fan(rightWaveShaper, leftWaveShaper); + /** + * Merge the outgoing signal + * @type {Tone.Merge} + * @private + */ + var merge = this.output = new Tone.Merge(); + //connections + split.left.chain(leftGain, merge.left); + split.right.chain(rightGain, merge.right); + this.pan.chain(leftWaveShaper, leftGain.gain); + this.pan.chain(rightWaveShaper, rightGain.gain); + }; + StereoPannerNode.prototype.disconnect = function () { + this.output.disconnect.apply(this.output, arguments); + }; + StereoPannerNode.prototype.connect = function () { + this.output.connect.apply(this.output, arguments); + }; + //add it to the AudioContext + AudioContext.prototype.createStereoPanner = function () { + return new StereoPannerNode(this); + }; + Tone.Context.prototype.createStereoPanner = function () { + return new StereoPannerNode(this); + }; + } + }); + Module(function (Tone) { + + /** + * @class Tone.Panner is an equal power Left/Right Panner and does not + * support 3D. Panner uses the StereoPannerNode when available. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {NormalRange} [initialPan=0] The initail panner value (center). + * @example + * //pan the input signal hard right. + * var panner = new Tone.Panner(1); + */ + Tone.Panner = function (initialPan) { + Tone.AudioNode.call(this); + /** + * the panner node + * @type {StereoPannerNode} + * @private + */ + this._panner = this.input = this.output = this.context.createStereoPanner(); + /** + * The pan control. -1 = hard left, 1 = hard right. + * @type {AudioRange} + * @signal + */ + this.pan = this._panner.pan; + //initial value + this.pan.value = Tone.defaultArg(initialPan, 0); + this._readOnly('pan'); + }; + Tone.extend(Tone.Panner, Tone.AudioNode); + /** + * Clean up. + * @returns {Tone.Panner} this + */ + Tone.Panner.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable('pan'); + this._panner.disconnect(); + this._panner = null; + this.pan = null; + return this; + }; + return Tone.Panner; + }); + Module(function (Tone) { + + /** + * @class A spatialized panner node which supports equalpower or HRTF panning. + * Tries to normalize the API across various browsers. See Tone.Listener + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Number} positionX The initial x position. + * @param {Number} positionY The initial y position. + * @param {Number} positionZ The initial z position. + */ + Tone.Panner3D = function () { + var options = Tone.defaults(arguments, [ + 'positionX', + 'positionY', + 'positionZ' + ], Tone.Panner3D); + Tone.AudioNode.call(this); + /** + * The panner node + * @type {PannerNode} + * @private + */ + this._panner = this.input = this.output = this.context.createPanner(); + //set some values + this._panner.panningModel = options.panningModel; + this._panner.maxDistance = options.maxDistance; + this._panner.distanceModel = options.distanceModel; + this._panner.coneOuterGain = options.coneOuterGain; + this._panner.coneOuterAngle = options.coneOuterAngle; + this._panner.coneInnerAngle = options.coneInnerAngle; + this._panner.refDistance = options.refDistance; + this._panner.rolloffFactor = options.rolloffFactor; + /** + * Holds the current orientation + * @type {Array} + * @private + */ + this._orientation = [ + options.orientationX, + options.orientationY, + options.orientationZ + ]; + /** + * Holds the current position + * @type {Array} + * @private + */ + this._position = [ + options.positionX, + options.positionY, + options.positionZ + ]; + // set the default position/orientation + this.orientationX = options.orientationX; + this.orientationY = options.orientationY; + this.orientationZ = options.orientationZ; + this.positionX = options.positionX; + this.positionY = options.positionY; + this.positionZ = options.positionZ; + }; + Tone.extend(Tone.Panner3D, Tone.AudioNode); + /** + * Defaults according to the specification + * @static + * @const + * @type {Object} + */ + Tone.Panner3D.defaults = { + 'positionX': 0, + 'positionY': 0, + 'positionZ': 0, + 'orientationX': 0, + 'orientationY': 0, + 'orientationZ': 0, + 'panningModel': 'equalpower', + 'maxDistance': 10000, + 'distanceModel': 'inverse', + 'coneOuterGain': 0, + 'coneOuterAngle': 360, + 'coneInnerAngle': 360, + 'refDistance': 1, + 'rolloffFactor': 1 + }; + /** + * The ramp time which is applied to the setTargetAtTime + * @type {Number} + * @private + */ + Tone.Panner3D.prototype._rampTimeConstant = 0.01; + /** + * Sets the position of the source in 3d space. + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @return {Tone.Panner3D} this + */ + Tone.Panner3D.prototype.setPosition = function (x, y, z) { + if (this._panner.positionX) { + var now = this.now(); + this._panner.positionX.setTargetAtTime(x, now, this._rampTimeConstant); + this._panner.positionY.setTargetAtTime(y, now, this._rampTimeConstant); + this._panner.positionZ.setTargetAtTime(z, now, this._rampTimeConstant); + } else { + this._panner.setPosition(x, y, z); + } + this._position = Array.prototype.slice.call(arguments); + return this; + }; + /** + * Sets the orientation of the source in 3d space. + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @return {Tone.Panner3D} this + */ + Tone.Panner3D.prototype.setOrientation = function (x, y, z) { + if (this._panner.orientationX) { + var now = this.now(); + this._panner.orientationX.setTargetAtTime(x, now, this._rampTimeConstant); + this._panner.orientationY.setTargetAtTime(y, now, this._rampTimeConstant); + this._panner.orientationZ.setTargetAtTime(z, now, this._rampTimeConstant); + } else { + this._panner.setOrientation(x, y, z); + } + this._orientation = Array.prototype.slice.call(arguments); + return this; + }; + /** + * The x position of the panner object. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name positionX + */ + Object.defineProperty(Tone.Panner3D.prototype, 'positionX', { + set: function (pos) { + this._position[0] = pos; + this.setPosition.apply(this, this._position); + }, + get: function () { + return this._position[0]; + } + }); + /** + * The y position of the panner object. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name positionY + */ + Object.defineProperty(Tone.Panner3D.prototype, 'positionY', { + set: function (pos) { + this._position[1] = pos; + this.setPosition.apply(this, this._position); + }, + get: function () { + return this._position[1]; + } + }); + /** + * The z position of the panner object. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name positionZ + */ + Object.defineProperty(Tone.Panner3D.prototype, 'positionZ', { + set: function (pos) { + this._position[2] = pos; + this.setPosition.apply(this, this._position); + }, + get: function () { + return this._position[2]; + } + }); + /** + * The x orientation of the panner object. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name orientationX + */ + Object.defineProperty(Tone.Panner3D.prototype, 'orientationX', { + set: function (pos) { + this._orientation[0] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[0]; + } + }); + /** + * The y orientation of the panner object. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name orientationY + */ + Object.defineProperty(Tone.Panner3D.prototype, 'orientationY', { + set: function (pos) { + this._orientation[1] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[1]; + } + }); + /** + * The z orientation of the panner object. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name orientationZ + */ + Object.defineProperty(Tone.Panner3D.prototype, 'orientationZ', { + set: function (pos) { + this._orientation[2] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[2]; + } + }); + /** + * Proxy a property on the panner to an exposed public propery + * @param {String} prop + * @private + */ + Tone.Panner3D._aliasProperty = function (prop) { + Object.defineProperty(Tone.Panner3D.prototype, prop, { + set: function (val) { + this._panner[prop] = val; + }, + get: function () { + return this._panner[prop]; + } + }); + }; + /** + * The panning model. Either "equalpower" or "HRTF". + * @type {String} + * @memberOf Tone.Panner3D# + * @name panningModel + */ + Tone.Panner3D._aliasProperty('panningModel'); + /** + * A reference distance for reducing volume as source move further from the listener + * @type {Number} + * @memberOf Tone.Panner3D# + * @name refDistance + */ + Tone.Panner3D._aliasProperty('refDistance'); + /** + * Describes how quickly the volume is reduced as source moves away from listener. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name rolloffFactor + */ + Tone.Panner3D._aliasProperty('rolloffFactor'); + /** + * The distance model used by, "linear", "inverse", or "exponential". + * @type {String} + * @memberOf Tone.Panner3D# + * @name distanceModel + */ + Tone.Panner3D._aliasProperty('distanceModel'); + /** + * The angle, in degrees, inside of which there will be no volume reduction + * @type {Degrees} + * @memberOf Tone.Panner3D# + * @name coneInnerAngle + */ + Tone.Panner3D._aliasProperty('coneInnerAngle'); + /** + * The angle, in degrees, outside of which the volume will be reduced + * to a constant value of coneOuterGain + * @type {Degrees} + * @memberOf Tone.Panner3D# + * @name coneOuterAngle + */ + Tone.Panner3D._aliasProperty('coneOuterAngle'); + /** + * The gain outside of the coneOuterAngle + * @type {Gain} + * @memberOf Tone.Panner3D# + * @name coneOuterGain + */ + Tone.Panner3D._aliasProperty('coneOuterGain'); + /** + * The maximum distance between source and listener, + * after which the volume will not be reduced any further. + * @type {Positive} + * @memberOf Tone.Panner3D# + * @name maxDistance + */ + Tone.Panner3D._aliasProperty('maxDistance'); + /** + * Clean up. + * @returns {Tone.Panner3D} this + */ + Tone.Panner3D.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._panner.disconnect(); + this._panner = null; + this._orientation = null; + this._position = null; + return this; + }; + return Tone.Panner3D; + }); + Module(function (Tone) { + + /** + * @class Tone.PanVol is a Tone.Panner and Tone.Volume in one. + * + * @extends {Tone.AudioNode} + * @constructor + * @param {AudioRange} pan the initial pan + * @param {number} volume The output volume. + * @example + * //pan the incoming signal left and drop the volume + * var panVol = new Tone.PanVol(-0.25, -12); + */ + Tone.PanVol = function () { + var options = Tone.defaults(arguments, [ + 'pan', + 'volume' + ], Tone.PanVol); + Tone.AudioNode.call(this); + /** + * The panning node + * @type {Tone.Panner} + * @private + */ + this._panner = this.input = new Tone.Panner(options.pan); + /** + * The L/R panning control. + * @type {AudioRange} + * @signal + */ + this.pan = this._panner.pan; + /** + * The volume node + * @type {Tone.Volume} + * @private + */ + this._volume = this.output = new Tone.Volume(options.volume); + /** + * The volume control in decibels. + * @type {Decibels} + * @signal + */ + this.volume = this._volume.volume; + //connections + this._panner.connect(this._volume); + this.mute = options.mute; + this._readOnly([ + 'pan', + 'volume' + ]); + }; + Tone.extend(Tone.PanVol, Tone.AudioNode); + /** + * The defaults + * @type {Object} + * @const + * @static + */ + Tone.PanVol.defaults = { + 'pan': 0, + 'volume': 0, + 'mute': false + }; + /** + * Mute/unmute the volume + * @memberOf Tone.PanVol# + * @name mute + * @type {Boolean} + */ + Object.defineProperty(Tone.PanVol.prototype, 'mute', { + get: function () { + return this._volume.mute; + }, + set: function (mute) { + this._volume.mute = mute; + } + }); + /** + * clean up + * @returns {Tone.PanVol} this + */ + Tone.PanVol.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'pan', + 'volume' + ]); + this._panner.dispose(); + this._panner = null; + this.pan = null; + this._volume.dispose(); + this._volume = null; + this.volume = null; + return this; + }; + return Tone.PanVol; + }); + Module(function (Tone) { + /** + * @class Tone.Solo lets you isolate a specific audio stream. When + * an instance is set to `solo=true`, it will mute all other instances. + * @extends {Tone.AudioNode} + * @example + * var soloA = new Tone.Solo() + * var soloB = new Tone.Solo() + * soloA.solo = true + * //no audio will pass through soloB + */ + Tone.Solo = function () { + var options = Tone.defaults(arguments, ['solo'], Tone.Solo); + Tone.AudioNode.call(this); + /** + * The input and output node + * @type {Tone.Gain} + */ + this.input = this.output = new Tone.Gain(); + /** + * A bound _soloed method + * @type {Function} + * @private + */ + this._soloBind = this._soloed.bind(this); + //listen for solo events class-wide. + this.context.on('solo', this._soloBind); + //set initially + this.solo = options.solo; + }; + Tone.extend(Tone.Solo, Tone.AudioNode); + /** + * The defaults + * @type {Object} + * @static + */ + Tone.Solo.defaults = { solo: false }; + /** + * Isolates this instance and mutes all other instances of Tone.Solo. + * Only one instance can be soloed at a time. A soloed + * instance will report `solo=false` when another instance is soloed. + * @memberOf Tone.Solo# + * @type {Boolean} + * @name solo + */ + Object.defineProperty(Tone.Solo.prototype, 'solo', { + get: function () { + return this._isSoloed(); + }, + set: function (solo) { + if (solo) { + this._addSolo(); + } else { + this._removeSolo(); + } + this.context.emit('solo', this); + } + }); + /** + * If the current instance is muted, i.e. another instance is soloed + * @memberOf Tone.Solo# + * @type {Boolean} + * @name muted + * @readOnly + */ + Object.defineProperty(Tone.Solo.prototype, 'muted', { + get: function () { + return this.input.gain.value === 0; + } + }); + /** + * Add this to the soloed array + * @private + */ + Tone.Solo.prototype._addSolo = function () { + if (!Tone.isArray(this.context._currentSolo)) { + this.context._currentSolo = []; + } + if (!this._isSoloed()) { + this.context._currentSolo.push(this); + } + }; + /** + * Remove this from the soloed array + * @private + */ + Tone.Solo.prototype._removeSolo = function () { + if (this._isSoloed()) { + var index = this.context._currentSolo.indexOf(this); + this.context._currentSolo.splice(index, 1); + } + }; + /** + * @return {Boolean} Is this on the soloed array + * @private + */ + Tone.Solo.prototype._isSoloed = function () { + if (Tone.isArray(this.context._currentSolo)) { + return this.context._currentSolo.length !== 0 && this.context._currentSolo.indexOf(this) !== -1; + } else { + return false; + } + }; + /** + * @return {Boolean} Returns true if no one is soloed + * @private + */ + Tone.Solo.prototype._noSolos = function () { + return !Tone.isArray(this.context._currentSolo) || this.context._currentSolo.length === 0; + }; + /** + * Solo the current instance and unsolo all other instances. + * @param {Tone.Solo} instance The instance which is being soloed/unsoloed. + * @private + */ + Tone.Solo.prototype._soloed = function () { + if (this._isSoloed()) { + this.input.gain.value = 1; + } else if (this._noSolos()) { + //no one is soloed + this.input.gain.value = 1; + } else { + this.input.gain.value = 0; + } + }; + /** + * Clean up + * @return {Tone.Solo} this + */ + Tone.Solo.prototype.dispose = function () { + this.context.off('solo', this._soloBind); + this._removeSolo(); + this._soloBind = null; + Tone.AudioNode.prototype.dispose.call(this); + return this; + }; + return Tone.Solo; + }); + Module(function (Tone) { + /** + * @class Get the current waveform data of the connected audio source. + * @extends {Tone.AudioNode} + * @param {Number=} size The size of the FFT. Value must be a power of + * two in the range 32 to 32768. + */ + Tone.Waveform = function () { + var options = Tone.defaults(arguments, ['size'], Tone.Waveform); + options.type = Tone.Analyser.Type.Waveform; + Tone.AudioNode.call(this); + /** + * The analyser node. + * @private + * @type {Tone.Analyser} + */ + this._analyser = this.input = this.output = new Tone.Analyser(options); + }; + Tone.extend(Tone.Waveform, Tone.AudioNode); + /** + * The default values. + * @type {Object} + * @const + */ + Tone.Waveform.defaults = { 'size': 1024 }; + /** + * Gets the waveform of the audio source. Returns the waveform data + * of length [size](#size) as a Float32Array with values between -1 and 1. + * @returns {TypedArray} + */ + Tone.Waveform.prototype.getValue = function () { + return this._analyser.getValue(); + }; + /** + * The size of analysis. This must be a power of two in the range 32 to 32768. + * @memberOf Tone.Waveform# + * @type {Number} + * @name size + */ + Object.defineProperty(Tone.Waveform.prototype, 'size', { + get: function () { + return this._analyser.size; + }, + set: function (size) { + this._analyser.size = size; + } + }); + /** + * Clean up. + * @return {Tone.Waveform} this + */ + Tone.Waveform.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._analyser.dispose(); + this._analyser = null; + }; + return Tone.Waveform; + }); + Module(function (Tone) { + + /** + * @class Tone.CtrlInterpolate will interpolate between given values based + * on the "index" property. Passing in an array or object literal + * will interpolate each of the parameters. Note (i.e. "C3") + * and Time (i.e. "4n + 2") can be interpolated. All other values are + * assumed to be numbers. + * @example + * var interp = new Tone.CtrlInterpolate([0, 2, 9, 4]); + * interp.index = 0.75; + * interp.value; //returns 1.5 + * + * @example + * var interp = new Tone.CtrlInterpolate([ + * [2, 4, 5], + * [9, 3, 2], + * ]); + * @param {Array} values The array of values to interpolate over + * @param {Positive} index The initial interpolation index. + * @extends {Tone} + */ + Tone.CtrlInterpolate = function () { + var options = Tone.defaults(arguments, [ + 'values', + 'index' + ], Tone.CtrlInterpolate); + Tone.call(this); + /** + * The values to interpolate between + * @type {Array} + */ + this.values = options.values; + /** + * The interpolated index between values. For example: a value of 1.5 + * would interpolate equally between the value at index 1 + * and the value at index 2. + * @example + * interp.index = 0; + * interp.value; //returns the value at 0 + * interp.index = 0.5; + * interp.value; //returns the value between indices 0 and 1. + * @type {Positive} + */ + this.index = options.index; + }; + Tone.extend(Tone.CtrlInterpolate); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.CtrlInterpolate.defaults = { + 'index': 0, + 'values': [] + }; + /** + * The current interpolated value based on the index + * @readOnly + * @memberOf Tone.CtrlInterpolate# + * @type {*} + * @name value + */ + Object.defineProperty(Tone.CtrlInterpolate.prototype, 'value', { + get: function () { + var index = this.index; + index = Math.min(index, this.values.length - 1); + var lowerPosition = Math.floor(index); + var lower = this.values[lowerPosition]; + var upper = this.values[Math.ceil(index)]; + return this._interpolate(index - lowerPosition, lower, upper); + } + }); + /** + * Internal interpolation routine + * @param {NormalRange} index The index between the lower and upper + * @param {*} lower + * @param {*} upper + * @return {*} The interpolated value + * @private + */ + Tone.CtrlInterpolate.prototype._interpolate = function (index, lower, upper) { + if (Tone.isArray(lower)) { + var retArray = []; + for (var i = 0; i < lower.length; i++) { + retArray[i] = this._interpolate(index, lower[i], upper[i]); + } + return retArray; + } else if (Tone.isObject(lower)) { + var retObj = {}; + for (var attr in lower) { + retObj[attr] = this._interpolate(index, lower[attr], upper[attr]); + } + return retObj; + } else { + lower = this._toNumber(lower); + upper = this._toNumber(upper); + return (1 - index) * lower + index * upper; + } + }; + /** + * Convert from the given type into a number + * @param {Number|String} value + * @return {Number} + * @private + */ + Tone.CtrlInterpolate.prototype._toNumber = function (val) { + if (Tone.isNumber(val)) { + return val; + } else { + //otherwise assume that it's Time... + return this.toSeconds(val); + } + }; + /** + * Clean up + * @return {Tone.CtrlInterpolate} this + */ + Tone.CtrlInterpolate.prototype.dispose = function () { + this.values = null; + }; + return Tone.CtrlInterpolate; + }); + Module(function (Tone) { + + /** + * @class Tone.CtrlMarkov represents a Markov Chain where each call + * to Tone.CtrlMarkov.next will move to the next state. If the next + * state choice is an array, the next state is chosen randomly with + * even probability for all of the choices. For a weighted probability + * of the next choices, pass in an object with "state" and "probability" attributes. + * The probabilities will be normalized and then chosen. If no next options + * are given for the current state, the state will stay there. + * @extends {Tone} + * @example + * var chain = new Tone.CtrlMarkov({ + * "beginning" : ["end", "middle"], + * "middle" : "end" + * }); + * chain.value = "beginning"; + * chain.next(); //returns "end" or "middle" with 50% probability + * + * @example + * var chain = new Tone.CtrlMarkov({ + * "beginning" : [{"value" : "end", "probability" : 0.8}, + * {"value" : "middle", "probability" : 0.2}], + * "middle" : "end" + * }); + * chain.value = "beginning"; + * chain.next(); //returns "end" with 80% probability or "middle" with 20%. + * @param {Object} values An object with the state names as the keys + * and the next state(s) as the values. + */ + Tone.CtrlMarkov = function (values, initial) { + Tone.call(this); + /** + * The Markov values with states as the keys + * and next state(s) as the values. + * @type {Object} + */ + this.values = Tone.defaultArg(values, {}); + /** + * The current state of the Markov values. The next + * state will be evaluated and returned when Tone.CtrlMarkov.next + * is invoked. + * @type {String} + */ + this.value = Tone.defaultArg(initial, Object.keys(this.values)[0]); + }; + Tone.extend(Tone.CtrlMarkov); + /** + * Returns the next state of the Markov values. + * @return {String} + */ + Tone.CtrlMarkov.prototype.next = function () { + if (this.values.hasOwnProperty(this.value)) { + var next = this.values[this.value]; + if (Tone.isArray(next)) { + var distribution = this._getProbDistribution(next); + var rand = Math.random(); + var total = 0; + for (var i = 0; i < distribution.length; i++) { + var dist = distribution[i]; + if (rand > total && rand < total + dist) { + var chosen = next[i]; + if (Tone.isObject(chosen)) { + this.value = chosen.value; + } else { + this.value = chosen; + } + } + total += dist; + } + } else { + this.value = next; + } + } + return this.value; + }; + /** + * Choose randomly from an array weighted options in the form + * {"state" : string, "probability" : number} or an array of values + * @param {Array} options + * @return {Array} The randomly selected choice + * @private + */ + Tone.CtrlMarkov.prototype._getProbDistribution = function (options) { + var distribution = []; + var total = 0; + var needsNormalizing = false; + for (var i = 0; i < options.length; i++) { + var option = options[i]; + if (Tone.isObject(option)) { + needsNormalizing = true; + distribution[i] = option.probability; + } else { + distribution[i] = 1 / options.length; + } + total += distribution[i]; + } + if (needsNormalizing) { + //normalize the values + for (var j = 0; j < distribution.length; j++) { + distribution[j] = distribution[j] / total; + } + } + return distribution; + }; + /** + * Clean up + * @return {Tone.CtrlMarkov} this + */ + Tone.CtrlMarkov.prototype.dispose = function () { + this.values = null; + }; + return Tone.CtrlMarkov; + }); + Module(function (Tone) { + + /** + * @class Generate patterns from an array of values. + * Has a number of arpeggiation and randomized + * selection patterns. + * <ul> + * <li>"up" - cycles upward</li> + * <li>"down" - cycles downward</li> + * <li>"upDown" - up then and down</li> + * <li>"downUp" - cycles down then and up</li> + * <li>"alternateUp" - jump up two and down one</li> + * <li>"alternateDown" - jump down two and up one</li> + * <li>"random" - randomly select an index</li> + * <li>"randomWalk" - randomly moves one index away from the current position</li> + * <li>"randomOnce" - randomly select an index without repeating until all values have been chosen.</li> + * </ul> + * @param {Array} values An array of options to choose from. + * @param {Tone.CtrlPattern.Type=} type The name of the pattern. + * @extends {Tone} + */ + Tone.CtrlPattern = function () { + var options = Tone.defaults(arguments, [ + 'values', + 'type' + ], Tone.CtrlPattern); + Tone.call(this); + /** + * The array of values to arpeggiate over + * @type {Array} + */ + this.values = options.values; + /** + * The current position in the values array + * @type {Number} + */ + this.index = 0; + /** + * The type placeholder + * @type {Tone.CtrlPattern.Type} + * @private + */ + this._type = null; + /** + * Shuffled values for the RandomOnce type + * @type {Array} + * @private + */ + this._shuffled = null; + /** + * The direction of the movement + * @type {String} + * @private + */ + this._direction = null; + this.type = options.type; + }; + Tone.extend(Tone.CtrlPattern); + /** + * The Control Patterns + * @type {Object} + * @static + */ + Tone.CtrlPattern.Type = { + Up: 'up', + Down: 'down', + UpDown: 'upDown', + DownUp: 'downUp', + AlternateUp: 'alternateUp', + AlternateDown: 'alternateDown', + Random: 'random', + RandomWalk: 'randomWalk', + RandomOnce: 'randomOnce' + }; + /** + * The default values. + * @type {Object} + */ + Tone.CtrlPattern.defaults = { + 'type': Tone.CtrlPattern.Type.Up, + 'values': [] + }; + /** + * The value at the current index of the pattern. + * @readOnly + * @memberOf Tone.CtrlPattern# + * @type {*} + * @name value + */ + Object.defineProperty(Tone.CtrlPattern.prototype, 'value', { + get: function () { + //some safeguards + if (this.values.length === 0) { + return; + } else if (this.values.length === 1) { + return this.values[0]; + } + this.index = Math.min(this.index, this.values.length - 1); + var val = this.values[this.index]; + if (this.type === Tone.CtrlPattern.Type.RandomOnce) { + if (this.values.length !== this._shuffled.length) { + this._shuffleValues(); + } + val = this.values[this._shuffled[this.index]]; + } + return val; + } + }); + /** + * The pattern used to select the next + * item from the values array + * @memberOf Tone.CtrlPattern# + * @type {Tone.CtrlPattern.Type} + * @name type + */ + Object.defineProperty(Tone.CtrlPattern.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + this._type = type; + this._shuffled = null; + //the first index + if (this._type === Tone.CtrlPattern.Type.Up || this._type === Tone.CtrlPattern.Type.UpDown || this._type === Tone.CtrlPattern.Type.RandomOnce || this._type === Tone.CtrlPattern.Type.AlternateUp) { + this.index = 0; + } else if (this._type === Tone.CtrlPattern.Type.Down || this._type === Tone.CtrlPattern.Type.DownUp || this._type === Tone.CtrlPattern.Type.AlternateDown) { + this.index = this.values.length - 1; + } + //the direction + if (this._type === Tone.CtrlPattern.Type.UpDown || this._type === Tone.CtrlPattern.Type.AlternateUp) { + this._direction = Tone.CtrlPattern.Type.Up; + } else if (this._type === Tone.CtrlPattern.Type.DownUp || this._type === Tone.CtrlPattern.Type.AlternateDown) { + this._direction = Tone.CtrlPattern.Type.Down; + } + //randoms + if (this._type === Tone.CtrlPattern.Type.RandomOnce) { + this._shuffleValues(); + } else if (this._type === Tone.CtrlPattern.Random) { + this.index = Math.floor(Math.random() * this.values.length); + } + } + }); + /** + * Return the next value given the current position + * and pattern. + * @return {*} The next value + */ + Tone.CtrlPattern.prototype.next = function () { + var type = this.type; + //choose the next index + if (type === Tone.CtrlPattern.Type.Up) { + this.index++; + if (this.index >= this.values.length) { + this.index = 0; + } + } else if (type === Tone.CtrlPattern.Type.Down) { + this.index--; + if (this.index < 0) { + this.index = this.values.length - 1; + } + } else if (type === Tone.CtrlPattern.Type.UpDown || type === Tone.CtrlPattern.Type.DownUp) { + if (this._direction === Tone.CtrlPattern.Type.Up) { + this.index++; + } else { + this.index--; + } + if (this.index < 0) { + this.index = 1; + this._direction = Tone.CtrlPattern.Type.Up; + } else if (this.index >= this.values.length) { + this.index = this.values.length - 2; + this._direction = Tone.CtrlPattern.Type.Down; + } + } else if (type === Tone.CtrlPattern.Type.Random) { + this.index = Math.floor(Math.random() * this.values.length); + } else if (type === Tone.CtrlPattern.Type.RandomWalk) { + if (Math.random() < 0.5) { + this.index--; + this.index = Math.max(this.index, 0); + } else { + this.index++; + this.index = Math.min(this.index, this.values.length - 1); + } + } else if (type === Tone.CtrlPattern.Type.RandomOnce) { + this.index++; + if (this.index >= this.values.length) { + this.index = 0; + //reshuffle the values for next time + this._shuffleValues(); + } + } else if (type === Tone.CtrlPattern.Type.AlternateUp) { + if (this._direction === Tone.CtrlPattern.Type.Up) { + this.index += 2; + this._direction = Tone.CtrlPattern.Type.Down; + } else { + this.index -= 1; + this._direction = Tone.CtrlPattern.Type.Up; + } + if (this.index >= this.values.length) { + this.index = 0; + this._direction = Tone.CtrlPattern.Type.Up; + } + } else if (type === Tone.CtrlPattern.Type.AlternateDown) { + if (this._direction === Tone.CtrlPattern.Type.Up) { + this.index += 1; + this._direction = Tone.CtrlPattern.Type.Down; + } else { + this.index -= 2; + this._direction = Tone.CtrlPattern.Type.Up; + } + if (this.index < 0) { + this.index = this.values.length - 1; + this._direction = Tone.CtrlPattern.Type.Down; + } + } + return this.value; + }; + /** + * Shuffles the values and places the results into the _shuffled + * @private + */ + Tone.CtrlPattern.prototype._shuffleValues = function () { + var copy = []; + this._shuffled = []; + for (var i = 0; i < this.values.length; i++) { + copy[i] = i; + } + while (copy.length > 0) { + var randVal = copy.splice(Math.floor(copy.length * Math.random()), 1); + this._shuffled.push(randVal[0]); + } + }; + /** + * Clean up + * @returns {Tone.CtrlPattern} this + */ + Tone.CtrlPattern.prototype.dispose = function () { + this._shuffled = null; + this.values = null; + }; + return Tone.CtrlPattern; + }); + Module(function (Tone) { + + /** + * @class Choose a random value. + * @extends {Tone} + * @example + * var randomWalk = new Tone.CtrlRandom({ + * "min" : 0, + * "max" : 10, + * "integer" : true + * }); + * randomWalk.eval(); + * + * @param {Number|Time=} min The minimum return value. + * @param {Number|Time=} max The maximum return value. + */ + Tone.CtrlRandom = function () { + var options = Tone.defaults(arguments, [ + 'min', + 'max' + ], Tone.CtrlRandom); + Tone.call(this); + /** + * The minimum return value + * @type {Number|Time} + */ + this.min = options.min; + /** + * The maximum return value + * @type {Number|Time} + */ + this.max = options.max; + /** + * If the return value should be an integer + * @type {Boolean} + */ + this.integer = options.integer; + }; + Tone.extend(Tone.CtrlRandom); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.CtrlRandom.defaults = { + 'min': 0, + 'max': 1, + 'integer': false + }; + /** + * Return a random value between min and max. + * @readOnly + * @memberOf Tone.CtrlRandom# + * @type {*} + * @name value + */ + Object.defineProperty(Tone.CtrlRandom.prototype, 'value', { + get: function () { + var min = this.toSeconds(this.min); + var max = this.toSeconds(this.max); + var rand = Math.random(); + var val = rand * min + (1 - rand) * max; + if (this.integer) { + val = Math.floor(val); + } + return val; + } + }); + return Tone.CtrlRandom; + }); + Module(function (Tone) { + /** + * @class A data structure for holding multiple buffers. + * + * @param {Object|Array} urls An object literal or array + * of urls to load. + * @param {Function=} callback The callback to invoke when + * the buffers are loaded. + * @extends {Tone} + * @example + * //load a whole bank of piano samples + * var pianoSamples = new Tone.Buffers({ + * "C4" : "path/to/C4.mp3" + * "C#4" : "path/to/C#4.mp3" + * "D4" : "path/to/D4.mp3" + * "D#4" : "path/to/D#4.mp3" + * ... + * }, function(){ + * //play one of the samples when they all load + * player.buffer = pianoSamples.get("C4"); + * player.start(); + * }); + * @example + * //To pass in additional parameters in the second parameter + * var buffers = new Tone.Buffers(urls, { + * "onload" : callback, + * "baseUrl" : "../path/to/audio/" + * }) + */ + Tone.Buffers = function (urls) { + //remove the urls from the options + var args = Array.prototype.slice.call(arguments); + args.shift(); + var options = Tone.defaults(args, [ + 'onload', + 'baseUrl' + ], Tone.Buffers); + Tone.call(this); + /** + * All of the buffers + * @type {Object} + * @private + */ + this._buffers = {}; + /** + * A path which is prefixed before every url. + * @type {String} + */ + this.baseUrl = options.baseUrl; + this._loadingCount = 0; + //add each one + for (var key in urls) { + this._loadingCount++; + this.add(key, urls[key], this._bufferLoaded.bind(this, options.onload)); + } + }; + Tone.extend(Tone.Buffers); + /** + * Defaults + * @type {Object} + */ + Tone.Buffers.defaults = { + 'onload': Tone.noOp, + 'baseUrl': '' + }; + /** + * True if the buffers object has a buffer by that name. + * @param {String|Number} name The key or index of the + * buffer. + * @return {Boolean} + */ + Tone.Buffers.prototype.has = function (name) { + return this._buffers.hasOwnProperty(name); + }; + /** + * Get a buffer by name. If an array was loaded, + * then use the array index. + * @param {String|Number} name The key or index of the + * buffer. + * @return {Tone.Buffer} + */ + Tone.Buffers.prototype.get = function (name) { + if (this.has(name)) { + return this._buffers[name]; + } else { + throw new Error('Tone.Buffers: no buffer named ' + name); + } + }; + /** + * A buffer was loaded. decrement the counter. + * @param {Function} callback + * @private + */ + Tone.Buffers.prototype._bufferLoaded = function (callback) { + this._loadingCount--; + if (this._loadingCount === 0 && callback) { + callback(this); + } + }; + /** + * If the buffers are loaded or not + * @memberOf Tone.Buffers# + * @type {Boolean} + * @name loaded + * @readOnly + */ + Object.defineProperty(Tone.Buffers.prototype, 'loaded', { + get: function () { + var isLoaded = true; + for (var buffName in this._buffers) { + var buff = this.get(buffName); + isLoaded = isLoaded && buff.loaded; + } + return isLoaded; + } + }); + /** + * Add a buffer by name and url to the Buffers + * @param {String} name A unique name to give + * the buffer + * @param {String|Tone.Buffer|Audiobuffer} url Either the url of the bufer, + * or a buffer which will be added + * with the given name. + * @param {Function=} callback The callback to invoke + * when the url is loaded. + */ + Tone.Buffers.prototype.add = function (name, url, callback) { + callback = Tone.defaultArg(callback, Tone.noOp); + if (url instanceof Tone.Buffer) { + this._buffers[name] = url; + callback(this); + } else if (url instanceof AudioBuffer) { + this._buffers[name] = new Tone.Buffer(url); + callback(this); + } else if (Tone.isString(url)) { + this._buffers[name] = new Tone.Buffer(this.baseUrl + url, callback); + } + return this; + }; + /** + * Clean up. + * @return {Tone.Buffers} this + */ + Tone.Buffers.prototype.dispose = function () { + Tone.prototype.dispose.call(this); + for (var name in this._buffers) { + this._buffers[name].dispose(); + } + this._buffers = null; + return this; + }; + return Tone.Buffers; + }); + Module(function (Tone) { + + /** + * buses are another way of routing audio + * + * augments Tone.prototype to include send and recieve + */ + /** + * All of the routes + * + * @type {Object} + * @static + * @private + */ + var Buses = {}; + /** + * Send this signal to the channel name. + * @param {String} channelName A named channel to send the signal to. + * @param {Decibels} amount The amount of the source to send to the bus. + * @return {GainNode} The gain node which connects this node to the desired channel. + * Can be used to adjust the levels of the send. + * @example + * source.send("reverb", -12); + */ + Tone.prototype.send = function (channelName, amount) { + if (!Buses.hasOwnProperty(channelName)) { + Buses[channelName] = this.context.createGain(); + } + amount = Tone.defaultArg(amount, 0); + var sendKnob = new Tone.Gain(amount, Tone.Type.Decibels); + this.connect(sendKnob); + sendKnob.connect(Buses[channelName]); + return sendKnob; + }; + /** + * Recieve the input from the desired channelName to the input + * + * @param {String} channelName A named channel to send the signal to. + * @param {Number=} channelNumber The channel to connect to + * @returns {Tone} this + * @example + * reverbEffect.receive("reverb"); + */ + Tone.prototype.receive = function (channelName, inputNum) { + if (!Buses.hasOwnProperty(channelName)) { + Buses[channelName] = this.context.createGain(); + } + Buses[channelName].connect(this, 0, inputNum); + return this; + }; + //remove all the send/receives when a new audio context is passed in + Tone.Context.on('init', function (context) { + if (context.Buses) { + Buses = context.Buses; + } else { + Buses = {}; + context.Buses = Buses; + } + }); + return Tone; + }); + Module(function (Tone) { + + /** + * @class Tone.Draw is useful for synchronizing visuals and audio events. + * Callbacks from Tone.Transport or any of the Tone.Event classes + * always happen _before_ the scheduled time and are not synchronized + * to the animation frame so they are not good for triggering tightly + * synchronized visuals and sound. Tone.Draw makes it easy to schedule + * callbacks using the AudioContext time and uses requestAnimationFrame. + * + * @singleton + * @extends {Tone} + * @example + * Tone.Transport.schedule(function(time){ + * //use the time argument to schedule a callback with Tone.Draw + * Tone.Draw.schedule(function(){ + * //do drawing or DOM manipulation here + * }, time) + * }, "+0.5") + */ + Tone.Draw = function () { + Tone.call(this); + /** + * All of the events. + * @type {Tone.Timeline} + * @private + */ + this._events = new Tone.Timeline(); + /** + * The duration after which events are not invoked. + * @type {Number} + * @default 0.25 + */ + this.expiration = 0.25; + /** + * The amount of time before the scheduled time + * that the callback can be invoked. Default is + * half the time of an animation frame (0.008 seconds). + * @type {Number} + * @default 0.008 + */ + this.anticipation = 0.008; + /** + * The draw loop + * @type {Function} + * @private + */ + this._boundDrawLoop = this._drawLoop.bind(this); + }; + Tone.extend(Tone.Draw); + /** + * Schedule a function at the given time to be invoked + * on the nearest animation frame. + * @param {Function} callback Callback is invoked at the given time. + * @param {Time} time The time relative to the AudioContext time + * to invoke the callback. + * @return {Tone.Draw} this + */ + Tone.Draw.prototype.schedule = function (callback, time) { + this._events.add({ + callback: callback, + time: this.toSeconds(time) + }); + //start the draw loop on the first event + if (this._events.length === 1) { + requestAnimationFrame(this._boundDrawLoop); + } + return this; + }; + /** + * Cancel events scheduled after the given time + * @param {Time=} after Time after which scheduled events will + * be removed from the scheduling timeline. + * @return {Tone.Draw} this + */ + Tone.Draw.prototype.cancel = function (after) { + this._events.cancel(this.toSeconds(after)); + return this; + }; + /** + * The draw loop + * @private + */ + Tone.Draw.prototype._drawLoop = function () { + var now = Tone.now(); + while (this._events.length && this._events.peek().time - this.anticipation <= now) { + var event = this._events.shift(); + if (now - event.time <= this.expiration) { + event.callback(); + } + } + if (this._events.length > 0) { + requestAnimationFrame(this._boundDrawLoop); + } + }; + //make a singleton + Tone.Draw = new Tone.Draw(); + return Tone.Draw; + }); + Module(function (Tone) { + + /** + * @class Both Tone.Panner3D and Tone.Listener have a position in 3D space + * using a right-handed cartesian coordinate system. + * The units used in the coordinate system are not defined; + * these coordinates are independent/invariant of any particular + * units such as meters or feet. Tone.Panner3D objects have an forward + * vector representing the direction the sound is projecting. Additionally, + * they have a sound cone representing how directional the sound is. + * For example, the sound could be omnidirectional, in which case it would + * be heard anywhere regardless of its forward, or it can be more directional + * and heard only if it is facing the listener. Tone.Listener objects + * (representing a person's ears) have an forward and up vector + * representing in which direction the person is facing. Because both the + * source stream and the listener can be moving, they both have a velocity + * vector representing both the speed and direction of movement. Taken together, + * these two velocities can be used to generate a doppler shift effect which changes the pitch. + * <br><br> + * Note: the position of the Listener will have no effect on nodes not connected to a Tone.Panner3D + * + * @constructor + * @extends {Tone} + * @singleton + */ + Tone.Listener = function () { + Tone.call(this); + /** + * Holds the current forward orientation + * @type {Array} + * @private + */ + this._orientation = [ + 0, + 0, + 0, + 0, + 0, + 0 + ]; + /** + * Holds the current position + * @type {Array} + * @private + */ + this._position = [ + 0, + 0, + 0 + ]; + Tone.getContext(function () { + // set the default position/forward + this.set(ListenerConstructor.defaults); + }.bind(this)); + }; + Tone.extend(Tone.Listener); + /** + * Defaults according to the specification + * @static + * @const + * @type {Object} + */ + Tone.Listener.defaults = { + 'positionX': 0, + 'positionY': 0, + 'positionZ': 0, + 'forwardX': 0, + 'forwardY': 0, + 'forwardZ': 1, + 'upX': 0, + 'upY': 1, + 'upZ': 0 + }; + /** + * The ramp time which is applied to the setTargetAtTime + * @type {Number} + * @private + */ + Tone.Listener.prototype._rampTimeConstant = 0.01; + /** + * Sets the position of the listener in 3d space. + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @return {Tone.Listener} this + */ + Tone.Listener.prototype.setPosition = function (x, y, z) { + if (this.context.listener.positionX) { + var now = this.now(); + this.context.listener.positionX.setTargetAtTime(x, now, this._rampTimeConstant); + this.context.listener.positionY.setTargetAtTime(y, now, this._rampTimeConstant); + this.context.listener.positionZ.setTargetAtTime(z, now, this._rampTimeConstant); + } else { + this.context.listener.setPosition(x, y, z); + } + this._position = Array.prototype.slice.call(arguments); + return this; + }; + /** + * Sets the orientation of the listener using two vectors, the forward + * vector (which direction the listener is facing) and the up vector + * (which the up direction of the listener). An up vector + * of 0, 0, 1 is equivalent to the listener standing up in the Z direction. + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {Number} upX + * @param {Number} upY + * @param {Number} upZ + * @return {Tone.Listener} this + */ + Tone.Listener.prototype.setOrientation = function (x, y, z, upX, upY, upZ) { + if (this.context.listener.forwardX) { + var now = this.now(); + this.context.listener.forwardX.setTargetAtTime(x, now, this._rampTimeConstant); + this.context.listener.forwardY.setTargetAtTime(y, now, this._rampTimeConstant); + this.context.listener.forwardZ.setTargetAtTime(z, now, this._rampTimeConstant); + this.context.listener.upX.setTargetAtTime(upX, now, this._rampTimeConstant); + this.context.listener.upY.setTargetAtTime(upY, now, this._rampTimeConstant); + this.context.listener.upZ.setTargetAtTime(upZ, now, this._rampTimeConstant); + } else { + this.context.listener.setOrientation(x, y, z, upX, upY, upZ); + } + this._orientation = Array.prototype.slice.call(arguments); + return this; + }; + /** + * The x position of the panner object. + * @type {Number} + * @memberOf Tone.Listener# + * @name positionX + */ + Object.defineProperty(Tone.Listener.prototype, 'positionX', { + set: function (pos) { + this._position[0] = pos; + this.setPosition.apply(this, this._position); + }, + get: function () { + return this._position[0]; + } + }); + /** + * The y position of the panner object. + * @type {Number} + * @memberOf Tone.Listener# + * @name positionY + */ + Object.defineProperty(Tone.Listener.prototype, 'positionY', { + set: function (pos) { + this._position[1] = pos; + this.setPosition.apply(this, this._position); + }, + get: function () { + return this._position[1]; + } + }); + /** + * The z position of the panner object. + * @type {Number} + * @memberOf Tone.Listener# + * @name positionZ + */ + Object.defineProperty(Tone.Listener.prototype, 'positionZ', { + set: function (pos) { + this._position[2] = pos; + this.setPosition.apply(this, this._position); + }, + get: function () { + return this._position[2]; + } + }); + /** + * The x coordinate of the listeners front direction. i.e. + * which way they are facing. + * @type {Number} + * @memberOf Tone.Listener# + * @name forwardX + */ + Object.defineProperty(Tone.Listener.prototype, 'forwardX', { + set: function (pos) { + this._orientation[0] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[0]; + } + }); + /** + * The y coordinate of the listeners front direction. i.e. + * which way they are facing. + * @type {Number} + * @memberOf Tone.Listener# + * @name forwardY + */ + Object.defineProperty(Tone.Listener.prototype, 'forwardY', { + set: function (pos) { + this._orientation[1] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[1]; + } + }); + /** + * The z coordinate of the listeners front direction. i.e. + * which way they are facing. + * @type {Number} + * @memberOf Tone.Listener# + * @name forwardZ + */ + Object.defineProperty(Tone.Listener.prototype, 'forwardZ', { + set: function (pos) { + this._orientation[2] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[2]; + } + }); + /** + * The x coordinate of the listener's up direction. i.e. + * the direction the listener is standing in. + * @type {Number} + * @memberOf Tone.Listener# + * @name upX + */ + Object.defineProperty(Tone.Listener.prototype, 'upX', { + set: function (pos) { + this._orientation[3] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[3]; + } + }); + /** + * The y coordinate of the listener's up direction. i.e. + * the direction the listener is standing in. + * @type {Number} + * @memberOf Tone.Listener# + * @name upY + */ + Object.defineProperty(Tone.Listener.prototype, 'upY', { + set: function (pos) { + this._orientation[4] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[4]; + } + }); + /** + * The z coordinate of the listener's up direction. i.e. + * the direction the listener is standing in. + * @type {Number} + * @memberOf Tone.Listener# + * @name upZ + */ + Object.defineProperty(Tone.Listener.prototype, 'upZ', { + set: function (pos) { + this._orientation[5] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[5]; + } + }); + /** + * Clean up. + * @returns {Tone.Listener} this + */ + Tone.Listener.prototype.dispose = function () { + this._orientation = null; + this._position = null; + return this; + }; + //SINGLETON SETUP + var ListenerConstructor = Tone.Listener; + Tone.Listener = new ListenerConstructor(); + Tone.Context.on('init', function (context) { + if (context.Listener instanceof ListenerConstructor) { + //a single listener object + Tone.Listener = context.Listener; + } else { + //make new Listener insides + Tone.Listener = new ListenerConstructor(); + } + context.Listener = Tone.Listener; + }); + //END SINGLETON SETUP + return Tone.Listener; + }); + Module(function (Tone) { + /** + * Because of a bug in iOS causing the currentTime to increment + * before the rendering is started, sometimes it takes multiple + * attempts to render the audio correctly. + * @private + */ + function attemptRender(callback, duration, sampleRate, tries) { + tries = Tone.defaultArg(tries, 0); + var context = new Tone.OfflineContext(2, duration, sampleRate); + Tone.context = context; + //invoke the callback/scheduling + var response = callback(Tone.Transport); + if (context.currentTime > 0 && tries < 1000) { + return attemptRender(callback, duration, sampleRate, ++tries); + } else { + return { + 'response': response, + 'context': context + }; + } + } + /** + * Generate a buffer by rendering all of the Tone.js code within the callback using the OfflineAudioContext. + * The OfflineAudioContext is capable of rendering much faster than real time in many cases. + * The callback function also passes in an offline instance of Tone.Transport which can be used + * to schedule events along the Transport. **NOTE** OfflineAudioContext has the same restrictions + * as the AudioContext in that on certain platforms (like iOS) it must be invoked by an explicit + * user action like a click or tap. + * @param {Function} callback All Tone.js nodes which are created and scheduled within this callback are recorded into the output Buffer. + * @param {Time} duration the amount of time to record for. + * @return {Promise} The promise which is invoked with the Tone.Buffer of the recorded output. + * @example + * //render 2 seconds of the oscillator + * Tone.Offline(function(){ + * //only nodes created in this callback will be recorded + * var oscillator = new Tone.Oscillator().toMaster().start(0) + * //schedule their events + * }, 2).then(function(buffer){ + * //do something with the output buffer + * }) + * @example + * //can also schedule events along the Transport + * //using the passed in Offline Transport + * Tone.Offline(function(Transport){ + * var osc = new Tone.Oscillator().toMaster() + * Transport.schedule(function(time){ + * osc.start(time).stop(time + 0.1) + * }, 1) + * Transport.start(0.2) + * }, 4).then(function(buffer){ + * //do something with the output buffer + * }) + */ + Tone.Offline = function (callback, duration) { + //set the OfflineAudioContext + var sampleRate = Tone.context.sampleRate; + var originalContext = Tone.context; + var renderRet = attemptRender(callback, duration, sampleRate); + var response = renderRet.response; + var context = renderRet.context; + var ret; + if (response instanceof Promise) { + //wait for the promise to resolve + ret = response.then(function () { + //then render the audio + return context.render(); + }); + } else { + //process the audio + ret = context.render(); + } + //return the original AudioContext + Tone.context = originalContext; + //return the audio + return ret.then(function (buffer) { + //wrap it in a Tone.Buffer + return new Tone.Buffer(buffer); + }); + }; + return Tone.Offline; + }); + Module(function (Tone) { + + /** + * @class Tone.Effect is the base class for effects. Connect the effect between + * the effectSend and effectReturn GainNodes, then control the amount of + * effect which goes to the output using the wet control. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {NormalRange|Object} [wet] The starting wet value. + */ + Tone.Effect = function () { + var options = Tone.defaults(arguments, ['wet'], Tone.Effect); + Tone.AudioNode.call(this); + this.createInsOuts(1, 1); + /** + * the drywet knob to control the amount of effect + * @type {Tone.CrossFade} + * @private + */ + this._dryWet = new Tone.CrossFade(options.wet); + /** + * The wet control is how much of the effected + * will pass through to the output. 1 = 100% effected + * signal, 0 = 100% dry signal. + * @type {NormalRange} + * @signal + */ + this.wet = this._dryWet.fade; + /** + * connect the effectSend to the input of hte effect + * @type {Tone.Gain} + * @private + */ + this.effectSend = new Tone.Gain(); + /** + * connect the output of the effect to the effectReturn + * @type {Tone.Gain} + * @private + */ + this.effectReturn = new Tone.Gain(); + //connections + this.input.connect(this._dryWet.a); + this.input.connect(this.effectSend); + this.effectReturn.connect(this._dryWet.b); + this._dryWet.connect(this.output); + this._readOnly(['wet']); + }; + Tone.extend(Tone.Effect, Tone.AudioNode); + /** + * @static + * @type {Object} + */ + Tone.Effect.defaults = { 'wet': 1 }; + /** + * chains the effect in between the effectSend and effectReturn + * @param {Tone} effect + * @private + * @returns {Tone.Effect} this + */ + Tone.Effect.prototype.connectEffect = function (effect) { + this.effectSend.chain(effect, this.effectReturn); + return this; + }; + /** + * Clean up. + * @returns {Tone.Effect} this + */ + Tone.Effect.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._dryWet.dispose(); + this._dryWet = null; + this.effectSend.dispose(); + this.effectSend = null; + this.effectReturn.dispose(); + this.effectReturn = null; + this._writable(['wet']); + this.wet = null; + return this; + }; + return Tone.Effect; + }); + Module(function (Tone) { + + /** + * @class Tone.AutoFilter is a Tone.Filter with a Tone.LFO connected to the filter cutoff frequency. + * Setting the LFO rate and depth allows for control over the filter modulation rate + * and depth. + * + * @constructor + * @extends {Tone.Effect} + * @param {Time|Object} [frequency] The rate of the LFO. + * @param {Frequency=} baseFrequency The lower value of the LFOs oscillation + * @param {Frequency=} octaves The number of octaves above the baseFrequency + * @example + * //create an autofilter and start it's LFO + * var autoFilter = new Tone.AutoFilter("4n").toMaster().start(); + * //route an oscillator through the filter and start it + * var oscillator = new Tone.Oscillator().connect(autoFilter).start(); + */ + Tone.AutoFilter = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'baseFrequency', + 'octaves' + ], Tone.AutoFilter); + Tone.Effect.call(this, options); + /** + * the lfo which drives the filter cutoff + * @type {Tone.LFO} + * @private + */ + this._lfo = new Tone.LFO({ + 'frequency': options.frequency, + 'amplitude': options.depth + }); + /** + * The range of the filter modulating between the min and max frequency. + * 0 = no modulation. 1 = full modulation. + * @type {NormalRange} + * @signal + */ + this.depth = this._lfo.amplitude; + /** + * How fast the filter modulates between min and max. + * @type {Frequency} + * @signal + */ + this.frequency = this._lfo.frequency; + /** + * The filter node + * @type {Tone.Filter} + */ + this.filter = new Tone.Filter(options.filter); + /** + * The octaves placeholder + * @type {Positive} + * @private + */ + this._octaves = 0; + //connections + this.connectEffect(this.filter); + this._lfo.connect(this.filter.frequency); + this.type = options.type; + this._readOnly([ + 'frequency', + 'depth' + ]); + this.octaves = options.octaves; + this.baseFrequency = options.baseFrequency; + }; + //extend Effect + Tone.extend(Tone.AutoFilter, Tone.Effect); + /** + * defaults + * @static + * @type {Object} + */ + Tone.AutoFilter.defaults = { + 'frequency': 1, + 'type': 'sine', + 'depth': 1, + 'baseFrequency': 200, + 'octaves': 2.6, + 'filter': { + 'type': 'lowpass', + 'rolloff': -12, + 'Q': 1 + } + }; + /** + * Start the effect. + * @param {Time} [time=now] When the LFO will start. + * @returns {Tone.AutoFilter} this + */ + Tone.AutoFilter.prototype.start = function (time) { + this._lfo.start(time); + return this; + }; + /** + * Stop the effect. + * @param {Time} [time=now] When the LFO will stop. + * @returns {Tone.AutoFilter} this + */ + Tone.AutoFilter.prototype.stop = function (time) { + this._lfo.stop(time); + return this; + }; + /** + * Sync the filter to the transport. + * @param {Time} [delay=0] Delay time before starting the effect after the + * Transport has started. + * @returns {Tone.AutoFilter} this + */ + Tone.AutoFilter.prototype.sync = function (delay) { + this._lfo.sync(delay); + return this; + }; + /** + * Unsync the filter from the transport. + * @returns {Tone.AutoFilter} this + */ + Tone.AutoFilter.prototype.unsync = function () { + this._lfo.unsync(); + return this; + }; + /** + * Type of oscillator attached to the AutoFilter. + * Possible values: "sine", "square", "triangle", "sawtooth". + * @memberOf Tone.AutoFilter# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.AutoFilter.prototype, 'type', { + get: function () { + return this._lfo.type; + }, + set: function (type) { + this._lfo.type = type; + } + }); + /** + * The minimum value of the filter's cutoff frequency. + * @memberOf Tone.AutoFilter# + * @type {Frequency} + * @name min + */ + Object.defineProperty(Tone.AutoFilter.prototype, 'baseFrequency', { + get: function () { + return this._lfo.min; + }, + set: function (freq) { + this._lfo.min = this.toFrequency(freq); + //and set the max + this.octaves = this._octaves; + } + }); + /** + * The maximum value of the filter's cutoff frequency. + * @memberOf Tone.AutoFilter# + * @type {Positive} + * @name octaves + */ + Object.defineProperty(Tone.AutoFilter.prototype, 'octaves', { + get: function () { + return this._octaves; + }, + set: function (oct) { + this._octaves = oct; + this._lfo.max = this.baseFrequency * Math.pow(2, oct); + } + }); + /** + * Clean up. + * @returns {Tone.AutoFilter} this + */ + Tone.AutoFilter.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._lfo.dispose(); + this._lfo = null; + this.filter.dispose(); + this.filter = null; + this._writable([ + 'frequency', + 'depth' + ]); + this.frequency = null; + this.depth = null; + return this; + }; + return Tone.AutoFilter; + }); + Module(function (Tone) { + + /** + * @class Tone.AutoPanner is a Tone.Panner with an LFO connected to the pan amount. + * More on using autopanners [here](https://www.ableton.com/en/blog/autopan-chopper-effect-and-more-liveschool/). + * + * @constructor + * @extends {Tone.Effect} + * @param {Frequency|Object} [frequency] Rate of left-right oscillation. + * @example + * //create an autopanner and start it's LFO + * var autoPanner = new Tone.AutoPanner("4n").toMaster().start(); + * //route an oscillator through the panner and start it + * var oscillator = new Tone.Oscillator().connect(autoPanner).start(); + */ + Tone.AutoPanner = function () { + var options = Tone.defaults(arguments, ['frequency'], Tone.AutoPanner); + Tone.Effect.call(this, options); + /** + * the lfo which drives the panning + * @type {Tone.LFO} + * @private + */ + this._lfo = new Tone.LFO({ + 'frequency': options.frequency, + 'amplitude': options.depth, + 'min': -1, + 'max': 1 + }); + /** + * The amount of panning between left and right. + * 0 = always center. 1 = full range between left and right. + * @type {NormalRange} + * @signal + */ + this.depth = this._lfo.amplitude; + /** + * the panner node which does the panning + * @type {Tone.Panner} + * @private + */ + this._panner = new Tone.Panner(); + /** + * How fast the panner modulates between left and right. + * @type {Frequency} + * @signal + */ + this.frequency = this._lfo.frequency; + //connections + this.connectEffect(this._panner); + this._lfo.connect(this._panner.pan); + this.type = options.type; + this._readOnly([ + 'depth', + 'frequency' + ]); + }; + //extend Effect + Tone.extend(Tone.AutoPanner, Tone.Effect); + /** + * defaults + * @static + * @type {Object} + */ + Tone.AutoPanner.defaults = { + 'frequency': 1, + 'type': 'sine', + 'depth': 1 + }; + /** + * Start the effect. + * @param {Time} [time=now] When the LFO will start. + * @returns {Tone.AutoPanner} this + */ + Tone.AutoPanner.prototype.start = function (time) { + this._lfo.start(time); + return this; + }; + /** + * Stop the effect. + * @param {Time} [time=now] When the LFO will stop. + * @returns {Tone.AutoPanner} this + */ + Tone.AutoPanner.prototype.stop = function (time) { + this._lfo.stop(time); + return this; + }; + /** + * Sync the panner to the transport. + * @param {Time} [delay=0] Delay time before starting the effect after the + * Transport has started. + * @returns {Tone.AutoPanner} this + */ + Tone.AutoPanner.prototype.sync = function (delay) { + this._lfo.sync(delay); + return this; + }; + /** + * Unsync the panner from the transport + * @returns {Tone.AutoPanner} this + */ + Tone.AutoPanner.prototype.unsync = function () { + this._lfo.unsync(); + return this; + }; + /** + * Type of oscillator attached to the AutoFilter. + * Possible values: "sine", "square", "triangle", "sawtooth". + * @memberOf Tone.AutoFilter# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.AutoPanner.prototype, 'type', { + get: function () { + return this._lfo.type; + }, + set: function (type) { + this._lfo.type = type; + } + }); + /** + * clean up + * @returns {Tone.AutoPanner} this + */ + Tone.AutoPanner.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._lfo.dispose(); + this._lfo = null; + this._panner.dispose(); + this._panner = null; + this._writable([ + 'depth', + 'frequency' + ]); + this.frequency = null; + this.depth = null; + return this; + }; + return Tone.AutoPanner; + }); + Module(function (Tone) { + + /** + * @class Tone.AutoWah connects a Tone.Follower to a bandpass filter (Tone.Filter). + * The frequency of the filter is adjusted proportionally to the + * incoming signal's amplitude. Inspiration from [Tuna.js](https://github.com/Dinahmoe/tuna). + * + * @constructor + * @extends {Tone.Effect} + * @param {Frequency|Object} [baseFrequency] The frequency the filter is set + * to at the low point of the wah + * @param {Positive} [octaves] The number of octaves above the baseFrequency + * the filter will sweep to when fully open + * @param {Decibels} [sensitivity] The decibel threshold sensitivity for + * the incoming signal. Normal range of -40 to 0. + * @example + * var autoWah = new Tone.AutoWah(50, 6, -30).toMaster(); + * //initialize the synth and connect to autowah + * var synth = new Synth.connect(autoWah); + * //Q value influences the effect of the wah - default is 2 + * autoWah.Q.value = 6; + * //more audible on higher notes + * synth.triggerAttackRelease("C4", "8n") + */ + Tone.AutoWah = function () { + var options = Tone.defaults(arguments, [ + 'baseFrequency', + 'octaves', + 'sensitivity' + ], Tone.AutoWah); + Tone.Effect.call(this, options); + /** + * The envelope follower. Set the attack/release + * timing to adjust how the envelope is followed. + * @type {Tone.Follower} + * @private + */ + this.follower = new Tone.Follower(options.follower); + /** + * scales the follower value to the frequency domain + * @type {Tone} + * @private + */ + this._sweepRange = new Tone.ScaleExp(0, 1, 0.5); + /** + * @type {number} + * @private + */ + this._baseFrequency = options.baseFrequency; + /** + * @type {number} + * @private + */ + this._octaves = options.octaves; + /** + * the input gain to adjust the sensitivity + * @type {Tone.Gain} + * @private + */ + this._inputBoost = new Tone.Gain(); + /** + * @type {BiquadFilterNode} + * @private + */ + this._bandpass = new Tone.Filter({ + 'rolloff': -48, + 'frequency': 0, + 'Q': options.Q + }); + /** + * @type {Tone.Filter} + * @private + */ + this._peaking = new Tone.Filter(0, 'peaking'); + this._peaking.gain.value = options.gain; + /** + * The gain of the filter. + * @type {Number} + * @signal + */ + this.gain = this._peaking.gain; + /** + * The quality of the filter. + * @type {Positive} + * @signal + */ + this.Q = this._bandpass.Q; + //the control signal path + this.effectSend.chain(this._inputBoost, this.follower, this._sweepRange); + this._sweepRange.connect(this._bandpass.frequency); + this._sweepRange.connect(this._peaking.frequency); + //the filtered path + this.effectSend.chain(this._bandpass, this._peaking, this.effectReturn); + //set the initial value + this._setSweepRange(); + this.sensitivity = options.sensitivity; + this._readOnly([ + 'gain', + 'Q' + ]); + }; + Tone.extend(Tone.AutoWah, Tone.Effect); + /** + * @static + * @type {Object} + */ + Tone.AutoWah.defaults = { + 'baseFrequency': 100, + 'octaves': 6, + 'sensitivity': 0, + 'Q': 2, + 'gain': 2, + 'follower': { + 'attack': 0.3, + 'release': 0.5 + } + }; + /** + * The number of octaves that the filter will sweep above the + * baseFrequency. + * @memberOf Tone.AutoWah# + * @type {Number} + * @name octaves + */ + Object.defineProperty(Tone.AutoWah.prototype, 'octaves', { + get: function () { + return this._octaves; + }, + set: function (octaves) { + this._octaves = octaves; + this._setSweepRange(); + } + }); + /** + * The base frequency from which the sweep will start from. + * @memberOf Tone.AutoWah# + * @type {Frequency} + * @name baseFrequency + */ + Object.defineProperty(Tone.AutoWah.prototype, 'baseFrequency', { + get: function () { + return this._baseFrequency; + }, + set: function (baseFreq) { + this._baseFrequency = baseFreq; + this._setSweepRange(); + } + }); + /** + * The sensitivity to control how responsive to the input signal the filter is. + * @memberOf Tone.AutoWah# + * @type {Decibels} + * @name sensitivity + */ + Object.defineProperty(Tone.AutoWah.prototype, 'sensitivity', { + get: function () { + return Tone.gainToDb(1 / this._inputBoost.gain.value); + }, + set: function (sensitivy) { + this._inputBoost.gain.value = 1 / Tone.dbToGain(sensitivy); + } + }); + /** + * sets the sweep range of the scaler + * @private + */ + Tone.AutoWah.prototype._setSweepRange = function () { + this._sweepRange.min = this._baseFrequency; + this._sweepRange.max = Math.min(this._baseFrequency * Math.pow(2, this._octaves), this.context.sampleRate / 2); + }; + /** + * Clean up. + * @returns {Tone.AutoWah} this + */ + Tone.AutoWah.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this.follower.dispose(); + this.follower = null; + this._sweepRange.dispose(); + this._sweepRange = null; + this._bandpass.dispose(); + this._bandpass = null; + this._peaking.dispose(); + this._peaking = null; + this._inputBoost.dispose(); + this._inputBoost = null; + this._writable([ + 'gain', + 'Q' + ]); + this.gain = null; + this.Q = null; + return this; + }; + return Tone.AutoWah; + }); + Module(function (Tone) { + + /** + * @class Signal-rate modulo operator. Only works in AudioRange [-1, 1] and for modulus + * values in the NormalRange. + * + * @constructor + * @extends {Tone.SignalBase} + * @param {NormalRange} modulus The modulus to apply. + * @example + * var mod = new Tone.Modulo(0.2) + * var sig = new Tone.Signal(0.5).connect(mod); + * //mod outputs 0.1 + */ + Tone.Modulo = function (modulus) { + Tone.SignalBase.call(this); + this.createInsOuts(1, 0); + /** + * A waveshaper gets the integer multiple of + * the input signal and the modulus. + * @private + * @type {Tone.WaveShaper} + */ + this._shaper = new Tone.WaveShaper(Math.pow(2, 16)); + /** + * the integer multiple is multiplied by the modulus + * @type {Tone.Multiply} + * @private + */ + this._multiply = new Tone.Multiply(); + /** + * and subtracted from the input signal + * @type {Tone.Subtract} + * @private + */ + this._subtract = this.output = new Tone.Subtract(); + /** + * the modulus signal + * @type {Tone.Signal} + * @private + */ + this._modSignal = new Tone.Signal(modulus); + //connections + this.input.fan(this._shaper, this._subtract); + this._modSignal.connect(this._multiply, 0, 0); + this._shaper.connect(this._multiply, 0, 1); + this._multiply.connect(this._subtract, 0, 1); + this._setWaveShaper(modulus); + }; + Tone.extend(Tone.Modulo, Tone.SignalBase); + /** + * @param {number} mod the modulus to apply + * @private + */ + Tone.Modulo.prototype._setWaveShaper = function (mod) { + this._shaper.setMap(function (val) { + var multiple = Math.floor((val + 0.0001) / mod); + return multiple; + }); + }; + /** + * The modulus value. + * @memberOf Tone.Modulo# + * @type {NormalRange} + * @name value + */ + Object.defineProperty(Tone.Modulo.prototype, 'value', { + get: function () { + return this._modSignal.value; + }, + set: function (mod) { + this._modSignal.value = mod; + this._setWaveShaper(mod); + } + }); + /** + * clean up + * @returns {Tone.Modulo} this + */ + Tone.Modulo.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._shaper.dispose(); + this._shaper = null; + this._multiply.dispose(); + this._multiply = null; + this._subtract.dispose(); + this._subtract = null; + this._modSignal.dispose(); + this._modSignal = null; + return this; + }; + return Tone.Modulo; + }); + Module(function (Tone) { + + /** + * @class Tone.Bitcrusher downsamples the incoming signal to a different bitdepth. + * Lowering the bitdepth of the signal creates distortion. Read more about Bitcrushing + * on [Wikipedia](https://en.wikipedia.org/wiki/Bitcrusher). + * + * @constructor + * @extends {Tone.Effect} + * @param {Number} bits The number of bits to downsample the signal. Nominal range + * of 1 to 8. + * @example + * //initialize crusher and route a synth through it + * var crusher = new Tone.BitCrusher(4).toMaster(); + * var synth = new Tone.MonoSynth().connect(crusher); + */ + Tone.BitCrusher = function () { + var options = Tone.defaults(arguments, ['bits'], Tone.BitCrusher); + Tone.Effect.call(this, options); + var invStepSize = 1 / Math.pow(2, options.bits - 1); + /** + * Subtract the input signal and the modulus of the input signal + * @type {Tone.Subtract} + * @private + */ + this._subtract = new Tone.Subtract(); + /** + * The mod function + * @type {Tone.Modulo} + * @private + */ + this._modulo = new Tone.Modulo(invStepSize); + /** + * keeps track of the bits + * @type {number} + * @private + */ + this._bits = options.bits; + //connect it up + this.effectSend.fan(this._subtract, this._modulo); + this._modulo.connect(this._subtract, 0, 1); + this._subtract.connect(this.effectReturn); + }; + Tone.extend(Tone.BitCrusher, Tone.Effect); + /** + * the default values + * @static + * @type {Object} + */ + Tone.BitCrusher.defaults = { 'bits': 4 }; + /** + * The bit depth of the effect. Nominal range of 1-8. + * @memberOf Tone.BitCrusher# + * @type {number} + * @name bits + */ + Object.defineProperty(Tone.BitCrusher.prototype, 'bits', { + get: function () { + return this._bits; + }, + set: function (bits) { + this._bits = bits; + var invStepSize = 1 / Math.pow(2, bits - 1); + this._modulo.value = invStepSize; + } + }); + /** + * Clean up. + * @returns {Tone.BitCrusher} this + */ + Tone.BitCrusher.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._subtract.dispose(); + this._subtract = null; + this._modulo.dispose(); + this._modulo = null; + return this; + }; + return Tone.BitCrusher; + }); + Module(function (Tone) { + + /** + * @class Tone.ChebyShev is a Chebyshev waveshaper, an effect which is good + * for making different types of distortion sounds. + * Note that odd orders sound very different from even ones, + * and order = 1 is no change. + * Read more at [music.columbia.edu](http://music.columbia.edu/cmc/musicandcomputers/chapter4/04_06.php). + * + * @extends {Tone.Effect} + * @constructor + * @param {Positive|Object} [order] The order of the chebyshev polynomial. Normal range between 1-100. + * @example + * //create a new cheby + * var cheby = new Tone.Chebyshev(50); + * //create a monosynth connected to our cheby + * synth = new Tone.MonoSynth().connect(cheby); + */ + Tone.Chebyshev = function () { + var options = Tone.defaults(arguments, ['order'], Tone.Chebyshev); + Tone.Effect.call(this, options); + /** + * @type {WaveShaperNode} + * @private + */ + this._shaper = new Tone.WaveShaper(4096); + /** + * holds onto the order of the filter + * @type {number} + * @private + */ + this._order = options.order; + this.connectEffect(this._shaper); + this.order = options.order; + this.oversample = options.oversample; + }; + Tone.extend(Tone.Chebyshev, Tone.Effect); + /** + * @static + * @const + * @type {Object} + */ + Tone.Chebyshev.defaults = { + 'order': 1, + 'oversample': 'none' + }; + /** + * get the coefficient for that degree + * @param {number} x the x value + * @param {number} degree + * @param {Object} memo memoize the computed value. + * this speeds up computation greatly. + * @return {number} the coefficient + * @private + */ + Tone.Chebyshev.prototype._getCoefficient = function (x, degree, memo) { + if (memo.hasOwnProperty(degree)) { + return memo[degree]; + } else if (degree === 0) { + memo[degree] = 0; + } else if (degree === 1) { + memo[degree] = x; + } else { + memo[degree] = 2 * x * this._getCoefficient(x, degree - 1, memo) - this._getCoefficient(x, degree - 2, memo); + } + return memo[degree]; + }; + /** + * The order of the Chebyshev polynomial which creates + * the equation which is applied to the incoming + * signal through a Tone.WaveShaper. The equations + * are in the form:<br> + * order 2: 2x^2 + 1<br> + * order 3: 4x^3 + 3x <br> + * @memberOf Tone.Chebyshev# + * @type {Positive} + * @name order + */ + Object.defineProperty(Tone.Chebyshev.prototype, 'order', { + get: function () { + return this._order; + }, + set: function (order) { + this._order = order; + var curve = new Array(4096); + var len = curve.length; + for (var i = 0; i < len; ++i) { + var x = i * 2 / len - 1; + if (x === 0) { + //should output 0 when input is 0 + curve[i] = 0; + } else { + curve[i] = this._getCoefficient(x, order, {}); + } + } + this._shaper.curve = curve; + } + }); + /** + * The oversampling of the effect. Can either be "none", "2x" or "4x". + * @memberOf Tone.Chebyshev# + * @type {string} + * @name oversample + */ + Object.defineProperty(Tone.Chebyshev.prototype, 'oversample', { + get: function () { + return this._shaper.oversample; + }, + set: function (oversampling) { + this._shaper.oversample = oversampling; + } + }); + /** + * Clean up. + * @returns {Tone.Chebyshev} this + */ + Tone.Chebyshev.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._shaper.dispose(); + this._shaper = null; + return this; + }; + return Tone.Chebyshev; + }); + Module(function (Tone) { + + /** + * @class Base class for Stereo effects. Provides effectSendL/R and effectReturnL/R. + * + * @constructor + * @extends {Tone.Effect} + */ + Tone.StereoEffect = function () { + //get the defaults + Tone.AudioNode.call(this); + var options = Tone.defaults(arguments, ['wet'], Tone.Effect); + this.createInsOuts(1, 1); + /** + * the drywet knob to control the amount of effect + * @type {Tone.CrossFade} + * @private + */ + this._dryWet = new Tone.CrossFade(options.wet); + /** + * The wet control, i.e. how much of the effected + * will pass through to the output. + * @type {NormalRange} + * @signal + */ + this.wet = this._dryWet.fade; + /** + * then split it + * @type {Tone.Split} + * @private + */ + this._split = new Tone.Split(); + /** + * the effects send LEFT + * @type {GainNode} + * @private + */ + this.effectSendL = this._split.left; + /** + * the effects send RIGHT + * @type {GainNode} + * @private + */ + this.effectSendR = this._split.right; + /** + * the stereo effect merger + * @type {Tone.Merge} + * @private + */ + this._merge = new Tone.Merge(); + /** + * the effect return LEFT + * @type {GainNode} + * @private + */ + this.effectReturnL = this._merge.left; + /** + * the effect return RIGHT + * @type {GainNode} + * @private + */ + this.effectReturnR = this._merge.right; + //connections + this.input.connect(this._split); + //dry wet connections + this.input.connect(this._dryWet, 0, 0); + this._merge.connect(this._dryWet, 0, 1); + this._dryWet.connect(this.output); + this._readOnly(['wet']); + }; + Tone.extend(Tone.StereoEffect, Tone.Effect); + /** + * Clean up. + * @returns {Tone.StereoEffect} this + */ + Tone.StereoEffect.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._dryWet.dispose(); + this._dryWet = null; + this._split.dispose(); + this._split = null; + this._merge.dispose(); + this._merge = null; + this.effectSendL = null; + this.effectSendR = null; + this.effectReturnL = null; + this.effectReturnR = null; + this._writable(['wet']); + this.wet = null; + return this; + }; + return Tone.StereoEffect; + }); + Module(function (Tone) { + + /** + * @class Tone.Chorus is a stereo chorus effect composed of + * a left and right delay with a Tone.LFO applied to the delayTime of each channel. + * Inspiration from [Tuna.js](https://github.com/Dinahmoe/tuna/blob/master/tuna.js). + * Read more on the chorus effect on [SoundOnSound](http://www.soundonsound.com/sos/jun04/articles/synthsecrets.htm). + * + * @constructor + * @extends {Tone.StereoEffect} + * @param {Frequency|Object} [frequency] The frequency of the LFO. + * @param {Milliseconds} [delayTime] The delay of the chorus effect in ms. + * @param {NormalRange} [depth] The depth of the chorus. + * @example + * var chorus = new Tone.Chorus(4, 2.5, 0.5); + * var synth = new Tone.PolySynth(4, Tone.MonoSynth).connect(chorus); + * synth.triggerAttackRelease(["C3","E3","G3"], "8n"); + */ + Tone.Chorus = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'delayTime', + 'depth' + ], Tone.Chorus); + Tone.StereoEffect.call(this, options); + /** + * the depth of the chorus + * @type {number} + * @private + */ + this._depth = options.depth; + /** + * the delayTime + * @type {number} + * @private + */ + this._delayTime = options.delayTime / 1000; + /** + * the lfo which controls the delayTime + * @type {Tone.LFO} + * @private + */ + this._lfoL = new Tone.LFO({ + 'frequency': options.frequency, + 'min': 0, + 'max': 1 + }); + /** + * another LFO for the right side with a 180 degree phase diff + * @type {Tone.LFO} + * @private + */ + this._lfoR = new Tone.LFO({ + 'frequency': options.frequency, + 'min': 0, + 'max': 1, + 'phase': 180 + }); + /** + * delay for left + * @type {Tone.Delay} + * @private + */ + this._delayNodeL = new Tone.Delay(); + /** + * delay for right + * @type {Tone.Delay} + * @private + */ + this._delayNodeR = new Tone.Delay(); + /** + * The frequency of the LFO which modulates the delayTime. + * @type {Frequency} + * @signal + */ + this.frequency = this._lfoL.frequency; + //connections + this.effectSendL.chain(this._delayNodeL, this.effectReturnL); + this.effectSendR.chain(this._delayNodeR, this.effectReturnR); + //and pass through to make the detune apparent + this.effectSendL.connect(this.effectReturnL); + this.effectSendR.connect(this.effectReturnR); + //lfo setup + this._lfoL.connect(this._delayNodeL.delayTime); + this._lfoR.connect(this._delayNodeR.delayTime); + //start the lfo + this._lfoL.start(); + this._lfoR.start(); + //have one LFO frequency control the other + this._lfoL.frequency.connect(this._lfoR.frequency); + //set the initial values + this.depth = this._depth; + this.frequency.value = options.frequency; + this.type = options.type; + this._readOnly(['frequency']); + this.spread = options.spread; + }; + Tone.extend(Tone.Chorus, Tone.StereoEffect); + /** + * @static + * @type {Object} + */ + Tone.Chorus.defaults = { + 'frequency': 1.5, + 'delayTime': 3.5, + 'depth': 0.7, + 'type': 'sine', + 'spread': 180 + }; + /** + * The depth of the effect. A depth of 1 makes the delayTime + * modulate between 0 and 2*delayTime (centered around the delayTime). + * @memberOf Tone.Chorus# + * @type {NormalRange} + * @name depth + */ + Object.defineProperty(Tone.Chorus.prototype, 'depth', { + get: function () { + return this._depth; + }, + set: function (depth) { + this._depth = depth; + var deviation = this._delayTime * depth; + this._lfoL.min = Math.max(this._delayTime - deviation, 0); + this._lfoL.max = this._delayTime + deviation; + this._lfoR.min = Math.max(this._delayTime - deviation, 0); + this._lfoR.max = this._delayTime + deviation; + } + }); + /** + * The delayTime in milliseconds of the chorus. A larger delayTime + * will give a more pronounced effect. Nominal range a delayTime + * is between 2 and 20ms. + * @memberOf Tone.Chorus# + * @type {Milliseconds} + * @name delayTime + */ + Object.defineProperty(Tone.Chorus.prototype, 'delayTime', { + get: function () { + return this._delayTime * 1000; + }, + set: function (delayTime) { + this._delayTime = delayTime / 1000; + this.depth = this._depth; + } + }); + /** + * The oscillator type of the LFO. + * @memberOf Tone.Chorus# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.Chorus.prototype, 'type', { + get: function () { + return this._lfoL.type; + }, + set: function (type) { + this._lfoL.type = type; + this._lfoR.type = type; + } + }); + /** + * Amount of stereo spread. When set to 0, both LFO's will be panned centrally. + * When set to 180, LFO's will be panned hard left and right respectively. + * @memberOf Tone.Chorus# + * @type {Degrees} + * @name spread + */ + Object.defineProperty(Tone.Chorus.prototype, 'spread', { + get: function () { + return this._lfoR.phase - this._lfoL.phase; + }, + set: function (spread) { + this._lfoL.phase = 90 - spread / 2; + this._lfoR.phase = spread / 2 + 90; + } + }); + /** + * Clean up. + * @returns {Tone.Chorus} this + */ + Tone.Chorus.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + this._lfoL.dispose(); + this._lfoL = null; + this._lfoR.dispose(); + this._lfoR = null; + this._delayNodeL.dispose(); + this._delayNodeL = null; + this._delayNodeR.dispose(); + this._delayNodeR = null; + this._writable('frequency'); + this.frequency = null; + return this; + }; + return Tone.Chorus; + }); + Module(function (Tone) { + + /** + * @class Tone.Convolver is a wrapper around the Native Web Audio + * [ConvolverNode](http://webaudio.github.io/web-audio-api/#the-convolvernode-interface). + * Convolution is useful for reverb and filter emulation. Read more about convolution reverb on + * [Wikipedia](https://en.wikipedia.org/wiki/Convolution_reverb). + * + * @constructor + * @extends {Tone.Effect} + * @param {string|Tone.Buffer|Object} [url] The URL of the impulse response or the Tone.Buffer + * contianing the impulse response. + * @param {Function=} onload The callback to invoke when the url is loaded. + * @example + * //initializing the convolver with an impulse response + * var convolver = new Tone.Convolver("./path/to/ir.wav").toMaster(); + */ + Tone.Convolver = function () { + var options = Tone.defaults(arguments, [ + 'url', + 'onload' + ], Tone.Convolver); + Tone.Effect.call(this, options); + /** + * convolver node + * @type {ConvolverNode} + * @private + */ + this._convolver = this.context.createConvolver(); + /** + * the convolution buffer + * @type {Tone.Buffer} + * @private + */ + this._buffer = new Tone.Buffer(options.url, function (buffer) { + this._convolver.buffer = buffer.get(); + options.onload(); + }.bind(this)); + this.connectEffect(this._convolver); + }; + Tone.extend(Tone.Convolver, Tone.Effect); + /** + * @static + * @const + * @type {Object} + */ + Tone.Convolver.defaults = { 'onload': Tone.noOp }; + /** + * The convolver's buffer + * @memberOf Tone.Convolver# + * @type {AudioBuffer} + * @name buffer + */ + Object.defineProperty(Tone.Convolver.prototype, 'buffer', { + get: function () { + return this._buffer.get(); + }, + set: function (buffer) { + this._buffer.set(buffer); + this._convolver.buffer = this._buffer.get(); + } + }); + /** + * Load an impulse response url as an audio buffer. + * Decodes the audio asynchronously and invokes + * the callback once the audio buffer loads. + * @param {string} url The url of the buffer to load. + * filetype support depends on the + * browser. + * @param {function=} callback + * @returns {Promise} + */ + Tone.Convolver.prototype.load = function (url, callback) { + return this._buffer.load(url, function (buff) { + this.buffer = buff; + if (callback) { + callback(); + } + }.bind(this)); + }; + /** + * Clean up. + * @returns {Tone.Convolver} this + */ + Tone.Convolver.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._convolver.disconnect(); + this._convolver = null; + this._buffer.dispose(); + this._buffer = null; + return this; + }; + return Tone.Convolver; + }); + Module(function (Tone) { + + /** + * @class Tone.Distortion is a simple distortion effect using Tone.WaveShaper. + * Algorithm from [a stackoverflow answer](http://stackoverflow.com/a/22313408). + * + * @extends {Tone.Effect} + * @constructor + * @param {Number|Object} [distortion] The amount of distortion (nominal range of 0-1) + * @example + * var dist = new Tone.Distortion(0.8).toMaster(); + * var fm = new Tone.SimpleFM().connect(dist); + * //this sounds good on bass notes + * fm.triggerAttackRelease("A1", "8n"); + */ + Tone.Distortion = function () { + var options = Tone.defaults(arguments, ['distortion'], Tone.Distortion); + Tone.Effect.call(this, options); + /** + * @type {Tone.WaveShaper} + * @private + */ + this._shaper = new Tone.WaveShaper(4096); + /** + * holds the distortion amount + * @type {number} + * @private + */ + this._distortion = options.distortion; + this.connectEffect(this._shaper); + this.distortion = options.distortion; + this.oversample = options.oversample; + }; + Tone.extend(Tone.Distortion, Tone.Effect); + /** + * @static + * @const + * @type {Object} + */ + Tone.Distortion.defaults = { + 'distortion': 0.4, + 'oversample': 'none' + }; + /** + * The amount of distortion. + * @memberOf Tone.Distortion# + * @type {NormalRange} + * @name distortion + */ + Object.defineProperty(Tone.Distortion.prototype, 'distortion', { + get: function () { + return this._distortion; + }, + set: function (amount) { + this._distortion = amount; + var k = amount * 100; + var deg = Math.PI / 180; + this._shaper.setMap(function (x) { + if (Math.abs(x) < 0.001) { + //should output 0 when input is 0 + return 0; + } else { + return (3 + k) * x * 20 * deg / (Math.PI + k * Math.abs(x)); + } + }); + } + }); + /** + * The oversampling of the effect. Can either be "none", "2x" or "4x". + * @memberOf Tone.Distortion# + * @type {string} + * @name oversample + */ + Object.defineProperty(Tone.Distortion.prototype, 'oversample', { + get: function () { + return this._shaper.oversample; + }, + set: function (oversampling) { + this._shaper.oversample = oversampling; + } + }); + /** + * Clean up. + * @returns {Tone.Distortion} this + */ + Tone.Distortion.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._shaper.dispose(); + this._shaper = null; + return this; + }; + return Tone.Distortion; + }); + Module(function (Tone) { + + /** + * @class Tone.FeedbackEffect provides a loop between an + * audio source and its own output. This is a base-class + * for feedback effects. + * + * @constructor + * @extends {Tone.Effect} + * @param {NormalRange|Object} [feedback] The initial feedback value. + */ + Tone.FeedbackEffect = function () { + var options = Tone.defaults(arguments, ['feedback'], Tone.FeedbackEffect); + Tone.Effect.call(this, options); + /** + * the gain which controls the feedback + * @type {Tone.Gain} + * @private + */ + this._feedbackGain = new Tone.Gain(options.feedback, Tone.Type.NormalRange); + /** + * The amount of signal which is fed back into the effect input. + * @type {NormalRange} + * @signal + */ + this.feedback = this._feedbackGain.gain; + //the feedback loop + this.effectReturn.chain(this._feedbackGain, this.effectSend); + this._readOnly(['feedback']); + }; + Tone.extend(Tone.FeedbackEffect, Tone.Effect); + /** + * @static + * @type {Object} + */ + Tone.FeedbackEffect.defaults = { 'feedback': 0.125 }; + /** + * Clean up. + * @returns {Tone.FeedbackEffect} this + */ + Tone.FeedbackEffect.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._writable(['feedback']); + this._feedbackGain.dispose(); + this._feedbackGain = null; + this.feedback = null; + return this; + }; + return Tone.FeedbackEffect; + }); + Module(function (Tone) { + + /** + * @class Tone.FeedbackDelay is a DelayNode in which part of output + * signal is fed back into the delay. + * + * @constructor + * @extends {Tone.FeedbackEffect} + * @param {Time|Object} [delayTime] The delay applied to the incoming signal. + * @param {NormalRange=} feedback The amount of the effected signal which + * is fed back through the delay. + * @example + * var feedbackDelay = new Tone.FeedbackDelay("8n", 0.5).toMaster(); + * var tom = new Tone.DrumSynth({ + * "octaves" : 4, + * "pitchDecay" : 0.1 + * }).connect(feedbackDelay); + * tom.triggerAttackRelease("A2","32n"); + */ + Tone.FeedbackDelay = function () { + var options = Tone.defaults(arguments, [ + 'delayTime', + 'feedback' + ], Tone.FeedbackDelay); + Tone.FeedbackEffect.call(this, options); + /** + * the delay node + * @type {Tone.Delay} + * @private + */ + this._delayNode = new Tone.Delay(options.delayTime, options.maxDelay); + /** + * The delayTime of the DelayNode. + * @type {Time} + * @signal + */ + this.delayTime = this._delayNode.delayTime; + // connect it up + this.connectEffect(this._delayNode); + this._readOnly(['delayTime']); + }; + Tone.extend(Tone.FeedbackDelay, Tone.FeedbackEffect); + /** + * The default values. + * @const + * @static + * @type {Object} + */ + Tone.FeedbackDelay.defaults = { + 'delayTime': 0.25, + 'maxDelay': 1 + }; + /** + * clean up + * @returns {Tone.FeedbackDelay} this + */ + Tone.FeedbackDelay.prototype.dispose = function () { + Tone.FeedbackEffect.prototype.dispose.call(this); + this._delayNode.dispose(); + this._delayNode = null; + this._writable(['delayTime']); + this.delayTime = null; + return this; + }; + return Tone.FeedbackDelay; + }); + Module(function (Tone) { + + /** + * an array of comb filter delay values from Freeverb implementation + * @static + * @private + * @type {Array} + */ + var combFilterTunings = [ + 1557 / 44100, + 1617 / 44100, + 1491 / 44100, + 1422 / 44100, + 1277 / 44100, + 1356 / 44100, + 1188 / 44100, + 1116 / 44100 + ]; + /** + * an array of allpass filter frequency values from Freeverb implementation + * @private + * @static + * @type {Array} + */ + var allpassFilterFrequencies = [ + 225, + 556, + 441, + 341 + ]; + /** + * @class Tone.Freeverb is a reverb based on [Freeverb](https://ccrma.stanford.edu/~jos/pasp/Freeverb.html). + * Read more on reverb on [Sound On Sound](https://web.archive.org/web/20160404083902/http://www.soundonsound.com:80/sos/feb01/articles/synthsecrets.asp). + * + * @extends {Tone.Effect} + * @constructor + * @param {NormalRange|Object} [roomSize] Correlated to the decay time. + * @param {Frequency} [dampening] The cutoff frequency of a lowpass filter as part + * of the reverb. + * @example + * var freeverb = new Tone.Freeverb().toMaster(); + * freeverb.dampening.value = 1000; + * //routing synth through the reverb + * var synth = new Tone.AMSynth().connect(freeverb); + */ + Tone.Freeverb = function () { + var options = Tone.defaults(arguments, [ + 'roomSize', + 'dampening' + ], Tone.Freeverb); + Tone.StereoEffect.call(this, options); + /** + * The roomSize value between. A larger roomSize + * will result in a longer decay. + * @type {NormalRange} + * @signal + */ + this.roomSize = new Tone.Signal(options.roomSize, Tone.Type.NormalRange); + /** + * The amount of dampening of the reverberant signal. + * @type {Frequency} + * @signal + */ + this.dampening = new Tone.Signal(options.dampening, Tone.Type.Frequency); + /** + * the comb filters + * @type {Array} + * @private + */ + this._combFilters = []; + /** + * the allpass filters on the left + * @type {Array} + * @private + */ + this._allpassFiltersL = []; + /** + * the allpass filters on the right + * @type {Array} + * @private + */ + this._allpassFiltersR = []; + //make the allpass filters on the right + for (var l = 0; l < allpassFilterFrequencies.length; l++) { + var allpassL = this.context.createBiquadFilter(); + allpassL.type = 'allpass'; + allpassL.frequency.value = allpassFilterFrequencies[l]; + this._allpassFiltersL.push(allpassL); + } + //make the allpass filters on the left + for (var r = 0; r < allpassFilterFrequencies.length; r++) { + var allpassR = this.context.createBiquadFilter(); + allpassR.type = 'allpass'; + allpassR.frequency.value = allpassFilterFrequencies[r]; + this._allpassFiltersR.push(allpassR); + } + //make the comb filters + for (var c = 0; c < combFilterTunings.length; c++) { + var lfpf = new Tone.LowpassCombFilter(combFilterTunings[c]); + if (c < combFilterTunings.length / 2) { + this.effectSendL.chain(lfpf, this._allpassFiltersL[0]); + } else { + this.effectSendR.chain(lfpf, this._allpassFiltersR[0]); + } + this.roomSize.connect(lfpf.resonance); + this.dampening.connect(lfpf.dampening); + this._combFilters.push(lfpf); + } + //chain the allpass filters togetehr + Tone.connectSeries.apply(Tone, this._allpassFiltersL); + Tone.connectSeries.apply(Tone, this._allpassFiltersR); + this._allpassFiltersL[this._allpassFiltersL.length - 1].connect(this.effectReturnL); + this._allpassFiltersR[this._allpassFiltersR.length - 1].connect(this.effectReturnR); + this._readOnly([ + 'roomSize', + 'dampening' + ]); + }; + Tone.extend(Tone.Freeverb, Tone.StereoEffect); + /** + * @static + * @type {Object} + */ + Tone.Freeverb.defaults = { + 'roomSize': 0.7, + 'dampening': 3000 + }; + /** + * Clean up. + * @returns {Tone.Freeverb} this + */ + Tone.Freeverb.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + for (var al = 0; al < this._allpassFiltersL.length; al++) { + this._allpassFiltersL[al].disconnect(); + this._allpassFiltersL[al] = null; + } + this._allpassFiltersL = null; + for (var ar = 0; ar < this._allpassFiltersR.length; ar++) { + this._allpassFiltersR[ar].disconnect(); + this._allpassFiltersR[ar] = null; + } + this._allpassFiltersR = null; + for (var cf = 0; cf < this._combFilters.length; cf++) { + this._combFilters[cf].dispose(); + this._combFilters[cf] = null; + } + this._combFilters = null; + this._writable([ + 'roomSize', + 'dampening' + ]); + this.roomSize.dispose(); + this.roomSize = null; + this.dampening.dispose(); + this.dampening = null; + return this; + }; + return Tone.Freeverb; + }); + Module(function (Tone) { + + /** + * an array of the comb filter delay time values + * @private + * @static + * @type {Array} + */ + var combFilterDelayTimes = [ + 1687 / 25000, + 1601 / 25000, + 2053 / 25000, + 2251 / 25000 + ]; + /** + * the resonances of each of the comb filters + * @private + * @static + * @type {Array} + */ + var combFilterResonances = [ + 0.773, + 0.802, + 0.753, + 0.733 + ]; + /** + * the allpass filter frequencies + * @private + * @static + * @type {Array} + */ + var allpassFilterFreqs = [ + 347, + 113, + 37 + ]; + /** + * @class Tone.JCReverb is a simple [Schroeder Reverberator](https://ccrma.stanford.edu/~jos/pasp/Schroeder_Reverberators.html) + * tuned by John Chowning in 1970. + * It is made up of three allpass filters and four Tone.FeedbackCombFilter. + * + * + * @extends {Tone.Effect} + * @constructor + * @param {NormalRange|Object} [roomSize] Coorelates to the decay time. + * @example + * var reverb = new Tone.JCReverb(0.4).connect(Tone.Master); + * var delay = new Tone.FeedbackDelay(0.5); + * //connecting the synth to reverb through delay + * var synth = new Tone.DuoSynth().chain(delay, reverb); + * synth.triggerAttackRelease("A4","8n"); + */ + Tone.JCReverb = function () { + var options = Tone.defaults(arguments, ['roomSize'], Tone.JCReverb); + Tone.StereoEffect.call(this, options); + /** + * room size control values between [0,1] + * @type {NormalRange} + * @signal + */ + this.roomSize = new Tone.Signal(options.roomSize, Tone.Type.NormalRange); + /** + * scale the room size + * @type {Tone.Scale} + * @private + */ + this._scaleRoomSize = new Tone.Scale(-0.733, 0.197); + /** + * a series of allpass filters + * @type {Array} + * @private + */ + this._allpassFilters = []; + /** + * parallel feedback comb filters + * @type {Array} + * @private + */ + this._feedbackCombFilters = []; + //make the allpass filters + for (var af = 0; af < allpassFilterFreqs.length; af++) { + var allpass = this.context.createBiquadFilter(); + allpass.type = 'allpass'; + allpass.frequency.value = allpassFilterFreqs[af]; + this._allpassFilters.push(allpass); + } + //and the comb filters + for (var cf = 0; cf < combFilterDelayTimes.length; cf++) { + var fbcf = new Tone.FeedbackCombFilter(combFilterDelayTimes[cf], 0.1); + this._scaleRoomSize.connect(fbcf.resonance); + fbcf.resonance.value = combFilterResonances[cf]; + this._allpassFilters[this._allpassFilters.length - 1].connect(fbcf); + if (cf < combFilterDelayTimes.length / 2) { + fbcf.connect(this.effectReturnL); + } else { + fbcf.connect(this.effectReturnR); + } + this._feedbackCombFilters.push(fbcf); + } + //chain the allpass filters together + this.roomSize.connect(this._scaleRoomSize); + Tone.connectSeries.apply(Tone, this._allpassFilters); + this.effectSendL.connect(this._allpassFilters[0]); + this.effectSendR.connect(this._allpassFilters[0]); + this._readOnly(['roomSize']); + }; + Tone.extend(Tone.JCReverb, Tone.StereoEffect); + /** + * the default values + * @static + * @const + * @type {Object} + */ + Tone.JCReverb.defaults = { 'roomSize': 0.5 }; + /** + * Clean up. + * @returns {Tone.JCReverb} this + */ + Tone.JCReverb.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + for (var apf = 0; apf < this._allpassFilters.length; apf++) { + this._allpassFilters[apf].disconnect(); + this._allpassFilters[apf] = null; + } + this._allpassFilters = null; + for (var fbcf = 0; fbcf < this._feedbackCombFilters.length; fbcf++) { + this._feedbackCombFilters[fbcf].dispose(); + this._feedbackCombFilters[fbcf] = null; + } + this._feedbackCombFilters = null; + this._writable(['roomSize']); + this.roomSize.dispose(); + this.roomSize = null; + this._scaleRoomSize.dispose(); + this._scaleRoomSize = null; + return this; + }; + return Tone.JCReverb; + }); + Module(function (Tone) { + + /** + * @class Mid/Side processing separates the the 'mid' signal + * (which comes out of both the left and the right channel) + * and the 'side' (which only comes out of the the side channels) + * and effects them separately before being recombined. + * Applies a Mid/Side seperation and recombination. + * Algorithm found in [kvraudio forums](http://www.kvraudio.com/forum/viewtopic.php?t=212587). + * <br><br> + * This is a base-class for Mid/Side Effects. + * + * @extends {Tone.Effect} + * @constructor + */ + Tone.MidSideEffect = function () { + Tone.Effect.apply(this, arguments); + /** + * The mid/side split + * @type {Tone.MidSideSplit} + * @private + */ + this._midSideSplit = new Tone.MidSideSplit(); + /** + * The mid/side merge + * @type {Tone.MidSideMerge} + * @private + */ + this._midSideMerge = new Tone.MidSideMerge(); + /** + * The mid send. Connect to mid processing + * @type {Tone} + * @private + */ + this.midSend = this._midSideSplit.mid; + /** + * The side send. Connect to side processing + * @type {Tone} + * @private + */ + this.sideSend = this._midSideSplit.side; + /** + * The mid return connection + * @type {GainNode} + * @private + */ + this.midReturn = this._midSideMerge.mid; + /** + * The side return connection + * @type {GainNode} + * @private + */ + this.sideReturn = this._midSideMerge.side; + //the connections + this.effectSend.connect(this._midSideSplit); + this._midSideMerge.connect(this.effectReturn); + }; + Tone.extend(Tone.MidSideEffect, Tone.Effect); + /** + * Clean up. + * @returns {Tone.MidSideEffect} this + */ + Tone.MidSideEffect.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._midSideSplit.dispose(); + this._midSideSplit = null; + this._midSideMerge.dispose(); + this._midSideMerge = null; + this.midSend = null; + this.sideSend = null; + this.midReturn = null; + this.sideReturn = null; + return this; + }; + return Tone.MidSideEffect; + }); + Module(function (Tone) { + + /** + * @class Tone.Phaser is a phaser effect. Phasers work by changing the phase + * of different frequency components of an incoming signal. Read more on + * [Wikipedia](https://en.wikipedia.org/wiki/Phaser_(effect)). + * Inspiration for this phaser comes from [Tuna.js](https://github.com/Dinahmoe/tuna/). + * + * @extends {Tone.StereoEffect} + * @constructor + * @param {Frequency|Object} [frequency] The speed of the phasing. + * @param {number} [octaves] The octaves of the effect. + * @param {Frequency} [baseFrequency] The base frequency of the filters. + * @example + * var phaser = new Tone.Phaser({ + * "frequency" : 15, + * "octaves" : 5, + * "baseFrequency" : 1000 + * }).toMaster(); + * var synth = new Tone.FMSynth().connect(phaser); + * synth.triggerAttackRelease("E3", "2n"); + */ + Tone.Phaser = function () { + //set the defaults + var options = Tone.defaults(arguments, [ + 'frequency', + 'octaves', + 'baseFrequency' + ], Tone.Phaser); + Tone.StereoEffect.call(this, options); + /** + * the lfo which controls the frequency on the left side + * @type {Tone.LFO} + * @private + */ + this._lfoL = new Tone.LFO(options.frequency, 0, 1); + /** + * the lfo which controls the frequency on the right side + * @type {Tone.LFO} + * @private + */ + this._lfoR = new Tone.LFO(options.frequency, 0, 1); + this._lfoR.phase = 180; + /** + * the base modulation frequency + * @type {number} + * @private + */ + this._baseFrequency = options.baseFrequency; + /** + * the octaves of the phasing + * @type {number} + * @private + */ + this._octaves = options.octaves; + /** + * The quality factor of the filters + * @type {Positive} + * @signal + */ + this.Q = new Tone.Signal(options.Q, Tone.Type.Positive); + /** + * the array of filters for the left side + * @type {Array} + * @private + */ + this._filtersL = this._makeFilters(options.stages, this._lfoL, this.Q); + /** + * the array of filters for the left side + * @type {Array} + * @private + */ + this._filtersR = this._makeFilters(options.stages, this._lfoR, this.Q); + /** + * the frequency of the effect + * @type {Tone.Signal} + */ + this.frequency = this._lfoL.frequency; + this.frequency.value = options.frequency; + //connect them up + this.effectSendL.connect(this._filtersL[0]); + this.effectSendR.connect(this._filtersR[0]); + this._filtersL[options.stages - 1].connect(this.effectReturnL); + this._filtersR[options.stages - 1].connect(this.effectReturnR); + //control the frequency with one LFO + this._lfoL.frequency.connect(this._lfoR.frequency); + //set the options + this.baseFrequency = options.baseFrequency; + this.octaves = options.octaves; + //start the lfo + this._lfoL.start(); + this._lfoR.start(); + this._readOnly([ + 'frequency', + 'Q' + ]); + }; + Tone.extend(Tone.Phaser, Tone.StereoEffect); + /** + * defaults + * @static + * @type {object} + */ + Tone.Phaser.defaults = { + 'frequency': 0.5, + 'octaves': 3, + 'stages': 10, + 'Q': 10, + 'baseFrequency': 350 + }; + /** + * @param {number} stages + * @returns {Array} the number of filters all connected together + * @private + */ + Tone.Phaser.prototype._makeFilters = function (stages, connectToFreq, Q) { + var filters = new Array(stages); + //make all the filters + for (var i = 0; i < stages; i++) { + var filter = this.context.createBiquadFilter(); + filter.type = 'allpass'; + Q.connect(filter.Q); + connectToFreq.connect(filter.frequency); + filters[i] = filter; + } + Tone.connectSeries.apply(Tone, filters); + return filters; + }; + /** + * The number of octaves the phase goes above + * the baseFrequency + * @memberOf Tone.Phaser# + * @type {Positive} + * @name octaves + */ + Object.defineProperty(Tone.Phaser.prototype, 'octaves', { + get: function () { + return this._octaves; + }, + set: function (octaves) { + this._octaves = octaves; + var max = this._baseFrequency * Math.pow(2, octaves); + this._lfoL.max = max; + this._lfoR.max = max; + } + }); + /** + * The the base frequency of the filters. + * @memberOf Tone.Phaser# + * @type {number} + * @name baseFrequency + */ + Object.defineProperty(Tone.Phaser.prototype, 'baseFrequency', { + get: function () { + return this._baseFrequency; + }, + set: function (freq) { + this._baseFrequency = freq; + this._lfoL.min = freq; + this._lfoR.min = freq; + this.octaves = this._octaves; + } + }); + /** + * clean up + * @returns {Tone.Phaser} this + */ + Tone.Phaser.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'Q' + ]); + this.Q.dispose(); + this.Q = null; + this._lfoL.dispose(); + this._lfoL = null; + this._lfoR.dispose(); + this._lfoR = null; + for (var i = 0; i < this._filtersL.length; i++) { + this._filtersL[i].disconnect(); + this._filtersL[i] = null; + } + this._filtersL = null; + for (var j = 0; j < this._filtersR.length; j++) { + this._filtersR[j].disconnect(); + this._filtersR[j] = null; + } + this._filtersR = null; + this.frequency = null; + return this; + }; + return Tone.Phaser; + }); + Module(function (Tone) { + + /** + * @class Just like a stereo feedback effect, but the feedback is routed from left to right + * and right to left instead of on the same channel. + * + * @constructor + * @extends {Tone.StereoEffect} + */ + Tone.StereoXFeedbackEffect = function () { + var options = Tone.defaults(arguments, ['feedback'], Tone.FeedbackEffect); + Tone.StereoEffect.call(this, options); + /** + * The amount of feedback from the output + * back into the input of the effect (routed + * across left and right channels). + * @type {NormalRange} + * @signal + */ + this.feedback = new Tone.Signal(options.feedback, Tone.Type.NormalRange); + /** + * the left side feeback + * @type {Tone.Gain} + * @private + */ + this._feedbackLR = new Tone.Gain(); + /** + * the right side feeback + * @type {Tone.Gain} + * @private + */ + this._feedbackRL = new Tone.Gain(); + //connect it up + this.effectReturnL.chain(this._feedbackLR, this.effectSendR); + this.effectReturnR.chain(this._feedbackRL, this.effectSendL); + this.feedback.fan(this._feedbackLR.gain, this._feedbackRL.gain); + this._readOnly(['feedback']); + }; + Tone.extend(Tone.StereoXFeedbackEffect, Tone.StereoEffect); + /** + * clean up + * @returns {Tone.StereoXFeedbackEffect} this + */ + Tone.StereoXFeedbackEffect.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + this._writable(['feedback']); + this.feedback.dispose(); + this.feedback = null; + this._feedbackLR.dispose(); + this._feedbackLR = null; + this._feedbackRL.dispose(); + this._feedbackRL = null; + return this; + }; + return Tone.StereoXFeedbackEffect; + }); + Module(function (Tone) { + + /** + * @class Tone.PingPongDelay is a feedback delay effect where the echo is heard + * first in one channel and next in the opposite channel. In a stereo + * system these are the right and left channels. + * PingPongDelay in more simplified terms is two Tone.FeedbackDelays + * with independent delay values. Each delay is routed to one channel + * (left or right), and the channel triggered second will always + * trigger at the same interval after the first. + * + * @constructor + * @extends {Tone.StereoXFeedbackEffect} + * @param {Time|Object} [delayTime] The delayTime between consecutive echos. + * @param {NormalRange=} feedback The amount of the effected signal which + * is fed back through the delay. + * @example + * var pingPong = new Tone.PingPongDelay("4n", 0.2).toMaster(); + * var drum = new Tone.DrumSynth().connect(pingPong); + * drum.triggerAttackRelease("C4", "32n"); + */ + Tone.PingPongDelay = function () { + var options = Tone.defaults(arguments, [ + 'delayTime', + 'feedback' + ], Tone.PingPongDelay); + Tone.StereoXFeedbackEffect.call(this, options); + /** + * the delay node on the left side + * @type {Tone.Delay} + * @private + */ + this._leftDelay = new Tone.Delay(0, options.maxDelayTime); + /** + * the delay node on the right side + * @type {Tone.Delay} + * @private + */ + this._rightDelay = new Tone.Delay(0, options.maxDelayTime); + /** + * the predelay on the right side + * @type {Tone.Delay} + * @private + */ + this._rightPreDelay = new Tone.Delay(0, options.maxDelayTime); + /** + * the delay time signal + * @type {Time} + * @signal + */ + this.delayTime = new Tone.Signal(options.delayTime, Tone.Type.Time); + //connect it up + this.effectSendL.chain(this._leftDelay, this.effectReturnL); + this.effectSendR.chain(this._rightPreDelay, this._rightDelay, this.effectReturnR); + this.delayTime.fan(this._leftDelay.delayTime, this._rightDelay.delayTime, this._rightPreDelay.delayTime); + //rearranged the feedback to be after the rightPreDelay + this._feedbackLR.disconnect(); + this._feedbackLR.connect(this._rightDelay); + this._readOnly(['delayTime']); + }; + Tone.extend(Tone.PingPongDelay, Tone.StereoXFeedbackEffect); + /** + * @static + * @type {Object} + */ + Tone.PingPongDelay.defaults = { + 'delayTime': 0.25, + 'maxDelayTime': 1 + }; + /** + * Clean up. + * @returns {Tone.PingPongDelay} this + */ + Tone.PingPongDelay.prototype.dispose = function () { + Tone.StereoXFeedbackEffect.prototype.dispose.call(this); + this._leftDelay.dispose(); + this._leftDelay = null; + this._rightDelay.dispose(); + this._rightDelay = null; + this._rightPreDelay.dispose(); + this._rightPreDelay = null; + this._writable(['delayTime']); + this.delayTime.dispose(); + this.delayTime = null; + return this; + }; + return Tone.PingPongDelay; + }); + Module(function (Tone) { + + /** + * @class Tone.PitchShift does near-realtime pitch shifting to the incoming signal. + * The effect is achieved by speeding up or slowing down the delayTime + * of a DelayNode using a sawtooth wave. + * Algorithm found in [this pdf](http://dsp-book.narod.ru/soundproc.pdf). + * Additional reference by [Miller Pucket](http://msp.ucsd.edu/techniques/v0.11/book-html/node115.html). + * + * @extends {Tone.FeedbackEffect} + * @param {Interval=} pitch The interval to transpose the incoming signal by. + */ + Tone.PitchShift = function () { + var options = Tone.defaults(arguments, ['pitch'], Tone.PitchShift); + Tone.FeedbackEffect.call(this, options); + /** + * The pitch signal + * @type {Tone.Signal} + * @private + */ + this._frequency = new Tone.Signal(0); + /** + * Uses two DelayNodes to cover up the jump in + * the sawtooth wave. + * @type {DelayNode} + * @private + */ + this._delayA = new Tone.Delay(0, 1); + /** + * The first LFO. + * @type {Tone.LFO} + * @private + */ + this._lfoA = new Tone.LFO({ + 'min': 0, + 'max': 0.1, + 'type': 'sawtooth' + }).connect(this._delayA.delayTime); + /** + * The second DelayNode + * @type {DelayNode} + * @private + */ + this._delayB = new Tone.Delay(0, 1); + /** + * The first LFO. + * @type {Tone.LFO} + * @private + */ + this._lfoB = new Tone.LFO({ + 'min': 0, + 'max': 0.1, + 'type': 'sawtooth', + 'phase': 180 + }).connect(this._delayB.delayTime); + /** + * Crossfade quickly between the two delay lines + * to cover up the jump in the sawtooth wave + * @type {Tone.CrossFade} + * @private + */ + this._crossFade = new Tone.CrossFade(); + /** + * LFO which alternates between the two + * delay lines to cover up the disparity in the + * sawtooth wave. + * @type {Tone.LFO} + * @private + */ + this._crossFadeLFO = new Tone.LFO({ + 'min': 0, + 'max': 1, + 'type': 'triangle', + 'phase': 90 + }).connect(this._crossFade.fade); + /** + * The delay node + * @type {Tone.Delay} + * @private + */ + this._feedbackDelay = new Tone.Delay(options.delayTime); + /** + * The amount of delay on the input signal + * @type {Time} + * @signal + */ + this.delayTime = this._feedbackDelay.delayTime; + this._readOnly('delayTime'); + /** + * Hold the current pitch + * @type {Number} + * @private + */ + this._pitch = options.pitch; + /** + * Hold the current windowSize + * @type {Number} + * @private + */ + this._windowSize = options.windowSize; + //connect the two delay lines up + this._delayA.connect(this._crossFade.a); + this._delayB.connect(this._crossFade.b); + //connect the frequency + this._frequency.fan(this._lfoA.frequency, this._lfoB.frequency, this._crossFadeLFO.frequency); + //route the input + this.effectSend.fan(this._delayA, this._delayB); + this._crossFade.chain(this._feedbackDelay, this.effectReturn); + //start the LFOs at the same time + var now = this.now(); + this._lfoA.start(now); + this._lfoB.start(now); + this._crossFadeLFO.start(now); + //set the initial value + this.windowSize = this._windowSize; + }; + Tone.extend(Tone.PitchShift, Tone.FeedbackEffect); + /** + * default values + * @static + * @type {Object} + * @const + */ + Tone.PitchShift.defaults = { + 'pitch': 0, + 'windowSize': 0.1, + 'delayTime': 0, + 'feedback': 0 + }; + /** + * Repitch the incoming signal by some interval (measured + * in semi-tones). + * @memberOf Tone.PitchShift# + * @type {Interval} + * @name pitch + * @example + * pitchShift.pitch = -12; //down one octave + * pitchShift.pitch = 7; //up a fifth + */ + Object.defineProperty(Tone.PitchShift.prototype, 'pitch', { + get: function () { + return this._pitch; + }, + set: function (interval) { + this._pitch = interval; + var factor = 0; + if (interval < 0) { + this._lfoA.min = 0; + this._lfoA.max = this._windowSize; + this._lfoB.min = 0; + this._lfoB.max = this._windowSize; + factor = Tone.intervalToFrequencyRatio(interval - 1) + 1; + } else { + this._lfoA.min = this._windowSize; + this._lfoA.max = 0; + this._lfoB.min = this._windowSize; + this._lfoB.max = 0; + factor = Tone.intervalToFrequencyRatio(interval) - 1; + } + this._frequency.value = factor * (1.2 / this._windowSize); + } + }); + /** + * The window size corresponds roughly to the sample length in a looping sampler. + * Smaller values are desirable for a less noticeable delay time of the pitch shifted + * signal, but larger values will result in smoother pitch shifting for larger intervals. + * A nominal range of 0.03 to 0.1 is recommended. + * @memberOf Tone.PitchShift# + * @type {Time} + * @name windowSize + * @example + * pitchShift.windowSize = 0.1; + */ + Object.defineProperty(Tone.PitchShift.prototype, 'windowSize', { + get: function () { + return this._windowSize; + }, + set: function (size) { + this._windowSize = this.toSeconds(size); + this.pitch = this._pitch; + } + }); + /** + * Clean up. + * @return {Tone.PitchShift} this + */ + Tone.PitchShift.prototype.dispose = function () { + Tone.FeedbackEffect.prototype.dispose.call(this); + this._frequency.dispose(); + this._frequency = null; + this._delayA.disconnect(); + this._delayA = null; + this._delayB.disconnect(); + this._delayB = null; + this._lfoA.dispose(); + this._lfoA = null; + this._lfoB.dispose(); + this._lfoB = null; + this._crossFade.dispose(); + this._crossFade = null; + this._crossFadeLFO.dispose(); + this._crossFadeLFO = null; + this._writable('delayTime'); + this._feedbackDelay.dispose(); + this._feedbackDelay = null; + this.delayTime = null; + return this; + }; + return Tone.PitchShift; + }); + Module(function (Tone) { + /** + * @class Wrapper around the native BufferSourceNode. + * @extends {Tone.AudioNode} + * @param {AudioBuffer|Tone.Buffer} buffer The buffer to play + * @param {Function} onload The callback to invoke when the + * buffer is done playing. + */ + Tone.BufferSource = function () { + var options = Tone.defaults(arguments, [ + 'buffer', + 'onload' + ], Tone.BufferSource); + Tone.AudioNode.call(this, options); + /** + * The callback to invoke after the + * buffer source is done playing. + * @type {Function} + */ + this.onended = options.onended; + /** + * The time that the buffer was started. + * @type {Number} + * @private + */ + this._startTime = -1; + /** + * An additional flag if the actual BufferSourceNode + * has been started. b/c stopping an unstarted buffer + * will throw it into an invalid state + * @type {Boolean} + * @private + */ + this._sourceStarted = false; + /** + * Flag if the source has already been stopped + * @type {Boolean} + * @private + */ + this._sourceStopped = false; + /** + * The time that the buffer is scheduled to stop. + * @type {Number} + * @private + */ + this._stopTime = -1; + /** + * The gain node which envelopes the BufferSource + * @type {Tone.Gain} + * @private + */ + this._gainNode = this.output = new Tone.Gain(); + /** + * The buffer source + * @type {AudioBufferSourceNode} + * @private + */ + this._source = this.context.createBufferSource(); + this._source.connect(this._gainNode); + this._source.onended = this._onended.bind(this); + /** + * The private buffer instance + * @type {Tone.Buffer} + * @private + */ + this._buffer = new Tone.Buffer(options.buffer, options.onload); + /** + * The playbackRate of the buffer + * @type {Positive} + * @signal + */ + this.playbackRate = new Tone.Param(this._source.playbackRate, Tone.Type.Positive); + /** + * The fadeIn time of the amplitude envelope. + * @type {Time} + */ + this.fadeIn = options.fadeIn; + /** + * The fadeOut time of the amplitude envelope. + * @type {Time} + */ + this.fadeOut = options.fadeOut; + /** + * The curve applied to the fades, either "linear" or "exponential" + * @type {String} + */ + this.curve = options.curve; + /** + * The value that the buffer ramps to + * @type {Gain} + * @private + */ + this._gain = 1; + /** + * The onended timeout + * @type {Number} + * @private + */ + this._onendedTimeout = -1; + //set some values initially + this.loop = options.loop; + this.loopStart = options.loopStart; + this.loopEnd = options.loopEnd; + this.playbackRate.value = options.playbackRate; + }; + Tone.extend(Tone.BufferSource, Tone.AudioNode); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.BufferSource.defaults = { + 'onended': Tone.noOp, + 'onload': Tone.noOp, + 'loop': false, + 'loopStart': 0, + 'loopEnd': 0, + 'fadeIn': 0, + 'fadeOut': 0, + 'curve': 'linear', + 'playbackRate': 1 + }; + /** + * Returns the playback state of the source, either "started" or "stopped". + * @type {Tone.State} + * @readOnly + * @memberOf Tone.BufferSource# + * @name state + */ + Object.defineProperty(Tone.BufferSource.prototype, 'state', { + get: function () { + return this.getStateAtTime(this.now()); + } + }); + /** + * Get the playback state at the given time + * @param {Time} time The time to test the state at + * @return {Tone.State} The playback state. + */ + Tone.BufferSource.prototype.getStateAtTime = function (time) { + time = this.toSeconds(time); + if (this._startTime !== -1 && time >= this._startTime && !this._sourceStopped) { + return Tone.State.Started; + } else { + return Tone.State.Stopped; + } + }; + /** + * Start the buffer + * @param {Time} [startTime=now] When the player should start. + * @param {Time} [offset=0] The offset from the beginning of the sample + * to start at. + * @param {Time=} duration How long the sample should play. If no duration + * is given, it will default to the full length + * of the sample (minus any offset) + * @param {Gain} [gain=1] The gain to play the buffer back at. + * @param {Time=} fadeInTime The optional fadeIn ramp time. + * @return {Tone.BufferSource} this + */ + Tone.BufferSource.prototype.start = function (time, offset, duration, gain, fadeInTime) { + if (this._startTime !== -1) { + throw new Error('Tone.BufferSource can only be started once.'); + } + if (!this.buffer.loaded) { + throw new Error('Tone.BufferSource: buffer is either not set or not loaded.'); + } + time = this.toSeconds(time); + //if it's a loop the default offset is the loopstart point + if (this.loop) { + offset = Tone.defaultArg(offset, this.loopStart); + } else { + //otherwise the default offset is 0 + offset = Tone.defaultArg(offset, 0); + } + offset = this.toSeconds(offset); + gain = Tone.defaultArg(gain, 1); + this._gain = gain; + fadeInTime = this.toSeconds(Tone.defaultArg(fadeInTime, this.fadeIn)); + this.fadeIn = fadeInTime; + if (fadeInTime > 0) { + this._gainNode.gain.setValueAtTime(0, time); + if (this.curve === 'linear') { + this._gainNode.gain.linearRampToValueAtTime(this._gain, time + fadeInTime); + } else { + this._gainNode.gain.exponentialApproachValueAtTime(this._gain, time, fadeInTime); + } + } else { + this._gainNode.gain.setValueAtTime(gain, time); + } + this._startTime = time; + var computedDur = this.toSeconds(Tone.defaultArg(duration, this.buffer.duration - offset % this.buffer.duration)); + computedDur = Math.max(computedDur, 0); + if (Tone.isDefined(duration)) { + //clip the duration when not looping + if (!this.loop) { + computedDur = Math.min(computedDur, this.buffer.duration - offset % this.buffer.duration); + } + this.stop(time + computedDur, this.fadeOut); + } + //start the buffer source + if (this.loop) { + //modify the offset if it's greater than the loop time + var loopEnd = this.loopEnd || this.buffer.duration; + var loopStart = this.loopStart; + var loopDuration = loopEnd - loopStart; + //move the offset back + if (offset >= loopEnd) { + offset = (offset - loopStart) % loopDuration + loopStart; + } + } + this._source.buffer = this.buffer.get(); + this._source.loopEnd = this.loopEnd || this.buffer.duration; + if (offset < this.buffer.duration) { + this._sourceStarted = true; + this._source.start(time, offset); + } + return this; + }; + /** + * Stop the buffer. Optionally add a ramp time to fade the + * buffer out. + * @param {Time=} time The time the buffer should stop. + * @param {Time=} fadeOutTime How long the gain should fade out for + * @return {Tone.BufferSource} this + */ + Tone.BufferSource.prototype.stop = function (time, fadeOutTime) { + if (!this.buffer.loaded) { + throw new Error('Tone.BufferSource: buffer is either not set or not loaded.'); + } + if (this._sourceStopped) { + return; + } + time = this.toSeconds(time); + //if the event has already been scheduled, clear it + if (this._stopTime !== -1) { + this.cancelStop(); + } + //stop if it's schedule before the start time + if (time <= this._startTime) { + this._gainNode.gain.cancelScheduledValues(time); + this._gainNode.gain.value = 0; + return this; + } + time = Math.max(this._startTime + this.fadeIn + this.sampleTime, time); + //cancel the previous curve + this._gainNode.gain.cancelScheduledValues(time); + this._stopTime = time; + //the fadeOut time + fadeOutTime = this.toSeconds(Tone.defaultArg(fadeOutTime, this.fadeOut)); + var heldDuration = time - this._startTime - this.fadeIn - this.sampleTime; + if (!this.loop) { + //make sure the fade does not go beyond the length of the buffer + heldDuration = Math.min(heldDuration, this.buffer.duration); + } + fadeOutTime = Math.min(heldDuration, fadeOutTime); + var startFade = time - fadeOutTime; + if (fadeOutTime > this.sampleTime) { + this._gainNode.gain.setValueAtTime(this._gain, startFade); + if (this.curve === 'linear') { + this._gainNode.gain.linearRampToValueAtTime(0, time); + } else { + this._gainNode.gain.exponentialApproachValueAtTime(0, startFade, fadeOutTime); + } + } else { + this._gainNode.gain.setValueAtTime(0, time); + } + Tone.context.clearTimeout(this._onendedTimeout); + this._onendedTimeout = Tone.context.setTimeout(this._onended.bind(this), this._stopTime - this.now()); + return this; + }; + /** + * Cancel a scheduled stop event + * @return {Tone.BufferSource} this + */ + Tone.BufferSource.prototype.cancelStop = function () { + if (this._startTime !== -1 && !this._sourceStopped) { + //cancel the stop envelope + var fadeInTime = this.toSeconds(this.fadeIn); + this._gainNode.gain.cancelScheduledValues(this._startTime + fadeInTime + this.sampleTime); + this._gainNode.gain.setValueAtTime(1, Math.max(this.now(), this._startTime + fadeInTime + this.sampleTime)); + this.context.clearTimeout(this._onendedTimeout); + this._stopTime = -1; + } + return this; + }; + /** + * Internal callback when the buffer is ended. + * Invokes `onended` and disposes the node. + * @private + */ + Tone.BufferSource.prototype._onended = function () { + if (!this._sourceStopped) { + this._sourceStopped = true; + //allow additional time for the exponential curve to fully decay + var additionalTail = this.curve === 'exponential' ? this.fadeOut * 2 : 0; + if (this._sourceStarted && this._stopTime !== -1) { + this._source.stop(this._stopTime + additionalTail); + } + this.onended(this); + } + }; + /** + * If loop is true, the loop will start at this position. + * @memberOf Tone.BufferSource# + * @type {Time} + * @name loopStart + */ + Object.defineProperty(Tone.BufferSource.prototype, 'loopStart', { + get: function () { + return this._source.loopStart; + }, + set: function (loopStart) { + this._source.loopStart = this.toSeconds(loopStart); + } + }); + /** + * If loop is true, the loop will end at this position. + * @memberOf Tone.BufferSource# + * @type {Time} + * @name loopEnd + */ + Object.defineProperty(Tone.BufferSource.prototype, 'loopEnd', { + get: function () { + return this._source.loopEnd; + }, + set: function (loopEnd) { + this._source.loopEnd = this.toSeconds(loopEnd); + } + }); + /** + * The audio buffer belonging to the player. + * @memberOf Tone.BufferSource# + * @type {Tone.Buffer} + * @name buffer + */ + Object.defineProperty(Tone.BufferSource.prototype, 'buffer', { + get: function () { + return this._buffer; + }, + set: function (buffer) { + this._buffer.set(buffer); + } + }); + /** + * If the buffer should loop once it's over. + * @memberOf Tone.BufferSource# + * @type {Boolean} + * @name loop + */ + Object.defineProperty(Tone.BufferSource.prototype, 'loop', { + get: function () { + return this._source.loop; + }, + set: function (loop) { + this._source.loop = loop; + this.cancelStop(); + } + }); + /** + * Clean up. + * @return {Tone.BufferSource} this + */ + Tone.BufferSource.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this.onended = null; + this._source.onended = null; + this._source.disconnect(); + this._source = null; + this._gainNode.dispose(); + this._gainNode = null; + this._buffer.dispose(); + this._buffer = null; + this._startTime = -1; + this.playbackRate = null; + Tone.context.clearTimeout(this._onendedTimeout); + return this; + }; + return Tone.BufferSource; + }); + Module(function (Tone) { + + /** + * @class Tone.Noise is a noise generator. It uses looped noise buffers to save on performance. + * Tone.Noise supports the noise types: "pink", "white", and "brown". Read more about + * colors of noise on [Wikipedia](https://en.wikipedia.org/wiki/Colors_of_noise). + * + * @constructor + * @extends {Tone.Source} + * @param {string} type the noise type (white|pink|brown) + * @example + * //initialize the noise and start + * var noise = new Tone.Noise("pink").start(); + * + * //make an autofilter to shape the noise + * var autoFilter = new Tone.AutoFilter({ + * "frequency" : "8m", + * "min" : 800, + * "max" : 15000 + * }).connect(Tone.Master); + * + * //connect the noise + * noise.connect(autoFilter); + * //start the autofilter LFO + * autoFilter.start() + */ + Tone.Noise = function () { + var options = Tone.defaults(arguments, ['type'], Tone.Noise); + Tone.Source.call(this, options); + /** + * @private + * @type {AudioBufferSourceNode} + */ + this._source = null; + /** + * the buffer + * @private + * @type {AudioBuffer} + */ + this._type = options.type; + /** + * The playback rate of the noise. Affects + * the "frequency" of the noise. + * @type {Positive} + * @signal + */ + this._playbackRate = options.playbackRate; + }; + Tone.extend(Tone.Noise, Tone.Source); + /** + * the default parameters + * + * @static + * @const + * @type {Object} + */ + Tone.Noise.defaults = { + 'type': 'white', + 'playbackRate': 1 + }; + /** + * The type of the noise. Can be "white", "brown", or "pink". + * @memberOf Tone.Noise# + * @type {string} + * @name type + * @example + * noise.type = "white"; + */ + Object.defineProperty(Tone.Noise.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + if (this._type !== type) { + if (type in _noiseBuffers) { + this._type = type; + //if it's playing, stop and restart it + if (this.state === Tone.State.Started) { + var now = this.now(); + this._stop(now); + this._start(now); + } + } else { + throw new TypeError('Tone.Noise: invalid type: ' + type); + } + } + } + }); + /** + * The playback rate of the noise. Affects + * the "frequency" of the noise. + * @type {Positive} + * @signal + */ + Object.defineProperty(Tone.Noise.prototype, 'playbackRate', { + get: function () { + return this._playbackRate; + }, + set: function (rate) { + this._playbackRate = rate; + if (this._source) { + this._source.playbackRate.value = rate; + } + } + }); + /** + * internal start method + * + * @param {Time} time + * @private + */ + Tone.Noise.prototype._start = function (time) { + var buffer = _noiseBuffers[this._type]; + this._source = new Tone.BufferSource(buffer).connect(this.output); + this._source.loop = true; + this._source.playbackRate.value = this._playbackRate; + this._source.start(this.toSeconds(time), Math.random() * (buffer.duration - 0.001)); + }; + /** + * internal stop method + * + * @param {Time} time + * @private + */ + Tone.Noise.prototype._stop = function (time) { + if (this._source) { + this._source.stop(this.toSeconds(time)); + this._source = null; + } + }; + /** + * Restarts the noise. + * @param {[type]} time [description] + * @return {[type]} [description] + */ + Tone.Noise.prototype.restart = function (time) { + //TODO could be optimized by cancelling the buffer source 'stop' + //stop and restart + this._stop(time); + this._start(time); + }; + /** + * Clean up. + * @returns {Tone.Noise} this + */ + Tone.Noise.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + if (this._source !== null) { + this._source.disconnect(); + this._source = null; + } + this._buffer = null; + return this; + }; + /////////////////////////////////////////////////////////////////////////// + // THE BUFFERS + /////////////////////////////////////////////////////////////////////////// + //Noise buffer stats + var bufferLength = 44100 * 5; + var channels = 2; + /** + * The noise arrays. Generated on initialization. + * borrowed heavily from https://github.com/zacharydenton/noise.js + * (c) 2013 Zach Denton (MIT) + * @static + * @private + * @type {Array} + */ + var _noiseArrays = { + 'pink': function () { + var buffer = []; + for (var channelNum = 0; channelNum < channels; channelNum++) { + var channel = new Float32Array(bufferLength); + buffer[channelNum] = channel; + var b0, b1, b2, b3, b4, b5, b6; + b0 = b1 = b2 = b3 = b4 = b5 = b6 = 0; + for (var i = 0; i < bufferLength; i++) { + var white = Math.random() * 2 - 1; + b0 = 0.99886 * b0 + white * 0.0555179; + b1 = 0.99332 * b1 + white * 0.0750759; + b2 = 0.969 * b2 + white * 0.153852; + b3 = 0.8665 * b3 + white * 0.3104856; + b4 = 0.55 * b4 + white * 0.5329522; + b5 = -0.7616 * b5 - white * 0.016898; + channel[i] = b0 + b1 + b2 + b3 + b4 + b5 + b6 + white * 0.5362; + channel[i] *= 0.11; + // (roughly) compensate for gain + b6 = white * 0.115926; + } + } + return buffer; + }(), + 'brown': function () { + var buffer = []; + for (var channelNum = 0; channelNum < channels; channelNum++) { + var channel = new Float32Array(bufferLength); + buffer[channelNum] = channel; + var lastOut = 0; + for (var i = 0; i < bufferLength; i++) { + var white = Math.random() * 2 - 1; + channel[i] = (lastOut + 0.02 * white) / 1.02; + lastOut = channel[i]; + channel[i] *= 3.5; // (roughly) compensate for gain + } + } + return buffer; + }(), + 'white': function () { + var buffer = []; + for (var channelNum = 0; channelNum < channels; channelNum++) { + var channel = new Float32Array(bufferLength); + buffer[channelNum] = channel; + for (var i = 0; i < bufferLength; i++) { + channel[i] = Math.random() * 2 - 1; + } + } + return buffer; + }() + }; + /** + * static noise buffers + * @static + * @private + * @type {Tone.Buffer} + */ + var _noiseBuffers = {}; + //create the Tone.Buffers + function createBuffers() { + for (var type in _noiseArrays) { + _noiseBuffers[type] = new Tone.Buffer().fromArray(_noiseArrays[type]); + } + } + //create the noise buffers + Tone.getContext(createBuffers); + Tone.Context.on('init', createBuffers); + return Tone.Noise; + }); + Module(function (Tone) { + + /** + * @class Simple convolution created with decaying noise. + * Generates an Impulse Response Buffer + * with Tone.Offline then feeds the IR into ConvolverNode. + * Note: the Reverb will not make any sound until [generate](#generate) + * has been invoked and resolved. + * + * Inspiration from [ReverbGen](https://github.com/adelespinasse/reverbGen). + * Copyright (c) 2014 Alan deLespinasse Apache 2.0 License. + * + * @extends {Tone.Convolver} + * @param {Time=} decay The amount of time it will reverberate for. + */ + Tone.Reverb = function () { + var options = Tone.defaults(arguments, ['decay'], Tone.Reverb); + Tone.Effect.call(this, options); + /** + * Convolver node + * @type {ConvolverNode} + * @private + */ + this._convolver = this.context.createConvolver(); + /** + * The duration of the reverb + * @type {Time} + */ + this.decay = options.decay; + /** + * The amount of time before the reverb is fully + * ramped in. + * @type {Time} + */ + this.preDelay = options.preDelay; + this.connectEffect(this._convolver); + }; + Tone.extend(Tone.Reverb, Tone.Effect); + /** + * The defaults + * @type {Object} + * @static + */ + Tone.Reverb.defaults = { + 'decay': 1.5, + 'preDelay': 0.01 + }; + /** + * Generate the Impulse Response. Returns a promise while the IR is being + * generated. + * @return {Promise<Tone.Reverb>} Promise which returns this object. + */ + Tone.Reverb.prototype.generate = function () { + return Tone.Offline(function () { + //create a noise burst which decays over the duration + var noiseL = new Tone.Noise(); + var noiseR = new Tone.Noise(); + var merge = new Tone.Merge(); + noiseL.connect(merge.left); + noiseR.connect(merge.right); + var gainNode = new Tone.Gain().toMaster(); + merge.connect(gainNode); + noiseL.start(0); + noiseR.start(0); + //short fade in + gainNode.gain.setValueAtTime(0, 0); + gainNode.gain.linearRampToValueAtTime(1, this.preDelay); + //decay + gainNode.gain.exponentialApproachValueAtTime(0, this.preDelay, this.decay - this.preDelay); + }.bind(this), this.decay).then(function (buffer) { + this._convolver.buffer = buffer.get(); + return this; + }.bind(this)); + }; + /** + * Clean up. + * @return {Tone.Reverb} this + */ + Tone.Reverb.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._convolver.disconnect(); + this._convolver = null; + return this; + }; + return Tone.Reverb; + }); + Module(function (Tone) { + + /** + * @class Base class for stereo feedback effects where the effectReturn + * is fed back into the same channel. + * + * @constructor + * @extends {Tone.StereoEffect} + */ + Tone.StereoFeedbackEffect = function () { + var options = Tone.defaults(arguments, ['feedback'], Tone.FeedbackEffect); + Tone.StereoEffect.call(this, options); + /** + * controls the amount of feedback + * @type {NormalRange} + * @signal + */ + this.feedback = new Tone.Signal(options.feedback, Tone.Type.NormalRange); + /** + * the left side feeback + * @type {Tone.Gain} + * @private + */ + this._feedbackL = new Tone.Gain(); + /** + * the right side feeback + * @type {Tone.Gain} + * @private + */ + this._feedbackR = new Tone.Gain(); + //connect it up + this.effectReturnL.chain(this._feedbackL, this.effectSendL); + this.effectReturnR.chain(this._feedbackR, this.effectSendR); + this.feedback.fan(this._feedbackL.gain, this._feedbackR.gain); + this._readOnly(['feedback']); + }; + Tone.extend(Tone.StereoFeedbackEffect, Tone.StereoEffect); + /** + * clean up + * @returns {Tone.StereoFeedbackEffect} this + */ + Tone.StereoFeedbackEffect.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + this._writable(['feedback']); + this.feedback.dispose(); + this.feedback = null; + this._feedbackL.dispose(); + this._feedbackL = null; + this._feedbackR.dispose(); + this._feedbackR = null; + return this; + }; + return Tone.StereoFeedbackEffect; + }); + Module(function (Tone) { + + /** + * @class Applies a width factor to the mid/side seperation. + * 0 is all mid and 1 is all side. + * Algorithm found in [kvraudio forums](http://www.kvraudio.com/forum/viewtopic.php?t=212587). + * <br><br> + * <code> + * Mid *= 2*(1-width)<br> + * Side *= 2*width + * </code> + * + * @extends {Tone.MidSideEffect} + * @constructor + * @param {NormalRange|Object} [width] The stereo width. A width of 0 is mono and 1 is stereo. 0.5 is no change. + */ + Tone.StereoWidener = function () { + var options = Tone.defaults(arguments, ['width'], Tone.StereoWidener); + Tone.MidSideEffect.call(this, options); + /** + * The width control. 0 = 100% mid. 1 = 100% side. 0.5 = no change. + * @type {NormalRange} + * @signal + */ + this.width = new Tone.Signal(options.width, Tone.Type.NormalRange); + this._readOnly(['width']); + /** + * Two times the (1-width) for the mid channel + * @type {Tone.Multiply} + * @private + */ + this._twoTimesWidthMid = new Tone.Multiply(2); + /** + * Two times the width for the side channel + * @type {Tone.Multiply} + * @private + */ + this._twoTimesWidthSide = new Tone.Multiply(2); + /** + * Mid multiplier + * @type {Tone.Multiply} + * @private + */ + this._midMult = new Tone.Multiply(); + this._twoTimesWidthMid.connect(this._midMult, 0, 1); + this.midSend.chain(this._midMult, this.midReturn); + /** + * 1 - width + * @type {Tone} + */ + this._oneMinusWidth = new Tone.Subtract(); + this._oneMinusWidth.connect(this._twoTimesWidthMid); + this.context.getConstant(1).connect(this._oneMinusWidth, 0, 0); + this.width.connect(this._oneMinusWidth, 0, 1); + /** + * Side multiplier + * @type {Tone.Multiply} + * @private + */ + this._sideMult = new Tone.Multiply(); + this.width.connect(this._twoTimesWidthSide); + this._twoTimesWidthSide.connect(this._sideMult, 0, 1); + this.sideSend.chain(this._sideMult, this.sideReturn); + }; + Tone.extend(Tone.StereoWidener, Tone.MidSideEffect); + /** + * the default values + * @static + * @type {Object} + */ + Tone.StereoWidener.defaults = { 'width': 0.5 }; + /** + * Clean up. + * @returns {Tone.StereoWidener} this + */ + Tone.StereoWidener.prototype.dispose = function () { + Tone.MidSideEffect.prototype.dispose.call(this); + this._writable(['width']); + this.width.dispose(); + this.width = null; + this._midMult.dispose(); + this._midMult = null; + this._sideMult.dispose(); + this._sideMult = null; + this._twoTimesWidthMid.dispose(); + this._twoTimesWidthMid = null; + this._twoTimesWidthSide.dispose(); + this._twoTimesWidthSide = null; + this._oneMinusWidth.dispose(); + this._oneMinusWidth = null; + return this; + }; + return Tone.StereoWidener; + }); + Module(function (Tone) { + + /** + * @class Tone.Tremolo modulates the amplitude of an incoming signal using a Tone.LFO. + * The type, frequency, and depth of the LFO is controllable. + * + * @extends {Tone.StereoEffect} + * @constructor + * @param {Frequency} [frequency] The rate of the effect. + * @param {NormalRange} [depth] The depth of the effect. + * @example + * //create a tremolo and start it's LFO + * var tremolo = new Tone.Tremolo(9, 0.75).toMaster().start(); + * //route an oscillator through the tremolo and start it + * var oscillator = new Tone.Oscillator().connect(tremolo).start(); + */ + Tone.Tremolo = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'depth' + ], Tone.Tremolo); + Tone.StereoEffect.call(this, options); + /** + * The tremelo LFO in the left channel + * @type {Tone.LFO} + * @private + */ + this._lfoL = new Tone.LFO({ + 'phase': options.spread, + 'min': 1, + 'max': 0 + }); + /** + * The tremelo LFO in the left channel + * @type {Tone.LFO} + * @private + */ + this._lfoR = new Tone.LFO({ + 'phase': options.spread, + 'min': 1, + 'max': 0 + }); + /** + * Where the gain is multiplied + * @type {Tone.Gain} + * @private + */ + this._amplitudeL = new Tone.Gain(); + /** + * Where the gain is multiplied + * @type {Tone.Gain} + * @private + */ + this._amplitudeR = new Tone.Gain(); + /** + * The frequency of the tremolo. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The depth of the effect. A depth of 0, has no effect + * on the amplitude, and a depth of 1 makes the amplitude + * modulate fully between 0 and 1. + * @type {NormalRange} + * @signal + */ + this.depth = new Tone.Signal(options.depth, Tone.Type.NormalRange); + this._readOnly([ + 'frequency', + 'depth' + ]); + this.effectSendL.chain(this._amplitudeL, this.effectReturnL); + this.effectSendR.chain(this._amplitudeR, this.effectReturnR); + this._lfoL.connect(this._amplitudeL.gain); + this._lfoR.connect(this._amplitudeR.gain); + this.frequency.fan(this._lfoL.frequency, this._lfoR.frequency); + this.depth.fan(this._lfoR.amplitude, this._lfoL.amplitude); + this.type = options.type; + this.spread = options.spread; + }; + Tone.extend(Tone.Tremolo, Tone.StereoEffect); + /** + * @static + * @const + * @type {Object} + */ + Tone.Tremolo.defaults = { + 'frequency': 10, + 'type': 'sine', + 'depth': 0.5, + 'spread': 180 + }; + /** + * Start the tremolo. + * @param {Time} [time=now] When the tremolo begins. + * @returns {Tone.Tremolo} this + */ + Tone.Tremolo.prototype.start = function (time) { + this._lfoL.start(time); + this._lfoR.start(time); + return this; + }; + /** + * Stop the tremolo. + * @param {Time} [time=now] When the tremolo stops. + * @returns {Tone.Tremolo} this + */ + Tone.Tremolo.prototype.stop = function (time) { + this._lfoL.stop(time); + this._lfoR.stop(time); + return this; + }; + /** + * Sync the effect to the transport. + * @param {Time} [delay=0] Delay time before starting the effect after the + * Transport has started. + * @returns {Tone.AutoFilter} this + */ + Tone.Tremolo.prototype.sync = function (delay) { + this._lfoL.sync(delay); + this._lfoR.sync(delay); + Tone.Transport.syncSignal(this.frequency); + return this; + }; + /** + * Unsync the filter from the transport + * @returns {Tone.Tremolo} this + */ + Tone.Tremolo.prototype.unsync = function () { + this._lfoL.unsync(); + this._lfoR.unsync(); + Tone.Transport.unsyncSignal(this.frequency); + return this; + }; + /** + * The Tremolo's oscillator type. + * @memberOf Tone.Tremolo# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.Tremolo.prototype, 'type', { + get: function () { + return this._lfoL.type; + }, + set: function (type) { + this._lfoL.type = type; + this._lfoR.type = type; + } + }); + /** + * Amount of stereo spread. When set to 0, both LFO's will be panned centrally. + * When set to 180, LFO's will be panned hard left and right respectively. + * @memberOf Tone.Tremolo# + * @type {Degrees} + * @name spread + */ + Object.defineProperty(Tone.Tremolo.prototype, 'spread', { + get: function () { + return this._lfoR.phase - this._lfoL.phase; //180 + }, + set: function (spread) { + this._lfoL.phase = 90 - spread / 2; + this._lfoR.phase = spread / 2 + 90; + } + }); + /** + * clean up + * @returns {Tone.Tremolo} this + */ + Tone.Tremolo.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'depth' + ]); + this._lfoL.dispose(); + this._lfoL = null; + this._lfoR.dispose(); + this._lfoR = null; + this._amplitudeL.dispose(); + this._amplitudeL = null; + this._amplitudeR.dispose(); + this._amplitudeR = null; + this.frequency = null; + this.depth = null; + return this; + }; + return Tone.Tremolo; + }); + Module(function (Tone) { + + /** + * @class A Vibrato effect composed of a Tone.Delay and a Tone.LFO. The LFO + * modulates the delayTime of the delay, causing the pitch to rise + * and fall. + * @extends {Tone.Effect} + * @param {Frequency} frequency The frequency of the vibrato. + * @param {NormalRange} depth The amount the pitch is modulated. + */ + Tone.Vibrato = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'depth' + ], Tone.Vibrato); + Tone.Effect.call(this, options); + /** + * The delay node used for the vibrato effect + * @type {Tone.Delay} + * @private + */ + this._delayNode = new Tone.Delay(0, options.maxDelay); + /** + * The LFO used to control the vibrato + * @type {Tone.LFO} + * @private + */ + this._lfo = new Tone.LFO({ + 'type': options.type, + 'min': 0, + 'max': options.maxDelay, + 'frequency': options.frequency, + 'phase': -90 //offse the phase so the resting position is in the center + }).start().connect(this._delayNode.delayTime); + /** + * The frequency of the vibrato + * @type {Frequency} + * @signal + */ + this.frequency = this._lfo.frequency; + /** + * The depth of the vibrato. + * @type {NormalRange} + * @signal + */ + this.depth = this._lfo.amplitude; + this.depth.value = options.depth; + this._readOnly([ + 'frequency', + 'depth' + ]); + this.effectSend.chain(this._delayNode, this.effectReturn); + }; + Tone.extend(Tone.Vibrato, Tone.Effect); + /** + * The defaults + * @type {Object} + * @const + */ + Tone.Vibrato.defaults = { + 'maxDelay': 0.005, + 'frequency': 5, + 'depth': 0.1, + 'type': 'sine' + }; + /** + * Type of oscillator attached to the Vibrato. + * @memberOf Tone.Vibrato# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.Vibrato.prototype, 'type', { + get: function () { + return this._lfo.type; + }, + set: function (type) { + this._lfo.type = type; + } + }); + /** + * Clean up. + * @returns {Tone.Vibrato} this + */ + Tone.Vibrato.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._delayNode.dispose(); + this._delayNode = null; + this._lfo.dispose(); + this._lfo = null; + this._writable([ + 'frequency', + 'depth' + ]); + this.frequency = null; + this.depth = null; + }; + return Tone.Vibrato; + }); + Module(function (Tone) { + + /** + * @class Tone.Event abstracts away Tone.Transport.schedule and provides a schedulable + * callback for a single or repeatable events along the timeline. + * + * @extends {Tone} + * @param {function} callback The callback to invoke at the time. + * @param {*} value The value or values which should be passed to + * the callback function on invocation. + * @example + * var chord = new Tone.Event(function(time, chord){ + * //the chord as well as the exact time of the event + * //are passed in as arguments to the callback function + * }, ["D4", "E4", "F4"]); + * //start the chord at the beginning of the transport timeline + * chord.start(); + * //loop it every measure for 8 measures + * chord.loop = 8; + * chord.loopEnd = "1m"; + */ + Tone.Event = function () { + var options = Tone.defaults(arguments, [ + 'callback', + 'value' + ], Tone.Event); + Tone.call(this); + /** + * Loop value + * @type {Boolean|Positive} + * @private + */ + this._loop = options.loop; + /** + * The callback to invoke. + * @type {Function} + */ + this.callback = options.callback; + /** + * The value which is passed to the + * callback function. + * @type {*} + * @private + */ + this.value = options.value; + /** + * When the note is scheduled to start. + * @type {Number} + * @private + */ + this._loopStart = this.toTicks(options.loopStart); + /** + * When the note is scheduled to start. + * @type {Number} + * @private + */ + this._loopEnd = this.toTicks(options.loopEnd); + /** + * Tracks the scheduled events + * @type {Tone.TimelineState} + * @private + */ + this._state = new Tone.TimelineState(Tone.State.Stopped); + /** + * The playback speed of the note. A speed of 1 + * is no change. + * @private + * @type {Positive} + */ + this._playbackRate = 1; + /** + * A delay time from when the event is scheduled to start + * @type {Ticks} + * @private + */ + this._startOffset = 0; + /** + * private holder of probability value + * @type {NormalRange} + * @private + */ + this._probability = options.probability; + /** + * the amount of variation from the + * given time. + * @type {Boolean|Time} + * @private + */ + this._humanize = options.humanize; + /** + * If mute is true, the callback won't be + * invoked. + * @type {Boolean} + */ + this.mute = options.mute; + //set the initial values + this.playbackRate = options.playbackRate; + }; + Tone.extend(Tone.Event); + /** + * The default values + * @type {Object} + * @const + */ + Tone.Event.defaults = { + 'callback': Tone.noOp, + 'loop': false, + 'loopEnd': '1m', + 'loopStart': 0, + 'playbackRate': 1, + 'value': null, + 'probability': 1, + 'mute': false, + 'humanize': false + }; + /** + * Reschedule all of the events along the timeline + * with the updated values. + * @param {Time} after Only reschedules events after the given time. + * @return {Tone.Event} this + * @private + */ + Tone.Event.prototype._rescheduleEvents = function (after) { + //if no argument is given, schedules all of the events + after = Tone.defaultArg(after, -1); + this._state.forEachFrom(after, function (event) { + var duration; + if (event.state === Tone.State.Started) { + if (Tone.isDefined(event.id)) { + Tone.Transport.clear(event.id); + } + var startTick = event.time + Math.round(this.startOffset / this._playbackRate); + if (this._loop) { + duration = Infinity; + if (Tone.isNumber(this._loop)) { + duration = this._loop * this._getLoopDuration(); + } + var nextEvent = this._state.getAfter(startTick); + if (nextEvent !== null) { + duration = Math.min(duration, nextEvent.time - startTick); + } + if (duration !== Infinity) { + //schedule a stop since it's finite duration + this._state.setStateAtTime(Tone.State.Stopped, startTick + duration + 1); + duration = Tone.Ticks(duration); + } + var interval = Tone.Ticks(this._getLoopDuration()); + event.id = Tone.Transport.scheduleRepeat(this._tick.bind(this), interval, Tone.Ticks(startTick), duration); + } else { + event.id = Tone.Transport.schedule(this._tick.bind(this), Tone.Ticks(startTick)); + } + } + }.bind(this)); + return this; + }; + /** + * Returns the playback state of the note, either "started" or "stopped". + * @type {String} + * @readOnly + * @memberOf Tone.Event# + * @name state + */ + Object.defineProperty(Tone.Event.prototype, 'state', { + get: function () { + return this._state.getValueAtTime(Tone.Transport.ticks); + } + }); + /** + * The start from the scheduled start time + * @type {Ticks} + * @memberOf Tone.Event# + * @name startOffset + * @private + */ + Object.defineProperty(Tone.Event.prototype, 'startOffset', { + get: function () { + return this._startOffset; + }, + set: function (offset) { + this._startOffset = offset; + } + }); + /** + * The probability of the notes being triggered. + * @memberOf Tone.Event# + * @type {NormalRange} + * @name probability + */ + Object.defineProperty(Tone.Event.prototype, 'probability', { + get: function () { + return this._probability; + }, + set: function (prob) { + this._probability = prob; + } + }); + /** + * If set to true, will apply small random variation + * to the callback time. If the value is given as a time, it will randomize + * by that amount. + * @example + * event.humanize = true; + * @type {Boolean|Time} + * @name humanize + */ + Object.defineProperty(Tone.Event.prototype, 'humanize', { + get: function () { + return this._humanize; + }, + set: function (variation) { + this._humanize = variation; + } + }); + /** + * Start the note at the given time. + * @param {TimelinePosition} time When the note should start. + * @return {Tone.Event} this + */ + Tone.Event.prototype.start = function (time) { + time = this.toTicks(time); + if (this._state.getValueAtTime(time) === Tone.State.Stopped) { + this._state.add({ + 'state': Tone.State.Started, + 'time': time, + 'id': undefined + }); + this._rescheduleEvents(time); + } + return this; + }; + /** + * Stop the Event at the given time. + * @param {TimelinePosition} time When the note should stop. + * @return {Tone.Event} this + */ + Tone.Event.prototype.stop = function (time) { + this.cancel(time); + time = this.toTicks(time); + if (this._state.getValueAtTime(time) === Tone.State.Started) { + this._state.setStateAtTime(Tone.State.Stopped, time); + var previousEvent = this._state.getBefore(time); + var reschedulTime = time; + if (previousEvent !== null) { + reschedulTime = previousEvent.time; + } + this._rescheduleEvents(reschedulTime); + } + return this; + }; + /** + * Cancel all scheduled events greater than or equal to the given time + * @param {TimelinePosition} [time=0] The time after which events will be cancel. + * @return {Tone.Event} this + */ + Tone.Event.prototype.cancel = function (time) { + time = Tone.defaultArg(time, -Infinity); + time = this.toTicks(time); + this._state.forEachFrom(time, function (event) { + Tone.Transport.clear(event.id); + }); + this._state.cancel(time); + return this; + }; + /** + * The callback function invoker. Also + * checks if the Event is done playing + * @param {Number} time The time of the event in seconds + * @private + */ + Tone.Event.prototype._tick = function (time) { + var ticks = Tone.Transport.getTicksAtTime(time); + if (!this.mute && this._state.getValueAtTime(ticks) === Tone.State.Started) { + if (this.probability < 1 && Math.random() > this.probability) { + return; + } + if (this.humanize) { + var variation = 0.02; + if (!Tone.isBoolean(this.humanize)) { + variation = this.toSeconds(this.humanize); + } + time += (Math.random() * 2 - 1) * variation; + } + this.callback(time, this.value); + } + }; + /** + * Get the duration of the loop. + * @return {Ticks} + * @private + */ + Tone.Event.prototype._getLoopDuration = function () { + return Math.round((this._loopEnd - this._loopStart) / this._playbackRate); + }; + /** + * If the note should loop or not + * between Tone.Event.loopStart and + * Tone.Event.loopEnd. An integer + * value corresponds to the number of + * loops the Event does after it starts. + * @memberOf Tone.Event# + * @type {Boolean|Positive} + * @name loop + */ + Object.defineProperty(Tone.Event.prototype, 'loop', { + get: function () { + return this._loop; + }, + set: function (loop) { + this._loop = loop; + this._rescheduleEvents(); + } + }); + /** + * The playback rate of the note. Defaults to 1. + * @memberOf Tone.Event# + * @type {Positive} + * @name playbackRate + * @example + * note.loop = true; + * //repeat the note twice as fast + * note.playbackRate = 2; + */ + Object.defineProperty(Tone.Event.prototype, 'playbackRate', { + get: function () { + return this._playbackRate; + }, + set: function (rate) { + this._playbackRate = rate; + this._rescheduleEvents(); + } + }); + /** + * The loopEnd point is the time the event will loop + * if Tone.Event.loop is true. + * @memberOf Tone.Event# + * @type {Time} + * @name loopEnd + */ + Object.defineProperty(Tone.Event.prototype, 'loopEnd', { + get: function () { + return Tone.Ticks(this._loopEnd).toSeconds(); + }, + set: function (loopEnd) { + this._loopEnd = this.toTicks(loopEnd); + if (this._loop) { + this._rescheduleEvents(); + } + } + }); + /** + * The time when the loop should start. + * @memberOf Tone.Event# + * @type {Time} + * @name loopStart + */ + Object.defineProperty(Tone.Event.prototype, 'loopStart', { + get: function () { + return Tone.Ticks(this._loopStart).toSeconds(); + }, + set: function (loopStart) { + this._loopStart = this.toTicks(loopStart); + if (this._loop) { + this._rescheduleEvents(); + } + } + }); + /** + * The current progress of the loop interval. + * Returns 0 if the event is not started yet or + * it is not set to loop. + * @memberOf Tone.Event# + * @type {NormalRange} + * @name progress + * @readOnly + */ + Object.defineProperty(Tone.Event.prototype, 'progress', { + get: function () { + if (this._loop) { + var ticks = Tone.Transport.ticks; + var lastEvent = this._state.get(ticks); + if (lastEvent !== null && lastEvent.state === Tone.State.Started) { + var loopDuration = this._getLoopDuration(); + var progress = (ticks - lastEvent.time) % loopDuration; + return progress / loopDuration; + } else { + return 0; + } + } else { + return 0; + } + } + }); + /** + * Clean up + * @return {Tone.Event} this + */ + Tone.Event.prototype.dispose = function () { + this.cancel(); + this._state.dispose(); + this._state = null; + this.callback = null; + this.value = null; + }; + return Tone.Event; + }); + Module(function (Tone) { + /** + * @class Tone.Loop creates a looped callback at the + * specified interval. The callback can be + * started, stopped and scheduled along + * the Transport's timeline. + * @example + * var loop = new Tone.Loop(function(time){ + * //triggered every eighth note. + * console.log(time); + * }, "8n").start(0); + * Tone.Transport.start(); + * @extends {Tone} + * @param {Function} callback The callback to invoke with the event. + * @param {Time} interval The time between successive callback calls. + */ + Tone.Loop = function () { + var options = Tone.defaults(arguments, [ + 'callback', + 'interval' + ], Tone.Loop); + Tone.call(this); + /** + * The event which produces the callbacks + */ + this._event = new Tone.Event({ + 'callback': this._tick.bind(this), + 'loop': true, + 'loopEnd': options.interval, + 'playbackRate': options.playbackRate, + 'probability': options.probability + }); + /** + * The callback to invoke with the next event in the pattern + * @type {Function} + */ + this.callback = options.callback; + //set the iterations + this.iterations = options.iterations; + }; + Tone.extend(Tone.Loop); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.Loop.defaults = { + 'interval': '4n', + 'callback': Tone.noOp, + 'playbackRate': 1, + 'iterations': Infinity, + 'probability': true, + 'mute': false + }; + /** + * Start the loop at the specified time along the Transport's + * timeline. + * @param {TimelinePosition=} time When to start the Loop. + * @return {Tone.Loop} this + */ + Tone.Loop.prototype.start = function (time) { + this._event.start(time); + return this; + }; + /** + * Stop the loop at the given time. + * @param {TimelinePosition=} time When to stop the Arpeggio + * @return {Tone.Loop} this + */ + Tone.Loop.prototype.stop = function (time) { + this._event.stop(time); + return this; + }; + /** + * Cancel all scheduled events greater than or equal to the given time + * @param {TimelinePosition} [time=0] The time after which events will be cancel. + * @return {Tone.Loop} this + */ + Tone.Loop.prototype.cancel = function (time) { + this._event.cancel(time); + return this; + }; + /** + * Internal function called when the notes should be called + * @param {Number} time The time the event occurs + * @private + */ + Tone.Loop.prototype._tick = function (time) { + this.callback(time); + }; + /** + * The state of the Loop, either started or stopped. + * @memberOf Tone.Loop# + * @type {String} + * @name state + * @readOnly + */ + Object.defineProperty(Tone.Loop.prototype, 'state', { + get: function () { + return this._event.state; + } + }); + /** + * The progress of the loop as a value between 0-1. 0, when + * the loop is stopped or done iterating. + * @memberOf Tone.Loop# + * @type {NormalRange} + * @name progress + * @readOnly + */ + Object.defineProperty(Tone.Loop.prototype, 'progress', { + get: function () { + return this._event.progress; + } + }); + /** + * The time between successive callbacks. + * @example + * loop.interval = "8n"; //loop every 8n + * @memberOf Tone.Loop# + * @type {Time} + * @name interval + */ + Object.defineProperty(Tone.Loop.prototype, 'interval', { + get: function () { + return this._event.loopEnd; + }, + set: function (interval) { + this._event.loopEnd = interval; + } + }); + /** + * The playback rate of the loop. The normal playback rate is 1 (no change). + * A `playbackRate` of 2 would be twice as fast. + * @memberOf Tone.Loop# + * @type {Time} + * @name playbackRate + */ + Object.defineProperty(Tone.Loop.prototype, 'playbackRate', { + get: function () { + return this._event.playbackRate; + }, + set: function (rate) { + this._event.playbackRate = rate; + } + }); + /** + * Random variation +/-0.01s to the scheduled time. + * Or give it a time value which it will randomize by. + * @type {Boolean|Time} + * @memberOf Tone.Loop# + * @name humanize + */ + Object.defineProperty(Tone.Loop.prototype, 'humanize', { + get: function () { + return this._event.humanize; + }, + set: function (variation) { + this._event.humanize = variation; + } + }); + /** + * The probably of the callback being invoked. + * @memberOf Tone.Loop# + * @type {NormalRange} + * @name probability + */ + Object.defineProperty(Tone.Loop.prototype, 'probability', { + get: function () { + return this._event.probability; + }, + set: function (prob) { + this._event.probability = prob; + } + }); + /** + * Muting the Loop means that no callbacks are invoked. + * @memberOf Tone.Loop# + * @type {Boolean} + * @name mute + */ + Object.defineProperty(Tone.Loop.prototype, 'mute', { + get: function () { + return this._event.mute; + }, + set: function (mute) { + this._event.mute = mute; + } + }); + /** + * The number of iterations of the loop. The default + * value is Infinity (loop forever). + * @memberOf Tone.Loop# + * @type {Positive} + * @name iterations + */ + Object.defineProperty(Tone.Loop.prototype, 'iterations', { + get: function () { + if (this._event.loop === true) { + return Infinity; + } else { + return this._event.loop; + } + }, + set: function (iters) { + if (iters === Infinity) { + this._event.loop = true; + } else { + this._event.loop = iters; + } + } + }); + /** + * Clean up + * @return {Tone.Loop} this + */ + Tone.Loop.prototype.dispose = function () { + this._event.dispose(); + this._event = null; + this.callback = null; + }; + return Tone.Loop; + }); + Module(function (Tone) { + + /** + * @class Tone.Part is a collection Tone.Events which can be + * started/stopped and looped as a single unit. + * + * @extends {Tone.Event} + * @param {Function} callback The callback to invoke on each event + * @param {Array} events the array of events + * @example + * var part = new Tone.Part(function(time, note){ + * //the notes given as the second element in the array + * //will be passed in as the second argument + * synth.triggerAttackRelease(note, "8n", time); + * }, [[0, "C2"], ["0:2", "C3"], ["0:3:2", "G2"]]); + * @example + * //use an array of objects as long as the object has a "time" attribute + * var part = new Tone.Part(function(time, value){ + * //the value is an object which contains both the note and the velocity + * synth.triggerAttackRelease(value.note, "8n", time, value.velocity); + * }, [{"time" : 0, "note" : "C3", "velocity": 0.9}, + * {"time" : "0:2", "note" : "C4", "velocity": 0.5} + * ]).start(0); + */ + Tone.Part = function () { + var options = Tone.defaults(arguments, [ + 'callback', + 'events' + ], Tone.Part); + Tone.Event.call(this, options); + /** + * An array of Objects. + * @type {Array} + * @private + */ + this._events = []; + //add the events + for (var i = 0; i < options.events.length; i++) { + if (Array.isArray(options.events[i])) { + this.add(options.events[i][0], options.events[i][1]); + } else { + this.add(options.events[i]); + } + } + }; + Tone.extend(Tone.Part, Tone.Event); + /** + * The default values + * @type {Object} + * @const + */ + Tone.Part.defaults = { + 'callback': Tone.noOp, + 'loop': false, + 'loopEnd': '1m', + 'loopStart': 0, + 'playbackRate': 1, + 'probability': 1, + 'humanize': false, + 'mute': false, + 'events': [] + }; + /** + * Start the part at the given time. + * @param {TransportTime} time When to start the part. + * @param {Time=} offset The offset from the start of the part + * to begin playing at. + * @return {Tone.Part} this + */ + Tone.Part.prototype.start = function (time, offset) { + var ticks = this.toTicks(time); + if (this._state.getValueAtTime(ticks) !== Tone.State.Started) { + if (this._loop) { + offset = Tone.defaultArg(offset, this._loopStart); + } else { + offset = Tone.defaultArg(offset, 0); + } + offset = this.toTicks(offset); + this._state.add({ + 'state': Tone.State.Started, + 'time': ticks, + 'offset': offset + }); + this._forEach(function (event) { + this._startNote(event, ticks, offset); + }); + } + return this; + }; + /** + * Start the event in the given event at the correct time given + * the ticks and offset and looping. + * @param {Tone.Event} event + * @param {Ticks} ticks + * @param {Ticks} offset + * @private + */ + Tone.Part.prototype._startNote = function (event, ticks, offset) { + ticks -= offset; + if (this._loop) { + if (event.startOffset >= this._loopStart && event.startOffset < this._loopEnd) { + if (event.startOffset < offset) { + //start it on the next loop + ticks += this._getLoopDuration(); + } + event.start(Tone.Ticks(ticks)); + } else if (event.startOffset < this._loopStart && event.startOffset >= offset) { + event.loop = false; + event.start(Tone.Ticks(ticks)); + } + } else if (event.startOffset >= offset) { + event.start(Tone.Ticks(ticks)); + } + }; + /** + * The start from the scheduled start time + * @type {Ticks} + * @memberOf Tone.Part# + * @name startOffset + * @private + */ + Object.defineProperty(Tone.Part.prototype, 'startOffset', { + get: function () { + return this._startOffset; + }, + set: function (offset) { + this._startOffset = offset; + this._forEach(function (event) { + event.startOffset += this._startOffset; + }); + } + }); + /** + * Stop the part at the given time. + * @param {TimelinePosition} time When to stop the part. + * @return {Tone.Part} this + */ + Tone.Part.prototype.stop = function (time) { + var ticks = this.toTicks(time); + this._state.cancel(ticks); + this._state.setStateAtTime(Tone.State.Stopped, ticks); + this._forEach(function (event) { + event.stop(time); + }); + return this; + }; + /** + * Get/Set an Event's value at the given time. + * If a value is passed in and no event exists at + * the given time, one will be created with that value. + * If two events are at the same time, the first one will + * be returned. + * @example + * part.at("1m"); //returns the part at the first measure + * + * part.at("2m", "C2"); //set the value at "2m" to C2. + * //if an event didn't exist at that time, it will be created. + * @param {TransportTime} time The time of the event to get or set. + * @param {*=} value If a value is passed in, the value of the + * event at the given time will be set to it. + * @return {Tone.Event} the event at the time + */ + Tone.Part.prototype.at = function (time, value) { + time = Tone.TransportTime(time); + var tickTime = Tone.Ticks(1).toSeconds(); + for (var i = 0; i < this._events.length; i++) { + var event = this._events[i]; + if (Math.abs(time.toTicks() - event.startOffset) < tickTime) { + if (Tone.isDefined(value)) { + event.value = value; + } + return event; + } + } + //if there was no event at that time, create one + if (Tone.isDefined(value)) { + this.add(time, value); + //return the new event + return this._events[this._events.length - 1]; + } else { + return null; + } + }; + /** + * Add a an event to the part. + * @param {Time} time The time the note should start. + * If an object is passed in, it should + * have a 'time' attribute and the rest + * of the object will be used as the 'value'. + * @param {Tone.Event|*} value + * @returns {Tone.Part} this + * @example + * part.add("1m", "C#+11"); + */ + Tone.Part.prototype.add = function (time, value) { + //extract the parameters + if (time.hasOwnProperty('time')) { + value = time; + time = value.time; + } + time = this.toTicks(time); + var event; + if (value instanceof Tone.Event) { + event = value; + event.callback = this._tick.bind(this); + } else { + event = new Tone.Event({ + 'callback': this._tick.bind(this), + 'value': value + }); + } + //the start offset + event.startOffset = time; + //initialize the values + event.set({ + 'loopEnd': this.loopEnd, + 'loopStart': this.loopStart, + 'loop': this.loop, + 'humanize': this.humanize, + 'playbackRate': this.playbackRate, + 'probability': this.probability + }); + this._events.push(event); + //start the note if it should be played right now + this._restartEvent(event); + return this; + }; + /** + * Restart the given event + * @param {Tone.Event} event + * @private + */ + Tone.Part.prototype._restartEvent = function (event) { + this._state.forEach(function (stateEvent) { + if (stateEvent.state === Tone.State.Started) { + this._startNote(event, stateEvent.time, stateEvent.offset); + } else { + //stop the note + event.stop(Tone.Ticks(stateEvent.time)); + } + }.bind(this)); + }; + /** + * Remove an event from the part. Will recursively iterate + * into nested parts to find the event. + * @param {Time} time The time of the event + * @param {*} value Optionally select only a specific event value + * @return {Tone.Part} this + */ + Tone.Part.prototype.remove = function (time, value) { + //extract the parameters + if (time.hasOwnProperty('time')) { + value = time; + time = value.time; + } + time = this.toTicks(time); + for (var i = this._events.length - 1; i >= 0; i--) { + var event = this._events[i]; + if (event instanceof Tone.Part) { + event.remove(time, value); + } else if (event.startOffset === time) { + if (Tone.isUndef(value) || Tone.isDefined(value) && event.value === value) { + this._events.splice(i, 1); + event.dispose(); + } + } + } + return this; + }; + /** + * Remove all of the notes from the group. + * @return {Tone.Part} this + */ + Tone.Part.prototype.removeAll = function () { + this._forEach(function (event) { + event.dispose(); + }); + this._events = []; + return this; + }; + /** + * Cancel scheduled state change events: i.e. "start" and "stop". + * @param {TimelinePosition} after The time after which to cancel the scheduled events. + * @return {Tone.Part} this + */ + Tone.Part.prototype.cancel = function (after) { + this._forEach(function (event) { + event.cancel(after); + }); + this._state.cancel(this.toTicks(after)); + return this; + }; + /** + * Iterate over all of the events + * @param {Function} callback + * @param {Object} ctx The context + * @private + */ + Tone.Part.prototype._forEach = function (callback, ctx) { + if (this._events) { + ctx = Tone.defaultArg(ctx, this); + for (var i = this._events.length - 1; i >= 0; i--) { + var e = this._events[i]; + if (e instanceof Tone.Part) { + e._forEach(callback, ctx); + } else { + callback.call(ctx, e); + } + } + } + return this; + }; + /** + * Set the attribute of all of the events + * @param {String} attr the attribute to set + * @param {*} value The value to set it to + * @private + */ + Tone.Part.prototype._setAll = function (attr, value) { + this._forEach(function (event) { + event[attr] = value; + }); + }; + /** + * Internal tick method + * @param {Number} time The time of the event in seconds + * @private + */ + Tone.Part.prototype._tick = function (time, value) { + if (!this.mute) { + this.callback(time, value); + } + }; + /** + * Determine if the event should be currently looping + * given the loop boundries of this Part. + * @param {Tone.Event} event The event to test + * @private + */ + Tone.Part.prototype._testLoopBoundries = function (event) { + if (event.startOffset < this._loopStart || event.startOffset >= this._loopEnd) { + event.cancel(0); + } else if (event.state === Tone.State.Stopped) { + //reschedule it if it's stopped + this._restartEvent(event); + } + }; + /** + * The probability of the notes being triggered. + * @memberOf Tone.Part# + * @type {NormalRange} + * @name probability + */ + Object.defineProperty(Tone.Part.prototype, 'probability', { + get: function () { + return this._probability; + }, + set: function (prob) { + this._probability = prob; + this._setAll('probability', prob); + } + }); + /** + * If set to true, will apply small random variation + * to the callback time. If the value is given as a time, it will randomize + * by that amount. + * @example + * event.humanize = true; + * @type {Boolean|Time} + * @name humanize + */ + Object.defineProperty(Tone.Part.prototype, 'humanize', { + get: function () { + return this._humanize; + }, + set: function (variation) { + this._humanize = variation; + this._setAll('humanize', variation); + } + }); + /** + * If the part should loop or not + * between Tone.Part.loopStart and + * Tone.Part.loopEnd. An integer + * value corresponds to the number of + * loops the Part does after it starts. + * @memberOf Tone.Part# + * @type {Boolean|Positive} + * @name loop + * @example + * //loop the part 8 times + * part.loop = 8; + */ + Object.defineProperty(Tone.Part.prototype, 'loop', { + get: function () { + return this._loop; + }, + set: function (loop) { + this._loop = loop; + this._forEach(function (event) { + event._loopStart = this._loopStart; + event._loopEnd = this._loopEnd; + event.loop = loop; + this._testLoopBoundries(event); + }); + } + }); + /** + * The loopEnd point determines when it will + * loop if Tone.Part.loop is true. + * @memberOf Tone.Part# + * @type {Time} + * @name loopEnd + */ + Object.defineProperty(Tone.Part.prototype, 'loopEnd', { + get: function () { + return Tone.Ticks(this._loopEnd).toSeconds(); + }, + set: function (loopEnd) { + this._loopEnd = this.toTicks(loopEnd); + if (this._loop) { + this._forEach(function (event) { + event.loopEnd = loopEnd; + this._testLoopBoundries(event); + }); + } + } + }); + /** + * The loopStart point determines when it will + * loop if Tone.Part.loop is true. + * @memberOf Tone.Part# + * @type {Time} + * @name loopStart + */ + Object.defineProperty(Tone.Part.prototype, 'loopStart', { + get: function () { + return Tone.Ticks(this._loopStart).toSeconds(); + }, + set: function (loopStart) { + this._loopStart = this.toTicks(loopStart); + if (this._loop) { + this._forEach(function (event) { + event.loopStart = this.loopStart; + this._testLoopBoundries(event); + }); + } + } + }); + /** + * The playback rate of the part + * @memberOf Tone.Part# + * @type {Positive} + * @name playbackRate + */ + Object.defineProperty(Tone.Part.prototype, 'playbackRate', { + get: function () { + return this._playbackRate; + }, + set: function (rate) { + this._playbackRate = rate; + this._setAll('playbackRate', rate); + } + }); + /** + * The number of scheduled notes in the part. + * @memberOf Tone.Part# + * @type {Positive} + * @name length + * @readOnly + */ + Object.defineProperty(Tone.Part.prototype, 'length', { + get: function () { + return this._events.length; + } + }); + /** + * Clean up + * @return {Tone.Part} this + */ + Tone.Part.prototype.dispose = function () { + this.removeAll(); + this._state.dispose(); + this._state = null; + this.callback = null; + this._events = null; + return this; + }; + return Tone.Part; + }); + Module(function (Tone) { + /** + * @class Tone.Pattern arpeggiates between the given notes + * in a number of patterns. See Tone.CtrlPattern for + * a full list of patterns. + * @example + * var pattern = new Tone.Pattern(function(time, note){ + * //the order of the notes passed in depends on the pattern + * }, ["C2", "D4", "E5", "A6"], "upDown"); + * @extends {Tone.Loop} + * @param {Function} callback The callback to invoke with the + * event. + * @param {Array} values The values to arpeggiate over. + */ + Tone.Pattern = function () { + var options = Tone.defaults(arguments, [ + 'callback', + 'values', + 'pattern' + ], Tone.Pattern); + Tone.Loop.call(this, options); + /** + * The pattern manager + * @type {Tone.CtrlPattern} + * @private + */ + this._pattern = new Tone.CtrlPattern({ + 'values': options.values, + 'type': options.pattern, + 'index': options.index + }); + }; + Tone.extend(Tone.Pattern, Tone.Loop); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.Pattern.defaults = { + 'pattern': Tone.CtrlPattern.Type.Up, + 'callback': Tone.noOp, + 'values': [] + }; + /** + * Internal function called when the notes should be called + * @param {Number} time The time the event occurs + * @private + */ + Tone.Pattern.prototype._tick = function (time) { + this.callback(time, this._pattern.value); + this._pattern.next(); + }; + /** + * The current index in the values array. + * @memberOf Tone.Pattern# + * @type {Positive} + * @name index + */ + Object.defineProperty(Tone.Pattern.prototype, 'index', { + get: function () { + return this._pattern.index; + }, + set: function (i) { + this._pattern.index = i; + } + }); + /** + * The array of events. + * @memberOf Tone.Pattern# + * @type {Array} + * @name values + */ + Object.defineProperty(Tone.Pattern.prototype, 'values', { + get: function () { + return this._pattern.values; + }, + set: function (vals) { + this._pattern.values = vals; + } + }); + /** + * The current value of the pattern. + * @memberOf Tone.Pattern# + * @type {*} + * @name value + * @readOnly + */ + Object.defineProperty(Tone.Pattern.prototype, 'value', { + get: function () { + return this._pattern.value; + } + }); + /** + * The pattern type. See Tone.CtrlPattern for the full list of patterns. + * @memberOf Tone.Pattern# + * @type {String} + * @name pattern + */ + Object.defineProperty(Tone.Pattern.prototype, 'pattern', { + get: function () { + return this._pattern.type; + }, + set: function (pattern) { + this._pattern.type = pattern; + } + }); + /** + * Clean up + * @return {Tone.Pattern} this + */ + Tone.Pattern.prototype.dispose = function () { + Tone.Loop.prototype.dispose.call(this); + this._pattern.dispose(); + this._pattern = null; + }; + return Tone.Pattern; + }); + Module(function (Tone) { + + /** + * @class A sequence is an alternate notation of a part. Instead + * of passing in an array of [time, event] pairs, pass + * in an array of events which will be spaced at the + * given subdivision. Sub-arrays will subdivide that beat + * by the number of items are in the array. + * Sequence notation inspiration from [Tidal](http://yaxu.org/tidal/) + * @param {Function} callback The callback to invoke with every note + * @param {Array} events The sequence + * @param {Time} subdivision The subdivision between which events are placed. + * @extends {Tone.Part} + * @example + * var seq = new Tone.Sequence(function(time, note){ + * console.log(note); + * //straight quater notes + * }, ["C4", "E4", "G4", "A4"], "4n"); + * @example + * var seq = new Tone.Sequence(function(time, note){ + * console.log(note); + * //subdivisions are given as subarrays + * }, ["C4", ["E4", "D4", "E4"], "G4", ["A4", "G4"]]); + */ + Tone.Sequence = function () { + var options = Tone.defaults(arguments, [ + 'callback', + 'events', + 'subdivision' + ], Tone.Sequence); + //remove the events + var events = options.events; + delete options.events; + Tone.Part.call(this, options); + /** + * The subdivison of each note + * @type {Ticks} + * @private + */ + this._subdivision = this.toTicks(options.subdivision); + //if no time was passed in, the loop end is the end of the cycle + if (Tone.isUndef(options.loopEnd) && Tone.isDefined(events)) { + this._loopEnd = events.length * this._subdivision; + } + //defaults to looping + this._loop = true; + //add all of the events + if (Tone.isDefined(events)) { + for (var i = 0; i < events.length; i++) { + this.add(i, events[i]); + } + } + }; + Tone.extend(Tone.Sequence, Tone.Part); + /** + * The default values. + * @type {Object} + */ + Tone.Sequence.defaults = { 'subdivision': '4n' }; + /** + * The subdivision of the sequence. This can only be + * set in the constructor. The subdivision is the + * interval between successive steps. + * @type {Time} + * @memberOf Tone.Sequence# + * @name subdivision + * @readOnly + */ + Object.defineProperty(Tone.Sequence.prototype, 'subdivision', { + get: function () { + return Tone.Ticks(this._subdivision).toSeconds(); + } + }); + /** + * Get/Set an index of the sequence. If the index contains a subarray, + * a Tone.Sequence representing that sub-array will be returned. + * @example + * var sequence = new Tone.Sequence(playNote, ["E4", "C4", "F#4", ["A4", "Bb3"]]) + * sequence.at(0)// => returns "E4" + * //set a value + * sequence.at(0, "G3"); + * //get a nested sequence + * sequence.at(3).at(1)// => returns "Bb3" + * @param {Positive} index The index to get or set + * @param {*} value Optionally pass in the value to set at the given index. + */ + Tone.Sequence.prototype.at = function (index, value) { + //if the value is an array, + if (Tone.isArray(value)) { + //remove the current event at that index + this.remove(index); + } + //call the parent's method + return Tone.Part.prototype.at.call(this, this._indexTime(index), value); + }; + /** + * Add an event at an index, if there's already something + * at that index, overwrite it. If `value` is an array, + * it will be parsed as a subsequence. + * @param {Number} index The index to add the event to + * @param {*} value The value to add at that index + * @returns {Tone.Sequence} this + */ + Tone.Sequence.prototype.add = function (index, value) { + if (value === null) { + return this; + } + if (Tone.isArray(value)) { + //make a subsequence and add that to the sequence + var subSubdivision = Math.round(this._subdivision / value.length); + value = new Tone.Sequence(this._tick.bind(this), value, Tone.Ticks(subSubdivision)); + } + Tone.Part.prototype.add.call(this, this._indexTime(index), value); + return this; + }; + /** + * Remove a value from the sequence by index + * @param {Number} index The index of the event to remove + * @returns {Tone.Sequence} this + */ + Tone.Sequence.prototype.remove = function (index, value) { + Tone.Part.prototype.remove.call(this, this._indexTime(index), value); + return this; + }; + /** + * Get the time of the index given the Sequence's subdivision + * @param {Number} index + * @return {Time} The time of that index + * @private + */ + Tone.Sequence.prototype._indexTime = function (index) { + if (index instanceof Tone.TransportTime) { + return index; + } else { + return Tone.Ticks(index * this._subdivision + this.startOffset).toSeconds(); + } + }; + /** + * Clean up. + * @return {Tone.Sequence} this + */ + Tone.Sequence.prototype.dispose = function () { + Tone.Part.prototype.dispose.call(this); + return this; + }; + return Tone.Sequence; + }); + Module(function (Tone) { + + /** + * @class Tone.PulseOscillator is a pulse oscillator with control over pulse width, + * also known as the duty cycle. At 50% duty cycle (width = 0.5) the wave is + * a square and only odd-numbered harmonics are present. At all other widths + * even-numbered harmonics are present. Read more + * [here](https://wigglewave.wordpress.com/2014/08/16/pulse-waveforms-and-harmonics/). + * + * @constructor + * @extends {Tone.Source} + * @param {Frequency} [frequency] The frequency of the oscillator + * @param {NormalRange} [width] The width of the pulse + * @example + * var pulse = new Tone.PulseOscillator("E5", 0.4).toMaster().start(); + */ + Tone.PulseOscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'width' + ], Tone.Oscillator); + Tone.Source.call(this, options); + /** + * The width of the pulse. + * @type {NormalRange} + * @signal + */ + this.width = new Tone.Signal(options.width, Tone.Type.NormalRange); + /** + * gate the width amount + * @type {Tone.Gain} + * @private + */ + this._widthGate = new Tone.Gain(); + /** + * the sawtooth oscillator + * @type {Tone.Oscillator} + * @private + */ + this._sawtooth = new Tone.Oscillator({ + frequency: options.frequency, + detune: options.detune, + type: 'sawtooth', + phase: options.phase + }); + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = this._sawtooth.frequency; + /** + * The detune in cents. + * @type {Cents} + * @signal + */ + this.detune = this._sawtooth.detune; + /** + * Threshold the signal to turn it into a square + * @type {Tone.WaveShaper} + * @private + */ + this._thresh = new Tone.WaveShaper(function (val) { + if (val < 0) { + return -1; + } else { + return 1; + } + }); + //connections + this._sawtooth.chain(this._thresh, this.output); + this.width.chain(this._widthGate, this._thresh); + this._readOnly([ + 'width', + 'frequency', + 'detune' + ]); + }; + Tone.extend(Tone.PulseOscillator, Tone.Source); + /** + * The default parameters. + * @static + * @const + * @type {Object} + */ + Tone.PulseOscillator.defaults = { + 'frequency': 440, + 'detune': 0, + 'phase': 0, + 'width': 0.2 + }; + /** + * start the oscillator + * @param {Time} time + * @private + */ + Tone.PulseOscillator.prototype._start = function (time) { + time = this.toSeconds(time); + this._sawtooth.start(time); + this._widthGate.gain.setValueAtTime(1, time); + }; + /** + * stop the oscillator + * @param {Time} time + * @private + */ + Tone.PulseOscillator.prototype._stop = function (time) { + time = this.toSeconds(time); + this._sawtooth.stop(time); + //the width is still connected to the output. + //that needs to be stopped also + this._widthGate.gain.setValueAtTime(0, time); + }; + /** + * restart the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.PulseOscillator.prototype.restart = function (time) { + this._sawtooth.restart(time); + }; + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.PulseOscillator# + * @type {Degrees} + * @name phase + */ + Object.defineProperty(Tone.PulseOscillator.prototype, 'phase', { + get: function () { + return this._sawtooth.phase; + }, + set: function (phase) { + this._sawtooth.phase = phase; + } + }); + /** + * The type of the oscillator. Always returns "pulse". + * @readOnly + * @memberOf Tone.PulseOscillator# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.PulseOscillator.prototype, 'type', { + get: function () { + return 'pulse'; + } + }); + /** + * The partials of the waveform. Cannot set partials for this waveform type + * @memberOf Tone.PulseOscillator# + * @type {Array} + * @name partials + * @private + */ + Object.defineProperty(Tone.PulseOscillator.prototype, 'partials', { + get: function () { + return []; + } + }); + /** + * Clean up method. + * @return {Tone.PulseOscillator} this + */ + Tone.PulseOscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this._sawtooth.dispose(); + this._sawtooth = null; + this._writable([ + 'width', + 'frequency', + 'detune' + ]); + this.width.dispose(); + this.width = null; + this._widthGate.dispose(); + this._widthGate = null; + this._thresh.dispose(); + this._thresh = null; + this.frequency = null; + this.detune = null; + return this; + }; + return Tone.PulseOscillator; + }); + Module(function (Tone) { + + /** + * @class Tone.PWMOscillator modulates the width of a Tone.PulseOscillator + * at the modulationFrequency. This has the effect of continuously + * changing the timbre of the oscillator by altering the harmonics + * generated. + * + * @extends {Tone.Source} + * @constructor + * @param {Frequency} frequency The starting frequency of the oscillator. + * @param {Frequency} modulationFrequency The modulation frequency of the width of the pulse. + * @example + * var pwm = new Tone.PWMOscillator("Ab3", 0.3).toMaster().start(); + */ + Tone.PWMOscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'modulationFrequency' + ], Tone.PWMOscillator); + Tone.Source.call(this, options); + /** + * the pulse oscillator + * @type {Tone.PulseOscillator} + * @private + */ + this._pulse = new Tone.PulseOscillator(options.modulationFrequency); + //change the pulse oscillator type + this._pulse._sawtooth.type = 'sine'; + /** + * the modulator + * @type {Tone.Oscillator} + * @private + */ + this._modulator = new Tone.Oscillator({ + 'frequency': options.frequency, + 'detune': options.detune, + 'phase': options.phase + }); + /** + * Scale the oscillator so it doesn't go silent + * at the extreme values. + * @type {Tone.Multiply} + * @private + */ + this._scale = new Tone.Multiply(2); + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = this._modulator.frequency; + /** + * The detune of the oscillator. + * @type {Cents} + * @signal + */ + this.detune = this._modulator.detune; + /** + * The modulation rate of the oscillator. + * @type {Frequency} + * @signal + */ + this.modulationFrequency = this._pulse.frequency; + //connections + this._modulator.chain(this._scale, this._pulse.width); + this._pulse.connect(this.output); + this._readOnly([ + 'modulationFrequency', + 'frequency', + 'detune' + ]); + }; + Tone.extend(Tone.PWMOscillator, Tone.Source); + /** + * default values + * @static + * @type {Object} + * @const + */ + Tone.PWMOscillator.defaults = { + 'frequency': 440, + 'detune': 0, + 'phase': 0, + 'modulationFrequency': 0.4 + }; + /** + * start the oscillator + * @param {Time} [time=now] + * @private + */ + Tone.PWMOscillator.prototype._start = function (time) { + time = this.toSeconds(time); + this._modulator.start(time); + this._pulse.start(time); + }; + /** + * stop the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.PWMOscillator.prototype._stop = function (time) { + time = this.toSeconds(time); + this._modulator.stop(time); + this._pulse.stop(time); + }; + /** + * restart the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.PWMOscillator.prototype.restart = function (time) { + this._modulator.restart(time); + this._pulse.restart(time); + }; + /** + * The type of the oscillator. Always returns "pwm". + * @readOnly + * @memberOf Tone.PWMOscillator# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.PWMOscillator.prototype, 'type', { + get: function () { + return 'pwm'; + } + }); + /** + * The partials of the waveform. Cannot set partials for this waveform type + * @memberOf Tone.PWMOscillator# + * @type {Array} + * @name partials + * @private + */ + Object.defineProperty(Tone.PWMOscillator.prototype, 'partials', { + get: function () { + return []; + } + }); + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.PWMOscillator# + * @type {number} + * @name phase + */ + Object.defineProperty(Tone.PWMOscillator.prototype, 'phase', { + get: function () { + return this._modulator.phase; + }, + set: function (phase) { + this._modulator.phase = phase; + } + }); + /** + * Clean up. + * @return {Tone.PWMOscillator} this + */ + Tone.PWMOscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this._pulse.dispose(); + this._pulse = null; + this._scale.dispose(); + this._scale = null; + this._modulator.dispose(); + this._modulator = null; + this._writable([ + 'modulationFrequency', + 'frequency', + 'detune' + ]); + this.frequency = null; + this.detune = null; + this.modulationFrequency = null; + return this; + }; + return Tone.PWMOscillator; + }); + Module(function (Tone) { + + /** + * @class Tone.FMOscillator + * + * @extends {Tone.Source} + * @constructor + * @param {Frequency} frequency The starting frequency of the oscillator. + * @param {String} type The type of the carrier oscillator. + * @param {String} modulationType The type of the modulator oscillator. + * @example + * //a sine oscillator frequency-modulated by a square wave + * var fmOsc = new Tone.FMOscillator("Ab3", "sine", "square").toMaster().start(); + */ + Tone.FMOscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type', + 'modulationType' + ], Tone.FMOscillator); + Tone.Source.call(this, options); + /** + * The carrier oscillator + * @type {Tone.Oscillator} + * @private + */ + this._carrier = new Tone.Oscillator(options.frequency, options.type); + /** + * The oscillator's frequency + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The detune control signal. + * @type {Cents} + * @signal + */ + this.detune = this._carrier.detune; + this.detune.value = options.detune; + /** + * The modulation index which is in essence the depth or amount of the modulation. In other terms it is the + * ratio of the frequency of the modulating signal (mf) to the amplitude of the + * modulating signal (ma) -- as in ma/mf. + * @type {Positive} + * @signal + */ + this.modulationIndex = new Tone.Multiply(options.modulationIndex); + this.modulationIndex.units = Tone.Type.Positive; + /** + * The modulating oscillator + * @type {Tone.Oscillator} + * @private + */ + this._modulator = new Tone.Oscillator(options.frequency, options.modulationType); + /** + * Harmonicity is the frequency ratio between the carrier and the modulator oscillators. + * A harmonicity of 1 gives both oscillators the same frequency. + * Harmonicity = 2 means a change of an octave. + * @type {Positive} + * @signal + * @example + * //pitch the modulator an octave below carrier + * synth.harmonicity.value = 0.5; + */ + this.harmonicity = new Tone.Multiply(options.harmonicity); + this.harmonicity.units = Tone.Type.Positive; + /** + * the node where the modulation happens + * @type {Tone.Gain} + * @private + */ + this._modulationNode = new Tone.Gain(0); + //connections + this.frequency.connect(this._carrier.frequency); + this.frequency.chain(this.harmonicity, this._modulator.frequency); + this.frequency.chain(this.modulationIndex, this._modulationNode); + this._modulator.connect(this._modulationNode.gain); + this._modulationNode.connect(this._carrier.frequency); + this._carrier.connect(this.output); + this.detune.connect(this._modulator.detune); + this.phase = options.phase; + this._readOnly([ + 'modulationIndex', + 'frequency', + 'detune', + 'harmonicity' + ]); + }; + Tone.extend(Tone.FMOscillator, Tone.Source); + /** + * default values + * @static + * @type {Object} + * @const + */ + Tone.FMOscillator.defaults = { + 'frequency': 440, + 'detune': 0, + 'phase': 0, + 'modulationIndex': 2, + 'modulationType': 'square', + 'harmonicity': 1 + }; + /** + * start the oscillator + * @param {Time} [time=now] + * @private + */ + Tone.FMOscillator.prototype._start = function (time) { + this._modulator.start(time); + this._carrier.start(time); + }; + /** + * stop the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.FMOscillator.prototype._stop = function (time) { + this._modulator.stop(time); + this._carrier.stop(time); + }; + /** + * stop the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.FMOscillator.prototype.restart = function (time) { + this._modulator.restart(time); + this._carrier.restart(time); + }; + /** + * The type of the carrier oscillator + * @memberOf Tone.FMOscillator# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.FMOscillator.prototype, 'type', { + get: function () { + return this._carrier.type; + }, + set: function (type) { + this._carrier.type = type; + } + }); + /** + * The type of the modulator oscillator + * @memberOf Tone.FMOscillator# + * @type {String} + * @name modulationType + */ + Object.defineProperty(Tone.FMOscillator.prototype, 'modulationType', { + get: function () { + return this._modulator.type; + }, + set: function (type) { + this._modulator.type = type; + } + }); + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.FMOscillator# + * @type {number} + * @name phase + */ + Object.defineProperty(Tone.FMOscillator.prototype, 'phase', { + get: function () { + return this._carrier.phase; + }, + set: function (phase) { + this._carrier.phase = phase; + this._modulator.phase = phase; + } + }); + /** + * The partials of the carrier waveform. A partial represents + * the amplitude at a harmonic. The first harmonic is the + * fundamental frequency, the second is the octave and so on + * following the harmonic series. + * Setting this value will automatically set the type to "custom". + * The value is an empty array when the type is not "custom". + * @memberOf Tone.FMOscillator# + * @type {Array} + * @name partials + * @example + * osc.partials = [1, 0.2, 0.01]; + */ + Object.defineProperty(Tone.FMOscillator.prototype, 'partials', { + get: function () { + return this._carrier.partials; + }, + set: function (partials) { + this._carrier.partials = partials; + } + }); + /** + * Clean up. + * @return {Tone.FMOscillator} this + */ + Tone.FMOscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this._writable([ + 'modulationIndex', + 'frequency', + 'detune', + 'harmonicity' + ]); + this.frequency.dispose(); + this.frequency = null; + this.detune = null; + this.harmonicity.dispose(); + this.harmonicity = null; + this._carrier.dispose(); + this._carrier = null; + this._modulator.dispose(); + this._modulator = null; + this._modulationNode.dispose(); + this._modulationNode = null; + this.modulationIndex.dispose(); + this.modulationIndex = null; + return this; + }; + return Tone.FMOscillator; + }); + Module(function (Tone) { + + /** + * @class Tone.AMOscillator + * + * @extends {Tone.Oscillator} + * @constructor + * @param {Frequency} frequency The starting frequency of the oscillator. + * @param {String} type The type of the carrier oscillator. + * @param {String} modulationType The type of the modulator oscillator. + * @example + * //a sine oscillator frequency-modulated by a square wave + * var fmOsc = new Tone.AMOscillator("Ab3", "sine", "square").toMaster().start(); + */ + Tone.AMOscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type', + 'modulationType' + ], Tone.AMOscillator); + Tone.Source.call(this, options); + /** + * The carrier oscillator + * @type {Tone.Oscillator} + * @private + */ + this._carrier = new Tone.Oscillator(options.frequency, options.type); + /** + * The oscillator's frequency + * @type {Frequency} + * @signal + */ + this.frequency = this._carrier.frequency; + /** + * The detune control signal. + * @type {Cents} + * @signal + */ + this.detune = this._carrier.detune; + this.detune.value = options.detune; + /** + * The modulating oscillator + * @type {Tone.Oscillator} + * @private + */ + this._modulator = new Tone.Oscillator(options.frequency, options.modulationType); + /** + * convert the -1,1 output to 0,1 + * @type {Tone.AudioToGain} + * @private + */ + this._modulationScale = new Tone.AudioToGain(); + /** + * Harmonicity is the frequency ratio between the carrier and the modulator oscillators. + * A harmonicity of 1 gives both oscillators the same frequency. + * Harmonicity = 2 means a change of an octave. + * @type {Positive} + * @signal + * @example + * //pitch the modulator an octave below carrier + * synth.harmonicity.value = 0.5; + */ + this.harmonicity = new Tone.Multiply(options.harmonicity); + this.harmonicity.units = Tone.Type.Positive; + /** + * the node where the modulation happens + * @type {Tone.Gain} + * @private + */ + this._modulationNode = new Tone.Gain(0); + //connections + this.frequency.chain(this.harmonicity, this._modulator.frequency); + this.detune.connect(this._modulator.detune); + this._modulator.chain(this._modulationScale, this._modulationNode.gain); + this._carrier.chain(this._modulationNode, this.output); + this.phase = options.phase; + this._readOnly([ + 'frequency', + 'detune', + 'harmonicity' + ]); + }; + Tone.extend(Tone.AMOscillator, Tone.Oscillator); + /** + * default values + * @static + * @type {Object} + * @const + */ + Tone.AMOscillator.defaults = { + 'frequency': 440, + 'detune': 0, + 'phase': 0, + 'modulationType': 'square', + 'harmonicity': 1 + }; + /** + * start the oscillator + * @param {Time} [time=now] + * @private + */ + Tone.AMOscillator.prototype._start = function (time) { + this._modulator.start(time); + this._carrier.start(time); + }; + /** + * stop the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.AMOscillator.prototype._stop = function (time) { + this._modulator.stop(time); + this._carrier.stop(time); + }; + /** + * restart the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.AMOscillator.prototype.restart = function (time) { + this._modulator.restart(time); + this._carrier.restart(time); + }; + /** + * The type of the carrier oscillator + * @memberOf Tone.AMOscillator# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.AMOscillator.prototype, 'type', { + get: function () { + return this._carrier.type; + }, + set: function (type) { + this._carrier.type = type; + } + }); + /** + * The type of the modulator oscillator + * @memberOf Tone.AMOscillator# + * @type {string} + * @name modulationType + */ + Object.defineProperty(Tone.AMOscillator.prototype, 'modulationType', { + get: function () { + return this._modulator.type; + }, + set: function (type) { + this._modulator.type = type; + } + }); + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.AMOscillator# + * @type {number} + * @name phase + */ + Object.defineProperty(Tone.AMOscillator.prototype, 'phase', { + get: function () { + return this._carrier.phase; + }, + set: function (phase) { + this._carrier.phase = phase; + this._modulator.phase = phase; + } + }); + /** + * The partials of the carrier waveform. A partial represents + * the amplitude at a harmonic. The first harmonic is the + * fundamental frequency, the second is the octave and so on + * following the harmonic series. + * Setting this value will automatically set the type to "custom". + * The value is an empty array when the type is not "custom". + * @memberOf Tone.AMOscillator# + * @type {Array} + * @name partials + * @example + * osc.partials = [1, 0.2, 0.01]; + */ + Object.defineProperty(Tone.AMOscillator.prototype, 'partials', { + get: function () { + return this._carrier.partials; + }, + set: function (partials) { + this._carrier.partials = partials; + } + }); + /** + * Clean up. + * @return {Tone.AMOscillator} this + */ + Tone.AMOscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'detune', + 'harmonicity' + ]); + this.frequency = null; + this.detune = null; + this.harmonicity.dispose(); + this.harmonicity = null; + this._carrier.dispose(); + this._carrier = null; + this._modulator.dispose(); + this._modulator = null; + this._modulationNode.dispose(); + this._modulationNode = null; + this._modulationScale.dispose(); + this._modulationScale = null; + return this; + }; + return Tone.AMOscillator; + }); + Module(function (Tone) { + + /** + * @class Tone.FatOscillator + * + * @extends {Tone.Source} + * @constructor + * @param {Frequency} frequency The starting frequency of the oscillator. + * @param {String} type The type of the carrier oscillator. + * @param {String} modulationType The type of the modulator oscillator. + * @example + * //a sine oscillator frequency-modulated by a square wave + * var fmOsc = new Tone.FatOscillator("Ab3", "sine", "square").toMaster().start(); + */ + Tone.FatOscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type', + 'spread' + ], Tone.FatOscillator); + Tone.Source.call(this, options); + /** + * The oscillator's frequency + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The detune control signal. + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(options.detune, Tone.Type.Cents); + /** + * The array of oscillators + * @type {Array} + * @private + */ + this._oscillators = []; + /** + * The total spread of the oscillators + * @type {Cents} + * @private + */ + this._spread = options.spread; + /** + * The type of the oscillator + * @type {String} + * @private + */ + this._type = options.type; + /** + * The phase of the oscillators + * @type {Degrees} + * @private + */ + this._phase = options.phase; + /** + * The partials array + * @type {Array} + * @private + */ + this._partials = Tone.defaultArg(options.partials, []); + //set the count initially + this.count = options.count; + this._readOnly([ + 'frequency', + 'detune' + ]); + }; + Tone.extend(Tone.FatOscillator, Tone.Source); + /** + * default values + * @static + * @type {Object} + * @const + */ + Tone.FatOscillator.defaults = { + 'frequency': 440, + 'detune': 0, + 'phase': 0, + 'spread': 20, + 'count': 3, + 'type': 'sawtooth' + }; + /** + * start the oscillator + * @param {Time} [time=now] + * @private + */ + Tone.FatOscillator.prototype._start = function (time) { + time = this.toSeconds(time); + this._forEach(function (osc) { + osc.start(time); + }); + }; + /** + * stop the oscillator + * @param {Time} [time=now] + * @private + */ + Tone.FatOscillator.prototype._stop = function (time) { + time = this.toSeconds(time); + this._forEach(function (osc) { + osc.stop(time); + }); + }; + /** + * restart the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.FatOscillator.prototype.restart = function (time) { + time = this.toSeconds(time); + this._forEach(function (osc) { + osc.restart(time); + }); + }; + /** + * Iterate over all of the oscillators + * @param {Function} iterator The iterator function + * @private + */ + Tone.FatOscillator.prototype._forEach = function (iterator) { + for (var i = 0; i < this._oscillators.length; i++) { + iterator.call(this, this._oscillators[i], i); + } + }; + /** + * The type of the carrier oscillator + * @memberOf Tone.FatOscillator# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.FatOscillator.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + this._type = type; + this._forEach(function (osc) { + osc.type = type; + }); + } + }); + /** + * The detune spread between the oscillators. If "count" is + * set to 3 oscillators and the "spread" is set to 40, + * the three oscillators would be detuned like this: [-20, 0, 20] + * for a total detune spread of 40 cents. + * @memberOf Tone.FatOscillator# + * @type {Cents} + * @name spread + */ + Object.defineProperty(Tone.FatOscillator.prototype, 'spread', { + get: function () { + return this._spread; + }, + set: function (spread) { + this._spread = spread; + if (this._oscillators.length > 1) { + var start = -spread / 2; + var step = spread / (this._oscillators.length - 1); + this._forEach(function (osc, i) { + osc.detune.value = start + step * i; + }); + } + } + }); + /** + * The number of detuned oscillators + * @memberOf Tone.FatOscillator# + * @type {Number} + * @name count + */ + Object.defineProperty(Tone.FatOscillator.prototype, 'count', { + get: function () { + return this._oscillators.length; + }, + set: function (count) { + count = Math.max(count, 1); + if (this._oscillators.length !== count) { + // var partials = this.partials; + // var type = this.type; + //dispose the previous oscillators + this._forEach(function (osc) { + osc.dispose(); + }); + this._oscillators = []; + for (var i = 0; i < count; i++) { + var osc = new Tone.Oscillator(); + if (this.type === Tone.Oscillator.Type.Custom) { + osc.partials = this._partials; + } else { + osc.type = this._type; + } + osc.phase = this._phase; + osc.volume.value = -6 - count * 1.1; + this.frequency.connect(osc.frequency); + this.detune.connect(osc.detune); + osc.connect(this.output); + this._oscillators[i] = osc; + } + //set the spread + this.spread = this._spread; + if (this.state === Tone.State.Started) { + this._forEach(function (osc) { + osc.start(); + }); + } + } + } + }); + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.FatOscillator# + * @type {Number} + * @name phase + */ + Object.defineProperty(Tone.FatOscillator.prototype, 'phase', { + get: function () { + return this._phase; + }, + set: function (phase) { + this._phase = phase; + this._forEach(function (osc) { + osc.phase = phase; + }); + } + }); + /** + * The partials of the carrier waveform. A partial represents + * the amplitude at a harmonic. The first harmonic is the + * fundamental frequency, the second is the octave and so on + * following the harmonic series. + * Setting this value will automatically set the type to "custom". + * The value is an empty array when the type is not "custom". + * @memberOf Tone.FatOscillator# + * @type {Array} + * @name partials + * @example + * osc.partials = [1, 0.2, 0.01]; + */ + Object.defineProperty(Tone.FatOscillator.prototype, 'partials', { + get: function () { + return this._partials; + }, + set: function (partials) { + this._partials = partials; + this._type = Tone.Oscillator.Type.Custom; + this._forEach(function (osc) { + osc.partials = partials; + }); + } + }); + /** + * Clean up. + * @return {Tone.FatOscillator} this + */ + Tone.FatOscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'detune' + ]); + this.frequency.dispose(); + this.frequency = null; + this.detune.dispose(); + this.detune = null; + this._forEach(function (osc) { + osc.dispose(); + }); + this._oscillators = null; + this._partials = null; + return this; + }; + return Tone.FatOscillator; + }); + Module(function (Tone) { + + /** + * @class Tone.OmniOscillator aggregates Tone.Oscillator, Tone.PulseOscillator, + * Tone.PWMOscillator, Tone.FMOscillator, Tone.AMOscillator, and Tone.FatOscillator + * into one class. The oscillator class can be changed by setting the `type`. + * `omniOsc.type = "pwm"` will set it to the Tone.PWMOscillator. Prefixing + * any of the basic types ("sine", "square4", etc.) with "fm", "am", or "fat" + * will use the FMOscillator, AMOscillator or FatOscillator respectively. + * For example: `omniOsc.type = "fatsawtooth"` will create set the oscillator + * to a FatOscillator of type "sawtooth". + * + * @extends {Tone.Source} + * @constructor + * @param {Frequency} frequency The initial frequency of the oscillator. + * @param {String} type The type of the oscillator. + * @example + * var omniOsc = new Tone.OmniOscillator("C#4", "pwm"); + */ + Tone.OmniOscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type' + ], Tone.OmniOscillator); + Tone.Source.call(this, options); + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The detune control + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(options.detune, Tone.Type.Cents); + /** + * the type of the oscillator source + * @type {String} + * @private + */ + this._sourceType = undefined; + /** + * the oscillator + * @type {Tone.Oscillator} + * @private + */ + this._oscillator = null; + //set the oscillator + this.type = options.type; + this._readOnly([ + 'frequency', + 'detune' + ]); + //set the options + this.set(options); + }; + Tone.extend(Tone.OmniOscillator, Tone.Source); + /** + * default values + * @static + * @type {Object} + * @const + */ + Tone.OmniOscillator.defaults = { + 'frequency': 440, + 'detune': 0, + 'type': 'sine', + 'phase': 0 + }; + /** + * @enum {String} + * @private + */ + var OmniOscType = { + Pulse: 'PulseOscillator', + PWM: 'PWMOscillator', + Osc: 'Oscillator', + FM: 'FMOscillator', + AM: 'AMOscillator', + Fat: 'FatOscillator' + }; + /** + * start the oscillator + * @param {Time} [time=now] the time to start the oscillator + * @private + */ + Tone.OmniOscillator.prototype._start = function (time) { + this._oscillator.start(time); + }; + /** + * start the oscillator + * @param {Time} [time=now] the time to start the oscillator + * @private + */ + Tone.OmniOscillator.prototype._stop = function (time) { + this._oscillator.stop(time); + }; + Tone.OmniOscillator.prototype.restart = function (time) { + this._oscillator.restart(time); + }; + /** + * The type of the oscillator. Can be any of the basic types: sine, square, triangle, sawtooth. Or + * prefix the basic types with "fm", "am", or "fat" to use the FMOscillator, AMOscillator or FatOscillator + * types. The oscillator could also be set to "pwm" or "pulse". All of the parameters of the + * oscillator's class are accessible when the oscillator is set to that type, but throws an error + * when it's not. + * + * @memberOf Tone.OmniOscillator# + * @type {String} + * @name type + * @example + * omniOsc.type = "pwm"; + * //modulationFrequency is parameter which is available + * //only when the type is "pwm". + * omniOsc.modulationFrequency.value = 0.5; + * @example + * //an square wave frequency modulated by a sawtooth + * omniOsc.type = "fmsquare"; + * omniOsc.modulationType = "sawtooth"; + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'type', { + get: function () { + var prefix = ''; + if (this._sourceType === OmniOscType.FM) { + prefix = 'fm'; + } else if (this._sourceType === OmniOscType.AM) { + prefix = 'am'; + } else if (this._sourceType === OmniOscType.Fat) { + prefix = 'fat'; + } + return prefix + this._oscillator.type; + }, + set: function (type) { + if (type.substr(0, 2) === 'fm') { + this._createNewOscillator(OmniOscType.FM); + this._oscillator.type = type.substr(2); + } else if (type.substr(0, 2) === 'am') { + this._createNewOscillator(OmniOscType.AM); + this._oscillator.type = type.substr(2); + } else if (type.substr(0, 3) === 'fat') { + this._createNewOscillator(OmniOscType.Fat); + this._oscillator.type = type.substr(3); + } else if (type === 'pwm') { + this._createNewOscillator(OmniOscType.PWM); + } else if (type === 'pulse') { + this._createNewOscillator(OmniOscType.Pulse); + } else { + this._createNewOscillator(OmniOscType.Osc); + this._oscillator.type = type; + } + } + }); + /** + * The partials of the waveform. A partial represents + * the amplitude at a harmonic. The first harmonic is the + * fundamental frequency, the second is the octave and so on + * following the harmonic series. + * Setting this value will automatically set the type to "custom". + * The value is an empty array when the type is not "custom". + * This is not available on "pwm" and "pulse" oscillator types. + * @memberOf Tone.OmniOscillator# + * @type {Array} + * @name partials + * @example + * osc.partials = [1, 0.2, 0.01]; + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'partials', { + get: function () { + return this._oscillator.partials; + }, + set: function (partials) { + this._oscillator.partials = partials; + } + }); + /** + * Set a member/attribute of the oscillator. + * @param {Object|String} params + * @param {number=} value + * @param {Time=} rampTime + * @returns {Tone.OmniOscillator} this + */ + Tone.OmniOscillator.prototype.set = function (params, value) { + //make sure the type is set first + if (params === 'type') { + this.type = value; + } else if (Tone.isObject(params) && params.hasOwnProperty('type')) { + this.type = params.type; + } + //then set the rest + Tone.prototype.set.apply(this, arguments); + return this; + }; + /** + * connect the oscillator to the frequency and detune signals + * @private + */ + Tone.OmniOscillator.prototype._createNewOscillator = function (oscType) { + if (oscType !== this._sourceType) { + this._sourceType = oscType; + var OscillatorConstructor = Tone[oscType]; + //short delay to avoid clicks on the change + var now = this.now(); + if (this._oscillator !== null) { + var oldOsc = this._oscillator; + oldOsc.stop(now); + //dispose the old one + this.context.setTimeout(function () { + oldOsc.dispose(); + oldOsc = null; + }, this.blockTime); + } + this._oscillator = new OscillatorConstructor(); + this.frequency.connect(this._oscillator.frequency); + this.detune.connect(this._oscillator.detune); + this._oscillator.connect(this.output); + if (this.state === Tone.State.Started) { + this._oscillator.start(now); + } + } + }; + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.OmniOscillator# + * @type {Degrees} + * @name phase + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'phase', { + get: function () { + return this._oscillator.phase; + }, + set: function (phase) { + this._oscillator.phase = phase; + } + }); + /** + * The width of the oscillator (only if the oscillator is set to "pulse") + * @memberOf Tone.OmniOscillator# + * @type {NormalRange} + * @signal + * @name width + * @example + * var omniOsc = new Tone.OmniOscillator(440, "pulse"); + * //can access the width attribute only if type === "pulse" + * omniOsc.width.value = 0.2; + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'width', { + get: function () { + if (this._sourceType === OmniOscType.Pulse) { + return this._oscillator.width; + } + } + }); + /** + * The number of detuned oscillators + * @memberOf Tone.OmniOscillator# + * @type {Number} + * @name count + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'count', { + get: function () { + if (this._sourceType === OmniOscType.Fat) { + return this._oscillator.count; + } + }, + set: function (count) { + if (this._sourceType === OmniOscType.Fat) { + this._oscillator.count = count; + } + } + }); + /** + * The detune spread between the oscillators. If "count" is + * set to 3 oscillators and the "spread" is set to 40, + * the three oscillators would be detuned like this: [-20, 0, 20] + * for a total detune spread of 40 cents. See Tone.FatOscillator + * for more info. + * @memberOf Tone.OmniOscillator# + * @type {Cents} + * @name spread + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'spread', { + get: function () { + if (this._sourceType === OmniOscType.Fat) { + return this._oscillator.spread; + } + }, + set: function (spread) { + if (this._sourceType === OmniOscType.Fat) { + this._oscillator.spread = spread; + } + } + }); + /** + * The type of the modulator oscillator. Only if the oscillator + * is set to "am" or "fm" types. see. Tone.AMOscillator or Tone.FMOscillator + * for more info. + * @memberOf Tone.OmniOscillator# + * @type {String} + * @name modulationType + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'modulationType', { + get: function () { + if (this._sourceType === OmniOscType.FM || this._sourceType === OmniOscType.AM) { + return this._oscillator.modulationType; + } + }, + set: function (mType) { + if (this._sourceType === OmniOscType.FM || this._sourceType === OmniOscType.AM) { + this._oscillator.modulationType = mType; + } + } + }); + /** + * The modulation index which is in essence the depth or amount of the modulation. In other terms it is the + * ratio of the frequency of the modulating signal (mf) to the amplitude of the + * modulating signal (ma) -- as in ma/mf. + * See Tone.FMOscillator for more info. + * @type {Positive} + * @signal + * @name modulationIndex + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'modulationIndex', { + get: function () { + if (this._sourceType === OmniOscType.FM) { + return this._oscillator.modulationIndex; + } + } + }); + /** + * Harmonicity is the frequency ratio between the carrier and the modulator oscillators. + * A harmonicity of 1 gives both oscillators the same frequency. + * Harmonicity = 2 means a change of an octave. See Tone.AMOscillator or Tone.FMOscillator + * for more info. + * @memberOf Tone.OmniOscillator# + * @signal + * @type {Positive} + * @name harmonicity + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'harmonicity', { + get: function () { + if (this._sourceType === OmniOscType.FM || this._sourceType === OmniOscType.AM) { + return this._oscillator.harmonicity; + } + } + }); + /** + * The modulationFrequency Signal of the oscillator + * (only if the oscillator type is set to pwm). See + * Tone.PWMOscillator for more info. + * @memberOf Tone.OmniOscillator# + * @type {Frequency} + * @signal + * @name modulationFrequency + * @example + * var omniOsc = new Tone.OmniOscillator(440, "pwm"); + * //can access the modulationFrequency attribute only if type === "pwm" + * omniOsc.modulationFrequency.value = 0.2; + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'modulationFrequency', { + get: function () { + if (this._sourceType === OmniOscType.PWM) { + return this._oscillator.modulationFrequency; + } + } + }); + /** + * Clean up. + * @return {Tone.OmniOscillator} this + */ + Tone.OmniOscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'detune' + ]); + this.detune.dispose(); + this.detune = null; + this.frequency.dispose(); + this.frequency = null; + this._oscillator.dispose(); + this._oscillator = null; + this._sourceType = null; + return this; + }; + return Tone.OmniOscillator; + }); + Module(function (Tone) { + + /** + * @class Base-class for all instruments + * + * @constructor + * @extends {Tone.AudioNode} + */ + Tone.Instrument = function (options) { + //get the defaults + options = Tone.defaultArg(options, Tone.Instrument.defaults); + Tone.AudioNode.call(this); + /** + * The output and volume triming node + * @type {Tone.Volume} + * @private + */ + this._volume = this.output = new Tone.Volume(options.volume); + /** + * The volume of the output in decibels. + * @type {Decibels} + * @signal + * @example + * source.volume.value = -6; + */ + this.volume = this._volume.volume; + this._readOnly('volume'); + /** + * Keep track of all events scheduled to the transport + * when the instrument is 'synced' + * @type {Array<Number>} + * @private + */ + this._scheduledEvents = []; + }; + Tone.extend(Tone.Instrument, Tone.AudioNode); + /** + * the default attributes + * @type {object} + */ + Tone.Instrument.defaults = { + /** the volume of the output in decibels */ + 'volume': 0 + }; + /** + * @abstract + * @param {string|number} note the note to trigger + * @param {Time} [time=now] the time to trigger the ntoe + * @param {number} [velocity=1] the velocity to trigger the note + */ + Tone.Instrument.prototype.triggerAttack = Tone.noOp; + /** + * @abstract + * @param {Time} [time=now] when to trigger the release + */ + Tone.Instrument.prototype.triggerRelease = Tone.noOp; + /** + * Sync the instrument to the Transport. All subsequent calls of + * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease) + * will be scheduled along the transport. + * @example + * instrument.sync() + * //schedule 3 notes when the transport first starts + * instrument.triggerAttackRelease('C4', '8n', 0) + * instrument.triggerAttackRelease('E4', '8n', '8n') + * instrument.triggerAttackRelease('G4', '8n', '4n') + * //start the transport to hear the notes + * Transport.start() + * @returns {Tone.Instrument} this + */ + Tone.Instrument.prototype.sync = function () { + this._syncMethod('triggerAttack', 1); + this._syncMethod('triggerRelease', 0); + return this; + }; + /** + * Wrap the given method so that it can be synchronized + * @param {String} method Which method to wrap and sync + * @param {Number} timePosition What position the time argument appears in + * @private + */ + Tone.Instrument.prototype._syncMethod = function (method, timePosition) { + var originalMethod = this['_original_' + method] = this[method]; + this[method] = function () { + var args = Array.prototype.slice.call(arguments); + var time = args[timePosition]; + var id = Tone.Transport.schedule(function (t) { + args[timePosition] = t; + originalMethod.apply(this, args); + }.bind(this), time); + this._scheduledEvents.push(id); + }.bind(this); + }; + /** + * Unsync the instrument from the Transport + * @returns {Tone.Instrument} this + */ + Tone.Instrument.prototype.unsync = function () { + this._scheduledEvents.forEach(function (id) { + Tone.Transport.clear(id); + }); + this._scheduledEvents = []; + if (this._original_triggerAttack) { + this.triggerAttack = this._original_triggerAttack; + this.triggerRelease = this._original_triggerRelease; + } + return this; + }; + /** + * Trigger the attack and then the release after the duration. + * @param {Frequency} note The note to trigger. + * @param {Time} duration How long the note should be held for before + * triggering the release. This value must be greater than 0. + * @param {Time} [time=now] When the note should be triggered. + * @param {NormalRange} [velocity=1] The velocity the note should be triggered at. + * @returns {Tone.Instrument} this + * @example + * //trigger "C4" for the duration of an 8th note + * synth.triggerAttackRelease("C4", "8n"); + */ + Tone.Instrument.prototype.triggerAttackRelease = function (note, duration, time, velocity) { + time = this.toSeconds(time); + duration = this.toSeconds(duration); + this.triggerAttack(note, time, velocity); + this.triggerRelease(time + duration); + return this; + }; + /** + * clean up + * @returns {Tone.Instrument} this + */ + Tone.Instrument.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._volume.dispose(); + this._volume = null; + this._writable(['volume']); + this.volume = null; + this.unsync(); + this._scheduledEvents = null; + return this; + }; + return Tone.Instrument; + }); + Module(function (Tone) { + + /** + * @class This is an abstract base class for other monophonic instruments to + * extend. IMPORTANT: It does not make any sound on its own and + * shouldn't be directly instantiated. + * + * @constructor + * @abstract + * @extends {Tone.Instrument} + */ + Tone.Monophonic = function (options) { + //get the defaults + options = Tone.defaultArg(options, Tone.Monophonic.defaults); + Tone.Instrument.call(this, options); + /** + * The glide time between notes. + * @type {Time} + */ + this.portamento = options.portamento; + }; + Tone.extend(Tone.Monophonic, Tone.Instrument); + /** + * @static + * @const + * @type {Object} + */ + Tone.Monophonic.defaults = { 'portamento': 0 }; + /** + * Trigger the attack of the note optionally with a given velocity. + * + * + * @param {Frequency} note The note to trigger. + * @param {Time} [time=now] When the note should start. + * @param {number} [velocity=1] velocity The velocity scaler + * determines how "loud" the note + * will be triggered. + * @returns {Tone.Monophonic} this + * @example + * synth.triggerAttack("C4"); + * @example + * //trigger the note a half second from now at half velocity + * synth.triggerAttack("C4", "+0.5", 0.5); + */ + Tone.Monophonic.prototype.triggerAttack = function (note, time, velocity) { + time = this.toSeconds(time); + this._triggerEnvelopeAttack(time, velocity); + this.setNote(note, time); + return this; + }; + /** + * Trigger the release portion of the envelope + * @param {Time} [time=now] If no time is given, the release happens immediatly + * @returns {Tone.Monophonic} this + * @example + * synth.triggerRelease(); + */ + Tone.Monophonic.prototype.triggerRelease = function (time) { + time = this.toSeconds(time); + this._triggerEnvelopeRelease(time); + return this; + }; + /** + * override this method with the actual method + * @abstract + * @private + */ + Tone.Monophonic.prototype._triggerEnvelopeAttack = function () { + }; + /** + * override this method with the actual method + * @abstract + * @private + */ + Tone.Monophonic.prototype._triggerEnvelopeRelease = function () { + }; + /** + * Get the level of the output at the given time. Measures + * the envelope(s) value at the time. + * @param {Time} time The time to query the envelope value + * @return {NormalRange} The output level between 0-1 + */ + Tone.Monophonic.prototype.getLevelAtTime = function (time) { + time = this.toSeconds(time); + return this.envelope.getValueAtTime(time); + }; + /** + * Set the note at the given time. If no time is given, the note + * will set immediately. + * @param {Frequency} note The note to change to. + * @param {Time} [time=now] The time when the note should be set. + * @returns {Tone.Monophonic} this + * @example + * //change to F#6 in one quarter note from now. + * synth.setNote("F#6", "+4n"); + * @example + * //change to Bb4 right now + * synth.setNote("Bb4"); + */ + Tone.Monophonic.prototype.setNote = function (note, time) { + time = this.toSeconds(time); + if (this.portamento > 0 && this.getLevelAtTime(time) > 0.05) { + var portTime = this.toSeconds(this.portamento); + this.frequency.exponentialRampTo(note, portTime, time); + } else { + this.frequency.setValueAtTime(note, time); + } + return this; + }; + return Tone.Monophonic; + }); + Module(function (Tone) { + + /** + * @class Tone.Synth is composed simply of a Tone.OmniOscillator + * routed through a Tone.AmplitudeEnvelope. + * <img src="https://docs.google.com/drawings/d/1-1_0YW2Z1J2EPI36P8fNCMcZG7N1w1GZluPs4og4evo/pub?w=1163&h=231"> + * + * @constructor + * @extends {Tone.Monophonic} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var synth = new Tone.Synth().toMaster(); + * synth.triggerAttackRelease("C4", "8n"); + */ + Tone.Synth = function (options) { + //get the defaults + options = Tone.defaultArg(options, Tone.Synth.defaults); + Tone.Monophonic.call(this, options); + /** + * The oscillator. + * @type {Tone.OmniOscillator} + */ + this.oscillator = new Tone.OmniOscillator(options.oscillator); + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = this.oscillator.frequency; + /** + * The detune control. + * @type {Cents} + * @signal + */ + this.detune = this.oscillator.detune; + /** + * The amplitude envelope. + * @type {Tone.AmplitudeEnvelope} + */ + this.envelope = new Tone.AmplitudeEnvelope(options.envelope); + //connect the oscillators to the output + this.oscillator.chain(this.envelope, this.output); + this._readOnly([ + 'oscillator', + 'frequency', + 'detune', + 'envelope' + ]); + }; + Tone.extend(Tone.Synth, Tone.Monophonic); + /** + * @const + * @static + * @type {Object} + */ + Tone.Synth.defaults = { + 'oscillator': { 'type': 'triangle' }, + 'envelope': { + 'attack': 0.005, + 'decay': 0.1, + 'sustain': 0.3, + 'release': 1 + } + }; + /** + * start the attack portion of the envelope + * @param {Time} [time=now] the time the attack should start + * @param {number} [velocity=1] the velocity of the note (0-1) + * @returns {Tone.Synth} this + * @private + */ + Tone.Synth.prototype._triggerEnvelopeAttack = function (time, velocity) { + //the envelopes + this.envelope.triggerAttack(time, velocity); + this.oscillator.start(time); + //if there is no release portion, stop the oscillator + if (this.envelope.sustain === 0) { + this.oscillator.stop(time + this.envelope.attack + this.envelope.decay); + } + return this; + }; + /** + * start the release portion of the envelope + * @param {Time} [time=now] the time the release should start + * @returns {Tone.Synth} this + * @private + */ + Tone.Synth.prototype._triggerEnvelopeRelease = function (time) { + time = this.toSeconds(time); + this.envelope.triggerRelease(time); + this.oscillator.stop(time + this.envelope.release); + return this; + }; + /** + * clean up + * @returns {Tone.Synth} this + */ + Tone.Synth.prototype.dispose = function () { + Tone.Monophonic.prototype.dispose.call(this); + this._writable([ + 'oscillator', + 'frequency', + 'detune', + 'envelope' + ]); + this.oscillator.dispose(); + this.oscillator = null; + this.envelope.dispose(); + this.envelope = null; + this.frequency = null; + this.detune = null; + return this; + }; + return Tone.Synth; + }); + Module(function (Tone) { + + /** + * @class AMSynth uses the output of one Tone.Synth to modulate the + * amplitude of another Tone.Synth. The harmonicity (the ratio between + * the two signals) affects the timbre of the output signal greatly. + * Read more about Amplitude Modulation Synthesis on + * [SoundOnSound](https://web.archive.org/web/20160404103653/http://www.soundonsound.com:80/sos/mar00/articles/synthsecrets.htm). + * <img src="https://docs.google.com/drawings/d/1TQu8Ed4iFr1YTLKpB3U1_hur-UwBrh5gdBXc8BxfGKw/pub?w=1009&h=457"> + * + * @constructor + * @extends {Tone.Monophonic} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var synth = new Tone.AMSynth().toMaster(); + * synth.triggerAttackRelease("C4", "4n"); + */ + Tone.AMSynth = function (options) { + options = Tone.defaultArg(options, Tone.AMSynth.defaults); + Tone.Monophonic.call(this, options); + /** + * The carrier voice. + * @type {Tone.Synth} + * @private + */ + this._carrier = new Tone.Synth(); + this._carrier.volume.value = -10; + /** + * The carrier's oscillator + * @type {Tone.Oscillator} + */ + this.oscillator = this._carrier.oscillator; + /** + * The carrier's envelope + * @type {Tone.AmplitudeEnvelope} + */ + this.envelope = this._carrier.envelope.set(options.envelope); + /** + * The modulator voice. + * @type {Tone.Synth} + * @private + */ + this._modulator = new Tone.Synth(); + this._modulator.volume.value = -10; + /** + * The modulator's oscillator which is applied + * to the amplitude of the oscillator + * @type {Tone.Oscillator} + */ + this.modulation = this._modulator.oscillator.set(options.modulation); + /** + * The modulator's envelope + * @type {Tone.AmplitudeEnvelope} + */ + this.modulationEnvelope = this._modulator.envelope.set(options.modulationEnvelope); + /** + * The frequency. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(440, Tone.Type.Frequency); + /** + * The detune in cents + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(options.detune, Tone.Type.Cents); + /** + * Harmonicity is the ratio between the two voices. A harmonicity of + * 1 is no change. Harmonicity = 2 means a change of an octave. + * @type {Positive} + * @signal + * @example + * //pitch voice1 an octave below voice0 + * synth.harmonicity.value = 0.5; + */ + this.harmonicity = new Tone.Multiply(options.harmonicity); + this.harmonicity.units = Tone.Type.Positive; + /** + * convert the -1,1 output to 0,1 + * @type {Tone.AudioToGain} + * @private + */ + this._modulationScale = new Tone.AudioToGain(); + /** + * the node where the modulation happens + * @type {Tone.Gain} + * @private + */ + this._modulationNode = new Tone.Gain(); + //control the two voices frequency + this.frequency.connect(this._carrier.frequency); + this.frequency.chain(this.harmonicity, this._modulator.frequency); + this.detune.fan(this._carrier.detune, this._modulator.detune); + this._modulator.chain(this._modulationScale, this._modulationNode.gain); + this._carrier.chain(this._modulationNode, this.output); + this._readOnly([ + 'frequency', + 'harmonicity', + 'oscillator', + 'envelope', + 'modulation', + 'modulationEnvelope', + 'detune' + ]); + }; + Tone.extend(Tone.AMSynth, Tone.Monophonic); + /** + * @static + * @type {Object} + */ + Tone.AMSynth.defaults = { + 'harmonicity': 3, + 'detune': 0, + 'oscillator': { 'type': 'sine' }, + 'envelope': { + 'attack': 0.01, + 'decay': 0.01, + 'sustain': 1, + 'release': 0.5 + }, + 'modulation': { 'type': 'square' }, + 'modulationEnvelope': { + 'attack': 0.5, + 'decay': 0, + 'sustain': 1, + 'release': 0.5 + } + }; + /** + * trigger the attack portion of the note + * + * @param {Time} [time=now] the time the note will occur + * @param {NormalRange} [velocity=1] the velocity of the note + * @private + * @returns {Tone.AMSynth} this + */ + Tone.AMSynth.prototype._triggerEnvelopeAttack = function (time, velocity) { + //the port glide + time = this.toSeconds(time); + //the envelopes + this._carrier._triggerEnvelopeAttack(time, velocity); + this._modulator._triggerEnvelopeAttack(time); + return this; + }; + /** + * trigger the release portion of the note + * + * @param {Time} [time=now] the time the note will release + * @private + * @returns {Tone.AMSynth} this + */ + Tone.AMSynth.prototype._triggerEnvelopeRelease = function (time) { + this._carrier._triggerEnvelopeRelease(time); + this._modulator._triggerEnvelopeRelease(time); + return this; + }; + /** + * clean up + * @returns {Tone.AMSynth} this + */ + Tone.AMSynth.prototype.dispose = function () { + Tone.Monophonic.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'harmonicity', + 'oscillator', + 'envelope', + 'modulation', + 'modulationEnvelope', + 'detune' + ]); + this._carrier.dispose(); + this._carrier = null; + this._modulator.dispose(); + this._modulator = null; + this.frequency.dispose(); + this.frequency = null; + this.detune.dispose(); + this.detune = null; + this.harmonicity.dispose(); + this.harmonicity = null; + this._modulationScale.dispose(); + this._modulationScale = null; + this._modulationNode.dispose(); + this._modulationNode = null; + this.oscillator = null; + this.envelope = null; + this.modulationEnvelope = null; + this.modulation = null; + return this; + }; + return Tone.AMSynth; + }); + Module(function (Tone) { + + /** + * @class Tone.MonoSynth is composed of one oscillator, one filter, and two envelopes. + * The amplitude of the Tone.Oscillator and the cutoff frequency of the + * Tone.Filter are controlled by Tone.Envelopes. + * <img src="https://docs.google.com/drawings/d/1gaY1DF9_Hzkodqf8JI1Cg2VZfwSElpFQfI94IQwad38/pub?w=924&h=240"> + * + * @constructor + * @extends {Tone.Monophonic} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var synth = new Tone.MonoSynth({ + * "oscillator" : { + * "type" : "square" + * }, + * "envelope" : { + * "attack" : 0.1 + * } + * }).toMaster(); + * synth.triggerAttackRelease("C4", "8n"); + */ + Tone.MonoSynth = function (options) { + //get the defaults + options = Tone.defaultArg(options, Tone.MonoSynth.defaults); + Tone.Monophonic.call(this, options); + /** + * The oscillator. + * @type {Tone.OmniOscillator} + */ + this.oscillator = new Tone.OmniOscillator(options.oscillator); + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = this.oscillator.frequency; + /** + * The detune control. + * @type {Cents} + * @signal + */ + this.detune = this.oscillator.detune; + /** + * The filter. + * @type {Tone.Filter} + */ + this.filter = new Tone.Filter(options.filter); + /** + * The filter envelope. + * @type {Tone.FrequencyEnvelope} + */ + this.filterEnvelope = new Tone.FrequencyEnvelope(options.filterEnvelope); + /** + * The amplitude envelope. + * @type {Tone.AmplitudeEnvelope} + */ + this.envelope = new Tone.AmplitudeEnvelope(options.envelope); + //connect the oscillators to the output + this.oscillator.chain(this.filter, this.envelope, this.output); + //connect the filter envelope + this.filterEnvelope.connect(this.filter.frequency); + this._readOnly([ + 'oscillator', + 'frequency', + 'detune', + 'filter', + 'filterEnvelope', + 'envelope' + ]); + }; + Tone.extend(Tone.MonoSynth, Tone.Monophonic); + /** + * @const + * @static + * @type {Object} + */ + Tone.MonoSynth.defaults = { + 'frequency': 'C4', + 'detune': 0, + 'oscillator': { 'type': 'square' }, + 'filter': { + 'Q': 6, + 'type': 'lowpass', + 'rolloff': -24 + }, + 'envelope': { + 'attack': 0.005, + 'decay': 0.1, + 'sustain': 0.9, + 'release': 1 + }, + 'filterEnvelope': { + 'attack': 0.06, + 'decay': 0.2, + 'sustain': 0.5, + 'release': 2, + 'baseFrequency': 200, + 'octaves': 7, + 'exponent': 2 + } + }; + /** + * start the attack portion of the envelope + * @param {Time} [time=now] the time the attack should start + * @param {NormalRange} [velocity=1] the velocity of the note (0-1) + * @returns {Tone.MonoSynth} this + * @private + */ + Tone.MonoSynth.prototype._triggerEnvelopeAttack = function (time, velocity) { + time = this.toSeconds(time); + //the envelopes + this.envelope.triggerAttack(time, velocity); + this.filterEnvelope.triggerAttack(time); + this.oscillator.start(time); + if (this.envelope.sustain === 0) { + this.oscillator.stop(time + this.envelope.attack + this.envelope.decay); + } + return this; + }; + /** + * start the release portion of the envelope + * @param {Time} [time=now] the time the release should start + * @returns {Tone.MonoSynth} this + * @private + */ + Tone.MonoSynth.prototype._triggerEnvelopeRelease = function (time) { + this.envelope.triggerRelease(time); + this.filterEnvelope.triggerRelease(time); + this.oscillator.stop(time + this.envelope.release); + return this; + }; + /** + * clean up + * @returns {Tone.MonoSynth} this + */ + Tone.MonoSynth.prototype.dispose = function () { + Tone.Monophonic.prototype.dispose.call(this); + this._writable([ + 'oscillator', + 'frequency', + 'detune', + 'filter', + 'filterEnvelope', + 'envelope' + ]); + this.oscillator.dispose(); + this.oscillator = null; + this.envelope.dispose(); + this.envelope = null; + this.filterEnvelope.dispose(); + this.filterEnvelope = null; + this.filter.dispose(); + this.filter = null; + this.frequency = null; + this.detune = null; + return this; + }; + return Tone.MonoSynth; + }); + Module(function (Tone) { + + /** + * @class Tone.DuoSynth is a monophonic synth composed of two + * MonoSynths run in parallel with control over the + * frequency ratio between the two voices and vibrato effect. + * <img src="https://docs.google.com/drawings/d/1bL4GXvfRMMlqS7XyBm9CjL9KJPSUKbcdBNpqOlkFLxk/pub?w=1012&h=448"> + * + * @constructor + * @extends {Tone.Monophonic} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var duoSynth = new Tone.DuoSynth().toMaster(); + * duoSynth.triggerAttackRelease("C4", "2n"); + */ + Tone.DuoSynth = function (options) { + options = Tone.defaultArg(options, Tone.DuoSynth.defaults); + Tone.Monophonic.call(this, options); + /** + * the first voice + * @type {Tone.MonoSynth} + */ + this.voice0 = new Tone.MonoSynth(options.voice0); + this.voice0.volume.value = -10; + /** + * the second voice + * @type {Tone.MonoSynth} + */ + this.voice1 = new Tone.MonoSynth(options.voice1); + this.voice1.volume.value = -10; + /** + * The vibrato LFO. + * @type {Tone.LFO} + * @private + */ + this._vibrato = new Tone.LFO(options.vibratoRate, -50, 50); + this._vibrato.start(); + /** + * the vibrato frequency + * @type {Frequency} + * @signal + */ + this.vibratoRate = this._vibrato.frequency; + /** + * the vibrato gain + * @type {Tone.Gain} + * @private + */ + this._vibratoGain = new Tone.Gain(options.vibratoAmount, Tone.Type.Positive); + /** + * The amount of vibrato + * @type {Positive} + * @signal + */ + this.vibratoAmount = this._vibratoGain.gain; + /** + * the frequency control + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(440, Tone.Type.Frequency); + /** + * Harmonicity is the ratio between the two voices. A harmonicity of + * 1 is no change. Harmonicity = 2 means a change of an octave. + * @type {Positive} + * @signal + * @example + * //pitch voice1 an octave below voice0 + * duoSynth.harmonicity.value = 0.5; + */ + this.harmonicity = new Tone.Multiply(options.harmonicity); + this.harmonicity.units = Tone.Type.Positive; + //control the two voices frequency + this.frequency.connect(this.voice0.frequency); + this.frequency.chain(this.harmonicity, this.voice1.frequency); + this._vibrato.connect(this._vibratoGain); + this._vibratoGain.fan(this.voice0.detune, this.voice1.detune); + this.voice0.connect(this.output); + this.voice1.connect(this.output); + this._readOnly([ + 'voice0', + 'voice1', + 'frequency', + 'vibratoAmount', + 'vibratoRate' + ]); + }; + Tone.extend(Tone.DuoSynth, Tone.Monophonic); + /** + * @static + * @type {Object} + */ + Tone.DuoSynth.defaults = { + 'vibratoAmount': 0.5, + 'vibratoRate': 5, + 'harmonicity': 1.5, + 'voice0': { + 'volume': -10, + 'portamento': 0, + 'oscillator': { 'type': 'sine' }, + 'filterEnvelope': { + 'attack': 0.01, + 'decay': 0, + 'sustain': 1, + 'release': 0.5 + }, + 'envelope': { + 'attack': 0.01, + 'decay': 0, + 'sustain': 1, + 'release': 0.5 + } + }, + 'voice1': { + 'volume': -10, + 'portamento': 0, + 'oscillator': { 'type': 'sine' }, + 'filterEnvelope': { + 'attack': 0.01, + 'decay': 0, + 'sustain': 1, + 'release': 0.5 + }, + 'envelope': { + 'attack': 0.01, + 'decay': 0, + 'sustain': 1, + 'release': 0.5 + } + } + }; + /** + * start the attack portion of the envelopes + * + * @param {Time} [time=now] the time the attack should start + * @param {NormalRange} [velocity=1] the velocity of the note (0-1) + * @returns {Tone.DuoSynth} this + * @private + */ + Tone.DuoSynth.prototype._triggerEnvelopeAttack = function (time, velocity) { + time = this.toSeconds(time); + this.voice0._triggerEnvelopeAttack(time, velocity); + this.voice1._triggerEnvelopeAttack(time, velocity); + return this; + }; + /** + * start the release portion of the envelopes + * + * @param {Time} [time=now] the time the release should start + * @returns {Tone.DuoSynth} this + * @private + */ + Tone.DuoSynth.prototype._triggerEnvelopeRelease = function (time) { + this.voice0._triggerEnvelopeRelease(time); + this.voice1._triggerEnvelopeRelease(time); + return this; + }; + /** + * Get the level of the output at the given time. Measures + * the envelope(s) value at the time. + * @param {Time} time The time to query the envelope value + * @return {NormalRange} The output level between 0-1 + */ + Tone.DuoSynth.prototype.getLevelAtTime = function (time) { + return (this.voice0.getLevelAtTime(time) + this.voice1.getLevelAtTime(time)) / 2; + }; + /** + * clean up + * @returns {Tone.DuoSynth} this + */ + Tone.DuoSynth.prototype.dispose = function () { + Tone.Monophonic.prototype.dispose.call(this); + this._writable([ + 'voice0', + 'voice1', + 'frequency', + 'vibratoAmount', + 'vibratoRate' + ]); + this.voice0.dispose(); + this.voice0 = null; + this.voice1.dispose(); + this.voice1 = null; + this.frequency.dispose(); + this.frequency = null; + this._vibratoGain.dispose(); + this._vibratoGain = null; + this._vibrato = null; + this.harmonicity.dispose(); + this.harmonicity = null; + this.vibratoAmount.dispose(); + this.vibratoAmount = null; + this.vibratoRate = null; + return this; + }; + return Tone.DuoSynth; + }); + Module(function (Tone) { + + /** + * @class FMSynth is composed of two Tone.Synths where one Tone.Synth modulates + * the frequency of a second Tone.Synth. A lot of spectral content + * can be explored using the modulationIndex parameter. Read more about + * frequency modulation synthesis on Sound On Sound: [Part 1](https://web.archive.org/web/20160403123704/http://www.soundonsound.com/sos/apr00/articles/synthsecrets.htm), [Part 2](https://web.archive.org/web/20160403115835/http://www.soundonsound.com/sos/may00/articles/synth.htm). + * <img src="https://docs.google.com/drawings/d/1h0PUDZXPgi4Ikx6bVT6oncrYPLluFKy7lj53puxj-DM/pub?w=902&h=462"> + * + * @constructor + * @extends {Tone.Monophonic} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var fmSynth = new Tone.FMSynth().toMaster(); + * fmSynth.triggerAttackRelease("C5", "4n"); + */ + Tone.FMSynth = function (options) { + options = Tone.defaultArg(options, Tone.FMSynth.defaults); + Tone.Monophonic.call(this, options); + /** + * The carrier voice. + * @type {Tone.Synth} + * @private + */ + this._carrier = new Tone.Synth(options.carrier); + this._carrier.volume.value = -10; + /** + * The carrier's oscillator + * @type {Tone.Oscillator} + */ + this.oscillator = this._carrier.oscillator; + /** + * The carrier's envelope + * @type {Tone.Oscillator} + */ + this.envelope = this._carrier.envelope.set(options.envelope); + /** + * The modulator voice. + * @type {Tone.Synth} + * @private + */ + this._modulator = new Tone.Synth(options.modulator); + this._modulator.volume.value = -10; + /** + * The modulator's oscillator which is applied + * to the amplitude of the oscillator + * @type {Tone.Oscillator} + */ + this.modulation = this._modulator.oscillator.set(options.modulation); + /** + * The modulator's envelope + * @type {Tone.Oscillator} + */ + this.modulationEnvelope = this._modulator.envelope.set(options.modulationEnvelope); + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(440, Tone.Type.Frequency); + /** + * The detune in cents + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(options.detune, Tone.Type.Cents); + /** + * Harmonicity is the ratio between the two voices. A harmonicity of + * 1 is no change. Harmonicity = 2 means a change of an octave. + * @type {Positive} + * @signal + * @example + * //pitch voice1 an octave below voice0 + * synth.harmonicity.value = 0.5; + */ + this.harmonicity = new Tone.Multiply(options.harmonicity); + this.harmonicity.units = Tone.Type.Positive; + /** + * The modulation index which essentially the depth or amount of the modulation. It is the + * ratio of the frequency of the modulating signal (mf) to the amplitude of the + * modulating signal (ma) -- as in ma/mf. + * @type {Positive} + * @signal + */ + this.modulationIndex = new Tone.Multiply(options.modulationIndex); + this.modulationIndex.units = Tone.Type.Positive; + /** + * the node where the modulation happens + * @type {GainNode} + * @private + */ + this._modulationNode = new Tone.Gain(0); + //control the two voices frequency + this.frequency.connect(this._carrier.frequency); + this.frequency.chain(this.harmonicity, this._modulator.frequency); + this.frequency.chain(this.modulationIndex, this._modulationNode); + this.detune.fan(this._carrier.detune, this._modulator.detune); + this._modulator.connect(this._modulationNode.gain); + this._modulationNode.connect(this._carrier.frequency); + this._carrier.connect(this.output); + this._readOnly([ + 'frequency', + 'harmonicity', + 'modulationIndex', + 'oscillator', + 'envelope', + 'modulation', + 'modulationEnvelope', + 'detune' + ]); + }; + Tone.extend(Tone.FMSynth, Tone.Monophonic); + /** + * @static + * @type {Object} + */ + Tone.FMSynth.defaults = { + 'harmonicity': 3, + 'modulationIndex': 10, + 'detune': 0, + 'oscillator': { 'type': 'sine' }, + 'envelope': { + 'attack': 0.01, + 'decay': 0.01, + 'sustain': 1, + 'release': 0.5 + }, + 'modulation': { 'type': 'square' }, + 'modulationEnvelope': { + 'attack': 0.5, + 'decay': 0, + 'sustain': 1, + 'release': 0.5 + } + }; + /** + * trigger the attack portion of the note + * + * @param {Time} [time=now] the time the note will occur + * @param {number} [velocity=1] the velocity of the note + * @returns {Tone.FMSynth} this + * @private + */ + Tone.FMSynth.prototype._triggerEnvelopeAttack = function (time, velocity) { + time = this.toSeconds(time); + //the envelopes + this._carrier._triggerEnvelopeAttack(time, velocity); + this._modulator._triggerEnvelopeAttack(time); + return this; + }; + /** + * trigger the release portion of the note + * + * @param {Time} [time=now] the time the note will release + * @returns {Tone.FMSynth} this + * @private + */ + Tone.FMSynth.prototype._triggerEnvelopeRelease = function (time) { + time = this.toSeconds(time); + this._carrier._triggerEnvelopeRelease(time); + this._modulator._triggerEnvelopeRelease(time); + return this; + }; + /** + * clean up + * @returns {Tone.FMSynth} this + */ + Tone.FMSynth.prototype.dispose = function () { + Tone.Monophonic.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'harmonicity', + 'modulationIndex', + 'oscillator', + 'envelope', + 'modulation', + 'modulationEnvelope', + 'detune' + ]); + this._carrier.dispose(); + this._carrier = null; + this._modulator.dispose(); + this._modulator = null; + this.frequency.dispose(); + this.frequency = null; + this.detune.dispose(); + this.detune = null; + this.modulationIndex.dispose(); + this.modulationIndex = null; + this.harmonicity.dispose(); + this.harmonicity = null; + this._modulationNode.dispose(); + this._modulationNode = null; + this.oscillator = null; + this.envelope = null; + this.modulationEnvelope = null; + this.modulation = null; + return this; + }; + return Tone.FMSynth; + }); + Module(function (Tone) { + + /** + * @class Tone.MembraneSynth makes kick and tom sounds using a single oscillator + * with an amplitude envelope and frequency ramp. A Tone.OmniOscillator + * is routed through a Tone.AmplitudeEnvelope to the output. The drum + * quality of the sound comes from the frequency envelope applied + * during Tone.MembraneSynth.triggerAttack(note). The frequency envelope + * starts at <code>note * .octaves</code> and ramps to <code>note</code> + * over the duration of <code>.pitchDecay</code>. + * + * @constructor + * @extends {Tone.Instrument} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var synth = new Tone.MembraneSynth().toMaster(); + * synth.triggerAttackRelease("C2", "8n"); + */ + Tone.MembraneSynth = function (options) { + options = Tone.defaultArg(options, Tone.MembraneSynth.defaults); + Tone.Instrument.call(this, options); + /** + * The oscillator. + * @type {Tone.OmniOscillator} + */ + this.oscillator = new Tone.OmniOscillator(options.oscillator); + /** + * The amplitude envelope. + * @type {Tone.AmplitudeEnvelope} + */ + this.envelope = new Tone.AmplitudeEnvelope(options.envelope); + /** + * The number of octaves the pitch envelope ramps. + * @type {Positive} + */ + this.octaves = options.octaves; + /** + * The amount of time the frequency envelope takes. + * @type {Time} + */ + this.pitchDecay = options.pitchDecay; + this.oscillator.chain(this.envelope, this.output); + this._readOnly([ + 'oscillator', + 'envelope' + ]); + }; + Tone.extend(Tone.MembraneSynth, Tone.Instrument); + /** + * @static + * @type {Object} + */ + Tone.MembraneSynth.defaults = { + 'pitchDecay': 0.05, + 'octaves': 10, + 'oscillator': { 'type': 'sine' }, + 'envelope': { + 'attack': 0.001, + 'decay': 0.4, + 'sustain': 0.01, + 'release': 1.4, + 'attackCurve': 'exponential' + } + }; + /** + * Trigger the note at the given time with the given velocity. + * + * @param {Frequency} note the note + * @param {Time} [time=now] the time, if not given is now + * @param {number} [velocity=1] velocity defaults to 1 + * @returns {Tone.MembraneSynth} this + * @example + * kick.triggerAttack(60); + */ + Tone.MembraneSynth.prototype.triggerAttack = function (note, time, velocity) { + time = this.toSeconds(time); + note = this.toFrequency(note); + var maxNote = note * this.octaves; + this.oscillator.frequency.setValueAtTime(maxNote, time); + this.oscillator.frequency.exponentialRampToValueAtTime(note, time + this.toSeconds(this.pitchDecay)); + this.envelope.triggerAttack(time, velocity); + this.oscillator.start(time); + return this; + }; + /** + * Trigger the release portion of the note. + * + * @param {Time} [time=now] the time the note will release + * @returns {Tone.MembraneSynth} this + */ + Tone.MembraneSynth.prototype.triggerRelease = function (time) { + time = this.toSeconds(time); + this.envelope.triggerRelease(time); + this.oscillator.stop(time + this.envelope.release); + return this; + }; + /** + * Clean up. + * @returns {Tone.MembraneSynth} this + */ + Tone.MembraneSynth.prototype.dispose = function () { + Tone.Instrument.prototype.dispose.call(this); + this._writable([ + 'oscillator', + 'envelope' + ]); + this.oscillator.dispose(); + this.oscillator = null; + this.envelope.dispose(); + this.envelope = null; + return this; + }; + return Tone.MembraneSynth; + }); + Module(function (Tone) { + /** + * Inharmonic ratio of frequencies based on the Roland TR-808 + * Taken from https://ccrma.stanford.edu/papers/tr-808-cymbal-physically-informed-circuit-bendable-digital-model + * @private + * @static + * @type {Array} + */ + var inharmRatios = [ + 1, + 1.483, + 1.932, + 2.546, + 2.63, + 3.897 + ]; + /** + * @class A highly inharmonic and spectrally complex source with a highpass filter + * and amplitude envelope which is good for making metalophone sounds. Based + * on CymbalSynth by [@polyrhythmatic](https://github.com/polyrhythmatic). + * Inspiration from [Sound on Sound](https://web.archive.org/web/20160610143924/https://www.soundonsound.com/sos/jul02/articles/synthsecrets0702.asp). + * + * @constructor + * @extends {Tone.Instrument} + * @param {Object} [options] The options availble for the synth + * see defaults below + */ + Tone.MetalSynth = function (options) { + options = Tone.defaultArg(options, Tone.MetalSynth.defaults); + Tone.Instrument.call(this, options); + /** + * The frequency of the cymbal + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The array of FMOscillators + * @type {Array} + * @private + */ + this._oscillators = []; + /** + * The frequency multipliers + * @type {Array} + * @private + */ + this._freqMultipliers = []; + /** + * The amplitude for the body + * @type {Tone.Gain} + * @private + */ + this._amplitue = new Tone.Gain(0).connect(this.output); + /** + * highpass the output + * @type {Tone.Filter} + * @private + */ + this._highpass = new Tone.Filter({ + 'type': 'highpass', + 'Q': -3.0102999566398125 + }).connect(this._amplitue); + /** + * The number of octaves the highpass + * filter frequency ramps + * @type {Number} + * @private + */ + this._octaves = options.octaves; + /** + * Scale the body envelope + * for the bandpass + * @type {Tone.Scale} + * @private + */ + this._filterFreqScaler = new Tone.Scale(options.resonance, 7000); + /** + * The envelope which is connected both to the + * amplitude and highpass filter's cutoff frequency + * @type {Tone.Envelope} + */ + this.envelope = new Tone.Envelope({ + 'attack': options.envelope.attack, + 'attackCurve': 'linear', + 'decay': options.envelope.decay, + 'sustain': 0, + 'release': options.envelope.release + }).chain(this._filterFreqScaler, this._highpass.frequency); + this.envelope.connect(this._amplitue.gain); + for (var i = 0; i < inharmRatios.length; i++) { + var osc = new Tone.FMOscillator({ + 'type': 'square', + 'modulationType': 'square', + 'harmonicity': options.harmonicity, + 'modulationIndex': options.modulationIndex + }); + osc.connect(this._highpass); + this._oscillators[i] = osc; + var mult = new Tone.Multiply(inharmRatios[i]); + this._freqMultipliers[i] = mult; + this.frequency.chain(mult, osc.frequency); + } + //set the octaves + this.octaves = options.octaves; + }; + Tone.extend(Tone.MetalSynth, Tone.Instrument); + /** + * default values + * @static + * @const + * @type {Object} + */ + Tone.MetalSynth.defaults = { + 'frequency': 200, + 'envelope': { + 'attack': 0.001, + 'decay': 1.4, + 'release': 0.2 + }, + 'harmonicity': 5.1, + 'modulationIndex': 32, + 'resonance': 4000, + 'octaves': 1.5 + }; + /** + * Trigger the attack. + * @param {Time} time When the attack should be triggered. + * @param {NormalRange} [velocity=1] The velocity that the envelope should be triggered at. + * @return {Tone.MetalSynth} this + */ + Tone.MetalSynth.prototype.triggerAttack = function (time, vel) { + time = this.toSeconds(time); + vel = Tone.defaultArg(vel, 1); + this.envelope.triggerAttack(time, vel); + this._oscillators.forEach(function (osc) { + osc.start(time); + }); + //if the sustain is 0, stop the oscillator as well + if (this.envelope.sustain === 0) { + this._oscillators.forEach(function (osc) { + osc.stop(time + this.envelope.attack + this.envelope.decay); + }.bind(this)); + } + return this; + }; + /** + * Trigger the release of the envelope. + * @param {Time} time When the release should be triggered. + * @return {Tone.MetalSynth} this + */ + Tone.MetalSynth.prototype.triggerRelease = function (time) { + time = this.toSeconds(time); + this.envelope.triggerRelease(time); + this._oscillators.forEach(function (osc) { + osc.stop(time + this.envelope.release); + }.bind(this)); + return this; + }; + /** + * Sync the instrument to the Transport. All subsequent calls of + * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease) + * will be scheduled along the transport. + * @example + * synth.sync() + * //schedule 3 notes when the transport first starts + * synth.triggerAttackRelease('8n', 0) + * synth.triggerAttackRelease('8n', '8n') + * synth.triggerAttackRelease('8n', '4n') + * //start the transport to hear the notes + * Transport.start() + * @returns {Tone.Instrument} this + */ + Tone.MetalSynth.prototype.sync = function () { + this._syncMethod('triggerAttack', 0); + this._syncMethod('triggerRelease', 0); + return this; + }; + /** + * Trigger the attack and release of the envelope after the given + * duration. + * @param {Time} duration The duration before triggering the release + * @param {Time} time When the attack should be triggered. + * @param {NormalRange} [velocity=1] The velocity that the envelope should be triggered at. + * @return {Tone.MetalSynth} this + */ + Tone.MetalSynth.prototype.triggerAttackRelease = function (duration, time, velocity) { + time = this.toSeconds(time); + duration = this.toSeconds(duration); + this.triggerAttack(time, velocity); + this.triggerRelease(time + duration); + return this; + }; + /** + * The modulationIndex of the oscillators which make up the source. + * see Tone.FMOscillator.modulationIndex + * @memberOf Tone.MetalSynth# + * @type {Positive} + * @name modulationIndex + */ + Object.defineProperty(Tone.MetalSynth.prototype, 'modulationIndex', { + get: function () { + return this._oscillators[0].modulationIndex.value; + }, + set: function (val) { + for (var i = 0; i < this._oscillators.length; i++) { + this._oscillators[i].modulationIndex.value = val; + } + } + }); + /** + * The harmonicity of the oscillators which make up the source. + * see Tone.FMOscillator.harmonicity + * @memberOf Tone.MetalSynth# + * @type {Positive} + * @name harmonicity + */ + Object.defineProperty(Tone.MetalSynth.prototype, 'harmonicity', { + get: function () { + return this._oscillators[0].harmonicity.value; + }, + set: function (val) { + for (var i = 0; i < this._oscillators.length; i++) { + this._oscillators[i].harmonicity.value = val; + } + } + }); + /** + * The frequency of the highpass filter attached to the envelope + * @memberOf Tone.MetalSynth# + * @type {Frequency} + * @name resonance + */ + Object.defineProperty(Tone.MetalSynth.prototype, 'resonance', { + get: function () { + return this._filterFreqScaler.min; + }, + set: function (val) { + this._filterFreqScaler.min = val; + this.octaves = this._octaves; + } + }); + /** + * The number of octaves above the "resonance" frequency + * that the filter ramps during the attack/decay envelope + * @memberOf Tone.MetalSynth# + * @type {Number} + * @name octaves + */ + Object.defineProperty(Tone.MetalSynth.prototype, 'octaves', { + get: function () { + return this._octaves; + }, + set: function (octs) { + this._octaves = octs; + this._filterFreqScaler.max = this._filterFreqScaler.min * Math.pow(2, octs); + } + }); + /** + * Clean up + * @returns {Tone.MetalSynth} this + */ + Tone.MetalSynth.prototype.dispose = function () { + Tone.Instrument.prototype.dispose.call(this); + for (var i = 0; i < this._oscillators.length; i++) { + this._oscillators[i].dispose(); + this._freqMultipliers[i].dispose(); + } + this._oscillators = null; + this._freqMultipliers = null; + this.frequency.dispose(); + this.frequency = null; + this._filterFreqScaler.dispose(); + this._filterFreqScaler = null; + this._amplitue.dispose(); + this._amplitue = null; + this.envelope.dispose(); + this.envelope = null; + this._highpass.dispose(); + this._highpass = null; + }; + return Tone.MetalSynth; + }); + Module(function (Tone) { + + /** + * @class Tone.NoiseSynth is composed of a noise generator (Tone.Noise), one filter (Tone.Filter), + * and two envelopes (Tone.Envelop). One envelope controls the amplitude + * of the noise and the other is controls the cutoff frequency of the filter. + * <img src="https://docs.google.com/drawings/d/1rqzuX9rBlhT50MRvD2TKml9bnZhcZmzXF1rf_o7vdnE/pub?w=918&h=242"> + * + * @constructor + * @extends {Tone.Instrument} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var noiseSynth = new Tone.NoiseSynth().toMaster(); + * noiseSynth.triggerAttackRelease("8n"); + */ + Tone.NoiseSynth = function (options) { + //get the defaults + options = Tone.defaultArg(options, Tone.NoiseSynth.defaults); + Tone.Instrument.call(this, options); + /** + * The noise source. + * @type {Tone.Noise} + * @example + * noiseSynth.set("noise.type", "brown"); + */ + this.noise = new Tone.Noise(); + /** + * The amplitude envelope. + * @type {Tone.AmplitudeEnvelope} + */ + this.envelope = new Tone.AmplitudeEnvelope(options.envelope); + //connect the noise to the output + this.noise.chain(this.envelope, this.output); + this._readOnly([ + 'noise', + 'envelope' + ]); + }; + Tone.extend(Tone.NoiseSynth, Tone.Instrument); + /** + * @const + * @static + * @type {Object} + */ + Tone.NoiseSynth.defaults = { + 'noise': { 'type': 'white' }, + 'envelope': { + 'attack': 0.005, + 'decay': 0.1, + 'sustain': 0 + } + }; + /** + * Start the attack portion of the envelopes. Unlike other + * instruments, Tone.NoiseSynth doesn't have a note. + * @param {Time} [time=now] the time the attack should start + * @param {number} [velocity=1] the velocity of the note (0-1) + * @returns {Tone.NoiseSynth} this + * @example + * noiseSynth.triggerAttack(); + */ + Tone.NoiseSynth.prototype.triggerAttack = function (time, velocity) { + //the envelopes + this.envelope.triggerAttack(time, velocity); + //start the noise + this.noise.start(time); + if (this.envelope.sustain === 0) { + this.noise.stop(time = this.envelope.attack + this.envelope.decay); + } + return this; + }; + /** + * Start the release portion of the envelopes. + * @param {Time} [time=now] the time the release should start + * @returns {Tone.NoiseSynth} this + */ + Tone.NoiseSynth.prototype.triggerRelease = function (time) { + this.envelope.triggerRelease(time); + this.noise.stop(time + this.envelope.release); + return this; + }; + /** + * Sync the instrument to the Transport. All subsequent calls of + * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease) + * will be scheduled along the transport. + * @example + * synth.sync() + * //schedule 3 notes when the transport first starts + * synth.triggerAttackRelease('8n', 0) + * synth.triggerAttackRelease('8n', '8n') + * synth.triggerAttackRelease('8n', '4n') + * //start the transport to hear the notes + * Transport.start() + * @returns {Tone.Instrument} this + */ + Tone.NoiseSynth.prototype.sync = function () { + this._syncMethod('triggerAttack', 0); + this._syncMethod('triggerRelease', 0); + return this; + }; + /** + * Trigger the attack and then the release. + * @param {Time} duration the duration of the note + * @param {Time} [time=now] the time of the attack + * @param {number} [velocity=1] the velocity + * @returns {Tone.NoiseSynth} this + */ + Tone.NoiseSynth.prototype.triggerAttackRelease = function (duration, time, velocity) { + time = this.toSeconds(time); + duration = this.toSeconds(duration); + this.triggerAttack(time, velocity); + this.triggerRelease(time + duration); + return this; + }; + /** + * Clean up. + * @returns {Tone.NoiseSynth} this + */ + Tone.NoiseSynth.prototype.dispose = function () { + Tone.Instrument.prototype.dispose.call(this); + this._writable([ + 'noise', + 'envelope' + ]); + this.noise.dispose(); + this.noise = null; + this.envelope.dispose(); + this.envelope = null; + return this; + }; + return Tone.NoiseSynth; + }); + Module(function (Tone) { + + /** + * @class Karplus-String string synthesis. Often out of tune. + * Will change when the AudioWorkerNode is available across + * browsers. + * + * @constructor + * @extends {Tone.Instrument} + * @param {Object} [options] see the defaults + * @example + * var plucky = new Tone.PluckSynth().toMaster(); + * plucky.triggerAttack("C4"); + */ + Tone.PluckSynth = function (options) { + options = Tone.defaultArg(options, Tone.PluckSynth.defaults); + Tone.Instrument.call(this, options); + /** + * @type {Tone.Noise} + * @private + */ + this._noise = new Tone.Noise('pink'); + /** + * The amount of noise at the attack. + * Nominal range of [0.1, 20] + * @type {number} + */ + this.attackNoise = options.attackNoise; + /** + * the LFCF + * @type {Tone.LowpassCombFilter} + * @private + */ + this._lfcf = new Tone.LowpassCombFilter({ + 'resonance': options.resonance, + 'dampening': options.dampening + }); + /** + * The resonance control. + * @type {NormalRange} + * @signal + */ + this.resonance = this._lfcf.resonance; + /** + * The dampening control. i.e. the lowpass filter frequency of the comb filter + * @type {Frequency} + * @signal + */ + this.dampening = this._lfcf.dampening; + //connections + this._noise.connect(this._lfcf); + this._lfcf.connect(this.output); + this._readOnly([ + 'resonance', + 'dampening' + ]); + }; + Tone.extend(Tone.PluckSynth, Tone.Instrument); + /** + * @static + * @const + * @type {Object} + */ + Tone.PluckSynth.defaults = { + 'attackNoise': 1, + 'dampening': 4000, + 'resonance': 0.7 + }; + /** + * Trigger the note. + * @param {Frequency} note The note to trigger. + * @param {Time} [time=now] When the note should be triggered. + * @returns {Tone.PluckSynth} this + */ + Tone.PluckSynth.prototype.triggerAttack = function (note, time) { + note = this.toFrequency(note); + time = this.toSeconds(time); + var delayAmount = 1 / note; + this._lfcf.delayTime.setValueAtTime(delayAmount, time); + this._noise.start(time); + this._noise.stop(time + delayAmount * this.attackNoise); + return this; + }; + /** + * Clean up. + * @returns {Tone.PluckSynth} this + */ + Tone.PluckSynth.prototype.dispose = function () { + Tone.Instrument.prototype.dispose.call(this); + this._noise.dispose(); + this._lfcf.dispose(); + this._noise = null; + this._lfcf = null; + this._writable([ + 'resonance', + 'dampening' + ]); + this.dampening = null; + this.resonance = null; + return this; + }; + return Tone.PluckSynth; + }); + Module(function (Tone) { + + /** + * @class Tone.PolySynth handles voice creation and allocation for any + * instruments passed in as the second paramter. PolySynth is + * not a synthesizer by itself, it merely manages voices of + * one of the other types of synths, allowing any of the + * monophonic synthesizers to be polyphonic. + * + * @constructor + * @extends {Tone.Instrument} + * @param {number|Object} [polyphony=4] The number of voices to create + * @param {function} [voice=Tone.Synth] The constructor of the voices + * uses Tone.Synth by default. + * @example + * //a polysynth composed of 6 Voices of Synth + * var synth = new Tone.PolySynth(6, Tone.Synth).toMaster(); + * //set the attributes using the set interface + * synth.set("detune", -1200); + * //play a chord + * synth.triggerAttackRelease(["C4", "E4", "A4"], "4n"); + */ + Tone.PolySynth = function () { + var options = Tone.defaults(arguments, [ + 'polyphony', + 'voice' + ], Tone.PolySynth); + Tone.Instrument.call(this, options); + options = Tone.defaultArg(options, Tone.Instrument.defaults); + //max polyphony + options.polyphony = Math.min(Tone.PolySynth.MAX_POLYPHONY, options.polyphony); + /** + * the array of voices + * @type {Array} + */ + this.voices = new Array(options.polyphony); + /** + * The queue of voices with data about last trigger + * and the triggered note + * @private + * @type {Array} + */ + this._triggers = new Array(options.polyphony); + /** + * The detune in cents + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(options.detune, Tone.Type.Cents); + this._readOnly('detune'); + //create the voices + for (var i = 0; i < options.polyphony; i++) { + var v = new options.voice(arguments[2], arguments[3]); + if (!(v instanceof Tone.Monophonic)) { + throw new Error('Synth constructor must be instance of Tone.Monophonic'); + } + this.voices[i] = v; + v.connect(this.output); + if (v.hasOwnProperty('detune')) { + this.detune.connect(v.detune); + } + this._triggers[i] = { + release: -1, + note: null, + voice: v + }; + } + }; + Tone.extend(Tone.PolySynth, Tone.Instrument); + /** + * the defaults + * @const + * @static + * @type {Object} + */ + Tone.PolySynth.defaults = { + 'polyphony': 4, + 'volume': 0, + 'detune': 0, + 'voice': Tone.Synth + }; + /** + * Trigger the attack portion of the note + * @param {Frequency|Array} notes The notes to play. Accepts a single + * Frequency or an array of frequencies. + * @param {Time} [time=now] The start time of the note. + * @param {number} [velocity=1] The velocity of the note. + * @returns {Tone.PolySynth} this + * @example + * //trigger a chord immediately with a velocity of 0.2 + * poly.triggerAttack(["Ab3", "C4", "F5"], undefined, 0.2); + */ + Tone.PolySynth.prototype.triggerAttack = function (notes, time, velocity) { + if (!Array.isArray(notes)) { + notes = [notes]; + } + time = this.toSeconds(time); + for (var i = 0; i < notes.length; i++) { + var val = notes[i]; + //trigger the oldest voice + var oldest = this._triggers[0]; + for (var j = 1; j < this._triggers.length; j++) { + if (this._triggers[j].release < oldest.release) { + oldest = this._triggers[j]; + } + } + oldest.release = Infinity; + oldest.note = JSON.stringify(val); + oldest.voice.triggerAttack(val, time, velocity); + } + return this; + }; + /** + * Trigger the attack and release after the specified duration + * + * @param {Frequency|Array} notes The notes to play. Accepts a single + * Frequency or an array of frequencies. + * @param {Time} duration the duration of the note + * @param {Time} [time=now] if no time is given, defaults to now + * @param {number} [velocity=1] the velocity of the attack (0-1) + * @returns {Tone.PolySynth} this + * @example + * //trigger a chord for a duration of a half note + * poly.triggerAttackRelease(["Eb3", "G4", "C5"], "2n"); + * @example + * //can pass in an array of durations as well + * poly.triggerAttackRelease(["Eb3", "G4", "C5"], ["2n", "4n", "4n"]); + */ + Tone.PolySynth.prototype.triggerAttackRelease = function (notes, duration, time, velocity) { + time = this.toSeconds(time); + this.triggerAttack(notes, time, velocity); + if (Tone.isArray(duration) && Tone.isArray(notes)) { + for (var i = 0; i < notes.length; i++) { + var d = duration[Math.min(i, duration.length - 1)]; + this.triggerRelease(notes[i], time + this.toSeconds(d)); + } + } else { + this.triggerRelease(notes, time + this.toSeconds(duration)); + } + return this; + }; + /** + * Trigger the release of the note. Unlike monophonic instruments, + * a note (or array of notes) needs to be passed in as the first argument. + * @param {Frequency|Array} notes The notes to play. Accepts a single + * Frequency or an array of frequencies. + * @param {Time} [time=now] When the release will be triggered. + * @returns {Tone.PolySynth} this + * @example + * poly.triggerRelease(["Ab3", "C4", "F5"], "+2n"); + */ + Tone.PolySynth.prototype.triggerRelease = function (notes, time) { + if (!Array.isArray(notes)) { + notes = [notes]; + } + time = this.toSeconds(time); + for (var i = 0; i < notes.length; i++) { + //get the voice + var stringified = JSON.stringify(notes[i]); + for (var v = 0; v < this._triggers.length; v++) { + var desc = this._triggers[v]; + if (desc.note === stringified && desc.release > time) { + desc.voice.triggerRelease(time); + desc.release = time; + } + } + } + return this; + }; + /** + * Sync the instrument to the Transport. All subsequent calls of + * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease) + * will be scheduled along the transport. + * @example + * synth.sync() + * //schedule 3 notes when the transport first starts + * synth.triggerAttackRelease('8n', 0) + * synth.triggerAttackRelease('8n', '8n') + * synth.triggerAttackRelease('8n', '4n') + * //start the transport to hear the notes + * Transport.start() + * @returns {Tone.Instrument} this + */ + Tone.PolySynth.prototype.sync = function () { + this._syncMethod('triggerAttack', 1); + this._syncMethod('triggerRelease', 1); + return this; + }; + /** + * Set a member/attribute of the voices. + * @param {Object|string} params + * @param {number=} value + * @param {Time=} rampTime + * @returns {Tone.PolySynth} this + * @example + * poly.set({ + * "filter" : { + * "type" : "highpass" + * }, + * "envelope" : { + * "attack" : 0.25 + * } + * }); + */ + Tone.PolySynth.prototype.set = function (params, value, rampTime) { + for (var i = 0; i < this.voices.length; i++) { + this.voices[i].set(params, value, rampTime); + } + return this; + }; + /** + * Get the synth's attributes. Given no arguments get + * will return all available object properties and their corresponding + * values. Pass in a single attribute to retrieve or an array + * of attributes. The attribute strings can also include a "." + * to access deeper properties. + * @param {Array=} params the parameters to get, otherwise will return + * all available. + */ + Tone.PolySynth.prototype.get = function (params) { + return this.voices[0].get(params); + }; + /** + * Trigger the release portion of all the currently active voices. + * @param {Time} [time=now] When the notes should be released. + * @return {Tone.PolySynth} this + */ + Tone.PolySynth.prototype.releaseAll = function (time) { + time = this.toSeconds(time); + for (var i = 0; i < this._triggers.length; i++) { + var desc = this._triggers[i]; + if (desc.release > time) { + desc.release = time; + desc.voice.triggerRelease(time); + } + } + return this; + }; + /** + * Clean up. + * @returns {Tone.PolySynth} this + */ + Tone.PolySynth.prototype.dispose = function () { + Tone.Instrument.prototype.dispose.call(this); + for (var i = 0; i < this.voices.length; i++) { + this.voices[i].dispose(); + this.voices[i] = null; + } + this._writable('detune'); + this.detune.dispose(); + this.detune = null; + this.voices = null; + this._triggers = null; + return this; + }; + /** + * The maximum number of notes that can be allocated + * to a polysynth. + * @type {Number} + * @static + */ + Tone.PolySynth.MAX_POLYPHONY = 20; + return Tone.PolySynth; + }); + Module(function (Tone) { + /** + * @class Automatically interpolates between a set of pitched samples. Pass in an object which maps the note's pitch or midi value to the url, then you can trigger the attack and release of that note like other instruments. By automatically repitching the samples, it is possible to play pitches which were not explicitly included which can save loading time. + * For sample or buffer playback where repitching is not necessary, use [Tone.Player](https://tonejs.github.io/docs/Player). + * @param {Object} samples An object of samples mapping either Midi + * Note Numbers or Scientific Pitch Notation + * to the url of that sample. + * @param {Function=} onload The callback to invoke when all of the samples are loaded. + * @param {String=} baseUrl The root URL of all of the samples, which is prepended to all the URLs. + * @example + * var sampler = new Tone.Sampler({ + * "C3" : "path/to/C3.mp3", + * "D#3" : "path/to/Dsharp3.mp3", + * "F#3" : "path/to/Fsharp3.mp3", + * "A3" : "path/to/A3.mp3", + * }, function(){ + * //sampler will repitch the closest sample + * sampler.triggerAttack("D3") + * }) + * @extends {Tone.Instrument} + */ + Tone.Sampler = function (urls) { + // shift arguments over one. Those are the remainder of the options + var args = Array.prototype.slice.call(arguments); + args.shift(); + var options = Tone.defaults(args, [ + 'onload', + 'baseUrl' + ], Tone.Sampler); + Tone.Instrument.call(this, options); + var urlMap = {}; + for (var note in urls) { + if (Tone.isNote(note)) { + //convert the note name to MIDI + var mid = Tone.Frequency(note).toMidi(); + urlMap[mid] = urls[note]; + } else if (!isNaN(parseFloat(note))) { + //otherwise if it's numbers assume it's midi + urlMap[note] = urls[note]; + } else { + throw new Error('Tone.Sampler: url keys must be the note\'s pitch'); + } + } + /** + * The stored and loaded buffers + * @type {Tone.Buffers} + * @private + */ + this._buffers = new Tone.Buffers(urlMap, options.onload, options.baseUrl); + /** + * The object of all currently playing BufferSources + * @type {Object} + * @private + */ + this._activeSources = {}; + /** + * The envelope applied to the beginning of the sample. + * @type {Time} + */ + this.attack = options.attack; + /** + * The envelope applied to the end of the envelope. + * @type {Time} + */ + this.release = options.release; + }; + Tone.extend(Tone.Sampler, Tone.Instrument); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.Sampler.defaults = { + attack: 0, + release: 0.1, + onload: Tone.noOp, + baseUrl: '' + }; + /** + * Returns the difference in steps between the given midi note at the closets sample. + * @param {Midi} midi + * @return {Interval} + * @private + */ + Tone.Sampler.prototype._findClosest = function (midi) { + //searches within 8 octaves of the given midi note + var MAX_INTERVAL = 96; + var interval = 0; + while (interval < MAX_INTERVAL) { + // check above and below + if (this._buffers.has(midi + interval)) { + return -interval; + } else if (this._buffers.has(midi - interval)) { + return interval; + } + interval++; + } + return null; + }; + /** + * @param {Frequency} note The note to play + * @param {Time=} time When to play the note + * @param {NormalRange=} velocity The velocity to play the sample back. + * @return {Tone.Sampler} this + */ + Tone.Sampler.prototype.triggerAttack = function (note, time, velocity) { + var midi = Tone.Frequency(note).toMidi(); + // find the closest note pitch + var difference = this._findClosest(midi); + if (difference !== null) { + var closestNote = midi - difference; + var buffer = this._buffers.get(closestNote); + // play that note + var source = new Tone.BufferSource({ + 'buffer': buffer, + 'playbackRate': Tone.intervalToFrequencyRatio(difference), + 'fadeIn': this.attack, + 'fadeOut': this.release, + 'curve': 'exponential' + }).connect(this.output); + source.start(time, 0, buffer.duration, velocity); + // add it to the active sources + if (!Tone.isArray(this._activeSources[midi])) { + this._activeSources[midi] = []; + } + this._activeSources[midi].push({ + note: midi, + source: source + }); + } + return this; + }; + /** + * @param {Frequency} note The note to release. + * @param {Time=} time When to release the note. + * @return {Tone.Sampler} this + */ + Tone.Sampler.prototype.triggerRelease = function (note, time) { + var midi = Tone.Frequency(note).toMidi(); + // find the note + if (this._activeSources[midi] && this._activeSources[midi].length) { + var source = this._activeSources[midi].shift().source; + time = this.toSeconds(time); + source.stop(time + this.release, this.release); + } + return this; + }; + /** + * Release all currently active notes. + * @param {Time=} time When to release the notes. + * @return {Tone.Sampler} this + */ + Tone.Sampler.prototype.releaseAll = function (time) { + time = this.toSeconds(time); + for (var note in this._activeSources) { + var sources = this._activeSources[note]; + while (sources.length) { + var source = sources.shift().source; + source.stop(time + this.release, this.release); + } + } + return this; + }; + /** + * Sync the instrument to the Transport. All subsequent calls of + * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease) + * will be scheduled along the transport. + * @example + * synth.sync() + * //schedule 3 notes when the transport first starts + * synth.triggerAttackRelease('8n', 0) + * synth.triggerAttackRelease('8n', '8n') + * synth.triggerAttackRelease('8n', '4n') + * //start the transport to hear the notes + * Transport.start() + * @returns {Tone.Instrument} this + */ + Tone.Sampler.prototype.sync = function () { + this._syncMethod('triggerAttack', 1); + this._syncMethod('triggerRelease', 1); + return this; + }; + /** + * Invoke the attack phase, then after the duration, invoke the release. + * @param {Frequency} note The note to play + * @param {Time} duration The time the note should be held + * @param {Time=} time When to start the attack + * @param {NormalRange} [velocity=1] The velocity of the attack + * @return {Tone.Sampler} this + */ + Tone.Sampler.prototype.triggerAttackRelease = function (note, duration, time, velocity) { + time = this.toSeconds(time); + duration = this.toSeconds(duration); + this.triggerAttack(note, time, velocity); + this.triggerRelease(note, time + duration); + return this; + }; + /** + * Add a note to the sampler. + * @param {Note|Midi} note The buffer's pitch. + * @param {String|Tone.Buffer|Audiobuffer} url Either the url of the bufer, + * or a buffer which will be added + * with the given name. + * @param {Function=} callback The callback to invoke + * when the url is loaded. + */ + Tone.Sampler.prototype.add = function (note, url, callback) { + if (Tone.isNote(note)) { + //convert the note name to MIDI + var mid = Tone.Frequency(note).toMidi(); + this._buffers.add(mid, url, callback); + } else if (!isNaN(parseFloat(note))) { + //otherwise if it's numbers assume it's midi + this._buffers.add(note, url, callback); + } else { + throw new Error('Tone.Sampler: note must be the note\'s pitch. Instead got ' + note); + } + }; + /** + * If the buffers are loaded or not + * @memberOf Tone.Sampler# + * @type {Boolean} + * @name loaded + * @readOnly + */ + Object.defineProperty(Tone.Sampler.prototype, 'loaded', { + get: function () { + return this._buffers.loaded; + } + }); + /** + * Clean up + * @return {Tone.Sampler} this + */ + Tone.Sampler.prototype.dispose = function () { + Tone.Instrument.prototype.dispose.call(this); + this._buffers.dispose(); + this._buffers = null; + for (var midi in this._activeSources) { + this._activeSources[midi].forEach(function (event) { + event.source.dispose(); + }); + } + this._activeSources = null; + return this; + }; + return Tone.Sampler; + }); + Module(function (Tone) { + if (Tone.supported) { + if (!OscillatorNode.prototype.setPeriodicWave) { + OscillatorNode.prototype.setPeriodicWave = OscillatorNode.prototype.setWaveTable; + } + if (!AudioContext.prototype.createPeriodicWave) { + AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable; + } + } + }); + Module(function (Tone) { + + /** + * @class Maps a NormalRange [0, 1] to an AudioRange [-1, 1]. + * See also Tone.AudioToGain. + * + * @extends {Tone.SignalBase} + * @constructor + * @example + * var g2a = new Tone.GainToAudio(); + */ + Tone.GainToAudio = function () { + Tone.SignalBase.call(this); + /** + * @type {WaveShaperNode} + * @private + */ + this._norm = this.input = this.output = new Tone.WaveShaper(function (x) { + return Math.abs(x) * 2 - 1; + }); + }; + Tone.extend(Tone.GainToAudio, Tone.SignalBase); + /** + * clean up + * @returns {Tone.GainToAudio} this + */ + Tone.GainToAudio.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._norm.dispose(); + this._norm = null; + return this; + }; + return Tone.GainToAudio; + }); + Module(function (Tone) { + + /** + * @class Normalize takes an input min and max and maps it linearly to NormalRange [0,1] + * + * @extends {Tone.SignalBase} + * @constructor + * @param {number} inputMin the min input value + * @param {number} inputMax the max input value + * @example + * var norm = new Tone.Normalize(2, 4); + * var sig = new Tone.Signal(3).connect(norm); + * //output of norm is 0.5. + */ + Tone.Normalize = function (inputMin, inputMax) { + Tone.SignalBase.call(this); + /** + * the min input value + * @type {number} + * @private + */ + this._inputMin = Tone.defaultArg(inputMin, 0); + /** + * the max input value + * @type {number} + * @private + */ + this._inputMax = Tone.defaultArg(inputMax, 1); + /** + * subtract the min from the input + * @type {Tone.Add} + * @private + */ + this._sub = this.input = new Tone.Add(0); + /** + * divide by the difference between the input and output + * @type {Tone.Multiply} + * @private + */ + this._div = this.output = new Tone.Multiply(1); + this._sub.connect(this._div); + this._setRange(); + }; + Tone.extend(Tone.Normalize, Tone.SignalBase); + /** + * The minimum value the input signal will reach. + * @memberOf Tone.Normalize# + * @type {number} + * @name min + */ + Object.defineProperty(Tone.Normalize.prototype, 'min', { + get: function () { + return this._inputMin; + }, + set: function (min) { + this._inputMin = min; + this._setRange(); + } + }); + /** + * The maximum value the input signal will reach. + * @memberOf Tone.Normalize# + * @type {number} + * @name max + */ + Object.defineProperty(Tone.Normalize.prototype, 'max', { + get: function () { + return this._inputMax; + }, + set: function (max) { + this._inputMax = max; + this._setRange(); + } + }); + /** + * set the values + * @private + */ + Tone.Normalize.prototype._setRange = function () { + this._sub.value = -this._inputMin; + this._div.value = 1 / (this._inputMax - this._inputMin); + }; + /** + * clean up + * @returns {Tone.Normalize} this + */ + Tone.Normalize.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._sub.dispose(); + this._sub = null; + this._div.dispose(); + this._div = null; + return this; + }; + return Tone.Normalize; + }); + Module(function (Tone) { + /** + * @class Tone.TransportTimelineSignal extends Tone.Signal, but adds the ability to synchronize the signal to the signal to the Tone.Transport + * @extends {Tone.Signal} + */ + Tone.TransportTimelineSignal = function () { + Tone.Signal.apply(this, arguments); + /** + * The real signal output + * @type {Tone.Signal} + * @private + */ + this.output = this._outputSig = new Tone.Signal(this._initialValue); + /** + * Keep track of the last value. (small optimization) + * @private + * @type {Number} + */ + this._lastVal = this.value; + /** + * The event id of the tick update loop + * @private + * @type {Number} + */ + this._synced = Tone.Transport.scheduleRepeat(this._onTick.bind(this), '1i'); + /** + * A bound version of the anchor value methods + * @type {Function} + * @private + */ + this._bindAnchorValue = this._anchorValue.bind(this); + Tone.Transport.on('start stop pause', this._bindAnchorValue); + this._events.memory = Infinity; + }; + Tone.extend(Tone.TransportTimelineSignal, Tone.Signal); + /** + * Callback which is invoked every tick. + * @private + * @param {Number} time + * @return {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype._onTick = function (time) { + var val = this.getValueAtTime(Tone.Transport.seconds); + if (this._lastVal !== val) { + this._lastVal = val; + //approximate ramp curves with linear ramps + this._outputSig.linearRampToValueAtTime(val, time); + } + }; + /** + * Anchor the value at the start and stop of the Transport + * @param {Number} time The time of the event + * @return {Tone.TransportTimelineSignal} this + * @private + */ + Tone.TransportTimelineSignal.prototype._anchorValue = function (time) { + var val = this.getValueAtTime(Tone.Transport.seconds); + this._lastVal = val; + this._outputSig.cancelScheduledValues(time); + this._outputSig.setValueAtTime(val, time); + return this; + }; + /** + * Get the scheduled value at the given time. This will + * return the unconverted (raw) value. + * @param {TransportTime} time The time in seconds. + * @return {Number} The scheduled value at the given time. + */ + Tone.TransportTimelineSignal.prototype.getValueAtTime = function (time) { + time = Tone.TransportTime(time); + return Tone.Signal.prototype.getValueAtTime.call(this, time); + }; + /** + * Set the output of the signal at the given time + * @param {Number} value The value to change to at the given time + * @param {TransportTime} time The time to change the signal + * @return {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype.setValueAtTime = function (value, time) { + time = Tone.TransportTime(time); + Tone.Signal.prototype.setValueAtTime.call(this, value, time); + return this; + }; + /** + * Linear ramp to the given value from the previous scheduled point to the given value + * @param {Number} value The value to change to at the given time + * @param {TransportTime} time The time to change the signal + * @return {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype.linearRampToValueAtTime = function (value, time) { + time = Tone.TransportTime(time); + Tone.Signal.prototype.linearRampToValueAtTime.call(this, value, time); + return this; + }; + /** + * Exponential ramp to the given value from the previous scheduled point to the given value + * @param {Number} value The value to change to at the given time + * @param {TransportTime} time The time to change the signal + * @return {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype.exponentialRampToValueAtTime = function (value, time) { + time = Tone.TransportTime(time); + Tone.Signal.prototype.exponentialRampToValueAtTime.call(this, value, time); + return this; + }; + /** + * Start exponentially approaching the target value at the given time with + * a rate having the given time constant. + * @param {number} value + * @param {TransportTime} startTime + * @param {number} timeConstant + * @return {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype.setTargetAtTime = function (value, startTime, timeConstant) { + startTime = Tone.TransportTime(startTime); + Tone.Signal.prototype.setTargetAtTime.call(this, value, startTime, timeConstant); + return this; + }; + /** + * Cancels all scheduled parameter changes with times greater than or + * equal to startTime. + * @param {TransportTime} startTime + * @returns {Tone.Param} this + */ + Tone.TransportTimelineSignal.prototype.cancelScheduledValues = function (startTime) { + startTime = Tone.TransportTime(startTime); + Tone.Signal.prototype.cancelScheduledValues.call(this, startTime); + return this; + }; + /** + * Set an array of arbitrary values starting at the given time for the given duration. + * @param {Float32Array} values + * @param {Time} startTime + * @param {Time} duration + * @param {NormalRange} [scaling=1] If the values in the curve should be scaled by some value + * @returns {Tone.Signal} this + */ + Tone.TransportTimelineSignal.prototype.setValueCurveAtTime = function (values, startTime, duration, scaling) { + startTime = Tone.TransportTime(startTime); + duration = Tone.TransportTime(duration); + Tone.Signal.prototype.setValueCurveAtTime.call(this, values, startTime, duration, scaling); + return this; + }; + /** + * This is similar to [cancelScheduledValues](#cancelScheduledValues) except + * it holds the automated value at time until the next automated event. + * @param {Time} time + * @returns {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype.cancelAndHoldAtTime = function (time) { + return Tone.Signal.prototype.cancelAndHoldAtTime.call(this, Tone.TransportTime(time)); + }; + /** + * Dispose and disconnect + * @return {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype.dispose = function () { + Tone.Transport.clear(this._synced); + Tone.Transport.off('start stop pause', this._syncedCallback); + this._events.cancel(0); + Tone.Signal.prototype.dispose.call(this); + this._outputSig.dispose(); + this._outputSig = null; + }; + return Tone.TransportTimelineSignal; + }); + Module(function (Tone) { + /** + * @class Tone.GrainPlayer implements [granular synthesis](https://en.wikipedia.org/wiki/Granular_synthesis). + * Granular Synthesis enables you to adjust pitch and playback rate independently. The grainSize is the + * amount of time each small chunk of audio is played for and the overlap is the + * amount of crossfading transition time between successive grains. + * @extends {Tone.Source} + * @param {String|Tone.Buffer} url The url to load, or the Tone.Buffer to play. + * @param {Function=} callback The callback to invoke after the url is loaded. + */ + Tone.GrainPlayer = function () { + var options = Tone.defaults(arguments, [ + 'url', + 'onload' + ], Tone.GrainPlayer); + Tone.Source.call(this, options); + /** + * The audio buffer belonging to the player. + * @type {Tone.Buffer} + */ + this.buffer = new Tone.Buffer(options.url, options.onload); + /** + * Create a repeating tick to schedule + * the grains. + * @type {Tone.Clock} + * @private + */ + this._clock = new Tone.Clock(this._tick.bind(this), options.grainSize); + /** + * @type {Number} + * @private + */ + this._loopStart = 0; + /** + * @type {Number} + * @private + */ + this._loopEnd = 0; + /** + * All of the currently playing BufferSources + * @type {Array} + * @private + */ + this._activeSources = []; + /** + * @type {Number} + * @private + */ + this._playbackRate = options.playbackRate; + /** + * @type {Number} + * @private + */ + this._grainSize = options.grainSize; + /** + * @private + * @type {Number} + */ + this._overlap = options.overlap; + /** + * Adjust the pitch independently of the playbackRate. + * @type {Cents} + */ + this.detune = options.detune; + //setup + this.overlap = options.overlap; + this.loop = options.loop; + this.playbackRate = options.playbackRate; + this.grainSize = options.grainSize; + this.loopStart = options.loopStart; + this.loopEnd = options.loopEnd; + this.reverse = options.reverse; + this._clock.on('stop', this._onstop.bind(this)); + }; + Tone.extend(Tone.GrainPlayer, Tone.Source); + /** + * the default parameters + * @static + * @const + * @type {Object} + */ + Tone.GrainPlayer.defaults = { + 'onload': Tone.noOp, + 'overlap': 0.1, + 'grainSize': 0.2, + 'playbackRate': 1, + 'detune': 0, + 'loop': false, + 'loopStart': 0, + 'loopEnd': 0, + 'reverse': false + }; + /** + * Play the buffer at the given startTime. Optionally add an offset + * and/or duration which will play the buffer from a position + * within the buffer for the given duration. + * + * @param {Time} [startTime=now] When the player should start. + * @param {Time} [offset=0] The offset from the beginning of the sample + * to start at. + * @param {Time=} duration How long the sample should play. If no duration + * is given, it will default to the full length + * of the sample (minus any offset) + * @returns {Tone.GrainPlayer} this + * @memberOf Tone.GrainPlayer# + * @method start + * @name start + */ + /** + * Internal start method + * @param {Time} time + * @param {Time} offset + * @private + */ + Tone.GrainPlayer.prototype._start = function (time, offset, duration) { + offset = Tone.defaultArg(offset, 0); + offset = this.toSeconds(offset); + time = this.toSeconds(time); + this._offset = offset; + this._clock.start(time); + if (duration) { + this.stop(time + this.toSeconds(duration)); + } + }; + /** + * Internal start method + * @param {Time} time + * @private + */ + Tone.GrainPlayer.prototype._stop = function (time) { + this._clock.stop(time); + }; + /** + * Invoked when the clock is stopped + * @param {Number} time + * @private + */ + Tone.GrainPlayer.prototype._onstop = function (time) { + //stop the players + this._activeSources.forEach(function (source) { + source.stop(time, 0); + }); + }; + /** + * Invoked on each clock tick. scheduled a new + * grain at this time. + * @param {Time} time + * @private + */ + Tone.GrainPlayer.prototype._tick = function (time) { + var fadeIn = this._offset < this._overlap ? 0 : this._overlap; + var source = new Tone.BufferSource({ + 'buffer': this.buffer, + 'fadeIn': fadeIn, + 'fadeOut': this._overlap, + 'loop': this.loop, + 'loopStart': this._loopStart, + 'loopEnd': this._loopEnd, + 'playbackRate': Tone.intervalToFrequencyRatio(this.detune / 100) + }).connect(this.output); + source.start(time, this._offset); + this._offset += this.grainSize; + source.stop(time + this.grainSize); + //add it to the active sources + this._activeSources.push(source); + //remove it when it's done + source.onended = function () { + var index = this._activeSources.indexOf(source); + if (index !== -1) { + this._activeSources.splice(index, 1); + } + }.bind(this); + }; + /** + * Jump to a specific time and play it. + * @param {Time} offset The offset to jump to. + * @param {Time=} time When to make the jump. + * @return {Tone.GrainPlayer} this + */ + Tone.GrainPlayer.prototype.seek = function (offset, time) { + this._offset = this.toSeconds(offset); + this._tick(this.toSeconds(time)); + return this; + }; + /** + * The playback rate of the sample + * @memberOf Tone.GrainPlayer# + * @type {Positive} + * @name playbackRate + */ + Object.defineProperty(Tone.GrainPlayer.prototype, 'playbackRate', { + get: function () { + return this._playbackRate; + }, + set: function (rate) { + this._playbackRate = rate; + this.grainSize = this._grainSize; + } + }); + /** + * The loop start time. + * @memberOf Tone.GrainPlayer# + * @type {Time} + * @name loopStart + */ + Object.defineProperty(Tone.GrainPlayer.prototype, 'loopStart', { + get: function () { + return this._loopStart; + }, + set: function (time) { + this._loopStart = this.toSeconds(time); + } + }); + /** + * The loop end time. + * @memberOf Tone.GrainPlayer# + * @type {Time} + * @name loopEnd + */ + Object.defineProperty(Tone.GrainPlayer.prototype, 'loopEnd', { + get: function () { + return this._loopEnd; + }, + set: function (time) { + this._loopEnd = this.toSeconds(time); + } + }); + /** + * The direction the buffer should play in + * @memberOf Tone.GrainPlayer# + * @type {boolean} + * @name reverse + */ + Object.defineProperty(Tone.GrainPlayer.prototype, 'reverse', { + get: function () { + return this.buffer.reverse; + }, + set: function (rev) { + this.buffer.reverse = rev; + } + }); + /** + * The size of each chunk of audio that the + * buffer is chopped into and played back at. + * @memberOf Tone.GrainPlayer# + * @type {Time} + * @name grainSize + */ + Object.defineProperty(Tone.GrainPlayer.prototype, 'grainSize', { + get: function () { + return this._grainSize; + }, + set: function (size) { + this._grainSize = this.toSeconds(size); + this._clock.frequency.value = this._playbackRate / this._grainSize; + } + }); + /** + * This is the duration of the cross-fade between + * sucessive grains. + * @memberOf Tone.GrainPlayer# + * @type {Time} + * @name overlap + */ + Object.defineProperty(Tone.GrainPlayer.prototype, 'overlap', { + get: function () { + return this._overlap; + }, + set: function (time) { + this._overlap = this.toSeconds(time); + } + }); + /** + * Clean up + * @return {Tone.GrainPlayer} this + */ + Tone.GrainPlayer.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this.buffer.dispose(); + this.buffer = null; + this._clock.dispose(); + this._clock = null; + this._activeSources.forEach(function (source) { + source.dispose(); + }); + this._activeSources = null; + return this; + }; + return Tone.GrainPlayer; + }); + Module(function (Tone) { + + /** + * @class Tone.Player is an audio file player with start, loop, and stop functions. + * + * @constructor + * @extends {Tone.Source} + * @param {string|AudioBuffer} url Either the AudioBuffer or the url from + * which to load the AudioBuffer + * @param {Function=} onload The function to invoke when the buffer is loaded. + * Recommended to use Tone.Buffer.on('load') instead. + * @example + * var player = new Tone.Player("./path/to/sample.mp3").toMaster(); + * //play as soon as the buffer is loaded + * player.autostart = true; + */ + Tone.Player = function (url) { + var options; + if (url instanceof Tone.Buffer && url.loaded) { + url = url.get(); + options = Tone.Player.defaults; + } else { + options = Tone.defaults(arguments, [ + 'url', + 'onload' + ], Tone.Player); + } + Tone.Source.call(this, options); + /** + * If the file should play as soon + * as the buffer is loaded. + * @type {Boolean} + * @example + * //will play as soon as it's loaded + * var player = new Tone.Player({ + * "url" : "./path/to/sample.mp3", + * "autostart" : true, + * }).toMaster(); + */ + this.autostart = options.autostart; + /** + * the buffer + * @private + * @type {Tone.Buffer} + */ + this._buffer = new Tone.Buffer({ + 'url': options.url, + 'onload': this._onload.bind(this, options.onload), + 'reverse': options.reverse + }); + if (url instanceof AudioBuffer) { + this._buffer.set(url); + } + /** + * if the buffer should loop once it's over + * @type {Boolean} + * @private + */ + this._loop = options.loop; + /** + * if 'loop' is true, the loop will start at this position + * @type {Time} + * @private + */ + this._loopStart = options.loopStart; + /** + * if 'loop' is true, the loop will end at this position + * @type {Time} + * @private + */ + this._loopEnd = options.loopEnd; + /** + * the playback rate + * @private + * @type {Number} + */ + this._playbackRate = options.playbackRate; + /** + * All of the active buffer source nodes + * @type {Array<Tone.BufferSource>} + * @private + */ + this._activeSources = []; + /** + * The elapsed time counter. + * @type {Tone.TickSource} + * @private + */ + this._elapsedTime = new Tone.TickSource(options.playbackRate); + /** + * The fadeIn time of the amplitude envelope. + * @type {Time} + */ + this.fadeIn = options.fadeIn; + /** + * The fadeOut time of the amplitude envelope. + * @type {Time} + */ + this.fadeOut = options.fadeOut; + }; + Tone.extend(Tone.Player, Tone.Source); + /** + * the default parameters + * @static + * @const + * @type {Object} + */ + Tone.Player.defaults = { + 'onload': Tone.noOp, + 'playbackRate': 1, + 'loop': false, + 'autostart': false, + 'loopStart': 0, + 'loopEnd': 0, + 'retrigger': false, + 'reverse': false, + 'fadeIn': 0, + 'fadeOut': 0 + }; + /** + * Load the audio file as an audio buffer. + * Decodes the audio asynchronously and invokes + * the callback once the audio buffer loads. + * Note: this does not need to be called if a url + * was passed in to the constructor. Only use this + * if you want to manually load a new url. + * @param {string} url The url of the buffer to load. + * Filetype support depends on the + * browser. + * @param {Function=} callback The function to invoke once + * the sample is loaded. + * @returns {Promise} + */ + Tone.Player.prototype.load = function (url, callback) { + return this._buffer.load(url, this._onload.bind(this, callback)); + }; + /** + * Internal callback when the buffer is loaded. + * @private + */ + Tone.Player.prototype._onload = function (callback) { + callback = Tone.defaultArg(callback, Tone.noOp); + callback(this); + if (this.autostart) { + this.start(); + } + }; + /** + * Internal callback when the buffer is done playing. + * @private + */ + Tone.Player.prototype._onSourceEnd = function (source) { + var index = this._activeSources.indexOf(source); + this._activeSources.splice(index, 1); + }; + /** + * Play the buffer at the given startTime. Optionally add an offset + * and/or duration which will play the buffer from a position + * within the buffer for the given duration. + * + * @param {Time} [startTime=now] When the player should start. + * @param {Time} [offset=0] The offset from the beginning of the sample + * to start at. + * @param {Time=} duration How long the sample should play. If no duration + * is given, it will default to the full length + * of the sample (minus any offset) + * @returns {Tone.Player} this + * @memberOf Tone.Player# + * @method start + * @name start + */ + /** + * Internal start method + * @private + */ + Tone.Player.prototype._start = function (startTime, offset, duration) { + //if it's a loop the default offset is the loopstart point + if (this._loop) { + offset = Tone.defaultArg(offset, this._loopStart); + } else { + //otherwise the default offset is 0 + offset = Tone.defaultArg(offset, 0); + } + //compute the values in seconds + offset = this.toSeconds(offset); + var computedDuration = Tone.defaultArg(duration, Math.max(this._buffer.duration - offset, 0)); + computedDuration = this.toSeconds(computedDuration); + startTime = this.toSeconds(startTime); + //start the elapsed time counter + this._elapsedTime.start(startTime, offset); + //make the source + var source = new Tone.BufferSource({ + 'buffer': this._buffer, + 'loop': this._loop, + 'loopStart': this._loopStart, + 'loopEnd': this._loopEnd, + 'onended': this._onSourceEnd.bind(this), + 'playbackRate': this._playbackRate, + 'fadeIn': this.fadeIn, + 'fadeOut': this.fadeOut + }).connect(this.output); + //set the looping properties + if (!this._loop && !this._synced) { + //if it's not looping, set the state change at the end of the sample + this._state.setStateAtTime(Tone.State.Stopped, startTime + computedDuration / this._playbackRate); + } + //add it to the array of active sources + this._activeSources.push(source); + //start it + if (this._loop && Tone.isUndef(duration)) { + source.start(startTime, offset); + } else { + source.start(startTime, offset, computedDuration); + } + return this; + }; + /** + * Stop playback. + * @private + * @param {Time} [time=now] + * @returns {Tone.Player} this + */ + Tone.Player.prototype._stop = function (time) { + time = this.toSeconds(time); + this._elapsedTime.stop(time); + this._activeSources.forEach(function (source) { + source.stop(time); + }); + return this; + }; + /** + * Stop and then restart the player from the beginning (or offset) + * @param {Time} [startTime=now] When the player should start. + * @param {Time} [offset=0] The offset from the beginning of the sample + * to start at. + * @param {Time=} duration How long the sample should play. If no duration + * is given, it will default to the full length + * of the sample (minus any offset) + * @returns {Tone.Player} this + */ + Tone.Player.prototype.restart = function (time, offset, duration) { + this._stop(time); + this._start(time, offset, duration); + return this; + }; + /** + * Seek to a specific time in the player's buffer. If the + * source is no longer playing at that time, it will stop. + * If you seek to a time that + * @param {Time} offset The time to seek to. + * @param {Time=} time The time for the seek event to occur. + * @return {Tone.Player} this + * @example + * source.start(0.2); + * source.stop(0.4); + */ + Tone.Player.prototype.seek = function (offset, time) { + time = this.toSeconds(time); + if (this._state.getValueAtTime(time) === Tone.State.Started) { + offset = this.toSeconds(offset); + // if it's currently playing, stop it + this._stop(time); + //restart it at the given time + this._start(time, offset); + } + return this; + }; + /** + * Set the loop start and end. Will only loop if loop is + * set to true. + * @param {Time} loopStart The loop end time + * @param {Time} loopEnd The loop end time + * @returns {Tone.Player} this + * @example + * //loop 0.1 seconds of the file. + * player.setLoopPoints(0.2, 0.3); + * player.loop = true; + */ + Tone.Player.prototype.setLoopPoints = function (loopStart, loopEnd) { + this.loopStart = loopStart; + this.loopEnd = loopEnd; + return this; + }; + /** + * If loop is true, the loop will start at this position. + * @memberOf Tone.Player# + * @type {Time} + * @name loopStart + */ + Object.defineProperty(Tone.Player.prototype, 'loopStart', { + get: function () { + return this._loopStart; + }, + set: function (loopStart) { + this._loopStart = loopStart; + //get the current source + this._activeSources.forEach(function (source) { + source.loopStart = loopStart; + }); + } + }); + /** + * If loop is true, the loop will end at this position. + * @memberOf Tone.Player# + * @type {Time} + * @name loopEnd + */ + Object.defineProperty(Tone.Player.prototype, 'loopEnd', { + get: function () { + return this._loopEnd; + }, + set: function (loopEnd) { + this._loopEnd = loopEnd; + //get the current source + this._activeSources.forEach(function (source) { + source.loopEnd = loopEnd; + }); + } + }); + /** + * The audio buffer belonging to the player. + * @memberOf Tone.Player# + * @type {Tone.Buffer} + * @name buffer + */ + Object.defineProperty(Tone.Player.prototype, 'buffer', { + get: function () { + return this._buffer; + }, + set: function (buffer) { + this._buffer.set(buffer); + } + }); + /** + * If the buffer should loop once it's over. + * @memberOf Tone.Player# + * @type {Boolean} + * @name loop + */ + Object.defineProperty(Tone.Player.prototype, 'loop', { + get: function () { + return this._loop; + }, + set: function (loop) { + //if no change, do nothing + if (this._loop === loop) { + return; + } + this._loop = loop; + var now = this.now(); + if (!loop) { + //stop the playback on the next cycle + this._stopAtNextIteration(now); + } else { + //remove the next stopEvent + var stopEvent = this._state.getNextState(Tone.State.Stopped, now); + if (stopEvent) { + this._activeSources.forEach(function (source) { + source.loop = loop; + }); + this._state.cancel(stopEvent.time); + this._elapsedTime.cancel(stopEvent.time); + } + } + } + }); + /** + * Schedules a stop event at the next full iteration. Used + * for scheduling stop when the loop state or playbackRate changes + * @param {Number} now The current time + * @private + */ + Tone.Player.prototype._stopAtNextIteration = function (now) { + if (this._state.getValueAtTime(now) === Tone.State.Started) { + var nextStop = this._state.getNextState(Tone.State.Stopped, now); + var position = this._elapsedTime.getTicksAtTime(now); + var iterations = Math.max(Math.ceil(position / this.buffer.duration), 1); + var stopTime = this._elapsedTime.getTimeOfTick(iterations * this.buffer.duration, nextStop ? nextStop.time - this.sampleTime : Infinity); + this.stop(stopTime); + } + }; + /** + * The playback speed. 1 is normal speed. This is not a signal because + * Safari and iOS currently don't support playbackRate as a signal. + * @memberOf Tone.Player# + * @type {Number} + * @name playbackRate + */ + Object.defineProperty(Tone.Player.prototype, 'playbackRate', { + get: function () { + return this._playbackRate; + }, + set: function (rate) { + this._playbackRate = rate; + var now = this.now(); + this._elapsedTime.frequency.setValueAtTime(rate, now); + //if it's not looping + if (!this._loop) { + this._stopAtNextIteration(now); + } + //set all the sources + this._activeSources.forEach(function (source) { + source.playbackRate.setValueAtTime(rate, now); + }); + } + }); + /** + * The current playback position of the buffer. + * @memberOf Tone.Player# + * @type {Number} + * @name position + */ + Object.defineProperty(Tone.Player.prototype, 'position', { + get: function () { + var now = this.now(); + if (this._state.getValueAtTime(now) === Tone.State.Started && this.loaded) { + var duration = this.buffer.duration; + var position = this._elapsedTime.getTicksAtTime(now); + return position % duration; + } else { + return 0; + } + } + }); + /** + * The direction the buffer should play in + * @memberOf Tone.Player# + * @type {Boolean} + * @name reverse + */ + Object.defineProperty(Tone.Player.prototype, 'reverse', { + get: function () { + return this._buffer.reverse; + }, + set: function (rev) { + this._buffer.reverse = rev; + } + }); + /** + * If all the buffer is loaded + * @memberOf Tone.Player# + * @type {Boolean} + * @name loaded + * @readOnly + */ + Object.defineProperty(Tone.Player.prototype, 'loaded', { + get: function () { + return this._buffer.loaded; + } + }); + /** + * Dispose and disconnect. + * @return {Tone.Player} this + */ + Tone.Player.prototype.dispose = function () { + //disconnect all of the players + this._activeSources.forEach(function (source) { + source.dispose(); + }); + this._activeSources = null; + Tone.Source.prototype.dispose.call(this); + this._buffer.dispose(); + this._buffer = null; + this._elapsedTime.dispose(); + this._elapsedTime = null; + return this; + }; + return Tone.Player; + }); + Module(function (Tone) { + + /** + * @class Tone.Players combines multiple [Tone.Player](Player) objects. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Object} urls An object mapping a name to a url. + * @param {function=} onload The function to invoke when all buffers are loaded. + */ + Tone.Players = function (urls) { + var args = Array.prototype.slice.call(arguments); + args.shift(); + var options = Tone.defaults(args, ['onload'], Tone.Players); + Tone.call(this); + /** + * The output volume node + * @type {Tone.Volume} + * @private + */ + this._volume = this.output = new Tone.Volume(options.volume); + /** + * The volume of the output in decibels. + * @type {Decibels} + * @signal + * @example + * source.volume.value = -6; + */ + this.volume = this._volume.volume; + this._readOnly('volume'); + //make the output explicitly stereo + this._volume.output.output.channelCount = 2; + this._volume.output.output.channelCountMode = 'explicit'; + //mute initially + this.mute = options.mute; + /** + * The container of all of the players + * @type {Object} + * @private + */ + this._players = {}; + /** + * The loading count + * @type {Number} + * @private + */ + this._loadingCount = 0; + /** + * private holder of the fadeIn time + * @type {Time} + * @private + */ + this._fadeIn = options.fadeIn; + /** + * private holder of the fadeOut time + * @type {Time} + * @private + */ + this._fadeOut = options.fadeOut; + //add all of the players + for (var name in urls) { + this._loadingCount++; + this.add(name, urls[name], this._bufferLoaded.bind(this, options.onload)); + } + }; + Tone.extend(Tone.Players, Tone.AudioNode); + /** + * The default values + * @type {Object} + */ + Tone.Players.defaults = { + 'volume': 0, + 'mute': false, + 'onload': Tone.noOp, + 'fadeIn': 0, + 'fadeOut': 0 + }; + /** + * A buffer was loaded. decrement the counter. + * @param {Function} callback + * @private + */ + Tone.Players.prototype._bufferLoaded = function (callback) { + this._loadingCount--; + if (this._loadingCount === 0 && callback) { + callback(this); + } + }; + /** + * Mute the output. + * @memberOf Tone.Source# + * @type {boolean} + * @name mute + * @example + * //mute the output + * source.mute = true; + */ + Object.defineProperty(Tone.Players.prototype, 'mute', { + get: function () { + return this._volume.mute; + }, + set: function (mute) { + this._volume.mute = mute; + } + }); + /** + * The fadeIn time of the amplitude envelope. + * @memberOf Tone.Source# + * @type {Time} + * @name fadeIn + */ + Object.defineProperty(Tone.Players.prototype, 'fadeIn', { + get: function () { + return this._fadeIn; + }, + set: function (fadeIn) { + this._fadeIn = fadeIn; + this._forEach(function (player) { + player.fadeIn = fadeIn; + }); + } + }); + /** + * The fadeOut time of the amplitude envelope. + * @memberOf Tone.Source# + * @type {Time} + * @name fadeOut + */ + Object.defineProperty(Tone.Players.prototype, 'fadeOut', { + get: function () { + return this._fadeOut; + }, + set: function (fadeOut) { + this._fadeOut = fadeOut; + this._forEach(function (player) { + player.fadeOut = fadeOut; + }); + } + }); + /** + * The state of the players object. Returns "started" if any of the players are playing. + * @memberOf Tone.Players# + * @type {String} + * @name state + * @readOnly + */ + Object.defineProperty(Tone.Players.prototype, 'state', { + get: function () { + var playing = false; + this._forEach(function (player) { + playing = playing || player.state === Tone.State.Started; + }); + return playing ? Tone.State.Started : Tone.State.Stopped; + } + }); + /** + * True if the buffers object has a buffer by that name. + * @param {String|Number} name The key or index of the + * buffer. + * @return {Boolean} + */ + Tone.Players.prototype.has = function (name) { + return this._players.hasOwnProperty(name); + }; + /** + * Get a player by name. + * @param {String} name The players name as defined in + * the constructor object or `add` method. + * @return {Tone.Player} + */ + Tone.Players.prototype.get = function (name) { + if (this.has(name)) { + return this._players[name]; + } else { + throw new Error('Tone.Players: no player named ' + name); + } + }; + /** + * Iterate over all of the players + * @param {Function} callback + * @return {Tone.Players} this + * @private + */ + Tone.Players.prototype._forEach = function (callback) { + for (var playerName in this._players) { + callback(this._players[playerName], playerName); + } + return this; + }; + /** + * If all the buffers are loaded or not + * @memberOf Tone.Players# + * @type {Boolean} + * @name loaded + * @readOnly + */ + Object.defineProperty(Tone.Players.prototype, 'loaded', { + get: function () { + var isLoaded = true; + this._forEach(function (player) { + isLoaded = isLoaded && player.loaded; + }); + return isLoaded; + } + }); + /** + * Add a player by name and url to the Players + * @param {String} name A unique name to give the player + * @param {String|Tone.Buffer|Audiobuffer} url Either the url of the bufer, + * or a buffer which will be added + * with the given name. + * @param {Function=} callback The callback to invoke + * when the url is loaded. + */ + Tone.Players.prototype.add = function (name, url, callback) { + this._players[name] = new Tone.Player(url, callback).connect(this.output); + this._players[name].fadeIn = this._fadeIn; + this._players[name].fadeOut = this._fadeOut; + return this; + }; + /** + * Stop all of the players at the given time + * @param {Time} time The time to stop all of the players. + * @return {Tone.Players} this + */ + Tone.Players.prototype.stopAll = function (time) { + this._forEach(function (player) { + player.stop(time); + }); + }; + /** + * Dispose and disconnect. + * @return {Tone.Players} this + */ + Tone.Players.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._volume.dispose(); + this._volume = null; + this._writable('volume'); + this.volume = null; + this.output = null; + this._forEach(function (player) { + player.dispose(); + }); + this._players = null; + return this; + }; + return Tone.Players; + }); + Module(function (Tone) { + + /** + * @class Tone.UserMedia uses MediaDevices.getUserMedia to open up + * and external microphone or audio input. Check + * [MediaDevices API Support](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) + * to see which browsers are supported. Access to an external input + * is limited to secure (HTTPS) connections. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Decibels=} volume The level of the input + * @example + * //list the inputs and open the third one + * var motu = new Tone.UserMedia(); + * + * //opening the input asks the user to activate their mic + * motu.open().then(function(){ + * //promise resolves when input is available + * }); + */ + Tone.UserMedia = function () { + var options = Tone.defaults(arguments, ['volume'], Tone.UserMedia); + Tone.AudioNode.call(this); + /** + * The MediaStreamNode + * @type {MediaStreamAudioSourceNode} + * @private + */ + this._mediaStream = null; + /** + * The media stream created by getUserMedia. + * @type {LocalMediaStream} + * @private + */ + this._stream = null; + /** + * The open device + * @type {MediaDeviceInfo} + * @private + */ + this._device = null; + /** + * The output volume node + * @type {Tone.Volume} + * @private + */ + this._volume = this.output = new Tone.Volume(options.volume); + /** + * The volume of the output in decibels. + * @type {Decibels} + * @signal + * @example + * input.volume.value = -6; + */ + this.volume = this._volume.volume; + this._readOnly('volume'); + this.mute = options.mute; + }; + Tone.extend(Tone.UserMedia, Tone.AudioNode); + /** + * the default parameters + * @type {Object} + */ + Tone.UserMedia.defaults = { + 'volume': 0, + 'mute': false + }; + /** + * Open the media stream. If a string is passed in, it is assumed + * to be the label or id of the stream, if a number is passed in, + * it is the input number of the stream. + * @param {String|Number} [labelOrId="default"] The label or id of the audio input media device. + * With no argument, the default stream is opened. + * @return {Promise} The promise is resolved when the stream is open. + */ + Tone.UserMedia.prototype.open = function (labelOrId) { + return Tone.UserMedia.enumerateDevices().then(function (devices) { + var device; + if (Tone.isNumber(labelOrId)) { + device = devices[labelOrId]; + } else { + device = devices.find(function (device) { + return device.label === labelOrId || device.deviceId === labelOrId; + }); + //didn't find a matching device + if (!device && devices.length > 0) { + device = devices[0]; + } else if (!device && Tone.isDefined(labelOrId)) { + throw new Error('Tone.UserMedia: no matching device: ' + labelOrId); + } + } + this._device = device; + //do getUserMedia + var constraints = { + audio: { + 'echoCancellation': false, + 'sampleRate': this.context.sampleRate + } + }; + if (device) { + constraints.audio.deviceId = device.deviceId; + } + return navigator.mediaDevices.getUserMedia(constraints).then(function (stream) { + //start a new source only if the previous one is closed + if (!this._stream) { + this._stream = stream; + //Wrap a MediaStreamSourceNode around the live input stream. + this._mediaStream = this.context.createMediaStreamSource(stream); + //Connect the MediaStreamSourceNode to a gate gain node + this._mediaStream.connect(this.output); + } + return this; + }.bind(this)); + }.bind(this)); + }; + /** + * Close the media stream + * @return {Tone.UserMedia} this + */ + Tone.UserMedia.prototype.close = function () { + if (this._stream) { + this._stream.getAudioTracks().forEach(function (track) { + track.stop(); + }); + this._stream = null; + //remove the old media stream + this._mediaStream.disconnect(); + this._mediaStream = null; + } + this._device = null; + return this; + }; + /** + * Returns a promise which resolves with the list of audio input devices available. + * @return {Promise} The promise that is resolved with the devices + * @static + * @example + * Tone.UserMedia.enumerateDevices().then(function(devices){ + * console.log(devices) + * }) + */ + Tone.UserMedia.enumerateDevices = function () { + return navigator.mediaDevices.enumerateDevices().then(function (devices) { + return devices.filter(function (device) { + return device.kind === 'audioinput'; + }); + }); + }; + /** + * Returns the playback state of the source, "started" when the microphone is open + * and "stopped" when the mic is closed. + * @type {Tone.State} + * @readOnly + * @memberOf Tone.UserMedia# + * @name state + */ + Object.defineProperty(Tone.UserMedia.prototype, 'state', { + get: function () { + return this._stream && this._stream.active ? Tone.State.Started : Tone.State.Stopped; + } + }); + /** + * Returns an identifier for the represented device that is + * persisted across sessions. It is un-guessable by other applications and + * unique to the origin of the calling application. It is reset when the + * user clears cookies (for Private Browsing, a different identifier is + * used that is not persisted across sessions). Returns undefined when the + * device is not open. + * @type {String} + * @readOnly + * @memberOf Tone.UserMedia# + * @name deviceId + */ + Object.defineProperty(Tone.UserMedia.prototype, 'deviceId', { + get: function () { + if (this._device) { + return this._device.deviceId; + } + } + }); + /** + * Returns a group identifier. Two devices have the + * same group identifier if they belong to the same physical device. + * Returns undefined when the device is not open. + * @type {String} + * @readOnly + * @memberOf Tone.UserMedia# + * @name groupId + */ + Object.defineProperty(Tone.UserMedia.prototype, 'groupId', { + get: function () { + if (this._device) { + return this._device.groupId; + } + } + }); + /** + * Returns a label describing this device (for example "Built-in Microphone"). + * Returns undefined when the device is not open or label is not available + * because of permissions. + * @type {String} + * @readOnly + * @memberOf Tone.UserMedia# + * @name groupId + */ + Object.defineProperty(Tone.UserMedia.prototype, 'label', { + get: function () { + if (this._device) { + return this._device.label; + } + } + }); + /** + * Mute the output. + * @memberOf Tone.UserMedia# + * @type {boolean} + * @name mute + * @example + * //mute the output + * userMedia.mute = true; + */ + Object.defineProperty(Tone.UserMedia.prototype, 'mute', { + get: function () { + return this._volume.mute; + }, + set: function (mute) { + this._volume.mute = mute; + } + }); + /** + * Clean up. + * @return {Tone.UserMedia} this + */ + Tone.UserMedia.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this.close(); + this._writable('volume'); + this._volume.dispose(); + this._volume = null; + this.volume = null; + return this; + }; + /** + * If getUserMedia is supported by the browser. + * @type {Boolean} + * @memberOf Tone.UserMedia# + * @name supported + * @static + * @readOnly + */ + Object.defineProperty(Tone.UserMedia, 'supported', { + get: function () { + return Tone.isDefined(navigator.mediaDevices) && Tone.isFunction(navigator.mediaDevices.getUserMedia); + } + }); + return Tone.UserMedia; + }); + Module(function (Tone) { + /** + * @class Tone.Midi is a primitive type for encoding Time values. + * Tone.Midi can be constructed with or without the `new` keyword. Tone.Midi can be passed + * into the parameter of any method which takes time as an argument. + * @constructor + * @extends {Tone.Frequency} + * @param {String|Number} val The time value. + * @param {String=} units The units of the value. + * @example + * var t = Tone.Midi("4n");//a quarter note + */ + Tone.Midi = function (val, units) { + if (this instanceof Tone.Midi) { + Tone.Frequency.call(this, val, units); + } else { + return new Tone.Midi(val, units); + } + }; + Tone.extend(Tone.Midi, Tone.Frequency); + /** + * The default units if none are given. + * @type {String} + * @private + */ + Tone.Midi.prototype._defaultUnits = 'midi'; + /** + * Returns the value of a frequency in the current units + * @param {Frequency} freq + * @return {Number} + * @private + */ + Tone.Midi.prototype._frequencyToUnits = function (freq) { + return Tone.Frequency.ftom(Tone.Frequency.prototype._frequencyToUnits.call(this, freq)); + }; + /** + * Returns the value of a tick in the current time units + * @param {Ticks} ticks + * @return {Number} + * @private + */ + Tone.Midi.prototype._ticksToUnits = function (ticks) { + return Tone.Frequency.ftom(Tone.Frequency.prototype._ticksToUnits.call(this, ticks)); + }; + /** + * Return the value of the beats in the current units + * @param {Number} beats + * @return {Number} + * @private + */ + Tone.Midi.prototype._beatsToUnits = function (beats) { + return Tone.Frequency.ftom(Tone.Frequency.prototype._beatsToUnits.call(this, beats)); + }; + /** + * Returns the value of a second in the current units + * @param {Seconds} seconds + * @return {Number} + * @private + */ + Tone.Midi.prototype._secondsToUnits = function (seconds) { + return Tone.Frequency.ftom(Tone.Frequency.prototype._secondsToUnits.call(this, seconds)); + }; + /** + * Return the value of the frequency as a MIDI note + * @return {MIDI} + * @example + * Tone.Midi(60).toMidi(); //60 + */ + Tone.Midi.prototype.toMidi = function () { + return this.valueOf(); + }; + /** + * Return the value of the frequency as a MIDI note + * @return {MIDI} + * @example + * Tone.Midi(60).toMidi(); //60 + */ + Tone.Midi.prototype.toFrequency = function () { + return Tone.Frequency.mtof(this.toMidi()); + }; + /** + * Transposes the frequency by the given number of semitones. + * @param {Interval} interval + * @return {Tone.Frequency} A new transposed frequency + * @example + * Tone.Frequency("A4").transpose(3); //"C5" + */ + Tone.Midi.prototype.transpose = function (interval) { + return new this.constructor(this.toMidi() + interval); + }; + return Tone.Midi; + }); + + return Tone; +})); + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.requestAudioContext = exports.browser = exports.mod = exports.choice = undefined; + +var _tone = __webpack_require__(4); + +var _tone2 = _interopRequireDefault(_tone); + +var _startAudioContext = __webpack_require__(18); + +var _startAudioContext2 = _interopRequireDefault(_startAudioContext); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var isIphone = navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i); +var isIpad = navigator.userAgent.match(/iPad/i); +var isAndroid = navigator.userAgent.match(/Android/i); +var isMobile = isIphone || isIpad || isAndroid; +var isDesktop = !isMobile; + +document.body.classList.add(isMobile ? 'mobile' : 'desktop'); + +var browser = { isIphone: isIphone, isIpad: isIpad, isMobile: isMobile, isDesktop: isDesktop }; + +function choice(a) { + return a[Math.floor(Math.random() * a.length)]; +} +function mod(n, m) { + return n - m * Math.floor(n / m); +} + +function requestAudioContext(fn) { + if (isMobile) { + var container = document.createElement('div'); + var button = document.createElement('div'); + button.innerHTML = 'Tap to start - please unmute your phone'; + Object.assign(container.style, { + position: 'absolute', + width: '100%', + height: '100%', + zIndex: '10000', + top: '0px', + left: '0px', + backgroundColor: 'rgba(0, 0, 0, 0.8)' + }); + Object.assign(button.style, { + position: 'absolute', + left: '50%', + top: '50%', + padding: '20px', + backgroundColor: '#7F33ED', + color: 'white', + fontFamily: 'monospace', + borderRadius: '3px', + transform: 'translate3D(-50%,-50%,0)', + textAlign: 'center', + lineHeight: '1.5' + }); + container.appendChild(button); + document.body.appendChild(container); + _startAudioContext2.default.setContext(_tone2.default.context); + _startAudioContext2.default.on(button); + _startAudioContext2.default.onStarted(function (_) { + container.remove(); + fn(); + }); + } else { + fn(); + } +} + +exports.choice = choice; +exports.mod = mod; +exports.browser = browser; +exports.requestAudioContext = requestAudioContext; + +/***/ }), +/* 6 */ +/***/ (function(module, exports) { + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + + return true; +}; + +EventEmitter.prototype.addListener = function(type, listener) { + var m; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); +}; + +function isFunction(arg) { + return typeof arg === 'function'; +} + +function isNumber(arg) { + return typeof arg === 'number'; +} + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} + +function isUndefined(arg) { + return arg === void 0; +} + + +/***/ }), +/* 7 */ +/***/ (function(module, exports) { + + +/** @class utils + Shared utility functions. These functions are exposed as methods of nx in NexusUI projects, i.e. .mtof() here can be accessed in your project with nx.mtof(). +*/ + + +/** @method findPosition + Returns the offset of an HTML element. Returns an object with 'top' and 'left' properties. + @param {DOM element} [element] + ```js + var button1Offset = nx.findPosition(button1.canvas) + ``` +*/ +exports.findPosition = function(element) { + var body = document.body, + win = document.defaultView, + docElem = document.documentElement, + box = document.createElement('div'); + box.style.paddingLeft = box.style.width = "1px"; + body.appendChild(box); + var isBoxModel = box.offsetWidth == 2; + body.removeChild(box); + box = element.getBoundingClientRect(); + var clientTop = docElem.clientTop || body.clientTop || 0, + clientLeft = docElem.clientLeft || body.clientLeft || 0, + scrollTop = win.pageYOffset || isBoxModel && docElem.scrollTop || body.scrollTop, + scrollLeft = win.pageXOffset || isBoxModel && docElem.scrollLeft || body.scrollLeft; + return { + top : box.top + scrollTop - clientTop, + left: box.left + scrollLeft - clientLeft + }; +} + +exports.getCursorPosition = function(e, canvas_offset) { + var x; + var y; + if (e.pageX != undefined && e.pageY != undefined) { + x = e.pageX; + y = e.pageY; + } else { + x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; + y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; + } + x -= canvas_offset.left; + y -= canvas_offset.top; + var click_position = {x: x, y: y}; + click_position.touches = [ {x: x, y: y } ]; + return click_position; +} + +exports.getTouchPosition = function(e, canvas_offset) { + var x; + var y; + x = e.targetTouches[0].pageX; + y = e.targetTouches[0].pageY; + x -= canvas_offset.left; + y -= canvas_offset.top; + var click_position = {x: x, y: y}; + + click_position.touches = new Array(); + for (var i=0;i<e.targetTouches.length;i++) { + click_position.touches.push({ + x: e.targetTouches[i].pageX - canvas_offset.left, + y: e.targetTouches[i].pageY - canvas_offset.top + }); + } + click_position.changed = new Array(); + for (var i=0;i<e.changedTouches.length;i++) { + click_position.changed.push({ + x: e.changedTouches[i].pageX - canvas_offset.left, + y: e.changedTouches[i].pageY - canvas_offset.top + }); + } + return click_position; +} + +/***/ }), +/* 8 */ +/***/ (function(module, exports) { + + + +exports.throttle = function(func, wait) { + var timeout; + return function() { + var context = this, args = arguments; + if (!timeout) { + // the first time the event fires, we setup a timer, which + // is used as a guard to block subsequent calls; once the + // timer's handler fires, we reset it and create a new one + timeout = setTimeout(function() { + timeout = null; + try { + func.apply(context, args); + } catch (err) { + console.log(err); + } + }, wait); + } + } +} + +/***/ }), +/* 9 */ +/***/ (function(module, exports) { + +exports.defineTransmit = function(protocol) { + + var newTransmit; + + if (typeof(protocol)=="function") { + return protocol; + } else { + switch (protocol) { + case 'js': + newTransmit = function(data,passive) { + this.makeOSC(this.emit, data, passive); + this.emit('*',data, passive); + } + return newTransmit + + case 'ajax': + newTransmit = function(data) { + this.makeOSC(exports.ajaxTransmit, data); + } + return newTransmit + + case 'node': + newTransmit = function(data) { + this.makeOSC(exports.nodeTransmit, data); + } + return newTransmit + + case 'ios': + newTransmit = function(data) { + + } + return newTransmit + + case 'max': + newTransmit = function(data) { + this.makeOSC(exports.maxTransmit, data); + } + return newTransmit + + case 'wc': + newTransmit = function(data, passive) { + this.emit('internal',data, passive); + } + return newTransmit + } + } +} + +exports.setGlobalTransmit = function(protocol) { + var newTransmit = exports.defineTransmit(protocol) + this.transmit = newTransmit + this.destination = protocol + for (var key in nx.widgets) { + this.widgets[key].transmit = newTransmit; + this.widgets[key].destination = protocol; + } +} + +exports.setWidgetTransmit = function(protocol) { + var newTransmit = exports.defineTransmit(protocol) + this.transmit = newTransmit + this.destination = protocol +} + + +exports.ajaxTransmit = function(subPath, data) { + + var oscPath = subPath=='value' ? this.oscPath : this.oscPath+"/"+subPath; + + xmlhttp=new XMLHttpRequest(); + xmlhttp.open("POST",nx.ajaxPath,true); + xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); + xmlhttp.send('oscName='+oscPath+'&data='+data); + +} + +exports.setAjaxPath = function(path) { + this.ajaxPath = path; +} + +exports.nodeTransmit = function(subPath, data) { + + var msg = { + oscName: subPath=='value' ? this.oscPath : this.oscPath+"/"+subPath, + value: data + } + socket.emit('nx', msg) + +} + +exports.maxTransmit = function (subPath, data) { + var oscPath = subPath=='value' ? this.oscPath : this.oscPath+"/"+subPath; + window.max.outlet(oscPath + " " + data); +} + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var palettes = [[[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 1.0], [0.00, 0.33, 0.67]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 1.0], [0.00, 0.10, 0.20]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 1.0], [0.30, 0.20, 0.20]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 0.5], [0.80, 0.90, 0.30]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 0.7, 0.4], [0.00, 0.15, 0.20]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [2.0, 1.0, 0.0], [0.50, 0.20, 0.25]], [[0.8, 0.5, 0.4], [0.2, 0.4, 0.2], [2.0, 1.0, 1.0], [0.00, 0.25, 0.25]]]; + +var palette = palettes[0]; + +function channel(t, a, b, c, d, add, mul) { + return a + b * Math.cos(2 * Math.PI * (c * t + d)) * mul + add; +} + +function color(t, add, mul) { + var a = void 0, + b = void 0, + c = void 0, + d = void 0; + var rgb = []; + for (var i = 0; i < 3; i++) { + a = palette[0][i]; + b = palette[1][i]; + c = palette[2][i]; + d = palette[3][i]; + rgb[i] = Math.round(channel(t, a, b, c, d, add, mul) * 255); + } + return 'rgb(' + rgb + ')'; +} + +exports.default = color; + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _tone = __webpack_require__(4); + +var _tone2 = _interopRequireDefault(_tone); + +var _util = __webpack_require__(5); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var player_count = 2; + +var compressor = new _tone2.default.Compressor(-30, 3).toMaster(); + +var samples = [{ root: 226, fn: 'samples/380737__cabled-mess__sansula-01-a-raw.wav' }, { root: 267, fn: 'samples/380736__cabled-mess__sansula-02-c-raw.wav' }, { root: 340, fn: 'samples/380735__cabled-mess__sansula-03-e-raw.wav' }, { root: 452, fn: 'samples/380733__cabled-mess__sansula-06-a-02-raw.wav' }]; + +samples.forEach(function (sample) { + sample.players = []; + sample.index = -1; + for (var i = 0; i < player_count; i++) { + var fn = sample.fn; + if (window.location.href.match(/asdf.us/)) { + fn = '//asdf.us/kalimba/' + fn; + } + var player = new _tone2.default.Player({ + url: fn, + retrigger: true, + playbackRate: 1 + }); + player.connect(compressor); + sample.players.push(player); + } +}); + +function play(freq) { + var best = { sample: (0, _util.choice)(samples) }; + best.sample.index = (best.sample.index + 1) % player_count; + + var player = best.sample.players[best.sample.index]; + player.playbackRate = freq / best.sample.root; + player.start(); +} + +exports.default = { play: play }; + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var keys = {}; +var key_numbers = {}; +var letters = "zxcvbnmasdfghjklqwertyuiop"; +var numbers = "1234567890"; + +var callback = function callback() {}; + +letters.toUpperCase().split("").map(function (k, i) { + keys[k.charCodeAt(0)] = i; +}); + +numbers.split("").map(function (k, i) { + keys[k.charCodeAt(0)] = i + letters.length; + key_numbers[k.charCodeAt(0)] = true; +}); + +window.addEventListener("keydown", keydown, true); +function keydown(e) { + if (e.altKey || e.ctrlKey || e.metaKey) { + e.stopPropagation(); + return; + } + if (document.activeElement instanceof HTMLInputElement && e.keyCode in key_numbers) { + e.stopPropagation(); + return; + } + if (!(e.keyCode in keys)) return; + var index = keys[e.keyCode]; + if (e.shiftKey) index += letters.length; + index -= 7; + callback(index); +} + +function listen(fn) { + callback = fn; +} + +exports.default = { listen: listen }; + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _intonation = __webpack_require__(17); + +var _intonation2 = _interopRequireDefault(_intonation); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var meantone = '! meanquar.scl\n!\n1/4-comma meantone scale. Pietro Aaron\'s temperament (1523)\n 12\n!\n 76.04900\n 193.15686\n 310.26471\n 5/4\n 503.42157\n 579.47057\n 696.57843\n 25/16\n 889.73529\n 1006.84314\n 1082.89214\n 2/1\n'; + +var mavila = '! mavila12.scl\n!\nA 12-note mavila scale (for warping meantone-based music), 5-limit TOP\n 12\n!\n-30.99719\n 163.50770\n 358.01258\n 327.01540\n 521.52028\n 490.52310\n 685.02798\n 654.03080\n 848.53568\n 1043.04057\n 1012.04338\n 1206.54826\n'; + +var carlos_alpha = '! carlos_alpha.scl\n!\nWendy Carlos\' Alpha scale with perfect fifth divided in nine\n 18\n!\n 78.00000\n 156.00000\n 234.00000\n 312.00000\n 390.00000\n 468.00000\n 546.00000\n 624.00000\n 702.00000\n 780.00000\n 858.00000\n 936.00000\n 1014.00000\n 1092.00000\n 1170.00000\n 1248.00000\n 1326.00000\n 1404.00000\n'; + +var lamonte = '! young-lm_piano.scl\n!\nLaMonte Young\'s Well-Tempered Piano\n12\n!\n567/512\n9/8\n147/128\n21/16\n1323/1024\n189/128\n3/2\n49/32\n7/4\n441/256\n63/32\n2/1\n'; + +var colundi = '! colundi.scl\n!\nColundi scale\n10\n!\n9/8\n171/140\n137/112\n43/35\n3/2\n421/280\n213/140\n263/150\n66/35\n2/1\n'; + +var scales = [{ + intervals: '1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1', + name: "harmonic scale" +}, { + root: 450, + intervals: '1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1', + name: "harmonic scale @ 450" +}, { + tet: 5 +}, { + tet: 12 +}, { + tet: 17 +}, { + intervals: '1/1 81/80 33/32 21/20 16/15 12/11 11/10 10/9 9/8 8/7 7/6 32/27 6/5 11/9 5/4 14/11 9/7 21/16 4/3 27/20 11/8 7/5 10/7 16/11 40/27 3/2 32/21 14/9 11/7 8/5 18/11 5/3 27/16 12/7 7/4 16/9 9/5 20/11 11/6 15/8 40/21 64/33 160/81 2/1', + name: "harry partch scale" +}, { + scl: lamonte +}, { + scl: meantone +}, { + scl: mavila +}, { + scl: carlos_alpha +}, { + scl: colundi +}].map(function (opt) { + return new _intonation2.default(opt); +}); + +var scale = scales[0]; +var handleChange = function handleChange() {}; + +function build() { + scales.forEach(function (scale, i) { + scale.heading = document.createElement('div'); + scale.heading.innerHTML = scale.name; + scale.heading.classList.add('heading'); + scale.heading.addEventListener('click', function () { + pick(i); + }); + scale_list.appendChild(scale.heading); + }); + + pick(0); +} + +function pick(i) { + if (scale) { + scale.heading && scale.heading.classList.remove('selected'); + } + scale = scales[i]; + scale.heading && scale.heading.classList.add('selected'); + handleChange(scale); +} + +function current() { + return scale; +} + +function onChange(fn) { + handleChange = fn; +} + +function names() { + return scales.map(function (scale) { + return scale.name; + }); +} + +exports.default = { scales: scales, current: current, build: build, pick: pick, names: names, onChange: onChange }; + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + +var manager = __webpack_require__(20); +var domUtils = __webpack_require__(7); +var drawingUtils = __webpack_require__(3); +var mathUtils = __webpack_require__(2); +var extend = __webpack_require__(19); +var WebFont = __webpack_require__(55); + +/************************************************ +* INSTANTIATE NX MANAGER AND CREATE ELEMENTS * +************************************************/ + +window.nx = new manager(); +window.nx.onload = function() {}; +window.nx = extend(window.nx,domUtils) +window.nx = extend(window.nx,drawingUtils) +window.nx = extend(window.nx,mathUtils) + +/* this onload function turns canvases into nexus elements, + * using the canvas's id as its var name */ + +window.onload = function() { + try { + WebFont.load({ + google: { + families: ['Open Sans'] + } + }); + } catch(e) { + console.log("font not loaded") + } + + nx.addStylesheet(); + + // get all canvases on the page and add them to the manager + var allcanvi = document.getElementsByTagName("canvas"); + for (i=0;i<allcanvi.length;i++) nx.transform(allcanvi[i]); + + if (nx.isTouchDevice) { + document.addEventListener("touchmove", nx.blockMove, true); + document.addEventListener("touchstart", nx.blockMove, true); + } + + nx.onload(); + + nx.startPulse(); + +}; + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* + +WebMidi v2.2.0 + +WebMidi.js helps you tame the Web MIDI API. Send and receive MIDI messages with ease. Control instruments with user-friendly functions (playNote, sendPitchBend, etc.). React to MIDI input with simple event listeners (noteon, pitchbend, controlchange, etc.). +https://github.com/djipco/webmidi + + +The MIT License (MIT) + +Copyright (c) 2015-2018, Jean-Philippe Côté + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT +NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +!function(scope){"use strict";function WebMidi(){if(WebMidi.prototype._singleton)throw new Error("WebMidi is a singleton, it cannot be instantiated directly.");WebMidi.prototype._singleton=this,this._inputs=[],this._outputs=[],this._userHandlers={},this._stateChangeQueue=[],this._processingStateChange=!1,this._midiInterfaceEvents=["connected","disconnected"],this._notes=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],this._semitones={C:0,D:2,E:4,F:5,G:7,A:9,B:11},Object.defineProperties(this,{MIDI_SYSTEM_MESSAGES:{value:{sysex:240,timecode:241,songposition:242,songselect:243,tuningrequest:246,sysexend:247,clock:248,start:250,"continue":251,stop:252,activesensing:254,reset:255,midimessage:0,unknownsystemmessage:-1},writable:!1,enumerable:!0,configurable:!1},MIDI_CHANNEL_MESSAGES:{value:{noteoff:8,noteon:9,keyaftertouch:10,controlchange:11,channelmode:11,programchange:12,channelaftertouch:13,pitchbend:14},writable:!1,enumerable:!0,configurable:!1},MIDI_REGISTERED_PARAMETER:{value:{pitchbendrange:[0,0],channelfinetuning:[0,1],channelcoarsetuning:[0,2],tuningprogram:[0,3],tuningbank:[0,4],modulationrange:[0,5],azimuthangle:[61,0],elevationangle:[61,1],gain:[61,2],distanceratio:[61,3],maximumdistance:[61,4],maximumdistancegain:[61,5],referencedistanceratio:[61,6],panspreadangle:[61,7],rollangle:[61,8]},writable:!1,enumerable:!0,configurable:!1},MIDI_CONTROL_CHANGE_MESSAGES:{value:{bankselectcoarse:0,modulationwheelcoarse:1,breathcontrollercoarse:2,footcontrollercoarse:4,portamentotimecoarse:5,dataentrycoarse:6,volumecoarse:7,balancecoarse:8,pancoarse:10,expressioncoarse:11,effectcontrol1coarse:12,effectcontrol2coarse:13,generalpurposeslider1:16,generalpurposeslider2:17,generalpurposeslider3:18,generalpurposeslider4:19,bankselectfine:32,modulationwheelfine:33,breathcontrollerfine:34,footcontrollerfine:36,portamentotimefine:37,dataentryfine:38,volumefine:39,balancefine:40,panfine:42,expressionfine:43,effectcontrol1fine:44,effectcontrol2fine:45,holdpedal:64,portamento:65,sustenutopedal:66,softpedal:67,legatopedal:68,hold2pedal:69,soundvariation:70,resonance:71,soundreleasetime:72,soundattacktime:73,brightness:74,soundcontrol6:75,soundcontrol7:76,soundcontrol8:77,soundcontrol9:78,soundcontrol10:79,generalpurposebutton1:80,generalpurposebutton2:81,generalpurposebutton3:82,generalpurposebutton4:83,reverblevel:91,tremololevel:92,choruslevel:93,celestelevel:94,phaserlevel:95,databuttonincrement:96,databuttondecrement:97,nonregisteredparametercoarse:98,nonregisteredparameterfine:99,registeredparametercoarse:100,registeredparameterfine:101},writable:!1,enumerable:!0,configurable:!1},MIDI_CHANNEL_MODE_MESSAGES:{value:{allsoundoff:120,resetallcontrollers:121,localcontrol:122,allnotesoff:123,omnimodeoff:124,omnimodeon:125,monomodeon:126,polymodeon:127},writable:!1,enumerable:!0,configurable:!1},octaveOffset:{value:0,writable:!0,enumerable:!0,configurable:!1}}),Object.defineProperties(this,{supported:{enumerable:!0,get:function(){return"requestMIDIAccess"in navigator}},enabled:{enumerable:!0,get:function(){return void 0!==this["interface"]}.bind(this)},inputs:{enumerable:!0,get:function(){return this._inputs}.bind(this)},outputs:{enumerable:!0,get:function(){return this._outputs}.bind(this)},sysexEnabled:{enumerable:!0,get:function(){return!(!this["interface"]||!this["interface"].sysexEnabled)}.bind(this)},time:{enumerable:!0,get:function(){return performance.now()}}})}function Input(midiInput){var that=this;this._userHandlers={channel:{},system:{}},this._midiInput=midiInput,Object.defineProperties(this,{connection:{enumerable:!0,get:function(){return that._midiInput.connection}},id:{enumerable:!0,get:function(){return that._midiInput.id}},manufacturer:{enumerable:!0,get:function(){return that._midiInput.manufacturer}},name:{enumerable:!0,get:function(){return that._midiInput.name}},state:{enumerable:!0,get:function(){return that._midiInput.state}},type:{enumerable:!0,get:function(){return that._midiInput.type}}}),this._initializeUserHandlers(),this._midiInput.onmidimessage=this._onMidiMessage.bind(this)}function Output(midiOutput){var that=this;this._midiOutput=midiOutput,Object.defineProperties(this,{connection:{enumerable:!0,get:function(){return that._midiOutput.connection}},id:{enumerable:!0,get:function(){return that._midiOutput.id}},manufacturer:{enumerable:!0,get:function(){return that._midiOutput.manufacturer}},name:{enumerable:!0,get:function(){return that._midiOutput.name}},state:{enumerable:!0,get:function(){return that._midiOutput.state}},type:{enumerable:!0,get:function(){return that._midiOutput.type}}})}var wm=new WebMidi;WebMidi.prototype.enable=function(callback,sysex){return this.enabled?void 0:this.supported?void navigator.requestMIDIAccess({sysex:sysex}).then(function(midiAccess){function onPortsOpen(){clearTimeout(promiseTimeout),this._updateInputsAndOutputs(),this["interface"].onstatechange=this._onInterfaceStateChange.bind(this),"function"==typeof callback&&callback.call(this),events.forEach(function(event){this._onInterfaceStateChange(event)}.bind(this))}var promiseTimeout,events=[],promises=[];this["interface"]=midiAccess,this._resetInterfaceUserHandlers(),this["interface"].onstatechange=function(e){events.push(e)};for(var inputs=midiAccess.inputs.values(),input=inputs.next();input&&!input.done;input=inputs.next())promises.push(input.value.open());for(var outputs=midiAccess.outputs.values(),output=outputs.next();output&&!output.done;output=outputs.next())promises.push(output.value.open());promiseTimeout=setTimeout(onPortsOpen.bind(this),200),Promise&&Promise.all(promises)["catch"](function(err){}).then(onPortsOpen.bind(this))}.bind(this),function(err){"function"==typeof callback&&callback.call(this,err)}.bind(this)):void("function"==typeof callback&&callback(new Error("The Web MIDI API is not supported by your browser.")))},WebMidi.prototype.disable=function(){if(!this.supported)throw new Error("The Web MIDI API is not supported by your browser.");this["interface"]&&(this["interface"].onstatechange=void 0),this["interface"]=void 0,this._inputs=[],this._outputs=[],this._resetInterfaceUserHandlers()},WebMidi.prototype.addListener=function(type,listener){if(!this.enabled)throw new Error("WebMidi must be enabled before adding event listeners.");if("function"!=typeof listener)throw new TypeError("The 'listener' parameter must be a function.");if(!(this._midiInterfaceEvents.indexOf(type)>=0))throw new TypeError("The specified event type is not supported.");return this._userHandlers[type].push(listener),this},WebMidi.prototype.hasListener=function(type,listener){if(!this.enabled)throw new Error("WebMidi must be enabled before checking event listeners.");if("function"!=typeof listener)throw new TypeError("The 'listener' parameter must be a function.");if(!(this._midiInterfaceEvents.indexOf(type)>=0))throw new TypeError("The specified event type is not supported.");for(var o=0;o<this._userHandlers[type].length;o++)if(this._userHandlers[type][o]===listener)return!0;return!1},WebMidi.prototype.removeListener=function(type,listener){if(!this.enabled)throw new Error("WebMidi must be enabled before removing event listeners.");if(void 0!==listener&&"function"!=typeof listener)throw new TypeError("The 'listener' parameter must be a function.");if(this._midiInterfaceEvents.indexOf(type)>=0)if(listener)for(var o=0;o<this._userHandlers[type].length;o++)this._userHandlers[type][o]===listener&&this._userHandlers[type].splice(o,1);else this._userHandlers[type]=[];else{if(void 0!==type)throw new TypeError("The specified event type is not supported.");this._resetInterfaceUserHandlers()}return this},WebMidi.prototype.toMIDIChannels=function(channel){var channels;return channels="all"===channel||void 0===channel?["all"]:Array.isArray(channel)?channel:[channel],channels.indexOf("all")>-1&&(channels=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),channels.map(function(ch){return parseInt(ch)}).filter(function(ch){return ch>=1&&16>=ch})},WebMidi.prototype.getInputById=function(id){if(!this.enabled)throw new Error("WebMidi is not enabled.");for(var i=0;i<this.inputs.length;i++)if(this.inputs[i].id===id)return this.inputs[i];return!1},WebMidi.prototype.getOutputById=function(id){if(!this.enabled)throw new Error("WebMidi is not enabled.");for(var i=0;i<this.outputs.length;i++)if(this.outputs[i].id===id)return this.outputs[i];return!1},WebMidi.prototype.getInputByName=function(name){if(!this.enabled)throw new Error("WebMidi is not enabled.");for(var i=0;i<this.inputs.length;i++)if(~this.inputs[i].name.indexOf(name))return this.inputs[i];return!1},WebMidi.prototype.getOctave=function(number){return null!=number&&number>=0&&127>=number?Math.floor(Math.floor(number)/12-1)+Math.floor(wm.octaveOffset):void 0},WebMidi.prototype.getOutputByName=function(name){if(!this.enabled)throw new Error("WebMidi is not enabled.");for(var i=0;i<this.outputs.length;i++)if(~this.outputs[i].name.indexOf(name))return this.outputs[i];return!1},WebMidi.prototype.guessNoteNumber=function(input){var output=!1;if(input&&input.toFixed&&input>=0&&127>=input?output=Math.round(input):parseInt(input)>=0&&parseInt(input)<=127?output=parseInt(input):("string"==typeof input||input instanceof String)&&(output=this.noteNameToNumber(input)),output===!1)throw new Error("Invalid input value ("+input+").");return output},WebMidi.prototype.noteNameToNumber=function(name){"string"!=typeof name&&(name="");var matches=name.match(/([CDEFGAB])(#{0,2}|b{0,2})(-?\d+)/i);if(!matches)throw new RangeError("Invalid note name.");var semitones=wm._semitones[matches[1].toUpperCase()],octave=parseInt(matches[3]),result=12*(octave+1-Math.floor(wm.octaveOffset))+semitones;if(matches[2].toLowerCase().indexOf("b")>-1?result-=matches[2].length:matches[2].toLowerCase().indexOf("#")>-1&&(result+=matches[2].length),0>result||result>127)throw new RangeError("Invalid note name or note outside valid range.");return result},WebMidi.prototype._updateInputsAndOutputs=function(){this._updateInputs(),this._updateOutputs()},WebMidi.prototype._updateInputs=function(){for(var i=0;i<this._inputs.length;i++){for(var remove=!0,updated=this["interface"].inputs.values(),input=updated.next();input&&!input.done;input=updated.next())if(this._inputs[i]._midiInput===input.value){remove=!1;break}remove&&this._inputs.splice(i,1)}this["interface"]&&this["interface"].inputs.forEach(function(nInput){for(var add=!0,j=0;j<this._inputs.length;j++)this._inputs[j]._midiInput===nInput&&(add=!1);add&&this._inputs.push(new Input(nInput))}.bind(this))},WebMidi.prototype._updateOutputs=function(){for(var i=0;i<this._outputs.length;i++){for(var remove=!0,updated=this["interface"].outputs.values(),output=updated.next();output&&!output.done;output=updated.next())if(this._outputs[i]._midiOutput===output.value){remove=!1;break}remove&&this._outputs.splice(i,1)}this["interface"]&&this["interface"].outputs.forEach(function(nOutput){for(var add=!0,j=0;j<this._outputs.length;j++)this._outputs[j]._midiOutput===nOutput&&(add=!1);add&&this._outputs.push(new Output(nOutput))}.bind(this))},WebMidi.prototype._onInterfaceStateChange=function(e){this._updateInputsAndOutputs();var event={timestamp:e.timeStamp,type:e.port.state};this["interface"]&&"connected"===e.port.state?"output"===e.port.type?event.port=this.getOutputById(e.port.id):"input"===e.port.type&&(event.port=this.getInputById(e.port.id)):event.port={connection:"closed",id:e.port.id,manufacturer:e.port.manufacturer,name:e.port.name,state:e.port.state,type:e.port.type},this._userHandlers[e.port.state].forEach(function(handler){handler(event)})},WebMidi.prototype._resetInterfaceUserHandlers=function(){for(var i=0;i<this._midiInterfaceEvents.length;i++)this._userHandlers[this._midiInterfaceEvents[i]]=[]},Input.prototype.addListener=function(type,channel,listener){var that=this;if(void 0===channel&&(channel="all"),Array.isArray(channel)||(channel=[channel]),channel.forEach(function(item){if("all"!==item&&!(item>=1&&16>=item))throw new RangeError("The 'channel' parameter is invalid.")}),"function"!=typeof listener)throw new TypeError("The 'listener' parameter must be a function.");if(void 0!==wm.MIDI_SYSTEM_MESSAGES[type])this._userHandlers.system[type]||(this._userHandlers.system[type]=[]),this._userHandlers.system[type].push(listener);else{if(void 0===wm.MIDI_CHANNEL_MESSAGES[type])throw new TypeError("The specified event type is not supported.");if(channel.indexOf("all")>-1){channel=[];for(var j=1;16>=j;j++)channel.push(j)}this._userHandlers.channel[type]||(this._userHandlers.channel[type]=[]),channel.forEach(function(ch){that._userHandlers.channel[type][ch]||(that._userHandlers.channel[type][ch]=[]),that._userHandlers.channel[type][ch].push(listener)})}return this},Input.prototype.on=Input.prototype.addListener,Input.prototype.hasListener=function(type,channel,listener){var that=this;if("function"!=typeof listener)throw new TypeError("The 'listener' parameter must be a function.");if(void 0===channel&&(channel="all"),channel.constructor!==Array&&(channel=[channel]),void 0!==wm.MIDI_SYSTEM_MESSAGES[type]){for(var o=0;o<this._userHandlers.system[type].length;o++)if(this._userHandlers.system[type][o]===listener)return!0}else if(void 0!==wm.MIDI_CHANNEL_MESSAGES[type]){if(channel.indexOf("all")>-1){channel=[];for(var j=1;16>=j;j++)channel.push(j)}return this._userHandlers.channel[type]?channel.every(function(chNum){var listeners=that._userHandlers.channel[type][chNum];return listeners&&listeners.indexOf(listener)>-1}):!1}return!1},Input.prototype.removeListener=function(type,channel,listener){var that=this;if(void 0!==listener&&"function"!=typeof listener)throw new TypeError("The 'listener' parameter must be a function.");if(void 0===channel&&(channel="all"),channel.constructor!==Array&&(channel=[channel]),void 0!==wm.MIDI_SYSTEM_MESSAGES[type])if(void 0===listener)this._userHandlers.system[type]=[];else for(var o=0;o<this._userHandlers.system[type].length;o++)this._userHandlers.system[type][o]===listener&&this._userHandlers.system[type].splice(o,1);else if(void 0!==wm.MIDI_CHANNEL_MESSAGES[type]){if(channel.indexOf("all")>-1){channel=[];for(var j=1;16>=j;j++)channel.push(j)}if(!this._userHandlers.channel[type])return this;channel.forEach(function(chNum){var listeners=that._userHandlers.channel[type][chNum];if(listeners)if(void 0===listener)that._userHandlers.channel[type][chNum]=[];else for(var l=0;l<listeners.length;l++)listeners[l]===listener&&listeners.splice(l,1)})}else{if(void 0!==type)throw new TypeError("The specified event type is not supported.");this._initializeUserHandlers()}return this},Input.prototype._initializeUserHandlers=function(){for(var prop1 in wm.MIDI_CHANNEL_MESSAGES)wm.MIDI_CHANNEL_MESSAGES.hasOwnProperty(prop1)&&(this._userHandlers.channel[prop1]={});for(var prop2 in wm.MIDI_SYSTEM_MESSAGES)wm.MIDI_SYSTEM_MESSAGES.hasOwnProperty(prop2)&&(this._userHandlers.system[prop2]=[])},Input.prototype._onMidiMessage=function(e){if(this._userHandlers.system.midimessage.length>0){var event={target:this,data:e.data,timestamp:e.timeStamp,type:"midimessage"};this._userHandlers.system.midimessage.forEach(function(callback){callback(event)})}e.data[0]<240?this._parseChannelEvent(e):e.data[0]<=255&&this._parseSystemEvent(e)},Input.prototype._parseChannelEvent=function(e){var data1,data2,command=e.data[0]>>4,channel=(15&e.data[0])+1;e.data.length>1&&(data1=e.data[1],data2=e.data.length>2?e.data[2]:void 0);var event={target:this,data:e.data,timestamp:e.timeStamp,channel:channel};command===wm.MIDI_CHANNEL_MESSAGES.noteoff||command===wm.MIDI_CHANNEL_MESSAGES.noteon&&0===data2?(event.type="noteoff",event.note={number:data1,name:wm._notes[data1%12],octave:wm.getOctave(data1)},event.velocity=data2/127,event.rawVelocity=data2):command===wm.MIDI_CHANNEL_MESSAGES.noteon?(event.type="noteon",event.note={number:data1,name:wm._notes[data1%12],octave:wm.getOctave(data1)},event.velocity=data2/127,event.rawVelocity=data2):command===wm.MIDI_CHANNEL_MESSAGES.keyaftertouch?(event.type="keyaftertouch",event.note={number:data1,name:wm._notes[data1%12],octave:wm.getOctave(data1)},event.value=data2/127):command===wm.MIDI_CHANNEL_MESSAGES.controlchange&&data1>=0&&119>=data1?(event.type="controlchange",event.controller={number:data1,name:this.getCcNameByNumber(data1)},event.value=data2):command===wm.MIDI_CHANNEL_MESSAGES.channelmode&&data1>=120&&127>=data1?(event.type="channelmode",event.controller={number:data1,name:this.getChannelModeByNumber(data1)},event.value=data2):command===wm.MIDI_CHANNEL_MESSAGES.programchange?(event.type="programchange",event.value=data1):command===wm.MIDI_CHANNEL_MESSAGES.channelaftertouch?(event.type="channelaftertouch",event.value=data1/127):command===wm.MIDI_CHANNEL_MESSAGES.pitchbend?(event.type="pitchbend",event.value=((data2<<7)+data1-8192)/8192):event.type="unknownchannelmessage",this._userHandlers.channel[event.type]&&this._userHandlers.channel[event.type][channel]&&this._userHandlers.channel[event.type][channel].forEach(function(callback){callback(event)})},Input.prototype.getCcNameByNumber=function(number){if(number=Math.floor(number),!(number>=0&&119>=number))throw new RangeError("The control change number must be between 0 and 119.");for(var cc in wm.MIDI_CONTROL_CHANGE_MESSAGES)if(wm.MIDI_CONTROL_CHANGE_MESSAGES.hasOwnProperty(cc)&&number===wm.MIDI_CONTROL_CHANGE_MESSAGES[cc])return cc;return void 0},Input.prototype.getChannelModeByNumber=function(number){if(number=Math.floor(number),!(number>=120&&status<=127))throw new RangeError("The control change number must be between 120 and 127.");for(var cm in wm.MIDI_CHANNEL_MODE_MESSAGES)if(wm.MIDI_CHANNEL_MODE_MESSAGES.hasOwnProperty(cm)&&number===wm.MIDI_CHANNEL_MODE_MESSAGES[cm])return cm},Input.prototype._parseSystemEvent=function(e){var command=e.data[0],event={target:this,data:e.data,timestamp:e.timeStamp};command===wm.MIDI_SYSTEM_MESSAGES.sysex?event.type="sysex":command===wm.MIDI_SYSTEM_MESSAGES.timecode?event.type="timecode":command===wm.MIDI_SYSTEM_MESSAGES.songposition?event.type="songposition":command===wm.MIDI_SYSTEM_MESSAGES.songselect?(event.type="songselect",event.song=e.data[1]):command===wm.MIDI_SYSTEM_MESSAGES.tuningrequest?event.type="tuningrequest":command===wm.MIDI_SYSTEM_MESSAGES.clock?event.type="clock":command===wm.MIDI_SYSTEM_MESSAGES.start?event.type="start":command===wm.MIDI_SYSTEM_MESSAGES["continue"]?event.type="continue":command===wm.MIDI_SYSTEM_MESSAGES.stop?event.type="stop":command===wm.MIDI_SYSTEM_MESSAGES.activesensing?event.type="activesensing":command===wm.MIDI_SYSTEM_MESSAGES.reset?event.type="reset":event.type="unknownsystemmessage",this._userHandlers.system[event.type]&&this._userHandlers.system[event.type].forEach(function(callback){callback(event)})},Output.prototype.send=function(status,data,timestamp){if(!(status>=128&&255>=status))throw new RangeError("The status byte must be an integer between 128 (0x80) and 255 (0xFF).");void 0===data&&(data=[]),Array.isArray(data)||(data=[data]);var message=[];return data.forEach(function(item,index){var parsed=Math.floor(item);if(!(parsed>=0&&255>=parsed))throw new RangeError("Data bytes must be integers between 0 (0x00) and 255 (0xFF).");message.push(parsed)}),this._midiOutput.send([status].concat(message),parseFloat(timestamp)||0),this},Output.prototype.sendSysex=function(manufacturer,data,options){if(!wm.sysexEnabled)throw new Error("Sysex message support must first be activated.");return options=options||{},manufacturer=[].concat(manufacturer),data.forEach(function(item){if(0>item||item>127)throw new RangeError("The data bytes of a sysex message must be integers between 0 (0x00) and 127 (0x7F).")}),data=manufacturer.concat(data,wm.MIDI_SYSTEM_MESSAGES.sysexend),this.send(wm.MIDI_SYSTEM_MESSAGES.sysex,data,this._parseTimeParameter(options.time)),this},Output.prototype.sendTimecodeQuarterFrame=function(value,options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.timecode,value,this._parseTimeParameter(options.time)),this},Output.prototype.sendSongPosition=function(value,options){value=Math.floor(value)||0,options=options||{};var msb=value>>7&127,lsb=127&value;return this.send(wm.MIDI_SYSTEM_MESSAGES.songposition,[msb,lsb],this._parseTimeParameter(options.time)),this},Output.prototype.sendSongSelect=function(value,options){if(value=Math.floor(value),options=options||{},!(value>=0&&127>=value))throw new RangeError("The song number must be between 0 and 127.");return this.send(wm.MIDI_SYSTEM_MESSAGES.songselect,[value],this._parseTimeParameter(options.time)),this},Output.prototype.sendTuningRequest=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.tuningrequest,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendClock=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.clock,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendStart=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.start,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendContinue=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES["continue"],void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendStop=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.stop,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendActiveSensing=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.activesensing,[],this._parseTimeParameter(options.time)),this},Output.prototype.sendReset=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.reset,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.stopNote=function(note,channel,options){if("all"===note)return this.sendChannelMode("allnotesoff",0,channel,options);var nVelocity=64;return options=options||{},options.rawVelocity?!isNaN(options.velocity)&&options.velocity>=0&&options.velocity<=127&&(nVelocity=options.velocity):!isNaN(options.velocity)&&options.velocity>=0&&options.velocity<=1&&(nVelocity=127*options.velocity),this._convertNoteToArray(note).forEach(function(item){wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.noteoff<<4)+(ch-1),[item,Math.round(nVelocity)],this._parseTimeParameter(options.time))}.bind(this))}.bind(this)),this},Output.prototype.playNote=function(note,channel,options){var nVelocity=64;if(options=options||{},options.rawVelocity?!isNaN(options.velocity)&&options.velocity>=0&&options.velocity<=127&&(nVelocity=options.velocity):!isNaN(options.velocity)&&options.velocity>=0&&options.velocity<=1&&(nVelocity=127*options.velocity),options.time=this._parseTimeParameter(options.time),this._convertNoteToArray(note).forEach(function(item){wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.noteon<<4)+(ch-1),[item,Math.round(nVelocity)],options.time)}.bind(this))}.bind(this)),!isNaN(options.duration)){options.duration<=0&&(options.duration=0);var nRelease=64;options.rawVelocity?!isNaN(options.release)&&options.release>=0&&options.release<=127&&(nRelease=options.release):!isNaN(options.release)&&options.release>=0&&options.release<=1&&(nRelease=127*options.release),this._convertNoteToArray(note).forEach(function(item){wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.noteoff<<4)+(ch-1),[item,Math.round(nRelease)],(options.time||wm.time)+options.duration)}.bind(this))}.bind(this))}return this},Output.prototype.sendKeyAftertouch=function(note,channel,pressure,options){var that=this;if(options=options||{},1>channel||channel>16)throw new RangeError("The channel must be between 1 and 16.");(isNaN(pressure)||0>pressure||pressure>1)&&(pressure=.5);var nPressure=Math.round(127*pressure);return this._convertNoteToArray(note).forEach(function(item){wm.toMIDIChannels(channel).forEach(function(ch){that.send((wm.MIDI_CHANNEL_MESSAGES.keyaftertouch<<4)+(ch-1),[item,nPressure],that._parseTimeParameter(options.time))})}),this},Output.prototype.sendControlChange=function(controller,value,channel,options){if(options=options||{},"string"==typeof controller){if(controller=wm.MIDI_CONTROL_CHANGE_MESSAGES[controller],!controller)throw new TypeError("Invalid controller name.")}else if(controller=Math.floor(controller),!(controller>=0&&119>=controller))throw new RangeError("Controller numbers must be between 0 and 119.");if(value=Math.floor(value)||0,!(value>=0&&127>=value))throw new RangeError("Controller value must be between 0 and 127.");return wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.controlchange<<4)+(ch-1),[controller,value],this._parseTimeParameter(options.time))}.bind(this)),this},Output.prototype._selectRegisteredParameter=function(parameter,channel,time){var that=this;if(parameter[0]=Math.floor(parameter[0]),!(parameter[0]>=0&¶meter[0]<=127))throw new RangeError("The control65 value must be between 0 and 127");if(parameter[1]=Math.floor(parameter[1]),!(parameter[1]>=0&¶meter[1]<=127))throw new RangeError("The control64 value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(101,parameter[0],channel,{time:time}),that.sendControlChange(100,parameter[1],channel,{time:time})}),this},Output.prototype._selectNonRegisteredParameter=function(parameter,channel,time){var that=this;if(parameter[0]=Math.floor(parameter[0]),!(parameter[0]>=0&¶meter[0]<=127))throw new RangeError("The control63 value must be between 0 and 127");if(parameter[1]=Math.floor(parameter[1]),!(parameter[1]>=0&¶meter[1]<=127))throw new RangeError("The control62 value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(99,parameter[0],channel,{time:time}),that.sendControlChange(98,parameter[1],channel,{time:time})}),this},Output.prototype._setCurrentRegisteredParameter=function(data,channel,time){var that=this;if(data=[].concat(data),data[0]=Math.floor(data[0]),!(data[0]>=0&&data[0]<=127))throw new RangeError("The msb value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(6,data[0],channel,{time:time})}),data[1]=Math.floor(data[1]),data[1]>=0&&data[1]<=127&&wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(38,data[1],channel,{time:time})}),this},Output.prototype._deselectRegisteredParameter=function(channel,time){var that=this;return wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(101,127,channel,{time:time}),that.sendControlChange(100,127,channel,{time:time})}),this},Output.prototype.setRegisteredParameter=function(parameter,data,channel,options){var that=this;if(options=options||{},!Array.isArray(parameter)){if(!wm.MIDI_REGISTERED_PARAMETER[parameter])throw new Error("The specified parameter is not available.");parameter=wm.MIDI_REGISTERED_PARAMETER[parameter]}return wm.toMIDIChannels(channel).forEach(function(ch){that._selectRegisteredParameter(parameter,channel,options.time),that._setCurrentRegisteredParameter(data,channel,options.time),that._deselectRegisteredParameter(channel,options.time)}),this},Output.prototype.setNonRegisteredParameter=function(parameter,data,channel,options){var that=this;if(options=options||{},!(parameter[0]>=0&¶meter[0]<=127&¶meter[1]>=0&¶meter[1]<=127))throw new Error("Position 0 and 1 of the 2-position parameter array must both be between 0 and 127.");return data=[].concat(data),wm.toMIDIChannels(channel).forEach(function(ch){that._selectNonRegisteredParameter(parameter,channel,options.time),that._setCurrentRegisteredParameter(data,channel,options.time),that._deselectRegisteredParameter(channel,options.time)}),this},Output.prototype.incrementRegisteredParameter=function(parameter,channel,options){var that=this;if(options=options||{},!Array.isArray(parameter)){if(!wm.MIDI_REGISTERED_PARAMETER[parameter])throw new Error("The specified parameter is not available.");parameter=wm.MIDI_REGISTERED_PARAMETER[parameter]}return wm.toMIDIChannels(channel).forEach(function(ch){that._selectRegisteredParameter(parameter,channel,options.time),that.sendControlChange(96,0,channel,{time:options.time}),that._deselectRegisteredParameter(channel,options.time)}),this},Output.prototype.decrementRegisteredParameter=function(parameter,channel,options){if(options=options||{},!Array.isArray(parameter)){if(!wm.MIDI_REGISTERED_PARAMETER[parameter])throw new TypeError("The specified parameter is not available.");parameter=wm.MIDI_REGISTERED_PARAMETER[parameter]}return wm.toMIDIChannels(channel).forEach(function(ch){this._selectRegisteredParameter(parameter,channel,options.time),this.sendControlChange(97,0,channel,{time:options.time}),this._deselectRegisteredParameter(channel,options.time)}.bind(this)),this},Output.prototype.setPitchBendRange=function(semitones,cents,channel,options){var that=this;if(options=options||{},semitones=Math.floor(semitones)||0,!(semitones>=0&&127>=semitones))throw new RangeError("The semitones value must be between 0 and 127");if(cents=Math.floor(cents)||0,!(cents>=0&&127>=cents))throw new RangeError("The cents value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter("pitchbendrange",[semitones,cents],channel,{time:options.time})}),this},Output.prototype.setModulationRange=function(semitones,cents,channel,options){var that=this;if(options=options||{},semitones=Math.floor(semitones)||0,!(semitones>=0&&127>=semitones))throw new RangeError("The semitones value must be between 0 and 127");if(cents=Math.floor(cents)||0,!(cents>=0&&127>=cents))throw new RangeError("The cents value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter("modulationrange",[semitones,cents],channel,{time:options.time})}),this},Output.prototype.setMasterTuning=function(value,channel,options){var that=this;if(options=options||{},value=parseFloat(value)||0,-65>=value||value>=64)throw new RangeError("The value must be a decimal number larger than -65 and smaller than 64.");var coarse=Math.floor(value)+64,fine=value-Math.floor(value);fine=Math.round((fine+1)/2*16383);var msb=fine>>7&127,lsb=127&fine;return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter("channelcoarsetuning",coarse,channel,{time:options.time}),that.setRegisteredParameter("channelfinetuning",[msb,lsb],channel,{time:options.time})}),this},Output.prototype.setTuningProgram=function(value,channel,options){var that=this;if(options=options||{},value=Math.floor(value),!(value>=0&&127>=value))throw new RangeError("The program value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter("tuningprogram",value,channel,{time:options.time})}),this},Output.prototype.setTuningBank=function(value,channel,options){var that=this;if(options=options||{},value=Math.floor(value)||0,!(value>=0&&127>=value))throw new RangeError("The bank value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter("tuningbank",value,channel,{time:options.time})}),this},Output.prototype.sendChannelMode=function(command,value,channel,options){if(options=options||{},"string"==typeof command){if(command=wm.MIDI_CHANNEL_MODE_MESSAGES[command],!command)throw new TypeError("Invalid channel mode message name.")}else if(command=Math.floor(command),!(command>=120&&127>=command))throw new RangeError("Channel mode numerical identifiers must be between 120 and 127.");if(value=Math.floor(value)||0,0>value||value>127)throw new RangeError("Value must be an integer between 0 and 127.");return wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.channelmode<<4)+(ch-1),[command,value],this._parseTimeParameter(options.time))}.bind(this)),this},Output.prototype.sendProgramChange=function(program,channel,options){ +var that=this;if(options=options||{},program=Math.floor(program),isNaN(program)||0>program||program>127)throw new RangeError("Program numbers must be between 0 and 127.");return wm.toMIDIChannels(channel).forEach(function(ch){that.send((wm.MIDI_CHANNEL_MESSAGES.programchange<<4)+(ch-1),[program],that._parseTimeParameter(options.time))}),this},Output.prototype.sendChannelAftertouch=function(pressure,channel,options){var that=this;options=options||{},pressure=parseFloat(pressure),(isNaN(pressure)||0>pressure||pressure>1)&&(pressure=.5);var nPressure=Math.round(127*pressure);return wm.toMIDIChannels(channel).forEach(function(ch){that.send((wm.MIDI_CHANNEL_MESSAGES.channelaftertouch<<4)+(ch-1),[nPressure],that._parseTimeParameter(options.time))}),this},Output.prototype.sendPitchBend=function(bend,channel,options){var that=this;if(options=options||{},isNaN(bend)||-1>bend||bend>1)throw new RangeError("Pitch bend value must be between -1 and 1.");var nLevel=Math.round((bend+1)/2*16383),msb=nLevel>>7&127,lsb=127&nLevel;return wm.toMIDIChannels(channel).forEach(function(ch){that.send((wm.MIDI_CHANNEL_MESSAGES.pitchbend<<4)+(ch-1),[lsb,msb],that._parseTimeParameter(options.time))}),this},Output.prototype._parseTimeParameter=function(time){var parsed,value;return"string"==typeof time&&"+"===time.substring(0,1)?(parsed=parseFloat(time),parsed&&parsed>0&&(value=wm.time+parsed)):(parsed=parseFloat(time),parsed>wm.time&&(value=parsed)),value},Output.prototype._convertNoteToArray=function(note){var notes=[];return Array.isArray(note)||(note=[note]),note.forEach(function(item){notes.push(wm.guessNoteNumber(item))}),notes}, true?!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function(){return wm}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)):"undefined"!=typeof module&&module.exports?module.exports=wm:scope.WebMidi||(scope.WebMidi=wm)}(this); + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _tone = __webpack_require__(4); + +var _tone2 = _interopRequireDefault(_tone); + +var _webmidi = __webpack_require__(15); + +var _webmidi2 = _interopRequireDefault(_webmidi); + +__webpack_require__(14); + +var _keys = __webpack_require__(12); + +var _keys2 = _interopRequireDefault(_keys); + +var _color = __webpack_require__(10); + +var _color2 = _interopRequireDefault(_color); + +var _kalimba = __webpack_require__(11); + +var _kalimba2 = _interopRequireDefault(_kalimba); + +var _scales = __webpack_require__(13); + +var _scales2 = _interopRequireDefault(_scales); + +var _util = __webpack_require__(5); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var nx = window.nx; + +var noteCount = _util.browser.isMobile ? 18 : 36; +var stepCount = 16; +var cellSize = _util.browser.isMobile ? 20 : 27; +var baseTone = _util.browser.isMobile ? 8 : 12; + +var grid = void 0, + midi = void 0; + +_webmidi2.default.enable(midi_ready); + +function midi_ready(err) { + if (err) { + console.error('webmidi failed to initialize'); + return; + } + if (!_webmidi2.default.outputs.length) { + console.error('no MIDI output found'); + } + console.log(_webmidi2.default.inputs); + console.log(_webmidi2.default.outputs); + midi = _webmidi2.default.outputs[0]; +} + +var loop = new _tone2.default.Sequence(function (time, col) { + var column = grid.matrix[col]; + grid.jumpToCol(col); + for (var i = 0; i < noteCount; i++) { + if (column[i] === 1) { + var index = noteCount - i - baseTone; + var freq = _scales2.default.current().index(index); + var midi_note = _tone2.default.Frequency.ftom(freq); + var midi_freq = _tone2.default.Frequency.mtof(midi_note); + console.log(midi_note, freq, midi_freq, freq - midi_freq); + if (midi) { + midi.playNote(_tone2.default.Frequency(midi_note, "midi").toNote(), 3, { duration: 90000 / _tone2.default.Transport.bpm.value }); + } else { + _kalimba2.default.play(freq); + } + } + } +}, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], "16n"); + +nx.onload = function () { + return (0, _util.requestAudioContext)(ready); +}; + +function ready() { + grid = nx.widgets.grid; + grid.sequenceMode = true; + grid.bpm = 1; + grid.col = stepCount; + grid.row = noteCount; + + grid.init(); + grid.resize(cellSize * stepCount, cellSize * noteCount); + grid.draw(); + + nx.widgets.scale.choices = _scales2.default.names(); + nx.widgets.scale.init(); + nx.widgets.scale.on('*', function (e) { + return _scales2.default.pick(e.value); + }); + _scales2.default.onChange(function (s) { + buildLabels(); + }); + buildLabels(); + + grid.on('*', function (e) { + return 'level' in e && buildLabels(); + }); + nx.widgets.shiftUp.on('*', tap(shiftUp)); + nx.widgets.shiftDown.on('*', tap(shiftDown)); + nx.widgets.slideUp.on('*', tap(slideUp)); + nx.widgets.slideDown.on('*', tap(slideDown)); + nx.widgets.slideLeft.on('*', tap(slideLeft)); + nx.widgets.slideRight.on('*', tap(slideRight)); + nx.widgets.rotateUp.on('*', tap(function () { + return rotateVertical(-1); + })); + nx.widgets.rotateDown.on('*', tap(function () { + return rotateVertical(1); + })); + nx.widgets.rotateLeft.on('*', tap(function () { + return rotateHorizontal(-1); + })); + nx.widgets.rotateRight.on('*', tap(function () { + return rotateHorizontal(1); + })); + nx.widgets.flip.on('*', tap(flip)); + nx.widgets.flop.on('*', tap(flop)); + + nx.colorize('#f4d142'); + + loop.start(); + _tone2.default.Transport.bpm.value = 108; + nx.widgets.tempo.min = 10; + nx.widgets.tempo.max = 1000; + nx.widgets.tempo.set({ value: 108 }); + nx.widgets.tempo.on('*', function (e) { + return _tone2.default.Transport.bpm.value = nx.widgets.tempo.val.value; + }); + _tone2.default.Transport.start(); +} +function tap(fn) { + return function (e) { + if (_util.browser.isMobile) fn();else if (e.press) fn(); + }; +} +function draw() { + grid.draw(); + buildLabels(); +} +function buildLabels() { + var labels = document.querySelector('#labels'); + var scaleCount = _scales2.default.current().scale.length; + var subScale = findSubScale(); + var str = ''; + for (var i = 0; i < noteCount; i++) { + var index = noteCount - i - baseTone; + var n = (0, _util.mod)(index, scaleCount); + var ns = n + 1; + /* + if (ns == 1) { + let octave = (index / scaleCount) + ns = ns + '<small>' + octave + '</small>' + } + */ + if (subScale.includes(n)) { + str += '<b>' + ns + '</b><br>'; + } else { + str += ns + '<br>'; + } + } + labels.innerHTML = str; +} +function findSubScale(notes) { + notes = notes || findNotes(); + var scaleCount = _scales2.default.current().scale.length; + return notes.reduce(function (acc, n) { + var scaleNote = (0, _util.mod)(noteCount - n - baseTone, scaleCount); + if (!acc.includes(scaleNote)) acc.push(scaleNote); + return acc; + }, []).sort(); +} + +function shiftUp() { + var notes = findNotes(); + var subScale = findSubScale(notes); + var scaleCount = _scales2.default.current().scale.length; + assignNotes(mapFunction(notes, function (n) { + var index = noteCount - n - baseTone; + var note = (0, _util.mod)(index, scaleCount); + var scaleIndex = subScale.indexOf(note) + 1; + var octave = Math.floor(index / scaleCount); + while (scaleIndex >= subScale.length) { + scaleIndex -= subScale.length; + octave += 1; + } + return noteCount - baseTone - (subScale[scaleIndex] + octave * scaleCount); + })); +} +function shiftDown() { + var notes = findNotes(); + var subScale = findSubScale(notes); + var scaleCount = _scales2.default.current().scale.length; + assignNotes(mapFunction(notes, function (n) { + var index = noteCount - n - baseTone; + var note = (0, _util.mod)(index, scaleCount); + var scaleIndex = subScale.indexOf(note) - 1; + var octave = Math.floor(index / scaleCount); + while (scaleIndex < 0) { + scaleIndex += subScale.length; + octave -= 1; + } + return noteCount - baseTone - (subScale[scaleIndex] + octave * scaleCount); + })); +} +function slideUp() { + assignNotes(mapFunction(findNotes(), function (n) { + return (n - 1 + noteCount) % noteCount; + })); +} +function slideDown() { + assignNotes(mapFunction(findNotes(), function (n) { + return (n + 1 + noteCount) % noteCount; + })); +} +function slideLeft() { + assignPositions(mapFunction(findPositions(), function (n) { + return (n - 1 + stepCount) % stepCount; + })); +} +function slideRight() { + assignPositions(mapFunction(findPositions(), function (n) { + return (n + 1 + stepCount) % stepCount; + })); +} +function flip() { + assignNotes(mapReverse(findNotes())); +} +function flop() { + assignPositions(mapReverse(findPositions())); +} +function rotateHorizontal(n) { + assignPositions(remapArray(findPositions(), n)); +} +function rotateVertical(n) { + assignNotes(remapArray(findNotes(), n)); +} +function assignPositions(positions) { + if (!positions) return; + var a = grid.matrix; + var b = iota(); + stride(a, function (i, j, v) { + if (i in positions) { + b[positions[i]][j] = v; + } + }); + assign(grid.matrix, b); + draw(); +} +function assignNotes(noteMap) { + if (!noteMap) return; + var a = grid.matrix; + var b = iota(); + stride(a, function (i, j, v) { + if (j in noteMap) { + b[i][noteMap[j]] = v; + } + }); + assign(grid.matrix, b); + draw(); +} + +function stride(a, f) { + var w = stepCount, + h = noteCount; + for (var i = 0; i < w; i++) { + for (var j = 0; j < h; j++) { + f(i, j, a[i][j]); + } + } + return a; +} + +// assign b -> a +function assign(a, b) { + return stride(b, function (i, j, v) { + return a[i][j] = b[i][j]; + }); +} +function clone(a) { + var b = iota(a.length, a[0].length); + return assign(b, a); +} +function iota() { + var w = grid.matrix.length, + h = grid.matrix[0].length; + var a = new Array(w); + for (var i = 0; i < w; i++) { + a[i] = new Array(h); + for (var j = 0; j < h; j++) { + a[i][j] = 0; + } + } + return a; +} +function findNotes() { + var a = new Array(noteCount); + stride(grid.matrix, function (i, j, v) { + if (v) a[j] = 1; + }); + return a.reduce(function (acc, v, i) { + if (v === 1) acc.push(i); + return acc; + }, []); +} +function findPositions() { + return grid.matrix.reduce(function (acc, row, i) { + if (row.some(function (x) { + return x === 1; + })) acc.push(i); + return acc; + }, []); +} +function remapArray(a, n) { + if (!a.length) return; + var h = {}; + var b = rotate(a, n); + for (var i = 0; i < b.length; i++) { + h[b[i]] = a[i]; + } + return h; +} +function rotate(a, n) { + var b = a.slice(0); + b.unshift.apply(b, b.splice(-n, b.length)); + return b; +} +function mapFunction(a, f) { + if (!a.length) return; + var h = {}; + for (var i = 0; i < a.length; i++) { + h[a[i]] = f(a[i]); + } + return h; +} +function mapReverse(a) { + if (!a.length) return; + var h = {}; + var b = a.slice(0).reverse(); + for (var i = 0; i < b.length; i++) { + h[b[i]] = a[i]; + } + return h; +} + +_keys2.default.listen(function (index) { + var freq = _scales2.default.current().index(index); + _kalimba2.default.play(freq); +}); + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +module.exports = function () { + var Intonation = function Intonation(opt) { + opt = this.opt = Object.assign({ + name: "", + root: 440, + octave: 0, + interval: 2, + tet: 0, + intervals: null + }, opt || {}); + this.generate(); + }; + Intonation.prototype.generate = function (opt) { + opt = Object.assign(this.opt, opt || {}); + if (opt.scl) { + this.generate_scl(); + } else if (opt.tet) { + this.generate_tet(); + } else if (opt.intervals) { + this.generate_intervals(); + } + }; + Intonation.prototype.generate_intervals = function () { + var root = this.opt.root; + var interval_list = this.opt.intervals; + if (typeof interval_list == "string") { + interval_list = interval_list.split(" "); + } + this.name = this.opt.name || "interval list"; + this.intervals = interval_list; + this.interval = this.opt.interval = parseInterval.call(this, interval_list.pop()); + this.scale = interval_list.map(parseIntervalString.bind(this)).filter(function (v) { + return !!v; + }); + }; + Intonation.prototype.generate_tet = function () { + var scale = this.scale = []; + var root = this.opt.root; + var tet = this.opt.tet; + var interval = this.interval = this.opt.interval; + var ratio = Math.pow(interval, 1 / tet); + var n = root; + scale.push(n); + for (var i = 0; i < tet - 1; i++) { + n *= ratio; + scale.push(n); + } + this.name = this.opt.name || tet + "-tone equal temperament"; + this.intervals = null; + }; + Intonation.prototype.generate_scl = function () { + var root = this.opt.root; + var scl = this.parse_scl(this.opt.scl); + this.intervals = scl.notes; + this.interval = scl.notes.pop(); + this.name = this.opt.name || scl.description; + this.scale = scl.notes.map(function (v) { + return v * root; + }); + }; + Intonation.prototype.parse_scl = function (s) { + var scl = {}; + scl.comments = []; + scl.notes = []; + s.trim().split("\n").forEach(function (line) { + // Lines beginning with an exclamation mark are regarded as comments + // and are to be ignored. + if (line.indexOf("!") !== -1) { + scl.comments.push(line); + } + // The first (non comment) line contains a short description of the scale. + // If there is no description, there should be an empty line. (nb: which is falsey) + else if (!('description' in scl)) { + scl.description = line; + } + // The second line contains the number of notes. + // The first note of 1/1 or 0.0 cents is implicit and not in the files. + else if (!scl.notes.length) { + scl.notes.push(1); + } else { + // If the value contains a period, it is a cents value, otherwise a ratio. + var note = line.replace(/^[^-\.0-9]+/, "").replace(/[^-\/\.0-9]+$/, ""); + if (note.indexOf(".") !== -1) { + note = Math.pow(2, parseFloat(note) / 1200); + } else { + note = parseInterval(note); + } + if (note) { + scl.notes.push(note); + } + } + }); + return scl; + }; + Intonation.prototype.index = function (i, octave) { + octave = octave || this.opt.octave; + var f = this.scale[mod(i, this.scale.length) | 0]; + var pow = Math.floor(norm(i, 0, this.scale.length)) + octave; + f *= Math.pow(this.interval, pow); + return f; + }; + Intonation.prototype.range = function (min, max) { + var a = []; + for (var i = min; i < max; i++) { + a.push(this.index(i)); + } + return a; + }; + Intonation.prototype.set_root = function (f) { + this.opt.root = f; + this.generate(); + }; + Intonation.prototype.quantize_frequency = function (f) { + if (f == 0) return 0; + var scale_f = f; + var pow = 0; + var interval = this.interval; + var scale = this.scale; + while (scale_f < root) { + scale_f *= interval; + pow -= 1; + } + while (scale_f > root * interval) { + scale_f /= interval; + pow += 1; + } + for (var i = 0; i < scale.length; i++) { + if (scale_f > scale[i]) continue; + scale_f = scale[i]; + break; + } + scale_f *= Math.pow(2, pow); + return scale_f; + }; + Intonation.prototype.quantize_index = function (i) { + return mod(index - 1, this.scale.length) | 0; + }; + var parseInterval = Intonation.prototype.parse_interval = function (s) { + if (typeof s == "number") return s; + if (!s.indexOf("/") == -1) return parseInt(s); + var pp = s.split("/"); + var num = parseInt(pp[0]); + var den = parseInt(pp[1]); + if (isNaN(num)) return 1; + if (isNaN(den) || den == 0) return num; + if (num == den) return 1; + return num / den; + }; + var parseIntervalString = Intonation.prototype.parse_interval_string = function (s) { + if (s.indexOf("/") !== -1) return parseInterval(s) * this.opt.root; // intervals + if (s.indexOf("f") !== -1) return parseFloat(s); // pure frequencies + return parseFloat(s); + }; + function norm(n, a, b) { + return (n - a) / (b - a); + } + function mod(n, m) { + return n - m * Math.floor(n / m); + } + + return Intonation; +}(); + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +/** * StartAudioContext.js * @author Yotam Mann * @license http://opensource.org/licenses/MIT MIT License * @copyright 2016 Yotam Mann */ -!function(i,r){n=[],s=r,void 0!==(o="function"==typeof s?s.apply(e,n):s)&&(t.exports=o)}(0,function(){function t(){if(e.context&&!e.isStarted()){var t=e.context.createOscillator(),i=e.context.createGain();i.gain.value=0,t.connect(i),i.connect(e.context.destination);var s=e.context.currentTime;t.start(s),t.stop(s+.5)}if(e._tapListeners){for(var n=0;n<e._tapListeners.length;n++)e._tapListeners[n].dispose();e._tapListeners=null}if(e._onStarted){for(var o=0;o<e._onStarted.length;o++)e._onStarted[o]();e._onStarted=null}}var e={context:null,_tapListeners:[],_onStarted:[]};e.setContext=function(t){return e.context=t,e},e.on=function(s){if(Array.isArray(s)||NodeList&&s instanceof NodeList)for(var n=0;n<s.length;n++)e.on(s[n]);else if("string"==typeof s)e.on(document.querySelectorAll(s));else if(s.jquery&&"function"==typeof s.toArray)e.on(s.toArray());else if(Element&&s instanceof Element){var o=new i(s,t);e._tapListeners.push(o)}return e},e.onStarted=function(t){return e.isStarted()?t():e._onStarted.push(t),e},e.isStarted=function(){return null!==e.context&&"running"===e.context.state};var i=function(t){this._dragged=!1,this._element=t,this._bindedMove=this._moved.bind(this),this._bindedEnd=this._ended.bind(this),t.addEventListener("touchmove",this._bindedMove),t.addEventListener("touchend",this._bindedEnd),t.addEventListener("mouseup",this._bindedEnd)};return i.prototype._moved=function(t){this._dragged=!0},i.prototype._ended=function(e){this._dragged||t(),this._dragged=!1},i.prototype.dispose=function(){this._element.removeEventListener("touchmove",this._bindedMove),this._element.removeEventListener("touchend",this._bindedEnd),this._element.removeEventListener("mouseup",this._bindedEnd),this._bindedMove=null,this._bindedEnd=null,this._element=null},e})},function(t,e){var i=Object.prototype.hasOwnProperty,s=Object.prototype.toString,n=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===s.call(t)},o=function(t){"use strict";if(!t||"[object Object]"!==s.call(t))return!1;var e=i.call(t,"constructor"),n=t.constructor&&t.constructor.prototype&&i.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!e&&!n)return!1;var o;for(o in t);return void 0===o||i.call(t,o)};t.exports=function t(){"use strict";var e,i,s,r,a,h,l=arguments[0],c=1,u=arguments.length,p=!1;for("boolean"==typeof l?(p=l,l=arguments[1]||{},c=2):("object"!=typeof l&&"function"!=typeof l||null==l)&&(l={});c<u;++c)if(null!=(e=arguments[c]))for(i in e)s=l[i],r=e[i],l!==r&&(p&&r&&(o(r)||(a=n(r)))?(a?(a=!1,h=s&&n(s)?s:[]):h=s&&o(s)?s:{},l[i]=t(p,h,r)):void 0!==r&&(l[i]=r));return l}},function(t,e,s){/** +(function (root, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === 'object' && module.exports) { + module.exports = factory(); + } else { + root.StartAudioContext = factory(); + } +})(undefined, function () { + + /** + * The StartAudioContext object + */ + var StartAudioContext = { + /** + * The audio context passed in by the user + * @type {AudioContext} + */ + context: null, + /** + * The TapListeners bound to the elements + * @type {Array} + * @private + */ + _tapListeners: [], + /** + * Callbacks to invoke when the audio context is started + * @type {Array} + * @private + */ + _onStarted: [] + }; + + /** + * Set the context + * @param {AudioContext} ctx + * @returns {StartAudioContext} + */ + StartAudioContext.setContext = function (ctx) { + StartAudioContext.context = ctx; + return StartAudioContext; + }; + + /** + * Add a tap listener to the audio context + * @param {Array|Element|String|jQuery} element + * @returns {StartAudioContext} + */ + StartAudioContext.on = function (element) { + if (Array.isArray(element) || NodeList && element instanceof NodeList) { + for (var i = 0; i < element.length; i++) { + StartAudioContext.on(element[i]); + } + } else if (typeof element === "string") { + StartAudioContext.on(document.querySelectorAll(element)); + } else if (element.jquery && typeof element.toArray === "function") { + StartAudioContext.on(element.toArray()); + } else if (Element && element instanceof Element) { + //if it's an element, create a TapListener + var tap = new TapListener(element, onTap); + StartAudioContext._tapListeners.push(tap); + } + return StartAudioContext; + }; + + /** + * Bind a callback to when the audio context is started. + * @param {Function} cb + * @return {StartAudioContext} + */ + StartAudioContext.onStarted = function (cb) { + //if it's already started, invoke the callback + if (StartAudioContext.isStarted()) { + cb(); + } else { + StartAudioContext._onStarted.push(cb); + } + return StartAudioContext; + }; + + /** + * returns true if the context is started + * @return {Boolean} + */ + StartAudioContext.isStarted = function () { + return StartAudioContext.context !== null && StartAudioContext.context.state === "running"; + }; + + /** + * @class Listens for non-dragging tap ends on the given element + * @param {Element} element + * @internal + */ + var TapListener = function TapListener(element) { + + this._dragged = false; + + this._element = element; + + this._bindedMove = this._moved.bind(this); + this._bindedEnd = this._ended.bind(this); + + element.addEventListener("touchmove", this._bindedMove); + element.addEventListener("touchend", this._bindedEnd); + element.addEventListener("mouseup", this._bindedEnd); + }; + + /** + * drag move event + */ + TapListener.prototype._moved = function (e) { + this._dragged = true; + }; + + /** + * tap ended listener + */ + TapListener.prototype._ended = function (e) { + if (!this._dragged) { + onTap(); + } + this._dragged = false; + }; + + /** + * remove all the bound events + */ + TapListener.prototype.dispose = function () { + this._element.removeEventListener("touchmove", this._bindedMove); + this._element.removeEventListener("touchend", this._bindedEnd); + this._element.removeEventListener("mouseup", this._bindedEnd); + this._bindedMove = null; + this._bindedEnd = null; + this._element = null; + }; + + /** + * Invoked the first time of the elements is tapped. + * Creates a silent oscillator when a non-dragging touchend + * event has been triggered. + */ + function onTap() { + //start the audio context with a silent oscillator + if (StartAudioContext.context && !StartAudioContext.isStarted()) { + var osc = StartAudioContext.context.createOscillator(); + var silent = StartAudioContext.context.createGain(); + silent.gain.value = 0; + osc.connect(silent); + silent.connect(StartAudioContext.context.destination); + var now = StartAudioContext.context.currentTime; + osc.start(now); + osc.stop(now + 0.5); + } + + //dispose all the tap listeners + if (StartAudioContext._tapListeners) { + for (var i = 0; i < StartAudioContext._tapListeners.length; i++) { + StartAudioContext._tapListeners[i].dispose(); + } + StartAudioContext._tapListeners = null; + } + //the onstarted callbacks + if (StartAudioContext._onStarted) { + for (var j = 0; j < StartAudioContext._onStarted.length; j++) { + StartAudioContext._onStarted[j](); + } + StartAudioContext._onStarted = null; + } + } + + return StartAudioContext; +}); + +/***/ }), +/* 19 */ +/***/ (function(module, exports) { + +var hasOwn = Object.prototype.hasOwnProperty; +var toStr = Object.prototype.toString; +var undefined; + +var isArray = function isArray(arr) { + if (typeof Array.isArray === 'function') { + return Array.isArray(arr); + } + + return toStr.call(arr) === '[object Array]'; +}; + +var isPlainObject = function isPlainObject(obj) { + 'use strict'; + if (!obj || toStr.call(obj) !== '[object Object]') { + return false; + } + + var has_own_constructor = hasOwn.call(obj, 'constructor'); + var has_is_property_of_method = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); + // Not own constructor property must be Object + if (obj.constructor && !has_own_constructor && !has_is_property_of_method) { + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + var key; + for (key in obj) {} + + return key === undefined || hasOwn.call(obj, key); +}; + +module.exports = function extend() { + 'use strict'; + var options, name, src, copy, copyIsArray, clone, + target = arguments[0], + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } else if ((typeof target !== 'object' && typeof target !== 'function') || target == null) { + target = {}; + } + + for (; i < length; ++i) { + options = arguments[i]; + // Only deal with non-null/undefined values + if (options != null) { + // Extend the base object + for (name in options) { + src = target[name]; + copy = options[name]; + + // Prevent never-ending loop + if (target === copy) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && isArray(src) ? src : []; + } else { + clone = src && isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[name] = extend(deep, clone, copy); + + // Don't bring in undefined values + } else if (copy !== undefined) { + target[name] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + + +/** @title NexusUI API @overview NexusUI is a JavaScript toolkit for easily creating musical interfaces in web browsers. Interfaces are rendered on HTML5 canvases and are ideal for web audio projects, mobile apps, or for sending OSC to external audio applications like Max. @author Ben Taylor, Jesse Allison, Yemin Oh, Sébastien Piquemal @copyright © 2011-2014 @license MIT */ -var n=(s(8),s(3)),o=s(6).EventEmitter,r=s(0),a=s(9),h=t.exports=function(){o.apply(this),this.widgets=new Object,this.elemTypeArr=new Array,this.aniItems=new Array,this.showLabels=!1,this.starttime=(new Date).getTime(),a&&(this.sendsTo=a.setGlobalTransmit,this.setAjaxPath=a.setAjaxPath,this.destination="js",this.ajaxPath="lib/nexusOSCRelay.php"),this.isTouchDevice="ontouchstart"in document.documentElement,this.metas=document.getElementsByTagName("meta"),this.globalWidgets=!0,this.font="'open sans'",this.fontSize=14,this.fontWeight="normal";var t=window.AudioContext||window.webkitAudioContext;this.context=new t,this.sys=navigator.userAgent.toLowerCase(),this.isAndroid=this.sys.indexOf("android")>-1,this.isMobile=this.sys.indexOf("mobile")>-1,this.throttlePeriod=20,this.colors.borderhl=n.shadeBlendConvert(-.5,this.colors.border),this.colors.accenthl=n.shadeBlendConvert(.15,this.colors.accent)};r.inherits(h,o),h.prototype.add=function(t,e){if(t){var i=document.createElement("canvas");if(i.setAttribute("nx",t),e){if((e.x||e.y)&&(i.style.position="absolute"),e.x&&(i.style.left=e.x+"px"),e.y&&(i.style.top=e.y+"px"),e.w&&(i.style.width=e.w,"string"!=typeof e.w&&(i.width=e.w)),e.h&&(i.style.height=e.h,"string"!=typeof e.h&&(i.height=e.h)),e.parent){var s;"string"==typeof e.parent?s=document.getElementById(e.parent):e.parent instanceof HTMLElement?s=e.parent:e.parent instanceof jQuery&&(s=e.parent[0])}e.name&&(i.id=e.name)}if(!s)var s=document.body;return s.appendChild(i),this.transform(i)}},h.prototype.transform=function(t,e){for(var i in nx.widgets)if(nx.widgets[i].canvasID==t.id)return;if(e)var n=e;else var n=t.getAttribute("nx");if(n){var o,r=0;for(j=0;j<this.elemTypeArr.length;j++)this.elemTypeArr[j]===n&&r++;if(this.elemTypeArr.push(n),!t.id){var a=r+1;t.id=n+a}if(n)try{var o=new(s(27)[n])(t.id)}catch(t){return void console.log("creation of "+n+" failed")}return o.type=n,this.widgets[o.canvasID]=o,this.globalWidgets&&(window[o.canvasID]=this.widgets[o.canvasID]),o.init(),o}},h.prototype.transmit=function(t,e){this.makeOSC(this.emit,t,e),this.emit("*",t,e)},h.prototype.colorize=function(t,e){e||(e=t,t="accent"),this.colors[t]=e,this.colors.borderhl=n.shadeBlendConvert(.1,this.colors.border,this.colors.black),this.colors.accenthl=n.shadeBlendConvert(.3,this.colors.accent);for(var i in this.widgets)this.widgets[i].colors[t]=e,this.widgets[i].colors.borderhl=this.colors.borderhl,this.widgets[i].colors.accenthl=this.colors.accenthl,this.widgets[i].draw()},h.prototype.setThrottlePeriod=function(t){this.throttlePeriod=t;for(var e in this.widgets)this.widgets[e].throttlePeriod=this.throttlePeriod},h.prototype.colors={accent:"#ff5500",fill:"#eeeeee",border:"#e3e3e3",mid:"#1af",black:"#000000",white:"#FFFFFF"},h.prototype.startPulse=function(){this.pulseInt=setInterval("nx.pulse()",30)},h.prototype.stopPulse=function(){clearInterval(this.pulseInt)},h.prototype.pulse=function(){for(var t=0;t<this.aniItems.length;t++)this.aniItems[t]()},h.prototype.addAni=function(t){},h.prototype.removeAni=function(t){this.aniItems.splice(this.aniItems.indexOf(t))},h.prototype.addStylesheet=function(){var t='select {width: 150px;padding: 5px 5px;font-size: 16px;color:#666666;border: solid 2px #e4e4e4;border-radius: 0;-webkit-appearance: none;outline: none;cursor:pointer;background-color:#EEE;font-family:"open sans";}input[type=text]::-moz-selection { background: transparent; }input[type=text]::selection { background: transparent; }input[type=text]::-webkit-selection { background: transparent; }canvas { cursor:pointer;border-radius:0px;moz-border-radius:0px;webkit-border-radius:0px;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;}input[type=text] { border-radius:5px;moz-border-radius:5px;webkit-border-radius:5px;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;}',e=document.head,i=document.createElement("style");i.type="text/css",i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t)),e.appendChild(i)},h.prototype.setViewport=function(t){for(i=0;i<this.metas.length;i++)"viewport"==this.metas[i].name&&(this.metas[i].content="minimum-scale="+t+", maximum-scale="+t)},h.prototype.setLabels=function(t){this.showLabels="on"==t;for(var e in this.widgets)this.widgets[e].draw()},h.prototype.setProp=function(t,e){if(t&&e){nx[t]=e;for(var i in this.widgets)this.widgets[i][t]=e,this.widgets[i].draw()}},h.prototype.blockMove=function(t){t.target.attributes.nx&&(t.preventDefault(),this.isAndroid&&!!t.stopPropagation&&t.stopPropagation())},h.prototype.calculateDigits=function(t){var e=this.max?Math.floor(this.max).toString().length:1;if(e<this.maxdigits)var i=3-e;else var i=0;return{wholes:e,decimals:i,total:e+i}},h.prototype.themes={light:{fill:"#DDDDDD",border:"#DADADA",black:"#000000",white:"#FFFFFF",body:"#F3F3F3"},dark:{fill:"#222",border:"#292929",black:"#FFFFFF",white:"#000000",body:"#111"},red:"#f24",orange:"#f50",yellow:"#ec1",green:"#1c9",blue:"#09d",purple:"#40a"},h.prototype.skin=function(t){var e=t.split("-");nx.colorize("fill",nx.themes[e[0]].fill),nx.colorize("border",nx.themes[e[0]].border),nx.colorize("black",nx.themes[e[0]].black),nx.colorize("white",nx.themes[e[0]].white),nx.colorize("accent",nx.themes[e[1]]),document.body.style.backgroundColor=nx.themes[e[0]].body},h.prototype.labelSize=function(t){for(var e in this.widgets){var i=this.widgets[e];if(i.label){var s=i.GUI.h+t;i.labelSize=t,["select","number","text"].indexOf(i.type)<0&&i.resize(!1,s)}}var n=document.querySelectorAll(".nxlabel");console.log(n);for(var o=0;o<n.length;o++)console.log(n[o]),n[o].style.fontSize=t/2.8+"px",console.log(n[o].style.fontSize)}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),banner=module.exports=function(t){this.defaultSize={width:100,height:40},widget.call(this,t),this.message1="Powered By",this.message2="NexusUI",this.link="http://www.nexusosc.com",this.isLink=!0};util.inherits(banner,widget),banner.prototype.init=function(){this.draw()},banner.prototype.draw=function(){with(this.context)globalAlpha=.1,fillStyle=this.colors.accent,beginPath(),moveTo(0,10),lineTo(10,this.GUI.h/2+5),lineTo(0,this.GUI.h),lineTo(30,this.GUI.h),lineTo(30,10),fill(),moveTo(this.GUI.w-30,10),lineTo(this.GUI.w-30,this.GUI.h),lineTo(this.GUI.w,this.GUI.h),lineTo(this.GUI.w-10,this.GUI.h/2+5),lineTo(this.GUI.w,10),fill(),closePath(),globalAlpha=1,fillStyle=this.colors.accent,fillRect(15,0,this.GUI.w-30,this.GUI.h-10),fillStyle=this.colors.white,font=this.fontWeight+" "+this.GUI.h/5+"px "+this.font,textAlign="center",fillText(this.message1,this.GUI.w/2,this.GUI.h/3.3),fillText(this.message2,this.GUI.w/2,this.GUI.h/3.3*2),fillStyle=this.colors.black,beginPath(),moveTo(15,this.GUI.h-10),lineTo(30,this.GUI.h),lineTo(30,this.GUI.h-10),lineTo(15,this.GUI.h-10),fill(),moveTo(this.GUI.w-15,this.GUI.h-10),lineTo(this.GUI.w-30,this.GUI.h),lineTo(this.GUI.w-30,this.GUI.h-10),lineTo(this.GUI.w-15,this.GUI.h-10),fill(),closePath()},banner.prototype.click=function(){this.isLink&&(window.location=this.link)}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),drawing=__webpack_require__(3),button=module.exports=function(t){this.defaultSize={width:50,height:50},widget.call(this,t),this.val={press:0},this.mode="aftertouch",this.lockResize=!0,this.image=null,this.imageHover=null,this.imageTouch=null,this.subval=new Object,this.init()};util.inherits(button,widget),button.prototype.init=function(){this.center={x:this.GUI.w/2,y:this.GUI.h/2},this.strokeWidth=this.GUI.w/20,this.radius=Math.min(this.center.x,this.center.y),this.draw()},button.prototype.draw=function(){with(this.erase(),this.context){if(null!==this.image)this.val.press?this.imageTouch?drawImage(this.imageTouch,0,0):(drawImage(this.image,0,0),globalAlpha=.5,fillStyle=this.colors.accent,fillRect(0,0,this.GUI.w,this.GUI.h),globalAlpha=1):drawImage(this.image,0,0);else if(this.val.press?this.val.press&&(fillStyle=this.colors.accent,strokeStyle=this.colors.accenthl):(fillStyle=this.colors.fill,strokeStyle=this.colors.border),lineWidth=this.strokeWidth,beginPath(),arc(this.center.x,this.center.y,this.radius,0,2*Math.PI,!0),fill(),closePath(),beginPath(),arc(this.center.x,this.center.y,this.radius-lineWidth/2,0,2*Math.PI,!0),stroke(),globalAlpha=1,closePath(),this.val.press&&"aftertouch"==this.mode){var x=nx.clip(this.clickPos.x,.2*this.GUI.w,this.GUI.w/1.3),y=nx.clip(this.clickPos.y,.2*this.GUI.h,this.GUI.h/1.3),gradient=this.context.createRadialGradient(x,y,this.GUI.w/6,this.center.x,this.center.y,1.3*this.radius);gradient.addColorStop(0,this.colors.accent),gradient.addColorStop(1,"white"),strokeStyle=gradient,lineWidth=this.GUI.w/20,beginPath(),arc(this.center.x,this.center.y,this.radius-this.GUI.w/40,0,2*Math.PI,!0),stroke(),closePath()}this.drawLabel()}},button.prototype.click=function(t){drawing.isInside(this.clickPos,{x:this.center.x-this.radius,y:this.center.y-this.radius,w:2*this.radius,h:2*this.radius})&&(this.val.press=1,"aftertouch"==this.mode&&(this.val.x=this.clickPos.x,this.val.y=this.clickPos.y),this.transmit(this.val),this.draw())},button.prototype.move=function(){"aftertouch"==this.mode&&(this.val.x=this.clickPos.x,this.val.y=this.clickPos.y,this.subval.x=this.clickPos.x,this.subval.y=this.clickPos.y,this.transmit(this.subval),this.draw())},button.prototype.release=function(){this.val.press=0,"toggle"!=this.mode&&"aftertouch"!=this.mode||this.transmit(this.val),this.draw()},button.prototype.setImage=function(t){this.image=new Image,this.image.onload=this.draw.bind(this),this.image.src=t},button.prototype.setHoverImage=function(t){this.imageHover=new Image,this.imageHover.onload=this.draw.bind(this),this.imageHover.src=t},button.prototype.setTouchImage=function(t){this.imageTouch=new Image,this.imageTouch.onload=this.draw.bind(this),this.imageTouch.src=t}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),colors=module.exports=function(t){this.defaultSize={width:100,height:100},widget.call(this,t),this.init()};util.inherits(colors,widget),colors.prototype.init=function(){this.gradient1=this.context.createLinearGradient(0,0,this.GUI.w,0),this.gradient1.addColorStop(0,"#F00"),this.gradient1.addColorStop(.17,"#FF0"),this.gradient1.addColorStop(.34,"#0F0"),this.gradient1.addColorStop(.51,"#0FF"),this.gradient1.addColorStop(.68,"#00F"),this.gradient1.addColorStop(.85,"#F0F"),this.gradient1.addColorStop(1,"#F00"),this.gradient2=this.context.createLinearGradient(0,0,0,this.GUI.h),this.gradient2.addColorStop(0,"rgba(0,0,0,255)"),this.gradient2.addColorStop(.49,"rgba(0,0,0,0)"),this.gradient2.addColorStop(.51,"rgba(255,255,255,0)"),this.gradient2.addColorStop(.95,"rgba(255,255,255,255)"),this.draw()},colors.prototype.draw=function(){with(this.erase(),this.context)fillStyle=this.gradient1,fillRect(0,0,this.GUI.w,this.GUI.h),fillStyle=this.gradient2,fillRect(0,0,this.GUI.w,this.GUI.h);this.drawLabel()},colors.prototype.drawColor=function(){with(this.context)fillStyle="rgb("+this.val.r+","+this.val.g+","+this.val.b+")",fillRect(0,.95*this.GUI.h,this.GUI.w,.05*this.GUI.h)},colors.prototype.click=function(t){if(this.clickPos.x>0&&this.clickPos.y>0&&this.clickPos.x<this.GUI.w&&this.clickPos.y<this.GUI.h){var e=this.context.getImageData(2*this.clickPos.x,2*this.clickPos.y,1,1);this.val={r:e.data[0],g:e.data[1],b:e.data[2]},this.transmit(this.val),this.drawColor()}},colors.prototype.move=function(t){this.click(t)}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),comment=module.exports=function(t){this.defaultSize={width:100,height:20},widget.call(this,t),this.val={text:"comment"},this.sizeSet=!1,this.init()};util.inherits(comment,widget),comment.prototype.setSize=function(t){this.size=t,this.sizeSet=!0,this.draw()},comment.prototype.init=function(){this.draw()},comment.prototype.draw=function(){with(this.sizeSet||(this.size=Math.sqrt(this.GUI.w*this.GUI.h/(2*this.val.text.length))),this.erase(),this.context)fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),fillStyle=this.colors.black,textAlign="left",font=this.size+"px 'Open Sans'";this.wrapText(this.val.text,6,3+this.size,this.GUI.w-6,this.size)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),crossfade=module.exports=function(t){this.defaultSize={width:100,height:30},widget.call(this,t),this.val={R:.75,L:.75},this.location=.5,this.init()};util.inherits(crossfade,widget),crossfade.prototype.init=function(){this.draw()},crossfade.prototype.draw=function(){with(this.erase(),this.location=Math.pow(this.val.R,2),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h);var y1=0,y2=this.GUI.h,x1=this.location*this.GUI.w;fillStyle=this.colors.accent,fillRect(x1,0,this.GUI.w-x1,y2),textBaseline="middle",font=this.GUI.h/3+"px 'Open Sans'",fillStyle=this.colors.accent,textAlign="right",fillText(this.val.R.toFixed(2),x1-2,this.GUI.h/4),fillStyle=this.colors.fill,textAlign="left",fillText(this.val.L.toFixed(2),x1+2,.75*this.GUI.h)}this.drawLabel()},crossfade.prototype.click=function(){this.move()},crossfade.prototype.move=function(){var t=math.clip(this.clickPos.x/this.GUI.w,0,1),e=1-t;this.location=t,this.val.R=math.prune(Math.sqrt(t),3),this.val.L=math.prune(Math.sqrt(e),3),this.draw(),this.transmit(this.val)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),dial=module.exports=function(t){this.defaultSize={width:100,height:100},widget.call(this,t),this.circleSize,this.handleLength,this.val={value:0},this.responsivity=.004,this.aniStart=0,this.aniStop=1,this.aniMove=.01,this.lockResize=!0,null!=this.canvas.getAttribute("min")?this.min=parseFloat(this.canvas.getAttribute("min")):this.min=0,null!=this.canvas.getAttribute("max")?this.max=parseFloat(this.canvas.getAttribute("max")):this.max=1,null!=this.canvas.getAttribute("step")?this.step=parseFloat(this.canvas.getAttribute("step")):this.step=.001,this.maxdigits=3,this.calculateDigits=nx.calculateDigits,this.init()};util.inherits(dial,widget),dial.prototype.init=function(){this.circleSize=Math.min(this.center.x,this.center.y),this.handleLength=this.circleSize,this.mindim=Math.min(this.GUI.w,this.GUI.h),this.mindim<101||this.mindim<101?this.accentWidth=1*this.lineWidth:this.accentWidth=2*this.lineWidth,this.draw()},dial.prototype.draw=function(){var normalval=this.normalize(this.val.value),dial_position=2*(normalval+.25)*Math.PI;with(this.erase(),this.context)if(lineCap="butt",beginPath(),lineWidth=this.circleSize/2,arc(this.center.x,this.center.y,this.circleSize-lineWidth/2,0*Math.PI,2*Math.PI,!1),strokeStyle=this.colors.fill,stroke(),closePath(),lineCap="butt",beginPath(),lineWidth=this.circleSize/2,arc(this.center.x,this.center.y,this.circleSize-lineWidth/2,.5*Math.PI,dial_position,!1),strokeStyle=this.colors.accent,stroke(),closePath(),clearRect(this.center.x-this.GUI.w/40,this.center.y,this.GUI.w/20,this.GUI.h/2),normalval>0&&(beginPath(),lineWidth=1.5,moveTo(this.center.x-this.GUI.w/40,this.center.y+this.circleSize/2),lineTo(this.center.x-this.GUI.w/40,this.center.y+this.circleSize),strokeStyle=this.colors.accent,stroke(),closePath()),this.val.value=math.prune(this.rangify(normalval),3),this.digits=this.calculateDigits(),valtextsize=this.mindim/this.digits.total*.55,valtextsize>7){var valtext=this.val.value.toFixed(this.digits.decimals);fillStyle=this.colors.borderhl,textAlign="center",textBaseline="middle",font=valtextsize+"px 'Open Sans'",fillText(valtext,this.GUI.w/2,this.GUI.h/2)}this.drawLabel()},dial.prototype.click=function(t){this.val.value=math.prune(this.val.value,4),this.transmit(this.val),this.draw(),this.aniStart=this.val.value},dial.prototype.move=function(){var t=this.normalize(this.val.value);t=math.clip(t-this.deltaMove.y*this.responsivity,0,1),this.val.value=math.prune(this.rangify(t),4),this.transmit(this.val),this.draw()},dial.prototype.release=function(){this.aniStop=this.val.value},dial.prototype.animate=function(t){switch(t){case"bounce":nx.aniItems.push(this.aniBounce.bind(this));break;case"none":nx.aniItems.splice(nx.aniItems.indexOf(this.aniBounce))}},dial.prototype.aniBounce=function(){this.clicked||(this.val.value+=this.aniMove,this.aniStop<this.aniStart&&(this.stopPlaceholder=this.aniStop,this.aniStop=this.aniStart,this.aniStart=this.stopPlaceholder),this.aniMove=math.bounce(this.val.value,this.aniStart,this.aniStop,this.aniMove),this.draw(),this.val.value=math.prune(this.val.value,4),this.transmit(this.val))}},function(module,exports,__webpack_require__){var startTime=0,math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),envelope=module.exports=function(t){this.defaultSize={width:200,height:100},widget.call(this,t),this.nodeSize=1,this.active=!1,this.duration=1e3,this.looping=!1,this.scanIndex=0,this.val={index:0,amp:0,points:[{x:.1,y:.4},{x:.35,y:.6},{x:.65,y:.2},{x:.9,y:.4}]},this.selectedNode=null,nx.aniItems.push(this.pulse.bind(this)),this.init()};util.inherits(envelope,widget),envelope.prototype.init=function(){this.mindim=this.GUI.w<this.GUI.h?this.GUI.w:this.GUI.h,this.draw()},envelope.prototype.draw=function(){with(this.erase(),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),fillStyle=this.colors.accent;var centerx=this.mindim/10,centery=this.GUI.h-this.mindim/10;beginPath(),moveTo(centerx,centery),arc(centerx,centery,this.mindim/10,1.5*Math.PI,2*Math.PI*this.val.index+1.5*Math.PI,!1),fill(),closePath();for(var drawingX=[],drawingY=[],i=0;i<this.val.points.length;i++)drawingX[i]=this.val.points[i].x*this.GUI.w,drawingY[i]=(1-this.val.points[i].y)*this.GUI.h,drawingX[i]<this.bgLeft+this.nodeSize?drawingX[i]=this.bgLeft+this.nodeSize:drawingX[i]>this.bgRight-this.nodeSize&&(drawingX[i]=this.bgRight-this.nodeSize),drawingY[i]<this.bgTop+this.nodeSize?drawingY[i]=this.bgTop+this.nodeSize:drawingY[i]>this.bgBottom-this.nodeSize&&(drawingY[i]=this.bgBottom-this.nodeSize);for(var j=0;j<drawingX.length;j++){var size=this.mindim/35+2;beginPath(),arc(drawingX[j],drawingY[j],size,0,2*Math.PI,!1),fillStyle=this.colors.accent,fill(),closePath()}beginPath(),strokeStyle=this.colors.accent,moveTo(-5,this.GUI.h),lineTo(-5,(1-this.val.points[0].y)*this.GUI.h);for(var j=0;j<drawingX.length;j++)lineTo(drawingX[j],drawingY[j]);lineTo(this.GUI.w+5,(1-this.val.points[this.val.points.length-1].y)*this.GUI.h),lineTo(this.GUI.w+5,this.GUI.h),stroke(),globalAlpha=.2,fillStyle=this.colors.accent,fill(),globalAlpha=1,closePath()}this.drawLabel()},envelope.prototype.scaleNode=function(t){var e=t,i=0,s=this.GUI.w,n=this.val.points[e].x,o=this.GUI.h-this.val.points[e].y,r=math.clip(n/this.GUI.w,0,1),a=math.clip(o/this.GUI.h,0,1);this.val.points[e].x=math.prune(r,3),this.val.points[e].y=math.prune(a,3),e>0&&(i=this.val.points[e-1].x),this.val.points.length>e+1&&(s=this.val.points[e+1].x),this.val.points[e].x<i&&(this.val.points.splice(e-1,0,this.val.points.splice(e,1)[0]),e-=1,this.selectedNode=e),this.val.points[e].x>s&&(this.val.points.splice(e+1,0,this.val.points.splice(e,1)[0]),e+=1,this.selectedNode=e)},envelope.prototype.click=function(){this.selectedNode=this.findNearestNode(this.clickPos.x/this.GUI.w,this.clickPos.y/this.GUI.h,this.val.points),this.transmit(this.val),this.draw()},envelope.prototype.move=function(){this.clicked&&(this.val.points[this.selectedNode].x=this.clickPos.x,this.val.points[this.selectedNode].y=this.clickPos.y,this.scaleNode(this.selectedNode),this.transmit(this.val),this.draw())},envelope.prototype.release=function(){this.hasMoved||this.val.points.splice(this.selectedNode,1),this.draw(),this.selectedNode=null},envelope.prototype.pulse=function(){if(this.active){var t=(nx.context.currentTime-startTime)/(this.duration/1e3);if(t>=1&&(this.looping?(t-=1,startTime+=this.duration/1e3,this.val.index=0,this.scanIndex=0):this.stop()),this.val.index=t,this.val.index>this.val.points[this.val.points.length-1].x)this.val.amp=this.val.points[this.val.points.length-1].y;else if(this.val.index<this.val.points[0].x)this.val.amp=this.val.points[0].y;else{for(this.scanIndex=0;this.val.index>this.val.points[this.scanIndex].x;)this.scanIndex++;var e=this.val.points[this.scanIndex].x,i=this.val.points[this.scanIndex-1].x,s=this.val.points[this.scanIndex].y,n=this.val.points[this.scanIndex-1].y;this.val.amp=math.interp((this.val.index-i)/(e-i),n,s)}this.transmit(this.val),this.draw()}},envelope.prototype.start=function(){this.active=!0,this.val.index=0,startTime=nx.context.currentTime},envelope.prototype.stop=function(){this.active=!1,this.val.index=0,this.draw()},envelope.prototype.findNearestNode=function(t,e,i){var s=null,n=1e3,o=!1;e=1-e;for(var r=0;r<i.length;r++){var a=Math.sqrt(Math.pow(i[r].x-t,2),Math.pow(i[r].y- -e,2));a<n&&(n=a,s=r,o=t>i[r].x)}return n>.1&&(o&&s++,this.val.points.splice(s,0,{x:this.clickPos.x/this.GUI.w,y:(this.GUI.h-this.clickPos.y)/this.GUI.h})),s}},function(t,e,i){t.exports={banner:i(20),button:i(21),colors:i(22),comment:i(23),crossfade:i(24),dial:i(25),envelope:i(26),joints:i(28),keyboard:i(29),matrix:i(30),message:i(31),meter:i(32),metro:i(33),motion:i(34),mouse:i(35),multislider:i(36),multitouch:i(37),number:i(38),position:i(39),range:i(40),select:i(41),slider:i(42),string:i(43),tabs:i(44),text:i(45),tilt:i(46),toggle:i(47),typewriter:i(48),vinyl:i(49),waveform:i(50)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),joints=module.exports=function(t){this.defaultSize={width:150,height:150},widget.call(this,t),this.nodeSize=this.GUI.w/14,this.values=[0,0],this.val={x:.35,y:.35,node1:0},this.joints=[{x:.1,y:.2},{x:.2,y:.1},{x:.3,y:.7},{x:.4,y:.4},{x:.5,y:.9},{x:.6,y:.15},{x:.7,y:.3},{x:.8,y:.8}],this.threshold=this.GUI.w/3};util.inherits(joints,widget),joints.prototype.init=function(){this.nodeSize=this.GUI.w/14,this.threshold=this.GUI.w/3,this.draw()},joints.prototype.draw=function(){with(this.erase(),this.drawingX=this.val.x*this.GUI.w,this.drawingY=this.val.y*this.GUI.h,this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),null!=this.val.x?this.drawNode():(fillStyle=this.colors.border,font="14px courier",fillText(this.default_text,10,20)),fillStyle=this.colors.accent,strokeStyle=this.colors.border;for(var i in this.joints){beginPath(),arc(this.joints[i].x*this.GUI.w,this.joints[i].y*this.GUI.h,this.nodeSize/2,0,2*Math.PI,!0),fill(),closePath();var cnctX=Math.abs(this.joints[i].x*this.GUI.w-this.drawingX),cnctY=Math.abs(this.joints[i].y*this.GUI.h-this.drawingY),strength=cnctX+cnctY;if(strength<this.threshold){beginPath(),moveTo(this.joints[i].x*this.GUI.w,this.joints[i].y*this.GUI.h),lineTo(this.drawingX,this.drawingY),strokeStyle=this.colors.accent,lineWidth=math.scale(strength,0,this.threshold,this.nodeSize/2,5),stroke(),closePath();var scaledstrength=math.scale(strength,0,this.threshold,1,0);this.val["node"+i]=scaledstrength}}}this.drawLabel()},joints.prototype.drawNode=function(){with(this.drawingX<this.nodeSize?this.drawingX=this.nodeSize:this.drawingX>this.GUI.w-this.nodeSize&&(this.drawingX=this.GUI.w-this.nodeSize),this.drawingY<this.nodeSize?this.drawingY=this.nodeSize:this.drawingY>this.GUI.h-this.nodeSize&&(this.drawingY=this.GUI.h-this.nodeSize),this.context)globalAlpha=1,beginPath(),fillStyle=this.colors.accent,strokeStyle=this.colors.border,lineWidth=this.lineWidth,arc(this.drawingX,this.drawingY,this.nodeSize,0,2*Math.PI,!0),fill(),closePath()},joints.prototype.click=function(){this.val=new Object,this.val.x=this.clickPos.x/this.GUI.w,this.val.y=this.clickPos.y/this.GUI.h,this.draw(),this.transmit(this.val),this.connections=new Array},joints.prototype.move=function(){this.val=new Object,this.clicked&&(this.val.x=this.clickPos.x/this.GUI.w,this.val.y=this.clickPos.y/this.GUI.h,this.draw(),this.transmit(this.val),this.connections=new Array)},joints.prototype.release=function(){this.anix=this.deltaMove.x/this.GUI.w,this.aniy=this.deltaMove.y/this.GUI.h},joints.prototype.animate=function(t){switch(t){case"bounce":nx.aniItems.push(this.aniBounce.bind(this));break;case"none":nx.aniItems.splice(nx.aniItems.indexOf(this.aniBounce))}},joints.prototype.anix=0,joints.prototype.aniy=0,joints.prototype.aniBounce=function(){!this.clicked&&this.val.x&&(this.val.x+=this.anix,this.val.y+=this.aniy,this.anix=math.bounce(this.val.x,.1,.9,this.anix),this.aniy=math.bounce(this.val.y,.1,.9,this.aniy),this.draw(),this.transmit(this.val))}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),drawing=__webpack_require__(3),math=__webpack_require__(2),keyboard=module.exports=function(t){this.defaultSize={width:300,height:75},widget.call(this,t),this.octaves=3,this.white={width:0,height:0},this.black={width:0,height:0},this.wkeys=new Array,this.bkeys=new Array,this.keypattern=["w","b","w","b","w","w","b","w","b","w","b","w"],this.keys=new Array,this.midibase=48,this.lineWidth=1,this.fingers=[{key:-1,pkey:-1}],this.multitouch=!1,this.oneleft=!1,this.mode="button",this.val={on:0,note:0,midi:"0 0"},this.init()};util.inherits(keyboard,widget),keyboard.prototype.init=function(){this.white={width:0,height:0},this.black={width:0,height:0},this.wkeys=new Array,this.bkeys=new Array,this.keys=new Array,this.white.num=0;for(var t=0;t<this.keypattern.length;t++)"w"==this.keypattern[t]&&this.white.num++;this.white.num*=this.octaves,this.white.width=this.GUI.w/this.white.num,this.white.height=this.GUI.h,this.black.width=.6*this.white.width,this.black.height=.6*this.GUI.h;for(var t=0;t<this.keypattern.length*this.octaves;t++)switch(this.keys[t]={note:t+this.midibase,on:!1},this.keypattern[t%this.keypattern.length]){case"w":this.keys[t].x=this.wkeys.length*this.white.width,this.keys[t].y=0,this.keys[t].w=this.white.width,this.keys[t].h=this.white.height,this.keys[t].type="w",this.keys[t].index=t,this.wkeys.push(this.keys[t]);break;case"b":this.keys[t].x=this.wkeys.length*this.white.width-this.black.width/2,this.keys[t].y=0,this.keys[t].w=this.black.width,this.keys[t].h=this.black.height,this.keys[t].type="b",this.keys[t].index=t,this.bkeys.push(this.keys[t])}this.draw()},keyboard.prototype.draw=function(){with(this.context){strokeStyle=this.colors.borderhl,lineWidth=1;for(var i in this.wkeys)fillStyle=this.wkeys[i].on?this.colors.borderhl:this.colors.fill,strokeRect(this.wkeys[i].x,0,this.white.width,this.white.height),fillRect(this.wkeys[i].x,0,this.white.width,this.white.height);for(var i in this.bkeys)fillStyle=this.bkeys[i].on?this.colors.borderhl:this.colors.black,fillRect(this.bkeys[i].x,0,this.black.width,this.black.height)}this.drawLabel()},keyboard.prototype.toggle=function(t,e){if("button"==this.mode){if(t){t.on=e||!1===e?e:!t.on;var i=t.on?1:0,s=128*math.invert(this.clickPos.y/this.GUI.h);s=math.prune(math.clip(s,5,128),0),this.val={on:i*s,note:t.note,midi:t.note+" "+i},this.transmit(this.val),this.draw()}}else if("sustain"==this.mode&&t){t.on=e||!t.on;var i=t.on?1:0,s=128*math.invert(this.clickPos.y/this.GUI.h);s=math.prune(math.clip(s,5,128),0),this.val={on:i*s,note:t.note,midi:t.note+" "+i},this.transmit(this.val),this.draw()}},keyboard.prototype.whichKey=function(t,e){for(var i in this.bkeys)if(drawing.isInside({x:t,y:e},this.bkeys[i]))return this.bkeys[i];var s=~~(t/this.white.width);return s>=this.wkeys.length&&(s=this.wkeys.length-1),s<0&&(s=0),this.wkeys[s]},keyboard.prototype.click=function(t){if(this.clickPos.touches.length>1||this.multitouch){this.multitouch=!0,this.clickPos.touches.length>=2&&this.oneleft&&(this.oneleft=!1),this.keysinuse=new Array;for(var e=0;e<this.clickPos.touches.length;e++)this.fingers[e]={key:this.whichKey(this.clickPos.touches[e].x,this.clickPos.touches[e].y)},this.fingers[e].key.on||this.toggle(this.fingers[e].key,!0),this.keysinuse.push(this.fingers[e].key.index);for(var e=0;e<this.keys.length;e++)this.keys[e].on&&this.keysinuse.indexOf(this.keys[e].index)<0&&this.toggle(this.keys[e],!1)}else this.fingers[0].pkey=this.fingers[0].key,this.fingers[0].key=this.whichKey(this.clickPos.x,this.clickPos.y),this.toggle(this.fingers[0].key)},keyboard.prototype.move=function(t){if(this.clickPos.touches.length>1||this.multitouch){this.keysinuse=new Array;for(var e=0;e<this.clickPos.touches.length;e++)this.fingers[e]={key:this.whichKey(this.clickPos.touches[e].x,this.clickPos.touches[e].y)},this.fingers[e].key.on||this.toggle(this.fingers[e].key,!0),this.keysinuse.push(this.fingers[e].key.index);for(var e=0;e<this.keys.length;e++)this.keys[e].on&&this.keysinuse.indexOf(this.keys[e].index)<0&&this.toggle(this.keys[e],!1)}else this.fingers[0].pkey=this.fingers[0].key,this.fingers[0].key=this.whichKey(this.clickPos.x,this.clickPos.y),this.fingers[0].key&&this.fingers[0].key.index!=this.fingers[0].pkey.index&&(this.toggle(this.fingers[0].pkey,!1),this.toggle(this.fingers[0].key,!0))},keyboard.prototype.release=function(t){if(this.clickPos.touches.length>1||this.multitouch){this.keysinuse=new Array;for(var e=0;e<this.clickPos.touches.length&&(!this.oneleft||1!=this.clickPos.touches.length);e++)this.fingers[e]={key:this.whichKey(this.clickPos.touches[e].x,this.clickPos.touches[e].y)},this.keysinuse.push(this.fingers[e].key.index);for(var e=0;e<this.keys.length;e++)this.keys[e].on&&this.keysinuse.indexOf(this.keys[e].index)<0&&this.toggle(this.keys[e],!1);1==this.clickPos.touches.length&&(this.oneleft=!0)}else"button"==this.mode&&this.toggle(this.fingers[0].key,!1)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),drawing=__webpack_require__(3),util=__webpack_require__(0),widget=__webpack_require__(1),matrix=module.exports=function(t){this.defaultSize={width:100,height:100},widget.call(this,t),this.row=4,this.col=4,this.cellHgt,this.cellWid,this.matrix,this.val={row:0,col:0,level:0,list:new Array},this.cur,this.prev,this.erasing=!1,this.place=null,this.starttime,this.lastbeat,this.thisframe=0,this.lastframe=0,this.context.lineWidth=1,this.sequencing=!1,this.cellBuffer=4,this.sequenceMode="linear",this.bpm=120,this.pbpm=this.bpm,this.starttime=nx.starttime,this.init()};util.inherits(matrix,widget),matrix.prototype.init=function(){this.pmatrix=!!this.matrix&&this.matrix,this.matrix=null,this.matrix=new Array(this.col);for(var t=0;t<this.col;t++){this.matrix[t]=new Array(this.row);for(var e=0;e<this.row;e++)this.matrix[t][e]=this.pmatrix&&this.pmatrix[t]?this.pmatrix[t][e]:0}this.draw(),this.life=this.unboundlife.bind(this)},matrix.prototype.draw=function(){with(this.erase(),this.cellWid=this.GUI.w/this.col,this.cellHgt=this.GUI.h/this.row,this.context)strokeStyle=this.colors.fill;for(var i=0;i<this.row;i++)for(var j=0;j<this.col;j++){var st_x=j*this.cellWid;0==j&&(st_x+=0);var st_y=i*this.cellHgt;0==i&&(st_y+=0);var boxwid=this.cellWid,boxhgt=this.cellHgt;with(this.context)strokeStyle=this.colors.border,lineWidth=this.cellBuffer,this.matrix[j][i]>0?fillStyle=this.colors.accent:fillStyle=this.colors.fill,fillRect(st_x+this.cellBuffer/2,st_y+this.cellBuffer/2,boxwid-this.cellBuffer,boxhgt-this.cellBuffer),this.place==j&&(globalAlpha=.4,fillStyle=this.colors.border,fillRect(st_x,st_y,boxwid,boxhgt),globalAlpha=1)}this.drawLabel()},matrix.prototype.click=function(t){this.cur={col:~~(this.clickPos.x/this.cellWid),row:~~(this.clickPos.y/this.cellHgt)},this.matrix[this.cur.col][this.cur.row]?(this.matrix[this.cur.col][this.cur.row]=0,this.erasing=!0):(this.matrix[this.cur.col][this.cur.row]=1,this.erasing=!1),this.cur.value=this.matrix[this.cur.col][this.cur.row],this.prev=this.cur,this.val={row:this.cur.row,col:this.cur.col,level:this.cur.value},this.transmit(this.val),this.draw()},matrix.prototype.move=function(t){this.clicked&&(this.cur={col:~~(this.clickPos.x/this.cellWid),row:~~(this.clickPos.y/this.cellHgt)},this.cur.row<this.row&&this.cur.col<this.col&&this.cur.row>=0&&this.cur.col>=0&&(this.cur.col==this.prev.col&&this.cur.row==this.prev.row||(this.erasing?this.matrix[this.cur.col][this.cur.row]=0:this.matrix[this.cur.col][this.cur.row]=1,this.cur.value=this.matrix[this.cur.col][this.cur.row],this.prev=this.cur,this.val={row:this.cur.row,col:this.cur.col,level:this.cur.value},this.transmit(this.val),this.draw())))},matrix.prototype.setCell=function(t,e,i){var s=i?1:0;this.matrix[t][e]=s,this.val={row:e,col:t,level:s},this.transmit(this.val),this.draw()},matrix.prototype.sequence=function(t){t&&(this.bpm=t),this.sequencing=!0,requestAnimationFrame(this.seqStep.bind(this))},matrix.prototype.setBPM=function(t){this.bpm=t},matrix.prototype.stop=function(){this.sequencing=!1},matrix.prototype.seqStep=function(){0==this.bpm&&(this.bpm=1);var t=(new Date).getTime(),e=t-this.starttime;if(this.bpm!=this.pbpm){e=e/(6e4/this.pbpm)*(6e4/this.bpm),this.starttime=t-e,this.thisframe=~~(e/(6e4/this.bpm))}else this.thisframe=~~(e/(6e4/this.bpm));this.pbpm=this.bpm,this.thisframe!=this.lastframe&&(this.lastbeat=t,"linear"==this.sequenceMode?this.place++:"random"==this.sequenceMode&&(this.place=math.random(this.col)),this.place>=this.col&&(this.place=0),null==this.place&&(this.place=0),this.jumpToCol(this.place)),this.lastframe=this.thisframe,this.sequencing&&requestAnimationFrame(this.seqStep.bind(this))},matrix.prototype.jumpToCol=function(t){this.place=t,this.val={list:this.matrix[this.place]},this.transmit(this.val),this.draw()},matrix.prototype.customDestroy=function(){this.stop()},matrix.prototype.unboundlife=function(){if(!this.clicked){this.newmatrix=[];for(var t=0;t<this.col;t++){this.newmatrix[t]=[];for(var e=0;e<this.row;e++){var i=0;t-1>=0&&(i+=this.matrix[t-1][e-1]?this.matrix[t-1][e-1]:0,i+=this.matrix[t-1][e]?this.matrix[t-1][e]:0,i+=this.matrix[t-1][e+1]?this.matrix[t-1][e+1]:0),i+=this.matrix[t][e-1]?this.matrix[t][e-1]:0,i+=this.matrix[t][e+1]?this.matrix[t][e+1]:0,t+1<this.col&&(i+=this.matrix[t+1][e-1]?this.matrix[t+1][e-1]:0,i+=this.matrix[t+1][e]?this.matrix[t+1][e]:0,i+=this.matrix[t+1][e+1]?this.matrix[t+1][e+1]:0),this.matrix[t][e]?i<2?this.newmatrix[t][e]=0:2==i||3==i?this.newmatrix[t][e]=1:i>3&&(this.newmatrix[t][e]=0):this.matrix[t][e]||3!=i?this.newmatrix[t][e]=this.matrix[t][e]:this.newmatrix[t][e]=1}}this.matrix=this.newmatrix}this.transmit({grid:this.matrix}),this.draw()},matrix.prototype.life=function(){return!1}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),message=module.exports=function(t){this.defaultSize={width:100,height:30},widget.call(this,t),this.val={value:"send a message"},this.size=14};util.inherits(message,widget),message.prototype.init=function(){this.canvas.getAttribute("label")&&(this.val.value=this.canvas.getAttribute("label")),this.draw()},message.prototype.draw=function(){with(this.erase(),this.context)this.clicked?fillStyle=this.colors.border:fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),this.clicked,fillStyle=this.colors.black,textAlign="left",font=this.size+"px "+nx.font;this.wrapText(this.val.value,5,1+this.size,this.GUI.w-6,this.size)},message.prototype.click=function(t){this.draw(),this.transmit(this.val)},message.prototype.release=function(t){this.draw()}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),drawing=__webpack_require__(3),widget=__webpack_require__(1),meter=module.exports=function(t){this.defaultSize={width:20,height:50},widget.call(this,t),this.val={level:0},this.dataArray,this.bars=8,this.init()};util.inherits(meter,widget),meter.prototype.init=function(){with(this.bar={x:0,y:0,w:this.GUI.w,h:this.GUI.h/this.bars},this.context)fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h)},meter.prototype.setup=function(t,e){this.actx=t,this.source=e,this.analyser=this.actx.createAnalyser(),this.analyser.smoothingTimeConstant=.85,this.analyser.fftsize=1024,this.bufferLength=this.analyser.frequencyBinCount,this.dataArray=new Uint8Array(this.bufferLength),this.source.connect(this.analyser),this.draw()},meter.prototype.draw=function(){if(this.dataArray){this.analyser.getByteTimeDomainData(this.dataArray);var max=Math.max.apply(null,this.dataArray),min=Math.min.apply(null,this.dataArray),amp=max-min;amp/=240;var db=Math.log(amp)/Math.log(10)*20;with(this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h);for(var dboffset=Math.floor((db+40)/(50/this.bars)),i=0;i<this.bars;i++)i>=.8*this.bars?fillStyle="rgb(255,0,0)":i<.8*this.bars&&i>=.69*this.bars?fillStyle="rgb(255,255,0)":i<.69*this.bars&&(fillStyle="rgb(0,255,0)"),i<dboffset&&fillRect(1,this.GUI.h-this.bar.h*i,this.GUI.w-2,this.bar.h-2)}}setTimeout(function(){window.requestAnimationFrame(this.draw.bind(this))}.bind(this),80)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),metro=module.exports=function(t){this.defaultSize={width:100,height:20},widget.call(this,t),this.val={beat:0},this.x=10,this.y=10,this.loc=10,this.nodeSize=10,this.speed=1,this.direction=1,this.orientation="horizontal",this.boundary=this.GUI.w,nx.aniItems.push(this.advance.bind(this)),this.active=!0,this.init()};util.inherits(metro,widget),metro.prototype.init=function(){this.nodeSize=Math.min(this.GUI.w,this.GUI.h)/2,this.GUI.w<this.GUI.h?(this.orientation="vertical",this.boundary=this.GUI.h):(this.orientation="horizontal",this.boundary=this.GUI.w),this.x=this.nodeSize,this.y=this.nodeSize,this.loc=this.nodeSize,this.draw()},metro.prototype.draw=function(){with(this.erase(),this.context)fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),beginPath(),fillStyle=this.colors.accent,arc(this.x,this.y,this.nodeSize,0,2*Math.PI,!0),fill(),closePath();this.drawLabel()},metro.prototype.click=function(){},metro.prototype.move=function(){this.clicked&&(this.speed-=this.deltaMove.y/50)},metro.prototype.release=function(){},metro.prototype.advance=function(){this.speed,this.loc+=this.speed*this.direction,(this.loc-this.nodeSize<0||this.loc+this.nodeSize>this.boundary)&&(this.val.beat=math.scale(this.direction,-1,1,0,1),this.transmit(this.val),this.direction*=-1),"vertical"==this.orientation?this.y=this.loc:this.x=this.loc,this.draw()},metro.prototype.customDestroy=function(){nx.removeAni(this.advance.bind(this))}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),motion=module.exports=function(target){if(this.defaultSize={width:75,height:75},widget.call(this,target),this.motionLR,this.motionFB,this.z,this.active=!0,this.px=0,this.py=0,this.pz=0,this.val={x:0,y:0,z:0},this.text="Motion",this.init(),this.boundMotion=this.motionlistener.bind(this),window.DeviceMotionEvent)window.addEventListener("devicemotion",this.boundMotion,!1);else with(this.context)fillText("incompatible",0,0),this.active=!1};util.inherits(motion,widget),motion.prototype.deviceMotionHandler=function(){this.val={x:math.prune(this.motionLR/10,4),y:math.prune(this.motionFB/10,4),z:math.prune(this.z/10,4)},this.transmit(this.val)},motion.prototype.motionlistener=function(e){var data=e.acceleration;if(this.active&&(this.motionLR=nx.lp(this.canvasID+"motionx",data.x,20),this.motionFB=nx.lp(this.canvasID+"motiony",data.y,20),this.z=nx.lp(this.canvasID+"motionz",data.z,20),this.deviceMotionHandler(),this.draw(),null===data.x||void 0===data.x)){with(this.erase(),this.context)fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),fillStyle=this.colors.black,font="12px courier",textAlign="center",fillText("no data",this.GUI.w/2,this.GUI.h/2);this.active=!1}},motion.prototype.init=function(){this.draw()},motion.prototype.draw=function(){with(this.erase(),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),fillStyle=this.colors.accent;var eighth=Math.PI/4;this.motionFB<0?(beginPath(),moveTo(this.GUI.w/2,this.GUI.h/2),arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,5*eighth,7*eighth,!1),globalAlpha=Math.pow(this.motionFB,2),fill(),closePath()):(beginPath(),moveTo(this.GUI.w/2,this.GUI.h/2),arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,1*eighth,3*eighth,!1),globalAlpha=Math.pow(this.motionFB,2),fill(),closePath()),this.motionLR<0?(beginPath(),moveTo(this.GUI.w/2,this.GUI.h/2),arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,7*eighth,1*eighth,!1),globalAlpha=Math.pow(this.motionLR,2),fill(),closePath()):(beginPath(),moveTo(this.GUI.w/2,this.GUI.h/2),arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,3*eighth,5*eighth,!1),globalAlpha=Math.pow(this.motionLR,2),fill(),closePath()),beginPath(),moveTo(this.GUI.w/2,this.GUI.h/2),arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/6,0,2*Math.PI,!1),globalAlpha=Math.pow(this.z,2),fill(),closePath(),globalAlpha=1}this.drawLabel()},motion.prototype.click=function(){this.active=!this.active,this.draw()},motion.prototype.customDestroy=function(){this.active=!1,window.removeEventListener("devicemotion",this.motionlistener,!1)}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),math=__webpack_require__(2),mouse=module.exports=function(t){this.defaultSize={width:98,height:100},widget.call(this,t),this.val={x:0,y:0,deltax:0,deltay:0},this.inside=new Object,this.boundmove=this.preMove.bind(this),this.mousing=window.addEventListener("mousemove",this.boundmove,!1),this.init()};util.inherits(mouse,widget),mouse.prototype.init=function(){this.inside.height=this.GUI.h,this.inside.width=this.GUI.w,this.inside.left=0,this.inside.top=0,this.inside.quarterwid=this.inside.width/4,this.draw()},mouse.prototype.draw=function(){with(this.erase(),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h);var scaledx=-this.val.x*this.GUI.h,scaledy=-this.val.y*this.GUI.h,scaleddx=-this.val.deltax*this.GUI.h-this.GUI.h/2,scaleddy=-this.val.deltay*this.GUI.h-this.GUI.h/2;fillStyle=this.colors.accent,fillRect(this.inside.left,this.inside.height,this.inside.quarterwid,scaledx),fillRect(this.inside.quarterwid,this.inside.height,this.inside.quarterwid,scaledy),fillRect(2*this.inside.quarterwid,this.inside.height,this.inside.quarterwid,scaleddx),fillRect(3*this.inside.quarterwid,this.inside.height,this.inside.quarterwid,scaleddy),globalAlpha=1,fillStyle=this.colors.fill,textAlign="center",font=this.GUI.w/7+"px "+this.font,globalAlpha=1}this.drawLabel()},mouse.prototype.move=function(t){this.val={deltax:t.clientX/window.innerWidth-this.val.x,deltay:math.invert(t.clientY/window.innerHeight)-this.val.y,x:t.clientX/window.innerWidth,y:math.invert(t.clientY/window.innerHeight)},this.draw(),this.transmit(this.val)},mouse.prototype.customDestroy=function(){window.removeEventListener("mousemove",this.boundmove,!1)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),multislider=module.exports=function(t){this.defaultSize={width:100,height:75},widget.call(this,t),this.sliders=15,this.sliderClicked=0,this.oldSliderToMove,this.init()};util.inherits(multislider,widget),multislider.prototype.init=function(){this.val=new Array;for(var t=0;t<this.sliders;t++)this.val[t]=.7;this.realSpace={x:this.GUI.w,y:this.GUI.h},this.sliderWidth=this.realSpace.x/this.sliders,this.draw()},multislider.prototype.draw=function(){with(this.erase(),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),strokeStyle=this.colors.accent,fillStyle=this.colors.accent,lineWidth=5;for(var i=0;i<this.sliders;i++)beginPath(),moveTo(i*this.sliderWidth,this.GUI.h-this.val[i]*this.GUI.h),lineTo(i*this.sliderWidth+this.sliderWidth,this.GUI.h-this.val[i]*this.GUI.h),stroke(),lineTo(i*this.sliderWidth+this.sliderWidth,this.GUI.h),lineTo(i*this.sliderWidth,this.GUI.h),globalAlpha=.3-i%3*.1,fill(),closePath(),globalAlpha=1}this.drawLabel()},multislider.prototype.click=function(){this.oldSliderToMove=!1,this.move(!0)},multislider.prototype.move=function(t){if(this.clicked){if(this.clickPos.touches.length>1)for(var e=0;e<this.clickPos.touches.length;e++){var i=Math.floor(this.clickPos.touches[e].x/this.sliderWidth);i=math.clip(i,0,this.sliders-1),this.val[i]=math.clip(math.invert(this.clickPos.touches[e].y/this.GUI.h),0,1)}else{var i=Math.floor(this.clickPos.x/this.sliderWidth);if(i=math.clip(i,0,this.sliders-1),this.val[i]=math.clip(math.invert(this.clickPos.y/this.GUI.h),0,1),this.oldSliderToMove&&this.oldSliderToMove>i+1)for(var s=this.oldSliderToMove-i-1,e=1;e<=s;e++)this.val[i+e]=this.val[i]+(this.val[this.oldSliderToMove]-this.val[i])*(e/(s+1));else if(this.oldSliderToMove&&i>this.oldSliderToMove+1)for(var s=i-this.oldSliderToMove-1,e=1;e<=s;e++)this.val[this.oldSliderToMove+e]=this.val[this.oldSliderToMove]+(this.val[i]-this.val[this.oldSliderToMove])*(e/(s+1))}this.draw()}var n=new Object;if(n[i]=this.val[i],"js"==this.destination||"node"==this.destination)n.list=this.val;else{n.list=new String;for(var o in this.val)n.list+=this.val[o]+" "}this.transmit(n),this.oldSliderToMove=i},multislider.prototype.setNumberOfSliders=function(t){this.sliders=t,this.val=new Array;for(var e=0;e<this.sliders;e++)this.val.push(.7);this.sliderWidth=this.realSpace.x/this.sliders,this.init()},multislider.prototype.setSliderValue=function(t,e){this.val[t]=e,this.draw();var i=new Object;if(i[t]=this.val[t],"js"==this.destination||"node"==this.destination)i.list=this.val;else{i.list=new String;for(var s in this.val)i.list+=this.val[s]+" "}this.transmit(i)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),drawing=__webpack_require__(3),util=__webpack_require__(0),widget=__webpack_require__(1),multitouch=module.exports=function(t){this.defaultSize={width:200,height:200},widget.call(this,t),this.nodeSize=this.GUI.w/10,this.val={touch1:{x:0,y:0}},this.nodes=new Array,this.text="multitouch",this.rainbow=["#00f","#04f","#08F","0AF","0FF"],this.mode="normal",this.rows=10,this.cols=10,this.matrixLabels=!1,this.init()};util.inherits(multitouch,widget),multitouch.prototype.init=function(){this.nodeSize=this.GUI.w/10,this.draw()},multitouch.prototype.draw=function(){with(this.erase(),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h);var count=0;if("matrix"==this.mode)for(var j=0;j<this.rows;j++)for(var i=0;i<this.cols;i++)with(this.context){beginPath(),fillStyle=this.colors.accent,strokeStyle=this.colors.border,lineWidth=1;var circx=i*this.GUI.w/this.cols+this.GUI.w/this.cols/2,circy=j*this.GUI.h/this.rows+this.GUI.h/this.rows/2;arc(circx,circy,this.GUI.h/this.rows/2,0,2*Math.PI,!0),stroke(),fillStyle=this.colors.border,textAlign="center",textBaseline="middle",this.matrixLabels&&(fillText(this.matrixLabels[count%this.matrixLabels.length],circx,circy),count++);var thisarea={x:i*this.GUI.w/this.cols,y:j*this.GUI.h/this.rows,w:this.GUI.w/this.cols,h:this.GUI.h/this.rows};if(this.clickPos.touches.length>=1)for(var k=0;k<this.clickPos.touches.length;k++)drawing.isInside(this.clickPos.touches[k],thisarea)&&(globalAlpha=.5,fillStyle=this.colors.accent,fill(),globalAlpha=.3,fillStyle=this.rainbow[k],fill(),globalAlpha=1);closePath()}else if(this.clickPos.touches.length>=1){for(var i=0;i<this.clickPos.touches.length;i++)with(this.context)globalAlpha=.5,beginPath(),fillStyle=this.colors.accent,strokeStyle=this.colors.border,lineWidth=this.lineWidth,arc(this.clickPos.touches[i].x,this.clickPos.touches[i].y,this.nodeSize,0,2*Math.PI,!0),fill(),closePath(),globalAlpha=.3,beginPath(),fillStyle=this.rainbow[i],strokeStyle=this.colors.border,lineWidth=this.lineWidth,arc(this.clickPos.touches[i].x,this.clickPos.touches[i].y,this.nodeSize,0,2*Math.PI,!0),fill(),closePath(),globalAlpha=1;clearRect(0,this.GUI.h,this.GUI.w,this.height-this.GUI.h)}else this.setFont(),fillStyle=this.colors.border,fillText(this.text,this.GUI.w/2,this.GUI.h/2),globalAlpha=1}this.drawLabel()},multitouch.prototype.click=function(){this.draw(),this.sendit()},multitouch.prototype.move=function(){this.clicked&&(this.draw(),this.sendit())},multitouch.prototype.release=function(){if(!this.clicked){this.clickPos.touches=new Array;for(var t=0;t<5;t++)this.val["touch"+t]={x:0,y:0};this.transmit(this.val)}this.draw(),this.sendit()},multitouch.prototype.sendit=function(){this.val=new Object;for(var t=0;t<this.clickPos.touches.length;t++)this.val["touch"+t]={x:this.clickPos.touches[t].x/this.canvas.width,y:math.invert(this.clickPos.touches[t].y/this.canvas.height)};this.transmit(this.val)}},function(t,e,i){var s=i(2),n=i(0),o=i(1),r=t.exports=function(t){this.defaultSize={width:50,height:20},o.call(this,t),this.val={value:0},this.min=-2e4,this.max=2e4,this.step=1,this.rate=.25,this.decimalPlaces=3,this.lostdata=0,this.actual=0,this.canvas.ontouchstart=null,this.canvas.ontouchmove=null,this.canvas.ontouchend=null;var e='<input type="text" nx="number" id="'+this.canvasID+'" style="height:'+this.GUI.h+"px;width:"+this.GUI.w+"px;font-size:"+this.GUI.h/2+'px;"></input><canvas height="1px" width="1px" style="display:none"></canvas>',i=this.canvas,n=this.canvas.style,r=i.parentNode,a=document.createElement("span");a.innerHTML=e,a.className="nx",r.replaceChild(a,i),this.el=document.getElementById(this.canvasID);for(var h in n)"height"!=h&&"width"!=h&&(this.el.style[h]=n[h]);if(this.label){var l=document.createElement("div");l.innerHTML=this.label,l.style.fontSize=this.labelSize/2.8+"px",l.style.fontFamily=this.labelFont,l.style.textAlign=this.labelAlign,l.style.lineHeight=this.labelSize+"px",l.style.width=this.GUI.w+"px",l.style.color=nx.colors.black,l.className="nxlabel",a.appendChild(l)}this.canvas=document.getElementById(this.canvasID),this.canvas.style.height=this.GUI.h+"px",this.canvas.style.fontSize=.6*this.GUI.h+"px",this.canvas.style.textAlign="left",this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.highlight=this.colors.fill,this.canvas.style.border="none",this.canvas.style.outline="none",this.canvas.style.padding="4px 10px",this.canvas.style.cursor="pointer",this.canvas.style.display="block",this.canvas.className="",this.canvas.addEventListener("blur",function(){this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.color=this.colors.black,this.canvas.value!=this.val.value&&(this.actual=parseFloat(this.canvas.value),this.actual=s.clip(this.actual,this.min,this.max),this.actual=s.prune(this.actual,this.decimalPlaces),this.set({value:this.actual},!0))}.bind(this)),this.canvas.addEventListener("keydown",function(t){(t.which<48||t.which>57)&&189!=t.which&&190!=t.which&&8!=t.which&&t.preventDefault(),13==t.which&&this.canvas.blur()}.bind(this)),nx.isTouchDevice?(this.canvas.ontouchstart=this.preTouch,this.canvas.ontouchmove=this.preTouchMove,this.canvas.ontouchend=this.preTouchRelease):this.canvas.addEventListener("mousedown",this.preClick,!1),this.canvas.style.userSelect="none !important",this.canvas.style.mozUserSelect="none !important",this.canvas.style.webkitUserSelect="none !important",this.init()};n.inherits(r,o),r.prototype.init=function(){this.draw()},r.prototype.draw=function(){this.canvas.value=this.val.value},r.prototype.click=function(t){this.canvas.readOnly=!0,this.actual=this.val.value},r.prototype.move=function(t){this.clicked&&(this.canvas.style.border="none",this.actual-=this.deltaMove.y*(this.rate*this.step),this.actual=s.clip(this.actual,this.min,this.max),this.val.value=Math.floor(this.actual/this.step)*this.step,this.val.value=s.prune(this.val.value,this.decimalPlaces),this.draw(),this.transmit(this.val))},r.prototype.release=function(t){!this.hasMoved&&this.canvas.readOnly&&(this.canvas.readOnly=!1,this.canvas.focus(),this.canvas.setSelectionRange(0,this.canvas.value.length),this.canvas.style.backgroundColor=this.colors.accent,this.canvas.style.color=this.colors.fill)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),position=module.exports=function(t){this.defaultSize={width:150,height:100},widget.call(this,t),this.nodeSize=15,this.val={x:.5,y:.5},this.init()};util.inherits(position,widget),position.prototype.init=function(){this.nodeSize=Math.min(this.GUI.h,this.GUI.w)/10,this.nodeSize=Math.max(this.nodeSize,10),this.actualWid=this.GUI.w-2*this.nodeSize,this.actualHgt=this.GUI.h-2*this.nodeSize,this.draw()},position.prototype.draw=function(){with(this.erase(),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h);var drawingX=this.val.x*this.actualWid+this.nodeSize,drawingY=math.invert(this.val.y)*this.actualHgt+this.nodeSize;with(drawingX<this.nodeSize?drawingX=this.nodeSize:drawingX>this.GUI.w-this.nodeSize&&(drawingX=this.GUI.w-this.nodeSize),drawingY<this.nodeSize?drawingY=this.nodeSize:drawingY>this.GUI.h-this.nodeSize&&(drawingY=this.GUI.h-this.nodeSize),this.context)beginPath(),fillStyle=this.colors.accent,arc(drawingX,drawingY,this.nodeSize,0,2*Math.PI,!0),fill(),closePath(),this.clicked&&(beginPath(),fillStyle=this.colors.accent,arc(drawingX,drawingY,2*this.nodeSize,0,2*Math.PI,!0),fill(),closePath(),clearRect(0,this.GUI.h,this.GUI.w,this.height-this.GUI.h))}this.drawLabel()},position.prototype.click=function(){this.val.x=this.clickPos.x,this.val.y=this.clickPos.y,this.scaleNode(),this.val.state="click",this.transmit(this.val),this.draw()},position.prototype.move=function(){this.val.x=this.clickPos.x,this.val.y=this.clickPos.y,this.scaleNode(),this.val.state="move",this.transmit(this.val),this.draw()},position.prototype.release=function(){this.val.x=this.clickPos.x,this.val.y=this.clickPos.y,this.scaleNode(),this.val.state="release",this.transmit(this.val),this.draw()},position.prototype.scaleNode=function(){var t=this.val.x-this.nodeSize,e=this.val.y-this.nodeSize,i=math.clip(t/this.actualWid,0,1),s=math.clip(e/this.actualHgt,0,1);this.val.x=math.prune(i,3),this.val.y=math.prune(s,3),this.val.y=math.invert(this.val.y)},position.prototype.animate=function(t){switch(t){case"bounce":nx.aniItems.push(this.aniBounce.bind(this));break;case"none":nx.aniItems.splice(nx.aniItems.indexOf(this.aniBounce))}},position.prototype.aniBounce=function(){!this.clicked&&this.val.x&&(this.val.x+=this.deltaMove.x/2/this.GUI.w,this.val.y-=this.deltaMove.y/2/this.GUI.h,this.val.state="animated",math.bounce(this.val.x,0,1,this.deltaMove.x)!=this.deltaMove.x&&(this.deltaMove.x=math.bounce(this.val.x,0,1,this.deltaMove.x),this.val.state="bounce"),(this.val.y>=1||this.val.y<=0)&&(this.deltaMove.y=-1*math.bounce(this.val.y,0,1,this.deltaMove.y),this.val.state="bounce"),this.transmit(this.val),this.draw())},position.prototype.customDestroy=function(){nx.removeAni(this.aniBounce)}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),math=__webpack_require__(2),range=module.exports=function(t){this.defaultSize={width:110,height:35},widget.call(this,t),this.val={start:.3,stop:.7,size:.4},this.hslider=!1,this.handle,this.relhandle,this.cap,this.firsttouch="start",this.mode="area",this.touchdown=new Object,this.init()};util.inherits(range,widget),range.prototype.init=function(){this.GUI.h>=this.GUI.w?this.hslider=!1:this.hslider=!0,null!=this.canvas.getAttribute("label")&&(this.label=this.canvas.getAttribute("label")),this.draw()},range.prototype.draw=function(){with(this.erase(),this.context)if(fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),this.hslider){var x1=this.val.start*this.GUI.w,y1=0,x2=this.val.stop*this.GUI.w,y2=this.GUI.h;fillStyle=this.colors.accent,fillRect(x1,y1,x2-x1,y2-y1)}else{var x1=0,y1=this.GUI.h-this.val.stop*this.GUI.h,x2=this.GUI.w,y2=this.GUI.h-this.val.start*this.GUI.h;fillStyle=this.colors.accent,fillRect(x1,y1,x2-x1,y2-y1)}this.drawLabel()},range.prototype.click=function(){"edge"==this.mode?this.hslider?Math.abs(this.clickPos.x-this.val.start*this.GUI.w)<Math.abs(this.clickPos.x-this.val.stop*this.GUI.w)?this.firsttouch="start":this.firsttouch="stop":Math.abs(Math.abs(this.clickPos.y-this.GUI.h)-this.val.start*this.GUI.h)<Math.abs(Math.abs(this.clickPos.y-this.GUI.h)-this.val.stop*this.GUI.h)?this.firsttouch="start":this.firsttouch="stop":"area"==this.mode&&(this.touchdown={x:this.clickPos.x,y:this.clickPos.y},this.startval=new Object,this.startval.size=this.val.stop-this.val.start,this.startval.loc=this.val.start+this.startval.size/2),this.move()},range.prototype.move=function(){if("edge"==this.mode)this.hslider?"start"==this.firsttouch?(this.val.start=this.clickPos.x/this.GUI.w,this.clickPos.touches.length>1&&(this.val.stop=this.clickPos.touches[1].x/this.GUI.w)):(this.val.stop=this.clickPos.x/this.GUI.w,this.clickPos.touches.length>1&&(this.val.start=this.clickPos.touches[1].x/this.GUI.w)):"start"==this.firsttouch?(this.val.start=math.invert(this.clickPos.y/this.GUI.h),this.clickPos.touches.length>1&&(this.val.stop=math.invert(this.clickPos.touches[1].y/this.GUI.h))):(this.val.stop=math.invert(this.clickPos.y/this.GUI.h),this.clickPos.touches.length>1&&(this.val.start=math.invert(this.clickPos.touches[1].y/this.GUI.h))),this.val.stop<this.val.start&&(this.tempstart=this.val.start,this.val.start=this.val.stop,this.val.stop=this.tempstart,"start"==this.firsttouch?this.firsttouch="stop":this.firsttouch="start"),this.val={start:math.clip(this.val.start,0,1),stop:math.clip(this.val.stop,0,1)},this.val.size=math.prune(math.clip(Math.abs(this.val.stop-this.val.start),0,1),3),this.draw(),this.transmit(this.val);else if("area"==this.mode){if(this.hslider)var t=this.clickPos.x/this.GUI.w,e=(this.touchdown.y-this.clickPos.y)/this.GUI.h;else{var t=nx.invert(this.clickPos.y/this.GUI.h),e=(this.touchdown.x-this.clickPos.x)/this.GUI.w;e*=-1}e/=3;var i=this.startval.size+e;i=math.clip(i,.001,1),this.val={start:t-i/2,stop:t+i/2},this.val.start=math.clip(this.val.start,0,1),this.val.stop=math.clip(this.val.stop,0,1),this.draw(),this.transmit(this.val)}}},function(t,e,i){var s=i(0),n=i(1),o=t.exports=function(t){this.defaultSize={width:200,height:30},n.call(this,t),this.choices=[],this.val=new Object,this.canvas.ontouchstart=null,this.canvas.ontouchmove=null,this.canvas.ontouchend=null,this.canvas.getAttribute("choices")&&(this.choices=this.canvas.getAttribute("choices"),this.choices=this.choices.split(","));var e='<select id="'+this.canvasID+'" class="nx" nx="select" style="height:'+this.GUI.h+"px;width:"+this.GUI.w+'px;" onchange="'+this.canvasID+'.change(this)"></select><canvas height="1px" width="1px" style="display:none"></canvas>',i=this.canvas,s=this.canvas.style,o=i.parentNode,r=document.createElement("span");r.innerHTML=e,r.className="nx",o.replaceChild(r,i),this.sel=document.getElementById(this.canvasID);for(var a in s)this.sel.style[a]=s[a];this.canvas=document.getElementById(this.canvasID),this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.border="solid 2px "+this.colors.border,this.canvas.style.color=this.colors.black,this.canvas.style.fontSize=Math.round(this.GUI.h/2.3)+"px",this.canvas.className=""};s.inherits(o,n),o.prototype.init=function(){this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.border="solid 2px "+this.colors.border,this.canvas.style.color=this.colors.black;var t=this.canvas.options.length;for(e=0;e<t;e++)this.canvas.options[e]=null;for(var e=0;e<this.choices.length;e++){var i=document.createElement("option");i.text=this.choices[e],i.value=this.choices[e],this.canvas.add(i,null)}this.val.text=this.choices[0]},o.prototype.change=function(t){this.val.text=t.value,this.val.value=t.selectedIndex,this.transmit(this.val)},o.prototype.draw=function(){this.canvas.value=this.val.text,this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.color=this.colors.black,this.canvas.style.border="solid 2px "+this.colors.border}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),slider=module.exports=function(t){this.defaultSize={width:35,height:110},widget.call(this,t),null!=this.canvas.getAttribute("min")?this.min=parseFloat(this.canvas.getAttribute("min")):this.min=0,null!=this.canvas.getAttribute("max")?this.max=parseFloat(this.canvas.getAttribute("max")):this.max=1,null!=this.canvas.getAttribute("step")?this.step=parseFloat(this.canvas.getAttribute("step")):this.step=.001,this.val.value=nx.scale(.7,0,1,this.min,this.max),this.mode="absolute",this.hslider=!1,this.handle,this.relhandle,this.cap,this.maxdigits=3,this.calculateDigits=nx.calculateDigits,this.init()};util.inherits(slider,widget),slider.prototype.init=function(){this.GUI.h>=this.GUI.w?this.hslider=!1:this.hslider=!0,this.draw()},slider.prototype.draw=function(){var normalval=this.normalize(this.val.value);with(this.digits=this.calculateDigits(),this.erase(),this.context){if(fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),this.hslider){var x1=0,y1=0,x2=normalval*this.GUI.w,y2=this.GUI.h;fillStyle=this.colors.accent,fillRect(x1,y1,x2-x1,y2-y1);var valtextsize=this.GUI.h/2;if(valtextsize>6){if(x2>this.digits.total*valtextsize/2){fillStyle=this.colors.white;var textx=5}else{fillStyle=this.colors.accent;var textx=x2+5}var texty=this.GUI.h/2,valtextAlign="left",valtextBaseline="middle"}}else{var x1=0,y1=this.GUI.h-normalval*this.GUI.h,x2=this.GUI.w,y2=this.GUI.h;fillStyle=this.colors.accent,fillRect(x1,y1,x2-x1,y2-y1);var valtextsize=this.GUI.w/this.digits.total*1.2;if(valtextsize>6){if(y1<this.GUI.h-valtextsize/2-5){fillStyle=this.colors.white;var texty=this.GUI.h-valtextsize/2-5}else{fillStyle=this.colors.accent;var texty=y1-valtextsize/2-5}var textx=this.GUI.w/2,valtextAlign="center",valtextBaseline="middle"}}var valtext=this.val.value.toFixed(this.digits.decimals);textBaseline=valtextBaseline,textAlign=valtextAlign,font=valtextsize+"px 'Open Sans'",fillText(valtext,textx,texty),this.label&&this.drawLabel()}},slider.prototype.click=function(){this.move()},slider.prototype.move=function(){var t=this.normalize(this.val.value);this.hslider?(this.handle=this.clickPos.x,this.relhandle=this.deltaMove.x,this.cap=this.GUI.w):(this.handle=this.clickPos.y,this.relhandle=-1*this.deltaMove.y,this.cap=this.GUI.h),"absolute"==this.mode?this.clicked&&(t=this.hslider?math.clip(this.clickPos.x/this.GUI.w,0,1):Math.abs(math.clip(this.clickPos.y/this.GUI.h,0,1)-1),this.draw()):"relative"==this.mode&&this.clicked&&(t=this.hslider?math.clip(t+this.deltaMove.x/this.GUI.w,0,1):math.clip(t+-1*this.deltaMove.y/this.GUI.h,0,1),this.draw()),this.val.value=math.prune(this.rangify(t),3),this.transmit(this.val)}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),string=module.exports=function(t){this.defaultSize={width:150,height:75},widget.call(this,t),this.val={string:0,x:0},this.numberOfStrings=10,this.strings=new Array,this.abovestring=new Array,this.friction=1;this.init(),nx.aniItems.push(this.draw.bind(this))};util.inherits(string,widget),string.prototype.init=function(){stringdiv=this.GUI.h/(this.numberOfStrings+1);for(var t=0;t<this.numberOfStrings;t++)this.strings[t]={x1:this.lineWidth,y1:stringdiv*(1+t),x2:this.GUI.w-this.lineWidth,y2:stringdiv*(t+1),held:!1,vibrating:!1,force:0,maxstretch:0,stretch:0,direction:0,above:!1};this.draw()},string.prototype.pulse=function(){this.draw()},string.prototype.setStrings=function(t){this.numberOfStrings=t,this.strings=new Array,this.init()},string.prototype.draw=function(){with(this.erase(),this.context){strokeStyle=this.colors.border,fillStyle=this.colors.fill,lineWidth=this.lineWidth,fillRect(0,0,this.GUI.w,this.GUI.h),strokeStyle=this.colors.accent;for(var i=0;i<this.strings.length;i++){var st=this.strings[i];st.vibrating?(st.maxstretch<0&&(st.vibrating=!1,st.held=!1),st.stretch=st.stretch+st.direction,Math.abs(st.stretch)>st.maxstretch&&(st.direction*=-1,st.stretch=st.stretch+st.direction,st.maxstretch=st.maxstretch-this.friction,st.direction=st.direction/Math.abs(st.direction)*(st.maxstretch/1)),beginPath(),moveTo(st.x1,st.y1),quadraticCurveTo(this.GUI.w/2,st.y1+st.stretch,st.x2,st.y2),stroke(),closePath(),st.on=!0):st.held?(beginPath(),moveTo(st.x1,st.y1),quadraticCurveTo(this.clickPos.x,this.clickPos.y,st.x2,st.y2),stroke(),closePath(),st.on=!0):(beginPath(),moveTo(st.x1,st.y1),lineTo(st.x2,st.y2),stroke(),closePath(),st.on&&(st.on=!1))}}this.drawLabel()},string.prototype.click=function(){for(var t=0;t<this.numberOfStrings;t++)this.strings[t].above=this.clickPos.y<this.strings[t].y1;this.draw()},string.prototype.move=function(){if(this.clicked)for(var t=0;t<this.strings.length;t++)this.strings[t].above!=this.clickPos.y<this.strings[t].y1&&(this.strings[t].held=!0,this.strings[t].above^=!0),this.strings[t].held&&Math.abs(this.clickPos.y-this.strings[t].y1)>this.GUI.h/(3*this.strings.length)&&this.pluck(t)},string.prototype.release=function(){for(var t=0;t<this.strings.length;t++)this.strings[t].held&&this.pluck(t)},string.prototype.pluck=function(t){var e=t;this.val={string:e,x:this.clickPos.x/this.GUI.w},this.transmit(this.val),this.strings[e].held=!1,this.strings[e].force=this.clickPos.y-this.strings[e].y1,this.strings[e].maxstretch=Math.abs(this.clickPos.y-this.strings[e].y1),this.strings[e].stretch=this.clickPos.y-this.strings[e].y1,this.strings[e].vibrating=!0,this.strings[e].direction=(this.clickPos.y-this.strings[e].y1)/Math.abs(this.clickPos.y-this.strings[e].y1)*((this.clickPos.y-this.strings[e].y1)/-1.2)},string.prototype.customDestroy=function(){nx.removeAni(this.draw.bind(this))}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),tabs=module.exports=function(t){this.defaultSize={width:150,height:50},widget.call(this,t),this.choice=0,this.val={index:0,text:""},this.tabwid=0,this.options=["one","two","three"],this.init()};util.inherits(tabs,widget),tabs.prototype.init=function(){this.draw()},tabs.prototype.draw=function(){with(this.context)fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),textAlign="center",textBaseline="middle",font="normal "+this.GUI.h/5+"px courier";this.tabwid=this.GUI.w/this.options.length;for(var i=0;i<this.options.length;i++){if(i==this.choice)var tabcol=this.colors.accent,textcol=this.colors.white;else{var tabcol=this.colors.fill,textcol=this.colors.black;globalAlpha=.7}with(this.context)fillStyle=tabcol,fillRect(this.tabwid*i,0,this.tabwid,this.GUI.h),i!=this.options.length-1&&(beginPath(),moveTo(this.tabwid*(i+1),0),lineTo(this.tabwid*(i+1),this.GUI.h),lineWidth=1,strokeStyle=this.colors.border,stroke(),closePath()),fillStyle=textcol,font=this.fontSize+"px "+this.font,fillText(this.options[i],this.tabwid*i+this.tabwid/2,this.GUI.h/2)}},tabs.prototype.click=function(){this.choice=~~(this.clickPos.x/this.tabwid),this.val={index:this.choice,text:this.options[this.choice]},this.transmit(this.val),this.draw()}},function(t,e,i){var s=i(0),n=i(1),o=t.exports=function(t){this.defaultSize={width:200,height:100},n.call(this,t),this.val={text:""};var e='<textarea id="'+this.canvasID+'" style="height:'+this.GUI.h+"px;width:"+this.GUI.w+'px;" onkeydown="'+this.canvasID+'.change(event,this)"></textarea><canvas height="1px" width="1px" style="display:none"></canvas>',i=this.canvas,s=this.canvas.style,o=i.parentNode,r=document.createElement("span");r.innerHTML=e,r.className="nx",o.replaceChild(r,i),this.el=document.getElementById(this.canvasID);for(var a in s)this.el.style[a]=s[a];this.el.style.display="block",this.el.style.backgroundColor=this.colors.fill,this.el.style.border="none",this.el.style.color=this.colors.black,this.el.style.outline="none",this.el.style.resize="none",this.el.style.boxSizing="border-box",this.el.style.padding="5px",this.el.style.fontFamily=nx.font,this.el.style.fontSize="16px",this.el.className="",this.canvas=document.getElementById(this.canvasID)};s.inherits(o,n),o.prototype.init=function(){this.canvas.ontouchstart=null,this.canvas.ontouchmove=null,this.canvas.ontouchend=null,this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.color=this.colors.black},o.prototype.change=function(t,e){this.val.text=e.value,"13"==t.which&&(this.transmit(this.val),this.val.text="",this.draw(),t.preventDefault())},o.prototype.draw=function(){this.el.value=this.val.text,this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.color=this.colors.black}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),tilt=module.exports=function(t){this.defaultSize={width:50,height:50},widget.call(this,t),this.tiltLR,this.tiltFB,this.z,this.active=!0,this.val={x:0,y:0,z:0},this.text="TILT",this.init(),this.boundChromeTilt=this.chromeTilt.bind(this),this.boundMozTilt=this.mozTilt.bind(this),window.DeviceOrientationEvent?window.addEventListener("deviceorientation",this.boundChromeTilt,!1):window.OrientationEvent?window.addEventListener("MozOrientation",this.boundMozTilt,!1):console.log("Not supported on your device or browser.")};util.inherits(tilt,widget),tilt.prototype.deviceOrientationHandler=function(){this.val={x:math.prune(this.tiltLR/90,3),y:math.prune(this.tiltFB/90,3),z:math.prune(this.z,3)},this.active&&this.transmit(this.val)},tilt.prototype.chromeTilt=function(t){this.tiltLR=t.gamma,this.tiltFB=t.beta,this.z=t.alpha,this.deviceOrientationHandler(),this.draw()},tilt.prototype.mozTilt=function(t){this.tiltLR=90*t.x,this.tiltFB=-90*t.y,this.z=t.z,this.deviceOrientationHandler(),this.draw()},tilt.prototype.init=function(){this.draw()},tilt.prototype.draw=function(){with(this.erase(),this.context)fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),save(),translate(this.GUI.w/2,this.GUI.h/2),rotate(-this.val.x*Math.PI/2),translate(-this.GUI.w/2,-this.GUI.h/2),globalAlpha=.4,this.active?fillStyle=this.colors.accent:fillStyle=this.colors.border,fillRect(-this.GUI.w,this.GUI.h*(this.val.y/2)+this.GUI.h/2,3*this.GUI.w,2*this.GUI.h),font="bold "+this.GUI.h/5+"px "+this.font,textAlign="center",textBaseline="middle",fillText(this.text,this.GUI.w/2,this.GUI.h*(this.val.y/2)+this.GUI.h/2-this.GUI.h/15),globalAlpha=1,restore(),clearRect(0,this.GUI.h,this.GUI.w,this.height-this.GUI.h);this.drawLabel()},tilt.prototype.click=function(){this.active=!this.active},tilt.prototype.customDestroy=function(){this.active=!1,window.removeEventListener("deviceorientation",this.boundChromeTilt,!1),window.removeEventListener("mozOrientation",this.boundMozTilt,!1)}},function(module,exports,__webpack_require__){var drawing=__webpack_require__(3),util=__webpack_require__(0),widget=__webpack_require__(1),toggle=module.exports=function(t){this.defaultSize={width:50,height:50},widget.call(this,t),this.val={value:0},this.init()};util.inherits(toggle,widget),toggle.prototype.init=function(){this.draw()},toggle.prototype.draw=function(){with(this.erase(),this.context)this.val.value?(fillStyle=this.colors.accent,strokeStyle=this.colors.accenthl,strokeAlpha=1):(fillStyle=this.colors.fill,strokeStyle=this.colors.border,strokeAlpha=1),lineWidth=Math.sqrt(this.GUI.w)/2,fillRect(0,0,this.GUI.w,this.GUI.h),globalAlpha=strokeAlpha,strokeRect(lineWidth/2,lineWidth/2,this.GUI.w-lineWidth,this.GUI.h-lineWidth),globalAlpha=1;this.drawLabel()},toggle.prototype.click=function(){this.val.value?this.val.value=0:this.val.value=1,this.draw(),this.transmit(this.val)}},function(module,exports,__webpack_require__){var drawing=__webpack_require__(3),util=__webpack_require__(0),widget=__webpack_require__(1),typewriter=module.exports=function(t){this.defaultSize={width:300,height:100},widget.call(this,t),this.letter="",this.keywid=this.GUI.w/14.5,this.keyhgt=this.GUI.h/5,this.active=!0,this.val={key:"",ascii:0,on:0},this.rows=[[{symbol:"`",value:192,width:1,on:!1},{symbol:"1",value:49,width:1,on:!1},{symbol:"2",value:50,width:1,on:!1},{symbol:"3",value:51,width:1,on:!1},{symbol:"4",value:52,width:1,on:!1},{symbol:"5",value:53,width:1,on:!1},{symbol:"6",value:54,width:1,on:!1},{symbol:"7",value:55,width:1,on:!1},{symbol:"8",value:56,width:1,on:!1},{symbol:"9",value:57,width:1,on:!1},{symbol:"0",value:48,width:1,on:!1},{symbol:"-",value:189,width:1,on:!1},{symbol:"=",value:187,width:1,on:!1},{symbol:"delete",value:46,width:1.5,on:!1}],[{symbol:"tab",value:9,width:1.5,on:!1},{symbol:"q",value:81,width:1,on:!1},{symbol:"w",value:87,width:1,on:!1},{symbol:"e",value:69,width:1,on:!1},{symbol:"r",value:82,width:1,on:!1},{symbol:"t",value:84,width:1,on:!1},{symbol:"y",value:89,width:1,on:!1},{symbol:"u",value:85,width:1,on:!1},{symbol:"i",value:73,width:1,on:!1},{symbol:"o",value:79,width:1,on:!1},{symbol:"p",value:80,width:1,on:!1},{symbol:"[",value:219,width:1,on:!1},{symbol:"]",value:221,width:1,on:!1},{symbol:"\\",value:220,width:1,on:!1}],[{symbol:"caps",value:20,width:1.75,on:!1},{symbol:"a",value:65,width:1,on:!1},{symbol:"s",value:83,width:1,on:!1},{symbol:"d",value:68,width:1,on:!1},{symbol:"f",value:70,width:1,on:!1},{symbol:"g",value:71,width:1,on:!1},{symbol:"h",value:72,width:1,on:!1},{symbol:"j",value:74,width:1,on:!1},{symbol:"k",value:75,width:1,on:!1},{symbol:"l",value:76,width:1,on:!1},{symbol:";",value:186,width:1,on:!1},{symbol:"'",value:222,width:1,on:!1},{symbol:"enter",value:13,width:1.75,on:!1}],[{symbol:"shift",value:16,width:2.25,on:!1},{symbol:"z",value:90,width:1,on:!1},{symbol:"x",value:88,width:1,on:!1},{symbol:"c",value:67,width:1,on:!1},{symbol:"v",value:86,width:1,on:!1},{symbol:"b",value:66,width:1,on:!1},{symbol:"n",value:78,width:1,on:!1},{symbol:"m",value:77,width:1,on:!1},{symbol:",",value:188,width:1,on:!1},{symbol:".",value:190,width:1,on:!1},{symbol:"/",value:191,width:1,on:!1},{symbol:"shift",value:16,width:2.25,on:!1}],[{symbol:"fn",value:10,width:1,on:!1},{symbol:"ctrl",value:17,width:1,on:!1},{symbol:"opt",value:10,width:1,on:!1},{symbol:"cmd",value:10,width:1.25,on:!1},{symbol:"space",value:32,width:5,on:!1},{symbol:"cmd",value:10,width:1,on:!1},{symbol:"opt",value:10,width:1,on:!1},{symbol:"left",value:37,width:.81,on:!1},{symbol:"up",value:38,width:.81,on:!1},{symbol:"down",value:40,width:.81,on:!1},{symbol:"right",value:39,width:.81,on:!1}]],this.boundType=this.typekey.bind(this),this.boundUntype=this.untype.bind(this),window.addEventListener("keydown",this.boundType),window.addEventListener("keyup",this.boundUntype),this.init()};util.inherits(typewriter,widget),typewriter.prototype.init=function(){this.keywid=this.GUI.w/14.5,this.keyhgt=this.GUI.h/5,this.draw()},typewriter.prototype.draw=function(){with(this.erase(),this.active?this.context.globalAlpha=1:this.context.globalAlpha=.4,this.context){strokeStyle=this.colors.borderhl,fillStyle=this.colors.accent,lineWidth=1;for(var i=0;i<this.rows.length;i++)for(var currkeyL=0,j=0;j<this.rows[i].length;j++)this.val.key==this.rows[i][j].symbol&&(this.val.on?this.rows[i][j].on=!0:this.rows[i][j].on=!1),drawing.makeRoundRect(this.context,currkeyL,i*this.keyhgt,this.keywid*this.rows[i][j].width,this.keyhgt,4),this.rows[i][j].on?(fillStyle=this.colors.accent,strokeStyle=this.colors.accent,fill(),stroke()):(fillStyle=this.colors.fill,strokeStyle=this.colors.borderhl,fill(),stroke()),currkeyL+=this.keywid*this.rows[i][j].width;this.val.on&&(this.setFont(),fillStyle=this.colors.borderhl,font=this.GUI.h+"px "+this.font,fillText(this.val.key,this.GUI.w/2,this.GUI.h/2),globalAlpha=1),this.active||(globalAlpha=.7,fillStyle=this.colors.borderhl,font=this.GUI.h/2+"px courier",textAlign="center",textBaseline="middle",fillText("inactive",this.GUI.w/2,this.GUI.h/2))}this.drawLabel()},typewriter.prototype.click=function(t){this.active=!this.active,this.draw()},typewriter.prototype.typekey=function(t){if(this.active){for(var e=t.which,i=0;i<this.rows.length;i++)for(var s=0;s<this.rows[i].length;s++)if(e==this.rows[i][s].value){this.val.key=this.rows[i][s].symbol,this.val.on=1,this.val.ascii=t.which,this.transmit(this.val);break}this.draw()}},typewriter.prototype.untype=function(t){if(this.active){for(var e=t.which,i=0;i<this.rows.length;i++)for(var s=0;s<this.rows[i].length;s++)if(e==this.rows[i][s].value){this.val.key=this.rows[i][s].symbol,this.val.on=0,this.val.ascii=t.which,this.transmit(this.val);break}this.draw()}},typewriter.prototype.customDestroy=function(){window.removeEventListener("keydown",this.boundType),window.removeEventListener("keyup",this.boundUntype)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),vinyl=module.exports=function(t){this.defaultSize={width:100,height:100},widget.call(this,t),this.circleSize,this.speed=.05,this.defaultspeed=.05,this.rotation=0,this.hasMovedOnce=!1,this.lockResize=!0,this.val={speed:0},this.init(),nx.aniItems.push(this.spin.bind(this))};util.inherits(vinyl,widget),vinyl.prototype.init=function(){this.circleSize=Math.min(this.center.x,this.center.y)-this.lineWidth,this.draw()},vinyl.prototype.draw=function(){with(this.erase(),this.context)strokeStyle=this.colors.border,fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),beginPath(),fillStyle=this.colors.black,arc(this.center.x,this.center.y,this.circleSize-5,0,2*Math.PI,!0),fill(),closePath(),beginPath(),fillStyle=this.colors.accent,arc(this.center.x,1*this.center.y,this.circleSize/4,0,2*Math.PI,!1),fill(),closePath(),beginPath(),globalAlpha=.5,fillStyle=this.colors.fill,arc(this.center.x,this.center.y,this.circleSize,this.rotation,this.rotation+.4,!1),lineTo(this.center.x,this.center.y),arc(this.center.x,this.center.y,this.circleSize,this.rotation+Math.PI,this.rotation+Math.PI+.4,!1),lineTo(this.center.x,this.center.y),fill(),globalAlpha=1,closePath(),beginPath(),fillStyle=this.colors.white,arc(this.center.x,1*this.center.y,this.circleSize/16,0,2*Math.PI,!1),fill(),closePath();this.drawLabel()},vinyl.prototype.click=function(t){this.hasMovedOnce=!1,this.lastRotation=this.rotation,this.grabAngle=this.rotation%(2*Math.PI),this.grabPos=math.toPolar(this.clickPos.x-this.center.x,this.clickPos.y-this.center.y).angle},vinyl.prototype.move=function(){this.hasMovedOnce||(this.hasMovedOnce=!0,this.grabAngle=this.rotation%(2*Math.PI),this.grabPos=math.toPolar(this.clickPos.x-this.center.x,this.clickPos.y-this.center.y).angle),this.rotation=math.toPolar(this.clickPos.x-this.center.x,this.clickPos.y-this.center.y).angle+this.grabAngle-this.grabPos},vinyl.prototype.release=function(){this.speed=(this.rotation-this.lastRotation+(this.lastRotation-this.lastRotation2))/2},vinyl.prototype.spin=function(){this.clicked?this.speed/=1.1:this.speed=.9*this.speed+.1*this.defaultspeed,this.val.speed=20*(this.rotation-this.lastRotation),this.lastRotation2=this.lastRotation,this.lastRotation=this.rotation,this.rotation+=this.speed,this.draw(),this.transmit(this.val)},vinyl.prototype.customDestroy=function(){nx.removeAni(this.spin.bind(this))}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),math=__webpack_require__(2),waveform=module.exports=function(t){this.defaultSize={width:400,height:125},widget.call(this,t),this.val={start:0,stop:0,size:0,starttime:0,stoptime:0,looptime:0},this.handle,this.relhandle,this.cap,this.firsttouch="start",this.buffer=[],nx.isMobile?this.definition=3:this.definition=1,this.pieces=!1,this.channels=1,this.rawbuffer=[],this.times=[{dur:10,format:1},{dur:50,format:1},{dur:100,format:1},{dur:200,format:1},{dur:500,format:1},{dur:1e3,format:1},{dur:2e3,format:1},{dur:5e3,format:1},{dur:1e4,format:3},{dur:15e3,format:3},{dur:6e4,format:3},{dur:12e4,format:3},{dur:3e5,format:3},{dur:6e5,format:3}],this.timescale=!1,this.mode="area",this.touchdown=new Object,this.init()};util.inherits(waveform,widget),waveform.prototype.init=function(){this.pieces=~~(this.GUI.w/this.definition),this.draw()},waveform.prototype.setBuffer=function(t){for(this.channels=t.numberOfChannels,this.duration=t.duration,this.sampleRate=t.sampleRate,this.waveHeight=this.GUI.h/this.channels,this.durationMS=1e3*this.duration,this.timescale=0;~~(this.durationMS/this.times[this.timescale].dur)>7&&this.timescale<this.times.length;)this.timescale++;this.timescale=this.times[this.timescale],this.rawbuffer=[],this.buffer=[];for(var e=0;e<this.channels;e++){this.rawbuffer.push(t.getChannelData(0)),this.buffer.push([]);for(var i=1+~~(this.rawbuffer[0].length/(5*this.sampleRate)),s=~~(this.rawbuffer[e].length/this.pieces),n=0,o=0,r=0,a=0;a<this.rawbuffer[e].length;a+=i)this.rawbuffer[e][a]>0?n=Math.max(n,this.rawbuffer[e][a]):o=Math.min(o,this.rawbuffer[e][a]),a>r*s&&(this.buffer[e].push([n,o]),r++,o=0,n=0)}this.val.start&&this.val.stop,this.val.starttime=Math.round(this.val.start*this.durationMS),this.val.stoptime=Math.round(this.val.stop*this.durationMS),this.val.looptime=Math.round(this.val.size*this.durationMS),this.draw()},waveform.prototype.select=function(t,e){this.val.start=math.clip(t/this.durationMS,0,1),this.val.stop=math.clip(e/this.durationMS,0,1),this.val.size=this.val.stop-this.val.start,this.val.starttime=t,this.val.stoptime=e,this.val.looptime=t-e,this.transmit(this.val),this.draw()},waveform.prototype.draw=function(){with(this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h);for(var i=0;i<this.buffer.length;i++){fillStyle=this.colors.black,this.waveTop=i*this.waveHeight,this.waveCenter=this.waveTop+this.waveHeight/2;for(var j=0;j<this.buffer[i].length;j++){var ht1=this.waveCenter-this.buffer[i][j][0]*this.waveHeight,ht2=this.waveCenter+Math.abs(this.buffer[i][j][1]*this.waveHeight);ht2-=ht1,fillRect(j*this.definition,ht1,this.definition,ht2)}this.buffer[i]}if(globalAlpha=.3,fillStyle=this.colors.border,fillRect(0,0,this.GUI.w,16),globalAlpha=1,textBaseline="middle",textAlign="left",fontSize="8px",this.timescale)for(var i=1;i<this.durationMS/this.timescale.dur;i++){var x=i*this.timescale.dur/this.durationMS;x*=this.GUI.w,fillStyle=this.colors.border,fillRect(x,0,1,this.GUI.h),fillStyle=this.colors.black,globalAlpha=.6,fillText(this.msToTime(i*this.timescale.dur,this.timescale.format),x+5,8),globalAlpha=1}var x1=this.val.start*this.GUI.w,y1=0,x2=this.val.stop*this.GUI.w,y2=this.GUI.h;if(fillStyle=this.colors.accent,strokeStyle=this.colors.accent,lineWidth=2,globalAlpha=.3,fillRect(x1,0,x2-x1,y2-0),globalAlpha=.7,strokeRect(x1,-2,x2-x1,y2-0+4),this.durationMS&&this.val.looptime){this.val.size=this.val.stop-this.val.start,textAlign="center";var dur=this.val.looptime;dur>1e3?(dur/=1e3,math.prune(dur,2),dur+=" s"):(math.prune(dur,0),dur+=" ms"),fillText(dur,x1+(x2-x1)/2,this.GUI.h/2)}globalAlpha=1}},waveform.prototype.msToTime=function(t,e){var e=e||2,i=~~(t/1e3),s=i%60;i=(i-s)/60;var n=i%60,o=t%1e3;return s=s<10&&n?s+"0":s,1==e?s+"."+o:2==e?n+":"+s+"."+o:3==e?n+":"+s:void 0},waveform.prototype.click=function(){"edge"==this.mode?Math.abs(this.clickPos.x-this.val.start*this.GUI.w)<Math.abs(this.clickPos.x-this.val.stop*this.GUI.w)?this.firsttouch="start":this.firsttouch="stop":"area"==this.mode&&(this.touchdown={x:this.clickPos.x,y:this.clickPos.y},this.startval=new Object,this.startval.size=this.val.stop-this.val.start,this.startval.loc=this.val.start+this.startval.size/2),this.move()},waveform.prototype.move=function(){if("edge"==this.mode)"start"==this.firsttouch?(this.val.start=this.clickPos.x/this.GUI.w,this.clickPos.touches.length>1&&(this.val.stop=this.clickPos.touches[1].x/this.GUI.w)):(this.val.stop=this.clickPos.x/this.GUI.w,this.clickPos.touches.length>1&&(this.val.start=this.clickPos.touches[1].x/this.GUI.w)),this.val.stop<this.val.start&&(this.tempstart=this.val.start,this.val.start=this.val.stop,this.val.stop=this.tempstart,"start"==this.firsttouch?this.firsttouch="stop":this.firsttouch="start");else if("area"==this.mode){var t=this.clickPos.x/this.GUI.w,e=(this.touchdown.y-this.clickPos.y)/this.GUI.h;e/=4;var i=this.startval.size+e;i=math.clip(i,.001,1),this.val={start:t-i/2,stop:t+i/2}}this.val.start=math.clip(this.val.start,0,1),this.val.stop=math.clip(this.val.stop,0,1),this.val.size=math.clip(Math.abs(this.val.stop-this.val.start),0,1),this.durationMS&&(this.val.starttime=Math.round(this.val.start*this.durationMS),this.val.stoptime=Math.round(this.val.stop*this.durationMS),this.val.looptime=Math.round(this.val.size*this.durationMS)),this.transmit(this.val),this.draw()}},function(t,e){function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function n(t){if(c===setTimeout)return setTimeout(t,0);if((c===i||!c)&&setTimeout)return c=setTimeout,setTimeout(t,0);try{return c(t,0)}catch(e){try{return c.call(null,t,0)}catch(e){return c.call(this,t,0)}}}function o(t){if(u===clearTimeout)return clearTimeout(t);if((u===s||!u)&&clearTimeout)return u=clearTimeout,clearTimeout(t);try{return u(t)}catch(e){try{return u.call(null,t)}catch(e){return u.call(this,t)}}}function r(){y&&d&&(y=!1,d.length?f=d.concat(f):_=-1,f.length&&a())}function a(){if(!y){var t=n(r);y=!0;for(var e=f.length;e;){for(d=f,f=[];++_<e;)d&&d[_].run();_=-1,e=f.length}d=null,y=!1,o(t)}}function h(t,e){this.fun=t,this.array=e}function l(){}var c,u,p=t.exports={};!function(){try{c="function"==typeof setTimeout?setTimeout:i}catch(t){c=i}try{u="function"==typeof clearTimeout?clearTimeout:s}catch(t){u=s}}();var d,f=[],y=!1,_=-1;p.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];f.push(new h(t,e)),1!==f.length||y||n(a)},h.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=l,p.addListener=l,p.once=l,p.off=l,p.removeListener=l,p.removeAllListeners=l,p.emit=l,p.binding=function(t){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(t){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e,i){var s;!function(){function n(t,e,i){return t.call.apply(t.bind,arguments)}function o(t,e,i){if(!t)throw Error();if(2<arguments.length){var s=Array.prototype.slice.call(arguments,2);return function(){var i=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(i,s),t.apply(e,i)}}return function(){return t.apply(e,arguments)}}function r(t,e,i){return r=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?n:o,r.apply(null,arguments)}function a(t,e){this.a=t,this.m=e||t,this.c=this.m.document}function h(t,e,i,s){if(e=t.c.createElement(e),i)for(var n in i)i.hasOwnProperty(n)&&("style"==n?e.style.cssText=i[n]:e.setAttribute(n,i[n]));return s&&e.appendChild(t.c.createTextNode(s)),e}function l(t,e,i){t=t.c.getElementsByTagName(e)[0],t||(t=document.documentElement),t.insertBefore(i,t.lastChild)}function c(t){t.parentNode&&t.parentNode.removeChild(t)}function u(t,e,i){e=e||[],i=i||[];for(var s=t.className.split(/\s+/),n=0;n<e.length;n+=1){for(var o=!1,r=0;r<s.length;r+=1)if(e[n]===s[r]){o=!0;break}o||s.push(e[n])}for(e=[],n=0;n<s.length;n+=1){for(o=!1,r=0;r<i.length;r+=1)if(s[n]===i[r]){o=!0;break}o||e.push(s[n])}t.className=e.join(" ").replace(/\s+/g," ").replace(/^\s+|\s+$/,"")}function p(t,e){for(var i=t.className.split(/\s+/),s=0,n=i.length;s<n;s++)if(i[s]==e)return!0;return!1}function d(t){if("string"==typeof t.f)return t.f;var e=t.m.location.protocol;return"about:"==e&&(e=t.a.location.protocol),"https:"==e?"https:":"http:"}function f(t){return t.m.location.hostname||t.a.location.hostname}function y(t,e,i){function s(){a&&n&&o&&(a(r),a=null)}e=h(t,"link",{rel:"stylesheet",href:e,media:"all"});var n=!1,o=!0,r=null,a=i||null;at?(e.onload=function(){n=!0,s()},e.onerror=function(){n=!0,r=Error("Stylesheet failed to load"),s()}):setTimeout(function(){n=!0,s()},0),l(t,"head",e)}function _(t,e,i,s){var n=t.c.getElementsByTagName("head")[0];if(n){var o=h(t,"script",{src:e}),r=!1;return o.onload=o.onreadystatechange=function(){r||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(r=!0,i&&i(null),o.onload=o.onreadystatechange=null,"HEAD"==o.parentNode.tagName&&n.removeChild(o))},n.appendChild(o),setTimeout(function(){r||(r=!0,i&&i(Error("Script load timeout")))},s||5e3),o}return null}function m(){this.a=0,this.c=null}function v(t){return t.a++,function(){t.a--,w(t)}}function g(t,e){t.c=e,w(t)}function w(t){0==t.a&&t.c&&(t.c(),t.c=null)}function b(t){this.a=t||"-"}function x(t,e){this.c=t,this.f=4,this.a="n";var i=(e||"n4").match(/^([nio])([1-9])$/i);i&&(this.a=i[1],this.f=parseInt(i[2],10))}function S(t){return P(t)+" "+t.f+"00 300px "+T(t.c)}function T(t){var e=[];t=t.split(/,\s*/);for(var i=0;i<t.length;i++){var s=t[i].replace(/['"]/g,"");-1!=s.indexOf(" ")||/^\d/.test(s)?e.push("'"+s+"'"):e.push(s)}return e.join(",")}function k(t){return t.a+t.f}function P(t){var e="normal";return"o"===t.a?e="oblique":"i"===t.a&&(e="italic"),e}function O(t){var e=4,i="n",s=null;return t&&((s=t.match(/(normal|oblique|italic)/i))&&s[1]&&(i=s[1].substr(0,1).toLowerCase()),(s=t.match(/([1-9]00|normal|bold)/i))&&s[1]&&(/bold/i.test(s[1])?e=7:/[1-9]00/.test(s[1])&&(e=parseInt(s[1].substr(0,1),10)))),i+e}function A(t,e){this.c=t,this.f=t.m.document.documentElement,this.h=e,this.a=new b("-"),this.j=!1!==e.events,this.g=!1!==e.classes}function M(t){t.g&&u(t.f,[t.a.c("wf","loading")]),q(t,"loading")}function I(t){if(t.g){var e=p(t.f,t.a.c("wf","active")),i=[],s=[t.a.c("wf","loading")];e||i.push(t.a.c("wf","inactive")),u(t.f,i,s)}q(t,"inactive")}function q(t,e,i){t.j&&t.h[e]&&(i?t.h[e](i.c,k(i)):t.h[e]())}function E(){this.c={}}function F(t,e,i){var s,n=[];for(s in e)if(e.hasOwnProperty(s)){var o=t.c[s];o&&n.push(o(e[s],i))}return n}function U(t,e){this.c=t,this.f=e,this.a=h(this.c,"span",{"aria-hidden":"true"},this.f)}function G(t){l(t.c,"body",t.a)}function R(t){return"display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:"+T(t.c)+";font-style:"+P(t)+";font-weight:"+t.f+"00;"}function C(t,e,i,s,n,o){this.g=t,this.j=e,this.a=s,this.c=i,this.f=n||3e3,this.h=o||void 0}function j(t,e,i,s,n,o,r){this.v=t,this.B=e,this.c=i,this.a=s,this.s=r||"BESbswy",this.f={},this.w=n||3e3,this.u=o||null,this.o=this.j=this.h=this.g=null,this.g=new U(this.c,this.s),this.h=new U(this.c,this.s),this.j=new U(this.c,this.s),this.o=new U(this.c,this.s),t=new x(this.a.c+",serif",k(this.a)),t=R(t),this.g.a.style.cssText=t,t=new x(this.a.c+",sans-serif",k(this.a)),t=R(t),this.h.a.style.cssText=t,t=new x("serif",k(this.a)),t=R(t),this.j.a.style.cssText=t,t=new x("sans-serif",k(this.a)),t=R(t),this.o.a.style.cssText=t,G(this.g),G(this.h),G(this.j),G(this.o)}function L(){if(null===lt){var t=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);lt=!!t&&(536>parseInt(t[1],10)||536===parseInt(t[1],10)&&11>=parseInt(t[2],10))}return lt}function z(t,e,i){for(var s in ht)if(ht.hasOwnProperty(s)&&e===t.f[ht[s]]&&i===t.f[ht[s]])return!0;return!1}function B(t){var e,i=t.g.a.offsetWidth,s=t.h.a.offsetWidth;(e=i===t.f.serif&&s===t.f["sans-serif"])||(e=L()&&z(t,i,s)),e?rt()-t.A>=t.w?L()&&z(t,i,s)&&(null===t.u||t.u.hasOwnProperty(t.a.c))?N(t,t.v):N(t,t.B):D(t):N(t,t.v)}function D(t){setTimeout(r(function(){B(this)},t),50)}function N(t,e){setTimeout(r(function(){c(this.g.a),c(this.h.a),c(this.j.a),c(this.o.a),e(this.a)},t),0)}function W(t,e,i){this.c=t,this.a=e,this.f=0,this.o=this.j=!1,this.s=i}function V(t){0==--t.f&&t.j&&(t.o?(t=t.a,t.g&&u(t.f,[t.a.c("wf","active")],[t.a.c("wf","loading"),t.a.c("wf","inactive")]),q(t,"active")):I(t.a))}function X(t){this.j=t,this.a=new E,this.h=0,this.f=this.g=!0}function Q(t,e,i,s,n){var o=0==--t.h;(t.f||t.g)&&setTimeout(function(){var t=n||null,a=s||null||{};if(0===i.length&&o)I(e.a);else{e.f+=i.length,o&&(e.j=o);var h,l=[];for(h=0;h<i.length;h++){var c=i[h],p=a[c.c],d=e.a,f=c;if(d.g&&u(d.f,[d.a.c("wf",f.c,k(f).toString(),"loading")]),q(d,"fontloading",f),d=null,null===ct)if(window.FontFace){var f=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent),y=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);ct=f?42<parseInt(f[1],10):!y}else ct=!1;d=ct?new C(r(e.g,e),r(e.h,e),e.c,c,e.s,p):new j(r(e.g,e),r(e.h,e),e.c,c,e.s,t,p),l.push(d)}for(h=0;h<l.length;h++)l[h].start()}},0)}function Y(t,e,i){var s=[],n=i.timeout;M(e);var s=F(t.a,i,t.c),o=new W(t.c,e,n);for(t.h=s.length,e=0,i=s.length;e<i;e++)s[e].load(function(e,i,s){Q(t,o,e,i,s)})}function H(t,e){this.c=t,this.a=e}function Z(t,e,i){var s=d(t.c);return t=(t.a.api||"fast.fonts.net/jsapi").replace(/^.*http(s?):(\/\/)?/,""),s+"//"+t+"/"+e+".js"+(i?"?v="+i:"")}function $(t,e){this.c=t,this.a=e}function J(t,e,i){this.c=t||e+ut,this.a=[],this.f=[],this.g=i||""}function K(t,e){for(var i=e.length,s=0;s<i;s++){var n=e[s].split(":");3==n.length&&t.f.push(n.pop());var o="";2==n.length&&""!=n[1]&&(o=":"),t.a.push(n.join(o))}}function tt(t){if(0==t.a.length)throw Error("No fonts to load!");if(-1!=t.c.indexOf("kit="))return t.c;for(var e=t.a.length,i=[],s=0;s<e;s++)i.push(t.a[s].replace(/ /g,"+"));return e=t.c+"?family="+i.join("%7C"),0<t.f.length&&(e+="&subset="+t.f.join(",")),0<t.g.length&&(e+="&text="+encodeURIComponent(t.g)),e}function et(t){this.f=t,this.a=[],this.c={}}function it(t){for(var e=t.f.length,i=0;i<e;i++){var s=t.f[i].split(":"),n=s[0].replace(/\+/g," "),o=["n4"];if(2<=s.length){var r,a=s[1];if(r=[],a)for(var a=a.split(","),h=a.length,l=0;l<h;l++){var c;if(c=a[l],c.match(/^[\w-]+$/)){var u=yt.exec(c.toLowerCase());if(null==u)c="";else{if(c=u[2],c=null==c||""==c?"n":ft[c],null==(u=u[1])||""==u)u="4";else var p=dt[u],u=p||(isNaN(u)?"4":u.substr(0,1));c=[c,u].join("")}}else c="";c&&r.push(c)}0<r.length&&(o=r),3==s.length&&(s=s[2],r=[],s=s?s.split(","):r,0<s.length&&(s=pt[s[0]])&&(t.c[n]=s))}for(t.c[n]||(s=pt[n])&&(t.c[n]=s),s=0;s<o.length;s+=1)t.a.push(new x(n,o[s]))}}function st(t,e){this.c=t,this.a=e}function nt(t,e){this.c=t,this.a=e}function ot(t,e){this.c=t,this.f=e,this.a=[]}var rt=Date.now||function(){return+new Date},at=!!window.FontFace;b.prototype.c=function(t){for(var e=[],i=0;i<arguments.length;i++)e.push(arguments[i].replace(/[\W_]+/g,"").toLowerCase());return e.join(this.a)},C.prototype.start=function(){var t=this.c.m.document,e=this,i=rt(),s=new Promise(function(s,n){function o(){rt()-i>=e.f?n():t.fonts.load(S(e.a),e.h).then(function(t){1<=t.length?s():setTimeout(o,25)},function(){n()})}o()}),n=new Promise(function(t,i){setTimeout(i,e.f)});Promise.race([n,s]).then(function(){e.g(e.a)},function(){e.j(e.a)})};var ht={D:"serif",C:"sans-serif"},lt=null;j.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.o.a.offsetWidth,this.A=rt(),B(this)};var ct=null;W.prototype.g=function(t){var e=this.a;e.g&&u(e.f,[e.a.c("wf",t.c,k(t).toString(),"active")],[e.a.c("wf",t.c,k(t).toString(),"loading"),e.a.c("wf",t.c,k(t).toString(),"inactive")]),q(e,"fontactive",t),this.o=!0,V(this)},W.prototype.h=function(t){var e=this.a;if(e.g){var i=p(e.f,e.a.c("wf",t.c,k(t).toString(),"active")),s=[],n=[e.a.c("wf",t.c,k(t).toString(),"loading")];i||s.push(e.a.c("wf",t.c,k(t).toString(),"inactive")),u(e.f,s,n)}q(e,"fontinactive",t),V(this)},X.prototype.load=function(t){this.c=new a(this.j,t.context||this.j),this.g=!1!==t.events,this.f=!1!==t.classes,Y(this,new A(this.c,t),t)},H.prototype.load=function(t){function e(){if(o["__mti_fntLst"+s]){var i,n=o["__mti_fntLst"+s](),r=[];if(n)for(var a=0;a<n.length;a++){var h=n[a].fontfamily;void 0!=n[a].fontStyle&&void 0!=n[a].fontWeight?(i=n[a].fontStyle+n[a].fontWeight,r.push(new x(h,i))):r.push(new x(h))}t(r)}else setTimeout(function(){e()},50)}var i=this,s=i.a.projectId,n=i.a.version;if(s){var o=i.c.m;_(this.c,Z(i,s,n),function(n){n?t([]):(o["__MonotypeConfiguration__"+s]=function(){return i.a},e())}).id="__MonotypeAPIScript__"+s}else t([])},$.prototype.load=function(t){var e,i,s=this.a.urls||[],n=this.a.families||[],o=this.a.testStrings||{},r=new m;for(e=0,i=s.length;e<i;e++)y(this.c,s[e],v(r));var a=[];for(e=0,i=n.length;e<i;e++)if(s=n[e].split(":"),s[1])for(var h=s[1].split(","),l=0;l<h.length;l+=1)a.push(new x(s[0],h[l]));else a.push(new x(s[0]));g(r,function(){t(a,o)})};var ut="//fonts.googleapis.com/css",pt={latin:"BESbswy","latin-ext":"çöüğş",cyrillic:"йяЖ",greek:"αβΣ",khmer:"កខគ",Hanuman:"កខគ"},dt={thin:"1",extralight:"2","extra-light":"2",ultralight:"2","ultra-light":"2",light:"3",regular:"4",book:"4",medium:"5","semi-bold":"6",semibold:"6","demi-bold":"6",demibold:"6",bold:"7","extra-bold":"8",extrabold:"8","ultra-bold":"8",ultrabold:"8",black:"9",heavy:"9",l:"3",r:"4",b:"7"},ft={i:"i",italic:"i",n:"n",normal:"n"},yt=/^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/,_t={Arimo:!0,Cousine:!0,Tinos:!0};st.prototype.load=function(t){var e=new m,i=this.c,s=new J(this.a.api,d(i),this.a.text),n=this.a.families;K(s,n);var o=new et(n);it(o),y(i,tt(s),v(e)),g(e,function(){t(o.a,o.c,_t)})},nt.prototype.load=function(t){var e=this.a.id,i=this.c.m;e?_(this.c,(this.a.api||"https://use.typekit.net")+"/"+e+".js",function(e){if(e)t([]);else if(i.Typekit&&i.Typekit.config&&i.Typekit.config.fn){e=i.Typekit.config.fn;for(var s=[],n=0;n<e.length;n+=2)for(var o=e[n],r=e[n+1],a=0;a<r.length;a++)s.push(new x(o,r[a]));try{i.Typekit.load({events:!1,classes:!1,async:!0})}catch(t){}t(s)}},2e3):t([])},ot.prototype.load=function(t){var e=this.f.id,i=this.c.m,s=this;e?(i.__webfontfontdeckmodule__||(i.__webfontfontdeckmodule__={}),i.__webfontfontdeckmodule__[e]=function(e,i){for(var n=0,o=i.fonts.length;n<o;++n){var r=i.fonts[n];s.a.push(new x(r.name,O("font-weight:"+r.weight+";font-style:"+r.style)))}t(s.a)},_(this.c,d(this.c)+(this.f.api||"//f.fontdeck.com/s/css/js/")+f(this.c)+"/"+e+".js",function(e){e&&t([])})):t([])};var mt=new X(window);mt.a.c.custom=function(t,e){return new $(e,t)},mt.a.c.fontdeck=function(t,e){return new ot(e,t)},mt.a.c.monotype=function(t,e){return new H(e,t)},mt.a.c.typekit=function(t,e){return new nt(e,t)},mt.a.c.google=function(t,e){return new st(e,t)};var vt={load:r(mt.load,mt)};void 0!==(s=function(){return vt}.call(e,i,e,t))&&(t.exports=s)}()},function(t,e){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(i=window)}t.exports=i}]); + + +var timingUtils = __webpack_require__(8); +var drawingUtils = __webpack_require__(3); +var EventEmitter = __webpack_require__(6).EventEmitter; +var util = __webpack_require__(0); +var transmit = __webpack_require__(9); +//var WAAClock = require('waaclock'); + + +var manager = module.exports = function() { + +/** + + @class nx + @description Central nexusUI manager with shared utility functions for all nexusUI objects + +*/ + + EventEmitter.apply(this) + + /**@property {object} widgets Contains all interface widgets (e.g. nx.widgets.dial1, nx.widgets.toggle1) */ + this.widgets = new Object(); + + this.elemTypeArr = new Array(); + this.aniItems = new Array(); + /* @property {boolean} showLabels Whether or not to draw an automatic text label on each interface component. */ + this.showLabels = false; + this.starttime = new Date().getTime(); + if (transmit) { + /** + @method sendsTo + @param {string or function} [destination] Protocol for transmitting data from interfaces (i.e. "js", "ajax", "ios", "max", or "node"). Also accepts custom functions. + ```js + nx.sendsTo("ajax") + + // or + + nx.sendsTo(function(data) { + //define a custom transmission function + }) + ``` + */ + this.sendsTo = transmit.setGlobalTransmit; + /** + @method setAjaxPath + @param {string} [path] If sending via AJAX, define the path to ajax destination + */ + this.setAjaxPath = transmit.setAjaxPath; + /** @property {string} destination NexusUI's transmission protocol (i.e. "js" or "ajax"). Defaults to "js". We recommend setting this property using nx.sendsTo() which ensures that all widgets receive this setting. */ + this.destination = "js"; + /** @property {string} ajaxPath If sending via AJAX, the destination path. Defaults to "lib/nexusOSCRelay.php". We recommend setting this property using nx.setAjaxPath() which ensures that all widgets receive this setting. */ + this.ajaxPath = "lib/nexusOSCRelay.php"; + } + + /** @property {boolean} isTouchDevice Returns true if page is loaded on a touch device. */ + this.isTouchDevice = ('ontouchstart' in document.documentElement)? true:false; + this.metas = document.getElementsByTagName('meta'); + + /** @property {boolean} globalWidgets Whether or not to instantiate a global variable for each widget (i.e. button1). Defaults to true. Designers of other softwares who wish to keep nexusUI entirely encapsulated in the nx object may set this property to false. In that case, all widgets are accessible in nx.widgets */ + this.globalWidgets = true; + + this.font = "'open sans'"; + this.fontSize = 14; + this.fontWeight = "normal"; + + var audioContext = window.AudioContext || window.webkitAudioContext; + this.context = new audioContext(); + + this.sys = navigator.userAgent.toLowerCase(); + this.isAndroid = this.sys.indexOf("android") > -1; + this.isMobile = this.sys.indexOf("mobile") > -1; + + /** @property {integer} throttlePeriod Throttle time in ms (for nx.throttle). */ + this.throttlePeriod = 20; + + + /* extra colors */ + + this.colors.borderhl = drawingUtils.shadeBlendConvert(-0.5,this.colors.border); // colors.border + [20% Darker] => colors.darkborder + this.colors.accenthl = drawingUtils.shadeBlendConvert(0.15,this.colors.accent); + +} + +util.inherits(manager, EventEmitter) + + +/** + @method add + Adds a NexusUI element to the webpage. This will create an HTML5 canvas and draw the interface on it. + @param {string} [type] NexusUI widget type (i.e. "dial"). + @param {object} [settings] (Optional.) Extra settings for the new widget. This settings object may have any of the following properties: x (integer in px), y, w (width), h (height), name (widget's OSC name and canvas ID), parent (the ID of the element you wish to add the canvas into). If no settings are provided, the element will be at default size and appended to the body of the HTML document. + */ +manager.prototype.add = function(type, args) { + //args may have optional properties: x, y, w, h, name, parent + + if(type) { + var canv = document.createElement("canvas"); + canv.setAttribute('nx', type); + if (args) { + if (args.x || args.y) { + canv.style.position = "absolute"; + } + if (args.x) { + canv.style.left = args.x + "px"; + } + if (args.y) { + canv.style.top = args.y + "px"; + } + if (args.w) { + canv.style.width = args.w; + if (typeof args.w != "string") + canv.width = args.w; + } + if (args.h) { + canv.style.height = args.h; + if (typeof args.h != "string") + canv.height = args.h; + } + if (args.parent) { + var parent; + if (typeof args.parent === "string") { + parent = document.getElementById(args.parent); + } else if (args.parent instanceof HTMLElement){ + parent = args.parent; + } else if (args.parent instanceof jQuery){ + parent = args.parent[0]; + } + } + if (args.name) { + canv.id = args.name + } + } + if (!parent) { + var parent = document.body + } + parent.appendChild(canv); + return this.transform(canv); + } +} + +/** @method transform +Transform an existing canvas into a NexusUI widget. +@param {string} [canvasID] The ID of the canvas to be transformed. +@param {string} [type] (Optional.) Specify which type of widget the canvas will become. If no type is given, the canvas must have an nx attribute with a valid widget type. +*/ +manager.prototype.transform = function(canvas, type) { + for (var key in nx.widgets) { + if (nx.widgets[key].canvasID == canvas.id) { + return; + } + } + if (type) { + var nxType = type; + } else { + var nxType = canvas.getAttribute("nx"); + } + + if (!nxType) { + return; + } + var elemCount = 0; + var newObj; + + /* find out how many of the same elem type have come before + i.e. nx.elemTypeArr will look like [ dial, dial, toggle, toggle ] + allowing you to count how many dials already exist on the page + and give your new dial the appropriate index and id: dial3 */ + + for (j=0;j<this.elemTypeArr.length;j++) { + if (this.elemTypeArr[j] === nxType) { + elemCount++; + } + } + + // add your new nexus element type to the element list + this.elemTypeArr.push(nxType); + + // check to see if it has a pre-given ID + // and use that as its id if so + if (!canvas.id) { + var idNum = elemCount + 1; + canvas.id = nxType + idNum; + } + + if(nxType) { + try { + var newObj = new (__webpack_require__(28)[nxType])(canvas.id); + } catch (err) { + console.log("creation of " + nxType + " failed"); + return; + } + } + + newObj.type = nxType; + + this.widgets[newObj.canvasID] = newObj; + if (this.globalWidgets) { + window[newObj.canvasID] = this.widgets[newObj.canvasID] + } + + newObj.init(); + return newObj; +} + +/** @method transmit +The "output" instructions for sending a widget's data to another application or to a JS callback. Inherited by each widget and executed when each widget is interacted with or its value changes. Set using nx.sendsTo() to ensure that all widgets inherit the new function correctly. +@param {object} [data] The data to be transmitted. Each property of the object will become its own OSC message. (This works with objects nested to up to 2 levels). +*/ + +manager.prototype.transmit = function(data, passive) { + //console.log(passive + " manager.transmit") + this.makeOSC(this.emit, data, passive); + this.emit('*',data, passive); +} + +/** + @method colorize + @param {string} [aspect] Which part of ui to change, i.e. "accent" "fill", "border" + @param {string} [color] Hex or rgb color code + Change the color of all nexus objects, by aspect ([fill, accent, border, accentborder] + + ```js + nx.colorize("#00ff00") // changes the accent color by default + nx.colorize("border", "#000000") // changes the border color + ``` + +**/ +manager.prototype.colorize = function(aspect, newCol) { + + if (!newCol) { + // just sending in a color value colorizes the accent + newCol = aspect; + aspect = "accent"; + } + + this.colors[aspect] = newCol; + + this.colors.borderhl = drawingUtils.shadeBlendConvert(0.1,this.colors.border,this.colors.black); // colors.border + [20% Darker] => colors.darkborder + this.colors.accenthl = drawingUtils.shadeBlendConvert(0.3,this.colors.accent); + + for (var key in this.widgets) { + this.widgets[key].colors[aspect] = newCol; + this.widgets[key].colors["borderhl"] = this.colors.borderhl; + this.widgets[key].colors["accenthl"] = this.colors.accenthl; + + this.widgets[key].draw(); + } + +} + + +/** @method setThrottlePeriod +Set throttle time of nx.throttle, which controls rapid network transmissions of widget data. +@param {integer} [throttle time] Throttle time in milliseconds. +*/ +manager.prototype.setThrottlePeriod = function(newThrottle) { + this.throttlePeriod = newThrottle; + for (var key in this.widgets) { + this.widgets[key].throttlePeriod = this.throttlePeriod; + } +} + + + + /* + * GUI + */ + +/** @property {object} colors The interface's color settings. Set with nx.colorize(). */ +manager.prototype.colors = { + "accent": "#ff5500", + "fill": "#eeeeee", + "border": "#e3e3e3", + "mid": "#1af", + "black": "#000000", + "white": "#FFFFFF" +}; + +/** @method startPulse + Start an animation interval for animated widgets (calls nx.pulse() every 30 ms). Executed by default when NexusUI loads. +*/ +manager.prototype.startPulse = function() { + this.pulseInt = setInterval("nx.pulse()", 30); +} + +/** @method stopPulse + Stop the animation pulse interval. +*/ +manager.prototype.stopPulse = function() { + clearInterval(this.pulseInt); +} + +/** @method pulse + Animation pulse which executes all functions stored in the nx.aniItems array. +*/ +manager.prototype.pulse = function() { + for (var i=0;i<this.aniItems.length;i++) { + this.aniItems[i](); + } +} + +manager.prototype.addAni = function(fn) { + +} + +manager.prototype.removeAni = function(fn) { + this.aniItems.splice(this.aniItems.indexOf(fn)); +} + +manager.prototype.addStylesheet = function() { + var cssString = 'select {' + + 'width: 150px;' + + 'padding: 5px 5px;' + + 'font-size: 16px;' + + 'color:#666666;' + + 'border: solid 2px #e4e4e4;' + + 'border-radius: 0;' + + '-webkit-appearance: none;' + + 'outline: none;' + + 'cursor:pointer;' + + 'background-color:#EEE;' + + 'font-family:"open sans";' + + '}' + + '' + + 'input[type=text]::-moz-selection { background: transparent; }' + + 'input[type=text]::selection { background: transparent; }' + + 'input[type=text]::-webkit-selection { background: transparent; }' + + '' + + 'canvas { ' + + 'cursor:pointer;' + + 'border-radius:0px;' + + 'moz-border-radius:0px;' + + 'webkit-border-radius:0px;' + + 'box-sizing:border-box;' + + '-moz-box-sizing:border-box;' + + '-webkit-box-sizing:border-box;' + + '}' + + '' + + 'input[type=text] { ' + + 'border-radius:5px;' + + 'moz-border-radius:5px;' + + 'webkit-border-radius:5px;' + + 'box-sizing:border-box;' + + '-moz-box-sizing:border-box;' + + '-webkit-box-sizing:border-box;' + + '}'; + + var head = document.head; + var style = document.createElement('style'); + + style.type = 'text/css'; + if (style.styleSheet){ + style.styleSheet.cssText = cssString; + } else { + style.appendChild(document.createTextNode(cssString)); + } + head.appendChild(style); +} + +/** @method setViewport + Set mobile viewport scale (similar to a zoom) + @param {integer} [scale] Zoom ratio (i.e. 0.5, 1, 2) */ +manager.prototype.setViewport = function(scale) { + for (i=0; i<this.metas.length; i++) { + if (this.metas[i].name == "viewport") { + this.metas[i].content = "minimum-scale="+scale+", maximum-scale="+scale; + } + } +} + +/* @method setLabels + Tell all widgets whether or not draw text labels on widgets + @param {boolean} [on/off] true to add labels, false to remove labels + */ +manager.prototype.setLabels = function(onoff) { + if (onoff=="on") { + this.showLabels = true; + } else { + this.showLabels = false; + } + for (var key in this.widgets) { + this.widgets[key].draw() + } +} + +manager.prototype.setProp = function(prop,val) { + if (prop && val) { + nx[prop] = val; + for (var key in this.widgets) { + this.widgets[key][prop] = val; + this.widgets[key].draw() + } + } +} + +manager.prototype.blockMove = function(e) { + if (e.target.attributes["nx"]) { + e.preventDefault(); + if (this.isAndroid) { + e.stopPropagation ? e.stopPropagation() : false; + } + } +} + +manager.prototype.calculateDigits = function(value) { + var nondecimals = this.max ? Math.floor(this.max).toString().length : 1 + if (nondecimals < this.maxdigits) { + var decimals = 3-nondecimals + } else { + var decimals = 0 + } + var valdigits = nondecimals + decimals + return { + wholes: nondecimals, + decimals: decimals, + total: nondecimals + decimals, + } +} + +manager.prototype.themes = { + "light": { + "fill": "#DDDDDD", + "border": "#DADADA", + "black": "#000000", + "white": "#FFFFFF", + "body": "#F3F3F3" + }, + "dark": { + "fill": "#222", + "border": "#292929", + "black": "#FFFFFF", + "white": "#000000", + "body": "#111" + }, + "red": "#f24", + "orange": "#f50", + "yellow": "#ec1", + "green": "#1c9", + "blue": "#09d", + "purple": "#40a", +} + +manager.prototype.skin = function(name) { + + var names = name.split("-") + + nx.colorize("fill", nx.themes[names[0]].fill) + nx.colorize("border", nx.themes[names[0]].border) + nx.colorize("black", nx.themes[names[0]].black) + nx.colorize("white", nx.themes[names[0]].white) + + nx.colorize("accent", nx.themes[names[1]]) + + document.body.style.backgroundColor = nx.themes[names[0]].body +} + + +manager.prototype.labelSize = function(size) { + for (var key in this.widgets) { + var widget = this.widgets[key] + + if (widget.label) { + var newheight = widget.GUI.h + size + widget.labelSize = size + if (["select","number","text"].indexOf(widget.type)<0) { + widget.resize(false,newheight) + } + } + } + var textLabels = document.querySelectorAll(".nxlabel"); + console.log(textLabels) + + for (var i = 0; i < textLabels.length; i++) { + console.log(textLabels[i]) + textLabels[i].style.fontSize = size/2.8+"px" + console.log(textLabels[i].style.fontSize) + } +} + + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class banner + "Powered by NexusUI" tag with a link to our website. Use it if you want to share the positive vibes of NexusUI. Thanks for using! + ```html + <canvas nx="banner"></canvas> + ``` + <canvas nx="banner" style="margin-left:25px"></canvas> +*/ + +var banner = module.exports = function (target) { + this.defaultSize = { width: 100, height: 40 }; + widget.call(this, target); + + //unique attributes + /** @property {string} message1 The first line of text on the banner. */ + this.message1 = "Powered By"; + /** @property {string} message2 The second line of text on the banner. */ + this.message2 = "NexusUI"; + /** @property {string} link The URL the banner will link to. */ + this.link = "http://www.nexusosc.com"; + /** @property {boolean} isLink Whether or not the banner is a hyperlink. Defaults to true. */ + this.isLink = true; +} +util.inherits(banner, widget); + +banner.prototype.init = function() { + this.draw(); +} + +banner.prototype.draw = function() { + with (this.context) { + + globalAlpha = 0.1; + fillStyle = this.colors.accent; + beginPath(); + moveTo(0,10); + lineTo(10,this.GUI.h/2+5); + lineTo(0,this.GUI.h); + lineTo(30,this.GUI.h); + lineTo(30,10); + fill(); + moveTo(this.GUI.w-30,10); + lineTo(this.GUI.w-30,this.GUI.h); + lineTo(this.GUI.w,this.GUI.h); + lineTo(this.GUI.w-10,this.GUI.h/2+5); + lineTo(this.GUI.w,10); + fill(); + closePath(); + globalAlpha = 1; + + fillStyle = this.colors.accent; + fillRect(15,0,this.GUI.w-30,this.GUI.h-10); + + fillStyle = this.colors.white; + font = this.fontWeight + " " +this.GUI.h/5+"px "+this.font; + textAlign = "center"; + fillText(this.message1, this.GUI.w/2, this.GUI.h/3.3); + fillText(this.message2, this.GUI.w/2, (this.GUI.h/3.3)*2); + + fillStyle = this.colors.black; + beginPath(); + moveTo(15,this.GUI.h-10); + lineTo(30,this.GUI.h); + lineTo(30,this.GUI.h-10); + lineTo(15,this.GUI.h-10); + fill(); + moveTo(this.GUI.w-15,this.GUI.h-10); + lineTo(this.GUI.w-30,this.GUI.h); + lineTo(this.GUI.w-30,this.GUI.h-10); + lineTo(this.GUI.w-15,this.GUI.h-10); + fill(); + closePath(); + + } +} + +banner.prototype.click = function() { + if (this.isLink) { + window.location = this.link; + } +} + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var widget = __webpack_require__(1); +var drawing = __webpack_require__(3); + +var button = module.exports = function(target) { + +/** + + @public + @class button + + Touch button with three modes of interaction ("toggle", "impulse", and "aftertouch"). + ```html + <canvas nx="button"></canvas> + ``` + <canvas nx="button" style="margin-left:25px"></canvas> +*/ + + this.defaultSize = { width: 50, height: 50 }; + widget.call(this, target); + + /** + @property {object} val Main value set and output, with sub-properties: + | | data + | --- | --- + | *press* | 0 (clicked) or 1 (unclicked) + | *x* | 0-1 float of x-position of click ("aftertouch" mode only) + | *y* | 0-1 float of y-position of click ("aftertouch" mode only) + + When the widget is interacted with, val is sent as the output data for the widget. + ```js + button1.on('*', function(data) { + // some code using data.press, data.x, and data.y + }); + ``` + Or, if NexusUI is outputting OSC (e.g. if nx.sendsTo("ajax")), val will be broken into OSC messages: + ```html + /button1/press 1 + /button1/x 37 + /button1/y 126 + ``` + */ + this.val = { + press: 0 + } + + /** @property {string} mode Interaction mode. Options: + <b>impulse</b> 1 on click <br> + <b>toggle</b> 1 on click, 0 on release<br> + <b>aftertouch</b> 1, x, y on click; x, y on move; 0, x, y on release _(default)_ <br> + ```js + button1.mode = "aftertouch" + ``` + */ + this.mode = "aftertouch"; + + this.lockResize = true; + + this.image = null; + this.imageHover = null; + this.imageTouch = null; + + this.subval = new Object(); + + this.init(); + +} +util.inherits(button, widget); + +button.prototype.init = function() { + this.center = { + x: this.GUI.w/2, + y: this.GUI.h/2 + } + this.strokeWidth = this.GUI.w/20; + this.radius = (Math.min(this.center.x, this.center.y)) + this.draw(); +} + +button.prototype.draw = function() { + + this.erase(); + + with (this.context) { + + if (this.image !== null) { + // Image Button + if (!this.val.press) { + // Draw Image if not touched + drawImage(this.image, 0, 0); + } else { + if (this.imageTouch) { + // Draw Touch Image + drawImage(this.imageTouch, 0, 0) + + } else { + + drawImage(this.image, 0, 0) + + // No touch image, apply highlighting + globalAlpha = 0.5; + fillStyle = this.colors.accent; + fillRect (0, 0, this.GUI.w, this.GUI.h); + globalAlpha = 1; + + } + } + + } else { + + // Regular Button + + if (!this.val.press) { + fillStyle = this.colors.fill + strokeStyle = this.colors.border + // var strokealpha = 1 + } else if (this.val.press) { + fillStyle = this.colors.accent; + // strokeStyle = this.colors.accentborder || "#fff" + strokeStyle = this.colors.accenthl + // var strokealpha = 0.2 + } + + lineWidth = this.strokeWidth; + + beginPath(); + arc(this.center.x, this.center.y, this.radius, 0, Math.PI*2, true); + fill() + closePath() + + beginPath(); + arc(this.center.x, this.center.y, this.radius-lineWidth/2, 0, Math.PI*2, true); + // globalAlpha = strokealpha + stroke() + globalAlpha = 1 + closePath() + + if (this.val.press && this.mode=="aftertouch") { + + var x = nx.clip(this.clickPos.x,this.GUI.w*.2,this.GUI.w/1.3) + var y = nx.clip(this.clickPos.y,this.GUI.h*.2,this.GUI.h/1.3) + + var gradient = this.context.createRadialGradient(x,y,this.GUI.w/6,this.center.x,this.center.y,this.radius*1.3); + gradient.addColorStop(0,this.colors.accent); + gradient.addColorStop(1,"white"); + + strokeStyle = gradient; + lineWidth = this.GUI.w/20; + + beginPath() + arc(this.center.x, this.center.y, this.radius-this.GUI.w/40, 0, Math.PI*2, true); + stroke() + closePath() + + } + } + + this.drawLabel(); + + } +} + +button.prototype.click = function(e) { + if (drawing.isInside(this.clickPos,{x: this.center.x-this.radius, y:this.center.y-this.radius, w:this.radius*2, h:this.radius*2})) { + this.val["press"] = 1; + if (this.mode=="aftertouch") { + this.val["x"] = this.clickPos.x; + this.val["y"] = this.clickPos.y; + } + this.transmit(this.val); + this.draw(); + } +} + +button.prototype.move = function () { + // use to track movement on the button + if (this.mode=="aftertouch") { + this.val["x"] = this.clickPos.x; + this.val["y"] = this.clickPos.y; + this.subval["x"] = this.clickPos.x; + this.subval["y"] = this.clickPos.y; + this.transmit(this.subval); + this.draw(); + } +} + +button.prototype.release = function() { + this.val["press"] = 0; + if (this.mode=="toggle" || this.mode=="aftertouch") { + this.transmit(this.val); + } + this.draw(); +} + + +/** @method setImage + Turns the button into an image button with custom image. Sets the default (unclicked) button image. + @param {string} [src] Image source */ +button.prototype.setImage = function(image) { + this.image = new Image(); + this.image.onload = this.draw.bind(this) + this.image.src = image; +} + +button.prototype.setHoverImage = function(image) { + this.imageHover = new Image(); + this.imageHover.onload = this.draw.bind(this) + this.imageHover.src = image; +} + +/** @method setTouchImage + Sets the image that will show when the button is clicked. + @param {string} [src] Image source */ +button.prototype.setTouchImage = function(image) { + this.imageTouch = new Image(); + this.imageTouch.onload = this.draw.bind(this) + this.imageTouch.src = image; +} + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class colors + Color picker that outputs RBG values + ```html + <canvas nx="colors"></canvas> + ``` + <canvas nx="colors" style="margin-left:25px"></canvas> +*/ + +var colors = module.exports = function (target) { + + this.defaultSize = { width: 100, height: 100 }; + widget.call(this, target); + + this.init(); + +} +util.inherits(colors, widget); + +colors.prototype.init = function() { + + /* new tactic */ + + this.gradient1 = this.context.createLinearGradient(0,0,this.GUI.w,0) + this.gradient1.addColorStop(0, '#F00'); + this.gradient1.addColorStop(0.17, '#FF0'); + this.gradient1.addColorStop(0.34, '#0F0'); + this.gradient1.addColorStop(0.51, '#0FF'); + this.gradient1.addColorStop(0.68, '#00F'); + this.gradient1.addColorStop(0.85, '#F0F'); + this.gradient1.addColorStop(1, '#F00'); + + this.gradient2 = this.context.createLinearGradient(0,0,0,this.GUI.h) + this.gradient2.addColorStop(0, 'rgba(0,0,0,255)'); + this.gradient2.addColorStop(0.49, 'rgba(0,0,0,0)'); + this.gradient2.addColorStop(0.51, 'rgba(255,255,255,0)'); + this.gradient2.addColorStop(0.95, 'rgba(255,255,255,255)'); + + this.draw(); +} + +colors.prototype.draw = function() { + this.erase(); + + with(this.context) { + fillStyle = this.gradient1; + fillRect(0,0,this.GUI.w,this.GUI.h) + fillStyle = this.gradient2; + fillRect(0,0,this.GUI.w,this.GUI.h) + } + + this.drawLabel(); +} + +colors.prototype.drawColor = function() { + with(this.context) { + fillStyle = "rgb("+this.val.r+","+this.val.g+","+this.val.b+")" + fillRect(0,this.GUI.h * 0.95,this.GUI.w,this.GUI.h* 0.05) + + } +} + +colors.prototype.click = function(e) { + if (this.clickPos.x > 0 && this.clickPos.y > 0 && this.clickPos.x < this.GUI.w && this.clickPos.y < this.GUI.h) { + var imgData = this.context.getImageData(this.clickPos.x*2,this.clickPos.y*2,1,1); + } else { + return; + } + + + /** @property {object} val RGB color value at mouse position. <br> This is also the widget's data output (See <a href="#nexusui-api-widget-widgetval">widget.val</a>). <br> Properties: + | | data + | --- | --- + | *r* | red value 0-256 + | *g* | green value 0-256 + | *b* | blue value 0-256 + ```js + colors1.on('*', function(data) { + // some code using data.r, data.g, and data.b + } + ``` + */ + + this.val = { + r: imgData.data[0], + g: imgData.data[1], + b: imgData.data[2] + } + this.transmit(this.val); + this.drawColor(); +} + + +colors.prototype.move = function(e) { + this.click(e); +} + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class comment + Text comment + ```html + <canvas nx="comment"></canvas> + ``` + <canvas nx="comment" style="margin-left:25px"></canvas> +*/ + +var comment = module.exports = function (target) { + + this.defaultSize = { width: 100, height: 20 }; + widget.call(this, target); + + /** @property {object} val + | | data + | --- | --- + | *text* | text of comment area (as string) + ```js + comment1.val.text = "This is my comment" + comment1.draw() + ``` + */ + + this.val = { + text: "comment" + } + this.sizeSet = false; + + this.init(); +} +util.inherits(comment, widget); + +/** @method setSize + Set the font size of the comment text + @param {integer} [size] Text size in pixels +*/ +comment.prototype.setSize = function(size) { + this.size = size; + this.sizeSet = true; + this.draw(); +} + +comment.prototype.init = function() { + this.draw(); +} + +comment.prototype.draw = function() { + if (!this.sizeSet) { + this.size = Math.sqrt((this.GUI.w * this.GUI.h) / (this.val.text.length*2)); + } + + this.erase(); + with (this.context) { + + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + + fillStyle = this.colors.black; + textAlign = "left"; + font = this.size+"px 'Open Sans'"; + } + this.wrapText(this.val.text, 6, 3+this.size, this.GUI.w-6, this.size); +} + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2) +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class crossfade + Crossfade for panning or mixing + ```html + <canvas nx="crossfade"></canvas> + ``` + <canvas nx="crossfade" style="margin-left:25px"></canvas> +*/ + +var crossfade = module.exports = function (target) { + this.defaultSize = { width: 100, height: 30 }; + widget.call(this, target); + + /** @property {object} val + | | data + | --- | --- + | *value* | Crossfade value (float -1 to 1) + */ + this.val = { + R: 0.75, + L: 0.75 + } + + this.location = 0.5 + + this.init(); +} +util.inherits(crossfade, widget); + +crossfade.prototype.init = function() { + this.draw(); +} + +crossfade.prototype.draw = function() { + + this.erase(); + + this.location = Math.pow(this.val.R,2) + + with (this.context) { + + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + + var y1 = 0; + var y2 = this.GUI.h; + var x1 = this.location*this.GUI.w; + //var x2 = this.GUI.w/5; + // + fillStyle = this.colors.accent; + fillRect(x1,y1,this.GUI.w-x1,y2); + + textBaseline="middle" + font = this.GUI.h/3 + "px 'Open Sans'" + + fillStyle = this.colors.accent; + textAlign="right" + fillText(this.val.R.toFixed(2), x1-2, this.GUI.h/4) + + fillStyle = this.colors.fill; + textAlign="left" + fillText(this.val.L.toFixed(2), x1+2, this.GUI.h* 0.75) + + + } + + this.drawLabel() + +} + +crossfade.prototype.click = function() { + this.move(); +} + +crossfade.prototype.move = function() { + var R = math.clip(this.clickPos.x/this.GUI.w,0,1) + var L = 1 - R + this.location = R + this.val.R = math.prune(Math.sqrt(R),3) + this.val.L = math.prune(Math.sqrt(L),3) + this.draw(); + this.transmit(this.val); +} + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2); +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class dial + Circular dial + ```html + <canvas nx="dial"></canvas> + ``` + <canvas nx="dial" style="margin-left:25px"></canvas> +*/ + +var dial = module.exports = function(target) { + + this.defaultSize = { width: 100, height: 100 }; + widget.call(this, target); + + //define unique attributes + this.circleSize; + this.handleLength; + + /** @property {object} val + | | data + | --- | --- + | *value* | Current value of dial as float 0-1 + */ + this.val = { + value: 0 + } + /** @property {float} responsivity How much the dial increments on drag. Default: 0.004<br> + */ + this.responsivity = 0.004; + + this.aniStart = 0; + this.aniStop = 1; + this.aniMove = 0.01; + + this.lockResize = true; + + if (this.canvas.getAttribute("min")!=null) { + this.min = parseFloat(this.canvas.getAttribute("min")); + } else { + this.min = 0 + } + if (this.canvas.getAttribute("max")!=null) { + this.max = parseFloat(this.canvas.getAttribute("max")); + } else { + this.max = 1 + } + if (this.canvas.getAttribute("step")!=null) { + this.step = parseFloat(this.canvas.getAttribute("step")); + } else { + this.step = 0.001 + } + + this.maxdigits = 3 + this.calculateDigits = nx.calculateDigits + + this.init(); + +} + +util.inherits(dial, widget); + +dial.prototype.init = function() { + + this.circleSize = (Math.min(this.center.x, this.center.y)); + this.handleLength = this.circleSize; + this.mindim = Math.min(this.GUI.w,this.GUI.h) + + if (this.mindim<101 || this.mindim<101) { + this.accentWidth = this.lineWidth * 1; + } else { + this.accentWidth = this.lineWidth * 2; + } + + this.draw(); + +} + +dial.prototype.draw = function() { + + var normalval = this.normalize(this.val.value) + + //var dial_angle = (((1.0 - this.val.value) * 2 * Math.PI) + (1.5 * Math.PI)); + var dial_position = (normalval + 0.25) * 2 * Math.PI + //var point = math.toCartesian(this.handleLength, dial_angle); + + this.erase(); + + with (this.context) { + + lineCap = 'butt'; + beginPath(); + lineWidth = this.circleSize/2; + arc(this.center.x, this.center.y, this.circleSize-lineWidth/2, Math.PI * 0, Math.PI * 2, false); + strokeStyle = this.colors.fill; + stroke(); + closePath(); + + //draw round accent + lineCap = 'butt'; + beginPath(); + lineWidth = this.circleSize/2; + arc(this.center.x, this.center.y, this.circleSize-lineWidth/2, Math.PI * 0.5, dial_position, false); + strokeStyle = this.colors.accent; + stroke(); + closePath(); + + clearRect(this.center.x-this.GUI.w/40,this.center.y,this.GUI.w/20,this.GUI.h/2) + + if (normalval > 0) { + beginPath(); + lineWidth = 1.5; + moveTo(this.center.x-this.GUI.w/40,this.center.y+this.circleSize/2) //this.radius-this.circleSize/4 + lineTo(this.center.x-this.GUI.w/40,this.center.y+this.circleSize) //this.radius+this.circleSize/4 + strokeStyle = this.colors.accent + stroke(); + closePath(); + } + + //figure out text size + // + // + // + this.val.value = math.prune(this.rangify(normalval),3) + + + //var valdigits = this.max ? Math.floor(this.max).toString().length : 1 + //valdigits += this.step ? this.step < 1 ? 1 : 2 : 2 + this.digits = this.calculateDigits() + + valtextsize = (this.mindim / this.digits.total) * 0.55 + + if (valtextsize > 7) { + + var valtext = this.val.value.toFixed(this.digits.decimals) + + fillStyle = this.colors.borderhl + textAlign = "center" + textBaseline = "middle" + font = valtextsize+"px 'Open Sans'" + fillText(valtext,this.GUI.w/2,this.GUI.h/2); + + } + + } + + this.drawLabel(); +} + + +dial.prototype.click = function(e) { + this.val.value = math.prune(this.val.value, 4) + this.transmit(this.val); + this.draw(); + this.aniStart = this.val.value; +} + + +dial.prototype.move = function() { + var normalval = this.normalize(this.val.value) + normalval = math.clip((normalval - (this.deltaMove.y * this.responsivity)), 0, 1); + this.val.value = math.prune(this.rangify(normalval), 4) + this.transmit(this.val); + + this.draw(); +} + + +dial.prototype.release = function() { + this.aniStop = this.val.value; +} + +/** @method animate + Animates the dial + @param {string} [type] Type of animation. Currently accepts "bounce" (bounces between mousedown and mouserelease points) or "none" */ +dial.prototype.animate = function(aniType) { + + switch (aniType) { + case "bounce": + nx.aniItems.push(this.aniBounce.bind(this)); + break; + case "none": + nx.aniItems.splice(nx.aniItems.indexOf(this.aniBounce)); + break; + } + +} + +dial.prototype.aniBounce = function() { + if (!this.clicked) { + this.val.value += this.aniMove; + if (this.aniStop < this.aniStart) { + this.stopPlaceholder = this.aniStop; + this.aniStop = this.aniStart; + this.aniStart = this.stopPlaceholder; + } + this.aniMove = math.bounce(this.val.value, this.aniStart, this.aniStop, this.aniMove); + this.draw(); + this.val.value = math.prune(this.val.value, 4) + this.transmit(this.val); + } +} + + + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +var startTime = 0; + +var math = __webpack_require__(2) +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class envelope + Multi-point line ramp generator + ```html + <canvas nx="envelope"></canvas> + ``` + <canvas nx="envelope" style="margin-left:25px"></canvas> +*/ + +var envelope = module.exports = function (target) { + this.defaultSize = { width: 200, height: 100 }; + widget.call(this, target); + + this.nodeSize = 1; + /** @property {boolean} active Whether or not the envelope is currently animating. */ + this.active = false; + /** @property {integer} duration The envelope's duration in ms. */ + this.duration = 1000; // 1000 ms + /** @property {boolean} looping Whether or not the envelope loops. */ + this.looping = false + + + this.scanIndex = 0 + + //define unique attributes + + /** @property {object} val + | | data + | --- | --- + | *amp* | amplitude at current point of ramp (float 0-1) + | *index* | current progress through ramp (float 0-1) + | *points* | array containing x/y coordinates of each node. + */ + + this.val = { + index: 0, + amp: 0, + points: [ + { + x: 0.1, + y: 0.4 + }, + { + x: 0.35, + y: 0.6 + }, + { + x: 0.65, + y: 0.2 + }, + { + x: 0.9, + y: 0.4 + } + ] + } + + // Index of which node was clicked + this.selectedNode = null; + + nx.aniItems.push(this.pulse.bind(this)); + + this.init(); +} + +util.inherits(envelope, widget); + +envelope.prototype.init = function() { + this.mindim = this.GUI.w < this.GUI.h ? this.GUI.w : this.GUI.h; + this.draw(); +} + +envelope.prototype.draw = function() { + this.erase(); + with (this.context) { + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + fillStyle = this.colors.accent; + var centerx = this.mindim/10 + var centery = this.GUI.h-this.mindim/10 + beginPath() + moveTo(centerx,centery) + arc(centerx,centery,this.mindim/10,Math.PI*1.5,Math.PI*2*this.val.index+Math.PI*1.5,false); + fill() + closePath() + + // draw all the points + var drawingX = []; + var drawingY = []; + + for (var i = 0; i < this.val.points.length; i++) { + drawingX[i] = this.val.points[i].x * this.GUI.w; + drawingY[i] = (1 - this.val.points[i].y) * this.GUI.h; + + //stay within right/left bounds + if (drawingX[i]<(this.bgLeft+this.nodeSize)) { + drawingX[i] = this.bgLeft + this.nodeSize; + } else if (drawingX[i]>(this.bgRight-this.nodeSize)) { + drawingX[i] = this.bgRight - this.nodeSize; + } + //stay within top/bottom bounds + if (drawingY[i]<(this.bgTop+this.nodeSize)) { + drawingY[i] = this.bgTop + this.nodeSize; + } else if (drawingY[i]>(this.bgBottom-this.nodeSize)) { + drawingY[i] = this.bgBottom - this.nodeSize; + } + } + + // draw rectangles + for (var j = 0; j < drawingX.length; j++) { + var size = this.mindim/35 + 2; + beginPath() + arc(drawingX[j],drawingY[j],size,0,Math.PI*2,false); + fillStyle = this.colors.accent + fill() + closePath() + } + + + // draw shape + beginPath(); + strokeStyle = this.colors.accent; + moveTo(-5,this.GUI.h); + lineTo(-5,(1-this.val.points[0].y)*this.GUI.h); + + // draw each line + for (var j = 0; j < drawingX.length; j++) { + lineTo(drawingX[j],drawingY[j]); + } + + lineTo(this.GUI.w+5,(1-this.val.points[this.val.points.length-1].y)*this.GUI.h); + lineTo(this.GUI.w+5,this.GUI.h); + stroke(); + globalAlpha = 0.2; + fillStyle = this.colors.accent; + fill(); + globalAlpha = 1 + closePath(); + + + + } + + this.drawLabel(); +} + +envelope.prototype.scaleNode = function(nodeIndex) { + var i = nodeIndex; + var prevX = 0; + var nextX = this.GUI.w; + + var actualX = this.val.points[i].x; + var actualY = (this.GUI.h - this.val.points[i].y); + var clippedX = math.clip(actualX/this.GUI.w, 0, 1); + var clippedY = math.clip(actualY/this.GUI.h, 0, 1); + + this.val.points[i].x = math.prune(clippedX, 3); + this.val.points[i].y = math.prune(clippedY, 3); + + // find x value of nodes to the right and left + if (i > 0) { + prevX = this.val.points[i-1].x; + } + if (this.val.points.length > i+1) { + nextX = this.val.points[i+1].x; + } + + if (this.val.points[i].x < prevX) { + this.val.points.splice(i-1, 0, this.val.points.splice(i, 1)[0]) + i = i-1; + this.selectedNode = i; + } + + if (this.val.points[i].x > nextX) { + this.val.points.splice(i+1, 0, this.val.points.splice(i, 1)[0]) + i = i+1; + this.selectedNode = i; + } + +} + +envelope.prototype.click = function() { + + // find nearest node and set this.selectedNode (index) + this.selectedNode = this.findNearestNode(this.clickPos.x/this.GUI.w, this.clickPos.y/this.GUI.h, this.val.points); + + this.transmit(this.val); + this.draw(); +} + +envelope.prototype.move = function() { + if (this.clicked) { + this.val.points[this.selectedNode].x = this.clickPos.x; + this.val.points[this.selectedNode].y = this.clickPos.y; + this.scaleNode(this.selectedNode); + this.transmit(this.val); + this.draw(); + } +} + +envelope.prototype.release = function() { + + if (!this.hasMoved) { + this.val.points.splice(this.selectedNode,1) + } + + this.draw(); + + // reset the this.selectedNode + this.selectedNode = null; +} + +// update index and amp +envelope.prototype.pulse = function() { + if (this.active) { + + // calculate index based on audio context + var percentDone = (nx.context.currentTime - startTime) / (this.duration/1000); + if (percentDone >= 1) { + if (this.looping) { + percentDone -= 1; + startTime += this.duration/1000; + this.val.index = 0 + this.scanIndex = 0 + } else { + this.stop(); + } + + } + this.val.index = percentDone; + + if (this.val.index > this.val.points[this.val.points.length-1].x) { + this.val.amp = this.val.points[this.val.points.length-1].y + } else if (this.val.index < this.val.points[0].x) { + this.val.amp = this.val.points[0].y + } else { + this.scanIndex = 0; + while (this.val.index > this.val.points[this.scanIndex].x) { + this.scanIndex++; + } + + var nextPX = this.val.points[this.scanIndex].x; + var prevPX = this.val.points[this.scanIndex-1].x; + var nextPY = this.val.points[this.scanIndex].y; + var prevPY = this.val.points[this.scanIndex-1].y; + + this.val.amp = math.interp((this.val.index-prevPX)/(nextPX - prevPX),prevPY,nextPY); + + } + + this.transmit(this.val); + this.draw(); + } +} + +/** @method start + Start ramp from beginning. If set to loop, will loop the ramp until stopped. */ +envelope.prototype.start = function() { + this.active = true; + this.val.index = 0; + + // set startTime + startTime = nx.context.currentTime; +} + +/** @method stop + Stop the ramp and set progress to 0. */ +envelope.prototype.stop = function() { + this.active = false; + this.val.index = 0; + this.draw(); +} + +envelope.prototype.findNearestNode = function(x, y, nodes) { + var nearestIndex = null; + var nearestDist = 1000; + var before = false; + y = 1 - y; + for (var i = 0; i<nodes.length; i++) { + var distance = Math.sqrt( Math.pow( (nodes[i].x - x), 2), Math.pow((nodes[i].y - (-y)), 2) ); + + if (distance < nearestDist) { + nearestDist = distance; + nearestIndex = i; + before = x > nodes[i].x + } + } + + if (nearestDist>.1) { + if (before) { nearestIndex++ } + this.val.points.splice(nearestIndex,0,{ + x: this.clickPos.x/this.GUI.w, + y: (this.GUI.h-this.clickPos.y)/this.GUI.h + }) + //nearestIndex++; + } + + return nearestIndex; +} + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = { + banner: __webpack_require__(21), + button: __webpack_require__(22), + colors: __webpack_require__(23), + comment: __webpack_require__(24), + crossfade: __webpack_require__(25), + dial: __webpack_require__(26), + envelope: __webpack_require__(27), + joints: __webpack_require__(29), + keyboard: __webpack_require__(30), + matrix: __webpack_require__(31), + message: __webpack_require__(32), + meter: __webpack_require__(33), + metro: __webpack_require__(34), + motion: __webpack_require__(35), + mouse: __webpack_require__(36), + multislider: __webpack_require__(37), + multitouch: __webpack_require__(38), + number: __webpack_require__(39), + position: __webpack_require__(40), + range: __webpack_require__(41), + select: __webpack_require__(42), + slider: __webpack_require__(43), + string: __webpack_require__(44), + tabs: __webpack_require__(45), + text: __webpack_require__(46), + tilt: __webpack_require__(47), + toggle: __webpack_require__(48), + typewriter: __webpack_require__(49), + vinyl: __webpack_require__(50), + waveform: __webpack_require__(51), +} + + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2) +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class joints + 2D slider with connections to several points; a proximity-based multislider. + ```html + <canvas nx="joints"></canvas> + ``` + <canvas nx="joints" style="margin-left:25px"></canvas> +*/ + +var joints = module.exports = function (target) { + this.defaultSize = { width: 150, height: 150 }; + widget.call(this, target); + + /* @property {integer} nodeSize The size of the proximity points in pixels */ + this.nodeSize = this.GUI.w/14; + this.values = [0,0]; + + /** @property {object} val + | | data + | --- | --- + | *x* | x position of touch/mouse + | *y* | y position of touch/mouse + | *node0* | nearness to first node if within range (float 0-1) + | *node1* | nearness to second node if within range (float 0-1) + | *node2* | nearness to third node if within range (float 0-1) + | etc... | + + */ + this.val = { + x: 0.35, + y: 0.35, + node1: 0 + } + /** @property {array} joints An array of objects with x and y properties detailing coordinates of each proximity node. Coordinates are 0-1 floats which are decimal fractions of the width and height. + ```js + // The widget will now have 2 proximity points instead of 8 + joints1.joints = [ + { x: 0.5 , y: 0.2 }, + { x: 0.5 , y: 0.7 } + ] + ``` + */ + this.joints = [ + { x: .1, y: .2 }, + { x: .2, y: .1 }, + { x: .3, y: .7 }, + { x: .4, y: .4 }, + { x: .5, y: .9 }, + { x: .6, y: .15 }, + { x: .7, y: .3 }, + { x: .8, y: .8 }, + ] + this.threshold = this.GUI.w / 3; +} +util.inherits(joints, widget); + +joints.prototype.init = function() { + this.nodeSize = this.GUI.w/14; + this.threshold = this.GUI.w/3; + this.draw(); +} + +joints.prototype.draw = function() { + this.erase(); + + this.drawingX = this.val.x * this.GUI.w; + this.drawingY = this.val.y * this.GUI.h; + + with (this.context) { + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + if (this.val.x != null) { + this.drawNode(); + } + else { + fillStyle = this.colors.border; + font = "14px courier"; + fillText(this.default_text, 10, 20); + } + fillStyle = this.colors.accent; + strokeStyle = this.colors.border; + for (var i in this.joints) { + beginPath(); + arc(this.joints[i].x*this.GUI.w, this.joints[i].y*this.GUI.h, this.nodeSize/2, 0, Math.PI*2, true); + fill(); + closePath(); + var cnctX = Math.abs(this.joints[i].x*this.GUI.w-this.drawingX); + var cnctY = Math.abs(this.joints[i].y*this.GUI.h-this.drawingY); + var strength = cnctX + cnctY; + if (strength < this.threshold) { + beginPath(); + moveTo(this.joints[i].x*this.GUI.w, this.joints[i].y*this.GUI.h); + lineTo(this.drawingX,this.drawingY); + strokeStyle = this.colors.accent; + lineWidth = math.scale( strength, 0, this.threshold, this.nodeSize/2, 5 ); + stroke(); + closePath(); + var scaledstrength = math.scale( strength, 0, this.threshold, 1, 0 ); + this.val["node"+i] = scaledstrength; + } + } + } + + this.drawLabel(); +} + +joints.prototype.drawNode = function() { + //stay within right/left bounds + if (this.drawingX<(this.nodeSize)) { + this.drawingX = this.nodeSize; + } else if (this.drawingX>(this.GUI.w-this.nodeSize)) { + this.drawingX = this.GUI.w - this.nodeSize; + } + //stay within top/bottom bounds + if (this.drawingY < this.nodeSize) { + this.drawingY = this.nodeSize; + } else if (this.drawingY>(this.GUI.h-this.nodeSize)) { + this.drawingY = this.GUI.h - this.nodeSize; + } + + with (this.context) { + globalAlpha=1; + beginPath(); + fillStyle = this.colors.accent; + strokeStyle = this.colors.border; + lineWidth = this.lineWidth; + arc(this.drawingX, this.drawingY, this.nodeSize, 0, Math.PI*2, true); + fill(); + closePath(); + } +} + +joints.prototype.click = function() { + this.val = new Object(); + this.val.x = this.clickPos.x/this.GUI.w; + this.val.y = this.clickPos.y/this.GUI.h; + this.draw(); + this.transmit(this.val); + this.connections = new Array(); + +} + +joints.prototype.move = function() { + this.val = new Object(); + if (this.clicked) { + this.val.x = this.clickPos.x/this.GUI.w; + this.val.y = this.clickPos.y/this.GUI.h; + this.draw(); + this.transmit(this.val); + this.connections = new Array(); + } +} + + +joints.prototype.release = function() { + this.anix = this.deltaMove.x/this.GUI.w; + this.aniy = (this.deltaMove.y)/this.GUI.h; + +} + +/** @method animate + Add simple physics to the widget + @param {string} [type] Currently accepts "bounce" or "none". +*/ + +joints.prototype.animate = function(aniType) { + + switch (aniType) { + case "bounce": + nx.aniItems.push(this.aniBounce.bind(this)); + break; + case "none": + nx.aniItems.splice(nx.aniItems.indexOf(this.aniBounce)); + break; + } + +} + +joints.prototype.anix = 0; +joints.prototype.aniy = 0; + +joints.prototype.aniBounce = function() { + if (!this.clicked && this.val.x) { + this.val.x += (this.anix); + this.val.y += (this.aniy); + this.anix = math.bounce(this.val.x, 0.1, 0.9, this.anix); + this.aniy = math.bounce(this.val.y, 0.1, 0.9, this.aniy); + this.draw(); + this.transmit(this.val); + } +} + + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var widget = __webpack_require__(1); +var drawing = __webpack_require__(3); +var math = __webpack_require__(2); + +/** + @class keyboard + Piano keyboard which outputs MIDI + ```html + <canvas nx="keyboard"></canvas> + ``` + <canvas nx="keyboard" style="margin-left:25px"></canvas> +*/ + +var keyboard = module.exports = function (target) { + + this.defaultSize = { width: 300, height: 75 }; + widget.call(this, target); + + /** @property {integer} octaves Number of octaves on the keyboard + ```js + //This key pattern would put a black key between every white key + keyboard1.octaves = 1 + keyboard1.init() + ``` + + */ + + this.octaves = 3; + + this.white = { + width:0, + height:0 + } + this.black = { + width:0, + height:0 + } + this.wkeys = new Array(); + this.bkeys = new Array(); + + /** @property {array} keypattern Array of 'w' and 'b' denoting the pattern of white and black keys. This can be customized! The pattern can be any number of keys, however each black key must be surrounded by two white keys. + ```js + //This key pattern would put a black key between every white key + keyboard1.keypattern = ['w','b','w','b','w','b','w','b','w','b','w','b'] + keyboard1.init() + + //This key pattern uses only white keys + keyboard2.keypattern = ['w','w','w','w','w','w','w','w','w','w','w','w'] + keyboard2.init() + ``` + + + */ + this.keypattern = ['w','b','w','b','w','w','b','w','b','w','b','w'] + this.keys = new Array(); + /** @property {integer} midibase The MIDI note value of the lowest note on the keyboard. Defaults to 48. */ + this.midibase = 48; + this.lineWidth = 1; + + //to enable multitouch + this.fingers = [ + { + key: -1, + pkey: -1 + + } + ] + this.multitouch = false; // will auto switch to true if experiences 2 simultaneous touches + this.oneleft = false; + + /** @property {string} mode Play mode. Currently accepts "button" (default) or "sustain" in which each key acts as a toggle. */ + this.mode = "button" // modes: "button", "sustain" and, possibly in future, "aftertouch" + + // for each key: x, y, w, h, color, on, note + + /** @property {object} val Core interactive values and data output + | | data + | --- | --- + | *on* | 0 if noteon, 1 if noteoff + | *note* | MIDI value of key pressed + | *midi* | paired MIDI message as a string - example "20 0" - This is to allow for simultaneous arrival of the MIDI pair if sent as an OSC message. + */ + this.val = { + on: 0, + note: 0, + midi: "0 0" + }; + + this.init(); + +} +util.inherits(keyboard, widget); + +keyboard.prototype.init = function() { + + //recap from header + this.white = { + width:0, + height:0 + } + this.black = { + width:0, + height:0 + } + this.wkeys = new Array(); + this.bkeys = new Array(); + + /** @property {array} keys Array of key objects. This may be of use in combination with the keyboard.toggle method. */ + this.keys = new Array(); + + //new stuff + this.white.num = 0; + for (var i=0;i<this.keypattern.length;i++) { + this.keypattern[i]=='w' ? this.white.num++ : null; + } + this.white.num *= this.octaves; + + this.white.width = this.GUI.w/this.white.num + this.white.height = this.GUI.h + + this.black.width = this.white.width*0.6 + this.black.height = this.GUI.h*0.6 + + for (var i=0;i<this.keypattern.length*this.octaves;i++) { + this.keys[i] = { + note: i+this.midibase, + on: false + } + switch (this.keypattern[i%this.keypattern.length]) { + case 'w': + this.keys[i].x = this.wkeys.length*this.white.width, + this.keys[i].y = 0, + this.keys[i].w = this.white.width, + this.keys[i].h = this.white.height, + this.keys[i].type = 'w'; + this.keys[i].index = i; + this.wkeys.push(this.keys[i]); + + break; + case 'b': + this.keys[i].x = this.wkeys.length*this.white.width - this.black.width/2, + this.keys[i].y = 0, + this.keys[i].w = this.black.width, + this.keys[i].h = this.black.height, + this.keys[i].type = 'b'; + this.keys[i].index = i; + this.bkeys.push(this.keys[i]); + break; + } + } + + + this.draw(); +} + +keyboard.prototype.draw = function() { + + with (this.context) { + strokeStyle = this.colors.borderhl; + lineWidth = 1; + + for (var i in this.wkeys) { + fillStyle = this.wkeys[i].on ? this.colors.borderhl : this.colors.fill + strokeRect(this.wkeys[i].x,0,this.white.width,this.white.height); + fillRect(this.wkeys[i].x,0,this.white.width,this.white.height); + } + for (var i in this.bkeys) { + fillStyle = this.bkeys[i].on ? this.colors.borderhl : this.colors.black + fillRect(this.bkeys[i].x,0,this.black.width,this.black.height); + } + //strokeRect(0,0,this.GUI.w,this.GUI.h); + } + this.drawLabel(); +} + +/** @method toggle + Manually toggle a key on or off, and transmit the new state. + @param {object} [key] A key object (from the .keys array) to be turned on or off + @param {boolean} [on/off] (Optional) Whether the key should be turned on (true) or off (false). If this parameter is left out, the key will switch to its opposite state. + ```js + // Turns the first key on + keyboard1.toggle( keyboard1.keys[0], true ); + ``` +*/ +keyboard.prototype.toggle = function(key, data) { + if (this.mode=="button") { + if (key) { + if (data || data===false) { + key.on = data; + } else { + key.on = !key.on; + } + + var on = key.on ? 1 : 0; + var amp = math.invert(this.clickPos.y/this.GUI.h) * 128; + amp = math.prune(math.clip(amp,5,128),0); + + this.val = { + on: on*amp, + note: key.note, + midi: key.note + " " + on + }; + this.transmit(this.val); + this.draw(); + } + } else if (this.mode=="sustain") { + if (key) { + if (data) { + key.on = data; + } else { + key.on = !key.on; + } + + var on = key.on ? 1 : 0; + var amp = math.invert(this.clickPos.y/this.GUI.h) * 128; + amp = math.prune(math.clip(amp,5,128),0); + + this.val = { + on: on*amp, + note: key.note, + midi: key.note + " " + on + }; + this.transmit(this.val); + this.draw(); + } + + } + +} + +keyboard.prototype.whichKey = function (x, y){ + + for (var i in this.bkeys) { + if (drawing.isInside({"x":x,"y":y}, this.bkeys[i])) { + return this.bkeys[i] + } + } + + var keyx = ~~(x/this.white.width); + if (keyx>=this.wkeys.length) { keyx = this.wkeys.length-1 } + if (keyx<0) { keyx = 0 } + return this.wkeys[keyx]; +} + +keyboard.prototype.click = function(e) { + + if (this.clickPos.touches.length>1 || this.multitouch) { + this.multitouch = true; + if (this.clickPos.touches.length>=2 && this.oneleft) { + this.oneleft = false; + } + this.keysinuse = new Array(); + for (var j=0;j<this.clickPos.touches.length;j++) { + this.fingers[j] = { + key: this.whichKey(this.clickPos.touches[j].x, this.clickPos.touches[j].y) + } + if (!this.fingers[j].key.on) { + this.toggle(this.fingers[j].key, true) + } + this.keysinuse.push(this.fingers[j].key.index) + } + for (var j=0;j<this.keys.length;j++) { + if (this.keys[j].on && this.keysinuse.indexOf(this.keys[j].index)<0) { + this.toggle(this.keys[j], false); + } + } + } else { + this.fingers[0].pkey = this.fingers[0].key; + this.fingers[0].key = this.whichKey(this.clickPos.x, this.clickPos.y); + this.toggle(this.fingers[0].key) + } + +} + +keyboard.prototype.move = function(e) { + if (this.clickPos.touches.length>1 || this.multitouch) { + this.keysinuse = new Array(); + for (var j=0;j<this.clickPos.touches.length;j++) { + this.fingers[j] = { + key: this.whichKey(this.clickPos.touches[j].x, this.clickPos.touches[j].y) + } + if (!this.fingers[j].key.on) { + this.toggle(this.fingers[j].key, true) + } + this.keysinuse.push(this.fingers[j].key.index) + } + for (var j=0;j<this.keys.length;j++) { + if (this.keys[j].on && this.keysinuse.indexOf(this.keys[j].index)<0) { + this.toggle(this.keys[j], false); + } + } + } else { + this.fingers[0].pkey = this.fingers[0].key; + this.fingers[0].key = this.whichKey(this.clickPos.x, this.clickPos.y); + if (this.fingers[0].key && this.fingers[0].key.index != this.fingers[0].pkey.index) { + this.toggle(this.fingers[0].pkey, false); + this.toggle(this.fingers[0].key, true); + } + } +} + +keyboard.prototype.release = function(e) { + if (this.clickPos.touches.length>1 || this.multitouch) { + this.keysinuse = new Array(); + for (var j=0;j<this.clickPos.touches.length;j++) { + if (this.oneleft && this.clickPos.touches.length==1) { + break; + } + this.fingers[j] = { + key: this.whichKey(this.clickPos.touches[j].x, this.clickPos.touches[j].y) + } + this.keysinuse.push(this.fingers[j].key.index) + } + for (var j=0;j<this.keys.length;j++) { + if (this.keys[j].on && this.keysinuse.indexOf(this.keys[j].index)<0) { + this.toggle(this.keys[j], false); + } + } + if (this.clickPos.touches.length==1) { this.oneleft = true } + } else { + if (this.mode=="button") { + this.toggle(this.fingers[0].key, false); + } + } +} + + + + + + + + + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2); +var drawing = __webpack_require__(3); +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class matrix + Matrix of toggles, with sequencer functionality. + ```html + <canvas nx="matrix"></canvas> + ``` + <canvas nx="matrix" style="margin-left:25px"></canvas> +*/ + + +var matrix = module.exports = function (target) { + this.defaultSize = { width: 100, height: 100 }; + widget.call(this, target); + + + /** @property {integer} row Number of rows in the matrix + ```js + matrix1.row = 2; + matrix1.init() + ``` + */ + this.row = 4; + + /** @property {integer} col Number of columns in the matrix + ```js + matrix1.col = 10; + matrix1.init() + ``` + */ + this.col = 4; + + this.cellHgt; + this.cellWid; + + /** @property {array} matrix Nested array of matrix values. Cells can be manually altered using .matrix (see code), however this will *not* cause the new value to be transmit. See .setCell() to set/transmit cell values. + ```js + //Turn on the cell at row 1 column 2 + matrix1.matrix[1][2] = 1 + matrix1.draw() + + + //Turn off the cell at row 3 column 0 + matrix1.matrix[3][0] = 0 + matrix1.draw() + ``` + */ + this.matrix; + + /** @property {object} val Core values and data output + | | data + | --- | --- + | *row* | Current row being changed + | *col* | Current column being changed + | *level* | Whether cell is on or off (0 or 1) + | *list * | Array of values in highlighted column (if sequencing) + */ + this.val = { + row: 0, + col: 0, + level: 0, + list: new Array() + } + + //for mouse logic + this.cur; + this.prev; + + /** @property {boolean} erasing Whether or not mouse clicks will erase cells. Set to true automatically if you click on an "on" cell. */ + this.erasing = false; + + /** @property {integer} place When sequencing, the current column. */ + this.place = null; + + this.starttime; + this.lastbeat; + this.thisframe = 0; + this.lastframe = 0; + this.context.lineWidth = 1; + + this.sequencing = false; + + /** @property {integer} cellBuffer How much padding between matrix cells, in pixels */ + this.cellBuffer = 4; + + /** @property {string} sequenceMode Sequence pattern (currently accepts "linear" which is default, or "random") */ + this.sequenceMode = "linear"; // "linear" or "random". future options would be "wander" (drunk) or "markov" + + /** @property {integer} bpm Beats per minute (if sequencing) + ```js + matrix1.bpm = 120; + ``` + */ + this.bpm = 120; + this.pbpm = this.bpm + + this.starttime = nx.starttime; + + this.init(); + +} +util.inherits(matrix, widget); + + + +matrix.prototype.init = function() { + + + this.pmatrix = this.matrix ? this.matrix : false; + + this.matrix = null; + // generate 2D matrix array + this.matrix = new Array(this.col) + for (var i=0;i<this.col;i++) { + this.matrix[i] = new Array(this.row) + for (var j=0;j<this.row;j++) { + this.matrix[i][j] = this.pmatrix ? this.pmatrix[i] ? this.pmatrix[i][j] : 0 : 0; // set value of each matrix cell + } + } + + this.draw(); + + this.life = this.unboundlife.bind(this) + +} + +matrix.prototype.draw = function() { + + this.erase(); + + this.cellWid = this.GUI.w/this.col; + this.cellHgt = this.GUI.h/this.row; + + with (this.context) { + strokeStyle = this.colors.fill + //lineWidth = 0 + //strokeRect(0,0,this.GUI.w,this.GUI.h) + } + + for (var i=0;i<this.row;i++){ + for (var j=0;j<this.col;j++) { + var st_x = j*this.cellWid // starting point(left) + j==0 ? st_x += 0 : null; + var st_y = i*this.cellHgt; // starting point(top) + i==0 ? st_y += 0 : null; + var boxwid = this.cellWid; + var boxhgt = this.cellHgt; + + + with (this.context) { + strokeStyle = this.colors.border; + lineWidth = this.cellBuffer; + if (this.matrix[j][i] > 0) { + fillStyle = this.colors.accent; + } else { + fillStyle = this.colors.fill; + } + fillRect(st_x+this.cellBuffer/2, st_y+this.cellBuffer/2, boxwid-this.cellBuffer, boxhgt-this.cellBuffer); + + // sequencer highlight + if (this.place == j) { + globalAlpha = 0.4; + fillStyle = this.colors.border; + fillRect(st_x, st_y, boxwid, boxhgt); + globalAlpha = 1; + } + + } + } + } + + this.drawLabel(); +} + + + +matrix.prototype.click = function(e) { + + this.cur = { + col: ~~(this.clickPos.x/this.cellWid), + row: ~~(this.clickPos.y/this.cellHgt) + } + + if (this.matrix[this.cur.col][this.cur.row]) { + this.matrix[this.cur.col][this.cur.row] = 0; + this.erasing = true; + } else { + this.matrix[this.cur.col][this.cur.row] = 1; + this.erasing = false; + } + + this.cur.value = this.matrix[this.cur.col][this.cur.row] + this.prev = this.cur; + +// var data = this.matrix[this.cur.col]; +// data = data.join(); +// data = data.replace(/\,/g," "); + + this.val = { + row: this.cur.row, + col: this.cur.col, + level: this.cur.value + } + + this.transmit(this.val); + this.draw(); +} + +matrix.prototype.move = function(e) { + if (this.clicked) { + + this.cur = { + col: ~~(this.clickPos.x/this.cellWid), + row: ~~(this.clickPos.y/this.cellHgt) + } + + if (this.cur.row < this.row && this.cur.col < this.col && this.cur.row >= 0 && this.cur.col >=0) { + if (this.cur.col!=this.prev.col || this.cur.row != this.prev.row) { + if (this.erasing) { + this.matrix[this.cur.col][this.cur.row] = 0; + } else { + this.matrix[this.cur.col][this.cur.row] = 1; + } + + this.cur.value = this.matrix[this.cur.col][this.cur.row] + this.prev = this.cur; + + this.val = { + row: this.cur.row, + col: this.cur.col, + level: this.cur.value + } + + this.transmit(this.val); + this.draw(); + } + } + + } +} + + +/** @method setCell +Manually set an individual cell on/off and transmit the new value. +@param {integer} [col] The column of the cell to be turned on/off +@param {integer} [row] The row of the cell to be turned on/off +@param {boolean} [on/off] Whether the cell should be turned on/off + +```js + // Turns cell on at column 1 row 3 + matrix1.setCell(1,3,true); +``` +*/ +matrix.prototype.setCell = function(col,row,on) { + + var value = on ? 1 : 0; + this.matrix[col][row] = value + + this.val = { + row: row, + col: col, + level: value + } + + this.transmit(this.val); + this.draw(); + +} + +/** @method sequence +@param {float} [bpm] Beats per minute of the pulse +Turns the matrix into a sequencer. + +```js + matrix1.sequence(240); +``` +*/ +matrix.prototype.sequence = function(bpm) { + + if (bpm) { + this.bpm = bpm; + } + this.sequencing = true; + requestAnimationFrame(this.seqStep.bind(this)); + +} + +matrix.prototype.setBPM = function(bpm) { + this.bpm = bpm + //console.log(bpm) + //nx.interval.bpm(this.pulse,bpm) +} + +/** @method stop +Stops the matrix sequencer. + +```js + matrix1.stop(); +``` +*/ +matrix.prototype.stop = function() { + this.sequencing = false; +} + +matrix.prototype.seqStep = function() { + + if (this.bpm == 0) { this.bpm = 1 } + + //current time + var now = new Date().getTime(); + + //delta time since start + var dt = now - this.starttime; + + if (this.bpm != this.pbpm) { + + //frame + decimal since last beat, in old bpm + var timeP = (dt/(60000/this.pbpm)) + + // scale to new bpm + dt = timeP * (60000/this.bpm) + + //adjust the starttime reference point + this.starttime = now - dt + + //calculate new frame # + this.thisframe = ~~(dt/(60000/this.bpm)); + + } else { + + //this.thisframe is a constantly ascending integer counter + //to compare with this.lastframe to determine when to increment this.place + //this.thisframe IS NOT the current column. + //the current column is this.place, which is set conditionally below. + this.thisframe = ~~(dt/(60000/this.bpm)); + + } + + this.pbpm = this.bpm; + + if (this.thisframe != this.lastframe) { + + this.lastbeat = now; + + if (this.sequenceMode=="linear") { + this.place++; + } else if (this.sequenceMode=="random") { + this.place = math.random(this.col); + } + if (this.place>=this.col) { + this.place = 0; + } + + if (this.place==null) { + this.place = 0; + } + + this.jumpToCol(this.place); + + } + + this.lastframe = this.thisframe; + if (this.sequencing) { + requestAnimationFrame(this.seqStep.bind(this)); + } +} + +/** @method jumpToCol +Jump to a certain column of the matrix, highlight it, and output its values as an array. Column numbers start at 0. + +```js + matrix1.jumpToCol(1); +``` +*/ + +matrix.prototype.jumpToCol = function(place) { + this.place = place + this.val = { + list: this.matrix[this.place] + } + this.transmit(this.val); + this.draw(); +} + + +matrix.prototype.customDestroy = function() { + this.stop(); +} + +matrix.prototype.unboundlife = function() { + if (!this.clicked) { + this.newmatrix = [] + for (var i=0;i<this.col;i++) { + this.newmatrix[i] = [] + for (var j=0;j<this.row;j++) { + var total = 0 + if (i-1 >= 0) { + total += this.matrix[i-1][j-1] ? this.matrix[i-1][j-1] : 0 + total += this.matrix[i-1][j] ? this.matrix[i-1][j] : 0 + total += this.matrix[i-1][j+1] ? this.matrix[i-1][j+1] : 0 + } + total += this.matrix[i][j-1] ? this.matrix[i][j-1] : 0 + total += this.matrix[i][j+1] ? this.matrix[i][j+1] : 0 + if (i+1 < this.col) { + total += this.matrix[i+1][j-1] ? this.matrix[i+1][j-1] : 0 + total += this.matrix[i+1][j] ? this.matrix[i+1][j] : 0 + total += this.matrix[i+1][j+1] ? this.matrix[i+1][j+1] : 0 + } + + if (this.matrix[i][j]) { + if (total < 2) { + this.newmatrix[i][j] = 0 + } else if (total ==2 || total == 3) { + this.newmatrix[i][j] = 1 + } else if (total > 3) { + this.newmatrix[i][j] = 0 + } + } else if (!this.matrix[i][j] && total == 3) { + this.newmatrix[i][j] = 1 + } else { + this.newmatrix[i][j] = this.matrix[i][j] + } + } + } + this.matrix = this.newmatrix + } + this.transmit({ grid: this.matrix}) + this.draw() +} + +/** @method life +Alters the matrix according to Conway's Game of Life. Matrix.life() constitutes one tick through the game. To simulate the game, you might use setInterval. + +```js + //one tick + matrix1.life(); + + //repeated ticks at 80ms + setInterval(matrix1.life,80) +``` +*/ +matrix.prototype.life = function() { + return false; +} + + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class message + Send a string of text. + ```html + <canvas nx="message"></canvas> + ``` + <canvas nx="message" style="margin-left:25px"></canvas> +*/ + +var message = module.exports = function (target) { + + this.defaultSize = { width: 100, height: 30 }; + widget.call(this, target); + + + /** @property {object} val + | | data + | --- | --- + | *value* | Text of message, as string + */ + + this.val = { + value: "send a message" + } + + /** @property {integer} size Text size in px */ + this.size = 14; + +} +util.inherits(message, widget); + +message.prototype.init = function() { + if (this.canvas.getAttribute("label")) { + this.val.value = this.canvas.getAttribute("label"); + } + //this.size = Math.sqrt((this.GUI.w * this.GUI.h) / (this.val.message.length)); + this.draw(); +} + +message.prototype.draw = function() { + this.erase(); + with (this.context) { + if (this.clicked) { + fillStyle = this.colors.border; + } else { + fillStyle = this.colors.fill; + } + fillRect(0,0,this.GUI.w,this.GUI.h) + + if (this.clicked) { + fillStyle = this.colors.black; + } else { + fillStyle = this.colors.black; + } + textAlign = "left"; + font = this.size+"px "+nx.font; + } + this.wrapText(this.val.value, 5, 1+this.size, this.GUI.w-6, this.size); +} + +message.prototype.click = function(e) { + this.draw(); + this.transmit(this.val); +} + +message.prototype.release = function(e) { + this.draw(); +} + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var drawing = __webpack_require__(3); +var widget = __webpack_require__(1); + +/** + + @public + @class meter + + Decibel level meter. + + ```html + <canvas nx="meter"></canvas> + ``` + <canvas nx="meter" style="margin-left:25px"></canvas> +*/ + +var meter = module.exports = function(target) { + + // to update, eventually (note to self) + // possibly a less-frequent animation request, to lighten the graphics load + // option for stereo meter? i.e. optional third .setup(ctx,s1,s2) argument + + this.defaultSize = { width: 20, height: 50 }; + widget.call(this, target); + + this.val = { + level: 0 + } + this.dataArray; + this.bars = 8; + + this.init(); + +} +util.inherits(meter, widget); + + +meter.prototype.init = function(){ + this.bar = { + x: 0, + y: 0, + w: this.GUI.w, + h: this.GUI.h/this.bars + } + with (this.context) { + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w, this.GUI.h); + } +} + + + +/** @method setup + Connect the meter to an audio source and start the meter's graphics. + @param {audio context} [context] The audio context hosting the source node + @param {audio node} [source] The audio source node to analyze + */ +meter.prototype.setup = function(actx,source){ + this.actx = actx; + this.source = source; + + this.analyser = this.actx.createAnalyser(); + this.analyser.smoothingTimeConstant = 0.85; + this.analyser.fftsize = 1024; + this.bufferLength = this.analyser.frequencyBinCount; + this.dataArray = new Uint8Array(this.bufferLength); + this.source.connect(this.analyser); + + this.draw(); +} + +meter.prototype.draw = function(){ + + if(this.dataArray) { + this.analyser.getByteTimeDomainData(this.dataArray); + + var max = Math.max.apply(null, this.dataArray); + var min = Math.min.apply(null, this.dataArray); + var amp = max - min; + amp /= 240 + + //converts amps to db + var db = 20 * (Math.log(amp) / Math.log(10)) + + with (this.context){ + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w, this.GUI.h); + + //scales: -40 to +10 db range => a number of bars + var dboffset = Math.floor((db + 40) / (50/this.bars) ); + + for (var i = 0; i<this.bars; i++) { + + // 0+ db is red + if(i >= this.bars*.8) { + fillStyle = 'rgb(255,0,0)'; + + // -5 to 0 db is yellow + } else if (i < this.bars*.8 && i >= this.bars*.69) { + fillStyle = 'rgb(255,255,0)'; + + // -40 to -5 db is green + } else if (i < this.bars*.69) { + fillStyle = 'rgb(0,255,0)'; + } + + // draw bar + if (i<dboffset) + fillRect(1,this.GUI.h-this.bar.h*i,this.GUI.w-2,this.bar.h-2); + + } + } + } + + setTimeout(function() { + window.requestAnimationFrame(this.draw.bind(this)); + }.bind(this), 80) + +} + + + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2) +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class metro + Bouncing ball metronome + ```html + <canvas nx="metro"></canvas> + ``` + <canvas nx="metro" style="margin-left:25px"></canvas> +*/ + +var metro = module.exports = function (target) { + this.defaultSize = { width: 100, height: 20 }; + widget.call(this, target); + + //define unique attributes + + /** @property {object} val + | | data + | --- | --- + | *beat* | Which side the ball is bouncing on (0 if left, 1 if right) + */ + this.val = { + beat: 0 + } + + this.x = 10; + this.y = 10; + this.loc = 10; + this.nodeSize = 10; + /** @property {float} speed Speed of the ball (default 1) */ + this.speed = 1; + this.direction = 1; + /** @property {string} orientation Orientation of metro. Default is "horizontal". */ + this.orientation = "horizontal" + this.boundary = this.GUI.w + + nx.aniItems.push(this.advance.bind(this)); + this.active = true; + + this.init(); +} +util.inherits(metro, widget); + +metro.prototype.init = function() { + this.nodeSize = Math.min(this.GUI.w,this.GUI.h)/2; + if (this.GUI.w<this.GUI.h) { + this.orientation = "vertical" + this.boundary = this.GUI.h + } else { + this.orientation = "horizontal" + this.boundary = this.GUI.w + } + this.x = this.nodeSize; + this.y = this.nodeSize; + this.loc = this.nodeSize; + + this.draw(); + +} + +metro.prototype.draw = function() { + this.erase() + with (this.context) { + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + + beginPath(); + fillStyle = this.colors.accent; + arc(this.x, this.y, this.nodeSize, 0, Math.PI*2, true); + fill(); + closePath(); + } + + this.drawLabel(); +} + +metro.prototype.click = function() { +} + +metro.prototype.move = function() { + if (this.clicked) { + this.speed -= (this.deltaMove.y / 50); + } +} + +metro.prototype.release = function() { +} + +metro.prototype.advance = function() { + if (this.speed>=0) { + this.loc += this.speed * this.direction; + } else { + this.loc += this.speed * this.direction; + } + if (this.loc-this.nodeSize<0 || this.loc+this.nodeSize>this.boundary) { + this.val.beat = math.scale(this.direction,-1,1,0,1) + this.transmit(this.val); + this.direction *= -1 + } + if (this.orientation == "vertical") { + this.y = this.loc + } else { + this.x = this.loc + } + this.draw(); +} + +metro.prototype.customDestroy = function() { + nx.removeAni(this.advance.bind(this)) +} + +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2) +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class motion + Mobile motion sensor. Does not work on all devices! <br> **Notes:** Clicking on this widget toggles it inactive or active. <br> + We recommend not calling .init() on this object after the original initialization, because it will add additional redundant motion listeners to your document. + ```html + <canvas nx="motion"></canvas> + ``` + <canvas nx="motion" style="margin-left:25px"></canvas> +*/ + +var motion = module.exports = function (target) { + this.defaultSize = { width: 75, height: 75 }; + widget.call(this, target); + + this.motionLR; + this.motionFB; + this.z; + /** @property {boolean} active Whether or not the motion widget is on (animating and transmitting data). */ + this.active = true; + + this.px = 0; + this.py = 0; + this.pz = 0; + + /** @property {object} val Object containing the core interactive aspects of the widget, which are also its data output. Has the following properties: + | | data + | --- | --- + | *x* | X-axis motion if supported (-1 to 1) + | *y* | Y-axis motion if supported (-1 to 1) + | *z* | Z-axis motion if supported (-1 to 1 or 0 to 360 depending on device) + */ + this.val = { + x: 0, + y: 0, + z: 0 + } + + /** @property {string} text Text shown on motion object + */ + + this.text = "Motion"; + this.init(); + + this.boundMotion = this.motionlistener.bind(this) + + if (window.DeviceMotionEvent) { + window.addEventListener('devicemotion', this.boundMotion, false); + } else { + with (this.context) { + fillText("incompatible",0,0) + this.active = false; + } + } + +} +util.inherits(motion, widget); + +motion.prototype.deviceMotionHandler = function() { + + this.val = { + x: math.prune(this.motionLR/10,4), + y: math.prune(this.motionFB/10,4), + z: math.prune(this.z/10,4) + } + + this.transmit(this.val); + +} + +motion.prototype.motionlistener = function(e) { + var data = e.acceleration + + if (this.active) { + + + this.motionLR = nx.lp(this.canvasID+"motionx",data.x,20) + this.motionFB = nx.lp(this.canvasID+"motiony",data.y,20) + this.z = nx.lp(this.canvasID+"motionz",data.z,20) + this.deviceMotionHandler() + + this.draw(); + + if (data.x===null || data.x===undefined) { + this.erase() + with (this.context) { + fillStyle = this.colors.fill + fillRect(0,0,this.GUI.w,this.GUI.h) + fillStyle = this.colors.black + font="12px courier"; + textAlign = "center" + fillText("no data",this.GUI.w/2,this.GUI.h/2) + } + this.active = false; + } + } +} + +motion.prototype.init = function() { + this.draw() +} + +motion.prototype.draw = function() { + + this.erase() + + with (this.context) { + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + fillStyle = this.colors.accent; + var eighth = Math.PI/4 + if (this.motionFB<0) { + beginPath() + moveTo(this.GUI.w/2,this.GUI.h/2) + arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,eighth*5,eighth*7,false) + globalAlpha = Math.pow(this.motionFB, 2) + fill() + closePath() + } else { + beginPath() + moveTo(this.GUI.w/2,this.GUI.h/2) + arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,eighth*1,eighth*3,false) + globalAlpha = Math.pow(this.motionFB, 2) + fill() + closePath() + } + if (this.motionLR<0) { + beginPath() + moveTo(this.GUI.w/2,this.GUI.h/2) + arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,eighth*7,eighth*1,false) + globalAlpha = Math.pow(this.motionLR, 2) + fill() + closePath() + } else { + beginPath() + moveTo(this.GUI.w/2,this.GUI.h/2) + arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,eighth*3,eighth*5,false) + globalAlpha = Math.pow(this.motionLR, 2) + fill() + closePath() + } + beginPath() + moveTo(this.GUI.w/2,this.GUI.h/2) + arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/6,0,Math.PI*2,false) + globalAlpha = Math.pow(this.z, 2) + fill() + closePath() + globalAlpha = 1 + } + this.drawLabel(); +} + +motion.prototype.click = function() { + this.active = !this.active; + this.draw() +} + +motion.prototype.customDestroy = function() { + this.active = false; + window.removeEventListener("devicemotion",this.motionlistener,false); +} + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var widget = __webpack_require__(1); +var math = __webpack_require__(2); + +/** + @class mouse + Mouse tracker, relative to web browser window. + ```html + <canvas nx="mouse"></canvas> + ``` + <canvas nx="mouse" style="margin-left:25px"></canvas> +*/ + +var mouse = module.exports = function (target) { + + this.defaultSize = { width: 98, height: 100 }; + widget.call(this, target); + + /** @property {object} val + | | data + | --- | --- + | *x* | x value of mouse relative to browser + | *y* | y value of mouse relative to browser + | *deltax* | x change in mouse from last position + | *deltay* | y change in mouse from last position + */ + this.val = { + x: 0, + y: 0, + deltax: 0, + deltay: 0 + } + this.inside = new Object(); + this.boundmove = this.preMove.bind(this) + this.mousing = window.addEventListener("mousemove", this.boundmove, false); + + this.init(); +} +util.inherits(mouse, widget); + +mouse.prototype.init = function() { + + this.inside.height = this.GUI.h; + this.inside.width = this.GUI.w; + this.inside.left = 0; + this.inside.top = 0; + this.inside.quarterwid = (this.inside.width)/4; + + this.draw(); +} + +mouse.prototype.draw = function() { + this.erase(); + + with (this.context) { + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + + var scaledx = -(this.val.x) * this.GUI.h; + var scaledy = -(this.val.y) * this.GUI.h; + var scaleddx = -(this.val.deltax) * this.GUI.h - this.GUI.h/2; + var scaleddy = -(this.val.deltay) * this.GUI.h - this.GUI.h/2; + + fillStyle = this.colors.accent; + fillRect(this.inside.left, this.inside.height, this.inside.quarterwid, scaledx); + fillRect(this.inside.quarterwid, this.inside.height, this.inside.quarterwid, scaledy); + fillRect(this.inside.quarterwid*2, this.inside.height, this.inside.quarterwid, scaleddx); + fillRect(this.inside.quarterwid*3, this.inside.height, this.inside.quarterwid, scaleddy); + + globalAlpha = 1; + fillStyle = this.colors.fill; + textAlign = "center"; + font = this.GUI.w/7+"px "+this.font; +/* fillText("x", this.inside.quarterwid*0 + this.inside.quarterwid/2, this.GUI.h-7); + fillText("y", this.inside.quarterwid*1 + this.inside.quarterwid/2, this.GUI.h-7); + fillText("dx", this.inside.quarterwid*2 + this.inside.quarterwid/2, this.GUI.h-7); + fillText("dy", this.inside.quarterwid*3 + this.inside.quarterwid/2, this.GUI.h-7); +*/ + globalAlpha = 1; + } + + this.drawLabel(); +} + +mouse.prototype.move = function(e) { + this.val = { + deltax: e.clientX/window.innerWidth - this.val.x, + deltay: math.invert(e.clientY/window.innerHeight) - this.val.y, + x: e.clientX/window.innerWidth, + y: math.invert(e.clientY/window.innerHeight) + } + this.draw(); + this.transmit(this.val); + +} + +mouse.prototype.customDestroy = function() { + window.removeEventListener("mousemove", this.boundmove, false); +} + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2) +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class multislider + Multiple vertical sliders in one interface. + ```html + <canvas nx="multislider"></canvas> + ``` + <canvas nx="multislider" style="margin-left:25px"></canvas> +*/ +var multislider = module.exports = function (target) { + + this.defaultSize = { width: 100, height: 75 }; + widget.call(this, target); + + /** @property {integer} sliders Number of sliders in the multislider. (Must call .init() after changing this setting, or set with .setNumberOfSliders) */ + this.sliders = 15; + + /** @property {array} val Array of slider values. <br> **Note:** This widget's output is not .val! Transmitted output is: + + | | data + | --- | --- + | *(slider index)* | value of currently changed slider + | list | all multislider values as list. (if the interface sends to js or node, this list will be an array. if sending to ajax, max7, etc, the list will be a string of space-separated values) + + */ + + this.sliderClicked = 0; + this.oldSliderToMove; + this.init(); +} +util.inherits(multislider, widget); + +multislider.prototype.init = function() { + this.val = new Array(); + for (var i=0;i<this.sliders;i++) { + this.val[i] = 0.7; + } + this.realSpace = { x: this.GUI.w, y: this.GUI.h } + this.sliderWidth = this.realSpace.x/this.sliders; + this.draw(); +} + +multislider.prototype.draw = function() { + this.erase(); + with (this.context) { + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + + strokeStyle = this.colors.accent; + fillStyle = this.colors.accent; + lineWidth = 5; + + for(var i=0; i<this.sliders; i++) { + beginPath(); + moveTo(i*this.sliderWidth, this.GUI.h-this.val[i]*this.GUI.h); + lineTo(i*this.sliderWidth + this.sliderWidth, this.GUI.h-this.val[i]*this.GUI.h); + stroke(); + lineTo(i*this.sliderWidth + this.sliderWidth, this.GUI.h); + lineTo(i*this.sliderWidth, this.GUI.h); + globalAlpha = 0.3 - (i%3)*0.1; + fill(); + closePath(); + globalAlpha = 1; + // var separation = i==this.sliders-1 ? 0 : 1; + // fillRect(i*this.sliderWidth, this.GUI.h-this.val[i]*this.GUI.h, this.sliderWidth-separation, this.val[i]*this.GUI.h) + } + } + this.drawLabel(); +} + +multislider.prototype.click = function() { + this.oldSliderToMove = false; + this.move(true); +} + +multislider.prototype.move = function(firstclick) { + if (this.clicked) { + + + if (this.clickPos.touches.length>1) { + + for (var i=0;i<this.clickPos.touches.length;i++) { + var sliderToMove = Math.floor(this.clickPos.touches[i].x / this.sliderWidth); + sliderToMove = math.clip(sliderToMove,0,this.sliders-1); + this.val[sliderToMove] = math.clip(math.invert((this.clickPos.touches[i].y / this.GUI.h)),0,1); + } + + } else { + + var sliderToMove = Math.floor(this.clickPos.x / this.sliderWidth); + sliderToMove = math.clip(sliderToMove,0,this.sliders-1); + this.val[sliderToMove] = math.clip(math.invert(this.clickPos.y / this.GUI.h),0,1); + + if (this.oldSliderToMove && this.oldSliderToMove > sliderToMove + 1) { + var missed = this.oldSliderToMove - sliderToMove - 1; + for (var i=1;i<=missed;i++) { + this.val[sliderToMove+i] = this.val[sliderToMove] + (this.val[this.oldSliderToMove] - this.val[sliderToMove]) * ((i/(missed+1))); + } + } else if (this.oldSliderToMove && sliderToMove > this.oldSliderToMove + 1) { + var missed = sliderToMove - this.oldSliderToMove - 1; + for (var i=1;i<=missed;i++) { + this.val[this.oldSliderToMove+i] = this.val[this.oldSliderToMove] + (this.val[sliderToMove] - this.val[this.oldSliderToMove]) * ((i/(missed+1))); + } + } + + } + this.draw(); + } + var msg = new Object() + msg[sliderToMove] = this.val[sliderToMove] + if (this.destination=="js" || this.destination=="node") { + msg["list"] = this.val; + } else { + msg["list"] = new String(); + for (var key in this.val) { msg["list"] += this.val[key] + " " } + } + this.transmit(msg); + this.oldSliderToMove = sliderToMove; + +} + +/** @method setNumberOfSliders +@param {integer} [num] New number of sliders in the multislider */ +multislider.prototype.setNumberOfSliders = function(numOfSliders) { + this.sliders = numOfSliders; + this.val = new Array(); + for (var i=0;i<this.sliders;i++) { + this.val.push(0.7); + } + this.sliderWidth = this.realSpace.x/this.sliders; + this.init(); +} + +/** @method setSliderValue +Sets a slider to new value and transmits. +@param {integer} [slider] Slider to set (slider index starts at 0) +@param {integer} [value] New slider value */ +multislider.prototype.setSliderValue = function(slider,value) { + this.val[slider] = value; + this.draw(); + var msg = new Object(); + msg[slider] = this.val[slider] + if (this.destination=="js" || this.destination=="node") { + msg["list"] = this.val; + } else { + msg["list"] = new String(); + for (var key in this.val) { msg["list"] += this.val[key] + " " } + } + this.transmit(msg); +} + + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2); +var drawing = __webpack_require__(3); +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class multitouch + Multitouch 2d-slider with up to 5 points of touch. + ```html + <canvas nx="multitouch"></canvas> + ``` + <canvas nx="multitouch" style="margin-left:25px"></canvas> +*/ + +var multitouch = module.exports = function (target) { + + this.defaultSize = { width: 200, height: 200 }; + widget.call(this, target); + + //unique attributes + this.nodeSize = this.GUI.w/10; + + /** @property {object} val + | | data + | --- | --- + | *touch1.x* | x position of first touch + | *touch1.y* | y position of first touch + | *touch2.x* | x position of second touch (if 2 touches) + | *touch2.y* | y position of second touch (if 2 touches) + | *etc* | + */ + this.val = { + touch1: { + x: 0, + y: 0 + } + } + + this.nodes = new Array(); + + /** @property {string} text Text that will show when object is static */ + this.text = "multitouch"; + + this.rainbow = ["#00f", "#04f", "#08F", "0AF", "0FF"]; + + /** @property {string} mode "normal" or "matrix" mode. "matrix" mode has a GUI of discrete touch areas. + */ + this.mode = "normal"; + + /** @property {integer} rows How many rows in the matrix (matrix mode only) + */ + this.rows = 10; + + /** @property {integer} cols How many rows in the matrix (matrix mode only) + */ + this.cols = 10; + + /** @property {array} matrixLabels An array of strings that can provide text labels on cells of the matrix. If shorter than the matrix cells, the array will repeat. + ``` + this.mode = "matrix" + this.matrixLabels = [ "A", "A#", "B", "C" ] + this.init(); + ``` + */ + this.matrixLabels = false; + + this.init(); +} +util.inherits(multitouch, widget); + +multitouch.prototype.init = function() { + this.nodeSize = this.GUI.w/10; + this.draw(); +} + +multitouch.prototype.draw = function() { + this.erase(); + with (this.context) { + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + + var count = 0; + + if (this.mode == "matrix") { + for (var j=0;j<this.rows;j++) { + for (var i=0;i<this.cols;i++) { + with (this.context) { + beginPath(); + fillStyle = this.colors.accent; + strokeStyle = this.colors.border; + lineWidth = 1; + var circx = i*this.GUI.w/this.cols + (this.GUI.w/this.cols)/2; + var circy = j*this.GUI.h/this.rows + (this.GUI.h/this.rows)/2; + arc(circx, circy, (this.GUI.h/this.rows)/2, 0, Math.PI*2, true); + stroke(); + fillStyle = this.colors.border; + textAlign = "center"; + textBaseline = "middle"; + if (this.matrixLabels) { + fillText(this.matrixLabels[count%this.matrixLabels.length], circx, circy); + count++ + } + var thisarea = { + x: i*this.GUI.w/this.cols, + y: j*this.GUI.h/this.rows, + w: this.GUI.w/this.cols, + h: this.GUI.h/this.rows + } + if (this.clickPos.touches.length>=1) { + for (var k=0;k<this.clickPos.touches.length;k++) { + if (drawing.isInside(this.clickPos.touches[k],thisarea)) { + globalAlpha=0.5; + fillStyle = this.colors.accent; + fill(); + globalAlpha=0.3; + fillStyle = this.rainbow[k]; + fill(); + globalAlpha=1; + } + } + } + closePath(); + } + } + } + } else { + if (this.clickPos.touches.length>=1) { + for (var i=0;i<this.clickPos.touches.length;i++) { + + with (this.context) { + globalAlpha=0.5; + beginPath(); + fillStyle = this.colors.accent; + strokeStyle = this.colors.border; + lineWidth = this.lineWidth; + arc(this.clickPos.touches[i].x, this.clickPos.touches[i].y, this.nodeSize, 0, Math.PI*2, true); + fill(); + // stroke(); + closePath(); + globalAlpha=0.3; + beginPath(); + fillStyle = this.rainbow[i]; + strokeStyle = this.colors.border; + lineWidth = this.lineWidth; + arc(this.clickPos.touches[i].x, this.clickPos.touches[i].y, this.nodeSize, 0, Math.PI*2, true); + fill(); + // stroke(); + closePath(); + globalAlpha=1; + } + } + clearRect(0,this.GUI.h,this.GUI.w,this.height - this.GUI.h) + } + else { + this.setFont() + fillStyle = this.colors.border; + fillText(this.text, this.GUI.w/2, this.GUI.h/2); + globalAlpha = 1; + } + } + } + this.drawLabel(); +} + +multitouch.prototype.click = function() { + this.draw(); + this.sendit(); +} + +multitouch.prototype.move = function() { + if (this.clicked) { + this.draw(); + this.sendit(); + } +} + +multitouch.prototype.release = function() { + + if(!this.clicked) { + this.clickPos.touches = new Array(); + for (var i=0;i<5;i++) { + this.val["touch"+i] = { + x: 0, + y: 0 + } + } + this.transmit(this.val); + } + + this.draw(); + this.sendit(); + +} + +multitouch.prototype.sendit = function() { + this.val = new Object(); + for (var i=0;i<this.clickPos.touches.length;i++) { + this.val["touch"+i] = { + x: this.clickPos.touches[i].x/this.canvas.width, + y: math.invert(this.clickPos.touches[i].y/this.canvas.height) + } + } + this.transmit(this.val); +} + +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2) +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class number + Number box + ```html + <canvas nx="number"></canvas> + ``` + <canvas nx="number" style="margin-left:25px"></canvas> +*/ + +var number = module.exports = function (target) { + this.defaultSize = { width: 50, height: 20 }; + widget.call(this, target); + + /** @property {object} val + | | data + | --- | --- + | *value* | Number value + + ```js + // Sets number1.val.value to 20 + number1.set({ + value: 20 + }) + ``` + */ + this.val = { + value: 0 + } + + /** @property {float} min The minimum number allowed. Default is -20000. + + ```js + // only allow positive numbers + number1.min = 0; + ``` + */ + this.min = -20000 + + /** @property {float} max The maximum number allowed. Default is 20000. + + ```js + // only allow negative numbers + number1.max = 0; + ``` + */ + this.max = 20000 + + /** @property {float} step The increment. Default is 1. + + ```js + // count by 10s + number1.step = 10; + ``` + */ + this.step = 1 + + + /** @property {float} rate Sensitivity of dragging. Default is .25 + + ```js + // For fine tuning + number1.rate = .001; + ``` + */ + this.rate = .25 + + /** @property {integer} decimalPlaces How many decimal places on the number. This applies to both the output and the interface text. Default is 2. To achieve an int (non-float), set decimalPlaces to 0. + + ```js + // For an int counter + number1.decimalPlaces = 0; + ``` + */ + this.decimalPlaces = 3; + this.lostdata = 0; + this.actual = 0; + + // SWAP + // + this.canvas.ontouchstart = null; + this.canvas.ontouchmove = null; + this.canvas.ontouchend = null; + + var htmlstr = '<input type="text" nx="number" id="'+this.canvasID+'" style="height:'+this.GUI.h+'px;width:'+this.GUI.w+'px;font-size:'+this.GUI.h/2+'px;"></input><canvas height="1px" width="1px" style="display:none"></canvas>' + var canv = this.canvas + var cstyle = this.canvas.style + var parent = canv.parentNode + var newdiv = document.createElement("span") + newdiv.innerHTML = htmlstr + newdiv.className = "nx" + parent.replaceChild(newdiv,canv) + + this.el = document.getElementById(this.canvasID) + for (var prop in cstyle) { + if (prop != "height" && prop != "width") { + this.el.style[prop] = cstyle[prop] + } + } + + if (this.label) { + var labeldiv = document.createElement("div") + labeldiv.innerHTML = this.label + labeldiv.style.fontSize = this.labelSize/2.8+"px" + labeldiv.style.fontFamily = this.labelFont + labeldiv.style.textAlign = this.labelAlign + labeldiv.style.lineHeight = this.labelSize+"px" + labeldiv.style.width = this.GUI.w+"px" + labeldiv.style.color = nx.colors.black + labeldiv.className = "nxlabel" + newdiv.appendChild(labeldiv) + } + + this.canvas = document.getElementById(this.canvasID); + this.canvas.style.height = this.GUI.h + "px" + this.canvas.style.fontSize = this.GUI.h * .6 + "px" + this.canvas.style.textAlign = "left" + this.canvas.style.backgroundColor = this.colors.fill + this.canvas.style.highlight = this.colors.fill + this.canvas.style.border = "none" + this.canvas.style.outline = "none" + this.canvas.style.padding = "4px 10px" + this.canvas.style.cursor = "pointer" + this.canvas.style.display = "block" + this.canvas.className = "" + + this.canvas.addEventListener("blur", function () { + //this.canvas.style.border = "none"; + + this.canvas.style.backgroundColor = this.colors.fill; + this.canvas.style.color = this.colors.black; + if (this.canvas.value != this.val.value) { + this.actual = parseFloat(this.canvas.value) + this.actual = math.clip(this.actual,this.min,this.max) + this.actual = math.prune(this.actual,this.decimalPlaces); + this.set({"value": this.actual}, true) + } + }.bind(this)); + + this.canvas.addEventListener("keydown", function (e) { + if (e.which < 48 || e.which > 57) { + if (e.which != 189 && e.which != 190 && e.which != 8) { + e.preventDefault(); + } + } + if (e.which==13) { + /* this.actual = parseFloat(this.canvas.value) + this.actual = math.clip(this.actual,this.min,this.max) + this.actual = math.prune(this.actual,this.decimalPlaces); + this.set({"value": this.actual}, true) */ + //this.canvas.style.outline = "none"; + this.canvas.blur() + } + }.bind(this)); + + + // Setup interaction + if (nx.isTouchDevice) { + this.canvas.ontouchstart = this.preTouch; + this.canvas.ontouchmove = this.preTouchMove; + this.canvas.ontouchend = this.preTouchRelease; + } else { + this.canvas.addEventListener('mousedown', this.preClick, false); + } + + + this.canvas.style.userSelect = "none !important"; + this.canvas.style.mozUserSelect = "none !important"; + this.canvas.style.webkitUserSelect = "none !important"; + + + + + + + this.init(); +} +util.inherits(number, widget); + +number.prototype.init = function() { + + + this.draw(); +} + +number.prototype.draw = function() { + + this.canvas.value = this.val.value; + +} + + +number.prototype.click = function(e) { + this.canvas.readOnly = true + this.actual = this.val.value +} + +number.prototype.move = function(e) { + if (this.clicked) { + this.canvas.style.border = "none"; + + this.actual -= (this.deltaMove.y*(this.rate*this.step)); + this.actual = math.clip(this.actual,this.min,this.max) + this.val.value = Math.floor(this.actual / this.step) * this.step; + this.val.value = math.prune(this.val.value,this.decimalPlaces); + this.draw(); + this.transmit(this.val); + } +} + + +number.prototype.release = function(e) { + if (!this.hasMoved && this.canvas.readOnly) { + this.canvas.readOnly = false; + this.canvas.focus() + this.canvas.setSelectionRange(0, this.canvas.value.length) + this.canvas.style.backgroundColor = this.colors.accent; + this.canvas.style.color = this.colors.fill; + } +} + + +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2) +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class position + Two-dimensional touch slider. + ```html + <canvas nx="position"></canvas> + ``` + <canvas nx="position" style="margin-left:25px"></canvas> +*/ + +var position = module.exports = function (target) { + + // define a default size + this.defaultSize = { width: 150, height: 100 }; + + widget.call(this, target); + + /** @property {integer} nodeSize Size of touch node graphic. */ + this.nodeSize = 15; + + /** @property {object} val val is an object containing the main interactive / actionable aspects of the widget. + | | data + | --- | --- + | *x* | x position of slider (float 0-1) + | *y* | y position of slider (float 0-1) + */ + this.val = { + x: 0.5, + y: 0.5 + } + + this.init(); +} + +// inherit the widget object template +util.inherits(position, widget); + +// .init() is called automatically when the widget is created on a webpage. +position.prototype.init = function() { + this.nodeSize = Math.min(this.GUI.h,this.GUI.w)/10; + this.nodeSize = Math.max(this.nodeSize,10) + this.actualWid = this.GUI.w - this.nodeSize*2; + this.actualHgt = this.GUI.h - this.nodeSize*2; + this.draw(); +} + +// .draw() should be used for any graphics activity +position.prototype.draw = function() { + this.erase(); + with (this.context) { + + // use this.colors.fill for the widget background color (default: very light gray) + // use this.colors.border for any extra structural needs (default: light gray) + // use this.colors.accent for important or highlighted parts (default: a bright color) + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + + var drawingX = this.val.x * this.actualWid + this.nodeSize + var drawingY = math.invert(this.val.y) * this.actualHgt + this.nodeSize + + //stay within right/left bounds + if (drawingX<(this.nodeSize)) { + drawingX = this.nodeSize; + } else if (drawingX>(this.GUI.w-this.nodeSize)) { + drawingX = this.GUI.w - this.nodeSize; + } + //stay within top/bottom bounds + if (drawingY<(this.nodeSize)) { + drawingY = this.nodeSize; + } else if (drawingY>(this.GUI.h-this.nodeSize)) { + drawingY = this.GUI.h - this.nodeSize; + } + + with (this.context) { + + // draw the touch point + beginPath(); + fillStyle = this.colors.accent; + arc(drawingX, drawingY, this.nodeSize, 0, Math.PI*2, true); + fill(); + closePath(); + + if (this.clicked) { + // draw the emphasis circle + beginPath(); + fillStyle = this.colors.accent; + arc(drawingX, drawingY, this.nodeSize*2, 0, Math.PI*2, true); + fill(); + closePath();clearRect(0,this.GUI.h,this.GUI.w,this.height - this.GUI.h) + } + } + } + + this.drawLabel(); +} + +// .click() will be fired when the interface is interacted with +// this.clicked is automatically set to true +// this.clickPos is already and object with x and y properties detailing click point. +position.prototype.click = function() { + this.val.x = this.clickPos.x; + this.val.y = this.clickPos.y; + this.scaleNode(); + this.val["state"] = "click" + this.transmit(this.val); + this.draw(); +} + +// .move() will be fired when the interface is moved over after being clicked +// this.clickPos is already and object with x and y properties detailing click point. +position.prototype.move = function() { + this.val.x = this.clickPos.x; + this.val.y = this.clickPos.y; + this.scaleNode(); + this.val["state"] = "move" + this.transmit(this.val); + this.draw(); +} + +// .release() will be fired on mouse up (unclick) +position.prototype.release = function() { + this.val.x = this.clickPos.x; + this.val.y = this.clickPos.y; + this.scaleNode(); + this.val["state"] = "release" + this.transmit(this.val); + this.draw(); +} + +/* TOUCH SPECIFIC EVENTS + currently, ontouch, ontouchmove, and ontouchrelease automatically execute .click, .move, and .release + so you only need to write one function for these events, and they will be touch compatible by default + however if you would like to create a touch-specific event you may define the following functions. + in these functions, .clickPos and .clicked will refer to your touch interactions. + +position.prototype.touch = function() { + +} + +position.prototype.touchmove = function() { + +} + +position.prototype.touchrelease = function() { + +} + + + + +*/ + + + +/* + extra functions pertaining only to this widget +*/ + +position.prototype.scaleNode = function() { + var actualX = this.val.x - this.nodeSize; + var actualY = this.val.y - this.nodeSize; + var clippedX = math.clip(actualX/this.actualWid, 0, 1); + var clippedY = math.clip(actualY/this.actualHgt, 0, 1); + this.val.x = math.prune(clippedX, 3) + this.val.y = math.prune(clippedY, 3) + this.val.y = math.invert(this.val.y); +} + +/** @method animate + Adds animation to the widget. + @param {string} [type] Type of animation. Currently accepts "none" or "bounce", in which case the touch node can be tossed and bounces. +*/ +position.prototype.animate = function(aniType) { + + switch (aniType) { + case "bounce": + nx.aniItems.push(this.aniBounce.bind(this)); + break; + case "none": + nx.aniItems.splice(nx.aniItems.indexOf(this.aniBounce)); + break; + } + +} + +position.prototype.aniBounce = function() { + if (!this.clicked && this.val.x) { + this.val.x += (this.deltaMove.x/2)/this.GUI.w; + this.val.y -= (this.deltaMove.y/2)/this.GUI.h; + this.val["state"] = "animated"; + if (math.bounce(this.val.x, 0, 1, this.deltaMove.x) != this.deltaMove.x) { + this.deltaMove.x = math.bounce(this.val.x, 0, 1, this.deltaMove.x); + this.val["state"] = "bounce"; + } + if (this.val.y >= 1 || this.val.y <= 0) { + this.deltaMove.y = math.bounce(this.val.y, 0, 1, this.deltaMove.y) * -1; + this.val["state"] = "bounce"; + } + this.transmit(this.val); + this.draw(); + } +} + +position.prototype.customDestroy = function() { + nx.removeAni(this.aniBounce); +} + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var widget = __webpack_require__(1); +var math = __webpack_require__(2) + +/** + @class range + Range slider + ```html + <canvas nx="range"></canvas> + ``` + <canvas nx="range" style="margin-left:25px"></canvas> +*/ + +var range = module.exports = function (target) { + this.defaultSize = { width: 110, height: 35 }; + widget.call(this, target); + + /** @property {object} val Object containing core interactive aspects of widget, which are also its data output. Has the following properties: + | | data + | --- | --- + | *start* | Range start value (float 0-1) + | *stop* | Range end value (float 0-1) + | *size* | Distance between ends (float 0-1) + */ + this.val = { + start: 0.3, + stop: 0.7, + size: 0.4 + } + + + // handling horiz possibility + /** @property {boolean} hslider Whether or not the slider is a horizontal slider. Default is false, but set automatically to true if the slider is wider than it is tall. */ + this.hslider = false; + this.handle; + this.relhandle; + this.cap; + this.firsttouch = "start"; + + /** @property {string} mode Mode of interaction. "edge" mode lets you drag each edge of the range individually. "area" mode (default) lets you drag the range as a whole (with parallel mouse movement) or scale the range as a whole (with transverse mouse movement) */ + this.mode = "area" // modes: "edge", "area" + this.touchdown = new Object(); + this.init(); +} +util.inherits(range, widget); + +range.prototype.init = function() { + + //decide if hslider or vslider + if (this.GUI.h>=this.GUI.w) { + this.hslider = false; + } else { + this.hslider = true; + } + + if (this.canvas.getAttribute("label")!=null) { + this.label = this.canvas.getAttribute("label"); + } + + this.draw(); +} + +range.prototype.draw = function() { + this.erase(); + + with (this.context) { + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + + if (!this.hslider) { + + var x1 = 0; + var y1 = this.GUI.h-this.val.stop*this.GUI.h; + var x2 = this.GUI.w; + var y2 = this.GUI.h-this.val.start*this.GUI.h; + + fillStyle = this.colors.accent; + fillRect(x1,y1,x2-x1,y2-y1); + + } else { + + var x1 = this.val.start*this.GUI.w; + var y1 = 0; + var x2 = this.val.stop*this.GUI.w; + var y2 = this.GUI.h; + + fillStyle = this.colors.accent; + fillRect(x1,y1,x2-x1,y2-y1); + } + } + this.drawLabel(); +} + +range.prototype.click = function() { + if (this.mode=="edge") { + if (this.hslider) { + if (Math.abs(this.clickPos.x-this.val.start*this.GUI.w) < Math.abs(this.clickPos.x-this.val.stop*this.GUI.w)) { + this.firsttouch = "start" + } else { + this.firsttouch = "stop" + } + } else { + if (Math.abs(Math.abs(this.clickPos.y-this.GUI.h)-this.val.start*this.GUI.h) < Math.abs(Math.abs(this.clickPos.y-this.GUI.h)-this.val.stop*this.GUI.h)) { + this.firsttouch = "start" + } else { + this.firsttouch = "stop" + } + } + } else if (this.mode=="area") { + this.touchdown = { + x: this.clickPos.x, + y: this.clickPos.y + } + this.startval = new Object(); + this.startval.size = this.val.stop - this.val.start; + this.startval.loc = this.val.start + this.startval.size/2; + } + this.move(); +} + +range.prototype.move = function() { + + if (this.mode=="edge") { + if (this.hslider) { + if (this.firsttouch=="start") { + this.val.start = this.clickPos.x/this.GUI.w; + if (this.clickPos.touches.length>1) { + this.val.stop = this.clickPos.touches[1].x/this.GUI.w; + } + } else { + this.val.stop = this.clickPos.x/this.GUI.w; + if (this.clickPos.touches.length>1) { + this.val.start = this.clickPos.touches[1].x/this.GUI.w; + } + } + } else { + if (this.firsttouch=="start") { + this.val.start = math.invert(this.clickPos.y/this.GUI.h); + if (this.clickPos.touches.length>1) { + this.val.stop = math.invert(this.clickPos.touches[1].y/this.GUI.h); + } + } else { + this.val.stop = math.invert(this.clickPos.y/this.GUI.h); + if (this.clickPos.touches.length>1) { + this.val.start = math.invert(this.clickPos.touches[1].y/this.GUI.h); + } + } + } + + if (this.val.stop < this.val.start) { + this.tempstart = this.val.start; + this.val.start = this.val.stop; + this.val.stop = this.tempstart; + if (this.firsttouch=="start") { + this.firsttouch = "stop"; + } else { + this.firsttouch = "start"; + } + } + this.val = { + start: math.clip(this.val.start, 0, 1), + stop: math.clip(this.val.stop, 0, 1), + } + this.val['size'] = math.prune(math.clip(Math.abs(this.val.stop - this.val.start), 0, 1), 3) + + this.draw(); + + this.transmit(this.val); + + } else if (this.mode=="area") { + + if (this.hslider) { + var moveloc = this.clickPos.x/this.GUI.w; + var movesize = (this.touchdown.y - this.clickPos.y)/this.GUI.h; + } else { + var moveloc = nx.invert(this.clickPos.y/this.GUI.h); + var movesize = (this.touchdown.x - this.clickPos.x)/this.GUI.w; + // moveloc *= -1; + movesize *= -1; + } + movesize /= 3; + var size = this.startval.size + movesize; + size = math.clip(size,0.001,1); + + this.val = { + start: moveloc - size/2, + stop: moveloc + size/2 + } + + this.val.start = math.clip(this.val.start,0,1); + this.val.stop = math.clip(this.val.stop,0,1); + + this.draw(); + + this.transmit(this.val); + + } +} + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class select + HTML-style option selector. Outputs the chosen text string. <br> **Note:** Currently the canvas is actaully replaced by an HTML select object. Any inline style on your canvas may be lost in this transformation. To style the resultant select element, we recommend creating CSS styles for the select object using its ID or the select tag. + ```html + <canvas nx="select" choices="sine,saw,square"></canvas> + ``` + <canvas nx="select" choices="sine,saw,square"></canvas> +*/ + +var select = module.exports = function (target) { + this.defaultSize = { width: 200, height: 30 }; + widget.call(this, target); + + /** @property {array} choices Desired choices, as an array of strings. Can be initialized with a "choices" HTML attribute of comma-separated text (see example above). + ```js + select1.choices = ["PartA", "PartB", "GoNuts"] + select1.init() + ``` + */ + this.choices = [ ]; + + /** @property {object} val + | | data + | --- | --- + | *value* | Text string of option chosen + */ + this.val = new Object(); + + + this.canvas.ontouchstart = null; + this.canvas.ontouchmove = null; + this.canvas.ontouchend = null; + + if (this.canvas.getAttribute("choices")) { + this.choices = this.canvas.getAttribute("choices"); + this.choices = this.choices.split(","); + } + var htmlstr = '<select id="'+this.canvasID+'" class="nx" nx="select" style="height:'+this.GUI.h+'px;width:'+this.GUI.w+'px;" onchange="'+this.canvasID+'.change(this)"></select><canvas height="1px" width="1px" style="display:none"></canvas>' + var canv = this.canvas + var cstyle = this.canvas.style + var parent = canv.parentNode + var newdiv = document.createElement("span") + newdiv.innerHTML = htmlstr + newdiv.className = "nx" + parent.replaceChild(newdiv,canv) + this.sel = document.getElementById(this.canvasID) + for (var prop in cstyle) + this.sel.style[prop] = cstyle[prop]; + + this.canvas = document.getElementById(this.canvasID); + + this.canvas.style.backgroundColor = this.colors.fill; + this.canvas.style.border = "solid 2px "+this.colors.border; + this.canvas.style.color = this.colors.black; + this.canvas.style.fontSize = Math.round(this.GUI.h/2.3) + "px" + + this.canvas.className = "" + +} +util.inherits(select, widget); + +select.prototype.init = function() { + + this.canvas.style.backgroundColor = this.colors.fill; + this.canvas.style.border = "solid 2px "+this.colors.border; + this.canvas.style.color = this.colors.black; + + var optlength = this.canvas.options.length; + for (i = 0; i < optlength; i++) { + this.canvas.options[i] = null; + } + + for (var i=0;i<this.choices.length;i++) { + var option=document.createElement("option"); + option.text = this.choices[i]; + option.value = this.choices[i]; + this.canvas.add(option,null); + } + + this.val.text = this.choices[0] + +} + +select.prototype.change = function(thisselect) { + this.val.text = thisselect.value; + this.val.value = thisselect.selectedIndex; + this.transmit(this.val); +} + +select.prototype.draw = function() { + + // included so that when .set() calls .draw(), this widget updates its value + this.canvas.value = this.val.text + this.canvas.style.backgroundColor = this.colors.fill; + this.canvas.style.color = this.colors.black; + this.canvas.style.border = "solid 2px "+this.colors.border; + +} + + +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2) +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class slider + Slider (vertical or horizontal) + ```html + <canvas nx="slider"></canvas> + ``` + <canvas nx="slider" style="margin-left:25px"></canvas> +*/ + +var slider = module.exports = function (target) { + this.defaultSize = { width: 35, height: 110 }; + widget.call(this, target); + + if (this.canvas.getAttribute("min")!=null) { + this.min = parseFloat(this.canvas.getAttribute("min")); + } else { + this.min = 0 + } + if (this.canvas.getAttribute("max")!=null) { + this.max = parseFloat(this.canvas.getAttribute("max")); + } else { + this.max = 1 + } + if (this.canvas.getAttribute("step")!=null) { + this.step = parseFloat(this.canvas.getAttribute("step")); + } else { + this.step = 0.001 + } + + /** @property {object} val + | | data + | --- | --- + | *value* | Slider value (float 0-1) + */ + this.val.value = nx.scale(0.7,0,1,this.min,this.max) + + + /** @property {string} mode Set "absolute" or "relative" mode. In absolute mode, slider will jump to click/touch position. In relative mode, it will not. + ```js + nx.onload = function() { + // Slider will not jump to touch position. + slider1.mode = "relative" + } + ``` + */ + this.mode = "absolute"; + + /** @property {boolean} hslider Whether or not the slider should be horizontal. This is set to true automatically if the canvas is wider than it is tall. To override the default decision, set this property to true to create a horizontal slider, or false to create a vertical slider. + + ```js + nx.onload = function() { + //forces horizontal slider + slider1.hslider = true + slider1.draw(); + //forces vertical slider + slider2.hslider = false + slider2.draw(); + } + ``` + */ + this.hslider = false; + this.handle; + this.relhandle; + this.cap; + + this.maxdigits = 3 + + this.calculateDigits = nx.calculateDigits; + + this.init(); +} +util.inherits(slider, widget); + +slider.prototype.init = function() { + + //decide if hslider or vslider + if (this.GUI.h>=this.GUI.w) { + this.hslider = false; + } else { + this.hslider = true; + } + + + this.draw(); +} + + +slider.prototype.draw = function() { + + var normalval = this.normalize(this.val.value) + + //figure out text size + this.digits = this.calculateDigits() + + this.erase(); + + with (this.context) { + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + + if (!this.hslider) { + + var x1 = 0; + var y1 = this.GUI.h-normalval*this.GUI.h; + var x2 = this.GUI.w; + var y2 = this.GUI.h; + + fillStyle = this.colors.accent; + fillRect(x1,y1,x2-x1,y2-y1); + + //text + var valtextsize = (this.GUI.w / this.digits.total) * 1.2 + if (valtextsize > 6) { + + // figure out val text location + if (y1 < this.GUI.h - valtextsize/2-5) { + fillStyle = this.colors.white + var texty = this.GUI.h-valtextsize/2-5 + } else { + fillStyle = this.colors.accent + var texty = y1 - valtextsize/2-5 + } + var textx = this.GUI.w/2 + var valtextAlign = "center" + var valtextBaseline = "middle" + } + + } else { + + var x1 = 0; + var y1 = 0; + var x2 = normalval*this.GUI.w; + var y2 = this.GUI.h; + + fillStyle = this.colors.accent + fillRect(x1,y1,x2-x1,y2-y1) + + //text + var valtextsize = this.GUI.h/2 + if (valtextsize > 6) { + + // figure out val text location + if (x2 > this.digits.total*valtextsize/2) { + fillStyle = this.colors.white + var textx = 5 + } else { + fillStyle = this.colors.accent + var textx = x2 + 5 + } + var texty = this.GUI.h/2 + var valtextAlign = "left" + var valtextBaseline = "middle" + } + + } + + + var valtext = this.val.value.toFixed(this.digits.decimals) + textBaseline = valtextBaseline + textAlign = valtextAlign + font = valtextsize+"px 'Open Sans'" + fillText(valtext,textx,texty); + + + if (this.label) { + this.drawLabel() + } + } +} + +slider.prototype.click = function() { + this.move(); +} + +slider.prototype.move = function() { + + var normalval = this.normalize(this.val.value) + + if (this.hslider) { + this.handle = this.clickPos.x; + this.relhandle = this.deltaMove.x; + this.cap = this.GUI.w; + } else { + this.handle = this.clickPos.y; + this.relhandle = this.deltaMove.y*-1; + this.cap = this.GUI.h + } + + if (this.mode=="absolute") { + if (this.clicked) { + if (!this.hslider) { + normalval = Math.abs((math.clip(this.clickPos.y/this.GUI.h, 0, 1) - 1)); + } else { + normalval = math.clip(this.clickPos.x/this.GUI.w, 0, 1); + } + this.draw(); + } + } else if (this.mode=="relative") { + if (this.clicked) { + if (!this.hslider) { + normalval = math.clip(normalval + ((this.deltaMove.y*-1)/this.GUI.h),0,1); + } else { + normalval = math.clip(normalval + ((this.deltaMove.x)/this.GUI.w),0,1); + } + this.draw(); + } + } + + this.val.value = math.prune(this.rangify(normalval),3) + this.transmit(this.val); +} + +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class string + Animated model of a plucked string interface. + ```html + <canvas nx="string"></canvas> + ``` + <canvas nx="string" style="margin-left:25px"></canvas> +*/ + +var string = module.exports = function (target) { + this.defaultSize = { width: 150, height: 75 }; + widget.call(this, target); + + /** @property {object} val Object containing the core interactive aspects of the widget, which are also its data output. Has the following properties: + | | data + | --- | --- + | *string* | Index of the string that is plucked (starts at 0) + | *x* | Where on the string the pluck occured (float 0-1); + */ + this.val = { + string: 0, + x: 0 + } + /** @property {integer} numberOfStrings How many strings in the widget. We recommend setting this property with .setStrings() */ + this.numberOfStrings = 10; + this.strings = new Array(); + this.abovestring = new Array(); + /** @property {integer} friction How quickly the string slows down */ + this.friction = 1; + + var stringdiv; + + this.init(); + + nx.aniItems.push(this.draw.bind(this)); +} +util.inherits(string, widget); + +string.prototype.init = function() { + stringdiv = this.GUI.h/(this.numberOfStrings + 1); + for (var i=0;i<this.numberOfStrings;i++) { + this.strings[i] = { + x1: this.lineWidth, + y1: stringdiv*(1+i), + x2: this.GUI.w - this.lineWidth, + y2: stringdiv*(i+1), + held: false, // whether or not it's gripped + vibrating: false, // whether or not its vibrating + force: 0, // amount of force of pull on string + maxstretch: 0, // vibration cap (in Y domain) + stretch: 0, // current point vibrating in y domain + direction: 0, // which direction it's vibrating + above: false // is mouse above or below string + }; + } + this.draw(); +} + +string.prototype.pulse = function() { + this.draw(); +} + +/* @method setStrings Sets how many strings are in the widget. + ```js + string1.setStrings(20); + ``` + */ +string.prototype.setStrings = function(val) { + this.numberOfStrings = val; + this.strings = new Array(); + this.init(); +} + +string.prototype.draw = function() { + this.erase(); + with (this.context) { + strokeStyle = this.colors.border; + fillStyle = this.colors.fill; + lineWidth = this.lineWidth; + // stroke(); + fillRect(0,0,this.GUI.w,this.GUI.h); + strokeStyle = this.colors.accent; + + for (var i = 0;i<this.strings.length;i++) { + + var st = this.strings[i]; + + if (st.vibrating) { + if (st.maxstretch < 0) { + st.vibrating = false; + st.held = false; + } + st.stretch = st.stretch + st.direction; + + if (Math.abs(st.stretch) > st.maxstretch) { + //st.direction *= (-0.99); + st.direction *= -1; + st.stretch = st.stretch + st.direction; + st.maxstretch = st.maxstretch - this.friction; + + st.direction = (st.direction / Math.abs(st.direction)) * (st.maxstretch/1) + } + + beginPath(); + moveTo(st.x1, st.y1); + quadraticCurveTo(this.GUI.w/2, st.y1+st.stretch, st.x2, st.y2); + stroke(); + closePath(); + st.on = true; + + + } else if (st.held) { + //will draw rounded + //if mouse is higher than string and gripup + //or if mouse is + // if (this.clickPos.y-st.y1<0 && st.gripup || this.clickPos.y-st.y1>0 && !st.gripup) { + beginPath(); + moveTo(st.x1, st.y1); + quadraticCurveTo(this.clickPos.x, this.clickPos.y, st.x2, st.y2); + stroke(); + closePath(); + st.on = true; + /* } else { + beginPath(); + moveTo(st.x1, st.y1); + lineTo(st.x2, st.y2); + stroke(); + closePath(); + } */ + } else { + beginPath(); + moveTo(st.x1, st.y1); + lineTo(st.x2, st.y2); + stroke(); + closePath(); + if (st.on) { + st.on = false; + } + } + } + } + this.drawLabel(); +} + +string.prototype.click = function() { + for (var i = 0;i<this.numberOfStrings;i++) { + this.strings[i].above = (this.clickPos.y<this.strings[i].y1); + } + this.draw(); +} + +string.prototype.move = function() { + if (this.clicked) { + for (var i = 0;i<this.strings.length;i++) { + + //if crosses string + if (this.strings[i].above != (this.clickPos.y<this.strings[i].y1) ) { + this.strings[i].held = true; + this.strings[i].above ^= true; + } + + if (this.strings[i].held && Math.abs(this.clickPos.y - this.strings[i].y1) > this.GUI.h/(this.strings.length*3)) { + + this.pluck(i) + + } + } + } +} + +string.prototype.release = function() { + for (var i = 0;i<this.strings.length;i++) { + if (this.strings[i].held) { + this.pluck(i); + } + } +} + +string.prototype.pluck = function(which) { + var i = which; + this.val = { + string: i, + x: this.clickPos.x/this.GUI.w + } + this.transmit(this.val); + this.strings[i].held = false; + this.strings[i].force = this.clickPos.y - this.strings[i].y1; + this.strings[i].maxstretch = Math.abs(this.clickPos.y - this.strings[i].y1); + this.strings[i].stretch = this.clickPos.y - this.strings[i].y1; + this.strings[i].vibrating = true; + this.strings[i].direction = (this.clickPos.y - this.strings[i].y1)/Math.abs(this.clickPos.y - this.strings[i].y1) * ((this.clickPos.y - this.strings[i].y1)/-1.2); +} + +string.prototype.customDestroy = function() { + nx.removeAni(this.draw.bind(this)); +} + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2) +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class tabs + + ```html + <canvas nx="tabs"></canvas> + ``` + <canvas nx="tabs" style="margin-left:25px"></canvas> +*/ + +var tabs = module.exports = function(target) { + + this.defaultSize = { width: 150, height: 50 }; + widget.call(this, target); + + //define unique attributes + this.choice = 0; + this.val = { + index: 0, + text: "" + } + this.tabwid = 0; + this.options = ["one", "two", "three"] + //init + this.init(); + +} + +util.inherits(tabs, widget); + + +tabs.prototype.init = function() { + this.draw(); +} + + +tabs.prototype.draw = function() { + + with (this.context) { + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h) + + textAlign = "center" + textBaseline = "middle" + font = "normal "+this.GUI.h/5+"px courier" + } + + this.tabwid = this.GUI.w/this.options.length + + for (var i=0;i<this.options.length;i++) { + if (i==this.choice) { + var tabcol = this.colors.accent; + var textcol = this.colors.white; + } else { + var tabcol = this.colors.fill; + var textcol = this.colors.black; + globalAlpha = 0.7; + } + with (this.context) { + fillStyle=tabcol; + fillRect(this.tabwid*i,0,this.tabwid,this.GUI.h) + if (i!=this.options.length-1) { + beginPath(); + moveTo(this.tabwid*(i+1),0) + lineTo(this.tabwid*(i+1),this.GUI.h) + lineWidth = 1; + strokeStyle = this.colors.border + stroke() + closePath() + } + fillStyle=textcol; + font = this.fontSize+"px "+this.font; + fillText(this.options[i],this.tabwid*i+this.tabwid/2,this.GUI.h/2) + } + + } +} + + +tabs.prototype.click = function() { + this.choice = ~~(this.clickPos.x / this.tabwid); + this.val = { + index: this.choice, + text: this.options[this.choice] + } + this.transmit(this.val) + this.draw(); +} + +/***/ }), +/* 46 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class text + Text editor. Outputs the typed text string when Enter is pressed. <br> **Note:** Currently the canvas is actaully replaced by an HTML textarea object. Any inline style on your canvas may be lost in this transformation. To style the resultant textarea element, we recommend creating CSS styles for the textarea element using its ID or the textarea tag. + ```html + <canvas nx="text"></canvas> + ``` + <canvas nx="text"></canvas> +*/ + +var text = module.exports = function (target) { + this.defaultSize = { width: 200, height: 100 }; + widget.call(this, target); + + /** @property {object} val + | | data + | --- | --- + | *text* | Text string + */ + this.val = { + text: "" + } + + var htmlstr = '<textarea id="'+this.canvasID+'" style="height:'+this.GUI.h+'px;width:'+this.GUI.w+'px;" onkeydown="'+this.canvasID+'.change(event,this)"></textarea><canvas height="1px" width="1px" style="display:none"></canvas>' + var canv = this.canvas + var cstyle = this.canvas.style + var parent = canv.parentNode; + var newdiv = document.createElement("span"); + newdiv.innerHTML = htmlstr; + newdiv.className = "nx" + parent.replaceChild(newdiv,canv) + this.el = document.getElementById(this.canvasID) + + for (var prop in cstyle) + this.el.style[prop] = cstyle[prop]; + + this.el.style.display = "block" + this.el.style.backgroundColor = this.colors.fill + this.el.style.border = "none" + this.el.style.color = this.colors.black + this.el.style.outline = "none" + this.el.style.resize = "none" + this.el.style.boxSizing = "border-box" + this.el.style.padding = "5px" + this.el.style.fontFamily = nx.font + this.el.style.fontSize = "16px" + this.el.className = "" + + + this.canvas = document.getElementById(this.canvasID); + + +} +util.inherits(text, widget); + +text.prototype.init = function() { + + this.canvas.ontouchstart = null; + this.canvas.ontouchmove = null; + this.canvas.ontouchend = null; + + this.canvas.style.backgroundColor = this.colors.fill; + this.canvas.style.color = this.colors.black; + +} + +// should have a modified "set" function +text.prototype.change = function(e,el) { + this.val.text = el.value + if (e.which=="13") { + this.transmit(this.val) + this.val.text = "" + this.draw() + e.preventDefault() + } +} + +text.prototype.draw = function() { + // needed especially for ghost + this.el.value = this.val.text + + this.canvas.style.backgroundColor = this.colors.fill; + this.canvas.style.color = this.colors.black; +} + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2) +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class tilt + Mobile and Mac/Chrome-compatible tilt sensor. May not work on all devices! <br> **Notes:** Clicking on this widget toggles it inactive or active. <br> + We recommend not calling .init() on this object after the original initialization, because it will add additional redundant tilt listeners to your document. + ```html + <canvas nx="tilt"></canvas> + ``` + <canvas nx="tilt" style="margin-left:25px"></canvas> +*/ + +var tilt = module.exports = function (target) { + this.defaultSize = { width: 50, height: 50 }; + widget.call(this, target); + + this.tiltLR; + this.tiltFB; + this.z; + /** @property {boolean} active Whether or not the tilt widget is on (animating and transmitting data). */ + this.active = true; + + /** @property {object} val Object containing the core interactive aspects of the widget, which are also its data output. Has the following properties: + | | data + | --- | --- + | *x* | X-axis rotation if supported (-1 to 1) + | *y* | Y-axis rotation if supported (-1 to 1) + | *z* | Z-axis rotation if supported (-1 to 1 or possibly 0 to 360 depending on device) + */ + this.val = { + x: 0, + y: 0, + z: 0 + } + + /** @property {string} text Text shown on tilt object + */ + + this.text = "TILT"; + this.init(); + + this.boundChromeTilt = this.chromeTilt.bind(this) + this.boundMozTilt = this.mozTilt.bind(this) + + if (window.DeviceOrientationEvent) { + window.addEventListener('deviceorientation', this.boundChromeTilt, false); + } else if (window.OrientationEvent) { + window.addEventListener('MozOrientation', this.boundMozTilt, false); + } else { + console.log("Not supported on your device or browser.") + } + +} +util.inherits(tilt, widget); + +tilt.prototype.deviceOrientationHandler = function() { + + this.val = { + x: math.prune(this.tiltLR/90,3), + y: math.prune(this.tiltFB/90,3), + z: math.prune(this.z,3) + } + + if (this.active) { + this.transmit(this.val); + } + +} + +tilt.prototype.chromeTilt = function(eventData) { + this.tiltLR = eventData.gamma; + this.tiltFB = eventData.beta; + this.z = eventData.alpha + this.deviceOrientationHandler(); + this.draw(); +} + +tilt.prototype.mozTilt = function(eventData) { + this.tiltLR = eventData.x * 90; + // y is the front-to-back tilt from -1 to +1, so we need to convert to degrees + // We also need to invert the value so tilting the device towards us (forward) + // results in a positive value. + this.tiltFB = eventData.y * -90; + this.z = eventData.z; + this.deviceOrientationHandler(); + this.draw(); +} + +tilt.prototype.init = function() { + this.draw(); +} + +tilt.prototype.draw = function() { + + this.erase(); + + with (this.context) { + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + + save(); + translate(this.GUI.w/2,this.GUI.h/2) + rotate(-this.val.x*Math.PI/2); + translate(-this.GUI.w/2,-this.GUI.h/2) + globalAlpha = 0.4; + + if (this.active) { + fillStyle = this.colors.accent; + } else { + fillStyle = this.colors.border; + } + + fillRect(-this.GUI.w,this.GUI.h*(this.val.y/2)+this.GUI.h/2,this.GUI.w*3,this.GUI.h*2) + font = "bold "+this.GUI.h/5+"px "+this.font; + textAlign = "center"; + textBaseline = "middle"; + fillText(this.text, this.GUI.w/2, this.GUI.h*(this.val.y/2)+this.GUI.h/2-this.GUI.h/15); + globalAlpha = 1; + restore(); + + clearRect(0,this.GUI.h,this.GUI.w,this.height - this.GUI.h) + } + this.drawLabel(); +} + +tilt.prototype.click = function() { + this.active = !this.active; +} + +tilt.prototype.customDestroy = function() { + this.active = false; + window.removeEventListener("deviceorientation",this.boundChromeTilt,false); + window.removeEventListener("mozOrientation",this.boundMozTilt,false); +} + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + +var drawing = __webpack_require__(3); +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class toggle + On/off toggle + ```html + <canvas nx="toggle"></canvas> + ``` + <canvas nx="toggle" style="margin-left:25px"></canvas> +*/ + +var toggle = module.exports = function (target) { + this.defaultSize = { width: 50, height: 50 }; + widget.call(this, target); + + /** @property {object} val Object containing the core interactive aspects of the widget, which are also its data output. Has the following properties: + | | data + | --- | --- + | *value*| 1 if on, 0 if off + */ + this.val = { + value: 0 + } + this.init(); +} +util.inherits(toggle, widget); + +toggle.prototype.init = function() { + this.draw(); +} + +toggle.prototype.draw = function() { + + this.erase() + + with (this.context) { + if (this.val.value) { + fillStyle = this.colors.accent; + // strokeStyle = this.colors.white; + // strokeAlpha = 0.3 + strokeStyle = this.colors.accenthl; + strokeAlpha = 1 + } else { + fillStyle = this.colors.fill; + strokeStyle = this.colors.border; + strokeAlpha = 1 + } + lineWidth = Math.sqrt(this.GUI.w)/2; + //lineWidth = this.GUI.w / 20; + + fillRect(0,0,this.GUI.w,this.GUI.h); + globalAlpha = strokeAlpha + strokeRect(lineWidth/2,lineWidth/2,this.GUI.w-lineWidth,this.GUI.h-lineWidth); + globalAlpha = 1 + } + + this.drawLabel(); + +} + +toggle.prototype.click = function() { + if (!this.val.value) { + this.val.value = 1; + } else { + this.val.value = 0; + } + this.draw(); + this.transmit(this.val); +} + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + +var drawing = __webpack_require__(3); +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class typewriter + Computer keyboard listener and visualization. (Desktop only) <br> **Note:** Clicking on the widget toggles it inactive or active, which can be useful if you need to temporarily type without triggering the widget's events. + ```html + <canvas nx="typewriter"></canvas> + ``` + <canvas nx="typewriter" style="margin-left:25px"></canvas> +*/ + +var typewriter = module.exports = function(target) { + this.defaultSize = { width: 300, height: 100 }; + widget.call(this, target); + + + this.letter = "" + this.keywid = this.GUI.w/14.5; + this.keyhgt = this.GUI.h/5 + + /** @property {boolean} active Whether or not the widget is on (listening for events and transmitting values).*/ + this.active = true; + + /** @property {object} val Object containing the core interactive aspects of the widget, which are also its data output. Has the following properties: + | | data + | --- | --- + | *key* | symbol of key pressed (example: "a") + | *ascii* | ascii value of key pressed (example: 48) + | *on* | 0 if key is being pressed, 1 if key is being released + */ + this.val = { + key: "", + ascii: 0, + on: 0 + } + + this.rows = [ + [ + { symbol: "`", value: 192, width: 1, on: false }, + { symbol: "1", value: 49, width: 1, on: false }, + { symbol: "2", value: 50, width: 1, on: false }, + { symbol: "3", value: 51, width: 1, on: false }, + { symbol: "4", value: 52, width: 1, on: false }, + { symbol: "5", value: 53, width: 1, on: false }, + { symbol: "6", value: 54, width: 1, on: false }, + { symbol: "7", value: 55, width: 1, on: false }, + { symbol: "8", value: 56, width: 1, on: false }, + { symbol: "9", value: 57, width: 1, on: false }, + { symbol: "0", value: 48, width: 1, on: false }, + { symbol: "-", value: 189, width: 1, on: false }, + { symbol: "=", value: 187, width: 1, on: false }, + { symbol: "delete", value: 46, width: 1.5, on: false } + ], + [ + { symbol: "tab", value: 9, width: 1.5, on: false }, + { symbol: "q", value: 81, width: 1, on: false }, + { symbol: "w", value: 87, width: 1, on: false }, + { symbol: "e", value: 69, width: 1, on: false }, + { symbol: "r", value: 82, width: 1, on: false }, + { symbol: "t", value: 84, width: 1, on: false }, + { symbol: "y", value: 89, width: 1, on: false }, + { symbol: "u", value: 85, width: 1, on: false }, + { symbol: "i", value: 73, width: 1, on: false }, + { symbol: "o", value: 79, width: 1, on: false }, + { symbol: "p", value: 80, width: 1, on: false }, + { symbol: "[", value: 219, width: 1, on: false }, + { symbol: "]", value: 221, width: 1, on: false }, + { symbol: "\\", value: 220, width: 1, on: false } + ], + [ + { symbol: "caps", value: 20, width: 1.75, on: false }, + { symbol: "a", value: 65, width: 1, on: false }, + { symbol: "s", value: 83, width: 1, on: false }, + { symbol: "d", value: 68, width: 1, on: false }, + { symbol: "f", value: 70, width: 1, on: false }, + { symbol: "g", value: 71, width: 1, on: false }, + { symbol: "h", value: 72, width: 1, on: false }, + { symbol: "j", value: 74, width: 1, on: false }, + { symbol: "k", value: 75, width: 1, on: false }, + { symbol: "l", value: 76, width: 1, on: false }, + { symbol: ";", value: 186, width: 1, on: false }, + { symbol: "'", value: 222, width: 1, on: false }, + { symbol: "enter", value: 13, width: 1.75, on: false } + ], + [ + { symbol: "shift", value: 16, width: 2.25, on: false }, + { symbol: "z", value: 90, width: 1, on: false }, + { symbol: "x", value: 88, width: 1, on: false }, + { symbol: "c", value: 67, width: 1, on: false }, + { symbol: "v", value: 86, width: 1, on: false }, + { symbol: "b", value: 66, width: 1, on: false }, + { symbol: "n", value: 78, width: 1, on: false }, + { symbol: "m", value: 77, width: 1, on: false }, + { symbol: ",", value: 188, width: 1, on: false }, + { symbol: ".", value: 190, width: 1, on: false }, + { symbol: "/", value: 191, width: 1, on: false }, + { symbol: "shift", value: 16, width: 2.25, on: false } + ], + [ + { symbol: "fn", value: 10, width: 1, on: false }, + { symbol: "ctrl", value: 17, width: 1, on: false }, + { symbol: "opt", value: 10, width: 1, on: false }, + { symbol: "cmd", value: 10, width: 1.25, on: false }, + { symbol: "space", value: 32, width: 5, on: false }, + { symbol: "cmd", value: 10, width: 1, on: false }, + { symbol: "opt", value: 10, width: 1, on: false }, + { symbol: "left", value: 37, width: .81, on: false }, + { symbol: "up", value: 38, width: .81, on: false }, + { symbol: "down", value: 40, width: .81, on: false }, + { symbol: "right", value: 39, width: .81, on: false } + ] + ] + + this.boundType = this.typekey.bind(this); + this.boundUntype = this.untype.bind(this); + window.addEventListener("keydown", this.boundType); + window.addEventListener("keyup", this.boundUntype); + + this.init(); +} +util.inherits(typewriter, widget); + +typewriter.prototype.init = function() { + + this.keywid = this.GUI.w/14.5; + this.keyhgt = this.GUI.h/5 + + this.draw(); +} + +typewriter.prototype.draw = function() { // erase + this.erase(); + + if (!this.active) { + this.context.globalAlpha = 0.4 + } else { + this.context.globalAlpha = 1 + } + + with (this.context) { + + strokeStyle = this.colors.borderhl + fillStyle = this.colors.accent + lineWidth = 1 + + for (var i=0;i<this.rows.length;i++) { + var currkeyL = 0; + for (var j=0;j<this.rows[i].length;j++) { + + if (this.val.key==this.rows[i][j].symbol) { + if (this.val.on) { + this.rows[i][j].on = true; + } else { + this.rows[i][j].on = false; + } + } + + drawing.makeRoundRect(this.context, currkeyL , i*this.keyhgt,this.keywid*this.rows[i][j].width,this.keyhgt,4); + + if (this.rows[i][j].on) { + fillStyle = this.colors.accent + strokeStyle = this.colors.accent + fill() + stroke() + } else { + fillStyle = this.colors.fill + strokeStyle = this.colors.borderhl + + fill() + stroke() + } + + currkeyL += this.keywid*this.rows[i][j].width; + + } + } + + if (this.val.on) { + this.setFont(); + fillStyle = this.colors.borderhl; + font = this.GUI.h+"px "+this.font; + fillText(this.val.key, this.GUI.w/2, this.GUI.h/2); + + globalAlpha = 1 + } + + if (!this.active) { + globalAlpha = 0.7 + fillStyle = this.colors.borderhl; + font = (this.GUI.h/2)+"px courier"; + textAlign = "center"; + textBaseline = "middle" + fillText("inactive", this.GUI.w/2, this.GUI.h/2); + } + } + + this.drawLabel(); +} + +typewriter.prototype.click = function(e) { + this.active = !this.active; + this.draw(); +} + +typewriter.prototype.typekey = function(e) { + if (this.active) { + var currKey = e.which; + for (var i=0;i<this.rows.length;i++) { + for (var j=0;j<this.rows[i].length;j++) { + if (currKey == this.rows[i][j].value) { + this.val.key = this.rows[i][j].symbol; + this.val.on = 1; + this.val.ascii = e.which; + this.transmit(this.val); + break; + } + } + } + this.draw(); + } +} + +typewriter.prototype.untype = function(e) { + if (this.active) { + var currKey = e.which; + for (var i=0;i<this.rows.length;i++) { + for (var j=0;j<this.rows[i].length;j++) { + if (currKey == this.rows[i][j].value) { + // this.rows[i][j].on = false; + this.val.key = this.rows[i][j].symbol; + this.val.on = 0; + this.val.ascii = e.which; + this.transmit(this.val); + break; + } + } + } + this.draw(); + } +} + +typewriter.prototype.customDestroy = function() { + window.removeEventListener("keydown", this.boundType); + window.removeEventListener("keyup", this.boundUntype); +} + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + +var math = __webpack_require__(2) +var util = __webpack_require__(0); +var widget = __webpack_require__(1); + +/** + @class vinyl + For the boom bap + ```html + <canvas nx="vinyl"></canvas> + ``` +<!-- <canvas nx="vinyl" style="margin-left:25px"></canvas> --> +*/ + +var vinyl = module.exports = function (target) { + this.defaultSize = { width: 100, height: 100 }; + widget.call(this, target); + + this.circleSize; + + /** @property speed The rotation increment. Default is 0.05. Not to be confused with .val.speed (see below) which is the data output. During rotation, .speed will always move towards .defaultSpeed */ + this.speed = 0.05; + /** @property defaultSpeed The "steady-state" rotation increment. Default is 0.05. During rotation, if .speed is changed, it will gradually move towards this. */ + this.defaultspeed = 0.05 + this.rotation = 0; + this.hasMovedOnce = false; + + this.lockResize = true; + + /** @property {object} val Object containing the core interactive aspects of the widget, which are also its data output. Has the following properties: + | | data + | --- | --- + | *speed*| Current speed of the record player's rotation. (Normal is 1.) + */ + this.val = { + speed: 0 + } + this.init(); + nx.aniItems.push(this.spin.bind(this)); +} +util.inherits(vinyl, widget); + +vinyl.prototype.init = function() { + + this.circleSize = (Math.min(this.center.x, this.center.y)-this.lineWidth); + this.draw(); +} + +vinyl.prototype.draw = function() { + this.erase() + + with (this.context) { + strokeStyle = this.colors.border; + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h) + + //draw main circle + beginPath(); + fillStyle = this.colors.black; + arc(this.center.x, this.center.y, this.circleSize-5, 0, Math.PI*2, true); + fill(); + closePath(); + + + //draw circle in center + beginPath(); + fillStyle = this.colors.accent; + arc(this.center.x, this.center.y*1, this.circleSize/4, 0, Math.PI*2, false); + fill() + closePath(); + + + //draw tint + beginPath(); + globalAlpha = 0.5; + fillStyle = this.colors.fill; + arc(this.center.x, this.center.y, this.circleSize, this.rotation, this.rotation + 0.4, false); + lineTo(this.center.x, this.center.y); + arc(this.center.x, this.center.y, this.circleSize, this.rotation+Math.PI, this.rotation +Math.PI+ 0.4, false); + lineTo(this.center.x, this.center.y); + fill(); + globalAlpha = 1; + closePath(); + + + //draw white circle in center + beginPath(); + fillStyle = this.colors.white; + arc(this.center.x, this.center.y*1, this.circleSize/16, 0, Math.PI*2, false); + fill() + closePath(); + + } + + this.drawLabel(); +} + +vinyl.prototype.click = function(e) { + this.hasMovedOnce = false; + this.lastRotation = this.rotation + this.grabAngle = this.rotation % (Math.PI*2) + this.grabPos = math.toPolar(this.clickPos.x-this.center.x,this.clickPos.y-this.center.y).angle + +} + +vinyl.prototype.move = function() { + + if (!this.hasMovedOnce) { + this.hasMovedOnce = true; + this.grabAngle = this.rotation % (Math.PI*2) + this.grabPos = math.toPolar(this.clickPos.x-this.center.x,this.clickPos.y-this.center.y).angle + } + + this.rotation = math.toPolar(this.clickPos.x-this.center.x,this.clickPos.y-this.center.y).angle + this.grabAngle - this.grabPos + + +} + +vinyl.prototype.release = function() { + this.speed = ((this.rotation - this.lastRotation) + (this.lastRotation-this.lastRotation2))/2 ; +} + +vinyl.prototype.spin = function() { + + if (this.clicked) { + this.speed /= 1.1; + } else { + this.speed = this.speed*0.9 + this.defaultspeed*0.1 + } + + // may need to math.clip(this.val.speed,-10,10); + this.val.speed = (this.rotation - this.lastRotation) * 20; // normalizes it to 1 + + this.lastRotation2 = this.lastRotation + this.lastRotation = this.rotation + + this.rotation += this.speed + + this.draw(); + + this.transmit(this.val) + +} + +vinyl.prototype.customDestroy = function() { + nx.removeAni(this.spin.bind(this)); +} + +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { + +var util = __webpack_require__(0); +var widget = __webpack_require__(1); +var math = __webpack_require__(2) + +/** + @class waveform + Waveform visualizer and selecter + ```html + <canvas nx="waveform"></canvas> + ``` +*/ + +var waveform = module.exports = function (target) { + this.defaultSize = { width: 400, height: 125 }; + widget.call(this, target); + + /** @property {object} val Object containing core interactive aspects of widget, which are also its data output. Has the following properties: + | | data + | --- | --- + | *starttime* | Waveform selection start position in milliseconds (integer) + | *stoptime* | Waveform selection end position in milliseconds (integer) + | *looptime* | Selection size, in milliseconds (integer) + | *start* | Waveform selection start, as fraction of waveform (float 0-1) + | *stop* | Waveform selection end, as fraction of waveform (float 0-1) + | *size* | Selection size, as fraction of waveform (float 0-1) + */ + this.val = { + start: 0, + stop: 0, + size: 0, + starttime: 0, + stoptime: 0, + looptime: 0 + } + + this.handle; + this.relhandle; + this.cap; + this.firsttouch = "start"; + + /** @property {Array} buffer Contains multiple arrays of reduced buffer data, for visualization */ + this.buffer = [] + + if (nx.isMobile) { + /** @property {integer} definition Horizontal definition of the visualization. Value of 3 means the waveform will be represented in 3 pixel chunks. Higher numbers (4+) lead to a smaller graphics load. Smaller numbers (1-3) look better. Default is 1 for desktop renders, 3 for mobile renders. */ + this.definition = 3; + } else { + this.definition = 1; + } + + this.pieces = false; + + /** @property {integer} channels How many channels in the waveform */ + this.channels = 1 + this.rawbuffer = [] + + this.times = [ + { dur: 10 , format: 1 }, + { dur: 50 , format: 1 }, + { dur: 100 , format: 1 }, + { dur: 200 , format: 1 }, + { dur: 500 , format: 1 }, + { dur: 1000 , format: 1 }, + { dur: 2000 , format: 1 }, + { dur: 5000 , format: 1 }, + { dur: 10000 , format: 3 }, + { dur: 15000 , format: 3 }, + { dur: 60000 , format: 3 }, // 1 min + { dur: 120000 , format: 3 }, // 2 mins + { dur: 300000 , format: 3 }, // 5 mins + { dur: 600000 , format: 3 }, // 10 mins + ] + this.timescale = false + + // to do -- + // // sample rate adjustments + // .select(500,1000) + + /** @property {string} mode Mode of interaction. "edge" mode lets you drag each edge of the waveform individually. "area" mode (default) lets you drag the waveform as a whole (with parallel mouse movement) or scale the waveform as a whole (with transverse mouse movement) */ + this.mode = "area" // modes: "edge", "area" + this.touchdown = new Object(); + this.init(); +} +util.inherits(waveform, widget); + +waveform.prototype.init = function() { + + this.pieces = ~~(this.GUI.w/this.definition); + + this.draw(); +} + + +/** + @method setBuffer + Load a web audio AudioBuffer into the waveform ui, for analysis and visualization. + @param {AudioBuffer} [buffer] The buffer to be loaded. + */ +waveform.prototype.setBuffer = function(prebuff) { + + this.channels = prebuff.numberOfChannels + this.duration = prebuff.duration + this.sampleRate = prebuff.sampleRate + this.waveHeight = this.GUI.h / this.channels + + // timescale + this.durationMS = (this.duration * 1000) + this.timescale = 0 + while (~~(this.durationMS/this.times[this.timescale].dur) > 7 && this.timescale < this.times.length ) { + this.timescale++; + } + this.timescale = this.times[this.timescale] + + this.rawbuffer = [] + this.buffer = [] + + // reduce/crush buffers + for (var i=0;i<this.channels;i++) { + this.rawbuffer.push(prebuff.getChannelData(0)) + this.buffer.push([]) + + // counts faster (& less accurately) through larger buffers. + // for every 5 seconds in the buffer, our counter skips 1. + // so a 10 second buffer will only look at every 3rd sample + // when calculating waveform. + var countinc = ~~(this.rawbuffer[0].length / (this.sampleRate*5)) + 1 + + var groupsize = ~~(this.rawbuffer[i].length/this.pieces) + var cmax = 0 + var cmin = 0 + var group = 0 + var vis = [] + for (var j=0;j<this.rawbuffer[i].length;j += countinc) { + if (this.rawbuffer[i][j]>0) { + cmax = Math.max(cmax,this.rawbuffer[i][j]) + } else { + cmin = Math.min(cmin,this.rawbuffer[i][j]) + } + if (j > group * groupsize) { + this.buffer[i].push([cmax,cmin]) + group++ + cmin = 0 + cmax = 0 + } + } + } + + if (this.val.start && this.val.stop) { + + } + + this.val.starttime = Math.round(this.val.start * this.durationMS) + this.val.stoptime = Math.round(this.val.stop * this.durationMS) + this.val.looptime = Math.round(this.val.size * this.durationMS) + + + this.draw() + +} + +/** + @method select + Set the selection start and end points. + @param {integer} [start] Selection start point in milliseconds + @param {integer} [end] Selection end point in milliseconds + */ +waveform.prototype.select = function(start,stop) { + this.val.start = math.clip(start / this.durationMS,0,1) + this.val.stop = math.clip(stop / this.durationMS,0,1) + this.val.size = this.val.stop - this.val.start + this.val.starttime = start + this.val.stoptime = stop + this.val.looptime = start - stop + this.transmit(this.val) + this.draw() +} + + +waveform.prototype.draw = function() { + //this.erase(); + + with (this.context) { + //bg + fillStyle = this.colors.fill; + fillRect(0,0,this.GUI.w,this.GUI.h); + + //waveform + for (var i=0;i<this.buffer.length;i++) { + fillStyle = this.colors.black + this.waveTop = i*this.waveHeight; + this.waveCenter = this.waveTop + this.waveHeight/2 + for (var j=0;j<this.buffer[i].length;j++) { + var ht1 = this.waveCenter - this.buffer[i][j][0]*this.waveHeight + var ht2 = this.waveCenter + Math.abs(this.buffer[i][j][1]*this.waveHeight) + ht2 = ht2 - ht1 + fillRect( j*this.definition, ht1 , this.definition, ht2) + } + this.buffer[i] + + } + + //time bar - top + globalAlpha = 0.3 + fillStyle = this.colors.border + fillRect(0,0,this.GUI.w,16) + globalAlpha = 1 + + + textBaseline = "middle" + textAlign = "left" + fontSize = "8px" + + //time lines + if (this.timescale) { + for (var i=1; i<this.durationMS/this.timescale.dur; i++) { + var x = (i * this.timescale.dur) / this.durationMS + x *= this.GUI.w + fillStyle = this.colors.border + fillRect(x,0,1,this.GUI.h) + fillStyle = this.colors.black + globalAlpha = 0.6 + fillText(this.msToTime(i * this.timescale.dur,this.timescale.format),x+5,8) + globalAlpha = 1 + } + } + + + // range selection + var x1 = this.val.start*this.GUI.w; + var y1 = 0; + var x2 = this.val.stop*this.GUI.w; + var y2 = this.GUI.h; + + fillStyle = this.colors.accent; + strokeStyle = this.colors.accent; + lineWidth = 2 + globalAlpha = 0.3 + fillRect(x1,y1,x2-x1,y2-y1); + globalAlpha = 0.7 + strokeRect(x1,y1-2,x2-x1,y2-y1+4); + if (this.durationMS && this.val.looptime) { + this.val.size = this.val.stop - this.val.start + textAlign = "center" + var dur = this.val.looptime + if (dur > 1000) { + dur /= 1000 + math.prune(dur,2) + dur += ' s' + } else { + math.prune(dur,0) + dur += ' ms' + } + fillText(dur,x1 + (x2-x1)/2,this.GUI.h/2) + } + + globalAlpha = 1 + + + } + +} + +waveform.prototype.msToTime = function(rawms,format) { + + var format = format ? format : 2 + + var s = ~~(rawms / 1000) + var secs = s % 60; + s = (s - secs) / 60; + var mins = s % 60; + var hrs = (s - mins) / 60; + var ms = rawms % 1000 + + //correct digits + secs = (secs < 10 && mins) ? secs + '0' : secs; + //ms = (ms < 10 && secs) ? ms + '0' : ms; + + if (format==1) { + return secs + '.' + ms; + } else if (format==2) { + return mins + ':' + secs + '.' + ms; + } else if (format==3) { + return mins + ':' + secs; + } + +} + +waveform.prototype.click = function() { + if (this.mode=="edge") { + if (Math.abs(this.clickPos.x-this.val.start*this.GUI.w) < Math.abs(this.clickPos.x-this.val.stop*this.GUI.w)) { + this.firsttouch = "start" + } else { + this.firsttouch = "stop" + } + } else if (this.mode=="area") { + this.touchdown = { + x: this.clickPos.x, + y: this.clickPos.y + } + this.startval = new Object(); + this.startval.size = this.val.stop - this.val.start; + this.startval.loc = this.val.start + this.startval.size/2; + } + this.move(); +} + +waveform.prototype.move = function() { + + if (this.mode=="edge") { + if (this.firsttouch=="start") { + this.val.start = this.clickPos.x/this.GUI.w; + if (this.clickPos.touches.length>1) { + this.val.stop = this.clickPos.touches[1].x/this.GUI.w; + } + } else { + this.val.stop = this.clickPos.x/this.GUI.w; + if (this.clickPos.touches.length>1) { + this.val.start = this.clickPos.touches[1].x/this.GUI.w; + } + } + + + if (this.val.stop < this.val.start) { + this.tempstart = this.val.start; + this.val.start = this.val.stop; + this.val.stop = this.tempstart; + if (this.firsttouch=="start") { + this.firsttouch = "stop"; + } else { + this.firsttouch = "start"; + } + } + + } else if (this.mode=="area") { + + var moveloc = this.clickPos.x/this.GUI.w; + var movesize = (this.touchdown.y - this.clickPos.y)/this.GUI.h; + + movesize /= 4; + var size = this.startval.size + movesize; + size = math.clip(size,0.001,1); + + this.val = { + start: moveloc - size/2, + stop: moveloc + size/2, + } + + } + + this.val.start = math.clip(this.val.start,0,1); + this.val.stop = math.clip(this.val.stop,0,1); + + this.val['size'] = math.clip(Math.abs(this.val.stop - this.val.start), 0, 1) + + if (this.durationMS) { + this.val["starttime"] = Math.round(this.val.start * this.durationMS) + this.val["stoptime"] = Math.round(this.val.stop * this.durationMS) + this.val["looptime"] = Math.round(this.val.size * this.durationMS) + } + + this.transmit(this.val); + this.draw(); + +} + +/***/ }), +/* 52 */ +/***/ (function(module, exports) { + +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + + +/***/ }), +/* 53 */ +/***/ (function(module, exports) { + +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + + +/***/ }), +/* 54 */ +/***/ (function(module, exports) { + +module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; +} + +/***/ }), +/* 55 */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_RESULT__;/* Web Font Loader v1.6.27 - (c) Adobe Systems, Google. License: Apache 2.0 */(function(){function aa(a,b,c){return a.call.apply(a.bind,arguments)}function ba(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function p(a,b,c){p=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?aa:ba;return p.apply(null,arguments)}var q=Date.now||function(){return+new Date};function ca(a,b){this.a=a;this.m=b||a;this.c=this.m.document}var da=!!window.FontFace;function t(a,b,c,d){b=a.c.createElement(b);if(c)for(var e in c)c.hasOwnProperty(e)&&("style"==e?b.style.cssText=c[e]:b.setAttribute(e,c[e]));d&&b.appendChild(a.c.createTextNode(d));return b}function u(a,b,c){a=a.c.getElementsByTagName(b)[0];a||(a=document.documentElement);a.insertBefore(c,a.lastChild)}function v(a){a.parentNode&&a.parentNode.removeChild(a)} +function w(a,b,c){b=b||[];c=c||[];for(var d=a.className.split(/\s+/),e=0;e<b.length;e+=1){for(var f=!1,g=0;g<d.length;g+=1)if(b[e]===d[g]){f=!0;break}f||d.push(b[e])}b=[];for(e=0;e<d.length;e+=1){f=!1;for(g=0;g<c.length;g+=1)if(d[e]===c[g]){f=!0;break}f||b.push(d[e])}a.className=b.join(" ").replace(/\s+/g," ").replace(/^\s+|\s+$/,"")}function y(a,b){for(var c=a.className.split(/\s+/),d=0,e=c.length;d<e;d++)if(c[d]==b)return!0;return!1} +function z(a){if("string"===typeof a.f)return a.f;var b=a.m.location.protocol;"about:"==b&&(b=a.a.location.protocol);return"https:"==b?"https:":"http:"}function ea(a){return a.m.location.hostname||a.a.location.hostname} +function A(a,b,c){function d(){k&&e&&f&&(k(g),k=null)}b=t(a,"link",{rel:"stylesheet",href:b,media:"all"});var e=!1,f=!0,g=null,k=c||null;da?(b.onload=function(){e=!0;d()},b.onerror=function(){e=!0;g=Error("Stylesheet failed to load");d()}):setTimeout(function(){e=!0;d()},0);u(a,"head",b)} +function B(a,b,c,d){var e=a.c.getElementsByTagName("head")[0];if(e){var f=t(a,"script",{src:b}),g=!1;f.onload=f.onreadystatechange=function(){g||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(g=!0,c&&c(null),f.onload=f.onreadystatechange=null,"HEAD"==f.parentNode.tagName&&e.removeChild(f))};e.appendChild(f);setTimeout(function(){g||(g=!0,c&&c(Error("Script load timeout")))},d||5E3);return f}return null};function C(){this.a=0;this.c=null}function D(a){a.a++;return function(){a.a--;E(a)}}function F(a,b){a.c=b;E(a)}function E(a){0==a.a&&a.c&&(a.c(),a.c=null)};function G(a){this.a=a||"-"}G.prototype.c=function(a){for(var b=[],c=0;c<arguments.length;c++)b.push(arguments[c].replace(/[\W_]+/g,"").toLowerCase());return b.join(this.a)};function H(a,b){this.c=a;this.f=4;this.a="n";var c=(b||"n4").match(/^([nio])([1-9])$/i);c&&(this.a=c[1],this.f=parseInt(c[2],10))}function fa(a){return I(a)+" "+(a.f+"00")+" 300px "+J(a.c)}function J(a){var b=[];a=a.split(/,\s*/);for(var c=0;c<a.length;c++){var d=a[c].replace(/['"]/g,"");-1!=d.indexOf(" ")||/^\d/.test(d)?b.push("'"+d+"'"):b.push(d)}return b.join(",")}function K(a){return a.a+a.f}function I(a){var b="normal";"o"===a.a?b="oblique":"i"===a.a&&(b="italic");return b} +function ga(a){var b=4,c="n",d=null;a&&((d=a.match(/(normal|oblique|italic)/i))&&d[1]&&(c=d[1].substr(0,1).toLowerCase()),(d=a.match(/([1-9]00|normal|bold)/i))&&d[1]&&(/bold/i.test(d[1])?b=7:/[1-9]00/.test(d[1])&&(b=parseInt(d[1].substr(0,1),10))));return c+b};function ha(a,b){this.c=a;this.f=a.m.document.documentElement;this.h=b;this.a=new G("-");this.j=!1!==b.events;this.g=!1!==b.classes}function ia(a){a.g&&w(a.f,[a.a.c("wf","loading")]);L(a,"loading")}function M(a){if(a.g){var b=y(a.f,a.a.c("wf","active")),c=[],d=[a.a.c("wf","loading")];b||c.push(a.a.c("wf","inactive"));w(a.f,c,d)}L(a,"inactive")}function L(a,b,c){if(a.j&&a.h[b])if(c)a.h[b](c.c,K(c));else a.h[b]()};function ja(){this.c={}}function ka(a,b,c){var d=[],e;for(e in b)if(b.hasOwnProperty(e)){var f=a.c[e];f&&d.push(f(b[e],c))}return d};function N(a,b){this.c=a;this.f=b;this.a=t(this.c,"span",{"aria-hidden":"true"},this.f)}function O(a){u(a.c,"body",a.a)}function P(a){return"display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:"+J(a.c)+";"+("font-style:"+I(a)+";font-weight:"+(a.f+"00")+";")};function Q(a,b,c,d,e,f){this.g=a;this.j=b;this.a=d;this.c=c;this.f=e||3E3;this.h=f||void 0}Q.prototype.start=function(){var a=this.c.m.document,b=this,c=q(),d=new Promise(function(d,e){function k(){q()-c>=b.f?e():a.fonts.load(fa(b.a),b.h).then(function(a){1<=a.length?d():setTimeout(k,25)},function(){e()})}k()}),e=new Promise(function(a,d){setTimeout(d,b.f)});Promise.race([e,d]).then(function(){b.g(b.a)},function(){b.j(b.a)})};function R(a,b,c,d,e,f,g){this.v=a;this.B=b;this.c=c;this.a=d;this.s=g||"BESbswy";this.f={};this.w=e||3E3;this.u=f||null;this.o=this.j=this.h=this.g=null;this.g=new N(this.c,this.s);this.h=new N(this.c,this.s);this.j=new N(this.c,this.s);this.o=new N(this.c,this.s);a=new H(this.a.c+",serif",K(this.a));a=P(a);this.g.a.style.cssText=a;a=new H(this.a.c+",sans-serif",K(this.a));a=P(a);this.h.a.style.cssText=a;a=new H("serif",K(this.a));a=P(a);this.j.a.style.cssText=a;a=new H("sans-serif",K(this.a));a= +P(a);this.o.a.style.cssText=a;O(this.g);O(this.h);O(this.j);O(this.o)}var S={D:"serif",C:"sans-serif"},T=null;function U(){if(null===T){var a=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);T=!!a&&(536>parseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}return T}R.prototype.start=function(){this.f.serif=this.j.a.offsetWidth;this.f["sans-serif"]=this.o.a.offsetWidth;this.A=q();la(this)}; +function ma(a,b,c){for(var d in S)if(S.hasOwnProperty(d)&&b===a.f[S[d]]&&c===a.f[S[d]])return!0;return!1}function la(a){var b=a.g.a.offsetWidth,c=a.h.a.offsetWidth,d;(d=b===a.f.serif&&c===a.f["sans-serif"])||(d=U()&&ma(a,b,c));d?q()-a.A>=a.w?U()&&ma(a,b,c)&&(null===a.u||a.u.hasOwnProperty(a.a.c))?V(a,a.v):V(a,a.B):na(a):V(a,a.v)}function na(a){setTimeout(p(function(){la(this)},a),50)}function V(a,b){setTimeout(p(function(){v(this.g.a);v(this.h.a);v(this.j.a);v(this.o.a);b(this.a)},a),0)};function W(a,b,c){this.c=a;this.a=b;this.f=0;this.o=this.j=!1;this.s=c}var X=null;W.prototype.g=function(a){var b=this.a;b.g&&w(b.f,[b.a.c("wf",a.c,K(a).toString(),"active")],[b.a.c("wf",a.c,K(a).toString(),"loading"),b.a.c("wf",a.c,K(a).toString(),"inactive")]);L(b,"fontactive",a);this.o=!0;oa(this)}; +W.prototype.h=function(a){var b=this.a;if(b.g){var c=y(b.f,b.a.c("wf",a.c,K(a).toString(),"active")),d=[],e=[b.a.c("wf",a.c,K(a).toString(),"loading")];c||d.push(b.a.c("wf",a.c,K(a).toString(),"inactive"));w(b.f,d,e)}L(b,"fontinactive",a);oa(this)};function oa(a){0==--a.f&&a.j&&(a.o?(a=a.a,a.g&&w(a.f,[a.a.c("wf","active")],[a.a.c("wf","loading"),a.a.c("wf","inactive")]),L(a,"active")):M(a.a))};function pa(a){this.j=a;this.a=new ja;this.h=0;this.f=this.g=!0}pa.prototype.load=function(a){this.c=new ca(this.j,a.context||this.j);this.g=!1!==a.events;this.f=!1!==a.classes;qa(this,new ha(this.c,a),a)}; +function ra(a,b,c,d,e){var f=0==--a.h;(a.f||a.g)&&setTimeout(function(){var a=e||null,k=d||null||{};if(0===c.length&&f)M(b.a);else{b.f+=c.length;f&&(b.j=f);var h,m=[];for(h=0;h<c.length;h++){var l=c[h],n=k[l.c],r=b.a,x=l;r.g&&w(r.f,[r.a.c("wf",x.c,K(x).toString(),"loading")]);L(r,"fontloading",x);r=null;if(null===X)if(window.FontFace){var x=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent),ya=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor); +X=x?42<parseInt(x[1],10):ya?!1:!0}else X=!1;X?r=new Q(p(b.g,b),p(b.h,b),b.c,l,b.s,n):r=new R(p(b.g,b),p(b.h,b),b.c,l,b.s,a,n);m.push(r)}for(h=0;h<m.length;h++)m[h].start()}},0)}function qa(a,b,c){var d=[],e=c.timeout;ia(b);var d=ka(a.a,c,a.c),f=new W(a.c,b,e);a.h=d.length;b=0;for(c=d.length;b<c;b++)d[b].load(function(b,d,c){ra(a,f,b,d,c)})};function sa(a,b){this.c=a;this.a=b}function ta(a,b,c){var d=z(a.c);a=(a.a.api||"fast.fonts.net/jsapi").replace(/^.*http(s?):(\/\/)?/,"");return d+"//"+a+"/"+b+".js"+(c?"?v="+c:"")} +sa.prototype.load=function(a){function b(){if(f["__mti_fntLst"+d]){var c=f["__mti_fntLst"+d](),e=[],h;if(c)for(var m=0;m<c.length;m++){var l=c[m].fontfamily;void 0!=c[m].fontStyle&&void 0!=c[m].fontWeight?(h=c[m].fontStyle+c[m].fontWeight,e.push(new H(l,h))):e.push(new H(l))}a(e)}else setTimeout(function(){b()},50)}var c=this,d=c.a.projectId,e=c.a.version;if(d){var f=c.c.m;B(this.c,ta(c,d,e),function(e){e?a([]):(f["__MonotypeConfiguration__"+d]=function(){return c.a},b())}).id="__MonotypeAPIScript__"+ +d}else a([])};function ua(a,b){this.c=a;this.a=b}ua.prototype.load=function(a){var b,c,d=this.a.urls||[],e=this.a.families||[],f=this.a.testStrings||{},g=new C;b=0;for(c=d.length;b<c;b++)A(this.c,d[b],D(g));var k=[];b=0;for(c=e.length;b<c;b++)if(d=e[b].split(":"),d[1])for(var h=d[1].split(","),m=0;m<h.length;m+=1)k.push(new H(d[0],h[m]));else k.push(new H(d[0]));F(g,function(){a(k,f)})};function va(a,b,c){a?this.c=a:this.c=b+wa;this.a=[];this.f=[];this.g=c||""}var wa="//fonts.googleapis.com/css";function xa(a,b){for(var c=b.length,d=0;d<c;d++){var e=b[d].split(":");3==e.length&&a.f.push(e.pop());var f="";2==e.length&&""!=e[1]&&(f=":");a.a.push(e.join(f))}} +function za(a){if(0==a.a.length)throw Error("No fonts to load!");if(-1!=a.c.indexOf("kit="))return a.c;for(var b=a.a.length,c=[],d=0;d<b;d++)c.push(a.a[d].replace(/ /g,"+"));b=a.c+"?family="+c.join("%7C");0<a.f.length&&(b+="&subset="+a.f.join(","));0<a.g.length&&(b+="&text="+encodeURIComponent(a.g));return b};function Aa(a){this.f=a;this.a=[];this.c={}} +var Ba={latin:"BESbswy","latin-ext":"\u00e7\u00f6\u00fc\u011f\u015f",cyrillic:"\u0439\u044f\u0416",greek:"\u03b1\u03b2\u03a3",khmer:"\u1780\u1781\u1782",Hanuman:"\u1780\u1781\u1782"},Ca={thin:"1",extralight:"2","extra-light":"2",ultralight:"2","ultra-light":"2",light:"3",regular:"4",book:"4",medium:"5","semi-bold":"6",semibold:"6","demi-bold":"6",demibold:"6",bold:"7","extra-bold":"8",extrabold:"8","ultra-bold":"8",ultrabold:"8",black:"9",heavy:"9",l:"3",r:"4",b:"7"},Da={i:"i",italic:"i",n:"n",normal:"n"}, +Ea=/^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/; +function Fa(a){for(var b=a.f.length,c=0;c<b;c++){var d=a.f[c].split(":"),e=d[0].replace(/\+/g," "),f=["n4"];if(2<=d.length){var g;var k=d[1];g=[];if(k)for(var k=k.split(","),h=k.length,m=0;m<h;m++){var l;l=k[m];if(l.match(/^[\w-]+$/)){var n=Ea.exec(l.toLowerCase());if(null==n)l="";else{l=n[2];l=null==l||""==l?"n":Da[l];n=n[1];if(null==n||""==n)n="4";else var r=Ca[n],n=r?r:isNaN(n)?"4":n.substr(0,1);l=[l,n].join("")}}else l="";l&&g.push(l)}0<g.length&&(f=g);3==d.length&&(d=d[2],g=[],d=d?d.split(","): +g,0<d.length&&(d=Ba[d[0]])&&(a.c[e]=d))}a.c[e]||(d=Ba[e])&&(a.c[e]=d);for(d=0;d<f.length;d+=1)a.a.push(new H(e,f[d]))}};function Ga(a,b){this.c=a;this.a=b}var Ha={Arimo:!0,Cousine:!0,Tinos:!0};Ga.prototype.load=function(a){var b=new C,c=this.c,d=new va(this.a.api,z(c),this.a.text),e=this.a.families;xa(d,e);var f=new Aa(e);Fa(f);A(c,za(d),D(b));F(b,function(){a(f.a,f.c,Ha)})};function Ia(a,b){this.c=a;this.a=b}Ia.prototype.load=function(a){var b=this.a.id,c=this.c.m;b?B(this.c,(this.a.api||"https://use.typekit.net")+"/"+b+".js",function(b){if(b)a([]);else if(c.Typekit&&c.Typekit.config&&c.Typekit.config.fn){b=c.Typekit.config.fn;for(var e=[],f=0;f<b.length;f+=2)for(var g=b[f],k=b[f+1],h=0;h<k.length;h++)e.push(new H(g,k[h]));try{c.Typekit.load({events:!1,classes:!1,async:!0})}catch(m){}a(e)}},2E3):a([])};function Ja(a,b){this.c=a;this.f=b;this.a=[]}Ja.prototype.load=function(a){var b=this.f.id,c=this.c.m,d=this;b?(c.__webfontfontdeckmodule__||(c.__webfontfontdeckmodule__={}),c.__webfontfontdeckmodule__[b]=function(b,c){for(var g=0,k=c.fonts.length;g<k;++g){var h=c.fonts[g];d.a.push(new H(h.name,ga("font-weight:"+h.weight+";font-style:"+h.style)))}a(d.a)},B(this.c,z(this.c)+(this.f.api||"//f.fontdeck.com/s/css/js/")+ea(this.c)+"/"+b+".js",function(b){b&&a([])})):a([])};var Y=new pa(window);Y.a.c.custom=function(a,b){return new ua(b,a)};Y.a.c.fontdeck=function(a,b){return new Ja(b,a)};Y.a.c.monotype=function(a,b){return new sa(b,a)};Y.a.c.typekit=function(a,b){return new Ia(b,a)};Y.a.c.google=function(a,b){return new Ga(b,a)};var Z={load:p(Y.load,Y)}; true?!(__WEBPACK_AMD_DEFINE_RESULT__ = function(){return Z}.call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)):"undefined"!==typeof module&&module.exports?module.exports=Z:(window.WebFont=Z,window.WebFontConfig&&Y.load(window.WebFontConfig));}()); + + +/***/ }), +/* 56 */ +/***/ (function(module, exports) { + +var g;
+
+// This works in non-strict mode
+g = (function() {
+ return this;
+})();
+
+try {
+ // This works if eval is allowed (see CSP)
+ g = g || Function("return this")() || (1,eval)("this");
+} catch(e) {
+ // This works if the window reference is available
+ if(typeof window === "object")
+ g = window;
+}
+
+// g can still be undefined, but nothing to do about it...
+// We return undefined, instead of nothing here, so it's
+// easier to handle this case. if(!global) { ...}
+
+module.exports = g;
+ + +/***/ }) +/******/ ]); //# sourceMappingURL=bundle.js.map
\ No newline at end of file diff --git a/bundle.js.map b/bundle.js.map index eee3621..f5549ab 100644 --- a/bundle.js.map +++ b/bundle.js.map @@ -1 +1 @@ -{"version":3,"file":"./bundle.js","sources":["webpack:///./bundle.js"],"sourcesContent":["!function(t){function e(s){if(i[s])return i[s].exports;var n=i[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var i={};e.m=t,e.c=i,e.i=function(t){return t},e.d=function(t,i,s){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:s})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,\"a\",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p=\"\",e(e.s=15)}([function(t,e,i){(function(t,s){function n(t,i){var s={seen:[],stylize:r};return arguments.length>=3&&(s.depth=arguments[2]),arguments.length>=4&&(s.colors=arguments[3]),y(i)?s.showHidden=i:i&&e._extend(s,i),b(s.showHidden)&&(s.showHidden=!1),b(s.depth)&&(s.depth=2),b(s.colors)&&(s.colors=!1),b(s.customInspect)&&(s.customInspect=!0),s.colors&&(s.stylize=o),h(s,t,s.depth)}function o(t,e){var i=n.styles[e];return i?\"\u001b[\"+n.colors[i][0]+\"m\"+t+\"\u001b[\"+n.colors[i][1]+\"m\":t}function r(t,e){return t}function a(t){var e={};return t.forEach(function(t,i){e[t]=!0}),e}function h(t,i,s){if(t.customInspect&&i&&P(i.inspect)&&i.inspect!==e.inspect&&(!i.constructor||i.constructor.prototype!==i)){var n=i.inspect(s,t);return g(n)||(n=h(t,n,s)),n}var o=l(t,i);if(o)return o;var r=Object.keys(i),y=a(r);if(t.showHidden&&(r=Object.getOwnPropertyNames(i)),k(i)&&(r.indexOf(\"message\")>=0||r.indexOf(\"description\")>=0))return c(i);if(0===r.length){if(P(i)){var _=i.name?\": \"+i.name:\"\";return t.stylize(\"[Function\"+_+\"]\",\"special\")}if(x(i))return t.stylize(RegExp.prototype.toString.call(i),\"regexp\");if(T(i))return t.stylize(Date.prototype.toString.call(i),\"date\");if(k(i))return c(i)}var m=\"\",v=!1,w=[\"{\",\"}\"];if(f(i)&&(v=!0,w=[\"[\",\"]\"]),P(i)){m=\" [Function\"+(i.name?\": \"+i.name:\"\")+\"]\"}if(x(i)&&(m=\" \"+RegExp.prototype.toString.call(i)),T(i)&&(m=\" \"+Date.prototype.toUTCString.call(i)),k(i)&&(m=\" \"+c(i)),0===r.length&&(!v||0==i.length))return w[0]+m+w[1];if(s<0)return x(i)?t.stylize(RegExp.prototype.toString.call(i),\"regexp\"):t.stylize(\"[Object]\",\"special\");t.seen.push(i);var b;return b=v?u(t,i,s,y,r):r.map(function(e){return p(t,i,s,y,e,v)}),t.seen.pop(),d(b,m,w)}function l(t,e){if(b(e))return t.stylize(\"undefined\",\"undefined\");if(g(e)){var i=\"'\"+JSON.stringify(e).replace(/^\"|\"$/g,\"\").replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"')+\"'\";return t.stylize(i,\"string\")}return v(e)?t.stylize(\"\"+e,\"number\"):y(e)?t.stylize(\"\"+e,\"boolean\"):_(e)?t.stylize(\"null\",\"null\"):void 0}function c(t){return\"[\"+Error.prototype.toString.call(t)+\"]\"}function u(t,e,i,s,n){for(var o=[],r=0,a=e.length;r<a;++r)q(e,String(r))?o.push(p(t,e,i,s,String(r),!0)):o.push(\"\");return n.forEach(function(n){n.match(/^\\d+$/)||o.push(p(t,e,i,s,n,!0))}),o}function p(t,e,i,s,n,o){var r,a,l;if(l=Object.getOwnPropertyDescriptor(e,n)||{value:e[n]},l.get?a=l.set?t.stylize(\"[Getter/Setter]\",\"special\"):t.stylize(\"[Getter]\",\"special\"):l.set&&(a=t.stylize(\"[Setter]\",\"special\")),q(s,n)||(r=\"[\"+n+\"]\"),a||(t.seen.indexOf(l.value)<0?(a=_(i)?h(t,l.value,null):h(t,l.value,i-1),a.indexOf(\"\\n\")>-1&&(a=o?a.split(\"\\n\").map(function(t){return\" \"+t}).join(\"\\n\").substr(2):\"\\n\"+a.split(\"\\n\").map(function(t){return\" \"+t}).join(\"\\n\"))):a=t.stylize(\"[Circular]\",\"special\")),b(r)){if(o&&n.match(/^\\d+$/))return a;r=JSON.stringify(\"\"+n),r.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)?(r=r.substr(1,r.length-2),r=t.stylize(r,\"name\")):(r=r.replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"').replace(/(^\"|\"$)/g,\"'\"),r=t.stylize(r,\"string\"))}return r+\": \"+a}function d(t,e,i){var s=0;return t.reduce(function(t,e){return s++,e.indexOf(\"\\n\")>=0&&s++,t+e.replace(/\\u001b\\[\\d\\d?m/g,\"\").length+1},0)>60?i[0]+(\"\"===e?\"\":e+\"\\n \")+\" \"+t.join(\",\\n \")+\" \"+i[1]:i[0]+e+\" \"+t.join(\", \")+\" \"+i[1]}function f(t){return Array.isArray(t)}function y(t){return\"boolean\"==typeof t}function _(t){return null===t}function m(t){return null==t}function v(t){return\"number\"==typeof t}function g(t){return\"string\"==typeof t}function w(t){return\"symbol\"==typeof t}function b(t){return void 0===t}function x(t){return S(t)&&\"[object RegExp]\"===A(t)}function S(t){return\"object\"==typeof t&&null!==t}function T(t){return S(t)&&\"[object Date]\"===A(t)}function k(t){return S(t)&&(\"[object Error]\"===A(t)||t instanceof Error)}function P(t){return\"function\"==typeof t}function O(t){return null===t||\"boolean\"==typeof t||\"number\"==typeof t||\"string\"==typeof t||\"symbol\"==typeof t||void 0===t}function A(t){return Object.prototype.toString.call(t)}function M(t){return t<10?\"0\"+t.toString(10):t.toString(10)}function I(){var t=new Date,e=[M(t.getHours()),M(t.getMinutes()),M(t.getSeconds())].join(\":\");return[t.getDate(),U[t.getMonth()],e].join(\" \")}function q(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.format=function(t){if(!g(t)){for(var e=[],i=0;i<arguments.length;i++)e.push(n(arguments[i]));return e.join(\" \")}for(var i=1,s=arguments,o=s.length,r=String(t).replace(/%[sdj%]/g,function(t){if(\"%%\"===t)return\"%\";if(i>=o)return t;switch(t){case\"%s\":return String(s[i++]);case\"%d\":return Number(s[i++]);case\"%j\":try{return JSON.stringify(s[i++])}catch(t){return\"[Circular]\"}default:return t}}),a=s[i];i<o;a=s[++i])_(a)||!S(a)?r+=\" \"+a:r+=\" \"+n(a);return r},e.deprecate=function(i,n){function o(){if(!r){if(s.throwDeprecation)throw new Error(n);s.traceDeprecation?console.trace(n):console.error(n),r=!0}return i.apply(this,arguments)}if(b(t.process))return function(){return e.deprecate(i,n).apply(this,arguments)};if(!0===s.noDeprecation)return i;var r=!1;return o};var E,F={};e.debuglog=function(t){if(b(E)&&(E=s.env.NODE_DEBUG||\"\"),t=t.toUpperCase(),!F[t])if(new RegExp(\"\\\\b\"+t+\"\\\\b\",\"i\").test(E)){var i=s.pid;F[t]=function(){var s=e.format.apply(e,arguments);console.error(\"%s %d: %s\",t,i,s)}}else F[t]=function(){};return F[t]},e.inspect=n,n.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},n.styles={special:\"cyan\",number:\"yellow\",boolean:\"yellow\",undefined:\"grey\",null:\"bold\",string:\"green\",date:\"magenta\",regexp:\"red\"},e.isArray=f,e.isBoolean=y,e.isNull=_,e.isNullOrUndefined=m,e.isNumber=v,e.isString=g,e.isSymbol=w,e.isUndefined=b,e.isRegExp=x,e.isObject=S,e.isDate=T,e.isError=k,e.isFunction=P,e.isPrimitive=O,e.isBuffer=i(53);var U=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"];e.log=function(){console.log(\"%s - %s\",I(),e.format.apply(e,arguments))},e.inherits=i(52),e._extend=function(t,e){if(!e||!S(e))return t;for(var i=Object.keys(e),s=i.length;s--;)t[i[s]]=e[i[s]];return t}}).call(e,i(55),i(51))},function(module,exports,__webpack_require__){var EventEmitter=__webpack_require__(6).EventEmitter,util=__webpack_require__(0),domUtils=__webpack_require__(7),drawingUtils=__webpack_require__(3),timingUtils=__webpack_require__(8),transmit=__webpack_require__(9),widget=module.exports=function(t){if(EventEmitter.apply(this),this.preClick=this.preClick.bind(this),this.preMove=this.preMove.bind(this),this.preRelease=this.preRelease.bind(this),this.preTouch=this.preTouch.bind(this),this.preTouchMove=this.preTouchMove.bind(this),this.preTouchRelease=this.preTouchRelease.bind(this),this.canvasID=t,this.oscPath=\"/\"+t,!document.getElementById(t)){var e=document.createElement(\"canvas\");e.id=t,document.body.appendChild(e)}if(this.type=void 0,this.canvas=document.getElementById(t),this.context=this.canvas.getContext(\"2d\"),this.checkPercentage(),this.canvas.className=this.canvas.className?this.canvas.className+=\" nx\":\"nx\",this.canvas.height=window.getComputedStyle(document.getElementById(t),null).getPropertyValue(\"height\").replace(\"px\",\"\"),this.canvas.width=window.getComputedStyle(document.getElementById(t),null).getPropertyValue(\"width\").replace(\"px\",\"\"),this.height=parseInt(window.getComputedStyle(document.getElementById(t),null).getPropertyValue(\"height\").replace(\"px\",\"\")),this.width=parseInt(window.getComputedStyle(document.getElementById(t),null).getPropertyValue(\"width\").replace(\"px\",\"\")),this.defaultSize||(this.defaultSize={width:100,height:100}),this.label=!1,this.labelSize=30,this.labelAlign=\"center\",this.labelFont=\"'Open Sans'\",null!=this.canvas.getAttribute(\"label\")&&(this.label=this.canvas.getAttribute(\"label\"),this.origDefaultHeight=this.defaultSize.height),this.label&&(this.defaultSize.height+=this.labelSize),300==this.width&&150==this.height)this.canvas.width=2*this.defaultSize.width,this.canvas.height=2*this.defaultSize.height,this.width=this.defaultSize.width,this.height=this.defaultSize.height;else{var i=this.width,s=this.height;this.canvas.width=2*i,this.canvas.height=2*s,this.width=i,this.height=s}this.canvas.style.width=this.canvas.width/2+\"px\",this.canvas.style.height=this.canvas.height/2+\"px\",this.context.scale(2,2),this.makeRoomForLabel(),this.offset=domUtils.findPosition(this.canvas),this.center={x:this.GUI.w/2,y:this.GUI.h/2},this.lineWidth=2,this.context.lineWidth=this.lineWidth,this.colors=new Object;for(var n in nx.colors)this.colors[n]=nx.colors[n];this.clickPos={x:0,y:0},this.clickPos.touches=new Array,this.clicked=!1,this.value=0,this.val=new Object,this.pval=new Object,this.nodePos=new Array,this.deltaMove=new Object,this.throttlePeriod=nx.throttlePeriod,this.throttle=timingUtils.throttle,this.hasMoved=!1,this.isRecording=!1,this.tapeNum=0,this.recorder=null,transmit&&(this.sendsTo=transmit.setWidgetTransmit,this.destination=\"js\"),this.events=new Object,nx.isTouchDevice?(this.canvas.ontouchstart=this.preTouch,this.canvas.ontouchmove=this.preTouchMove,this.canvas.ontouchend=this.preTouchRelease):this.canvas.addEventListener(\"mousedown\",this.preClick,!1),this.fontSize=nx.fontSize,this.fontWeight=nx.fontWeight,this.font=nx.font,this.clickCB=!1,this.releaseCB=!1,this.actuated=!0};util.inherits(widget,EventEmitter),widget.prototype.transmit=nx.transmit,widget.prototype.makeOSC=function(t,e){if(this.action=t,\"object\"==typeof e&&null!==e)for(var i in e)if(\"object\"==typeof e[i]&&null!==e[i])for(var s in e[i])this.action(i+\"/\"+s,e[i][s]);else this.action(i,e[i]);else\"number\"!=typeof e&&\"string\"!=typeof e||this.action(\"value\",e)},widget.prototype.getOffset=function(){this.offset=domUtils.findPosition(this.canvas)},widget.prototype.preClick=function(t){this.actuated=!0,this.offset=domUtils.findPosition(this.canvas),this.clickPos=domUtils.getCursorPosition(t,this.offset),document.addEventListener(\"mousemove\",this.preMove,!1),document.addEventListener(\"mouseup\",this.preRelease,!1),this.clicked=!0,this.deltaMove.x=0,this.deltaMove.y=0,this.hasMoved=!1,this.clickCB&&this.clickCB(),this.click(t),document.body.style.userSelect=\"none\",document.body.style.mozUserSelect=\"none\",document.body.style.webkitUserSelect=\"none\",document.body.style.cursor=\"pointer\"},widget.prototype.preMove=function(t){this.actuated=!0;var e=domUtils.getCursorPosition(t,this.offset);this.deltaMove.y=e.y-this.clickPos.y,this.deltaMove.x=e.x-this.clickPos.x,this.clickPos=e,this.hasMoved=!0,this.move(t)},widget.prototype.preRelease=function(t){this.actuated=!0,document.removeEventListener(\"mousemove\",this.preMove,!1),document.removeEventListener(\"mouseup\",this.preRelease,!1),this.clicked=!1,this.releaseCB&&this.releaseCB(),this.release(),document.body.style.userSelect=\"text\",document.body.style.mozUserSelect=\"text\",document.body.style.webkitUserSelect=\"text\",document.body.style.cursor=\"default\"},widget.prototype.preTouch=function(t){this.actuated=!0,this.clickPos=domUtils.getTouchPosition(t,this.offset),this.clicked=!0,this.deltaMove.x=0,this.deltaMove.y=0,this.hasMoved=!1,this.touch(t)},widget.prototype.preTouchMove=function(t){if(this.clicked){this.actuated=!0;var e=domUtils.getTouchPosition(t,this.offset);this.deltaMove.y=e.y-this.clickPos.y,this.deltaMove.x=e.x-this.clickPos.x,this.clickPos=e,this.hasMoved=!0,this.touchMove(t)}},widget.prototype.preTouchRelease=function(t){if(this.actuated=!0,t.targetTouches.length>=1){var e=domUtils.getTouchPosition(t,this.offset);this.clickPos=e}else this.clicked=!1;this.touchRelease()},widget.prototype.draw=function(){},widget.prototype.click=function(){},widget.prototype.move=function(){},widget.prototype.release=function(){},widget.prototype.touch=function(){this.click()},widget.prototype.touchMove=function(){this.move()},widget.prototype.touchRelease=function(){this.release()},widget.prototype.adjustSizeIfDefault=function(){300==this.width&&150==this.height&&(this.canvas.width=this.defaultSize.width,this.canvas.height=this.defaultSize.height,this.width=this.defaultSize.width,this.height=this.defaultSize.height)},widget.prototype.makeRoundedBG=function(){this.bgLeft=this.lineWidth,this.bgRight=this.width-this.lineWidth,this.bgTop=this.lineWidth,this.bgBottom=this.height-this.lineWidth,this.bgHeight=this.bgBottom-this.lineWidth,this.bgWidth=this.bgRight-this.lineWidth,drawingUtils.makeRoundRect(this.context,this.bgLeft,this.bgTop,this.bgWidth,this.bgHeight)},widget.prototype.erase=function(){this.context.clearRect(0,0,this.width,this.height)},widget.prototype.hideCursor=function(){this.canvas.style.cursor=\"none\"},widget.prototype.showCursor=function(){this.canvas.style.cursor=\"auto\"},widget.prototype.getName=function(){return\"deprecated -- use widget.type instead\"},widget.prototype.set=function(t,e){if(this.actuated=!1,\"object\"==typeof this.val&&\"null\"!==this.val){if(\"object\"==typeof t&&\"null\"!==t)for(var i in t)this.val[i]=t[i]}else\"string\"!=typeof this.val&&\"number\"!=typeof this.val||(\"object\"==typeof t&&\"null\"!==t?(this.val=t.value,this.draw()):\"string\"!=typeof t&&\"number\"!=typeof t||(this.val=t));this.draw(),e&&this.transmit(this.val,!0)},widget.prototype.destroy=function(){var t=nx.elemTypeArr.indexOf(this.getName());nx.elemTypeArr.splice(t,1),this.canvas.ontouchmove=null,this.canvas.ontouchend=null,this.canvas.onclick=null,this.canvas.onmousemove=null,this.canvas.onmouseoff=null,document.removeEventListener(\"mousemove\",this.preMove,!1),document.removeEventListener(\"mouseup\",this.preRelease,!1);var e=document.getElementById(this.canvasID);e&&e.parentNode.removeChild(e),this.customDestroy();var i=this.canvasID;delete nx.widgets[i],delete window[i]},widget.prototype.customDestroy=function(){},widget.prototype.wrapText=function(t,e,i,s,n){if(t){for(var o=t.split(\" \"),r=\"\",a=0;a<o.length;a++){var h=r+o[a]+\" \";this.context.measureText(h).width>s&&a>0?(this.context.fillText(r,e,i),r=o[a]+\" \",i+=n):r=h}this.context.fillText(r,e,i)}},widget.prototype.drawLabel=function(){if(this.label)with(this.context)fillStyle=this.colors.black,textAlign=\"center\",textBaseline=\"middle\",font=this.labelSize/2.8+\"px \"+this.labelFont+\" normal\",fillText(this.label,this.width/2,this.labelY)},widget.prototype.saveCanv=function(){var t=this.canvas.toDataURL(\"image/png\").replace(\"image/png\",\"image/octet-stream\");window.location.href=t},widget.prototype.setFont=function(){with(this.context)textAlign=\"center\",font=this.fontWeight+\" \"+this.fontSize+\"px \"+this.font,fillStyle=this.colors.black,globalAlpha=1},widget.prototype.checkPercentage=function(){var t=this.canvas.style.width,e=this.canvas.style.height;(t.indexOf(\"%\")>=0||e.indexOf(\"%\")>=0)&&(this.percent={w:t.indexOf(\"%\")>=0&&t.replace(\"%\",\"\"),h:e.indexOf(\"%\")>=0&&e.replace(\"%\",\"\")},this.stretch())},widget.prototype.stretch=function(){window.addEventListener(\"resize\",function(t){if(this.percent.w){var e=window.getComputedStyle(this.canvas.parentNode,null).getPropertyValue(\"width\").replace(\"px\",\"\");e*=this.percent.w/100}else var e=!1;if(this.percent.h){var i=window.getComputedStyle(this.canvas.parentNode,null).getPropertyValue(\"height\").replace(\"px\",\"\");i*=this.percent.h/100}else var i=!1;this.resize(e,i)}.bind(this))},widget.prototype.resize=function(t,e){this.canvas.width=t?2*t:this.canvas.width,this.canvas.height=e?2*e:this.canvas.height,this.width=t||this.width,this.height=e||this.height,this.canvas.style.width=this.width+\"px\",this.canvas.style.height=this.height+\"px\",this.context.scale(2,2),this.center={x:this.GUI.w/2,y:this.GUI.h/2},this.makeRoomForLabel(),this.init(),this.draw()},widget.prototype.normalize=function(t){return nx.scale(t,this.min,this.max,0,1)},widget.prototype.rangify=function(t){return nx.scale(t,0,1,this.min,this.max)},widget.prototype.makeRoomForLabel=function(){this.GUI={w:this.width,h:this.label?this.height-this.labelSize:this.height},this.labelY=this.height-this.labelSize/2}},function(t,e){e.toPolar=function(t,e){var i=Math.sqrt(t*t+e*e),s=Math.atan2(e,t);return s<0&&(s+=2*Math.PI),{radius:i,angle:s}},e.toCartesian=function(t,e){return{x:t*Math.cos(e),y:t*Math.sin(e)*-1}},e.clip=function(t,e,i){return Math.min(i,Math.max(e,t))},e.prune=function(t,e){if(\"number\"==typeof t)t=parseFloat(t.toFixed(e));else if(t instanceof Array)for(var i=0;i<t.length;i++)\"number\"==typeof t[i]&&(t[i]=parseFloat(t[i].toFixed(e)));return t},e.scale=function(t,e,i,s,n){return(t-e)*(n-s)/(i-e)+s},e.invert=function(t){return e.scale(t,1,0,0,1)},e.bounce=function(t,e,i,s){return t>e&&t<i?s:t<=e?Math.abs(s):t>=i?-1*Math.abs(s):void 0},e.mtof=function(t){return 440*Math.pow(2,(t-69)/12)},e.random=function(t){return Math.floor(Math.random()*t)},e.interp=function(t,e,i){return t*(i-e)+e},e.lphistory={},e.lp=function(t,e,i){this.lphistory[t]||(this.lphistory[t]=[]);var s=0;this.lphistory[t].push(e),this.lphistory[t].length>i&&this.lphistory[t].splice(0,1);for(var n=0;n<this.lphistory[t].length;n++)s+=this.lphistory[t][n];return s/this.lphistory[t].length},e.lp2=function(t,e){for(var i=0,s=0;s<this.lphistory.length;s++)i+=this.lphistory[s];i+=t;var n=i/(this.lphistory.length+1);return this.lphistory.push(n),this.lphistory.length>e&&this.lphistory.splice(0,1),n},e.lp3=function(t,e,i){var s=t+e*i;return newvalue=s/(i+1),newvalue}},function(module,exports,__webpack_require__){var math=__webpack_require__(2);exports.randomColor=function(){return\"rgb(\"+math.random(250)+\",\"+math.random(250)+\",\"+math.random(250)+\")\"},exports.hexToRgb=function(t,e){t=t.replace(/^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i,function(t,e,i,s){return e+e+i+i+s+s});var i=/^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(t);return e||(e=.5),\"rgba(\"+parseInt(i[1],16)+\",\"+parseInt(i[2],16)+\",\"+parseInt(i[3],16)+\",\"+e+\")\"},exports.isInside=function(t,e){return t.x>e.x&&t.x<e.x+e.w&&t.y>e.y&&t.y<e.y+e.h},exports.makeRoundRect=function(t,e,i,s,n,o){var r=e,a=i,h=s+r,l=n+a;o||(o=2),t.beginPath(),t.moveTo(r+o,a),t.lineTo(h-o,a),t.quadraticCurveTo(h,a,h,a+o),t.lineTo(h,l-o),t.quadraticCurveTo(h,l,h-o,l),t.lineTo(r+o,l),t.quadraticCurveTo(r,l,r,l-o),t.lineTo(r,a+o),t.quadraticCurveTo(r,a,r+o,a),t.closePath()},exports.text=function(context,text,position){with(position||(position=[10,10]),context)beginPath(),font=\"bold 12px sans-serif\",fillText(text,position[0],position[1]),closePath()},exports.shadeBlendConvert=function(t,e,i){if(\"number\"!=typeof t||t<-1||t>1||\"string\"!=typeof e||\"r\"!=e[0]&&\"#\"!=e[0]||\"string\"!=typeof i&&void 0!==i)return null;this.sbcRip=function(t){var e=t.length,i=new Object;if(e>9){if(t=t.split(\",\"),t.length<3||t.length>4)return null;i[0]=s(t[0].slice(4)),i[1]=s(t[1]),i[2]=s(t[2]),i[3]=t[3]?parseFloat(t[3]):-1}else{switch(e){case 8:case 6:case 3:case 2:case 1:return null}e<6&&(t=\"#\"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(e>4?t[4]+\"\"+t[4]:\"\")),t=s(t.slice(1),16),i[0]=t>>16&255,i[1]=t>>8&255,i[2]=255&t,i[3]=9==e||5==e?n((t>>24&255)/255*1e4)/1e4:-1}return i};var s=parseInt,n=Math.round,o=e.length>9,o=\"string\"==typeof i?i.length>9||\"c\"==i&&!o:o,r=t<0,t=r?-1*t:t,i=i&&\"c\"!=i?i:r?\"#000000\":\"#FFFFFF\",a=this.sbcRip(e),h=this.sbcRip(i);return a&&h?o?\"rgb(\"+n((h[0]-a[0])*t+a[0])+\",\"+n((h[1]-a[1])*t+a[1])+\",\"+n((h[2]-a[2])*t+a[2])+(a[3]<0&&h[3]<0?\")\":\",\"+(a[3]>-1&&h[3]>-1?n(1e4*((h[3]-a[3])*t+a[3]))/1e4:h[3]<0?a[3]:h[3])+\")\"):\"#\"+(4294967296+16777216*(a[3]>-1&&h[3]>-1?n(255*((h[3]-a[3])*t+a[3])):h[3]>-1?n(255*h[3]):a[3]>-1?n(255*a[3]):255)+65536*n((h[0]-a[0])*t+a[0])+256*n((h[1]-a[1])*t+a[1])+n((h[2]-a[2])*t+a[2])).toString(16).slice(a[3]>-1||h[3]>-1?1:3):null}},function(t,e,i){var s;!function(n,o){void 0!==(s=function(){return o()}.call(e,i,e,t))&&(t.exports=s)}(0,function(){\"use strict\";function t(t){t(e)}var e;/**\n\t * Tone.js\n\t * @author Yotam Mann\n\t * @license http://opensource.org/licenses/MIT MIT License\n\t * @copyright 2014-2017 Yotam Mann\n\t */\nreturn function(t){e=t()}(function(){var t=function(t,e){this.isUndef(t)||1===t?this.input=this.context.createGain():t>1&&(this.input=new Array(t)),this.isUndef(e)||1===e?this.output=this.context.createGain():e>1&&(this.output=new Array(t))};t.prototype.set=function(e,i,s){if(this.isObject(e))s=i;else if(this.isString(e)){var n={};n[e]=i,e=n}t:for(var o in e){i=e[o];var r=this;if(-1!==o.indexOf(\".\")){for(var a=o.split(\".\"),h=0;h<a.length-1;h++)if((r=r[a[h]])instanceof t){a.splice(0,h+1);var l=a.join(\".\");r.set(l,i);continue t}o=a[a.length-1]}var c=r[o];this.isUndef(c)||(t.Signal&&c instanceof t.Signal||t.Param&&c instanceof t.Param?c.value!==i&&(this.isUndef(s)?c.value=i:c.rampTo(i,s)):c instanceof AudioParam?c.value!==i&&(c.value=i):c instanceof t?c.set(i):c!==i&&(r[o]=i))}return this},t.prototype.get=function(e){this.isUndef(e)?e=this._collectDefaults(this.constructor):this.isString(e)&&(e=[e]);for(var i={},s=0;s<e.length;s++){var n=e[s],o=this,r=i;if(-1!==n.indexOf(\".\")){for(var a=n.split(\".\"),h=0;h<a.length-1;h++){var l=a[h];r[l]=r[l]||{},r=r[l],o=o[l]}n=a[a.length-1]}var c=o[n];this.isObject(e[n])?r[n]=c.get():t.Signal&&c instanceof t.Signal?r[n]=c.value:t.Param&&c instanceof t.Param?r[n]=c.value:c instanceof AudioParam?r[n]=c.value:c instanceof t?r[n]=c.get():this.isFunction(c)||this.isUndef(c)||(r[n]=c)}return i},t.prototype._collectDefaults=function(t){var e=[];if(this.isUndef(t.defaults)||(e=Object.keys(t.defaults)),!this.isUndef(t._super))for(var i=this._collectDefaults(t._super),s=0;s<i.length;s++)-1===e.indexOf(i[s])&&e.push(i[s]);return e},t.prototype.toString=function(){for(var e in t){var i=e[0].match(/^[A-Z]$/),s=t[e]===this.constructor;if(this.isFunction(t[e])&&i&&s)return e}return\"Tone\"},Object.defineProperty(t.prototype,\"numberOfInputs\",{get:function(){return this.input?this.isArray(this.input)?this.input.length:1:0}}),Object.defineProperty(t.prototype,\"numberOfOutputs\",{get:function(){return this.output?this.isArray(this.output)?this.output.length:1:0}}),t.prototype.dispose=function(){return this.isUndef(this.input)||(this.input instanceof AudioNode&&this.input.disconnect(),this.input=null),this.isUndef(this.output)||(this.output instanceof AudioNode&&this.output.disconnect(),this.output=null),this},t.prototype.connect=function(t,e,i){return Array.isArray(this.output)?(e=this.defaultArg(e,0),this.output[e].connect(t,0,i)):this.output.connect(t,e,i),this},t.prototype.disconnect=function(t,e,i){this.isArray(this.output)?this.isNumber(t)?this.output[t].disconnect():(e=this.defaultArg(e,0),this.output[e].disconnect(t,0,i)):this.output.disconnect.apply(this.output,arguments)},t.prototype.connectSeries=function(){if(arguments.length>1)for(var t=arguments[0],e=1;e<arguments.length;e++){var i=arguments[e];t.connect(i),t=i}return this},t.prototype.chain=function(){if(arguments.length>0)for(var t=this,e=0;e<arguments.length;e++){var i=arguments[e];t.connect(i),t=i}return this},t.prototype.fan=function(){if(arguments.length>0)for(var t=0;t<arguments.length;t++)this.connect(arguments[t]);return this},AudioNode.prototype.chain=t.prototype.chain,AudioNode.prototype.fan=t.prototype.fan,t.prototype.defaultArg=function(t,e){if(this.isObject(t)&&this.isObject(e)){var i={};for(var s in t)i[s]=this.defaultArg(e[s],t[s]);for(var n in e)i[n]=this.defaultArg(t[n],e[n]);return i}return this.isUndef(t)?e:t},t.prototype.optionsObject=function(t,e,i){var s={};if(1===t.length&&this.isObject(t[0]))s=t[0];else for(var n=0;n<e.length;n++)s[e[n]]=t[n];return this.isUndef(i)?s:this.defaultArg(s,i)},t.prototype.isUndef=function(t){return void 0===t},t.prototype.isFunction=function(t){return\"function\"==typeof t},t.prototype.isNumber=function(t){return\"number\"==typeof t},t.prototype.isObject=function(t){return\"[object Object]\"===Object.prototype.toString.call(t)&&t.constructor===Object},t.prototype.isBoolean=function(t){return\"boolean\"==typeof t},t.prototype.isArray=function(t){return Array.isArray(t)},t.prototype.isString=function(t){return\"string\"==typeof t},t.noOp=function(){},t.prototype._readOnly=function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)this._readOnly(t[e]);else Object.defineProperty(this,t,{writable:!1,enumerable:!0})},t.prototype._writable=function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)this._writable(t[e]);else Object.defineProperty(this,t,{writable:!0})},t.State={Started:\"started\",Stopped:\"stopped\",Paused:\"paused\"},t.prototype.equalPowerScale=function(t){var e=.5*Math.PI;return Math.sin(t*e)},t.prototype.dbToGain=function(t){return Math.pow(2,t/6)},t.prototype.gainToDb=function(t){return Math.log(t)/Math.LN10*20},t.prototype.intervalToFrequencyRatio=function(t){return Math.pow(2,t/12)},t.prototype.now=function(){return t.context.now()},t.now=function(){return t.context.now()},t.extend=function(e,i){function s(){}t.prototype.isUndef(i)&&(i=t),s.prototype=i.prototype,e.prototype=new s,e.prototype.constructor=e,e._super=i};var e;return Object.defineProperty(t,\"context\",{get:function(){return e},set:function(i){e=t.Context&&i instanceof t.Context?i:new t.Context(i),t.Context&&t.Context.emit(\"init\",e)}}),Object.defineProperty(t.prototype,\"context\",{get:function(){return t.context}}),t.setContext=function(e){t.context=e},Object.defineProperty(t.prototype,\"blockTime\",{get:function(){return 128/this.context.sampleRate}}),Object.defineProperty(t.prototype,\"sampleTime\",{get:function(){return 1/this.context.sampleRate}}),Object.defineProperty(t,\"supported\",{get:function(){var t=window.hasOwnProperty(\"AudioContext\")||window.hasOwnProperty(\"webkitAudioContext\"),e=window.hasOwnProperty(\"Promise\"),i=window.hasOwnProperty(\"Worker\");return t&&e&&i}}),t.version=\"r10\",window.TONE_SILENCE_VERSION_LOGGING||console.log(\"%c * Tone.js \"+t.version+\" * \",\"background: #000; color: #fff\"),t}),t(function(t){return t.SignalBase=function(){},t.extend(t.SignalBase),t.SignalBase.prototype.connect=function(e,i,s){return t.Signal&&t.Signal===e.constructor||t.Param&&t.Param===e.constructor||t.TimelineSignal&&t.TimelineSignal===e.constructor?(e._param.cancelScheduledValues(0),e._param.value=0,e.overridden=!0):e instanceof AudioParam&&(e.cancelScheduledValues(0),e.value=0),t.prototype.connect.call(this,e,i,s),this},t.SignalBase}),t(function(t){return t.WaveShaper=function(t,e){this._shaper=this.input=this.output=this.context.createWaveShaper(),this._curve=null,Array.isArray(t)?this.curve=t:isFinite(t)||this.isUndef(t)?this._curve=new Float32Array(this.defaultArg(t,1024)):this.isFunction(t)&&(this._curve=new Float32Array(this.defaultArg(e,1024)),this.setMap(t))},t.extend(t.WaveShaper,t.SignalBase),t.WaveShaper.prototype.setMap=function(t){for(var e=0,i=this._curve.length;e<i;e++){var s=e/(i-1)*2-1;this._curve[e]=t(s,e)}return this._shaper.curve=this._curve,this},Object.defineProperty(t.WaveShaper.prototype,\"curve\",{get:function(){return this._shaper.curve},set:function(t){this._curve=new Float32Array(t),this._shaper.curve=this._curve}}),Object.defineProperty(t.WaveShaper.prototype,\"oversample\",{get:function(){return this._shaper.oversample},set:function(t){if(-1===[\"none\",\"2x\",\"4x\"].indexOf(t))throw new RangeError(\"Tone.WaveShaper: oversampling must be either 'none', '2x', or '4x'\");this._shaper.oversample=t}}),t.WaveShaper.prototype.dispose=function(){return t.prototype.dispose.call(this),this._shaper.disconnect(),this._shaper=null,this._curve=null,this},t.WaveShaper}),t(function(t){return t.TimeBase=function(e,i){if(!(this instanceof t.TimeBase))return new t.TimeBase(e,i);if(this._expr=this._noOp,e instanceof t.TimeBase)this.copy(e);else if(!this.isUndef(i)||this.isNumber(e)){i=this.defaultArg(i,this._defaultUnits);var s=this._primaryExpressions[i].method;this._expr=s.bind(this,e)}else this.isString(e)?this.set(e):this.isUndef(e)&&(this._expr=this._defaultExpr())},t.extend(t.TimeBase),t.TimeBase.prototype.set=function(t){return this._expr=this._parseExprString(t),this},t.TimeBase.prototype.clone=function(){var t=new this.constructor;return t.copy(this),t},t.TimeBase.prototype.copy=function(t){var e=t._expr();return this.set(e)},t.TimeBase.prototype._primaryExpressions={n:{regexp:/^(\\d+)n/i,method:function(t){return t=parseInt(t),1===t?this._beatsToUnits(this._timeSignature()):this._beatsToUnits(4/t)}},t:{regexp:/^(\\d+)t/i,method:function(t){return t=parseInt(t),this._beatsToUnits(8/(3*parseInt(t)))}},m:{regexp:/^(\\d+)m/i,method:function(t){return this._beatsToUnits(parseInt(t)*this._timeSignature())}},i:{regexp:/^(\\d+)i/i,method:function(t){return this._ticksToUnits(parseInt(t))}},hz:{regexp:/^(\\d+(?:\\.\\d+)?)hz/i,method:function(t){return this._frequencyToUnits(parseFloat(t))}},tr:{regexp:/^(\\d+(?:\\.\\d+)?):(\\d+(?:\\.\\d+)?):?(\\d+(?:\\.\\d+)?)?/,method:function(t,e,i){var s=0;return t&&\"0\"!==t&&(s+=this._beatsToUnits(this._timeSignature()*parseFloat(t))),e&&\"0\"!==e&&(s+=this._beatsToUnits(parseFloat(e))),i&&\"0\"!==i&&(s+=this._beatsToUnits(parseFloat(i)/4)),s}},s:{regexp:/^(\\d+(?:\\.\\d+)?s)/,method:function(t){return this._secondsToUnits(parseFloat(t))}},samples:{regexp:/^(\\d+)samples/,method:function(t){return parseInt(t)/this.context.sampleRate}},default:{regexp:/^(\\d+(?:\\.\\d+)?)/,method:function(t){return this._primaryExpressions[this._defaultUnits].method.call(this,t)}}},t.TimeBase.prototype._binaryExpressions={\"+\":{regexp:/^\\+/,precedence:2,method:function(t,e){return t()+e()}},\"-\":{regexp:/^\\-/,precedence:2,method:function(t,e){return t()-e()}},\"*\":{regexp:/^\\*/,precedence:1,method:function(t,e){return t()*e()}},\"/\":{regexp:/^\\//,precedence:1,method:function(t,e){return t()/e()}}},t.TimeBase.prototype._unaryExpressions={neg:{regexp:/^\\-/,method:function(t){return-t()}}},t.TimeBase.prototype._syntaxGlue={\"(\":{regexp:/^\\(/},\")\":{regexp:/^\\)/}},t.TimeBase.prototype._tokenize=function(t){for(var e=-1,i=[];t.length>0;){t=t.trim();var s=function(t,e){for(var i=[\"_binaryExpressions\",\"_unaryExpressions\",\"_primaryExpressions\",\"_syntaxGlue\"],s=0;s<i.length;s++){var n=e[i[s]];for(var o in n){var r=n[o],a=r.regexp,h=t.match(a);if(null!==h)return{method:r.method,precedence:r.precedence,regexp:r.regexp,value:h[0]}}}throw new SyntaxError(\"Tone.TimeBase: Unexpected token \"+t)}(t,this);i.push(s),t=t.substr(s.value.length)}return{next:function(){return i[++e]},peek:function(){return i[e+1]}}},t.TimeBase.prototype._matchGroup=function(t,e,i){if(!this.isUndef(t))for(var s in e){var n=e[s];if(n.regexp.test(t.value)){if(this.isUndef(i))return n;if(n.precedence===i)return n}}return!1},t.TimeBase.prototype._parseBinary=function(t,e){this.isUndef(e)&&(e=2);var i;i=e<0?this._parseUnary(t):this._parseBinary(t,e-1);for(var s=t.peek();s&&this._matchGroup(s,this._binaryExpressions,e);)s=t.next(),i=s.method.bind(this,i,this._parseBinary(t,e-1)),s=t.peek();return i},t.TimeBase.prototype._parseUnary=function(t){var e,i;e=t.peek();var s=this._matchGroup(e,this._unaryExpressions);return s?(e=t.next(),i=this._parseUnary(t),s.method.bind(this,i)):this._parsePrimary(t)},t.TimeBase.prototype._parsePrimary=function(t){var e,i;if(e=t.peek(),this.isUndef(e))throw new SyntaxError(\"Tone.TimeBase: Unexpected end of expression\");if(this._matchGroup(e,this._primaryExpressions)){e=t.next();var s=e.value.match(e.regexp);return e.method.bind(this,s[1],s[2],s[3])}if(e&&\"(\"===e.value){if(t.next(),i=this._parseBinary(t),!(e=t.next())||\")\"!==e.value)throw new SyntaxError(\"Expected )\");return i}throw new SyntaxError(\"Tone.TimeBase: Cannot process token \"+e.value)},t.TimeBase.prototype._parseExprString=function(t){this.isString(t)||(t=t.toString());var e=this._tokenize(t);return this._parseBinary(e)},t.TimeBase.prototype._noOp=function(){return 0},t.TimeBase.prototype._defaultExpr=function(){return this._noOp},t.TimeBase.prototype._defaultUnits=\"s\",t.TimeBase.prototype._frequencyToUnits=function(t){return 1/t},t.TimeBase.prototype._beatsToUnits=function(e){return 60/t.Transport.bpm.value*e},t.TimeBase.prototype._secondsToUnits=function(t){return t},t.TimeBase.prototype._ticksToUnits=function(e){return e*(this._beatsToUnits(1)/t.Transport.PPQ)},t.TimeBase.prototype._timeSignature=function(){return t.Transport.timeSignature},t.TimeBase.prototype._pushExpr=function(e,i,s){return e instanceof t.TimeBase||(e=new this.constructor(e,s)),this._expr=this._binaryExpressions[i].method.bind(this,this._expr,e._expr),this},t.TimeBase.prototype.add=function(t,e){return this._pushExpr(t,\"+\",e)},t.TimeBase.prototype.sub=function(t,e){return this._pushExpr(t,\"-\",e)},t.TimeBase.prototype.mult=function(t,e){return this._pushExpr(t,\"*\",e)},t.TimeBase.prototype.div=function(t,e){return this._pushExpr(t,\"/\",e)},t.TimeBase.prototype.valueOf=function(){return this._expr()},t.TimeBase.prototype.dispose=function(){this._expr=null},t.TimeBase}),t(function(t){return t.Time=function(e,i){if(!(this instanceof t.Time))return new t.Time(e,i);this._plusNow=!1,t.TimeBase.call(this,e,i)},t.extend(t.Time,t.TimeBase),t.Time.prototype._unaryExpressions=Object.create(t.TimeBase.prototype._unaryExpressions),t.Time.prototype._unaryExpressions.quantize={regexp:/^@/,method:function(e){return t.Transport.nextSubdivision(e())}},t.Time.prototype._unaryExpressions.now={regexp:/^\\+/,method:function(t){return this._plusNow=!0,t()}},t.Time.prototype.quantize=function(t,e){return e=this.defaultArg(e,1),this._expr=function(t,e,i){return t=t(),e=e.toSeconds(),t+(Math.round(t/e)*e-t)*i}.bind(this,this._expr,new this.constructor(t),e),this},t.Time.prototype.addNow=function(){return this._plusNow=!0,this},t.Time.prototype._defaultExpr=function(){return this._plusNow=!0,this._noOp},t.Time.prototype.copy=function(e){return t.TimeBase.prototype.copy.call(this,e),this._plusNow=e._plusNow,this},t.Time.prototype.toNotation=function(){var t=this.toSeconds(),e=[\"1m\",\"2n\",\"4n\",\"8n\",\"16n\",\"32n\",\"64n\",\"128n\"],i=this._toNotationHelper(t,e),s=[\"1m\",\"2n\",\"2t\",\"4n\",\"4t\",\"8n\",\"8t\",\"16n\",\"16t\",\"32n\",\"32t\",\"64n\",\"64t\",\"128n\"],n=this._toNotationHelper(t,s);return n.split(\"+\").length<i.split(\"+\").length?n:i},t.Time.prototype._toNotationHelper=function(t,e){for(var i=this._notationToUnits(e[e.length-1]),s=\"\",n=0;n<e.length;n++){var o=this._notationToUnits(e[n]),r=t/o;if(1-r%1<1e-6&&(r+=1e-6),(r=Math.floor(r))>0){if(s+=1===r?e[n]:r.toString()+\"*\"+e[n],(t-=r*o)<i)break;s+=\" + \"}}return\"\"===s&&(s=\"0\"),s},t.Time.prototype._notationToUnits=function(t){for(var e=this._primaryExpressions,i=[e.n,e.t,e.m],s=0;s<i.length;s++){var n=i[s],o=t.match(n.regexp);if(o)return n.method.call(this,o[1])}},t.Time.prototype.toBarsBeatsSixteenths=function(){var t=this._beatsToUnits(1),e=this.toSeconds()/t,i=Math.floor(e/this._timeSignature()),s=e%1*4;return e=Math.floor(e)%this._timeSignature(),s=s.toString(),s.length>3&&(s=parseFloat(s).toFixed(3)),[i,e,s].join(\":\")},t.Time.prototype.toTicks=function(){var e=this._beatsToUnits(1),i=this.valueOf()/e;return Math.floor(i*t.Transport.PPQ)},t.Time.prototype.toSamples=function(){return this.toSeconds()*this.context.sampleRate},t.Time.prototype.toFrequency=function(){return 1/this.toSeconds()},t.Time.prototype.toSeconds=function(){return this.valueOf()},t.Time.prototype.toMilliseconds=function(){return 1e3*this.toSeconds()},t.Time.prototype.valueOf=function(){return this._expr()+(this._plusNow?this.now():0)},t.Time}),t(function(t){t.Frequency=function(e,i){if(!(this instanceof t.Frequency))return new t.Frequency(e,i);t.TimeBase.call(this,e,i)},t.extend(t.Frequency,t.TimeBase),t.Frequency.prototype._primaryExpressions=Object.create(t.TimeBase.prototype._primaryExpressions),t.Frequency.prototype._primaryExpressions.midi={regexp:/^(\\d+(?:\\.\\d+)?midi)/,method:function(t){return this.midiToFrequency(t)}},t.Frequency.prototype._primaryExpressions.note={regexp:/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,method:function(t,i){var s=e[t.toLowerCase()],n=s+12*(parseInt(i)+1);return this.midiToFrequency(n)}},t.Frequency.prototype._primaryExpressions.tr={regexp:/^(\\d+(?:\\.\\d+)?):(\\d+(?:\\.\\d+)?):?(\\d+(?:\\.\\d+)?)?/,method:function(t,e,i){var s=1;return t&&\"0\"!==t&&(s*=this._beatsToUnits(this._timeSignature()*parseFloat(t))),e&&\"0\"!==e&&(s*=this._beatsToUnits(parseFloat(e))),i&&\"0\"!==i&&(s*=this._beatsToUnits(parseFloat(i)/4)),s}},t.Frequency.prototype.transpose=function(t){return this._expr=function(t,e){return t()*this.intervalToFrequencyRatio(e)}.bind(this,this._expr,t),this},t.Frequency.prototype.harmonize=function(t){return this._expr=function(t,e){for(var i=t(),s=[],n=0;n<e.length;n++)s[n]=i*this.intervalToFrequencyRatio(e[n]);return s}.bind(this,this._expr,t),this},t.Frequency.prototype.toMidi=function(){return this.frequencyToMidi(this.valueOf())},t.Frequency.prototype.toNote=function(){var e=this.valueOf(),s=Math.log(e/t.Frequency.A4)/Math.LN2,n=Math.round(12*s)+57,o=Math.floor(n/12);return o<0&&(n+=-12*o),i[n%12]+o.toString()},t.Frequency.prototype.toSeconds=function(){return 1/this.valueOf()},t.Frequency.prototype.toFrequency=function(){return this.valueOf()},t.Frequency.prototype.toTicks=function(){var e=this._beatsToUnits(1),i=this.valueOf()/e;return Math.floor(i*t.Transport.PPQ)},t.Frequency.prototype._frequencyToUnits=function(t){return t},t.Frequency.prototype._ticksToUnits=function(e){return 1/(60*e/(t.Transport.bpm.value*t.Transport.PPQ))},t.Frequency.prototype._beatsToUnits=function(e){return 1/t.TimeBase.prototype._beatsToUnits.call(this,e)},t.Frequency.prototype._secondsToUnits=function(t){return 1/t},t.Frequency.prototype._defaultUnits=\"hz\";var e={cbb:-2,cb:-1,c:0,\"c#\":1,cx:2,dbb:0,db:1,d:2,\"d#\":3,dx:4,ebb:2,eb:3,e:4,\"e#\":5,ex:6,fbb:3,fb:4,f:5,\"f#\":6,fx:7,gbb:5,gb:6,g:7,\"g#\":8,gx:9,abb:7,ab:8,a:9,\"a#\":10,ax:11,bbb:9,bb:10,b:11,\"b#\":12,bx:13},i=[\"C\",\"C#\",\"D\",\"D#\",\"E\",\"F\",\"F#\",\"G\",\"G#\",\"A\",\"A#\",\"B\"];return t.Frequency.A4=440,t.Frequency.prototype.midiToFrequency=function(e){return t.Frequency.A4*Math.pow(2,(e-69)/12)},t.Frequency.prototype.frequencyToMidi=function(e){return 69+12*Math.log(e/t.Frequency.A4)/Math.LN2},t.Frequency}),t(function(t){return t.TransportTime=function(e,i){if(!(this instanceof t.TransportTime))return new t.TransportTime(e,i);t.Time.call(this,e,i)},t.extend(t.TransportTime,t.Time),t.TransportTime.prototype._unaryExpressions=Object.create(t.Time.prototype._unaryExpressions),t.TransportTime.prototype._unaryExpressions.quantize={regexp:/^@/,method:function(e){var i=this._secondsToTicks(e()),s=Math.ceil(t.Transport.ticks/i);return this._ticksToUnits(s*i)}},t.TransportTime.prototype._secondsToTicks=function(e){var i=this._beatsToUnits(1),s=e/i;return Math.round(s*t.Transport.PPQ)},t.TransportTime.prototype.valueOf=function(){return this._secondsToTicks(this._expr())+(this._plusNow?t.Transport.ticks:0)},t.TransportTime.prototype.toTicks=function(){return this.valueOf()},t.TransportTime.prototype.toSeconds=function(){return this._expr()+(this._plusNow?t.Transport.seconds:0)},t.TransportTime.prototype.toFrequency=function(){return 1/this.toSeconds()},t.TransportTime}),t(function(t){return t.Emitter=function(){this._events={}},t.extend(t.Emitter),t.Emitter.prototype.on=function(t,e){for(var i=t.split(/\\W+/),s=0;s<i.length;s++){var n=i[s];this._events.hasOwnProperty(n)||(this._events[n]=[]),this._events[n].push(e)}return this},t.Emitter.prototype.off=function(e,i){for(var s=e.split(/\\W+/),n=0;n<s.length;n++)if(e=s[n],this._events.hasOwnProperty(e))if(t.prototype.isUndef(i))this._events[e]=[];else for(var o=this._events[e],r=0;r<o.length;r++)o[r]===i&&o.splice(r,1);return this},t.Emitter.prototype.emit=function(t){if(this._events){var e=Array.apply(null,arguments).slice(1);if(this._events.hasOwnProperty(t))for(var i=this._events[t],s=0,n=i.length;s<n;s++)i[s].apply(this,e)}return this},t.Emitter.mixin=function(e){var i=[\"on\",\"off\",\"emit\"];e._events={};for(var s=0;s<i.length;s++){var n=i[s],o=t.Emitter.prototype[n];e[n]=o}},t.Emitter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._events=null,this},t.Emitter}),t(function(t){return!window.hasOwnProperty(\"AudioContext\")&&window.hasOwnProperty(\"webkitAudioContext\")&&(window.AudioContext=window.webkitAudioContext),t.Context=function(e){t.Emitter.call(this),e||(e=new window.AudioContext),this._context=e;for(var i in this._context)this._defineProperty(this._context,i);this._latencyHint=\"interactive\",this._lookAhead=.1,this._updateInterval=this._lookAhead/3,this._computedUpdateInterval=0,this._worker=this._createWorker(),this._constants={}},t.extend(t.Context,t.Emitter),t.Emitter.mixin(t.Context),t.Context.prototype._defineProperty=function(t,e){this.isUndef(this[e])&&Object.defineProperty(this,e,{get:function(){return\"function\"==typeof t[e]?t[e].bind(t):t[e]},set:function(i){t[e]=i}})},t.Context.prototype.now=function(){return this._context.currentTime},t.Context.prototype._createWorker=function(){window.URL=window.URL||window.webkitURL;var t=new Blob([\"var timeoutTime = \"+(1e3*this._updateInterval).toFixed(1)+\";self.onmessage = function(msg){\\ttimeoutTime = parseInt(msg.data);};function tick(){\\tsetTimeout(tick, timeoutTime);\\tself.postMessage('tick');}tick();\"]),e=URL.createObjectURL(t),i=new Worker(e);return i.addEventListener(\"message\",function(){this.emit(\"tick\")}.bind(this)),i.addEventListener(\"message\",function(){var t=this.now();if(this.isNumber(this._lastUpdate)){var e=t-this._lastUpdate;this._computedUpdateInterval=Math.max(e,.97*this._computedUpdateInterval)}this._lastUpdate=t}.bind(this)),i},t.Context.prototype.getConstant=function(t){if(this._constants[t])return this._constants[t];for(var e=this._context.createBuffer(1,128,this._context.sampleRate),i=e.getChannelData(0),s=0;s<i.length;s++)i[s]=t;var n=this._context.createBufferSource();return n.channelCount=1,n.channelCountMode=\"explicit\",n.buffer=e,n.loop=!0,n.start(0),this._constants[t]=n,n},Object.defineProperty(t.Context.prototype,\"lag\",{get:function(){var t=this._computedUpdateInterval-this._updateInterval;return t=Math.max(t,0)}}),Object.defineProperty(t.Context.prototype,\"lookAhead\",{get:function(){return this._lookAhead},set:function(t){this._lookAhead=t}}),Object.defineProperty(t.Context.prototype,\"updateInterval\",{get:function(){return this._updateInterval},set:function(e){this._updateInterval=Math.max(e,t.prototype.blockTime),this._worker.postMessage(Math.max(1e3*e,1))}}),Object.defineProperty(t.Context.prototype,\"latencyHint\",{get:function(){return this._latencyHint},set:function(t){var e=t;if(this._latencyHint=t,this.isString(t))switch(t){case\"interactive\":e=.1,this._context.latencyHint=t;break;case\"playback\":e=.8,this._context.latencyHint=t;break;case\"balanced\":e=.25,this._context.latencyHint=t;break;case\"fastest\":e=.01}this.lookAhead=e,this.updateInterval=e/3}}),t.supported?(!function(){function e(e,i,n){if(e.input)Array.isArray(e.input)?(t.prototype.isUndef(n)&&(n=0),this.connect(e.input[n])):this.connect(e.input,i,n);else try{e instanceof AudioNode?s.call(this,e,i,n):s.call(this,e,i)}catch(t){throw new Error(\"error connecting to node: \"+e+\"\\n\"+t)}}function i(e,i,s){if(e&&e.input&&Array.isArray(e.input))t.prototype.isUndef(s)&&(s=0),this.disconnect(e.input[s],i,s);else if(e&&e.input)this.disconnect(e.input,i,s);else try{n.apply(this,arguments)}catch(t){throw new Error(\"error disconnecting node: \"+e+\"\\n\"+t)}}var s=AudioNode.prototype.connect,n=AudioNode.prototype.disconnect;AudioNode.prototype.connect!==e&&(AudioNode.prototype.connect=e,AudioNode.prototype.disconnect=i)}(),t.context=new t.Context):console.warn(\"This browser does not support Tone.js\"),t.Context}),t(function(t){return t.Type={Default:\"number\",Time:\"time\",Frequency:\"frequency\",TransportTime:\"transportTime\",Ticks:\"ticks\",NormalRange:\"normalRange\",AudioRange:\"audioRange\",Decibels:\"db\",Interval:\"interval\",BPM:\"bpm\",Positive:\"positive\",Cents:\"cents\",Degrees:\"degrees\",MIDI:\"midi\",BarsBeatsSixteenths:\"barsBeatsSixteenths\",Samples:\"samples\",Hertz:\"hertz\",Note:\"note\",Milliseconds:\"milliseconds\",Seconds:\"seconds\",Notation:\"notation\"},t.prototype.toSeconds=function(e){return this.isNumber(e)?e:this.isUndef(e)?this.now():this.isString(e)?new t.Time(e).toSeconds():e instanceof t.TimeBase?e.toSeconds():void 0},t.prototype.toFrequency=function(e){return this.isNumber(e)?e:this.isString(e)||this.isUndef(e)?new t.Frequency(e).valueOf():e instanceof t.TimeBase?e.toFrequency():void 0},t.prototype.toTicks=function(e){return this.isNumber(e)||this.isString(e)?new t.TransportTime(e).toTicks():this.isUndef(e)?t.Transport.ticks:e instanceof t.TimeBase?e.toTicks():void 0},t}),t(function(t){return t.Param=function(){var e=this.optionsObject(arguments,[\"param\",\"units\",\"convert\"],t.Param.defaults);this._param=this.input=e.param,this.units=e.units,this.convert=e.convert,this.overridden=!1,this._lfo=null,this.isObject(e.lfo)?this.value=e.lfo:this.isUndef(e.value)||(this.value=e.value)},t.extend(t.Param),t.Param.defaults={units:t.Type.Default,convert:!0,param:void 0},Object.defineProperty(t.Param.prototype,\"value\",{get:function(){return this._toUnits(this._param.value)},set:function(e){if(this.isObject(e)){if(this.isUndef(t.LFO))throw new Error(\"Include 'Tone.LFO' to use an LFO as a Param value.\");this._lfo&&this._lfo.dispose(),this._lfo=new t.LFO(e).start(),this._lfo.connect(this.input)}else{var i=this._fromUnits(e);this._param.cancelScheduledValues(0),this._param.value=i}}}),t.Param.prototype._fromUnits=function(e){if(!this.convert&&!this.isUndef(this.convert))return e;switch(this.units){case t.Type.Time:return this.toSeconds(e);case t.Type.Frequency:return this.toFrequency(e);case t.Type.Decibels:return this.dbToGain(e);case t.Type.NormalRange:return Math.min(Math.max(e,0),1);case t.Type.AudioRange:return Math.min(Math.max(e,-1),1);case t.Type.Positive:return Math.max(e,0);default:return e}},t.Param.prototype._toUnits=function(e){if(!this.convert&&!this.isUndef(this.convert))return e;switch(this.units){case t.Type.Decibels:return this.gainToDb(e);default:return e}},t.Param.prototype._minOutput=1e-5,t.Param.prototype.setValueAtTime=function(t,e){return t=this._fromUnits(t),e=this.toSeconds(e),e<=this.now()+this.blockTime?this._param.value=t:this._param.setValueAtTime(t,e),this},t.Param.prototype.setRampPoint=function(t){t=this.defaultArg(t,this.now());var e=this._param.value;return 0===e&&(e=this._minOutput),this._param.setValueAtTime(e,t),this},t.Param.prototype.linearRampToValueAtTime=function(t,e){return t=this._fromUnits(t),this._param.linearRampToValueAtTime(t,this.toSeconds(e)),this},t.Param.prototype.exponentialRampToValueAtTime=function(t,e){return t=this._fromUnits(t),t=Math.max(this._minOutput,t),this._param.exponentialRampToValueAtTime(t,this.toSeconds(e)),this},t.Param.prototype.exponentialRampToValue=function(t,e,i){return i=this.toSeconds(i),this.setRampPoint(i),this.exponentialRampToValueAtTime(t,i+this.toSeconds(e)),this},t.Param.prototype.linearRampToValue=function(t,e,i){return i=this.toSeconds(i),this.setRampPoint(i),this.linearRampToValueAtTime(t,i+this.toSeconds(e)),this},t.Param.prototype.setTargetAtTime=function(t,e,i){return t=this._fromUnits(t),t=Math.max(this._minOutput,t),i=Math.max(this._minOutput,i),this._param.setTargetAtTime(t,this.toSeconds(e),i),this},t.Param.prototype.setValueCurveAtTime=function(t,e,i){for(var s=0;s<t.length;s++)t[s]=this._fromUnits(t[s]);return this._param.setValueCurveAtTime(t,this.toSeconds(e),this.toSeconds(i)),this},t.Param.prototype.cancelScheduledValues=function(t){return this._param.cancelScheduledValues(this.toSeconds(t)),this},t.Param.prototype.rampTo=function(e,i,s){return i=this.defaultArg(i,0),this.units===t.Type.Frequency||this.units===t.Type.BPM||this.units===t.Type.Decibels?this.exponentialRampToValue(e,i,s):this.linearRampToValue(e,i,s),this},Object.defineProperty(t.Param.prototype,\"lfo\",{get:function(){return this._lfo}}),t.Param.prototype.dispose=function(){return t.prototype.dispose.call(this),this._param=null,this._lfo&&(this._lfo.dispose(),this._lfo=null),this},t.Param}),t(function(t){return window.GainNode&&!AudioContext.prototype.createGain&&(AudioContext.prototype.createGain=AudioContext.prototype.createGainNode),t.Gain=function(){var e=this.optionsObject(arguments,[\"gain\",\"units\"],t.Gain.defaults);this.input=this.output=this._gainNode=this.context.createGain(),this.gain=new t.Param({param:this._gainNode.gain,units:e.units,value:e.gain,convert:e.convert}),this._readOnly(\"gain\")},t.extend(t.Gain),t.Gain.defaults={gain:1,convert:!0},t.Gain.prototype.dispose=function(){t.Param.prototype.dispose.call(this),this._gainNode.disconnect(),this._gainNode=null,this._writable(\"gain\"),this.gain.dispose(),this.gain=null},t.prototype.createInsOuts=function(e,i){1===e?this.input=new t.Gain:e>1&&(this.input=new Array(e)),1===i?this.output=new t.Gain:i>1&&(this.output=new Array(e))},t.Gain}),t(function(t){return t.Signal=function(){var e=this.optionsObject(arguments,[\"value\",\"units\"],t.Signal.defaults);this.output=this._gain=this.context.createGain(),e.param=this._gain.gain,t.Param.call(this,e),this.input=this._param=this._gain.gain,this.context.getConstant(1).chain(this._gain)},t.extend(t.Signal,t.Param),t.Signal.defaults={value:0,units:t.Type.Default,convert:!0},t.Signal.prototype.connect=t.SignalBase.prototype.connect,t.Signal.prototype.dispose=function(){return t.Param.prototype.dispose.call(this),this._param=null,this._gain.disconnect(),this._gain=null,this},t.Signal}),t(function(t){return t.Timeline=function(){var e=this.optionsObject(arguments,[\"memory\"],t.Timeline.defaults);this._timeline=[],this._toRemove=[],this._iterating=!1,this.memory=e.memory},t.extend(t.Timeline),t.Timeline.defaults={memory:1/0},Object.defineProperty(t.Timeline.prototype,\"length\",{get:function(){return this._timeline.length}}),t.Timeline.prototype.add=function(t){if(this.isUndef(t.time))throw new Error(\"Tone.Timeline: events must have a time attribute\");if(this._timeline.length){var e=this._search(t.time);this._timeline.splice(e+1,0,t)}else this._timeline.push(t);if(this.length>this.memory){var i=this.length-this.memory;this._timeline.splice(0,i)}return this},t.Timeline.prototype.remove=function(t){if(this._iterating)this._toRemove.push(t);else{var e=this._timeline.indexOf(t);-1!==e&&this._timeline.splice(e,1)}return this},t.Timeline.prototype.get=function(t){var e=this._search(t);return-1!==e?this._timeline[e]:null},t.Timeline.prototype.peek=function(){return this._timeline[0]},t.Timeline.prototype.shift=function(){return this._timeline.shift()},t.Timeline.prototype.getAfter=function(t){var e=this._search(t);return e+1<this._timeline.length?this._timeline[e+1]:null},t.Timeline.prototype.getBefore=function(t){var e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];var i=this._search(t);return i-1>=0?this._timeline[i-1]:null},t.Timeline.prototype.cancel=function(t){if(this._timeline.length>1){var e=this._search(t);if(e>=0)if(this._timeline[e].time===t){for(var i=e;i>=0&&this._timeline[i].time===t;i--)e=i;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else 1===this._timeline.length&&this._timeline[0].time>=t&&(this._timeline=[]);return this},t.Timeline.prototype.cancelBefore=function(t){if(this._timeline.length){var e=this._search(t);e>=0&&(this._timeline=this._timeline.slice(e+1))}return this},t.Timeline.prototype._search=function(t){var e=0,i=this._timeline.length,s=i;if(i>0&&this._timeline[i-1].time<=t)return i-1;for(;e<s;){var n=Math.floor(e+(s-e)/2),o=this._timeline[n],r=this._timeline[n+1];if(o.time===t){for(var a=n;a<this._timeline.length;a++){this._timeline[a].time===t&&(n=a)}return n}if(o.time<t&&r.time>t)return n;o.time>t?s=n:o.time<t&&(e=n+1)}return-1},t.Timeline.prototype._iterate=function(t,e,i){this._iterating=!0,e=this.defaultArg(e,0),i=this.defaultArg(i,this._timeline.length-1);for(var s=e;s<=i;s++)t(this._timeline[s]);if(this._iterating=!1,this._toRemove.length>0){for(var n=0;n<this._toRemove.length;n++){var o=this._timeline.indexOf(this._toRemove[n]);-1!==o&&this._timeline.splice(o,1)}this._toRemove=[]}},t.Timeline.prototype.forEach=function(t){return this._iterate(t),this},t.Timeline.prototype.forEachBefore=function(t,e){var i=this._search(t);return-1!==i&&this._iterate(e,0,i),this},t.Timeline.prototype.forEachAfter=function(t,e){var i=this._search(t);return this._iterate(e,i+1),this},t.Timeline.prototype.forEachFrom=function(t,e){for(var i=this._search(t);i>=0&&this._timeline[i].time>=t;)i--;return this._iterate(e,i+1),this},t.Timeline.prototype.forEachAtTime=function(t,e){var i=this._search(t);return-1!==i&&this._iterate(function(i){i.time===t&&e(i)},0,i),this},t.Timeline.prototype.dispose=function(){t.prototype.dispose.call(this),this._timeline=null,this._toRemove=null},t.Timeline}),t(function(t){return t.TimelineSignal=function(){var e=this.optionsObject(arguments,[\"value\",\"units\"],t.Signal.defaults);this._events=new t.Timeline(10),t.Signal.apply(this,e),e.param=this._param,t.Param.call(this,e),this._initial=this._fromUnits(this._param.value)},t.extend(t.TimelineSignal,t.Param),t.TimelineSignal.Type={Linear:\"linear\",Exponential:\"exponential\",Target:\"target\",Curve:\"curve\",Set:\"set\"},Object.defineProperty(t.TimelineSignal.prototype,\"value\",{get:function(){var t=this.now(),e=this.getValueAtTime(t);return this._toUnits(e)},set:function(t){var e=this._fromUnits(t);this._initial=e,this.cancelScheduledValues(),this._param.value=e}}),t.TimelineSignal.prototype.setValueAtTime=function(e,i){return e=this._fromUnits(e),i=this.toSeconds(i),this._events.add({type:t.TimelineSignal.Type.Set,value:e,time:i}),this._param.setValueAtTime(e,i),this},t.TimelineSignal.prototype.linearRampToValueAtTime=function(e,i){return e=this._fromUnits(e),i=this.toSeconds(i),this._events.add({type:t.TimelineSignal.Type.Linear,value:e,time:i}),this._param.linearRampToValueAtTime(e,i),this},t.TimelineSignal.prototype.exponentialRampToValueAtTime=function(e,i){i=this.toSeconds(i);var s=this._searchBefore(i);s&&0===s.value&&this.setValueAtTime(this._minOutput,s.time),e=this._fromUnits(e);var n=Math.max(e,this._minOutput);return this._events.add({type:t.TimelineSignal.Type.Exponential,value:n,time:i}),e<this._minOutput?(this._param.exponentialRampToValueAtTime(this._minOutput,i-this.sampleTime),this.setValueAtTime(0,i)):this._param.exponentialRampToValueAtTime(e,i),this},t.TimelineSignal.prototype.setTargetAtTime=function(e,i,s){return e=this._fromUnits(e),e=Math.max(this._minOutput,e),s=Math.max(this._minOutput,s),i=this.toSeconds(i),this._events.add({type:t.TimelineSignal.Type.Target,value:e,time:i,constant:s}),this._param.setTargetAtTime(e,i,s),this},t.TimelineSignal.prototype.setValueCurveAtTime=function(e,i,s,n){n=this.defaultArg(n,1);for(var o=new Array(e.length),r=0;r<o.length;r++)o[r]=this._fromUnits(e[r])*n;i=this.toSeconds(i),s=this.toSeconds(s),this._events.add({type:t.TimelineSignal.Type.Curve,value:o,time:i,duration:s}),this._param.setValueAtTime(o[0],i);for(var a=1;a<o.length;a++){var h=i+a/(o.length-1)*s;this._param.linearRampToValueAtTime(o[a],h)}return this},t.TimelineSignal.prototype.cancelScheduledValues=function(t){return t=this.toSeconds(t),this._events.cancel(t),this._param.cancelScheduledValues(t),this},t.TimelineSignal.prototype.setRampPoint=function(e){e=this.toSeconds(e);var i=this._toUnits(this.getValueAtTime(e)),s=this._searchBefore(e);if(s&&s.time===e)this.cancelScheduledValues(e+this.sampleTime);else if(s&&s.type===t.TimelineSignal.Type.Curve&&s.time+s.duration>e)this.cancelScheduledValues(e),this.linearRampToValueAtTime(i,e);else{var n=this._searchAfter(e);n&&(this.cancelScheduledValues(e),n.type===t.TimelineSignal.Type.Linear?this.linearRampToValueAtTime(i,e):n.type===t.TimelineSignal.Type.Exponential&&this.exponentialRampToValueAtTime(i,e)),this.setValueAtTime(i,e)}return this},t.TimelineSignal.prototype.linearRampToValueBetween=function(t,e,i){return this.setRampPoint(e),this.linearRampToValueAtTime(t,i),this},t.TimelineSignal.prototype.exponentialRampToValueBetween=function(t,e,i){return this.setRampPoint(e),this.exponentialRampToValueAtTime(t,i),this},t.TimelineSignal.prototype._searchBefore=function(t){return this._events.get(t)},t.TimelineSignal.prototype._searchAfter=function(t){return this._events.getAfter(t)},t.TimelineSignal.prototype.getValueAtTime=function(e){e=this.toSeconds(e);var i=this._searchAfter(e),s=this._searchBefore(e),n=this._initial;if(null===s)n=this._initial;else if(s.type===t.TimelineSignal.Type.Target){var o,r=this._events.getBefore(s.time);o=null===r?this._initial:r.value,n=this._exponentialApproach(s.time,o,s.value,s.constant,e)}else n=s.type===t.TimelineSignal.Type.Curve?this._curveInterpolate(s.time,s.value,s.duration,e):null===i?s.value:i.type===t.TimelineSignal.Type.Linear?this._linearInterpolate(s.time,s.value,i.time,i.value,e):i.type===t.TimelineSignal.Type.Exponential?this._exponentialInterpolate(s.time,s.value,i.time,i.value,e):s.value;return n},t.TimelineSignal.prototype.connect=t.SignalBase.prototype.connect,t.TimelineSignal.prototype._exponentialApproach=function(t,e,i,s,n){return i+(e-i)*Math.exp(-(n-t)/s)},t.TimelineSignal.prototype._linearInterpolate=function(t,e,i,s,n){return e+(n-t)/(i-t)*(s-e)},t.TimelineSignal.prototype._exponentialInterpolate=function(t,e,i,s,n){return(e=Math.max(this._minOutput,e))*Math.pow(s/e,(n-t)/(i-t))},t.TimelineSignal.prototype._curveInterpolate=function(t,e,i,s){var n=e.length;if(s>=t+i)return e[n-1];if(s<=t)return e[0];var o=(s-t)/i,r=Math.floor((n-1)*o),a=Math.ceil((n-1)*o),h=e[r],l=e[a];return a===r?h:this._linearInterpolate(r,h,a,l,o*(n-1))},t.TimelineSignal.prototype.dispose=function(){t.Signal.prototype.dispose.call(this),t.Param.prototype.dispose.call(this),this._events.dispose(),this._events=null},t.TimelineSignal}),t(function(t){return t.Pow=function(e){this._exp=this.defaultArg(e,1),this._expScaler=this.input=this.output=new t.WaveShaper(this._expFunc(this._exp),8192)},t.extend(t.Pow,t.SignalBase),Object.defineProperty(t.Pow.prototype,\"value\",{get:function(){return this._exp},set:function(t){this._exp=t,this._expScaler.setMap(this._expFunc(this._exp))}}),t.Pow.prototype._expFunc=function(t){return function(e){return Math.pow(Math.abs(e),t)}},t.Pow.prototype.dispose=function(){return t.prototype.dispose.call(this),this._expScaler.dispose(),this._expScaler=null,this},t.Pow}),t(function(t){return t.Envelope=function(){var e=this.optionsObject(arguments,[\"attack\",\"decay\",\"sustain\",\"release\"],t.Envelope.defaults);this.attack=e.attack,this.decay=e.decay,this.sustain=e.sustain,this.release=e.release,this._attackCurve=\"linear\",this._releaseCurve=\"exponential\",this._sig=this.output=new t.TimelineSignal,this._sig.setValueAtTime(0,0),this.attackCurve=e.attackCurve,this.releaseCurve=e.releaseCurve},t.extend(t.Envelope),t.Envelope.defaults={attack:.01,decay:.1,sustain:.5,release:1,attackCurve:\"linear\",releaseCurve:\"exponential\"},Object.defineProperty(t.Envelope.prototype,\"value\",{get:function(){return this.getValueAtTime(this.now())}}),Object.defineProperty(t.Envelope.prototype,\"attackCurve\",{get:function(){if(this.isString(this._attackCurve))return this._attackCurve;if(this.isArray(this._attackCurve)){for(var e in t.Envelope.Type)if(t.Envelope.Type[e].In===this._attackCurve)return e;return this._attackCurve}},set:function(e){if(t.Envelope.Type.hasOwnProperty(e)){var i=t.Envelope.Type[e];this.isObject(i)?this._attackCurve=i.In:this._attackCurve=i}else{if(!this.isArray(e))throw new Error(\"Tone.Envelope: invalid curve: \"+e);this._attackCurve=e}}}),Object.defineProperty(t.Envelope.prototype,\"releaseCurve\",{get:function(){if(this.isString(this._releaseCurve))return this._releaseCurve;if(this.isArray(this._releaseCurve)){for(var e in t.Envelope.Type)if(t.Envelope.Type[e].Out===this._releaseCurve)return e;return this._releaseCurve}},set:function(e){if(t.Envelope.Type.hasOwnProperty(e)){var i=t.Envelope.Type[e];this.isObject(i)?this._releaseCurve=i.Out:this._releaseCurve=i}else{if(!this.isArray(e))throw new Error(\"Tone.Envelope: invalid curve: \"+e);this._releaseCurve=e}}}),t.Envelope.prototype.triggerAttack=function(t,e){t=this.toSeconds(t);var i=this.toSeconds(this.attack),s=i,n=this.toSeconds(this.decay);e=this.defaultArg(e,1);var o=this.getValueAtTime(t);if(o>0){s=(1-o)/(1/s)}if(\"linear\"===this._attackCurve)this._sig.linearRampToValue(e,s,t);else if(\"exponential\"===this._attackCurve)this._sig.exponentialRampToValue(e,s,t);else if(s>0){this._sig.setRampPoint(t);var r=this._attackCurve;if(s<i){var a=1-s/i,h=Math.floor(a*this._attackCurve.length);r=this._attackCurve.slice(h),r[0]=o}this._sig.setValueCurveAtTime(r,t,s,e)}return this._sig.exponentialRampToValue(e*this.sustain,n,s+t),this},t.Envelope.prototype.triggerRelease=function(t){t=this.toSeconds(t);var e=this.getValueAtTime(t);if(e>0){var i=this.toSeconds(this.release);if(\"linear\"===this._releaseCurve)this._sig.linearRampToValue(0,i,t);else if(\"exponential\"===this._releaseCurve)this._sig.exponentialRampToValue(0,i,t);else{var s=this._releaseCurve;this.isArray(s)&&(this._sig.setRampPoint(t),this._sig.setValueCurveAtTime(s,t,i,e))}}return this},t.Envelope.prototype.getValueAtTime=function(t){return this._sig.getValueAtTime(t)},t.Envelope.prototype.triggerAttackRelease=function(t,e,i){return e=this.toSeconds(e),this.triggerAttack(e,i),this.triggerRelease(e+this.toSeconds(t)),this},t.Envelope.prototype.cancel=function(t){return this._sig.cancelScheduledValues(t),this},t.Envelope.prototype.connect=t.Signal.prototype.connect,function(){function e(t){for(var e=new Array(t.length),i=0;i<t.length;i++)e[i]=1-t[i];return e}var i,s,n=[];for(i=0;i<128;i++)n[i]=Math.sin(i/127*(Math.PI/2));var o=[];for(i=0;i<127;i++){s=i/127;var r=Math.sin(s*(2*Math.PI)*6.4-Math.PI/2)+1;o[i]=r/10+.83*s}o[127]=1;var a=[];for(i=0;i<128;i++)a[i]=Math.ceil(i/127*5)/5;var h=[];for(i=0;i<128;i++)s=i/127,h[i]=.5*(1-Math.cos(Math.PI*s));var l=[];for(i=0;i<128;i++){s=i/127;var c=4*Math.pow(s,3)+.2,u=Math.cos(c*Math.PI*2*s);l[i]=Math.abs(u*(1-s))}t.Envelope.Type={linear:\"linear\",exponential:\"exponential\",bounce:{In:e(l),Out:l},cosine:{In:n,Out:function(t){return t.slice(0).reverse()}(n)},step:{In:a,Out:e(a)},ripple:{In:o,Out:e(o)},sine:{In:h,Out:e(h)}}}(),t.Envelope.prototype.dispose=function(){return t.prototype.dispose.call(this),this._sig.dispose(),this._sig=null,this._attackCurve=null,this._releaseCurve=null,this},t.Envelope}),t(function(t){return t.AmplitudeEnvelope=function(){t.Envelope.apply(this,arguments),this.input=this.output=new t.Gain,this._sig.connect(this.output.gain)},t.extend(t.AmplitudeEnvelope,t.Envelope),t.AmplitudeEnvelope.prototype.dispose=function(){return this.input.dispose(),this.input=null,t.Envelope.prototype.dispose.call(this),this},t.AmplitudeEnvelope}),t(function(t){return window.AnalyserNode&&!AnalyserNode.prototype.getFloatTimeDomainData&&(AnalyserNode.prototype.getFloatTimeDomainData=function(t){var e=new Uint8Array(t.length);this.getByteTimeDomainData(e);for(var i=0;i<e.length;i++)t[i]=(e[i]-128)/128}),t.Analyser=function(){var e=this.optionsObject(arguments,[\"type\",\"size\"],t.Analyser.defaults);this._analyser=this.input=this.output=this.context.createAnalyser(),this._type=e.type,this._returnType=e.returnType,this._buffer=null,this.size=e.size,this.type=e.type,this.returnType=e.returnType,this.minDecibels=e.minDecibels,this.maxDecibels=e.maxDecibels},t.extend(t.Analyser),t.Analyser.defaults={size:1024,returnType:\"byte\",type:\"fft\",smoothing:.8,maxDecibels:-30,minDecibels:-100},t.Analyser.Type={Waveform:\"waveform\",FFT:\"fft\"},t.Analyser.ReturnType={Byte:\"byte\",Float:\"float\"},t.Analyser.prototype.analyse=function(){return this._type===t.Analyser.Type.FFT?this._returnType===t.Analyser.ReturnType.Byte?this._analyser.getByteFrequencyData(this._buffer):this._analyser.getFloatFrequencyData(this._buffer):this._type===t.Analyser.Type.Waveform&&(this._returnType===t.Analyser.ReturnType.Byte?this._analyser.getByteTimeDomainData(this._buffer):this._analyser.getFloatTimeDomainData(this._buffer)),this._buffer},Object.defineProperty(t.Analyser.prototype,\"size\",{get:function(){return this._analyser.frequencyBinCount},set:function(t){this._analyser.fftSize=2*t,this.type=this._type}}),Object.defineProperty(t.Analyser.prototype,\"returnType\",{get:function(){return this._returnType},set:function(e){if(e===t.Analyser.ReturnType.Byte)this._buffer=new Uint8Array(this._analyser.frequencyBinCount);else{if(e!==t.Analyser.ReturnType.Float)throw new TypeError(\"Tone.Analayser: invalid return type: \"+e);this._buffer=new Float32Array(this._analyser.frequencyBinCount)}this._returnType=e}}),Object.defineProperty(t.Analyser.prototype,\"type\",{get:function(){return this._type},set:function(e){if(e!==t.Analyser.Type.Waveform&&e!==t.Analyser.Type.FFT)throw new TypeError(\"Tone.Analyser: invalid type: \"+e);this._type=e}}),Object.defineProperty(t.Analyser.prototype,\"smoothing\",{get:function(){return this._analyser.smoothingTimeConstant},set:function(t){this._analyser.smoothingTimeConstant=t}}),Object.defineProperty(t.Analyser.prototype,\"minDecibels\",{get:function(){return this._analyser.minDecibels},set:function(t){this._analyser.minDecibels=t}}),Object.defineProperty(t.Analyser.prototype,\"maxDecibels\",{get:function(){return this._analyser.maxDecibels},set:function(t){this._analyser.maxDecibels=t}}),t.Analyser.prototype.dispose=function(){t.prototype.dispose.call(this),this._analyser.disconnect(),this._analyser=null,this._buffer=null},t.Analyser}),t(function(t){return t.Compressor=function(){var e=this.optionsObject(arguments,[\"threshold\",\"ratio\"],t.Compressor.defaults);this._compressor=this.input=this.output=this.context.createDynamicsCompressor(),this.threshold=new t.Param({param:this._compressor.threshold,units:t.Type.Decibels,convert:!1}),this.attack=new t.Param(this._compressor.attack,t.Type.Time),this.release=new t.Param(this._compressor.release,t.Type.Time),this.knee=new t.Param({param:this._compressor.knee,units:t.Type.Decibels,convert:!1}),this.ratio=new t.Param({param:this._compressor.ratio,convert:!1}),this._readOnly([\"knee\",\"release\",\"attack\",\"ratio\",\"threshold\"]),this.set(e)},t.extend(t.Compressor),t.Compressor.defaults={ratio:12,threshold:-24,release:.25,attack:.003,knee:30},t.Compressor.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable([\"knee\",\"release\",\"attack\",\"ratio\",\"threshold\"]),this._compressor.disconnect(),this._compressor=null,this.attack.dispose(),this.attack=null,this.release.dispose(),this.release=null,this.threshold.dispose(),this.threshold=null,this.ratio.dispose(),this.ratio=null,this.knee.dispose(),this.knee=null,this},t.Compressor}),t(function(t){return t.Add=function(e){this.createInsOuts(2,0),this._sum=this.input[0]=this.input[1]=this.output=new t.Gain,this._param=this.input[1]=new t.Signal(e),this._param.connect(this._sum)},t.extend(t.Add,t.Signal),t.Add.prototype.dispose=function(){return t.prototype.dispose.call(this),this._sum.dispose(),this._sum=null,this._param.dispose(),this._param=null,this},t.Add}),t(function(t){return t.Multiply=function(e){this.createInsOuts(2,0),this._mult=this.input[0]=this.output=new t.Gain,this._param=this.input[1]=this.output.gain,this._param.value=this.defaultArg(e,0)},t.extend(t.Multiply,t.Signal),t.Multiply.prototype.dispose=function(){return t.prototype.dispose.call(this),this._mult.dispose(),this._mult=null,this._param=null,this},t.Multiply}),t(function(t){return t.Negate=function(){this._multiply=this.input=this.output=new t.Multiply(-1)},t.extend(t.Negate,t.SignalBase),t.Negate.prototype.dispose=function(){return t.prototype.dispose.call(this),this._multiply.dispose(),this._multiply=null,this},t.Negate}),t(function(t){return t.Subtract=function(e){this.createInsOuts(2,0),this._sum=this.input[0]=this.output=new t.Gain,this._neg=new t.Negate,this._param=this.input[1]=new t.Signal(e),this._param.chain(this._neg,this._sum)},t.extend(t.Subtract,t.Signal),t.Subtract.prototype.dispose=function(){return t.prototype.dispose.call(this),this._neg.dispose(),this._neg=null,this._sum.disconnect(),this._sum=null,this._param.dispose(),this._param=null,this},t.Subtract}),t(function(t){return t.GreaterThanZero=function(){this._thresh=this.output=new t.WaveShaper(function(t){return t<=0?0:1},127),this._scale=this.input=new t.Multiply(1e4),this._scale.connect(this._thresh)},t.extend(t.GreaterThanZero,t.SignalBase),t.GreaterThanZero.prototype.dispose=function(){return t.prototype.dispose.call(this),this._scale.dispose(),this._scale=null,this._thresh.dispose(),this._thresh=null,this},t.GreaterThanZero}),t(function(t){return t.GreaterThan=function(e){this.createInsOuts(2,0),this._param=this.input[0]=new t.Subtract(e),this.input[1]=this._param.input[1],this._gtz=this.output=new t.GreaterThanZero,this._param.connect(this._gtz)},t.extend(t.GreaterThan,t.Signal),t.GreaterThan.prototype.dispose=function(){return t.prototype.dispose.call(this),this._param.dispose(),this._param=null,this._gtz.dispose(),this._gtz=null,this},t.GreaterThan}),t(function(t){return t.Abs=function(){this._abs=this.input=this.output=new t.WaveShaper(function(t){return 0===t?0:Math.abs(t)},127)},t.extend(t.Abs,t.SignalBase),t.Abs.prototype.dispose=function(){return t.prototype.dispose.call(this),this._abs.dispose(),this._abs=null,this},t.Abs}),t(function(t){return t.Modulo=function(e){this.createInsOuts(1,0),this._shaper=new t.WaveShaper(Math.pow(2,16)),this._multiply=new t.Multiply,this._subtract=this.output=new t.Subtract,this._modSignal=new t.Signal(e),this.input.fan(this._shaper,this._subtract),this._modSignal.connect(this._multiply,0,0),this._shaper.connect(this._multiply,0,1),this._multiply.connect(this._subtract,0,1),this._setWaveShaper(e)},t.extend(t.Modulo,t.SignalBase),t.Modulo.prototype._setWaveShaper=function(t){this._shaper.setMap(function(e){return Math.floor((e+1e-4)/t)})},Object.defineProperty(t.Modulo.prototype,\"value\",{get:function(){return this._modSignal.value},set:function(t){this._modSignal.value=t,this._setWaveShaper(t)}}),t.Modulo.prototype.dispose=function(){return t.prototype.dispose.call(this),this._shaper.dispose(),this._shaper=null,this._multiply.dispose(),this._multiply=null,this._subtract.dispose(),this._subtract=null,this._modSignal.dispose(),this._modSignal=null,this},t.Modulo}),t(function(t){return t.AudioToGain=function(){this._norm=this.input=this.output=new t.WaveShaper(function(t){return(t+1)/2})},t.extend(t.AudioToGain,t.SignalBase),t.AudioToGain.prototype.dispose=function(){return t.prototype.dispose.call(this),this._norm.dispose(),this._norm=null,this},t.AudioToGain}),t(function(t){function e(t,e,i){var s=new t;return i._eval(e[0]).connect(s,0,0),i._eval(e[1]).connect(s,0,1),s}function i(t,e,i){var s=new t;return i._eval(e[0]).connect(s,0,0),s}function s(t){return t?parseFloat(t):void 0}function n(t){return t&&t.args?parseFloat(t.args):void 0}return t.Expr=function(){var t=this._replacements(Array.prototype.slice.call(arguments)),e=this._parseInputs(t);this._nodes=[],this.input=new Array(e);for(var i=0;i<e;i++)this.input[i]=this.context.createGain();var s,n=this._parseTree(t);try{s=this._eval(n)}catch(e){throw this._disposeNodes(),new Error(\"Tone.Expr: Could evaluate expression: \"+t)}this.output=s},t.extend(t.Expr,t.SignalBase),t.Expr._Expressions={value:{signal:{regexp:/^\\d+\\.\\d+|^\\d+/,method:function(e){return new t.Signal(s(e))}},input:{regexp:/^\\$\\d/,method:function(t,e){return e.input[s(t.substr(1))]}}},glue:{\"(\":{regexp:/^\\(/},\")\":{regexp:/^\\)/},\",\":{regexp:/^,/}},func:{abs:{regexp:/^abs/,method:i.bind(this,t.Abs)},mod:{regexp:/^mod/,method:function(e,i){var s=n(e[1]),o=new t.Modulo(s);return i._eval(e[0]).connect(o),o}},pow:{regexp:/^pow/,method:function(e,i){var s=n(e[1]),o=new t.Pow(s);return i._eval(e[0]).connect(o),o}},a2g:{regexp:/^a2g/,method:function(e,i){var s=new t.AudioToGain;return i._eval(e[0]).connect(s),s}}},binary:{\"+\":{regexp:/^\\+/,precedence:1,method:e.bind(this,t.Add)},\"-\":{regexp:/^\\-/,precedence:1,method:function(s,n){return 1===s.length?i(t.Negate,s,n):e(t.Subtract,s,n)}},\"*\":{regexp:/^\\*/,precedence:0,method:e.bind(this,t.Multiply)}},unary:{\"-\":{regexp:/^\\-/,method:i.bind(this,t.Negate)},\"!\":{regexp:/^\\!/,method:i.bind(this,t.NOT)}}},t.Expr.prototype._parseInputs=function(t){var e=t.match(/\\$\\d/g),i=0;if(null!==e)for(var s=0;s<e.length;s++){var n=parseInt(e[s].substr(1))+1;i=Math.max(i,n)}return i},t.Expr.prototype._replacements=function(t){for(var e=t.shift(),i=0;i<t.length;i++)e=e.replace(/\\%/i,t[i]);return e},t.Expr.prototype._tokenize=function(e){for(var i=-1,s=[];e.length>0;){e=e.trim();var n=function(e){for(var i in t.Expr._Expressions){var s=t.Expr._Expressions[i];for(var n in s){var o=s[n],r=o.regexp,a=e.match(r);if(null!==a)return{type:i,value:a[0],method:o.method}}}throw new SyntaxError(\"Tone.Expr: Unexpected token \"+e)}(e);s.push(n),e=e.substr(n.value.length)}return{next:function(){return s[++i]},peek:function(){return s[i+1]}}},t.Expr.prototype._parseTree=function(e){function i(t,e){return!c(t)&&\"glue\"===t.type&&t.value===e}function s(e,i,s){var n=t.Expr._Expressions[i];if(!c(e))for(var o in n){var r=n[o];if(r.regexp.test(e.value)){if(c(s))return!0;if(r.precedence===s)return!0}}return!1}function n(t){c(t)&&(t=5);var e;e=t<0?o():n(t-1);for(var i=l.peek();s(i,\"binary\",t);)i=l.next(),e={operator:i.value,method:i.method,args:[e,n(t-1)]},i=l.peek();return e}function o(){var t,e;return t=l.peek(),s(t,\"unary\")?(t=l.next(),e=o(),{operator:t.value,method:t.method,args:[e]}):r()}function r(){var t,e;if(t=l.peek(),c(t))throw new SyntaxError(\"Tone.Expr: Unexpected termination of expression\");if(\"func\"===t.type)return t=l.next(),a(t);if(\"value\"===t.type)return t=l.next(),{method:t.method,args:t.value};if(i(t,\"(\")){if(l.next(),e=n(),t=l.next(),!i(t,\")\"))throw new SyntaxError(\"Expected )\");return e}throw new SyntaxError(\"Tone.Expr: Parse error, cannot process token \"+t.value)}function a(t){var e,s=[];if(e=l.next(),!i(e,\"(\"))throw new SyntaxError('Tone.Expr: Expected ( in a function call \"'+t.value+'\"');if(e=l.peek(),i(e,\")\")||(s=h()),e=l.next(),!i(e,\")\"))throw new SyntaxError('Tone.Expr: Expected ) in a function call \"'+t.value+'\"');return{method:t.method,args:s,name:name}}function h(){for(var t,e,s=[];;){if(e=n(),c(e))break;if(s.push(e),t=l.peek(),!i(t,\",\"))break;l.next()}return s}var l=this._tokenize(e),c=this.isUndef.bind(this);return n()},t.Expr.prototype._eval=function(t){if(!this.isUndef(t)){var e=t.method(t.args,this);return this._nodes.push(e),e}},t.Expr.prototype._disposeNodes=function(){for(var t=0;t<this._nodes.length;t++){var e=this._nodes[t];this.isFunction(e.dispose)?e.dispose():this.isFunction(e.disconnect)&&e.disconnect(),e=null,this._nodes[t]=null}this._nodes=null},t.Expr.prototype.dispose=function(){t.prototype.dispose.call(this),this._disposeNodes()},t.Expr}),t(function(t){return t.EqualPowerGain=function(){this._eqPower=this.input=this.output=new t.WaveShaper(function(t){return Math.abs(t)<.001?0:this.equalPowerScale(t)}.bind(this),4096)},t.extend(t.EqualPowerGain,t.SignalBase),t.EqualPowerGain.prototype.dispose=function(){return t.prototype.dispose.call(this),this._eqPower.dispose(),this._eqPower=null,this},t.EqualPowerGain}),t(function(t){return t.CrossFade=function(e){this.createInsOuts(2,1),this.a=this.input[0]=new t.Gain,this.b=this.input[1]=new t.Gain,this.fade=new t.Signal(this.defaultArg(e,.5),t.Type.NormalRange),this._equalPowerA=new t.EqualPowerGain,this._equalPowerB=new t.EqualPowerGain,this._invert=new t.Expr(\"1 - $0\"),this.a.connect(this.output),this.b.connect(this.output),this.fade.chain(this._equalPowerB,this.b.gain),this.fade.chain(this._invert,this._equalPowerA,this.a.gain),this._readOnly(\"fade\")},t.extend(t.CrossFade),t.CrossFade.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable(\"fade\"),this._equalPowerA.dispose(),this._equalPowerA=null,this._equalPowerB.dispose(),this._equalPowerB=null,this.fade.dispose(),this.fade=null,this._invert.dispose(),this._invert=null,this.a.dispose(),this.a=null,this.b.dispose(),this.b=null,this},t.CrossFade}),t(function(t){return t.Filter=function(){this.createInsOuts(1,1);var e=this.optionsObject(arguments,[\"frequency\",\"type\",\"rolloff\"],t.Filter.defaults);this._filters=[],this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=new t.Signal(0,t.Type.Cents),this.gain=new t.Signal({value:e.gain,convert:!1}),this.Q=new t.Signal(e.Q),this._type=e.type,this._rolloff=e.rolloff,this.rolloff=e.rolloff,this._readOnly([\"detune\",\"frequency\",\"gain\",\"Q\"])},t.extend(t.Filter),t.Filter.defaults={type:\"lowpass\",frequency:350,rolloff:-12,Q:1,gain:0},Object.defineProperty(t.Filter.prototype,\"type\",{get:function(){return this._type},set:function(t){if(-1===[\"lowpass\",\"highpass\",\"bandpass\",\"lowshelf\",\"highshelf\",\"notch\",\"allpass\",\"peaking\"].indexOf(t))throw new TypeError(\"Tone.Filter: invalid type \"+t);this._type=t;for(var e=0;e<this._filters.length;e++)this._filters[e].type=t}}),Object.defineProperty(t.Filter.prototype,\"rolloff\",{get:function(){return this._rolloff},set:function(t){t=parseInt(t,10);var e=[-12,-24,-48,-96],i=e.indexOf(t);if(-1===i)throw new RangeError(\"Tone.Filter: rolloff can only be -12, -24, -48 or -96\");i+=1,this._rolloff=t,this.input.disconnect();for(var s=0;s<this._filters.length;s++)this._filters[s].disconnect(),this._filters[s]=null;this._filters=new Array(i);for(var n=0;n<i;n++){var o=this.context.createBiquadFilter();o.type=this._type,this.frequency.connect(o.frequency),this.detune.connect(o.detune),this.Q.connect(o.Q),this.gain.connect(o.gain),this._filters[n]=o}var r=[this.input].concat(this._filters).concat([this.output]);this.connectSeries.apply(this,r)}}),t.Filter.prototype.dispose=function(){t.prototype.dispose.call(this);for(var e=0;e<this._filters.length;e++)this._filters[e].disconnect(),this._filters[e]=null;return this._filters=null,this._writable([\"detune\",\"frequency\",\"gain\",\"Q\"]),this.frequency.dispose(),this.Q.dispose(),this.frequency=null,this.Q=null,this.detune.dispose(),this.detune=null,this.gain.dispose(),this.gain=null,this},t.Filter}),t(function(t){return t.MultibandSplit=function(){var e=this.optionsObject(arguments,[\"lowFrequency\",\"highFrequency\"],t.MultibandSplit.defaults);this.input=new t.Gain,this.output=new Array(3),this.low=this.output[0]=new t.Filter(0,\"lowpass\"),this._lowMidFilter=new t.Filter(0,\"highpass\"),this.mid=this.output[1]=new t.Filter(0,\"lowpass\"),this.high=this.output[2]=new t.Filter(0,\"highpass\"),this.lowFrequency=new t.Signal(e.lowFrequency,t.Type.Frequency),this.highFrequency=new t.Signal(e.highFrequency,t.Type.Frequency),this.Q=new t.Signal(e.Q),this.input.fan(this.low,this.high),this.input.chain(this._lowMidFilter,this.mid),this.lowFrequency.connect(this.low.frequency),this.lowFrequency.connect(this._lowMidFilter.frequency),this.highFrequency.connect(this.mid.frequency),this.highFrequency.connect(this.high.frequency),this.Q.connect(this.low.Q),this.Q.connect(this._lowMidFilter.Q),this.Q.connect(this.mid.Q),this.Q.connect(this.high.Q),this._readOnly([\"high\",\"mid\",\"low\",\"highFrequency\",\"lowFrequency\"])},t.extend(t.MultibandSplit),t.MultibandSplit.defaults={lowFrequency:400,highFrequency:2500,Q:1},t.MultibandSplit.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable([\"high\",\"mid\",\"low\",\"highFrequency\",\"lowFrequency\"]),this.low.dispose(),this.low=null,this._lowMidFilter.dispose(),this._lowMidFilter=null,this.mid.dispose(),this.mid=null,this.high.dispose(),this.high=null,this.lowFrequency.dispose(),this.lowFrequency=null,this.highFrequency.dispose(),this.highFrequency=null,this.Q.dispose(),this.Q=null,this},t.MultibandSplit}),t(function(t){return t.EQ3=function(){var e=this.optionsObject(arguments,[\"low\",\"mid\",\"high\"],t.EQ3.defaults);this.output=new t.Gain,this._multibandSplit=this.input=new t.MultibandSplit({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency}),this._lowGain=new t.Gain(e.low,t.Type.Decibels),this._midGain=new t.Gain(e.mid,t.Type.Decibels),this._highGain=new t.Gain(e.high,t.Type.Decibels),this.low=this._lowGain.gain,this.mid=this._midGain.gain,this.high=this._highGain.gain,this.Q=this._multibandSplit.Q,this.lowFrequency=this._multibandSplit.lowFrequency,this.highFrequency=this._multibandSplit.highFrequency,this._multibandSplit.low.chain(this._lowGain,this.output),this._multibandSplit.mid.chain(this._midGain,this.output),this._multibandSplit.high.chain(this._highGain,this.output),this._readOnly([\"low\",\"mid\",\"high\",\"lowFrequency\",\"highFrequency\"])},t.extend(t.EQ3),t.EQ3.defaults={low:0,mid:0,high:0,lowFrequency:400,highFrequency:2500},t.EQ3.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable([\"low\",\"mid\",\"high\",\"lowFrequency\",\"highFrequency\"]),this._multibandSplit.dispose(),this._multibandSplit=null,this.lowFrequency=null,this.highFrequency=null,this._lowGain.dispose(),this._lowGain=null,this._midGain.dispose(),this._midGain=null,this._highGain.dispose(),this._highGain=null,this.low=null,this.mid=null,this.high=null,this.Q=null,this},t.EQ3}),t(function(t){return t.Scale=function(e,i){this._outputMin=this.defaultArg(e,0),this._outputMax=this.defaultArg(i,1),this._scale=this.input=new t.Multiply(1),this._add=this.output=new t.Add(0),this._scale.connect(this._add),this._setRange()},t.extend(t.Scale,t.SignalBase),Object.defineProperty(t.Scale.prototype,\"min\",{get:function(){return this._outputMin},set:function(t){this._outputMin=t,this._setRange()}}),Object.defineProperty(t.Scale.prototype,\"max\",{get:function(){return this._outputMax},set:function(t){this._outputMax=t,this._setRange()}}),t.Scale.prototype._setRange=function(){this._add.value=this._outputMin,this._scale.value=this._outputMax-this._outputMin},t.Scale.prototype.dispose=function(){return t.prototype.dispose.call(this),this._add.dispose(),this._add=null,this._scale.dispose(),this._scale=null,this},t.Scale}),t(function(t){return t.ScaleExp=function(e,i,s){this._scale=this.output=new t.Scale(e,i),this._exp=this.input=new t.Pow(this.defaultArg(s,2)),this._exp.connect(this._scale)},t.extend(t.ScaleExp,t.SignalBase),Object.defineProperty(t.ScaleExp.prototype,\"exponent\",{get:function(){return this._exp.value},set:function(t){this._exp.value=t}}),Object.defineProperty(t.ScaleExp.prototype,\"min\",{get:function(){return this._scale.min},set:function(t){this._scale.min=t}}),Object.defineProperty(t.ScaleExp.prototype,\"max\",{get:function(){return this._scale.max},set:function(t){this._scale.max=t}}),t.ScaleExp.prototype.dispose=function(){return t.prototype.dispose.call(this),this._scale.dispose(),this._scale=null,this._exp.dispose(),this._exp=null,this},t.ScaleExp}),t(function(t){return window.DelayNode&&!AudioContext.prototype.createDelay&&(AudioContext.prototype.createDelay=AudioContext.prototype.createDelayNode),t.Delay=function(){var e=this.optionsObject(arguments,[\"delayTime\",\"maxDelay\"],t.Delay.defaults);this._delayNode=this.input=this.output=this.context.createDelay(this.toSeconds(e.maxDelay)),this.delayTime=new t.Param({param:this._delayNode.delayTime,units:t.Type.Time,value:e.delayTime}),this._readOnly(\"delayTime\")},t.extend(t.Delay),t.Delay.defaults={maxDelay:1,delayTime:0},t.Delay.prototype.dispose=function(){return t.Param.prototype.dispose.call(this),this._delayNode.disconnect(),this._delayNode=null,this._writable(\"delayTime\"),this.delayTime=null,this},t.Delay}),t(function(t){return t.FeedbackCombFilter=function(){var e=this.optionsObject(arguments,[\"delayTime\",\"resonance\"],t.FeedbackCombFilter.defaults);this._delay=this.input=this.output=new t.Delay(e.delayTime),this.delayTime=this._delay.delayTime,this._feedback=new t.Gain(e.resonance,t.Type.NormalRange),this.resonance=this._feedback.gain,this._delay.chain(this._feedback,this._delay),this._readOnly([\"resonance\",\"delayTime\"])},t.extend(t.FeedbackCombFilter),t.FeedbackCombFilter.defaults={delayTime:.1,resonance:.5},t.FeedbackCombFilter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable([\"resonance\",\"delayTime\"]),this._delay.dispose(),this._delay=null,this.delayTime=null,this._feedback.dispose(),this._feedback=null,this.resonance=null,this},t.FeedbackCombFilter}),t(function(t){return t.Follower=function(){this.createInsOuts(1,1);var e=this.optionsObject(arguments,[\"attack\",\"release\"],t.Follower.defaults);this._abs=new t.Abs,this._filter=this.context.createBiquadFilter(),this._filter.type=\"lowpass\",this._filter.frequency.value=0,this._filter.Q.value=-100,this._frequencyValues=new t.WaveShaper,this._sub=new t.Subtract,this._delay=new t.Delay(this.blockTime),this._mult=new t.Multiply(1e4),this._attack=e.attack,this._release=e.release,this.input.chain(this._abs,this._filter,this.output),this._abs.connect(this._sub,0,1),this._filter.chain(this._delay,this._sub),this._sub.chain(this._mult,this._frequencyValues,this._filter.frequency),this._setAttackRelease(this._attack,this._release)},t.extend(t.Follower),t.Follower.defaults={attack:.05,release:.5},t.Follower.prototype._setAttackRelease=function(e,i){var s=this.blockTime;e=t.Time(e).toFrequency(),i=t.Time(i).toFrequency(),e=Math.max(e,s),i=Math.max(i,s),this._frequencyValues.setMap(function(t){return t<=0?e:i})},Object.defineProperty(t.Follower.prototype,\"attack\",{get:function(){return this._attack},set:function(t){this._attack=t,this._setAttackRelease(this._attack,this._release)}}),Object.defineProperty(t.Follower.prototype,\"release\",{get:function(){return this._release},set:function(t){this._release=t,this._setAttackRelease(this._attack,this._release)}}),t.Follower.prototype.connect=t.Signal.prototype.connect,t.Follower.prototype.dispose=function(){return t.prototype.dispose.call(this),this._filter.disconnect(),this._filter=null,this._frequencyValues.disconnect(),this._frequencyValues=null,this._delay.dispose(),this._delay=null,this._sub.disconnect(),this._sub=null,this._abs.dispose(),this._abs=null,this._mult.dispose(),this._mult=null,this._curve=null,this},t.Follower}),t(function(t){return t.ScaledEnvelope=function(){var e=this.optionsObject(arguments,[\"attack\",\"decay\",\"sustain\",\"release\"],t.Envelope.defaults);t.Envelope.call(this,e),e=this.defaultArg(e,t.ScaledEnvelope.defaults),this._exp=this.output=new t.Pow(e.exponent),this._scale=this.output=new t.Scale(e.min,e.max),this._sig.chain(this._exp,this._scale)},t.extend(t.ScaledEnvelope,t.Envelope),t.ScaledEnvelope.defaults={min:0,max:1,exponent:1},Object.defineProperty(t.ScaledEnvelope.prototype,\"min\",{get:function(){return this._scale.min},set:function(t){this._scale.min=t}}),Object.defineProperty(t.ScaledEnvelope.prototype,\"max\",{get:function(){return this._scale.max},set:function(t){this._scale.max=t}}),Object.defineProperty(t.ScaledEnvelope.prototype,\"exponent\",{get:function(){return this._exp.value},set:function(t){this._exp.value=t}}),t.ScaledEnvelope.prototype.dispose=function(){return t.Envelope.prototype.dispose.call(this),this._scale.dispose(),this._scale=null,this._exp.dispose(),this._exp=null,this},t.ScaledEnvelope}),t(function(t){return t.FrequencyEnvelope=function(){var e=this.optionsObject(arguments,[\"attack\",\"decay\",\"sustain\",\"release\"],t.Envelope.defaults);t.ScaledEnvelope.call(this,e),e=this.defaultArg(e,t.FrequencyEnvelope.defaults),this._octaves=e.octaves,this.baseFrequency=e.baseFrequency,this.octaves=e.octaves},t.extend(t.FrequencyEnvelope,t.Envelope),t.FrequencyEnvelope.defaults={baseFrequency:200,octaves:4,exponent:2},Object.defineProperty(t.FrequencyEnvelope.prototype,\"baseFrequency\",{get:function(){return this._scale.min},set:function(t){this._scale.min=this.toFrequency(t),this.octaves=this._octaves}}),Object.defineProperty(t.FrequencyEnvelope.prototype,\"octaves\",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._scale.max=this.baseFrequency*Math.pow(2,t)}}),Object.defineProperty(t.FrequencyEnvelope.prototype,\"exponent\",{get:function(){return this._exp.value},set:function(t){this._exp.value=t}}),t.FrequencyEnvelope.prototype.dispose=function(){return t.ScaledEnvelope.prototype.dispose.call(this),this},t.FrequencyEnvelope}),t(function(t){return t.Gate=function(){this.createInsOuts(1,1);var e=this.optionsObject(arguments,[\"threshold\",\"attack\",\"release\"],t.Gate.defaults);this._follower=new t.Follower(e.attack,e.release),this._gt=new t.GreaterThan(this.dbToGain(e.threshold)),this.input.connect(this.output),this.input.chain(this._gt,this._follower,this.output.gain)},t.extend(t.Gate),t.Gate.defaults={attack:.1,release:.1,threshold:-40},Object.defineProperty(t.Gate.prototype,\"threshold\",{get:function(){return this.gainToDb(this._gt.value)},set:function(t){this._gt.value=this.dbToGain(t)}}),Object.defineProperty(t.Gate.prototype,\"attack\",{get:function(){return this._follower.attack},set:function(t){this._follower.attack=t}}),Object.defineProperty(t.Gate.prototype,\"release\",{get:function(){return this._follower.release},set:function(t){this._follower.release=t}}),t.Gate.prototype.dispose=function(){return t.prototype.dispose.call(this),this._follower.dispose(),this._gt.dispose(),this._follower=null,this._gt=null,this},t.Gate}),t(function(t){return t.TimelineState=function(e){t.Timeline.call(this),this._initial=e},t.extend(t.TimelineState,t.Timeline),t.TimelineState.prototype.getValueAtTime=function(t){var e=this.get(t);return null!==e?e.state:this._initial},t.TimelineState.prototype.setStateAtTime=function(t,e){this.add({state:t,time:e})},t.TimelineState}),t(function(t){return t.Clock=function(){t.Emitter.call(this);var e=this.optionsObject(arguments,[\"callback\",\"frequency\"],t.Clock.defaults);this.callback=e.callback,this._nextTick=0,this._lastState=t.State.Stopped,this.frequency=new t.TimelineSignal(e.frequency,t.Type.Frequency),this._readOnly(\"frequency\"),this.ticks=0,this._state=new t.TimelineState(t.State.Stopped),this._boundLoop=this._loop.bind(this),this.context.on(\"tick\",this._boundLoop)},t.extend(t.Clock,t.Emitter),t.Clock.defaults={callback:t.noOp,frequency:1,lookAhead:\"auto\"},Object.defineProperty(t.Clock.prototype,\"state\",{get:function(){return this._state.getValueAtTime(this.now())}}),t.Clock.prototype.start=function(e,i){return e=this.toSeconds(e),this._state.getValueAtTime(e)!==t.State.Started&&this._state.add({state:t.State.Started,time:e,offset:i}),this},t.Clock.prototype.stop=function(e){return e=this.toSeconds(e),this._state.cancel(e),this._state.setStateAtTime(t.State.Stopped,e),this},t.Clock.prototype.pause=function(e){return e=this.toSeconds(e),this._state.getValueAtTime(e)===t.State.Started&&this._state.setStateAtTime(t.State.Paused,e),this},t.Clock.prototype._loop=function(){for(var e=this.now(),i=this.context.lookAhead,s=this.context.updateInterval,n=2*this.context.lag,o=e+i+s+n;o>this._nextTick&&this._state;){var r=this._state.getValueAtTime(this._nextTick);if(r!==this._lastState){this._lastState=r;var a=this._state.get(this._nextTick);r===t.State.Started?(this._nextTick=a.time,this.isUndef(a.offset)||(this.ticks=a.offset),this.emit(\"start\",a.time,this.ticks)):r===t.State.Stopped?(this.ticks=0,this.emit(\"stop\",a.time)):r===t.State.Paused&&this.emit(\"pause\",a.time)}var h=this._nextTick;this.frequency&&(this._nextTick+=1/this.frequency.getValueAtTime(this._nextTick),r===t.State.Started&&(this.callback(h),this.ticks++))}},t.Clock.prototype.getStateAtTime=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)},t.Clock.prototype.dispose=function(){t.Emitter.prototype.dispose.call(this),this.context.off(\"tick\",this._boundLoop),this._writable(\"frequency\"),this.frequency.dispose(),this.frequency=null,this._boundLoop=null,this._nextTick=1/0,this.callback=null,this._state.dispose(),this._state=null},t.Clock}),t(function(t){t.IntervalTimeline=function(){this._root=null,this._length=0},t.extend(t.IntervalTimeline),t.IntervalTimeline.prototype.add=function(t){if(this.isUndef(t.time)||this.isUndef(t.duration))throw new Error(\"Tone.IntervalTimeline: events must have time and duration parameters\");var i=new e(t.time,t.time+t.duration,t);for(null===this._root?this._root=i:this._root.insert(i),this._length++;null!==i;)i.updateHeight(),i.updateMax(),this._rebalance(i),i=i.parent;return this},t.IntervalTimeline.prototype.remove=function(t){if(null!==this._root){var e=[];this._root.search(t.time,e);for(var i=0;i<e.length;i++){var s=e[i];if(s.event===t){this._removeNode(s),this._length--;break}}}return this},Object.defineProperty(t.IntervalTimeline.prototype,\"length\",{get:function(){return this._length}}),t.IntervalTimeline.prototype.cancel=function(t){return this.forEachAfter(t,function(t){this.remove(t)}.bind(this)),this},t.IntervalTimeline.prototype._setRoot=function(t){this._root=t,null!==this._root&&(this._root.parent=null)},t.IntervalTimeline.prototype._replaceNodeInParent=function(t,e){null!==t.parent?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)},t.IntervalTimeline.prototype._removeNode=function(t){if(null===t.left&&null===t.right)this._replaceNodeInParent(t,null);else if(null===t.right)this._replaceNodeInParent(t,t.left);else if(null===t.left)this._replaceNodeInParent(t,t.right);else{var e,i,s=t.getBalance();if(s>0)if(null===t.left.right)e=t.left,e.right=t.right,i=e;else{for(e=t.left.right;null!==e.right;)e=e.right;e.parent.right=e.left,i=e.parent,e.left=t.left,e.right=t.right}else if(null===t.right.left)e=t.right,e.left=t.left,i=e;else{for(e=t.right.left;null!==e.left;)e=e.left;e.parent=e.parent,e.parent.left=e.right,i=e.parent,e.left=t.left,e.right=t.right}null!==t.parent?t.isLeftChild()?t.parent.left=e:t.parent.right=e:this._setRoot(e),this._rebalance(i)}t.dispose()},t.IntervalTimeline.prototype._rotateLeft=function(t){var e=t.parent,i=t.isLeftChild(),s=t.right;t.right=s.left,s.left=t,null!==e?i?e.left=s:e.right=s:this._setRoot(s)},t.IntervalTimeline.prototype._rotateRight=function(t){var e=t.parent,i=t.isLeftChild(),s=t.left;t.left=s.right,s.right=t,null!==e?i?e.left=s:e.right=s:this._setRoot(s)},t.IntervalTimeline.prototype._rebalance=function(t){var e=t.getBalance();e>1?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))},t.IntervalTimeline.prototype.get=function(t){if(null!==this._root){var e=[];if(this._root.search(t,e),e.length>0){for(var i=e[0],s=1;s<e.length;s++)e[s].low>i.low&&(i=e[s]);return i.event}}return null},t.IntervalTimeline.prototype.forEach=function(t){if(null!==this._root){var e=[];null!==this._root&&this._root.traverse(function(t){e.push(t)});for(var i=0;i<e.length;i++){var s=e[i].event;s&&t(s)}}return this},t.IntervalTimeline.prototype.forEachAtTime=function(t,e){if(null!==this._root){var i=[];this._root.search(t,i);for(var s=i.length-1;s>=0;s--){var n=i[s].event;n&&e(n)}}return this},t.IntervalTimeline.prototype.forEachAfter=function(t,e){if(null!==this._root){var i=[];this._root.searchAfter(t,i);for(var s=i.length-1;s>=0;s--){var n=i[s].event;n&&e(n)}}return this},t.IntervalTimeline.prototype.dispose=function(){var t=[];null!==this._root&&this._root.traverse(function(e){t.push(e)});for(var e=0;e<t.length;e++)t[e].dispose();return t=null,this._root=null,this};var e=function(t,e,i){this.event=i,this.low=t,this.high=e,this.max=this.high,this._left=null,this._right=null,this.parent=null,this.height=0};return e.prototype.insert=function(t){t.low<=this.low?null===this.left?this.left=t:this.left.insert(t):null===this.right?this.right=t:this.right.insert(t)},e.prototype.search=function(t,e){t>this.max||(null!==this.left&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),this.low>t||null!==this.right&&this.right.search(t,e))},e.prototype.searchAfter=function(t,e){this.low>=t&&(e.push(this),null!==this.left&&this.left.searchAfter(t,e)),null!==this.right&&this.right.searchAfter(t,e)},e.prototype.traverse=function(t){t(this),null!==this.left&&this.left.traverse(t),null!==this.right&&this.right.traverse(t)},e.prototype.updateHeight=function(){null!==this.left&&null!==this.right?this.height=Math.max(this.left.height,this.right.height)+1:null!==this.right?this.height=this.right.height+1:null!==this.left?this.height=this.left.height+1:this.height=0},e.prototype.updateMax=function(){this.max=this.high,null!==this.left&&(this.max=Math.max(this.max,this.left.max)),null!==this.right&&(this.max=Math.max(this.max,this.right.max))},e.prototype.getBalance=function(){var t=0;return null!==this.left&&null!==this.right?t=this.left.height-this.right.height:null!==this.left?t=this.left.height+1:null!==this.right&&(t=-(this.right.height+1)),t},e.prototype.isLeftChild=function(){return null!==this.parent&&this.parent.left===this},Object.defineProperty(e.prototype,\"left\",{get:function(){return this._left},set:function(t){this._left=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}}),Object.defineProperty(e.prototype,\"right\",{get:function(){return this._right},set:function(t){this._right=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}}),e.prototype.dispose=function(){this.parent=null,this._left=null,this._right=null,this.event=null},t.IntervalTimeline}),t(function(t){t.Transport=function(){t.Emitter.call(this),this.loop=!1,this._loopStart=0,this._loopEnd=0,this._ppq=e.defaults.PPQ,this._clock=new t.Clock({callback:this._processTick.bind(this),frequency:0}),this._bindClockEvents(),this.bpm=this._clock.frequency,this.bpm._toUnits=this._toUnits.bind(this),this.bpm._fromUnits=this._fromUnits.bind(this),this.bpm.units=t.Type.BPM,this.bpm.value=e.defaults.bpm,this._readOnly(\"bpm\"),this._timeSignature=e.defaults.timeSignature,this._scheduledEvents={},this._eventID=0,this._timeline=new t.Timeline,this._repeatedEvents=new t.IntervalTimeline,this._onceEvents=new t.Timeline,this._syncedSignals=[],this._swingTicks=e.defaults.PPQ/2,this._swingAmount=0},t.extend(t.Transport,t.Emitter),t.Transport.defaults={bpm:120,swing:0,swingSubdivision:\"8n\",timeSignature:4,loopStart:0,loopEnd:\"4m\",PPQ:192},t.Transport.prototype._processTick=function(e){var i=this._clock.ticks;if(this._swingAmount>0&&i%this._ppq!=0&&i%(2*this._swingTicks)!=0){var s=i%(2*this._swingTicks)/(2*this._swingTicks),n=Math.sin(s*Math.PI)*this._swingAmount;e+=t.Time(2*this._swingTicks/3,\"i\")*n}this.loop&&i===this._loopEnd&&(this.emit(\"loopEnd\",e),this._clock.ticks=this._loopStart,i=this._loopStart,this.emit(\"loopStart\",e,this.seconds),this.emit(\"loop\",e)),this._onceEvents.forEachBefore(i,function(t){t.callback(e),delete this._scheduledEvents[t.id.toString()]}.bind(this)),this._onceEvents.cancelBefore(i),this._timeline.forEachAtTime(i,function(t){t.callback(e)}),this._repeatedEvents.forEachAtTime(i,function(t){(i-t.time)%t.interval==0&&t.callback(e)})},t.Transport.prototype.schedule=function(t,e){var i={time:this.toTicks(e),callback:t},s=this._eventID++;return this._scheduledEvents[s.toString()]={event:i,timeline:this._timeline},this._timeline.add(i),s},t.Transport.prototype.scheduleRepeat=function(t,e,i,s){if(e<=0)throw new Error(\"Tone.Transport: repeat events must have an interval larger than 0\");var n={time:this.toTicks(i),duration:this.toTicks(this.defaultArg(s,1/0)),interval:this.toTicks(e),callback:t},o=this._eventID++;return this._scheduledEvents[o.toString()]={event:n,timeline:this._repeatedEvents},this._repeatedEvents.add(n),o},t.Transport.prototype.scheduleOnce=function(t,e){var i=this._eventID++,s={time:this.toTicks(e),callback:t,id:i};return this._scheduledEvents[i.toString()]={event:s,timeline:this._onceEvents},this._onceEvents.add(s),i},t.Transport.prototype.clear=function(t){if(this._scheduledEvents.hasOwnProperty(t)){var e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),delete this._scheduledEvents[t.toString()]}return this},t.Transport.prototype.cancel=function(t){return t=this.defaultArg(t,0),t=this.toTicks(t),this._timeline.cancel(t),this._onceEvents.cancel(t),this._repeatedEvents.cancel(t),this},t.Transport.prototype._bindClockEvents=function(){this._clock.on(\"start\",function(e,i){i=t.Time(this._clock.ticks,\"i\").toSeconds(),this.emit(\"start\",e,i)}.bind(this)),this._clock.on(\"stop\",function(t){this.emit(\"stop\",t)}.bind(this)),this._clock.on(\"pause\",function(t){this.emit(\"pause\",t)}.bind(this))},Object.defineProperty(t.Transport.prototype,\"state\",{get:function(){return this._clock.getStateAtTime(this.now())}}),t.Transport.prototype.start=function(t,e){return this.isUndef(e)||(e=this.toTicks(e)),this._clock.start(t,e),this},t.Transport.prototype.stop=function(t){return this._clock.stop(t),this},t.Transport.prototype.pause=function(t){return this._clock.pause(t),this},Object.defineProperty(t.Transport.prototype,\"timeSignature\",{get:function(){return this._timeSignature},set:function(t){this.isArray(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}}),Object.defineProperty(t.Transport.prototype,\"loopStart\",{get:function(){return t.TransportTime(this._loopStart,\"i\").toSeconds()},set:function(t){this._loopStart=this.toTicks(t)}}),Object.defineProperty(t.Transport.prototype,\"loopEnd\",{get:function(){return t.TransportTime(this._loopEnd,\"i\").toSeconds()},set:function(t){this._loopEnd=this.toTicks(t)}}),t.Transport.prototype.setLoopPoints=function(t,e){return this.loopStart=t,this.loopEnd=e,this},Object.defineProperty(t.Transport.prototype,\"swing\",{get:function(){return this._swingAmount},set:function(t){this._swingAmount=t}}),Object.defineProperty(t.Transport.prototype,\"swingSubdivision\",{get:function(){return t.Time(this._swingTicks,\"i\").toNotation()},set:function(t){this._swingTicks=this.toTicks(t)}}),Object.defineProperty(t.Transport.prototype,\"position\",{get:function(){return t.TransportTime(this.ticks,\"i\").toBarsBeatsSixteenths()},set:function(t){var e=this.toTicks(t);this.ticks=e}}),Object.defineProperty(t.Transport.prototype,\"seconds\",{get:function(){return t.TransportTime(this.ticks,\"i\").toSeconds()},set:function(t){var e=this.toTicks(t);this.ticks=e}}),Object.defineProperty(t.Transport.prototype,\"progress\",{get:function(){return this.loop?(this.ticks-this._loopStart)/(this._loopEnd-this._loopStart):0}}),Object.defineProperty(t.Transport.prototype,\"ticks\",{get:function(){return this._clock.ticks},set:function(e){if(this._clock.ticks!==e){var i=this.now();this.state===t.State.Started?(this.emit(\"stop\",i),this._clock.ticks=e,this.emit(\"start\",i,this.seconds)):this._clock.ticks=e}}}),Object.defineProperty(t.Transport.prototype,\"PPQ\",{get:function(){return this._ppq},set:function(t){var e=this.bpm.value;this._ppq=t,this.bpm.value=e}}),Object.defineProperty(t.Transport.prototype,\"latencyHint\",{get:function(){return t.Clock.latencyHint},set:function(e){t.Clock.latencyHint=e}}),t.Transport.prototype._fromUnits=function(t){return 1/(60/t/this.PPQ)},t.Transport.prototype._toUnits=function(t){return t/this.PPQ*60},t.Transport.prototype.nextSubdivision=function(e){e=this.toSeconds(e);var i;if(this.state!==t.State.Started)return 0;i=this._clock._nextTick;var s=t.Time(this.ticks,\"i\"),n=e-s%e;return 0===n&&(n=e),i+n},t.Transport.prototype.syncSignal=function(e,i){i||(i=0!==e._param.value?e._param.value/this.bpm._param.value:0);var s=new t.Gain(i);return this.bpm.chain(s,e._param),this._syncedSignals.push({ratio:s,signal:e,initial:e._param.value}),e._param.value=0,this},t.Transport.prototype.unsyncSignal=function(t){for(var e=this._syncedSignals.length-1;e>=0;e--){var i=this._syncedSignals[e];i.signal===t&&(i.ratio.dispose(),i.signal._param.value=i.initial,this._syncedSignals.splice(e,1))}return this},t.Transport.prototype.dispose=function(){return t.Emitter.prototype.dispose.call(this),this._clock.dispose(),this._clock=null,this._writable(\"bpm\"),this.bpm=null,this._timeline.dispose(),this._timeline=null,this._onceEvents.dispose(),this._onceEvents=null,this._repeatedEvents.dispose(),this._repeatedEvents=null,this};var e=t.Transport;return t.Transport=new e,t.Context.on(\"init\",function(i){i.Transport instanceof e?t.Transport=i.Transport:(t.Transport=new e,i.Transport=t.Transport)}),t.Transport}),t(function(t){return t.Volume=function(){var e=this.optionsObject(arguments,[\"volume\"],t.Volume.defaults);this.output=this.input=new t.Gain(e.volume,t.Type.Decibels),this._unmutedVolume=e.volume,this.volume=this.output.gain,this._readOnly(\"volume\"),this.mute=e.mute},t.extend(t.Volume),t.Volume.defaults={volume:0,mute:!1},Object.defineProperty(t.Volume.prototype,\"mute\",{get:function(){return this.volume.value===-1/0},set:function(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}}),t.Volume.prototype.dispose=function(){return this.input.dispose(),t.prototype.dispose.call(this),this._writable(\"volume\"),this.volume.dispose(),this.volume=null,this},t.Volume}),t(function(t){t.Master=function(){this.createInsOuts(1,1),this._volume=this.output=new t.Volume,this.volume=this._volume.volume,this._readOnly(\"volume\"),this.input.chain(this.output,this.context.destination)},t.extend(t.Master),t.Master.defaults={volume:0,mute:!1},Object.defineProperty(t.Master.prototype,\"mute\",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),t.Master.prototype.chain=function(){this.input.disconnect(),this.input.chain.apply(this.input,arguments),arguments[arguments.length-1].connect(this.output)},t.Master.prototype.dispose=function(){t.prototype.dispose.call(this),this._writable(\"volume\"),this._volume.dispose(),this._volume=null,this.volume=null},t.prototype.toMaster=function(){return this.connect(t.Master),this},AudioNode.prototype.toMaster=function(){return this.connect(t.Master),this};var e=t.Master;return t.Master=new e,t.Context.on(\"init\",function(i){i.Master instanceof e?t.Master=i.Master:t.Master=new e,i.Master=t.Master}),t.Master}),t(function(t){return t.Source=function(e){e=this.defaultArg(e,t.Source.defaults),this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._readOnly(\"volume\"),this._state=new t.TimelineState(t.State.Stopped),this._state.memory=10,this._synced=!1,this._scheduled=[],this._volume.output.output.channelCount=2,this._volume.output.output.channelCountMode=\"explicit\",this.mute=e.mute},t.extend(t.Source),t.Source.defaults={volume:0,mute:!1},Object.defineProperty(t.Source.prototype,\"state\",{get:function(){return this._synced?t.Transport.state===t.State.Started?this._state.getValueAtTime(t.Transport.seconds):t.State.Stopped:this._state.getValueAtTime(this.now())}}),Object.defineProperty(t.Source.prototype,\"mute\",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),t.Source.prototype._start=t.noOp,t.Source.prototype._stop=t.noOp,t.Source.prototype.start=function(e,i,s){if(e=this.isUndef(e)&&this._synced?t.Transport.seconds:this.toSeconds(e),this.retrigger||this._state.getValueAtTime(e)!==t.State.Started||this.stop(e),this._state.setStateAtTime(t.State.Started,e),this._synced){var n=this._state.get(e);n.offset=this.defaultArg(i,0),n.duration=s;var o=t.Transport.schedule(function(t){this._start(t,i,s)}.bind(this),e);this._scheduled.push(o)}else this._start.apply(this,arguments);return this},t.Source.prototype.stop=function(e){if(e=this.isUndef(e)&&this._synced?t.Transport.seconds:this.toSeconds(e),this._state.cancel(e),this._state.setStateAtTime(t.State.Stopped,e),this._synced){var i=t.Transport.schedule(this._stop.bind(this),e);this._scheduled.push(i)}else this._stop.apply(this,arguments);return this},t.Source.prototype.sync=function(){return this._synced=!0,t.Transport.on(\"start loopStart\",function(e,i){if(i>0){var s=this._state.get(i);if(s&&s.state===t.State.Started&&s.time!==i){var n,o=i-this.toSeconds(s.time);s.duration&&(n=this.toSeconds(s.duration)-o),this._start(e,this.toSeconds(s.offset)+o,n)}}}.bind(this)),t.Transport.on(\"stop pause loopEnd\",function(e){this._state.getValueAtTime(t.Transport.seconds)===t.State.Started&&this._stop(e)}.bind(this)),this},t.Source.prototype.unsync=function(){this._synced=!1,t.Transport.off(\"start stop pause loopEnd loopStart\");for(var e=0;e<this._scheduled.length;e++){var i=this._scheduled[e];t.Transport.clear(i)}return this._scheduled=[],this._state.cancel(0),this},t.Source.prototype.dispose=function(){t.prototype.dispose.call(this),this.unsync(),this._scheduled=null,this._writable(\"volume\"),this._volume.dispose(),this._volume=null,this.volume=null,this._state.dispose(),this._state=null},t.Source}),t(function(t){return window.OscillatorNode&&!OscillatorNode.prototype.start&&(OscillatorNode.prototype.start=OscillatorNode.prototype.noteOn,OscillatorNode.prototype.stop=OscillatorNode.prototype.noteOff,OscillatorNode.prototype.setPeriodicWave||(OscillatorNode.prototype.setPeriodicWave=OscillatorNode.prototype.setWaveTable),AudioContext.prototype.createPeriodicWave||(AudioContext.prototype.createPeriodicWave=AudioContext.prototype.createWaveTable)),t.Oscillator=function(){var e=this.optionsObject(arguments,[\"frequency\",\"type\"],t.Oscillator.defaults);t.Source.call(this,e),this._oscillator=null,this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this._wave=null,this._partials=this.defaultArg(e.partials,[1]),this._phase=e.phase,this._type=null,this.type=e.type,this.phase=this._phase,this._readOnly([\"frequency\",\"detune\"])},t.extend(t.Oscillator,t.Source),t.Oscillator.defaults={type:\"sine\",frequency:440,detune:0,phase:0,partials:[]},t.Oscillator.Type={Sine:\"sine\",Triangle:\"triangle\",Sawtooth:\"sawtooth\",Square:\"square\",Custom:\"custom\"},t.Oscillator.prototype._start=function(t){this._oscillator=this.context.createOscillator(),this._oscillator.setPeriodicWave(this._wave),this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(this.toSeconds(t))},t.Oscillator.prototype._stop=function(t){return this._oscillator&&(this._oscillator.stop(this.toSeconds(t)),this._oscillator=null),this},t.Oscillator.prototype.syncFrequency=function(){return t.Transport.syncSignal(this.frequency),this},t.Oscillator.prototype.unsyncFrequency=function(){return t.Transport.unsyncSignal(this.frequency),this},Object.defineProperty(t.Oscillator.prototype,\"type\",{get:function(){return this._type},set:function(t){var e=this._getRealImaginary(t,this._phase),i=this.context.createPeriodicWave(e[0],e[1]);this._wave=i,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave),this._type=t}}),t.Oscillator.prototype._getRealImaginary=function(e,i){var s=2048,n=new Float32Array(s),o=new Float32Array(s),r=1;if(e===t.Oscillator.Type.Custom)r=this._partials.length+1,s=r;else{var a=/^(sine|triangle|square|sawtooth)(\\d+)$/.exec(e);a&&(r=parseInt(a[2])+1,e=a[1],r=Math.max(r,2),s=r)}for(var h=1;h<s;++h){var l,c=2/(h*Math.PI);switch(e){case t.Oscillator.Type.Sine:l=h<=r?1:0;break;case t.Oscillator.Type.Square:l=1&h?2*c:0;break;case t.Oscillator.Type.Sawtooth:l=c*(1&h?1:-1);break;case t.Oscillator.Type.Triangle:l=1&h?c*c*2*(h-1>>1&1?-1:1):0;break;case t.Oscillator.Type.Custom:l=this._partials[h-1];break;default:throw new TypeError(\"Tone.Oscillator: invalid type: \"+e)}0!==l?(n[h]=-l*Math.sin(i*h),o[h]=l*Math.cos(i*h)):(n[h]=0,o[h]=0)}return[n,o]},t.Oscillator.prototype._inverseFFT=function(t,e,i){for(var s=0,n=t.length,o=0;o<n;o++)s+=t[o]*Math.cos(o*i)+e[o]*Math.sin(o*i);return s},t.Oscillator.prototype._getInitialValue=function(){for(var t=this._getRealImaginary(this._type,0),e=t[0],i=t[1],s=0,n=2*Math.PI,o=0;o<8;o++)s=Math.max(this._inverseFFT(e,i,o/8*n),s);return-this._inverseFFT(e,i,this._phase)/s},Object.defineProperty(t.Oscillator.prototype,\"partials\",{get:function(){return this._type!==t.Oscillator.Type.Custom?[]:this._partials},set:function(e){this._partials=e,this.type=t.Oscillator.Type.Custom}}),Object.defineProperty(t.Oscillator.prototype,\"phase\",{get:function(){return this._phase*(180/Math.PI)},set:function(t){this._phase=t*Math.PI/180,this.type=this._type}}),t.Oscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),null!==this._oscillator&&(this._oscillator.disconnect(),this._oscillator=null),this._wave=null,this._writable([\"frequency\",\"detune\"]),this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this._partials=null,this},t.Oscillator}),t(function(t){return t.Zero=function(){this._gain=this.input=this.output=new t.Gain,this.context.getConstant(0).connect(this._gain)},t.extend(t.Zero),t.Zero.prototype.dispose=function(){return t.prototype.dispose.call(this),this._gain.dispose(),this._gain=null,this},t.Zero}),t(function(t){return t.LFO=function(){var e=this.optionsObject(arguments,[\"frequency\",\"min\",\"max\"],t.LFO.defaults);this._oscillator=new t.Oscillator({frequency:e.frequency,type:e.type}),this.frequency=this._oscillator.frequency,this.amplitude=this._oscillator.volume,this.amplitude.units=t.Type.NormalRange,this.amplitude.value=e.amplitude,this._stoppedSignal=new t.Signal(0,t.Type.AudioRange),this._zeros=new t.Zero,this._stoppedValue=0,this._a2g=new t.AudioToGain,this._scaler=this.output=new t.Scale(e.min,e.max),this._units=t.Type.Default,this.units=e.units,this._oscillator.chain(this._a2g,this._scaler),this._zeros.connect(this._a2g),this._stoppedSignal.connect(this._a2g),this._readOnly([\"amplitude\",\"frequency\"]),this.phase=e.phase},t.extend(t.LFO,t.Oscillator),t.LFO.defaults={type:\"sine\",min:0,max:1,phase:0,frequency:\"4n\",amplitude:1,units:t.Type.Default},t.LFO.prototype.start=function(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(0,t),this._oscillator.start(t),this},t.LFO.prototype.stop=function(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(this._stoppedValue,t),this._oscillator.stop(t),this},t.LFO.prototype.sync=function(){return this._oscillator.sync(),this._oscillator.syncFrequency(),this},t.LFO.prototype.unsync=function(){return this._oscillator.unsync(),this._oscillator.unsyncFrequency(),this},Object.defineProperty(t.LFO.prototype,\"min\",{get:function(){return this._toUnits(this._scaler.min)},set:function(t){t=this._fromUnits(t),this._scaler.min=t}}),Object.defineProperty(t.LFO.prototype,\"max\",{get:function(){return this._toUnits(this._scaler.max)},set:function(t){t=this._fromUnits(t),this._scaler.max=t}}),Object.defineProperty(t.LFO.prototype,\"type\",{get:function(){return this._oscillator.type},set:function(t){this._oscillator.type=t,this._stoppedValue=this._oscillator._getInitialValue(),this._stoppedSignal.value=this._stoppedValue}}),Object.defineProperty(t.LFO.prototype,\"phase\",{get:function(){return this._oscillator.phase},set:function(t){this._oscillator.phase=t,this._stoppedValue=this._oscillator._getInitialValue(),this._stoppedSignal.value=this._stoppedValue}}),Object.defineProperty(t.LFO.prototype,\"units\",{get:function(){return this._units},set:function(t){var e=this.min,i=this.max;this._units=t,this.min=e,this.max=i}}),Object.defineProperty(t.LFO.prototype,\"mute\",{get:function(){return this._oscillator.mute},set:function(t){this._oscillator.mute=t}}),Object.defineProperty(t.LFO.prototype,\"state\",{get:function(){return this._oscillator.state}}),t.LFO.prototype.connect=function(e){return e.constructor!==t.Signal&&e.constructor!==t.Param&&e.constructor!==t.TimelineSignal||(this.convert=e.convert,this.units=e.units),t.Signal.prototype.connect.apply(this,arguments),this},t.LFO.prototype._fromUnits=t.Param.prototype._fromUnits,t.LFO.prototype._toUnits=t.Param.prototype._toUnits,t.LFO.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable([\"amplitude\",\"frequency\"]),this._oscillator.dispose(),this._oscillator=null,this._stoppedSignal.dispose(),this._stoppedSignal=null,this._zeros.dispose(),this._zeros=null,this._scaler.dispose(),this._scaler=null,this._a2g.dispose(),this._a2g=null,this.frequency=null,this.amplitude=null,this},t.LFO}),t(function(t){return t.Limiter=function(){var e=this.optionsObject(arguments,[\"threshold\"],t.Limiter.defaults);this._compressor=this.input=this.output=new t.Compressor({attack:.001,decay:.001,threshold:e.threshold}),this.threshold=this._compressor.threshold,this._readOnly(\"threshold\")},t.extend(t.Limiter),t.Limiter.defaults={threshold:-12},t.Limiter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._compressor.dispose(),this._compressor=null,this._writable(\"threshold\"),this.threshold=null,this},t.Limiter}),t(function(t){return t.LowpassCombFilter=function(){this.createInsOuts(1,1);var e=this.optionsObject(arguments,[\"delayTime\",\"resonance\",\"dampening\"],t.LowpassCombFilter.defaults);this._delay=this.input=new t.Delay(e.delayTime),this.delayTime=this._delay.delayTime,this._lowpass=this.output=this.context.createBiquadFilter(),this._lowpass.Q.value=-3.0102999566398125,this._lowpass.type=\"lowpass\",this.dampening=new t.Param({param:this._lowpass.frequency,units:t.Type.Frequency,value:e.dampening}),this._feedback=new t.Gain(e.resonance,t.Type.NormalRange),this.resonance=this._feedback.gain,this._delay.chain(this._lowpass,this._feedback,this._delay),this._readOnly([\"dampening\",\"resonance\",\"delayTime\"])},t.extend(t.LowpassCombFilter),t.LowpassCombFilter.defaults={delayTime:.1,resonance:.5,dampening:3e3},t.LowpassCombFilter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable([\"dampening\",\"resonance\",\"delayTime\"]),this.dampening.dispose(),this.dampening=null,this.resonance.dispose(),this.resonance=null,this._delay.dispose(),this._delay=null,this.delayTime=null,this._lowpass.disconnect(),this._lowpass=null,this._feedback.disconnect(),this._feedback=null,this},t.LowpassCombFilter}),t(function(t){return t.Merge=function(){this.createInsOuts(2,0),this.left=this.input[0]=new t.Gain,this.right=this.input[1]=new t.Gain,this._merger=this.output=this.context.createChannelMerger(2),this.left.connect(this._merger,0,0),this.right.connect(this._merger,0,1),this.left.channelCount=1,this.right.channelCount=1,this.left.channelCountMode=\"explicit\",this.right.channelCountMode=\"explicit\"},t.extend(t.Merge),t.Merge.prototype.dispose=function(){return t.prototype.dispose.call(this),this.left.dispose(),this.left=null,this.right.dispose(),this.right=null,this._merger.disconnect(),this._merger=null,this},t.Merge}),t(function(t){return t.Meter=function(){var e=this.optionsObject(arguments,[\"type\",\"smoothing\"],t.Meter.defaults);this.type=e.type,this.input=this.output=this._analyser=new t.Analyser(\"waveform\",512),this._analyser.returnType=\"float\",this.smoothing=e.smoothing,this._lastValue=0},t.extend(t.Meter),t.Meter.Type={Level:\"level\",Signal:\"signal\"},t.Meter.defaults={smoothing:.8,type:t.Meter.Type.Level},Object.defineProperty(t.Meter.prototype,\"value\",{get:function(){var e=this._analyser.analyse();if(this.type===t.Meter.Type.Level){for(var i=0,s=0;s<e.length;s++)i+=Math.pow(e[s],2);var n=Math.sqrt(i/e.length);n=Math.max(n,this._lastValue*this.smoothing),this._lastValue=n;var o=n/.35;return Math.sqrt(o)}return e[0]}}),t.Meter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._analyser.dispose(),this._analyser=null,this},t.Meter}),t(function(t){return t.Split=function(){this.createInsOuts(0,2),this._splitter=this.input=this.context.createChannelSplitter(2),this.left=this.output[0]=new t.Gain,this.right=this.output[1]=new t.Gain,this._splitter.connect(this.left,0,0),this._splitter.connect(this.right,1,0)},t.extend(t.Split),t.Split.prototype.dispose=function(){return t.prototype.dispose.call(this),this._splitter.disconnect(),this.left.dispose(),this.left=null,this.right.dispose(),this.right=null,this._splitter=null,this},t.Split}),t(function(t){return t.MidSideSplit=function(){this.createInsOuts(0,2),this._split=this.input=new t.Split,this.mid=this.output[0]=new t.Expr(\"($0 + $1) * $2\"),this.side=this.output[1]=new t.Expr(\"($0 - $1) * $2\"),this._split.connect(this.mid,0,0),this._split.connect(this.mid,1,1),this._split.connect(this.side,0,0),this._split.connect(this.side,1,1),this.context.getConstant(Math.SQRT1_2).connect(this.mid,0,2),this.context.getConstant(Math.SQRT1_2).connect(this.side,0,2)},t.extend(t.MidSideSplit),t.MidSideSplit.prototype.dispose=function(){return t.prototype.dispose.call(this),this.mid.dispose(),this.mid=null,this.side.dispose(),this.side=null,this._split.dispose(),this._split=null,this},t.MidSideSplit}),t(function(t){return t.MidSideMerge=function(){this.createInsOuts(2,0),this.mid=this.input[0]=new t.Gain,this._left=new t.Expr(\"($0 + $1) * $2\"),this.side=this.input[1]=new t.Gain,this._right=new t.Expr(\"($0 - $1) * $2\"),this._merge=this.output=new t.Merge,this.mid.connect(this._left,0,0),this.side.connect(this._left,0,1),this.mid.connect(this._right,0,0),this.side.connect(this._right,0,1),this._left.connect(this._merge,0,0),this._right.connect(this._merge,0,1),this.context.getConstant(Math.SQRT1_2).connect(this._left,0,2),this.context.getConstant(Math.SQRT1_2).connect(this._right,0,2)},t.extend(t.MidSideMerge),t.MidSideMerge.prototype.dispose=function(){return t.prototype.dispose.call(this),this.mid.dispose(),this.mid=null,this.side.dispose(),this.side=null,this._left.dispose(),this._left=null,this._right.dispose(),this._right=null,this._merge.dispose(),this._merge=null,this},t.MidSideMerge}),t(function(t){return t.MidSideCompressor=function(e){e=this.defaultArg(e,t.MidSideCompressor.defaults),this._midSideSplit=this.input=new t.MidSideSplit,this._midSideMerge=this.output=new t.MidSideMerge,this.mid=new t.Compressor(e.mid),this.side=new t.Compressor(e.side),this._midSideSplit.mid.chain(this.mid,this._midSideMerge.mid),this._midSideSplit.side.chain(this.side,this._midSideMerge.side),this._readOnly([\"mid\",\"side\"])},t.extend(t.MidSideCompressor),t.MidSideCompressor.defaults={mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},side:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10}},t.MidSideCompressor.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable([\"mid\",\"side\"]),this.mid.dispose(),this.mid=null,this.side.dispose(),this.side=null,this._midSideSplit.dispose(),this._midSideSplit=null,this._midSideMerge.dispose(),this._midSideMerge=null,this},t.MidSideCompressor}),t(function(t){return t.Mono=function(){this.createInsOuts(1,0),this._merge=this.output=new t.Merge,this.input.connect(this._merge,0,0),this.input.connect(this._merge,0,1),this.input.gain.value=this.dbToGain(-10)},t.extend(t.Mono),t.Mono.prototype.dispose=function(){return t.prototype.dispose.call(this),this._merge.dispose(),this._merge=null,this},t.Mono}),t(function(t){return t.MultibandCompressor=function(e){e=this.defaultArg(arguments,t.MultibandCompressor.defaults),this._splitter=this.input=new t.MultibandSplit({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency}),this.lowFrequency=this._splitter.lowFrequency,this.highFrequency=this._splitter.highFrequency,this.output=new t.Gain,this.low=new t.Compressor(e.low),this.mid=new t.Compressor(e.mid),this.high=new t.Compressor(e.high),this._splitter.low.chain(this.low,this.output),this._splitter.mid.chain(this.mid,this.output),this._splitter.high.chain(this.high,this.output),this._readOnly([\"high\",\"mid\",\"low\",\"highFrequency\",\"lowFrequency\"])},t.extend(t.MultibandCompressor),t.MultibandCompressor.defaults={low:t.Compressor.defaults,mid:t.Compressor.defaults,high:t.Compressor.defaults,lowFrequency:250,highFrequency:2e3},t.MultibandCompressor.prototype.dispose=function(){return t.prototype.dispose.call(this),this._splitter.dispose(),this._writable([\"high\",\"mid\",\"low\",\"highFrequency\",\"lowFrequency\"]),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this._splitter=null,this.low=null,this.mid=null,this.high=null,this.lowFrequency=null,this.highFrequency=null,this},t.MultibandCompressor}),t(function(t){return t.Panner=function(e){this._hasStereoPanner?(this._panner=this.input=this.output=this.context.createStereoPanner(),this.pan=this._panner.pan):(this._crossFade=new t.CrossFade,this._merger=this.output=new t.Merge,this._splitter=this.input=new t.Split,this.pan=new t.Signal(0,t.Type.AudioRange),this._zero=new t.Zero,this._a2g=new t.AudioToGain,this._zero.connect(this._a2g),this.pan.chain(this._a2g,this._crossFade.fade),this._splitter.connect(this._crossFade,0,0),this._splitter.connect(this._crossFade,1,1),this._crossFade.a.connect(this._merger,0,0),this._crossFade.b.connect(this._merger,0,1)),this.pan.value=this.defaultArg(e,0),this._readOnly(\"pan\")},t.extend(t.Panner),t.Panner.prototype._hasStereoPanner=t.prototype.isFunction(t.context.createStereoPanner),t.Panner.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable(\"pan\"),this._hasStereoPanner?(this._panner.disconnect(),this._panner=null,this.pan=null):(this._zero.dispose(),this._zero=null,this._crossFade.dispose(),this._crossFade=null,this._splitter.dispose(),this._splitter=null,this._merger.dispose(),this._merger=null,this.pan.dispose(),this.pan=null,this._a2g.dispose(),this._a2g=null),this},t.Panner}),t(function(t){return t.Panner3D=function(){var e=this.optionsObject(arguments,[\"positionX\",\"positionY\",\"positionZ\"],t.Panner3D.defaults);this._panner=this.input=this.output=this.context.createPanner(),this._panner.panningModel=e.panningModel,this._panner.maxDistance=e.maxDistance,this._panner.distanceModel=e.distanceModel,this._panner.coneOuterGain=e.coneOuterGain,this._panner.coneOuterAngle=e.coneOuterAngle,this._panner.coneInnerAngle=e.coneInnerAngle,this._panner.refDistance=e.refDistance,this._panner.rolloffFactor=e.rolloffFactor,this._orientation=[e.orientationX,e.orientationY,e.orientationZ],this._position=[e.positionX,e.positionY,e.positionZ],this.orientationX=e.orientationX,this.orientationY=e.orientationY,this.orientationZ=e.orientationZ,this.positionX=e.positionX,this.positionY=e.positionY,this.positionZ=e.positionZ},t.extend(t.Panner3D),t.Panner3D.defaults={positionX:0,positionY:0,positionZ:0,orientationX:0,orientationY:0,orientationZ:0,panningModel:\"equalpower\",maxDistance:1e4,distanceModel:\"inverse\",coneOuterGain:0,coneOuterAngle:360,coneInnerAngle:360,refDistance:1,rolloffFactor:1},t.Panner3D.prototype._rampTimeConstant=.01,t.Panner3D.prototype.setPosition=function(t,e,i){if(this._panner.positionX){var s=this.now();this._panner.positionX.setTargetAtTime(t,s,this._rampTimeConstant),this._panner.positionY.setTargetAtTime(e,s,this._rampTimeConstant),this._panner.positionZ.setTargetAtTime(i,s,this._rampTimeConstant)}else this._panner.setPosition(t,e,i);return this._position=Array.prototype.slice.call(arguments),this},t.Panner3D.prototype.setOrientation=function(t,e,i){if(this._panner.orientationX){var s=this.now();this._panner.orientationX.setTargetAtTime(t,s,this._rampTimeConstant),this._panner.orientationY.setTargetAtTime(e,s,this._rampTimeConstant),this._panner.orientationZ.setTargetAtTime(i,s,this._rampTimeConstant)}else this._panner.setOrientation(t,e,i);return this._orientation=Array.prototype.slice.call(arguments),this},Object.defineProperty(t.Panner3D.prototype,\"positionX\",{set:function(t){this._position[0]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[0]}}),Object.defineProperty(t.Panner3D.prototype,\"positionY\",{set:function(t){this._position[1]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[1]}}),Object.defineProperty(t.Panner3D.prototype,\"positionZ\",{set:function(t){this._position[2]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[2]}}),Object.defineProperty(t.Panner3D.prototype,\"orientationX\",{set:function(t){this._orientation[0]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[0]}}),Object.defineProperty(t.Panner3D.prototype,\"orientationY\",{set:function(t){this._orientation[1]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[1]}}),Object.defineProperty(t.Panner3D.prototype,\"orientationZ\",{set:function(t){this._orientation[2]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[2]}}),t.Panner3D._aliasProperty=function(e){Object.defineProperty(t.Panner3D.prototype,e,{set:function(t){this._panner[e]=t},get:function(){return this._panner[e]}})},t.Panner3D._aliasProperty(\"panningModel\"),t.Panner3D._aliasProperty(\"refDistance\"),t.Panner3D._aliasProperty(\"rolloffFactor\"),t.Panner3D._aliasProperty(\"distanceModel\"),t.Panner3D._aliasProperty(\"coneInnerAngle\"),t.Panner3D._aliasProperty(\"coneOuterAngle\"),t.Panner3D._aliasProperty(\"coneOuterGain\"),t.Panner3D._aliasProperty(\"maxDistance\"),t.Panner3D.prototype.dispose=function(){return this._panner.disconnect(),this._panner=null,this._orientation=null,this._position=null,this},t.Panner3D}),t(function(t){return t.PanVol=function(){var e=this.optionsObject(arguments,[\"pan\",\"volume\"],t.PanVol.defaults);this._panner=this.input=new t.Panner(e.pan),this.pan=this._panner.pan,this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._panner.connect(this._volume),this._readOnly([\"pan\",\"volume\"])},t.extend(t.PanVol),t.PanVol.defaults={pan:.5,volume:0},t.PanVol.prototype.dispose=function(){return t.prototype.dispose.call(this),this._writable([\"pan\",\"volume\"]),this._panner.dispose(),this._panner=null,this.pan=null,this._volume.dispose(),this._volume=null,this.volume=null,this},t.PanVol}),t(function(t){return t.CtrlInterpolate=function(){var e=this.optionsObject(arguments,[\"values\",\"index\"],t.CtrlInterpolate.defaults);this.values=e.values,this.index=e.index},t.extend(t.CtrlInterpolate),t.CtrlInterpolate.defaults={index:0,values:[]},Object.defineProperty(t.CtrlInterpolate.prototype,\"value\",{get:function(){var t=this.index;t=Math.min(t,this.values.length-1);var e=Math.floor(t),i=this.values[e],s=this.values[Math.ceil(t)];return this._interpolate(t-e,i,s)}}),t.CtrlInterpolate.prototype._interpolate=function(t,e,i){if(this.isArray(e)){for(var s=[],n=0;n<e.length;n++)s[n]=this._interpolate(t,e[n],i[n]);return s}if(this.isObject(e)){var o={};for(var r in e)o[r]=this._interpolate(t,e[r],i[r]);return o}return e=this._toNumber(e),i=this._toNumber(i),(1-t)*e+t*i},t.CtrlInterpolate.prototype._toNumber=function(t){return this.isNumber(t)?t:this.toSeconds(t)},t.CtrlInterpolate.prototype.dispose=function(){this.values=null},t.CtrlInterpolate}),t(function(t){return t.CtrlMarkov=function(t,e){this.values=this.defaultArg(t,{}),this.value=this.defaultArg(e,Object.keys(this.values)[0])},t.extend(t.CtrlMarkov),t.CtrlMarkov.prototype.next=function(){if(this.values.hasOwnProperty(this.value)){var t=this.values[this.value];if(this.isArray(t))for(var e=this._getProbDistribution(t),i=Math.random(),s=0,n=0;n<e.length;n++){var o=e[n];if(i>s&&i<s+o){var r=t[n];this.isObject(r)?this.value=r.value:this.value=r}s+=o}else this.value=t}return this.value},t.CtrlMarkov.prototype._getProbDistribution=function(t){for(var e=[],i=0,s=!1,n=0;n<t.length;n++){var o=t[n];this.isObject(o)?(s=!0,e[n]=o.probability):e[n]=1/t.length,i+=e[n]}if(s)for(var r=0;r<e.length;r++)e[r]=e[r]/i;return e},t.CtrlMarkov.prototype.dispose=function(){this.values=null},t.CtrlMarkov}),t(function(t){return t.CtrlPattern=function(){var e=this.optionsObject(arguments,[\"values\",\"type\"],t.CtrlPattern.defaults);this.values=e.values,this.index=0,this._type=null,this._shuffled=null,this._direction=null,this.type=e.type},t.extend(t.CtrlPattern),t.CtrlPattern.Type={Up:\"up\",Down:\"down\",UpDown:\"upDown\",DownUp:\"downUp\",AlternateUp:\"alternateUp\",AlternateDown:\"alternateDown\",Random:\"random\",RandomWalk:\"randomWalk\",RandomOnce:\"randomOnce\"},t.CtrlPattern.defaults={type:t.CtrlPattern.Type.Up,values:[]},Object.defineProperty(t.CtrlPattern.prototype,\"value\",{get:function(){if(0!==this.values.length){if(1===this.values.length)return this.values[0];this.index=Math.min(this.index,this.values.length-1);var e=this.values[this.index];return this.type===t.CtrlPattern.Type.RandomOnce&&(this.values.length!==this._shuffled.length&&this._shuffleValues(),e=this.values[this._shuffled[this.index]]),e}}}),Object.defineProperty(t.CtrlPattern.prototype,\"type\",{get:function(){return this._type},set:function(e){this._type=e,this._shuffled=null,this._type===t.CtrlPattern.Type.Up||this._type===t.CtrlPattern.Type.UpDown||this._type===t.CtrlPattern.Type.RandomOnce||this._type===t.CtrlPattern.Type.AlternateUp?this.index=0:this._type!==t.CtrlPattern.Type.Down&&this._type!==t.CtrlPattern.Type.DownUp&&this._type!==t.CtrlPattern.Type.AlternateDown||(this.index=this.values.length-1),this._type===t.CtrlPattern.Type.UpDown||this._type===t.CtrlPattern.Type.AlternateUp?this._direction=t.CtrlPattern.Type.Up:this._type!==t.CtrlPattern.Type.DownUp&&this._type!==t.CtrlPattern.Type.AlternateDown||(this._direction=t.CtrlPattern.Type.Down),this._type===t.CtrlPattern.Type.RandomOnce?this._shuffleValues():this._type===t.CtrlPattern.Random&&(this.index=Math.floor(Math.random()*this.values.length))}}),t.CtrlPattern.prototype.next=function(){var e=this.type;return e===t.CtrlPattern.Type.Up?++this.index>=this.values.length&&(this.index=0):e===t.CtrlPattern.Type.Down?--this.index<0&&(this.index=this.values.length-1):e===t.CtrlPattern.Type.UpDown||e===t.CtrlPattern.Type.DownUp?(this._direction===t.CtrlPattern.Type.Up?this.index++:this.index--,this.index<0?(this.index=1,this._direction=t.CtrlPattern.Type.Up):this.index>=this.values.length&&(this.index=this.values.length-2,this._direction=t.CtrlPattern.Type.Down)):e===t.CtrlPattern.Type.Random?this.index=Math.floor(Math.random()*this.values.length):e===t.CtrlPattern.Type.RandomWalk?Math.random()<.5?(this.index--,this.index=Math.max(this.index,0)):(this.index++,this.index=Math.min(this.index,this.values.length-1)):e===t.CtrlPattern.Type.RandomOnce?++this.index>=this.values.length&&(this.index=0,this._shuffleValues()):e===t.CtrlPattern.Type.AlternateUp?(this._direction===t.CtrlPattern.Type.Up?(this.index+=2,this._direction=t.CtrlPattern.Type.Down):(this.index-=1,this._direction=t.CtrlPattern.Type.Up),this.index>=this.values.length&&(this.index=0,this._direction=t.CtrlPattern.Type.Up)):e===t.CtrlPattern.Type.AlternateDown&&(this._direction===t.CtrlPattern.Type.Up?(this.index+=1,this._direction=t.CtrlPattern.Type.Down):(this.index-=2,this._direction=t.CtrlPattern.Type.Up),this.index<0&&(this.index=this.values.length-1,this._direction=t.CtrlPattern.Type.Down)),this.value},t.CtrlPattern.prototype._shuffleValues=function(){var t=[];this._shuffled=[];for(var e=0;e<this.values.length;e++)t[e]=e;for(;t.length>0;){var i=t.splice(Math.floor(t.length*Math.random()),1);this._shuffled.push(i[0])}},t.CtrlPattern.prototype.dispose=function(){this._shuffled=null,this.values=null},t.CtrlPattern}),t(function(t){return t.CtrlRandom=function(){var e=this.optionsObject(arguments,[\"min\",\"max\"],t.CtrlRandom.defaults);this.min=e.min,this.max=e.max,this.integer=e.integer},t.extend(t.CtrlRandom),t.CtrlRandom.defaults={min:0,max:1,integer:!1},Object.defineProperty(t.CtrlRandom.prototype,\"value\",{get:function(){var t=this.toSeconds(this.min),e=this.toSeconds(this.max),i=Math.random(),s=i*t+(1-i)*e;return this.integer&&(s=Math.floor(s)),s}}),t.CtrlRandom}),t(function(t){return window.AudioBuffer&&!AudioBuffer.prototype.copyToChannel&&(AudioBuffer.prototype.copyToChannel=function(t,e,i){var s=this.getChannelData(e);i=i||0;for(var n=0;n<s.length;n++)s[n+i]=t[n]},AudioBuffer.prototype.copyFromChannel=function(t,e,i){var s=this.getChannelData(e);i=i||0;for(var n=0;n<s.length;n++)t[n]=s[n+i]}),t.Buffer=function(){var e=this.optionsObject(arguments,[\"url\",\"onload\",\"onerror\"],t.Buffer.defaults);this._buffer=null,this._reversed=e.reverse,this._xhr=null,e.url instanceof AudioBuffer||e.url instanceof t.Buffer?(this.set(e.url),e.onload&&e.onload(this)):this.isString(e.url)&&this.load(e.url,e.onload,e.onerror)},t.extend(t.Buffer),t.Buffer.defaults={url:void 0,reverse:!1},t.Buffer.prototype.set=function(e){return e instanceof t.Buffer?this._buffer=e.get():this._buffer=e,this},t.Buffer.prototype.get=function(){return this._buffer},t.Buffer.prototype.load=function(e,i,s){return new Promise(function(n,o){this._xhr=t.Buffer.load(e,function(t){this._xhr=null,this.set(t),n(this),i&&i(this)}.bind(this),function(t){this._xhr=null,o(t),s&&s(t)}.bind(this))}.bind(this))},t.Buffer.prototype.dispose=function(){return t.Emitter.prototype.dispose.call(this),this._buffer=null,this._xhr&&(t.Buffer._currentDownloads--,this._xhr.abort(),this._xhr=null),this},Object.defineProperty(t.Buffer.prototype,\"loaded\",{get:function(){return this.length>0}}),Object.defineProperty(t.Buffer.prototype,\"duration\",{get:function(){return this._buffer?this._buffer.duration:0}}),Object.defineProperty(t.Buffer.prototype,\"length\",{get:function(){return this._buffer?this._buffer.length:0}}),Object.defineProperty(t.Buffer.prototype,\"numberOfChannels\",{get:function(){return this._buffer?this._buffer.numberOfChannels:0}}),t.Buffer.prototype.fromArray=function(t){var e=t[0].length>0,i=e?t.length:1,s=e?t[0].length:t.length,n=this.context.createBuffer(i,s,this.context.sampleRate);e||1!==i||(t=[t]);for(var o=0;o<i;o++)n.copyToChannel(t[o],o);return this._buffer=n,this},t.Buffer.prototype.toMono=function(t){if(this.isNumber(t))this.fromArray(this.toArray(t));else{for(var e=new Float32Array(this.length),i=this.numberOfChannels,s=0;s<i;s++)for(var n=this.toArray(s),o=0;o<n.length;o++)e[o]+=n[o];e=e.map(function(t){return t/i}),this.fromArray(e)}return this},t.Buffer.prototype.toArray=function(t){if(this.isNumber(t))return this.getChannelData(t);if(1===this.numberOfChannels)return this.toArray(0);for(var e=[],i=0;i<this.numberOfChannels;i++)e[i]=this.getChannelData(i);return e},t.Buffer.prototype.getChannelData=function(t){return this._buffer.getChannelData(t)},t.Buffer.prototype.slice=function(e,i){i=this.defaultArg(i,this.duration);for(var s=Math.floor(this.context.sampleRate*this.toSeconds(e)),n=Math.floor(this.context.sampleRate*this.toSeconds(i)),o=[],r=0;r<this.numberOfChannels;r++)o[r]=this.toArray(r).slice(s,n);return(new t.Buffer).fromArray(o)},t.Buffer.prototype._reverse=function(){if(this.loaded)for(var t=0;t<this.numberOfChannels;t++)Array.prototype.reverse.call(this.getChannelData(t));return this},Object.defineProperty(t.Buffer.prototype,\"reverse\",{get:function(){return this._reversed},set:function(t){this._reversed!==t&&(this._reversed=t,this._reverse())}}),t.Emitter.mixin(t.Buffer),t.Buffer._downloadQueue=[],t.Buffer._currentDownloads=0,t.Buffer.baseUrl=\"\",t.Buffer.load=function(e,i,s){function n(e){if(!s)throw new Error(e);s(e),t.Buffer.emit(\"error\",e)}function o(){for(var e=0,i=0;i<t.Buffer._downloadQueue.length;i++)e+=t.Buffer._downloadQueue[i].progress;t.Buffer.emit(\"progress\",e/t.Buffer._downloadQueue.length)}i=i||t.noOp;var r=new XMLHttpRequest;return r.open(\"GET\",t.Buffer.baseUrl+e,!0),r.responseType=\"arraybuffer\",r.progress=0,t.Buffer._currentDownloads++,t.Buffer._downloadQueue.push(r),r.addEventListener(\"load\",function(){200===r.status?t.context.decodeAudioData(r.response,function(e){r.progress=1,o(),i(e),0===--t.Buffer._currentDownloads&&(t.Buffer._downloadQueue=[],t.Buffer.emit(\"load\"))},function(){n(\"Tone.Buffer: could not decode audio data: \"+e)}):n(\"Tone.Buffer: could not locate file: \"+e)}),r.addEventListener(\"error\",n),r.addEventListener(\"progress\",function(t){t.lengthComputable&&(r.progress=t.loaded/t.total*.95,o())}),r.send(),r},t.Buffer.cancelDownloads=function(){return t.Buffer._downloadQueue.forEach(function(t){t.abort()}),t.Buffer._currentDownloads=0,t.Buffer},t.Buffer.supportsType=function(t){var e=t.split(\".\");return e=e[e.length-1],\"\"!==document.createElement(\"audio\").canPlayType(\"audio/\"+e)},t.loaded=function(){function e(){t.Buffer.off(\"load\",i),t.Buffer.off(\"error\",s)}var i,s;return new Promise(function(e,n){i=function(){e()},s=function(){n()},t.Buffer.on(\"load\",i),t.Buffer.on(\"error\",s)}).then(e).catch(function(t){throw e(),new Error(t)})},t.Buffer}),t(function(t){return t.Buffers=function(t,e,i){this._buffers={},this.baseUrl=this.defaultArg(i,\"\"),t=this._flattenUrls(t),this._loadingCount=0;for(var s in t)this._loadingCount++,this.add(s,t[s],this._bufferLoaded.bind(this,e))},t.extend(t.Buffers),t.Buffers.prototype.has=function(t){return this._buffers.hasOwnProperty(t)},t.Buffers.prototype.get=function(t){if(this.has(t))return this._buffers[t];throw new Error(\"Tone.Buffers: no buffer named \"+t)},t.Buffers.prototype._bufferLoaded=function(t){0===--this._loadingCount&&t&&t(this)},Object.defineProperty(t.Buffers.prototype,\"loaded\",{get:function(){var t=!0;for(var e in this._buffers){var i=this.get(e);t=t&&i.loaded}return t}}),t.Buffers.prototype.add=function(e,i,s){return s=this.defaultArg(s,t.noOp),i instanceof t.Buffer?(this._buffers[e]=i,s(this)):i instanceof AudioBuffer?(this._buffers[e]=new t.Buffer(i),s(this)):this.isString(i)&&(this._buffers[e]=new t.Buffer(this.baseUrl+i,s)),this},t.Buffers.prototype._flattenUrls=function(t){var e={};for(var i in t)if(t.hasOwnProperty(i))if(this.isObject(t[i])){var s=this._flattenUrls(t[i]);for(var n in s)s.hasOwnProperty(n)&&(e[i+\".\"+n]=s[n])}else e[i]=t[i];return e},t.Buffers.prototype.dispose=function(){for(var t in this._buffers)this._buffers[t].dispose();return this._buffers=null,this},t.Buffers}),t(function(t){var e={};return t.prototype.send=function(i,s){e.hasOwnProperty(i)||(e[i]=this.context.createGain()),s=this.defaultArg(s,0);var n=new t.Gain(s,t.Type.Decibels);return this.output.chain(n,e[i]),n},t.prototype.receive=function(t,i){return e.hasOwnProperty(t)||(e[t]=this.context.createGain()),this.isUndef(i)&&(i=this.input),e[t].connect(i),this},t.Context.on(\"init\",function(t){t.Buses?e=t.Buses:(e={},t.Buses=e)}),t}),t(function(t){return t.Draw=function(){this._events=new t.Timeline,this.expiration=.25,this.anticipation=.008,this._boundDrawLoop=this._drawLoop.bind(this)},t.extend(t.Draw),t.Draw.prototype.schedule=function(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),1===this._events.length&&requestAnimationFrame(this._boundDrawLoop),this},t.Draw.prototype.cancel=function(t){return this._events.cancel(this.toSeconds(t)),this},t.Draw.prototype._drawLoop=function(){for(var e=t.now();this._events.length&&this._events.peek().time-this.anticipation<=e;){var i=this._events.shift();e-i.time<=this.expiration&&i.callback()}this._events.length>0&&requestAnimationFrame(this._boundDrawLoop)},t.Draw=new t.Draw,t.Draw}),t(function(t){t.Listener=function(){var t=this.optionsObject(arguments,[\"positionX\",\"positionY\",\"positionZ\"],e.defaults);this._orientation=[t.forwardX,t.forwardY,t.forwardZ,t.upX,t.upY,t.upZ],this._position=[t.positionX,t.positionY,t.positionZ],this.forwardX=t.forwardX,this.forwardY=t.forwardY,this.forwardZ=t.forwardZ,this.upX=t.upX,this.upY=t.upY,this.upZ=t.upZ,this.positionX=t.positionX,this.positionY=t.positionY,this.positionZ=t.positionZ},t.extend(t.Listener),t.Listener.defaults={positionX:0,positionY:0,positionZ:0,forwardX:0,forwardY:0,forwardZ:1,upX:0,upY:1,upZ:0},t.Listener.prototype._rampTimeConstant=.01,t.Listener.prototype.setPosition=function(t,e,i){if(this.context.listener.positionX){var s=this.now();this.context.listener.positionX.setTargetAtTime(t,s,this._rampTimeConstant),this.context.listener.positionY.setTargetAtTime(e,s,this._rampTimeConstant),this.context.listener.positionZ.setTargetAtTime(i,s,this._rampTimeConstant)}else this.context.listener.setPosition(t,e,i);return this._position=Array.prototype.slice.call(arguments),this},t.Listener.prototype.setOrientation=function(t,e,i,s,n,o){if(this.context.listener.forwardX){var r=this.now();this.context.listener.forwardX.setTargetAtTime(t,r,this._rampTimeConstant),this.context.listener.forwardY.setTargetAtTime(e,r,this._rampTimeConstant),this.context.listener.forwardZ.setTargetAtTime(i,r,this._rampTimeConstant),this.context.listener.upX.setTargetAtTime(s,r,this._rampTimeConstant),this.context.listener.upY.setTargetAtTime(n,r,this._rampTimeConstant),this.context.listener.upZ.setTargetAtTime(o,r,this._rampTimeConstant)}else this.context.listener.setOrientation(t,e,i,s,n,o);return this._orientation=Array.prototype.slice.call(arguments),this},Object.defineProperty(t.Listener.prototype,\"positionX\",{set:function(t){this._position[0]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[0]}}),Object.defineProperty(t.Listener.prototype,\"positionY\",{set:function(t){this._position[1]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[1]}}),Object.defineProperty(t.Listener.prototype,\"positionZ\",{set:function(t){this._position[2]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[2]}}),Object.defineProperty(t.Listener.prototype,\"forwardX\",{set:function(t){this._orientation[0]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[0]}}),Object.defineProperty(t.Listener.prototype,\"forwardY\",{set:function(t){this._orientation[1]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[1]}}),Object.defineProperty(t.Listener.prototype,\"forwardZ\",{set:function(t){this._orientation[2]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[2]}}),Object.defineProperty(t.Listener.prototype,\"upX\",{set:function(t){this._orientation[3]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[3]}}),Object.defineProperty(t.Listener.prototype,\"upY\",{set:function(t){this._orientation[4]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[4]}}),Object.defineProperty(t.Listener.prototype,\"upZ\",{set:function(t){this._orientation[5]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[5]}}),t.Listener.prototype.dispose=function(){return this._orientation=null,this._position=null,this};var e=t.Listener;return t.Listener=new e,t.Context.on(\"init\",function(i){i.Listener instanceof e?t.Listener=i.Listener:t.Listener=new e,i.Listener=t.Listener}),t.Listener}),t(function(t){return!window.hasOwnProperty(\"OfflineAudioContext\")&&window.hasOwnProperty(\"webkitOfflineAudioContext\")&&(window.OfflineAudioContext=window.webkitOfflineAudioContext),t.OfflineContext=function(e,i,s){var n=new OfflineAudioContext(e,i*s,s);t.Context.call(this,n),this._duration=i,this._currentTime=0,this.lookAhead=this.blockTime,this.updateInterval=this.blockTime},t.extend(t.OfflineContext,t.Context),t.OfflineContext.prototype.now=function(){return this._currentTime},t.OfflineContext.prototype._createWorker=function(){return{postMessage:function(){}}},t.OfflineContext.prototype.render=function(){for(;this._duration-this._currentTime>=0;)this.emit(\"tick\"),this._currentTime+=t.prototype.blockTime;return new Promise(function(t){this._context.oncomplete=function(e){t(e.renderedBuffer)},this._context.startRendering()}.bind(this))},t.OfflineContext}),t(function(t){return t.Offline=function(e,i){var s=t.context.sampleRate,n=t.context,o=new t.OfflineContext(2,i,s);t.context=o,e(t.Transport);var r=o.render();return t.context=n,r.then(function(e){return new t.Buffer(e)})},t.Offline}),t(function(t){return t.Effect=function(){this.createInsOuts(1,1);var e=this.optionsObject(arguments,[\"wet\"],t.Effect.defaults);this._dryWet=new t.CrossFade(e.wet),this.wet=this._dryWet.fade,this.effectSend=new t.Gain,this.effectReturn=new t.Gain,this.input.connect(this._dryWet.a),this.input.connect(this.effectSend),this.effectReturn.connect(this._dryWet.b),this._dryWet.connect(this.output),this._readOnly([\"wet\"])},t.extend(t.Effect),t.Effect.defaults={wet:1},t.Effect.prototype.connectEffect=function(t){return this.effectSend.chain(t,this.effectReturn),this},t.Effect.prototype.dispose=function(){return t.prototype.dispose.call(this),this._dryWet.dispose(),this._dryWet=null,this.effectSend.dispose(),this.effectSend=null,this.effectReturn.dispose(),this.effectReturn=null,this._writable([\"wet\"]),this.wet=null,this},t.Effect}),t(function(t){return t.AutoFilter=function(){var e=this.optionsObject(arguments,[\"frequency\",\"baseFrequency\",\"octaves\"],t.AutoFilter.defaults);t.Effect.call(this,e),this._lfo=new t.LFO({frequency:e.frequency,amplitude:e.depth}),this.depth=this._lfo.amplitude,this.frequency=this._lfo.frequency,this.filter=new t.Filter(e.filter),this._octaves=0,this.connectEffect(this.filter),this._lfo.connect(this.filter.frequency),this.type=e.type,this._readOnly([\"frequency\",\"depth\"]),this.octaves=e.octaves,this.baseFrequency=e.baseFrequency},t.extend(t.AutoFilter,t.Effect),t.AutoFilter.defaults={frequency:1,type:\"sine\",depth:1,baseFrequency:200,octaves:2.6,filter:{type:\"lowpass\",rolloff:-12,Q:1}},t.AutoFilter.prototype.start=function(t){return this._lfo.start(t),this},t.AutoFilter.prototype.stop=function(t){return this._lfo.stop(t),this},t.AutoFilter.prototype.sync=function(t){return this._lfo.sync(t),this},t.AutoFilter.prototype.unsync=function(){return this._lfo.unsync(),this},Object.defineProperty(t.AutoFilter.prototype,\"type\",{get:function(){return this._lfo.type},set:function(t){this._lfo.type=t}}),Object.defineProperty(t.AutoFilter.prototype,\"baseFrequency\",{get:function(){return this._lfo.min},set:function(t){this._lfo.min=this.toFrequency(t),this.octaves=this._octaves}}),Object.defineProperty(t.AutoFilter.prototype,\"octaves\",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._lfo.max=this.baseFrequency*Math.pow(2,t)}}),t.AutoFilter.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._lfo.dispose(),this._lfo=null,this.filter.dispose(),this.filter=null,this._writable([\"frequency\",\"depth\"]),this.frequency=null,this.depth=null,this},t.AutoFilter}),t(function(t){return t.AutoPanner=function(){var e=this.optionsObject(arguments,[\"frequency\"],t.AutoPanner.defaults);t.Effect.call(this,e),this._lfo=new t.LFO({frequency:e.frequency,amplitude:e.depth,min:-1,max:1}),this.depth=this._lfo.amplitude,this._panner=new t.Panner,this.frequency=this._lfo.frequency,this.connectEffect(this._panner),this._lfo.connect(this._panner.pan),this.type=e.type,this._readOnly([\"depth\",\"frequency\"])},t.extend(t.AutoPanner,t.Effect),t.AutoPanner.defaults={frequency:1,type:\"sine\",depth:1},t.AutoPanner.prototype.start=function(t){return this._lfo.start(t),this},t.AutoPanner.prototype.stop=function(t){return this._lfo.stop(t),this},t.AutoPanner.prototype.sync=function(t){return this._lfo.sync(t),this},t.AutoPanner.prototype.unsync=function(){return this._lfo.unsync(),this},Object.defineProperty(t.AutoPanner.prototype,\"type\",{get:function(){return this._lfo.type},set:function(t){this._lfo.type=t}}),t.AutoPanner.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._lfo.dispose(),this._lfo=null,this._panner.dispose(),this._panner=null,this._writable([\"depth\",\"frequency\"]),this.frequency=null,this.depth=null,this},t.AutoPanner}),t(function(t){return t.AutoWah=function(){var e=this.optionsObject(arguments,[\"baseFrequency\",\"octaves\",\"sensitivity\"],t.AutoWah.defaults);t.Effect.call(this,e),this.follower=new t.Follower(e.follower),this._sweepRange=new t.ScaleExp(0,1,.5),this._baseFrequency=e.baseFrequency,this._octaves=e.octaves,this._inputBoost=new t.Gain,this._bandpass=new t.Filter({rolloff:-48,frequency:0,Q:e.Q}),this._peaking=new t.Filter(0,\"peaking\"),this._peaking.gain.value=e.gain,this.gain=this._peaking.gain,this.Q=this._bandpass.Q,this.effectSend.chain(this._inputBoost,this.follower,this._sweepRange),this._sweepRange.connect(this._bandpass.frequency),this._sweepRange.connect(this._peaking.frequency),this.effectSend.chain(this._bandpass,this._peaking,this.effectReturn),this._setSweepRange(),this.sensitivity=e.sensitivity,this._readOnly([\"gain\",\"Q\"])},t.extend(t.AutoWah,t.Effect),t.AutoWah.defaults={baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,follower:{attack:.3,release:.5}},Object.defineProperty(t.AutoWah.prototype,\"octaves\",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._setSweepRange()}}),Object.defineProperty(t.AutoWah.prototype,\"baseFrequency\",{get:function(){return this._baseFrequency},set:function(t){this._baseFrequency=t,this._setSweepRange()}}),Object.defineProperty(t.AutoWah.prototype,\"sensitivity\",{get:function(){return this.gainToDb(1/this._inputBoost.gain.value)},set:function(t){this._inputBoost.gain.value=1/this.dbToGain(t)}}),t.AutoWah.prototype._setSweepRange=function(){this._sweepRange.min=this._baseFrequency,this._sweepRange.max=Math.min(this._baseFrequency*Math.pow(2,this._octaves),this.context.sampleRate/2)},t.AutoWah.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this.follower.dispose(),this.follower=null,this._sweepRange.dispose(),this._sweepRange=null,this._bandpass.dispose(),this._bandpass=null,this._peaking.dispose(),this._peaking=null,this._inputBoost.dispose(),this._inputBoost=null,this._writable([\"gain\",\"Q\"]),this.gain=null,this.Q=null,this},t.AutoWah}),t(function(t){return t.BitCrusher=function(){var e=this.optionsObject(arguments,[\"bits\"],t.BitCrusher.defaults);t.Effect.call(this,e);var i=1/Math.pow(2,e.bits-1);this._subtract=new t.Subtract,this._modulo=new t.Modulo(i),this._bits=e.bits,this.effectSend.fan(this._subtract,this._modulo),this._modulo.connect(this._subtract,0,1),this._subtract.connect(this.effectReturn)},t.extend(t.BitCrusher,t.Effect),t.BitCrusher.defaults={bits:4},Object.defineProperty(t.BitCrusher.prototype,\"bits\",{get:function(){return this._bits},set:function(t){this._bits=t;var e=1/Math.pow(2,t-1);this._modulo.value=e}}),t.BitCrusher.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._subtract.dispose(),this._subtract=null,this._modulo.dispose(),this._modulo=null,this},t.BitCrusher}),t(function(t){return t.Chebyshev=function(){var e=this.optionsObject(arguments,[\"order\"],t.Chebyshev.defaults);t.Effect.call(this,e),this._shaper=new t.WaveShaper(4096),this._order=e.order,this.connectEffect(this._shaper),this.order=e.order,this.oversample=e.oversample},t.extend(t.Chebyshev,t.Effect),t.Chebyshev.defaults={order:1,oversample:\"none\"},t.Chebyshev.prototype._getCoefficient=function(t,e,i){return i.hasOwnProperty(e)?i[e]:(i[e]=0===e?0:1===e?t:2*t*this._getCoefficient(t,e-1,i)-this._getCoefficient(t,e-2,i),i[e])},Object.defineProperty(t.Chebyshev.prototype,\"order\",{get:function(){return this._order},set:function(t){this._order=t;for(var e=new Array(4096),i=e.length,s=0;s<i;++s){var n=2*s/i-1;e[s]=0===n?0:this._getCoefficient(n,t,{})}this._shaper.curve=e}}),Object.defineProperty(t.Chebyshev.prototype,\"oversample\",{get:function(){return this._shaper.oversample},set:function(t){this._shaper.oversample=t}}),t.Chebyshev.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._shaper.dispose(),this._shaper=null,this},t.Chebyshev}),t(function(t){return t.StereoEffect=function(){this.createInsOuts(1,1);var e=this.optionsObject(arguments,[\"wet\"],t.Effect.defaults);this._dryWet=new t.CrossFade(e.wet),this.wet=this._dryWet.fade,this._split=new t.Split,this.effectSendL=this._split.left,this.effectSendR=this._split.right,this._merge=new t.Merge,this.effectReturnL=this._merge.left,this.effectReturnR=this._merge.right,this.input.connect(this._split),this.input.connect(this._dryWet,0,0),this._merge.connect(this._dryWet,0,1),this._dryWet.connect(this.output),this._readOnly([\"wet\"])},t.extend(t.StereoEffect,t.Effect),t.StereoEffect.prototype.dispose=function(){return t.prototype.dispose.call(this),this._dryWet.dispose(),this._dryWet=null,this._split.dispose(),this._split=null,this._merge.dispose(),this._merge=null,this.effectSendL=null,this.effectSendR=null,this.effectReturnL=null,this.effectReturnR=null,this._writable([\"wet\"]),this.wet=null,this},t.StereoEffect}),t(function(t){return t.FeedbackEffect=function(){var e=this.optionsObject(arguments,[\"feedback\"]);e=this.defaultArg(e,t.FeedbackEffect.defaults),t.Effect.call(this,e),this._feedbackGain=new t.Gain(e.feedback,t.Type.NormalRange),this.feedback=this._feedbackGain.gain,this.effectReturn.chain(this._feedbackGain,this.effectSend),this._readOnly([\"feedback\"])},t.extend(t.FeedbackEffect,t.Effect),t.FeedbackEffect.defaults={feedback:.125},t.FeedbackEffect.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._writable([\"feedback\"]),this._feedbackGain.dispose(),this._feedbackGain=null,this.feedback=null,this},t.FeedbackEffect}),t(function(t){return t.StereoXFeedbackEffect=function(){var e=this.optionsObject(arguments,[\"feedback\"],t.FeedbackEffect.defaults);t.StereoEffect.call(this,e),this.feedback=new t.Signal(e.feedback,t.Type.NormalRange),this._feedbackLR=new t.Gain,this._feedbackRL=new t.Gain,this.effectReturnL.chain(this._feedbackLR,this.effectSendR),this.effectReturnR.chain(this._feedbackRL,this.effectSendL),this.feedback.fan(this._feedbackLR.gain,this._feedbackRL.gain),this._readOnly([\"feedback\"])},t.extend(t.StereoXFeedbackEffect,t.FeedbackEffect),t.StereoXFeedbackEffect.prototype.dispose=function(){return t.StereoEffect.prototype.dispose.call(this),this._writable([\"feedback\"]),this.feedback.dispose(),this.feedback=null,this._feedbackLR.dispose(),this._feedbackLR=null,this._feedbackRL.dispose(),this._feedbackRL=null,this},t.StereoXFeedbackEffect}),t(function(t){return t.Chorus=function(){var e=this.optionsObject(arguments,[\"frequency\",\"delayTime\",\"depth\"],t.Chorus.defaults);t.StereoXFeedbackEffect.call(this,e),this._depth=e.depth,this._delayTime=e.delayTime/1e3,this._lfoL=new t.LFO({frequency:e.frequency,min:0,max:1}),this._lfoR=new t.LFO({frequency:e.frequency,min:0,max:1,phase:180}),this._delayNodeL=new t.Delay,this._delayNodeR=new t.Delay,this.frequency=this._lfoL.frequency,this.effectSendL.chain(this._delayNodeL,this.effectReturnL),this.effectSendR.chain(this._delayNodeR,this.effectReturnR),this.effectSendL.connect(this.effectReturnL),this.effectSendR.connect(this.effectReturnR),this._lfoL.connect(this._delayNodeL.delayTime),this._lfoR.connect(this._delayNodeR.delayTime),this._lfoL.start(),this._lfoR.start(),this._lfoL.frequency.connect(this._lfoR.frequency),this.depth=this._depth,this.frequency.value=e.frequency,this.type=e.type,this._readOnly([\"frequency\"]),this.spread=e.spread},t.extend(t.Chorus,t.StereoXFeedbackEffect),t.Chorus.defaults={frequency:1.5,delayTime:3.5,depth:.7,feedback:.1,type:\"sine\",spread:180},Object.defineProperty(t.Chorus.prototype,\"depth\",{get:function(){return this._depth},set:function(t){this._depth=t;var e=this._delayTime*t;this._lfoL.min=Math.max(this._delayTime-e,0),this._lfoL.max=this._delayTime+e,this._lfoR.min=Math.max(this._delayTime-e,0),this._lfoR.max=this._delayTime+e}}),Object.defineProperty(t.Chorus.prototype,\"delayTime\",{get:function(){return 1e3*this._delayTime},set:function(t){this._delayTime=t/1e3,this.depth=this._depth}}),Object.defineProperty(t.Chorus.prototype,\"type\",{get:function(){return this._lfoL.type},set:function(t){this._lfoL.type=t,this._lfoR.type=t}}),Object.defineProperty(t.Chorus.prototype,\"spread\",{get:function(){return this._lfoR.phase-this._lfoL.phase},set:function(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/2+90}}),t.Chorus.prototype.dispose=function(){return t.StereoXFeedbackEffect.prototype.dispose.call(this),this._lfoL.dispose(),this._lfoL=null,this._lfoR.dispose(),this._lfoR=null,this._delayNodeL.dispose(),this._delayNodeL=null,this._delayNodeR.dispose(),this._delayNodeR=null,this._writable(\"frequency\"),this.frequency=null,this},t.Chorus}),t(function(t){return t.Convolver=function(){var e=this.optionsObject(arguments,[\"url\",\"onload\"],t.Convolver.defaults);t.Effect.call(this,e),this._convolver=this.context.createConvolver(),this._buffer=new t.Buffer,this.isString(e.url)?this._buffer.load(e.url,function(t){this.buffer=t,e.onload()}.bind(this)):e.url&&(this.buffer=e.url,e.onload()),this.connectEffect(this._convolver)},t.extend(t.Convolver,t.Effect),t.Convolver.defaults={onload:t.noOp},Object.defineProperty(t.Convolver.prototype,\"buffer\",{get:function(){return this._buffer.get()},set:function(t){this._buffer.set(t),this._convolver.buffer=this._buffer.get()}}),t.Convolver.prototype.load=function(t,e){return this._buffer.load(t,function(t){this.buffer=t,e&&e()}.bind(this))},t.Convolver.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._convolver.disconnect(),this._convolver=null,this._buffer.dispose(),this._buffer=null,this},t.Convolver}),t(function(t){return t.Distortion=function(){var e=this.optionsObject(arguments,[\"distortion\"],t.Distortion.defaults);t.Effect.call(this,e),this._shaper=new t.WaveShaper(4096),this._distortion=e.distortion,this.connectEffect(this._shaper),this.distortion=e.distortion,this.oversample=e.oversample},t.extend(t.Distortion,t.Effect),t.Distortion.defaults={distortion:.4,oversample:\"none\"},Object.defineProperty(t.Distortion.prototype,\"distortion\",{get:function(){return this._distortion},set:function(t){this._distortion=t;var e=100*t,i=Math.PI/180;this._shaper.setMap(function(t){return Math.abs(t)<.001?0:(3+e)*t*20*i/(Math.PI+e*Math.abs(t))})}}),Object.defineProperty(t.Distortion.prototype,\"oversample\",{get:function(){return this._shaper.oversample},set:function(t){this._shaper.oversample=t}}),t.Distortion.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._shaper.dispose(),this._shaper=null,this},t.Distortion}),t(function(t){return t.FeedbackDelay=function(){var e=this.optionsObject(arguments,[\"delayTime\",\"feedback\"],t.FeedbackDelay.defaults);t.FeedbackEffect.call(this,e),this._delayNode=new t.Delay(e.delayTime),this.delayTime=this._delayNode.delayTime,this.connectEffect(this._delayNode),this._readOnly([\"delayTime\"])},t.extend(t.FeedbackDelay,t.FeedbackEffect),t.FeedbackDelay.defaults={delayTime:.25},t.FeedbackDelay.prototype.dispose=function(){return t.FeedbackEffect.prototype.dispose.call(this),this._delayNode.dispose(),this._delayNode=null,this._writable([\"delayTime\"]),this.delayTime=null,this},t.FeedbackDelay}),t(function(t){var e=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100],i=[225,556,441,341];return t.Freeverb=function(){var s=this.optionsObject(arguments,[\"roomSize\",\"dampening\"],t.Freeverb.defaults);t.StereoEffect.call(this,s),this.roomSize=new t.Signal(s.roomSize,t.Type.NormalRange),this.dampening=new t.Signal(s.dampening,t.Type.Frequency),this._combFilters=[],this._allpassFiltersL=[],this._allpassFiltersR=[];for(var n=0;n<i.length;n++){var o=this.context.createBiquadFilter();o.type=\"allpass\",o.frequency.value=i[n],this._allpassFiltersL.push(o)}for(var r=0;r<i.length;r++){var a=this.context.createBiquadFilter();a.type=\"allpass\",a.frequency.value=i[r],this._allpassFiltersR.push(a)}for(var h=0;h<e.length;h++){var l=new t.LowpassCombFilter(e[h]);h<e.length/2?this.effectSendL.chain(l,this._allpassFiltersL[0]):this.effectSendR.chain(l,this._allpassFiltersR[0]),this.roomSize.connect(l.resonance),this.dampening.connect(l.dampening),this._combFilters.push(l)}this.connectSeries.apply(this,this._allpassFiltersL),this.connectSeries.apply(this,this._allpassFiltersR),this._allpassFiltersL[this._allpassFiltersL.length-1].connect(this.effectReturnL),this._allpassFiltersR[this._allpassFiltersR.length-1].connect(this.effectReturnR),this._readOnly([\"roomSize\",\"dampening\"])},t.extend(t.Freeverb,t.StereoEffect),t.Freeverb.defaults={roomSize:.7,dampening:3e3},t.Freeverb.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this);for(var e=0;e<this._allpassFiltersL.length;e++)this._allpassFiltersL[e].disconnect(),this._allpassFiltersL[e]=null;this._allpassFiltersL=null;for(var i=0;i<this._allpassFiltersR.length;i++)this._allpassFiltersR[i].disconnect(),this._allpassFiltersR[i]=null;this._allpassFiltersR=null;for(var s=0;s<this._combFilters.length;s++)this._combFilters[s].dispose(),this._combFilters[s]=null;return this._combFilters=null,this._writable([\"roomSize\",\"dampening\"]),this.roomSize.dispose(),this.roomSize=null,this.dampening.dispose(),this.dampening=null,this},t.Freeverb}),t(function(t){var e=[.06748,.06404,.08212,.09004],i=[.773,.802,.753,.733],s=[347,113,37];return t.JCReverb=function(){var n=this.optionsObject(arguments,[\"roomSize\"],t.JCReverb.defaults);t.StereoEffect.call(this,n),this.roomSize=new t.Signal(n.roomSize,t.Type.NormalRange),this._scaleRoomSize=new t.Scale(-.733,.197),this._allpassFilters=[],this._feedbackCombFilters=[];for(var o=0;o<s.length;o++){var r=this.context.createBiquadFilter();r.type=\"allpass\",r.frequency.value=s[o],this._allpassFilters.push(r)}for(var a=0;a<e.length;a++){var h=new t.FeedbackCombFilter(e[a],.1);this._scaleRoomSize.connect(h.resonance),h.resonance.value=i[a],this._allpassFilters[this._allpassFilters.length-1].connect(h),a<e.length/2?h.connect(this.effectReturnL):h.connect(this.effectReturnR),this._feedbackCombFilters.push(h)}this.roomSize.connect(this._scaleRoomSize),this.connectSeries.apply(this,this._allpassFilters),this.effectSendL.connect(this._allpassFilters[0]),this.effectSendR.connect(this._allpassFilters[0]),this._readOnly([\"roomSize\"])},t.extend(t.JCReverb,t.StereoEffect),t.JCReverb.defaults={roomSize:.5},t.JCReverb.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this);for(var e=0;e<this._allpassFilters.length;e++)this._allpassFilters[e].disconnect(),this._allpassFilters[e]=null;this._allpassFilters=null;for(var i=0;i<this._feedbackCombFilters.length;i++)this._feedbackCombFilters[i].dispose(),this._feedbackCombFilters[i]=null;return this._feedbackCombFilters=null,this._writable([\"roomSize\"]),this.roomSize.dispose(),this.roomSize=null,this._scaleRoomSize.dispose(),this._scaleRoomSize=null,this},t.JCReverb}),t(function(t){return t.MidSideEffect=function(){t.Effect.apply(this,arguments),this._midSideSplit=new t.MidSideSplit,this._midSideMerge=new t.MidSideMerge,this.midSend=this._midSideSplit.mid,this.sideSend=this._midSideSplit.side,this.midReturn=this._midSideMerge.mid,this.sideReturn=this._midSideMerge.side,this.effectSend.connect(this._midSideSplit),this._midSideMerge.connect(this.effectReturn)},t.extend(t.MidSideEffect,t.Effect),t.MidSideEffect.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._midSideSplit.dispose(),this._midSideSplit=null,this._midSideMerge.dispose(),this._midSideMerge=null,this.midSend=null,this.sideSend=null,this.midReturn=null,this.sideReturn=null,this},t.MidSideEffect}),t(function(t){return t.Phaser=function(){var e=this.optionsObject(arguments,[\"frequency\",\"octaves\",\"baseFrequency\"],t.Phaser.defaults);t.StereoEffect.call(this,e),this._lfoL=new t.LFO(e.frequency,0,1),this._lfoR=new t.LFO(e.frequency,0,1),this._lfoR.phase=180,this._baseFrequency=e.baseFrequency,this._octaves=e.octaves,this.Q=new t.Signal(e.Q,t.Type.Positive),this._filtersL=this._makeFilters(e.stages,this._lfoL,this.Q),this._filtersR=this._makeFilters(e.stages,this._lfoR,this.Q),this.frequency=this._lfoL.frequency,this.frequency.value=e.frequency,this.effectSendL.connect(this._filtersL[0]),this.effectSendR.connect(this._filtersR[0]),this._filtersL[e.stages-1].connect(this.effectReturnL),this._filtersR[e.stages-1].connect(this.effectReturnR),this._lfoL.frequency.connect(this._lfoR.frequency),this.baseFrequency=e.baseFrequency,this.octaves=e.octaves,this._lfoL.start(),this._lfoR.start(),this._readOnly([\"frequency\",\"Q\"])},t.extend(t.Phaser,t.StereoEffect),t.Phaser.defaults={frequency:.5,octaves:3,stages:10,Q:10,baseFrequency:350},t.Phaser.prototype._makeFilters=function(t,e,i){for(var s=new Array(t),n=0;n<t;n++){var o=this.context.createBiquadFilter();o.type=\"allpass\",i.connect(o.Q),e.connect(o.frequency),s[n]=o}return this.connectSeries.apply(this,s),s},Object.defineProperty(t.Phaser.prototype,\"octaves\",{get:function(){return this._octaves},set:function(t){this._octaves=t;var e=this._baseFrequency*Math.pow(2,t);this._lfoL.max=e,this._lfoR.max=e}}),Object.defineProperty(t.Phaser.prototype,\"baseFrequency\",{get:function(){return this._baseFrequency},set:function(t){this._baseFrequency=t,this._lfoL.min=t,this._lfoR.min=t,this.octaves=this._octaves}}),t.Phaser.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this),this._writable([\"frequency\",\"Q\"]),this.Q.dispose(),this.Q=null,this._lfoL.dispose(),this._lfoL=null,this._lfoR.dispose(),this._lfoR=null;for(var e=0;e<this._filtersL.length;e++)this._filtersL[e].disconnect(),this._filtersL[e]=null;this._filtersL=null;for(var i=0;i<this._filtersR.length;i++)this._filtersR[i].disconnect(),this._filtersR[i]=null;return this._filtersR=null,this.frequency=null,this},t.Phaser}),t(function(t){return t.PingPongDelay=function(){var e=this.optionsObject(arguments,[\"delayTime\",\"feedback\"],t.PingPongDelay.defaults);t.StereoXFeedbackEffect.call(this,e),this._leftDelay=new t.Delay(0,e.maxDelayTime),this._rightDelay=new t.Delay(0,e.maxDelayTime),this._rightPreDelay=new t.Delay(0,e.maxDelayTime),this.delayTime=new t.Signal(e.delayTime,t.Type.Time),this.effectSendL.chain(this._leftDelay,this.effectReturnL),this.effectSendR.chain(this._rightPreDelay,this._rightDelay,this.effectReturnR),this.delayTime.fan(this._leftDelay.delayTime,this._rightDelay.delayTime,this._rightPreDelay.delayTime),this._feedbackLR.disconnect(),this._feedbackLR.connect(this._rightDelay),this._readOnly([\"delayTime\"])},t.extend(t.PingPongDelay,t.StereoXFeedbackEffect),t.PingPongDelay.defaults={delayTime:.25,maxDelayTime:1},t.PingPongDelay.prototype.dispose=function(){return t.StereoXFeedbackEffect.prototype.dispose.call(this),this._leftDelay.dispose(),this._leftDelay=null,this._rightDelay.dispose(),this._rightDelay=null,this._rightPreDelay.dispose(),this._rightPreDelay=null,this._writable([\"delayTime\"]),this.delayTime.dispose(),this.delayTime=null,this},t.PingPongDelay}),t(function(t){return t.PitchShift=function(){var e=this.optionsObject(arguments,[\"pitch\"],t.PitchShift.defaults);t.FeedbackEffect.call(this,e),this._frequency=new t.Signal(0),this._delayA=new t.Delay(0,1),this._lfoA=new t.LFO({min:0,max:.1,type:\"sawtooth\"}).connect(this._delayA.delayTime),this._delayB=new t.Delay(0,1),this._lfoB=new t.LFO({min:0,max:.1,type:\"sawtooth\",phase:180}).connect(this._delayB.delayTime),this._crossFade=new t.CrossFade,this._crossFadeLFO=new t.LFO({min:0,max:1,type:\"triangle\",phase:90}).connect(this._crossFade.fade),this._feedbackDelay=new t.Delay(e.delayTime),this.delayTime=this._feedbackDelay.delayTime,this._readOnly(\"delayTime\"),this._pitch=e.pitch,this._windowSize=e.windowSize,this._delayA.connect(this._crossFade.a),this._delayB.connect(this._crossFade.b),this._frequency.fan(this._lfoA.frequency,this._lfoB.frequency,this._crossFadeLFO.frequency),this.effectSend.fan(this._delayA,this._delayB),this._crossFade.chain(this._feedbackDelay,this.effectReturn);var i=this.now();this._lfoA.start(i),this._lfoB.start(i),this._crossFadeLFO.start(i),this.windowSize=this._windowSize},t.extend(t.PitchShift,t.FeedbackEffect),t.PitchShift.defaults={pitch:0,windowSize:.1,delayTime:0,feedback:0},Object.defineProperty(t.PitchShift.prototype,\"pitch\",{get:function(){return this._pitch},set:function(t){this._pitch=t;var e=0;t<0?(this._lfoA.min=0,this._lfoA.max=this._windowSize,this._lfoB.min=0,this._lfoB.max=this._windowSize,e=this.intervalToFrequencyRatio(t-1)+1):(this._lfoA.min=this._windowSize,this._lfoA.max=0,this._lfoB.min=this._windowSize,this._lfoB.max=0,e=this.intervalToFrequencyRatio(t)-1),this._frequency.value=e*(1.2/this._windowSize)}}),Object.defineProperty(t.PitchShift.prototype,\"windowSize\",{get:function(){return this._windowSize},set:function(t){this._windowSize=this.toSeconds(t),this.pitch=this._pitch}}),t.PitchShift.prototype.dispose=function(){return t.FeedbackEffect.prototype.dispose.call(this),this._frequency.dispose(),this._frequency=null,this._delayA.disconnect(),this._delayA=null,this._delayB.disconnect(),this._delayB=null,this._lfoA.dispose(),this._lfoA=null,this._lfoB.dispose(),this._lfoB=null,this._crossFade.dispose(),this._crossFade=null,this._crossFadeLFO.dispose(),this._crossFadeLFO=null,this._writable(\"delayTime\"),this._feedbackDelay.dispose(),this._feedbackDelay=null,this.delayTime=null,this},t.PitchShift}),t(function(t){return t.StereoFeedbackEffect=function(){var e=this.optionsObject(arguments,[\"feedback\"],t.FeedbackEffect.defaults);t.StereoEffect.call(this,e),this.feedback=new t.Signal(e.feedback,t.Type.NormalRange),this._feedbackL=new t.Gain,this._feedbackR=new t.Gain,this.effectReturnL.chain(this._feedbackL,this.effectSendL),this.effectReturnR.chain(this._feedbackR,this.effectSendR),this.feedback.fan(this._feedbackL.gain,this._feedbackR.gain),this._readOnly([\"feedback\"])},t.extend(t.StereoFeedbackEffect,t.FeedbackEffect),t.StereoFeedbackEffect.prototype.dispose=function(){return t.StereoEffect.prototype.dispose.call(this),this._writable([\"feedback\"]),this.feedback.dispose(),this.feedback=null,this._feedbackL.dispose(),this._feedbackL=null,this._feedbackR.dispose(),this._feedbackR=null,this},t.StereoFeedbackEffect}),t(function(t){return t.StereoWidener=function(){var e=this.optionsObject(arguments,[\"width\"],t.StereoWidener.defaults);t.MidSideEffect.call(this,e),this.width=new t.Signal(e.width,t.Type.NormalRange),this._midMult=new t.Expr(\"$0 * ($1 * (1 - $2))\"),this._sideMult=new t.Expr(\"$0 * ($1 * $2)\"),this._two=new t.Signal(2),this._two.connect(this._midMult,0,1),this.width.connect(this._midMult,0,2),this._two.connect(this._sideMult,0,1),this.width.connect(this._sideMult,0,2),this.midSend.chain(this._midMult,this.midReturn),this.sideSend.chain(this._sideMult,this.sideReturn),this._readOnly([\"width\"])},t.extend(t.StereoWidener,t.MidSideEffect),t.StereoWidener.defaults={width:.5},t.StereoWidener.prototype.dispose=function(){return t.MidSideEffect.prototype.dispose.call(this),this._writable([\"width\"]),this.width.dispose(),this.width=null,this._midMult.dispose(),this._midMult=null,this._sideMult.dispose(),this._sideMult=null,this._two.dispose(),this._two=null,this},t.StereoWidener}),t(function(t){return t.Tremolo=function(){var e=this.optionsObject(arguments,[\"frequency\",\"depth\"],t.Tremolo.defaults);t.StereoEffect.call(this,e),this._lfoL=new t.LFO({phase:e.spread,min:1,max:0}),this._lfoR=new t.LFO({phase:e.spread,min:1,max:0}),this._amplitudeL=new t.Gain,this._amplitudeR=new t.Gain,this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.depth=new t.Signal(e.depth,t.Type.NormalRange),this._readOnly([\"frequency\",\"depth\"]),this.effectSendL.chain(this._amplitudeL,this.effectReturnL),this.effectSendR.chain(this._amplitudeR,this.effectReturnR),this._lfoL.connect(this._amplitudeL.gain),this._lfoR.connect(this._amplitudeR.gain),this.frequency.fan(this._lfoL.frequency,this._lfoR.frequency),this.depth.fan(this._lfoR.amplitude,this._lfoL.amplitude),this.type=e.type,this.spread=e.spread},t.extend(t.Tremolo,t.StereoEffect),t.Tremolo.defaults={frequency:10,type:\"sine\",depth:.5,spread:180},t.Tremolo.prototype.start=function(t){return this._lfoL.start(t),this._lfoR.start(t),this},t.Tremolo.prototype.stop=function(t){return this._lfoL.stop(t),this._lfoR.stop(t),this},t.Tremolo.prototype.sync=function(t){return this._lfoL.sync(t),this._lfoR.sync(t),this},t.Tremolo.prototype.unsync=function(){return this._lfoL.unsync(),this._lfoR.unsync(),this},Object.defineProperty(t.Tremolo.prototype,\"type\",{get:function(){return this._lfoL.type},set:function(t){this._lfoL.type=t,this._lfoR.type=t}}),Object.defineProperty(t.Tremolo.prototype,\"spread\",{get:function(){return this._lfoR.phase-this._lfoL.phase},set:function(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/2+90}}),t.Tremolo.prototype.dispose=function(){return t.StereoEffect.prototype.dispose.call(this),this._writable([\"frequency\",\"depth\"]),this._lfoL.dispose(),this._lfoL=null,this._lfoR.dispose(),this._lfoR=null,this._amplitudeL.dispose(),this._amplitudeL=null,this._amplitudeR.dispose(),this._amplitudeR=null,this.frequency=null,this.depth=null,this},t.Tremolo}),t(function(t){return t.Vibrato=function(){var e=this.optionsObject(arguments,[\"frequency\",\"depth\"],t.Vibrato.defaults);t.Effect.call(this,e),this._delayNode=new t.Delay(0,e.maxDelay),this._lfo=new t.LFO({type:e.type,min:0,max:e.maxDelay,frequency:e.frequency,phase:-90}).start().connect(this._delayNode.delayTime),this.frequency=this._lfo.frequency,this.depth=this._lfo.amplitude,this.depth.value=e.depth,this._readOnly([\"frequency\",\"depth\"]),this.effectSend.chain(this._delayNode,this.effectReturn)},t.extend(t.Vibrato,t.Effect),t.Vibrato.defaults={maxDelay:.005,frequency:5,depth:.1,type:\"sine\"},Object.defineProperty(t.Vibrato.prototype,\"type\",{get:function(){return this._lfo.type},set:function(t){this._lfo.type=t}}),t.Vibrato.prototype.dispose=function(){t.Effect.prototype.dispose.call(this),this._delayNode.dispose(),this._delayNode=null,this._lfo.dispose(),this._lfo=null,this._writable([\"frequency\",\"depth\"]),this.frequency=null,this.depth=null},t.Vibrato}),t(function(t){return t.Event=function(){var e=this.optionsObject(arguments,[\"callback\",\"value\"],t.Event.defaults);this._loop=e.loop,this.callback=e.callback,this.value=e.value,this._loopStart=this.toTicks(e.loopStart),this._loopEnd=this.toTicks(e.loopEnd),this._state=new t.TimelineState(t.State.Stopped),this._playbackRate=1,this._startOffset=0,this.probability=e.probability,this.humanize=e.humanize,this.mute=e.mute,this.playbackRate=e.playbackRate},t.extend(t.Event),t.Event.defaults={callback:t.noOp,loop:!1,loopEnd:\"1m\",loopStart:0,playbackRate:1,value:null,probability:1,mute:!1,humanize:!1},t.Event.prototype._rescheduleEvents=function(e){return e=this.defaultArg(e,-1),this._state.forEachFrom(e,function(e){var i;if(e.state===t.State.Started){this.isUndef(e.id)||t.Transport.clear(e.id);var s=e.time+Math.round(this.startOffset/this._playbackRate);if(this._loop){i=1/0,this.isNumber(this._loop)&&(i=this._loop*this._getLoopDuration());var n=this._state.getAfter(s);null!==n&&(i=Math.min(i,n.time-s)),i!==1/0&&(this._state.setStateAtTime(t.State.Stopped,s+i+1),i=t.Time(i,\"i\"));var o=t.Time(this._getLoopDuration(),\"i\");e.id=t.Transport.scheduleRepeat(this._tick.bind(this),o,t.TransportTime(s,\"i\"),i)}else e.id=t.Transport.schedule(this._tick.bind(this),s+\"i\")}}.bind(this)),this},Object.defineProperty(t.Event.prototype,\"state\",{get:function(){return this._state.getValueAtTime(t.Transport.ticks)}}),Object.defineProperty(t.Event.prototype,\"startOffset\",{get:function(){return this._startOffset},set:function(t){this._startOffset=t}}),t.Event.prototype.start=function(e){return e=this.toTicks(e),this._state.getValueAtTime(e)===t.State.Stopped&&(this._state.add({state:t.State.Started,time:e,id:void 0}),this._rescheduleEvents(e)),this},t.Event.prototype.stop=function(e){if(this.cancel(e),e=this.toTicks(e),this._state.getValueAtTime(e)===t.State.Started){this._state.setStateAtTime(t.State.Stopped,e);var i=this._state.getBefore(e),s=e;null!==i&&(s=i.time),this._rescheduleEvents(s)}return this},t.Event.prototype.cancel=function(e){return e=this.defaultArg(e,-1/0),e=this.toTicks(e),this._state.forEachFrom(e,function(e){t.Transport.clear(e.id)}),this._state.cancel(e),this},t.Event.prototype._tick=function(e){if(!this.mute&&this._state.getValueAtTime(t.Transport.ticks)===t.State.Started){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){var i=.02;this.isBoolean(this.humanize)||(i=this.toSeconds(this.humanize)),e+=(2*Math.random()-1)*i}this.callback(e,this.value)}},t.Event.prototype._getLoopDuration=function(){return Math.round((this._loopEnd-this._loopStart)/this._playbackRate)},Object.defineProperty(t.Event.prototype,\"loop\",{get:function(){return this._loop},set:function(t){this._loop=t,this._rescheduleEvents()}}),Object.defineProperty(t.Event.prototype,\"playbackRate\",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._rescheduleEvents()}}),Object.defineProperty(t.Event.prototype,\"loopEnd\",{get:function(){return t.TransportTime(this._loopEnd,\"i\").toNotation()},set:function(t){this._loopEnd=this.toTicks(t),this._loop&&this._rescheduleEvents()}}),Object.defineProperty(t.Event.prototype,\"loopStart\",{get:function(){return t.TransportTime(this._loopStart,\"i\").toNotation()},set:function(t){this._loopStart=this.toTicks(t),this._loop&&this._rescheduleEvents()}}),Object.defineProperty(t.Event.prototype,\"progress\",{get:function(){if(this._loop){var e=t.Transport.ticks,i=this._state.get(e);if(null!==i&&i.state===t.State.Started){var s=this._getLoopDuration();return(e-i.time)%s/s}return 0}return 0}}),t.Event.prototype.dispose=function(){this.cancel(),this._state.dispose(),this._state=null,this.callback=null,this.value=null},t.Event}),t(function(t){return t.Loop=function(){var e=this.optionsObject(arguments,[\"callback\",\"interval\"],t.Loop.defaults);this._event=new t.Event({callback:this._tick.bind(this),loop:!0,loopEnd:e.interval,playbackRate:e.playbackRate,probability:e.probability}),this.callback=e.callback,this.iterations=e.iterations},t.extend(t.Loop),t.Loop.defaults={interval:\"4n\",callback:t.noOp,playbackRate:1,iterations:1/0,probability:!0,mute:!1},t.Loop.prototype.start=function(t){return this._event.start(t),this},t.Loop.prototype.stop=function(t){return this._event.stop(t),this},t.Loop.prototype.cancel=function(t){return this._event.cancel(t),this},t.Loop.prototype._tick=function(t){this.callback(t)},Object.defineProperty(t.Loop.prototype,\"state\",{get:function(){return this._event.state}}),Object.defineProperty(t.Loop.prototype,\"progress\",{get:function(){return this._event.progress}}),Object.defineProperty(t.Loop.prototype,\"interval\",{get:function(){return this._event.loopEnd},set:function(t){this._event.loopEnd=t}}),Object.defineProperty(t.Loop.prototype,\"playbackRate\",{get:function(){return this._event.playbackRate},set:function(t){this._event.playbackRate=t}}),Object.defineProperty(t.Loop.prototype,\"humanize\",{get:function(){return this._event.humanize},set:function(t){this._event.humanize=t}}),Object.defineProperty(t.Loop.prototype,\"probability\",{get:function(){return this._event.probability},set:function(t){this._event.probability=t}}),Object.defineProperty(t.Loop.prototype,\"mute\",{get:function(){return this._event.mute},set:function(t){this._event.mute=t}}),Object.defineProperty(t.Loop.prototype,\"iterations\",{get:function(){return!0===this._event.loop?1/0:this._event.loop},set:function(t){this._event.loop=t===1/0||t}}),t.Loop.prototype.dispose=function(){this._event.dispose(),this._event=null,this.callback=null},t.Loop}),t(function(t){return t.Part=function(){var e=this.optionsObject(arguments,[\"callback\",\"events\"],t.Part.defaults);this._loop=e.loop,this._loopStart=this.toTicks(e.loopStart),this._loopEnd=this.toTicks(e.loopEnd),this._playbackRate=e.playbackRate,this._probability=e.probability,this._humanize=e.humanize,this._startOffset=0,this._state=new t.TimelineState(t.State.Stopped),this._events=[],this.callback=e.callback,this.mute=e.mute;var i=this.defaultArg(e.events,[]);if(!this.isUndef(e.events))for(var s=0;s<i.length;s++)Array.isArray(i[s])?this.add(i[s][0],i[s][1]):this.add(i[s])},t.extend(t.Part,t.Event),t.Part.defaults={callback:t.noOp,loop:!1,loopEnd:\"1m\",loopStart:0,playbackRate:1,probability:1,humanize:!1,mute:!1},t.Part.prototype.start=function(e,i){var s=this.toTicks(e);return this._state.getValueAtTime(s)!==t.State.Started&&(i=this._loop?this.defaultArg(i,this._loopStart):this.defaultArg(i,0),i=this.toTicks(i),this._state.add({state:t.State.Started,time:s,offset:i}),this._forEach(function(t){this._startNote(t,s,i)})),this},t.Part.prototype._startNote=function(e,i,s){i-=s,this._loop?e.startOffset>=this._loopStart&&e.startOffset<this._loopEnd?(e.startOffset<s&&(i+=this._getLoopDuration()),e.start(t.TransportTime(i,\"i\"))):e.startOffset<this._loopStart&&e.startOffset>=s&&(e.loop=!1,e.start(t.TransportTime(i,\"i\"))):e.startOffset>=s&&e.start(t.TransportTime(i,\"i\"))},Object.defineProperty(t.Part.prototype,\"startOffset\",{get:function(){return this._startOffset},set:function(t){this._startOffset=t,this._forEach(function(t){t.startOffset+=this._startOffset})}}),t.Part.prototype.stop=function(e){var i=this.toTicks(e);return this._state.cancel(i),this._state.setStateAtTime(t.State.Stopped,i),this._forEach(function(t){t.stop(e)}),this},t.Part.prototype.at=function(e,i){e=t.TransportTime(e);for(var s=t.Time(1,\"i\").toSeconds(),n=0;n<this._events.length;n++){var o=this._events[n];if(Math.abs(e.toTicks()-o.startOffset)<s)return this.isUndef(i)||(o.value=i),o}return this.isUndef(i)?null:(this.add(e,i),this._events[this._events.length-1])},t.Part.prototype.add=function(e,i){e.hasOwnProperty(\"time\")&&(i=e,e=i.time),e=this.toTicks(e);var s;return i instanceof t.Event?(s=i,s.callback=this._tick.bind(this)):s=new t.Event({callback:this._tick.bind(this),value:i}),s.startOffset=e,s.set({loopEnd:this.loopEnd,loopStart:this.loopStart,loop:this.loop,humanize:this.humanize,playbackRate:this.playbackRate,probability:this.probability}),this._events.push(s),this._restartEvent(s),this},t.Part.prototype._restartEvent=function(e){this._state.forEach(function(i){i.state===t.State.Started?this._startNote(e,i.time,i.offset):e.stop(t.TransportTime(i.time,\"i\"))}.bind(this))},t.Part.prototype.remove=function(e,i){e.hasOwnProperty(\"time\")&&(i=e,e=i.time),e=this.toTicks(e);for(var s=this._events.length-1;s>=0;s--){var n=this._events[s];n instanceof t.Part?n.remove(e,i):n.startOffset===e&&(this.isUndef(i)||!this.isUndef(i)&&n.value===i)&&(this._events.splice(s,1),n.dispose())}return this},t.Part.prototype.removeAll=function(){return this._forEach(function(t){t.dispose()}),this._events=[],this},t.Part.prototype.cancel=function(t){return t=this.toTicks(t),this._forEach(function(e){e.cancel(t)}),this._state.cancel(t),this},t.Part.prototype._forEach=function(e,i){i=this.defaultArg(i,this);for(var s=this._events.length-1;s>=0;s--){var n=this._events[s];n instanceof t.Part?n._forEach(e,i):e.call(i,n)}return this},t.Part.prototype._setAll=function(t,e){this._forEach(function(i){i[t]=e})},t.Part.prototype._tick=function(t,e){this.mute||this.callback(t,e)},t.Part.prototype._testLoopBoundries=function(e){e.startOffset<this._loopStart||e.startOffset>=this._loopEnd?e.cancel(0):e.state===t.State.Stopped&&this._restartEvent(e)},Object.defineProperty(t.Part.prototype,\"probability\",{get:function(){return this._probability},set:function(t){this._probability=t,this._setAll(\"probability\",t)}}),Object.defineProperty(t.Part.prototype,\"humanize\",{get:function(){return this._humanize},set:function(t){this._humanize=t,this._setAll(\"humanize\",t)}}),Object.defineProperty(t.Part.prototype,\"loop\",{get:function(){return this._loop},set:function(t){this._loop=t,this._forEach(function(e){e._loopStart=this._loopStart,e._loopEnd=this._loopEnd,e.loop=t,this._testLoopBoundries(e)})}}),Object.defineProperty(t.Part.prototype,\"loopEnd\",{get:function(){return t.TransportTime(this._loopEnd,\"i\").toNotation()},set:function(t){this._loopEnd=this.toTicks(t),this._loop&&this._forEach(function(e){e.loopEnd=t,this._testLoopBoundries(e)})}}),Object.defineProperty(t.Part.prototype,\"loopStart\",{get:function(){return t.TransportTime(this._loopStart,\"i\").toNotation()},set:function(t){this._loopStart=this.toTicks(t),this._loop&&this._forEach(function(t){t.loopStart=this.loopStart,this._testLoopBoundries(t)})}}),Object.defineProperty(t.Part.prototype,\"playbackRate\",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._setAll(\"playbackRate\",t)}}),Object.defineProperty(t.Part.prototype,\"length\",{get:function(){return this._events.length}}),t.Part.prototype.dispose=function(){return this.removeAll(),this._state.dispose(),this._state=null,this.callback=null,this._events=null,this},t.Part}),t(function(t){return t.Pattern=function(){var e=this.optionsObject(arguments,[\"callback\",\"values\",\"pattern\"],t.Pattern.defaults);t.Loop.call(this,e),this._pattern=new t.CtrlPattern({values:e.values,type:e.pattern,index:e.index})},t.extend(t.Pattern,t.Loop),t.Pattern.defaults={pattern:t.CtrlPattern.Type.Up,values:[]},t.Pattern.prototype._tick=function(t){this.callback(t,this._pattern.value),this._pattern.next()},Object.defineProperty(t.Pattern.prototype,\"index\",{get:function(){return this._pattern.index},set:function(t){this._pattern.index=t}}),Object.defineProperty(t.Pattern.prototype,\"values\",{get:function(){return this._pattern.values},set:function(t){this._pattern.values=t}}),Object.defineProperty(t.Pattern.prototype,\"value\",{get:function(){return this._pattern.value}}),Object.defineProperty(t.Pattern.prototype,\"pattern\",{get:function(){return this._pattern.type},set:function(t){this._pattern.type=t}}),t.Pattern.prototype.dispose=function(){t.Loop.prototype.dispose.call(this),this._pattern.dispose(),this._pattern=null},t.Pattern}),t(function(t){return t.Sequence=function(){var e=this.optionsObject(arguments,[\"callback\",\"events\",\"subdivision\"],t.Sequence.defaults),i=e.events;if(delete e.events,t.Part.call(this,e),this._subdivision=this.toTicks(e.subdivision),this.isUndef(e.loopEnd)&&!this.isUndef(i)&&(this._loopEnd=i.length*this._subdivision),this._loop=!0,!this.isUndef(i))for(var s=0;s<i.length;s++)this.add(s,i[s])},t.extend(t.Sequence,t.Part),t.Sequence.defaults={subdivision:\"4n\"},Object.defineProperty(t.Sequence.prototype,\"subdivision\",{get:function(){return t.Time(this._subdivision,\"i\").toNotation()}}),t.Sequence.prototype.at=function(e,i){return this.isArray(i)&&this.remove(e),t.Part.prototype.at.call(this,this._indexTime(e),i)},t.Sequence.prototype.add=function(e,i){if(null===i)return this;if(this.isArray(i)){var s=Math.round(this._subdivision/i.length);i=new t.Sequence(this._tick.bind(this),i,t.Time(s,\"i\"))}return t.Part.prototype.add.call(this,this._indexTime(e),i),this},t.Sequence.prototype.remove=function(e,i){return t.Part.prototype.remove.call(this,this._indexTime(e),i),this},t.Sequence.prototype._indexTime=function(e){return e instanceof t.TransportTime?e:t.TransportTime(e*this._subdivision+this.startOffset,\"i\")},t.Sequence.prototype.dispose=function(){return t.Part.prototype.dispose.call(this),this},t.Sequence}),t(function(t){return t.PulseOscillator=function(){var e=this.optionsObject(arguments,[\"frequency\",\"width\"],t.Oscillator.defaults);t.Source.call(this,e),this.width=new t.Signal(e.width,t.Type.NormalRange),this._widthGate=new t.Gain,this._sawtooth=new t.Oscillator({frequency:e.frequency,detune:e.detune,type:\"sawtooth\",phase:e.phase}),this.frequency=this._sawtooth.frequency,this.detune=this._sawtooth.detune,this._thresh=new t.WaveShaper(function(t){return t<0?-1:1}),this._sawtooth.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),this._readOnly([\"width\",\"frequency\",\"detune\"])},t.extend(t.PulseOscillator,t.Oscillator),t.PulseOscillator.defaults={frequency:440,detune:0,phase:0,width:.2},t.PulseOscillator.prototype._start=function(t){t=this.toSeconds(t),this._sawtooth.start(t),this._widthGate.gain.setValueAtTime(1,t)},t.PulseOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._sawtooth.stop(t),this._widthGate.gain.setValueAtTime(0,t)},Object.defineProperty(t.PulseOscillator.prototype,\"phase\",{get:function(){return this._sawtooth.phase},set:function(t){this._sawtooth.phase=t}}),Object.defineProperty(t.PulseOscillator.prototype,\"type\",{get:function(){return\"pulse\"}}),Object.defineProperty(t.PulseOscillator.prototype,\"partials\",{get:function(){return[]}}),t.PulseOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._sawtooth.dispose(),this._sawtooth=null,this._writable([\"width\",\"frequency\",\"detune\"]),this.width.dispose(),this.width=null,this._widthGate.dispose(),this._widthGate=null,this._thresh.dispose(),this._thresh=null,this.frequency=null,this.detune=null,this},t.PulseOscillator}),t(function(t){return t.PWMOscillator=function(){var e=this.optionsObject(arguments,[\"frequency\",\"modulationFrequency\"],t.PWMOscillator.defaults);t.Source.call(this,e),this._pulse=new t.PulseOscillator(e.modulationFrequency),this._pulse._sawtooth.type=\"sine\",this._modulator=new t.Oscillator({frequency:e.frequency,detune:e.detune,phase:e.phase}),this._scale=new t.Multiply(2),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this.modulationFrequency=this._pulse.frequency,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),this._readOnly([\"modulationFrequency\",\"frequency\",\"detune\"])},t.extend(t.PWMOscillator,t.Oscillator),t.PWMOscillator.defaults={frequency:440,detune:0,phase:0,modulationFrequency:.4},t.PWMOscillator.prototype._start=function(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)},t.PWMOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)},Object.defineProperty(t.PWMOscillator.prototype,\"type\",{get:function(){return\"pwm\"}}),Object.defineProperty(t.PWMOscillator.prototype,\"partials\",{get:function(){return[]}}),Object.defineProperty(t.PWMOscillator.prototype,\"phase\",{get:function(){return this._modulator.phase},set:function(t){this._modulator.phase=t}}),t.PWMOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._pulse.dispose(),this._pulse=null,this._scale.dispose(),this._scale=null,this._modulator.dispose(),this._modulator=null,this._writable([\"modulationFrequency\",\"frequency\",\"detune\"]),this.frequency=null,this.detune=null,this.modulationFrequency=null,this},t.PWMOscillator}),t(function(t){return t.FMOscillator=function(){var e=this.optionsObject(arguments,[\"frequency\",\"type\",\"modulationType\"],t.FMOscillator.defaults);t.Source.call(this,e),this._carrier=new t.Oscillator(e.frequency,e.type),this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=this._carrier.detune,this.detune.value=e.detune,this.modulationIndex=new t.Multiply(e.modulationIndex),this.modulationIndex.units=t.Type.Positive,this._modulator=new t.Oscillator(e.frequency,e.modulationType),this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this._modulationNode=new t.Gain(0),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),this.phase=e.phase,this._readOnly([\"modulationIndex\",\"frequency\",\"detune\",\"harmonicity\"])},t.extend(t.FMOscillator,t.Oscillator),t.FMOscillator.defaults={frequency:440,detune:0,phase:0,modulationIndex:2,modulationType:\"square\",harmonicity:1},t.FMOscillator.prototype._start=function(t){t=this.toSeconds(t),this._modulator.start(t),this._carrier.start(t)},t.FMOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._modulator.stop(t),this._carrier.stop(t)},Object.defineProperty(t.FMOscillator.prototype,\"type\",{get:function(){return this._carrier.type},set:function(t){this._carrier.type=t}}),Object.defineProperty(t.FMOscillator.prototype,\"modulationType\",{get:function(){return this._modulator.type},set:function(t){this._modulator.type=t}}),Object.defineProperty(t.FMOscillator.prototype,\"phase\",{get:function(){return this._carrier.phase},set:function(t){this._carrier.phase=t,this._modulator.phase=t}}),Object.defineProperty(t.FMOscillator.prototype,\"partials\",{get:function(){return this._carrier.partials},set:function(t){this._carrier.partials=t}}),t.FMOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._writable([\"modulationIndex\",\"frequency\",\"detune\",\"harmonicity\"]),this.frequency.dispose(),this.frequency=null,this.detune=null,this.harmonicity.dispose(),this.harmonicity=null,this._carrier.dispose(),this._carrier=null,this._modulator.dispose(),this._modulator=null,this._modulationNode.dispose(),this._modulationNode=null,this.modulationIndex.dispose(),this.modulationIndex=null,this},t.FMOscillator}),t(function(t){return t.AMOscillator=function(){var e=this.optionsObject(arguments,[\"frequency\",\"type\",\"modulationType\"],t.AMOscillator.defaults);t.Source.call(this,e),this._carrier=new t.Oscillator(e.frequency,e.type),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this.detune.value=e.detune,this._modulator=new t.Oscillator(e.frequency,e.modulationType),this._modulationScale=new t.AudioToGain,this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this._modulationNode=new t.Gain(0),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.detune.connect(this._modulator.detune),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),this.phase=e.phase,this._readOnly([\"frequency\",\"detune\",\"harmonicity\"])},t.extend(t.AMOscillator,t.Oscillator),t.AMOscillator.defaults={frequency:440,detune:0,phase:0,modulationType:\"square\",harmonicity:1},t.AMOscillator.prototype._start=function(t){t=this.toSeconds(t),this._modulator.start(t),this._carrier.start(t)},t.AMOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._modulator.stop(t),this._carrier.stop(t)},Object.defineProperty(t.AMOscillator.prototype,\"type\",{get:function(){return this._carrier.type},set:function(t){this._carrier.type=t}}),Object.defineProperty(t.AMOscillator.prototype,\"modulationType\",{get:function(){return this._modulator.type},set:function(t){this._modulator.type=t}}),Object.defineProperty(t.AMOscillator.prototype,\"phase\",{get:function(){return this._carrier.phase},set:function(t){this._carrier.phase=t,this._modulator.phase=t}}),Object.defineProperty(t.AMOscillator.prototype,\"partials\",{get:function(){return this._carrier.partials},set:function(t){this._carrier.partials=t}}),t.AMOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._writable([\"frequency\",\"detune\",\"harmonicity\"]),this.frequency=null,this.detune=null,this.harmonicity.dispose(),this.harmonicity=null,this._carrier.dispose(),this._carrier=null,this._modulator.dispose(),this._modulator=null,this._modulationNode.dispose(),this._modulationNode=null,this._modulationScale.dispose(),this._modulationScale=null,this},t.AMOscillator}),t(function(t){return t.FatOscillator=function(){var e=this.optionsObject(arguments,[\"frequency\",\"type\",\"spread\"],t.FatOscillator.defaults);t.Source.call(this,e),this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this._oscillators=[],this._spread=e.spread,this._type=e.type,this._phase=e.phase,this._partials=this.defaultArg(e.partials,[]),this.count=e.count,this._readOnly([\"frequency\",\"detune\"])},t.extend(t.FatOscillator,t.Oscillator),t.FatOscillator.defaults={frequency:440,detune:0,phase:0,spread:20,count:3,type:\"sawtooth\"},t.FatOscillator.prototype._start=function(t){t=this.toSeconds(t),this._forEach(function(e){e.start(t)})},t.FatOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._forEach(function(e){e.stop(t)})},t.FatOscillator.prototype._forEach=function(t){for(var e=0;e<this._oscillators.length;e++)t.call(this,this._oscillators[e],e)},Object.defineProperty(t.FatOscillator.prototype,\"type\",{get:function(){return this._type},set:function(t){this._type=t,this._forEach(function(e){e.type=t})}}),Object.defineProperty(t.FatOscillator.prototype,\"spread\",{get:function(){return this._spread},set:function(t){if(this._spread=t,this._oscillators.length>1){var e=-t/2,i=t/(this._oscillators.length-1);this._forEach(function(t,s){t.detune.value=e+i*s})}}}),Object.defineProperty(t.FatOscillator.prototype,\"count\",{get:function(){return this._oscillators.length},set:function(e){if(e=Math.max(e,1),this._oscillators.length!==e){this._forEach(function(t){t.dispose()}),this._oscillators=[];for(var i=0;i<e;i++){var s=new t.Oscillator;this.type===t.Oscillator.Type.Custom?s.partials=this._partials:s.type=this._type,s.phase=this._phase,s.volume.value=-6-e,this.frequency.connect(s.frequency),this.detune.connect(s.detune),s.connect(this.output),this._oscillators[i]=s}this.spread=this._spread,this.state===t.State.Started&&this._forEach(function(t){t.start()})}}}),Object.defineProperty(t.FatOscillator.prototype,\"phase\",{get:function(){return this._phase},set:function(t){this._phase=t,this._forEach(function(e){e.phase=t})}}),Object.defineProperty(t.FatOscillator.prototype,\"partials\",{get:function(){return this._partials},set:function(e){this._partials=e,this._type=t.Oscillator.Type.Custom,this._forEach(function(t){t.partials=e})}}),t.FatOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._writable([\"frequency\",\"detune\"]),this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this._forEach(function(t){t.dispose()}),this._oscillators=null,this._partials=null,this},t.FatOscillator}),t(function(t){t.OmniOscillator=function(){var e=this.optionsObject(arguments,[\"frequency\",\"type\"],t.OmniOscillator.defaults);t.Source.call(this,e),this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this._sourceType=void 0,this._oscillator=null,this.type=e.type,this._readOnly([\"frequency\",\"detune\"]),this.set(e)},t.extend(t.OmniOscillator,t.Oscillator),t.OmniOscillator.defaults={frequency:440,detune:0,type:\"sine\",phase:0};var e={Pulse:\"PulseOscillator\",PWM:\"PWMOscillator\",Osc:\"Oscillator\",FM:\"FMOscillator\",AM:\"AMOscillator\",Fat:\"FatOscillator\"};return t.OmniOscillator.prototype._start=function(t){this._oscillator.start(t)},t.OmniOscillator.prototype._stop=function(t){this._oscillator.stop(t)},Object.defineProperty(t.OmniOscillator.prototype,\"type\",{get:function(){var t=\"\";return this._sourceType===e.FM?t=\"fm\":this._sourceType===e.AM?t=\"am\":this._sourceType===e.Fat&&(t=\"fat\"),t+this._oscillator.type},set:function(t){\"fm\"===t.substr(0,2)?(this._createNewOscillator(e.FM),this._oscillator.type=t.substr(2)):\"am\"===t.substr(0,2)?(this._createNewOscillator(e.AM),this._oscillator.type=t.substr(2)):\"fat\"===t.substr(0,3)?(this._createNewOscillator(e.Fat),this._oscillator.type=t.substr(3)):\"pwm\"===t?this._createNewOscillator(e.PWM):\"pulse\"===t?this._createNewOscillator(e.Pulse):(this._createNewOscillator(e.Osc),this._oscillator.type=t)}}),Object.defineProperty(t.OmniOscillator.prototype,\"partials\",{get:function(){return this._oscillator.partials},set:function(t){this._oscillator.partials=t}}),t.OmniOscillator.prototype.set=function(e,i){return\"type\"===e?this.type=i:this.isObject(e)&&e.hasOwnProperty(\"type\")&&(this.type=e.type),t.prototype.set.apply(this,arguments),this},t.OmniOscillator.prototype._createNewOscillator=function(e){if(e!==this._sourceType){this._sourceType=e;var i=t[e],s=this.now()+this.blockTime;if(null!==this._oscillator){var n=this._oscillator;n.stop(s),setTimeout(function(){n.dispose(),n=null},1e3*this.blockTime)}this._oscillator=new i,this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this.state===t.State.Started&&this._oscillator.start(s)}},Object.defineProperty(t.OmniOscillator.prototype,\"phase\",{get:function(){return this._oscillator.phase},set:function(t){this._oscillator.phase=t}}),Object.defineProperty(t.OmniOscillator.prototype,\"width\",{get:function(){if(this._sourceType===e.Pulse)return this._oscillator.width}}),Object.defineProperty(t.OmniOscillator.prototype,\"count\",{get:function(){if(this._sourceType===e.Fat)return this._oscillator.count},set:function(t){this._sourceType===e.Fat&&(this._oscillator.count=t)}}),Object.defineProperty(t.OmniOscillator.prototype,\"spread\",{get:function(){if(this._sourceType===e.Fat)return this._oscillator.spread},set:function(t){this._sourceType===e.Fat&&(this._oscillator.spread=t)}}),Object.defineProperty(t.OmniOscillator.prototype,\"modulationType\",{get:function(){if(this._sourceType===e.FM||this._sourceType===e.AM)return this._oscillator.modulationType},set:function(t){this._sourceType!==e.FM&&this._sourceType!==e.AM||(this._oscillator.modulationType=t)}}),Object.defineProperty(t.OmniOscillator.prototype,\"modulationIndex\",{get:function(){if(this._sourceType===e.FM)return this._oscillator.modulationIndex}}),Object.defineProperty(t.OmniOscillator.prototype,\"harmonicity\",{get:function(){if(this._sourceType===e.FM||this._sourceType===e.AM)return this._oscillator.harmonicity}}),Object.defineProperty(t.OmniOscillator.prototype,\"modulationFrequency\",{get:function(){if(this._sourceType===e.PWM)return this._oscillator.modulationFrequency}}),t.OmniOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._writable([\"frequency\",\"detune\"]),this.detune.dispose(),this.detune=null,this.frequency.dispose(),this.frequency=null,this._oscillator.dispose(),this._oscillator=null,this._sourceType=null,this},t.OmniOscillator}),t(function(t){return t.Instrument=function(e){e=this.defaultArg(e,t.Instrument.defaults),this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._readOnly(\"volume\")},t.extend(t.Instrument),t.Instrument.defaults={volume:0},t.Instrument.prototype.triggerAttack=t.noOp,t.Instrument.prototype.triggerRelease=t.noOp,t.Instrument.prototype.triggerAttackRelease=function(t,e,i,s){return i=this.isUndef(i)?this.now()+this.blockTime:this.toSeconds(i),e=this.toSeconds(e),this.triggerAttack(t,i,s),this.triggerRelease(i+e),this},t.Instrument.prototype.dispose=function(){return t.prototype.dispose.call(this),this._volume.dispose(),this._volume=null,this._writable([\"volume\"]),this.volume=null,this},t.Instrument}),t(function(t){return t.Monophonic=function(e){e=this.defaultArg(e,t.Monophonic.defaults),t.Instrument.call(this,e),this.portamento=e.portamento},t.extend(t.Monophonic,t.Instrument),t.Monophonic.defaults={portamento:0},t.Monophonic.prototype.triggerAttack=function(t,e,i){return e=this.isUndef(e)?this.now()+this.blockTime:this.toSeconds(e),this._triggerEnvelopeAttack(e,i),this.setNote(t,e),this},t.Monophonic.prototype.triggerRelease=function(t){return t=this.isUndef(t)?this.now()+this.blockTime:this.toSeconds(t),this._triggerEnvelopeRelease(t),this},t.Monophonic.prototype._triggerEnvelopeAttack=function(){},t.Monophonic.prototype._triggerEnvelopeRelease=function(){},t.Monophonic.prototype.setNote=function(t,e){if(e=this.toSeconds(e),this.portamento>0){var i=this.frequency.value;this.frequency.setValueAtTime(i,e);var s=this.toSeconds(this.portamento);this.frequency.exponentialRampToValueAtTime(t,e+s)}else this.frequency.setValueAtTime(t,e);return this},t.Monophonic}),t(function(t){return t.Synth=function(e){e=this.defaultArg(e,t.Synth.defaults),t.Monophonic.call(this,e),this.oscillator=new t.OmniOscillator(e.oscillator),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new t.AmplitudeEnvelope(e.envelope),this.oscillator.chain(this.envelope,this.output),this.oscillator.start(),this._readOnly([\"oscillator\",\"frequency\",\"detune\",\"envelope\"])},t.extend(t.Synth,t.Monophonic),t.Synth.defaults={oscillator:{type:\"triangle\"},envelope:{attack:.005,decay:.1,sustain:.3,release:1}},t.Synth.prototype._triggerEnvelopeAttack=function(t,e){return this.envelope.triggerAttack(t,e),this},t.Synth.prototype._triggerEnvelopeRelease=function(t){return this.envelope.triggerRelease(t),this},t.Synth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable([\"oscillator\",\"frequency\",\"detune\",\"envelope\"]),this.oscillator.dispose(),this.oscillator=null,this.envelope.dispose(),this.envelope=null,this.frequency=null,this.detune=null,this},t.Synth}),t(function(t){return t.AMSynth=function(e){e=this.defaultArg(e,t.AMSynth.defaults),t.Monophonic.call(this,e),this._carrier=new t.Synth,this._carrier.volume.value=-10,this.oscillator=this._carrier.oscillator,this.envelope=this._carrier.envelope.set(e.envelope),this._modulator=new t.Synth,this._modulator.volume.value=-10,this.modulation=this._modulator.oscillator.set(e.modulation),this.modulationEnvelope=this._modulator.envelope.set(e.modulationEnvelope),this.frequency=new t.Signal(440,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this._modulationScale=new t.AudioToGain,this._modulationNode=new t.Gain,this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),this._readOnly([\"frequency\",\"harmonicity\",\"oscillator\",\"envelope\",\"modulation\",\"modulationEnvelope\",\"detune\"])},t.extend(t.AMSynth,t.Monophonic),t.AMSynth.defaults={harmonicity:3,detune:0,oscillator:{type:\"sine\"},envelope:{attack:.01,decay:.01,sustain:1,release:.5},modulation:{type:\"square\"},modulationEnvelope:{attack:.5,decay:0,sustain:1,release:.5}},t.AMSynth.prototype._triggerEnvelopeAttack=function(t,e){return t=this.toSeconds(t),this.envelope.triggerAttack(t,e),this.modulationEnvelope.triggerAttack(t,e),this},t.AMSynth.prototype._triggerEnvelopeRelease=function(t){return this.envelope.triggerRelease(t),this.modulationEnvelope.triggerRelease(t),this},t.AMSynth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable([\"frequency\",\"harmonicity\",\"oscillator\",\"envelope\",\"modulation\",\"modulationEnvelope\",\"detune\"]),this._carrier.dispose(),this._carrier=null,this._modulator.dispose(),this._modulator=null,this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this.harmonicity.dispose(),this.harmonicity=null,this._modulationScale.dispose(),this._modulationScale=null,this._modulationNode.dispose(),this._modulationNode=null,this.oscillator=null,this.envelope=null,this.modulationEnvelope=null,this.modulation=null,this},t.AMSynth}),t(function(t){return t.MonoSynth=function(e){e=this.defaultArg(e,t.MonoSynth.defaults),t.Monophonic.call(this,e),this.oscillator=new t.OmniOscillator(e.oscillator),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new t.Filter(e.filter),this.filterEnvelope=new t.FrequencyEnvelope(e.filterEnvelope),this.envelope=new t.AmplitudeEnvelope(e.envelope),this.oscillator.chain(this.filter,this.envelope,this.output),this.oscillator.start(),this.filterEnvelope.connect(this.filter.frequency),this._readOnly([\"oscillator\",\"frequency\",\"detune\",\"filter\",\"filterEnvelope\",\"envelope\"])},t.extend(t.MonoSynth,t.Monophonic),t.MonoSynth.defaults={frequency:\"C4\",detune:0,oscillator:{type:\"square\"},filter:{Q:6,type:\"lowpass\",rolloff:-24},envelope:{attack:.005,decay:.1,sustain:.9,release:1},filterEnvelope:{attack:.06,decay:.2,sustain:.5,release:2,baseFrequency:200,octaves:7,exponent:2}},t.MonoSynth.prototype._triggerEnvelopeAttack=function(t,e){return this.envelope.triggerAttack(t,e),this.filterEnvelope.triggerAttack(t),this},t.MonoSynth.prototype._triggerEnvelopeRelease=function(t){return this.envelope.triggerRelease(t),this.filterEnvelope.triggerRelease(t),this},t.MonoSynth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable([\"oscillator\",\"frequency\",\"detune\",\"filter\",\"filterEnvelope\",\"envelope\"]),this.oscillator.dispose(),this.oscillator=null,this.envelope.dispose(),this.envelope=null,this.filterEnvelope.dispose(),this.filterEnvelope=null,this.filter.dispose(),this.filter=null,this.frequency=null,this.detune=null,this},t.MonoSynth}),t(function(t){return t.DuoSynth=function(e){e=this.defaultArg(e,t.DuoSynth.defaults),t.Monophonic.call(this,e),this.voice0=new t.MonoSynth(e.voice0),this.voice0.volume.value=-10,this.voice1=new t.MonoSynth(e.voice1),this.voice1.volume.value=-10,this._vibrato=new t.LFO(e.vibratoRate,-50,50),this._vibrato.start(),this.vibratoRate=this._vibrato.frequency,this._vibratoGain=new t.Gain(e.vibratoAmount,t.Type.Positive),this.vibratoAmount=this._vibratoGain.gain,this.frequency=new t.Signal(440,t.Type.Frequency),this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this.frequency.connect(this.voice0.frequency),this.frequency.chain(this.harmonicity,this.voice1.frequency),this._vibrato.connect(this._vibratoGain),this._vibratoGain.fan(this.voice0.detune,this.voice1.detune),this.voice0.connect(this.output),this.voice1.connect(this.output),this._readOnly([\"voice0\",\"voice1\",\"frequency\",\"vibratoAmount\",\"vibratoRate\"])},t.extend(t.DuoSynth,t.Monophonic),t.DuoSynth.defaults={vibratoAmount:.5,vibratoRate:5,harmonicity:1.5,voice0:{volume:-10,portamento:0,oscillator:{type:\"sine\"},filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}},voice1:{volume:-10,portamento:0,oscillator:{type:\"sine\"},filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}},t.DuoSynth.prototype._triggerEnvelopeAttack=function(t,e){return t=this.toSeconds(t),this.voice0.envelope.triggerAttack(t,e),this.voice1.envelope.triggerAttack(t,e),this.voice0.filterEnvelope.triggerAttack(t),this.voice1.filterEnvelope.triggerAttack(t),this},t.DuoSynth.prototype._triggerEnvelopeRelease=function(t){return this.voice0.triggerRelease(t),this.voice1.triggerRelease(t),this},t.DuoSynth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable([\"voice0\",\"voice1\",\"frequency\",\"vibratoAmount\",\"vibratoRate\"]),this.voice0.dispose(),this.voice0=null,this.voice1.dispose(),this.voice1=null,this.frequency.dispose(),this.frequency=null,this._vibratoGain.dispose(),this._vibratoGain=null,this._vibrato=null,this.harmonicity.dispose(),this.harmonicity=null,this.vibratoAmount.dispose(),this.vibratoAmount=null,this.vibratoRate=null,this},t.DuoSynth}),t(function(t){return t.FMSynth=function(e){e=this.defaultArg(e,t.FMSynth.defaults),t.Monophonic.call(this,e),this._carrier=new t.Synth(e.carrier),this._carrier.volume.value=-10,this.oscillator=this._carrier.oscillator,this.envelope=this._carrier.envelope.set(e.envelope),this._modulator=new t.Synth(e.modulator),this._modulator.volume.value=-10,this.modulation=this._modulator.oscillator.set(e.modulation),this.modulationEnvelope=this._modulator.envelope.set(e.modulationEnvelope),this.frequency=new t.Signal(440,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this.modulationIndex=new t.Multiply(e.modulationIndex),this.modulationIndex.units=t.Type.Positive,this._modulationNode=new t.Gain(0),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this._readOnly([\"frequency\",\"harmonicity\",\"modulationIndex\",\"oscillator\",\"envelope\",\"modulation\",\"modulationEnvelope\",\"detune\"])},t.extend(t.FMSynth,t.Monophonic),t.FMSynth.defaults={harmonicity:3,modulationIndex:10,detune:0,oscillator:{type:\"sine\"},envelope:{attack:.01,decay:.01,sustain:1,release:.5},modulation:{type:\"square\"},modulationEnvelope:{attack:.5,decay:0,sustain:1,release:.5}},t.FMSynth.prototype._triggerEnvelopeAttack=function(t,e){return t=this.toSeconds(t),this.envelope.triggerAttack(t,e),this.modulationEnvelope.triggerAttack(t),this},t.FMSynth.prototype._triggerEnvelopeRelease=function(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this.modulationEnvelope.triggerRelease(t),this},t.FMSynth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable([\"frequency\",\"harmonicity\",\"modulationIndex\",\"oscillator\",\"envelope\",\"modulation\",\"modulationEnvelope\",\"detune\"]),this._carrier.dispose(),this._carrier=null,this._modulator.dispose(),this._modulator=null,this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this.modulationIndex.dispose(),this.modulationIndex=null,this.harmonicity.dispose(),this.harmonicity=null,this._modulationNode.dispose(),this._modulationNode=null,this.oscillator=null,this.envelope=null,this.modulationEnvelope=null,this.modulation=null,this},t.FMSynth}),t(function(t){return t.MembraneSynth=function(e){e=this.defaultArg(e,t.MembraneSynth.defaults),t.Instrument.call(this,e),this.oscillator=new t.OmniOscillator(e.oscillator).start(),this.envelope=new t.AmplitudeEnvelope(e.envelope),this.octaves=e.octaves,this.pitchDecay=e.pitchDecay,this.oscillator.chain(this.envelope,this.output),this._readOnly([\"oscillator\",\"envelope\"])},t.extend(t.MembraneSynth,t.Instrument),t.MembraneSynth.defaults={pitchDecay:.05,octaves:10,oscillator:{type:\"sine\"},envelope:{attack:.001,decay:.4,sustain:.01,release:1.4,attackCurve:\"exponential\"}},t.MembraneSynth.prototype.triggerAttack=function(t,e,i){e=this.toSeconds(e),t=this.toFrequency(t);var s=t*this.octaves;return this.oscillator.frequency.setValueAtTime(s,e),this.oscillator.frequency.exponentialRampToValueAtTime(t,e+this.toSeconds(this.pitchDecay)),this.envelope.triggerAttack(e,i),this},t.MembraneSynth.prototype.triggerRelease=function(t){return this.envelope.triggerRelease(t),this},t.MembraneSynth.prototype.dispose=function(){return t.Instrument.prototype.dispose.call(this),this._writable([\"oscillator\",\"envelope\"]),this.oscillator.dispose(),this.oscillator=null,this.envelope.dispose(),this.envelope=null,this},t.MembraneSynth}),t(function(t){var e=[1,1.483,1.932,2.546,2.63,3.897];return t.MetalSynth=function(i){i=this.defaultArg(i,t.MetalSynth.defaults),t.Instrument.call(this,i),this.frequency=new t.Signal(i.frequency,t.Type.Frequency),this._oscillators=[],this._freqMultipliers=[],this._amplitue=new t.Gain(0).connect(this.output),this._highpass=new t.Filter({type:\"highpass\",Q:-3.0102999566398125}).connect(this._amplitue),this._octaves=i.octaves,this._filterFreqScaler=new t.Scale(i.resonance,7e3),this.envelope=new t.Envelope({attack:i.envelope.attack,attackCurve:\"linear\",decay:i.envelope.decay,sustain:0,release:i.envelope.release}).chain(this._filterFreqScaler,this._highpass.frequency),this.envelope.connect(this._amplitue.gain);for(var s=0;s<e.length;s++){var n=new t.FMOscillator({type:\"square\",modulationType:\"square\",harmonicity:i.harmonicity,modulationIndex:i.modulationIndex});n.connect(this._highpass).start(0),this._oscillators[s]=n;var o=new t.Multiply(e[s]);this._freqMultipliers[s]=o,this.frequency.chain(o,n.frequency)}this.octaves=i.octaves},t.extend(t.MetalSynth,t.Instrument),t.MetalSynth.defaults={frequency:200,envelope:{attack:.001,decay:1.4,release:.2},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1.5},t.MetalSynth.prototype.triggerAttack=function(t,e){return t=this.toSeconds(t),e=this.defaultArg(e,1),this.envelope.triggerAttack(t,e),this},t.MetalSynth.prototype.triggerRelease=function(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this},t.MetalSynth.prototype.triggerAttackRelease=function(t,e,i){return e=this.toSeconds(e),t=this.toSeconds(t),this.triggerAttack(e,i),this.triggerRelease(e+t),this},Object.defineProperty(t.MetalSynth.prototype,\"modulationIndex\",{get:function(){return this._oscillators[0].modulationIndex.value},set:function(t){for(var e=0;e<this._oscillators.length;e++)this._oscillators[e].modulationIndex.value=t}}),Object.defineProperty(t.MetalSynth.prototype,\"harmonicity\",{get:function(){return this._oscillators[0].harmonicity.value},set:function(t){for(var e=0;e<this._oscillators.length;e++)this._oscillators[e].harmonicity.value=t}}),Object.defineProperty(t.MetalSynth.prototype,\"resonance\",{get:function(){return this._filterFreqScaler.min},set:function(t){this._filterFreqScaler.min=t,this.octaves=this._octaves}}),Object.defineProperty(t.MetalSynth.prototype,\"octaves\",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._filterFreqScaler.max=this._filterFreqScaler.min*Math.pow(2,t)}}),t.MetalSynth.prototype.dispose=function(){t.Instrument.prototype.dispose.call(this);for(var e=0;e<this._oscillators.length;e++)this._oscillators[e].dispose(),this._freqMultipliers[e].dispose();this._oscillators=null,this._freqMultipliers=null,this.frequency.dispose(),this.frequency=null,this._filterFreqScaler.dispose(),this._filterFreqScaler=null,this._amplitue.dispose(),this._amplitue=null,this.envelope.dispose(),this.envelope=null,this._highpass.dispose(),this._highpass=null},t.MetalSynth}),t(function(t){return window.AudioBufferSourceNode&&!AudioBufferSourceNode.prototype.start&&(AudioBufferSourceNode.prototype.start=AudioBufferSourceNode.prototype.noteGrainOn,AudioBufferSourceNode.prototype.stop=AudioBufferSourceNode.prototype.noteOff),t.BufferSource=function(){var e=this.optionsObject(arguments,[\"buffer\",\"onended\"],t.BufferSource.defaults);this.onended=e.onended,this._startTime=-1,this._stopTime=-1,this._gainNode=this.output=new t.Gain,this._source=this.context.createBufferSource(),this._source.connect(this._gainNode),this.playbackRate=new t.Param(this._source.playbackRate,t.Type.Positive),this.fadeIn=e.fadeIn,this.fadeOut=e.fadeOut,this._gain=1,this._onendedTimeout=-1,this.isUndef(e.buffer)||(this.buffer=e.buffer),this.loop=e.loop},t.extend(t.BufferSource),t.BufferSource.defaults={onended:t.noOp,fadeIn:0,fadeOut:0},Object.defineProperty(t.BufferSource.prototype,\"state\",{get:function(){var e=this.now();return-1!==this._startTime&&e>=this._startTime&&e<this._stopTime?t.State.Started:t.State.Stopped}}),t.BufferSource.prototype.start=function(t,e,i,s,n){if(-1!==this._startTime)throw new Error(\"Tone.BufferSource: can only be started once.\");return this.buffer&&(t=this.toSeconds(t),e=this.loop?this.defaultArg(e,this.loopStart):this.defaultArg(e,0),e=this.toSeconds(e),t=this.toSeconds(t),this._source.start(t,e),s=this.defaultArg(s,1),this._gain=s,n=this.isUndef(n)?this.toSeconds(this.fadeIn):this.toSeconds(n),n>0?(this._gainNode.gain.setValueAtTime(0,t),this._gainNode.gain.linearRampToValueAtTime(this._gain,t+n)):this._gainNode.gain.setValueAtTime(s,t),this._startTime=t+n,this.isUndef(i)||(i=this.defaultArg(i,this.buffer.duration-e),i=this.toSeconds(i),this.stop(t+i+n,n))),this},t.BufferSource.prototype.stop=function(t,e){return this.buffer&&(t=this.toSeconds(t),e=this.isUndef(e)?this.toSeconds(this.fadeOut):this.toSeconds(e),this._stopTime=t+e,this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),e>0?(this._gainNode.gain.setValueAtTime(this._gain,t),this._gainNode.gain.linearRampToValueAtTime(0,t+e),t+=e):this._gainNode.gain.setValueAtTime(0,t),this.isNumber(this._source.playbackState)&&2!==this._source.playbackState||this._source.stop(t),clearTimeout(this._onendedTimeout),this._onendedTimeout=setTimeout(this._onended.bind(this),1e3*(this._stopTime-this.now()))),this},t.BufferSource.prototype._onended=function(){this.onended(this),this.dispose()},Object.defineProperty(t.BufferSource.prototype,\"loopStart\",{get:function(){return this._source.loopStart},set:function(t){this._source.loopStart=this.toSeconds(t)}}),Object.defineProperty(t.BufferSource.prototype,\"loopEnd\",{get:function(){return this._source.loopEnd},set:function(t){this._source.loopEnd=this.toSeconds(t)}}),Object.defineProperty(t.BufferSource.prototype,\"buffer\",{get:function(){return this._source?this._source.buffer:null},set:function(e){e instanceof t.Buffer?this._source.buffer=e.get():this._source.buffer=e}}),Object.defineProperty(t.BufferSource.prototype,\"loop\",{get:function(){return this._source.loop},set:function(t){this._source.loop=t}}),t.BufferSource.prototype.dispose=function(){return this.onended=null,this._source&&(this._source.disconnect(),this._source=null),this._gainNode&&(this._gainNode.dispose(),this._gainNode=null),this._startTime=-1,this.playbackRate=null,this.output=null,clearTimeout(this._onendedTimeout),this},t.BufferSource}),t(function(t){function e(){for(var e in i)s[e]=(new t.Buffer).fromArray(i[e])}t.Noise=function(){var e=this.optionsObject(arguments,[\"type\"],t.Noise.defaults);t.Source.call(this,e),this._source=null,this._type=e.type,this._playbackRate=e.playbackRate},t.extend(t.Noise,t.Source),t.Noise.defaults={type:\"white\",playbackRate:1},Object.defineProperty(t.Noise.prototype,\"type\",{get:function(){return this._type},set:function(e){if(this._type!==e){if(!(e in s))throw new TypeError(\"Tone.Noise: invalid type: \"+e);if(this._type=e,this.state===t.State.Started){var i=this.now()+this.blockTime;this._stop(i),this._start(i)}}}}),Object.defineProperty(t.Noise.prototype,\"playbackRate\",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}}),t.Noise.prototype._start=function(e){var i=s[this._type];this._source=new t.BufferSource(i).connect(this.output),this._source.loop=!0,this._source.playbackRate.value=this._playbackRate,this._source.start(this.toSeconds(e),Math.random()*(i.duration-.001))},t.Noise.prototype._stop=function(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)},t.Noise.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),null!==this._source&&(this._source.disconnect(),this._source=null),this._buffer=null,this};var i={pink:function(){for(var t=[],e=0;e<2;e++){var i=new Float32Array(220500);t[e]=i;var s,n,o,r,a,h,l;s=n=o=r=a=h=l=0;for(var c=0;c<220500;c++){var u=2*Math.random()-1;s=.99886*s+.0555179*u,n=.99332*n+.0750759*u,o=.969*o+.153852*u,r=.8665*r+.3104856*u,a=.55*a+.5329522*u,h=-.7616*h-.016898*u,i[c]=s+n+o+r+a+h+l+.5362*u,i[c]*=.11,l=.115926*u}}return t}(),brown:function(){for(var t=[],e=0;e<2;e++){var i=new Float32Array(220500);t[e]=i;for(var s=0,n=0;n<220500;n++){var o=2*Math.random()-1;i[n]=(s+.02*o)/1.02,s=i[n],i[n]*=3.5}}return t}(),white:function(){for(var t=[],e=0;e<2;e++){var i=new Float32Array(220500);t[e]=i;for(var s=0;s<220500;s++)i[s]=2*Math.random()-1}return t}()},s={};return e(),t.Context.on(\"init\",e),t.Noise}),t(function(t){return t.NoiseSynth=function(e){e=this.defaultArg(e,t.NoiseSynth.defaults),t.Instrument.call(this,e),this.noise=new t.Noise,this.envelope=new t.AmplitudeEnvelope(e.envelope),this.noise.chain(this.envelope,this.output),this.noise.start(),this._readOnly([\"noise\",\"envelope\"])},t.extend(t.NoiseSynth,t.Instrument),t.NoiseSynth.defaults={noise:{type:\"white\"},envelope:{attack:.005,decay:.1,sustain:0}},t.NoiseSynth.prototype.triggerAttack=function(t,e){return this.envelope.triggerAttack(t,e),this},t.NoiseSynth.prototype.triggerRelease=function(t){return this.envelope.triggerRelease(t),this},t.NoiseSynth.prototype.triggerAttackRelease=function(t,e,i){return e=this.toSeconds(e),t=this.toSeconds(t),this.triggerAttack(e,i),this.triggerRelease(e+t),this},t.NoiseSynth.prototype.dispose=function(){return t.Instrument.prototype.dispose.call(this),this._writable([\"noise\",\"envelope\"]),this.noise.dispose(),this.noise=null,this.envelope.dispose(),this.envelope=null,this},t.NoiseSynth}),t(function(t){return t.PluckSynth=function(e){e=this.defaultArg(e,t.PluckSynth.defaults),t.Instrument.call(this,e),this._noise=new t.Noise(\"pink\"),this.attackNoise=e.attackNoise,this._lfcf=new t.LowpassCombFilter({resonance:e.resonance,dampening:e.dampening}),this.resonance=this._lfcf.resonance,this.dampening=this._lfcf.dampening,this._noise.connect(this._lfcf),this._lfcf.connect(this.output),this._readOnly([\"resonance\",\"dampening\"])},t.extend(t.PluckSynth,t.Instrument),t.PluckSynth.defaults={attackNoise:1,dampening:4e3,resonance:.9},t.PluckSynth.prototype.triggerAttack=function(t,e){t=this.toFrequency(t),e=this.toSeconds(e);var i=1/t;return this._lfcf.delayTime.setValueAtTime(i,e),this._noise.start(e),this._noise.stop(e+i*this.attackNoise),this},t.PluckSynth.prototype.dispose=function(){return t.Instrument.prototype.dispose.call(this),this._noise.dispose(),this._lfcf.dispose(),this._noise=null,this._lfcf=null,this._writable([\"resonance\",\"dampening\"]),this.dampening=null,this.resonance=null,this},t.PluckSynth}),t(function(t){return t.PolySynth=function(){t.Instrument.call(this);var e=this.optionsObject(arguments,[\"polyphony\",\"voice\"],t.PolySynth.defaults);e=this.defaultArg(e,t.Instrument.defaults),e.polyphony=Math.min(t.PolySynth.MAX_POLYPHONY,e.polyphony),this.voices=new Array(e.polyphony),this._triggers=new Array(e.polyphony),this.detune=new t.Signal(e.detune,t.Type.Cents),this._readOnly(\"detune\");for(var i=0;i<e.polyphony;i++){var s=new e.voice(arguments[2],arguments[3]);this.voices[i]=s,s.connect(this.output),s.hasOwnProperty(\"detune\")&&this.detune.connect(s.detune),this._triggers[i]={release:-1,note:null,voice:s}}this.volume.value=e.volume},t.extend(t.PolySynth,t.Instrument),t.PolySynth.defaults={polyphony:4,volume:0,detune:0,voice:t.Synth},t.PolySynth.prototype.triggerAttack=function(t,e,i){Array.isArray(t)||(t=[t]),e=this.toSeconds(e);for(var s=0;s<t.length;s++){for(var n=t[s],o=this._triggers[0],r=1;r<this._triggers.length;r++)this._triggers[r].release<o.release&&(o=this._triggers[r],r);o.release=1/0,o.note=JSON.stringify(n),o.voice.triggerAttack(n,e,i)}return this},t.PolySynth.prototype.triggerAttackRelease=function(t,e,i,s){if(i=this.toSeconds(i),this.triggerAttack(t,i,s),this.isArray(e)&&this.isArray(t))for(var n=0;n<t.length;n++){var o=e[Math.min(n,e.length-1)];this.triggerRelease(t[n],i+this.toSeconds(o))}else this.triggerRelease(t,i+this.toSeconds(e));return this},t.PolySynth.prototype.triggerRelease=function(t,e){Array.isArray(t)||(t=[t]),e=this.toSeconds(e);for(var i=0;i<t.length;i++)for(var s=JSON.stringify(t[i]),n=0;n<this._triggers.length;n++){var o=this._triggers[n];o.note===s&&o.release>e&&(o.voice.triggerRelease(e),o.release=e)}return this},t.PolySynth.prototype.set=function(t,e,i){for(var s=0;s<this.voices.length;s++)this.voices[s].set(t,e,i);return this},t.PolySynth.prototype.get=function(t){return this.voices[0].get(t)},t.PolySynth.prototype.releaseAll=function(t){t=this.toSeconds(t);for(var e=0;e<this._triggers.length;e++){var i=this._triggers[e];i.release>t&&(i.release=t,i.voice.triggerRelease(t))}return this},t.PolySynth.prototype.dispose=function(){t.Instrument.prototype.dispose.call(this);for(var e=0;e<this.voices.length;e++)this.voices[e].dispose(),this.voices[e]=null;return this._writable(\"detune\"),this.detune.dispose(),this.detune=null,this.voices=null,this._triggers=null,this},t.PolySynth.MAX_POLYPHONY=20,t.PolySynth}),t(function(t){return t.Player=function(e){var i;e instanceof t.Buffer?(e=e.get(),i=t.Player.defaults):i=this.optionsObject(arguments,[\"url\",\"onload\"],t.Player.defaults),t.Source.call(this,i),this._source=null,this.autostart=i.autostart,this._buffer=new t.Buffer({url:i.url,onload:this._onload.bind(this,i.onload),reverse:i.reverse}),e instanceof AudioBuffer&&this._buffer.set(e),this._loop=i.loop,this._loopStart=i.loopStart,this._loopEnd=i.loopEnd,this._playbackRate=i.playbackRate,this.retrigger=i.retrigger},t.extend(t.Player,t.Source),t.Player.defaults={onload:t.noOp,playbackRate:1,loop:!1,autostart:!1,loopStart:0,loopEnd:0,retrigger:!1,reverse:!1},t.Player.prototype.load=function(t,e){return this._buffer.load(t,this._onload.bind(this,e))},t.Player.prototype._onload=function(e){e=this.defaultArg(e,t.noOp),e(this),this.autostart&&this.start()},t.Player.prototype._start=function(e,i,s){if(!this._buffer.loaded)throw Error(\"Tone.Player: tried to start Player before the buffer was loaded\");if(i=this._loop?this.defaultArg(i,this._loopStart):this.defaultArg(i,0),i=this.toSeconds(i),s=this.defaultArg(s,Math.max(this._buffer.duration-i,0)),s=this.toSeconds(s),e=this.toSeconds(e),this._source=this.context.createBufferSource(),this._source.buffer=this._buffer.get(),this._loop?(this._source.loop=this._loop,this._source.loopStart=this.toSeconds(this._loopStart),this._source.loopEnd=this.toSeconds(this._loopEnd)):this._synced||this._state.setStateAtTime(t.State.Stopped,e+s),this._source.playbackRate.value=this._playbackRate,this._source.connect(this.output),this._loop){var n=this._source.loopEnd||this._buffer.duration,o=this._source.loopStart,r=n-o;if(i>n)for(;i>n;)i-=r;this._source.start(e,i)}else this._source.start(e,i,s);return this},t.Player.prototype._stop=function(t){return this._source&&(this._source.stop(this.toSeconds(t)),this._source=null),this},t.Player.prototype.seek=function(e,i){return i=this.toSeconds(i),this._state.getValueAtTime(i)===t.State.Started&&(e=this.toSeconds(e),this._stop(i),this._start(i,e)),this},t.Player.prototype.setLoopPoints=function(t,e){return this.loopStart=t,this.loopEnd=e,this},Object.defineProperty(t.Player.prototype,\"loopStart\",{get:function(){return this._loopStart},set:function(t){this._loopStart=t,this._source&&(this._source.loopStart=this.toSeconds(t))}}),Object.defineProperty(t.Player.prototype,\"loopEnd\",{get:function(){return this._loopEnd},set:function(t){this._loopEnd=t,this._source&&(this._source.loopEnd=this.toSeconds(t))}}),Object.defineProperty(t.Player.prototype,\"buffer\",{get:function(){return this._buffer},set:function(t){this._buffer.set(t)}}),Object.defineProperty(t.Player.prototype,\"loop\",{get:function(){return this._loop},set:function(t){this._loop=t,this._source&&(this._source.loop=t)}}),Object.defineProperty(t.Player.prototype,\"playbackRate\",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}}),Object.defineProperty(t.Player.prototype,\"reverse\",{get:function(){return this._buffer.reverse},set:function(t){this._buffer.reverse=t}}),t.Player.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),null!==this._source&&(this._source.disconnect(),this._source=null),this._buffer.dispose(),this._buffer=null,this},t.Player}),t(function(t){return t.Sampler=function(){var e=this.optionsObject(arguments,[\"url\",\"onload\"],t.Sampler.defaults);t.Instrument.call(this,e),this.player=new t.Player(e.url,e.onload),this.player.retrigger=!0,this.envelope=new t.AmplitudeEnvelope(e.envelope),this.player.chain(this.envelope,this.output),this._readOnly([\"player\",\"envelope\"]),this.loop=e.loop,this.reverse=e.reverse},t.extend(t.Sampler,t.Instrument),t.Sampler.defaults={onload:t.noOp,loop:!1,reverse:!1,envelope:{attack:.001,decay:0,sustain:1,release:.1}},t.Sampler.prototype.triggerAttack=function(t,e,i){return e=this.toSeconds(e),t=this.defaultArg(t,0),this.player.playbackRate=this.intervalToFrequencyRatio(t),this.player.start(e),this.envelope.triggerAttack(e,i),this},t.Sampler.prototype.triggerRelease=function(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this.player.stop(this.toSeconds(this.envelope.release)+t),this},Object.defineProperty(t.Sampler.prototype,\"loop\",{get:function(){return this.player.loop},set:function(t){this.player.loop=t}}),Object.defineProperty(t.Sampler.prototype,\"reverse\",{get:function(){return this.player.reverse},set:function(t){this.player.reverse=t}}),Object.defineProperty(t.Sampler.prototype,\"buffer\",{get:function(){return this.player.buffer},set:function(t){this.player.buffer=t}}),t.Sampler.prototype.dispose=function(){return t.Instrument.prototype.dispose.call(this),this._writable([\"player\",\"envelope\"]),this.player.dispose(),this.player=null,this.envelope.dispose(),this.envelope=null,this},t.Sampler}),t(function(t){return t.GainToAudio=function(){this._norm=this.input=this.output=new t.WaveShaper(function(t){return 2*Math.abs(t)-1})},t.extend(t.GainToAudio,t.SignalBase),t.GainToAudio.prototype.dispose=function(){return t.prototype.dispose.call(this),this._norm.dispose(),this._norm=null,this},t.GainToAudio}),t(function(t){return t.Normalize=function(e,i){this._inputMin=this.defaultArg(e,0),this._inputMax=this.defaultArg(i,1),this._sub=this.input=new t.Add(0),this._div=this.output=new t.Multiply(1),this._sub.connect(this._div),this._setRange()},t.extend(t.Normalize,t.SignalBase),Object.defineProperty(t.Normalize.prototype,\"min\",{get:function(){return this._inputMin},set:function(t){this._inputMin=t,this._setRange()}}),Object.defineProperty(t.Normalize.prototype,\"max\",{get:function(){return this._inputMax},set:function(t){this._inputMax=t,this._setRange()}}),t.Normalize.prototype._setRange=function(){this._sub.value=-this._inputMin,this._div.value=1/(this._inputMax-this._inputMin)},t.Normalize.prototype.dispose=function(){return t.prototype.dispose.call(this),this._sub.dispose(),this._sub=null,this._div.dispose(),this._div=null,this},t.Normalize}),t(function(t){return t.MultiPlayer=function(){var e=this.optionsObject(arguments,[\"urls\",\"onload\"],t.MultiPlayer.defaults);e.urls instanceof t.Buffers?this.buffers=e.urls:this.buffers=new t.Buffers(e.urls,e.onload),this._activeSources={},this.fadeIn=e.fadeIn,this.fadeOut=e.fadeOut,this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._readOnly(\"volume\"),this._volume.output.output.channelCount=2,this._volume.output.output.channelCountMode=\"explicit\",this.mute=e.mute},t.extend(t.MultiPlayer,t.Source),t.MultiPlayer.defaults={onload:t.noOp,fadeIn:0,fadeOut:0},t.MultiPlayer.prototype._makeSource=function(e){var i;this.isString(e)||this.isNumber(e)?i=this.buffers.get(e).get():e instanceof t.Buffer?i=e.get():e instanceof AudioBuffer&&(i=e);var s=new t.BufferSource(i).connect(this.output);return this._activeSources.hasOwnProperty(e)||(this._activeSources[e]=[]),this._activeSources[e].push(s),s},t.MultiPlayer.prototype.start=function(t,e,i,s,n,o){e=this.toSeconds(e);var r=this._makeSource(t);return r.start(e,i,s,this.defaultArg(o,1),this.fadeIn),s&&r.stop(e+this.toSeconds(s),this.fadeOut),n=this.defaultArg(n,0),r.playbackRate.value=this.intervalToFrequencyRatio(n),this},t.MultiPlayer.prototype.startLoop=function(t,e,i,s,n,o,r){e=this.toSeconds(e);var a=this._makeSource(t);return a.loop=!0,a.loopStart=this.toSeconds(this.defaultArg(s,0)),a.loopEnd=this.toSeconds(this.defaultArg(n,0)),a.start(e,i,void 0,this.defaultArg(r,1),this.fadeIn),o=this.defaultArg(o,0),a.playbackRate.value=this.intervalToFrequencyRatio(o),this},t.MultiPlayer.prototype.stop=function(t,e){if(!this._activeSources[t]||!this._activeSources[t].length)throw new Error(\"Tone.MultiPlayer: cannot stop a buffer that hasn't been started or is already stopped\");return e=this.toSeconds(e),this._activeSources[t].shift().stop(e,this.fadeOut),this},t.MultiPlayer.prototype.stopAll=function(t){t=this.toSeconds(t);for(var e in this._activeSources)for(var i=this._activeSources[e],s=0;s<i.length;s++)i[s].stop(t);return this},t.MultiPlayer.prototype.add=function(t,e,i){return this.buffers.add(t,e,i),this},Object.defineProperty(t.MultiPlayer.prototype,\"state\",{get:function(){return this._activeSources.length>0?t.State.Started:t.State.Stopped}}),Object.defineProperty(t.MultiPlayer.prototype,\"mute\",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),t.MultiPlayer.prototype.dispose=function(){t.prototype.dispose.call(this),this._volume.dispose(),this._volume=null,this._writable(\"volume\"),this.volume=null;for(var e in this._activeSources)this._activeSources[e].forEach(function(t){t.dispose()});return this.buffers.dispose(),this.buffers=null,this._activeSources=null,this},t.MultiPlayer}),t(function(t){return t.GrainPlayer=function(){var e=this.optionsObject(arguments,[\"url\",\"onload\"],t.GrainPlayer.defaults);t.Source.call(this),this.buffer=new t.Buffer(e.url,e.onload),this._player=(new t.MultiPlayer).connect(this.output),this._clock=new t.Clock(this._tick.bind(this),1),this._loopStart=0,this._loopEnd=0,this._playbackRate=e.playbackRate,this._grainSize=e.grainSize,this._overlap=e.overlap,this.detune=e.detune,this.drift=e.drift,this.overlap=e.overlap,this.loop=e.loop,this.playbackRate=e.playbackRate,this.grainSize=e.grainSize,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.reverse=e.reverse},t.extend(t.GrainPlayer,t.Source),t.GrainPlayer.defaults={onload:t.noOp,overlap:.1,grainSize:.2,drift:0,playbackRate:1,detune:0,loop:!1,loopStart:0,loopEnd:0,reverse:!1},t.GrainPlayer.prototype._start=function(t,e,i){e=this.defaultArg(e,0),e=this.toSeconds(e),t=this.toSeconds(t),this._offset=e,this._clock.start(t),this._player.volume.setValueAtTime(0,t),i&&this._stop(t+this.toSeconds(i))},t.GrainPlayer.prototype._stop=function(t){this._clock.stop(t),this._player.volume.cancelScheduledValues(t),this._player.volume.setValueAtTime(-1/0,t)},t.GrainPlayer.prototype._tick=function(t){var e=this.buffer.duration;this.loop&&this._loopEnd>0&&(e=this._loopEnd);var i=(2*Math.random()-1)*this.drift,s=this._offset-this._overlap+i,n=this.detune/100;s=Math.max(s,0),s=Math.min(s,e);var o=this._player.fadeIn;if(this.loop&&this._offset>e){var r=this._offset-e;this._player.start(this.buffer,t,s,r+this._overlap,n),s=this._offset%e,this._offset=this._loopStart,this._player.fadeIn=0,this._player.start(this.buffer,t+r,this._offset,s+this._overlap,n)}else this._offset>e?this.stop(t):(0===s&&(this._player.fadeIn=0),this._player.start(this.buffer,t,s,this.grainSize+this._overlap,n));this._player.fadeIn=o;var a=this._clock._nextTick-t;this._offset+=a*this._playbackRate},t.GrainPlayer.prototype.scrub=function(t,e){return this._offset=this.toSeconds(t),this._tick(this.toSeconds(e)),this},Object.defineProperty(t.GrainPlayer.prototype,\"playbackRate\",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this.grainSize=this._grainSize}}),Object.defineProperty(t.GrainPlayer.prototype,\"loopStart\",{get:function(){return this._loopStart},set:function(t){this._loopStart=this.toSeconds(t)}}),Object.defineProperty(t.GrainPlayer.prototype,\"loopEnd\",{get:function(){return this._loopEnd},set:function(t){this._loopEnd=this.toSeconds(t)}}),Object.defineProperty(t.GrainPlayer.prototype,\"reverse\",{get:function(){return this.buffer.reverse},set:function(t){this.buffer.reverse=t}}),Object.defineProperty(t.GrainPlayer.prototype,\"grainSize\",{get:function(){return this._grainSize},set:function(t){this._grainSize=this.toSeconds(t),this._clock.frequency.value=this._playbackRate/this._grainSize}}),Object.defineProperty(t.GrainPlayer.prototype,\"overlap\",{get:function(){return this._overlap},set:function(t){t=this.toSeconds(t),this._overlap=t,this._overlap<0?(this._player.fadeIn=.01,this._player.fadeOut=.01):(this._player.fadeIn=t,this._player.fadeOut=t)}}),t.GrainPlayer.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this.buffer.dispose(),this.buffer=null,this._player.dispose(),this._player=null,this._clock.dispose(),this._clock=null,this},t.GrainPlayer}),t(function(t){return t.UserMedia=function(){var e=this.optionsObject(arguments,[\"volume\"],t.UserMedia.defaults);this._mediaStream=null,this._stream=null,this._device=null,this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._readOnly(\"volume\"),this.mute=e.mute},t.extend(t.UserMedia),t.UserMedia.defaults={volume:0,mute:!1},t.UserMedia.prototype.open=function(t){return t=this.defaultArg(t,\"default\"),this.enumerateDevices().then(function(e){var i;if(this.isNumber(t)?i=e[t]:(i=e.find(function(e){return e.label===t||e.deviceId===t}))||(i=e[0]),!i)throw new Error(\"Tone.UserMedia: no matching audio inputs.\");this._device=i;var s={audio:{deviceId:i.deviceId,echoCancellation:!1,sampleRate:this.context.sampleRate}};return navigator.mediaDevices.getUserMedia(s).then(function(t){return this._stream||(this._stream=t,this._mediaStream=this.context.createMediaStreamSource(t),this._mediaStream.connect(this.output)),this}.bind(this))}.bind(this))},t.UserMedia.prototype.close=function(){return this._stream&&(this._stream.getAudioTracks().forEach(function(t){t.stop()}),this._stream=null,this._mediaStream.disconnect(),this._mediaStream=null),this._device=null,this},t.UserMedia.prototype.enumerateDevices=function(){return navigator.mediaDevices.enumerateDevices().then(function(t){return t.filter(function(t){return\"audioinput\"===t.kind})})},Object.defineProperty(t.UserMedia.prototype,\"state\",{get:function(){return this._stream&&this._stream.active?t.State.Started:t.State.Stopped}}),Object.defineProperty(t.UserMedia.prototype,\"deviceId\",{get:function(){if(this._device)return this._device.deviceId}}),Object.defineProperty(t.UserMedia.prototype,\"groupId\",{get:function(){if(this._device)return this._device.groupId}}),Object.defineProperty(t.UserMedia.prototype,\"label\",{get:function(){if(this._device)return this._device.label}}),Object.defineProperty(t.UserMedia.prototype,\"mute\",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),t.UserMedia.prototype.dispose=function(){return t.prototype.dispose.call(this),this.close(),this._writable(\"volume\"),this._volume.dispose(),this._volume=null,this.volume=null,this},Object.defineProperty(t.UserMedia,\"supported\",{get:function(){return!t.prototype.isUndef(navigator.mediaDevices)&&t.prototype.isFunction(navigator.mediaDevices.getUserMedia)}}),t.UserMedia}),e})},function(t,e,i){\"use strict\";function s(t){return t&&t.__esModule?t:{default:t}}function n(t){return t[Math.floor(Math.random()*t.length)]}function o(t,e){return t-e*Math.floor(t/e)}function r(t){if(f){var e=document.createElement(\"div\"),i=document.createElement(\"div\");i.innerHTML=\"Tap to start - please unmute your phone\",Object.assign(e.style,{position:\"absolute\",width:\"100%\",height:\"100%\",zIndex:\"10000\",top:\"0px\",left:\"0px\",backgroundColor:\"rgba(0, 0, 0, 0.8)\"}),Object.assign(i.style,{position:\"absolute\",left:\"50%\",top:\"50%\",padding:\"20px\",backgroundColor:\"#7F33ED\",color:\"white\",fontFamily:\"monospace\",borderRadius:\"3px\",transform:\"translate3D(-50%,-50%,0)\",textAlign:\"center\",lineHeight:\"1.5\"}),e.appendChild(i),document.body.appendChild(e),c.default.setContext(h.default.context),c.default.on(i),c.default.onStarted(function(i){e.remove(),t()})}else t()}Object.defineProperty(e,\"__esModule\",{value:!0}),e.requestAudioContext=e.browser=e.mod=e.choice=void 0;var a=i(4),h=s(a),l=i(17),c=s(l),u=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i),p=navigator.userAgent.match(/iPad/i),d=navigator.userAgent.match(/Android/i),f=u||p||d,y=!f;document.body.classList.add(f?\"mobile\":\"desktop\");var _={isIphone:u,isIpad:p,isMobile:f,isDesktop:y};e.choice=n,e.mod=o,e.browser=_,e.requestAudioContext=r},function(t,e){function i(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function s(t){return\"function\"==typeof t}function n(t){return\"number\"==typeof t}function o(t){return\"object\"==typeof t&&null!==t}function r(t){return void 0===t}t.exports=i,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._maxListeners=void 0,i.defaultMaxListeners=10,i.prototype.setMaxListeners=function(t){if(!n(t)||t<0||isNaN(t))throw TypeError(\"n must be a positive number\");return this._maxListeners=t,this},i.prototype.emit=function(t){var e,i,n,a,h,l;if(this._events||(this._events={}),\"error\"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var c=new Error('Uncaught, unspecified \"error\" event. ('+e+\")\");throw c.context=e,c}if(i=this._events[t],r(i))return!1;if(s(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),i.apply(this,a)}else if(o(i))for(a=Array.prototype.slice.call(arguments,1),l=i.slice(),n=l.length,h=0;h<n;h++)l[h].apply(this,a);return!0},i.prototype.addListener=function(t,e){var n;if(!s(e))throw TypeError(\"listener must be a function\");return this._events||(this._events={}),this._events.newListener&&this.emit(\"newListener\",t,s(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(n=r(this._maxListeners)?i.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error(\"(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.\",this._events[t].length),\"function\"==typeof console.trace&&console.trace()),this},i.prototype.on=i.prototype.addListener,i.prototype.once=function(t,e){function i(){this.removeListener(t,i),n||(n=!0,e.apply(this,arguments))}if(!s(e))throw TypeError(\"listener must be a function\");var n=!1;return i.listener=e,this.on(t,i),this},i.prototype.removeListener=function(t,e){var i,n,r,a;if(!s(e))throw TypeError(\"listener must be a function\");if(!this._events||!this._events[t])return this;if(i=this._events[t],r=i.length,n=-1,i===e||s(i.listener)&&i.listener===e)delete this._events[t],this._events.removeListener&&this.emit(\"removeListener\",t,e);else if(o(i)){for(a=r;a-- >0;)if(i[a]===e||i[a].listener&&i[a].listener===e){n=a;break}if(n<0)return this;1===i.length?(i.length=0,delete this._events[t]):i.splice(n,1),this._events.removeListener&&this.emit(\"removeListener\",t,e)}return this},i.prototype.removeAllListeners=function(t){var e,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)\"removeListener\"!==e&&this.removeAllListeners(e);return this.removeAllListeners(\"removeListener\"),this._events={},this}if(i=this._events[t],s(i))this.removeListener(t,i);else if(i)for(;i.length;)this.removeListener(t,i[i.length-1]);return delete this._events[t],this},i.prototype.listeners=function(t){return this._events&&this._events[t]?s(this._events[t])?[this._events[t]]:this._events[t].slice():[]},i.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(s(e))return 1;if(e)return e.length}return 0},i.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e){e.findPosition=function(t){var e=document.body,i=document.defaultView,s=document.documentElement,n=document.createElement(\"div\");n.style.paddingLeft=n.style.width=\"1px\",e.appendChild(n);var o=2==n.offsetWidth;e.removeChild(n),n=t.getBoundingClientRect();var r=s.clientTop||e.clientTop||0,a=s.clientLeft||e.clientLeft||0,h=i.pageYOffset||o&&s.scrollTop||e.scrollTop,l=i.pageXOffset||o&&s.scrollLeft||e.scrollLeft;return{top:n.top+h-r,left:n.left+l-a}},e.getCursorPosition=function(t,e){var i,s;void 0!=t.pageX&&void 0!=t.pageY?(i=t.pageX,s=t.pageY):(i=t.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,s=t.clientY+document.body.scrollTop+document.documentElement.scrollTop),i-=e.left,s-=e.top;var n={x:i,y:s};return n.touches=[{x:i,y:s}],n},e.getTouchPosition=function(t,e){var i,s;i=t.targetTouches[0].pageX,s=t.targetTouches[0].pageY,i-=e.left,s-=e.top;var n={x:i,y:s};n.touches=new Array;for(var o=0;o<t.targetTouches.length;o++)n.touches.push({x:t.targetTouches[o].pageX-e.left,y:t.targetTouches[o].pageY-e.top});n.changed=new Array;for(var o=0;o<t.changedTouches.length;o++)n.changed.push({x:t.changedTouches[o].pageX-e.left,y:t.changedTouches[o].pageY-e.top});return n}},function(t,e){e.throttle=function(t,e){var i;return function(){var s=this,n=arguments;i||(i=setTimeout(function(){i=null;try{t.apply(s,n)}catch(t){console.log(t)}},e))}}},function(t,e){e.defineTransmit=function(t){if(\"function\"==typeof t)return t;switch(t){case\"js\":return function(t,e){this.makeOSC(this.emit,t,e),this.emit(\"*\",t,e)};case\"ajax\":return function(t){this.makeOSC(e.ajaxTransmit,t)};case\"node\":return function(t){this.makeOSC(e.nodeTransmit,t)};case\"ios\":return function(t){};case\"max\":return function(t){this.makeOSC(e.maxTransmit,t)};case\"wc\":return function(t,e){this.emit(\"internal\",t,e)}}},e.setGlobalTransmit=function(t){var i=e.defineTransmit(t);this.transmit=i,this.destination=t;for(var s in nx.widgets)this.widgets[s].transmit=i,this.widgets[s].destination=t},e.setWidgetTransmit=function(t){var i=e.defineTransmit(t);this.transmit=i,this.destination=t},e.ajaxTransmit=function(t,e){var i=\"value\"==t?this.oscPath:this.oscPath+\"/\"+t;xmlhttp=new XMLHttpRequest,xmlhttp.open(\"POST\",nx.ajaxPath,!0),xmlhttp.setRequestHeader(\"Content-type\",\"application/x-www-form-urlencoded\"),xmlhttp.send(\"oscName=\"+i+\"&data=\"+e)},e.setAjaxPath=function(t){this.ajaxPath=t},e.nodeTransmit=function(t,e){var i={oscName:\"value\"==t?this.oscPath:this.oscPath+\"/\"+t,value:e};socket.emit(\"nx\",i)},e.maxTransmit=function(t,e){var i=\"value\"==t?this.oscPath:this.oscPath+\"/\"+t;window.max.outlet(i+\" \"+e)}},function(t,e,i){\"use strict\";function s(t,e,i,s,n,o,r){return e+i*Math.cos(2*Math.PI*(s*t+n))*r+o}function n(t,e,i){for(var n=void 0,o=void 0,a=void 0,h=void 0,l=[],c=0;c<3;c++)n=r[0][c],o=r[1][c],a=r[2][c],h=r[3][c],l[c]=Math.round(255*s(t,n,o,a,h,e,i));return\"rgb(\"+l+\")\"}Object.defineProperty(e,\"__esModule\",{value:!0});var o=[[[.5,.5,.5],[.5,.5,.5],[1,1,1],[0,.33,.67]],[[.5,.5,.5],[.5,.5,.5],[1,1,1],[0,.1,.2]],[[.5,.5,.5],[.5,.5,.5],[1,1,1],[.3,.2,.2]],[[.5,.5,.5],[.5,.5,.5],[1,1,.5],[.8,.9,.3]],[[.5,.5,.5],[.5,.5,.5],[1,.7,.4],[0,.15,.2]],[[.5,.5,.5],[.5,.5,.5],[2,1,0],[.5,.2,.25]],[[.8,.5,.4],[.2,.4,.2],[2,1,1],[0,.25,.25]]],r=o[0];e.default=n},function(t,e,i){\"use strict\";function s(t){var e={sample:(0,r.choice)(l)};e.sample.index=(e.sample.index+1)%a;var i=e.sample.players[e.sample.index];i.playbackRate=t/e.sample.root,i.start()}Object.defineProperty(e,\"__esModule\",{value:!0});var n=i(4),o=function(t){return t&&t.__esModule?t:{default:t}}(n),r=i(5),a=2,h=new o.default.Compressor(-30,3).toMaster(),l=[{root:226,fn:\"samples/380737__cabled-mess__sansula-01-a-raw.wav\"},{root:267,fn:\"samples/380736__cabled-mess__sansula-02-c-raw.wav\"},{root:340,fn:\"samples/380735__cabled-mess__sansula-03-e-raw.wav\"},{root:452,fn:\"samples/380733__cabled-mess__sansula-06-a-02-raw.wav\"}];l.forEach(function(t){t.players=[],t.index=-1;for(var e=0;e<a;e++){var i=t.fn;window.location.href.match(/asdf.us/)&&(i=\"//asdf.us/kalimba/\"+i);var s=new o.default.Player({url:i,retrigger:!0,playbackRate:1});s.connect(h),t.players.push(s)}}),e.default={play:s}},function(t,e,i){\"use strict\";function s(t){if(t.altKey||t.ctrlKey||t.metaKey)return void t.stopPropagation();if(document.activeElement instanceof HTMLInputElement&&t.keyCode in r)return void t.stopPropagation();if(t.keyCode in o){var e=o[t.keyCode];t.shiftKey&&(e+=a.length),e-=7,h(e)}}function n(t){h=t}Object.defineProperty(e,\"__esModule\",{value:!0});var o={},r={},a=\"zxcvbnmasdfghjklqwertyuiop\",h=function(){};a.toUpperCase().split(\"\").map(function(t,e){o[t.charCodeAt(0)]=e}),\"1234567890\".split(\"\").map(function(t,e){o[t.charCodeAt(0)]=e+a.length,r[t.charCodeAt(0)]=!0}),window.addEventListener(\"keydown\",s,!0),e.default={listen:n}},function(t,e,i){\"use strict\";function s(){c.forEach(function(t,e){t.heading=document.createElement(\"div\"),t.heading.innerHTML=t.name,t.heading.classList.add(\"heading\"),t.heading.addEventListener(\"click\",function(){n(e)}),scale_list.appendChild(t.heading)}),n(0)}function n(t){u&&u.heading&&u.heading.classList.remove(\"selected\"),u=c[t],u.heading&&u.heading.classList.add(\"selected\"),p(u)}function o(){return u}function r(t){p=t}function a(){return c.map(function(t){return t.name})}Object.defineProperty(e,\"__esModule\",{value:!0});var h=i(16),l=function(t){return t&&t.__esModule?t:{default:t}}(h),c=[{intervals:\"1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1\",name:\"harmonic scale\"},{root:450,intervals:\"1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1\",name:\"harmonic scale @ 450\"},{tet:5},{tet:12},{tet:17},{intervals:\"1/1 81/80 33/32 21/20 16/15 12/11 11/10 10/9 9/8 8/7 7/6 32/27 6/5 11/9 5/4 14/11 9/7 21/16 4/3 27/20 11/8 7/5 10/7 16/11 40/27 3/2 32/21 14/9 11/7 8/5 18/11 5/3 27/16 12/7 7/4 16/9 9/5 20/11 11/6 15/8 40/21 64/33 160/81 2/1\",name:\"harry partch scale\"},{scl:\"! young-lm_piano.scl\\n!\\nLaMonte Young's Well-Tempered Piano\\n12\\n!\\n567/512\\n9/8\\n147/128\\n21/16\\n1323/1024\\n189/128\\n3/2\\n49/32\\n7/4\\n441/256\\n63/32\\n2/1\\n\"},{scl:\"! meanquar.scl\\n!\\n1/4-comma meantone scale. Pietro Aaron's temperament (1523)\\n 12\\n!\\n 76.04900\\n 193.15686\\n 310.26471\\n 5/4\\n 503.42157\\n 579.47057\\n 696.57843\\n 25/16\\n 889.73529\\n 1006.84314\\n 1082.89214\\n 2/1\\n\"},{scl:\"! mavila12.scl\\n!\\nA 12-note mavila scale (for warping meantone-based music), 5-limit TOP\\n 12\\n!\\n-30.99719\\n 163.50770\\n 358.01258\\n 327.01540\\n 521.52028\\n 490.52310\\n 685.02798\\n 654.03080\\n 848.53568\\n 1043.04057\\n 1012.04338\\n 1206.54826\\n\"},{scl:\"! carlos_alpha.scl\\n!\\nWendy Carlos' Alpha scale with perfect fifth divided in nine\\n 18\\n!\\n 78.00000\\n 156.00000\\n 234.00000\\n 312.00000\\n 390.00000\\n 468.00000\\n 546.00000\\n 624.00000\\n 702.00000\\n 780.00000\\n 858.00000\\n 936.00000\\n 1014.00000\\n 1092.00000\\n 1170.00000\\n 1248.00000\\n 1326.00000\\n 1404.00000\\n\"},{scl:\"! colundi.scl\\n!\\nColundi scale\\n10\\n!\\n9/8\\n171/140\\n137/112\\n43/35\\n3/2\\n421/280\\n213/140\\n263/150\\n66/35\\n2/1\\n\"}].map(function(t){return new l.default(t)}),u=c[0],p=function(){};e.default={scales:c,current:o,build:s,pick:n,names:a,onChange:r}},function(t,e,s){var n=s(19),o=s(7),r=s(3),a=s(2),h=s(18),l=s(54);window.nx=new n,window.nx.onload=function(){},window.nx=h(window.nx,o),window.nx=h(window.nx,r),window.nx=h(window.nx,a),window.onload=function(){try{l.load({google:{families:[\"Open Sans\"]}})}catch(t){console.log(\"font not loaded\")}nx.addStylesheet();var t=document.getElementsByTagName(\"canvas\");for(i=0;i<t.length;i++)nx.transform(t[i]);nx.isTouchDevice&&(document.addEventListener(\"touchmove\",nx.blockMove,!0),document.addEventListener(\"touchstart\",nx.blockMove,!0)),nx.onload(),nx.startPulse()}},function(t,e,i){\"use strict\";function s(t){return t&&t.__esModule?t:{default:t}}function n(){V=z.widgets.grid,V.sequenceMode=!0,V.bpm=1,V.col=D,V.row=B,V.init(),V.resize(N*D,N*B),V.draw(),z.widgets.scale.choices=j.default.names(),z.widgets.scale.init(),z.widgets.scale.on(\"*\",function(t){return j.default.pick(t.value)}),j.default.onChange(function(t){a()}),a(),V.on(\"*\",function(t){return\"level\"in t&&a()}),z.widgets.shiftUp.on(\"*\",o(l)),z.widgets.shiftDown.on(\"*\",o(c)),z.widgets.slideUp.on(\"*\",o(u)),z.widgets.slideDown.on(\"*\",o(p)),z.widgets.slideLeft.on(\"*\",o(d)),z.widgets.slideRight.on(\"*\",o(f)),z.widgets.rotateUp.on(\"*\",o(function(){return v(-1)})),z.widgets.rotateDown.on(\"*\",o(function(){return v(1)})),z.widgets.rotateLeft.on(\"*\",o(function(){return m(-1)})),z.widgets.rotateRight.on(\"*\",o(function(){return m(1)})),z.widgets.flip.on(\"*\",o(y)),z.widgets.flop.on(\"*\",o(_)),z.colorize(\"#f4d142\"),X.start(),q.default.Transport.bpm.value=108,z.widgets.tempo.min=10,z.widgets.tempo.max=1e3,z.widgets.tempo.set({value:108}),z.widgets.tempo.on(\"*\",function(t){return q.default.Transport.bpm.value=z.widgets.tempo.val.value}),q.default.Transport.start()}function o(t){return function(e){L.browser.isMobile?t():e.press&&t()}}function r(){V.draw(),a()}function a(){for(var t=document.querySelector(\"#labels\"),e=j.default.current().scale.length,i=h(),s=\"\",n=0;n<B;n++){var o=B-n-W,r=(0,L.mod)(o,e),a=r+1;i.includes(r)?s+=\"<b>\"+a+\"</b><br>\":s+=a+\"<br>\"}t.innerHTML=s}function h(t){t=t||T();var e=j.default.current().scale.length;return t.reduce(function(t,i){var s=(0,L.mod)(B-i-W,e);return t.includes(s)||t.push(s),t},[]).sort()}function l(){var t=T(),e=h(t),i=j.default.current().scale.length;w(A(t,function(t){for(var s=B-t-W,n=(0,L.mod)(s,i),o=e.indexOf(n)+1,r=Math.floor(s/i);o>=e.length;)o-=e.length,r+=1;return B-W-(e[o]+r*i)}))}function c(){var t=T(),e=h(t),i=j.default.current().scale.length;w(A(t,function(t){for(var s=B-t-W,n=(0,L.mod)(s,i),o=e.indexOf(n)-1,r=Math.floor(s/i);o<0;)o+=e.length,r-=1;return B-W-(e[o]+r*i)}))}function u(){w(A(T(),function(t){return(t-1+B)%B}))}function p(){w(A(T(),function(t){return(t+1+B)%B}))}function d(){g(A(k(),function(t){return(t-1+D)%D}))}function f(){g(A(k(),function(t){return(t+1+D)%D}))}function y(){w(M(T()))}function _(){g(M(k()))}function m(t){g(P(k(),t))}function v(t){w(P(T(),t))}function g(t){if(t){var e=V.matrix,i=S();b(e,function(e,s,n){e in t&&(i[t[e]][s]=n)}),x(V.matrix,i),r()}}function w(t){if(t){var e=V.matrix,i=S();b(e,function(e,s,n){s in t&&(i[e][t[s]]=n)}),x(V.matrix,i),r()}}function b(t,e){for(var i=D,s=B,n=0;n<i;n++)for(var o=0;o<s;o++)e(n,o,t[n][o]);return t}function x(t,e){return b(e,function(i,s,n){return t[i][s]=e[i][s]})}function S(){for(var t=V.matrix.length,e=V.matrix[0].length,i=new Array(t),s=0;s<t;s++){i[s]=new Array(e);for(var n=0;n<e;n++)i[s][n]=0}return i}function T(){var t=new Array(B);return b(V.matrix,function(e,i,s){s&&(t[i]=1)}),t.reduce(function(t,e,i){return 1===e&&t.push(i),t},[])}function k(){return V.matrix.reduce(function(t,e,i){return e.some(function(t){return 1===t})&&t.push(i),t},[])}function P(t,e){if(t.length){for(var i={},s=O(t,e),n=0;n<s.length;n++)i[s[n]]=t[n];return i}}function O(t,e){var i=t.slice(0);return i.unshift.apply(i,i.splice(-e,i.length)),i}function A(t,e){if(t.length){for(var i={},s=0;s<t.length;s++)i[t[s]]=e(t[s]);return i}}function M(t){if(t.length){for(var e={},i=t.slice(0).reverse(),s=0;s<i.length;s++)e[i[s]]=t[s];return e}}var I=i(4),q=s(I);i(14);var E=i(12),F=s(E),U=i(10),G=(s(U),i(11)),R=s(G),C=i(13),j=s(C),L=i(5),z=window.nx,B=L.browser.isMobile?18:24,D=16,N=L.browser.isMobile?20:27,W=L.browser.isMobile?8:12,V=void 0,X=new q.default.Sequence(function(t,e){var i=V.matrix[e];V.jumpToCol(e);for(var s=0;s<B;s++)if(1===i[s]){var n=j.default.current().index(B-s-W);R.default.play(n)}},[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],\"16n\");z.onload=function(){return(0,L.requestAudioContext)(n)},F.default.listen(function(t){var e=j.default.current().index(t);R.default.play(e)})},function(t,e,i){\"use strict\";t.exports=function(){function t(t,e,i){return(t-e)/(i-e)}function e(t,e){return t-e*Math.floor(t/e)}var i=function(t){t=this.opt=Object.assign({name:\"\",root:440,octave:0,interval:2,tet:0,intervals:null},t||{}),this.generate()};i.prototype.generate=function(t){t=Object.assign(this.opt,t||{}),t.scl?this.generate_scl():t.tet?this.generate_tet():t.intervals&&this.generate_intervals()},i.prototype.generate_intervals=function(){var t=(this.opt.root,this.opt.intervals);\"string\"==typeof t&&(t=t.split(\" \")),this.name=this.opt.name||\"interval list\",this.intervals=t,this.interval=this.opt.interval=s.call(this,t.pop()),this.scale=t.map(n.bind(this)).filter(function(t){return!!t})},i.prototype.generate_tet=function(){var t=this.scale=[],e=this.opt.root,i=this.opt.tet,s=this.interval=this.opt.interval,n=Math.pow(s,1/i),o=e;t.push(o);for(var r=0;r<i-1;r++)o*=n,t.push(o);this.name=this.opt.name||i+\"-tone equal temperament\",this.intervals=null},i.prototype.generate_scl=function(){var t=this.opt.root,e=this.parse_scl(this.opt.scl);this.intervals=e.notes,this.interval=e.notes.pop(),this.name=this.opt.name||e.description,this.scale=e.notes.map(function(e){return e*t})},i.prototype.parse_scl=function(t){var e={};return e.comments=[],e.notes=[],t.trim().split(\"\\n\").forEach(function(t){if(-1!==t.indexOf(\"!\"))e.comments.push(t);else if(\"description\"in e)if(e.notes.length){var i=t.replace(/^[^-\\.0-9]+/,\"\").replace(/[^-\\/\\.0-9]+$/,\"\");i=-1!==i.indexOf(\".\")?Math.pow(2,parseFloat(i)/1200):s(i),i&&e.notes.push(i)}else e.notes.push(1);else e.description=t}),e},i.prototype.index=function(i,s){s=s||this.opt.octave;var n=this.scale[0|e(i,this.scale.length)],o=Math.floor(t(i,0,this.scale.length))+s;return n*=Math.pow(this.interval,o)},i.prototype.range=function(t,e){for(var i=[],s=t;s<e;s++)i.push(this.index(s));return i},i.prototype.set_root=function(t){this.opt.root=t,this.generate()},i.prototype.quantize_frequency=function(t){if(0==t)return 0;for(var e=t,i=0,s=this.interval,n=this.scale;e<root;)e*=s,i-=1;for(;e>root*s;)e/=s,i+=1;for(var o=0;o<n.length;o++)if(!(e>n[o])){e=n[o];break}return e*=Math.pow(2,i)},i.prototype.quantize_index=function(t){return 0|e(index-1,this.scale.length)};var s=i.prototype.parse_interval=function(t){if(\"number\"==typeof t)return t;if(-1==!t.indexOf(\"/\"))return parseInt(t);var e=t.split(\"/\"),i=parseInt(e[0]),s=parseInt(e[1]);return isNaN(i)?1:isNaN(s)||0==s?i:i==s?1:i/s},n=i.prototype.parse_interval_string=function(t){return-1!==t.indexOf(\"/\")?s(t)*this.opt.root:(t.indexOf(\"f\"),parseFloat(t))};return i}()},function(t,e,i){\"use strict\";var s,n,o;\"function\"==typeof Symbol&&Symbol.iterator;/**\n * StartAudioContext.js\n * @author Yotam Mann\n * @license http://opensource.org/licenses/MIT MIT License\n * @copyright 2016 Yotam Mann\n */\n!function(i,r){n=[],s=r,void 0!==(o=\"function\"==typeof s?s.apply(e,n):s)&&(t.exports=o)}(0,function(){function t(){if(e.context&&!e.isStarted()){var t=e.context.createOscillator(),i=e.context.createGain();i.gain.value=0,t.connect(i),i.connect(e.context.destination);var s=e.context.currentTime;t.start(s),t.stop(s+.5)}if(e._tapListeners){for(var n=0;n<e._tapListeners.length;n++)e._tapListeners[n].dispose();e._tapListeners=null}if(e._onStarted){for(var o=0;o<e._onStarted.length;o++)e._onStarted[o]();e._onStarted=null}}var e={context:null,_tapListeners:[],_onStarted:[]};e.setContext=function(t){return e.context=t,e},e.on=function(s){if(Array.isArray(s)||NodeList&&s instanceof NodeList)for(var n=0;n<s.length;n++)e.on(s[n]);else if(\"string\"==typeof s)e.on(document.querySelectorAll(s));else if(s.jquery&&\"function\"==typeof s.toArray)e.on(s.toArray());else if(Element&&s instanceof Element){var o=new i(s,t);e._tapListeners.push(o)}return e},e.onStarted=function(t){return e.isStarted()?t():e._onStarted.push(t),e},e.isStarted=function(){return null!==e.context&&\"running\"===e.context.state};var i=function(t){this._dragged=!1,this._element=t,this._bindedMove=this._moved.bind(this),this._bindedEnd=this._ended.bind(this),t.addEventListener(\"touchmove\",this._bindedMove),t.addEventListener(\"touchend\",this._bindedEnd),t.addEventListener(\"mouseup\",this._bindedEnd)};return i.prototype._moved=function(t){this._dragged=!0},i.prototype._ended=function(e){this._dragged||t(),this._dragged=!1},i.prototype.dispose=function(){this._element.removeEventListener(\"touchmove\",this._bindedMove),this._element.removeEventListener(\"touchend\",this._bindedEnd),this._element.removeEventListener(\"mouseup\",this._bindedEnd),this._bindedMove=null,this._bindedEnd=null,this._element=null},e})},function(t,e){var i=Object.prototype.hasOwnProperty,s=Object.prototype.toString,n=function(t){return\"function\"==typeof Array.isArray?Array.isArray(t):\"[object Array]\"===s.call(t)},o=function(t){\"use strict\";if(!t||\"[object Object]\"!==s.call(t))return!1;var e=i.call(t,\"constructor\"),n=t.constructor&&t.constructor.prototype&&i.call(t.constructor.prototype,\"isPrototypeOf\");if(t.constructor&&!e&&!n)return!1;var o;for(o in t);return void 0===o||i.call(t,o)};t.exports=function t(){\"use strict\";var e,i,s,r,a,h,l=arguments[0],c=1,u=arguments.length,p=!1;for(\"boolean\"==typeof l?(p=l,l=arguments[1]||{},c=2):(\"object\"!=typeof l&&\"function\"!=typeof l||null==l)&&(l={});c<u;++c)if(null!=(e=arguments[c]))for(i in e)s=l[i],r=e[i],l!==r&&(p&&r&&(o(r)||(a=n(r)))?(a?(a=!1,h=s&&n(s)?s:[]):h=s&&o(s)?s:{},l[i]=t(p,h,r)):void 0!==r&&(l[i]=r));return l}},function(t,e,s){/**\n @title NexusUI API\n @overview NexusUI is a JavaScript toolkit for easily creating musical interfaces in web browsers. Interfaces are rendered on HTML5 canvases and are ideal for web audio projects, mobile apps, or for sending OSC to external audio applications like Max.\n @author Ben Taylor, Jesse Allison, Yemin Oh, Sébastien Piquemal\n @copyright © 2011-2014\n @license MIT\n */\nvar n=(s(8),s(3)),o=s(6).EventEmitter,r=s(0),a=s(9),h=t.exports=function(){o.apply(this),this.widgets=new Object,this.elemTypeArr=new Array,this.aniItems=new Array,this.showLabels=!1,this.starttime=(new Date).getTime(),a&&(this.sendsTo=a.setGlobalTransmit,this.setAjaxPath=a.setAjaxPath,this.destination=\"js\",this.ajaxPath=\"lib/nexusOSCRelay.php\"),this.isTouchDevice=\"ontouchstart\"in document.documentElement,this.metas=document.getElementsByTagName(\"meta\"),this.globalWidgets=!0,this.font=\"'open sans'\",this.fontSize=14,this.fontWeight=\"normal\";var t=window.AudioContext||window.webkitAudioContext;this.context=new t,this.sys=navigator.userAgent.toLowerCase(),this.isAndroid=this.sys.indexOf(\"android\")>-1,this.isMobile=this.sys.indexOf(\"mobile\")>-1,this.throttlePeriod=20,this.colors.borderhl=n.shadeBlendConvert(-.5,this.colors.border),this.colors.accenthl=n.shadeBlendConvert(.15,this.colors.accent)};r.inherits(h,o),h.prototype.add=function(t,e){if(t){var i=document.createElement(\"canvas\");if(i.setAttribute(\"nx\",t),e){if((e.x||e.y)&&(i.style.position=\"absolute\"),e.x&&(i.style.left=e.x+\"px\"),e.y&&(i.style.top=e.y+\"px\"),e.w&&(i.style.width=e.w,\"string\"!=typeof e.w&&(i.width=e.w)),e.h&&(i.style.height=e.h,\"string\"!=typeof e.h&&(i.height=e.h)),e.parent){var s;\"string\"==typeof e.parent?s=document.getElementById(e.parent):e.parent instanceof HTMLElement?s=e.parent:e.parent instanceof jQuery&&(s=e.parent[0])}e.name&&(i.id=e.name)}if(!s)var s=document.body;return s.appendChild(i),this.transform(i)}},h.prototype.transform=function(t,e){for(var i in nx.widgets)if(nx.widgets[i].canvasID==t.id)return;if(e)var n=e;else var n=t.getAttribute(\"nx\");if(n){var o,r=0;for(j=0;j<this.elemTypeArr.length;j++)this.elemTypeArr[j]===n&&r++;if(this.elemTypeArr.push(n),!t.id){var a=r+1;t.id=n+a}if(n)try{var o=new(s(27)[n])(t.id)}catch(t){return void console.log(\"creation of \"+n+\" failed\")}return o.type=n,this.widgets[o.canvasID]=o,this.globalWidgets&&(window[o.canvasID]=this.widgets[o.canvasID]),o.init(),o}},h.prototype.transmit=function(t,e){this.makeOSC(this.emit,t,e),this.emit(\"*\",t,e)},h.prototype.colorize=function(t,e){e||(e=t,t=\"accent\"),this.colors[t]=e,this.colors.borderhl=n.shadeBlendConvert(.1,this.colors.border,this.colors.black),this.colors.accenthl=n.shadeBlendConvert(.3,this.colors.accent);for(var i in this.widgets)this.widgets[i].colors[t]=e,this.widgets[i].colors.borderhl=this.colors.borderhl,this.widgets[i].colors.accenthl=this.colors.accenthl,this.widgets[i].draw()},h.prototype.setThrottlePeriod=function(t){this.throttlePeriod=t;for(var e in this.widgets)this.widgets[e].throttlePeriod=this.throttlePeriod},h.prototype.colors={accent:\"#ff5500\",fill:\"#eeeeee\",border:\"#e3e3e3\",mid:\"#1af\",black:\"#000000\",white:\"#FFFFFF\"},h.prototype.startPulse=function(){this.pulseInt=setInterval(\"nx.pulse()\",30)},h.prototype.stopPulse=function(){clearInterval(this.pulseInt)},h.prototype.pulse=function(){for(var t=0;t<this.aniItems.length;t++)this.aniItems[t]()},h.prototype.addAni=function(t){},h.prototype.removeAni=function(t){this.aniItems.splice(this.aniItems.indexOf(t))},h.prototype.addStylesheet=function(){var t='select {width: 150px;padding: 5px 5px;font-size: 16px;color:#666666;border: solid 2px #e4e4e4;border-radius: 0;-webkit-appearance: none;outline: none;cursor:pointer;background-color:#EEE;font-family:\"open sans\";}input[type=text]::-moz-selection { background: transparent; }input[type=text]::selection { background: transparent; }input[type=text]::-webkit-selection { background: transparent; }canvas { cursor:pointer;border-radius:0px;moz-border-radius:0px;webkit-border-radius:0px;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;}input[type=text] { border-radius:5px;moz-border-radius:5px;webkit-border-radius:5px;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;}',e=document.head,i=document.createElement(\"style\");i.type=\"text/css\",i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t)),e.appendChild(i)},h.prototype.setViewport=function(t){for(i=0;i<this.metas.length;i++)\"viewport\"==this.metas[i].name&&(this.metas[i].content=\"minimum-scale=\"+t+\", maximum-scale=\"+t)},h.prototype.setLabels=function(t){this.showLabels=\"on\"==t;for(var e in this.widgets)this.widgets[e].draw()},h.prototype.setProp=function(t,e){if(t&&e){nx[t]=e;for(var i in this.widgets)this.widgets[i][t]=e,this.widgets[i].draw()}},h.prototype.blockMove=function(t){t.target.attributes.nx&&(t.preventDefault(),this.isAndroid&&!!t.stopPropagation&&t.stopPropagation())},h.prototype.calculateDigits=function(t){var e=this.max?Math.floor(this.max).toString().length:1;if(e<this.maxdigits)var i=3-e;else var i=0;return{wholes:e,decimals:i,total:e+i}},h.prototype.themes={light:{fill:\"#DDDDDD\",border:\"#DADADA\",black:\"#000000\",white:\"#FFFFFF\",body:\"#F3F3F3\"},dark:{fill:\"#222\",border:\"#292929\",black:\"#FFFFFF\",white:\"#000000\",body:\"#111\"},red:\"#f24\",orange:\"#f50\",yellow:\"#ec1\",green:\"#1c9\",blue:\"#09d\",purple:\"#40a\"},h.prototype.skin=function(t){var e=t.split(\"-\");nx.colorize(\"fill\",nx.themes[e[0]].fill),nx.colorize(\"border\",nx.themes[e[0]].border),nx.colorize(\"black\",nx.themes[e[0]].black),nx.colorize(\"white\",nx.themes[e[0]].white),nx.colorize(\"accent\",nx.themes[e[1]]),document.body.style.backgroundColor=nx.themes[e[0]].body},h.prototype.labelSize=function(t){for(var e in this.widgets){var i=this.widgets[e];if(i.label){var s=i.GUI.h+t;i.labelSize=t,[\"select\",\"number\",\"text\"].indexOf(i.type)<0&&i.resize(!1,s)}}var n=document.querySelectorAll(\".nxlabel\");console.log(n);for(var o=0;o<n.length;o++)console.log(n[o]),n[o].style.fontSize=t/2.8+\"px\",console.log(n[o].style.fontSize)}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),banner=module.exports=function(t){this.defaultSize={width:100,height:40},widget.call(this,t),this.message1=\"Powered By\",this.message2=\"NexusUI\",this.link=\"http://www.nexusosc.com\",this.isLink=!0};util.inherits(banner,widget),banner.prototype.init=function(){this.draw()},banner.prototype.draw=function(){with(this.context)globalAlpha=.1,fillStyle=this.colors.accent,beginPath(),moveTo(0,10),lineTo(10,this.GUI.h/2+5),lineTo(0,this.GUI.h),lineTo(30,this.GUI.h),lineTo(30,10),fill(),moveTo(this.GUI.w-30,10),lineTo(this.GUI.w-30,this.GUI.h),lineTo(this.GUI.w,this.GUI.h),lineTo(this.GUI.w-10,this.GUI.h/2+5),lineTo(this.GUI.w,10),fill(),closePath(),globalAlpha=1,fillStyle=this.colors.accent,fillRect(15,0,this.GUI.w-30,this.GUI.h-10),fillStyle=this.colors.white,font=this.fontWeight+\" \"+this.GUI.h/5+\"px \"+this.font,textAlign=\"center\",fillText(this.message1,this.GUI.w/2,this.GUI.h/3.3),fillText(this.message2,this.GUI.w/2,this.GUI.h/3.3*2),fillStyle=this.colors.black,beginPath(),moveTo(15,this.GUI.h-10),lineTo(30,this.GUI.h),lineTo(30,this.GUI.h-10),lineTo(15,this.GUI.h-10),fill(),moveTo(this.GUI.w-15,this.GUI.h-10),lineTo(this.GUI.w-30,this.GUI.h),lineTo(this.GUI.w-30,this.GUI.h-10),lineTo(this.GUI.w-15,this.GUI.h-10),fill(),closePath()},banner.prototype.click=function(){this.isLink&&(window.location=this.link)}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),drawing=__webpack_require__(3),button=module.exports=function(t){this.defaultSize={width:50,height:50},widget.call(this,t),this.val={press:0},this.mode=\"aftertouch\",this.lockResize=!0,this.image=null,this.imageHover=null,this.imageTouch=null,this.subval=new Object,this.init()};util.inherits(button,widget),button.prototype.init=function(){this.center={x:this.GUI.w/2,y:this.GUI.h/2},this.strokeWidth=this.GUI.w/20,this.radius=Math.min(this.center.x,this.center.y),this.draw()},button.prototype.draw=function(){with(this.erase(),this.context){if(null!==this.image)this.val.press?this.imageTouch?drawImage(this.imageTouch,0,0):(drawImage(this.image,0,0),globalAlpha=.5,fillStyle=this.colors.accent,fillRect(0,0,this.GUI.w,this.GUI.h),globalAlpha=1):drawImage(this.image,0,0);else if(this.val.press?this.val.press&&(fillStyle=this.colors.accent,strokeStyle=this.colors.accenthl):(fillStyle=this.colors.fill,strokeStyle=this.colors.border),lineWidth=this.strokeWidth,beginPath(),arc(this.center.x,this.center.y,this.radius,0,2*Math.PI,!0),fill(),closePath(),beginPath(),arc(this.center.x,this.center.y,this.radius-lineWidth/2,0,2*Math.PI,!0),stroke(),globalAlpha=1,closePath(),this.val.press&&\"aftertouch\"==this.mode){var x=nx.clip(this.clickPos.x,.2*this.GUI.w,this.GUI.w/1.3),y=nx.clip(this.clickPos.y,.2*this.GUI.h,this.GUI.h/1.3),gradient=this.context.createRadialGradient(x,y,this.GUI.w/6,this.center.x,this.center.y,1.3*this.radius);gradient.addColorStop(0,this.colors.accent),gradient.addColorStop(1,\"white\"),strokeStyle=gradient,lineWidth=this.GUI.w/20,beginPath(),arc(this.center.x,this.center.y,this.radius-this.GUI.w/40,0,2*Math.PI,!0),stroke(),closePath()}this.drawLabel()}},button.prototype.click=function(t){drawing.isInside(this.clickPos,{x:this.center.x-this.radius,y:this.center.y-this.radius,w:2*this.radius,h:2*this.radius})&&(this.val.press=1,\"aftertouch\"==this.mode&&(this.val.x=this.clickPos.x,this.val.y=this.clickPos.y),this.transmit(this.val),this.draw())},button.prototype.move=function(){\"aftertouch\"==this.mode&&(this.val.x=this.clickPos.x,this.val.y=this.clickPos.y,this.subval.x=this.clickPos.x,this.subval.y=this.clickPos.y,this.transmit(this.subval),this.draw())},button.prototype.release=function(){this.val.press=0,\"toggle\"!=this.mode&&\"aftertouch\"!=this.mode||this.transmit(this.val),this.draw()},button.prototype.setImage=function(t){this.image=new Image,this.image.onload=this.draw.bind(this),this.image.src=t},button.prototype.setHoverImage=function(t){this.imageHover=new Image,this.imageHover.onload=this.draw.bind(this),this.imageHover.src=t},button.prototype.setTouchImage=function(t){this.imageTouch=new Image,this.imageTouch.onload=this.draw.bind(this),this.imageTouch.src=t}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),colors=module.exports=function(t){this.defaultSize={width:100,height:100},widget.call(this,t),this.init()};util.inherits(colors,widget),colors.prototype.init=function(){this.gradient1=this.context.createLinearGradient(0,0,this.GUI.w,0),this.gradient1.addColorStop(0,\"#F00\"),this.gradient1.addColorStop(.17,\"#FF0\"),this.gradient1.addColorStop(.34,\"#0F0\"),this.gradient1.addColorStop(.51,\"#0FF\"),this.gradient1.addColorStop(.68,\"#00F\"),this.gradient1.addColorStop(.85,\"#F0F\"),this.gradient1.addColorStop(1,\"#F00\"),this.gradient2=this.context.createLinearGradient(0,0,0,this.GUI.h),this.gradient2.addColorStop(0,\"rgba(0,0,0,255)\"),this.gradient2.addColorStop(.49,\"rgba(0,0,0,0)\"),this.gradient2.addColorStop(.51,\"rgba(255,255,255,0)\"),this.gradient2.addColorStop(.95,\"rgba(255,255,255,255)\"),this.draw()},colors.prototype.draw=function(){with(this.erase(),this.context)fillStyle=this.gradient1,fillRect(0,0,this.GUI.w,this.GUI.h),fillStyle=this.gradient2,fillRect(0,0,this.GUI.w,this.GUI.h);this.drawLabel()},colors.prototype.drawColor=function(){with(this.context)fillStyle=\"rgb(\"+this.val.r+\",\"+this.val.g+\",\"+this.val.b+\")\",fillRect(0,.95*this.GUI.h,this.GUI.w,.05*this.GUI.h)},colors.prototype.click=function(t){if(this.clickPos.x>0&&this.clickPos.y>0&&this.clickPos.x<this.GUI.w&&this.clickPos.y<this.GUI.h){var e=this.context.getImageData(2*this.clickPos.x,2*this.clickPos.y,1,1);this.val={r:e.data[0],g:e.data[1],b:e.data[2]},this.transmit(this.val),this.drawColor()}},colors.prototype.move=function(t){this.click(t)}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),comment=module.exports=function(t){this.defaultSize={width:100,height:20},widget.call(this,t),this.val={text:\"comment\"},this.sizeSet=!1,this.init()};util.inherits(comment,widget),comment.prototype.setSize=function(t){this.size=t,this.sizeSet=!0,this.draw()},comment.prototype.init=function(){this.draw()},comment.prototype.draw=function(){with(this.sizeSet||(this.size=Math.sqrt(this.GUI.w*this.GUI.h/(2*this.val.text.length))),this.erase(),this.context)fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),fillStyle=this.colors.black,textAlign=\"left\",font=this.size+\"px 'Open Sans'\";this.wrapText(this.val.text,6,3+this.size,this.GUI.w-6,this.size)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),crossfade=module.exports=function(t){this.defaultSize={width:100,height:30},widget.call(this,t),this.val={R:.75,L:.75},this.location=.5,this.init()};util.inherits(crossfade,widget),crossfade.prototype.init=function(){this.draw()},crossfade.prototype.draw=function(){with(this.erase(),this.location=Math.pow(this.val.R,2),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h);var y1=0,y2=this.GUI.h,x1=this.location*this.GUI.w;fillStyle=this.colors.accent,fillRect(x1,0,this.GUI.w-x1,y2),textBaseline=\"middle\",font=this.GUI.h/3+\"px 'Open Sans'\",fillStyle=this.colors.accent,textAlign=\"right\",fillText(this.val.R.toFixed(2),x1-2,this.GUI.h/4),fillStyle=this.colors.fill,textAlign=\"left\",fillText(this.val.L.toFixed(2),x1+2,.75*this.GUI.h)}this.drawLabel()},crossfade.prototype.click=function(){this.move()},crossfade.prototype.move=function(){var t=math.clip(this.clickPos.x/this.GUI.w,0,1),e=1-t;this.location=t,this.val.R=math.prune(Math.sqrt(t),3),this.val.L=math.prune(Math.sqrt(e),3),this.draw(),this.transmit(this.val)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),dial=module.exports=function(t){this.defaultSize={width:100,height:100},widget.call(this,t),this.circleSize,this.handleLength,this.val={value:0},this.responsivity=.004,this.aniStart=0,this.aniStop=1,this.aniMove=.01,this.lockResize=!0,null!=this.canvas.getAttribute(\"min\")?this.min=parseFloat(this.canvas.getAttribute(\"min\")):this.min=0,null!=this.canvas.getAttribute(\"max\")?this.max=parseFloat(this.canvas.getAttribute(\"max\")):this.max=1,null!=this.canvas.getAttribute(\"step\")?this.step=parseFloat(this.canvas.getAttribute(\"step\")):this.step=.001,this.maxdigits=3,this.calculateDigits=nx.calculateDigits,this.init()};util.inherits(dial,widget),dial.prototype.init=function(){this.circleSize=Math.min(this.center.x,this.center.y),this.handleLength=this.circleSize,this.mindim=Math.min(this.GUI.w,this.GUI.h),this.mindim<101||this.mindim<101?this.accentWidth=1*this.lineWidth:this.accentWidth=2*this.lineWidth,this.draw()},dial.prototype.draw=function(){var normalval=this.normalize(this.val.value),dial_position=2*(normalval+.25)*Math.PI;with(this.erase(),this.context)if(lineCap=\"butt\",beginPath(),lineWidth=this.circleSize/2,arc(this.center.x,this.center.y,this.circleSize-lineWidth/2,0*Math.PI,2*Math.PI,!1),strokeStyle=this.colors.fill,stroke(),closePath(),lineCap=\"butt\",beginPath(),lineWidth=this.circleSize/2,arc(this.center.x,this.center.y,this.circleSize-lineWidth/2,.5*Math.PI,dial_position,!1),strokeStyle=this.colors.accent,stroke(),closePath(),clearRect(this.center.x-this.GUI.w/40,this.center.y,this.GUI.w/20,this.GUI.h/2),normalval>0&&(beginPath(),lineWidth=1.5,moveTo(this.center.x-this.GUI.w/40,this.center.y+this.circleSize/2),lineTo(this.center.x-this.GUI.w/40,this.center.y+this.circleSize),strokeStyle=this.colors.accent,stroke(),closePath()),this.val.value=math.prune(this.rangify(normalval),3),this.digits=this.calculateDigits(),valtextsize=this.mindim/this.digits.total*.55,valtextsize>7){var valtext=this.val.value.toFixed(this.digits.decimals);fillStyle=this.colors.borderhl,textAlign=\"center\",textBaseline=\"middle\",font=valtextsize+\"px 'Open Sans'\",fillText(valtext,this.GUI.w/2,this.GUI.h/2)}this.drawLabel()},dial.prototype.click=function(t){this.val.value=math.prune(this.val.value,4),this.transmit(this.val),this.draw(),this.aniStart=this.val.value},dial.prototype.move=function(){var t=this.normalize(this.val.value);t=math.clip(t-this.deltaMove.y*this.responsivity,0,1),this.val.value=math.prune(this.rangify(t),4),this.transmit(this.val),this.draw()},dial.prototype.release=function(){this.aniStop=this.val.value},dial.prototype.animate=function(t){switch(t){case\"bounce\":nx.aniItems.push(this.aniBounce.bind(this));break;case\"none\":nx.aniItems.splice(nx.aniItems.indexOf(this.aniBounce))}},dial.prototype.aniBounce=function(){this.clicked||(this.val.value+=this.aniMove,this.aniStop<this.aniStart&&(this.stopPlaceholder=this.aniStop,this.aniStop=this.aniStart,this.aniStart=this.stopPlaceholder),this.aniMove=math.bounce(this.val.value,this.aniStart,this.aniStop,this.aniMove),this.draw(),this.val.value=math.prune(this.val.value,4),this.transmit(this.val))}},function(module,exports,__webpack_require__){var startTime=0,math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),envelope=module.exports=function(t){this.defaultSize={width:200,height:100},widget.call(this,t),this.nodeSize=1,this.active=!1,this.duration=1e3,this.looping=!1,this.scanIndex=0,this.val={index:0,amp:0,points:[{x:.1,y:.4},{x:.35,y:.6},{x:.65,y:.2},{x:.9,y:.4}]},this.selectedNode=null,nx.aniItems.push(this.pulse.bind(this)),this.init()};util.inherits(envelope,widget),envelope.prototype.init=function(){this.mindim=this.GUI.w<this.GUI.h?this.GUI.w:this.GUI.h,this.draw()},envelope.prototype.draw=function(){with(this.erase(),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),fillStyle=this.colors.accent;var centerx=this.mindim/10,centery=this.GUI.h-this.mindim/10;beginPath(),moveTo(centerx,centery),arc(centerx,centery,this.mindim/10,1.5*Math.PI,2*Math.PI*this.val.index+1.5*Math.PI,!1),fill(),closePath();for(var drawingX=[],drawingY=[],i=0;i<this.val.points.length;i++)drawingX[i]=this.val.points[i].x*this.GUI.w,drawingY[i]=(1-this.val.points[i].y)*this.GUI.h,drawingX[i]<this.bgLeft+this.nodeSize?drawingX[i]=this.bgLeft+this.nodeSize:drawingX[i]>this.bgRight-this.nodeSize&&(drawingX[i]=this.bgRight-this.nodeSize),drawingY[i]<this.bgTop+this.nodeSize?drawingY[i]=this.bgTop+this.nodeSize:drawingY[i]>this.bgBottom-this.nodeSize&&(drawingY[i]=this.bgBottom-this.nodeSize);for(var j=0;j<drawingX.length;j++){var size=this.mindim/35+2;beginPath(),arc(drawingX[j],drawingY[j],size,0,2*Math.PI,!1),fillStyle=this.colors.accent,fill(),closePath()}beginPath(),strokeStyle=this.colors.accent,moveTo(-5,this.GUI.h),lineTo(-5,(1-this.val.points[0].y)*this.GUI.h);for(var j=0;j<drawingX.length;j++)lineTo(drawingX[j],drawingY[j]);lineTo(this.GUI.w+5,(1-this.val.points[this.val.points.length-1].y)*this.GUI.h),lineTo(this.GUI.w+5,this.GUI.h),stroke(),globalAlpha=.2,fillStyle=this.colors.accent,fill(),globalAlpha=1,closePath()}this.drawLabel()},envelope.prototype.scaleNode=function(t){var e=t,i=0,s=this.GUI.w,n=this.val.points[e].x,o=this.GUI.h-this.val.points[e].y,r=math.clip(n/this.GUI.w,0,1),a=math.clip(o/this.GUI.h,0,1);this.val.points[e].x=math.prune(r,3),this.val.points[e].y=math.prune(a,3),e>0&&(i=this.val.points[e-1].x),this.val.points.length>e+1&&(s=this.val.points[e+1].x),this.val.points[e].x<i&&(this.val.points.splice(e-1,0,this.val.points.splice(e,1)[0]),e-=1,this.selectedNode=e),this.val.points[e].x>s&&(this.val.points.splice(e+1,0,this.val.points.splice(e,1)[0]),e+=1,this.selectedNode=e)},envelope.prototype.click=function(){this.selectedNode=this.findNearestNode(this.clickPos.x/this.GUI.w,this.clickPos.y/this.GUI.h,this.val.points),this.transmit(this.val),this.draw()},envelope.prototype.move=function(){this.clicked&&(this.val.points[this.selectedNode].x=this.clickPos.x,this.val.points[this.selectedNode].y=this.clickPos.y,this.scaleNode(this.selectedNode),this.transmit(this.val),this.draw())},envelope.prototype.release=function(){this.hasMoved||this.val.points.splice(this.selectedNode,1),this.draw(),this.selectedNode=null},envelope.prototype.pulse=function(){if(this.active){var t=(nx.context.currentTime-startTime)/(this.duration/1e3);if(t>=1&&(this.looping?(t-=1,startTime+=this.duration/1e3,this.val.index=0,this.scanIndex=0):this.stop()),this.val.index=t,this.val.index>this.val.points[this.val.points.length-1].x)this.val.amp=this.val.points[this.val.points.length-1].y;else if(this.val.index<this.val.points[0].x)this.val.amp=this.val.points[0].y;else{for(this.scanIndex=0;this.val.index>this.val.points[this.scanIndex].x;)this.scanIndex++;var e=this.val.points[this.scanIndex].x,i=this.val.points[this.scanIndex-1].x,s=this.val.points[this.scanIndex].y,n=this.val.points[this.scanIndex-1].y;this.val.amp=math.interp((this.val.index-i)/(e-i),n,s)}this.transmit(this.val),this.draw()}},envelope.prototype.start=function(){this.active=!0,this.val.index=0,startTime=nx.context.currentTime},envelope.prototype.stop=function(){this.active=!1,this.val.index=0,this.draw()},envelope.prototype.findNearestNode=function(t,e,i){var s=null,n=1e3,o=!1;e=1-e;for(var r=0;r<i.length;r++){var a=Math.sqrt(Math.pow(i[r].x-t,2),Math.pow(i[r].y- -e,2));a<n&&(n=a,s=r,o=t>i[r].x)}return n>.1&&(o&&s++,this.val.points.splice(s,0,{x:this.clickPos.x/this.GUI.w,y:(this.GUI.h-this.clickPos.y)/this.GUI.h})),s}},function(t,e,i){t.exports={banner:i(20),button:i(21),colors:i(22),comment:i(23),crossfade:i(24),dial:i(25),envelope:i(26),joints:i(28),keyboard:i(29),matrix:i(30),message:i(31),meter:i(32),metro:i(33),motion:i(34),mouse:i(35),multislider:i(36),multitouch:i(37),number:i(38),position:i(39),range:i(40),select:i(41),slider:i(42),string:i(43),tabs:i(44),text:i(45),tilt:i(46),toggle:i(47),typewriter:i(48),vinyl:i(49),waveform:i(50)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),joints=module.exports=function(t){this.defaultSize={width:150,height:150},widget.call(this,t),this.nodeSize=this.GUI.w/14,this.values=[0,0],this.val={x:.35,y:.35,node1:0},this.joints=[{x:.1,y:.2},{x:.2,y:.1},{x:.3,y:.7},{x:.4,y:.4},{x:.5,y:.9},{x:.6,y:.15},{x:.7,y:.3},{x:.8,y:.8}],this.threshold=this.GUI.w/3};util.inherits(joints,widget),joints.prototype.init=function(){this.nodeSize=this.GUI.w/14,this.threshold=this.GUI.w/3,this.draw()},joints.prototype.draw=function(){with(this.erase(),this.drawingX=this.val.x*this.GUI.w,this.drawingY=this.val.y*this.GUI.h,this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),null!=this.val.x?this.drawNode():(fillStyle=this.colors.border,font=\"14px courier\",fillText(this.default_text,10,20)),fillStyle=this.colors.accent,strokeStyle=this.colors.border;for(var i in this.joints){beginPath(),arc(this.joints[i].x*this.GUI.w,this.joints[i].y*this.GUI.h,this.nodeSize/2,0,2*Math.PI,!0),fill(),closePath();var cnctX=Math.abs(this.joints[i].x*this.GUI.w-this.drawingX),cnctY=Math.abs(this.joints[i].y*this.GUI.h-this.drawingY),strength=cnctX+cnctY;if(strength<this.threshold){beginPath(),moveTo(this.joints[i].x*this.GUI.w,this.joints[i].y*this.GUI.h),lineTo(this.drawingX,this.drawingY),strokeStyle=this.colors.accent,lineWidth=math.scale(strength,0,this.threshold,this.nodeSize/2,5),stroke(),closePath();var scaledstrength=math.scale(strength,0,this.threshold,1,0);this.val[\"node\"+i]=scaledstrength}}}this.drawLabel()},joints.prototype.drawNode=function(){with(this.drawingX<this.nodeSize?this.drawingX=this.nodeSize:this.drawingX>this.GUI.w-this.nodeSize&&(this.drawingX=this.GUI.w-this.nodeSize),this.drawingY<this.nodeSize?this.drawingY=this.nodeSize:this.drawingY>this.GUI.h-this.nodeSize&&(this.drawingY=this.GUI.h-this.nodeSize),this.context)globalAlpha=1,beginPath(),fillStyle=this.colors.accent,strokeStyle=this.colors.border,lineWidth=this.lineWidth,arc(this.drawingX,this.drawingY,this.nodeSize,0,2*Math.PI,!0),fill(),closePath()},joints.prototype.click=function(){this.val=new Object,this.val.x=this.clickPos.x/this.GUI.w,this.val.y=this.clickPos.y/this.GUI.h,this.draw(),this.transmit(this.val),this.connections=new Array},joints.prototype.move=function(){this.val=new Object,this.clicked&&(this.val.x=this.clickPos.x/this.GUI.w,this.val.y=this.clickPos.y/this.GUI.h,this.draw(),this.transmit(this.val),this.connections=new Array)},joints.prototype.release=function(){this.anix=this.deltaMove.x/this.GUI.w,this.aniy=this.deltaMove.y/this.GUI.h},joints.prototype.animate=function(t){switch(t){case\"bounce\":nx.aniItems.push(this.aniBounce.bind(this));break;case\"none\":nx.aniItems.splice(nx.aniItems.indexOf(this.aniBounce))}},joints.prototype.anix=0,joints.prototype.aniy=0,joints.prototype.aniBounce=function(){!this.clicked&&this.val.x&&(this.val.x+=this.anix,this.val.y+=this.aniy,this.anix=math.bounce(this.val.x,.1,.9,this.anix),this.aniy=math.bounce(this.val.y,.1,.9,this.aniy),this.draw(),this.transmit(this.val))}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),drawing=__webpack_require__(3),math=__webpack_require__(2),keyboard=module.exports=function(t){this.defaultSize={width:300,height:75},widget.call(this,t),this.octaves=3,this.white={width:0,height:0},this.black={width:0,height:0},this.wkeys=new Array,this.bkeys=new Array,this.keypattern=[\"w\",\"b\",\"w\",\"b\",\"w\",\"w\",\"b\",\"w\",\"b\",\"w\",\"b\",\"w\"],this.keys=new Array,this.midibase=48,this.lineWidth=1,this.fingers=[{key:-1,pkey:-1}],this.multitouch=!1,this.oneleft=!1,this.mode=\"button\",this.val={on:0,note:0,midi:\"0 0\"},this.init()};util.inherits(keyboard,widget),keyboard.prototype.init=function(){this.white={width:0,height:0},this.black={width:0,height:0},this.wkeys=new Array,this.bkeys=new Array,this.keys=new Array,this.white.num=0;for(var t=0;t<this.keypattern.length;t++)\"w\"==this.keypattern[t]&&this.white.num++;this.white.num*=this.octaves,this.white.width=this.GUI.w/this.white.num,this.white.height=this.GUI.h,this.black.width=.6*this.white.width,this.black.height=.6*this.GUI.h;for(var t=0;t<this.keypattern.length*this.octaves;t++)switch(this.keys[t]={note:t+this.midibase,on:!1},this.keypattern[t%this.keypattern.length]){case\"w\":this.keys[t].x=this.wkeys.length*this.white.width,this.keys[t].y=0,this.keys[t].w=this.white.width,this.keys[t].h=this.white.height,this.keys[t].type=\"w\",this.keys[t].index=t,this.wkeys.push(this.keys[t]);break;case\"b\":this.keys[t].x=this.wkeys.length*this.white.width-this.black.width/2,this.keys[t].y=0,this.keys[t].w=this.black.width,this.keys[t].h=this.black.height,this.keys[t].type=\"b\",this.keys[t].index=t,this.bkeys.push(this.keys[t])}this.draw()},keyboard.prototype.draw=function(){with(this.context){strokeStyle=this.colors.borderhl,lineWidth=1;for(var i in this.wkeys)fillStyle=this.wkeys[i].on?this.colors.borderhl:this.colors.fill,strokeRect(this.wkeys[i].x,0,this.white.width,this.white.height),fillRect(this.wkeys[i].x,0,this.white.width,this.white.height);for(var i in this.bkeys)fillStyle=this.bkeys[i].on?this.colors.borderhl:this.colors.black,fillRect(this.bkeys[i].x,0,this.black.width,this.black.height)}this.drawLabel()},keyboard.prototype.toggle=function(t,e){if(\"button\"==this.mode){if(t){t.on=e||!1===e?e:!t.on;var i=t.on?1:0,s=128*math.invert(this.clickPos.y/this.GUI.h);s=math.prune(math.clip(s,5,128),0),this.val={on:i*s,note:t.note,midi:t.note+\" \"+i},this.transmit(this.val),this.draw()}}else if(\"sustain\"==this.mode&&t){t.on=e||!t.on;var i=t.on?1:0,s=128*math.invert(this.clickPos.y/this.GUI.h);s=math.prune(math.clip(s,5,128),0),this.val={on:i*s,note:t.note,midi:t.note+\" \"+i},this.transmit(this.val),this.draw()}},keyboard.prototype.whichKey=function(t,e){for(var i in this.bkeys)if(drawing.isInside({x:t,y:e},this.bkeys[i]))return this.bkeys[i];var s=~~(t/this.white.width);return s>=this.wkeys.length&&(s=this.wkeys.length-1),s<0&&(s=0),this.wkeys[s]},keyboard.prototype.click=function(t){if(this.clickPos.touches.length>1||this.multitouch){this.multitouch=!0,this.clickPos.touches.length>=2&&this.oneleft&&(this.oneleft=!1),this.keysinuse=new Array;for(var e=0;e<this.clickPos.touches.length;e++)this.fingers[e]={key:this.whichKey(this.clickPos.touches[e].x,this.clickPos.touches[e].y)},this.fingers[e].key.on||this.toggle(this.fingers[e].key,!0),this.keysinuse.push(this.fingers[e].key.index);for(var e=0;e<this.keys.length;e++)this.keys[e].on&&this.keysinuse.indexOf(this.keys[e].index)<0&&this.toggle(this.keys[e],!1)}else this.fingers[0].pkey=this.fingers[0].key,this.fingers[0].key=this.whichKey(this.clickPos.x,this.clickPos.y),this.toggle(this.fingers[0].key)},keyboard.prototype.move=function(t){if(this.clickPos.touches.length>1||this.multitouch){this.keysinuse=new Array;for(var e=0;e<this.clickPos.touches.length;e++)this.fingers[e]={key:this.whichKey(this.clickPos.touches[e].x,this.clickPos.touches[e].y)},this.fingers[e].key.on||this.toggle(this.fingers[e].key,!0),this.keysinuse.push(this.fingers[e].key.index);for(var e=0;e<this.keys.length;e++)this.keys[e].on&&this.keysinuse.indexOf(this.keys[e].index)<0&&this.toggle(this.keys[e],!1)}else this.fingers[0].pkey=this.fingers[0].key,this.fingers[0].key=this.whichKey(this.clickPos.x,this.clickPos.y),this.fingers[0].key&&this.fingers[0].key.index!=this.fingers[0].pkey.index&&(this.toggle(this.fingers[0].pkey,!1),this.toggle(this.fingers[0].key,!0))},keyboard.prototype.release=function(t){if(this.clickPos.touches.length>1||this.multitouch){this.keysinuse=new Array;for(var e=0;e<this.clickPos.touches.length&&(!this.oneleft||1!=this.clickPos.touches.length);e++)this.fingers[e]={key:this.whichKey(this.clickPos.touches[e].x,this.clickPos.touches[e].y)},this.keysinuse.push(this.fingers[e].key.index);for(var e=0;e<this.keys.length;e++)this.keys[e].on&&this.keysinuse.indexOf(this.keys[e].index)<0&&this.toggle(this.keys[e],!1);1==this.clickPos.touches.length&&(this.oneleft=!0)}else\"button\"==this.mode&&this.toggle(this.fingers[0].key,!1)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),drawing=__webpack_require__(3),util=__webpack_require__(0),widget=__webpack_require__(1),matrix=module.exports=function(t){this.defaultSize={width:100,height:100},widget.call(this,t),this.row=4,this.col=4,this.cellHgt,this.cellWid,this.matrix,this.val={row:0,col:0,level:0,list:new Array},this.cur,this.prev,this.erasing=!1,this.place=null,this.starttime,this.lastbeat,this.thisframe=0,this.lastframe=0,this.context.lineWidth=1,this.sequencing=!1,this.cellBuffer=4,this.sequenceMode=\"linear\",this.bpm=120,this.pbpm=this.bpm,this.starttime=nx.starttime,this.init()};util.inherits(matrix,widget),matrix.prototype.init=function(){this.pmatrix=!!this.matrix&&this.matrix,this.matrix=null,this.matrix=new Array(this.col);for(var t=0;t<this.col;t++){this.matrix[t]=new Array(this.row);for(var e=0;e<this.row;e++)this.matrix[t][e]=this.pmatrix&&this.pmatrix[t]?this.pmatrix[t][e]:0}this.draw(),this.life=this.unboundlife.bind(this)},matrix.prototype.draw=function(){with(this.erase(),this.cellWid=this.GUI.w/this.col,this.cellHgt=this.GUI.h/this.row,this.context)strokeStyle=this.colors.fill;for(var i=0;i<this.row;i++)for(var j=0;j<this.col;j++){var st_x=j*this.cellWid;0==j&&(st_x+=0);var st_y=i*this.cellHgt;0==i&&(st_y+=0);var boxwid=this.cellWid,boxhgt=this.cellHgt;with(this.context)strokeStyle=this.colors.border,lineWidth=this.cellBuffer,this.matrix[j][i]>0?fillStyle=this.colors.accent:fillStyle=this.colors.fill,fillRect(st_x+this.cellBuffer/2,st_y+this.cellBuffer/2,boxwid-this.cellBuffer,boxhgt-this.cellBuffer),this.place==j&&(globalAlpha=.4,fillStyle=this.colors.border,fillRect(st_x,st_y,boxwid,boxhgt),globalAlpha=1)}this.drawLabel()},matrix.prototype.click=function(t){this.cur={col:~~(this.clickPos.x/this.cellWid),row:~~(this.clickPos.y/this.cellHgt)},this.matrix[this.cur.col][this.cur.row]?(this.matrix[this.cur.col][this.cur.row]=0,this.erasing=!0):(this.matrix[this.cur.col][this.cur.row]=1,this.erasing=!1),this.cur.value=this.matrix[this.cur.col][this.cur.row],this.prev=this.cur,this.val={row:this.cur.row,col:this.cur.col,level:this.cur.value},this.transmit(this.val),this.draw()},matrix.prototype.move=function(t){this.clicked&&(this.cur={col:~~(this.clickPos.x/this.cellWid),row:~~(this.clickPos.y/this.cellHgt)},this.cur.row<this.row&&this.cur.col<this.col&&this.cur.row>=0&&this.cur.col>=0&&(this.cur.col==this.prev.col&&this.cur.row==this.prev.row||(this.erasing?this.matrix[this.cur.col][this.cur.row]=0:this.matrix[this.cur.col][this.cur.row]=1,this.cur.value=this.matrix[this.cur.col][this.cur.row],this.prev=this.cur,this.val={row:this.cur.row,col:this.cur.col,level:this.cur.value},this.transmit(this.val),this.draw())))},matrix.prototype.setCell=function(t,e,i){var s=i?1:0;this.matrix[t][e]=s,this.val={row:e,col:t,level:s},this.transmit(this.val),this.draw()},matrix.prototype.sequence=function(t){t&&(this.bpm=t),this.sequencing=!0,requestAnimationFrame(this.seqStep.bind(this))},matrix.prototype.setBPM=function(t){this.bpm=t},matrix.prototype.stop=function(){this.sequencing=!1},matrix.prototype.seqStep=function(){0==this.bpm&&(this.bpm=1);var t=(new Date).getTime(),e=t-this.starttime;if(this.bpm!=this.pbpm){e=e/(6e4/this.pbpm)*(6e4/this.bpm),this.starttime=t-e,this.thisframe=~~(e/(6e4/this.bpm))}else this.thisframe=~~(e/(6e4/this.bpm));this.pbpm=this.bpm,this.thisframe!=this.lastframe&&(this.lastbeat=t,\"linear\"==this.sequenceMode?this.place++:\"random\"==this.sequenceMode&&(this.place=math.random(this.col)),this.place>=this.col&&(this.place=0),null==this.place&&(this.place=0),this.jumpToCol(this.place)),this.lastframe=this.thisframe,this.sequencing&&requestAnimationFrame(this.seqStep.bind(this))},matrix.prototype.jumpToCol=function(t){this.place=t,this.val={list:this.matrix[this.place]},this.transmit(this.val),this.draw()},matrix.prototype.customDestroy=function(){this.stop()},matrix.prototype.unboundlife=function(){if(!this.clicked){this.newmatrix=[];for(var t=0;t<this.col;t++){this.newmatrix[t]=[];for(var e=0;e<this.row;e++){var i=0;t-1>=0&&(i+=this.matrix[t-1][e-1]?this.matrix[t-1][e-1]:0,i+=this.matrix[t-1][e]?this.matrix[t-1][e]:0,i+=this.matrix[t-1][e+1]?this.matrix[t-1][e+1]:0),i+=this.matrix[t][e-1]?this.matrix[t][e-1]:0,i+=this.matrix[t][e+1]?this.matrix[t][e+1]:0,t+1<this.col&&(i+=this.matrix[t+1][e-1]?this.matrix[t+1][e-1]:0,i+=this.matrix[t+1][e]?this.matrix[t+1][e]:0,i+=this.matrix[t+1][e+1]?this.matrix[t+1][e+1]:0),this.matrix[t][e]?i<2?this.newmatrix[t][e]=0:2==i||3==i?this.newmatrix[t][e]=1:i>3&&(this.newmatrix[t][e]=0):this.matrix[t][e]||3!=i?this.newmatrix[t][e]=this.matrix[t][e]:this.newmatrix[t][e]=1}}this.matrix=this.newmatrix}this.transmit({grid:this.matrix}),this.draw()},matrix.prototype.life=function(){return!1}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),message=module.exports=function(t){this.defaultSize={width:100,height:30},widget.call(this,t),this.val={value:\"send a message\"},this.size=14};util.inherits(message,widget),message.prototype.init=function(){this.canvas.getAttribute(\"label\")&&(this.val.value=this.canvas.getAttribute(\"label\")),this.draw()},message.prototype.draw=function(){with(this.erase(),this.context)this.clicked?fillStyle=this.colors.border:fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),this.clicked,fillStyle=this.colors.black,textAlign=\"left\",font=this.size+\"px \"+nx.font;this.wrapText(this.val.value,5,1+this.size,this.GUI.w-6,this.size)},message.prototype.click=function(t){this.draw(),this.transmit(this.val)},message.prototype.release=function(t){this.draw()}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),drawing=__webpack_require__(3),widget=__webpack_require__(1),meter=module.exports=function(t){this.defaultSize={width:20,height:50},widget.call(this,t),this.val={level:0},this.dataArray,this.bars=8,this.init()};util.inherits(meter,widget),meter.prototype.init=function(){with(this.bar={x:0,y:0,w:this.GUI.w,h:this.GUI.h/this.bars},this.context)fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h)},meter.prototype.setup=function(t,e){this.actx=t,this.source=e,this.analyser=this.actx.createAnalyser(),this.analyser.smoothingTimeConstant=.85,this.analyser.fftsize=1024,this.bufferLength=this.analyser.frequencyBinCount,this.dataArray=new Uint8Array(this.bufferLength),this.source.connect(this.analyser),this.draw()},meter.prototype.draw=function(){if(this.dataArray){this.analyser.getByteTimeDomainData(this.dataArray);var max=Math.max.apply(null,this.dataArray),min=Math.min.apply(null,this.dataArray),amp=max-min;amp/=240;var db=Math.log(amp)/Math.log(10)*20;with(this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h);for(var dboffset=Math.floor((db+40)/(50/this.bars)),i=0;i<this.bars;i++)i>=.8*this.bars?fillStyle=\"rgb(255,0,0)\":i<.8*this.bars&&i>=.69*this.bars?fillStyle=\"rgb(255,255,0)\":i<.69*this.bars&&(fillStyle=\"rgb(0,255,0)\"),i<dboffset&&fillRect(1,this.GUI.h-this.bar.h*i,this.GUI.w-2,this.bar.h-2)}}setTimeout(function(){window.requestAnimationFrame(this.draw.bind(this))}.bind(this),80)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),metro=module.exports=function(t){this.defaultSize={width:100,height:20},widget.call(this,t),this.val={beat:0},this.x=10,this.y=10,this.loc=10,this.nodeSize=10,this.speed=1,this.direction=1,this.orientation=\"horizontal\",this.boundary=this.GUI.w,nx.aniItems.push(this.advance.bind(this)),this.active=!0,this.init()};util.inherits(metro,widget),metro.prototype.init=function(){this.nodeSize=Math.min(this.GUI.w,this.GUI.h)/2,this.GUI.w<this.GUI.h?(this.orientation=\"vertical\",this.boundary=this.GUI.h):(this.orientation=\"horizontal\",this.boundary=this.GUI.w),this.x=this.nodeSize,this.y=this.nodeSize,this.loc=this.nodeSize,this.draw()},metro.prototype.draw=function(){with(this.erase(),this.context)fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),beginPath(),fillStyle=this.colors.accent,arc(this.x,this.y,this.nodeSize,0,2*Math.PI,!0),fill(),closePath();this.drawLabel()},metro.prototype.click=function(){},metro.prototype.move=function(){this.clicked&&(this.speed-=this.deltaMove.y/50)},metro.prototype.release=function(){},metro.prototype.advance=function(){this.speed,this.loc+=this.speed*this.direction,(this.loc-this.nodeSize<0||this.loc+this.nodeSize>this.boundary)&&(this.val.beat=math.scale(this.direction,-1,1,0,1),this.transmit(this.val),this.direction*=-1),\"vertical\"==this.orientation?this.y=this.loc:this.x=this.loc,this.draw()},metro.prototype.customDestroy=function(){nx.removeAni(this.advance.bind(this))}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),motion=module.exports=function(target){if(this.defaultSize={width:75,height:75},widget.call(this,target),this.motionLR,this.motionFB,this.z,this.active=!0,this.px=0,this.py=0,this.pz=0,this.val={x:0,y:0,z:0},this.text=\"Motion\",this.init(),this.boundMotion=this.motionlistener.bind(this),window.DeviceMotionEvent)window.addEventListener(\"devicemotion\",this.boundMotion,!1);else with(this.context)fillText(\"incompatible\",0,0),this.active=!1};util.inherits(motion,widget),motion.prototype.deviceMotionHandler=function(){this.val={x:math.prune(this.motionLR/10,4),y:math.prune(this.motionFB/10,4),z:math.prune(this.z/10,4)},this.transmit(this.val)},motion.prototype.motionlistener=function(e){var data=e.acceleration;if(this.active&&(this.motionLR=nx.lp(this.canvasID+\"motionx\",data.x,20),this.motionFB=nx.lp(this.canvasID+\"motiony\",data.y,20),this.z=nx.lp(this.canvasID+\"motionz\",data.z,20),this.deviceMotionHandler(),this.draw(),null===data.x||void 0===data.x)){with(this.erase(),this.context)fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),fillStyle=this.colors.black,font=\"12px courier\",textAlign=\"center\",fillText(\"no data\",this.GUI.w/2,this.GUI.h/2);this.active=!1}},motion.prototype.init=function(){this.draw()},motion.prototype.draw=function(){with(this.erase(),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),fillStyle=this.colors.accent;var eighth=Math.PI/4;this.motionFB<0?(beginPath(),moveTo(this.GUI.w/2,this.GUI.h/2),arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,5*eighth,7*eighth,!1),globalAlpha=Math.pow(this.motionFB,2),fill(),closePath()):(beginPath(),moveTo(this.GUI.w/2,this.GUI.h/2),arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,1*eighth,3*eighth,!1),globalAlpha=Math.pow(this.motionFB,2),fill(),closePath()),this.motionLR<0?(beginPath(),moveTo(this.GUI.w/2,this.GUI.h/2),arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,7*eighth,1*eighth,!1),globalAlpha=Math.pow(this.motionLR,2),fill(),closePath()):(beginPath(),moveTo(this.GUI.w/2,this.GUI.h/2),arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,3*eighth,5*eighth,!1),globalAlpha=Math.pow(this.motionLR,2),fill(),closePath()),beginPath(),moveTo(this.GUI.w/2,this.GUI.h/2),arc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/6,0,2*Math.PI,!1),globalAlpha=Math.pow(this.z,2),fill(),closePath(),globalAlpha=1}this.drawLabel()},motion.prototype.click=function(){this.active=!this.active,this.draw()},motion.prototype.customDestroy=function(){this.active=!1,window.removeEventListener(\"devicemotion\",this.motionlistener,!1)}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),math=__webpack_require__(2),mouse=module.exports=function(t){this.defaultSize={width:98,height:100},widget.call(this,t),this.val={x:0,y:0,deltax:0,deltay:0},this.inside=new Object,this.boundmove=this.preMove.bind(this),this.mousing=window.addEventListener(\"mousemove\",this.boundmove,!1),this.init()};util.inherits(mouse,widget),mouse.prototype.init=function(){this.inside.height=this.GUI.h,this.inside.width=this.GUI.w,this.inside.left=0,this.inside.top=0,this.inside.quarterwid=this.inside.width/4,this.draw()},mouse.prototype.draw=function(){with(this.erase(),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h);var scaledx=-this.val.x*this.GUI.h,scaledy=-this.val.y*this.GUI.h,scaleddx=-this.val.deltax*this.GUI.h-this.GUI.h/2,scaleddy=-this.val.deltay*this.GUI.h-this.GUI.h/2;fillStyle=this.colors.accent,fillRect(this.inside.left,this.inside.height,this.inside.quarterwid,scaledx),fillRect(this.inside.quarterwid,this.inside.height,this.inside.quarterwid,scaledy),fillRect(2*this.inside.quarterwid,this.inside.height,this.inside.quarterwid,scaleddx),fillRect(3*this.inside.quarterwid,this.inside.height,this.inside.quarterwid,scaleddy),globalAlpha=1,fillStyle=this.colors.fill,textAlign=\"center\",font=this.GUI.w/7+\"px \"+this.font,globalAlpha=1}this.drawLabel()},mouse.prototype.move=function(t){this.val={deltax:t.clientX/window.innerWidth-this.val.x,deltay:math.invert(t.clientY/window.innerHeight)-this.val.y,x:t.clientX/window.innerWidth,y:math.invert(t.clientY/window.innerHeight)},this.draw(),this.transmit(this.val)},mouse.prototype.customDestroy=function(){window.removeEventListener(\"mousemove\",this.boundmove,!1)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),multislider=module.exports=function(t){this.defaultSize={width:100,height:75},widget.call(this,t),this.sliders=15,this.sliderClicked=0,this.oldSliderToMove,this.init()};util.inherits(multislider,widget),multislider.prototype.init=function(){this.val=new Array;for(var t=0;t<this.sliders;t++)this.val[t]=.7;this.realSpace={x:this.GUI.w,y:this.GUI.h},this.sliderWidth=this.realSpace.x/this.sliders,this.draw()},multislider.prototype.draw=function(){with(this.erase(),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),strokeStyle=this.colors.accent,fillStyle=this.colors.accent,lineWidth=5;for(var i=0;i<this.sliders;i++)beginPath(),moveTo(i*this.sliderWidth,this.GUI.h-this.val[i]*this.GUI.h),lineTo(i*this.sliderWidth+this.sliderWidth,this.GUI.h-this.val[i]*this.GUI.h),stroke(),lineTo(i*this.sliderWidth+this.sliderWidth,this.GUI.h),lineTo(i*this.sliderWidth,this.GUI.h),globalAlpha=.3-i%3*.1,fill(),closePath(),globalAlpha=1}this.drawLabel()},multislider.prototype.click=function(){this.oldSliderToMove=!1,this.move(!0)},multislider.prototype.move=function(t){if(this.clicked){if(this.clickPos.touches.length>1)for(var e=0;e<this.clickPos.touches.length;e++){var i=Math.floor(this.clickPos.touches[e].x/this.sliderWidth);i=math.clip(i,0,this.sliders-1),this.val[i]=math.clip(math.invert(this.clickPos.touches[e].y/this.GUI.h),0,1)}else{var i=Math.floor(this.clickPos.x/this.sliderWidth);if(i=math.clip(i,0,this.sliders-1),this.val[i]=math.clip(math.invert(this.clickPos.y/this.GUI.h),0,1),this.oldSliderToMove&&this.oldSliderToMove>i+1)for(var s=this.oldSliderToMove-i-1,e=1;e<=s;e++)this.val[i+e]=this.val[i]+(this.val[this.oldSliderToMove]-this.val[i])*(e/(s+1));else if(this.oldSliderToMove&&i>this.oldSliderToMove+1)for(var s=i-this.oldSliderToMove-1,e=1;e<=s;e++)this.val[this.oldSliderToMove+e]=this.val[this.oldSliderToMove]+(this.val[i]-this.val[this.oldSliderToMove])*(e/(s+1))}this.draw()}var n=new Object;if(n[i]=this.val[i],\"js\"==this.destination||\"node\"==this.destination)n.list=this.val;else{n.list=new String;for(var o in this.val)n.list+=this.val[o]+\" \"}this.transmit(n),this.oldSliderToMove=i},multislider.prototype.setNumberOfSliders=function(t){this.sliders=t,this.val=new Array;for(var e=0;e<this.sliders;e++)this.val.push(.7);this.sliderWidth=this.realSpace.x/this.sliders,this.init()},multislider.prototype.setSliderValue=function(t,e){this.val[t]=e,this.draw();var i=new Object;if(i[t]=this.val[t],\"js\"==this.destination||\"node\"==this.destination)i.list=this.val;else{i.list=new String;for(var s in this.val)i.list+=this.val[s]+\" \"}this.transmit(i)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),drawing=__webpack_require__(3),util=__webpack_require__(0),widget=__webpack_require__(1),multitouch=module.exports=function(t){this.defaultSize={width:200,height:200},widget.call(this,t),this.nodeSize=this.GUI.w/10,this.val={touch1:{x:0,y:0}},this.nodes=new Array,this.text=\"multitouch\",this.rainbow=[\"#00f\",\"#04f\",\"#08F\",\"0AF\",\"0FF\"],this.mode=\"normal\",this.rows=10,this.cols=10,this.matrixLabels=!1,this.init()};util.inherits(multitouch,widget),multitouch.prototype.init=function(){this.nodeSize=this.GUI.w/10,this.draw()},multitouch.prototype.draw=function(){with(this.erase(),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h);var count=0;if(\"matrix\"==this.mode)for(var j=0;j<this.rows;j++)for(var i=0;i<this.cols;i++)with(this.context){beginPath(),fillStyle=this.colors.accent,strokeStyle=this.colors.border,lineWidth=1;var circx=i*this.GUI.w/this.cols+this.GUI.w/this.cols/2,circy=j*this.GUI.h/this.rows+this.GUI.h/this.rows/2;arc(circx,circy,this.GUI.h/this.rows/2,0,2*Math.PI,!0),stroke(),fillStyle=this.colors.border,textAlign=\"center\",textBaseline=\"middle\",this.matrixLabels&&(fillText(this.matrixLabels[count%this.matrixLabels.length],circx,circy),count++);var thisarea={x:i*this.GUI.w/this.cols,y:j*this.GUI.h/this.rows,w:this.GUI.w/this.cols,h:this.GUI.h/this.rows};if(this.clickPos.touches.length>=1)for(var k=0;k<this.clickPos.touches.length;k++)drawing.isInside(this.clickPos.touches[k],thisarea)&&(globalAlpha=.5,fillStyle=this.colors.accent,fill(),globalAlpha=.3,fillStyle=this.rainbow[k],fill(),globalAlpha=1);closePath()}else if(this.clickPos.touches.length>=1){for(var i=0;i<this.clickPos.touches.length;i++)with(this.context)globalAlpha=.5,beginPath(),fillStyle=this.colors.accent,strokeStyle=this.colors.border,lineWidth=this.lineWidth,arc(this.clickPos.touches[i].x,this.clickPos.touches[i].y,this.nodeSize,0,2*Math.PI,!0),fill(),closePath(),globalAlpha=.3,beginPath(),fillStyle=this.rainbow[i],strokeStyle=this.colors.border,lineWidth=this.lineWidth,arc(this.clickPos.touches[i].x,this.clickPos.touches[i].y,this.nodeSize,0,2*Math.PI,!0),fill(),closePath(),globalAlpha=1;clearRect(0,this.GUI.h,this.GUI.w,this.height-this.GUI.h)}else this.setFont(),fillStyle=this.colors.border,fillText(this.text,this.GUI.w/2,this.GUI.h/2),globalAlpha=1}this.drawLabel()},multitouch.prototype.click=function(){this.draw(),this.sendit()},multitouch.prototype.move=function(){this.clicked&&(this.draw(),this.sendit())},multitouch.prototype.release=function(){if(!this.clicked){this.clickPos.touches=new Array;for(var t=0;t<5;t++)this.val[\"touch\"+t]={x:0,y:0};this.transmit(this.val)}this.draw(),this.sendit()},multitouch.prototype.sendit=function(){this.val=new Object;for(var t=0;t<this.clickPos.touches.length;t++)this.val[\"touch\"+t]={x:this.clickPos.touches[t].x/this.canvas.width,y:math.invert(this.clickPos.touches[t].y/this.canvas.height)};this.transmit(this.val)}},function(t,e,i){var s=i(2),n=i(0),o=i(1),r=t.exports=function(t){this.defaultSize={width:50,height:20},o.call(this,t),this.val={value:0},this.min=-2e4,this.max=2e4,this.step=1,this.rate=.25,this.decimalPlaces=3,this.lostdata=0,this.actual=0,this.canvas.ontouchstart=null,this.canvas.ontouchmove=null,this.canvas.ontouchend=null;var e='<input type=\"text\" nx=\"number\" id=\"'+this.canvasID+'\" style=\"height:'+this.GUI.h+\"px;width:\"+this.GUI.w+\"px;font-size:\"+this.GUI.h/2+'px;\"></input><canvas height=\"1px\" width=\"1px\" style=\"display:none\"></canvas>',i=this.canvas,n=this.canvas.style,r=i.parentNode,a=document.createElement(\"span\");a.innerHTML=e,a.className=\"nx\",r.replaceChild(a,i),this.el=document.getElementById(this.canvasID);for(var h in n)\"height\"!=h&&\"width\"!=h&&(this.el.style[h]=n[h]);if(this.label){var l=document.createElement(\"div\");l.innerHTML=this.label,l.style.fontSize=this.labelSize/2.8+\"px\",l.style.fontFamily=this.labelFont,l.style.textAlign=this.labelAlign,l.style.lineHeight=this.labelSize+\"px\",l.style.width=this.GUI.w+\"px\",l.style.color=nx.colors.black,l.className=\"nxlabel\",a.appendChild(l)}this.canvas=document.getElementById(this.canvasID),this.canvas.style.height=this.GUI.h+\"px\",this.canvas.style.fontSize=.6*this.GUI.h+\"px\",this.canvas.style.textAlign=\"left\",this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.highlight=this.colors.fill,this.canvas.style.border=\"none\",this.canvas.style.outline=\"none\",this.canvas.style.padding=\"4px 10px\",this.canvas.style.cursor=\"pointer\",this.canvas.style.display=\"block\",this.canvas.className=\"\",this.canvas.addEventListener(\"blur\",function(){this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.color=this.colors.black,this.canvas.value!=this.val.value&&(this.actual=parseFloat(this.canvas.value),this.actual=s.clip(this.actual,this.min,this.max),this.actual=s.prune(this.actual,this.decimalPlaces),this.set({value:this.actual},!0))}.bind(this)),this.canvas.addEventListener(\"keydown\",function(t){(t.which<48||t.which>57)&&189!=t.which&&190!=t.which&&8!=t.which&&t.preventDefault(),13==t.which&&this.canvas.blur()}.bind(this)),nx.isTouchDevice?(this.canvas.ontouchstart=this.preTouch,this.canvas.ontouchmove=this.preTouchMove,this.canvas.ontouchend=this.preTouchRelease):this.canvas.addEventListener(\"mousedown\",this.preClick,!1),this.canvas.style.userSelect=\"none !important\",this.canvas.style.mozUserSelect=\"none !important\",this.canvas.style.webkitUserSelect=\"none !important\",this.init()};n.inherits(r,o),r.prototype.init=function(){this.draw()},r.prototype.draw=function(){this.canvas.value=this.val.value},r.prototype.click=function(t){this.canvas.readOnly=!0,this.actual=this.val.value},r.prototype.move=function(t){this.clicked&&(this.canvas.style.border=\"none\",this.actual-=this.deltaMove.y*(this.rate*this.step),this.actual=s.clip(this.actual,this.min,this.max),this.val.value=Math.floor(this.actual/this.step)*this.step,this.val.value=s.prune(this.val.value,this.decimalPlaces),this.draw(),this.transmit(this.val))},r.prototype.release=function(t){!this.hasMoved&&this.canvas.readOnly&&(this.canvas.readOnly=!1,this.canvas.focus(),this.canvas.setSelectionRange(0,this.canvas.value.length),this.canvas.style.backgroundColor=this.colors.accent,this.canvas.style.color=this.colors.fill)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),position=module.exports=function(t){this.defaultSize={width:150,height:100},widget.call(this,t),this.nodeSize=15,this.val={x:.5,y:.5},this.init()};util.inherits(position,widget),position.prototype.init=function(){this.nodeSize=Math.min(this.GUI.h,this.GUI.w)/10,this.nodeSize=Math.max(this.nodeSize,10),this.actualWid=this.GUI.w-2*this.nodeSize,this.actualHgt=this.GUI.h-2*this.nodeSize,this.draw()},position.prototype.draw=function(){with(this.erase(),this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h);var drawingX=this.val.x*this.actualWid+this.nodeSize,drawingY=math.invert(this.val.y)*this.actualHgt+this.nodeSize;with(drawingX<this.nodeSize?drawingX=this.nodeSize:drawingX>this.GUI.w-this.nodeSize&&(drawingX=this.GUI.w-this.nodeSize),drawingY<this.nodeSize?drawingY=this.nodeSize:drawingY>this.GUI.h-this.nodeSize&&(drawingY=this.GUI.h-this.nodeSize),this.context)beginPath(),fillStyle=this.colors.accent,arc(drawingX,drawingY,this.nodeSize,0,2*Math.PI,!0),fill(),closePath(),this.clicked&&(beginPath(),fillStyle=this.colors.accent,arc(drawingX,drawingY,2*this.nodeSize,0,2*Math.PI,!0),fill(),closePath(),clearRect(0,this.GUI.h,this.GUI.w,this.height-this.GUI.h))}this.drawLabel()},position.prototype.click=function(){this.val.x=this.clickPos.x,this.val.y=this.clickPos.y,this.scaleNode(),this.val.state=\"click\",this.transmit(this.val),this.draw()},position.prototype.move=function(){this.val.x=this.clickPos.x,this.val.y=this.clickPos.y,this.scaleNode(),this.val.state=\"move\",this.transmit(this.val),this.draw()},position.prototype.release=function(){this.val.x=this.clickPos.x,this.val.y=this.clickPos.y,this.scaleNode(),this.val.state=\"release\",this.transmit(this.val),this.draw()},position.prototype.scaleNode=function(){var t=this.val.x-this.nodeSize,e=this.val.y-this.nodeSize,i=math.clip(t/this.actualWid,0,1),s=math.clip(e/this.actualHgt,0,1);this.val.x=math.prune(i,3),this.val.y=math.prune(s,3),this.val.y=math.invert(this.val.y)},position.prototype.animate=function(t){switch(t){case\"bounce\":nx.aniItems.push(this.aniBounce.bind(this));break;case\"none\":nx.aniItems.splice(nx.aniItems.indexOf(this.aniBounce))}},position.prototype.aniBounce=function(){!this.clicked&&this.val.x&&(this.val.x+=this.deltaMove.x/2/this.GUI.w,this.val.y-=this.deltaMove.y/2/this.GUI.h,this.val.state=\"animated\",math.bounce(this.val.x,0,1,this.deltaMove.x)!=this.deltaMove.x&&(this.deltaMove.x=math.bounce(this.val.x,0,1,this.deltaMove.x),this.val.state=\"bounce\"),(this.val.y>=1||this.val.y<=0)&&(this.deltaMove.y=-1*math.bounce(this.val.y,0,1,this.deltaMove.y),this.val.state=\"bounce\"),this.transmit(this.val),this.draw())},position.prototype.customDestroy=function(){nx.removeAni(this.aniBounce)}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),math=__webpack_require__(2),range=module.exports=function(t){this.defaultSize={width:110,height:35},widget.call(this,t),this.val={start:.3,stop:.7,size:.4},this.hslider=!1,this.handle,this.relhandle,this.cap,this.firsttouch=\"start\",this.mode=\"area\",this.touchdown=new Object,this.init()};util.inherits(range,widget),range.prototype.init=function(){this.GUI.h>=this.GUI.w?this.hslider=!1:this.hslider=!0,null!=this.canvas.getAttribute(\"label\")&&(this.label=this.canvas.getAttribute(\"label\")),this.draw()},range.prototype.draw=function(){with(this.erase(),this.context)if(fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),this.hslider){var x1=this.val.start*this.GUI.w,y1=0,x2=this.val.stop*this.GUI.w,y2=this.GUI.h;fillStyle=this.colors.accent,fillRect(x1,y1,x2-x1,y2-y1)}else{var x1=0,y1=this.GUI.h-this.val.stop*this.GUI.h,x2=this.GUI.w,y2=this.GUI.h-this.val.start*this.GUI.h;fillStyle=this.colors.accent,fillRect(x1,y1,x2-x1,y2-y1)}this.drawLabel()},range.prototype.click=function(){\"edge\"==this.mode?this.hslider?Math.abs(this.clickPos.x-this.val.start*this.GUI.w)<Math.abs(this.clickPos.x-this.val.stop*this.GUI.w)?this.firsttouch=\"start\":this.firsttouch=\"stop\":Math.abs(Math.abs(this.clickPos.y-this.GUI.h)-this.val.start*this.GUI.h)<Math.abs(Math.abs(this.clickPos.y-this.GUI.h)-this.val.stop*this.GUI.h)?this.firsttouch=\"start\":this.firsttouch=\"stop\":\"area\"==this.mode&&(this.touchdown={x:this.clickPos.x,y:this.clickPos.y},this.startval=new Object,this.startval.size=this.val.stop-this.val.start,this.startval.loc=this.val.start+this.startval.size/2),this.move()},range.prototype.move=function(){if(\"edge\"==this.mode)this.hslider?\"start\"==this.firsttouch?(this.val.start=this.clickPos.x/this.GUI.w,this.clickPos.touches.length>1&&(this.val.stop=this.clickPos.touches[1].x/this.GUI.w)):(this.val.stop=this.clickPos.x/this.GUI.w,this.clickPos.touches.length>1&&(this.val.start=this.clickPos.touches[1].x/this.GUI.w)):\"start\"==this.firsttouch?(this.val.start=math.invert(this.clickPos.y/this.GUI.h),this.clickPos.touches.length>1&&(this.val.stop=math.invert(this.clickPos.touches[1].y/this.GUI.h))):(this.val.stop=math.invert(this.clickPos.y/this.GUI.h),this.clickPos.touches.length>1&&(this.val.start=math.invert(this.clickPos.touches[1].y/this.GUI.h))),this.val.stop<this.val.start&&(this.tempstart=this.val.start,this.val.start=this.val.stop,this.val.stop=this.tempstart,\"start\"==this.firsttouch?this.firsttouch=\"stop\":this.firsttouch=\"start\"),this.val={start:math.clip(this.val.start,0,1),stop:math.clip(this.val.stop,0,1)},this.val.size=math.prune(math.clip(Math.abs(this.val.stop-this.val.start),0,1),3),this.draw(),this.transmit(this.val);else if(\"area\"==this.mode){if(this.hslider)var t=this.clickPos.x/this.GUI.w,e=(this.touchdown.y-this.clickPos.y)/this.GUI.h;else{var t=nx.invert(this.clickPos.y/this.GUI.h),e=(this.touchdown.x-this.clickPos.x)/this.GUI.w;e*=-1}e/=3;var i=this.startval.size+e;i=math.clip(i,.001,1),this.val={start:t-i/2,stop:t+i/2},this.val.start=math.clip(this.val.start,0,1),this.val.stop=math.clip(this.val.stop,0,1),this.draw(),this.transmit(this.val)}}},function(t,e,i){var s=i(0),n=i(1),o=t.exports=function(t){this.defaultSize={width:200,height:30},n.call(this,t),this.choices=[],this.val=new Object,this.canvas.ontouchstart=null,this.canvas.ontouchmove=null,this.canvas.ontouchend=null,this.canvas.getAttribute(\"choices\")&&(this.choices=this.canvas.getAttribute(\"choices\"),this.choices=this.choices.split(\",\"));var e='<select id=\"'+this.canvasID+'\" class=\"nx\" nx=\"select\" style=\"height:'+this.GUI.h+\"px;width:\"+this.GUI.w+'px;\" onchange=\"'+this.canvasID+'.change(this)\"></select><canvas height=\"1px\" width=\"1px\" style=\"display:none\"></canvas>',i=this.canvas,s=this.canvas.style,o=i.parentNode,r=document.createElement(\"span\");r.innerHTML=e,r.className=\"nx\",o.replaceChild(r,i),this.sel=document.getElementById(this.canvasID);for(var a in s)this.sel.style[a]=s[a];this.canvas=document.getElementById(this.canvasID),this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.border=\"solid 2px \"+this.colors.border,this.canvas.style.color=this.colors.black,this.canvas.style.fontSize=Math.round(this.GUI.h/2.3)+\"px\",this.canvas.className=\"\"};s.inherits(o,n),o.prototype.init=function(){this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.border=\"solid 2px \"+this.colors.border,this.canvas.style.color=this.colors.black;var t=this.canvas.options.length;for(e=0;e<t;e++)this.canvas.options[e]=null;for(var e=0;e<this.choices.length;e++){var i=document.createElement(\"option\");i.text=this.choices[e],i.value=this.choices[e],this.canvas.add(i,null)}this.val.text=this.choices[0]},o.prototype.change=function(t){this.val.text=t.value,this.val.value=t.selectedIndex,this.transmit(this.val)},o.prototype.draw=function(){this.canvas.value=this.val.text,this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.color=this.colors.black,this.canvas.style.border=\"solid 2px \"+this.colors.border}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),slider=module.exports=function(t){this.defaultSize={width:35,height:110},widget.call(this,t),null!=this.canvas.getAttribute(\"min\")?this.min=parseFloat(this.canvas.getAttribute(\"min\")):this.min=0,null!=this.canvas.getAttribute(\"max\")?this.max=parseFloat(this.canvas.getAttribute(\"max\")):this.max=1,null!=this.canvas.getAttribute(\"step\")?this.step=parseFloat(this.canvas.getAttribute(\"step\")):this.step=.001,this.val.value=nx.scale(.7,0,1,this.min,this.max),this.mode=\"absolute\",this.hslider=!1,this.handle,this.relhandle,this.cap,this.maxdigits=3,this.calculateDigits=nx.calculateDigits,this.init()};util.inherits(slider,widget),slider.prototype.init=function(){this.GUI.h>=this.GUI.w?this.hslider=!1:this.hslider=!0,this.draw()},slider.prototype.draw=function(){var normalval=this.normalize(this.val.value);with(this.digits=this.calculateDigits(),this.erase(),this.context){if(fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),this.hslider){var x1=0,y1=0,x2=normalval*this.GUI.w,y2=this.GUI.h;fillStyle=this.colors.accent,fillRect(x1,y1,x2-x1,y2-y1);var valtextsize=this.GUI.h/2;if(valtextsize>6){if(x2>this.digits.total*valtextsize/2){fillStyle=this.colors.white;var textx=5}else{fillStyle=this.colors.accent;var textx=x2+5}var texty=this.GUI.h/2,valtextAlign=\"left\",valtextBaseline=\"middle\"}}else{var x1=0,y1=this.GUI.h-normalval*this.GUI.h,x2=this.GUI.w,y2=this.GUI.h;fillStyle=this.colors.accent,fillRect(x1,y1,x2-x1,y2-y1);var valtextsize=this.GUI.w/this.digits.total*1.2;if(valtextsize>6){if(y1<this.GUI.h-valtextsize/2-5){fillStyle=this.colors.white;var texty=this.GUI.h-valtextsize/2-5}else{fillStyle=this.colors.accent;var texty=y1-valtextsize/2-5}var textx=this.GUI.w/2,valtextAlign=\"center\",valtextBaseline=\"middle\"}}var valtext=this.val.value.toFixed(this.digits.decimals);textBaseline=valtextBaseline,textAlign=valtextAlign,font=valtextsize+\"px 'Open Sans'\",fillText(valtext,textx,texty),this.label&&this.drawLabel()}},slider.prototype.click=function(){this.move()},slider.prototype.move=function(){var t=this.normalize(this.val.value);this.hslider?(this.handle=this.clickPos.x,this.relhandle=this.deltaMove.x,this.cap=this.GUI.w):(this.handle=this.clickPos.y,this.relhandle=-1*this.deltaMove.y,this.cap=this.GUI.h),\"absolute\"==this.mode?this.clicked&&(t=this.hslider?math.clip(this.clickPos.x/this.GUI.w,0,1):Math.abs(math.clip(this.clickPos.y/this.GUI.h,0,1)-1),this.draw()):\"relative\"==this.mode&&this.clicked&&(t=this.hslider?math.clip(t+this.deltaMove.x/this.GUI.w,0,1):math.clip(t+-1*this.deltaMove.y/this.GUI.h,0,1),this.draw()),this.val.value=math.prune(this.rangify(t),3),this.transmit(this.val)}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),string=module.exports=function(t){this.defaultSize={width:150,height:75},widget.call(this,t),this.val={string:0,x:0},this.numberOfStrings=10,this.strings=new Array,this.abovestring=new Array,this.friction=1;this.init(),nx.aniItems.push(this.draw.bind(this))};util.inherits(string,widget),string.prototype.init=function(){stringdiv=this.GUI.h/(this.numberOfStrings+1);for(var t=0;t<this.numberOfStrings;t++)this.strings[t]={x1:this.lineWidth,y1:stringdiv*(1+t),x2:this.GUI.w-this.lineWidth,y2:stringdiv*(t+1),held:!1,vibrating:!1,force:0,maxstretch:0,stretch:0,direction:0,above:!1};this.draw()},string.prototype.pulse=function(){this.draw()},string.prototype.setStrings=function(t){this.numberOfStrings=t,this.strings=new Array,this.init()},string.prototype.draw=function(){with(this.erase(),this.context){strokeStyle=this.colors.border,fillStyle=this.colors.fill,lineWidth=this.lineWidth,fillRect(0,0,this.GUI.w,this.GUI.h),strokeStyle=this.colors.accent;for(var i=0;i<this.strings.length;i++){var st=this.strings[i];st.vibrating?(st.maxstretch<0&&(st.vibrating=!1,st.held=!1),st.stretch=st.stretch+st.direction,Math.abs(st.stretch)>st.maxstretch&&(st.direction*=-1,st.stretch=st.stretch+st.direction,st.maxstretch=st.maxstretch-this.friction,st.direction=st.direction/Math.abs(st.direction)*(st.maxstretch/1)),beginPath(),moveTo(st.x1,st.y1),quadraticCurveTo(this.GUI.w/2,st.y1+st.stretch,st.x2,st.y2),stroke(),closePath(),st.on=!0):st.held?(beginPath(),moveTo(st.x1,st.y1),quadraticCurveTo(this.clickPos.x,this.clickPos.y,st.x2,st.y2),stroke(),closePath(),st.on=!0):(beginPath(),moveTo(st.x1,st.y1),lineTo(st.x2,st.y2),stroke(),closePath(),st.on&&(st.on=!1))}}this.drawLabel()},string.prototype.click=function(){for(var t=0;t<this.numberOfStrings;t++)this.strings[t].above=this.clickPos.y<this.strings[t].y1;this.draw()},string.prototype.move=function(){if(this.clicked)for(var t=0;t<this.strings.length;t++)this.strings[t].above!=this.clickPos.y<this.strings[t].y1&&(this.strings[t].held=!0,this.strings[t].above^=!0),this.strings[t].held&&Math.abs(this.clickPos.y-this.strings[t].y1)>this.GUI.h/(3*this.strings.length)&&this.pluck(t)},string.prototype.release=function(){for(var t=0;t<this.strings.length;t++)this.strings[t].held&&this.pluck(t)},string.prototype.pluck=function(t){var e=t;this.val={string:e,x:this.clickPos.x/this.GUI.w},this.transmit(this.val),this.strings[e].held=!1,this.strings[e].force=this.clickPos.y-this.strings[e].y1,this.strings[e].maxstretch=Math.abs(this.clickPos.y-this.strings[e].y1),this.strings[e].stretch=this.clickPos.y-this.strings[e].y1,this.strings[e].vibrating=!0,this.strings[e].direction=(this.clickPos.y-this.strings[e].y1)/Math.abs(this.clickPos.y-this.strings[e].y1)*((this.clickPos.y-this.strings[e].y1)/-1.2)},string.prototype.customDestroy=function(){nx.removeAni(this.draw.bind(this))}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),tabs=module.exports=function(t){this.defaultSize={width:150,height:50},widget.call(this,t),this.choice=0,this.val={index:0,text:\"\"},this.tabwid=0,this.options=[\"one\",\"two\",\"three\"],this.init()};util.inherits(tabs,widget),tabs.prototype.init=function(){this.draw()},tabs.prototype.draw=function(){with(this.context)fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),textAlign=\"center\",textBaseline=\"middle\",font=\"normal \"+this.GUI.h/5+\"px courier\";this.tabwid=this.GUI.w/this.options.length;for(var i=0;i<this.options.length;i++){if(i==this.choice)var tabcol=this.colors.accent,textcol=this.colors.white;else{var tabcol=this.colors.fill,textcol=this.colors.black;globalAlpha=.7}with(this.context)fillStyle=tabcol,fillRect(this.tabwid*i,0,this.tabwid,this.GUI.h),i!=this.options.length-1&&(beginPath(),moveTo(this.tabwid*(i+1),0),lineTo(this.tabwid*(i+1),this.GUI.h),lineWidth=1,strokeStyle=this.colors.border,stroke(),closePath()),fillStyle=textcol,font=this.fontSize+\"px \"+this.font,fillText(this.options[i],this.tabwid*i+this.tabwid/2,this.GUI.h/2)}},tabs.prototype.click=function(){this.choice=~~(this.clickPos.x/this.tabwid),this.val={index:this.choice,text:this.options[this.choice]},this.transmit(this.val),this.draw()}},function(t,e,i){var s=i(0),n=i(1),o=t.exports=function(t){this.defaultSize={width:200,height:100},n.call(this,t),this.val={text:\"\"};var e='<textarea id=\"'+this.canvasID+'\" style=\"height:'+this.GUI.h+\"px;width:\"+this.GUI.w+'px;\" onkeydown=\"'+this.canvasID+'.change(event,this)\"></textarea><canvas height=\"1px\" width=\"1px\" style=\"display:none\"></canvas>',i=this.canvas,s=this.canvas.style,o=i.parentNode,r=document.createElement(\"span\");r.innerHTML=e,r.className=\"nx\",o.replaceChild(r,i),this.el=document.getElementById(this.canvasID);for(var a in s)this.el.style[a]=s[a];this.el.style.display=\"block\",this.el.style.backgroundColor=this.colors.fill,this.el.style.border=\"none\",this.el.style.color=this.colors.black,this.el.style.outline=\"none\",this.el.style.resize=\"none\",this.el.style.boxSizing=\"border-box\",this.el.style.padding=\"5px\",this.el.style.fontFamily=nx.font,this.el.style.fontSize=\"16px\",this.el.className=\"\",this.canvas=document.getElementById(this.canvasID)};s.inherits(o,n),o.prototype.init=function(){this.canvas.ontouchstart=null,this.canvas.ontouchmove=null,this.canvas.ontouchend=null,this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.color=this.colors.black},o.prototype.change=function(t,e){this.val.text=e.value,\"13\"==t.which&&(this.transmit(this.val),this.val.text=\"\",this.draw(),t.preventDefault())},o.prototype.draw=function(){this.el.value=this.val.text,this.canvas.style.backgroundColor=this.colors.fill,this.canvas.style.color=this.colors.black}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),tilt=module.exports=function(t){this.defaultSize={width:50,height:50},widget.call(this,t),this.tiltLR,this.tiltFB,this.z,this.active=!0,this.val={x:0,y:0,z:0},this.text=\"TILT\",this.init(),this.boundChromeTilt=this.chromeTilt.bind(this),this.boundMozTilt=this.mozTilt.bind(this),window.DeviceOrientationEvent?window.addEventListener(\"deviceorientation\",this.boundChromeTilt,!1):window.OrientationEvent?window.addEventListener(\"MozOrientation\",this.boundMozTilt,!1):console.log(\"Not supported on your device or browser.\")};util.inherits(tilt,widget),tilt.prototype.deviceOrientationHandler=function(){this.val={x:math.prune(this.tiltLR/90,3),y:math.prune(this.tiltFB/90,3),z:math.prune(this.z,3)},this.active&&this.transmit(this.val)},tilt.prototype.chromeTilt=function(t){this.tiltLR=t.gamma,this.tiltFB=t.beta,this.z=t.alpha,this.deviceOrientationHandler(),this.draw()},tilt.prototype.mozTilt=function(t){this.tiltLR=90*t.x,this.tiltFB=-90*t.y,this.z=t.z,this.deviceOrientationHandler(),this.draw()},tilt.prototype.init=function(){this.draw()},tilt.prototype.draw=function(){with(this.erase(),this.context)fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),save(),translate(this.GUI.w/2,this.GUI.h/2),rotate(-this.val.x*Math.PI/2),translate(-this.GUI.w/2,-this.GUI.h/2),globalAlpha=.4,this.active?fillStyle=this.colors.accent:fillStyle=this.colors.border,fillRect(-this.GUI.w,this.GUI.h*(this.val.y/2)+this.GUI.h/2,3*this.GUI.w,2*this.GUI.h),font=\"bold \"+this.GUI.h/5+\"px \"+this.font,textAlign=\"center\",textBaseline=\"middle\",fillText(this.text,this.GUI.w/2,this.GUI.h*(this.val.y/2)+this.GUI.h/2-this.GUI.h/15),globalAlpha=1,restore(),clearRect(0,this.GUI.h,this.GUI.w,this.height-this.GUI.h);this.drawLabel()},tilt.prototype.click=function(){this.active=!this.active},tilt.prototype.customDestroy=function(){this.active=!1,window.removeEventListener(\"deviceorientation\",this.boundChromeTilt,!1),window.removeEventListener(\"mozOrientation\",this.boundMozTilt,!1)}},function(module,exports,__webpack_require__){var drawing=__webpack_require__(3),util=__webpack_require__(0),widget=__webpack_require__(1),toggle=module.exports=function(t){this.defaultSize={width:50,height:50},widget.call(this,t),this.val={value:0},this.init()};util.inherits(toggle,widget),toggle.prototype.init=function(){this.draw()},toggle.prototype.draw=function(){with(this.erase(),this.context)this.val.value?(fillStyle=this.colors.accent,strokeStyle=this.colors.accenthl,strokeAlpha=1):(fillStyle=this.colors.fill,strokeStyle=this.colors.border,strokeAlpha=1),lineWidth=Math.sqrt(this.GUI.w)/2,fillRect(0,0,this.GUI.w,this.GUI.h),globalAlpha=strokeAlpha,strokeRect(lineWidth/2,lineWidth/2,this.GUI.w-lineWidth,this.GUI.h-lineWidth),globalAlpha=1;this.drawLabel()},toggle.prototype.click=function(){this.val.value?this.val.value=0:this.val.value=1,this.draw(),this.transmit(this.val)}},function(module,exports,__webpack_require__){var drawing=__webpack_require__(3),util=__webpack_require__(0),widget=__webpack_require__(1),typewriter=module.exports=function(t){this.defaultSize={width:300,height:100},widget.call(this,t),this.letter=\"\",this.keywid=this.GUI.w/14.5,this.keyhgt=this.GUI.h/5,this.active=!0,this.val={key:\"\",ascii:0,on:0},this.rows=[[{symbol:\"`\",value:192,width:1,on:!1},{symbol:\"1\",value:49,width:1,on:!1},{symbol:\"2\",value:50,width:1,on:!1},{symbol:\"3\",value:51,width:1,on:!1},{symbol:\"4\",value:52,width:1,on:!1},{symbol:\"5\",value:53,width:1,on:!1},{symbol:\"6\",value:54,width:1,on:!1},{symbol:\"7\",value:55,width:1,on:!1},{symbol:\"8\",value:56,width:1,on:!1},{symbol:\"9\",value:57,width:1,on:!1},{symbol:\"0\",value:48,width:1,on:!1},{symbol:\"-\",value:189,width:1,on:!1},{symbol:\"=\",value:187,width:1,on:!1},{symbol:\"delete\",value:46,width:1.5,on:!1}],[{symbol:\"tab\",value:9,width:1.5,on:!1},{symbol:\"q\",value:81,width:1,on:!1},{symbol:\"w\",value:87,width:1,on:!1},{symbol:\"e\",value:69,width:1,on:!1},{symbol:\"r\",value:82,width:1,on:!1},{symbol:\"t\",value:84,width:1,on:!1},{symbol:\"y\",value:89,width:1,on:!1},{symbol:\"u\",value:85,width:1,on:!1},{symbol:\"i\",value:73,width:1,on:!1},{symbol:\"o\",value:79,width:1,on:!1},{symbol:\"p\",value:80,width:1,on:!1},{symbol:\"[\",value:219,width:1,on:!1},{symbol:\"]\",value:221,width:1,on:!1},{symbol:\"\\\\\",value:220,width:1,on:!1}],[{symbol:\"caps\",value:20,width:1.75,on:!1},{symbol:\"a\",value:65,width:1,on:!1},{symbol:\"s\",value:83,width:1,on:!1},{symbol:\"d\",value:68,width:1,on:!1},{symbol:\"f\",value:70,width:1,on:!1},{symbol:\"g\",value:71,width:1,on:!1},{symbol:\"h\",value:72,width:1,on:!1},{symbol:\"j\",value:74,width:1,on:!1},{symbol:\"k\",value:75,width:1,on:!1},{symbol:\"l\",value:76,width:1,on:!1},{symbol:\";\",value:186,width:1,on:!1},{symbol:\"'\",value:222,width:1,on:!1},{symbol:\"enter\",value:13,width:1.75,on:!1}],[{symbol:\"shift\",value:16,width:2.25,on:!1},{symbol:\"z\",value:90,width:1,on:!1},{symbol:\"x\",value:88,width:1,on:!1},{symbol:\"c\",value:67,width:1,on:!1},{symbol:\"v\",value:86,width:1,on:!1},{symbol:\"b\",value:66,width:1,on:!1},{symbol:\"n\",value:78,width:1,on:!1},{symbol:\"m\",value:77,width:1,on:!1},{symbol:\",\",value:188,width:1,on:!1},{symbol:\".\",value:190,width:1,on:!1},{symbol:\"/\",value:191,width:1,on:!1},{symbol:\"shift\",value:16,width:2.25,on:!1}],[{symbol:\"fn\",value:10,width:1,on:!1},{symbol:\"ctrl\",value:17,width:1,on:!1},{symbol:\"opt\",value:10,width:1,on:!1},{symbol:\"cmd\",value:10,width:1.25,on:!1},{symbol:\"space\",value:32,width:5,on:!1},{symbol:\"cmd\",value:10,width:1,on:!1},{symbol:\"opt\",value:10,width:1,on:!1},{symbol:\"left\",value:37,width:.81,on:!1},{symbol:\"up\",value:38,width:.81,on:!1},{symbol:\"down\",value:40,width:.81,on:!1},{symbol:\"right\",value:39,width:.81,on:!1}]],this.boundType=this.typekey.bind(this),this.boundUntype=this.untype.bind(this),window.addEventListener(\"keydown\",this.boundType),window.addEventListener(\"keyup\",this.boundUntype),this.init()};util.inherits(typewriter,widget),typewriter.prototype.init=function(){this.keywid=this.GUI.w/14.5,this.keyhgt=this.GUI.h/5,this.draw()},typewriter.prototype.draw=function(){with(this.erase(),this.active?this.context.globalAlpha=1:this.context.globalAlpha=.4,this.context){strokeStyle=this.colors.borderhl,fillStyle=this.colors.accent,lineWidth=1;for(var i=0;i<this.rows.length;i++)for(var currkeyL=0,j=0;j<this.rows[i].length;j++)this.val.key==this.rows[i][j].symbol&&(this.val.on?this.rows[i][j].on=!0:this.rows[i][j].on=!1),drawing.makeRoundRect(this.context,currkeyL,i*this.keyhgt,this.keywid*this.rows[i][j].width,this.keyhgt,4),this.rows[i][j].on?(fillStyle=this.colors.accent,strokeStyle=this.colors.accent,fill(),stroke()):(fillStyle=this.colors.fill,strokeStyle=this.colors.borderhl,fill(),stroke()),currkeyL+=this.keywid*this.rows[i][j].width;this.val.on&&(this.setFont(),fillStyle=this.colors.borderhl,font=this.GUI.h+\"px \"+this.font,fillText(this.val.key,this.GUI.w/2,this.GUI.h/2),globalAlpha=1),this.active||(globalAlpha=.7,fillStyle=this.colors.borderhl,font=this.GUI.h/2+\"px courier\",textAlign=\"center\",textBaseline=\"middle\",fillText(\"inactive\",this.GUI.w/2,this.GUI.h/2))}this.drawLabel()},typewriter.prototype.click=function(t){this.active=!this.active,this.draw()},typewriter.prototype.typekey=function(t){if(this.active){for(var e=t.which,i=0;i<this.rows.length;i++)for(var s=0;s<this.rows[i].length;s++)if(e==this.rows[i][s].value){this.val.key=this.rows[i][s].symbol,this.val.on=1,this.val.ascii=t.which,this.transmit(this.val);break}this.draw()}},typewriter.prototype.untype=function(t){if(this.active){for(var e=t.which,i=0;i<this.rows.length;i++)for(var s=0;s<this.rows[i].length;s++)if(e==this.rows[i][s].value){this.val.key=this.rows[i][s].symbol,this.val.on=0,this.val.ascii=t.which,this.transmit(this.val);break}this.draw()}},typewriter.prototype.customDestroy=function(){window.removeEventListener(\"keydown\",this.boundType),window.removeEventListener(\"keyup\",this.boundUntype)}},function(module,exports,__webpack_require__){var math=__webpack_require__(2),util=__webpack_require__(0),widget=__webpack_require__(1),vinyl=module.exports=function(t){this.defaultSize={width:100,height:100},widget.call(this,t),this.circleSize,this.speed=.05,this.defaultspeed=.05,this.rotation=0,this.hasMovedOnce=!1,this.lockResize=!0,this.val={speed:0},this.init(),nx.aniItems.push(this.spin.bind(this))};util.inherits(vinyl,widget),vinyl.prototype.init=function(){this.circleSize=Math.min(this.center.x,this.center.y)-this.lineWidth,this.draw()},vinyl.prototype.draw=function(){with(this.erase(),this.context)strokeStyle=this.colors.border,fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h),beginPath(),fillStyle=this.colors.black,arc(this.center.x,this.center.y,this.circleSize-5,0,2*Math.PI,!0),fill(),closePath(),beginPath(),fillStyle=this.colors.accent,arc(this.center.x,1*this.center.y,this.circleSize/4,0,2*Math.PI,!1),fill(),closePath(),beginPath(),globalAlpha=.5,fillStyle=this.colors.fill,arc(this.center.x,this.center.y,this.circleSize,this.rotation,this.rotation+.4,!1),lineTo(this.center.x,this.center.y),arc(this.center.x,this.center.y,this.circleSize,this.rotation+Math.PI,this.rotation+Math.PI+.4,!1),lineTo(this.center.x,this.center.y),fill(),globalAlpha=1,closePath(),beginPath(),fillStyle=this.colors.white,arc(this.center.x,1*this.center.y,this.circleSize/16,0,2*Math.PI,!1),fill(),closePath();this.drawLabel()},vinyl.prototype.click=function(t){this.hasMovedOnce=!1,this.lastRotation=this.rotation,this.grabAngle=this.rotation%(2*Math.PI),this.grabPos=math.toPolar(this.clickPos.x-this.center.x,this.clickPos.y-this.center.y).angle},vinyl.prototype.move=function(){this.hasMovedOnce||(this.hasMovedOnce=!0,this.grabAngle=this.rotation%(2*Math.PI),this.grabPos=math.toPolar(this.clickPos.x-this.center.x,this.clickPos.y-this.center.y).angle),this.rotation=math.toPolar(this.clickPos.x-this.center.x,this.clickPos.y-this.center.y).angle+this.grabAngle-this.grabPos},vinyl.prototype.release=function(){this.speed=(this.rotation-this.lastRotation+(this.lastRotation-this.lastRotation2))/2},vinyl.prototype.spin=function(){this.clicked?this.speed/=1.1:this.speed=.9*this.speed+.1*this.defaultspeed,this.val.speed=20*(this.rotation-this.lastRotation),this.lastRotation2=this.lastRotation,this.lastRotation=this.rotation,this.rotation+=this.speed,this.draw(),this.transmit(this.val)},vinyl.prototype.customDestroy=function(){nx.removeAni(this.spin.bind(this))}},function(module,exports,__webpack_require__){var util=__webpack_require__(0),widget=__webpack_require__(1),math=__webpack_require__(2),waveform=module.exports=function(t){this.defaultSize={width:400,height:125},widget.call(this,t),this.val={start:0,stop:0,size:0,starttime:0,stoptime:0,looptime:0},this.handle,this.relhandle,this.cap,this.firsttouch=\"start\",this.buffer=[],nx.isMobile?this.definition=3:this.definition=1,this.pieces=!1,this.channels=1,this.rawbuffer=[],this.times=[{dur:10,format:1},{dur:50,format:1},{dur:100,format:1},{dur:200,format:1},{dur:500,format:1},{dur:1e3,format:1},{dur:2e3,format:1},{dur:5e3,format:1},{dur:1e4,format:3},{dur:15e3,format:3},{dur:6e4,format:3},{dur:12e4,format:3},{dur:3e5,format:3},{dur:6e5,format:3}],this.timescale=!1,this.mode=\"area\",this.touchdown=new Object,this.init()};util.inherits(waveform,widget),waveform.prototype.init=function(){this.pieces=~~(this.GUI.w/this.definition),this.draw()},waveform.prototype.setBuffer=function(t){for(this.channels=t.numberOfChannels,this.duration=t.duration,this.sampleRate=t.sampleRate,this.waveHeight=this.GUI.h/this.channels,this.durationMS=1e3*this.duration,this.timescale=0;~~(this.durationMS/this.times[this.timescale].dur)>7&&this.timescale<this.times.length;)this.timescale++;this.timescale=this.times[this.timescale],this.rawbuffer=[],this.buffer=[];for(var e=0;e<this.channels;e++){this.rawbuffer.push(t.getChannelData(0)),this.buffer.push([]);for(var i=1+~~(this.rawbuffer[0].length/(5*this.sampleRate)),s=~~(this.rawbuffer[e].length/this.pieces),n=0,o=0,r=0,a=0;a<this.rawbuffer[e].length;a+=i)this.rawbuffer[e][a]>0?n=Math.max(n,this.rawbuffer[e][a]):o=Math.min(o,this.rawbuffer[e][a]),a>r*s&&(this.buffer[e].push([n,o]),r++,o=0,n=0)}this.val.start&&this.val.stop,this.val.starttime=Math.round(this.val.start*this.durationMS),this.val.stoptime=Math.round(this.val.stop*this.durationMS),this.val.looptime=Math.round(this.val.size*this.durationMS),this.draw()},waveform.prototype.select=function(t,e){this.val.start=math.clip(t/this.durationMS,0,1),this.val.stop=math.clip(e/this.durationMS,0,1),this.val.size=this.val.stop-this.val.start,this.val.starttime=t,this.val.stoptime=e,this.val.looptime=t-e,this.transmit(this.val),this.draw()},waveform.prototype.draw=function(){with(this.context){fillStyle=this.colors.fill,fillRect(0,0,this.GUI.w,this.GUI.h);for(var i=0;i<this.buffer.length;i++){fillStyle=this.colors.black,this.waveTop=i*this.waveHeight,this.waveCenter=this.waveTop+this.waveHeight/2;for(var j=0;j<this.buffer[i].length;j++){var ht1=this.waveCenter-this.buffer[i][j][0]*this.waveHeight,ht2=this.waveCenter+Math.abs(this.buffer[i][j][1]*this.waveHeight);ht2-=ht1,fillRect(j*this.definition,ht1,this.definition,ht2)}this.buffer[i]}if(globalAlpha=.3,fillStyle=this.colors.border,fillRect(0,0,this.GUI.w,16),globalAlpha=1,textBaseline=\"middle\",textAlign=\"left\",fontSize=\"8px\",this.timescale)for(var i=1;i<this.durationMS/this.timescale.dur;i++){var x=i*this.timescale.dur/this.durationMS;x*=this.GUI.w,fillStyle=this.colors.border,fillRect(x,0,1,this.GUI.h),fillStyle=this.colors.black,globalAlpha=.6,fillText(this.msToTime(i*this.timescale.dur,this.timescale.format),x+5,8),globalAlpha=1}var x1=this.val.start*this.GUI.w,y1=0,x2=this.val.stop*this.GUI.w,y2=this.GUI.h;if(fillStyle=this.colors.accent,strokeStyle=this.colors.accent,lineWidth=2,globalAlpha=.3,fillRect(x1,0,x2-x1,y2-0),globalAlpha=.7,strokeRect(x1,-2,x2-x1,y2-0+4),this.durationMS&&this.val.looptime){this.val.size=this.val.stop-this.val.start,textAlign=\"center\";var dur=this.val.looptime;dur>1e3?(dur/=1e3,math.prune(dur,2),dur+=\" s\"):(math.prune(dur,0),dur+=\" ms\"),fillText(dur,x1+(x2-x1)/2,this.GUI.h/2)}globalAlpha=1}},waveform.prototype.msToTime=function(t,e){var e=e||2,i=~~(t/1e3),s=i%60;i=(i-s)/60;var n=i%60,o=t%1e3;return s=s<10&&n?s+\"0\":s,1==e?s+\".\"+o:2==e?n+\":\"+s+\".\"+o:3==e?n+\":\"+s:void 0},waveform.prototype.click=function(){\"edge\"==this.mode?Math.abs(this.clickPos.x-this.val.start*this.GUI.w)<Math.abs(this.clickPos.x-this.val.stop*this.GUI.w)?this.firsttouch=\"start\":this.firsttouch=\"stop\":\"area\"==this.mode&&(this.touchdown={x:this.clickPos.x,y:this.clickPos.y},this.startval=new Object,this.startval.size=this.val.stop-this.val.start,this.startval.loc=this.val.start+this.startval.size/2),this.move()},waveform.prototype.move=function(){if(\"edge\"==this.mode)\"start\"==this.firsttouch?(this.val.start=this.clickPos.x/this.GUI.w,this.clickPos.touches.length>1&&(this.val.stop=this.clickPos.touches[1].x/this.GUI.w)):(this.val.stop=this.clickPos.x/this.GUI.w,this.clickPos.touches.length>1&&(this.val.start=this.clickPos.touches[1].x/this.GUI.w)),this.val.stop<this.val.start&&(this.tempstart=this.val.start,this.val.start=this.val.stop,this.val.stop=this.tempstart,\"start\"==this.firsttouch?this.firsttouch=\"stop\":this.firsttouch=\"start\");else if(\"area\"==this.mode){var t=this.clickPos.x/this.GUI.w,e=(this.touchdown.y-this.clickPos.y)/this.GUI.h;e/=4;var i=this.startval.size+e;i=math.clip(i,.001,1),this.val={start:t-i/2,stop:t+i/2}}this.val.start=math.clip(this.val.start,0,1),this.val.stop=math.clip(this.val.stop,0,1),this.val.size=math.clip(Math.abs(this.val.stop-this.val.start),0,1),this.durationMS&&(this.val.starttime=Math.round(this.val.start*this.durationMS),this.val.stoptime=Math.round(this.val.stop*this.durationMS),this.val.looptime=Math.round(this.val.size*this.durationMS)),this.transmit(this.val),this.draw()}},function(t,e){function i(){throw new Error(\"setTimeout has not been defined\")}function s(){throw new Error(\"clearTimeout has not been defined\")}function n(t){if(c===setTimeout)return setTimeout(t,0);if((c===i||!c)&&setTimeout)return c=setTimeout,setTimeout(t,0);try{return c(t,0)}catch(e){try{return c.call(null,t,0)}catch(e){return c.call(this,t,0)}}}function o(t){if(u===clearTimeout)return clearTimeout(t);if((u===s||!u)&&clearTimeout)return u=clearTimeout,clearTimeout(t);try{return u(t)}catch(e){try{return u.call(null,t)}catch(e){return u.call(this,t)}}}function r(){y&&d&&(y=!1,d.length?f=d.concat(f):_=-1,f.length&&a())}function a(){if(!y){var t=n(r);y=!0;for(var e=f.length;e;){for(d=f,f=[];++_<e;)d&&d[_].run();_=-1,e=f.length}d=null,y=!1,o(t)}}function h(t,e){this.fun=t,this.array=e}function l(){}var c,u,p=t.exports={};!function(){try{c=\"function\"==typeof setTimeout?setTimeout:i}catch(t){c=i}try{u=\"function\"==typeof clearTimeout?clearTimeout:s}catch(t){u=s}}();var d,f=[],y=!1,_=-1;p.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];f.push(new h(t,e)),1!==f.length||y||n(a)},h.prototype.run=function(){this.fun.apply(null,this.array)},p.title=\"browser\",p.browser=!0,p.env={},p.argv=[],p.version=\"\",p.versions={},p.on=l,p.addListener=l,p.once=l,p.off=l,p.removeListener=l,p.removeAllListeners=l,p.emit=l,p.binding=function(t){throw new Error(\"process.binding is not supported\")},p.cwd=function(){return\"/\"},p.chdir=function(t){throw new Error(\"process.chdir is not supported\")},p.umask=function(){return 0}},function(t,e){\"function\"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}},function(t,e){t.exports=function(t){return t&&\"object\"==typeof t&&\"function\"==typeof t.copy&&\"function\"==typeof t.fill&&\"function\"==typeof t.readUInt8}},function(t,e,i){var s;!function(){function n(t,e,i){return t.call.apply(t.bind,arguments)}function o(t,e,i){if(!t)throw Error();if(2<arguments.length){var s=Array.prototype.slice.call(arguments,2);return function(){var i=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(i,s),t.apply(e,i)}}return function(){return t.apply(e,arguments)}}function r(t,e,i){return r=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf(\"native code\")?n:o,r.apply(null,arguments)}function a(t,e){this.a=t,this.m=e||t,this.c=this.m.document}function h(t,e,i,s){if(e=t.c.createElement(e),i)for(var n in i)i.hasOwnProperty(n)&&(\"style\"==n?e.style.cssText=i[n]:e.setAttribute(n,i[n]));return s&&e.appendChild(t.c.createTextNode(s)),e}function l(t,e,i){t=t.c.getElementsByTagName(e)[0],t||(t=document.documentElement),t.insertBefore(i,t.lastChild)}function c(t){t.parentNode&&t.parentNode.removeChild(t)}function u(t,e,i){e=e||[],i=i||[];for(var s=t.className.split(/\\s+/),n=0;n<e.length;n+=1){for(var o=!1,r=0;r<s.length;r+=1)if(e[n]===s[r]){o=!0;break}o||s.push(e[n])}for(e=[],n=0;n<s.length;n+=1){for(o=!1,r=0;r<i.length;r+=1)if(s[n]===i[r]){o=!0;break}o||e.push(s[n])}t.className=e.join(\" \").replace(/\\s+/g,\" \").replace(/^\\s+|\\s+$/,\"\")}function p(t,e){for(var i=t.className.split(/\\s+/),s=0,n=i.length;s<n;s++)if(i[s]==e)return!0;return!1}function d(t){if(\"string\"==typeof t.f)return t.f;var e=t.m.location.protocol;return\"about:\"==e&&(e=t.a.location.protocol),\"https:\"==e?\"https:\":\"http:\"}function f(t){return t.m.location.hostname||t.a.location.hostname}function y(t,e,i){function s(){a&&n&&o&&(a(r),a=null)}e=h(t,\"link\",{rel:\"stylesheet\",href:e,media:\"all\"});var n=!1,o=!0,r=null,a=i||null;at?(e.onload=function(){n=!0,s()},e.onerror=function(){n=!0,r=Error(\"Stylesheet failed to load\"),s()}):setTimeout(function(){n=!0,s()},0),l(t,\"head\",e)}function _(t,e,i,s){var n=t.c.getElementsByTagName(\"head\")[0];if(n){var o=h(t,\"script\",{src:e}),r=!1;return o.onload=o.onreadystatechange=function(){r||this.readyState&&\"loaded\"!=this.readyState&&\"complete\"!=this.readyState||(r=!0,i&&i(null),o.onload=o.onreadystatechange=null,\"HEAD\"==o.parentNode.tagName&&n.removeChild(o))},n.appendChild(o),setTimeout(function(){r||(r=!0,i&&i(Error(\"Script load timeout\")))},s||5e3),o}return null}function m(){this.a=0,this.c=null}function v(t){return t.a++,function(){t.a--,w(t)}}function g(t,e){t.c=e,w(t)}function w(t){0==t.a&&t.c&&(t.c(),t.c=null)}function b(t){this.a=t||\"-\"}function x(t,e){this.c=t,this.f=4,this.a=\"n\";var i=(e||\"n4\").match(/^([nio])([1-9])$/i);i&&(this.a=i[1],this.f=parseInt(i[2],10))}function S(t){return P(t)+\" \"+t.f+\"00 300px \"+T(t.c)}function T(t){var e=[];t=t.split(/,\\s*/);for(var i=0;i<t.length;i++){var s=t[i].replace(/['\"]/g,\"\");-1!=s.indexOf(\" \")||/^\\d/.test(s)?e.push(\"'\"+s+\"'\"):e.push(s)}return e.join(\",\")}function k(t){return t.a+t.f}function P(t){var e=\"normal\";return\"o\"===t.a?e=\"oblique\":\"i\"===t.a&&(e=\"italic\"),e}function O(t){var e=4,i=\"n\",s=null;return t&&((s=t.match(/(normal|oblique|italic)/i))&&s[1]&&(i=s[1].substr(0,1).toLowerCase()),(s=t.match(/([1-9]00|normal|bold)/i))&&s[1]&&(/bold/i.test(s[1])?e=7:/[1-9]00/.test(s[1])&&(e=parseInt(s[1].substr(0,1),10)))),i+e}function A(t,e){this.c=t,this.f=t.m.document.documentElement,this.h=e,this.a=new b(\"-\"),this.j=!1!==e.events,this.g=!1!==e.classes}function M(t){t.g&&u(t.f,[t.a.c(\"wf\",\"loading\")]),q(t,\"loading\")}function I(t){if(t.g){var e=p(t.f,t.a.c(\"wf\",\"active\")),i=[],s=[t.a.c(\"wf\",\"loading\")];e||i.push(t.a.c(\"wf\",\"inactive\")),u(t.f,i,s)}q(t,\"inactive\")}function q(t,e,i){t.j&&t.h[e]&&(i?t.h[e](i.c,k(i)):t.h[e]())}function E(){this.c={}}function F(t,e,i){var s,n=[];for(s in e)if(e.hasOwnProperty(s)){var o=t.c[s];o&&n.push(o(e[s],i))}return n}function U(t,e){this.c=t,this.f=e,this.a=h(this.c,\"span\",{\"aria-hidden\":\"true\"},this.f)}function G(t){l(t.c,\"body\",t.a)}function R(t){return\"display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:\"+T(t.c)+\";font-style:\"+P(t)+\";font-weight:\"+t.f+\"00;\"}function C(t,e,i,s,n,o){this.g=t,this.j=e,this.a=s,this.c=i,this.f=n||3e3,this.h=o||void 0}function j(t,e,i,s,n,o,r){this.v=t,this.B=e,this.c=i,this.a=s,this.s=r||\"BESbswy\",this.f={},this.w=n||3e3,this.u=o||null,this.o=this.j=this.h=this.g=null,this.g=new U(this.c,this.s),this.h=new U(this.c,this.s),this.j=new U(this.c,this.s),this.o=new U(this.c,this.s),t=new x(this.a.c+\",serif\",k(this.a)),t=R(t),this.g.a.style.cssText=t,t=new x(this.a.c+\",sans-serif\",k(this.a)),t=R(t),this.h.a.style.cssText=t,t=new x(\"serif\",k(this.a)),t=R(t),this.j.a.style.cssText=t,t=new x(\"sans-serif\",k(this.a)),t=R(t),this.o.a.style.cssText=t,G(this.g),G(this.h),G(this.j),G(this.o)}function L(){if(null===lt){var t=/AppleWebKit\\/([0-9]+)(?:\\.([0-9]+))/.exec(window.navigator.userAgent);lt=!!t&&(536>parseInt(t[1],10)||536===parseInt(t[1],10)&&11>=parseInt(t[2],10))}return lt}function z(t,e,i){for(var s in ht)if(ht.hasOwnProperty(s)&&e===t.f[ht[s]]&&i===t.f[ht[s]])return!0;return!1}function B(t){var e,i=t.g.a.offsetWidth,s=t.h.a.offsetWidth;(e=i===t.f.serif&&s===t.f[\"sans-serif\"])||(e=L()&&z(t,i,s)),e?rt()-t.A>=t.w?L()&&z(t,i,s)&&(null===t.u||t.u.hasOwnProperty(t.a.c))?N(t,t.v):N(t,t.B):D(t):N(t,t.v)}function D(t){setTimeout(r(function(){B(this)},t),50)}function N(t,e){setTimeout(r(function(){c(this.g.a),c(this.h.a),c(this.j.a),c(this.o.a),e(this.a)},t),0)}function W(t,e,i){this.c=t,this.a=e,this.f=0,this.o=this.j=!1,this.s=i}function V(t){0==--t.f&&t.j&&(t.o?(t=t.a,t.g&&u(t.f,[t.a.c(\"wf\",\"active\")],[t.a.c(\"wf\",\"loading\"),t.a.c(\"wf\",\"inactive\")]),q(t,\"active\")):I(t.a))}function X(t){this.j=t,this.a=new E,this.h=0,this.f=this.g=!0}function Q(t,e,i,s,n){var o=0==--t.h;(t.f||t.g)&&setTimeout(function(){var t=n||null,a=s||null||{};if(0===i.length&&o)I(e.a);else{e.f+=i.length,o&&(e.j=o);var h,l=[];for(h=0;h<i.length;h++){var c=i[h],p=a[c.c],d=e.a,f=c;if(d.g&&u(d.f,[d.a.c(\"wf\",f.c,k(f).toString(),\"loading\")]),q(d,\"fontloading\",f),d=null,null===ct)if(window.FontFace){var f=/Gecko.*Firefox\\/(\\d+)/.exec(window.navigator.userAgent),y=/OS X.*Version\\/10\\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);ct=f?42<parseInt(f[1],10):!y}else ct=!1;d=ct?new C(r(e.g,e),r(e.h,e),e.c,c,e.s,p):new j(r(e.g,e),r(e.h,e),e.c,c,e.s,t,p),l.push(d)}for(h=0;h<l.length;h++)l[h].start()}},0)}function Y(t,e,i){var s=[],n=i.timeout;M(e);var s=F(t.a,i,t.c),o=new W(t.c,e,n);for(t.h=s.length,e=0,i=s.length;e<i;e++)s[e].load(function(e,i,s){Q(t,o,e,i,s)})}function H(t,e){this.c=t,this.a=e}function Z(t,e,i){var s=d(t.c);return t=(t.a.api||\"fast.fonts.net/jsapi\").replace(/^.*http(s?):(\\/\\/)?/,\"\"),s+\"//\"+t+\"/\"+e+\".js\"+(i?\"?v=\"+i:\"\")}function $(t,e){this.c=t,this.a=e}function J(t,e,i){this.c=t||e+ut,this.a=[],this.f=[],this.g=i||\"\"}function K(t,e){for(var i=e.length,s=0;s<i;s++){var n=e[s].split(\":\");3==n.length&&t.f.push(n.pop());var o=\"\";2==n.length&&\"\"!=n[1]&&(o=\":\"),t.a.push(n.join(o))}}function tt(t){if(0==t.a.length)throw Error(\"No fonts to load!\");if(-1!=t.c.indexOf(\"kit=\"))return t.c;for(var e=t.a.length,i=[],s=0;s<e;s++)i.push(t.a[s].replace(/ /g,\"+\"));return e=t.c+\"?family=\"+i.join(\"%7C\"),0<t.f.length&&(e+=\"&subset=\"+t.f.join(\",\")),0<t.g.length&&(e+=\"&text=\"+encodeURIComponent(t.g)),e}function et(t){this.f=t,this.a=[],this.c={}}function it(t){for(var e=t.f.length,i=0;i<e;i++){var s=t.f[i].split(\":\"),n=s[0].replace(/\\+/g,\" \"),o=[\"n4\"];if(2<=s.length){var r,a=s[1];if(r=[],a)for(var a=a.split(\",\"),h=a.length,l=0;l<h;l++){var c;if(c=a[l],c.match(/^[\\w-]+$/)){var u=yt.exec(c.toLowerCase());if(null==u)c=\"\";else{if(c=u[2],c=null==c||\"\"==c?\"n\":ft[c],null==(u=u[1])||\"\"==u)u=\"4\";else var p=dt[u],u=p||(isNaN(u)?\"4\":u.substr(0,1));c=[c,u].join(\"\")}}else c=\"\";c&&r.push(c)}0<r.length&&(o=r),3==s.length&&(s=s[2],r=[],s=s?s.split(\",\"):r,0<s.length&&(s=pt[s[0]])&&(t.c[n]=s))}for(t.c[n]||(s=pt[n])&&(t.c[n]=s),s=0;s<o.length;s+=1)t.a.push(new x(n,o[s]))}}function st(t,e){this.c=t,this.a=e}function nt(t,e){this.c=t,this.a=e}function ot(t,e){this.c=t,this.f=e,this.a=[]}var rt=Date.now||function(){return+new Date},at=!!window.FontFace;b.prototype.c=function(t){for(var e=[],i=0;i<arguments.length;i++)e.push(arguments[i].replace(/[\\W_]+/g,\"\").toLowerCase());return e.join(this.a)},C.prototype.start=function(){var t=this.c.m.document,e=this,i=rt(),s=new Promise(function(s,n){function o(){rt()-i>=e.f?n():t.fonts.load(S(e.a),e.h).then(function(t){1<=t.length?s():setTimeout(o,25)},function(){n()})}o()}),n=new Promise(function(t,i){setTimeout(i,e.f)});Promise.race([n,s]).then(function(){e.g(e.a)},function(){e.j(e.a)})};var ht={D:\"serif\",C:\"sans-serif\"},lt=null;j.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f[\"sans-serif\"]=this.o.a.offsetWidth,this.A=rt(),B(this)};var ct=null;W.prototype.g=function(t){var e=this.a;e.g&&u(e.f,[e.a.c(\"wf\",t.c,k(t).toString(),\"active\")],[e.a.c(\"wf\",t.c,k(t).toString(),\"loading\"),e.a.c(\"wf\",t.c,k(t).toString(),\"inactive\")]),q(e,\"fontactive\",t),this.o=!0,V(this)},W.prototype.h=function(t){var e=this.a;if(e.g){var i=p(e.f,e.a.c(\"wf\",t.c,k(t).toString(),\"active\")),s=[],n=[e.a.c(\"wf\",t.c,k(t).toString(),\"loading\")];i||s.push(e.a.c(\"wf\",t.c,k(t).toString(),\"inactive\")),u(e.f,s,n)}q(e,\"fontinactive\",t),V(this)},X.prototype.load=function(t){this.c=new a(this.j,t.context||this.j),this.g=!1!==t.events,this.f=!1!==t.classes,Y(this,new A(this.c,t),t)},H.prototype.load=function(t){function e(){if(o[\"__mti_fntLst\"+s]){var i,n=o[\"__mti_fntLst\"+s](),r=[];if(n)for(var a=0;a<n.length;a++){var h=n[a].fontfamily;void 0!=n[a].fontStyle&&void 0!=n[a].fontWeight?(i=n[a].fontStyle+n[a].fontWeight,r.push(new x(h,i))):r.push(new x(h))}t(r)}else setTimeout(function(){e()},50)}var i=this,s=i.a.projectId,n=i.a.version;if(s){var o=i.c.m;_(this.c,Z(i,s,n),function(n){n?t([]):(o[\"__MonotypeConfiguration__\"+s]=function(){return i.a},e())}).id=\"__MonotypeAPIScript__\"+s}else t([])},$.prototype.load=function(t){var e,i,s=this.a.urls||[],n=this.a.families||[],o=this.a.testStrings||{},r=new m;for(e=0,i=s.length;e<i;e++)y(this.c,s[e],v(r));var a=[];for(e=0,i=n.length;e<i;e++)if(s=n[e].split(\":\"),s[1])for(var h=s[1].split(\",\"),l=0;l<h.length;l+=1)a.push(new x(s[0],h[l]));else a.push(new x(s[0]));g(r,function(){t(a,o)})};var ut=\"//fonts.googleapis.com/css\",pt={latin:\"BESbswy\",\"latin-ext\":\"çöüğş\",cyrillic:\"йяЖ\",greek:\"αβΣ\",khmer:\"កខគ\",Hanuman:\"កខគ\"},dt={thin:\"1\",extralight:\"2\",\"extra-light\":\"2\",ultralight:\"2\",\"ultra-light\":\"2\",light:\"3\",regular:\"4\",book:\"4\",medium:\"5\",\"semi-bold\":\"6\",semibold:\"6\",\"demi-bold\":\"6\",demibold:\"6\",bold:\"7\",\"extra-bold\":\"8\",extrabold:\"8\",\"ultra-bold\":\"8\",ultrabold:\"8\",black:\"9\",heavy:\"9\",l:\"3\",r:\"4\",b:\"7\"},ft={i:\"i\",italic:\"i\",n:\"n\",normal:\"n\"},yt=/^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/,_t={Arimo:!0,Cousine:!0,Tinos:!0};st.prototype.load=function(t){var e=new m,i=this.c,s=new J(this.a.api,d(i),this.a.text),n=this.a.families;K(s,n);var o=new et(n);it(o),y(i,tt(s),v(e)),g(e,function(){t(o.a,o.c,_t)})},nt.prototype.load=function(t){var e=this.a.id,i=this.c.m;e?_(this.c,(this.a.api||\"https://use.typekit.net\")+\"/\"+e+\".js\",function(e){if(e)t([]);else if(i.Typekit&&i.Typekit.config&&i.Typekit.config.fn){e=i.Typekit.config.fn;for(var s=[],n=0;n<e.length;n+=2)for(var o=e[n],r=e[n+1],a=0;a<r.length;a++)s.push(new x(o,r[a]));try{i.Typekit.load({events:!1,classes:!1,async:!0})}catch(t){}t(s)}},2e3):t([])},ot.prototype.load=function(t){var e=this.f.id,i=this.c.m,s=this;e?(i.__webfontfontdeckmodule__||(i.__webfontfontdeckmodule__={}),i.__webfontfontdeckmodule__[e]=function(e,i){for(var n=0,o=i.fonts.length;n<o;++n){var r=i.fonts[n];s.a.push(new x(r.name,O(\"font-weight:\"+r.weight+\";font-style:\"+r.style)))}t(s.a)},_(this.c,d(this.c)+(this.f.api||\"//f.fontdeck.com/s/css/js/\")+f(this.c)+\"/\"+e+\".js\",function(e){e&&t([])})):t([])};var mt=new X(window);mt.a.c.custom=function(t,e){return new $(e,t)},mt.a.c.fontdeck=function(t,e){return new ot(e,t)},mt.a.c.monotype=function(t,e){return new H(e,t)},mt.a.c.typekit=function(t,e){return new nt(e,t)},mt.a.c.google=function(t,e){return new st(e,t)};var vt={load:r(mt.load,mt)};void 0!==(s=function(){return vt}.call(e,i,e,t))&&(t.exports=s)}()},function(t,e){var i;i=function(){return this}();try{i=i||Function(\"return this\")()||(0,eval)(\"this\")}catch(t){\"object\"==typeof window&&(i=window)}t.exports=i}]);\n\n\n// WEBPACK FOOTER //\n// ./bundle.js"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourceRoot":""}
\ No newline at end of file +{"version":3,"file":"./bundle.js","sources":["webpack:///webpack/bootstrap f428192e4f5d8a517d25","webpack:///./~/util/util.js","webpack:///./~/nexusui/lib/core/widget.js","webpack:///./~/nexusui/lib/utils/math.js","webpack:///./~/nexusui/lib/utils/drawing.js","webpack:///./~/tone/build/Tone.js","webpack:///./client/lib/util.js","webpack:///./~/events/events.js","webpack:///./~/nexusui/lib/utils/dom.js","webpack:///./~/nexusui/lib/utils/timing.js","webpack:///./~/nexusui/lib/utils/transmit.js","webpack:///./client/lib/color.js","webpack:///./client/lib/kalimba.js","webpack:///./client/lib/keys.js","webpack:///./client/lib/scales.js","webpack:///./~/nexusui/index.js","webpack:///./~/webmidi/webmidi.min.js","webpack:///./client/index.js","webpack:///./client/lib/intonation.js","webpack:///./client/lib/startAudioContext.js","webpack:///./~/extend/index.js","webpack:///./~/nexusui/lib/core/manager.js","webpack:///./~/nexusui/lib/widgets/banner.js","webpack:///./~/nexusui/lib/widgets/button.js","webpack:///./~/nexusui/lib/widgets/colors.js","webpack:///./~/nexusui/lib/widgets/comment.js","webpack:///./~/nexusui/lib/widgets/crossfade.js","webpack:///./~/nexusui/lib/widgets/dial.js","webpack:///./~/nexusui/lib/widgets/envelope.js","webpack:///./~/nexusui/lib/widgets/index.js","webpack:///./~/nexusui/lib/widgets/joints.js","webpack:///./~/nexusui/lib/widgets/keyboard.js","webpack:///./~/nexusui/lib/widgets/matrix.js","webpack:///./~/nexusui/lib/widgets/message.js","webpack:///./~/nexusui/lib/widgets/meter.js","webpack:///./~/nexusui/lib/widgets/metro.js","webpack:///./~/nexusui/lib/widgets/motion.js","webpack:///./~/nexusui/lib/widgets/mouse.js","webpack:///./~/nexusui/lib/widgets/multislider.js","webpack:///./~/nexusui/lib/widgets/multitouch.js","webpack:///./~/nexusui/lib/widgets/number.js","webpack:///./~/nexusui/lib/widgets/position.js","webpack:///./~/nexusui/lib/widgets/range.js","webpack:///./~/nexusui/lib/widgets/select.js","webpack:///./~/nexusui/lib/widgets/slider.js","webpack:///./~/nexusui/lib/widgets/string.js","webpack:///./~/nexusui/lib/widgets/tabs.js","webpack:///./~/nexusui/lib/widgets/text.js","webpack:///./~/nexusui/lib/widgets/tilt.js","webpack:///./~/nexusui/lib/widgets/toggle.js","webpack:///./~/nexusui/lib/widgets/typewriter.js","webpack:///./~/nexusui/lib/widgets/vinyl.js","webpack:///./~/nexusui/lib/widgets/waveform.js","webpack:///./~/process/browser.js","webpack:///./~/util/~/inherits/inherits_browser.js","webpack:///./~/util/support/isBufferBrowser.js","webpack:///./~/webfontloader/webfontloader.js","webpack:///(webpack)/buildin/global.js"],"sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 16);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap f428192e4f5d8a517d25","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar formatRegExp = /%[sdj%]/g;\nexports.format = function(f) {\n if (!isString(f)) {\n var objects = [];\n for (var i = 0; i < arguments.length; i++) {\n objects.push(inspect(arguments[i]));\n }\n return objects.join(' ');\n }\n\n var i = 1;\n var args = arguments;\n var len = args.length;\n var str = String(f).replace(formatRegExp, function(x) {\n if (x === '%%') return '%';\n if (i >= len) return x;\n switch (x) {\n case '%s': return String(args[i++]);\n case '%d': return Number(args[i++]);\n case '%j':\n try {\n return JSON.stringify(args[i++]);\n } catch (_) {\n return '[Circular]';\n }\n default:\n return x;\n }\n });\n for (var x = args[i]; i < len; x = args[++i]) {\n if (isNull(x) || !isObject(x)) {\n str += ' ' + x;\n } else {\n str += ' ' + inspect(x);\n }\n }\n return str;\n};\n\n\n// Mark that a method should not be used.\n// Returns a modified function which warns once by default.\n// If --no-deprecation is set, then it is a no-op.\nexports.deprecate = function(fn, msg) {\n // Allow for deprecating things in the process of starting up.\n if (isUndefined(global.process)) {\n return function() {\n return exports.deprecate(fn, msg).apply(this, arguments);\n };\n }\n\n if (process.noDeprecation === true) {\n return fn;\n }\n\n var warned = false;\n function deprecated() {\n if (!warned) {\n if (process.throwDeprecation) {\n throw new Error(msg);\n } else if (process.traceDeprecation) {\n console.trace(msg);\n } else {\n console.error(msg);\n }\n warned = true;\n }\n return fn.apply(this, arguments);\n }\n\n return deprecated;\n};\n\n\nvar debugs = {};\nvar debugEnviron;\nexports.debuglog = function(set) {\n if (isUndefined(debugEnviron))\n debugEnviron = process.env.NODE_DEBUG || '';\n set = set.toUpperCase();\n if (!debugs[set]) {\n if (new RegExp('\\\\b' + set + '\\\\b', 'i').test(debugEnviron)) {\n var pid = process.pid;\n debugs[set] = function() {\n var msg = exports.format.apply(exports, arguments);\n console.error('%s %d: %s', set, pid, msg);\n };\n } else {\n debugs[set] = function() {};\n }\n }\n return debugs[set];\n};\n\n\n/**\n * Echos the value of a value. Trys to print the value out\n * in the best way possible given the different types.\n *\n * @param {Object} obj The object to print out.\n * @param {Object} opts Optional options object that alters the output.\n */\n/* legacy: obj, showHidden, depth, colors*/\nfunction inspect(obj, opts) {\n // default options\n var ctx = {\n seen: [],\n stylize: stylizeNoColor\n };\n // legacy...\n if (arguments.length >= 3) ctx.depth = arguments[2];\n if (arguments.length >= 4) ctx.colors = arguments[3];\n if (isBoolean(opts)) {\n // legacy...\n ctx.showHidden = opts;\n } else if (opts) {\n // got an \"options\" object\n exports._extend(ctx, opts);\n }\n // set default options\n if (isUndefined(ctx.showHidden)) ctx.showHidden = false;\n if (isUndefined(ctx.depth)) ctx.depth = 2;\n if (isUndefined(ctx.colors)) ctx.colors = false;\n if (isUndefined(ctx.customInspect)) ctx.customInspect = true;\n if (ctx.colors) ctx.stylize = stylizeWithColor;\n return formatValue(ctx, obj, ctx.depth);\n}\nexports.inspect = inspect;\n\n\n// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\ninspect.colors = {\n 'bold' : [1, 22],\n 'italic' : [3, 23],\n 'underline' : [4, 24],\n 'inverse' : [7, 27],\n 'white' : [37, 39],\n 'grey' : [90, 39],\n 'black' : [30, 39],\n 'blue' : [34, 39],\n 'cyan' : [36, 39],\n 'green' : [32, 39],\n 'magenta' : [35, 39],\n 'red' : [31, 39],\n 'yellow' : [33, 39]\n};\n\n// Don't use 'blue' not visible on cmd.exe\ninspect.styles = {\n 'special': 'cyan',\n 'number': 'yellow',\n 'boolean': 'yellow',\n 'undefined': 'grey',\n 'null': 'bold',\n 'string': 'green',\n 'date': 'magenta',\n // \"name\": intentionally not styling\n 'regexp': 'red'\n};\n\n\nfunction stylizeWithColor(str, styleType) {\n var style = inspect.styles[styleType];\n\n if (style) {\n return '\\u001b[' + inspect.colors[style][0] + 'm' + str +\n '\\u001b[' + inspect.colors[style][1] + 'm';\n } else {\n return str;\n }\n}\n\n\nfunction stylizeNoColor(str, styleType) {\n return str;\n}\n\n\nfunction arrayToHash(array) {\n var hash = {};\n\n array.forEach(function(val, idx) {\n hash[val] = true;\n });\n\n return hash;\n}\n\n\nfunction formatValue(ctx, value, recurseTimes) {\n // Provide a hook for user-specified inspect functions.\n // Check that value is an object with an inspect function on it\n if (ctx.customInspect &&\n value &&\n isFunction(value.inspect) &&\n // Filter out the util module, it's inspect function is special\n value.inspect !== exports.inspect &&\n // Also filter out any prototype objects using the circular check.\n !(value.constructor && value.constructor.prototype === value)) {\n var ret = value.inspect(recurseTimes, ctx);\n if (!isString(ret)) {\n ret = formatValue(ctx, ret, recurseTimes);\n }\n return ret;\n }\n\n // Primitive types cannot have properties\n var primitive = formatPrimitive(ctx, value);\n if (primitive) {\n return primitive;\n }\n\n // Look up the keys of the object.\n var keys = Object.keys(value);\n var visibleKeys = arrayToHash(keys);\n\n if (ctx.showHidden) {\n keys = Object.getOwnPropertyNames(value);\n }\n\n // IE doesn't make error fields non-enumerable\n // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx\n if (isError(value)\n && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {\n return formatError(value);\n }\n\n // Some type of object without properties can be shortcutted.\n if (keys.length === 0) {\n if (isFunction(value)) {\n var name = value.name ? ': ' + value.name : '';\n return ctx.stylize('[Function' + name + ']', 'special');\n }\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n }\n if (isDate(value)) {\n return ctx.stylize(Date.prototype.toString.call(value), 'date');\n }\n if (isError(value)) {\n return formatError(value);\n }\n }\n\n var base = '', array = false, braces = ['{', '}'];\n\n // Make Array say that they are Array\n if (isArray(value)) {\n array = true;\n braces = ['[', ']'];\n }\n\n // Make functions say that they are functions\n if (isFunction(value)) {\n var n = value.name ? ': ' + value.name : '';\n base = ' [Function' + n + ']';\n }\n\n // Make RegExps say that they are RegExps\n if (isRegExp(value)) {\n base = ' ' + RegExp.prototype.toString.call(value);\n }\n\n // Make dates with properties first say the date\n if (isDate(value)) {\n base = ' ' + Date.prototype.toUTCString.call(value);\n }\n\n // Make error with message first say the error\n if (isError(value)) {\n base = ' ' + formatError(value);\n }\n\n if (keys.length === 0 && (!array || value.length == 0)) {\n return braces[0] + base + braces[1];\n }\n\n if (recurseTimes < 0) {\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n } else {\n return ctx.stylize('[Object]', 'special');\n }\n }\n\n ctx.seen.push(value);\n\n var output;\n if (array) {\n output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);\n } else {\n output = keys.map(function(key) {\n return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);\n });\n }\n\n ctx.seen.pop();\n\n return reduceToSingleString(output, base, braces);\n}\n\n\nfunction formatPrimitive(ctx, value) {\n if (isUndefined(value))\n return ctx.stylize('undefined', 'undefined');\n if (isString(value)) {\n var simple = '\\'' + JSON.stringify(value).replace(/^\"|\"$/g, '')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"') + '\\'';\n return ctx.stylize(simple, 'string');\n }\n if (isNumber(value))\n return ctx.stylize('' + value, 'number');\n if (isBoolean(value))\n return ctx.stylize('' + value, 'boolean');\n // For some reason typeof null is \"object\", so special case here.\n if (isNull(value))\n return ctx.stylize('null', 'null');\n}\n\n\nfunction formatError(value) {\n return '[' + Error.prototype.toString.call(value) + ']';\n}\n\n\nfunction formatArray(ctx, value, recurseTimes, visibleKeys, keys) {\n var output = [];\n for (var i = 0, l = value.length; i < l; ++i) {\n if (hasOwnProperty(value, String(i))) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n String(i), true));\n } else {\n output.push('');\n }\n }\n keys.forEach(function(key) {\n if (!key.match(/^\\d+$/)) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n key, true));\n }\n });\n return output;\n}\n\n\nfunction formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {\n var name, str, desc;\n desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };\n if (desc.get) {\n if (desc.set) {\n str = ctx.stylize('[Getter/Setter]', 'special');\n } else {\n str = ctx.stylize('[Getter]', 'special');\n }\n } else {\n if (desc.set) {\n str = ctx.stylize('[Setter]', 'special');\n }\n }\n if (!hasOwnProperty(visibleKeys, key)) {\n name = '[' + key + ']';\n }\n if (!str) {\n if (ctx.seen.indexOf(desc.value) < 0) {\n if (isNull(recurseTimes)) {\n str = formatValue(ctx, desc.value, null);\n } else {\n str = formatValue(ctx, desc.value, recurseTimes - 1);\n }\n if (str.indexOf('\\n') > -1) {\n if (array) {\n str = str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n').substr(2);\n } else {\n str = '\\n' + str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n');\n }\n }\n } else {\n str = ctx.stylize('[Circular]', 'special');\n }\n }\n if (isUndefined(name)) {\n if (array && key.match(/^\\d+$/)) {\n return str;\n }\n name = JSON.stringify('' + key);\n if (name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)) {\n name = name.substr(1, name.length - 2);\n name = ctx.stylize(name, 'name');\n } else {\n name = name.replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"')\n .replace(/(^\"|\"$)/g, \"'\");\n name = ctx.stylize(name, 'string');\n }\n }\n\n return name + ': ' + str;\n}\n\n\nfunction reduceToSingleString(output, base, braces) {\n var numLinesEst = 0;\n var length = output.reduce(function(prev, cur) {\n numLinesEst++;\n if (cur.indexOf('\\n') >= 0) numLinesEst++;\n return prev + cur.replace(/\\u001b\\[\\d\\d?m/g, '').length + 1;\n }, 0);\n\n if (length > 60) {\n return braces[0] +\n (base === '' ? '' : base + '\\n ') +\n ' ' +\n output.join(',\\n ') +\n ' ' +\n braces[1];\n }\n\n return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];\n}\n\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\nfunction isArray(ar) {\n return Array.isArray(ar);\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return isObject(re) && objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return isObject(d) && objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return isObject(e) &&\n (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('./support/isBuffer');\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n\n\nfunction pad(n) {\n return n < 10 ? '0' + n.toString(10) : n.toString(10);\n}\n\n\nvar months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',\n 'Oct', 'Nov', 'Dec'];\n\n// 26 Feb 16:19:34\nfunction timestamp() {\n var d = new Date();\n var time = [pad(d.getHours()),\n pad(d.getMinutes()),\n pad(d.getSeconds())].join(':');\n return [d.getDate(), months[d.getMonth()], time].join(' ');\n}\n\n\n// log is just a thin wrapper to console.log that prepends a timestamp\nexports.log = function() {\n console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));\n};\n\n\n/**\n * Inherit the prototype methods from one constructor into another.\n *\n * The Function.prototype.inherits from lang.js rewritten as a standalone\n * function (not on Function.prototype). NOTE: If this file is to be loaded\n * during bootstrapping this function needs to be rewritten using some native\n * functions as prototype setup using normal JavaScript does not work as\n * expected during bootstrapping (see mirror.js in r114903).\n *\n * @param {function} ctor Constructor function which needs to inherit the\n * prototype.\n * @param {function} superCtor Constructor function to inherit prototype from.\n */\nexports.inherits = require('inherits');\n\nexports._extend = function(origin, add) {\n // Don't do anything if add isn't an object\n if (!add || !isObject(add)) return origin;\n\n var keys = Object.keys(add);\n var i = keys.length;\n while (i--) {\n origin[keys[i]] = add[keys[i]];\n }\n return origin;\n};\n\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/util/util.js\n// module id = 0\n// module chunks = 0","var EventEmitter = require('events').EventEmitter;\nvar util = require('util');\nvar domUtils = require('../utils/dom');\nvar drawingUtils = require('../utils/drawing');\nvar timingUtils = require('../utils/timing');\nvar transmit = require('../utils/transmit');\n\n\n\nvar widget = module.exports = function (target) {\n EventEmitter.apply(this)\n this.preClick = this.preClick.bind(this)\n this.preMove = this.preMove.bind(this)\n this.preRelease = this.preRelease.bind(this)\n this.preTouch = this.preTouch.bind(this)\n this.preTouchMove = this.preTouchMove.bind(this)\n this.preTouchRelease = this.preTouchRelease.bind(this)\n\n/**\n\n @class widget\n All NexusUI interface widgets inherit from the widget class. The properties and methods of the widget class are usable by any NexusUI interface.\n\n*/\n\n /** @property {string} canvasID ID attribute of the interface's HTML5 canvas */\n this.canvasID = target;\n /** @property {string} oscPath OSC prefix for this interface. By default this is populated using the canvas ID (i.e. an ID of dial1 has OSC path /dial1) */\n this.oscPath = \"/\"+target;\n if (!document.getElementById(target)) {\n var newcanv = document.createElement(\"canvas\")\n newcanv.id = target;\n document.body.appendChild(newcanv)\n }\n /**\n * @property {string} type The type of NexusUI widget (i.e. \"dial\", \"toggle\", \"slider\"). Set automatically at creation.\n */\n this.type = undefined;\n /** @property {DOM element} canvas The widget's HTML5 canvas */\n this.canvas = document.getElementById(target);\n /** @property {HTML5 drawing context} context The canvas's drawing context */\n this.context = this.canvas.getContext(\"2d\");\n\n this.checkPercentage();\n this.canvas.className = this.canvas.className ? this.canvas.className += \" nx\" : \"nx\"\n\n this.canvas.height = window.getComputedStyle(document.getElementById(target), null).getPropertyValue(\"height\").replace(\"px\",\"\");\n this.canvas.width = window.getComputedStyle(document.getElementById(target), null).getPropertyValue(\"width\").replace(\"px\",\"\");\n /** @property {integer} height The widget canvas's computed height in pixels */\n this.height = parseInt(window.getComputedStyle(document.getElementById(target), null).getPropertyValue(\"height\").replace(\"px\",\"\"));\n /** @property {integer} width The widget canvas's computed width in pixels */\n this.width = parseInt(window.getComputedStyle(document.getElementById(target), null).getPropertyValue(\"width\").replace(\"px\",\"\"));\n if (!this.defaultSize) {\n /** @property {object} defaultSize The widget's default size if not defined with HTML/CSS style. (Has properties 'width' and 'height', both in pixels) */\n this.defaultSize = { width: 100, height: 100 };\n }\n\n /** @property {boolean} label Whether or not to draw a text label this widget. */\n this.label = false\n this.labelSize = 30\n this.labelAlign = \"center\"\n this.labelFont = \"'Open Sans'\"\n\n if (this.canvas.getAttribute(\"label\")!=null) {\n this.label = this.canvas.getAttribute(\"label\")\n this.origDefaultHeight = this.defaultSize.height\n }\n if (this.label) {\n this.defaultSize.height += this.labelSize\n }\n\n if (this.width==300 && this.height==150) {\n this.canvas.width = this.defaultSize.width*2;\n this.canvas.height = this.defaultSize.height*2;\n this.width = this.defaultSize.width;\n this.height = this.defaultSize.height;\n } else {\n \tvar proxyw = this.width;\n \tvar proxyh = this.height;\n \tthis.canvas.width = proxyw*2;\n this.canvas.height = proxyh*2;\n this.width = proxyw;\n this.height = proxyh;\n }\n this.canvas.style.width = this.canvas.width/2+\"px\";\n this.canvas.style.height = this.canvas.height/2+\"px\";\n this.context.scale(2,2)\n\n\n this.makeRoomForLabel()\n\n /** @property {object} offset The widget's computed offset from the top left of the document. (Has properties 'top' and 'left', both in pixels) */\n this.offset = domUtils.findPosition(this.canvas);\n /** @property {object} center The center of the widget's canvas. A 100x100 widget would have a center at 50x50. (Has properties 'x' and 'y', both in pixels) */\n this.center = {\n x: this.GUI.w/2,\n y: this.GUI.h/2\n };\n //drawing\n /** @property {integer} lineWidth The default line width for drawing (default is 2 pixels). In many widgets, this is overwritten to suite the widget. However it does dictate the border width on most widgets. */\n this.lineWidth = 2;\n this.context.lineWidth = this.lineWidth;\n /** @property {object} colors A widget's individual color scheme. Inherited from nx.colors. (Has properties \"accent\", \"fill\", \"border\", \"black\", and \"white\") */\n this.colors = new Object();\n // define colors individually so they are not pointers to nx.colors\n // this way each object can have its own color scheme\n for (var key in nx.colors) {\n this.colors[key] = nx.colors[key]\n }\n /*this.colors.accent = nx.colors.accent;\n this.colors.fill = nx.colors.fill;\n this.colors.border = nx.colors.border;\n this.colors.accentborder = nx.colors.accentborder;\n this.colors.black = nx.colors.black;\n this.colors.white = nx.colors.white;\n this.colors.highlight = nx.colors.highlight; */\n //interaction\n /** @property {object} clickPos The most recent mouse/touch position when interating with a widget. (Has properties x and y) */\n this.clickPos = {x: 0, y: 0};\n /** @property {array} clickPos.touches If multitouch, an array of touch positions */\n this.clickPos.touches = new Array();\n /** @property {boolean} clicked Whether or not the widget is currently clicked */\n this.clicked = false;\n this.value = 0;\n /**\n @property {object} val An object containing the core interactive values of the widget, which are also the widget's data output.\n */\n this.val = new Object();\n this.pval = new Object();\n this.nodePos = new Array();\n /** @property {object} deltaMove Difference between the current touch/mouse position and the previous touch/mouse position, in pixels. */\n this.deltaMove = new Object();\n this.throttlePeriod = nx.throttlePeriod;\n this.throttle = timingUtils.throttle;\n this.hasMoved = false;\n //recording\n /** @property {boolean} isRecording Whether or not this widget's output is being recorded to a \"remix\" widget */\n this.isRecording = false;\n this.tapeNum = 0;\n this.recorder = null;\n //transmission\n if (transmit) {\n /** @method sendsTo\n Set the transmission protocol for this widget individually\n @param {string or function} [destination] Protocol for transmitting data from this widget (i.e. \"js\", \"ajax\", \"ios\", \"max\", or \"node\"). Also accepts custom functions.\n ```js\n dial1.sendsTo(\"ajax\")\n\n // or\n\n dial1.sendsTo(function(data) {\n //define a custom transmission function\n })\n ```\n */\n this.sendsTo = transmit.setWidgetTransmit;\n this.destination = \"js\";\n }\n this.events = new Object();\n\n // Setup interaction\n if (nx.isTouchDevice) {\n this.canvas.ontouchstart = this.preTouch;\n this.canvas.ontouchmove = this.preTouchMove;\n this.canvas.ontouchend = this.preTouchRelease;\n } else {\n// if ('onmousedown' in document.documentElement) {\n this.canvas.addEventListener('mousedown', this.preClick, false);\n }\n\n this.fontSize = nx.fontSize;\n this.fontWeight = nx.fontWeight;\n this.font = nx.font;\n\n this.clickCB = false;\n this.releaseCB = false;\n\n this.actuated = true;\n\n\n\n}\nutil.inherits(widget, EventEmitter)\n\n/** @method transmit\n The \"output\" instructions for sending the widget's data to another application or to a JS callback. Inherited from nx.transmit and executed when each widget is interacted with or during animation. Set using .sendsTo() to use our built-in transmission defintions.\n @param {object} [data] The data to be transmitted. Each property of the object will become its own OSC message if sending via \"ajax\" or \"max7\" protocols. (This works with objects nested to up to 2 levels).\n*/\nwidget.prototype.transmit = nx.transmit;\n\n/** @method makeOSC\n Loops through an object (i.e. a widget's data), creates OSC path/value pairs, and executes a callback function with these two arguments.\n @param {function} [callback] A function defining the action to be taken with each OSC path/value pair. This function should have two parameters, path (string) and data (type depends on widget data type).\n @param {object} [data] The data as an object, to be broken into individual OSC messages.\n*/\nwidget.prototype.makeOSC = function(action, data) {\n this.action = action;\n if ((typeof data == \"object\") && (data !== null)) {\n for (var key in data) {\n if ((typeof data[key] == \"object\") && (data[key] !== null)) {\n for (var key2 in data[key]) {\n this.action(key+\"/\"+key2, data[key][key2])\n }\n } else {\n this.action(key, data[key])\n }\n }\n } else if (typeof data == \"number\" || typeof data == \"string\") {\n this.action('value', data)\n }\n}\n\n// getoffset is useful as an API for others\n// otherwise they would have to write\n// dial1.offset = utils.findPosition()\n// now it is simply:\n// dial1.getOffset()\n\n/** @method getOffset\n Recalculate the computed offset of the widget's canvas and store it in widget.offset. This is useful if a widget has been moved after being created.\n */\nwidget.prototype.getOffset = function() {\n this.offset = domUtils.findPosition(this.canvas)\n}\n\nwidget.prototype.preClick = function(e) {\n this.actuated = true;\n this.offset = domUtils.findPosition(this.canvas)\n this.clickPos = domUtils.getCursorPosition(e, this.offset);\n // need something like:\n // if (this.clickPos.y < this.GUI.h) {\n document.addEventListener(\"mousemove\", this.preMove, false);\n document.addEventListener(\"mouseup\", this.preRelease, false);\n this.clicked = true;\n this.deltaMove.x = 0;\n this.deltaMove.y = 0;\n this.hasMoved = false;\n this.clickCB ? this.clickCB() : null;\n this.click(e);\n document.body.style.userSelect = \"none\";\n document.body.style.mozUserSelect = \"none\";\n document.body.style.webkitUserSelect = \"none\";\n document.body.style.cursor = \"pointer\";\n}\n\nwidget.prototype.preMove = function(e) {\n this.actuated = true;\n var newClickPos = domUtils.getCursorPosition(e, this.offset);\n this.deltaMove.y = newClickPos.y - this.clickPos.y;\n this.deltaMove.x = newClickPos.x - this.clickPos.x;\n this.clickPos = newClickPos;\n this.hasMoved = true;\n this.move(e);\n}\n\nwidget.prototype.preRelease = function(e) {\n this.actuated = true;\n document.removeEventListener(\"mousemove\", this.preMove, false);\n document.removeEventListener(\"mouseup\", this.preRelease, false);\n this.clicked = false;\n this.releaseCB ? this.releaseCB() : null;\n this.release();\n document.body.style.userSelect = \"text\";\n document.body.style.mozUserSelect = \"text\";\n document.body.style.webkitUserSelect = \"text\";\n document.body.style.cursor = \"default\";\n}\n\nwidget.prototype.preTouch = function(e) {\n this.actuated = true;\n this.clickPos = domUtils.getTouchPosition(e, this.offset);\n this.clicked = true;\n this.deltaMove.x = 0;\n this.deltaMove.y = 0;\n this.hasMoved = false;\n this.touch(e);\n}\n\nwidget.prototype.preTouchMove = function(e) {\n if (this.clicked) {\n this.actuated = true;\n var newClickPos = domUtils.getTouchPosition(e, this.offset);\n this.deltaMove.y = newClickPos.y - this.clickPos.y;\n this.deltaMove.x = newClickPos.x - this.clickPos.x;\n this.clickPos = newClickPos;\n this.hasMoved = true;\n this.touchMove(e);\n }\n}\n\nwidget.prototype.preTouchRelease = function(e) {\n this.actuated = true;\n if (e.targetTouches.length>=1) {\n var newClickPos = domUtils.getTouchPosition(e, this.offset);\n this.clickPos = newClickPos;\n } else {\n this.clicked = false;\n }\n this.touchRelease();\n}\n\n\n/** @method init\n Initialize or re-initialize the widget. Defined separately within each widget.\n */\n\n/** @method draw\n Draw the widget onto the canvas.\n */\nwidget.prototype.draw = function() {\n}\n\n\n/** @method click\n Executes when the widget is clicked on\n */\nwidget.prototype.click = function() {\n}\n\n\n/** @method move\n Executes on drag (mouse moves while clicked).\n */\nwidget.prototype.move = function() {\n}\n\n\n/** @method release\n Executes when the mouse releases after having clicked on the widget.\n */\nwidget.prototype.release = function() {\n}\n\n/** @method touch\n Executes when the widget is touched on a touch device.\n */\nwidget.prototype.touch = function() {\n this.click();\n}\n\n/** @method touchMove\n Executes on drag (touch then move) on a touch device\n */\nwidget.prototype.touchMove = function() {\n this.move();\n}\n\n/** @method touchRelease\n Executes when the touch releases after having touched the widget.\n */\nwidget.prototype.touchRelease = function() {\n this.release();\n}\n\nwidget.prototype.adjustSizeIfDefault = function() {\n if (this.width==300 && this.height==150) {\n this.canvas.width = this.defaultSize.width;\n this.canvas.height = this.defaultSize.height;\n this.width = this.defaultSize.width;\n this.height = this.defaultSize.height;\n }\n}\n\nwidget.prototype.makeRoundedBG = function() {\n this.bgLeft = this.lineWidth;\n this.bgRight = this.width - this.lineWidth;\n this.bgTop = this.lineWidth;\n this.bgBottom = this.height - this.lineWidth;\n this.bgHeight = this.bgBottom - this.lineWidth;\n this.bgWidth = this.bgRight - this.lineWidth;\n\n drawingUtils.makeRoundRect(this.context, this.bgLeft, this.bgTop, this.bgWidth, this.bgHeight);\n}\n\n/** @method erase\n Erase the widget's canvas.\n */\nwidget.prototype.erase = function() {\n this.context.clearRect(0,0,this.width,this.height);\n}\n\nwidget.prototype.hideCursor = function() {\n this.canvas.style.cursor = \"none\";\n}\n\nwidget.prototype.showCursor = function() {\n this.canvas.style.cursor = \"auto\";\n}\n\n// allow us to get the constructor function name programatically\n//i.e. if element is a dial, this function will return \"dial\"\n//deprecated\nwidget.prototype.getName = function() {\n return \"deprecated -- use widget.type instead\"\n}\n\n/** @method set\nManually set a widget's value (that is, set any properties of a widget's .val). See widget.val or the .val property of individual widgets for more info.\n@param {object} [data] Parameter/value pairs in object notation.\n@param {boolean} [transmit] (optional) Whether or not to transmit new value after being set.\nSets the value of an object.\n\n```js\n position1.set({\n x: 100,\n y: 250\n })\n```\n\nAn optional second argument decides whether the object then transmits its new value.\n```js\n button1.set({\n press: 100\n }, true)\n```\n*/\nwidget.prototype.set = function(data, transmit) {\n\n this.actuated = false;\n\n if (typeof this.val == \"object\" && this.val !== \"null\") {\n if (typeof data == \"object\" && data !== \"null\") {\n for (var key in data) {\n this.val[key] = data[key];\n }\n }\n } else if (typeof this.val == \"string\" || typeof this.val == \"number\") {\n if (typeof data == \"object\" && data !== \"null\") {\n this.val = data[\"value\"];\n this.draw();\n } else if (typeof data == \"string\" || typeof data == \"number\") {\n this.val = data;\n }\n }\n this.draw();\n\n if (transmit) {\n this.transmit(this.val,true)\n }\n}\n\n/** @method destroy\n Remove the widget object, canvas, and all related event listeners from the document.\n */\nwidget.prototype.destroy = function() {\n var type = nx.elemTypeArr.indexOf(this.getName())\n nx.elemTypeArr.splice(type,1)\n\n this.canvas.ontouchmove = null;\n this.canvas.ontouchend = null;\n this.canvas.onclick = null;\n this.canvas.onmousemove = null;\n this.canvas.onmouseoff = null;\n document.removeEventListener(\"mousemove\", this.preMove, false);\n document.removeEventListener(\"mouseup\", this.preRelease, false);\n\n var elemToKill = document.getElementById(this.canvasID)\n if (elemToKill) {\n elemToKill.parentNode.removeChild(elemToKill);\n }\n\n this.customDestroy();\n\n var id = this.canvasID\n delete nx.widgets[id];\n delete window[id];\n\n}\n\nwidget.prototype.customDestroy = function() {\n\n}\n\nwidget.prototype.wrapText = function(text, x, y, maxWidth, lineHeight) {\n if (text) {\n var words = text.split(' ');\n var line = '';\n\n for(var n = 0; n < words.length; n++) {\n var testLine = line + words[n] + ' ';\n var metrics = this.context.measureText(testLine);\n var testWidth = metrics.width;\n if (testWidth > maxWidth && n > 0) {\n this.context.fillText(line, x, y);\n line = words[n] + ' ';\n y += lineHeight;\n }\n else {\n line = testLine;\n }\n }\n this.context.fillText(line, x, y);\n }\n}\n\nwidget.prototype.drawLabel = function() {\n if (this.label) {\n with(this.context) {\n fillStyle = this.colors.black;\n textAlign = \"center\"\n textBaseline = \"middle\";\n font = (this.labelSize/2.8) + \"px \"+this.labelFont+\" normal\"\n fillText(this.label,this.width/2,this.labelY);\n }\n }\n}\n\n/** @method saveCanv\n Download the widget's current graphical state as an image (png).\n */\nwidget.prototype.saveCanv = function() {\n var data = this.canvas.toDataURL(\"image/png\").replace(\"image/png\", \"image/octet-stream\");\n window.location.href = data\n}\n\nwidget.prototype.setFont = function() {\n with (this.context) {\n textAlign = \"center\";\n font = this.fontWeight+\" \"+this.fontSize+\"px \"+this.font;\n fillStyle = this.colors.black;\n globalAlpha = 1;\n }\n}\n\n\n/* Percentage width support */\n\n\nwidget.prototype.checkPercentage = function() {\n var wstr = this.canvas.style.width;\n var hstr = this.canvas.style.height;\n if (wstr.indexOf(\"%\") >= 0 || hstr.indexOf(\"%\") >= 0) {\n this.percent = {\n w: (wstr.indexOf(\"%\") >= 0) ? wstr.replace(\"%\",\"\") : false,\n h: (hstr.indexOf(\"%\") >= 0) ? hstr.replace(\"%\",\"\") : false\n }\n this.stretch();\n }\n}\n\nwidget.prototype.stretch = function() {\n window.addEventListener(\"resize\", function(e) {\n if (this.percent.w) {\n var newWidth = window.getComputedStyle(this.canvas.parentNode, null).getPropertyValue(\"width\").replace(\"px\",\"\");\n newWidth *= this.percent.w/100\n } else {\n var newWidth = false;\n }\n if (this.percent.h) {\n var newHeight = window.getComputedStyle(this.canvas.parentNode, null).getPropertyValue(\"height\").replace(\"px\",\"\");\n newHeight *= this.percent.h/100\n } else {\n var newHeight = false;\n }\n this.resize(newWidth,newHeight);\n }.bind(this))\n}\n\nwidget.prototype.resize = function(w,h) {\n\n this.canvas.width = w ? w*2 : this.canvas.width;\n this.canvas.height = h ? h*2 : this.canvas.height;\n this.width = w ? w : this.width;\n this.height = h ? h : this.height;\n this.canvas.style.width = this.width+\"px\";\n this.canvas.style.height = this.height+\"px\";\n this.context.scale(2,2)\n\n this.center = {\n x: this.GUI.w/2,\n y: this.GUI.h/2\n };\n\n this.makeRoomForLabel()\n\n this.init();\n this.draw();\n\n}\n\nwidget.prototype.normalize = function(value) {\n return nx.scale(value,this.min,this.max,0,1)\n}\nwidget.prototype.rangify = function(value) {\n return nx.scale(value,0,1,this.min,this.max)\n}\n\n\nwidget.prototype.makeRoomForLabel = function() {\n this.GUI = {\n w: this.width,\n h: this.label ? this.height - this.labelSize : this.height\n }\n this.labelY = this.height - this.labelSize/2;\n // must add the above code to widget.resize\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/core/widget.js\n// module id = 1\n// module chunks = 0","\n\n/** @method toPolar \n Receives cartesian coordinates and returns polar coordinates as an object with 'radius' and 'angle' properties.\n @param {float} [x] \n @param {float} [y] \n ```js\n var ImOnACircle = nx.toPolar({ x: 20, y: 50 }})\n ```\n*/\nexports.toPolar = function(x,y) {\n var r = Math.sqrt(x*x + y*y);\n\n var theta = Math.atan2(y,x);\n if (theta < 0.) {\n theta = theta + (2 * Math.PI);\n }\n return {radius: r, angle: theta};\n}\n\n/** @method toCartesian \n Receives polar coordinates and returns cartesian coordinates as an object with 'x' and 'y' properties.\n @param {float} [radius] \n @param {float} [angle] \n*/\nexports.toCartesian = function(radius, angle){\n var cos = Math.cos(angle);\n var sin = Math.sin(angle);\n return {x: radius*cos, y: radius*sin*-1};\n}\n\n\n/** @method clip \n Limits a number to within low and high values.\n @param {float} [input value] \n @param {float} [low limit] \n @param {float} [high limit] \n ```js\n nx.clip(5,0,10) // returns 5\n nx.clip(15,0,10) // returns 10\n nx.clip(-1,0,10) // returns 0\n ```\n*/\nexports.clip = function(value, low, high) {\n return Math.min(high, Math.max(low, value));\n}\n\n/** @method prune \n Limits a float to within a certain number of decimal places\n @param {float} [input value] \n @param {integer} [max decimal places] \n ```js\n nx.prine(1.2345, 3) // returns 1.234\n nx.prune(1.2345, 1) // returns 1.2\n ```\n*/\n\nexports.prune = function(data, scale) {\n if (typeof data === \"number\") {\n data = parseFloat(data.toFixed(scale));\n } else if (data instanceof Array) {\n for (var i=0;i<data.length;i++) {\n if (typeof data[i]==\"number\") {\n data[i] = parseFloat(data[i].toFixed(scale));\n }\n }\n }\n return data;\n}\n\n\n/** @method scale \n Scales an input number to a new range of numbers\n @param {float} [input value] \n @param {float} [low1] input range (low)\n @param {float} [high1] input range (high)\n @param {float} [low2] output range (low)\n @param {float} [high2] output range (high)\n ```js\n nx.scale(5,0,10,0,100) // returns 50\n nx.scale(5,0,10,1,2) // returns 1.5\n ```\n*/\nexports.scale = function(inNum, inMin, inMax, outMin, outMax) {\n return (((inNum - inMin) * (outMax - outMin)) / (inMax - inMin)) + outMin; \n}\n\n/** @method invert \n Equivalent to nx.scale(input,0,1,1,0). Inverts a normalized (0-1) number. \n @param {float} [input value] \n ```js\n nx.invert(0.25) // returns 0.75\n nx.invert(0) // returns 1\n ```\n*/\nexports.invert = function (inNum) {\n return exports.scale(inNum, 1, 0, 0, 1);\n}\n\nexports.bounce = function(posIn, borderMin, borderMax, delta) {\n if (posIn > borderMin && posIn < borderMax) {\n return delta;\n } else if (posIn <= borderMin) {\n return Math.abs(delta); \n } else if (posIn >= borderMax) {\n return Math.abs(delta) * (-1);\n }\n}\n\n\n/** @method mtof \n MIDI to frequency conversion. Returns frequency in Hz.\n @param {float} [MIDI] MIDI value to convert\n ```js\n nx.mtof(69) // returns 440\n ```\n*/\nexports.mtof = function(midi) {\n return Math.pow(2, ((midi-69)/12)) * 440;\n}\n\n\n/** @method random \n Returns a random integer between 0 a given scale parameter.\n @param {float} [scale] Upper limit of random range.\n ```js\n nx.random(10) // returns a random number from 0 to 9.\n ```\n*/\nexports.random = function(scale) {\n return Math.floor(Math.random() * scale);\n}\n\n\nexports.interp = function(loc,min,max) {\n return loc * (max - min) + min; \n}\n\nexports.lphistory = {}\n\n\nexports.lp = function(tag,value,limit) {\n\n if (!this.lphistory[tag]) {\n this.lphistory[tag] = []\n }\n\n var total = 0;\n\n this.lphistory[tag].push(value)\n\n if (this.lphistory[tag].length>limit) {\n this.lphistory[tag].splice(0,1)\n }\n\n for (var i=0;i<this.lphistory[tag].length;i++) {\n total += this.lphistory[tag][i]\n }\n\n var newvalue = total / this.lphistory[tag].length;\n\n return newvalue;\n}\n\n\nexports.lp2 = function(value,limit) {\n\n var total = 0;\n for (var i=0;i<this.lphistory.length;i++) {\n total += this.lphistory[i]\n }\n total += value;\n\n var newvalue = total / ( this.lphistory.length + 1 )\n\n this.lphistory.push(newvalue)\n\n if (this.lphistory.length>limit) {\n this.lphistory.splice(0,1)\n }\n\n return newvalue;\n}\n\n\nexports.lp3 = function(value,pvalue,limit) {\n\n var total = value + pvalue * limit;\n newvalue = total / (limit + 1)\n\n return newvalue;\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/utils/math.js\n// module id = 2\n// module chunks = 0","var math = require('./math')\n\n/** @method randomColor\n Returns a random color string in rgb format\n*/\nexports.randomColor = function() {\n return \"rgb(\" + math.random(250) + \",\" + math.random(250) + \",\" + math.random(250) + \")\";\n}\n\n/** @method hexToRgb\n Converts a hex color code to rgb format\n @param {color code} [hex] Input color code in hex format\n @param {float} [alpha] Color alpha level\n*/\nexports.hexToRgb = function(hex, a) {\n // Expand shorthand form (e.g. \"03F\") to full form (e.g. \"0033FF\")\n var shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\n hex = hex.replace(shorthandRegex, function(m, r, g, b) {\n return r + r + g + g + b + b;\n });\n\n var result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n if (!a) {\n a = 0.5;\n }\n \n var r = parseInt(result[1], 16);\n var g = parseInt(result[2], 16);\n var b = parseInt(result[3], 16);\n\n return \"rgba(\" + r + \",\" + g + \",\" + b + \",\" + a + \")\";\n}\n\nexports.isInside = function(clickedNode,currObject) {\n if (clickedNode.x > currObject.x && clickedNode.x < (currObject.x+currObject.w) && clickedNode.y > currObject.y && clickedNode.y < (currObject.y+currObject.h)) {\n return true;\n } else {\n return false; \n }\n}\n\nexports.makeRoundRect = function(ctx,xpos,ypos,wid,hgt,depth) {\n var x1 = xpos;\n var y1 = ypos;\n var x2 = wid+x1;\n var y2 = hgt+y1;\n if (!depth) {\n depth = 2;\n }\n \n ctx.beginPath();\n ctx.moveTo(x1+depth, y1); //TOP LEFT\n ctx.lineTo(x2-depth, y1); //TOP RIGHT\n ctx.quadraticCurveTo(x2, y1, x2, y1+depth);\n ctx.lineTo(x2, y2-depth); //BOTTOM RIGHT\n ctx.quadraticCurveTo(x2, y2, x2-depth, y2);\n ctx.lineTo(x1+depth, y2); //BOTTOM LEFT\n ctx.quadraticCurveTo(x1, y2, x1, y2-depth);\n ctx.lineTo(x1, y1+depth); //TOP LEFT\n ctx.quadraticCurveTo(x1, y1, x1+depth, y1);\n ctx.closePath();\n}\n\nexports.text = function(context, text, position) {\n if (!position) {\n position = [10 , 10];\n }\n with(context) {\n beginPath();\n font = \"bold 12px sans-serif\";\n fillText(text,position[0],position[1]);\n closePath();\n }\n}\n\nexports.shadeBlendConvert = function(p, from, to) {\n if(typeof(p)!=\"number\"||p<-1||p>1||typeof(from)!=\"string\"||(from[0]!='r'&&from[0]!='#')||(typeof(to)!=\"string\"&&typeof(to)!=\"undefined\"))return null; //ErrorCheck\n this.sbcRip=function(d){\n var l=d.length,RGB=new Object();\n if(l>9){\n d=d.split(\",\");\n if(d.length<3||d.length>4)return null;//ErrorCheck\n RGB[0]=i(d[0].slice(4)),RGB[1]=i(d[1]),RGB[2]=i(d[2]),RGB[3]=d[3]?parseFloat(d[3]):-1;\n }else{\n switch(l){case 8:case 6:case 3:case 2:case 1:return null;} //ErrorCheck\n if(l<6)d=\"#\"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3]+(l>4?d[4]+\"\"+d[4]:\"\"); //3 digit\n d=i(d.slice(1),16),RGB[0]=d>>16&255,RGB[1]=d>>8&255,RGB[2]=d&255,RGB[3]=l==9||l==5?r(((d>>24&255)/255)*10000)/10000:-1;\n }\n return RGB;}\n var i=parseInt,r=Math.round,h=from.length>9,h=typeof(to)==\"string\"?to.length>9?true:to==\"c\"?!h:false:h,b=p<0,p=b?p*-1:p,to=to&&to!=\"c\"?to:b?\"#000000\":\"#FFFFFF\",f=this.sbcRip(from),t=this.sbcRip(to);\n if(!f||!t)return null; //ErrorCheck\n if(h)return \"rgb(\"+r((t[0]-f[0])*p+f[0])+\",\"+r((t[1]-f[1])*p+f[1])+\",\"+r((t[2]-f[2])*p+f[2])+(f[3]<0&&t[3]<0?\")\":\",\"+(f[3]>-1&&t[3]>-1?r(((t[3]-f[3])*p+f[3])*10000)/10000:t[3]<0?f[3]:t[3])+\")\");\n else return \"#\"+(0x100000000+(f[3]>-1&&t[3]>-1?r(((t[3]-f[3])*p+f[3])*255):t[3]>-1?r(t[3]*255):f[3]>-1?r(f[3]*255):255)*0x1000000+r((t[0]-f[0])*p+f[0])*0x10000+r((t[1]-f[1])*p+f[1])*0x100+r((t[2]-f[2])*p+f[2])).toString(16).slice(f[3]>-1||t[3]>-1?1:3);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/utils/drawing.js\n// module id = 3\n// module chunks = 0","(function(root, factory){\n\n\t//UMD\n\tif ( typeof define === \"function\" && define.amd ) {\n\t\tdefine(function() {\n\t\t\treturn factory();\n\t\t});\n\t} else if (typeof module === \"object\") {\n\t\tmodule.exports = factory();\n \t} else {\n\t\troot.Tone = factory();\n\t}\n\n}(this, function(){\n\n\t\"use strict\";\n\t\n\tvar Tone;\n\t//constructs the main Tone object\n\tfunction Main(func){\n\t\tTone = func();\n\t}\n\t//invokes each of the modules with the main Tone object as the argument\n\tfunction Module(func){\n\t\tfunc(Tone);\n\t}\t/**\n\t * Tone.js\n\t * @author Yotam Mann\n\t * @license http://opensource.org/licenses/MIT MIT License\n\t * @copyright 2014-2018 Yotam Mann\n\t */\n\tMain(function () {\n\t \n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tTONE\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * @class Tone is the base class of all other classes.\n\t\t * @constructor\n\t\t */\n\t var Tone = function () {\n\t if (!(this instanceof Tone)) {\n\t throw new Error('constructor needs to be called with the \\'new\\' keyword');\n\t }\n\t };\n\t /**\n\t\t * @memberOf Tone#\n\t\t * @returns {String} returns the name of the class as a string\n\t\t */\n\t Tone.prototype.toString = function () {\n\t for (var className in Tone) {\n\t var isLetter = className[0].match(/^[A-Z]$/);\n\t var sameConstructor = Tone[className] === this.constructor;\n\t if (Tone.isFunction(Tone[className]) && isLetter && sameConstructor) {\n\t return className;\n\t }\n\t }\n\t return 'Tone';\n\t };\n\t /**\n\t\t * @memberOf Tone#\n\t\t * disconnect and dispose\n\t\t * @returns {Tone} this\n\t\t */\n\t Tone.prototype.dispose = function () {\n\t return this;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tGET/SET\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Set the parameters at once. Either pass in an\n\t\t * object mapping parameters to values, or to set a\n\t\t * single parameter, by passing in a string and value.\n\t\t * The last argument is an optional ramp time which\n\t\t * will ramp any signal values to their destination value\n\t\t * over the duration of the rampTime.\n\t\t * @param {Object|String} params\n\t\t * @param {Number=} value\n\t\t * @param {Time=} rampTime\n\t\t * @returns {Tone} this\n\t\t * @memberOf Tone#\n\t\t * @example\n\t\t * //set values using an object\n\t\t * filter.set({\n\t\t * \t\"frequency\" : 300,\n\t\t * \t\"type\" : highpass\n\t\t * });\n\t\t * @example\n\t\t * filter.set(\"type\", \"highpass\");\n\t\t * @example\n\t\t * //ramp to the value 220 over 3 seconds.\n\t\t * oscillator.set({\n\t\t * \t\"frequency\" : 220\n\t\t * }, 3);\n\t\t */\n\t Tone.prototype.set = function (params, value, rampTime) {\n\t if (Tone.isObject(params)) {\n\t rampTime = value;\n\t } else if (Tone.isString(params)) {\n\t var tmpObj = {};\n\t tmpObj[params] = value;\n\t params = tmpObj;\n\t }\n\t paramLoop:\n\t for (var attr in params) {\n\t value = params[attr];\n\t var parent = this;\n\t if (attr.indexOf('.') !== -1) {\n\t var attrSplit = attr.split('.');\n\t for (var i = 0; i < attrSplit.length - 1; i++) {\n\t parent = parent[attrSplit[i]];\n\t if (parent instanceof Tone) {\n\t attrSplit.splice(0, i + 1);\n\t var innerParam = attrSplit.join('.');\n\t parent.set(innerParam, value);\n\t continue paramLoop;\n\t }\n\t }\n\t attr = attrSplit[attrSplit.length - 1];\n\t }\n\t var param = parent[attr];\n\t if (Tone.isUndef(param)) {\n\t continue;\n\t }\n\t if (Tone.Signal && param instanceof Tone.Signal || Tone.Param && param instanceof Tone.Param) {\n\t if (param.value !== value) {\n\t if (Tone.isUndef(rampTime)) {\n\t param.value = value;\n\t } else {\n\t param.rampTo(value, rampTime);\n\t }\n\t }\n\t } else if (param instanceof AudioParam) {\n\t if (param.value !== value) {\n\t param.value = value;\n\t }\n\t } else if (Tone.TimeBase && param instanceof Tone.TimeBase) {\n\t parent[attr] = value;\n\t } else if (param instanceof Tone) {\n\t param.set(value);\n\t } else if (param !== value) {\n\t parent[attr] = value;\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Get the object's attributes. Given no arguments get\n\t\t * will return all available object properties and their corresponding\n\t\t * values. Pass in a single attribute to retrieve or an array\n\t\t * of attributes. The attribute strings can also include a \".\"\n\t\t * to access deeper properties.\n\t\t * @memberOf Tone#\n\t\t * @example\n\t\t * osc.get();\n\t\t * //returns {\"type\" : \"sine\", \"frequency\" : 440, ...etc}\n\t\t * @example\n\t\t * osc.get(\"type\");\n\t\t * //returns { \"type\" : \"sine\"}\n\t\t * @example\n\t\t * //use dot notation to access deep properties\n\t\t * synth.get([\"envelope.attack\", \"envelope.release\"]);\n\t\t * //returns {\"envelope\" : {\"attack\" : 0.2, \"release\" : 0.4}}\n\t\t * @param {Array=|string|undefined} params the parameters to get, otherwise will return\n\t\t * \t\t\t\t\t all available.\n\t\t * @returns {Object}\n\t\t */\n\t Tone.prototype.get = function (params) {\n\t if (Tone.isUndef(params)) {\n\t params = this._collectDefaults(this.constructor);\n\t } else if (Tone.isString(params)) {\n\t params = [params];\n\t }\n\t var ret = {};\n\t for (var i = 0; i < params.length; i++) {\n\t var attr = params[i];\n\t var parent = this;\n\t var subRet = ret;\n\t if (attr.indexOf('.') !== -1) {\n\t var attrSplit = attr.split('.');\n\t for (var j = 0; j < attrSplit.length - 1; j++) {\n\t var subAttr = attrSplit[j];\n\t subRet[subAttr] = subRet[subAttr] || {};\n\t subRet = subRet[subAttr];\n\t parent = parent[subAttr];\n\t }\n\t attr = attrSplit[attrSplit.length - 1];\n\t }\n\t var param = parent[attr];\n\t if (Tone.isObject(params[attr])) {\n\t subRet[attr] = param.get();\n\t } else if (Tone.Signal && param instanceof Tone.Signal) {\n\t subRet[attr] = param.value;\n\t } else if (Tone.Param && param instanceof Tone.Param) {\n\t subRet[attr] = param.value;\n\t } else if (param instanceof AudioParam) {\n\t subRet[attr] = param.value;\n\t } else if (param instanceof Tone) {\n\t subRet[attr] = param.get();\n\t } else if (!Tone.isFunction(param) && Tone.isDefined(param)) {\n\t subRet[attr] = param;\n\t }\n\t }\n\t return ret;\n\t };\n\t /**\n\t\t * collect all of the default attributes in one\n\t\t * @private\n\t\t * @param {Function} constr the constructor to find the defaults from\n\t\t * @return {Array} all of the attributes which belong to the class\n\t\t */\n\t Tone.prototype._collectDefaults = function (constr) {\n\t var ret = [];\n\t if (Tone.isDefined(constr.defaults)) {\n\t ret = Object.keys(constr.defaults);\n\t }\n\t if (Tone.isDefined(constr._super)) {\n\t var superDefs = this._collectDefaults(constr._super);\n\t //filter out repeats\n\t for (var i = 0; i < superDefs.length; i++) {\n\t if (ret.indexOf(superDefs[i]) === -1) {\n\t ret.push(superDefs[i]);\n\t }\n\t }\n\t }\n\t return ret;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tDEFAULTS\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * @memberOf Tone\n\t\t * @param {Array} values The arguments array\n\t\t * @param {Array} keys The names of the arguments\n\t\t * @param {Function|Object} constr The class constructor\n\t\t * @return {Object} An object composed of the defaults between the class' defaults\n\t\t * and the passed in arguments.\n\t\t */\n\t Tone.defaults = function (values, keys, constr) {\n\t var options = {};\n\t if (values.length === 1 && Tone.isObject(values[0])) {\n\t options = values[0];\n\t } else {\n\t for (var i = 0; i < keys.length; i++) {\n\t options[keys[i]] = values[i];\n\t }\n\t }\n\t if (Tone.isDefined(constr.defaults)) {\n\t return Tone.defaultArg(options, constr.defaults);\n\t } else if (Tone.isObject(constr)) {\n\t return Tone.defaultArg(options, constr);\n\t } else {\n\t return options;\n\t }\n\t };\n\t /**\n\t\t * If the `given` parameter is undefined, use the `fallback`.\n\t\t * If both `given` and `fallback` are object literals, it will\n\t\t * return a deep copy which includes all of the parameters from both\n\t\t * objects. If a parameter is undefined in given, it will return\n\t\t * the fallback property.\n\t\t * <br><br>\n\t\t * WARNING: if object is self referential, it will go into an an\n\t\t * infinite recursive loop.\n\t\t * @memberOf Tone\n\t\t * @param {*} given\n\t\t * @param {*} fallback\n\t\t * @return {*}\n\t\t */\n\t Tone.defaultArg = function (given, fallback) {\n\t if (Tone.isObject(given) && Tone.isObject(fallback)) {\n\t var ret = {};\n\t //make a deep copy of the given object\n\t for (var givenProp in given) {\n\t ret[givenProp] = Tone.defaultArg(fallback[givenProp], given[givenProp]);\n\t }\n\t for (var fallbackProp in fallback) {\n\t ret[fallbackProp] = Tone.defaultArg(given[fallbackProp], fallback[fallbackProp]);\n\t }\n\t return ret;\n\t } else {\n\t return Tone.isUndef(given) ? fallback : given;\n\t }\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tCONNECTIONS\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * connect together all of the arguments in series\n\t\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t\t * @returns {Tone}\n\t\t * @memberOf Tone\n\t\t * @static\n\t\t */\n\t Tone.connectSeries = function () {\n\t var currentUnit = arguments[0];\n\t for (var i = 1; i < arguments.length; i++) {\n\t var toUnit = arguments[i];\n\t currentUnit.connect(toUnit);\n\t currentUnit = toUnit;\n\t }\n\t return Tone;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t // TYPE CHECKING\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Test if the arg is undefined\n\t\t * @param {*} arg the argument to test\n\t\t * @returns {Boolean} true if the arg is undefined\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.isUndef = function (val) {\n\t return typeof val === 'undefined';\n\t };\n\t /**\n\t\t * Test if the arg is not undefined\n\t\t * @param {*} arg the argument to test\n\t\t * @returns {Boolean} true if the arg is undefined\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.isDefined = function (val) {\n\t return !Tone.isUndef(val);\n\t };\n\t /**\n\t\t * Test if the arg is a function\n\t\t * @param {*} arg the argument to test\n\t\t * @returns {Boolean} true if the arg is a function\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.isFunction = function (val) {\n\t return typeof val === 'function';\n\t };\n\t /**\n\t\t * Test if the argument is a number.\n\t\t * @param {*} arg the argument to test\n\t\t * @returns {Boolean} true if the arg is a number\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.isNumber = function (arg) {\n\t return typeof arg === 'number';\n\t };\n\t /**\n\t\t * Test if the given argument is an object literal (i.e. `{}`);\n\t\t * @param {*} arg the argument to test\n\t\t * @returns {Boolean} true if the arg is an object literal.\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.isObject = function (arg) {\n\t return Object.prototype.toString.call(arg) === '[object Object]' && arg.constructor === Object;\n\t };\n\t /**\n\t\t * Test if the argument is a boolean.\n\t\t * @param {*} arg the argument to test\n\t\t * @returns {Boolean} true if the arg is a boolean\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.isBoolean = function (arg) {\n\t return typeof arg === 'boolean';\n\t };\n\t /**\n\t\t * Test if the argument is an Array\n\t\t * @param {*} arg the argument to test\n\t\t * @returns {Boolean} true if the arg is an array\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.isArray = function (arg) {\n\t return Array.isArray(arg);\n\t };\n\t /**\n\t\t * Test if the argument is a string.\n\t\t * @param {*} arg the argument to test\n\t\t * @returns {Boolean} true if the arg is a string\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.isString = function (arg) {\n\t return typeof arg === 'string';\n\t };\n\t /**\n\t\t * Test if the argument is in the form of a note in scientific pitch notation.\n\t\t * e.g. \"C4\"\n\t\t * @param {*} arg the argument to test\n\t\t * @returns {Boolean} true if the arg is a string\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.isNote = function (arg) {\n\t return Tone.isString(arg) && /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(arg);\n\t };\n\t /**\n\t\t * An empty function.\n\t\t * @static\n\t\t */\n\t Tone.noOp = function () {\n\t };\n\t /**\n\t\t * Make the property not writable. Internal use only.\n\t\t * @private\n\t\t * @param {String} property the property to make not writable\n\t\t */\n\t Tone.prototype._readOnly = function (property) {\n\t if (Array.isArray(property)) {\n\t for (var i = 0; i < property.length; i++) {\n\t this._readOnly(property[i]);\n\t }\n\t } else {\n\t Object.defineProperty(this, property, {\n\t writable: false,\n\t enumerable: true\n\t });\n\t }\n\t };\n\t /**\n\t\t * Make an attribute writeable. Interal use only.\n\t\t * @private\n\t\t * @param {String} property the property to make writable\n\t\t */\n\t Tone.prototype._writable = function (property) {\n\t if (Array.isArray(property)) {\n\t for (var i = 0; i < property.length; i++) {\n\t this._writable(property[i]);\n\t }\n\t } else {\n\t Object.defineProperty(this, property, { writable: true });\n\t }\n\t };\n\t /**\n\t\t * Possible play states.\n\t\t * @enum {String}\n\t\t */\n\t Tone.State = {\n\t Started: 'started',\n\t Stopped: 'stopped',\n\t Paused: 'paused'\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t // CONVERSIONS\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Equal power gain scale. Good for cross-fading.\n\t\t * @param {NormalRange} percent (0-1)\n\t\t * @return {Number} output gain (0-1)\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.equalPowerScale = function (percent) {\n\t var piFactor = 0.5 * Math.PI;\n\t return Math.sin(percent * piFactor);\n\t };\n\t /**\n\t\t * Convert decibels into gain.\n\t\t * @param {Decibels} db\n\t\t * @return {Number}\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.dbToGain = function (db) {\n\t return Math.pow(10, db / 20);\n\t };\n\t /**\n\t\t * Convert gain to decibels.\n\t\t * @param {Number} gain (0-1)\n\t\t * @return {Decibels}\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.gainToDb = function (gain) {\n\t return 20 * (Math.log(gain) / Math.LN10);\n\t };\n\t /**\n\t\t * Convert an interval (in semitones) to a frequency ratio.\n\t\t * @param {Interval} interval the number of semitones above the base note\n\t\t * @return {Number} the frequency ratio\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t * @example\n\t\t * tone.intervalToFrequencyRatio(0); // 1\n\t\t * tone.intervalToFrequencyRatio(12); // 2\n\t\t * tone.intervalToFrequencyRatio(-12); // 0.5\n\t\t */\n\t Tone.intervalToFrequencyRatio = function (interval) {\n\t return Math.pow(2, interval / 12);\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tTIMING\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Return the current time of the AudioContext clock.\n\t\t * @return {Number} the currentTime from the AudioContext\n\t\t * @memberOf Tone#\n\t\t */\n\t Tone.prototype.now = function () {\n\t return Tone.context.now();\n\t };\n\t /**\n\t\t * Return the current time of the AudioContext clock.\n\t\t * @return {Number} the currentTime from the AudioContext\n\t\t * @static\n\t\t * @memberOf Tone\n\t\t */\n\t Tone.now = function () {\n\t return Tone.context.now();\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tINHERITANCE\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * have a child inherit all of Tone's (or a parent's) prototype\n\t\t * to inherit the parent's properties, make sure to call\n\t\t * Parent.call(this) in the child's constructor\n\t\t *\n\t\t * based on closure library's inherit function\n\t\t *\n\t\t * @memberOf Tone\n\t\t * @static\n\t\t * @param {Function} \tchild\n\t\t * @param {Function=} parent (optional) parent to inherit from\n\t\t * if no parent is supplied, the child\n\t\t * will inherit from Tone\n\t\t */\n\t Tone.extend = function (child, parent) {\n\t if (Tone.isUndef(parent)) {\n\t parent = Tone;\n\t }\n\t function TempConstructor() {\n\t }\n\t TempConstructor.prototype = parent.prototype;\n\t child.prototype = new TempConstructor();\n\t /** @override */\n\t child.prototype.constructor = child;\n\t child._super = parent;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tCONTEXT\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Private reference to the global AudioContext\n\t\t * @type {AudioContext}\n\t\t * @private\n\t\t */\n\t var audioContext = null;\n\t /**\n\t\t * A static pointer to the audio context accessible as Tone.context.\n\t\t * @type {Tone.Context}\n\t\t * @name context\n\t\t * @memberOf Tone\n\t\t */\n\t Object.defineProperty(Tone, 'context', {\n\t get: function () {\n\t return audioContext;\n\t },\n\t set: function (context) {\n\t if (Tone.Context && context instanceof Tone.Context) {\n\t audioContext = context;\n\t } else {\n\t audioContext = new Tone.Context(context);\n\t }\n\t //initialize the new audio context\n\t Tone.Context.emit('init', audioContext);\n\t }\n\t });\n\t /**\n\t\t * The AudioContext\n\t\t * @type {Tone.Context}\n\t\t * @name context\n\t\t * @memberOf Tone#\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.prototype, 'context', {\n\t get: function () {\n\t return Tone.context;\n\t }\n\t });\n\t /**\n\t\t * Tone automatically creates a context on init, but if you are working\n\t\t * with other libraries which also create an AudioContext, it can be\n\t\t * useful to set your own. If you are going to set your own context,\n\t\t * be sure to do it at the start of your code, before creating any objects.\n\t\t * @static\n\t\t * @param {AudioContext} ctx The new audio context to set\n\t\t */\n\t Tone.setContext = function (ctx) {\n\t Tone.context = ctx;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tATTRIBUTES\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * The number of seconds of 1 processing block (128 samples)\n\t\t * @type {Number}\n\t\t * @name blockTime\n\t\t * @memberOf Tone\n\t\t * @static\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.prototype, 'blockTime', {\n\t get: function () {\n\t return 128 / this.context.sampleRate;\n\t }\n\t });\n\t /**\n\t\t * The duration in seconds of one sample.\n\t\t * @type {Number}\n\t\t * @name sampleTime\n\t\t * @memberOf Tone\n\t\t * @static\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.prototype, 'sampleTime', {\n\t get: function () {\n\t return 1 / this.context.sampleRate;\n\t }\n\t });\n\t /**\n\t\t * Whether or not all the technologies that Tone.js relies on are supported by the current browser.\n\t\t * @type {Boolean}\n\t\t * @name supported\n\t\t * @memberOf Tone\n\t\t * @readOnly\n\t\t * @static\n\t\t */\n\t Object.defineProperty(Tone, 'supported', {\n\t get: function () {\n\t var hasAudioContext = window.hasOwnProperty('AudioContext') || window.hasOwnProperty('webkitAudioContext');\n\t var hasPromises = window.hasOwnProperty('Promise');\n\t var hasWorkers = window.hasOwnProperty('Worker');\n\t return hasAudioContext && hasPromises && hasWorkers;\n\t }\n\t });\n\t /**\n\t\t * Boolean value if the audio context has been initialized.\n\t\t * @type {Boolean}\n\t\t * @memberOf Tone\n\t\t * @static\n\t\t * @name initialized\n\t\t */\n\t Object.defineProperty(Tone, 'initialized', {\n\t get: function () {\n\t return audioContext !== null;\n\t }\n\t });\n\t /**\n\t\t * Get the context when it becomes available\n\t\t * @param {Function} resolve Callback when the context is initialized\n\t\t * @return {Tone}\n\t\t */\n\t Tone.getContext = function (resolve) {\n\t if (Tone.initialized) {\n\t resolve(Tone.context);\n\t } else {\n\t var resCallback = function () {\n\t resolve(Tone.context);\n\t Tone.Context.off('init', resCallback);\n\t };\n\t Tone.Context.on('init', resCallback);\n\t }\n\t return Tone;\n\t };\n\t /**\n\t\t * The version number\n\t\t * @type {String}\n\t\t * @static\n\t\t */\n\t Tone.version = 'r12';\n\t return Tone;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Emitter gives classes which extend it\n\t\t * the ability to listen for and emit events.\n\t\t * Inspiration and reference from Jerome Etienne's [MicroEvent](https://github.com/jeromeetienne/microevent.js).\n\t\t * MIT (c) 2011 Jerome Etienne.\n\t\t *\n\t\t * @extends {Tone}\n\t\t */\n\t Tone.Emitter = function () {\n\t Tone.call(this);\n\t /**\n\t\t\t * Contains all of the events.\n\t\t\t * @private\n\t\t\t * @type {Object}\n\t\t\t */\n\t this._events = {};\n\t };\n\t Tone.extend(Tone.Emitter);\n\t /**\n\t\t * Bind a callback to a specific event.\n\t\t * @param {String} event The name of the event to listen for.\n\t\t * @param {Function} callback The callback to invoke when the\n\t\t * event is emitted\n\t\t * @return {Tone.Emitter} this\n\t\t */\n\t Tone.Emitter.prototype.on = function (event, callback) {\n\t //split the event\n\t var events = event.split(/\\W+/);\n\t for (var i = 0; i < events.length; i++) {\n\t var eventName = events[i];\n\t if (!this._events.hasOwnProperty(eventName)) {\n\t this._events[eventName] = [];\n\t }\n\t this._events[eventName].push(callback);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Bind a callback which is only invoked once\n\t\t * @param {String} event The name of the event to listen for.\n\t\t * @param {Function} callback The callback to invoke when the\n\t\t * event is emitted\n\t\t * @return {Tone.Emitter} this\n\t\t */\n\t Tone.Emitter.prototype.once = function (event, callback) {\n\t var boundCallback = function () {\n\t //invoke the callback\n\t callback.apply(this, arguments);\n\t this.off(event, boundCallback);\n\t }.bind(this);\n\t this.on(event, boundCallback);\n\t return this;\n\t };\n\t /**\n\t\t * Remove the event listener.\n\t\t * @param {String} event The event to stop listening to.\n\t\t * @param {Function=} callback The callback which was bound to\n\t\t * the event with Tone.Emitter.on.\n\t\t * If no callback is given, all callbacks\n\t\t * events are removed.\n\t\t * @return {Tone.Emitter} this\n\t\t */\n\t Tone.Emitter.prototype.off = function (event, callback) {\n\t var events = event.split(/\\W+/);\n\t for (var ev = 0; ev < events.length; ev++) {\n\t event = events[ev];\n\t if (this._events.hasOwnProperty(event)) {\n\t if (Tone.isUndef(callback)) {\n\t this._events[event] = [];\n\t } else {\n\t var eventList = this._events[event];\n\t for (var i = 0; i < eventList.length; i++) {\n\t if (eventList[i] === callback) {\n\t eventList.splice(i, 1);\n\t }\n\t }\n\t }\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Invoke all of the callbacks bound to the event\n\t\t * with any arguments passed in.\n\t\t * @param {String} event The name of the event.\n\t\t * @param {*} args... The arguments to pass to the functions listening.\n\t\t * @return {Tone.Emitter} this\n\t\t */\n\t Tone.Emitter.prototype.emit = function (event) {\n\t if (this._events) {\n\t var args = Array.apply(null, arguments).slice(1);\n\t if (this._events.hasOwnProperty(event)) {\n\t var eventList = this._events[event].slice(0);\n\t for (var i = 0, len = eventList.length; i < len; i++) {\n\t eventList[i].apply(this, args);\n\t }\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Add Emitter functions (on/off/emit) to the object\n\t\t * @param {Object|Function} object The object or class to extend.\n\t\t * @returns {Tone.Emitter}\n\t\t */\n\t Tone.Emitter.mixin = function (object) {\n\t var functions = [\n\t 'on',\n\t 'once',\n\t 'off',\n\t 'emit'\n\t ];\n\t object._events = {};\n\t for (var i = 0; i < functions.length; i++) {\n\t var func = functions[i];\n\t var emitterFunc = Tone.Emitter.prototype[func];\n\t object[func] = emitterFunc;\n\t }\n\t return Tone.Emitter;\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.Emitter} this\n\t\t */\n\t Tone.Emitter.prototype.dispose = function () {\n\t Tone.prototype.dispose.call(this);\n\t this._events = null;\n\t return this;\n\t };\n\t return Tone.Emitter;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class A Timeline class for scheduling and maintaining state\n\t\t * along a timeline. All events must have a \"time\" property.\n\t\t * Internally, events are stored in time order for fast\n\t\t * retrieval.\n\t\t * @extends {Tone}\n\t\t * @param {Positive} [memory=Infinity] The number of previous events that are retained.\n\t\t */\n\t Tone.Timeline = function () {\n\t var options = Tone.defaults(arguments, ['memory'], Tone.Timeline);\n\t Tone.call(this);\n\t /**\n\t\t\t * The array of scheduled timeline events\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._timeline = [];\n\t /**\n\t\t\t * The memory of the timeline, i.e.\n\t\t\t * how many events in the past it will retain\n\t\t\t * @type {Positive}\n\t\t\t */\n\t this.memory = options.memory;\n\t };\n\t Tone.extend(Tone.Timeline);\n\t /**\n\t\t * the default parameters\n\t\t * @static\n\t\t * @const\n\t\t */\n\t Tone.Timeline.defaults = { 'memory': Infinity };\n\t /**\n\t\t * The number of items in the timeline.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Timeline#\n\t\t * @name length\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Timeline.prototype, 'length', {\n\t get: function () {\n\t return this._timeline.length;\n\t }\n\t });\n\t /**\n\t\t * Insert an event object onto the timeline. Events must have a \"time\" attribute.\n\t\t * @param {Object} event The event object to insert into the\n\t\t * timeline.\n\t\t * @returns {Tone.Timeline} this\n\t\t */\n\t Tone.Timeline.prototype.add = function (event) {\n\t //the event needs to have a time attribute\n\t if (Tone.isUndef(event.time)) {\n\t throw new Error('Tone.Timeline: events must have a time attribute');\n\t }\n\t event.time = event.time.valueOf();\n\t var index = this._search(event.time);\n\t this._timeline.splice(index + 1, 0, event);\n\t //if the length is more than the memory, remove the previous ones\n\t if (this.length > this.memory) {\n\t var diff = this.length - this.memory;\n\t this._timeline.splice(0, diff);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Remove an event from the timeline.\n\t\t * @param {Object} event The event object to remove from the list.\n\t\t * @returns {Tone.Timeline} this\n\t\t */\n\t Tone.Timeline.prototype.remove = function (event) {\n\t var index = this._timeline.indexOf(event);\n\t if (index !== -1) {\n\t this._timeline.splice(index, 1);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Get the nearest event whose time is less than or equal to the given time.\n\t\t * @param {Number} time The time to query.\n\t\t * @param {String} comparator Which value in the object to compare\n\t\t * @returns {Object} The event object set after that time.\n\t\t */\n\t Tone.Timeline.prototype.get = function (time, comparator) {\n\t comparator = Tone.defaultArg(comparator, 'time');\n\t var index = this._search(time, comparator);\n\t if (index !== -1) {\n\t return this._timeline[index];\n\t } else {\n\t return null;\n\t }\n\t };\n\t /**\n\t\t * Return the first event in the timeline without removing it\n\t\t * @returns {Object} The first event object\n\t\t */\n\t Tone.Timeline.prototype.peek = function () {\n\t return this._timeline[0];\n\t };\n\t /**\n\t\t * Return the first event in the timeline and remove it\n\t\t * @returns {Object} The first event object\n\t\t */\n\t Tone.Timeline.prototype.shift = function () {\n\t return this._timeline.shift();\n\t };\n\t /**\n\t\t * Get the event which is scheduled after the given time.\n\t\t * @param {Number} time The time to query.\n\t\t * @param {String} comparator Which value in the object to compare\n\t\t * @returns {Object} The event object after the given time\n\t\t */\n\t Tone.Timeline.prototype.getAfter = function (time, comparator) {\n\t comparator = Tone.defaultArg(comparator, 'time');\n\t var index = this._search(time, comparator);\n\t if (index + 1 < this._timeline.length) {\n\t return this._timeline[index + 1];\n\t } else {\n\t return null;\n\t }\n\t };\n\t /**\n\t\t * Get the event before the event at the given time.\n\t\t * @param {Number} time The time to query.\n\t\t * @param {String} comparator Which value in the object to compare\n\t\t * @returns {Object} The event object before the given time\n\t\t */\n\t Tone.Timeline.prototype.getBefore = function (time, comparator) {\n\t comparator = Tone.defaultArg(comparator, 'time');\n\t var len = this._timeline.length;\n\t //if it's after the last item, return the last item\n\t if (len > 0 && this._timeline[len - 1][comparator] < time) {\n\t return this._timeline[len - 1];\n\t }\n\t var index = this._search(time, comparator);\n\t if (index - 1 >= 0) {\n\t return this._timeline[index - 1];\n\t } else {\n\t return null;\n\t }\n\t };\n\t /**\n\t\t * Cancel events after the given time\n\t\t * @param {Number} time The time to query.\n\t\t * @returns {Tone.Timeline} this\n\t\t */\n\t Tone.Timeline.prototype.cancel = function (after) {\n\t if (this._timeline.length > 1) {\n\t var index = this._search(after);\n\t if (index >= 0) {\n\t if (this._timeline[index].time === after) {\n\t //get the first item with that time\n\t for (var i = index; i >= 0; i--) {\n\t if (this._timeline[i].time === after) {\n\t index = i;\n\t } else {\n\t break;\n\t }\n\t }\n\t this._timeline = this._timeline.slice(0, index);\n\t } else {\n\t this._timeline = this._timeline.slice(0, index + 1);\n\t }\n\t } else {\n\t this._timeline = [];\n\t }\n\t } else if (this._timeline.length === 1) {\n\t //the first item's time\n\t if (this._timeline[0].time >= after) {\n\t this._timeline = [];\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Cancel events before or equal to the given time.\n\t\t * @param {Number} time The time to cancel before.\n\t\t * @returns {Tone.Timeline} this\n\t\t */\n\t Tone.Timeline.prototype.cancelBefore = function (time) {\n\t var index = this._search(time);\n\t if (index >= 0) {\n\t this._timeline = this._timeline.slice(index + 1);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Returns the previous event if there is one. null otherwise\n\t\t * @param {Object} event The event to find the previous one of\n\t\t * @return {Object} The event right before the given event\n\t\t */\n\t Tone.Timeline.prototype.previousEvent = function (event) {\n\t var index = this._timeline.indexOf(event);\n\t if (index > 0) {\n\t return this._timeline[index - 1];\n\t } else {\n\t return null;\n\t }\n\t };\n\t /**\n\t\t * Does a binary search on the timeline array and returns the\n\t\t * nearest event index whose time is after or equal to the given time.\n\t\t * If a time is searched before the first index in the timeline, -1 is returned.\n\t\t * If the time is after the end, the index of the last item is returned.\n\t\t * @param {Number} time\n\t\t * @param {String} comparator Which value in the object to compare\n\t\t * @return {Number} the index in the timeline array\n\t\t * @private\n\t\t */\n\t Tone.Timeline.prototype._search = function (time, comparator) {\n\t if (this._timeline.length === 0) {\n\t return -1;\n\t }\n\t comparator = Tone.defaultArg(comparator, 'time');\n\t var beginning = 0;\n\t var len = this._timeline.length;\n\t var end = len;\n\t if (len > 0 && this._timeline[len - 1][comparator] <= time) {\n\t return len - 1;\n\t }\n\t while (beginning < end) {\n\t // calculate the midpoint for roughly equal partition\n\t var midPoint = Math.floor(beginning + (end - beginning) / 2);\n\t var event = this._timeline[midPoint];\n\t var nextEvent = this._timeline[midPoint + 1];\n\t if (event[comparator] === time) {\n\t //choose the last one that has the same time\n\t for (var i = midPoint; i < this._timeline.length; i++) {\n\t var testEvent = this._timeline[i];\n\t if (testEvent[comparator] === time) {\n\t midPoint = i;\n\t }\n\t }\n\t return midPoint;\n\t } else if (event[comparator] < time && nextEvent[comparator] > time) {\n\t return midPoint;\n\t } else if (event[comparator] > time) {\n\t //search lower\n\t end = midPoint;\n\t } else {\n\t //search upper\n\t beginning = midPoint + 1;\n\t }\n\t }\n\t return -1;\n\t };\n\t /**\n\t\t * Internal iterator. Applies extra safety checks for\n\t\t * removing items from the array.\n\t\t * @param {Function} callback\n\t\t * @param {Number=} lowerBound\n\t\t * @param {Number=} upperBound\n\t\t * @private\n\t\t */\n\t Tone.Timeline.prototype._iterate = function (callback, lowerBound, upperBound) {\n\t lowerBound = Tone.defaultArg(lowerBound, 0);\n\t upperBound = Tone.defaultArg(upperBound, this._timeline.length - 1);\n\t this._timeline.slice(lowerBound, upperBound + 1).forEach(function (event) {\n\t callback.call(this, event);\n\t }.bind(this));\n\t };\n\t /**\n\t\t * Iterate over everything in the array\n\t\t * @param {Function} callback The callback to invoke with every item\n\t\t * @returns {Tone.Timeline} this\n\t\t */\n\t Tone.Timeline.prototype.forEach = function (callback) {\n\t this._iterate(callback);\n\t return this;\n\t };\n\t /**\n\t\t * Iterate over everything in the array at or before the given time.\n\t\t * @param {Number} time The time to check if items are before\n\t\t * @param {Function} callback The callback to invoke with every item\n\t\t * @returns {Tone.Timeline} this\n\t\t */\n\t Tone.Timeline.prototype.forEachBefore = function (time, callback) {\n\t //iterate over the items in reverse so that removing an item doesn't break things\n\t var upperBound = this._search(time);\n\t if (upperBound !== -1) {\n\t this._iterate(callback, 0, upperBound);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Iterate over everything in the array after the given time.\n\t\t * @param {Number} time The time to check if items are before\n\t\t * @param {Function} callback The callback to invoke with every item\n\t\t * @returns {Tone.Timeline} this\n\t\t */\n\t Tone.Timeline.prototype.forEachAfter = function (time, callback) {\n\t //iterate over the items in reverse so that removing an item doesn't break things\n\t var lowerBound = this._search(time);\n\t this._iterate(callback, lowerBound + 1);\n\t return this;\n\t };\n\t /**\n\t\t * Iterate over everything in the array between the startTime and endTime. \n\t\t * The timerange is inclusive of the startTime, but exclusive of the endTime. \n\t\t * range = [startTime, endTime). \n\t\t * @param {Number} startTime The time to check if items are before\n\t\t * @param {Number} endTime The end of the test interval. \n\t\t * @param {Function} callback The callback to invoke with every item\n\t\t * @returns {Tone.Timeline} this\n\t\t */\n\t Tone.Timeline.prototype.forEachBetween = function (startTime, endTime, callback) {\n\t var lowerBound = this._search(startTime);\n\t var upperBound = this._search(endTime);\n\t if (lowerBound !== -1 && upperBound !== -1) {\n\t if (this._timeline[lowerBound].time !== startTime) {\n\t lowerBound += 1;\n\t }\n\t //exclusive of the end time\n\t if (this._timeline[upperBound].time === endTime) {\n\t upperBound -= 1;\n\t }\n\t this._iterate(callback, lowerBound, upperBound);\n\t } else if (lowerBound === -1) {\n\t this._iterate(callback, 0, upperBound);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Iterate over everything in the array at or after the given time. Similar to\n\t\t * forEachAfter, but includes the item(s) at the given time.\n\t\t * @param {Number} time The time to check if items are before\n\t\t * @param {Function} callback The callback to invoke with every item\n\t\t * @returns {Tone.Timeline} this\n\t\t */\n\t Tone.Timeline.prototype.forEachFrom = function (time, callback) {\n\t //iterate over the items in reverse so that removing an item doesn't break things\n\t var lowerBound = this._search(time);\n\t //work backwards until the event time is less than time\n\t while (lowerBound >= 0 && this._timeline[lowerBound].time >= time) {\n\t lowerBound--;\n\t }\n\t this._iterate(callback, lowerBound + 1);\n\t return this;\n\t };\n\t /**\n\t\t * Iterate over everything in the array at the given time\n\t\t * @param {Number} time The time to check if items are before\n\t\t * @param {Function} callback The callback to invoke with every item\n\t\t * @returns {Tone.Timeline} this\n\t\t */\n\t Tone.Timeline.prototype.forEachAtTime = function (time, callback) {\n\t //iterate over the items in reverse so that removing an item doesn't break things\n\t var upperBound = this._search(time);\n\t if (upperBound !== -1) {\n\t this._iterate(function (event) {\n\t if (event.time === time) {\n\t callback.call(this, event);\n\t }\n\t }, 0, upperBound);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.Timeline} this\n\t\t */\n\t Tone.Timeline.prototype.dispose = function () {\n\t Tone.prototype.dispose.call(this);\n\t this._timeline = null;\n\t return this;\n\t };\n\t return Tone.Timeline;\n\t});\n\tModule(function (Tone) {\n\t if (Tone.supported) {\n\t if (!window.hasOwnProperty('OfflineAudioContext') && window.hasOwnProperty('webkitOfflineAudioContext')) {\n\t window.OfflineAudioContext = window.webkitOfflineAudioContext;\n\t }\n\t //returns promise?\n\t var context = new OfflineAudioContext(1, 1, 44100);\n\t var ret = context.startRendering();\n\t if (!(ret instanceof Promise)) {\n\t OfflineAudioContext.prototype._native_startRendering = OfflineAudioContext.prototype.startRendering;\n\t OfflineAudioContext.prototype.startRendering = function () {\n\t return new Promise(function (done) {\n\t this.oncomplete = function (e) {\n\t done(e.renderedBuffer);\n\t };\n\t this._native_startRendering();\n\t }.bind(this));\n\t };\n\t }\n\t }\n\t});\n\tModule(function (Tone) {\n\t if (Tone.supported) {\n\t if (!window.hasOwnProperty('AudioContext') && window.hasOwnProperty('webkitAudioContext')) {\n\t window.AudioContext = window.webkitAudioContext;\n\t }\n\t //not functionally equivalent, but only an API placeholder\n\t if (!AudioContext.prototype.close) {\n\t AudioContext.prototype.close = function () {\n\t if (Tone.isFunction(this.suspend)) {\n\t this.suspend();\n\t }\n\t return Promise.resolve();\n\t };\n\t }\n\t //not functionally equivalent\n\t if (!AudioContext.prototype.resume) {\n\t AudioContext.prototype.resume = function () {\n\t return Promise.resolve();\n\t };\n\t }\n\t //createGain\n\t if (!AudioContext.prototype.createGain && AudioContext.prototype.createGainNode) {\n\t AudioContext.prototype.createGain = AudioContext.prototype.createGainNode;\n\t }\n\t //createDelay\n\t if (!AudioContext.prototype.createDelay && AudioContext.prototype.createDelayNode) {\n\t AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode;\n\t }\n\t //test decodeAudioData returns a promise\n\t // https://github.com/mohayonao/web-audio-api-shim/blob/master/src/AudioContext.js\n\t // MIT License (c) 2015 @mohayonao\n\t var decodeAudioDataPromise = false;\n\t var offlineContext = new OfflineAudioContext(1, 1, 44100);\n\t var audioData = new Uint32Array([\n\t 1179011410,\n\t 48,\n\t 1163280727,\n\t 544501094,\n\t 16,\n\t 131073,\n\t 44100,\n\t 176400,\n\t 1048580,\n\t 1635017060,\n\t 8,\n\t 0,\n\t 0,\n\t 0,\n\t 0\n\t ]).buffer;\n\t try {\n\t var ret = offlineContext.decodeAudioData(audioData);\n\t if (ret instanceof Promise) {\n\t decodeAudioDataPromise = true;\n\t }\n\t } catch (e) {\n\t decodeAudioDataPromise = false;\n\t }\n\t if (!decodeAudioDataPromise) {\n\t AudioContext.prototype._native_decodeAudioData = AudioContext.prototype.decodeAudioData;\n\t AudioContext.prototype.decodeAudioData = function (audioData) {\n\t return new Promise(function (success, error) {\n\t this._native_decodeAudioData(audioData, success, error);\n\t }.bind(this));\n\t };\n\t }\n\t }\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Wrapper around the native AudioContext.\n\t\t * @extends {Tone.Emitter}\n\t\t * @param {AudioContext=} context optionally pass in a context\n\t\t */\n\t Tone.Context = function () {\n\t Tone.Emitter.call(this);\n\t var options = Tone.defaults(arguments, ['context'], Tone.Context);\n\t if (!options.context) {\n\t options.context = new window.AudioContext();\n\t if (!options.context) {\n\t throw new Error('could not create AudioContext. Possibly too many AudioContexts running already.');\n\t }\n\t }\n\t this._context = options.context;\n\t // extend all of the methods\n\t for (var prop in this._context) {\n\t this._defineProperty(this._context, prop);\n\t }\n\t /**\n\t\t\t * The default latency hint\n\t\t\t * @type {String}\n\t\t\t * @private\n\t\t\t */\n\t this._latencyHint = options.latencyHint;\n\t /**\n\t\t\t * An object containing all of the constants AudioBufferSourceNodes\n\t\t\t * @type {Object}\n\t\t\t * @private\n\t\t\t */\n\t this._constants = {};\n\t ///////////////////////////////////////////////////////////////////////\n\t // WORKER\n\t ///////////////////////////////////////////////////////////////////////\n\t /**\n\t\t\t * The amount of time events are scheduled\n\t\t\t * into the future\n\t\t\t * @type {Number}\n\t\t\t */\n\t this.lookAhead = options.lookAhead;\n\t /**\n\t\t\t * A reference to the actual computed update interval\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._computedUpdateInterval = 0;\n\t /**\n\t\t\t * A reliable callback method\n\t\t\t * @private\n\t\t\t * @type {Ticker}\n\t\t\t */\n\t this._ticker = new Ticker(this.emit.bind(this, 'tick'), options.clockSource, options.updateInterval);\n\t ///////////////////////////////////////////////////////////////////////\n\t // TIMEOUTS\n\t ///////////////////////////////////////////////////////////////////////\n\t /**\n\t\t\t * All of the setTimeout events.\n\t\t\t * @type {Tone.Timeline}\n\t\t\t * @private\n\t\t\t */\n\t this._timeouts = new Tone.Timeline();\n\t /**\n\t\t\t * The timeout id counter\n\t\t\t * @private\n\t\t\t * @type {Number}\n\t\t\t */\n\t this._timeoutIds = 0;\n\t this.on('tick', this._timeoutLoop.bind(this));\n\t };\n\t Tone.extend(Tone.Context, Tone.Emitter);\n\t Tone.Emitter.mixin(Tone.Context);\n\t /**\n\t\t * defaults\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.Context.defaults = {\n\t 'clockSource': 'worker',\n\t 'latencyHint': 'interactive',\n\t 'lookAhead': 0.1,\n\t 'updateInterval': 0.03\n\t };\n\t /**\n\t\t * Define a property on this Tone.Context.\n\t\t * This is used to extend the native AudioContext\n\t\t * @param {AudioContext} context\n\t\t * @param {String} prop\n\t\t * @private\n\t\t */\n\t Tone.Context.prototype._defineProperty = function (context, prop) {\n\t if (Tone.isUndef(this[prop])) {\n\t Object.defineProperty(this, prop, {\n\t get: function () {\n\t if (typeof context[prop] === 'function') {\n\t return context[prop].bind(context);\n\t } else {\n\t return context[prop];\n\t }\n\t },\n\t set: function (val) {\n\t context[prop] = val;\n\t }\n\t });\n\t }\n\t };\n\t /**\n\t\t * The current audio context time\n\t\t * @return {Number}\n\t\t */\n\t Tone.Context.prototype.now = function () {\n\t return this._context.currentTime + this.lookAhead;\n\t };\n\t /**\n\t\t * Promise which is invoked when the context is running.\n\t\t * Tries to resume the context if it's not started.\n\t\t * @return {Promise}\n\t\t */\n\t Tone.Context.prototype.ready = function () {\n\t return new Promise(function (done) {\n\t if (this._context.state === 'running') {\n\t done();\n\t } else {\n\t this._context.resume().then(function () {\n\t done();\n\t });\n\t }\n\t }.bind(this));\n\t };\n\t /**\n\t\t * Promise which is invoked when the context is running.\n\t\t * Tries to resume the context if it's not started.\n\t\t * @return {Promise}\n\t\t */\n\t Tone.Context.prototype.close = function () {\n\t return this._context.close().then(function () {\n\t Tone.Context.emit('close', this);\n\t }.bind(this));\n\t };\n\t /**\n\t\t * Generate a looped buffer at some constant value.\n\t\t * @param {Number} val\n\t\t * @return {BufferSourceNode}\n\t\t */\n\t Tone.Context.prototype.getConstant = function (val) {\n\t if (this._constants[val]) {\n\t return this._constants[val];\n\t } else {\n\t var buffer = this._context.createBuffer(1, 128, this._context.sampleRate);\n\t var arr = buffer.getChannelData(0);\n\t for (var i = 0; i < arr.length; i++) {\n\t arr[i] = val;\n\t }\n\t var constant = this._context.createBufferSource();\n\t constant.channelCount = 1;\n\t constant.channelCountMode = 'explicit';\n\t constant.buffer = buffer;\n\t constant.loop = true;\n\t constant.start(0);\n\t this._constants[val] = constant;\n\t return constant;\n\t }\n\t };\n\t /**\n\t\t * The private loop which keeps track of the context scheduled timeouts\n\t\t * Is invoked from the clock source\n\t\t * @private\n\t\t */\n\t Tone.Context.prototype._timeoutLoop = function () {\n\t var now = this.now();\n\t while (this._timeouts && this._timeouts.length && this._timeouts.peek().time <= now) {\n\t this._timeouts.shift().callback();\n\t }\n\t };\n\t /**\n\t\t * A setTimeout which is gaurenteed by the clock source.\n\t\t * Also runs in the offline context.\n\t\t * @param {Function} fn The callback to invoke\n\t\t * @param {Seconds} timeout The timeout in seconds\n\t\t * @returns {Number} ID to use when invoking Tone.Context.clearTimeout\n\t\t */\n\t Tone.Context.prototype.setTimeout = function (fn, timeout) {\n\t this._timeoutIds++;\n\t var now = this.now();\n\t this._timeouts.add({\n\t callback: fn,\n\t time: now + timeout,\n\t id: this._timeoutIds\n\t });\n\t return this._timeoutIds;\n\t };\n\t /**\n\t\t * Clears a previously scheduled timeout with Tone.context.setTimeout\n\t\t * @param {Number} id The ID returned from setTimeout\n\t\t * @return {Tone.Context} this\n\t\t */\n\t Tone.Context.prototype.clearTimeout = function (id) {\n\t this._timeouts.forEach(function (event) {\n\t if (event.id === id) {\n\t this.remove(event);\n\t }\n\t });\n\t return this;\n\t };\n\t /**\n\t\t * How often the Web Worker callback is invoked.\n\t\t * This number corresponds to how responsive the scheduling\n\t\t * can be. Context.updateInterval + Context.lookAhead gives you the\n\t\t * total latency between scheduling an event and hearing it.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Context#\n\t\t * @name updateInterval\n\t\t */\n\t Object.defineProperty(Tone.Context.prototype, 'updateInterval', {\n\t get: function () {\n\t return this._ticker.updateInterval;\n\t },\n\t set: function (interval) {\n\t this._ticker.updateInterval = interval;\n\t }\n\t });\n\t /**\n\t\t * What the source of the clock is, either \"worker\" (Web Worker [default]),\n\t\t * \"timeout\" (setTimeout), or \"offline\" (none).\n\t\t * @type {String}\n\t\t * @memberOf Tone.Context#\n\t\t * @name clockSource\n\t\t */\n\t Object.defineProperty(Tone.Context.prototype, 'clockSource', {\n\t get: function () {\n\t return this._ticker.type;\n\t },\n\t set: function (type) {\n\t this._ticker.type = type;\n\t }\n\t });\n\t /**\n\t\t * The type of playback, which affects tradeoffs between audio\n\t\t * output latency and responsiveness.\n\t\t *\n\t\t * In addition to setting the value in seconds, the latencyHint also\n\t\t * accepts the strings \"interactive\" (prioritizes low latency),\n\t\t * \"playback\" (prioritizes sustained playback), \"balanced\" (balances\n\t\t * latency and performance), and \"fastest\" (lowest latency, might glitch more often).\n\t\t * @type {String|Seconds}\n\t\t * @memberOf Tone.Context#\n\t\t * @name latencyHint\n\t\t * @example\n\t\t * //set the lookAhead to 0.3 seconds\n\t\t * Tone.context.latencyHint = 0.3;\n\t\t */\n\t Object.defineProperty(Tone.Context.prototype, 'latencyHint', {\n\t get: function () {\n\t return this._latencyHint;\n\t },\n\t set: function (hint) {\n\t var lookAhead = hint;\n\t this._latencyHint = hint;\n\t if (Tone.isString(hint)) {\n\t switch (hint) {\n\t case 'interactive':\n\t lookAhead = 0.1;\n\t this._context.latencyHint = hint;\n\t break;\n\t case 'playback':\n\t lookAhead = 0.8;\n\t this._context.latencyHint = hint;\n\t break;\n\t case 'balanced':\n\t lookAhead = 0.25;\n\t this._context.latencyHint = hint;\n\t break;\n\t case 'fastest':\n\t this._context.latencyHint = 'interactive';\n\t lookAhead = 0.01;\n\t break;\n\t }\n\t }\n\t this.lookAhead = lookAhead;\n\t this.updateInterval = lookAhead / 3;\n\t }\n\t });\n\t /**\n\t\t * Unlike other dispose methods, this returns a Promise\n\t\t * which executes when the context is closed and disposed\n\t\t * @returns {Promise} this\n\t\t */\n\t Tone.Context.prototype.dispose = function () {\n\t return this.close().then(function () {\n\t Tone.Emitter.prototype.dispose.call(this);\n\t this._ticker.dispose();\n\t this._ticker = null;\n\t this._timeouts.dispose();\n\t this._timeouts = null;\n\t for (var con in this._constants) {\n\t this._constants[con].disconnect();\n\t }\n\t this._constants = null;\n\t }.bind(this));\n\t };\n\t /**\n\t\t * @class A class which provides a reliable callback using either\n\t\t * a Web Worker, or if that isn't supported, falls back to setTimeout.\n\t\t * @private\n\t\t */\n\t var Ticker = function (callback, type, updateInterval) {\n\t /**\n\t\t\t * Either \"worker\" or \"timeout\"\n\t\t\t * @type {String}\n\t\t\t * @private\n\t\t\t */\n\t this._type = type;\n\t /**\n\t\t\t * The update interval of the worker\n\t\t\t * @private\n\t\t\t * @type {Number}\n\t\t\t */\n\t this._updateInterval = updateInterval;\n\t /**\n\t\t\t * The callback to invoke at regular intervals\n\t\t\t * @type {Function}\n\t\t\t * @private\n\t\t\t */\n\t this._callback = Tone.defaultArg(callback, Tone.noOp);\n\t //create the clock source for the first time\n\t this._createClock();\n\t };\n\t /**\n\t\t * The possible ticker types\n\t\t * @private\n\t\t * @type {Object}\n\t\t */\n\t Ticker.Type = {\n\t Worker: 'worker',\n\t Timeout: 'timeout',\n\t Offline: 'offline'\n\t };\n\t /**\n\t\t * Generate a web worker\n\t\t * @return {WebWorker}\n\t\t * @private\n\t\t */\n\t Ticker.prototype._createWorker = function () {\n\t //URL Shim\n\t window.URL = window.URL || window.webkitURL;\n\t var blob = new Blob([//the initial timeout time\n\t 'var timeoutTime = ' + (this._updateInterval * 1000).toFixed(1) + ';' + //onmessage callback\n\t 'self.onmessage = function(msg){' + '\\ttimeoutTime = parseInt(msg.data);' + '};' + //the tick function which posts a message\n\t //and schedules a new tick\n\t 'function tick(){' + '\\tsetTimeout(tick, timeoutTime);' + '\\tself.postMessage(\\'tick\\');' + '}' + //call tick initially\n\t 'tick();']);\n\t var blobUrl = URL.createObjectURL(blob);\n\t var worker = new Worker(blobUrl);\n\t worker.onmessage = this._callback.bind(this);\n\t this._worker = worker;\n\t };\n\t /**\n\t\t * Create a timeout loop\n\t\t * @private\n\t\t */\n\t Ticker.prototype._createTimeout = function () {\n\t this._timeout = setTimeout(function () {\n\t this._createTimeout();\n\t this._callback();\n\t }.bind(this), this._updateInterval * 1000);\n\t };\n\t /**\n\t\t * Create the clock source.\n\t\t * @private\n\t\t */\n\t Ticker.prototype._createClock = function () {\n\t if (this._type === Ticker.Type.Worker) {\n\t try {\n\t this._createWorker();\n\t } catch (e) {\n\t // workers not supported, fallback to timeout\n\t this._type = Ticker.Type.Timeout;\n\t this._createClock();\n\t }\n\t } else if (this._type === Ticker.Type.Timeout) {\n\t this._createTimeout();\n\t }\n\t };\n\t /**\n\t\t * @memberOf Ticker#\n\t\t * @type {Number}\n\t\t * @name updateInterval\n\t\t * @private\n\t\t */\n\t Object.defineProperty(Ticker.prototype, 'updateInterval', {\n\t get: function () {\n\t return this._updateInterval;\n\t },\n\t set: function (interval) {\n\t this._updateInterval = Math.max(interval, 128 / 44100);\n\t if (this._type === Ticker.Type.Worker) {\n\t this._worker.postMessage(Math.max(interval * 1000, 1));\n\t }\n\t }\n\t });\n\t /**\n\t\t * The type of the ticker, either a worker or a timeout\n\t\t * @memberOf Ticker#\n\t\t * @type {Number}\n\t\t * @name type\n\t\t * @private\n\t\t */\n\t Object.defineProperty(Ticker.prototype, 'type', {\n\t get: function () {\n\t return this._type;\n\t },\n\t set: function (type) {\n\t this._disposeClock();\n\t this._type = type;\n\t this._createClock();\n\t }\n\t });\n\t /**\n\t\t * Clean up the current clock source\n\t\t * @private\n\t\t */\n\t Ticker.prototype._disposeClock = function () {\n\t if (this._timeout) {\n\t clearTimeout(this._timeout);\n\t this._timeout = null;\n\t }\n\t if (this._worker) {\n\t this._worker.terminate();\n\t this._worker.onmessage = null;\n\t this._worker = null;\n\t }\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @private\n\t\t */\n\t Ticker.prototype.dispose = function () {\n\t this._disposeClock();\n\t this._callback = null;\n\t };\n\t /**\n\t\t * Shim all connect/disconnect and some deprecated methods which are still in\n\t\t * some older implementations.\n\t\t * @private\n\t\t */\n\t Tone.getContext(function () {\n\t var nativeConnect = AudioNode.prototype.connect;\n\t var nativeDisconnect = AudioNode.prototype.disconnect;\n\t //replace the old connect method\n\t function toneConnect(B, outNum, inNum) {\n\t if (B.input) {\n\t inNum = Tone.defaultArg(inNum, 0);\n\t if (Tone.isArray(B.input)) {\n\t return this.connect(B.input[inNum]);\n\t } else {\n\t return this.connect(B.input, outNum, inNum);\n\t }\n\t } else {\n\t try {\n\t if (B instanceof AudioNode) {\n\t nativeConnect.call(this, B, outNum, inNum);\n\t return B;\n\t } else {\n\t nativeConnect.call(this, B, outNum);\n\t return B;\n\t }\n\t } catch (e) {\n\t throw new Error('error connecting to node: ' + B + '\\n' + e);\n\t }\n\t }\n\t }\n\t //replace the old disconnect method\n\t function toneDisconnect(B, outNum, inNum) {\n\t if (B && B.input && Tone.isArray(B.input)) {\n\t inNum = Tone.defaultArg(inNum, 0);\n\t this.disconnect(B.input[inNum], outNum, 0);\n\t } else if (B && B.input) {\n\t this.disconnect(B.input, outNum, inNum);\n\t } else {\n\t try {\n\t nativeDisconnect.apply(this, arguments);\n\t } catch (e) {\n\t throw new Error('error disconnecting node: ' + B + '\\n' + e);\n\t }\n\t }\n\t }\n\t if (AudioNode.prototype.connect !== toneConnect) {\n\t AudioNode.prototype.connect = toneConnect;\n\t AudioNode.prototype.disconnect = toneDisconnect;\n\t }\n\t });\n\t // set the audio context initially, and if one is not already created\n\t if (Tone.supported && !Tone.initialized) {\n\t Tone.context = new Tone.Context();\n\t // log on first initialization\n\t // allow optional silencing of this log\n\t if (!window.TONE_SILENCE_VERSION_LOGGING) {\n\t // eslint-disable-next-line no-console\n\t console.log('%c * Tone.js ' + Tone.version + ' * ', 'background: #000; color: #fff');\n\t }\n\t } else if (!Tone.supported) {\n\t // eslint-disable-next-line no-console\n\t console.warn('This browser does not support Tone.js');\n\t }\n\t return Tone.Context;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.AudioNode is the base class for classes which process audio.\n\t\t * AudioNodes have inputs and outputs.\n\t\t * @param\t{AudioContext=} context\tThe audio context to use with the class\n\t\t * @extends {Tone}\n\t\t */\n\t Tone.AudioNode = function () {\n\t Tone.call(this);\n\t //use the default context if one is not passed in\n\t var options = Tone.defaults(arguments, ['context'], { 'context': Tone.context });\n\t /**\n\t\t\t * The AudioContext of this instance\n\t\t\t * @private\n\t\t\t * @type {AudioContext}\n\t\t\t */\n\t this._context = options.context;\n\t };\n\t Tone.extend(Tone.AudioNode);\n\t /**\n\t\t * Get the audio context belonging to this instance.\n\t\t * @type {Tone.Context}\n\t\t * @memberOf Tone.AudioNode#\n\t\t * @name context\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.AudioNode.prototype, 'context', {\n\t get: function () {\n\t return this._context;\n\t }\n\t });\n\t /**\n\t\t * Create input and outputs for this object.\n\t\t * @param {Number} [input=0] The number of inputs\n\t\t * @param {Number} [outputs=0] The number of outputs\n\t\t * @return {Tone.AudioNode} this\n\t\t * @private\n\t\t */\n\t Tone.AudioNode.prototype.createInsOuts = function (inputs, outputs) {\n\t if (inputs === 1) {\n\t this.input = this.context.createGain();\n\t } else if (inputs > 1) {\n\t this.input = new Array(inputs);\n\t }\n\t if (outputs === 1) {\n\t this.output = this.context.createGain();\n\t } else if (outputs > 1) {\n\t this.output = new Array(outputs);\n\t }\n\t };\n\t /**\n\t\t * channelCount is the number of channels used when up-mixing and down-mixing\n\t\t * connections to any inputs to the node. The default value is 2 except for\n\t\t * specific nodes where its value is specially determined.\n\t\t *\n\t\t * @memberof Tone.AudioNode#\n\t\t * @type {Number}\n\t\t * @name channelCount\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.AudioNode.prototype, 'channelCount', {\n\t get: function () {\n\t return this.output.channelCount;\n\t },\n\t set: function (c) {\n\t return this.output.channelCount = c;\n\t }\n\t });\n\t /**\n\t\t * channelCountMode determines how channels will be counted when up-mixing and\n\t\t * down-mixing connections to any inputs to the node.\n\t\t * The default value is \"max\". This attribute has no effect for nodes with no inputs.\n\t\t * @memberof Tone.AudioNode#\n\t\t * @type {String}\n\t\t * @name channelCountMode\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.AudioNode.prototype, 'channelCountMode', {\n\t get: function () {\n\t return this.output.channelCountMode;\n\t },\n\t set: function (m) {\n\t return this.output.channelCountMode = m;\n\t }\n\t });\n\t /**\n\t\t * channelInterpretation determines how individual channels will be treated\n\t\t * when up-mixing and down-mixing connections to any inputs to the node.\n\t\t * The default value is \"speakers\".\n\t\t * @memberof Tone.AudioNode#\n\t\t * @type {String}\n\t\t * @name channelInterpretation\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.AudioNode.prototype, 'channelInterpretation', {\n\t get: function () {\n\t return this.output.channelInterpretation;\n\t },\n\t set: function (i) {\n\t return this.output.channelInterpretation = i;\n\t }\n\t });\n\t /**\n\t\t * The number of inputs feeding into the AudioNode.\n\t\t * For source nodes, this will be 0.\n\t\t * @type {Number}\n\t\t * @name numberOfInputs\n\t\t * @memberof Tone.AudioNode#\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.AudioNode.prototype, 'numberOfInputs', {\n\t get: function () {\n\t if (this.input) {\n\t if (Tone.isArray(this.input)) {\n\t return this.input.length;\n\t } else {\n\t return 1;\n\t }\n\t } else {\n\t return 0;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The number of outputs coming out of the AudioNode.\n\t\t * @type {Number}\n\t\t * @name numberOfOutputs\n\t\t * @memberof Tone.AudioNode#\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.AudioNode.prototype, 'numberOfOutputs', {\n\t get: function () {\n\t if (this.output) {\n\t if (Tone.isArray(this.output)) {\n\t return this.output.length;\n\t } else {\n\t return 1;\n\t }\n\t } else {\n\t return 0;\n\t }\n\t }\n\t });\n\t /**\n\t\t * Called when an audio param connects to this node\n\t\t * @private\n\t\t */\n\t Tone.AudioNode.prototype._onConnect = function () {\n\t };\n\t /**\n\t\t * connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode\n\t\t * @param {Tone | AudioParam | AudioNode} unit\n\t\t * @param {number} [outputNum=0] optionally which output to connect from\n\t\t * @param {number} [inputNum=0] optionally which input to connect to\n\t\t * @returns {Tone.AudioNode} this\n\t\t */\n\t Tone.AudioNode.prototype.connect = function (unit, outputNum, inputNum) {\n\t if (unit._onConnect) {\n\t unit._onConnect(this);\n\t }\n\t if (Tone.isArray(this.output)) {\n\t outputNum = Tone.defaultArg(outputNum, 0);\n\t this.output[outputNum].connect(unit, 0, inputNum);\n\t } else {\n\t this.output.connect(unit, outputNum, inputNum);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * disconnect the output\n\t\t * @param {Number|AudioNode} output Either the output index to disconnect\n\t\t * if the output is an array, or the\n\t\t * node to disconnect from.\n\t\t * @returns {Tone.AudioNode} this\n\t\t */\n\t Tone.AudioNode.prototype.disconnect = function (destination, outputNum, inputNum) {\n\t if (Tone.isArray(this.output)) {\n\t if (Tone.isNumber(destination)) {\n\t this.output[destination].disconnect();\n\t } else {\n\t outputNum = Tone.defaultArg(outputNum, 0);\n\t this.output[outputNum].disconnect(destination, 0, inputNum);\n\t }\n\t } else {\n\t this.output.disconnect.apply(this.output, arguments);\n\t }\n\t };\n\t /**\n\t\t * Connect the output of this node to the rest of the nodes in series.\n\t\t * @example\n\t\t * //connect a node to an effect, panVol and then to the master output\n\t\t * node.chain(effect, panVol, Tone.Master);\n\t\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t\t * @returns {Tone.AudioNode} this\n\t\t * @private\n\t\t */\n\t Tone.AudioNode.prototype.chain = function () {\n\t var currentUnit = this;\n\t for (var i = 0; i < arguments.length; i++) {\n\t var toUnit = arguments[i];\n\t currentUnit.connect(toUnit);\n\t currentUnit = toUnit;\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * connect the output of this node to the rest of the nodes in parallel.\n\t\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t\t * @returns {Tone.AudioNode} this\n\t\t * @private\n\t\t */\n\t Tone.AudioNode.prototype.fan = function () {\n\t for (var i = 0; i < arguments.length; i++) {\n\t this.connect(arguments[i]);\n\t }\n\t return this;\n\t };\n\t if (window.AudioNode) {\n\t //give native nodes chain and fan methods\n\t AudioNode.prototype.chain = Tone.AudioNode.prototype.chain;\n\t AudioNode.prototype.fan = Tone.AudioNode.prototype.fan;\n\t }\n\t /**\n\t\t * Dispose and disconnect\n\t\t * @return {Tone.AudioNode} this\n\t\t */\n\t Tone.AudioNode.prototype.dispose = function () {\n\t if (Tone.isDefined(this.input)) {\n\t if (this.input instanceof AudioNode) {\n\t this.input.disconnect();\n\t }\n\t this.input = null;\n\t }\n\t if (Tone.isDefined(this.output)) {\n\t if (this.output instanceof AudioNode) {\n\t this.output.disconnect();\n\t }\n\t this.output = null;\n\t }\n\t this._context = null;\n\t return this;\n\t };\n\t return Tone.AudioNode;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Base class for all Signals. Used Internally.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone}\n\t\t */\n\t Tone.SignalBase = function () {\n\t Tone.AudioNode.call(this);\n\t };\n\t Tone.extend(Tone.SignalBase, Tone.AudioNode);\n\t /**\n\t\t * When signals connect to other signals or AudioParams,\n\t\t * they take over the output value of that signal or AudioParam.\n\t\t * For all other nodes, the behavior is the same as a default <code>connect</code>.\n\t\t *\n\t\t * @override\n\t\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node\n\t\t * @param {number} [outputNumber=0] The output number to connect from.\n\t\t * @param {number} [inputNumber=0] The input number to connect to.\n\t\t * @returns {Tone.SignalBase} this\n\t\t */\n\t Tone.SignalBase.prototype.connect = function (node, outputNumber, inputNumber) {\n\t //zero it out so that the signal can have full control\n\t if (Tone.Signal && Tone.Signal === node.constructor || Tone.Param && Tone.Param === node.constructor) {\n\t //cancel changes\n\t node._param.cancelScheduledValues(0);\n\t //reset the value\n\t node._param.value = 0;\n\t //mark the value as overridden\n\t node.overridden = true;\n\t } else if (node instanceof AudioParam) {\n\t node.cancelScheduledValues(0);\n\t node.value = 0;\n\t }\n\t Tone.AudioNode.prototype.connect.call(this, node, outputNumber, inputNumber);\n\t return this;\n\t };\n\t return Tone.SignalBase;\n\t});\n\tModule(function (Tone) {\n\t if (Tone.supported) {\n\t //fixes safari only bug which is still present in 11\n\t var ua = navigator.userAgent.toLowerCase();\n\t var isSafari = ua.includes('safari') && !ua.includes('chrome');\n\t if (isSafari) {\n\t var WaveShaperNode = function (context) {\n\t this._internalNode = this.input = this.output = context._native_createWaveShaper();\n\t this._curve = null;\n\t for (var prop in this._internalNode) {\n\t this._defineProperty(this._internalNode, prop);\n\t }\n\t };\n\t Object.defineProperty(WaveShaperNode.prototype, 'curve', {\n\t get: function () {\n\t return this._curve;\n\t },\n\t set: function (curve) {\n\t this._curve = curve;\n\t var array = new Float32Array(curve.length + 1);\n\t array.set(curve, 1);\n\t array[0] = curve[0];\n\t this._internalNode.curve = array;\n\t }\n\t });\n\t WaveShaperNode.prototype._defineProperty = function (context, prop) {\n\t if (Tone.isUndef(this[prop])) {\n\t Object.defineProperty(this, prop, {\n\t get: function () {\n\t if (typeof context[prop] === 'function') {\n\t return context[prop].bind(context);\n\t } else {\n\t return context[prop];\n\t }\n\t },\n\t set: function (val) {\n\t context[prop] = val;\n\t }\n\t });\n\t }\n\t };\n\t AudioContext.prototype._native_createWaveShaper = AudioContext.prototype.createWaveShaper;\n\t AudioContext.prototype.createWaveShaper = function () {\n\t return new WaveShaperNode(this);\n\t };\n\t }\n\t }\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Wraps the native Web Audio API\n\t\t * [WaveShaperNode](http://webaudio.github.io/web-audio-api/#the-waveshapernode-interface).\n\t\t *\n\t\t * @extends {Tone.SignalBase}\n\t\t * @constructor\n\t\t * @param {function|Array|Number} mapping The function used to define the values.\n\t\t * The mapping function should take two arguments:\n\t\t * the first is the value at the current position\n\t\t * and the second is the array position.\n\t\t * If the argument is an array, that array will be\n\t\t * set as the wave shaping function. The input\n\t\t * signal is an AudioRange [-1, 1] value and the output\n\t\t * signal can take on any numerical values.\n\t\t *\n\t\t * @param {Number} [bufferLen=1024] The length of the WaveShaperNode buffer.\n\t\t * @example\n\t\t * var timesTwo = new Tone.WaveShaper(function(val){\n\t\t * \treturn val * 2;\n\t\t * }, 2048);\n\t\t * @example\n\t\t * //a waveshaper can also be constructed with an array of values\n\t\t * var invert = new Tone.WaveShaper([1, -1]);\n\t\t */\n\t Tone.WaveShaper = function (mapping, bufferLen) {\n\t Tone.SignalBase.call(this);\n\t /**\n\t\t\t * the waveshaper\n\t\t\t * @type {WaveShaperNode}\n\t\t\t * @private\n\t\t\t */\n\t this._shaper = this.input = this.output = this.context.createWaveShaper();\n\t /**\n\t\t\t * the waveshapers curve\n\t\t\t * @type {Float32Array}\n\t\t\t * @private\n\t\t\t */\n\t this._curve = null;\n\t if (Array.isArray(mapping)) {\n\t this.curve = mapping;\n\t } else if (isFinite(mapping) || Tone.isUndef(mapping)) {\n\t this._curve = new Float32Array(Tone.defaultArg(mapping, 1024));\n\t } else if (Tone.isFunction(mapping)) {\n\t this._curve = new Float32Array(Tone.defaultArg(bufferLen, 1024));\n\t this.setMap(mapping);\n\t }\n\t };\n\t Tone.extend(Tone.WaveShaper, Tone.SignalBase);\n\t /**\n\t\t * Uses a mapping function to set the value of the curve.\n\t\t * @param {function} mapping The function used to define the values.\n\t\t * The mapping function take two arguments:\n\t\t * the first is the value at the current position\n\t\t * which goes from -1 to 1 over the number of elements\n\t\t * in the curve array. The second argument is the array position.\n\t\t * @returns {Tone.WaveShaper} this\n\t\t * @example\n\t\t * //map the input signal from [-1, 1] to [0, 10]\n\t\t * shaper.setMap(function(val, index){\n\t\t * \treturn (val + 1) * 5;\n\t\t * })\n\t\t */\n\t Tone.WaveShaper.prototype.setMap = function (mapping) {\n\t var array = new Array(this._curve.length);\n\t for (var i = 0, len = this._curve.length; i < len; i++) {\n\t var normalized = i / (len - 1) * 2 - 1;\n\t array[i] = mapping(normalized, i);\n\t }\n\t this.curve = array;\n\t return this;\n\t };\n\t /**\n\t\t * The array to set as the waveshaper curve. For linear curves\n\t\t * array length does not make much difference, but for complex curves\n\t\t * longer arrays will provide smoother interpolation.\n\t\t * @memberOf Tone.WaveShaper#\n\t\t * @type {Array}\n\t\t * @name curve\n\t\t */\n\t Object.defineProperty(Tone.WaveShaper.prototype, 'curve', {\n\t get: function () {\n\t return this._shaper.curve;\n\t },\n\t set: function (mapping) {\n\t this._curve = new Float32Array(mapping);\n\t this._shaper.curve = this._curve;\n\t }\n\t });\n\t /**\n\t\t * Specifies what type of oversampling (if any) should be used when\n\t\t * applying the shaping curve. Can either be \"none\", \"2x\" or \"4x\".\n\t\t * @memberOf Tone.WaveShaper#\n\t\t * @type {string}\n\t\t * @name oversample\n\t\t */\n\t Object.defineProperty(Tone.WaveShaper.prototype, 'oversample', {\n\t get: function () {\n\t return this._shaper.oversample;\n\t },\n\t set: function (oversampling) {\n\t if ([\n\t 'none',\n\t '2x',\n\t '4x'\n\t ].includes(oversampling)) {\n\t this._shaper.oversample = oversampling;\n\t } else {\n\t throw new RangeError('Tone.WaveShaper: oversampling must be either \\'none\\', \\'2x\\', or \\'4x\\'');\n\t }\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.WaveShaper} this\n\t\t */\n\t Tone.WaveShaper.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._shaper.disconnect();\n\t this._shaper = null;\n\t this._curve = null;\n\t return this;\n\t };\n\t return Tone.WaveShaper;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.TimeBase is a flexible encoding of time\n\t\t * which can be evaluated to and from a string.\n\t\t * @extends {Tone}\n\t\t * @param {Time} val The time value as a number or string\n\t\t * @param {String=} units Unit values\n\t\t * @example\n\t\t * Tone.TimeBase(4, \"n\")\n\t\t * Tone.TimeBase(2, \"t\")\n\t\t * Tone.TimeBase(\"2t\")\n\t\t * Tone.TimeBase(\"2t\") + Tone.TimeBase(\"4n\");\n\t\t */\n\t Tone.TimeBase = function (val, units) {\n\t //allows it to be constructed with or without 'new'\n\t if (this instanceof Tone.TimeBase) {\n\t /**\n\t\t\t\t * The value\n\t\t\t\t * @type {Number|String|Tone.TimeBase}\n\t\t\t\t * @private\n\t\t\t\t */\n\t this._val = val;\n\t /**\n\t\t\t\t * The units\n\t\t\t\t * @type {String?}\n\t\t\t\t * @private\n\t\t\t\t */\n\t this._units = units;\n\t //test if the value is a string representation of a number\n\t if (Tone.isUndef(this._units) && Tone.isString(this._val) && // eslint-disable-next-line eqeqeq\n\t parseFloat(this._val) == this._val && this._val.charAt(0) !== '+') {\n\t this._val = parseFloat(this._val);\n\t this._units = this._defaultUnits;\n\t } else if (val && val.constructor === this.constructor) {\n\t //if they're the same type, just copy values over\n\t this._val = val._val;\n\t this._units = val._units;\n\t } else if (val instanceof Tone.TimeBase) {\n\t switch (this._defaultUnits) {\n\t case 's':\n\t this._val = val.toSeconds();\n\t break;\n\t case 'i':\n\t this._val = val.toTicks();\n\t break;\n\t case 'hz':\n\t this._val = val.toFrequency();\n\t break;\n\t case 'midi':\n\t this._val = val.toMidi();\n\t break;\n\t default:\n\t throw new Error('Unrecognized default units ' + this._defaultUnits);\n\t }\n\t }\n\t } else {\n\t return new Tone.TimeBase(val, units);\n\t }\n\t };\n\t Tone.extend(Tone.TimeBase);\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tABSTRACT SYNTAX TREE PARSER\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * All the primary expressions.\n\t\t * @private\n\t\t * @type {Object}\n\t\t */\n\t Tone.TimeBase.prototype._expressions = {\n\t 'n': {\n\t regexp: /^(\\d+)n(\\.?)$/i,\n\t method: function (value, dot) {\n\t value = parseInt(value);\n\t var scalar = dot === '.' ? 1.5 : 1;\n\t if (value === 1) {\n\t return this._beatsToUnits(this._getTimeSignature()) * scalar;\n\t } else {\n\t return this._beatsToUnits(4 / value) * scalar;\n\t }\n\t }\n\t },\n\t 't': {\n\t regexp: /^(\\d+)t$/i,\n\t method: function (value) {\n\t value = parseInt(value);\n\t return this._beatsToUnits(8 / (parseInt(value) * 3));\n\t }\n\t },\n\t 'm': {\n\t regexp: /^(\\d+)m$/i,\n\t method: function (value) {\n\t return this._beatsToUnits(parseInt(value) * this._getTimeSignature());\n\t }\n\t },\n\t 'i': {\n\t regexp: /^(\\d+)i$/i,\n\t method: function (value) {\n\t return this._ticksToUnits(parseInt(value));\n\t }\n\t },\n\t 'hz': {\n\t regexp: /^(\\d+(?:\\.\\d+)?)hz$/i,\n\t method: function (value) {\n\t return this._frequencyToUnits(parseFloat(value));\n\t }\n\t },\n\t 'tr': {\n\t regexp: /^(\\d+(?:\\.\\d+)?):(\\d+(?:\\.\\d+)?):?(\\d+(?:\\.\\d+)?)?$/,\n\t method: function (m, q, s) {\n\t var total = 0;\n\t if (m && m !== '0') {\n\t total += this._beatsToUnits(this._getTimeSignature() * parseFloat(m));\n\t }\n\t if (q && q !== '0') {\n\t total += this._beatsToUnits(parseFloat(q));\n\t }\n\t if (s && s !== '0') {\n\t total += this._beatsToUnits(parseFloat(s) / 4);\n\t }\n\t return total;\n\t }\n\t },\n\t 's': {\n\t regexp: /^(\\d+(?:\\.\\d+)?)s$/,\n\t method: function (value) {\n\t return this._secondsToUnits(parseFloat(value));\n\t }\n\t },\n\t 'samples': {\n\t regexp: /^(\\d+)samples$/,\n\t method: function (value) {\n\t return parseInt(value) / this.context.sampleRate;\n\t }\n\t },\n\t 'default': {\n\t regexp: /^(\\d+(?:\\.\\d+)?)$/,\n\t method: function (value) {\n\t return this._expressions[this._defaultUnits].method.call(this, value);\n\t }\n\t }\n\t };\n\t /**\n\t\t * The default units if none are given.\n\t\t * @type {String}\n\t\t * @private\n\t\t */\n\t Tone.TimeBase.prototype._defaultUnits = 's';\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tTRANSPORT FALLBACKS\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Return the bpm, or 120 if Transport is not available\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t Tone.TimeBase.prototype._getBpm = function () {\n\t if (Tone.Transport) {\n\t return Tone.Transport.bpm.value;\n\t } else {\n\t return 120;\n\t }\n\t };\n\t /**\n\t\t * Return the timeSignature or 4 if Transport is not available\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t Tone.TimeBase.prototype._getTimeSignature = function () {\n\t if (Tone.Transport) {\n\t return Tone.Transport.timeSignature;\n\t } else {\n\t return 4;\n\t }\n\t };\n\t /**\n\t\t * Return the PPQ or 192 if Transport is not available\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t Tone.TimeBase.prototype._getPPQ = function () {\n\t if (Tone.Transport) {\n\t return Tone.Transport.PPQ;\n\t } else {\n\t return 192;\n\t }\n\t };\n\t /**\n\t\t * Return the current time in whichever context is relevant\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t Tone.TimeBase.prototype._now = function () {\n\t return this.now();\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tUNIT CONVERSIONS\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Returns the value of a frequency in the current units\n\t\t * @param {Frequency} freq\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.TimeBase.prototype._frequencyToUnits = function (freq) {\n\t return 1 / freq;\n\t };\n\t /**\n\t\t * Return the value of the beats in the current units\n\t\t * @param {Number} beats\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.TimeBase.prototype._beatsToUnits = function (beats) {\n\t return 60 / this._getBpm() * beats;\n\t };\n\t /**\n\t\t * Returns the value of a second in the current units\n\t\t * @param {Seconds} seconds\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.TimeBase.prototype._secondsToUnits = function (seconds) {\n\t return seconds;\n\t };\n\t /**\n\t\t * Returns the value of a tick in the current time units\n\t\t * @param {Ticks} ticks\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.TimeBase.prototype._ticksToUnits = function (ticks) {\n\t return ticks * (this._beatsToUnits(1) / this._getPPQ());\n\t };\n\t /**\n\t\t * With no arguments, return 'now'\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.TimeBase.prototype._noArg = function () {\n\t return this._now();\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tEXPRESSIONS\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Evaluate the time value. Returns the time\n\t\t * in seconds.\n\t\t * @return {Seconds}\n\t\t */\n\t Tone.TimeBase.prototype.valueOf = function () {\n\t if (Tone.isUndef(this._val)) {\n\t return this._noArg();\n\t } else if (Tone.isString(this._val) && Tone.isUndef(this._units)) {\n\t for (var units in this._expressions) {\n\t if (this._expressions[units].regexp.test(this._val.trim())) {\n\t this._units = units;\n\t break;\n\t }\n\t }\n\t }\n\t if (Tone.isDefined(this._units)) {\n\t var expr = this._expressions[this._units];\n\t var matching = this._val.toString().trim().match(expr.regexp);\n\t if (matching) {\n\t return expr.method.apply(this, matching.slice(1));\n\t } else {\n\t return expr.method.call(this, parseFloat(this._val));\n\t }\n\t } else {\n\t return this._val;\n\t }\n\t };\n\t /**\n\t\t * Return the value in seconds\n\t\t * @return {Seconds}\n\t\t */\n\t Tone.TimeBase.prototype.toSeconds = function () {\n\t return this.valueOf();\n\t };\n\t /**\n\t\t * Return the value in hertz\n\t\t * @return {Frequency}\n\t\t */\n\t Tone.TimeBase.prototype.toFrequency = function () {\n\t return 1 / this.toSeconds();\n\t };\n\t /**\n\t\t * Return the time in samples\n\t\t * @return {Samples}\n\t\t */\n\t Tone.TimeBase.prototype.toSamples = function () {\n\t return this.toSeconds() * this.context.sampleRate;\n\t };\n\t /**\n\t\t * Return the time in milliseconds.\n\t\t * @return {Milliseconds}\n\t\t */\n\t Tone.TimeBase.prototype.toMilliseconds = function () {\n\t return this.toSeconds() * 1000;\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.TimeBase} this\n\t\t */\n\t Tone.TimeBase.prototype.dispose = function () {\n\t this._val = null;\n\t this._units = null;\n\t };\n\t return Tone.TimeBase;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.Frequency is a primitive type for encoding Frequency values.\n\t\t * Eventually all time values are evaluated to hertz\n\t\t * using the `eval` method.\n\t\t * @constructor\n\t\t * @extends {Tone.TimeBase}\n\t\t * @param {String|Number} val The time value.\n\t\t * @param {String=} units The units of the value.\n\t\t * @example\n\t\t * Tone.Frequency(\"C3\") // 261\n\t\t * Tone.Frequency(38, \"midi\") //\n\t\t * Tone.Frequency(\"C3\").transpose(4);\n\t\t */\n\t Tone.Frequency = function (val, units) {\n\t if (this instanceof Tone.Frequency) {\n\t Tone.TimeBase.call(this, val, units);\n\t } else {\n\t return new Tone.Frequency(val, units);\n\t }\n\t };\n\t Tone.extend(Tone.Frequency, Tone.TimeBase);\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tAUGMENT BASE EXPRESSIONS\n\t ///////////////////////////////////////////////////////////////////////////\n\t Tone.Frequency.prototype._expressions = Object.assign({}, Tone.TimeBase.prototype._expressions, {\n\t 'midi': {\n\t regexp: /^(\\d+(?:\\.\\d+)?midi)/,\n\t method: function (value) {\n\t if (this._defaultUnits === 'midi') {\n\t return value;\n\t } else {\n\t return Tone.Frequency.mtof(value);\n\t }\n\t }\n\t },\n\t 'note': {\n\t regexp: /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,\n\t method: function (pitch, octave) {\n\t var index = noteToScaleIndex[pitch.toLowerCase()];\n\t var noteNumber = index + (parseInt(octave) + 1) * 12;\n\t if (this._defaultUnits === 'midi') {\n\t return noteNumber;\n\t } else {\n\t return Tone.Frequency.mtof(noteNumber);\n\t }\n\t }\n\t },\n\t 'tr': {\n\t regexp: /^(\\d+(?:\\.\\d+)?):(\\d+(?:\\.\\d+)?):?(\\d+(?:\\.\\d+)?)?/,\n\t method: function (m, q, s) {\n\t var total = 1;\n\t if (m && m !== '0') {\n\t total *= this._beatsToUnits(this._getTimeSignature() * parseFloat(m));\n\t }\n\t if (q && q !== '0') {\n\t total *= this._beatsToUnits(parseFloat(q));\n\t }\n\t if (s && s !== '0') {\n\t total *= this._beatsToUnits(parseFloat(s) / 4);\n\t }\n\t return total;\n\t }\n\t }\n\t });\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tEXPRESSIONS\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Transposes the frequency by the given number of semitones.\n\t\t * @param {Interval} interval\n\t\t * @return {Tone.Frequency} A new transposed frequency\n\t\t * @example\n\t\t * Tone.Frequency(\"A4\").transpose(3); //\"C5\"\n\t\t */\n\t Tone.Frequency.prototype.transpose = function (interval) {\n\t return new this.constructor(this.valueOf() * Tone.intervalToFrequencyRatio(interval));\n\t };\n\t /**\n\t\t * Takes an array of semitone intervals and returns\n\t\t * an array of frequencies transposed by those intervals.\n\t\t * @param {Array} intervals\n\t\t * @return {Array<Tone.Frequency>} Returns an array of Frequencies\n\t\t * @example\n\t\t * Tone.Frequency(\"A4\").harmonize([0, 3, 7]); //[\"A4\", \"C5\", \"E5\"]\n\t\t */\n\t Tone.Frequency.prototype.harmonize = function (intervals) {\n\t return intervals.map(function (interval) {\n\t return this.transpose(interval);\n\t }.bind(this));\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tUNIT CONVERSIONS\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Return the value of the frequency as a MIDI note\n\t\t * @return {MIDI}\n\t\t * @example\n\t\t * Tone.Frequency(\"C4\").toMidi(); //60\n\t\t */\n\t Tone.Frequency.prototype.toMidi = function () {\n\t return Tone.Frequency.ftom(this.valueOf());\n\t };\n\t /**\n\t\t * Return the value of the frequency in Scientific Pitch Notation\n\t\t * @return {Note}\n\t\t * @example\n\t\t * Tone.Frequency(69, \"midi\").toNote(); //\"A4\"\n\t\t */\n\t Tone.Frequency.prototype.toNote = function () {\n\t var freq = this.toFrequency();\n\t var log = Math.log2(freq / Tone.Frequency.A4);\n\t var noteNumber = Math.round(12 * log) + 57;\n\t var octave = Math.floor(noteNumber / 12);\n\t if (octave < 0) {\n\t noteNumber += -12 * octave;\n\t }\n\t var noteName = scaleIndexToNote[noteNumber % 12];\n\t return noteName + octave.toString();\n\t };\n\t /**\n\t\t * Return the duration of one cycle in seconds.\n\t\t * @return {Seconds}\n\t\t */\n\t Tone.Frequency.prototype.toSeconds = function () {\n\t return 1 / Tone.TimeBase.prototype.toSeconds.call(this);\n\t };\n\t /**\n\t\t * Return the value in Hertz\n\t\t * @return {Frequency}\n\t\t */\n\t Tone.Frequency.prototype.toFrequency = function () {\n\t return Tone.TimeBase.prototype.toFrequency.call(this);\n\t };\n\t /**\n\t\t * Return the duration of one cycle in ticks\n\t\t * @return {Ticks}\n\t\t */\n\t Tone.Frequency.prototype.toTicks = function () {\n\t var quarterTime = this._beatsToUnits(1);\n\t var quarters = this.valueOf() / quarterTime;\n\t return Math.floor(quarters * Tone.Transport.PPQ);\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tUNIT CONVERSIONS HELPERS\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * With no arguments, return 0\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.Frequency.prototype._noArg = function () {\n\t return 0;\n\t };\n\t /**\n\t\t * Returns the value of a frequency in the current units\n\t\t * @param {Frequency} freq\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.Frequency.prototype._frequencyToUnits = function (freq) {\n\t return freq;\n\t };\n\t /**\n\t\t * Returns the value of a tick in the current time units\n\t\t * @param {Ticks} ticks\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.Frequency.prototype._ticksToUnits = function (ticks) {\n\t return 1 / (ticks * 60 / (Tone.Transport.bpm.value * Tone.Transport.PPQ));\n\t };\n\t /**\n\t\t * Return the value of the beats in the current units\n\t\t * @param {Number} beats\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.Frequency.prototype._beatsToUnits = function (beats) {\n\t return 1 / Tone.TimeBase.prototype._beatsToUnits.call(this, beats);\n\t };\n\t /**\n\t\t * Returns the value of a second in the current units\n\t\t * @param {Seconds} seconds\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.Frequency.prototype._secondsToUnits = function (seconds) {\n\t return 1 / seconds;\n\t };\n\t /**\n\t\t * The default units if none are given.\n\t\t * @private\n\t\t */\n\t Tone.Frequency.prototype._defaultUnits = 'hz';\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tFREQUENCY CONVERSIONS\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Note to scale index\n\t\t * @type {Object}\n\t\t */\n\t var noteToScaleIndex = {\n\t 'cbb': -2,\n\t 'cb': -1,\n\t 'c': 0,\n\t 'c#': 1,\n\t 'cx': 2,\n\t 'dbb': 0,\n\t 'db': 1,\n\t 'd': 2,\n\t 'd#': 3,\n\t 'dx': 4,\n\t 'ebb': 2,\n\t 'eb': 3,\n\t 'e': 4,\n\t 'e#': 5,\n\t 'ex': 6,\n\t 'fbb': 3,\n\t 'fb': 4,\n\t 'f': 5,\n\t 'f#': 6,\n\t 'fx': 7,\n\t 'gbb': 5,\n\t 'gb': 6,\n\t 'g': 7,\n\t 'g#': 8,\n\t 'gx': 9,\n\t 'abb': 7,\n\t 'ab': 8,\n\t 'a': 9,\n\t 'a#': 10,\n\t 'ax': 11,\n\t 'bbb': 9,\n\t 'bb': 10,\n\t 'b': 11,\n\t 'b#': 12,\n\t 'bx': 13\n\t };\n\t /**\n\t\t * scale index to note (sharps)\n\t\t * @type {Array}\n\t\t */\n\t var scaleIndexToNote = [\n\t 'C',\n\t 'C#',\n\t 'D',\n\t 'D#',\n\t 'E',\n\t 'F',\n\t 'F#',\n\t 'G',\n\t 'G#',\n\t 'A',\n\t 'A#',\n\t 'B'\n\t ];\n\t /**\n\t\t * The [concert pitch](https://en.wikipedia.org/wiki/Concert_pitch)\n\t\t * A4's values in Hertz.\n\t\t * @type {Frequency}\n\t\t * @static\n\t\t */\n\t Tone.Frequency.A4 = 440;\n\t /**\n\t\t * Convert a MIDI note to frequency value.\n\t\t * @param {MIDI} midi The midi number to convert.\n\t\t * @return {Frequency} the corresponding frequency value\n\t\t * @static\n\t\t * @example\n\t\t * Tone.Frequency.mtof(69); // returns 440\n\t\t */\n\t Tone.Frequency.mtof = function (midi) {\n\t return Tone.Frequency.A4 * Math.pow(2, (midi - 69) / 12);\n\t };\n\t /**\n\t\t * Convert a frequency value to a MIDI note.\n\t\t * @param {Frequency} frequency The value to frequency value to convert.\n\t\t * @returns {MIDI}\n\t\t * @static\n\t\t * @example\n\t\t * Tone.Frequency.ftom(440); // returns 69\n\t\t */\n\t Tone.Frequency.ftom = function (frequency) {\n\t return 69 + Math.round(12 * Math.log2(frequency / Tone.Frequency.A4));\n\t };\n\t return Tone.Frequency;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.Time is a primitive type for encoding Time values.\n\t\t * Tone.Time can be constructed with or without the `new` keyword. Tone.Time can be passed\n\t\t * into the parameter of any method which takes time as an argument.\n\t\t * @constructor\n\t\t * @extends {Tone.TimeBase}\n\t\t * @param {String|Number} val The time value.\n\t\t * @param {String=} units The units of the value.\n\t\t * @example\n\t\t * var t = Tone.Time(\"4n\");//a quarter note\n\t\t */\n\t Tone.Time = function (val, units) {\n\t if (this instanceof Tone.Time) {\n\t Tone.TimeBase.call(this, val, units);\n\t } else {\n\t return new Tone.Time(val, units);\n\t }\n\t };\n\t Tone.extend(Tone.Time, Tone.TimeBase);\n\t /**\n\t\t * Extend the base expressions\n\t\t */\n\t Tone.Time.prototype._expressions = Object.assign({}, Tone.TimeBase.prototype._expressions, {\n\t 'quantize': {\n\t regexp: /^@(.+)/,\n\t method: function (capture) {\n\t if (Tone.Transport) {\n\t var quantTo = new this.constructor(capture);\n\t return Tone.Transport.nextSubdivision(quantTo);\n\t } else {\n\t return 0;\n\t }\n\t }\n\t },\n\t 'now': {\n\t regexp: /^\\+(.+)/,\n\t method: function (capture) {\n\t return this._now() + new this.constructor(capture);\n\t }\n\t }\n\t });\n\t /**\n\t\t * Quantize the time by the given subdivision. Optionally add a\n\t\t * percentage which will move the time value towards the ideal\n\t\t * quantized value by that percentage.\n\t\t * @param {Number|Time} val The subdivision to quantize to\n\t\t * @param {NormalRange} [percent=1] Move the time value\n\t\t * towards the quantized value by\n\t\t * a percentage.\n\t\t * @return {Number} this\n\t\t * @example\n\t\t * Tone.Time(21).quantize(2) //returns 22\n\t\t * Tone.Time(0.6).quantize(\"4n\", 0.5) //returns 0.55\n\t\t */\n\t Tone.Time.prototype.quantize = function (subdiv, percent) {\n\t percent = Tone.defaultArg(percent, 1);\n\t var subdivision = new this.constructor(subdiv);\n\t var value = this.valueOf();\n\t var multiple = Math.round(value / subdivision);\n\t var ideal = multiple * subdivision;\n\t var diff = ideal - value;\n\t return value + diff * percent;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t // CONVERSIONS\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Convert a Time to Notation. The notation values are will be the\n\t\t * closest representation between 1m to 128th note.\n\t\t * @return {Notation}\n\t\t * @example\n\t\t * //if the Transport is at 120bpm:\n\t\t * Tone.Time(2).toNotation();//returns \"1m\"\n\t\t */\n\t Tone.Time.prototype.toNotation = function () {\n\t var time = this.toSeconds();\n\t var testNotations = ['1m'];\n\t for (var power = 1; power < 8; power++) {\n\t var subdiv = Math.pow(2, power);\n\t testNotations.push(subdiv + 'n.');\n\t testNotations.push(subdiv + 'n');\n\t testNotations.push(subdiv + 't');\n\t }\n\t testNotations.push('0');\n\t //find the closets notation representation\n\t var closest = testNotations[0];\n\t var closestSeconds = Tone.Time(testNotations[0]).toSeconds();\n\t testNotations.forEach(function (notation) {\n\t var notationSeconds = Tone.Time(notation).toSeconds();\n\t if (Math.abs(notationSeconds - time) < Math.abs(closestSeconds - time)) {\n\t closest = notation;\n\t closestSeconds = notationSeconds;\n\t }\n\t });\n\t return closest;\n\t };\n\t /**\n\t\t * Return the time encoded as Bars:Beats:Sixteenths.\n\t\t * @return {BarsBeatsSixteenths}\n\t\t */\n\t Tone.Time.prototype.toBarsBeatsSixteenths = function () {\n\t var quarterTime = this._beatsToUnits(1);\n\t var quarters = this.valueOf() / quarterTime;\n\t var measures = Math.floor(quarters / this._getTimeSignature());\n\t var sixteenths = quarters % 1 * 4;\n\t quarters = Math.floor(quarters) % this._getTimeSignature();\n\t sixteenths = sixteenths.toString();\n\t if (sixteenths.length > 3) {\n\t // the additional parseFloat removes insignificant trailing zeroes\n\t sixteenths = parseFloat(parseFloat(sixteenths).toFixed(3));\n\t }\n\t var progress = [\n\t measures,\n\t quarters,\n\t sixteenths\n\t ];\n\t return progress.join(':');\n\t };\n\t /**\n\t\t * Return the time in ticks.\n\t\t * @return {Ticks}\n\t\t */\n\t Tone.Time.prototype.toTicks = function () {\n\t var quarterTime = this._beatsToUnits(1);\n\t var quarters = this.valueOf() / quarterTime;\n\t return Math.round(quarters * this._getPPQ());\n\t };\n\t /**\n\t\t * Return the time in seconds.\n\t\t * @return {Seconds}\n\t\t */\n\t Tone.Time.prototype.toSeconds = function () {\n\t return this.valueOf();\n\t };\n\t /**\n\t\t * Return the value as a midi note.\n\t\t * @return {Midi}\n\t\t */\n\t Tone.Time.prototype.toMidi = function () {\n\t return Tone.Frequency.ftom(this.toFrequency());\n\t };\n\t return Tone.Time;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.TransportTime is a the time along the Transport's\n\t\t * timeline. It is similar to Tone.Time, but instead of evaluating\n\t\t * against the AudioContext's clock, it is evaluated against\n\t\t * the Transport's position. See [TransportTime wiki](https://github.com/Tonejs/Tone.js/wiki/TransportTime).\n\t\t * @constructor\n\t\t * @param {Time} val The time value as a number or string\n\t\t * @param {String=} units Unit values\n\t\t * @extends {Tone.Time}\n\t\t */\n\t Tone.TransportTime = function (val, units) {\n\t if (this instanceof Tone.TransportTime) {\n\t Tone.Time.call(this, val, units);\n\t } else {\n\t return new Tone.TransportTime(val, units);\n\t }\n\t };\n\t Tone.extend(Tone.TransportTime, Tone.Time);\n\t /**\n\t\t * Return the current time in whichever context is relevant\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t Tone.TransportTime.prototype._now = function () {\n\t return Tone.Transport.seconds;\n\t };\n\t return Tone.TransportTime;\n\t});\n\tModule(function (Tone) {\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tTYPES\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Units which a value can take on.\n\t\t * @enum {String}\n\t\t */\n\t Tone.Type = {\n\t /**\n\t\t\t * Default units\n\t\t\t * @typedef {Default}\n\t\t\t */\n\t Default: 'number',\n\t /**\n\t\t\t * Time can be described in a number of ways. Read more [Time](https://github.com/Tonejs/Tone.js/wiki/Time).\n\t\t\t *\n\t\t\t * * Numbers, which will be taken literally as the time (in seconds).\n\t\t\t * * Notation, (\"4n\", \"8t\") describes time in BPM and time signature relative values.\n\t\t\t * * TransportTime, (\"4:3:2\") will also provide tempo and time signature relative times\n\t\t\t * in the form BARS:QUARTERS:SIXTEENTHS.\n\t\t\t * * Frequency, (\"8hz\") is converted to the length of the cycle in seconds.\n\t\t\t * * Now-Relative, (\"+1\") prefix any of the above with \"+\" and it will be interpreted as\n\t\t\t * \"the current time plus whatever expression follows\".\n\t\t\t * * Expressions, (\"3:0 + 2 - (1m / 7)\") any of the above can also be combined\n\t\t\t * into a mathematical expression which will be evaluated to compute the desired time.\n\t\t\t * * No Argument, for methods which accept time, no argument will be interpreted as\n\t\t\t * \"now\" (i.e. the currentTime).\n\t\t\t *\n\t\t\t * @typedef {Time}\n\t\t\t */\n\t Time: 'time',\n\t /**\n\t\t\t * Frequency can be described similar to time, except ultimately the\n\t\t\t * values are converted to frequency instead of seconds. A number\n\t\t\t * is taken literally as the value in hertz. Additionally any of the\n\t\t\t * Time encodings can be used. Note names in the form\n\t\t\t * of NOTE OCTAVE (i.e. C4) are also accepted and converted to their\n\t\t\t * frequency value.\n\t\t\t * @typedef {Frequency}\n\t\t\t */\n\t Frequency: 'frequency',\n\t /**\n\t\t\t * TransportTime describes a position along the Transport's timeline. It is\n\t\t\t * similar to Time in that it uses all the same encodings, but TransportTime specifically\n\t\t\t * pertains to the Transport's timeline, which is startable, stoppable, loopable, and seekable.\n\t\t\t * [Read more](https://github.com/Tonejs/Tone.js/wiki/TransportTime)\n\t\t\t * @typedef {TransportTime}\n\t\t\t */\n\t TransportTime: 'transportTime',\n\t /**\n\t\t\t * Ticks are the basic subunit of the Transport. They are\n\t\t\t * the smallest unit of time that the Transport supports.\n\t\t\t * @typedef {Ticks}\n\t\t\t */\n\t Ticks: 'ticks',\n\t /**\n\t\t\t * Normal values are within the range [0, 1].\n\t\t\t * @typedef {NormalRange}\n\t\t\t */\n\t NormalRange: 'normalRange',\n\t /**\n\t\t\t * AudioRange values are between [-1, 1].\n\t\t\t * @typedef {AudioRange}\n\t\t\t */\n\t AudioRange: 'audioRange',\n\t /**\n\t\t\t * Decibels are a logarithmic unit of measurement which is useful for volume\n\t\t\t * because of the logarithmic way that we perceive loudness. 0 decibels\n\t\t\t * means no change in volume. -10db is approximately half as loud and 10db\n\t\t\t * is twice is loud.\n\t\t\t * @typedef {Decibels}\n\t\t\t */\n\t Decibels: 'db',\n\t /**\n\t\t\t * Half-step note increments, i.e. 12 is an octave above the root. and 1 is a half-step up.\n\t\t\t * @typedef {Interval}\n\t\t\t */\n\t Interval: 'interval',\n\t /**\n\t\t\t * Beats per minute.\n\t\t\t * @typedef {BPM}\n\t\t\t */\n\t BPM: 'bpm',\n\t /**\n\t\t\t * The value must be greater than or equal to 0.\n\t\t\t * @typedef {Positive}\n\t\t\t */\n\t Positive: 'positive',\n\t /**\n\t\t\t * Gain is the ratio between input and output of a signal.\n\t\t\t * A gain of 0 is the same as silencing the signal. A gain of\n\t\t\t * 1, causes no change to the incoming signal.\n\t\t\t * @typedef {Gain}\n\t\t\t */\n\t Gain: 'gain',\n\t /**\n\t\t\t * A cent is a hundredth of a semitone.\n\t\t\t * @typedef {Cents}\n\t\t\t */\n\t Cents: 'cents',\n\t /**\n\t\t\t * Angle between 0 and 360.\n\t\t\t * @typedef {Degrees}\n\t\t\t */\n\t Degrees: 'degrees',\n\t /**\n\t\t\t * A number representing a midi note.\n\t\t\t * @typedef {MIDI}\n\t\t\t */\n\t MIDI: 'midi',\n\t /**\n\t\t\t * A colon-separated representation of time in the form of\n\t\t\t * Bars:Beats:Sixteenths.\n\t\t\t * @typedef {BarsBeatsSixteenths}\n\t\t\t */\n\t BarsBeatsSixteenths: 'barsBeatsSixteenths',\n\t /**\n\t\t\t * Sampling is the reduction of a continuous signal to a discrete signal.\n\t\t\t * Audio is typically sampled 44100 times per second.\n\t\t\t * @typedef {Samples}\n\t\t\t */\n\t Samples: 'samples',\n\t /**\n\t\t\t * Hertz are a frequency representation defined as one cycle per second.\n\t\t\t * @typedef {Hertz}\n\t\t\t */\n\t Hertz: 'hertz',\n\t /**\n\t\t\t * A frequency represented by a letter name,\n\t\t\t * accidental and octave. This system is known as\n\t\t\t * [Scientific Pitch Notation](https://en.wikipedia.org/wiki/Scientific_pitch_notation).\n\t\t\t * @typedef {Note}\n\t\t\t */\n\t Note: 'note',\n\t /**\n\t\t\t * One millisecond is a thousandth of a second.\n\t\t\t * @typedef {Milliseconds}\n\t\t\t */\n\t Milliseconds: 'milliseconds',\n\t /**\n\t\t\t * Seconds are the time unit of the AudioContext. In the end,\n\t\t\t * all values need to be evaluated to seconds.\n\t\t\t * @typedef {Seconds}\n\t\t\t */\n\t Seconds: 'seconds',\n\t /**\n\t\t\t * A string representing a duration relative to a measure.\n\t\t\t * * \"4n\" = quarter note\n\t\t\t * * \"2m\" = two measures\n\t\t\t * * \"8t\" = eighth-note triplet\n\t\t\t * @typedef {Notation}\n\t\t\t */\n\t Notation: 'notation'\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t // AUGMENT TONE's PROTOTYPE\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Convert Time into seconds.\n\t\t *\n\t\t * Unlike the method which it overrides, this takes into account\n\t\t * transporttime and musical notation.\n\t\t *\n\t\t * Time : 1.40\n\t\t * Notation: 4n or 1m or 2t\n\t\t * Now Relative: +3n\n\t\t * Math: 3n+16n or even complicated expressions ((3n*2)/6 + 1)\n\t\t *\n\t\t * @param {Time} time\n\t\t * @return {Seconds}\n\t\t */\n\t Tone.prototype.toSeconds = function (time) {\n\t if (Tone.isNumber(time)) {\n\t return time;\n\t } else if (Tone.isUndef(time)) {\n\t return this.now();\n\t } else if (Tone.isString(time)) {\n\t return new Tone.Time(time).toSeconds();\n\t } else if (time instanceof Tone.TimeBase) {\n\t return time.toSeconds();\n\t }\n\t };\n\t /**\n\t\t * Convert a frequency representation into a number.\n\t\t * @param {Frequency} freq\n\t\t * @return {Hertz} the frequency in hertz\n\t\t */\n\t Tone.prototype.toFrequency = function (freq) {\n\t if (Tone.isNumber(freq)) {\n\t return freq;\n\t } else if (Tone.isString(freq) || Tone.isUndef(freq)) {\n\t return new Tone.Frequency(freq).valueOf();\n\t } else if (freq instanceof Tone.TimeBase) {\n\t return freq.toFrequency();\n\t }\n\t };\n\t /**\n\t\t * Convert a time representation into ticks.\n\t\t * @param {Time} time\n\t\t * @return {Ticks} the time in ticks\n\t\t */\n\t Tone.prototype.toTicks = function (time) {\n\t if (Tone.isNumber(time) || Tone.isString(time)) {\n\t return new Tone.TransportTime(time).toTicks();\n\t } else if (Tone.isUndef(time)) {\n\t return Tone.Transport.ticks;\n\t } else if (time instanceof Tone.TimeBase) {\n\t return time.toTicks();\n\t }\n\t };\n\t return Tone;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Param wraps the native Web Audio's AudioParam to provide\n\t\t * additional unit conversion functionality. It also\n\t\t * serves as a base-class for classes which have a single,\n\t\t * automatable parameter.\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {AudioParam} param The parameter to wrap.\n\t\t * @param {Tone.Type} units The units of the audio param.\n\t\t * @param {Boolean} convert If the param should be converted.\n\t\t */\n\t Tone.Param = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'param',\n\t 'units',\n\t 'convert'\n\t ], Tone.Param);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The native parameter to control\n\t\t\t * @type {AudioParam}\n\t\t\t * @private\n\t\t\t */\n\t this._param = this.input = options.param;\n\t /**\n\t\t\t * The units of the parameter\n\t\t\t * @type {Tone.Type}\n\t\t\t */\n\t this.units = options.units;\n\t /**\n\t\t\t * If the value should be converted or not\n\t\t\t * @type {Boolean}\n\t\t\t */\n\t this.convert = options.convert;\n\t /**\n\t\t\t * True if the signal value is being overridden by\n\t\t\t * a connected signal.\n\t\t\t * @readOnly\n\t\t\t * @type {boolean}\n\t\t\t * @private\n\t\t\t */\n\t this.overridden = false;\n\t /**\n\t\t\t * The timeline which tracks all of the automations.\n\t\t\t * @type {Tone.Timeline}\n\t\t\t * @private\n\t\t\t */\n\t this._events = new Tone.Timeline(1000);\n\t if (Tone.isDefined(options.value) && this._param) {\n\t this.value = options.value;\n\t }\n\t };\n\t Tone.extend(Tone.Param, Tone.AudioNode);\n\t /**\n\t\t * Defaults\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.Param.defaults = {\n\t 'units': Tone.Type.Default,\n\t 'convert': true,\n\t 'param': undefined\n\t };\n\t /**\n\t\t * The current value of the parameter.\n\t\t * @memberOf Tone.Param#\n\t\t * @type {Number}\n\t\t * @name value\n\t\t */\n\t Object.defineProperty(Tone.Param.prototype, 'value', {\n\t get: function () {\n\t var now = this.now();\n\t return this._toUnits(this.getValueAtTime(now));\n\t },\n\t set: function (value) {\n\t this._initialValue = this._fromUnits(value);\n\t this.cancelScheduledValues(this.context.currentTime);\n\t this.setValueAtTime(value, this.context.currentTime);\n\t }\n\t });\n\t /**\n\t\t * The minimum output value of the parameter\n\t\t * @memberOf Tone.Param#\n\t\t * @type {Number}\n\t\t * @name value\n\t\t */\n\t Object.defineProperty(Tone.Param.prototype, 'minValue', {\n\t get: function () {\n\t if (this.units === Tone.Type.Time || this.units === Tone.Type.Frequency || this.units === Tone.Type.NormalRange || this.units === Tone.Type.Positive || this.units === Tone.Type.BPM) {\n\t return 0;\n\t } else if (this.units === Tone.Type.AudioRange) {\n\t return -1;\n\t } else if (this.units === Tone.Type.Decibels) {\n\t return -Infinity;\n\t } else {\n\t return this._param.minValue;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The maximum output value of the parameter\n\t\t * @memberOf Tone.Param#\n\t\t * @type {Number}\n\t\t * @name value\n\t\t */\n\t Object.defineProperty(Tone.Param.prototype, 'maxValue', {\n\t get: function () {\n\t if (this.units === Tone.Type.NormalRange || this.units === Tone.Type.AudioRange) {\n\t return 1;\n\t } else {\n\t return this._param.maxValue;\n\t }\n\t }\n\t });\n\t /**\n\t\t * Convert the given value from the type specified by Tone.Param.units\n\t\t * into the destination value (such as Gain or Frequency).\n\t\t * @private\n\t\t * @param {*} val the value to convert\n\t\t * @return {number} the number which the value should be set to\n\t\t */\n\t Tone.Param.prototype._fromUnits = function (val) {\n\t if ((this.convert || Tone.isUndef(this.convert)) && !this.overridden) {\n\t switch (this.units) {\n\t case Tone.Type.Time:\n\t return this.toSeconds(val);\n\t case Tone.Type.Frequency:\n\t return this.toFrequency(val);\n\t case Tone.Type.Decibels:\n\t return Tone.dbToGain(val);\n\t case Tone.Type.NormalRange:\n\t return Math.min(Math.max(val, 0), 1);\n\t case Tone.Type.AudioRange:\n\t return Math.min(Math.max(val, -1), 1);\n\t case Tone.Type.Positive:\n\t return Math.max(val, 0);\n\t default:\n\t return val;\n\t }\n\t } else {\n\t return val;\n\t }\n\t };\n\t /**\n\t\t * Convert the parameters value into the units specified by Tone.Param.units.\n\t\t * @private\n\t\t * @param {number} val the value to convert\n\t\t * @return {number}\n\t\t */\n\t Tone.Param.prototype._toUnits = function (val) {\n\t if (this.convert || Tone.isUndef(this.convert)) {\n\t switch (this.units) {\n\t case Tone.Type.Decibels:\n\t return Tone.gainToDb(val);\n\t default:\n\t return val;\n\t }\n\t } else {\n\t return val;\n\t }\n\t };\n\t /**\n\t\t * the minimum output value\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t Tone.Param.prototype._minOutput = 0.00001;\n\t /**\n\t\t * The event types\n\t\t * @enum {String}\n\t\t * @private\n\t\t */\n\t Tone.Param.AutomationType = {\n\t Linear: 'linearRampToValueAtTime',\n\t Exponential: 'exponentialRampToValueAtTime',\n\t Target: 'setTargetAtTime',\n\t SetValue: 'setValueAtTime'\n\t };\n\t /**\n\t\t * Schedules a parameter value change at the given time.\n\t\t * @param {*}\tvalue The value to set the signal.\n\t\t * @param {Time} time The time when the change should occur.\n\t\t * @returns {Tone.Param} this\n\t\t * @example\n\t\t * //set the frequency to \"G4\" in exactly 1 second from now.\n\t\t * freq.setValueAtTime(\"G4\", \"+1\");\n\t\t */\n\t Tone.Param.prototype.setValueAtTime = function (value, time) {\n\t time = this.toSeconds(time);\n\t value = this._fromUnits(value);\n\t this._events.add({\n\t 'type': Tone.Param.AutomationType.SetValue,\n\t 'value': value,\n\t 'time': time\n\t });\n\t this._param.setValueAtTime(value, time);\n\t return this;\n\t };\n\t /**\n\t\t * Get the signals value at the given time. Subsequent scheduling\n\t\t * may invalidate the returned value.\n\t\t * @param {Time} time When to get the value\n\t\t * @returns {Number} The value at the given time\n\t\t */\n\t Tone.Param.prototype.getValueAtTime = function (time) {\n\t time = this.toSeconds(time);\n\t var after = this._events.getAfter(time);\n\t var before = this._events.get(time);\n\t var initialValue = Tone.defaultArg(this._initialValue, this._param.defaultValue);\n\t var value = initialValue;\n\t //if it was set by\n\t if (before === null) {\n\t value = initialValue;\n\t } else if (before.type === Tone.Param.AutomationType.Target) {\n\t var previous = this._events.getBefore(before.time);\n\t var previousVal;\n\t if (previous === null) {\n\t previousVal = initialValue;\n\t } else {\n\t previousVal = previous.value;\n\t }\n\t value = this._exponentialApproach(before.time, previousVal, before.value, before.constant, time);\n\t } else if (after === null) {\n\t value = before.value;\n\t } else if (after.type === Tone.Param.AutomationType.Linear) {\n\t value = this._linearInterpolate(before.time, before.value, after.time, after.value, time);\n\t } else if (after.type === Tone.Param.AutomationType.Exponential) {\n\t value = this._exponentialInterpolate(before.time, before.value, after.time, after.value, time);\n\t } else {\n\t value = before.value;\n\t }\n\t return value;\n\t };\n\t /**\n\t\t * Creates a schedule point with the current value at the current time.\n\t\t * This is useful for creating an automation anchor point in order to\n\t\t * schedule changes from the current value.\n\t\t *\n\t\t * @param {number=} now (Optionally) pass the now value in.\n\t\t * @returns {Tone.Param} this\n\t\t */\n\t Tone.Param.prototype.setRampPoint = function (time) {\n\t time = this.toSeconds(time);\n\t var currentVal = this.getValueAtTime(time);\n\t this.cancelAndHoldAtTime(time);\n\t if (currentVal === 0) {\n\t currentVal = this._minOutput;\n\t }\n\t this.setValueAtTime(this._toUnits(currentVal), time);\n\t return this;\n\t };\n\t /**\n\t\t * Schedules a linear continuous change in parameter value from the\n\t\t * previous scheduled parameter value to the given value.\n\t\t *\n\t\t * @param {number} value\n\t\t * @param {Time} endTime\n\t\t * @returns {Tone.Param} this\n\t\t */\n\t Tone.Param.prototype.linearRampToValueAtTime = function (value, endTime) {\n\t value = this._fromUnits(value);\n\t endTime = this.toSeconds(endTime);\n\t this._events.add({\n\t 'type': Tone.Param.AutomationType.Linear,\n\t 'value': value,\n\t 'time': endTime\n\t });\n\t this._param.linearRampToValueAtTime(value, endTime);\n\t return this;\n\t };\n\t /**\n\t\t * Schedules an exponential continuous change in parameter value from\n\t\t * the previous scheduled parameter value to the given value.\n\t\t *\n\t\t * @param {number} value\n\t\t * @param {Time} endTime\n\t\t * @returns {Tone.Param} this\n\t\t */\n\t Tone.Param.prototype.exponentialRampToValueAtTime = function (value, endTime) {\n\t value = this._fromUnits(value);\n\t value = Math.max(this._minOutput, value);\n\t endTime = this.toSeconds(endTime);\n\t //store the event\n\t this._events.add({\n\t 'type': Tone.Param.AutomationType.Exponential,\n\t 'time': endTime,\n\t 'value': value\n\t });\n\t this._param.exponentialRampToValueAtTime(value, endTime);\n\t return this;\n\t };\n\t /**\n\t\t * Schedules an exponential continuous change in parameter value from\n\t\t * the current time and current value to the given value over the\n\t\t * duration of the rampTime.\n\t\t *\n\t\t * @param {number} value The value to ramp to.\n\t\t * @param {Time} rampTime the time that it takes the\n\t\t * value to ramp from it's current value\n\t\t * @param {Time}\t[startTime=now] \tWhen the ramp should start.\n\t\t * @returns {Tone.Param} this\n\t\t * @example\n\t\t * //exponentially ramp to the value 2 over 4 seconds.\n\t\t * signal.exponentialRampTo(2, 4);\n\t\t */\n\t Tone.Param.prototype.exponentialRampTo = function (value, rampTime, startTime) {\n\t startTime = this.toSeconds(startTime);\n\t this.setRampPoint(startTime);\n\t this.exponentialRampToValueAtTime(value, startTime + this.toSeconds(rampTime));\n\t return this;\n\t };\n\t /**\n\t\t * Schedules an linear continuous change in parameter value from\n\t\t * the current time and current value to the given value over the\n\t\t * duration of the rampTime.\n\t\t *\n\t\t * @param {number} value The value to ramp to.\n\t\t * @param {Time} rampTime the time that it takes the\n\t\t * value to ramp from it's current value\n\t\t * @param {Time}\t[startTime=now] \tWhen the ramp should start.\n\t\t * @returns {Tone.Param} this\n\t\t * @example\n\t\t * //linearly ramp to the value 4 over 3 seconds.\n\t\t * signal.linearRampTo(4, 3);\n\t\t */\n\t Tone.Param.prototype.linearRampTo = function (value, rampTime, startTime) {\n\t startTime = this.toSeconds(startTime);\n\t this.setRampPoint(startTime);\n\t this.linearRampToValueAtTime(value, startTime + this.toSeconds(rampTime));\n\t return this;\n\t };\n\t /**\n\t\t * Start exponentially approaching the target value at the given time. Since it\n\t\t * is an exponential approach it will continue approaching after the ramp duration. The\n\t\t * rampTime is the time that it takes to reach over 99% of the way towards the value.\n\t\t * @param {number} value The value to ramp to.\n\t\t * @param {Time} rampTime the time that it takes the\n\t\t * value to ramp from it's current value\n\t\t * @param {Time}\t[startTime=now] \tWhen the ramp should start.\n\t\t * @returns {Tone.Param} this\n\t\t * @example\n\t\t * //exponentially ramp to the value 2 over 4 seconds.\n\t\t * signal.exponentialRampTo(2, 4);\n\t\t */\n\t Tone.Param.prototype.targetRampTo = function (value, rampTime, startTime) {\n\t startTime = this.toSeconds(startTime);\n\t this.setRampPoint(startTime);\n\t this.exponentialApproachValueAtTime(value, startTime, rampTime);\n\t return this;\n\t };\n\t /**\n\t\t * Start exponentially approaching the target value at the given time. Since it\n\t\t * is an exponential approach it will continue approaching after the ramp duration. The\n\t\t * rampTime is the time that it takes to reach over 99% of the way towards the value. This methods\n\t\t * is similar to setTargetAtTime except the third argument is a time instead of a 'timeConstant'\n\t\t * @param {number} value The value to ramp to.\n\t\t * @param {Time}\ttime \tWhen the ramp should start.\n\t\t * @param {Time} rampTime the time that it takes the\n\t\t * value to ramp from it's current value\n\t\t * @returns {Tone.Param} this\n\t\t * @example\n\t\t * //exponentially ramp to the value 2 over 4 seconds.\n\t\t * signal.exponentialRampTo(2, 4);\n\t\t */\n\t Tone.Param.prototype.exponentialApproachValueAtTime = function (value, time, rampTime) {\n\t var timeConstant = Math.log(this.toSeconds(rampTime) + 1) / Math.log(200);\n\t time = this.toSeconds(time);\n\t return this.setTargetAtTime(value, time, timeConstant);\n\t };\n\t /**\n\t\t * Start exponentially approaching the target value at the given time with\n\t\t * a rate having the given time constant.\n\t\t * @param {number} value\n\t\t * @param {Time} startTime\n\t\t * @param {number} timeConstant\n\t\t * @returns {Tone.Param} this\n\t\t */\n\t Tone.Param.prototype.setTargetAtTime = function (value, startTime, timeConstant) {\n\t value = this._fromUnits(value);\n\t // The value will never be able to approach without timeConstant > 0.\n\t if (timeConstant <= 0) {\n\t throw new Error('timeConstant must be greater than 0');\n\t }\n\t startTime = this.toSeconds(startTime);\n\t this._events.add({\n\t 'type': Tone.Param.AutomationType.Target,\n\t 'value': value,\n\t 'time': startTime,\n\t 'constant': timeConstant\n\t });\n\t this._param.setTargetAtTime(value, startTime, timeConstant);\n\t return this;\n\t };\n\t /**\n\t\t * Sets an array of arbitrary parameter values starting at the given time\n\t\t * for the given duration.\n\t\t *\n\t\t * @param {Array} values\n\t\t * @param {Time} startTime\n\t\t * @param {Time} duration\n\t\t * @param {NormalRange} [scaling=1] If the values in the curve should be scaled by some value\n\t\t * @returns {Tone.Param} this\n\t\t */\n\t Tone.Param.prototype.setValueCurveAtTime = function (values, startTime, duration, scaling) {\n\t scaling = Tone.defaultArg(scaling, 1);\n\t duration = this.toSeconds(duration);\n\t startTime = this.toSeconds(startTime);\n\t this.setValueAtTime(values[0] * scaling, startTime);\n\t var segTime = duration / (values.length - 1);\n\t for (var i = 1; i < values.length; i++) {\n\t this.linearRampToValueAtTime(values[i] * scaling, startTime + i * segTime);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Cancels all scheduled parameter changes with times greater than or\n\t\t * equal to startTime.\n\t\t *\n\t\t * @param {Time} time\n\t\t * @returns {Tone.Param} this\n\t\t */\n\t Tone.Param.prototype.cancelScheduledValues = function (time) {\n\t time = this.toSeconds(time);\n\t this._events.cancel(time);\n\t this._param.cancelScheduledValues(time);\n\t return this;\n\t };\n\t /**\n\t\t * This is similar to [cancelScheduledValues](#cancelScheduledValues) except\n\t\t * it holds the automated value at time until the next automated event.\n\t\t * @param {Time} time\n\t\t * @returns {Tone.Param} this\n\t\t */\n\t Tone.Param.prototype.cancelAndHoldAtTime = function (time) {\n\t var valueAtTime = this.getValueAtTime(time);\n\t //if there is an event at the given time\n\t //and that even is not a \"set\"\n\t var before = this._events.get(time);\n\t var after = this._events.getAfter(time);\n\t if (before && before.time === time) {\n\t //remove everything after\n\t if (after) {\n\t this._events.cancel(after.time);\n\t } else {\n\t this._events.cancel(time + 0.000001);\n\t }\n\t } else if (after) {\n\t //cancel the next event(s)\n\t this._events.cancel(after.time);\n\t if (!this._param.cancelAndHoldAtTime) {\n\t this._param.cancelScheduledValues(time);\n\t }\n\t if (after.type === Tone.Param.AutomationType.Linear) {\n\t if (!this._param.cancelAndHoldAtTime) {\n\t this.linearRampToValueAtTime(valueAtTime, time);\n\t } else {\n\t this._events.add({\n\t 'type': Tone.Param.AutomationType.Linear,\n\t 'value': valueAtTime,\n\t 'time': time\n\t });\n\t }\n\t } else if (after.type === Tone.Param.AutomationType.Exponential) {\n\t if (!this._param.cancelAndHoldAtTime) {\n\t this.exponentialRampToValueAtTime(valueAtTime, time);\n\t } else {\n\t this._events.add({\n\t 'type': Tone.Param.AutomationType.Exponential,\n\t 'value': valueAtTime,\n\t 'time': time\n\t });\n\t }\n\t }\n\t }\n\t //set the value at the given time\n\t this._events.add({\n\t 'type': Tone.Param.AutomationType.SetValue,\n\t 'value': valueAtTime,\n\t 'time': time\n\t });\n\t if (this._param.cancelAndHoldAtTime) {\n\t this._param.cancelAndHoldAtTime(time);\n\t } else {\n\t this._param.setValueAtTime(valueAtTime, time);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Ramps to the given value over the duration of the rampTime.\n\t\t * Automatically selects the best ramp type (exponential or linear)\n\t\t * depending on the `units` of the signal\n\t\t *\n\t\t * @param {number} value\n\t\t * @param {Time} rampTime \tThe time that it takes the\n\t\t * value to ramp from it's current value\n\t\t * @param {Time}\t[startTime=now] \tWhen the ramp should start.\n\t\t * @returns {Tone.Param} this\n\t\t * @example\n\t\t * //ramp to the value either linearly or exponentially\n\t\t * //depending on the \"units\" value of the signal\n\t\t * signal.rampTo(0, 10);\n\t\t * @example\n\t\t * //schedule it to ramp starting at a specific time\n\t\t * signal.rampTo(0, 10, 5)\n\t\t */\n\t Tone.Param.prototype.rampTo = function (value, rampTime, startTime) {\n\t rampTime = Tone.defaultArg(rampTime, 0.1);\n\t if (this.units === Tone.Type.Frequency || this.units === Tone.Type.BPM || this.units === Tone.Type.Decibels) {\n\t this.exponentialRampTo(value, rampTime, startTime);\n\t } else {\n\t this.linearRampTo(value, rampTime, startTime);\n\t }\n\t return this;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tAUTOMATION CURVE CALCULATIONS\n\t //\tMIT License, copyright (c) 2014 Jordan Santell\n\t ///////////////////////////////////////////////////////////////////////////\n\t // Calculates the the value along the curve produced by setTargetAtTime\n\t Tone.Param.prototype._exponentialApproach = function (t0, v0, v1, timeConstant, t) {\n\t return v1 + (v0 - v1) * Math.exp(-(t - t0) / timeConstant);\n\t };\n\t // Calculates the the value along the curve produced by linearRampToValueAtTime\n\t Tone.Param.prototype._linearInterpolate = function (t0, v0, t1, v1, t) {\n\t return v0 + (v1 - v0) * ((t - t0) / (t1 - t0));\n\t };\n\t // Calculates the the value along the curve produced by exponentialRampToValueAtTime\n\t Tone.Param.prototype._exponentialInterpolate = function (t0, v0, t1, v1, t) {\n\t return v0 * Math.pow(v1 / v0, (t - t0) / (t1 - t0));\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @returns {Tone.Param} this\n\t\t */\n\t Tone.Param.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._param = null;\n\t this._events = null;\n\t return this;\n\t };\n\t return Tone.Param;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Wrapper around the OfflineAudioContext\n\t\t * @extends {Tone.Context}\n\t\t * @param {Number} channels The number of channels to render\n\t\t * @param {Number} duration The duration to render in samples\n\t\t * @param {Number} sampleRate the sample rate to render at\n\t\t */\n\t Tone.OfflineContext = function (channels, duration, sampleRate) {\n\t /**\n\t\t\t * The offline context\n\t\t\t * @private\n\t\t\t * @type {OfflineAudioContext}\n\t\t\t */\n\t var offlineContext = new OfflineAudioContext(channels, duration * sampleRate, sampleRate);\n\t //wrap the methods/members\n\t Tone.Context.call(this, {\n\t 'context': offlineContext,\n\t 'clockSource': 'offline',\n\t 'lookAhead': 0,\n\t 'updateInterval': 128 / sampleRate\n\t });\n\t /**\n\t\t\t * A private reference to the duration\n\t\t\t * @private\n\t\t\t * @type {Number}\n\t\t\t */\n\t this._duration = duration;\n\t /**\n\t\t\t * An artificial clock source\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._currentTime = 0;\n\t };\n\t Tone.extend(Tone.OfflineContext, Tone.Context);\n\t /**\n\t\t * Override the now method to point to the internal clock time\n\t\t * @return {Number}\n\t\t */\n\t Tone.OfflineContext.prototype.now = function () {\n\t return this._currentTime;\n\t };\n\t /**\n\t\t * Render the output of the OfflineContext\n\t\t * @return {Promise}\n\t\t */\n\t Tone.OfflineContext.prototype.render = function () {\n\t while (this._duration - this._currentTime >= 0) {\n\t //invoke all the callbacks on that time\n\t this.emit('tick');\n\t //increment the clock\n\t this._currentTime += this.blockTime;\n\t }\n\t return this._context.startRendering();\n\t };\n\t /**\n\t\t * Close the context\n\t\t * @return {Promise}\n\t\t */\n\t Tone.OfflineContext.prototype.close = function () {\n\t this._context = null;\n\t return Promise.resolve();\n\t };\n\t return Tone.OfflineContext;\n\t});\n\tModule(function (Tone) {\n\t if (Tone.supported) {\n\t var ua = navigator.userAgent.toLowerCase();\n\t var isMobileSafari = ua.includes('safari') && !ua.includes('chrome') && ua.includes('mobile');\n\t if (isMobileSafari) {\n\t //mobile safari has a bizarre bug with the offline context\n\t //when a BufferSourceNode is started, it starts the offline context\n\t //\n\t //deferring all BufferSource starts till the last possible moment\n\t //reduces the likelihood of this happening\n\t Tone.OfflineContext.prototype.createBufferSource = function () {\n\t var bufferSource = this._context.createBufferSource();\n\t var _native_start = bufferSource.start;\n\t bufferSource.start = function (time) {\n\t this.setTimeout(function () {\n\t _native_start.call(bufferSource, time);\n\t }.bind(this), 0);\n\t }.bind(this);\n\t return bufferSource;\n\t };\n\t }\n\t }\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class A thin wrapper around the Native Web Audio GainNode.\n\t\t * The GainNode is a basic building block of the Web Audio\n\t\t * API and is useful for routing audio and adjusting gains.\n\t\t * @extends {Tone}\n\t\t * @param {Number=} gain The initial gain of the GainNode\n\t\t * @param {Tone.Type=} units The units of the gain parameter.\n\t\t */\n\t Tone.Gain = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'gain',\n\t 'units'\n\t ], Tone.Gain);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The GainNode\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this.input = this.output = this._gainNode = this.context.createGain();\n\t /**\n\t\t\t * The gain parameter of the gain node.\n\t\t\t * @type {Gain}\n\t\t\t * @signal\n\t\t\t */\n\t this.gain = new Tone.Param({\n\t 'param': this._gainNode.gain,\n\t 'units': options.units,\n\t 'value': options.gain,\n\t 'convert': options.convert\n\t });\n\t this._readOnly('gain');\n\t };\n\t Tone.extend(Tone.Gain, Tone.AudioNode);\n\t /**\n\t\t * The defaults\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Gain.defaults = {\n\t 'gain': 1,\n\t 'convert': true\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.Gain} this\n\t\t */\n\t Tone.Gain.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._gainNode.disconnect();\n\t this._gainNode = null;\n\t this._writable('gain');\n\t this.gain.dispose();\n\t this.gain = null;\n\t };\n\t return Tone.Gain;\n\t});\n\tModule(function (Tone) {\n\t if (Tone.supported && !AudioContext.prototype.createConstantSource) {\n\t var ConstantSourceNode = function (context) {\n\t this.context = context;\n\t var buffer = context.createBuffer(1, 128, context.sampleRate);\n\t var arr = buffer.getChannelData(0);\n\t for (var i = 0; i < arr.length; i++) {\n\t arr[i] = 1;\n\t }\n\t this._bufferSource = context.createBufferSource();\n\t this._bufferSource.channelCount = 1;\n\t this._bufferSource.channelCountMode = 'explicit';\n\t this._bufferSource.buffer = buffer;\n\t this._bufferSource.loop = true;\n\t var gainNode = this._output = context.createGain();\n\t this.offset = gainNode.gain;\n\t this._bufferSource.connect(gainNode);\n\t };\n\t ConstantSourceNode.prototype.start = function (time) {\n\t this._bufferSource.start(time);\n\t return this;\n\t };\n\t ConstantSourceNode.prototype.stop = function (time) {\n\t this._bufferSource.stop(time);\n\t return this;\n\t };\n\t ConstantSourceNode.prototype.connect = function () {\n\t this._output.connect.apply(this._output, arguments);\n\t return this;\n\t };\n\t ConstantSourceNode.prototype.disconnect = function () {\n\t this._output.disconnect.apply(this._output, arguments);\n\t return this;\n\t };\n\t AudioContext.prototype.createConstantSource = function () {\n\t return new ConstantSourceNode(this);\n\t };\n\t Tone.Context.prototype.createConstantSource = function () {\n\t return new ConstantSourceNode(this);\n\t };\n\t }\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class A signal is an audio-rate value. Tone.Signal is a core component of the library.\n\t\t * Unlike a number, Signals can be scheduled with sample-level accuracy. Tone.Signal\n\t\t * has all of the methods available to native Web Audio\n\t\t * [AudioParam](http://webaudio.github.io/web-audio-api/#the-audioparam-interface)\n\t\t * as well as additional conveniences. Read more about working with signals\n\t\t * [here](https://github.com/Tonejs/Tone.js/wiki/Signals).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Param}\n\t\t * @param {Number|AudioParam} [value] Initial value of the signal. If an AudioParam\n\t\t * is passed in, that parameter will be wrapped\n\t\t * and controlled by the Signal.\n\t\t * @param {string} [units=Number] unit The units the signal is in.\n\t\t * @example\n\t\t * var signal = new Tone.Signal(10);\n\t\t */\n\t Tone.Signal = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'value',\n\t 'units'\n\t ], Tone.Signal);\n\t Tone.Param.call(this, options);\n\t /**\n\t\t\t* When a signal is connected to another signal or audio param,\n\t\t\t* this signal becomes a proxy for it\n\t\t\t* @type {Array}\n\t\t\t* @private\n\t\t\t*/\n\t this._proxies = [];\n\t /**\n\t\t\t* Indicates if the constant source was started or not\n\t\t\t* @private\n\t\t\t* @type {Boolean}\n\t\t\t*/\n\t this._sourceStarted = false;\n\t /**\n\t\t\t * The constant source node which generates the signal\n\t\t\t * @type {ConstantSourceNode}\n\t\t\t * @private\n\t\t\t */\n\t this._constantSource = this.context.createConstantSource();\n\t this._param = this._constantSource.offset;\n\t this.value = options.value;\n\t /**\n\t\t\t * The node where the constant signal value is scaled.\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this.output = this._constantSource;\n\t /**\n\t\t\t * The node where the value is set.\n\t\t\t * @type {Tone.Param}\n\t\t\t * @private\n\t\t\t */\n\t this.input = this._param = this.output.offset;\n\t };\n\t Tone.extend(Tone.Signal, Tone.Param);\n\t /**\n\t\t * The default values\n\t\t * @type {Object}\n\t\t * @static\n\t\t * @const\n\t\t */\n\t Tone.Signal.defaults = {\n\t 'value': 0,\n\t 'units': Tone.Type.Default,\n\t 'convert': true\n\t };\n\t /**\n\t\t * When signals connect to other signals or AudioParams,\n\t\t * they take over the output value of that signal or AudioParam.\n\t\t * For all other nodes, the behavior is the same as a default <code>connect</code>.\n\t\t *\n\t\t * @override\n\t\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node\n\t\t * @param {number} [outputNumber=0] The output number to connect from.\n\t\t * @param {number} [inputNumber=0] The input number to connect to.\n\t\t * @returns {Tone.Signal} this\n\t\t * @method\n\t\t */\n\t Tone.Signal.prototype.connect = function (node) {\n\t //this is an optimization where this node will forward automations\n\t //to connected nodes without any signal if possible.\n\t if (this._isParam(node) && !this._sourceStarted) {\n\t this._proxies.push(node);\n\t node.overridden = true;\n\t this._applyAutomations(node);\n\t } else {\n\t Tone.SignalBase.prototype.connect.apply(this, arguments);\n\t if (!this._sourceStarted) {\n\t this._sourceStarted = true;\n\t this._constantSource.start(0);\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Takes a node as an argument and returns if it is a Param or AudioParam\n\t\t * @param {*} node The node to test\n\t\t * @return {Boolean}\n\t\t * @private\n\t\t */\n\t Tone.Signal.prototype._isParam = function (node) {\n\t return Tone.Param && Tone.Param === node.constructor || node instanceof AudioParam;\n\t };\n\t /**\n\t\t * Discard the optimization and connect all of the proxies\n\t\t * @private\n\t\t */\n\t Tone.Signal.prototype._connectProxies = function () {\n\t if (!this._sourceStarted) {\n\t this._sourceStarted = true;\n\t this._constantSource.start(0);\n\t }\n\t this._proxies.forEach(function (proxy) {\n\t Tone.SignalBase.prototype.connect.call(this, proxy);\n\t if (proxy._proxies) {\n\t proxy._connectProxies();\n\t }\n\t }.bind(this));\n\t };\n\t /**\n\t\t * Invoked when a node is connected to this\n\t\t * @param {AudioNode} from\n\t\t * @private\n\t\t */\n\t Tone.Signal.prototype._onConnect = function (from) {\n\t if (!this._isParam(from)) {\n\t //connect all the proxies\n\t this._connectProxies();\n\t }\n\t };\n\t /**\n\t\t * Apply all the current automations to the given parameter\n\t\t * @param {AudioParam} param\n\t\t * @private\n\t\t */\n\t Tone.Signal.prototype._applyAutomations = function (param) {\n\t var now = this.context.currentTime;\n\t param.cancelScheduledValues(now);\n\t var currentVal = this.getValueAtTime(now);\n\t param.setValueAtTime(currentVal, now);\n\t this._events.forEachFrom(now, function (event) {\n\t param[event.type](event.value, event.time, event.constant);\n\t });\n\t };\n\t /**\n\t\t * Disconnect from the given node or all nodes if no param is given.\n\t\t * @param {AudioNode|AudioParam} node\n\t\t * @return {Tone.Signal} this\n\t\t */\n\t Tone.Signal.prototype.disconnect = function (node) {\n\t if (this._proxies.includes(node)) {\n\t var index = this._proxies.indexOf(node);\n\t this._proxies.splice(index, 1);\n\t } else if (!node) {\n\t //no argument, disconnect everything\n\t this._proxies = [];\n\t }\n\t return Tone.SignalBase.prototype.disconnect.apply(this, arguments);\n\t };\n\t /**\n\t\t * Return the current signal value at the given time.\n\t\t * @param {Time} time When to get the signal value\n\t\t * @return {Number}\n\t\t */\n\t Tone.Signal.prototype.getValueAtTime = function (time) {\n\t if (this._param.getValueAtTime) {\n\t return this._param.getValueAtTime(time);\n\t } else {\n\t return Tone.Param.prototype.getValueAtTime.call(this, time);\n\t }\n\t };\n\t //wrap all of the automation methods\n\t [\n\t 'setValueAtTime',\n\t 'linearRampToValueAtTime',\n\t 'exponentialRampToValueAtTime',\n\t 'setTargetAtTime'\n\t ].forEach(function (method) {\n\t var previousMethod = Tone.Signal.prototype[method];\n\t Tone.Signal.prototype[method] = function () {\n\t var args = arguments;\n\t previousMethod.apply(this, arguments);\n\t args[0] = this._fromUnits(args[0]);\n\t args[1] = this.toSeconds(args[1]);\n\t //apply it to the proxies\n\t this._proxies.forEach(function (signal) {\n\t signal[method].apply(signal, args);\n\t });\n\t };\n\t });\n\t [\n\t 'cancelScheduledValues',\n\t 'cancelAndHoldAtTime'\n\t ].forEach(function (method) {\n\t var previousMethod = Tone.Signal.prototype[method];\n\t Tone.Signal.prototype[method] = function () {\n\t var args = arguments;\n\t previousMethod.apply(this, arguments);\n\t args[0] = this.toSeconds(args[0]);\n\t //apply it to the proxies\n\t this._proxies.forEach(function (signal) {\n\t signal[method].apply(signal, args);\n\t });\n\t };\n\t });\n\t /**\n\t\t * dispose and disconnect\n\t\t * @returns {Tone.Signal} this\n\t\t */\n\t Tone.Signal.prototype.dispose = function () {\n\t Tone.Param.prototype.dispose.call(this);\n\t this._constantSource.disconnect();\n\t this._constantSource = null;\n\t this._proxies = null;\n\t return this;\n\t };\n\t return Tone.Signal;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Pow applies an exponent to the incoming signal. The incoming signal\n\t\t * must be AudioRange.\n\t\t *\n\t\t * @extends {Tone.SignalBase}\n\t\t * @constructor\n\t\t * @param {Positive} exp The exponent to apply to the incoming signal, must be at least 2. \n\t\t * @example\n\t\t * var pow = new Tone.Pow(2);\n\t\t * var sig = new Tone.Signal(0.5).connect(pow);\n\t\t * //output of pow is 0.25. \n\t\t */\n\t Tone.Pow = function (exp) {\n\t Tone.SignalBase.call(this);\n\t /**\n\t\t\t * the exponent\n\t\t\t * @private\n\t\t\t * @type {number}\n\t\t\t */\n\t this._exp = Tone.defaultArg(exp, 1);\n\t /**\n\t\t\t * @type {WaveShaperNode}\n\t\t\t * @private\n\t\t\t */\n\t this._expScaler = this.input = this.output = new Tone.WaveShaper(this._expFunc(this._exp), 8192);\n\t };\n\t Tone.extend(Tone.Pow, Tone.SignalBase);\n\t /**\n\t\t * The value of the exponent.\n\t\t * @memberOf Tone.Pow#\n\t\t * @type {number}\n\t\t * @name value\n\t\t */\n\t Object.defineProperty(Tone.Pow.prototype, 'value', {\n\t get: function () {\n\t return this._exp;\n\t },\n\t set: function (exp) {\n\t this._exp = exp;\n\t this._expScaler.setMap(this._expFunc(this._exp));\n\t }\n\t });\n\t /**\n\t\t * the function which maps the waveshaper\n\t\t * @param {number} exp\n\t\t * @return {function}\n\t\t * @private\n\t\t */\n\t Tone.Pow.prototype._expFunc = function (exp) {\n\t return function (val) {\n\t return Math.pow(Math.abs(val), exp);\n\t };\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Pow} this\n\t\t */\n\t Tone.Pow.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._expScaler.dispose();\n\t this._expScaler = null;\n\t return this;\n\t };\n\t return Tone.Pow;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Envelope is an [ADSR](https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope)\n\t\t * envelope generator. Tone.Envelope outputs a signal which\n\t\t * can be connected to an AudioParam or Tone.Signal.\n\t\t * <img src=\"https://upload.wikimedia.org/wikipedia/commons/e/ea/ADSR_parameter.svg\">\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {Time} [attack] The amount of time it takes for the envelope to go from\n\t\t * 0 to it's maximum value.\n\t\t * @param {Time} [decay]\tThe period of time after the attack that it takes for the envelope\n\t\t * \tto fall to the sustain value.\n\t\t * @param {NormalRange} [sustain]\tThe percent of the maximum value that the envelope rests at until\n\t\t * \tthe release is triggered.\n\t\t * @param {Time} [release]\tThe amount of time after the release is triggered it takes to reach 0.\n\t\t * @example\n\t\t * //an amplitude envelope\n\t\t * var gainNode = Tone.context.createGain();\n\t\t * var env = new Tone.Envelope({\n\t\t * \t\"attack\" : 0.1,\n\t\t * \t\"decay\" : 0.2,\n\t\t * \t\"sustain\" : 1,\n\t\t * \t\"release\" : 0.8,\n\t\t * });\n\t\t * env.connect(gainNode.gain);\n\t\t */\n\t Tone.Envelope = function () {\n\t //get all of the defaults\n\t var options = Tone.defaults(arguments, [\n\t 'attack',\n\t 'decay',\n\t 'sustain',\n\t 'release'\n\t ], Tone.Envelope);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * When triggerAttack is called, the attack time is the amount of\n\t\t\t * time it takes for the envelope to reach it's maximum value.\n\t\t\t * @type {Time}\n\t\t\t */\n\t this.attack = options.attack;\n\t /**\n\t\t\t * After the attack portion of the envelope, the value will fall\n\t\t\t * over the duration of the decay time to it's sustain value.\n\t\t\t * @type {Time}\n\t\t\t */\n\t this.decay = options.decay;\n\t /**\n\t\t\t * \tThe sustain value is the value\n\t\t\t * \twhich the envelope rests at after triggerAttack is\n\t\t\t * \tcalled, but before triggerRelease is invoked.\n\t\t\t * @type {NormalRange}\n\t\t\t */\n\t this.sustain = options.sustain;\n\t /**\n\t\t\t * After triggerRelease is called, the envelope's\n\t\t\t * value will fall to it's miminum value over the\n\t\t\t * duration of the release time.\n\t\t\t * @type {Time}\n\t\t\t */\n\t this.release = options.release;\n\t /**\n\t\t\t * the next time the envelope is at standby\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._attackCurve = 'linear';\n\t /**\n\t\t\t * the next time the envelope is at standby\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._releaseCurve = 'exponential';\n\t /**\n\t\t\t * the signal\n\t\t\t * @type {Tone.Signal}\n\t\t\t * @private\n\t\t\t */\n\t this._sig = this.output = new Tone.Signal(0);\n\t //set the attackCurve initially\n\t this.attackCurve = options.attackCurve;\n\t this.releaseCurve = options.releaseCurve;\n\t };\n\t Tone.extend(Tone.Envelope, Tone.AudioNode);\n\t /**\n\t\t * the default parameters\n\t\t * @static\n\t\t * @const\n\t\t */\n\t Tone.Envelope.defaults = {\n\t 'attack': 0.01,\n\t 'decay': 0.1,\n\t 'sustain': 0.5,\n\t 'release': 1,\n\t 'attackCurve': 'linear',\n\t 'releaseCurve': 'exponential'\n\t };\n\t /**\n\t\t * Read the current value of the envelope. Useful for\n\t\t * syncronizing visual output to the envelope.\n\t\t * @memberOf Tone.Envelope#\n\t\t * @type {Number}\n\t\t * @name value\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Envelope.prototype, 'value', {\n\t get: function () {\n\t return this.getValueAtTime(this.now());\n\t }\n\t });\n\t /**\n\t\t * The shape of the attack.\n\t\t * Can be any of these strings:\n\t\t * <ul>\n\t\t * <li>linear</li>\n\t\t * <li>exponential</li>\n\t\t * <li>sine</li>\n\t\t * <li>cosine</li>\n\t\t * <li>bounce</li>\n\t\t * <li>ripple</li>\n\t\t * <li>step</li>\n\t\t * </ul>\n\t\t * Can also be an array which describes the curve. Values\n\t\t * in the array are evenly subdivided and linearly\n\t\t * interpolated over the duration of the attack.\n\t\t * @memberOf Tone.Envelope#\n\t\t * @type {String|Array}\n\t\t * @name attackCurve\n\t\t * @example\n\t\t * env.attackCurve = \"linear\";\n\t\t * @example\n\t\t * //can also be an array\n\t\t * env.attackCurve = [0, 0.2, 0.3, 0.4, 1]\n\t\t */\n\t Object.defineProperty(Tone.Envelope.prototype, 'attackCurve', {\n\t get: function () {\n\t if (Tone.isString(this._attackCurve)) {\n\t return this._attackCurve;\n\t } else if (Tone.isArray(this._attackCurve)) {\n\t //look up the name in the curves array\n\t for (var type in Tone.Envelope.Type) {\n\t if (Tone.Envelope.Type[type].In === this._attackCurve) {\n\t return type;\n\t }\n\t }\n\t //otherwise just return the array\n\t return this._attackCurve;\n\t }\n\t },\n\t set: function (curve) {\n\t //check if it's a valid type\n\t if (Tone.Envelope.Type.hasOwnProperty(curve)) {\n\t var curveDef = Tone.Envelope.Type[curve];\n\t if (Tone.isObject(curveDef)) {\n\t this._attackCurve = curveDef.In;\n\t } else {\n\t this._attackCurve = curveDef;\n\t }\n\t } else if (Tone.isArray(curve)) {\n\t this._attackCurve = curve;\n\t } else {\n\t throw new Error('Tone.Envelope: invalid curve: ' + curve);\n\t }\n\t }\n\t });\n\t /**\n\t\t * The shape of the release. See the attack curve types.\n\t\t * @memberOf Tone.Envelope#\n\t\t * @type {String|Array}\n\t\t * @name releaseCurve\n\t\t * @example\n\t\t * env.releaseCurve = \"linear\";\n\t\t */\n\t Object.defineProperty(Tone.Envelope.prototype, 'releaseCurve', {\n\t get: function () {\n\t if (Tone.isString(this._releaseCurve)) {\n\t return this._releaseCurve;\n\t } else if (Tone.isArray(this._releaseCurve)) {\n\t //look up the name in the curves array\n\t for (var type in Tone.Envelope.Type) {\n\t if (Tone.Envelope.Type[type].Out === this._releaseCurve) {\n\t return type;\n\t }\n\t }\n\t //otherwise just return the array\n\t return this._releaseCurve;\n\t }\n\t },\n\t set: function (curve) {\n\t //check if it's a valid type\n\t if (Tone.Envelope.Type.hasOwnProperty(curve)) {\n\t var curveDef = Tone.Envelope.Type[curve];\n\t if (Tone.isObject(curveDef)) {\n\t this._releaseCurve = curveDef.Out;\n\t } else {\n\t this._releaseCurve = curveDef;\n\t }\n\t } else if (Tone.isArray(curve)) {\n\t this._releaseCurve = curve;\n\t } else {\n\t throw new Error('Tone.Envelope: invalid curve: ' + curve);\n\t }\n\t }\n\t });\n\t /**\n\t\t * Trigger the attack/decay portion of the ADSR envelope.\n\t\t * @param {Time} [time=now] When the attack should start.\n\t\t * @param {NormalRange} [velocity=1] The velocity of the envelope scales the vales.\n\t\t * number between 0-1\n\t\t * @returns {Tone.Envelope} this\n\t\t * @example\n\t\t * //trigger the attack 0.5 seconds from now with a velocity of 0.2\n\t\t * env.triggerAttack(\"+0.5\", 0.2);\n\t\t */\n\t Tone.Envelope.prototype.triggerAttack = function (time, velocity) {\n\t time = this.toSeconds(time);\n\t var originalAttack = this.toSeconds(this.attack);\n\t var attack = originalAttack;\n\t var decay = this.toSeconds(this.decay);\n\t velocity = Tone.defaultArg(velocity, 1);\n\t //check if it's not a complete attack\n\t var currentValue = this.getValueAtTime(time);\n\t if (currentValue > 0) {\n\t //subtract the current value from the attack time\n\t var attackRate = 1 / attack;\n\t var remainingDistance = 1 - currentValue;\n\t //the attack is now the remaining time\n\t attack = remainingDistance / attackRate;\n\t }\n\t //attack\n\t if (this._attackCurve === 'linear') {\n\t this._sig.linearRampTo(velocity, attack, time);\n\t } else if (this._attackCurve === 'exponential') {\n\t this._sig.targetRampTo(velocity, attack, time);\n\t } else if (attack > 0) {\n\t this._sig.cancelAndHoldAtTime(time);\n\t var curve = this._attackCurve;\n\t //take only a portion of the curve\n\t if (attack < originalAttack) {\n\t var percentComplete = 1 - attack / originalAttack;\n\t var sliceIndex = Math.floor(percentComplete * this._attackCurve.length);\n\t curve = this._attackCurve.slice(sliceIndex);\n\t //the first index is the current value\n\t curve[0] = currentValue;\n\t }\n\t this._sig.setValueCurveAtTime(curve, time, attack, velocity);\n\t }\n\t //decay\n\t if (decay) {\n\t this._sig.targetRampTo(velocity * this.sustain, decay, attack + time);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Triggers the release of the envelope.\n\t\t * @param {Time} [time=now] When the release portion of the envelope should start.\n\t\t * @returns {Tone.Envelope} this\n\t\t * @example\n\t\t * //trigger release immediately\n\t\t * env.triggerRelease();\n\t\t */\n\t Tone.Envelope.prototype.triggerRelease = function (time) {\n\t time = this.toSeconds(time);\n\t var currentValue = this.getValueAtTime(time);\n\t if (currentValue > 0) {\n\t var release = this.toSeconds(this.release);\n\t if (this._releaseCurve === 'linear') {\n\t this._sig.linearRampTo(0, release, time);\n\t } else if (this._releaseCurve === 'exponential') {\n\t this._sig.targetRampTo(0, release, time);\n\t } else {\n\t var curve = this._releaseCurve;\n\t if (Tone.isArray(curve)) {\n\t this._sig.cancelAndHoldAtTime(time);\n\t this._sig.setValueCurveAtTime(curve, time, release, currentValue);\n\t }\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Get the scheduled value at the given time. This will\n\t\t * return the unconverted (raw) value.\n\t\t * @param {Number} time The time in seconds.\n\t\t * @return {Number} The scheduled value at the given time.\n\t\t */\n\t Tone.Envelope.prototype.getValueAtTime = function (time) {\n\t return this._sig.getValueAtTime(time);\n\t };\n\t /**\n\t\t * triggerAttackRelease is shorthand for triggerAttack, then waiting\n\t\t * some duration, then triggerRelease.\n\t\t * @param {Time} duration The duration of the sustain.\n\t\t * @param {Time} [time=now] When the attack should be triggered.\n\t\t * @param {number} [velocity=1] The velocity of the envelope.\n\t\t * @returns {Tone.Envelope} this\n\t\t * @example\n\t\t * //trigger the attack and then the release after 0.6 seconds.\n\t\t * env.triggerAttackRelease(0.6);\n\t\t */\n\t Tone.Envelope.prototype.triggerAttackRelease = function (duration, time, velocity) {\n\t time = this.toSeconds(time);\n\t this.triggerAttack(time, velocity);\n\t this.triggerRelease(time + this.toSeconds(duration));\n\t return this;\n\t };\n\t /**\n\t\t * Cancels all scheduled envelope changes after the given time.\n\t\t * @param {Time} after\n\t\t * @returns {Tone.Envelope} this\n\t\t */\n\t Tone.Envelope.prototype.cancel = function (after) {\n\t this._sig.cancelScheduledValues(after);\n\t return this;\n\t };\n\t /**\n\t\t * Borrows the connect method from Tone.Signal.\n\t\t * @function\n\t\t * @private\n\t\t */\n\t Tone.Envelope.prototype.connect = Tone.SignalBase.prototype.connect;\n\t /**\n\t \t * Generate some complex envelope curves.\n\t \t */\n\t (function _createCurves() {\n\t var curveLen = 128;\n\t var i, k;\n\t //cosine curve\n\t var cosineCurve = [];\n\t for (i = 0; i < curveLen; i++) {\n\t cosineCurve[i] = Math.sin(i / (curveLen - 1) * (Math.PI / 2));\n\t }\n\t //ripple curve\n\t var rippleCurve = [];\n\t var rippleCurveFreq = 6.4;\n\t for (i = 0; i < curveLen - 1; i++) {\n\t k = i / (curveLen - 1);\n\t var sineWave = Math.sin(k * (Math.PI * 2) * rippleCurveFreq - Math.PI / 2) + 1;\n\t rippleCurve[i] = sineWave / 10 + k * 0.83;\n\t }\n\t rippleCurve[curveLen - 1] = 1;\n\t //stairs curve\n\t var stairsCurve = [];\n\t var steps = 5;\n\t for (i = 0; i < curveLen; i++) {\n\t stairsCurve[i] = Math.ceil(i / (curveLen - 1) * steps) / steps;\n\t }\n\t //in-out easing curve\n\t var sineCurve = [];\n\t for (i = 0; i < curveLen; i++) {\n\t k = i / (curveLen - 1);\n\t sineCurve[i] = 0.5 * (1 - Math.cos(Math.PI * k));\n\t }\n\t //a bounce curve\n\t var bounceCurve = [];\n\t for (i = 0; i < curveLen; i++) {\n\t k = i / (curveLen - 1);\n\t var freq = Math.pow(k, 3) * 4 + 0.2;\n\t var val = Math.cos(freq * Math.PI * 2 * k);\n\t bounceCurve[i] = Math.abs(val * (1 - k));\n\t }\n\t /**\n\t\t\t * Invert a value curve to make it work for the release\n\t\t\t * @private\n\t\t\t */\n\t function invertCurve(curve) {\n\t var out = new Array(curve.length);\n\t for (var j = 0; j < curve.length; j++) {\n\t out[j] = 1 - curve[j];\n\t }\n\t return out;\n\t }\n\t /**\n\t\t\t * reverse the curve\n\t\t\t * @private\n\t\t\t */\n\t function reverseCurve(curve) {\n\t return curve.slice(0).reverse();\n\t }\n\t /**\n\t\t\t * attack and release curve arrays\n\t\t\t * @type {Object}\n\t\t\t * @private\n\t\t\t */\n\t Tone.Envelope.Type = {\n\t 'linear': 'linear',\n\t 'exponential': 'exponential',\n\t 'bounce': {\n\t In: invertCurve(bounceCurve),\n\t Out: bounceCurve\n\t },\n\t 'cosine': {\n\t In: cosineCurve,\n\t Out: reverseCurve(cosineCurve)\n\t },\n\t 'step': {\n\t In: stairsCurve,\n\t Out: invertCurve(stairsCurve)\n\t },\n\t 'ripple': {\n\t In: rippleCurve,\n\t Out: invertCurve(rippleCurve)\n\t },\n\t 'sine': {\n\t In: sineCurve,\n\t Out: invertCurve(sineCurve)\n\t }\n\t };\n\t }());\n\t /**\n\t\t * Disconnect and dispose.\n\t\t * @returns {Tone.Envelope} this\n\t\t */\n\t Tone.Envelope.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._sig.dispose();\n\t this._sig = null;\n\t this._attackCurve = null;\n\t this._releaseCurve = null;\n\t return this;\n\t };\n\t return Tone.Envelope;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.AmplitudeEnvelope is a Tone.Envelope connected to a gain node.\n\t\t * Unlike Tone.Envelope, which outputs the envelope's value, Tone.AmplitudeEnvelope accepts\n\t\t * an audio signal as the input and will apply the envelope to the amplitude\n\t\t * of the signal. Read more about ADSR Envelopes on [Wikipedia](https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Envelope}\n\t\t * @param {Time|Object} [attack] The amount of time it takes for the envelope to go from\n\t\t * 0 to it's maximum value.\n\t\t * @param {Time} [decay]\tThe period of time after the attack that it takes for the envelope\n\t\t * \tto fall to the sustain value.\n\t\t * @param {NormalRange} [sustain]\tThe percent of the maximum value that the envelope rests at until\n\t\t * \tthe release is triggered.\n\t\t * @param {Time} [release]\tThe amount of time after the release is triggered it takes to reach 0.\n\t\t * @example\n\t\t * var ampEnv = new Tone.AmplitudeEnvelope({\n\t\t * \t\"attack\": 0.1,\n\t\t * \t\"decay\": 0.2,\n\t\t * \t\"sustain\": 1.0,\n\t\t * \t\"release\": 0.8\n\t\t * }).toMaster();\n\t\t * //create an oscillator and connect it\n\t\t * var osc = new Tone.Oscillator().connect(ampEnv).start();\n\t\t * //trigger the envelopes attack and release \"8t\" apart\n\t\t * ampEnv.triggerAttackRelease(\"8t\");\n\t\t */\n\t Tone.AmplitudeEnvelope = function () {\n\t Tone.Envelope.apply(this, arguments);\n\t /**\n\t\t\t * the input node\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this.input = this.output = new Tone.Gain();\n\t this._sig.connect(this.output.gain);\n\t };\n\t Tone.extend(Tone.AmplitudeEnvelope, Tone.Envelope);\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.AmplitudeEnvelope} this\n\t\t */\n\t Tone.AmplitudeEnvelope.prototype.dispose = function () {\n\t Tone.Envelope.prototype.dispose.call(this);\n\t return this;\n\t };\n\t return Tone.AmplitudeEnvelope;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * AnalyserNode.getFloatTimeDomainData polyfill\n\t\t * @private\n\t\t */\n\t if (Tone.supported) {\n\t if (!AnalyserNode.prototype.getFloatTimeDomainData) {\n\t //referenced https://github.com/mohayonao/get-float-time-domain-data\n\t AnalyserNode.prototype.getFloatTimeDomainData = function (array) {\n\t var uint8 = new Uint8Array(array.length);\n\t this.getByteTimeDomainData(uint8);\n\t for (var i = 0; i < uint8.length; i++) {\n\t array[i] = (uint8[i] - 128) / 128;\n\t }\n\t };\n\t }\n\t }\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Wrapper around the native Web Audio's\n\t\t * [AnalyserNode](http://webaudio.github.io/web-audio-api/#idl-def-AnalyserNode).\n\t\t * Extracts FFT or Waveform data from the incoming signal.\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {String=} type The return type of the analysis, either \"fft\", or \"waveform\".\n\t\t * @param {Number=} size The size of the FFT. Value must be a power of\n\t\t * two in the range 32 to 32768.\n\t\t */\n\t Tone.Analyser = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'type',\n\t 'size'\n\t ], Tone.Analyser);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The analyser node.\n\t\t\t * @private\n\t\t\t * @type {AnalyserNode}\n\t\t\t */\n\t this._analyser = this.input = this.output = this.context.createAnalyser();\n\t /**\n\t\t\t * The analysis type\n\t\t\t * @type {String}\n\t\t\t * @private\n\t\t\t */\n\t this._type = options.type;\n\t /**\n\t\t\t * The buffer that the FFT data is written to\n\t\t\t * @type {TypedArray}\n\t\t\t * @private\n\t\t\t */\n\t this._buffer = null;\n\t //set the values initially\n\t this.size = options.size;\n\t this.type = options.type;\n\t };\n\t Tone.extend(Tone.Analyser, Tone.AudioNode);\n\t /**\n\t\t * The default values.\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.Analyser.defaults = {\n\t 'size': 1024,\n\t 'type': 'fft',\n\t 'smoothing': 0.8\n\t };\n\t /**\n\t\t * Possible return types of analyser.getValue()\n\t\t * @enum {String}\n\t\t */\n\t Tone.Analyser.Type = {\n\t Waveform: 'waveform',\n\t FFT: 'fft'\n\t };\n\t /**\n\t\t * Run the analysis given the current settings and return the\n\t\t * result as a TypedArray.\n\t\t * @returns {TypedArray}\n\t\t */\n\t Tone.Analyser.prototype.getValue = function () {\n\t if (this._type === Tone.Analyser.Type.FFT) {\n\t this._analyser.getFloatFrequencyData(this._buffer);\n\t } else if (this._type === Tone.Analyser.Type.Waveform) {\n\t this._analyser.getFloatTimeDomainData(this._buffer);\n\t }\n\t return this._buffer;\n\t };\n\t /**\n\t\t * The size of analysis. This must be a power of two in the range 32 to 32768.\n\t\t * @memberOf Tone.Analyser#\n\t\t * @type {Number}\n\t\t * @name size\n\t\t */\n\t Object.defineProperty(Tone.Analyser.prototype, 'size', {\n\t get: function () {\n\t return this._analyser.frequencyBinCount;\n\t },\n\t set: function (size) {\n\t this._analyser.fftSize = size * 2;\n\t this._buffer = new Float32Array(size);\n\t }\n\t });\n\t /**\n\t\t * The analysis function returned by analyser.getValue(), either \"fft\" or \"waveform\".\n\t\t * @memberOf Tone.Analyser#\n\t\t * @type {String}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.Analyser.prototype, 'type', {\n\t get: function () {\n\t return this._type;\n\t },\n\t set: function (type) {\n\t if (type !== Tone.Analyser.Type.Waveform && type !== Tone.Analyser.Type.FFT) {\n\t throw new TypeError('Tone.Analyser: invalid type: ' + type);\n\t }\n\t this._type = type;\n\t }\n\t });\n\t /**\n\t\t * 0 represents no time averaging with the last analysis frame.\n\t\t * @memberOf Tone.Analyser#\n\t\t * @type {NormalRange}\n\t\t * @name smoothing\n\t\t */\n\t Object.defineProperty(Tone.Analyser.prototype, 'smoothing', {\n\t get: function () {\n\t return this._analyser.smoothingTimeConstant;\n\t },\n\t set: function (val) {\n\t this._analyser.smoothingTimeConstant = val;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.Analyser} this\n\t\t */\n\t Tone.Analyser.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._analyser.disconnect();\n\t this._analyser = null;\n\t this._buffer = null;\n\t };\n\t return Tone.Analyser;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Compressor is a thin wrapper around the Web Audio\n\t\t * [DynamicsCompressorNode](http://webaudio.github.io/web-audio-api/#the-dynamicscompressornode-interface).\n\t\t * Compression reduces the volume of loud sounds or amplifies quiet sounds\n\t\t * by narrowing or \"compressing\" an audio signal's dynamic range.\n\t\t * Read more on [Wikipedia](https://en.wikipedia.org/wiki/Dynamic_range_compression).\n\t\t *\n\t\t * @extends {Tone.AudioNode}\n\t\t * @constructor\n\t\t * @param {Decibels|Object} [threshold] The value above which the compression starts to be applied.\n\t\t * @param {Positive} [ratio] The gain reduction ratio.\n\t\t * @example\n\t\t * var comp = new Tone.Compressor(-30, 3);\n\t\t */\n\t Tone.Compressor = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'threshold',\n\t 'ratio'\n\t ], Tone.Compressor);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * the compressor node\n\t\t\t * @type {DynamicsCompressorNode}\n\t\t\t * @private\n\t\t\t */\n\t this._compressor = this.input = this.output = this.context.createDynamicsCompressor();\n\t /**\n\t\t\t * the threshold vaue\n\t\t\t * @type {Decibels}\n\t\t\t * @signal\n\t\t\t */\n\t this.threshold = new Tone.Param({\n\t 'param': this._compressor.threshold,\n\t 'units': Tone.Type.Decibels,\n\t 'convert': false\n\t });\n\t /**\n\t\t\t * The attack parameter\n\t\t\t * @type {Time}\n\t\t\t * @signal\n\t\t\t */\n\t this.attack = new Tone.Param(this._compressor.attack, Tone.Type.Time);\n\t /**\n\t\t\t * The release parameter\n\t\t\t * @type {Time}\n\t\t\t * @signal\n\t\t\t */\n\t this.release = new Tone.Param(this._compressor.release, Tone.Type.Time);\n\t /**\n\t\t\t * The knee parameter\n\t\t\t * @type {Decibels}\n\t\t\t * @signal\n\t\t\t */\n\t this.knee = new Tone.Param({\n\t 'param': this._compressor.knee,\n\t 'units': Tone.Type.Decibels,\n\t 'convert': false\n\t });\n\t /**\n\t\t\t * The ratio value\n\t\t\t * @type {Number}\n\t\t\t * @signal\n\t\t\t */\n\t this.ratio = new Tone.Param({\n\t 'param': this._compressor.ratio,\n\t 'convert': false\n\t });\n\t //set the defaults\n\t this._readOnly([\n\t 'knee',\n\t 'release',\n\t 'attack',\n\t 'ratio',\n\t 'threshold'\n\t ]);\n\t this.set(options);\n\t };\n\t Tone.extend(Tone.Compressor, Tone.AudioNode);\n\t /**\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Compressor.defaults = {\n\t 'ratio': 12,\n\t 'threshold': -24,\n\t 'release': 0.25,\n\t 'attack': 0.003,\n\t 'knee': 30\n\t };\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.Compressor} this\n\t\t */\n\t Tone.Compressor.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._writable([\n\t 'knee',\n\t 'release',\n\t 'attack',\n\t 'ratio',\n\t 'threshold'\n\t ]);\n\t this._compressor.disconnect();\n\t this._compressor = null;\n\t this.attack.dispose();\n\t this.attack = null;\n\t this.release.dispose();\n\t this.release = null;\n\t this.threshold.dispose();\n\t this.threshold = null;\n\t this.ratio.dispose();\n\t this.ratio = null;\n\t this.knee.dispose();\n\t this.knee = null;\n\t return this;\n\t };\n\t return Tone.Compressor;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Add a signal and a number or two signals. When no value is\n\t\t * passed into the constructor, Tone.Add will sum <code>input[0]</code>\n\t\t * and <code>input[1]</code>. If a value is passed into the constructor, \n\t\t * the it will be added to the input.\n\t\t * \n\t\t * @constructor\n\t\t * @extends {Tone.Signal}\n\t\t * @param {number=} value If no value is provided, Tone.Add will sum the first\n\t\t * and second inputs. \n\t\t * @example\n\t\t * var signal = new Tone.Signal(2);\n\t\t * var add = new Tone.Add(2);\n\t\t * signal.connect(add);\n\t\t * //the output of add equals 4\n\t\t * @example\n\t\t * //if constructed with no arguments\n\t\t * //it will add the first and second inputs\n\t\t * var add = new Tone.Add();\n\t\t * var sig0 = new Tone.Signal(3).connect(add, 0, 0);\n\t\t * var sig1 = new Tone.Signal(4).connect(add, 0, 1);\n\t\t * //the output of add equals 7. \n\t\t */\n\t Tone.Add = function (value) {\n\t Tone.Signal.call(this);\n\t this.createInsOuts(2, 0);\n\t /**\n\t\t\t * the summing node\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this._sum = this.input[0] = this.input[1] = this.output = new Tone.Gain();\n\t /**\n\t\t\t * @private\n\t\t\t * @type {Tone.Signal}\n\t\t\t */\n\t this._param = this.input[1] = new Tone.Signal(value);\n\t this._param.connect(this._sum);\n\t };\n\t Tone.extend(Tone.Add, Tone.Signal);\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Add} this\n\t\t */\n\t Tone.Add.prototype.dispose = function () {\n\t Tone.Signal.prototype.dispose.call(this);\n\t this._sum.dispose();\n\t this._sum = null;\n\t return this;\n\t };\n\t return Tone.Add;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Multiply two incoming signals. Or, if a number is given in the constructor,\n\t\t * multiplies the incoming signal by that value.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Signal}\n\t\t * @param {number=} value Constant value to multiple. If no value is provided,\n\t\t * it will return the product of the first and second inputs\n\t\t * @example\n\t\t * var mult = new Tone.Multiply();\n\t\t * var sigA = new Tone.Signal(3);\n\t\t * var sigB = new Tone.Signal(4);\n\t\t * sigA.connect(mult, 0, 0);\n\t\t * sigB.connect(mult, 0, 1);\n\t\t * //output of mult is 12.\n\t\t * @example\n\t\t * var mult = new Tone.Multiply(10);\n\t\t * var sig = new Tone.Signal(2).connect(mult);\n\t\t * //the output of mult is 20.\n\t\t */\n\t Tone.Multiply = function (value) {\n\t Tone.Signal.call(this);\n\t this.createInsOuts(2, 0);\n\t /**\n\t\t\t * the input node is the same as the output node\n\t\t\t * it is also the GainNode which handles the scaling of incoming signal\n\t\t\t *\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this._mult = this.input[0] = this.output = new Tone.Gain();\n\t /**\n\t\t\t * the scaling parameter\n\t\t\t * @type {AudioParam}\n\t\t\t * @private\n\t\t\t */\n\t this._param = this.input[1] = this.output.gain;\n\t this.value = Tone.defaultArg(value, 0);\n\t };\n\t Tone.extend(Tone.Multiply, Tone.Signal);\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.Multiply} this\n\t\t */\n\t Tone.Multiply.prototype.dispose = function () {\n\t Tone.Signal.prototype.dispose.call(this);\n\t this._mult.dispose();\n\t this._mult = null;\n\t this._param = null;\n\t return this;\n\t };\n\t return Tone.Multiply;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Negate the incoming signal. i.e. an input signal of 10 will output -10\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.SignalBase}\n\t\t * @example\n\t\t * var neg = new Tone.Negate();\n\t\t * var sig = new Tone.Signal(-2).connect(neg);\n\t\t * //output of neg is positive 2. \n\t\t */\n\t Tone.Negate = function () {\n\t Tone.SignalBase.call(this);\n\t /**\n\t\t\t * negation is done by multiplying by -1\n\t\t\t * @type {Tone.Multiply}\n\t\t\t * @private\n\t\t\t */\n\t this._multiply = this.input = this.output = new Tone.Multiply(-1);\n\t };\n\t Tone.extend(Tone.Negate, Tone.SignalBase);\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.Negate} this\n\t\t */\n\t Tone.Negate.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._multiply.dispose();\n\t this._multiply = null;\n\t return this;\n\t };\n\t return Tone.Negate;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Subtract the signal connected to <code>input[1]</code> from the signal connected \n\t\t * to <code>input[0]</code>. If an argument is provided in the constructor, the \n\t\t * signals <code>.value</code> will be subtracted from the incoming signal.\n\t\t *\n\t\t * @extends {Tone.Signal}\n\t\t * @constructor\n\t\t * @param {number=} value The value to subtract from the incoming signal. If the value\n\t\t * is omitted, it will subtract the second signal from the first.\n\t\t * @example\n\t\t * var sub = new Tone.Subtract(1);\n\t\t * var sig = new Tone.Signal(4).connect(sub);\n\t\t * //the output of sub is 3. \n\t\t * @example\n\t\t * var sub = new Tone.Subtract();\n\t\t * var sigA = new Tone.Signal(10);\n\t\t * var sigB = new Tone.Signal(2.5);\n\t\t * sigA.connect(sub, 0, 0);\n\t\t * sigB.connect(sub, 0, 1);\n\t\t * //output of sub is 7.5\n\t\t */\n\t Tone.Subtract = function (value) {\n\t Tone.Signal.call(this);\n\t this.createInsOuts(2, 0);\n\t /**\n\t\t\t * the summing node\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this._sum = this.input[0] = this.output = new Tone.Gain();\n\t /**\n\t\t\t * negate the input of the second input before connecting it\n\t\t\t * to the summing node.\n\t\t\t * @type {Tone.Negate}\n\t\t\t * @private\n\t\t\t */\n\t this._neg = new Tone.Negate();\n\t /**\n\t\t\t * the node where the value is set\n\t\t\t * @private\n\t\t\t * @type {Tone.Signal}\n\t\t\t */\n\t this._param = this.input[1] = new Tone.Signal(value);\n\t this._param.chain(this._neg, this._sum);\n\t };\n\t Tone.extend(Tone.Subtract, Tone.Signal);\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.SignalBase} this\n\t\t */\n\t Tone.Subtract.prototype.dispose = function () {\n\t Tone.Signal.prototype.dispose.call(this);\n\t this._neg.dispose();\n\t this._neg = null;\n\t this._sum.disconnect();\n\t this._sum = null;\n\t return this;\n\t };\n\t return Tone.Subtract;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Convert an incoming signal between 0, 1 to an equal power gain scale.\n\t\t *\n\t\t * @extends {Tone.SignalBase}\n\t\t * @constructor\n\t\t * @example\n\t\t * var eqPowGain = new Tone.EqualPowerGain();\n\t\t */\n\t Tone.EqualPowerGain = function () {\n\t Tone.SignalBase.call(this);\n\t /**\n\t\t\t * @type {Tone.WaveShaper}\n\t\t\t * @private\n\t\t\t */\n\t this._eqPower = this.input = this.output = new Tone.WaveShaper(function (val) {\n\t if (Math.abs(val) < 0.001) {\n\t //should output 0 when input is 0\n\t return 0;\n\t } else {\n\t return Tone.equalPowerScale(val);\n\t }\n\t }.bind(this), 4096);\n\t };\n\t Tone.extend(Tone.EqualPowerGain, Tone.SignalBase);\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.EqualPowerGain} this\n\t\t */\n\t Tone.EqualPowerGain.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._eqPower.dispose();\n\t this._eqPower = null;\n\t return this;\n\t };\n\t return Tone.EqualPowerGain;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Crossfade provides equal power fading between two inputs.\n\t\t * More on crossfading technique [here](https://en.wikipedia.org/wiki/Fade_(audio_engineering)#Crossfading).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {NormalRange} [initialFade=0.5]\n\t\t * @example\n\t\t * var crossFade = new Tone.CrossFade(0.5);\n\t\t * //connect effect A to crossfade from\n\t\t * //effect output 0 to crossfade input 0\n\t\t * effectA.connect(crossFade, 0, 0);\n\t\t * //connect effect B to crossfade from\n\t\t * //effect output 0 to crossfade input 1\n\t\t * effectB.connect(crossFade, 0, 1);\n\t\t * crossFade.fade.value = 0;\n\t\t * // ^ only effectA is output\n\t\t * crossFade.fade.value = 1;\n\t\t * // ^ only effectB is output\n\t\t * crossFade.fade.value = 0.5;\n\t\t * // ^ the two signals are mixed equally.\n\t\t */\n\t Tone.CrossFade = function (initialFade) {\n\t Tone.AudioNode.call(this);\n\t this.createInsOuts(2, 1);\n\t /**\n\t\t\t * Alias for <code>input[0]</code>.\n\t\t\t * @type {Tone.Gain}\n\t\t\t */\n\t this.a = this.input[0] = new Tone.Gain();\n\t /**\n\t\t\t * Alias for <code>input[1]</code>.\n\t\t\t * @type {Tone.Gain}\n\t\t\t */\n\t this.b = this.input[1] = new Tone.Gain();\n\t /**\n\t\t\t * \tThe mix between the two inputs. A fade value of 0\n\t\t\t * \twill output 100% <code>input[0]</code> and\n\t\t\t * \ta value of 1 will output 100% <code>input[1]</code>.\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.fade = new Tone.Signal(Tone.defaultArg(initialFade, 0.5), Tone.Type.NormalRange);\n\t /**\n\t\t\t * equal power gain cross fade\n\t\t\t * @private\n\t\t\t * @type {Tone.EqualPowerGain}\n\t\t\t */\n\t this._equalPowerA = new Tone.EqualPowerGain();\n\t /**\n\t\t\t * equal power gain cross fade\n\t\t\t * @private\n\t\t\t * @type {Tone.EqualPowerGain}\n\t\t\t */\n\t this._equalPowerB = new Tone.EqualPowerGain();\n\t /**\n\t\t\t * invert the incoming signal\n\t\t\t * @private\n\t\t\t * @type {Tone}\n\t\t\t */\n\t this._one = this.context.getConstant(1);\n\t /**\n\t\t\t * invert the incoming signal\n\t\t\t * @private\n\t\t\t * @type {Tone.Subtract}\n\t\t\t */\n\t this._invert = new Tone.Subtract();\n\t //connections\n\t this.a.connect(this.output);\n\t this.b.connect(this.output);\n\t this.fade.chain(this._equalPowerB, this.b.gain);\n\t this._one.connect(this._invert, 0, 0);\n\t this.fade.connect(this._invert, 0, 1);\n\t this._invert.chain(this._equalPowerA, this.a.gain);\n\t this._readOnly('fade');\n\t };\n\t Tone.extend(Tone.CrossFade, Tone.AudioNode);\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.CrossFade} this\n\t\t */\n\t Tone.CrossFade.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._writable('fade');\n\t this._equalPowerA.dispose();\n\t this._equalPowerA = null;\n\t this._equalPowerB.dispose();\n\t this._equalPowerB = null;\n\t this.fade.dispose();\n\t this.fade = null;\n\t this._invert.dispose();\n\t this._invert = null;\n\t this._one = null;\n\t this.a.dispose();\n\t this.a = null;\n\t this.b.dispose();\n\t this.b = null;\n\t return this;\n\t };\n\t return Tone.CrossFade;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Filter is a filter which allows for all of the same native methods\n\t\t * as the [BiquadFilterNode](http://webaudio.github.io/web-audio-api/#the-biquadfilternode-interface).\n\t\t * Tone.Filter has the added ability to set the filter rolloff at -12\n\t\t * (default), -24 and -48.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {Frequency|Object} [frequency] The cutoff frequency of the filter.\n\t\t * @param {string=} type The type of filter.\n\t\t * @param {number=} rolloff The drop in decibels per octave after the cutoff frequency.\n\t\t * 3 choices: -12, -24, and -48\n\t\t * @example\n\t\t * var filter = new Tone.Filter(200, \"highpass\");\n\t\t */\n\t Tone.Filter = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'type',\n\t 'rolloff'\n\t ], Tone.Filter);\n\t Tone.AudioNode.call(this);\n\t this.createInsOuts(1, 1);\n\t /**\n\t\t\t * the filter(s)\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._filters = [];\n\t /**\n\t\t\t * The cutoff frequency of the filter.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency);\n\t /**\n\t\t\t * The detune parameter\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = new Tone.Signal(0, Tone.Type.Cents);\n\t /**\n\t\t\t * The gain of the filter, only used in certain filter types\n\t\t\t * @type {Number}\n\t\t\t * @signal\n\t\t\t */\n\t this.gain = new Tone.Signal({\n\t 'value': options.gain,\n\t 'convert': false\n\t });\n\t /**\n\t\t\t * The Q or Quality of the filter\n\t\t\t * @type {Positive}\n\t\t\t * @signal\n\t\t\t */\n\t this.Q = new Tone.Signal(options.Q);\n\t /**\n\t\t\t * the type of the filter\n\t\t\t * @type {string}\n\t\t\t * @private\n\t\t\t */\n\t this._type = options.type;\n\t /**\n\t\t\t * the rolloff value of the filter\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._rolloff = options.rolloff;\n\t //set the rolloff;\n\t this.rolloff = options.rolloff;\n\t this._readOnly([\n\t 'detune',\n\t 'frequency',\n\t 'gain',\n\t 'Q'\n\t ]);\n\t };\n\t Tone.extend(Tone.Filter, Tone.AudioNode);\n\t /**\n\t\t * the default parameters\n\t\t *\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.Filter.defaults = {\n\t 'type': 'lowpass',\n\t 'frequency': 350,\n\t 'rolloff': -12,\n\t 'Q': 1,\n\t 'gain': 0\n\t };\n\t /**\n\t\t * The type of the filter. Types: \"lowpass\", \"highpass\",\n\t\t * \"bandpass\", \"lowshelf\", \"highshelf\", \"notch\", \"allpass\", or \"peaking\".\n\t\t * @memberOf Tone.Filter#\n\t\t * @type {string}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.Filter.prototype, 'type', {\n\t get: function () {\n\t return this._type;\n\t },\n\t set: function (type) {\n\t var types = [\n\t 'lowpass',\n\t 'highpass',\n\t 'bandpass',\n\t 'lowshelf',\n\t 'highshelf',\n\t 'notch',\n\t 'allpass',\n\t 'peaking'\n\t ];\n\t if (types.indexOf(type) === -1) {\n\t throw new TypeError('Tone.Filter: invalid type ' + type);\n\t }\n\t this._type = type;\n\t for (var i = 0; i < this._filters.length; i++) {\n\t this._filters[i].type = type;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The rolloff of the filter which is the drop in db\n\t\t * per octave. Implemented internally by cascading filters.\n\t\t * Only accepts the values -12, -24, -48 and -96.\n\t\t * @memberOf Tone.Filter#\n\t\t * @type {number}\n\t\t * @name rolloff\n\t\t */\n\t Object.defineProperty(Tone.Filter.prototype, 'rolloff', {\n\t get: function () {\n\t return this._rolloff;\n\t },\n\t set: function (rolloff) {\n\t rolloff = parseInt(rolloff, 10);\n\t var possibilities = [\n\t -12,\n\t -24,\n\t -48,\n\t -96\n\t ];\n\t var cascadingCount = possibilities.indexOf(rolloff);\n\t //check the rolloff is valid\n\t if (cascadingCount === -1) {\n\t throw new RangeError('Tone.Filter: rolloff can only be -12, -24, -48 or -96');\n\t }\n\t cascadingCount += 1;\n\t this._rolloff = rolloff;\n\t //first disconnect the filters and throw them away\n\t this.input.disconnect();\n\t for (var i = 0; i < this._filters.length; i++) {\n\t this._filters[i].disconnect();\n\t this._filters[i] = null;\n\t }\n\t this._filters = new Array(cascadingCount);\n\t for (var count = 0; count < cascadingCount; count++) {\n\t var filter = this.context.createBiquadFilter();\n\t filter.type = this._type;\n\t this.frequency.connect(filter.frequency);\n\t this.detune.connect(filter.detune);\n\t this.Q.connect(filter.Q);\n\t this.gain.connect(filter.gain);\n\t this._filters[count] = filter;\n\t }\n\t //connect them up\n\t var connectionChain = [this.input].concat(this._filters).concat([this.output]);\n\t Tone.connectSeries.apply(Tone, connectionChain);\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.Filter} this\n\t\t */\n\t Tone.Filter.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t for (var i = 0; i < this._filters.length; i++) {\n\t this._filters[i].disconnect();\n\t this._filters[i] = null;\n\t }\n\t this._filters = null;\n\t this._writable([\n\t 'detune',\n\t 'frequency',\n\t 'gain',\n\t 'Q'\n\t ]);\n\t this.frequency.dispose();\n\t this.Q.dispose();\n\t this.frequency = null;\n\t this.Q = null;\n\t this.detune.dispose();\n\t this.detune = null;\n\t this.gain.dispose();\n\t this.gain = null;\n\t return this;\n\t };\n\t return Tone.Filter;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Split the incoming signal into three bands (low, mid, high)\n\t\t * with two crossover frequency controls.\n\t\t *\n\t\t * @extends {Tone.AudioNode}\n\t\t * @constructor\n\t\t * @param {Frequency|Object} [lowFrequency] the low/mid crossover frequency\n\t\t * @param {Frequency} [highFrequency] the mid/high crossover frequency\n\t\t */\n\t Tone.MultibandSplit = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'lowFrequency',\n\t 'highFrequency'\n\t ], Tone.MultibandSplit);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * the input\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this.input = new Tone.Gain();\n\t /**\n\t\t\t * the outputs\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this.output = new Array(3);\n\t /**\n\t\t\t * The low band. Alias for <code>output[0]</code>\n\t\t\t * @type {Tone.Filter}\n\t\t\t */\n\t this.low = this.output[0] = new Tone.Filter(0, 'lowpass');\n\t /**\n\t\t\t * the lower filter of the mid band\n\t\t\t * @type {Tone.Filter}\n\t\t\t * @private\n\t\t\t */\n\t this._lowMidFilter = new Tone.Filter(0, 'highpass');\n\t /**\n\t\t\t * The mid band output. Alias for <code>output[1]</code>\n\t\t\t * @type {Tone.Filter}\n\t\t\t */\n\t this.mid = this.output[1] = new Tone.Filter(0, 'lowpass');\n\t /**\n\t\t\t * The high band output. Alias for <code>output[2]</code>\n\t\t\t * @type {Tone.Filter}\n\t\t\t */\n\t this.high = this.output[2] = new Tone.Filter(0, 'highpass');\n\t /**\n\t\t\t * The low/mid crossover frequency.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.lowFrequency = new Tone.Signal(options.lowFrequency, Tone.Type.Frequency);\n\t /**\n\t\t\t * The mid/high crossover frequency.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.highFrequency = new Tone.Signal(options.highFrequency, Tone.Type.Frequency);\n\t /**\n\t\t\t * The quality of all the filters\n\t\t\t * @type {Number}\n\t\t\t * @signal\n\t\t\t */\n\t this.Q = new Tone.Signal(options.Q);\n\t this.input.fan(this.low, this.high);\n\t this.input.chain(this._lowMidFilter, this.mid);\n\t //the frequency control signal\n\t this.lowFrequency.connect(this.low.frequency);\n\t this.lowFrequency.connect(this._lowMidFilter.frequency);\n\t this.highFrequency.connect(this.mid.frequency);\n\t this.highFrequency.connect(this.high.frequency);\n\t //the Q value\n\t this.Q.connect(this.low.Q);\n\t this.Q.connect(this._lowMidFilter.Q);\n\t this.Q.connect(this.mid.Q);\n\t this.Q.connect(this.high.Q);\n\t this._readOnly([\n\t 'high',\n\t 'mid',\n\t 'low',\n\t 'highFrequency',\n\t 'lowFrequency'\n\t ]);\n\t };\n\t Tone.extend(Tone.MultibandSplit, Tone.AudioNode);\n\t /**\n\t\t * @private\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.MultibandSplit.defaults = {\n\t 'lowFrequency': 400,\n\t 'highFrequency': 2500,\n\t 'Q': 1\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.MultibandSplit} this\n\t\t */\n\t Tone.MultibandSplit.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._writable([\n\t 'high',\n\t 'mid',\n\t 'low',\n\t 'highFrequency',\n\t 'lowFrequency'\n\t ]);\n\t this.low.dispose();\n\t this.low = null;\n\t this._lowMidFilter.dispose();\n\t this._lowMidFilter = null;\n\t this.mid.dispose();\n\t this.mid = null;\n\t this.high.dispose();\n\t this.high = null;\n\t this.lowFrequency.dispose();\n\t this.lowFrequency = null;\n\t this.highFrequency.dispose();\n\t this.highFrequency = null;\n\t this.Q.dispose();\n\t this.Q = null;\n\t return this;\n\t };\n\t return Tone.MultibandSplit;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.EQ3 is a three band EQ with control over low, mid, and high gain as\n\t\t * well as the low and high crossover frequencies.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t *\n\t\t * @param {Decibels|Object} [lowLevel] The gain applied to the lows.\n\t\t * @param {Decibels} [midLevel] The gain applied to the mid.\n\t\t * @param {Decibels} [highLevel] The gain applied to the high.\n\t\t * @example\n\t\t * var eq = new Tone.EQ3(-10, 3, -20);\n\t\t */\n\t Tone.EQ3 = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'low',\n\t 'mid',\n\t 'high'\n\t ], Tone.EQ3);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * the output node\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this.output = new Tone.Gain();\n\t /**\n\t\t\t * the multiband split\n\t\t\t * @type {Tone.MultibandSplit}\n\t\t\t * @private\n\t\t\t */\n\t this._multibandSplit = this.input = new Tone.MultibandSplit({\n\t 'lowFrequency': options.lowFrequency,\n\t 'highFrequency': options.highFrequency\n\t });\n\t /**\n\t\t\t * The gain for the lower signals\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._lowGain = new Tone.Gain(options.low, Tone.Type.Decibels);\n\t /**\n\t\t\t * The gain for the mid signals\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._midGain = new Tone.Gain(options.mid, Tone.Type.Decibels);\n\t /**\n\t\t\t * The gain in decibels of the high part\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._highGain = new Tone.Gain(options.high, Tone.Type.Decibels);\n\t /**\n\t\t\t * The gain in decibels of the low part\n\t\t\t * @type {Decibels}\n\t\t\t * @signal\n\t\t\t */\n\t this.low = this._lowGain.gain;\n\t /**\n\t\t\t * The gain in decibels of the mid part\n\t\t\t * @type {Decibels}\n\t\t\t * @signal\n\t\t\t */\n\t this.mid = this._midGain.gain;\n\t /**\n\t\t\t * The gain in decibels of the high part\n\t\t\t * @type {Decibels}\n\t\t\t * @signal\n\t\t\t */\n\t this.high = this._highGain.gain;\n\t /**\n\t\t\t * The Q value for all of the filters.\n\t\t\t * @type {Positive}\n\t\t\t * @signal\n\t\t\t */\n\t this.Q = this._multibandSplit.Q;\n\t /**\n\t\t\t * The low/mid crossover frequency.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.lowFrequency = this._multibandSplit.lowFrequency;\n\t /**\n\t\t\t * The mid/high crossover frequency.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.highFrequency = this._multibandSplit.highFrequency;\n\t //the frequency bands\n\t this._multibandSplit.low.chain(this._lowGain, this.output);\n\t this._multibandSplit.mid.chain(this._midGain, this.output);\n\t this._multibandSplit.high.chain(this._highGain, this.output);\n\t this._readOnly([\n\t 'low',\n\t 'mid',\n\t 'high',\n\t 'lowFrequency',\n\t 'highFrequency'\n\t ]);\n\t };\n\t Tone.extend(Tone.EQ3, Tone.AudioNode);\n\t /**\n\t\t * the default values\n\t\t */\n\t Tone.EQ3.defaults = {\n\t 'low': 0,\n\t 'mid': 0,\n\t 'high': 0,\n\t 'lowFrequency': 400,\n\t 'highFrequency': 2500\n\t };\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.EQ3} this\n\t\t */\n\t Tone.EQ3.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._writable([\n\t 'low',\n\t 'mid',\n\t 'high',\n\t 'lowFrequency',\n\t 'highFrequency'\n\t ]);\n\t this._multibandSplit.dispose();\n\t this._multibandSplit = null;\n\t this.lowFrequency = null;\n\t this.highFrequency = null;\n\t this._lowGain.dispose();\n\t this._lowGain = null;\n\t this._midGain.dispose();\n\t this._midGain = null;\n\t this._highGain.dispose();\n\t this._highGain = null;\n\t this.low = null;\n\t this.mid = null;\n\t this.high = null;\n\t this.Q = null;\n\t return this;\n\t };\n\t return Tone.EQ3;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Performs a linear scaling on an input signal.\n\t\t * Scales a NormalRange input to between\n\t\t * outputMin and outputMax.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.SignalBase}\n\t\t * @param {number} [outputMin=0] The output value when the input is 0. \n\t\t * @param {number} [outputMax=1]\tThe output value when the input is 1. \n\t\t * @example\n\t\t * var scale = new Tone.Scale(50, 100);\n\t\t * var signal = new Tone.Signal(0.5).connect(scale);\n\t\t * //the output of scale equals 75\n\t\t */\n\t Tone.Scale = function (outputMin, outputMax) {\n\t Tone.SignalBase.call(this);\n\t /** \n\t\t\t * @private\n\t\t\t * @type {number}\n\t\t\t */\n\t this._outputMin = Tone.defaultArg(outputMin, 0);\n\t /** \n\t\t\t * @private\n\t\t\t * @type {number}\n\t\t\t */\n\t this._outputMax = Tone.defaultArg(outputMax, 1);\n\t /** \n\t\t\t * @private\n\t\t\t * @type {Tone.Multiply}\n\t\t\t * @private\n\t\t\t */\n\t this._scale = this.input = new Tone.Multiply(1);\n\t /** \n\t\t\t * @private\n\t\t\t * @type {Tone.Add}\n\t\t\t * @private\n\t\t\t */\n\t this._add = this.output = new Tone.Add(0);\n\t this._scale.connect(this._add);\n\t this._setRange();\n\t };\n\t Tone.extend(Tone.Scale, Tone.SignalBase);\n\t /**\n\t\t * The minimum output value. This number is output when \n\t\t * the value input value is 0. \n\t\t * @memberOf Tone.Scale#\n\t\t * @type {number}\n\t\t * @name min\n\t\t */\n\t Object.defineProperty(Tone.Scale.prototype, 'min', {\n\t get: function () {\n\t return this._outputMin;\n\t },\n\t set: function (min) {\n\t this._outputMin = min;\n\t this._setRange();\n\t }\n\t });\n\t /**\n\t\t * The maximum output value. This number is output when \n\t\t * the value input value is 1. \n\t\t * @memberOf Tone.Scale#\n\t\t * @type {number}\n\t\t * @name max\n\t\t */\n\t Object.defineProperty(Tone.Scale.prototype, 'max', {\n\t get: function () {\n\t return this._outputMax;\n\t },\n\t set: function (max) {\n\t this._outputMax = max;\n\t this._setRange();\n\t }\n\t });\n\t /**\n\t\t * set the values\n\t\t * @private\n\t\t */\n\t Tone.Scale.prototype._setRange = function () {\n\t this._add.value = this._outputMin;\n\t this._scale.value = this._outputMax - this._outputMin;\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Scale} this\n\t\t */\n\t Tone.Scale.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._add.dispose();\n\t this._add = null;\n\t this._scale.dispose();\n\t this._scale = null;\n\t return this;\n\t };\n\t return Tone.Scale;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Performs an exponential scaling on an input signal.\n\t\t * Scales a NormalRange value [0,1] exponentially\n\t\t * to the output range of outputMin to outputMax.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.SignalBase}\n\t\t * @param {number} [outputMin=0] The output value when the input is 0.\n\t\t * @param {number} [outputMax=1]\tThe output value when the input is 1.\n\t\t * @param {number} [exponent=2] The exponent which scales the incoming signal.\n\t\t * @example\n\t\t * var scaleExp = new Tone.ScaleExp(0, 100, 2);\n\t\t * var signal = new Tone.Signal(0.5).connect(scaleExp);\n\t\t */\n\t Tone.ScaleExp = function (outputMin, outputMax, exponent) {\n\t Tone.SignalBase.call(this);\n\t /**\n\t\t\t * scale the input to the output range\n\t\t\t * @type {Tone.Scale}\n\t\t\t * @private\n\t\t\t */\n\t this._scale = this.output = new Tone.Scale(outputMin, outputMax);\n\t /**\n\t\t\t * @private\n\t\t\t * @type {Tone.Pow}\n\t\t\t * @private\n\t\t\t */\n\t this._exp = this.input = new Tone.Pow(Tone.defaultArg(exponent, 2));\n\t this._exp.connect(this._scale);\n\t };\n\t Tone.extend(Tone.ScaleExp, Tone.SignalBase);\n\t /**\n\t\t * Instead of interpolating linearly between the <code>min</code> and\n\t\t * <code>max</code> values, setting the exponent will interpolate between\n\t\t * the two values with an exponential curve.\n\t\t * @memberOf Tone.ScaleExp#\n\t\t * @type {number}\n\t\t * @name exponent\n\t\t */\n\t Object.defineProperty(Tone.ScaleExp.prototype, 'exponent', {\n\t get: function () {\n\t return this._exp.value;\n\t },\n\t set: function (exp) {\n\t this._exp.value = exp;\n\t }\n\t });\n\t /**\n\t\t * The minimum output value. This number is output when\n\t\t * the value input value is 0.\n\t\t * @memberOf Tone.ScaleExp#\n\t\t * @type {number}\n\t\t * @name min\n\t\t */\n\t Object.defineProperty(Tone.ScaleExp.prototype, 'min', {\n\t get: function () {\n\t return this._scale.min;\n\t },\n\t set: function (min) {\n\t this._scale.min = min;\n\t }\n\t });\n\t /**\n\t\t * The maximum output value. This number is output when\n\t\t * the value input value is 1.\n\t\t * @memberOf Tone.ScaleExp#\n\t\t * @type {number}\n\t\t * @name max\n\t\t */\n\t Object.defineProperty(Tone.ScaleExp.prototype, 'max', {\n\t get: function () {\n\t return this._scale.max;\n\t },\n\t set: function (max) {\n\t this._scale.max = max;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.ScaleExp} this\n\t\t */\n\t Tone.ScaleExp.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._scale.dispose();\n\t this._scale = null;\n\t this._exp.dispose();\n\t this._exp = null;\n\t return this;\n\t };\n\t return Tone.ScaleExp;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Wrapper around Web Audio's native [DelayNode](http://webaudio.github.io/web-audio-api/#the-delaynode-interface).\n\t\t * @extends {Tone}\n\t\t * @param {Time=} delayTime The delay applied to the incoming signal.\n\t\t * @param {Time=} maxDelay The maximum delay time.\n\t\t */\n\t Tone.Delay = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'delayTime',\n\t 'maxDelay'\n\t ], Tone.Delay);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The maximum delay time initialized with the node\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._maxDelay = Math.max(this.toSeconds(options.maxDelay), this.toSeconds(options.delayTime));\n\t /**\n\t\t\t * The native delay node\n\t\t\t * @type {DelayNode}\n\t\t\t * @private\n\t\t\t */\n\t this._delayNode = this.input = this.output = this.context.createDelay(this._maxDelay);\n\t /**\n\t\t\t * The amount of time the incoming signal is\n\t\t\t * delayed.\n\t\t\t * @type {Time}\n\t\t\t * @signal\n\t\t\t */\n\t this.delayTime = new Tone.Param({\n\t 'param': this._delayNode.delayTime,\n\t 'units': Tone.Type.Time,\n\t 'value': options.delayTime\n\t });\n\t this._readOnly('delayTime');\n\t };\n\t Tone.extend(Tone.Delay, Tone.AudioNode);\n\t /**\n\t\t * The defaults\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Delay.defaults = {\n\t 'maxDelay': 1,\n\t 'delayTime': 0\n\t };\n\t /**\n\t\t * The maximum delay time. This cannot be changed. The value is passed into the constructor.\n\t\t * @memberof Tone.Delay#\n\t\t * @type {Time}\n\t\t * @name maxDelay\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Delay.prototype, 'maxDelay', {\n\t get: function () {\n\t return this._maxDelay;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.Delay} this\n\t\t */\n\t Tone.Delay.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._delayNode.disconnect();\n\t this._delayNode = null;\n\t this._writable('delayTime');\n\t this.delayTime = null;\n\t return this;\n\t };\n\t return Tone.Delay;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Comb filters are basic building blocks for physical modeling. Read more\n\t\t * about comb filters on [CCRMA's website](https://ccrma.stanford.edu/~jos/pasp/Feedback_Comb_Filters.html).\n\t\t *\n\t\t * @extends {Tone.AudioNode}\n\t\t * @constructor\n\t\t * @param {Time|Object} [delayTime] The delay time of the filter.\n\t\t * @param {NormalRange=} resonance The amount of feedback the filter has.\n\t\t */\n\t Tone.FeedbackCombFilter = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'delayTime',\n\t 'resonance'\n\t ], Tone.FeedbackCombFilter);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * the delay node\n\t\t\t * @type {DelayNode}\n\t\t\t * @private\n\t\t\t */\n\t this._delay = this.input = this.output = new Tone.Delay(options.delayTime);\n\t /**\n\t\t\t * The amount of delay of the comb filter.\n\t\t\t * @type {Time}\n\t\t\t * @signal\n\t\t\t */\n\t this.delayTime = this._delay.delayTime;\n\t /**\n\t\t\t * the feedback node\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this._feedback = new Tone.Gain(options.resonance, Tone.Type.NormalRange);\n\t /**\n\t\t\t * The amount of feedback of the delayed signal.\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.resonance = this._feedback.gain;\n\t this._delay.chain(this._feedback, this._delay);\n\t this._readOnly([\n\t 'resonance',\n\t 'delayTime'\n\t ]);\n\t };\n\t Tone.extend(Tone.FeedbackCombFilter, Tone.AudioNode);\n\t /**\n\t\t * the default parameters\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.FeedbackCombFilter.defaults = {\n\t 'delayTime': 0.1,\n\t 'resonance': 0.5\n\t };\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.FeedbackCombFilter} this\n\t\t */\n\t Tone.FeedbackCombFilter.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._writable([\n\t 'resonance',\n\t 'delayTime'\n\t ]);\n\t this._delay.dispose();\n\t this._delay = null;\n\t this.delayTime = null;\n\t this._feedback.dispose();\n\t this._feedback = null;\n\t this.resonance = null;\n\t return this;\n\t };\n\t return Tone.FeedbackCombFilter;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Get the current waveform data of the connected audio source.\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {Number=} size The size of the FFT. Value must be a power of\n\t\t * two in the range 32 to 32768.\n\t\t */\n\t Tone.FFT = function () {\n\t var options = Tone.defaults(arguments, ['size'], Tone.FFT);\n\t options.type = Tone.Analyser.Type.FFT;\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The analyser node.\n\t\t\t * @private\n\t\t\t * @type {Tone.Analyser}\n\t\t\t */\n\t this._analyser = this.input = this.output = new Tone.Analyser(options);\n\t };\n\t Tone.extend(Tone.FFT, Tone.AudioNode);\n\t /**\n\t\t * The default values.\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.FFT.defaults = { 'size': 1024 };\n\t /**\n\t\t * Gets the waveform of the audio source. Returns the waveform data\n\t\t * of length [size](#size) as a Float32Array with values between -1 and 1.\n\t\t * @returns {TypedArray}\n\t\t */\n\t Tone.FFT.prototype.getValue = function () {\n\t return this._analyser.getValue();\n\t };\n\t /**\n\t\t * The size of analysis. This must be a power of two in the range 32 to 32768.\n\t\t * @memberOf Tone.FFT#\n\t\t * @type {Number}\n\t\t * @name size\n\t\t */\n\t Object.defineProperty(Tone.FFT.prototype, 'size', {\n\t get: function () {\n\t return this._analyser.size;\n\t },\n\t set: function (size) {\n\t this._analyser.size = size;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.FFT} this\n\t\t */\n\t Tone.FFT.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._analyser.dispose();\n\t this._analyser = null;\n\t };\n\t return Tone.FFT;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Return the absolute value of an incoming signal.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.SignalBase}\n\t\t * @example\n\t\t * var signal = new Tone.Signal(-1);\n\t\t * var abs = new Tone.Abs();\n\t\t * signal.connect(abs);\n\t\t * //the output of abs is 1.\n\t\t */\n\t Tone.Abs = function () {\n\t Tone.SignalBase.call(this);\n\t /**\n\t\t\t * @type {Tone.LessThan}\n\t\t\t * @private\n\t\t\t */\n\t this._abs = this.input = this.output = new Tone.WaveShaper(function (val) {\n\t if (Math.abs(val) < 0.001) {\n\t return 0;\n\t } else {\n\t return Math.abs(val);\n\t }\n\t }, 1024);\n\t };\n\t Tone.extend(Tone.Abs, Tone.SignalBase);\n\t /**\n\t\t * dispose method\n\t\t * @returns {Tone.Abs} this\n\t\t */\n\t Tone.Abs.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._abs.dispose();\n\t this._abs = null;\n\t return this;\n\t };\n\t return Tone.Abs;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Follower is a crude envelope follower which will follow\n\t\t * the amplitude of an incoming signal.\n\t\t * Take care with small (< 0.02) attack or decay values\n\t\t * as follower has some ripple which is exaggerated\n\t\t * at these values. Read more about envelope followers (also known\n\t\t * as envelope detectors) on [Wikipedia](https://en.wikipedia.org/wiki/Envelope_detector).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {Time|Object} [attack] The rate at which the follower rises.\n\t\t * @param {Time=} release The rate at which the folower falls.\n\t\t * @example\n\t\t * var follower = new Tone.Follower(0.2, 0.4);\n\t\t */\n\t Tone.Follower = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'attack',\n\t 'release'\n\t ], Tone.Follower);\n\t Tone.AudioNode.call(this);\n\t this.createInsOuts(1, 1);\n\t /**\n\t\t\t * @type {Tone.Abs}\n\t\t\t * @private\n\t\t\t */\n\t this._abs = new Tone.Abs();\n\t /**\n\t\t\t * the lowpass filter which smooths the input\n\t\t\t * @type {BiquadFilterNode}\n\t\t\t * @private\n\t\t\t */\n\t this._filter = this.context.createBiquadFilter();\n\t this._filter.type = 'lowpass';\n\t this._filter.frequency.value = 0;\n\t this._filter.Q.value = -100;\n\t /**\n\t\t\t * @type {WaveShaperNode}\n\t\t\t * @private\n\t\t\t */\n\t this._frequencyValues = new Tone.WaveShaper();\n\t /**\n\t\t\t * @type {Tone.Subtract}\n\t\t\t * @private\n\t\t\t */\n\t this._sub = new Tone.Subtract();\n\t /**\n\t\t\t * @type {Tone.Delay}\n\t\t\t * @private\n\t\t\t */\n\t this._delay = new Tone.Delay(this.blockTime);\n\t /**\n\t\t\t * this keeps it far from 0, even for very small differences\n\t\t\t * @type {Tone.Multiply}\n\t\t\t * @private\n\t\t\t */\n\t this._mult = new Tone.Multiply(10000);\n\t /**\n\t\t\t * @private\n\t\t\t * @type {number}\n\t\t\t */\n\t this._attack = options.attack;\n\t /**\n\t\t\t * @private\n\t\t\t * @type {number}\n\t\t\t */\n\t this._release = options.release;\n\t //the smoothed signal to get the values\n\t this.input.chain(this._abs, this._filter, this.output);\n\t //the difference path\n\t this._abs.connect(this._sub, 0, 1);\n\t this._filter.chain(this._delay, this._sub);\n\t //threshold the difference and use the thresh to set the frequency\n\t this._sub.chain(this._mult, this._frequencyValues, this._filter.frequency);\n\t //set the attack and release values in the table\n\t this._setAttackRelease(this._attack, this._release);\n\t };\n\t Tone.extend(Tone.Follower, Tone.AudioNode);\n\t /**\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.Follower.defaults = {\n\t 'attack': 0.05,\n\t 'release': 0.5\n\t };\n\t /**\n\t\t * sets the attack and release times in the wave shaper\n\t\t * @param {Time} attack\n\t\t * @param {Time} release\n\t\t * @private\n\t\t */\n\t Tone.Follower.prototype._setAttackRelease = function (attack, release) {\n\t var minTime = this.blockTime;\n\t attack = Tone.Time(attack).toFrequency();\n\t release = Tone.Time(release).toFrequency();\n\t attack = Math.max(attack, minTime);\n\t release = Math.max(release, minTime);\n\t this._frequencyValues.setMap(function (val) {\n\t if (val <= 0) {\n\t return attack;\n\t } else {\n\t return release;\n\t }\n\t });\n\t };\n\t /**\n\t\t * The attack time.\n\t\t * @memberOf Tone.Follower#\n\t\t * @type {Time}\n\t\t * @name attack\n\t\t */\n\t Object.defineProperty(Tone.Follower.prototype, 'attack', {\n\t get: function () {\n\t return this._attack;\n\t },\n\t set: function (attack) {\n\t this._attack = attack;\n\t this._setAttackRelease(this._attack, this._release);\n\t }\n\t });\n\t /**\n\t\t * The release time.\n\t\t * @memberOf Tone.Follower#\n\t\t * @type {Time}\n\t\t * @name release\n\t\t */\n\t Object.defineProperty(Tone.Follower.prototype, 'release', {\n\t get: function () {\n\t return this._release;\n\t },\n\t set: function (release) {\n\t this._release = release;\n\t this._setAttackRelease(this._attack, this._release);\n\t }\n\t });\n\t /**\n\t\t * Borrows the connect method from Signal so that the output can be used\n\t\t * as a Tone.Signal control signal.\n\t\t * @function\n\t\t */\n\t Tone.Follower.prototype.connect = Tone.SignalBase.prototype.connect;\n\t /**\n\t\t * dispose\n\t\t * @returns {Tone.Follower} this\n\t\t */\n\t Tone.Follower.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._filter.disconnect();\n\t this._filter = null;\n\t this._frequencyValues.disconnect();\n\t this._frequencyValues = null;\n\t this._delay.dispose();\n\t this._delay = null;\n\t this._sub.disconnect();\n\t this._sub = null;\n\t this._abs.dispose();\n\t this._abs = null;\n\t this._mult.dispose();\n\t this._mult = null;\n\t this._curve = null;\n\t return this;\n\t };\n\t return Tone.Follower;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.ScaledEnvelop is an envelope which can be scaled\n\t\t * to any range. It's useful for applying an envelope\n\t\t * to a frequency or any other non-NormalRange signal\n\t\t * parameter.\n\t\t *\n\t\t * @extends {Tone.Envelope}\n\t\t * @constructor\n\t\t * @param {Time|Object} [attack]\tthe attack time in seconds\n\t\t * @param {Time} [decay]\tthe decay time in seconds\n\t\t * @param {number} [sustain] \ta percentage (0-1) of the full amplitude\n\t\t * @param {Time} [release]\tthe release time in seconds\n\t\t * @example\n\t\t * var scaledEnv = new Tone.ScaledEnvelope({\n\t\t * \t\"attack\" : 0.2,\n\t\t * \t\"min\" : 200,\n\t\t * \t\"max\" : 2000\n\t\t * });\n\t\t * scaledEnv.connect(oscillator.frequency);\n\t\t */\n\t Tone.ScaledEnvelope = function () {\n\t //get all of the defaults\n\t var options = Tone.defaults(arguments, [\n\t 'attack',\n\t 'decay',\n\t 'sustain',\n\t 'release'\n\t ], Tone.Envelope);\n\t Tone.Envelope.call(this, options);\n\t options = Tone.defaultArg(options, Tone.ScaledEnvelope.defaults);\n\t /**\n\t\t\t * scale the incoming signal by an exponent\n\t\t\t * @type {Tone.Pow}\n\t\t\t * @private\n\t\t\t */\n\t this._exp = this.output = new Tone.Pow(options.exponent);\n\t /**\n\t\t\t * scale the signal to the desired range\n\t\t\t * @type {Tone.Multiply}\n\t\t\t * @private\n\t\t\t */\n\t this._scale = this.output = new Tone.Scale(options.min, options.max);\n\t this._sig.chain(this._exp, this._scale);\n\t };\n\t Tone.extend(Tone.ScaledEnvelope, Tone.Envelope);\n\t /**\n\t\t * the default parameters\n\t\t * @static\n\t\t */\n\t Tone.ScaledEnvelope.defaults = {\n\t 'min': 0,\n\t 'max': 1,\n\t 'exponent': 1\n\t };\n\t /**\n\t\t * The envelope's min output value. This is the value which it\n\t\t * starts at.\n\t\t * @memberOf Tone.ScaledEnvelope#\n\t\t * @type {number}\n\t\t * @name min\n\t\t */\n\t Object.defineProperty(Tone.ScaledEnvelope.prototype, 'min', {\n\t get: function () {\n\t return this._scale.min;\n\t },\n\t set: function (min) {\n\t this._scale.min = min;\n\t }\n\t });\n\t /**\n\t\t * The envelope's max output value. In other words, the value\n\t\t * at the peak of the attack portion of the envelope.\n\t\t * @memberOf Tone.ScaledEnvelope#\n\t\t * @type {number}\n\t\t * @name max\n\t\t */\n\t Object.defineProperty(Tone.ScaledEnvelope.prototype, 'max', {\n\t get: function () {\n\t return this._scale.max;\n\t },\n\t set: function (max) {\n\t this._scale.max = max;\n\t }\n\t });\n\t /**\n\t\t * The envelope's exponent value.\n\t\t * @memberOf Tone.ScaledEnvelope#\n\t\t * @type {number}\n\t\t * @name exponent\n\t\t */\n\t Object.defineProperty(Tone.ScaledEnvelope.prototype, 'exponent', {\n\t get: function () {\n\t return this._exp.value;\n\t },\n\t set: function (exp) {\n\t this._exp.value = exp;\n\t }\n\t });\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.ScaledEnvelope} this\n\t\t */\n\t Tone.ScaledEnvelope.prototype.dispose = function () {\n\t Tone.Envelope.prototype.dispose.call(this);\n\t this._scale.dispose();\n\t this._scale = null;\n\t this._exp.dispose();\n\t this._exp = null;\n\t return this;\n\t };\n\t return Tone.ScaledEnvelope;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.FrequencyEnvelope is a Tone.ScaledEnvelope, but instead of `min` and `max`\n\t\t * it's got a `baseFrequency` and `octaves` parameter.\n\t\t *\n\t\t * @extends {Tone.Envelope}\n\t\t * @constructor\n\t\t * @param {Time|Object} [attack]\tthe attack time in seconds\n\t\t * @param {Time} [decay]\tthe decay time in seconds\n\t\t * @param {number} [sustain] \ta percentage (0-1) of the full amplitude\n\t\t * @param {Time} [release]\tthe release time in seconds\n\t\t * @example\n\t\t * var freqEnv = new Tone.FrequencyEnvelope({\n\t\t * \t\"attack\" : 0.2,\n\t\t * \t\"baseFrequency\" : \"C2\",\n\t\t * \t\"octaves\" : 4\n\t\t * });\n\t\t * freqEnv.connect(oscillator.frequency);\n\t\t */\n\t Tone.FrequencyEnvelope = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'attack',\n\t 'decay',\n\t 'sustain',\n\t 'release'\n\t ], Tone.Envelope);\n\t Tone.ScaledEnvelope.call(this, options);\n\t //merge it with the frequency envelope defaults\n\t options = Tone.defaultArg(options, Tone.FrequencyEnvelope.defaults);\n\t /**\n\t\t\t * Stores the octave value\n\t\t\t * @type {Positive}\n\t\t\t * @private\n\t\t\t */\n\t this._octaves = options.octaves;\n\t //setup\n\t this.baseFrequency = options.baseFrequency;\n\t this.octaves = options.octaves;\n\t };\n\t Tone.extend(Tone.FrequencyEnvelope, Tone.Envelope);\n\t /**\n\t\t * the default parameters\n\t\t * @static\n\t\t */\n\t Tone.FrequencyEnvelope.defaults = {\n\t 'baseFrequency': 200,\n\t 'octaves': 4,\n\t 'exponent': 2\n\t };\n\t /**\n\t\t * The envelope's mininum output value. This is the value which it\n\t\t * starts at.\n\t\t * @memberOf Tone.FrequencyEnvelope#\n\t\t * @type {Frequency}\n\t\t * @name baseFrequency\n\t\t */\n\t Object.defineProperty(Tone.FrequencyEnvelope.prototype, 'baseFrequency', {\n\t get: function () {\n\t return this._scale.min;\n\t },\n\t set: function (min) {\n\t this._scale.min = this.toFrequency(min);\n\t //also update the octaves\n\t this.octaves = this._octaves;\n\t }\n\t });\n\t /**\n\t\t * The number of octaves above the baseFrequency that the\n\t\t * envelope will scale to.\n\t\t * @memberOf Tone.FrequencyEnvelope#\n\t\t * @type {Positive}\n\t\t * @name octaves\n\t\t */\n\t Object.defineProperty(Tone.FrequencyEnvelope.prototype, 'octaves', {\n\t get: function () {\n\t return this._octaves;\n\t },\n\t set: function (octaves) {\n\t this._octaves = octaves;\n\t this._scale.max = this.baseFrequency * Math.pow(2, octaves);\n\t }\n\t });\n\t /**\n\t\t * The envelope's exponent value.\n\t\t * @memberOf Tone.FrequencyEnvelope#\n\t\t * @type {number}\n\t\t * @name exponent\n\t\t */\n\t Object.defineProperty(Tone.FrequencyEnvelope.prototype, 'exponent', {\n\t get: function () {\n\t return this._exp.value;\n\t },\n\t set: function (exp) {\n\t this._exp.value = exp;\n\t }\n\t });\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.FrequencyEnvelope} this\n\t\t */\n\t Tone.FrequencyEnvelope.prototype.dispose = function () {\n\t Tone.ScaledEnvelope.prototype.dispose.call(this);\n\t return this;\n\t };\n\t return Tone.FrequencyEnvelope;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class GreaterThanZero outputs 1 when the input is strictly greater than zero\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.SignalBase}\n\t\t * @example\n\t\t * var gt0 = new Tone.GreaterThanZero();\n\t\t * var sig = new Tone.Signal(0.01).connect(gt0);\n\t\t * //the output of gt0 is 1.\n\t\t * sig.value = 0;\n\t\t * //the output of gt0 is 0.\n\t\t */\n\t Tone.GreaterThanZero = function () {\n\t Tone.SignalBase.call(this);\n\t /**\n\t\t\t * @type {Tone.WaveShaper}\n\t\t\t * @private\n\t\t\t */\n\t this._thresh = this.output = new Tone.WaveShaper(function (val) {\n\t if (val <= 0) {\n\t return 0;\n\t } else {\n\t return 1;\n\t }\n\t }, 127);\n\t /**\n\t\t\t * scale the first thresholded signal by a large value.\n\t\t\t * this will help with values which are very close to 0\n\t\t\t * @type {Tone.Multiply}\n\t\t\t * @private\n\t\t\t */\n\t this._scale = this.input = new Tone.Multiply(10000);\n\t //connections\n\t this._scale.connect(this._thresh);\n\t };\n\t Tone.extend(Tone.GreaterThanZero, Tone.SignalBase);\n\t /**\n\t\t * dispose method\n\t\t * @returns {Tone.GreaterThanZero} this\n\t\t */\n\t Tone.GreaterThanZero.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._scale.dispose();\n\t this._scale = null;\n\t this._thresh.dispose();\n\t this._thresh = null;\n\t return this;\n\t };\n\t return Tone.GreaterThanZero;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Output 1 if the signal is greater than the value, otherwise outputs 0.\n\t\t * can compare two signals or a signal and a number.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Signal}\n\t\t * @param {number} [value=0] the value to compare to the incoming signal\n\t\t * @example\n\t\t * var gt = new Tone.GreaterThan(2);\n\t\t * var sig = new Tone.Signal(4).connect(gt);\n\t\t * //output of gt is equal 1.\n\t\t */\n\t Tone.GreaterThan = function (value) {\n\t Tone.Signal.call(this);\n\t this.createInsOuts(2, 0);\n\t /**\n\t\t\t * subtract the amount from the incoming signal\n\t\t\t * @type {Tone.Subtract}\n\t\t\t * @private\n\t\t\t */\n\t this._param = this.input[0] = new Tone.Subtract(value);\n\t this.input[1] = this._param.input[1];\n\t /**\n\t\t\t * compare that amount to zero\n\t\t\t * @type {Tone.GreaterThanZero}\n\t\t\t * @private\n\t\t\t */\n\t this._gtz = this.output = new Tone.GreaterThanZero();\n\t //connect\n\t this._param.connect(this._gtz);\n\t };\n\t Tone.extend(Tone.GreaterThan, Tone.Signal);\n\t /**\n\t\t * dispose method\n\t\t * @returns {Tone.GreaterThan} this\n\t\t */\n\t Tone.GreaterThan.prototype.dispose = function () {\n\t Tone.Signal.prototype.dispose.call(this);\n\t this._gtz.dispose();\n\t this._gtz = null;\n\t return this;\n\t };\n\t return Tone.GreaterThan;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Gate only passes a signal through when the incoming\n\t\t * signal exceeds a specified threshold. To do this, Gate uses\n\t\t * a Tone.Follower to follow the amplitude of the incoming signal.\n\t\t * A common implementation of this class is a [Noise Gate](https://en.wikipedia.org/wiki/Noise_gate).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {Decibels|Object} [threshold] The threshold above which the gate will open.\n\t\t * @param {Time=} attack The follower's attack time\n\t\t * @param {Time=} release The follower's release time\n\t\t * @example\n\t\t * var gate = new Tone.Gate(-30, 0.2, 0.3).toMaster();\n\t\t * var mic = new Tone.UserMedia().connect(gate);\n\t\t * //the gate will only pass through the incoming\n\t\t * //signal when it's louder than -30db\n\t\t */\n\t Tone.Gate = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'threshold',\n\t 'attack',\n\t 'release'\n\t ], Tone.Gate);\n\t Tone.AudioNode.call(this);\n\t this.createInsOuts(1, 1);\n\t /**\n\t\t\t * @type {Tone.Follower}\n\t\t\t * @private\n\t\t\t */\n\t this._follower = new Tone.Follower(options.attack, options.release);\n\t /**\n\t\t\t * @type {Tone.GreaterThan}\n\t\t\t * @private\n\t\t\t */\n\t this._gt = new Tone.GreaterThan(Tone.dbToGain(options.threshold));\n\t //the connections\n\t this.input.connect(this.output);\n\t //the control signal\n\t this.input.chain(this._gt, this._follower, this.output.gain);\n\t };\n\t Tone.extend(Tone.Gate, Tone.AudioNode);\n\t /**\n\t\t * @const\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.Gate.defaults = {\n\t 'attack': 0.1,\n\t 'release': 0.1,\n\t 'threshold': -40\n\t };\n\t /**\n\t\t * The threshold of the gate in decibels\n\t\t * @memberOf Tone.Gate#\n\t\t * @type {Decibels}\n\t\t * @name threshold\n\t\t */\n\t Object.defineProperty(Tone.Gate.prototype, 'threshold', {\n\t get: function () {\n\t return Tone.gainToDb(this._gt.value);\n\t },\n\t set: function (thresh) {\n\t this._gt.value = Tone.dbToGain(thresh);\n\t }\n\t });\n\t /**\n\t\t * The attack speed of the gate\n\t\t * @memberOf Tone.Gate#\n\t\t * @type {Time}\n\t\t * @name attack\n\t\t */\n\t Object.defineProperty(Tone.Gate.prototype, 'attack', {\n\t get: function () {\n\t return this._follower.attack;\n\t },\n\t set: function (attackTime) {\n\t this._follower.attack = attackTime;\n\t }\n\t });\n\t /**\n\t\t * The release speed of the gate\n\t\t * @memberOf Tone.Gate#\n\t\t * @type {Time}\n\t\t * @name release\n\t\t */\n\t Object.defineProperty(Tone.Gate.prototype, 'release', {\n\t get: function () {\n\t return this._follower.release;\n\t },\n\t set: function (releaseTime) {\n\t this._follower.release = releaseTime;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Gate} this\n\t\t */\n\t Tone.Gate.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._follower.dispose();\n\t this._gt.dispose();\n\t this._follower = null;\n\t this._gt = null;\n\t return this;\n\t };\n\t return Tone.Gate;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.TickSignal extends Tone.Signal, but adds the capability\n\t\t * to calculate the number of elapsed ticks. exponential and target curves\n\t\t * are approximated with multiple linear ramps.\n\t\t *\n\t\t * Thank you Bruno Dias, H. Sofia Pinto, and David M. Matos, for your [WAC paper](https://smartech.gatech.edu/bitstream/handle/1853/54588/WAC2016-49.pdf)\n\t\t * describing integrating timing functions for tempo calculations.\n\t\t *\n\t\t * @param {Number} value The initial value of the signal\n\t\t * @extends {Tone.Signal}\n\t\t */\n\t Tone.TickSignal = function (value) {\n\t value = Tone.defaultArg(value, 1);\n\t Tone.Signal.call(this, {\n\t 'units': Tone.Type.Ticks,\n\t 'value': value\n\t });\n\t //extend the memory\n\t this._events.memory = Infinity;\n\t //clear the clock from the beginning\n\t this.cancelScheduledValues(0);\n\t //set an initial event\n\t this._events.add({\n\t 'type': Tone.Param.AutomationType.SetValue,\n\t 'time': 0,\n\t 'value': value\n\t });\n\t };\n\t Tone.extend(Tone.TickSignal, Tone.Signal);\n\t /**\n\t\t * Wraps Tone.Signal methods so that they also\n\t\t * record the ticks.\n\t\t * @param {Function} method\n\t\t * @return {Function}\n\t\t * @private\n\t\t */\n\t function _wrapScheduleMethods(method) {\n\t return function (value, time) {\n\t time = this.toSeconds(time);\n\t method.apply(this, arguments);\n\t var event = this._events.get(time);\n\t var previousEvent = this._events.previousEvent(event);\n\t var ticksUntilTime = this._getTicksUntilEvent(previousEvent, time);\n\t event.ticks = Math.max(ticksUntilTime, 0);\n\t return this;\n\t };\n\t }\n\t Tone.TickSignal.prototype.setValueAtTime = _wrapScheduleMethods(Tone.Signal.prototype.setValueAtTime);\n\t Tone.TickSignal.prototype.linearRampToValueAtTime = _wrapScheduleMethods(Tone.Signal.prototype.linearRampToValueAtTime);\n\t /**\n\t\t * Start exponentially approaching the target value at the given time with\n\t\t * a rate having the given time constant.\n\t\t * @param {number} value\n\t\t * @param {Time} startTime\n\t\t * @param {number} timeConstant\n\t\t * @returns {Tone.TickSignal} this\n\t\t */\n\t Tone.TickSignal.prototype.setTargetAtTime = function (value, time, constant) {\n\t //aproximate it with multiple linear ramps\n\t time = this.toSeconds(time);\n\t this.setRampPoint(time);\n\t value = this._fromUnits(value);\n\t //start from previously scheduled value\n\t var prevEvent = this._events.get(time);\n\t var segments = Math.round(Math.max(1 / constant, 1));\n\t for (var i = 0; i <= segments; i++) {\n\t var segTime = constant * i + time;\n\t var rampVal = this._exponentialApproach(prevEvent.time, prevEvent.value, value, constant, segTime);\n\t this.linearRampToValueAtTime(this._toUnits(rampVal), segTime);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Schedules an exponential continuous change in parameter value from\n\t\t * the previous scheduled parameter value to the given value.\n\t\t * @param {number} value\n\t\t * @param {Time} endTime\n\t\t * @returns {Tone.TickSignal} this\n\t\t */\n\t Tone.TickSignal.prototype.exponentialRampToValueAtTime = function (value, time) {\n\t //aproximate it with multiple linear ramps\n\t time = this.toSeconds(time);\n\t value = this._fromUnits(value);\n\t //start from previously scheduled value\n\t var prevEvent = this._events.get(time);\n\t if (prevEvent === null) {\n\t prevEvent = {\n\t 'value': this._initialValue,\n\t 'time': 0\n\t };\n\t }\n\t //approx 10 segments per second\n\t var segments = Math.round(Math.max((time - prevEvent.time) * 10, 1));\n\t var segmentDur = (time - prevEvent.time) / segments;\n\t for (var i = 0; i <= segments; i++) {\n\t var segTime = segmentDur * i + prevEvent.time;\n\t var rampVal = this._exponentialInterpolate(prevEvent.time, prevEvent.value, time, value, segTime);\n\t this.linearRampToValueAtTime(this._toUnits(rampVal), segTime);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Returns the tick value at the time. Takes into account\n\t\t * any automation curves scheduled on the signal.\n\t\t * @private\n\t\t * @param {Time} time The time to get the tick count at\n\t\t * @return {Ticks} The number of ticks which have elapsed at the time\n\t\t * given any automations.\n\t\t */\n\t Tone.TickSignal.prototype._getTicksUntilEvent = function (event, time) {\n\t if (event === null) {\n\t event = {\n\t 'ticks': 0,\n\t 'time': 0\n\t };\n\t } else if (Tone.isUndef(event.ticks)) {\n\t var previousEvent = this._events.previousEvent(event);\n\t event.ticks = this._getTicksUntilEvent(previousEvent, event.time);\n\t }\n\t var val0 = this.getValueAtTime(event.time);\n\t var val1 = this.getValueAtTime(time);\n\t //if it's right on the line, take the previous value\n\t if (this._events.get(time).time === time && this._events.get(time).type === Tone.Param.AutomationType.SetValue) {\n\t val1 = this.getValueAtTime(time - this.sampleTime);\n\t }\n\t return 0.5 * (time - event.time) * (val0 + val1) + event.ticks;\n\t };\n\t /**\n\t\t * Returns the tick value at the time. Takes into account\n\t\t * any automation curves scheduled on the signal.\n\t\t * @param {Time} time The time to get the tick count at\n\t\t * @return {Ticks} The number of ticks which have elapsed at the time\n\t\t * given any automations.\n\t\t */\n\t Tone.TickSignal.prototype.getTicksAtTime = function (time) {\n\t time = this.toSeconds(time);\n\t var event = this._events.get(time);\n\t return Math.max(this._getTicksUntilEvent(event, time), 0);\n\t };\n\t /**\n\t\t * Return the elapsed time of the number of ticks from the given time\n\t\t * @param {Ticks} ticks The number of ticks to calculate\n\t\t * @param {Time} time The time to get the next tick from\n\t\t * @return {Seconds} The duration of the number of ticks from the given time in seconds\n\t\t */\n\t Tone.TickSignal.prototype.getDurationOfTicks = function (ticks, time) {\n\t time = this.toSeconds(time);\n\t var currentTick = this.getTicksAtTime(time);\n\t return this.getTimeOfTick(currentTick + ticks) - time;\n\t };\n\t /**\n\t\t * Given a tick, returns the time that tick occurs at.\n\t\t * @param {Ticks} tick\n\t\t * @return {Time} The time that the tick occurs.\n\t\t */\n\t Tone.TickSignal.prototype.getTimeOfTick = function (tick) {\n\t var before = this._events.get(tick, 'ticks');\n\t var after = this._events.getAfter(tick, 'ticks');\n\t if (before && before.ticks === tick) {\n\t return before.time;\n\t } else if (before && after && after.type === Tone.Param.AutomationType.Linear && before.value !== after.value) {\n\t var val0 = this.getValueAtTime(before.time);\n\t var val1 = this.getValueAtTime(after.time);\n\t var delta = (val1 - val0) / (after.time - before.time);\n\t var k = Math.sqrt(Math.pow(val0, 2) - 2 * delta * (before.ticks - tick));\n\t var sol1 = (-val0 + k) / delta;\n\t var sol2 = (-val0 - k) / delta;\n\t return (sol1 > 0 ? sol1 : sol2) + before.time;\n\t } else if (before) {\n\t if (before.value === 0) {\n\t return Infinity;\n\t } else {\n\t return before.time + (tick - before.ticks) / before.value;\n\t }\n\t } else {\n\t return tick / this._initialValue;\n\t }\n\t };\n\t /**\n\t\t * Convert some number of ticks their the duration in seconds accounting\n\t\t * for any automation curves starting at the given time.\n\t\t * @param {Ticks} ticks The number of ticks to convert to seconds.\n\t\t * @param {Time} [when=now] When along the automation timeline to convert the ticks.\n\t\t * @return {Tone.Time} The duration in seconds of the ticks.\n\t\t */\n\t Tone.TickSignal.prototype.ticksToTime = function (ticks, when) {\n\t when = this.toSeconds(when);\n\t return new Tone.Time(this.getDurationOfTicks(ticks, when));\n\t };\n\t /**\n\t\t * The inverse of [ticksToTime](#tickstotime). Convert a duration in\n\t\t * seconds to the corresponding number of ticks accounting for any\n\t\t * automation curves starting at the given time.\n\t\t * @param {Time} duration The time interval to convert to ticks.\n\t\t * @param {Time} [when=now] When along the automation timeline to convert the ticks.\n\t\t * @return {Tone.Ticks} The duration in ticks.\n\t\t */\n\t Tone.TickSignal.prototype.timeToTicks = function (duration, when) {\n\t when = this.toSeconds(when);\n\t duration = this.toSeconds(duration);\n\t var startTicks = this.getTicksAtTime(when);\n\t var endTicks = this.getTicksAtTime(when + duration);\n\t return new Tone.Ticks(endTicks - startTicks);\n\t };\n\t return Tone.TickSignal;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class A Timeline State. Provides the methods: <code>setStateAtTime(\"state\", time)</code>\n\t\t * and <code>getValueAtTime(time)</code>.\n\t\t *\n\t\t * @extends {Tone.Timeline}\n\t\t * @param {String} initial The initial state of the TimelineState. \n\t\t * Defaults to <code>undefined</code>\n\t\t */\n\t Tone.TimelineState = function (initial) {\n\t Tone.Timeline.call(this);\n\t /**\n\t\t\t * The initial state\n\t\t\t * @private\n\t\t\t * @type {String}\n\t\t\t */\n\t this._initial = initial;\n\t };\n\t Tone.extend(Tone.TimelineState, Tone.Timeline);\n\t /**\n\t\t * Returns the scheduled state scheduled before or at\n\t\t * the given time.\n\t\t * @param {Number} time The time to query.\n\t\t * @return {String} The name of the state input in setStateAtTime.\n\t\t */\n\t Tone.TimelineState.prototype.getValueAtTime = function (time) {\n\t var event = this.get(time);\n\t if (event !== null) {\n\t return event.state;\n\t } else {\n\t return this._initial;\n\t }\n\t };\n\t /**\n\t\t * Add a state to the timeline.\n\t\t * @param {String} state The name of the state to set.\n\t\t * @param {Number} time The time to query.\n\t\t * @returns {Tone.TimelineState} this\n\t\t */\n\t Tone.TimelineState.prototype.setStateAtTime = function (state, time) {\n\t //all state changes need to be >= the previous state time\n\t //TODO throw error if time < the previous event time\n\t this.add({\n\t 'state': state,\n\t 'time': time\n\t });\n\t return this;\n\t };\n\t /**\n\t\t * Return the event before the time with the given state\n\t\t * @param {Tone.State} state The state to look for\n\t\t * @param {Time} time When to check before\t\t\t\n\t\t * @return {Object} The event with the given state before the time\n\t\t */\n\t Tone.TimelineState.prototype.getLastState = function (state, time) {\n\t time = this.toSeconds(time);\n\t var index = this._search(time);\n\t for (var i = index; i >= 0; i--) {\n\t var event = this._timeline[i];\n\t if (event.state === state) {\n\t return event;\n\t }\n\t }\n\t };\n\t /**\n\t\t * Return the event after the time with the given state\n\t\t * @param {Tone.State} state The state to look for\n\t\t * @param {Time} time When to check from\n\t\t * @return {Object} The event with the given state after the time\n\t\t */\n\t Tone.TimelineState.prototype.getNextState = function (state, time) {\n\t time = this.toSeconds(time);\n\t var index = this._search(time);\n\t if (index !== -1) {\n\t for (var i = index; i < this._timeline.length; i++) {\n\t var event = this._timeline[i];\n\t if (event.state === state) {\n\t return event;\n\t }\n\t }\n\t }\n\t };\n\t return Tone.TimelineState;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Uses [Tone.TickSignal](TickSignal) to track elapsed ticks with\n\t\t * \t\tcomplex automation curves.\n\t\t *\n\t\t * \t@constructor\n\t * @param {Frequency} frequency The initial frequency that the signal ticks at\n\t\t * @extends {Tone}\n\t\t */\n\t Tone.TickSource = function () {\n\t var options = Tone.defaults(arguments, ['frequency'], Tone.TickSource);\n\t /**\n\t\t\t * The frequency the callback function should be invoked.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = new Tone.TickSignal(options.frequency, Tone.Type.Frequency);\n\t this._readOnly('frequency');\n\t /**\n\t\t\t * The state timeline\n\t\t\t * @type {Tone.TimelineState}\n\t\t\t * @private\n\t\t\t */\n\t this._state = new Tone.TimelineState(Tone.State.Stopped);\n\t this._state.setStateAtTime(Tone.State.Stopped, 0);\n\t /**\n\t\t\t * The offset values of the ticks\n\t\t\t * @type {Tone.Timeline}\n\t\t\t * @private\n\t\t\t */\n\t this._tickOffset = new Tone.Timeline();\n\t //add the first event\n\t this.setTicksAtTime(0, 0);\n\t };\n\t Tone.extend(Tone.TickSource);\n\t /**\n\t\t * The defaults\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.TickSource.defaults = { 'frequency': 1 };\n\t /**\n\t\t * Returns the playback state of the source, either \"started\", \"stopped\" or \"paused\".\n\t\t * @type {Tone.State}\n\t\t * @readOnly\n\t\t * @memberOf Tone.TickSource#\n\t\t * @name state\n\t\t */\n\t Object.defineProperty(Tone.TickSource.prototype, 'state', {\n\t get: function () {\n\t return this._state.getValueAtTime(this.now());\n\t }\n\t });\n\t /**\n\t\t * Start the clock at the given time. Optionally pass in an offset\n\t\t * of where to start the tick counter from.\n\t\t * @param {Time=} time The time the clock should start\n\t\t * @param {Ticks=0} offset The number of ticks to start the source at\n\t\t * @return {Tone.TickSource} this\n\t\t */\n\t Tone.TickSource.prototype.start = function (time, offset) {\n\t time = this.toSeconds(time);\n\t if (this._state.getValueAtTime(time) !== Tone.State.Started) {\n\t this._state.setStateAtTime(Tone.State.Started, time);\n\t if (Tone.isDefined(offset)) {\n\t this.setTicksAtTime(offset, time);\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Stop the clock. Stopping the clock resets the tick counter to 0.\n\t\t * @param {Time} [time=now] The time when the clock should stop.\n\t\t * @returns {Tone.TickSource} this\n\t\t * @example\n\t\t * clock.stop();\n\t\t */\n\t Tone.TickSource.prototype.stop = function (time) {\n\t time = this.toSeconds(time);\n\t //cancel the previous stop\n\t if (this._state.getValueAtTime(time) === Tone.State.Stopped) {\n\t var event = this._state.get(time);\n\t if (event.time > 0) {\n\t this._tickOffset.cancel(event.time);\n\t this._state.cancel(event.time);\n\t }\n\t }\n\t this._state.cancel(time);\n\t this._state.setStateAtTime(Tone.State.Stopped, time);\n\t this.setTicksAtTime(0, time);\n\t return this;\n\t };\n\t /**\n\t\t * Pause the clock. Pausing does not reset the tick counter.\n\t\t * @param {Time} [time=now] The time when the clock should stop.\n\t\t * @returns {Tone.TickSource} this\n\t\t */\n\t Tone.TickSource.prototype.pause = function (time) {\n\t time = this.toSeconds(time);\n\t if (this._state.getValueAtTime(time) === Tone.State.Started) {\n\t this._state.setStateAtTime(Tone.State.Paused, time);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Cancel start/stop/pause and setTickAtTime events scheduled after the given time.\n\t\t * @param {Time} [time=now] When to clear the events after\n\t\t * @returns {Tone.TickSource} this\n\t\t */\n\t Tone.TickSource.prototype.cancel = function (time) {\n\t time = this.toSeconds(time);\n\t this._state.cancel(time);\n\t this._tickOffset.cancel(time);\n\t return this;\n\t };\n\t /**\n\t\t * Get the elapsed ticks at the given time\n\t\t * @param {Time} time When to get the tick value\n\t\t * @return {Ticks} The number of ticks\n\t\t */\n\t Tone.TickSource.prototype.getTicksAtTime = function (time) {\n\t time = this.toSeconds(time);\n\t var stopEvent = this._state.getLastState(Tone.State.Stopped, time);\n\t //this event allows forEachBetween to iterate until the current time\n\t var tmpEvent = {\n\t state: Tone.State.Paused,\n\t time: time\n\t };\n\t this._state.add(tmpEvent);\n\t //keep track of the previous offset event\n\t var lastState = stopEvent;\n\t var elapsedTicks = 0;\n\t //iterate through all the events since the last stop\n\t this._state.forEachBetween(stopEvent.time, time + this.sampleTime, function (e) {\n\t var periodStartTime = lastState.time;\n\t //if there is an offset event in this period use that\n\t var offsetEvent = this._tickOffset.get(e.time);\n\t if (offsetEvent.time >= lastState.time) {\n\t elapsedTicks = offsetEvent.ticks;\n\t periodStartTime = offsetEvent.time;\n\t }\n\t if (lastState.state === Tone.State.Started && e.state !== Tone.State.Started) {\n\t elapsedTicks += this.frequency.getTicksAtTime(e.time) - this.frequency.getTicksAtTime(periodStartTime);\n\t }\n\t lastState = e;\n\t }.bind(this));\n\t //remove the temporary event\n\t this._state.remove(tmpEvent);\n\t //return the ticks\n\t return elapsedTicks;\n\t };\n\t /**\n\t\t * The number of times the callback was invoked. Starts counting at 0\n\t\t * and increments after the callback was invoked. Returns -1 when stopped.\n\t\t * @memberOf Tone.TickSource#\n\t\t * @name ticks\n\t\t * @type {Ticks}\n\t\t */\n\t Object.defineProperty(Tone.TickSource.prototype, 'ticks', {\n\t get: function () {\n\t return this.getTicksAtTime(this.now());\n\t },\n\t set: function (t) {\n\t this.setTicksAtTime(t, this.now());\n\t }\n\t });\n\t /**\n\t\t * The time since ticks=0 that the TickSource has been running. Accounts\n\t\t * for tempo curves\n\t\t * @memberOf Tone.TickSource#\n\t\t * @name seconds\n\t\t * @type {Seconds}\n\t\t */\n\t Object.defineProperty(Tone.TickSource.prototype, 'seconds', {\n\t get: function () {\n\t return this.getSecondsAtTime(this.now());\n\t },\n\t set: function (s) {\n\t var now = this.now();\n\t var ticks = this.frequency.timeToTicks(s, now);\n\t this.setTicksAtTime(ticks, now);\n\t }\n\t });\n\t /**\n\t\t * Return the elapsed seconds at the given time.\n\t\t * @param {Time} time When to get the elapsed seconds\n\t\t * @return {Seconds} The number of elapsed seconds\n\t\t */\n\t Tone.TickSource.prototype.getSecondsAtTime = function (time) {\n\t time = this.toSeconds(time);\n\t var stopEvent = this._state.getLastState(Tone.State.Stopped, time);\n\t //this event allows forEachBetween to iterate until the current time\n\t var tmpEvent = {\n\t state: Tone.State.Paused,\n\t time: time\n\t };\n\t this._state.add(tmpEvent);\n\t //keep track of the previous offset event\n\t var lastState = stopEvent;\n\t var elapsedSeconds = 0;\n\t //iterate through all the events since the last stop\n\t this._state.forEachBetween(stopEvent.time, time + this.sampleTime, function (e) {\n\t var periodStartTime = lastState.time;\n\t //if there is an offset event in this period use that\n\t var offsetEvent = this._tickOffset.get(e.time);\n\t if (offsetEvent.time >= lastState.time) {\n\t elapsedSeconds = offsetEvent.seconds;\n\t periodStartTime = offsetEvent.time;\n\t }\n\t if (lastState.state === Tone.State.Started && e.state !== Tone.State.Started) {\n\t elapsedSeconds += e.time - periodStartTime;\n\t }\n\t lastState = e;\n\t }.bind(this));\n\t //remove the temporary event\n\t this._state.remove(tmpEvent);\n\t //return the ticks\n\t return elapsedSeconds;\n\t };\n\t /**\n\t\t * Set the clock's ticks at the given time.\n\t\t * @param {Ticks} ticks The tick value to set\n\t\t * @param {Time} time When to set the tick value\n\t\t * @return {Tone.TickSource} this\n\t\t */\n\t Tone.TickSource.prototype.setTicksAtTime = function (ticks, time) {\n\t time = this.toSeconds(time);\n\t this._tickOffset.cancel(time);\n\t this._tickOffset.add({\n\t 'time': time,\n\t 'ticks': ticks,\n\t 'seconds': this.frequency.getDurationOfTicks(ticks, time)\n\t });\n\t return this;\n\t };\n\t /**\n\t\t * Returns the scheduled state at the given time.\n\t\t * @param {Time} time The time to query.\n\t\t * @return {String} The name of the state input in setStateAtTime.\n\t\t * @example\n\t\t * source.start(\"+0.1\");\n\t\t * source.getStateAtTime(\"+0.1\"); //returns \"started\"\n\t\t */\n\t Tone.TickSource.prototype.getStateAtTime = function (time) {\n\t time = this.toSeconds(time);\n\t return this._state.getValueAtTime(time);\n\t };\n\t /**\n\t\t * Get the time of the given tick. The second argument\n\t\t * is when to test before. Since ticks can be set (with setTicksAtTime)\n\t\t * there may be multiple times for a given tick value. \n\t\t * @param {Ticks} ticks The tick number.\n\t\t * @param {Time=} before When to measure the tick value from. \n\t\t * @return {Time} The time of the tick\n\t\t */\n\t Tone.TickSource.prototype.getTimeOfTick = function (tick, before) {\n\t before = Tone.defaultArg(before, this.now());\n\t var offset = this._tickOffset.get(before);\n\t var event = this._state.get(before);\n\t var startTime = Math.max(offset.time, event.time);\n\t var absoluteTicks = this.frequency.getTicksAtTime(startTime) + tick - offset.ticks;\n\t return this.frequency.getTimeOfTick(absoluteTicks);\n\t };\n\t /**\n\t\t * Invoke the callback event at all scheduled ticks between the \n\t\t * start time and the end time\n\t\t * @param {Time} startTime The beginning of the search range\n\t\t * @param {Time} endTime The end of the search range\n\t\t * @param {Function<Time,Ticks>} callback The callback to invoke with each tick\n\t\t * @return {Tone.TickSource} this\n\t\t */\n\t Tone.TickSource.prototype.forEachTickBetween = function (startTime, endTime, callback) {\n\t //only iterate through the sections where it is \"started\"\n\t var lastStateEvent = this._state.get(startTime);\n\t this._state.forEachBetween(startTime, endTime, function (event) {\n\t if (lastStateEvent.state === Tone.State.Started && event.state !== Tone.State.Started) {\n\t this.forEachTickBetween(Math.max(lastStateEvent.time, startTime), event.time - this.sampleTime, callback);\n\t }\n\t lastStateEvent = event;\n\t }.bind(this));\n\t startTime = Math.max(lastStateEvent.time, startTime);\n\t if (lastStateEvent.state === Tone.State.Started && this._state) {\n\t //figure out the difference between the frequency ticks and the \n\t var startTicks = this.frequency.getTicksAtTime(startTime);\n\t var ticksAtStart = this.frequency.getTicksAtTime(lastStateEvent.time);\n\t var diff = startTicks - ticksAtStart;\n\t var offset = diff % 1;\n\t if (offset !== 0) {\n\t offset = 1 - offset;\n\t }\n\t var nextTickTime = this.frequency.getTimeOfTick(startTicks + offset);\n\t var error = null;\n\t while (nextTickTime < endTime && this._state) {\n\t try {\n\t callback(nextTickTime, Math.round(this.getTicksAtTime(nextTickTime)));\n\t } catch (e) {\n\t error = e;\n\t break;\n\t }\n\t if (this._state) {\n\t nextTickTime += this.frequency.getDurationOfTicks(1, nextTickTime);\n\t }\n\t }\n\t }\n\t if (error) {\n\t throw error;\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @returns {Tone.TickSource} this\n\t\t */\n\t Tone.TickSource.prototype.dispose = function () {\n\t Tone.Param.prototype.dispose.call(this);\n\t this._state.dispose();\n\t this._state = null;\n\t this._tickOffset.dispose();\n\t this._tickOffset = null;\n\t this._writable('frequency');\n\t this.frequency.dispose();\n\t this.frequency = null;\n\t return this;\n\t };\n\t return Tone.TickSource;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class A sample accurate clock which provides a callback at the given rate.\n\t\t * While the callback is not sample-accurate (it is still susceptible to\n\t\t * loose JS timing), the time passed in as the argument to the callback\n\t\t * is precise. For most applications, it is better to use Tone.Transport\n\t\t * instead of the Clock by itself since you can synchronize multiple callbacks.\n\t\t *\n\t\t * \t@constructor\n\t\t * @extends {Tone.Emitter}\n\t\t * \t@param {function} callback The callback to be invoked with the time of the audio event\n\t\t * \t@param {Frequency} frequency The rate of the callback\n\t\t * \t@example\n\t\t * //the callback will be invoked approximately once a second\n\t\t * //and will print the time exactly once a second apart.\n\t\t * var clock = new Tone.Clock(function(time){\n\t\t * \tconsole.log(time);\n\t\t * }, 1);\n\t\t */\n\t Tone.Clock = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'callback',\n\t 'frequency'\n\t ], Tone.Clock);\n\t Tone.Emitter.call(this);\n\t /**\n\t\t\t * The callback function to invoke at the scheduled tick.\n\t\t\t * @type {Function}\n\t\t\t */\n\t this.callback = options.callback;\n\t /**\n\t\t\t * The next time the callback is scheduled.\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._nextTick = 0;\n\t /**\n\t\t\t * The tick counter\n\t\t\t * @type {Tone.TickSource}\n\t\t\t * @private\n\t\t\t */\n\t this._tickSource = new Tone.TickSource(options.frequency);\n\t /**\n\t\t\t * The last time the loop callback was invoked\n\t\t\t * @private\n\t\t\t * @type {Number}\n\t\t\t */\n\t this._lastUpdate = 0;\n\t /**\n\t\t\t * The rate the callback function should be invoked.\n\t\t\t * @type {BPM}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = this._tickSource.frequency;\n\t this._readOnly('frequency');\n\t /**\n\t\t\t * The state timeline\n\t\t\t * @type {Tone.TimelineState}\n\t\t\t * @private\n\t\t\t */\n\t this._state = new Tone.TimelineState(Tone.State.Stopped);\n\t //add an initial state\n\t this._state.setStateAtTime(Tone.State.Stopped, 0);\n\t /**\n\t\t\t * The loop function bound to its context.\n\t\t\t * This is necessary to remove the event in the end.\n\t\t\t * @type {Function}\n\t\t\t * @private\n\t\t\t */\n\t this._boundLoop = this._loop.bind(this);\n\t //bind a callback to the worker thread\n\t this.context.on('tick', this._boundLoop);\n\t };\n\t Tone.extend(Tone.Clock, Tone.Emitter);\n\t /**\n\t\t * The defaults\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Clock.defaults = {\n\t 'callback': Tone.noOp,\n\t 'frequency': 1\n\t };\n\t /**\n\t\t * Returns the playback state of the source, either \"started\", \"stopped\" or \"paused\".\n\t\t * @type {Tone.State}\n\t\t * @readOnly\n\t\t * @memberOf Tone.Clock#\n\t\t * @name state\n\t\t */\n\t Object.defineProperty(Tone.Clock.prototype, 'state', {\n\t get: function () {\n\t return this._state.getValueAtTime(this.now());\n\t }\n\t });\n\t /**\n\t\t * Start the clock at the given time. Optionally pass in an offset\n\t\t * of where to start the tick counter from.\n\t\t * @param {Time=} time The time the clock should start\n\t\t * @param {Ticks=} offset Where the tick counter starts counting from.\n\t\t * @return {Tone.Clock} this\n\t\t */\n\t Tone.Clock.prototype.start = function (time, offset) {\n\t time = this.toSeconds(time);\n\t if (this._state.getValueAtTime(time) !== Tone.State.Started) {\n\t this._state.setStateAtTime(Tone.State.Started, time);\n\t this._tickSource.start(time, offset);\n\t if (time < this._lastUpdate) {\n\t this.emit('start', time, offset);\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Stop the clock. Stopping the clock resets the tick counter to 0.\n\t\t * @param {Time} [time=now] The time when the clock should stop.\n\t\t * @returns {Tone.Clock} this\n\t\t * @example\n\t\t * clock.stop();\n\t\t */\n\t Tone.Clock.prototype.stop = function (time) {\n\t time = this.toSeconds(time);\n\t this._state.cancel(time);\n\t this._state.setStateAtTime(Tone.State.Stopped, time);\n\t this._tickSource.stop(time);\n\t if (time < this._lastUpdate) {\n\t this.emit('stop', time);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Pause the clock. Pausing does not reset the tick counter.\n\t\t * @param {Time} [time=now] The time when the clock should stop.\n\t\t * @returns {Tone.Clock} this\n\t\t */\n\t Tone.Clock.prototype.pause = function (time) {\n\t time = this.toSeconds(time);\n\t if (this._state.getValueAtTime(time) === Tone.State.Started) {\n\t this._state.setStateAtTime(Tone.State.Paused, time);\n\t this._tickSource.pause(time);\n\t if (time < this._lastUpdate) {\n\t this.emit('pause', time);\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * The number of times the callback was invoked. Starts counting at 0\n\t\t * and increments after the callback was invoked.\n\t\t * @type {Ticks}\n\t\t */\n\t Object.defineProperty(Tone.Clock.prototype, 'ticks', {\n\t get: function () {\n\t return Math.ceil(this.getTicksAtTime(this.now()));\n\t },\n\t set: function (t) {\n\t this._tickSource.ticks = t;\n\t }\n\t });\n\t /**\n\t\t * The time since ticks=0 that the Clock has been running. Accounts\n\t\t * for tempo curves\n\t\t * @type {Seconds}\n\t\t */\n\t Object.defineProperty(Tone.Clock.prototype, 'seconds', {\n\t get: function () {\n\t return this._tickSource.seconds;\n\t },\n\t set: function (s) {\n\t this._tickSource.seconds = s;\n\t }\n\t });\n\t /**\n\t\t * Return the elapsed seconds at the given time.\n\t\t * @param {Time} time When to get the elapsed seconds\n\t\t * @return {Seconds} The number of elapsed seconds\n\t\t */\n\t Tone.Clock.prototype.getSecondsAtTime = function (time) {\n\t return this._tickSource.getSecondsAtTime(time);\n\t };\n\t /**\n\t\t * Set the clock's ticks at the given time.\n\t\t * @param {Ticks} ticks The tick value to set\n\t\t * @param {Time} time When to set the tick value\n\t\t * @return {Tone.Clock} this\n\t\t */\n\t Tone.Clock.prototype.setTicksAtTime = function (ticks, time) {\n\t this._tickSource.setTicksAtTime(ticks, time);\n\t return this;\n\t };\n\t /**\n\t\t * Get the clock's ticks at the given time.\n\t\t * @param {Time} time When to get the tick value\n\t\t * @return {Ticks} The tick value at the given time.\n\t\t */\n\t Tone.Clock.prototype.getTicksAtTime = function (time) {\n\t return this._tickSource.getTicksAtTime(time);\n\t };\n\t /**\n\t\t * Get the time of the next tick\n\t\t * @param {Ticks} ticks The tick number.\n\t\t * @param {Time} before \n\t\t * @return {Tone.Clock} this\n\t\t */\n\t Tone.Clock.prototype.nextTickTime = function (offset, when) {\n\t when = this.toSeconds(when);\n\t var currentTick = this.getTicksAtTime(when);\n\t return this._tickSource.getTimeOfTick(currentTick + offset, when);\n\t };\n\t /**\n\t\t * The scheduling loop.\n\t\t * @private\n\t\t */\n\t Tone.Clock.prototype._loop = function () {\n\t var startTime = this._lastUpdate;\n\t var endTime = this.now();\n\t this._lastUpdate = endTime;\n\t if (startTime !== endTime) {\n\t //the state change events\n\t this._state.forEachBetween(startTime, endTime, function (e) {\n\t switch (e.state) {\n\t case Tone.State.Started:\n\t var offset = this._tickSource.getTicksAtTime(e.time);\n\t this.emit('start', e.time, offset);\n\t break;\n\t case Tone.State.Stopped:\n\t if (e.time !== 0) {\n\t this.emit('stop', e.time);\n\t }\n\t break;\n\t case Tone.State.Paused:\n\t this.emit('pause', e.time);\n\t break;\n\t }\n\t }.bind(this));\n\t //the tick callbacks\n\t this._tickSource.forEachTickBetween(startTime, endTime, function (time, ticks) {\n\t this.callback(time, ticks);\n\t }.bind(this));\n\t }\n\t };\n\t /**\n\t\t * Returns the scheduled state at the given time.\n\t\t * @param {Time} time The time to query.\n\t\t * @return {String} The name of the state input in setStateAtTime.\n\t\t * @example\n\t\t * clock.start(\"+0.1\");\n\t\t * clock.getStateAtTime(\"+0.1\"); //returns \"started\"\n\t\t */\n\t Tone.Clock.prototype.getStateAtTime = function (time) {\n\t time = this.toSeconds(time);\n\t return this._state.getValueAtTime(time);\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @returns {Tone.Clock} this\n\t\t */\n\t Tone.Clock.prototype.dispose = function () {\n\t Tone.Emitter.prototype.dispose.call(this);\n\t this.context.off('tick', this._boundLoop);\n\t this._writable('frequency');\n\t this._tickSource.dispose();\n\t this._tickSource = null;\n\t this.frequency = null;\n\t this._boundLoop = null;\n\t this._nextTick = Infinity;\n\t this.callback = null;\n\t this._state.dispose();\n\t this._state = null;\n\t };\n\t return Tone.Clock;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Similar to Tone.Timeline, but all events represent\n\t\t * intervals with both \"time\" and \"duration\" times. The\n\t\t * events are placed in a tree structure optimized\n\t\t * for querying an intersection point with the timeline\n\t\t * events. Internally uses an [Interval Tree](https://en.wikipedia.org/wiki/Interval_tree)\n\t\t * to represent the data.\n\t\t * @extends {Tone}\n\t\t */\n\t Tone.IntervalTimeline = function () {\n\t Tone.call(this);\n\t /**\n\t\t\t * The root node of the inteval tree\n\t\t\t * @type {IntervalNode}\n\t\t\t * @private\n\t\t\t */\n\t this._root = null;\n\t /**\n\t\t\t * Keep track of the length of the timeline.\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._length = 0;\n\t };\n\t Tone.extend(Tone.IntervalTimeline);\n\t /**\n\t\t * The event to add to the timeline. All events must\n\t\t * have a time and duration value\n\t\t * @param {Object} event The event to add to the timeline\n\t\t * @return {Tone.IntervalTimeline} this\n\t\t */\n\t Tone.IntervalTimeline.prototype.add = function (event) {\n\t if (Tone.isUndef(event.time) || Tone.isUndef(event.duration)) {\n\t throw new Error('Tone.IntervalTimeline: events must have time and duration parameters');\n\t }\n\t event.time = event.time.valueOf();\n\t var node = new IntervalNode(event.time, event.time + event.duration, event);\n\t if (this._root === null) {\n\t this._root = node;\n\t } else {\n\t this._root.insert(node);\n\t }\n\t this._length++;\n\t // Restructure tree to be balanced\n\t while (node !== null) {\n\t node.updateHeight();\n\t node.updateMax();\n\t this._rebalance(node);\n\t node = node.parent;\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Remove an event from the timeline.\n\t\t * @param {Object} event The event to remove from the timeline\n\t\t * @return {Tone.IntervalTimeline} this\n\t\t */\n\t Tone.IntervalTimeline.prototype.remove = function (event) {\n\t if (this._root !== null) {\n\t var results = [];\n\t this._root.search(event.time, results);\n\t for (var i = 0; i < results.length; i++) {\n\t var node = results[i];\n\t if (node.event === event) {\n\t this._removeNode(node);\n\t this._length--;\n\t break;\n\t }\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * The number of items in the timeline.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.IntervalTimeline#\n\t\t * @name length\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.IntervalTimeline.prototype, 'length', {\n\t get: function () {\n\t return this._length;\n\t }\n\t });\n\t /**\n\t\t * Remove events whose time time is after the given time\n\t\t * @param {Number} time The time to query.\n\t\t * @returns {Tone.IntervalTimeline} this\n\t\t */\n\t Tone.IntervalTimeline.prototype.cancel = function (after) {\n\t this.forEachFrom(after, function (event) {\n\t this.remove(event);\n\t }.bind(this));\n\t return this;\n\t };\n\t /**\n\t\t * Set the root node as the given node\n\t\t * @param {IntervalNode} node\n\t\t * @private\n\t\t */\n\t Tone.IntervalTimeline.prototype._setRoot = function (node) {\n\t this._root = node;\n\t if (this._root !== null) {\n\t this._root.parent = null;\n\t }\n\t };\n\t /**\n\t\t * Replace the references to the node in the node's parent\n\t\t * with the replacement node.\n\t\t * @param {IntervalNode} node\n\t\t * @param {IntervalNode} replacement\n\t\t * @private\n\t\t */\n\t Tone.IntervalTimeline.prototype._replaceNodeInParent = function (node, replacement) {\n\t if (node.parent !== null) {\n\t if (node.isLeftChild()) {\n\t node.parent.left = replacement;\n\t } else {\n\t node.parent.right = replacement;\n\t }\n\t this._rebalance(node.parent);\n\t } else {\n\t this._setRoot(replacement);\n\t }\n\t };\n\t /**\n\t\t * Remove the node from the tree and replace it with\n\t\t * a successor which follows the schema.\n\t\t * @param {IntervalNode} node\n\t\t * @private\n\t\t */\n\t Tone.IntervalTimeline.prototype._removeNode = function (node) {\n\t if (node.left === null && node.right === null) {\n\t this._replaceNodeInParent(node, null);\n\t } else if (node.right === null) {\n\t this._replaceNodeInParent(node, node.left);\n\t } else if (node.left === null) {\n\t this._replaceNodeInParent(node, node.right);\n\t } else {\n\t var balance = node.getBalance();\n\t var replacement, temp;\n\t if (balance > 0) {\n\t if (node.left.right === null) {\n\t replacement = node.left;\n\t replacement.right = node.right;\n\t temp = replacement;\n\t } else {\n\t replacement = node.left.right;\n\t while (replacement.right !== null) {\n\t replacement = replacement.right;\n\t }\n\t replacement.parent.right = replacement.left;\n\t temp = replacement.parent;\n\t replacement.left = node.left;\n\t replacement.right = node.right;\n\t }\n\t } else if (node.right.left === null) {\n\t replacement = node.right;\n\t replacement.left = node.left;\n\t temp = replacement;\n\t } else {\n\t replacement = node.right.left;\n\t while (replacement.left !== null) {\n\t replacement = replacement.left;\n\t }\n\t replacement.parent = replacement.parent;\n\t replacement.parent.left = replacement.right;\n\t temp = replacement.parent;\n\t replacement.left = node.left;\n\t replacement.right = node.right;\n\t }\n\t if (node.parent !== null) {\n\t if (node.isLeftChild()) {\n\t node.parent.left = replacement;\n\t } else {\n\t node.parent.right = replacement;\n\t }\n\t } else {\n\t this._setRoot(replacement);\n\t }\n\t // this._replaceNodeInParent(node, replacement);\n\t this._rebalance(temp);\n\t }\n\t node.dispose();\n\t };\n\t /**\n\t\t * Rotate the tree to the left\n\t\t * @param {IntervalNode} node\n\t\t * @private\n\t\t */\n\t Tone.IntervalTimeline.prototype._rotateLeft = function (node) {\n\t var parent = node.parent;\n\t var isLeftChild = node.isLeftChild();\n\t // Make node.right the new root of this sub tree (instead of node)\n\t var pivotNode = node.right;\n\t node.right = pivotNode.left;\n\t pivotNode.left = node;\n\t if (parent !== null) {\n\t if (isLeftChild) {\n\t parent.left = pivotNode;\n\t } else {\n\t parent.right = pivotNode;\n\t }\n\t } else {\n\t this._setRoot(pivotNode);\n\t }\n\t };\n\t /**\n\t\t * Rotate the tree to the right\n\t\t * @param {IntervalNode} node\n\t\t * @private\n\t\t */\n\t Tone.IntervalTimeline.prototype._rotateRight = function (node) {\n\t var parent = node.parent;\n\t var isLeftChild = node.isLeftChild();\n\t // Make node.left the new root of this sub tree (instead of node)\n\t var pivotNode = node.left;\n\t node.left = pivotNode.right;\n\t pivotNode.right = node;\n\t if (parent !== null) {\n\t if (isLeftChild) {\n\t parent.left = pivotNode;\n\t } else {\n\t parent.right = pivotNode;\n\t }\n\t } else {\n\t this._setRoot(pivotNode);\n\t }\n\t };\n\t /**\n\t\t * Balance the BST\n\t\t * @param {IntervalNode} node\n\t\t * @private\n\t\t */\n\t Tone.IntervalTimeline.prototype._rebalance = function (node) {\n\t var balance = node.getBalance();\n\t if (balance > 1) {\n\t if (node.left.getBalance() < 0) {\n\t this._rotateLeft(node.left);\n\t } else {\n\t this._rotateRight(node);\n\t }\n\t } else if (balance < -1) {\n\t if (node.right.getBalance() > 0) {\n\t this._rotateRight(node.right);\n\t } else {\n\t this._rotateLeft(node);\n\t }\n\t }\n\t };\n\t /**\n\t\t * Get an event whose time and duration span the give time. Will\n\t\t * return the match whose \"time\" value is closest to the given time.\n\t\t * @param {Object} event The event to add to the timeline\n\t\t * @return {Object} The event which spans the desired time\n\t\t */\n\t Tone.IntervalTimeline.prototype.get = function (time) {\n\t if (this._root !== null) {\n\t var results = [];\n\t this._root.search(time, results);\n\t if (results.length > 0) {\n\t var max = results[0];\n\t for (var i = 1; i < results.length; i++) {\n\t if (results[i].low > max.low) {\n\t max = results[i];\n\t }\n\t }\n\t return max.event;\n\t }\n\t }\n\t return null;\n\t };\n\t /**\n\t\t * Iterate over everything in the timeline.\n\t\t * @param {Function} callback The callback to invoke with every item\n\t\t * @returns {Tone.IntervalTimeline} this\n\t\t */\n\t Tone.IntervalTimeline.prototype.forEach = function (callback) {\n\t if (this._root !== null) {\n\t var allNodes = [];\n\t this._root.traverse(function (node) {\n\t allNodes.push(node);\n\t });\n\t for (var i = 0; i < allNodes.length; i++) {\n\t var ev = allNodes[i].event;\n\t if (ev) {\n\t callback(ev);\n\t }\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Iterate over everything in the array in which the given time\n\t\t * overlaps with the time and duration time of the event.\n\t\t * @param {Number} time The time to check if items are overlapping\n\t\t * @param {Function} callback The callback to invoke with every item\n\t\t * @returns {Tone.IntervalTimeline} this\n\t\t */\n\t Tone.IntervalTimeline.prototype.forEachAtTime = function (time, callback) {\n\t if (this._root !== null) {\n\t var results = [];\n\t this._root.search(time, results);\n\t for (var i = results.length - 1; i >= 0; i--) {\n\t var ev = results[i].event;\n\t if (ev) {\n\t callback(ev);\n\t }\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Iterate over everything in the array in which the time is greater\n\t\t * than or equal to the given time.\n\t\t * @param {Number} time The time to check if items are before\n\t\t * @param {Function} callback The callback to invoke with every item\n\t\t * @returns {Tone.IntervalTimeline} this\n\t\t */\n\t Tone.IntervalTimeline.prototype.forEachFrom = function (time, callback) {\n\t if (this._root !== null) {\n\t var results = [];\n\t this._root.searchAfter(time, results);\n\t for (var i = results.length - 1; i >= 0; i--) {\n\t var ev = results[i].event;\n\t callback(ev);\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.IntervalTimeline} this\n\t\t */\n\t Tone.IntervalTimeline.prototype.dispose = function () {\n\t var allNodes = [];\n\t if (this._root !== null) {\n\t this._root.traverse(function (node) {\n\t allNodes.push(node);\n\t });\n\t }\n\t for (var i = 0; i < allNodes.length; i++) {\n\t allNodes[i].dispose();\n\t }\n\t allNodes = null;\n\t this._root = null;\n\t return this;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tINTERVAL NODE HELPER\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Represents a node in the binary search tree, with the addition\n\t\t * of a \"high\" value which keeps track of the highest value of\n\t\t * its children.\n\t\t * References:\n\t\t * https://brooknovak.wordpress.com/2013/12/07/augmented-interval-tree-in-c/\n\t\t * http://www.mif.vu.lt/~valdas/ALGORITMAI/LITERATURA/Cormen/Cormen.pdf\n\t\t * @param {Number} low\n\t\t * @param {Number} high\n\t\t * @private\n\t\t */\n\t var IntervalNode = function (low, high, event) {\n\t //the event container\n\t this.event = event;\n\t //the low value\n\t this.low = low;\n\t //the high value\n\t this.high = high;\n\t //the high value for this and all child nodes\n\t this.max = this.high;\n\t //the nodes to the left\n\t this._left = null;\n\t //the nodes to the right\n\t this._right = null;\n\t //the parent node\n\t this.parent = null;\n\t //the number of child nodes\n\t this.height = 0;\n\t };\n\t /**\n\t\t * Insert a node into the correct spot in the tree\n\t\t * @param {IntervalNode} node\n\t\t */\n\t IntervalNode.prototype.insert = function (node) {\n\t if (node.low <= this.low) {\n\t if (this.left === null) {\n\t this.left = node;\n\t } else {\n\t this.left.insert(node);\n\t }\n\t } else if (this.right === null) {\n\t this.right = node;\n\t } else {\n\t this.right.insert(node);\n\t }\n\t };\n\t /**\n\t\t * Search the tree for nodes which overlap\n\t\t * with the given point\n\t\t * @param {Number} point The point to query\n\t\t * @param {Array} results The array to put the results\n\t\t */\n\t IntervalNode.prototype.search = function (point, results) {\n\t // If p is to the right of the rightmost point of any interval\n\t // in this node and all children, there won't be any matches.\n\t if (point > this.max) {\n\t return;\n\t }\n\t // Search left children\n\t if (this.left !== null) {\n\t this.left.search(point, results);\n\t }\n\t // Check this node\n\t if (this.low <= point && this.high > point) {\n\t results.push(this);\n\t }\n\t // If p is to the left of the time of this interval,\n\t // then it can't be in any child to the right.\n\t if (this.low > point) {\n\t return;\n\t }\n\t // Search right children\n\t if (this.right !== null) {\n\t this.right.search(point, results);\n\t }\n\t };\n\t /**\n\t\t * Search the tree for nodes which are less\n\t\t * than the given point\n\t\t * @param {Number} point The point to query\n\t\t * @param {Array} results The array to put the results\n\t\t */\n\t IntervalNode.prototype.searchAfter = function (point, results) {\n\t // Check this node\n\t if (this.low >= point) {\n\t results.push(this);\n\t if (this.left !== null) {\n\t this.left.searchAfter(point, results);\n\t }\n\t }\n\t // search the right side\n\t if (this.right !== null) {\n\t this.right.searchAfter(point, results);\n\t }\n\t };\n\t /**\n\t\t * Invoke the callback on this element and both it's branches\n\t\t * @param {Function} callback\n\t\t */\n\t IntervalNode.prototype.traverse = function (callback) {\n\t callback(this);\n\t if (this.left !== null) {\n\t this.left.traverse(callback);\n\t }\n\t if (this.right !== null) {\n\t this.right.traverse(callback);\n\t }\n\t };\n\t /**\n\t\t * Update the height of the node\n\t\t */\n\t IntervalNode.prototype.updateHeight = function () {\n\t if (this.left !== null && this.right !== null) {\n\t this.height = Math.max(this.left.height, this.right.height) + 1;\n\t } else if (this.right !== null) {\n\t this.height = this.right.height + 1;\n\t } else if (this.left !== null) {\n\t this.height = this.left.height + 1;\n\t } else {\n\t this.height = 0;\n\t }\n\t };\n\t /**\n\t\t * Update the height of the node\n\t\t */\n\t IntervalNode.prototype.updateMax = function () {\n\t this.max = this.high;\n\t if (this.left !== null) {\n\t this.max = Math.max(this.max, this.left.max);\n\t }\n\t if (this.right !== null) {\n\t this.max = Math.max(this.max, this.right.max);\n\t }\n\t };\n\t /**\n\t\t * The balance is how the leafs are distributed on the node\n\t\t * @return {Number} Negative numbers are balanced to the right\n\t\t */\n\t IntervalNode.prototype.getBalance = function () {\n\t var balance = 0;\n\t if (this.left !== null && this.right !== null) {\n\t balance = this.left.height - this.right.height;\n\t } else if (this.left !== null) {\n\t balance = this.left.height + 1;\n\t } else if (this.right !== null) {\n\t balance = -(this.right.height + 1);\n\t }\n\t return balance;\n\t };\n\t /**\n\t\t * @returns {Boolean} true if this node is the left child\n\t\t * of its parent\n\t\t */\n\t IntervalNode.prototype.isLeftChild = function () {\n\t return this.parent !== null && this.parent.left === this;\n\t };\n\t /**\n\t\t * get/set the left node\n\t\t * @type {IntervalNode}\n\t\t */\n\t Object.defineProperty(IntervalNode.prototype, 'left', {\n\t get: function () {\n\t return this._left;\n\t },\n\t set: function (node) {\n\t this._left = node;\n\t if (node !== null) {\n\t node.parent = this;\n\t }\n\t this.updateHeight();\n\t this.updateMax();\n\t }\n\t });\n\t /**\n\t\t * get/set the right node\n\t\t * @type {IntervalNode}\n\t\t */\n\t Object.defineProperty(IntervalNode.prototype, 'right', {\n\t get: function () {\n\t return this._right;\n\t },\n\t set: function (node) {\n\t this._right = node;\n\t if (node !== null) {\n\t node.parent = this;\n\t }\n\t this.updateHeight();\n\t this.updateMax();\n\t }\n\t });\n\t /**\n\t\t * null out references.\n\t\t */\n\t IntervalNode.prototype.dispose = function () {\n\t this.parent = null;\n\t this._left = null;\n\t this._right = null;\n\t this.event = null;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tEND INTERVAL NODE HELPER\n\t ///////////////////////////////////////////////////////////////////////////\n\t return Tone.IntervalTimeline;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.Ticks is a primitive type for encoding Time values.\n\t\t * Tone.Ticks can be constructed with or without the `new` keyword. Tone.Ticks can be passed\n\t\t * into the parameter of any method which takes time as an argument.\n\t\t * @constructor\n\t\t * @extends {Tone.TransportTime}\n\t\t * @param {String|Number} val The time value.\n\t\t * @param {String=} units The units of the value.\n\t\t * @example\n\t\t * var t = Tone.Ticks(\"4n\");//a quarter note\n\t\t */\n\t Tone.Ticks = function (val, units) {\n\t if (this instanceof Tone.Ticks) {\n\t Tone.TransportTime.call(this, val, units);\n\t } else {\n\t return new Tone.Ticks(val, units);\n\t }\n\t };\n\t Tone.extend(Tone.Ticks, Tone.TransportTime);\n\t /**\n\t\t * The default units if none are given.\n\t\t * @type {String}\n\t\t * @private\n\t\t */\n\t Tone.Ticks.prototype._defaultUnits = 'i';\n\t /**\n\t\t * Get the current time in the given units\n\t\t * @return {Ticks}\n\t\t * @private\n\t\t */\n\t Tone.Ticks.prototype._now = function () {\n\t return Tone.Transport.ticks;\n\t };\n\t /**\n\t\t * Return the value of the beats in the current units\n\t\t * @param {Number} beats\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.Ticks.prototype._beatsToUnits = function (beats) {\n\t return this._getPPQ() * beats;\n\t };\n\t /**\n\t\t * Returns the value of a second in the current units\n\t\t * @param {Seconds} seconds\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.Ticks.prototype._secondsToUnits = function (seconds) {\n\t return seconds / (60 / this._getBpm()) * this._getPPQ();\n\t };\n\t /**\n\t\t * Returns the value of a tick in the current time units\n\t\t * @param {Ticks} ticks\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.Ticks.prototype._ticksToUnits = function (ticks) {\n\t return ticks;\n\t };\n\t /**\n\t\t * Return the time in ticks\n\t\t * @return {Ticks}\n\t\t */\n\t Tone.Ticks.prototype.toTicks = function () {\n\t return this.valueOf();\n\t };\n\t /**\n\t\t * Return the time in ticks\n\t\t * @return {Ticks}\n\t\t */\n\t Tone.Ticks.prototype.toSeconds = function () {\n\t return this.valueOf() / this._getPPQ() * (60 / this._getBpm());\n\t };\n\t return Tone.Ticks;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.TransportEvent is an internal class used by (Tone.Transport)[Transport]\n\t\t * to schedule events. Do no invoke this class directly, it is\n\t\t * handled from within Tone.Transport.\n\t\t * @extends {Tone}\n\t\t * @param {Object} options\n\t\t */\n\t Tone.TransportEvent = function (Transport, options) {\n\t options = Tone.defaultArg(options, Tone.TransportEvent.defaults);\n\t Tone.call(this);\n\t /**\n\t\t\t * Reference to the Transport that created it\n\t\t\t * @type {Tone.Transport}\n\t\t\t */\n\t this.Transport = Transport;\n\t /**\n\t\t\t * The unique id of the event\n\t\t\t * @type {Number}\n\t\t\t */\n\t this.id = Tone.TransportEvent._eventId++;\n\t /**\n\t\t\t * The time the event starts\n\t\t\t * @type {Ticks}\n\t\t\t */\n\t this.time = Tone.Ticks(options.time);\n\t /**\n\t\t\t * The callback to invoke\n\t\t\t * @type {Function}\n\t\t\t */\n\t this.callback = options.callback;\n\t /**\n\t\t\t * If the event should be removed after being created.\n\t\t\t * @type {Boolean}\n\t\t\t * @private\n\t\t\t */\n\t this._once = options.once;\n\t };\n\t Tone.extend(Tone.TransportEvent);\n\t /**\n\t\t * The defaults\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.TransportEvent.defaults = {\n\t 'once': false,\n\t 'callback': Tone.noOp\n\t };\n\t /**\n\t\t * Current ID counter\n\t\t * @private\n\t\t * @static\n\t\t * @type {Number}\n\t\t */\n\t Tone.TransportEvent._eventId = 0;\n\t /**\n\t\t * Invoke the event callback.\n\t\t * @param {Time} time The AudioContext time in seconds of the event\n\t\t */\n\t Tone.TransportEvent.prototype.invoke = function (time) {\n\t if (this.callback) {\n\t this.callback(time);\n\t if (this._once && this.Transport) {\n\t this.Transport.clear(this.id);\n\t }\n\t }\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.TransportEvent} this\n\t\t */\n\t Tone.TransportEvent.prototype.dispose = function () {\n\t Tone.prototype.dispose.call(this);\n\t this.Transport = null;\n\t this.callback = null;\n\t this.time = null;\n\t return this;\n\t };\n\t return Tone.TransportEvent;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.TransportRepeatEvent is an internal class used by Tone.Transport\n\t\t * to schedule repeat events. This class should not be instantiated directly.\n\t\t * @extends {Tone.TransportEvent}\n\t\t * @param {Object} options\n\t\t */\n\t Tone.TransportRepeatEvent = function (Transport, options) {\n\t Tone.TransportEvent.call(this, Transport, options);\n\t options = Tone.defaultArg(options, Tone.TransportRepeatEvent.defaults);\n\t /**\n\t\t\t * When the event should stop repeating\n\t\t\t * @type {Ticks}\n\t\t\t * @private\n\t\t\t */\n\t this.duration = Tone.Ticks(options.duration);\n\t /**\n\t\t\t * The interval of the repeated event\n\t\t\t * @type {Ticks}\n\t\t\t * @private\n\t\t\t */\n\t this._interval = Tone.Ticks(options.interval);\n\t /**\n\t\t\t * The ID of the current timeline event\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._currentId = -1;\n\t /**\n\t\t\t * The ID of the next timeline event\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._nextId = -1;\n\t /**\n\t\t\t * The time of the next event\n\t\t\t * @type {Ticks}\n\t\t\t * @private\n\t\t\t */\n\t this._nextTick = this.time;\n\t /**\n\t\t\t * a reference to the bound start method\n\t\t\t * @type {Function}\n\t\t\t * @private\n\t\t\t */\n\t this._boundRestart = this._restart.bind(this);\n\t this.Transport.on('start loopStart', this._boundRestart);\n\t this._restart();\n\t };\n\t Tone.extend(Tone.TransportRepeatEvent, Tone.TransportEvent);\n\t /**\n\t\t * The defaults\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.TransportRepeatEvent.defaults = {\n\t 'duration': Infinity,\n\t 'interval': 1\n\t };\n\t /**\n\t\t * Invoke the callback. Returns the tick time which\n\t\t * the next event should be scheduled at.\n\t\t * @param {Number} time The AudioContext time in seconds of the event\n\t\t */\n\t Tone.TransportRepeatEvent.prototype.invoke = function (time) {\n\t //create more events if necessary\n\t this._createEvents(time);\n\t //call the super class\n\t Tone.TransportEvent.prototype.invoke.call(this, time);\n\t };\n\t /**\n\t\t * Push more events onto the timeline to keep up with the position of the timeline\n\t\t * @private\n\t\t */\n\t Tone.TransportRepeatEvent.prototype._createEvents = function (time) {\n\t // schedule the next event\n\t var ticks = this.Transport.getTicksAtTime(time);\n\t if (ticks >= this.time && ticks >= this._nextTick && this._nextTick + this._interval < this.time + this.duration) {\n\t this._nextTick += this._interval;\n\t this._currentId = this._nextId;\n\t this._nextId = this.Transport.scheduleOnce(this.invoke.bind(this), Tone.Ticks(this._nextTick));\n\t }\n\t };\n\t /**\n\t\t * Push more events onto the timeline to keep up with the position of the timeline\n\t\t * @private\n\t\t */\n\t Tone.TransportRepeatEvent.prototype._restart = function (time) {\n\t this.Transport.clear(this._currentId);\n\t this.Transport.clear(this._nextId);\n\t this._nextTick = this.time;\n\t var ticks = this.Transport.getTicksAtTime(time);\n\t if (ticks > this.time) {\n\t this._nextTick = this.time + Math.ceil((ticks - this.time) / this._interval) * this._interval;\n\t }\n\t this._currentId = this.Transport.scheduleOnce(this.invoke.bind(this), Tone.Ticks(this._nextTick));\n\t this._nextTick += this._interval;\n\t this._nextId = this.Transport.scheduleOnce(this.invoke.bind(this), Tone.Ticks(this._nextTick));\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.TransportRepeatEvent} this\n\t\t */\n\t Tone.TransportRepeatEvent.prototype.dispose = function () {\n\t this.Transport.clear(this._currentId);\n\t this.Transport.clear(this._nextId);\n\t this.Transport.off('start loopStart', this._boundRestart);\n\t this._boundCreateEvents = null;\n\t Tone.TransportEvent.prototype.dispose.call(this);\n\t this.duration = null;\n\t this._interval = null;\n\t return this;\n\t };\n\t return Tone.TransportRepeatEvent;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Transport for timing musical events.\n\t\t * Supports tempo curves and time changes. Unlike browser-based timing (setInterval, requestAnimationFrame)\n\t\t * Tone.Transport timing events pass in the exact time of the scheduled event\n\t\t * in the argument of the callback function. Pass that time value to the object\n\t\t * you're scheduling. <br><br>\n\t\t * A single transport is created for you when the library is initialized.\n\t\t * <br><br>\n\t\t * The transport emits the events: \"start\", \"stop\", \"pause\", and \"loop\" which are\n\t\t * called with the time of that event as the argument.\n\t\t *\n\t\t * @extends {Tone.Emitter}\n\t\t * @singleton\n\t\t * @example\n\t\t * //repeated event every 8th note\n\t\t * Tone.Transport.scheduleRepeat(function(time){\n\t\t * \t//do something with the time\n\t\t * }, \"8n\");\n\t\t * @example\n\t\t * //schedule an event on the 16th measure\n\t\t * Tone.Transport.schedule(function(time){\n\t\t * \t//do something with the time\n\t\t * }, \"16:0:0\");\n\t\t */\n\t Tone.Transport = function () {\n\t Tone.Emitter.call(this);\n\t Tone.getContext(function () {\n\t ///////////////////////////////////////////////////////////////////////\n\t //\tLOOPING\n\t //////////////////////////////////////////////////////////////////////\n\t /**\n\t\t\t\t * \tIf the transport loops or not.\n\t\t\t\t * @type {boolean}\n\t\t\t\t */\n\t this.loop = false;\n\t /**\n\t\t\t\t * \tThe loop start position in ticks\n\t\t\t\t * @type {Ticks}\n\t\t\t\t * @private\n\t\t\t\t */\n\t this._loopStart = 0;\n\t /**\n\t\t\t\t * \tThe loop end position in ticks\n\t\t\t\t * @type {Ticks}\n\t\t\t\t * @private\n\t\t\t\t */\n\t this._loopEnd = 0;\n\t ///////////////////////////////////////////////////////////////////////\n\t //\tCLOCK/TEMPO\n\t //////////////////////////////////////////////////////////////////////\n\t /**\n\t\t\t\t * Pulses per quarter is the number of ticks per quarter note.\n\t\t\t\t * @private\n\t\t\t\t * @type {Number}\n\t\t\t\t */\n\t this._ppq = TransportConstructor.defaults.PPQ;\n\t /**\n\t\t\t\t * watches the main oscillator for timing ticks\n\t\t\t\t * initially starts at 120bpm\n\t\t\t\t * @private\n\t\t\t\t * @type {Tone.Clock}\n\t\t\t\t */\n\t this._clock = new Tone.Clock({\n\t 'callback': this._processTick.bind(this),\n\t 'frequency': 0\n\t });\n\t this._bindClockEvents();\n\t /**\n\t\t\t\t * The Beats Per Minute of the Transport.\n\t\t\t\t * @type {BPM}\n\t\t\t\t * @signal\n\t\t\t\t * @example\n\t\t\t\t * Tone.Transport.bpm.value = 80;\n\t\t\t\t * //ramp the bpm to 120 over 10 seconds\n\t\t\t\t * Tone.Transport.bpm.rampTo(120, 10);\n\t\t\t\t */\n\t this.bpm = this._clock.frequency;\n\t this.bpm._toUnits = this._toUnits.bind(this);\n\t this.bpm._fromUnits = this._fromUnits.bind(this);\n\t this.bpm.units = Tone.Type.BPM;\n\t this.bpm.value = TransportConstructor.defaults.bpm;\n\t this._readOnly('bpm');\n\t /**\n\t\t\t\t * The time signature, or more accurately the numerator\n\t\t\t\t * of the time signature over a denominator of 4.\n\t\t\t\t * @type {Number}\n\t\t\t\t * @private\n\t\t\t\t */\n\t this._timeSignature = TransportConstructor.defaults.timeSignature;\n\t ///////////////////////////////////////////////////////////////////////\n\t //\tTIMELINE EVENTS\n\t //////////////////////////////////////////////////////////////////////\n\t /**\n\t\t\t\t * All the events in an object to keep track by ID\n\t\t\t\t * @type {Object}\n\t\t\t\t * @private\n\t\t\t\t */\n\t this._scheduledEvents = {};\n\t /**\n\t\t\t\t * \tThe scheduled events.\n\t\t\t\t * @type {Tone.Timeline}\n\t\t\t\t * @private\n\t\t\t\t */\n\t this._timeline = new Tone.Timeline();\n\t /**\n\t\t\t\t * Repeated events\n\t\t\t\t * @type {Array}\n\t\t\t\t * @private\n\t\t\t\t */\n\t this._repeatedEvents = new Tone.IntervalTimeline();\n\t /**\n\t\t\t\t * All of the synced Signals\n\t\t\t\t * @private\n\t\t\t\t * @type {Array}\n\t\t\t\t */\n\t this._syncedSignals = [];\n\t ///////////////////////////////////////////////////////////////////////\n\t //\tSWING\n\t //////////////////////////////////////////////////////////////////////\n\t /**\n\t\t\t\t * The subdivision of the swing\n\t\t\t\t * @type {Ticks}\n\t\t\t\t * @private\n\t\t\t\t */\n\t this._swingTicks = TransportConstructor.defaults.PPQ / 2;\n\t //8n\n\t /**\n\t\t\t\t * The swing amount\n\t\t\t\t * @type {NormalRange}\n\t\t\t\t * @private\n\t\t\t\t */\n\t this._swingAmount = 0;\n\t }.bind(this));\n\t };\n\t Tone.extend(Tone.Transport, Tone.Emitter);\n\t /**\n\t\t * the defaults\n\t\t * @type {Object}\n\t\t * @const\n\t\t * @static\n\t\t */\n\t Tone.Transport.defaults = {\n\t 'bpm': 120,\n\t 'swing': 0,\n\t 'swingSubdivision': '8n',\n\t 'timeSignature': 4,\n\t 'loopStart': 0,\n\t 'loopEnd': '4m',\n\t 'PPQ': 192\n\t };\n\t ///////////////////////////////////////////////////////////////////////////////\n\t //\tTICKS\n\t ///////////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * called on every tick\n\t\t * @param {number} tickTime clock relative tick time\n\t\t * @private\n\t\t */\n\t Tone.Transport.prototype._processTick = function (tickTime, ticks) {\n\t //handle swing\n\t if (this._swingAmount > 0 && ticks % this._ppq !== 0 && //not on a downbeat\n\t ticks % (this._swingTicks * 2) !== 0) {\n\t //add some swing\n\t var progress = ticks % (this._swingTicks * 2) / (this._swingTicks * 2);\n\t var amount = Math.sin(progress * Math.PI) * this._swingAmount;\n\t tickTime += Tone.Ticks(this._swingTicks * 2 / 3).toSeconds() * amount;\n\t }\n\t //do the loop test\n\t if (this.loop) {\n\t if (ticks >= this._loopEnd) {\n\t this.emit('loopEnd', tickTime);\n\t this._clock.setTicksAtTime(this._loopStart, tickTime);\n\t ticks = this._loopStart;\n\t this.emit('loopStart', tickTime, this._clock.getSecondsAtTime(tickTime));\n\t this.emit('loop', tickTime);\n\t }\n\t }\n\t //invoke the timeline events scheduled on this tick\n\t this._timeline.forEachAtTime(ticks, function (event) {\n\t event.invoke(tickTime);\n\t });\n\t };\n\t ///////////////////////////////////////////////////////////////////////////////\n\t //\tSCHEDULABLE EVENTS\n\t ///////////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Schedule an event along the timeline.\n\t\t * @param {Function} callback The callback to be invoked at the time.\n\t\t * @param {TransportTime} time The time to invoke the callback at.\n\t\t * @return {Number} The id of the event which can be used for canceling the event.\n\t\t * @example\n\t\t * //trigger the callback when the Transport reaches the desired time\n\t\t * Tone.Transport.schedule(function(time){\n\t\t * \tenvelope.triggerAttack(time);\n\t\t * }, \"128i\");\n\t\t */\n\t Tone.Transport.prototype.schedule = function (callback, time) {\n\t var event = new Tone.TransportEvent(this, {\n\t 'time': Tone.TransportTime(time),\n\t 'callback': callback\n\t });\n\t return this._addEvent(event, this._timeline);\n\t };\n\t /**\n\t\t * Schedule a repeated event along the timeline. The event will fire\n\t\t * at the `interval` starting at the `startTime` and for the specified\n\t\t * `duration`.\n\t\t * @param {Function} callback The callback to invoke.\n\t\t * @param {Time} interval The duration between successive\n\t\t * callbacks. Must be a positive number.\n\t\t * @param {TransportTime=} startTime When along the timeline the events should\n\t\t * start being invoked.\n\t\t * @param {Time} [duration=Infinity] How long the event should repeat.\n\t\t * @return {Number} The ID of the scheduled event. Use this to cancel\n\t\t * the event.\n\t\t * @example\n\t\t * //a callback invoked every eighth note after the first measure\n\t\t * Tone.Transport.scheduleRepeat(callback, \"8n\", \"1m\");\n\t\t */\n\t Tone.Transport.prototype.scheduleRepeat = function (callback, interval, startTime, duration) {\n\t var event = new Tone.TransportRepeatEvent(this, {\n\t 'callback': callback,\n\t 'interval': Tone.Time(interval),\n\t 'time': Tone.TransportTime(startTime),\n\t 'duration': Tone.Time(Tone.defaultArg(duration, Infinity))\n\t });\n\t //kick it off if the Transport is started\n\t return this._addEvent(event, this._repeatedEvents);\n\t };\n\t /**\n\t\t * Schedule an event that will be removed after it is invoked.\n\t\t * Note that if the given time is less than the current transport time,\n\t\t * the event will be invoked immediately.\n\t\t * @param {Function} callback The callback to invoke once.\n\t\t * @param {TransportTime} time The time the callback should be invoked.\n\t\t * @returns {Number} The ID of the scheduled event.\n\t\t */\n\t Tone.Transport.prototype.scheduleOnce = function (callback, time) {\n\t var event = new Tone.TransportEvent(this, {\n\t 'time': Tone.TransportTime(time),\n\t 'callback': callback,\n\t 'once': true\n\t });\n\t return this._addEvent(event, this._timeline);\n\t };\n\t /**\n\t\t * Clear the passed in event id from the timeline\n\t\t * @param {Number} eventId The id of the event.\n\t\t * @returns {Tone.Transport} this\n\t\t */\n\t Tone.Transport.prototype.clear = function (eventId) {\n\t if (this._scheduledEvents.hasOwnProperty(eventId)) {\n\t var item = this._scheduledEvents[eventId.toString()];\n\t item.timeline.remove(item.event);\n\t item.event.dispose();\n\t delete this._scheduledEvents[eventId.toString()];\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Add an event to the correct timeline. Keep track of the\n\t\t * timeline it was added to.\n\t\t * @param {Tone.TransportEvent}\tevent\n\t\t * @param {Tone.Timeline} timeline\n\t\t * @returns {Number} the event id which was just added\n\t\t * @private\n\t\t */\n\t Tone.Transport.prototype._addEvent = function (event, timeline) {\n\t this._scheduledEvents[event.id.toString()] = {\n\t 'event': event,\n\t 'timeline': timeline\n\t };\n\t timeline.add(event);\n\t return event.id;\n\t };\n\t /**\n\t\t * Remove scheduled events from the timeline after\n\t\t * the given time. Repeated events will be removed\n\t\t * if their startTime is after the given time\n\t\t * @param {TransportTime} [after=0] Clear all events after\n\t\t * this time.\n\t\t * @returns {Tone.Transport} this\n\t\t */\n\t Tone.Transport.prototype.cancel = function (after) {\n\t after = Tone.defaultArg(after, 0);\n\t after = this.toTicks(after);\n\t this._timeline.forEachFrom(after, function (event) {\n\t this.clear(event.id);\n\t }.bind(this));\n\t this._repeatedEvents.forEachFrom(after, function (event) {\n\t this.clear(event.id);\n\t }.bind(this));\n\t return this;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////////\n\t //\tSTART/STOP/PAUSE\n\t ///////////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Bind start/stop/pause events from the clock and emit them.\n\t\t * @private\n\t\t */\n\t Tone.Transport.prototype._bindClockEvents = function () {\n\t this._clock.on('start', function (time, offset) {\n\t offset = Tone.Ticks(offset).toSeconds();\n\t this.emit('start', time, offset);\n\t }.bind(this));\n\t this._clock.on('stop', function (time) {\n\t this.emit('stop', time);\n\t }.bind(this));\n\t this._clock.on('pause', function (time) {\n\t this.emit('pause', time);\n\t }.bind(this));\n\t };\n\t /**\n\t\t * Returns the playback state of the source, either \"started\", \"stopped\", or \"paused\"\n\t\t * @type {Tone.State}\n\t\t * @readOnly\n\t\t * @memberOf Tone.Transport#\n\t\t * @name state\n\t\t */\n\t Object.defineProperty(Tone.Transport.prototype, 'state', {\n\t get: function () {\n\t return this._clock.getStateAtTime(this.now());\n\t }\n\t });\n\t /**\n\t\t * Start the transport and all sources synced to the transport.\n\t\t * @param {Time} [time=now] The time when the transport should start.\n\t\t * @param {TransportTime=} offset The timeline offset to start the transport.\n\t\t * @returns {Tone.Transport} this\n\t\t * @example\n\t\t * //start the transport in one second starting at beginning of the 5th measure.\n\t\t * Tone.Transport.start(\"+1\", \"4:0:0\");\n\t\t */\n\t Tone.Transport.prototype.start = function (time, offset) {\n\t //start the clock\n\t if (Tone.isDefined(offset)) {\n\t offset = this.toTicks(offset);\n\t }\n\t this._clock.start(time, offset);\n\t return this;\n\t };\n\t /**\n\t\t * Stop the transport and all sources synced to the transport.\n\t\t * @param {Time} [time=now] The time when the transport should stop.\n\t\t * @returns {Tone.Transport} this\n\t\t * @example\n\t\t * Tone.Transport.stop();\n\t\t */\n\t Tone.Transport.prototype.stop = function (time) {\n\t this._clock.stop(time);\n\t return this;\n\t };\n\t /**\n\t\t * Pause the transport and all sources synced to the transport.\n\t\t * @param {Time} [time=now]\n\t\t * @returns {Tone.Transport} this\n\t\t */\n\t Tone.Transport.prototype.pause = function (time) {\n\t this._clock.pause(time);\n\t return this;\n\t };\n\t /**\n\t\t * Toggle the current state of the transport. If it is\n\t\t * started, it will stop it, otherwise it will start the Transport.\n\t\t * @param {Time=} time The time of the event\n\t\t * @return {Tone.Transport} this\n\t\t */\n\t Tone.Transport.prototype.toggle = function (time) {\n\t time = this.toSeconds(time);\n\t if (this._clock.getStateAtTime(time) !== Tone.State.Started) {\n\t this.start(time);\n\t } else {\n\t this.stop(time);\n\t }\n\t return this;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////////\n\t //\tSETTERS/GETTERS\n\t ///////////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * The time signature as just the numerator over 4.\n\t\t * For example 4/4 would be just 4 and 6/8 would be 3.\n\t\t * @memberOf Tone.Transport#\n\t\t * @type {Number|Array}\n\t\t * @name timeSignature\n\t\t * @example\n\t\t * //common time\n\t\t * Tone.Transport.timeSignature = 4;\n\t\t * // 7/8\n\t\t * Tone.Transport.timeSignature = [7, 8];\n\t\t * //this will be reduced to a single number\n\t\t * Tone.Transport.timeSignature; //returns 3.5\n\t\t */\n\t Object.defineProperty(Tone.Transport.prototype, 'timeSignature', {\n\t get: function () {\n\t return this._timeSignature;\n\t },\n\t set: function (timeSig) {\n\t if (Tone.isArray(timeSig)) {\n\t timeSig = timeSig[0] / timeSig[1] * 4;\n\t }\n\t this._timeSignature = timeSig;\n\t }\n\t });\n\t /**\n\t\t * When the Tone.Transport.loop = true, this is the starting position of the loop.\n\t\t * @memberOf Tone.Transport#\n\t\t * @type {Time}\n\t\t * @name loopStart\n\t\t */\n\t Object.defineProperty(Tone.Transport.prototype, 'loopStart', {\n\t get: function () {\n\t return Tone.Ticks(this._loopStart).toSeconds();\n\t },\n\t set: function (startPosition) {\n\t this._loopStart = this.toTicks(startPosition);\n\t }\n\t });\n\t /**\n\t\t * When the Tone.Transport.loop = true, this is the ending position of the loop.\n\t\t * @memberOf Tone.Transport#\n\t\t * @type {Time}\n\t\t * @name loopEnd\n\t\t */\n\t Object.defineProperty(Tone.Transport.prototype, 'loopEnd', {\n\t get: function () {\n\t return Tone.Ticks(this._loopEnd).toSeconds();\n\t },\n\t set: function (endPosition) {\n\t this._loopEnd = this.toTicks(endPosition);\n\t }\n\t });\n\t /**\n\t\t * Set the loop start and stop at the same time.\n\t\t * @param {TransportTime} startPosition\n\t\t * @param {TransportTime} endPosition\n\t\t * @returns {Tone.Transport} this\n\t\t * @example\n\t\t * //loop over the first measure\n\t\t * Tone.Transport.setLoopPoints(0, \"1m\");\n\t\t * Tone.Transport.loop = true;\n\t\t */\n\t Tone.Transport.prototype.setLoopPoints = function (startPosition, endPosition) {\n\t this.loopStart = startPosition;\n\t this.loopEnd = endPosition;\n\t return this;\n\t };\n\t /**\n\t\t * The swing value. Between 0-1 where 1 equal to\n\t\t * the note + half the subdivision.\n\t\t * @memberOf Tone.Transport#\n\t\t * @type {NormalRange}\n\t\t * @name swing\n\t\t */\n\t Object.defineProperty(Tone.Transport.prototype, 'swing', {\n\t get: function () {\n\t return this._swingAmount;\n\t },\n\t set: function (amount) {\n\t //scale the values to a normal range\n\t this._swingAmount = amount;\n\t }\n\t });\n\t /**\n\t\t * Set the subdivision which the swing will be applied to.\n\t\t * The default value is an 8th note. Value must be less\n\t\t * than a quarter note.\n\t\t *\n\t\t * @memberOf Tone.Transport#\n\t\t * @type {Time}\n\t\t * @name swingSubdivision\n\t\t */\n\t Object.defineProperty(Tone.Transport.prototype, 'swingSubdivision', {\n\t get: function () {\n\t return Tone.Ticks(this._swingTicks).toNotation();\n\t },\n\t set: function (subdivision) {\n\t this._swingTicks = this.toTicks(subdivision);\n\t }\n\t });\n\t /**\n\t\t * The Transport's position in Bars:Beats:Sixteenths.\n\t\t * Setting the value will jump to that position right away.\n\t\t * @memberOf Tone.Transport#\n\t\t * @type {BarsBeatsSixteenths}\n\t\t * @name position\n\t\t */\n\t Object.defineProperty(Tone.Transport.prototype, 'position', {\n\t get: function () {\n\t var now = this.now();\n\t var ticks = this._clock.getTicksAtTime(now);\n\t return Tone.Ticks(ticks).toBarsBeatsSixteenths();\n\t },\n\t set: function (progress) {\n\t var ticks = this.toTicks(progress);\n\t this.ticks = ticks;\n\t }\n\t });\n\t /**\n\t\t * The Transport's position in seconds\n\t\t * Setting the value will jump to that position right away.\n\t\t * @memberOf Tone.Transport#\n\t\t * @type {Seconds}\n\t\t * @name seconds\n\t\t */\n\t Object.defineProperty(Tone.Transport.prototype, 'seconds', {\n\t get: function () {\n\t return this._clock.seconds;\n\t },\n\t set: function (s) {\n\t var now = this.now();\n\t var ticks = this.bpm.timeToTicks(s, now);\n\t this.ticks = ticks;\n\t }\n\t });\n\t /**\n\t\t * The Transport's loop position as a normalized value. Always\n\t\t * returns 0 if the transport if loop is not true.\n\t\t * @memberOf Tone.Transport#\n\t\t * @name progress\n\t\t * @type {NormalRange}\n\t\t */\n\t Object.defineProperty(Tone.Transport.prototype, 'progress', {\n\t get: function () {\n\t if (this.loop) {\n\t var now = this.now();\n\t var ticks = this._clock.getTicksAtTime(now);\n\t return (ticks - this._loopStart) / (this._loopEnd - this._loopStart);\n\t } else {\n\t return 0;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The transports current tick position.\n\t\t *\n\t\t * @memberOf Tone.Transport#\n\t\t * @type {Ticks}\n\t\t * @name ticks\n\t\t */\n\t Object.defineProperty(Tone.Transport.prototype, 'ticks', {\n\t get: function () {\n\t return this._clock.ticks;\n\t },\n\t set: function (t) {\n\t if (this._clock.ticks !== t) {\n\t var now = this.now();\n\t //stop everything synced to the transport\n\t if (this.state === Tone.State.Started) {\n\t this.emit('stop', now);\n\t this._clock.setTicksAtTime(t, now);\n\t //restart it with the new time\n\t this.emit('start', now, this.seconds);\n\t } else {\n\t this._clock.setTicksAtTime(t, now);\n\t }\n\t }\n\t }\n\t });\n\t /**\n\t\t * Get the clock's ticks at the given time.\n\t\t * @param {Time} time When to get the tick value\n\t\t * @return {Ticks} The tick value at the given time.\n\t\t */\n\t Tone.Transport.prototype.getTicksAtTime = function (time) {\n\t return Math.round(this._clock.getTicksAtTime(time));\n\t };\n\t /**\n\t\t * Return the elapsed seconds at the given time.\n\t\t * @param {Time} time When to get the elapsed seconds\n\t\t * @return {Seconds} The number of elapsed seconds\n\t\t */\n\t Tone.Transport.prototype.getSecondsAtTime = function (time) {\n\t return this._clock.getSecondsAtTime(time);\n\t };\n\t /**\n\t\t * Pulses Per Quarter note. This is the smallest resolution\n\t\t * the Transport timing supports. This should be set once\n\t\t * on initialization and not set again. Changing this value\n\t\t * after other objects have been created can cause problems.\n\t\t *\n\t\t * @memberOf Tone.Transport#\n\t\t * @type {Number}\n\t\t * @name PPQ\n\t\t */\n\t Object.defineProperty(Tone.Transport.prototype, 'PPQ', {\n\t get: function () {\n\t return this._ppq;\n\t },\n\t set: function (ppq) {\n\t var bpm = this.bpm.value;\n\t this._ppq = ppq;\n\t this.bpm.value = bpm;\n\t }\n\t });\n\t /**\n\t\t * Convert from BPM to frequency (factoring in PPQ)\n\t\t * @param {BPM} bpm The BPM value to convert to frequency\n\t\t * @return {Frequency} The BPM as a frequency with PPQ factored in.\n\t\t * @private\n\t\t */\n\t Tone.Transport.prototype._fromUnits = function (bpm) {\n\t return 1 / (60 / bpm / this.PPQ);\n\t };\n\t /**\n\t\t * Convert from frequency (with PPQ) into BPM\n\t\t * @param {Frequency} freq The clocks frequency to convert to BPM\n\t\t * @return {BPM} The frequency value as BPM.\n\t\t * @private\n\t\t */\n\t Tone.Transport.prototype._toUnits = function (freq) {\n\t return freq / this.PPQ * 60;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////////\n\t //\tSYNCING\n\t ///////////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Returns the time aligned to the next subdivision\n\t\t * of the Transport. If the Transport is not started,\n\t\t * it will return 0.\n\t\t * Note: this will not work precisely during tempo ramps.\n\t\t * @param {Time} subdivision The subdivision to quantize to\n\t\t * @return {Number} The context time of the next subdivision.\n\t\t * @example\n\t\t * Tone.Transport.start(); //the transport must be started\n\t\t * Tone.Transport.nextSubdivision(\"4n\");\n\t\t */\n\t Tone.Transport.prototype.nextSubdivision = function (subdivision) {\n\t subdivision = this.toTicks(subdivision);\n\t if (this.state !== Tone.State.Started) {\n\t //if the transport's not started, return 0\n\t return 0;\n\t } else {\n\t var now = this.now();\n\t //the remainder of the current ticks and the subdivision\n\t var transportPos = this.getTicksAtTime(now);\n\t var remainingTicks = subdivision - transportPos % subdivision;\n\t return this._clock.nextTickTime(remainingTicks, now);\n\t }\n\t };\n\t /**\n\t\t * Attaches the signal to the tempo control signal so that\n\t\t * any changes in the tempo will change the signal in the same\n\t\t * ratio.\n\t\t *\n\t\t * @param {Tone.Signal} signal\n\t\t * @param {number=} ratio Optionally pass in the ratio between\n\t\t * the two signals. Otherwise it will be computed\n\t\t * based on their current values.\n\t\t * @returns {Tone.Transport} this\n\t\t */\n\t Tone.Transport.prototype.syncSignal = function (signal, ratio) {\n\t if (!ratio) {\n\t //get the sync ratio\n\t var now = this.now();\n\t if (signal.getValueAtTime(now) !== 0) {\n\t ratio = signal.getValueAtTime(now) / this.bpm.getValueAtTime(now);\n\t } else {\n\t ratio = 0;\n\t }\n\t }\n\t var ratioSignal = new Tone.Gain(ratio);\n\t this.bpm.chain(ratioSignal, signal._param);\n\t this._syncedSignals.push({\n\t 'ratio': ratioSignal,\n\t 'signal': signal,\n\t 'initial': signal.value\n\t });\n\t signal.value = 0;\n\t return this;\n\t };\n\t /**\n\t\t * Unsyncs a previously synced signal from the transport's control.\n\t\t * See Tone.Transport.syncSignal.\n\t\t * @param {Tone.Signal} signal\n\t\t * @returns {Tone.Transport} this\n\t\t */\n\t Tone.Transport.prototype.unsyncSignal = function (signal) {\n\t for (var i = this._syncedSignals.length - 1; i >= 0; i--) {\n\t var syncedSignal = this._syncedSignals[i];\n\t if (syncedSignal.signal === signal) {\n\t syncedSignal.ratio.dispose();\n\t syncedSignal.signal.value = syncedSignal.initial;\n\t this._syncedSignals.splice(i, 1);\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Transport} this\n\t\t * @private\n\t\t */\n\t Tone.Transport.prototype.dispose = function () {\n\t Tone.Emitter.prototype.dispose.call(this);\n\t this._clock.dispose();\n\t this._clock = null;\n\t this._writable('bpm');\n\t this.bpm = null;\n\t this._timeline.dispose();\n\t this._timeline = null;\n\t this._repeatedEvents.dispose();\n\t this._repeatedEvents = null;\n\t return this;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////////\n\t //\tINITIALIZATION\n\t ///////////////////////////////////////////////////////////////////////////////\n\t var TransportConstructor = Tone.Transport;\n\t Tone.Transport = new TransportConstructor();\n\t Tone.Context.on('init', function (context) {\n\t if (context.Transport instanceof TransportConstructor) {\n\t Tone.Transport = context.Transport;\n\t } else {\n\t Tone.Transport = new TransportConstructor();\n\t }\n\t //store the Transport on the context so it can be retrieved later\n\t context.Transport = Tone.Transport;\n\t });\n\t Tone.Context.on('close', function (context) {\n\t if (context.Transport instanceof TransportConstructor) {\n\t context.Transport.dispose();\n\t }\n\t });\n\t return Tone.Transport;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Volume is a simple volume node, useful for creating a volume fader.\n\t\t *\n\t\t * @extends {Tone.AudioNode}\n\t\t * @constructor\n\t\t * @param {Decibels} [volume=0] the initial volume\n\t\t * @example\n\t\t * var vol = new Tone.Volume(-12);\n\t\t * instrument.chain(vol, Tone.Master);\n\t\t */\n\t Tone.Volume = function () {\n\t var options = Tone.defaults(arguments, ['volume'], Tone.Volume);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * the output node\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this.output = this.input = new Tone.Gain(options.volume, Tone.Type.Decibels);\n\t /**\n\t\t\t * The unmuted volume\n\t\t\t * @type {Decibels}\n\t\t\t * @private\n\t\t\t */\n\t this._unmutedVolume = options.volume;\n\t /**\n\t\t\t * The volume control in decibels.\n\t\t\t * @type {Decibels}\n\t\t\t * @signal\n\t\t\t */\n\t this.volume = this.output.gain;\n\t this._readOnly('volume');\n\t //set the mute initially\n\t this.mute = options.mute;\n\t };\n\t Tone.extend(Tone.Volume, Tone.AudioNode);\n\t /**\n\t\t * Defaults\n\t\t * @type {Object}\n\t\t * @const\n\t\t * @static\n\t\t */\n\t Tone.Volume.defaults = {\n\t 'volume': 0,\n\t 'mute': false\n\t };\n\t /**\n\t\t * Mute the output.\n\t\t * @memberOf Tone.Volume#\n\t\t * @type {boolean}\n\t\t * @name mute\n\t\t * @example\n\t\t * //mute the output\n\t\t * volume.mute = true;\n\t\t */\n\t Object.defineProperty(Tone.Volume.prototype, 'mute', {\n\t get: function () {\n\t return this.volume.value === -Infinity;\n\t },\n\t set: function (mute) {\n\t if (!this.mute && mute) {\n\t this._unmutedVolume = this.volume.value;\n\t //maybe it should ramp here?\n\t this.volume.value = -Infinity;\n\t } else if (this.mute && !mute) {\n\t this.volume.value = this._unmutedVolume;\n\t }\n\t }\n\t });\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.Volume} this\n\t\t */\n\t Tone.Volume.prototype.dispose = function () {\n\t this.input.dispose();\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._writable('volume');\n\t this.volume.dispose();\n\t this.volume = null;\n\t return this;\n\t };\n\t return Tone.Volume;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class A single master output which is connected to the\n\t\t * AudioDestinationNode (aka your speakers).\n\t\t * It provides useful conveniences such as the ability\n\t\t * to set the volume and mute the entire application.\n\t\t * It also gives you the ability to apply master effects to your application.\n\t\t * <br><br>\n\t\t * Like Tone.Transport, A single Tone.Master is created\n\t\t * on initialization and you do not need to explicitly construct one.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone}\n\t\t * @singleton\n\t\t * @example\n\t\t * //the audio will go from the oscillator to the speakers\n\t\t * oscillator.connect(Tone.Master);\n\t\t * //a convenience for connecting to the master output is also provided:\n\t\t * oscillator.toMaster();\n\t\t * //the above two examples are equivalent.\n\t\t */\n\t Tone.Master = function () {\n\t Tone.AudioNode.call(this);\n\t Tone.getContext(function () {\n\t this.createInsOuts(1, 0);\n\t /**\n\t\t\t\t * The private volume node\n\t\t\t\t * @type {Tone.Volume}\n\t\t\t\t * @private\n\t\t\t\t */\n\t this._volume = this.output = new Tone.Volume();\n\t /**\n\t\t\t\t * The volume of the master output.\n\t\t\t\t * @type {Decibels}\n\t\t\t\t * @signal\n\t\t\t\t */\n\t this.volume = this._volume.volume;\n\t this._readOnly('volume');\n\t //connections\n\t this.input.chain(this.output, this.context.destination);\n\t }.bind(this));\n\t };\n\t Tone.extend(Tone.Master, Tone.AudioNode);\n\t /**\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.Master.defaults = {\n\t 'volume': 0,\n\t 'mute': false\n\t };\n\t /**\n\t\t * Mute the output.\n\t\t * @memberOf Tone.Master#\n\t\t * @type {boolean}\n\t\t * @name mute\n\t\t * @example\n\t\t * //mute the output\n\t\t * Tone.Master.mute = true;\n\t\t */\n\t Object.defineProperty(Tone.Master.prototype, 'mute', {\n\t get: function () {\n\t return this._volume.mute;\n\t },\n\t set: function (mute) {\n\t this._volume.mute = mute;\n\t }\n\t });\n\t /**\n\t\t * Add a master effects chain. NOTE: this will disconnect any nodes which were previously\n\t\t * chained in the master effects chain.\n\t\t * @param {AudioNode|Tone} args... All arguments will be connected in a row\n\t\t * and the Master will be routed through it.\n\t\t * @return {Tone.Master} this\n\t\t * @example\n\t\t * //some overall compression to keep the levels in check\n\t\t * var masterCompressor = new Tone.Compressor({\n\t\t * \t\"threshold\" : -6,\n\t\t * \t\"ratio\" : 3,\n\t\t * \t\"attack\" : 0.5,\n\t\t * \t\"release\" : 0.1\n\t\t * });\n\t\t * //give a little boost to the lows\n\t\t * var lowBump = new Tone.Filter(200, \"lowshelf\");\n\t\t * //route everything through the filter\n\t\t * //and compressor before going to the speakers\n\t\t * Tone.Master.chain(lowBump, masterCompressor);\n\t\t */\n\t Tone.Master.prototype.chain = function () {\n\t this.input.disconnect();\n\t this.input.chain.apply(this.input, arguments);\n\t arguments[arguments.length - 1].connect(this.output);\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.Master} this\n\t\t */\n\t Tone.Master.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._writable('volume');\n\t this._volume.dispose();\n\t this._volume = null;\n\t this.volume = null;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t //\tAUGMENT TONE's PROTOTYPE\n\t ///////////////////////////////////////////////////////////////////////////\n\t /**\n\t\t * Connect 'this' to the master output. Shorthand for this.connect(Tone.Master)\n\t\t * @returns {Tone.AudioNode} this\n\t\t * @example\n\t\t * //connect an oscillator to the master output\n\t\t * var osc = new Tone.Oscillator().toMaster();\n\t\t */\n\t Tone.AudioNode.prototype.toMaster = function () {\n\t this.connect(Tone.Master);\n\t return this;\n\t };\n\t if (window.AudioNode) {\n\t // Also augment AudioNode's prototype to include toMaster as a convenience\n\t AudioNode.prototype.toMaster = function () {\n\t this.connect(Tone.Master);\n\t return this;\n\t };\n\t }\n\t /**\n\t\t * initialize the module and listen for new audio contexts\n\t\t */\n\t var MasterConstructor = Tone.Master;\n\t Tone.Master = new MasterConstructor();\n\t Tone.Context.on('init', function (context) {\n\t // if it already exists, just restore it\n\t if (context.Master instanceof MasterConstructor) {\n\t Tone.Master = context.Master;\n\t } else {\n\t Tone.Master = new MasterConstructor();\n\t }\n\t context.Master = Tone.Master;\n\t });\n\t Tone.Context.on('close', function (context) {\n\t if (context.Master instanceof MasterConstructor) {\n\t context.Master.dispose();\n\t }\n\t });\n\t return Tone.Master;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Base class for sources. Sources have start/stop methods\n\t\t * and the ability to be synced to the\n\t\t * start/stop of Tone.Transport.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @example\n\t\t * //Multiple state change events can be chained together,\n\t\t * //but must be set in the correct order and with ascending times\n\t\t *\n\t\t * // OK\n\t\t * state.start().stop(\"+0.2\");\n\t\t * // AND\n\t\t * state.start().stop(\"+0.2\").start(\"+0.4\").stop(\"+0.7\")\n\t\t *\n\t\t * // BAD\n\t\t * state.stop(\"+0.2\").start();\n\t\t * // OR\n\t\t * state.start(\"+0.3\").stop(\"+0.2\");\n\t\t *\n\t\t */\n\t Tone.Source = function (options) {\n\t options = Tone.defaultArg(options, Tone.Source.defaults);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The output volume node\n\t\t\t * @type {Tone.Volume}\n\t\t\t * @private\n\t\t\t */\n\t this._volume = this.output = new Tone.Volume(options.volume);\n\t /**\n\t\t\t * The volume of the output in decibels.\n\t\t\t * @type {Decibels}\n\t\t\t * @signal\n\t\t\t * @example\n\t\t\t * source.volume.value = -6;\n\t\t\t */\n\t this.volume = this._volume.volume;\n\t this._readOnly('volume');\n\t /**\n\t\t\t * \tKeep track of the scheduled state.\n\t\t\t * @type {Tone.TimelineState}\n\t\t\t * @private\n\t\t\t */\n\t this._state = new Tone.TimelineState(Tone.State.Stopped);\n\t this._state.memory = 100;\n\t /**\n\t\t\t * The synced `start` callback function from the transport\n\t\t\t * @type {Function}\n\t\t\t * @private\n\t\t\t */\n\t this._synced = false;\n\t /**\n\t\t\t * Keep track of all of the scheduled event ids\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._scheduled = [];\n\t //make the output explicitly stereo\n\t this._volume.output.output.channelCount = 2;\n\t this._volume.output.output.channelCountMode = 'explicit';\n\t //mute initially\n\t this.mute = options.mute;\n\t };\n\t Tone.extend(Tone.Source, Tone.AudioNode);\n\t /**\n\t\t * The default parameters\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Source.defaults = {\n\t 'volume': 0,\n\t 'mute': false\n\t };\n\t /**\n\t\t * Returns the playback state of the source, either \"started\" or \"stopped\".\n\t\t * @type {Tone.State}\n\t\t * @readOnly\n\t\t * @memberOf Tone.Source#\n\t\t * @name state\n\t\t */\n\t Object.defineProperty(Tone.Source.prototype, 'state', {\n\t get: function () {\n\t if (this._synced) {\n\t if (Tone.Transport.state === Tone.State.Started) {\n\t return this._state.getValueAtTime(Tone.Transport.seconds);\n\t } else {\n\t return Tone.State.Stopped;\n\t }\n\t } else {\n\t return this._state.getValueAtTime(this.now());\n\t }\n\t }\n\t });\n\t /**\n\t\t * Mute the output.\n\t\t * @memberOf Tone.Source#\n\t\t * @type {boolean}\n\t\t * @name mute\n\t\t * @example\n\t\t * //mute the output\n\t\t * source.mute = true;\n\t\t */\n\t Object.defineProperty(Tone.Source.prototype, 'mute', {\n\t get: function () {\n\t return this._volume.mute;\n\t },\n\t set: function (mute) {\n\t this._volume.mute = mute;\n\t }\n\t });\n\t //overwrite these functions\n\t Tone.Source.prototype._start = Tone.noOp;\n\t Tone.Source.prototype.restart = Tone.noOp;\n\t Tone.Source.prototype._stop = Tone.noOp;\n\t /**\n\t\t * Start the source at the specified time. If no time is given,\n\t\t * start the source now.\n\t\t * @param {Time} [time=now] When the source should be started.\n\t\t * @returns {Tone.Source} this\n\t\t * @example\n\t\t * source.start(\"+0.5\"); //starts the source 0.5 seconds from now\n\t\t */\n\t Tone.Source.prototype.start = function (time, offset, duration) {\n\t if (Tone.isUndef(time) && this._synced) {\n\t time = Tone.Transport.seconds;\n\t } else {\n\t time = this.toSeconds(time);\n\t }\n\t //if it's started, stop it and restart it\n\t if (this._state.getValueAtTime(time) === Tone.State.Started) {\n\t this._state.cancel(time);\n\t this._state.setStateAtTime(Tone.State.Started, time);\n\t this.restart(time, offset, duration);\n\t } else {\n\t this._state.setStateAtTime(Tone.State.Started, time);\n\t if (this._synced) {\n\t // add the offset time to the event\n\t var event = this._state.get(time);\n\t event.offset = Tone.defaultArg(offset, 0);\n\t event.duration = duration;\n\t var sched = Tone.Transport.schedule(function (t) {\n\t this._start(t, offset, duration);\n\t }.bind(this), time);\n\t this._scheduled.push(sched);\n\t //if it's already started\n\t if (Tone.Transport.state === Tone.State.Started) {\n\t this._syncedStart(this.now(), Tone.Transport.seconds);\n\t }\n\t } else {\n\t this._start.apply(this, arguments);\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Stop the source at the specified time. If no time is given,\n\t\t * stop the source now.\n\t\t * @param {Time} [time=now] When the source should be stopped.\n\t\t * @returns {Tone.Source} this\n\t\t * @example\n\t\t * source.stop(); // stops the source immediately\n\t\t */\n\t Tone.Source.prototype.stop = function (time) {\n\t if (Tone.isUndef(time) && this._synced) {\n\t time = Tone.Transport.seconds;\n\t } else {\n\t time = this.toSeconds(time);\n\t }\n\t if (!this._synced) {\n\t this._stop.apply(this, arguments);\n\t } else {\n\t var sched = Tone.Transport.schedule(this._stop.bind(this), time);\n\t this._scheduled.push(sched);\n\t }\n\t this._state.cancel(time);\n\t this._state.setStateAtTime(Tone.State.Stopped, time);\n\t return this;\n\t };\n\t /**\n\t\t * Sync the source to the Transport so that all subsequent\n\t\t * calls to `start` and `stop` are synced to the TransportTime\n\t\t * instead of the AudioContext time.\n\t\t *\n\t\t * @returns {Tone.Source} this\n\t\t * @example\n\t\t * //sync the source so that it plays between 0 and 0.3 on the Transport's timeline\n\t\t * source.sync().start(0).stop(0.3);\n\t\t * //start the transport.\n\t\t * Tone.Transport.start();\n\t\t *\n\t\t * @example\n\t\t * //start the transport with an offset and the sync'ed sources\n\t\t * //will start in the correct position\n\t\t * source.sync().start(0.1);\n\t\t * //the source will be invoked with an offset of 0.4\n\t\t * Tone.Transport.start(\"+0.5\", 0.5);\n\t\t */\n\t Tone.Source.prototype.sync = function () {\n\t this._synced = true;\n\t this._syncedStart = function (time, offset) {\n\t if (offset > 0) {\n\t // get the playback state at that time\n\t var stateEvent = this._state.get(offset);\n\t // listen for start events which may occur in the middle of the sync'ed time\n\t if (stateEvent && stateEvent.state === Tone.State.Started && stateEvent.time !== offset) {\n\t // get the offset\n\t var startOffset = offset - this.toSeconds(stateEvent.time);\n\t var duration;\n\t if (stateEvent.duration) {\n\t duration = this.toSeconds(stateEvent.duration) - startOffset;\n\t }\n\t this._start(time, this.toSeconds(stateEvent.offset) + startOffset, duration);\n\t }\n\t }\n\t }.bind(this);\n\t this._syncedStop = function (time) {\n\t var seconds = Tone.Transport.getSecondsAtTime(Math.max(time - this.sampleTime, 0));\n\t if (this._state.getValueAtTime(seconds) === Tone.State.Started) {\n\t this._stop(time);\n\t }\n\t }.bind(this);\n\t Tone.Transport.on('start loopStart', this._syncedStart);\n\t Tone.Transport.on('stop pause loopEnd', this._syncedStop);\n\t return this;\n\t };\n\t /**\n\t\t * Unsync the source to the Transport. See Tone.Source.sync\n\t\t * @returns {Tone.Source} this\n\t\t */\n\t Tone.Source.prototype.unsync = function () {\n\t if (this._synced) {\n\t Tone.Transport.off('stop pause loopEnd', this._syncedStop);\n\t Tone.Transport.off('start loopStart', this._syncedStart);\n\t }\n\t this._synced = false;\n\t // clear all of the scheduled ids\n\t for (var i = 0; i < this._scheduled.length; i++) {\n\t var id = this._scheduled[i];\n\t Tone.Transport.clear(id);\n\t }\n\t this._scheduled = [];\n\t this._state.cancel(0);\n\t return this;\n\t };\n\t /**\n\t\t *\tClean up.\n\t\t * @return {Tone.Source} this\n\t\t */\n\t Tone.Source.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this.unsync();\n\t this._scheduled = null;\n\t this._writable('volume');\n\t this._volume.dispose();\n\t this._volume = null;\n\t this.volume = null;\n\t this._state.dispose();\n\t this._state = null;\n\t };\n\t return Tone.Source;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * AudioBuffer.copyTo/FromChannel polyfill\n\t\t * @private\n\t\t */\n\t if (Tone.supported) {\n\t if (!AudioBuffer.prototype.copyToChannel) {\n\t AudioBuffer.prototype.copyToChannel = function (src, chanNum, start) {\n\t var channel = this.getChannelData(chanNum);\n\t start = start || 0;\n\t for (var i = 0; i < channel.length; i++) {\n\t channel[i + start] = src[i];\n\t }\n\t };\n\t AudioBuffer.prototype.copyFromChannel = function (dest, chanNum, start) {\n\t var channel = this.getChannelData(chanNum);\n\t start = start || 0;\n\t for (var i = 0; i < dest.length; i++) {\n\t dest[i] = channel[i + start];\n\t }\n\t };\n\t }\n\t }\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Buffer loading and storage. Tone.Buffer is used internally by all\n\t\t * classes that make requests for audio files such as Tone.Player,\n\t\t * Tone.Sampler and Tone.Convolver.\n\t\t *\n\t\t * Aside from load callbacks from individual buffers, Tone.Buffer\n\t\t * \t\tprovides events which keep track of the loading progress\n\t\t * \t\tof _all_ of the buffers. These are Tone.Buffer.on(\"load\" / \"progress\" / \"error\")\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone}\n\t\t * @param {AudioBuffer|String} url The url to load, or the audio buffer to set.\n\t\t * @param {Function=} onload A callback which is invoked after the buffer is loaded.\n\t\t * It's recommended to use `Tone.Buffer.on('load', callback)` instead\n\t\t * since it will give you a callback when _all_ buffers are loaded.\n\t\t * @param {Function=} onerror The callback to invoke if there is an error\n\t\t * @example\n\t\t * var buffer = new Tone.Buffer(\"path/to/sound.mp3\", function(){\n\t\t * \t//the buffer is now available.\n\t\t * \tvar buff = buffer.get();\n\t\t * });\n\t\t * @example\n\t\t * //can load provide fallback extension types if the first type is not supported.\n\t\t * var buffer = new Tone.Buffer(\"path/to/sound.[mp3|ogg|wav]\");\n\t\t */\n\t Tone.Buffer = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'url',\n\t 'onload',\n\t 'onerror'\n\t ], Tone.Buffer);\n\t Tone.call(this);\n\t /**\n\t\t\t * stores the loaded AudioBuffer\n\t\t\t * @type {AudioBuffer}\n\t\t\t * @private\n\t\t\t */\n\t this._buffer = null;\n\t /**\n\t\t\t * indicates if the buffer should be reversed or not\n\t\t\t * @type {Boolean}\n\t\t\t * @private\n\t\t\t */\n\t this._reversed = options.reverse;\n\t /**\n\t\t\t * The XHR\n\t\t\t * @type {XMLHttpRequest}\n\t\t\t * @private\n\t\t\t */\n\t this._xhr = null;\n\t /**\n\t\t\t * Private callback when the buffer is loaded.\n\t\t\t * @type {Function}\n\t\t\t * @private\n\t\t\t */\n\t this._onload = Tone.noOp;\n\t if (options.url instanceof AudioBuffer || options.url instanceof Tone.Buffer) {\n\t this.set(options.url);\n\t // invoke the onload callback\n\t if (options.onload) {\n\t if (this.loaded) {\n\t options.onload(this);\n\t } else {\n\t this._onload = options.onload;\n\t }\n\t }\n\t } else if (Tone.isString(options.url)) {\n\t this.load(options.url).then(options.onload).catch(options.onerror);\n\t }\n\t };\n\t Tone.extend(Tone.Buffer);\n\t /**\n\t\t * the default parameters\n\t\t * @type {Object}\n\t\t */\n\t Tone.Buffer.defaults = {\n\t 'url': undefined,\n\t 'reverse': false,\n\t 'onload': Tone.noOp,\n\t 'onerror': Tone.noOp\n\t };\n\t /**\n\t\t * Pass in an AudioBuffer or Tone.Buffer to set the value\n\t\t * of this buffer.\n\t\t * @param {AudioBuffer|Tone.Buffer} buffer the buffer\n\t\t * @returns {Tone.Buffer} this\n\t\t */\n\t Tone.Buffer.prototype.set = function (buffer) {\n\t if (buffer instanceof Tone.Buffer) {\n\t if (buffer.loaded) {\n\t this._buffer = buffer.get();\n\t } else {\n\t buffer._onload = function () {\n\t this.set(buffer);\n\t this._onload(this);\n\t }.bind(this);\n\t }\n\t } else {\n\t this._buffer = buffer;\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * @return {AudioBuffer} The audio buffer stored in the object.\n\t\t */\n\t Tone.Buffer.prototype.get = function () {\n\t return this._buffer;\n\t };\n\t /**\n\t\t * Makes an xhr reqest for the selected url then decodes\n\t\t * the file as an audio buffer. Invokes\n\t\t * the callback once the audio buffer loads.\n\t\t * @param {String} url The url of the buffer to load.\n\t\t * filetype support depends on the\n\t\t * browser.\n\t\t * @returns {Promise} returns a Promise which resolves with the Tone.Buffer\n\t\t */\n\t Tone.Buffer.prototype.load = function (url, onload, onerror) {\n\t var promise = new Promise(function (load, error) {\n\t this._xhr = Tone.Buffer.load(url, //success\n\t function (buff) {\n\t this._xhr = null;\n\t this.set(buff);\n\t load(this);\n\t this._onload(this);\n\t if (onload) {\n\t onload(this);\n\t }\n\t }.bind(this), //error\n\t function (err) {\n\t this._xhr = null;\n\t error(err);\n\t if (onerror) {\n\t onerror(err);\n\t }\n\t }.bind(this));\n\t }.bind(this));\n\t return promise;\n\t };\n\t /**\n\t\t * dispose and disconnect\n\t\t * @returns {Tone.Buffer} this\n\t\t */\n\t Tone.Buffer.prototype.dispose = function () {\n\t Tone.prototype.dispose.call(this);\n\t this._buffer = null;\n\t if (this._xhr) {\n\t Tone.Buffer._removeFromDownloadQueue(this._xhr);\n\t this._xhr.abort();\n\t this._xhr = null;\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * If the buffer is loaded or not\n\t\t * @memberOf Tone.Buffer#\n\t\t * @type {Boolean}\n\t\t * @name loaded\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Buffer.prototype, 'loaded', {\n\t get: function () {\n\t return this.length > 0;\n\t }\n\t });\n\t /**\n\t\t * The duration of the buffer.\n\t\t * @memberOf Tone.Buffer#\n\t\t * @type {Number}\n\t\t * @name duration\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Buffer.prototype, 'duration', {\n\t get: function () {\n\t if (this._buffer) {\n\t return this._buffer.duration;\n\t } else {\n\t return 0;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The length of the buffer in samples\n\t\t * @memberOf Tone.Buffer#\n\t\t * @type {Number}\n\t\t * @name length\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Buffer.prototype, 'length', {\n\t get: function () {\n\t if (this._buffer) {\n\t return this._buffer.length;\n\t } else {\n\t return 0;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The number of discrete audio channels. Returns 0 if no buffer\n\t\t * is loaded.\n\t\t * @memberOf Tone.Buffer#\n\t\t * @type {Number}\n\t\t * @name numberOfChannels\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Buffer.prototype, 'numberOfChannels', {\n\t get: function () {\n\t if (this._buffer) {\n\t return this._buffer.numberOfChannels;\n\t } else {\n\t return 0;\n\t }\n\t }\n\t });\n\t /**\n\t\t * Set the audio buffer from the array. To create a multichannel AudioBuffer,\n\t\t * pass in a multidimensional array.\n\t\t * @param {Float32Array} array The array to fill the audio buffer\n\t\t * @return {Tone.Buffer} this\n\t\t */\n\t Tone.Buffer.prototype.fromArray = function (array) {\n\t var isMultidimensional = array[0].length > 0;\n\t var channels = isMultidimensional ? array.length : 1;\n\t var len = isMultidimensional ? array[0].length : array.length;\n\t var buffer = this.context.createBuffer(channels, len, this.context.sampleRate);\n\t if (!isMultidimensional && channels === 1) {\n\t array = [array];\n\t }\n\t for (var c = 0; c < channels; c++) {\n\t buffer.copyToChannel(array[c], c);\n\t }\n\t this._buffer = buffer;\n\t return this;\n\t };\n\t /**\n\t\t * \tSums muliple channels into 1 channel\n\t\t * @param {Number=} channel Optionally only copy a single channel from the array.\n\t\t * @return {Array}\n\t\t */\n\t Tone.Buffer.prototype.toMono = function (chanNum) {\n\t if (Tone.isNumber(chanNum)) {\n\t this.fromArray(this.toArray(chanNum));\n\t } else {\n\t var outputArray = new Float32Array(this.length);\n\t var numChannels = this.numberOfChannels;\n\t for (var channel = 0; channel < numChannels; channel++) {\n\t var channelArray = this.toArray(channel);\n\t for (var i = 0; i < channelArray.length; i++) {\n\t outputArray[i] += channelArray[i];\n\t }\n\t }\n\t //divide by the number of channels\n\t outputArray = outputArray.map(function (sample) {\n\t return sample / numChannels;\n\t });\n\t this.fromArray(outputArray);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * \tGet the buffer as an array. Single channel buffers will return a 1-dimensional\n\t\t * \tFloat32Array, and multichannel buffers will return multidimensional arrays.\n\t\t * @param {Number=} channel Optionally only copy a single channel from the array.\n\t\t * @return {Array}\n\t\t */\n\t Tone.Buffer.prototype.toArray = function (channel) {\n\t if (Tone.isNumber(channel)) {\n\t return this.getChannelData(channel);\n\t } else if (this.numberOfChannels === 1) {\n\t return this.toArray(0);\n\t } else {\n\t var ret = [];\n\t for (var c = 0; c < this.numberOfChannels; c++) {\n\t ret[c] = this.getChannelData(c);\n\t }\n\t return ret;\n\t }\n\t };\n\t /**\n\t\t * Returns the Float32Array representing the PCM audio data for the specific channel.\n\t\t * @param {Number} channel The channel number to return\n\t\t * @return {Float32Array} The audio as a TypedArray\n\t\t */\n\t Tone.Buffer.prototype.getChannelData = function (channel) {\n\t return this._buffer.getChannelData(channel);\n\t };\n\t /**\n\t\t * Cut a subsection of the array and return a buffer of the\n\t\t * subsection. Does not modify the original buffer\n\t\t * @param {Time} start The time to start the slice\n\t\t * @param {Time=} end The end time to slice. If none is given\n\t\t * will default to the end of the buffer\n\t\t * @return {Tone.Buffer} this\n\t\t */\n\t Tone.Buffer.prototype.slice = function (start, end) {\n\t end = Tone.defaultArg(end, this.duration);\n\t var startSamples = Math.floor(this.context.sampleRate * this.toSeconds(start));\n\t var endSamples = Math.floor(this.context.sampleRate * this.toSeconds(end));\n\t var replacement = [];\n\t for (var i = 0; i < this.numberOfChannels; i++) {\n\t replacement[i] = this.toArray(i).slice(startSamples, endSamples);\n\t }\n\t var retBuffer = new Tone.Buffer().fromArray(replacement);\n\t return retBuffer;\n\t };\n\t /**\n\t\t * Reverse the buffer.\n\t\t * @private\n\t\t * @return {Tone.Buffer} this\n\t\t */\n\t Tone.Buffer.prototype._reverse = function () {\n\t if (this.loaded) {\n\t for (var i = 0; i < this.numberOfChannels; i++) {\n\t Array.prototype.reverse.call(this.getChannelData(i));\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Reverse the buffer.\n\t\t * @memberOf Tone.Buffer#\n\t\t * @type {Boolean}\n\t\t * @name reverse\n\t\t */\n\t Object.defineProperty(Tone.Buffer.prototype, 'reverse', {\n\t get: function () {\n\t return this._reversed;\n\t },\n\t set: function (rev) {\n\t if (this._reversed !== rev) {\n\t this._reversed = rev;\n\t this._reverse();\n\t }\n\t }\n\t });\n\t ///////////////////////////////////////////////////////////////////////////\n\t // STATIC METHODS\n\t ///////////////////////////////////////////////////////////////////////////\n\t //statically inherits Emitter methods\n\t Tone.Emitter.mixin(Tone.Buffer);\n\t /**\n\t\t * the static queue for all of the xhr requests\n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t Tone.Buffer._downloadQueue = [];\n\t /**\n\t\t * A path which is prefixed before every url.\n\t\t * @type {String}\n\t\t * @static\n\t\t */\n\t Tone.Buffer.baseUrl = '';\n\t /**\n\t\t * Create a Tone.Buffer from the array. To create a multichannel AudioBuffer,\n\t\t * pass in a multidimensional array.\n\t\t * @param {Float32Array} array The array to fill the audio buffer\n\t\t * @return {Tone.Buffer} A Tone.Buffer created from the array\n\t\t */\n\t Tone.Buffer.fromArray = function (array) {\n\t return new Tone.Buffer().fromArray(array);\n\t };\n\t /**\n\t\t * Creates a Tone.Buffer from a URL, returns a promise\n\t\t * which resolves to a Tone.Buffer\n\t\t * @param {String} url The url to load.\n\t\t * @return {Promise<Tone.Buffer>} A promise which resolves to a Tone.Buffer\n\t\t */\n\t Tone.Buffer.fromUrl = function (url) {\n\t var buffer = new Tone.Buffer();\n\t return buffer.load(url).then(function () {\n\t return buffer;\n\t });\n\t };\n\t /**\n\t\t * Remove an xhr request from the download queue\n\t\t * @private\n\t\t */\n\t Tone.Buffer._removeFromDownloadQueue = function (request) {\n\t var index = Tone.Buffer._downloadQueue.indexOf(request);\n\t if (index !== -1) {\n\t Tone.Buffer._downloadQueue.splice(index, 1);\n\t }\n\t };\n\t /**\n\t\t * Loads a url using XMLHttpRequest.\n\t\t * @param {String} url\n\t\t * @param {Function} onload\n\t\t * @param {Function} onerror\n\t\t * @param {Function} onprogress\n\t\t * @return {XMLHttpRequest}\n\t\t */\n\t Tone.Buffer.load = function (url, onload, onerror) {\n\t //default\n\t onload = Tone.defaultArg(onload, Tone.noOp);\n\t // test if the url contains multiple extensions\n\t var matches = url.match(/\\[(.+\\|?)+\\]$/);\n\t if (matches) {\n\t var extensions = matches[1].split('|');\n\t var extension = extensions[0];\n\t for (var i = 0; i < extensions.length; i++) {\n\t if (Tone.Buffer.supportsType(extensions[i])) {\n\t extension = extensions[i];\n\t break;\n\t }\n\t }\n\t url = url.replace(matches[0], extension);\n\t }\n\t function onError(e) {\n\t Tone.Buffer._removeFromDownloadQueue(request);\n\t Tone.Buffer.emit('error', e);\n\t if (onerror) {\n\t onerror(e);\n\t } else {\n\t throw e;\n\t }\n\t }\n\t function onProgress() {\n\t //calculate the progress\n\t var totalProgress = 0;\n\t for (var i = 0; i < Tone.Buffer._downloadQueue.length; i++) {\n\t totalProgress += Tone.Buffer._downloadQueue[i].progress;\n\t }\n\t Tone.Buffer.emit('progress', totalProgress / Tone.Buffer._downloadQueue.length);\n\t }\n\t var request = new XMLHttpRequest();\n\t request.open('GET', Tone.Buffer.baseUrl + url, true);\n\t request.responseType = 'arraybuffer';\n\t //start out as 0\n\t request.progress = 0;\n\t Tone.Buffer._downloadQueue.push(request);\n\t request.addEventListener('load', function () {\n\t if (request.status === 200) {\n\t Tone.context.decodeAudioData(request.response).then(function (buff) {\n\t request.progress = 1;\n\t onProgress();\n\t onload(buff);\n\t Tone.Buffer._removeFromDownloadQueue(request);\n\t if (Tone.Buffer._downloadQueue.length === 0) {\n\t //emit the event at the end\n\t Tone.Buffer.emit('load');\n\t }\n\t }).catch(function () {\n\t Tone.Buffer._removeFromDownloadQueue(request);\n\t onError('Tone.Buffer: could not decode audio data: ' + url);\n\t });\n\t } else {\n\t onError('Tone.Buffer: could not locate file: ' + url);\n\t }\n\t });\n\t request.addEventListener('error', onError);\n\t request.addEventListener('progress', function (event) {\n\t if (event.lengthComputable) {\n\t //only go to 95%, the last 5% is when the audio is decoded\n\t request.progress = event.loaded / event.total * 0.95;\n\t onProgress();\n\t }\n\t });\n\t request.send();\n\t return request;\n\t };\n\t /**\n\t\t * Stop all of the downloads in progress\n\t\t * @return {Tone.Buffer}\n\t\t * @static\n\t\t */\n\t Tone.Buffer.cancelDownloads = function () {\n\t Tone.Buffer._downloadQueue.slice().forEach(function (request) {\n\t Tone.Buffer._removeFromDownloadQueue(request);\n\t request.abort();\n\t });\n\t return Tone.Buffer;\n\t };\n\t /**\n\t\t * Checks a url's extension to see if the current browser can play that file type.\n\t\t * @param {String} url The url/extension to test\n\t\t * @return {Boolean} If the file extension can be played\n\t\t * @static\n\t\t * @example\n\t\t * Tone.Buffer.supportsType(\"wav\"); //returns true\n\t\t * Tone.Buffer.supportsType(\"path/to/file.wav\"); //returns true\n\t\t */\n\t Tone.Buffer.supportsType = function (url) {\n\t var extension = url.split('.');\n\t extension = extension[extension.length - 1];\n\t var response = document.createElement('audio').canPlayType('audio/' + extension);\n\t return response !== '';\n\t };\n\t /**\n\t\t * Returns a Promise which resolves when all of the buffers have loaded\n\t\t * @return {Promise}\n\t\t */\n\t Tone.loaded = function () {\n\t var onload, onerror;\n\t function removeEvents() {\n\t //remove the events when it's resolved\n\t Tone.Buffer.off('load', onload);\n\t Tone.Buffer.off('error', onerror);\n\t }\n\t return new Promise(function (success, fail) {\n\t onload = function () {\n\t success();\n\t };\n\t onerror = function () {\n\t fail();\n\t };\n\t //add the event listeners\n\t Tone.Buffer.on('load', onload);\n\t Tone.Buffer.on('error', onerror);\n\t }).then(removeEvents).catch(function (e) {\n\t removeEvents();\n\t throw new Error(e);\n\t });\n\t };\n\t return Tone.Buffer;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Wrapper around the native fire-and-forget OscillatorNode. Adds the\n\t\t * ability to reschedule the stop method.\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {AudioBuffer|Tone.Buffer} buffer The buffer to play\n\t\t * @param {Function} onload The callback to invoke when the\n\t\t * buffer is done playing.\n\t\t */\n\t Tone.OscillatorNode = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'type'\n\t ], Tone.OscillatorNode);\n\t Tone.AudioNode.call(this, options);\n\t /**\n\t\t\t * The callback to invoke after the\n\t\t\t * buffer source is done playing.\n\t\t\t * @type {Function}\n\t\t\t */\n\t this.onended = options.onended;\n\t /**\n\t\t\t * The oscillator start time\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._startTime = -1;\n\t /**\n\t\t\t * The oscillator stop time\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._stopTime = -1;\n\t /**\n\t\t\t * The gain node which envelopes the OscillatorNode\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._gainNode = this.output = new Tone.Gain();\n\t this._gainNode.gain.setValueAtTime(0, this.context.currentTime);\n\t /**\n\t\t\t * The oscillator\n\t\t\t * @type {OscillatorNode}\n\t\t\t * @private\n\t\t\t */\n\t this._oscillator = this.context.createOscillator();\n\t this._oscillator.connect(this._gainNode);\n\t this.type = options.type;\n\t /**\n\t\t\t * The frequency of the oscillator\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = new Tone.Param(this._oscillator.frequency, Tone.Type.Frequency);\n\t this.frequency.value = options.frequency;\n\t /**\n\t\t\t * The detune of the oscillator\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = new Tone.Param(this._oscillator.detune, Tone.Type.Cents);\n\t this.detune.value = options.detune;\n\t /**\n\t\t\t * The value that the buffer ramps to\n\t\t\t * @type {Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._gain = 1;\n\t };\n\t Tone.extend(Tone.OscillatorNode, Tone.AudioNode);\n\t /**\n\t\t * The defaults\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.OscillatorNode.defaults = {\n\t 'frequency': 440,\n\t 'detune': 0,\n\t 'type': 'sine',\n\t 'onended': Tone.noOp\n\t };\n\t /**\n\t\t * Returns the playback state of the oscillator, either \"started\" or \"stopped\".\n\t\t * @type {Tone.State}\n\t\t * @readOnly\n\t\t * @memberOf Tone.OscillatorNode#\n\t\t * @name state\n\t\t */\n\t Object.defineProperty(Tone.OscillatorNode.prototype, 'state', {\n\t get: function () {\n\t return this.getStateAtTime(this.now());\n\t }\n\t });\n\t /**\n\t\t * Get the playback state at the given time\n\t\t * @param {Time} time The time to test the state at\n\t\t * @return {Tone.State} The playback state. \n\t\t */\n\t Tone.OscillatorNode.prototype.getStateAtTime = function (time) {\n\t time = this.toSeconds(time);\n\t if (this._startTime !== -1 && time >= this._startTime && (this._stopTime === -1 || time <= this._stopTime)) {\n\t return Tone.State.Started;\n\t } else {\n\t return Tone.State.Stopped;\n\t }\n\t };\n\t /**\n\t * Start the oscillator node at the given time\n\t * @param {Time=} time When to start the oscillator\n\t * @return {OscillatorNode} this\n\t */\n\t Tone.OscillatorNode.prototype.start = function (time) {\n\t if (this._startTime === -1) {\n\t this._startTime = this.toSeconds(time);\n\t this._oscillator.start(this._startTime);\n\t var now = this.context.currentTime;\n\t this._gainNode.gain.cancelScheduledValues(now);\n\t this._gainNode.gain.setValueAtTime(0, now);\n\t this._gainNode.gain.setValueAtTime(1, this._startTime);\n\t } else {\n\t throw new Error('cannot call OscillatorNode.start more than once');\n\t }\n\t return this;\n\t };\n\t /**\n\t * Sets an arbitrary custom periodic waveform given a PeriodicWave.\n\t * @param {PeriodicWave} periodicWave PeriodicWave should be created with context.createPeriodicWave\n\t * @return {OscillatorNode} this\n\t */\n\t Tone.OscillatorNode.prototype.setPeriodicWave = function (periodicWave) {\n\t this._oscillator.setPeriodicWave(periodicWave);\n\t return this;\n\t };\n\t /**\n\t * Stop the oscillator node at the given time\n\t * @param {Time=} time When to stop the oscillator\n\t * @return {OscillatorNode} this\n\t */\n\t Tone.OscillatorNode.prototype.stop = function (time) {\n\t //cancel the previous stop\n\t this.cancelStop();\n\t //reschedule it\n\t this._stopTime = this.toSeconds(time);\n\t this._gainNode.gain.setValueAtTime(0, this._stopTime);\n\t this.context.clearTimeout(this._timeout);\n\t this._timeout = this.context.setTimeout(function () {\n\t this._oscillator.stop(this.now());\n\t this.onended();\n\t }.bind(this), this._stopTime - this.now());\n\t return this;\n\t };\n\t /**\n\t\t * Cancel a scheduled stop event\n\t\t * @return {Tone.OscillatorNode} this\n\t\t */\n\t Tone.OscillatorNode.prototype.cancelStop = function () {\n\t if (this._startTime !== -1) {\n\t //cancel the stop envelope\n\t this._gainNode.gain.cancelScheduledValues(this._startTime + this.sampleTime);\n\t this._gainNode.gain.setValueAtTime(1, Math.max(this.now(), this._startTime));\n\t this.context.clearTimeout(this._timeout);\n\t this._stopTime = -1;\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * The oscillator type. Either 'sine', 'sawtooth', 'square', or 'triangle'\n\t\t * @memberOf Tone.OscillatorNode#\n\t\t * @type {Time}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.OscillatorNode.prototype, 'type', {\n\t get: function () {\n\t return this._oscillator.type;\n\t },\n\t set: function (type) {\n\t this._oscillator.type = type;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.OscillatorNode} this\n\t\t */\n\t Tone.OscillatorNode.prototype.dispose = function () {\n\t this.context.clearTimeout(this._timeout);\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this.onended = null;\n\t this._oscillator.disconnect();\n\t this._oscillator = null;\n\t this._gainNode.dispose();\n\t this._gainNode = null;\n\t this.frequency.dispose();\n\t this.frequency = null;\n\t this.detune.dispose();\n\t this.detune = null;\n\t return this;\n\t };\n\t return Tone.OscillatorNode;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Oscillator supports a number of features including\n\t\t * phase rotation, multiple oscillator types (see Tone.Oscillator.type),\n\t\t * and Transport syncing (see Tone.Oscillator.syncFrequency).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Source}\n\t\t * @param {Frequency} [frequency] Starting frequency\n\t\t * @param {string} [type] The oscillator type. Read more about type below.\n\t\t * @example\n\t\t * //make and start a 440hz sine tone\n\t\t * var osc = new Tone.Oscillator(440, \"sine\").toMaster().start();\n\t\t */\n\t Tone.Oscillator = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'type'\n\t ], Tone.Oscillator);\n\t Tone.Source.call(this, options);\n\t /**\n\t\t\t * the main oscillator\n\t\t\t * @type {OscillatorNode}\n\t\t\t * @private\n\t\t\t */\n\t this._oscillator = null;\n\t /**\n\t\t\t * The frequency control.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency);\n\t /**\n\t\t\t * The detune control signal.\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = new Tone.Signal(options.detune, Tone.Type.Cents);\n\t /**\n\t\t\t * the periodic wave\n\t\t\t * @type {PeriodicWave}\n\t\t\t * @private\n\t\t\t */\n\t this._wave = null;\n\t /**\n\t\t\t * The partials of the oscillator\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._partials = Tone.defaultArg(options.partials, [1]);\n\t /**\n\t\t\t * the phase of the oscillator\n\t\t\t * between 0 - 360\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._phase = options.phase;\n\t /**\n\t\t\t * the type of the oscillator\n\t\t\t * @type {string}\n\t\t\t * @private\n\t\t\t */\n\t this._type = null;\n\t //setup\n\t this.type = options.type;\n\t this.phase = this._phase;\n\t this._readOnly([\n\t 'frequency',\n\t 'detune'\n\t ]);\n\t };\n\t Tone.extend(Tone.Oscillator, Tone.Source);\n\t /**\n\t\t * the default parameters\n\t\t * @type {Object}\n\t\t */\n\t Tone.Oscillator.defaults = {\n\t 'type': 'sine',\n\t 'frequency': 440,\n\t 'detune': 0,\n\t 'phase': 0,\n\t 'partials': []\n\t };\n\t /**\n\t\t * The Oscillator types\n\t\t * @enum {String}\n\t\t */\n\t Tone.Oscillator.Type = {\n\t Sine: 'sine',\n\t Triangle: 'triangle',\n\t Sawtooth: 'sawtooth',\n\t Square: 'square',\n\t Custom: 'custom'\n\t };\n\t /**\n\t\t * start the oscillator\n\t\t * @param {Time} [time=now]\n\t\t * @private\n\t\t */\n\t Tone.Oscillator.prototype._start = function (time) {\n\t //new oscillator with previous values\n\t this._oscillator = new Tone.OscillatorNode();\n\t if (this._wave) {\n\t this._oscillator.setPeriodicWave(this._wave);\n\t } else {\n\t this._oscillator.type = this._type;\n\t }\n\t //connect the control signal to the oscillator frequency & detune\n\t this._oscillator.connect(this.output);\n\t this.frequency.connect(this._oscillator.frequency);\n\t this.detune.connect(this._oscillator.detune);\n\t //start the oscillator\n\t time = this.toSeconds(time);\n\t this._oscillator.start(time);\n\t };\n\t /**\n\t\t * stop the oscillator\n\t\t * @private\n\t\t * @param {Time} [time=now] (optional) timing parameter\n\t\t * @returns {Tone.Oscillator} this\n\t\t */\n\t Tone.Oscillator.prototype._stop = function (time) {\n\t if (this._oscillator) {\n\t time = this.toSeconds(time);\n\t this._oscillator.stop(time);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Restart the oscillator. Does not stop the oscillator, but instead\n\t\t * just cancels any scheduled 'stop' from being invoked.\n\t\t * @param {Time=} time\n\t\t * @return {Tone.Oscillator} this\n\t\t */\n\t Tone.Oscillator.prototype.restart = function (time) {\n\t this._oscillator.cancelStop();\n\t this._state.cancel(this.toSeconds(time));\n\t return this;\n\t };\n\t /**\n\t\t * Sync the signal to the Transport's bpm. Any changes to the transports bpm,\n\t\t * will also affect the oscillators frequency.\n\t\t * @returns {Tone.Oscillator} this\n\t\t * @example\n\t\t * Tone.Transport.bpm.value = 120;\n\t\t * osc.frequency.value = 440;\n\t\t * //the ration between the bpm and the frequency will be maintained\n\t\t * osc.syncFrequency();\n\t\t * Tone.Transport.bpm.value = 240;\n\t\t * // the frequency of the oscillator is doubled to 880\n\t\t */\n\t Tone.Oscillator.prototype.syncFrequency = function () {\n\t Tone.Transport.syncSignal(this.frequency);\n\t return this;\n\t };\n\t /**\n\t\t * Unsync the oscillator's frequency from the Transport.\n\t\t * See Tone.Oscillator.syncFrequency\n\t\t * @returns {Tone.Oscillator} this\n\t\t */\n\t Tone.Oscillator.prototype.unsyncFrequency = function () {\n\t Tone.Transport.unsyncSignal(this.frequency);\n\t return this;\n\t };\n\t /**\n\t\t * The type of the oscillator: either sine, square, triangle, or sawtooth. Also capable of\n\t\t * setting the first x number of partials of the oscillator. For example: \"sine4\" would\n\t\t * set be the first 4 partials of the sine wave and \"triangle8\" would set the first\n\t\t * 8 partials of the triangle wave.\n\t\t * <br><br>\n\t\t * Uses PeriodicWave internally even for native types so that it can set the phase.\n\t\t * PeriodicWave equations are from the\n\t\t * [Webkit Web Audio implementation](https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp&sq=package:chromium).\n\t\t *\n\t\t * @memberOf Tone.Oscillator#\n\t\t * @type {string}\n\t\t * @name type\n\t\t * @example\n\t\t * //set it to a square wave\n\t\t * osc.type = \"square\";\n\t\t * @example\n\t\t * //set the first 6 partials of a sawtooth wave\n\t\t * osc.type = \"sawtooth6\";\n\t\t */\n\t Object.defineProperty(Tone.Oscillator.prototype, 'type', {\n\t get: function () {\n\t return this._type;\n\t },\n\t set: function (type) {\n\t var isBasicType = [\n\t Tone.Oscillator.Type.Sine,\n\t Tone.Oscillator.Type.Square,\n\t Tone.Oscillator.Type.Triangle,\n\t Tone.Oscillator.Type.Sawtooth\n\t ].includes(type);\n\t if (this._phase === 0 && isBasicType) {\n\t this._wave = null;\n\t //just go with the basic approach\n\t if (this._oscillator !== null) {\n\t this._oscillator.type === type;\n\t }\n\t } else {\n\t var coefs = this._getRealImaginary(type, this._phase);\n\t var periodicWave = this.context.createPeriodicWave(coefs[0], coefs[1]);\n\t this._wave = periodicWave;\n\t if (this._oscillator !== null) {\n\t this._oscillator.setPeriodicWave(this._wave);\n\t }\n\t }\n\t this._type = type;\n\t }\n\t });\n\t /**\n\t\t * Returns the real and imaginary components based\n\t\t * on the oscillator type.\n\t\t * @returns {Array} [real, imaginary]\n\t\t * @private\n\t\t */\n\t Tone.Oscillator.prototype._getRealImaginary = function (type, phase) {\n\t var fftSize = 4096;\n\t var periodicWaveSize = fftSize / 2;\n\t var real = new Float32Array(periodicWaveSize);\n\t var imag = new Float32Array(periodicWaveSize);\n\t var partialCount = 1;\n\t if (type === Tone.Oscillator.Type.Custom) {\n\t partialCount = this._partials.length + 1;\n\t periodicWaveSize = partialCount;\n\t } else {\n\t var partial = /^(sine|triangle|square|sawtooth)(\\d+)$/.exec(type);\n\t if (partial) {\n\t partialCount = parseInt(partial[2]) + 1;\n\t type = partial[1];\n\t partialCount = Math.max(partialCount, 2);\n\t periodicWaveSize = partialCount;\n\t }\n\t }\n\t for (var n = 1; n < periodicWaveSize; ++n) {\n\t var piFactor = 2 / (n * Math.PI);\n\t var b;\n\t switch (type) {\n\t case Tone.Oscillator.Type.Sine:\n\t b = n <= partialCount ? 1 : 0;\n\t break;\n\t case Tone.Oscillator.Type.Square:\n\t b = n & 1 ? 2 * piFactor : 0;\n\t break;\n\t case Tone.Oscillator.Type.Sawtooth:\n\t b = piFactor * (n & 1 ? 1 : -1);\n\t break;\n\t case Tone.Oscillator.Type.Triangle:\n\t if (n & 1) {\n\t b = 2 * (piFactor * piFactor) * (n - 1 >> 1 & 1 ? -1 : 1);\n\t } else {\n\t b = 0;\n\t }\n\t break;\n\t case Tone.Oscillator.Type.Custom:\n\t b = this._partials[n - 1];\n\t break;\n\t default:\n\t throw new TypeError('Tone.Oscillator: invalid type: ' + type);\n\t }\n\t if (b !== 0) {\n\t real[n] = -b * Math.sin(phase * n);\n\t imag[n] = b * Math.cos(phase * n);\n\t } else {\n\t real[n] = 0;\n\t imag[n] = 0;\n\t }\n\t }\n\t return [\n\t real,\n\t imag\n\t ];\n\t };\n\t /**\n\t\t * Compute the inverse FFT for a given phase.\n\t\t * @param {Float32Array} real\n\t\t * @param {Float32Array} imag\n\t\t * @param {NormalRange} phase\n\t\t * @return {AudioRange}\n\t\t * @private\n\t\t */\n\t Tone.Oscillator.prototype._inverseFFT = function (real, imag, phase) {\n\t var sum = 0;\n\t var len = real.length;\n\t for (var i = 0; i < len; i++) {\n\t sum += real[i] * Math.cos(i * phase) + imag[i] * Math.sin(i * phase);\n\t }\n\t return sum;\n\t };\n\t /**\n\t\t * Returns the initial value of the oscillator.\n\t\t * @return {AudioRange}\n\t\t * @private\n\t\t */\n\t Tone.Oscillator.prototype._getInitialValue = function () {\n\t var coefs = this._getRealImaginary(this._type, 0);\n\t var real = coefs[0];\n\t var imag = coefs[1];\n\t var maxValue = 0;\n\t var twoPi = Math.PI * 2;\n\t //check for peaks in 8 places\n\t for (var i = 0; i < 8; i++) {\n\t maxValue = Math.max(this._inverseFFT(real, imag, i / 8 * twoPi), maxValue);\n\t }\n\t return -this._inverseFFT(real, imag, this._phase) / maxValue;\n\t };\n\t /**\n\t\t * The partials of the waveform. A partial represents\n\t\t * the amplitude at a harmonic. The first harmonic is the\n\t\t * fundamental frequency, the second is the octave and so on\n\t\t * following the harmonic series.\n\t\t * Setting this value will automatically set the type to \"custom\".\n\t\t * The value is an empty array when the type is not \"custom\".\n\t\t * @memberOf Tone.Oscillator#\n\t\t * @type {Array}\n\t\t * @name partials\n\t\t * @example\n\t\t * osc.partials = [1, 0.2, 0.01];\n\t\t */\n\t Object.defineProperty(Tone.Oscillator.prototype, 'partials', {\n\t get: function () {\n\t if (this._type !== Tone.Oscillator.Type.Custom) {\n\t return [];\n\t } else {\n\t return this._partials;\n\t }\n\t },\n\t set: function (partials) {\n\t this._partials = partials;\n\t this.type = Tone.Oscillator.Type.Custom;\n\t }\n\t });\n\t /**\n\t\t * The phase of the oscillator in degrees.\n\t\t * @memberOf Tone.Oscillator#\n\t\t * @type {Degrees}\n\t\t * @name phase\n\t\t * @example\n\t\t * osc.phase = 180; //flips the phase of the oscillator\n\t\t */\n\t Object.defineProperty(Tone.Oscillator.prototype, 'phase', {\n\t get: function () {\n\t return this._phase * (180 / Math.PI);\n\t },\n\t set: function (phase) {\n\t this._phase = phase * Math.PI / 180;\n\t //reset the type\n\t this.type = this._type;\n\t }\n\t });\n\t /**\n\t\t * Dispose and disconnect.\n\t\t * @return {Tone.Oscillator} this\n\t\t */\n\t Tone.Oscillator.prototype.dispose = function () {\n\t Tone.Source.prototype.dispose.call(this);\n\t if (this._oscillator !== null) {\n\t this._oscillator.dispose();\n\t this._oscillator = null;\n\t }\n\t this._wave = null;\n\t this._writable([\n\t 'frequency',\n\t 'detune'\n\t ]);\n\t this.frequency.dispose();\n\t this.frequency = null;\n\t this.detune.dispose();\n\t this.detune = null;\n\t this._partials = null;\n\t return this;\n\t };\n\t return Tone.Oscillator;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class AudioToGain converts an input in AudioRange [-1,1] to NormalRange [0,1]. \n\t\t * See Tone.GainToAudio.\n\t\t *\n\t\t * @extends {Tone.SignalBase}\n\t\t * @constructor\n\t\t * @example\n\t\t * var a2g = new Tone.AudioToGain();\n\t\t */\n\t Tone.AudioToGain = function () {\n\t Tone.SignalBase.call(this);\n\t /**\n\t\t\t * @type {WaveShaperNode}\n\t\t\t * @private\n\t\t\t */\n\t this._norm = this.input = this.output = new Tone.WaveShaper(function (x) {\n\t return (x + 1) / 2;\n\t });\n\t };\n\t Tone.extend(Tone.AudioToGain, Tone.SignalBase);\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.AudioToGain} this\n\t\t */\n\t Tone.AudioToGain.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._norm.dispose();\n\t this._norm = null;\n\t return this;\n\t };\n\t return Tone.AudioToGain;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.Zero outputs 0's at audio-rate. The reason this has to be\n\t\t * it's own class is that many browsers optimize out Tone.Signal\n\t\t * with a value of 0 and will not process nodes further down the graph.\n\t\t * @extends {Tone.SignalBase}\n\t\t */\n\t Tone.Zero = function () {\n\t Tone.SignalBase.call(this);\n\t /**\n\t\t\t * The gain node\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._gain = this.input = this.output = new Tone.Gain();\n\t this.context.getConstant(0).connect(this._gain);\n\t };\n\t Tone.extend(Tone.Zero, Tone.SignalBase);\n\t /**\n\t\t * clean up\n\t\t * @return {Tone.Zero} this\n\t\t */\n\t Tone.Zero.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._gain.dispose();\n\t this._gain = null;\n\t return this;\n\t };\n\t return Tone.Zero;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class LFO stands for low frequency oscillator. Tone.LFO produces an output signal\n\t\t * which can be attached to an AudioParam or Tone.Signal\n\t\t * in order to modulate that parameter with an oscillator. The LFO can\n\t\t * also be synced to the transport to start/stop and change when the tempo changes.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {Frequency|Object} [frequency] The frequency of the oscillation. Typically, LFOs will be\n\t\t * in the frequency range of 0.1 to 10 hertz.\n\t\t * @param {number=} min The minimum output value of the LFO.\n\t\t * @param {number=} max The maximum value of the LFO.\n\t\t * @example\n\t\t * var lfo = new Tone.LFO(\"4n\", 400, 4000);\n\t\t * lfo.connect(filter.frequency);\n\t\t */\n\t Tone.LFO = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'min',\n\t 'max'\n\t ], Tone.LFO);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The oscillator.\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t * @private\n\t\t\t */\n\t this._oscillator = new Tone.Oscillator({\n\t 'frequency': options.frequency,\n\t 'type': options.type\n\t });\n\t /**\n\t\t\t * the lfo's frequency\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = this._oscillator.frequency;\n\t /**\n\t\t\t * The amplitude of the LFO, which controls the output range between\n\t\t\t * the min and max output. For example if the min is -10 and the max\n\t\t\t * is 10, setting the amplitude to 0.5 would make the LFO modulate\n\t\t\t * between -5 and 5.\n\t\t\t * @type {Number}\n\t\t\t * @signal\n\t\t\t */\n\t this.amplitude = this._oscillator.volume;\n\t this.amplitude.units = Tone.Type.NormalRange;\n\t this.amplitude.value = options.amplitude;\n\t /**\n\t\t\t * The signal which is output when the LFO is stopped\n\t\t\t * @type {Tone.Signal}\n\t\t\t * @private\n\t\t\t */\n\t this._stoppedSignal = new Tone.Signal(0, Tone.Type.AudioRange);\n\t /**\n\t\t\t * Just outputs zeros.\n\t\t\t * @type {Tone.Zero}\n\t\t\t * @private\n\t\t\t */\n\t this._zeros = new Tone.Zero();\n\t /**\n\t\t\t * The value that the LFO outputs when it's stopped\n\t\t\t * @type {AudioRange}\n\t\t\t * @private\n\t\t\t */\n\t this._stoppedValue = 0;\n\t /**\n\t\t\t * @type {Tone.AudioToGain}\n\t\t\t * @private\n\t\t\t */\n\t this._a2g = new Tone.AudioToGain();\n\t /**\n\t\t\t * @type {Tone.Scale}\n\t\t\t * @private\n\t\t\t */\n\t this._scaler = this.output = new Tone.Scale(options.min, options.max);\n\t /**\n\t\t\t * the units of the LFO (used for converting)\n\t\t\t * @type {Tone.Type}\n\t\t\t * @private\n\t\t\t */\n\t this._units = Tone.Type.Default;\n\t this.units = options.units;\n\t //connect it up\n\t this._oscillator.chain(this._a2g, this._scaler);\n\t this._zeros.connect(this._a2g);\n\t this._stoppedSignal.connect(this._a2g);\n\t this._readOnly([\n\t 'amplitude',\n\t 'frequency'\n\t ]);\n\t this.phase = options.phase;\n\t };\n\t Tone.extend(Tone.LFO, Tone.AudioNode);\n\t /**\n\t\t * the default parameters\n\t\t *\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.LFO.defaults = {\n\t 'type': 'sine',\n\t 'min': 0,\n\t 'max': 1,\n\t 'phase': 0,\n\t 'frequency': '4n',\n\t 'amplitude': 1,\n\t 'units': Tone.Type.Default\n\t };\n\t /**\n\t\t * Start the LFO.\n\t\t * @param {Time} [time=now] the time the LFO will start\n\t\t * @returns {Tone.LFO} this\n\t\t */\n\t Tone.LFO.prototype.start = function (time) {\n\t time = this.toSeconds(time);\n\t this._stoppedSignal.setValueAtTime(0, time);\n\t this._oscillator.start(time);\n\t return this;\n\t };\n\t /**\n\t\t * Stop the LFO.\n\t\t * @param {Time} [time=now] the time the LFO will stop\n\t\t * @returns {Tone.LFO} this\n\t\t */\n\t Tone.LFO.prototype.stop = function (time) {\n\t time = this.toSeconds(time);\n\t this._stoppedSignal.setValueAtTime(this._stoppedValue, time);\n\t this._oscillator.stop(time);\n\t return this;\n\t };\n\t /**\n\t\t * Sync the start/stop/pause to the transport\n\t\t * and the frequency to the bpm of the transport\n\t\t * @returns {Tone.LFO} this\n\t\t * @example\n\t\t * lfo.frequency.value = \"8n\";\n\t\t * lfo.sync().start(0)\n\t\t * //the rate of the LFO will always be an eighth note,\n\t\t * //even as the tempo changes\n\t\t */\n\t Tone.LFO.prototype.sync = function () {\n\t this._oscillator.sync();\n\t this._oscillator.syncFrequency();\n\t return this;\n\t };\n\t /**\n\t\t * unsync the LFO from transport control\n\t\t * @returns {Tone.LFO} this\n\t\t */\n\t Tone.LFO.prototype.unsync = function () {\n\t this._oscillator.unsync();\n\t this._oscillator.unsyncFrequency();\n\t return this;\n\t };\n\t /**\n\t\t * The miniumum output of the LFO.\n\t\t * @memberOf Tone.LFO#\n\t\t * @type {number}\n\t\t * @name min\n\t\t */\n\t Object.defineProperty(Tone.LFO.prototype, 'min', {\n\t get: function () {\n\t return this._toUnits(this._scaler.min);\n\t },\n\t set: function (min) {\n\t min = this._fromUnits(min);\n\t this._scaler.min = min;\n\t }\n\t });\n\t /**\n\t\t * The maximum output of the LFO.\n\t\t * @memberOf Tone.LFO#\n\t\t * @type {number}\n\t\t * @name max\n\t\t */\n\t Object.defineProperty(Tone.LFO.prototype, 'max', {\n\t get: function () {\n\t return this._toUnits(this._scaler.max);\n\t },\n\t set: function (max) {\n\t max = this._fromUnits(max);\n\t this._scaler.max = max;\n\t }\n\t });\n\t /**\n\t\t * The type of the oscillator: sine, square, sawtooth, triangle.\n\t\t * @memberOf Tone.LFO#\n\t\t * @type {string}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.LFO.prototype, 'type', {\n\t get: function () {\n\t return this._oscillator.type;\n\t },\n\t set: function (type) {\n\t this._oscillator.type = type;\n\t this._stoppedValue = this._oscillator._getInitialValue();\n\t this._stoppedSignal.value = this._stoppedValue;\n\t }\n\t });\n\t /**\n\t\t * The phase of the LFO.\n\t\t * @memberOf Tone.LFO#\n\t\t * @type {number}\n\t\t * @name phase\n\t\t */\n\t Object.defineProperty(Tone.LFO.prototype, 'phase', {\n\t get: function () {\n\t return this._oscillator.phase;\n\t },\n\t set: function (phase) {\n\t this._oscillator.phase = phase;\n\t this._stoppedValue = this._oscillator._getInitialValue();\n\t this._stoppedSignal.value = this._stoppedValue;\n\t }\n\t });\n\t /**\n\t\t * The output units of the LFO.\n\t\t * @memberOf Tone.LFO#\n\t\t * @type {Tone.Type}\n\t\t * @name units\n\t\t */\n\t Object.defineProperty(Tone.LFO.prototype, 'units', {\n\t get: function () {\n\t return this._units;\n\t },\n\t set: function (val) {\n\t var currentMin = this.min;\n\t var currentMax = this.max;\n\t //convert the min and the max\n\t this._units = val;\n\t this.min = currentMin;\n\t this.max = currentMax;\n\t }\n\t });\n\t /**\n\t\t * Mute the output.\n\t\t * @memberOf Tone.LFO#\n\t\t * @type {Boolean}\n\t\t * @name mute\n\t\t */\n\t Object.defineProperty(Tone.LFO.prototype, 'mute', {\n\t get: function () {\n\t return this._oscillator.mute;\n\t },\n\t set: function (mute) {\n\t this._oscillator.mute = mute;\n\t }\n\t });\n\t /**\n\t\t * Returns the playback state of the source, either \"started\" or \"stopped\".\n\t\t * @type {Tone.State}\n\t\t * @readOnly\n\t\t * @memberOf Tone.LFO#\n\t\t * @name state\n\t\t */\n\t Object.defineProperty(Tone.LFO.prototype, 'state', {\n\t get: function () {\n\t return this._oscillator.state;\n\t }\n\t });\n\t /**\n\t\t * Connect the output of the LFO to an AudioParam, AudioNode, or Tone Node.\n\t\t * Tone.LFO will automatically convert to the destination units of the\n\t\t * will get the units from the connected node.\n\t\t * @param {Tone | AudioParam | AudioNode} node\n\t\t * @param {number} [outputNum=0] optionally which output to connect from\n\t\t * @param {number} [inputNum=0] optionally which input to connect to\n\t\t * @returns {Tone.LFO} this\n\t\t * @private\n\t\t */\n\t Tone.LFO.prototype.connect = function (node) {\n\t if (node.constructor === Tone.Signal || node.constructor === Tone.Param) {\n\t this.convert = node.convert;\n\t this.units = node.units;\n\t }\n\t Tone.SignalBase.prototype.connect.apply(this, arguments);\n\t return this;\n\t };\n\t /**\n\t\t * private method borrowed from Param converts\n\t\t * units from their destination value\n\t\t * @function\n\t\t * @private\n\t\t */\n\t Tone.LFO.prototype._fromUnits = Tone.Param.prototype._fromUnits;\n\t /**\n\t\t * private method borrowed from Param converts\n\t\t * units to their destination value\n\t\t * @function\n\t\t * @private\n\t\t */\n\t Tone.LFO.prototype._toUnits = Tone.Param.prototype._toUnits;\n\t /**\n\t\t * disconnect and dispose\n\t\t * @returns {Tone.LFO} this\n\t\t */\n\t Tone.LFO.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._writable([\n\t 'amplitude',\n\t 'frequency'\n\t ]);\n\t this._oscillator.dispose();\n\t this._oscillator = null;\n\t this._stoppedSignal.dispose();\n\t this._stoppedSignal = null;\n\t this._zeros.dispose();\n\t this._zeros = null;\n\t this._scaler.dispose();\n\t this._scaler = null;\n\t this._a2g.dispose();\n\t this._a2g = null;\n\t this.frequency = null;\n\t this.amplitude = null;\n\t return this;\n\t };\n\t return Tone.LFO;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Limiter will limit the loudness of an incoming signal.\n\t\t * It is composed of a Tone.Compressor with a fast attack\n\t\t * and release. Limiters are commonly used to safeguard against\n\t\t * signal clipping. Unlike a compressor, limiters do not provide\n\t\t * smooth gain reduction and almost completely prevent\n\t\t * additional gain above the threshold.\n\t\t *\n\t\t * @extends {Tone.AudioNode}\n\t\t * @constructor\n\t\t * @param {number} threshold The theshold above which the limiting is applied.\n\t\t * @example\n\t\t * var limiter = new Tone.Limiter(-6);\n\t\t */\n\t Tone.Limiter = function () {\n\t var options = Tone.defaults(arguments, ['threshold'], Tone.Limiter);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * the compressor\n\t\t\t * @private\n\t\t\t * @type {Tone.Compressor}\n\t\t\t */\n\t this._compressor = this.input = this.output = new Tone.Compressor({\n\t 'attack': 0.001,\n\t 'decay': 0.001,\n\t 'threshold': options.threshold\n\t });\n\t /**\n\t\t\t * The threshold of of the limiter\n\t\t\t * @type {Decibel}\n\t\t\t * @signal\n\t\t\t */\n\t this.threshold = this._compressor.threshold;\n\t this._readOnly('threshold');\n\t };\n\t Tone.extend(Tone.Limiter, Tone.AudioNode);\n\t /**\n\t\t * The default value\n\t\t * @type {Object}\n\t\t * @const\n\t\t * @static\n\t\t */\n\t Tone.Limiter.defaults = { 'threshold': -12 };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Limiter} this\n\t\t */\n\t Tone.Limiter.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._compressor.dispose();\n\t this._compressor = null;\n\t this._writable('threshold');\n\t this.threshold = null;\n\t return this;\n\t };\n\t return Tone.Limiter;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Lowpass is a lowpass feedback comb filter. It is similar to\n\t\t * Tone.FeedbackCombFilter, but includes a lowpass filter.\n\t\t *\n\t\t * @extends {Tone.AudioNode}\n\t\t * @constructor\n\t\t * @param {Time|Object} [delayTime] The delay time of the comb filter\n\t\t * @param {NormalRange=} resonance The resonance (feedback) of the comb filter\n\t\t * @param {Frequency=} dampening The cutoff of the lowpass filter dampens the\n\t\t * signal as it is fedback.\n\t\t */\n\t Tone.LowpassCombFilter = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'delayTime',\n\t 'resonance',\n\t 'dampening'\n\t ], Tone.LowpassCombFilter);\n\t Tone.AudioNode.call(this);\n\t this.createInsOuts(1, 1);\n\t /**\n\t\t\t * the delay node\n\t\t\t * @type {DelayNode}\n\t\t\t * @private\n\t\t\t */\n\t this._delay = this.input = new Tone.Delay(options.delayTime);\n\t /**\n\t\t\t * The delayTime of the comb filter.\n\t\t\t * @type {Time}\n\t\t\t * @signal\n\t\t\t */\n\t this.delayTime = this._delay.delayTime;\n\t /**\n\t\t\t * the lowpass filter\n\t\t\t * @type {BiquadFilterNode}\n\t\t\t * @private\n\t\t\t */\n\t this._lowpass = this.output = this.context.createBiquadFilter();\n\t this._lowpass.Q.value = -3.0102999566398125;\n\t this._lowpass.type = 'lowpass';\n\t /**\n\t\t\t * The dampening control of the feedback\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.dampening = new Tone.Param({\n\t 'param': this._lowpass.frequency,\n\t 'units': Tone.Type.Frequency,\n\t 'value': options.dampening\n\t });\n\t /**\n\t\t\t * the feedback gain\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._feedback = new Tone.Gain(options.resonance, Tone.Type.NormalRange);\n\t /**\n\t\t\t * The amount of feedback of the delayed signal.\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.resonance = this._feedback.gain;\n\t //connections\n\t this._delay.chain(this._lowpass, this._feedback, this._delay);\n\t this._readOnly([\n\t 'dampening',\n\t 'resonance',\n\t 'delayTime'\n\t ]);\n\t };\n\t Tone.extend(Tone.LowpassCombFilter, Tone.AudioNode);\n\t /**\n\t\t * the default parameters\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.LowpassCombFilter.defaults = {\n\t 'delayTime': 0.1,\n\t 'resonance': 0.5,\n\t 'dampening': 3000\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.LowpassCombFilter} this\n\t\t */\n\t Tone.LowpassCombFilter.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._writable([\n\t 'dampening',\n\t 'resonance',\n\t 'delayTime'\n\t ]);\n\t this.dampening.dispose();\n\t this.dampening = null;\n\t this.resonance.dispose();\n\t this.resonance = null;\n\t this._delay.dispose();\n\t this._delay = null;\n\t this.delayTime = null;\n\t this._lowpass.disconnect();\n\t this._lowpass = null;\n\t this._feedback.disconnect();\n\t this._feedback = null;\n\t return this;\n\t };\n\t return Tone.LowpassCombFilter;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Merge brings two signals into the left and right\n\t\t * channels of a single stereo channel.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @example\n\t\t * var merge = new Tone.Merge().toMaster();\n\t\t * //routing a sine tone in the left channel\n\t\t * //and noise in the right channel\n\t\t * var osc = new Tone.Oscillator().connect(merge.left);\n\t\t * var noise = new Tone.Noise().connect(merge.right);\n\t\t * //starting our oscillators\n\t\t * noise.start();\n\t\t * osc.start();\n\t\t */\n\t Tone.Merge = function () {\n\t Tone.AudioNode.call(this);\n\t this.createInsOuts(2, 0);\n\t /**\n\t\t\t * The left input channel.\n\t\t\t * Alias for <code>input[0]</code>\n\t\t\t * @type {GainNode}\n\t\t\t */\n\t this.left = this.input[0] = new Tone.Gain();\n\t /**\n\t\t\t * The right input channel.\n\t\t\t * Alias for <code>input[1]</code>.\n\t\t\t * @type {GainNode}\n\t\t\t */\n\t this.right = this.input[1] = new Tone.Gain();\n\t /**\n\t\t\t * the merger node for the two channels\n\t\t\t * @type {ChannelMergerNode}\n\t\t\t * @private\n\t\t\t */\n\t this._merger = this.output = this.context.createChannelMerger(2);\n\t //connections\n\t this.left.connect(this._merger, 0, 0);\n\t this.right.connect(this._merger, 0, 1);\n\t this.left.channelCount = 1;\n\t this.right.channelCount = 1;\n\t this.left.channelCountMode = 'explicit';\n\t this.right.channelCountMode = 'explicit';\n\t };\n\t Tone.extend(Tone.Merge, Tone.AudioNode);\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Merge} this\n\t\t */\n\t Tone.Merge.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this.left.dispose();\n\t this.left = null;\n\t this.right.dispose();\n\t this.right = null;\n\t this._merger.disconnect();\n\t this._merger = null;\n\t return this;\n\t };\n\t return Tone.Merge;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Meter gets the [RMS](https://en.wikipedia.org/wiki/Root_mean_square)\n\t\t * of an input signal with some averaging applied. It can also get the raw\n\t\t * value of the input signal.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {Number} smoothing The amount of smoothing applied between frames.\n\t\t * @example\n\t\t * var meter = new Tone.Meter();\n\t\t * var mic = new Tone.UserMedia().open();\n\t\t * //connect mic to the meter\n\t\t * mic.connect(meter);\n\t\t * //the current level of the mic input in decibels\n\t\t * var level = meter.getValue();\n\t\t */\n\t Tone.Meter = function () {\n\t var options = Tone.defaults(arguments, ['smoothing'], Tone.Meter);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The analyser node which computes the levels.\n\t\t\t * @private\n\t\t\t * @type {Tone.Analyser}\n\t\t\t */\n\t this.input = this.output = this._analyser = new Tone.Analyser('waveform', 1024);\n\t /**\n\t\t\t * The amount of carryover between the current and last frame.\n\t\t\t * Only applied meter for \"level\" type.\n\t\t\t * @type {Number}\n\t\t\t */\n\t this.smoothing = options.smoothing;\n\t };\n\t Tone.extend(Tone.Meter, Tone.AudioNode);\n\t /**\n\t\t * The defaults\n\t\t * @type {Object}\n\t\t * @static\n\t\t * @const\n\t\t */\n\t Tone.Meter.defaults = { 'smoothing': 0.8 };\n\t /**\n\t\t * Get the current decibel value of the incoming signal\n\t\t * @returns {Decibels}\n\t\t */\n\t Tone.Meter.prototype.getLevel = function () {\n\t this._analyser.type = 'fft';\n\t var values = this._analyser.getValue();\n\t var offset = 28;\n\t // normalizes most signal levels\n\t // TODO: compute loudness from FFT\n\t return Math.max.apply(this, values) + offset;\n\t };\n\t /**\n\t\t * Get the signal value of the incoming signal\n\t\t * @returns {Number}\n\t\t */\n\t Tone.Meter.prototype.getValue = function () {\n\t this._analyser.type = 'waveform';\n\t var value = this._analyser.getValue();\n\t return value[0];\n\t };\n\t /**\n\t\t * A value from 0 -> 1 where 0 represents no time averaging with the last analysis frame.\n\t\t * @memberOf Tone.Meter#\n\t\t * @type {Number}\n\t\t * @name smoothing\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Meter.prototype, 'smoothing', {\n\t get: function () {\n\t return this._analyser.smoothing;\n\t },\n\t set: function (val) {\n\t this._analyser.smoothing = val;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Meter} this\n\t\t */\n\t Tone.Meter.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._analyser.dispose();\n\t this._analyser = null;\n\t return this;\n\t };\n\t return Tone.Meter;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t *\t@class Tone.Split splits an incoming signal into left and right channels.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @example\n\t\t * var split = new Tone.Split();\n\t\t * stereoSignal.connect(split);\n\t\t */\n\t Tone.Split = function () {\n\t Tone.AudioNode.call(this);\n\t this.createInsOuts(0, 2);\n\t /**\n\t\t\t * @type {ChannelSplitterNode}\n\t\t\t * @private\n\t\t\t */\n\t this._splitter = this.input = this.context.createChannelSplitter(2);\n\t this._splitter.channelCount = 2;\n\t this._splitter.channelCountMode = 'explicit';\n\t /**\n\t\t\t * Left channel output.\n\t\t\t * Alias for <code>output[0]</code>\n\t\t\t * @type {Tone.Gain}\n\t\t\t */\n\t this.left = this.output[0] = new Tone.Gain();\n\t /**\n\t\t\t * Right channel output.\n\t\t\t * Alias for <code>output[1]</code>\n\t\t\t * @type {Tone.Gain}\n\t\t\t */\n\t this.right = this.output[1] = new Tone.Gain();\n\t //connections\n\t this._splitter.connect(this.left, 0, 0);\n\t this._splitter.connect(this.right, 1, 0);\n\t };\n\t Tone.extend(Tone.Split, Tone.AudioNode);\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Split} this\n\t\t */\n\t Tone.Split.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._splitter.disconnect();\n\t this.left.dispose();\n\t this.left = null;\n\t this.right.dispose();\n\t this.right = null;\n\t this._splitter = null;\n\t return this;\n\t };\n\t return Tone.Split;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Mid/Side processing separates the the 'mid' signal\n\t\t * (which comes out of both the left and the right channel)\n\t\t * and the 'side' (which only comes out of the the side channels). <br><br>\n\t\t * <code>\n\t\t * Mid = (Left+Right)/sqrt(2); // obtain mid-signal from left and right<br>\n\t\t * Side = (Left-Right)/sqrt(2); // obtain side-signal from left and righ<br>\n\t\t * </code>\n\t\t *\n\t\t * @extends {Tone.AudioNode}\n\t\t * @constructor\n\t\t */\n\t Tone.MidSideSplit = function () {\n\t Tone.AudioNode.call(this);\n\t this.createInsOuts(0, 2);\n\t /**\n\t\t\t * split the incoming signal into left and right channels\n\t\t\t * @type {Tone.Split}\n\t\t\t * @private\n\t\t\t */\n\t this._split = this.input = new Tone.Split();\n\t /**\n\t\t\t * The mid send. Connect to mid processing. Alias for\n\t\t\t * <code>output[0]</code>\n\t\t\t * @type {Tone.Add}\n\t\t\t */\n\t this._midAdd = new Tone.Add();\n\t /**\n\t\t\t * Multiply the _midAdd by sqrt(1/2)\n\t\t\t * @type {Tone.Multiply}\n\t\t\t */\n\t this.mid = this.output[0] = new Tone.Multiply(Math.SQRT1_2);\n\t /**\n\t\t\t * The side output. Connect to side processing. Also Output 1\n\t\t\t * @type {Tone.Subtract}\n\t\t\t */\n\t this._sideSubtract = new Tone.Subtract();\n\t /**\n\t\t\t * Multiply the _midAdd by sqrt(1/2)\n\t\t\t * @type {Tone.Multiply}\n\t\t\t */\n\t this.side = this.output[1] = new Tone.Multiply(Math.SQRT1_2);\n\t this._split.connect(this._midAdd, 0, 0);\n\t this._split.connect(this._midAdd, 1, 1);\n\t this._split.connect(this._sideSubtract, 0, 0);\n\t this._split.connect(this._sideSubtract, 1, 1);\n\t this._midAdd.connect(this.mid);\n\t this._sideSubtract.connect(this.side);\n\t };\n\t Tone.extend(Tone.MidSideSplit, Tone.AudioNode);\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.MidSideSplit} this\n\t\t */\n\t Tone.MidSideSplit.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this.mid.dispose();\n\t this.mid = null;\n\t this.side.dispose();\n\t this.side = null;\n\t this._midAdd.dispose();\n\t this._midAdd = null;\n\t this._sideSubtract.dispose();\n\t this._sideSubtract = null;\n\t this._split.dispose();\n\t this._split = null;\n\t return this;\n\t };\n\t return Tone.MidSideSplit;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Mid/Side processing separates the the 'mid' signal\n\t\t * (which comes out of both the left and the right channel)\n\t\t * and the 'side' (which only comes out of the the side channels).\n\t\t * MidSideMerge merges the mid and side signal after they've been seperated\n\t\t * by Tone.MidSideSplit.<br><br>\n\t\t * <code>\n\t\t * Left = (Mid+Side)/sqrt(2); // obtain left signal from mid and side<br>\n\t\t * Right = (Mid-Side)/sqrt(2); // obtain right signal from mid and side<br>\n\t\t * </code>\n\t\t *\n\t\t * @extends {Tone.AudioNode}\n\t\t * @constructor\n\t\t */\n\t Tone.MidSideMerge = function () {\n\t Tone.AudioNode.call(this);\n\t this.createInsOuts(2, 0);\n\t /**\n\t\t\t * The mid signal input. Alias for\n\t\t\t * <code>input[0]</code>\n\t\t\t * @type {Tone.Gain}\n\t\t\t */\n\t this.mid = this.input[0] = new Tone.Gain();\n\t /**\n\t\t\t * recombine the mid/side into Left\n\t\t\t * @type {Tone.Add}\n\t\t\t * @private\n\t\t\t */\n\t this._left = new Tone.Add();\n\t /**\n\t\t\t * Multiply the left by sqrt(1/2)\n\t\t\t * @type {Tone.Multiply}\n\t\t\t */\n\t this._timesTwoLeft = new Tone.Multiply(Math.SQRT1_2);\n\t /**\n\t\t\t * The side signal input. Alias for\n\t\t\t * <code>input[1]</code>\n\t\t\t * @type {Tone.Gain}\n\t\t\t */\n\t this.side = this.input[1] = new Tone.Gain();\n\t /**\n\t\t\t * recombine the mid/side into Right\n\t\t\t * @type {Tone.Subtract}\n\t\t\t * @private\n\t\t\t */\n\t this._right = new Tone.Subtract();\n\t /**\n\t\t\t * Multiply the right by sqrt(1/2)\n\t\t\t * @type {Tone.Multiply}\n\t\t\t */\n\t this._timesTwoRight = new Tone.Multiply(Math.SQRT1_2);\n\t /**\n\t\t\t * Merge the left/right signal back into a stereo signal.\n\t\t\t * @type {Tone.Merge}\n\t\t\t * @private\n\t\t\t */\n\t this._merge = this.output = new Tone.Merge();\n\t this.mid.connect(this._left, 0, 0);\n\t this.side.connect(this._left, 0, 1);\n\t this.mid.connect(this._right, 0, 0);\n\t this.side.connect(this._right, 0, 1);\n\t this._left.connect(this._timesTwoLeft);\n\t this._right.connect(this._timesTwoRight);\n\t this._timesTwoLeft.connect(this._merge, 0, 0);\n\t this._timesTwoRight.connect(this._merge, 0, 1);\n\t };\n\t Tone.extend(Tone.MidSideMerge, Tone.AudioNode);\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.MidSideMerge} this\n\t\t */\n\t Tone.MidSideMerge.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this.mid.dispose();\n\t this.mid = null;\n\t this.side.dispose();\n\t this.side = null;\n\t this._left.dispose();\n\t this._left = null;\n\t this._timesTwoLeft.dispose();\n\t this._timesTwoLeft = null;\n\t this._right.dispose();\n\t this._right = null;\n\t this._timesTwoRight.dispose();\n\t this._timesTwoRight = null;\n\t this._merge.dispose();\n\t this._merge = null;\n\t return this;\n\t };\n\t return Tone.MidSideMerge;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.MidSideCompressor applies two different compressors to the mid\n\t\t * and side signal components. See Tone.MidSideSplit.\n\t\t *\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {Object} options The options that are passed to the mid and side\n\t\t * compressors.\n\t\t * @constructor\n\t\t */\n\t Tone.MidSideCompressor = function (options) {\n\t Tone.AudioNode.call(this);\n\t options = Tone.defaultArg(options, Tone.MidSideCompressor.defaults);\n\t /**\n\t\t\t * the mid/side split\n\t\t\t * @type {Tone.MidSideSplit}\n\t\t\t * @private\n\t\t\t */\n\t this._midSideSplit = this.input = new Tone.MidSideSplit();\n\t /**\n\t\t\t * the mid/side recombination\n\t\t\t * @type {Tone.MidSideMerge}\n\t\t\t * @private\n\t\t\t */\n\t this._midSideMerge = this.output = new Tone.MidSideMerge();\n\t /**\n\t\t\t * The compressor applied to the mid signal\n\t\t\t * @type {Tone.Compressor}\n\t\t\t */\n\t this.mid = new Tone.Compressor(options.mid);\n\t /**\n\t\t\t * The compressor applied to the side signal\n\t\t\t * @type {Tone.Compressor}\n\t\t\t */\n\t this.side = new Tone.Compressor(options.side);\n\t this._midSideSplit.mid.chain(this.mid, this._midSideMerge.mid);\n\t this._midSideSplit.side.chain(this.side, this._midSideMerge.side);\n\t this._readOnly([\n\t 'mid',\n\t 'side'\n\t ]);\n\t };\n\t Tone.extend(Tone.MidSideCompressor, Tone.AudioNode);\n\t /**\n\t\t * @const\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.MidSideCompressor.defaults = {\n\t 'mid': {\n\t 'ratio': 3,\n\t 'threshold': -24,\n\t 'release': 0.03,\n\t 'attack': 0.02,\n\t 'knee': 16\n\t },\n\t 'side': {\n\t 'ratio': 6,\n\t 'threshold': -30,\n\t 'release': 0.25,\n\t 'attack': 0.03,\n\t 'knee': 10\n\t }\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.MidSideCompressor} this\n\t\t */\n\t Tone.MidSideCompressor.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._writable([\n\t 'mid',\n\t 'side'\n\t ]);\n\t this.mid.dispose();\n\t this.mid = null;\n\t this.side.dispose();\n\t this.side = null;\n\t this._midSideSplit.dispose();\n\t this._midSideSplit = null;\n\t this._midSideMerge.dispose();\n\t this._midSideMerge = null;\n\t return this;\n\t };\n\t return Tone.MidSideCompressor;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Mono coerces the incoming mono or stereo signal into a mono signal\n\t\t * where both left and right channels have the same value. This can be useful\n\t\t * for [stereo imaging](https://en.wikipedia.org/wiki/Stereo_imaging).\n\t\t *\n\t\t * @extends {Tone.AudioNode}\n\t\t * @constructor\n\t\t */\n\t Tone.Mono = function () {\n\t Tone.AudioNode.call(this);\n\t this.createInsOuts(1, 0);\n\t /**\n\t\t\t * merge the signal\n\t\t\t * @type {Tone.Merge}\n\t\t\t * @private\n\t\t\t */\n\t this._merge = this.output = new Tone.Merge();\n\t this.input.connect(this._merge, 0, 0);\n\t this.input.connect(this._merge, 0, 1);\n\t };\n\t Tone.extend(Tone.Mono, Tone.AudioNode);\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.Mono} this\n\t\t */\n\t Tone.Mono.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._merge.dispose();\n\t this._merge = null;\n\t return this;\n\t };\n\t return Tone.Mono;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class A compressor with seperate controls over low/mid/high dynamics\n\t\t *\n\t\t * @extends {Tone.AudioNode}\n\t\t * @constructor\n\t\t * @param {Object} options The low/mid/high compressor settings.\n\t\t * @example\n\t\t * var multiband = new Tone.MultibandCompressor({\n\t\t * \t\"lowFrequency\" : 200,\n\t\t * \t\"highFrequency\" : 1300\n\t\t * \t\"low\" : {\n\t\t * \t\t\"threshold\" : -12\n\t\t * \t}\n\t\t * })\n\t\t */\n\t Tone.MultibandCompressor = function (options) {\n\t Tone.AudioNode.call(this);\n\t options = Tone.defaultArg(arguments, Tone.MultibandCompressor.defaults);\n\t /**\n\t\t\t * split the incoming signal into high/mid/low\n\t\t\t * @type {Tone.MultibandSplit}\n\t\t\t * @private\n\t\t\t */\n\t this._splitter = this.input = new Tone.MultibandSplit({\n\t 'lowFrequency': options.lowFrequency,\n\t 'highFrequency': options.highFrequency\n\t });\n\t /**\n\t\t\t * low/mid crossover frequency.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.lowFrequency = this._splitter.lowFrequency;\n\t /**\n\t\t\t * mid/high crossover frequency.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.highFrequency = this._splitter.highFrequency;\n\t /**\n\t\t\t * the output\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this.output = new Tone.Gain();\n\t /**\n\t\t\t * The compressor applied to the low frequencies.\n\t\t\t * @type {Tone.Compressor}\n\t\t\t */\n\t this.low = new Tone.Compressor(options.low);\n\t /**\n\t\t\t * The compressor applied to the mid frequencies.\n\t\t\t * @type {Tone.Compressor}\n\t\t\t */\n\t this.mid = new Tone.Compressor(options.mid);\n\t /**\n\t\t\t * The compressor applied to the high frequencies.\n\t\t\t * @type {Tone.Compressor}\n\t\t\t */\n\t this.high = new Tone.Compressor(options.high);\n\t //connect the compressor\n\t this._splitter.low.chain(this.low, this.output);\n\t this._splitter.mid.chain(this.mid, this.output);\n\t this._splitter.high.chain(this.high, this.output);\n\t this._readOnly([\n\t 'high',\n\t 'mid',\n\t 'low',\n\t 'highFrequency',\n\t 'lowFrequency'\n\t ]);\n\t };\n\t Tone.extend(Tone.MultibandCompressor, Tone.AudioNode);\n\t /**\n\t\t * @const\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.MultibandCompressor.defaults = {\n\t 'low': Tone.Compressor.defaults,\n\t 'mid': Tone.Compressor.defaults,\n\t 'high': Tone.Compressor.defaults,\n\t 'lowFrequency': 250,\n\t 'highFrequency': 2000\n\t };\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.MultibandCompressor} this\n\t\t */\n\t Tone.MultibandCompressor.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._splitter.dispose();\n\t this._writable([\n\t 'high',\n\t 'mid',\n\t 'low',\n\t 'highFrequency',\n\t 'lowFrequency'\n\t ]);\n\t this.low.dispose();\n\t this.mid.dispose();\n\t this.high.dispose();\n\t this._splitter = null;\n\t this.low = null;\n\t this.mid = null;\n\t this.high = null;\n\t this.lowFrequency = null;\n\t this.highFrequency = null;\n\t return this;\n\t };\n\t return Tone.MultibandCompressor;\n\t});\n\tModule(function (Tone) {\n\t if (Tone.supported && !window.StereoPannerNode) {\n\t /**\n\t\t\t * @class Shimmed StereoPannerNode\n\t\t\t * @param {AudioContext} context\n\t\t\t * @private\n\t\t\t */\n\t var StereoPannerNode = function (context) {\n\t /**\n\t\t\t\t * The audio context\n\t\t\t\t * @type {AudioContext}\n\t\t\t\t */\n\t this.context = context;\n\t /**\n\t\t\t\t * The left/right panning. [-1, 1]\n\t\t\t\t * @type {AudioRange}\n\t\t\t\t * @signal\n\t\t\t\t */\n\t this.pan = new Tone.Signal(0, Tone.Type.AudioRange);\n\t /**\n\t\t\t\t * Equal power scaling of the right gain\n\t\t\t\t * @type {Tone.WaveShaper}\n\t\t\t\t */\n\t var rightWaveShaper = new Tone.WaveShaper(function (val) {\n\t return Tone.equalPowerScale((val + 1) / 2);\n\t }, 4096);\n\t /**\n\t\t\t\t * Equal power scaling of the left gain\n\t\t\t\t * @type {Tone.WaveShaper}\n\t\t\t\t * @private\n\t\t\t\t */\n\t var leftWaveShaper = new Tone.WaveShaper(function (val) {\n\t return Tone.equalPowerScale(1 - (val + 1) / 2);\n\t }, 4096);\n\t /**\n\t\t\t\t * The left gain value\n\t\t\t\t * @type {Tone.Gain}\n\t\t\t\t * @private\n\t\t\t\t */\n\t var leftGain = new Tone.Gain();\n\t /**\n\t\t\t\t * The right gain value\n\t\t\t\t * @type {Tone.Gain}\n\t\t\t\t * @private\n\t\t\t\t */\n\t var rightGain = new Tone.Gain();\n\t /**\n\t\t\t\t * Split the incoming signal\n\t\t\t\t * @type {Tone.Split}\n\t\t\t\t * @private\n\t\t\t\t */\n\t var split = this.input = new Tone.Split();\n\t /**\n\t\t\t\t * Keeps the waveshapers from optimizing 0s\n\t\t\t\t * @type {Tone.Zero}\n\t\t\t\t * @private\n\t\t\t\t */\n\t var zero = new Tone.Zero();\n\t zero.fan(rightWaveShaper, leftWaveShaper);\n\t /**\n\t\t\t\t * Merge the outgoing signal\n\t\t\t\t * @type {Tone.Merge}\n\t\t\t\t * @private\n\t\t\t\t */\n\t var merge = this.output = new Tone.Merge();\n\t //connections\n\t split.left.chain(leftGain, merge.left);\n\t split.right.chain(rightGain, merge.right);\n\t this.pan.chain(leftWaveShaper, leftGain.gain);\n\t this.pan.chain(rightWaveShaper, rightGain.gain);\n\t };\n\t StereoPannerNode.prototype.disconnect = function () {\n\t this.output.disconnect.apply(this.output, arguments);\n\t };\n\t StereoPannerNode.prototype.connect = function () {\n\t this.output.connect.apply(this.output, arguments);\n\t };\n\t //add it to the AudioContext\n\t AudioContext.prototype.createStereoPanner = function () {\n\t return new StereoPannerNode(this);\n\t };\n\t Tone.Context.prototype.createStereoPanner = function () {\n\t return new StereoPannerNode(this);\n\t };\n\t }\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Panner is an equal power Left/Right Panner and does not\n\t\t * support 3D. Panner uses the StereoPannerNode when available.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {NormalRange} [initialPan=0] The initail panner value (center).\n\t\t * @example\n\t\t * //pan the input signal hard right.\n\t\t * var panner = new Tone.Panner(1);\n\t\t */\n\t Tone.Panner = function (initialPan) {\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t* the panner node\n\t\t\t* @type {StereoPannerNode}\n\t\t\t* @private\n\t\t\t*/\n\t this._panner = this.input = this.output = this.context.createStereoPanner();\n\t /**\n\t\t\t* The pan control. -1 = hard left, 1 = hard right.\n\t\t\t* @type {AudioRange}\n\t\t\t* @signal\n\t\t\t*/\n\t this.pan = this._panner.pan;\n\t //initial value\n\t this.pan.value = Tone.defaultArg(initialPan, 0);\n\t this._readOnly('pan');\n\t };\n\t Tone.extend(Tone.Panner, Tone.AudioNode);\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Panner} this\n\t\t */\n\t Tone.Panner.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._writable('pan');\n\t this._panner.disconnect();\n\t this._panner = null;\n\t this.pan = null;\n\t return this;\n\t };\n\t return Tone.Panner;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class A spatialized panner node which supports equalpower or HRTF panning.\n\t\t * Tries to normalize the API across various browsers. See Tone.Listener\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {Number} positionX The initial x position.\n\t\t * @param {Number} positionY The initial y position.\n\t\t * @param {Number} positionZ The initial z position.\n\t\t */\n\t Tone.Panner3D = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'positionX',\n\t 'positionY',\n\t 'positionZ'\n\t ], Tone.Panner3D);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The panner node\n\t\t\t * @type {PannerNode}\n\t\t\t * @private\n\t\t\t */\n\t this._panner = this.input = this.output = this.context.createPanner();\n\t //set some values\n\t this._panner.panningModel = options.panningModel;\n\t this._panner.maxDistance = options.maxDistance;\n\t this._panner.distanceModel = options.distanceModel;\n\t this._panner.coneOuterGain = options.coneOuterGain;\n\t this._panner.coneOuterAngle = options.coneOuterAngle;\n\t this._panner.coneInnerAngle = options.coneInnerAngle;\n\t this._panner.refDistance = options.refDistance;\n\t this._panner.rolloffFactor = options.rolloffFactor;\n\t /**\n\t\t\t * Holds the current orientation\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._orientation = [\n\t options.orientationX,\n\t options.orientationY,\n\t options.orientationZ\n\t ];\n\t /**\n\t\t\t * Holds the current position\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._position = [\n\t options.positionX,\n\t options.positionY,\n\t options.positionZ\n\t ];\n\t // set the default position/orientation\n\t this.orientationX = options.orientationX;\n\t this.orientationY = options.orientationY;\n\t this.orientationZ = options.orientationZ;\n\t this.positionX = options.positionX;\n\t this.positionY = options.positionY;\n\t this.positionZ = options.positionZ;\n\t };\n\t Tone.extend(Tone.Panner3D, Tone.AudioNode);\n\t /**\n\t\t * Defaults according to the specification\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Panner3D.defaults = {\n\t 'positionX': 0,\n\t 'positionY': 0,\n\t 'positionZ': 0,\n\t 'orientationX': 0,\n\t 'orientationY': 0,\n\t 'orientationZ': 0,\n\t 'panningModel': 'equalpower',\n\t 'maxDistance': 10000,\n\t 'distanceModel': 'inverse',\n\t 'coneOuterGain': 0,\n\t 'coneOuterAngle': 360,\n\t 'coneInnerAngle': 360,\n\t 'refDistance': 1,\n\t 'rolloffFactor': 1\n\t };\n\t /**\n\t\t * The ramp time which is applied to the setTargetAtTime\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t Tone.Panner3D.prototype._rampTimeConstant = 0.01;\n\t /**\n\t\t * Sets the position of the source in 3d space.\n\t\t * @param {Number} x\n\t\t * @param {Number} y\n\t\t * @param {Number} z\n\t\t * @return {Tone.Panner3D} this\n\t\t */\n\t Tone.Panner3D.prototype.setPosition = function (x, y, z) {\n\t if (this._panner.positionX) {\n\t var now = this.now();\n\t this._panner.positionX.setTargetAtTime(x, now, this._rampTimeConstant);\n\t this._panner.positionY.setTargetAtTime(y, now, this._rampTimeConstant);\n\t this._panner.positionZ.setTargetAtTime(z, now, this._rampTimeConstant);\n\t } else {\n\t this._panner.setPosition(x, y, z);\n\t }\n\t this._position = Array.prototype.slice.call(arguments);\n\t return this;\n\t };\n\t /**\n\t\t * Sets the orientation of the source in 3d space.\n\t\t * @param {Number} x\n\t\t * @param {Number} y\n\t\t * @param {Number} z\n\t\t * @return {Tone.Panner3D} this\n\t\t */\n\t Tone.Panner3D.prototype.setOrientation = function (x, y, z) {\n\t if (this._panner.orientationX) {\n\t var now = this.now();\n\t this._panner.orientationX.setTargetAtTime(x, now, this._rampTimeConstant);\n\t this._panner.orientationY.setTargetAtTime(y, now, this._rampTimeConstant);\n\t this._panner.orientationZ.setTargetAtTime(z, now, this._rampTimeConstant);\n\t } else {\n\t this._panner.setOrientation(x, y, z);\n\t }\n\t this._orientation = Array.prototype.slice.call(arguments);\n\t return this;\n\t };\n\t /**\n\t\t * The x position of the panner object.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name positionX\n\t\t */\n\t Object.defineProperty(Tone.Panner3D.prototype, 'positionX', {\n\t set: function (pos) {\n\t this._position[0] = pos;\n\t this.setPosition.apply(this, this._position);\n\t },\n\t get: function () {\n\t return this._position[0];\n\t }\n\t });\n\t /**\n\t\t * The y position of the panner object.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name positionY\n\t\t */\n\t Object.defineProperty(Tone.Panner3D.prototype, 'positionY', {\n\t set: function (pos) {\n\t this._position[1] = pos;\n\t this.setPosition.apply(this, this._position);\n\t },\n\t get: function () {\n\t return this._position[1];\n\t }\n\t });\n\t /**\n\t\t * The z position of the panner object.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name positionZ\n\t\t */\n\t Object.defineProperty(Tone.Panner3D.prototype, 'positionZ', {\n\t set: function (pos) {\n\t this._position[2] = pos;\n\t this.setPosition.apply(this, this._position);\n\t },\n\t get: function () {\n\t return this._position[2];\n\t }\n\t });\n\t /**\n\t\t * The x orientation of the panner object.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name orientationX\n\t\t */\n\t Object.defineProperty(Tone.Panner3D.prototype, 'orientationX', {\n\t set: function (pos) {\n\t this._orientation[0] = pos;\n\t this.setOrientation.apply(this, this._orientation);\n\t },\n\t get: function () {\n\t return this._orientation[0];\n\t }\n\t });\n\t /**\n\t\t * The y orientation of the panner object.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name orientationY\n\t\t */\n\t Object.defineProperty(Tone.Panner3D.prototype, 'orientationY', {\n\t set: function (pos) {\n\t this._orientation[1] = pos;\n\t this.setOrientation.apply(this, this._orientation);\n\t },\n\t get: function () {\n\t return this._orientation[1];\n\t }\n\t });\n\t /**\n\t\t * The z orientation of the panner object.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name orientationZ\n\t\t */\n\t Object.defineProperty(Tone.Panner3D.prototype, 'orientationZ', {\n\t set: function (pos) {\n\t this._orientation[2] = pos;\n\t this.setOrientation.apply(this, this._orientation);\n\t },\n\t get: function () {\n\t return this._orientation[2];\n\t }\n\t });\n\t /**\n\t\t * Proxy a property on the panner to an exposed public propery\n\t\t * @param {String} prop\n\t\t * @private\n\t\t */\n\t Tone.Panner3D._aliasProperty = function (prop) {\n\t Object.defineProperty(Tone.Panner3D.prototype, prop, {\n\t set: function (val) {\n\t this._panner[prop] = val;\n\t },\n\t get: function () {\n\t return this._panner[prop];\n\t }\n\t });\n\t };\n\t /**\n\t\t * The panning model. Either \"equalpower\" or \"HRTF\".\n\t\t * @type {String}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name panningModel\n\t\t */\n\t Tone.Panner3D._aliasProperty('panningModel');\n\t /**\n\t\t * A reference distance for reducing volume as source move further from the listener\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name refDistance\n\t\t */\n\t Tone.Panner3D._aliasProperty('refDistance');\n\t /**\n\t\t * Describes how quickly the volume is reduced as source moves away from listener.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name rolloffFactor\n\t\t */\n\t Tone.Panner3D._aliasProperty('rolloffFactor');\n\t /**\n\t\t * The distance model used by, \"linear\", \"inverse\", or \"exponential\".\n\t\t * @type {String}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name distanceModel\n\t\t */\n\t Tone.Panner3D._aliasProperty('distanceModel');\n\t /**\n\t\t * The angle, in degrees, inside of which there will be no volume reduction\n\t\t * @type {Degrees}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name coneInnerAngle\n\t\t */\n\t Tone.Panner3D._aliasProperty('coneInnerAngle');\n\t /**\n\t\t * The angle, in degrees, outside of which the volume will be reduced\n\t\t * to a constant value of coneOuterGain\n\t\t * @type {Degrees}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name coneOuterAngle\n\t\t */\n\t Tone.Panner3D._aliasProperty('coneOuterAngle');\n\t /**\n\t\t * The gain outside of the coneOuterAngle\n\t\t * @type {Gain}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name coneOuterGain\n\t\t */\n\t Tone.Panner3D._aliasProperty('coneOuterGain');\n\t /**\n\t\t * The maximum distance between source and listener,\n\t\t * after which the volume will not be reduced any further.\n\t\t * @type {Positive}\n\t\t * @memberOf Tone.Panner3D#\n\t\t * @name maxDistance\n\t\t */\n\t Tone.Panner3D._aliasProperty('maxDistance');\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Panner3D} this\n\t\t */\n\t Tone.Panner3D.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._panner.disconnect();\n\t this._panner = null;\n\t this._orientation = null;\n\t this._position = null;\n\t return this;\n\t };\n\t return Tone.Panner3D;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.PanVol is a Tone.Panner and Tone.Volume in one.\n\t\t *\n\t\t * @extends {Tone.AudioNode}\n\t\t * @constructor\n\t\t * @param {AudioRange} pan the initial pan\n\t\t * @param {number} volume The output volume.\n\t\t * @example\n\t\t * //pan the incoming signal left and drop the volume\n\t\t * var panVol = new Tone.PanVol(-0.25, -12);\n\t\t */\n\t Tone.PanVol = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'pan',\n\t 'volume'\n\t ], Tone.PanVol);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The panning node\n\t\t\t * @type {Tone.Panner}\n\t\t\t * @private\n\t\t\t */\n\t this._panner = this.input = new Tone.Panner(options.pan);\n\t /**\n\t\t\t * The L/R panning control.\n\t\t\t * @type {AudioRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.pan = this._panner.pan;\n\t /**\n\t\t\t * The volume node\n\t\t\t * @type {Tone.Volume}\n\t\t\t * @private\n\t\t\t */\n\t this._volume = this.output = new Tone.Volume(options.volume);\n\t /**\n\t\t\t * The volume control in decibels.\n\t\t\t * @type {Decibels}\n\t\t\t * @signal\n\t\t\t */\n\t this.volume = this._volume.volume;\n\t //connections\n\t this._panner.connect(this._volume);\n\t this.mute = options.mute;\n\t this._readOnly([\n\t 'pan',\n\t 'volume'\n\t ]);\n\t };\n\t Tone.extend(Tone.PanVol, Tone.AudioNode);\n\t /**\n\t\t * The defaults\n\t\t * @type {Object}\n\t\t * @const\n\t\t * @static\n\t\t */\n\t Tone.PanVol.defaults = {\n\t 'pan': 0,\n\t 'volume': 0,\n\t 'mute': false\n\t };\n\t /**\n\t\t * Mute/unmute the volume\n\t\t * @memberOf Tone.PanVol#\n\t\t * @name mute\n\t\t * @type {Boolean}\n\t\t */\n\t Object.defineProperty(Tone.PanVol.prototype, 'mute', {\n\t get: function () {\n\t return this._volume.mute;\n\t },\n\t set: function (mute) {\n\t this._volume.mute = mute;\n\t }\n\t });\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.PanVol} this\n\t\t */\n\t Tone.PanVol.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._writable([\n\t 'pan',\n\t 'volume'\n\t ]);\n\t this._panner.dispose();\n\t this._panner = null;\n\t this.pan = null;\n\t this._volume.dispose();\n\t this._volume = null;\n\t this.volume = null;\n\t return this;\n\t };\n\t return Tone.PanVol;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.Solo lets you isolate a specific audio stream. When\n\t\t * an instance is set to `solo=true`, it will mute all other instances.\n\t\t * @extends {Tone.AudioNode}\n\t\t * @example\n\t\t * var soloA = new Tone.Solo()\n\t\t * var soloB = new Tone.Solo()\n\t\t * soloA.solo = true\n\t\t * //no audio will pass through soloB\n\t\t */\n\t Tone.Solo = function () {\n\t var options = Tone.defaults(arguments, ['solo'], Tone.Solo);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The input and output node\n\t\t\t * @type {Tone.Gain}\n\t\t\t */\n\t this.input = this.output = new Tone.Gain();\n\t /**\n\t\t\t * A bound _soloed method\n\t\t\t * @type {Function}\n\t\t\t * @private\n\t\t\t */\n\t this._soloBind = this._soloed.bind(this);\n\t //listen for solo events class-wide.\n\t this.context.on('solo', this._soloBind);\n\t //set initially\n\t this.solo = options.solo;\n\t };\n\t Tone.extend(Tone.Solo, Tone.AudioNode);\n\t /**\n\t\t * The defaults\n\t\t * @type {Object}\n\t\t * @static\n\t\t */\n\t Tone.Solo.defaults = { solo: false };\n\t /**\n\t\t * Isolates this instance and mutes all other instances of Tone.Solo.\n\t\t * Only one instance can be soloed at a time. A soloed\n\t\t * instance will report `solo=false` when another instance is soloed.\n\t\t * @memberOf Tone.Solo#\n\t\t * @type {Boolean}\n\t\t * @name solo\n\t\t */\n\t Object.defineProperty(Tone.Solo.prototype, 'solo', {\n\t get: function () {\n\t return this._isSoloed();\n\t },\n\t set: function (solo) {\n\t if (solo) {\n\t this._addSolo();\n\t } else {\n\t this._removeSolo();\n\t }\n\t this.context.emit('solo', this);\n\t }\n\t });\n\t /**\n\t\t * If the current instance is muted, i.e. another instance is soloed\n\t\t * @memberOf Tone.Solo#\n\t\t * @type {Boolean}\n\t\t * @name muted\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Solo.prototype, 'muted', {\n\t get: function () {\n\t return this.input.gain.value === 0;\n\t }\n\t });\n\t /**\n\t\t * Add this to the soloed array\n\t\t * @private\n\t\t */\n\t Tone.Solo.prototype._addSolo = function () {\n\t if (!Tone.isArray(this.context._currentSolo)) {\n\t this.context._currentSolo = [];\n\t }\n\t if (!this._isSoloed()) {\n\t this.context._currentSolo.push(this);\n\t }\n\t };\n\t /**\n\t\t * Remove this from the soloed array\n\t\t * @private\n\t\t */\n\t Tone.Solo.prototype._removeSolo = function () {\n\t if (this._isSoloed()) {\n\t var index = this.context._currentSolo.indexOf(this);\n\t this.context._currentSolo.splice(index, 1);\n\t }\n\t };\n\t /**\n\t\t * @return {Boolean} Is this on the soloed array\n\t\t * @private\n\t\t */\n\t Tone.Solo.prototype._isSoloed = function () {\n\t if (Tone.isArray(this.context._currentSolo)) {\n\t return this.context._currentSolo.length !== 0 && this.context._currentSolo.indexOf(this) !== -1;\n\t } else {\n\t return false;\n\t }\n\t };\n\t /**\n\t\t * @return {Boolean} Returns true if no one is soloed\n\t\t * @private\n\t\t */\n\t Tone.Solo.prototype._noSolos = function () {\n\t return !Tone.isArray(this.context._currentSolo) || this.context._currentSolo.length === 0;\n\t };\n\t /**\n\t\t * Solo the current instance and unsolo all other instances.\n\t\t * @param {Tone.Solo} instance The instance which is being soloed/unsoloed.\n\t\t * @private\n\t\t */\n\t Tone.Solo.prototype._soloed = function () {\n\t if (this._isSoloed()) {\n\t this.input.gain.value = 1;\n\t } else if (this._noSolos()) {\n\t //no one is soloed\n\t this.input.gain.value = 1;\n\t } else {\n\t this.input.gain.value = 0;\n\t }\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.Solo} this\n\t\t */\n\t Tone.Solo.prototype.dispose = function () {\n\t this.context.off('solo', this._soloBind);\n\t this._removeSolo();\n\t this._soloBind = null;\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t return this;\n\t };\n\t return Tone.Solo;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Get the current waveform data of the connected audio source.\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {Number=} size The size of the FFT. Value must be a power of\n\t\t * two in the range 32 to 32768.\n\t\t */\n\t Tone.Waveform = function () {\n\t var options = Tone.defaults(arguments, ['size'], Tone.Waveform);\n\t options.type = Tone.Analyser.Type.Waveform;\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The analyser node.\n\t\t\t * @private\n\t\t\t * @type {Tone.Analyser}\n\t\t\t */\n\t this._analyser = this.input = this.output = new Tone.Analyser(options);\n\t };\n\t Tone.extend(Tone.Waveform, Tone.AudioNode);\n\t /**\n\t\t * The default values.\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.Waveform.defaults = { 'size': 1024 };\n\t /**\n\t\t * Gets the waveform of the audio source. Returns the waveform data\n\t\t * of length [size](#size) as a Float32Array with values between -1 and 1.\n\t\t * @returns {TypedArray}\n\t\t */\n\t Tone.Waveform.prototype.getValue = function () {\n\t return this._analyser.getValue();\n\t };\n\t /**\n\t\t * The size of analysis. This must be a power of two in the range 32 to 32768.\n\t\t * @memberOf Tone.Waveform#\n\t\t * @type {Number}\n\t\t * @name size\n\t\t */\n\t Object.defineProperty(Tone.Waveform.prototype, 'size', {\n\t get: function () {\n\t return this._analyser.size;\n\t },\n\t set: function (size) {\n\t this._analyser.size = size;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.Waveform} this\n\t\t */\n\t Tone.Waveform.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._analyser.dispose();\n\t this._analyser = null;\n\t };\n\t return Tone.Waveform;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.CtrlInterpolate will interpolate between given values based\n\t\t * on the \"index\" property. Passing in an array or object literal\n\t\t * will interpolate each of the parameters. Note (i.e. \"C3\")\n\t\t * and Time (i.e. \"4n + 2\") can be interpolated. All other values are\n\t\t * assumed to be numbers. \n\t\t * @example\n\t\t * var interp = new Tone.CtrlInterpolate([0, 2, 9, 4]);\n\t\t * interp.index = 0.75;\n\t\t * interp.value; //returns 1.5\n\t\t *\n\t\t * @example\n\t\t * var interp = new Tone.CtrlInterpolate([\n\t\t * \t[2, 4, 5],\n\t\t * \t[9, 3, 2],\n\t\t * ]);\n\t\t * @param {Array} values The array of values to interpolate over\n\t\t * @param {Positive} index The initial interpolation index.\n\t\t * @extends {Tone}\n\t\t */\n\t Tone.CtrlInterpolate = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'values',\n\t 'index'\n\t ], Tone.CtrlInterpolate);\n\t Tone.call(this);\n\t /**\n\t\t\t * The values to interpolate between\n\t\t\t * @type {Array}\n\t\t\t */\n\t this.values = options.values;\n\t /**\n\t\t\t * The interpolated index between values. For example: a value of 1.5\n\t\t\t * would interpolate equally between the value at index 1\n\t\t\t * and the value at index 2. \n\t\t\t * @example\n\t\t\t * interp.index = 0; \n\t\t\t * interp.value; //returns the value at 0\n\t\t\t * interp.index = 0.5;\n\t\t\t * interp.value; //returns the value between indices 0 and 1. \n\t\t\t * @type {Positive}\n\t\t\t */\n\t this.index = options.index;\n\t };\n\t Tone.extend(Tone.CtrlInterpolate);\n\t /**\n\t\t * The defaults\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.CtrlInterpolate.defaults = {\n\t 'index': 0,\n\t 'values': []\n\t };\n\t /**\n\t\t * The current interpolated value based on the index\n\t\t * @readOnly\n\t\t * @memberOf Tone.CtrlInterpolate#\n\t\t * @type {*}\n\t\t * @name value\n\t\t */\n\t Object.defineProperty(Tone.CtrlInterpolate.prototype, 'value', {\n\t get: function () {\n\t var index = this.index;\n\t index = Math.min(index, this.values.length - 1);\n\t var lowerPosition = Math.floor(index);\n\t var lower = this.values[lowerPosition];\n\t var upper = this.values[Math.ceil(index)];\n\t return this._interpolate(index - lowerPosition, lower, upper);\n\t }\n\t });\n\t /**\n\t\t * Internal interpolation routine\n\t\t * @param {NormalRange} index The index between the lower and upper\n\t\t * @param {*} lower \n\t\t * @param {*} upper \n\t\t * @return {*} The interpolated value\n\t\t * @private\n\t\t */\n\t Tone.CtrlInterpolate.prototype._interpolate = function (index, lower, upper) {\n\t if (Tone.isArray(lower)) {\n\t var retArray = [];\n\t for (var i = 0; i < lower.length; i++) {\n\t retArray[i] = this._interpolate(index, lower[i], upper[i]);\n\t }\n\t return retArray;\n\t } else if (Tone.isObject(lower)) {\n\t var retObj = {};\n\t for (var attr in lower) {\n\t retObj[attr] = this._interpolate(index, lower[attr], upper[attr]);\n\t }\n\t return retObj;\n\t } else {\n\t lower = this._toNumber(lower);\n\t upper = this._toNumber(upper);\n\t return (1 - index) * lower + index * upper;\n\t }\n\t };\n\t /**\n\t\t * Convert from the given type into a number\n\t\t * @param {Number|String} value\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.CtrlInterpolate.prototype._toNumber = function (val) {\n\t if (Tone.isNumber(val)) {\n\t return val;\n\t } else {\n\t //otherwise assume that it's Time...\n\t return this.toSeconds(val);\n\t }\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.CtrlInterpolate} this\n\t\t */\n\t Tone.CtrlInterpolate.prototype.dispose = function () {\n\t this.values = null;\n\t };\n\t return Tone.CtrlInterpolate;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.CtrlMarkov represents a Markov Chain where each call\n\t\t * to Tone.CtrlMarkov.next will move to the next state. If the next\n\t\t * state choice is an array, the next state is chosen randomly with\n\t\t * even probability for all of the choices. For a weighted probability\n\t\t * of the next choices, pass in an object with \"state\" and \"probability\" attributes. \n\t\t * The probabilities will be normalized and then chosen. If no next options\n\t\t * are given for the current state, the state will stay there. \n\t\t * @extends {Tone}\n\t\t * @example\n\t\t * var chain = new Tone.CtrlMarkov({\n\t\t * \t\"beginning\" : [\"end\", \"middle\"],\n\t\t * \t\"middle\" : \"end\"\n\t\t * });\n\t\t * chain.value = \"beginning\";\n\t\t * chain.next(); //returns \"end\" or \"middle\" with 50% probability\n\t\t *\n\t\t * @example\n\t\t * var chain = new Tone.CtrlMarkov({\n\t\t * \t\"beginning\" : [{\"value\" : \"end\", \"probability\" : 0.8}, \n\t\t * \t\t\t\t\t{\"value\" : \"middle\", \"probability\" : 0.2}],\n\t\t * \t\"middle\" : \"end\"\n\t\t * });\n\t\t * chain.value = \"beginning\";\n\t\t * chain.next(); //returns \"end\" with 80% probability or \"middle\" with 20%.\n\t\t * @param {Object} values An object with the state names as the keys\n\t\t * and the next state(s) as the values. \n\t\t */\n\t Tone.CtrlMarkov = function (values, initial) {\n\t Tone.call(this);\n\t /**\n\t\t\t * The Markov values with states as the keys\n\t\t\t * and next state(s) as the values. \n\t\t\t * @type {Object}\n\t\t\t */\n\t this.values = Tone.defaultArg(values, {});\n\t /**\n\t\t\t * The current state of the Markov values. The next\n\t\t\t * state will be evaluated and returned when Tone.CtrlMarkov.next\n\t\t\t * is invoked.\n\t\t\t * @type {String}\n\t\t\t */\n\t this.value = Tone.defaultArg(initial, Object.keys(this.values)[0]);\n\t };\n\t Tone.extend(Tone.CtrlMarkov);\n\t /**\n\t\t * Returns the next state of the Markov values. \n\t\t * @return {String}\n\t\t */\n\t Tone.CtrlMarkov.prototype.next = function () {\n\t if (this.values.hasOwnProperty(this.value)) {\n\t var next = this.values[this.value];\n\t if (Tone.isArray(next)) {\n\t var distribution = this._getProbDistribution(next);\n\t var rand = Math.random();\n\t var total = 0;\n\t for (var i = 0; i < distribution.length; i++) {\n\t var dist = distribution[i];\n\t if (rand > total && rand < total + dist) {\n\t var chosen = next[i];\n\t if (Tone.isObject(chosen)) {\n\t this.value = chosen.value;\n\t } else {\n\t this.value = chosen;\n\t }\n\t }\n\t total += dist;\n\t }\n\t } else {\n\t this.value = next;\n\t }\n\t }\n\t return this.value;\n\t };\n\t /**\n\t\t * Choose randomly from an array weighted options in the form \n\t\t * {\"state\" : string, \"probability\" : number} or an array of values\n\t\t * @param {Array} options \n\t\t * @return {Array} The randomly selected choice\n\t\t * @private\n\t\t */\n\t Tone.CtrlMarkov.prototype._getProbDistribution = function (options) {\n\t var distribution = [];\n\t var total = 0;\n\t var needsNormalizing = false;\n\t for (var i = 0; i < options.length; i++) {\n\t var option = options[i];\n\t if (Tone.isObject(option)) {\n\t needsNormalizing = true;\n\t distribution[i] = option.probability;\n\t } else {\n\t distribution[i] = 1 / options.length;\n\t }\n\t total += distribution[i];\n\t }\n\t if (needsNormalizing) {\n\t //normalize the values\n\t for (var j = 0; j < distribution.length; j++) {\n\t distribution[j] = distribution[j] / total;\n\t }\n\t }\n\t return distribution;\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.CtrlMarkov} this\n\t\t */\n\t Tone.CtrlMarkov.prototype.dispose = function () {\n\t this.values = null;\n\t };\n\t return Tone.CtrlMarkov;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Generate patterns from an array of values.\n\t\t * Has a number of arpeggiation and randomized\n\t\t * selection patterns. \n\t\t * <ul>\n\t\t * \t <li>\"up\" - cycles upward</li>\n\t\t * \t\t\t<li>\"down\" - cycles downward</li>\n\t\t * \t\t\t<li>\"upDown\" - up then and down</li>\n\t\t * \t\t\t<li>\"downUp\" - cycles down then and up</li>\n\t\t * \t\t\t<li>\"alternateUp\" - jump up two and down one</li>\n\t\t * \t\t\t<li>\"alternateDown\" - jump down two and up one</li>\n\t\t * \t\t\t<li>\"random\" - randomly select an index</li>\n\t\t * \t\t\t<li>\"randomWalk\" - randomly moves one index away from the current position</li>\n\t\t * \t\t\t<li>\"randomOnce\" - randomly select an index without repeating until all values have been chosen.</li>\n\t\t * \t\t</ul>\n\t\t * @param {Array} values An array of options to choose from.\n\t\t * @param {Tone.CtrlPattern.Type=} type The name of the pattern.\n\t\t * @extends {Tone}\n\t\t */\n\t Tone.CtrlPattern = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'values',\n\t 'type'\n\t ], Tone.CtrlPattern);\n\t Tone.call(this);\n\t /**\n\t\t\t * The array of values to arpeggiate over\n\t\t\t * @type {Array}\n\t\t\t */\n\t this.values = options.values;\n\t /**\n\t\t\t * The current position in the values array\n\t\t\t * @type {Number}\n\t\t\t */\n\t this.index = 0;\n\t /**\n\t\t\t * The type placeholder\n\t\t\t * @type {Tone.CtrlPattern.Type}\n\t\t\t * @private\n\t\t\t */\n\t this._type = null;\n\t /**\n\t\t\t * Shuffled values for the RandomOnce type\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._shuffled = null;\n\t /**\n\t\t\t * The direction of the movement\n\t\t\t * @type {String}\n\t\t\t * @private\n\t\t\t */\n\t this._direction = null;\n\t this.type = options.type;\n\t };\n\t Tone.extend(Tone.CtrlPattern);\n\t /**\n\t\t * The Control Patterns\n\t\t * @type {Object}\n\t\t * @static\n\t\t */\n\t Tone.CtrlPattern.Type = {\n\t Up: 'up',\n\t Down: 'down',\n\t UpDown: 'upDown',\n\t DownUp: 'downUp',\n\t AlternateUp: 'alternateUp',\n\t AlternateDown: 'alternateDown',\n\t Random: 'random',\n\t RandomWalk: 'randomWalk',\n\t RandomOnce: 'randomOnce'\n\t };\n\t /**\n\t\t * The default values. \n\t\t * @type {Object}\n\t\t */\n\t Tone.CtrlPattern.defaults = {\n\t 'type': Tone.CtrlPattern.Type.Up,\n\t 'values': []\n\t };\n\t /**\n\t\t * The value at the current index of the pattern.\n\t\t * @readOnly\n\t\t * @memberOf Tone.CtrlPattern#\n\t\t * @type {*}\n\t\t * @name value\n\t\t */\n\t Object.defineProperty(Tone.CtrlPattern.prototype, 'value', {\n\t get: function () {\n\t //some safeguards\n\t if (this.values.length === 0) {\n\t return;\n\t } else if (this.values.length === 1) {\n\t return this.values[0];\n\t }\n\t this.index = Math.min(this.index, this.values.length - 1);\n\t var val = this.values[this.index];\n\t if (this.type === Tone.CtrlPattern.Type.RandomOnce) {\n\t if (this.values.length !== this._shuffled.length) {\n\t this._shuffleValues();\n\t }\n\t val = this.values[this._shuffled[this.index]];\n\t }\n\t return val;\n\t }\n\t });\n\t /**\n\t\t * The pattern used to select the next\n\t\t * item from the values array\n\t\t * @memberOf Tone.CtrlPattern#\n\t\t * @type {Tone.CtrlPattern.Type}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.CtrlPattern.prototype, 'type', {\n\t get: function () {\n\t return this._type;\n\t },\n\t set: function (type) {\n\t this._type = type;\n\t this._shuffled = null;\n\t //the first index\n\t if (this._type === Tone.CtrlPattern.Type.Up || this._type === Tone.CtrlPattern.Type.UpDown || this._type === Tone.CtrlPattern.Type.RandomOnce || this._type === Tone.CtrlPattern.Type.AlternateUp) {\n\t this.index = 0;\n\t } else if (this._type === Tone.CtrlPattern.Type.Down || this._type === Tone.CtrlPattern.Type.DownUp || this._type === Tone.CtrlPattern.Type.AlternateDown) {\n\t this.index = this.values.length - 1;\n\t }\n\t //the direction\n\t if (this._type === Tone.CtrlPattern.Type.UpDown || this._type === Tone.CtrlPattern.Type.AlternateUp) {\n\t this._direction = Tone.CtrlPattern.Type.Up;\n\t } else if (this._type === Tone.CtrlPattern.Type.DownUp || this._type === Tone.CtrlPattern.Type.AlternateDown) {\n\t this._direction = Tone.CtrlPattern.Type.Down;\n\t }\n\t //randoms\n\t if (this._type === Tone.CtrlPattern.Type.RandomOnce) {\n\t this._shuffleValues();\n\t } else if (this._type === Tone.CtrlPattern.Random) {\n\t this.index = Math.floor(Math.random() * this.values.length);\n\t }\n\t }\n\t });\n\t /**\n\t\t * Return the next value given the current position\n\t\t * and pattern.\n\t\t * @return {*} The next value\n\t\t */\n\t Tone.CtrlPattern.prototype.next = function () {\n\t var type = this.type;\n\t //choose the next index\n\t if (type === Tone.CtrlPattern.Type.Up) {\n\t this.index++;\n\t if (this.index >= this.values.length) {\n\t this.index = 0;\n\t }\n\t } else if (type === Tone.CtrlPattern.Type.Down) {\n\t this.index--;\n\t if (this.index < 0) {\n\t this.index = this.values.length - 1;\n\t }\n\t } else if (type === Tone.CtrlPattern.Type.UpDown || type === Tone.CtrlPattern.Type.DownUp) {\n\t if (this._direction === Tone.CtrlPattern.Type.Up) {\n\t this.index++;\n\t } else {\n\t this.index--;\n\t }\n\t if (this.index < 0) {\n\t this.index = 1;\n\t this._direction = Tone.CtrlPattern.Type.Up;\n\t } else if (this.index >= this.values.length) {\n\t this.index = this.values.length - 2;\n\t this._direction = Tone.CtrlPattern.Type.Down;\n\t }\n\t } else if (type === Tone.CtrlPattern.Type.Random) {\n\t this.index = Math.floor(Math.random() * this.values.length);\n\t } else if (type === Tone.CtrlPattern.Type.RandomWalk) {\n\t if (Math.random() < 0.5) {\n\t this.index--;\n\t this.index = Math.max(this.index, 0);\n\t } else {\n\t this.index++;\n\t this.index = Math.min(this.index, this.values.length - 1);\n\t }\n\t } else if (type === Tone.CtrlPattern.Type.RandomOnce) {\n\t this.index++;\n\t if (this.index >= this.values.length) {\n\t this.index = 0;\n\t //reshuffle the values for next time\n\t this._shuffleValues();\n\t }\n\t } else if (type === Tone.CtrlPattern.Type.AlternateUp) {\n\t if (this._direction === Tone.CtrlPattern.Type.Up) {\n\t this.index += 2;\n\t this._direction = Tone.CtrlPattern.Type.Down;\n\t } else {\n\t this.index -= 1;\n\t this._direction = Tone.CtrlPattern.Type.Up;\n\t }\n\t if (this.index >= this.values.length) {\n\t this.index = 0;\n\t this._direction = Tone.CtrlPattern.Type.Up;\n\t }\n\t } else if (type === Tone.CtrlPattern.Type.AlternateDown) {\n\t if (this._direction === Tone.CtrlPattern.Type.Up) {\n\t this.index += 1;\n\t this._direction = Tone.CtrlPattern.Type.Down;\n\t } else {\n\t this.index -= 2;\n\t this._direction = Tone.CtrlPattern.Type.Up;\n\t }\n\t if (this.index < 0) {\n\t this.index = this.values.length - 1;\n\t this._direction = Tone.CtrlPattern.Type.Down;\n\t }\n\t }\n\t return this.value;\n\t };\n\t /**\n\t\t * Shuffles the values and places the results into the _shuffled\n\t\t * @private\n\t\t */\n\t Tone.CtrlPattern.prototype._shuffleValues = function () {\n\t var copy = [];\n\t this._shuffled = [];\n\t for (var i = 0; i < this.values.length; i++) {\n\t copy[i] = i;\n\t }\n\t while (copy.length > 0) {\n\t var randVal = copy.splice(Math.floor(copy.length * Math.random()), 1);\n\t this._shuffled.push(randVal[0]);\n\t }\n\t };\n\t /**\n\t\t * Clean up\n\t\t * @returns {Tone.CtrlPattern} this\n\t\t */\n\t Tone.CtrlPattern.prototype.dispose = function () {\n\t this._shuffled = null;\n\t this.values = null;\n\t };\n\t return Tone.CtrlPattern;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Choose a random value.\n\t\t * @extends {Tone}\n\t\t * @example\n\t\t * var randomWalk = new Tone.CtrlRandom({\n\t\t * \t\"min\" : 0,\n\t\t * \t\"max\" : 10,\n\t\t * \t\"integer\" : true\n\t\t * });\n\t\t * randomWalk.eval();\n\t\t *\n\t\t * @param {Number|Time=} min The minimum return value.\n\t\t * @param {Number|Time=} max The maximum return value.\n\t\t */\n\t Tone.CtrlRandom = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'min',\n\t 'max'\n\t ], Tone.CtrlRandom);\n\t Tone.call(this);\n\t /**\n\t\t\t * The minimum return value\n\t\t\t * @type {Number|Time}\n\t\t\t */\n\t this.min = options.min;\n\t /**\n\t\t\t * The maximum return value\n\t\t\t * @type {Number|Time}\n\t\t\t */\n\t this.max = options.max;\n\t /**\n\t\t\t * If the return value should be an integer\n\t\t\t * @type {Boolean}\n\t\t\t */\n\t this.integer = options.integer;\n\t };\n\t Tone.extend(Tone.CtrlRandom);\n\t /**\n\t\t * The defaults\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.CtrlRandom.defaults = {\n\t 'min': 0,\n\t 'max': 1,\n\t 'integer': false\n\t };\n\t /**\n\t\t * Return a random value between min and max. \n\t\t * @readOnly\n\t\t * @memberOf Tone.CtrlRandom#\n\t\t * @type {*}\n\t\t * @name value\n\t\t */\n\t Object.defineProperty(Tone.CtrlRandom.prototype, 'value', {\n\t get: function () {\n\t var min = this.toSeconds(this.min);\n\t var max = this.toSeconds(this.max);\n\t var rand = Math.random();\n\t var val = rand * min + (1 - rand) * max;\n\t if (this.integer) {\n\t val = Math.floor(val);\n\t }\n\t return val;\n\t }\n\t });\n\t return Tone.CtrlRandom;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class A data structure for holding multiple buffers.\n\t\t * \n\t\t * @param {Object|Array} urls An object literal or array\n\t\t * of urls to load.\n\t\t * @param {Function=} callback The callback to invoke when\n\t\t * the buffers are loaded. \n\t\t * @extends {Tone}\n\t\t * @example\n\t\t * //load a whole bank of piano samples\n\t\t * var pianoSamples = new Tone.Buffers({\n\t\t * \t\"C4\" : \"path/to/C4.mp3\"\n\t\t * \t\"C#4\" : \"path/to/C#4.mp3\"\n\t\t * \t\"D4\" : \"path/to/D4.mp3\"\n\t\t * \t\"D#4\" : \"path/to/D#4.mp3\"\n\t\t * \t...\n\t\t * }, function(){\n\t\t * \t//play one of the samples when they all load\n\t\t * \tplayer.buffer = pianoSamples.get(\"C4\");\n\t\t * \tplayer.start();\n\t\t * });\n\t\t * \t@example\n\t\t * //To pass in additional parameters in the second parameter\n\t\t * var buffers = new Tone.Buffers(urls, {\n\t\t * \t\"onload\" : callback,\n\t\t * \t\"baseUrl\" : \"../path/to/audio/\"\n\t\t * })\n\t\t */\n\t Tone.Buffers = function (urls) {\n\t //remove the urls from the options\n\t var args = Array.prototype.slice.call(arguments);\n\t args.shift();\n\t var options = Tone.defaults(args, [\n\t 'onload',\n\t 'baseUrl'\n\t ], Tone.Buffers);\n\t Tone.call(this);\n\t /**\n\t\t\t * All of the buffers\n\t\t\t * @type {Object}\n\t\t\t * @private\n\t\t\t */\n\t this._buffers = {};\n\t /**\n\t\t\t * A path which is prefixed before every url.\n\t\t\t * @type {String}\n\t\t\t */\n\t this.baseUrl = options.baseUrl;\n\t this._loadingCount = 0;\n\t //add each one\n\t for (var key in urls) {\n\t this._loadingCount++;\n\t this.add(key, urls[key], this._bufferLoaded.bind(this, options.onload));\n\t }\n\t };\n\t Tone.extend(Tone.Buffers);\n\t /**\n\t\t * Defaults\n\t\t * @type {Object}\n\t\t */\n\t Tone.Buffers.defaults = {\n\t 'onload': Tone.noOp,\n\t 'baseUrl': ''\n\t };\n\t /**\n\t\t * True if the buffers object has a buffer by that name.\n\t\t * @param {String|Number} name The key or index of the \n\t\t * buffer.\n\t\t * @return {Boolean}\n\t\t */\n\t Tone.Buffers.prototype.has = function (name) {\n\t return this._buffers.hasOwnProperty(name);\n\t };\n\t /**\n\t\t * Get a buffer by name. If an array was loaded, \n\t\t * then use the array index.\n\t\t * @param {String|Number} name The key or index of the \n\t\t * buffer.\n\t\t * @return {Tone.Buffer}\n\t\t */\n\t Tone.Buffers.prototype.get = function (name) {\n\t if (this.has(name)) {\n\t return this._buffers[name];\n\t } else {\n\t throw new Error('Tone.Buffers: no buffer named ' + name);\n\t }\n\t };\n\t /**\n\t\t * A buffer was loaded. decrement the counter.\n\t\t * @param {Function} callback \n\t\t * @private\n\t\t */\n\t Tone.Buffers.prototype._bufferLoaded = function (callback) {\n\t this._loadingCount--;\n\t if (this._loadingCount === 0 && callback) {\n\t callback(this);\n\t }\n\t };\n\t /**\n\t\t * If the buffers are loaded or not\n\t\t * @memberOf Tone.Buffers#\n\t\t * @type {Boolean}\n\t\t * @name loaded\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Buffers.prototype, 'loaded', {\n\t get: function () {\n\t var isLoaded = true;\n\t for (var buffName in this._buffers) {\n\t var buff = this.get(buffName);\n\t isLoaded = isLoaded && buff.loaded;\n\t }\n\t return isLoaded;\n\t }\n\t });\n\t /**\n\t\t * Add a buffer by name and url to the Buffers\n\t\t * @param {String} name A unique name to give\n\t\t * the buffer\n\t\t * @param {String|Tone.Buffer|Audiobuffer} url Either the url of the bufer, \n\t\t * or a buffer which will be added\n\t\t * with the given name.\n\t\t * @param {Function=} callback The callback to invoke \n\t\t * when the url is loaded.\n\t\t */\n\t Tone.Buffers.prototype.add = function (name, url, callback) {\n\t callback = Tone.defaultArg(callback, Tone.noOp);\n\t if (url instanceof Tone.Buffer) {\n\t this._buffers[name] = url;\n\t callback(this);\n\t } else if (url instanceof AudioBuffer) {\n\t this._buffers[name] = new Tone.Buffer(url);\n\t callback(this);\n\t } else if (Tone.isString(url)) {\n\t this._buffers[name] = new Tone.Buffer(this.baseUrl + url, callback);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.Buffers} this\n\t\t */\n\t Tone.Buffers.prototype.dispose = function () {\n\t Tone.prototype.dispose.call(this);\n\t for (var name in this._buffers) {\n\t this._buffers[name].dispose();\n\t }\n\t this._buffers = null;\n\t return this;\n\t };\n\t return Tone.Buffers;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * buses are another way of routing audio\n\t\t *\n\t\t * augments Tone.prototype to include send and recieve\n\t\t */\n\t /**\n\t\t * All of the routes\n\t\t *\n\t\t * @type {Object}\n\t\t * @static\n\t\t * @private\n\t\t */\n\t var Buses = {};\n\t /**\n\t\t * Send this signal to the channel name.\n\t\t * @param {String} channelName A named channel to send the signal to.\n\t\t * @param {Decibels} amount The amount of the source to send to the bus.\n\t\t * @return {GainNode} The gain node which connects this node to the desired channel.\n\t\t * Can be used to adjust the levels of the send.\n\t\t * @example\n\t\t * source.send(\"reverb\", -12);\n\t\t */\n\t Tone.prototype.send = function (channelName, amount) {\n\t if (!Buses.hasOwnProperty(channelName)) {\n\t Buses[channelName] = this.context.createGain();\n\t }\n\t amount = Tone.defaultArg(amount, 0);\n\t var sendKnob = new Tone.Gain(amount, Tone.Type.Decibels);\n\t this.connect(sendKnob);\n\t sendKnob.connect(Buses[channelName]);\n\t return sendKnob;\n\t };\n\t /**\n\t\t * Recieve the input from the desired channelName to the input\n\t\t *\n\t\t * @param {String} channelName A named channel to send the signal to.\n\t\t * @param {Number=} channelNumber The channel to connect to\n\t\t * @returns {Tone} this\n\t\t * @example\n\t\t * reverbEffect.receive(\"reverb\");\n\t\t */\n\t Tone.prototype.receive = function (channelName, inputNum) {\n\t if (!Buses.hasOwnProperty(channelName)) {\n\t Buses[channelName] = this.context.createGain();\n\t }\n\t Buses[channelName].connect(this, 0, inputNum);\n\t return this;\n\t };\n\t //remove all the send/receives when a new audio context is passed in\n\t Tone.Context.on('init', function (context) {\n\t if (context.Buses) {\n\t Buses = context.Buses;\n\t } else {\n\t Buses = {};\n\t context.Buses = Buses;\n\t }\n\t });\n\t return Tone;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Draw is useful for synchronizing visuals and audio events.\n\t\t * Callbacks from Tone.Transport or any of the Tone.Event classes\n\t\t * always happen _before_ the scheduled time and are not synchronized\n\t\t * to the animation frame so they are not good for triggering tightly\n\t\t * synchronized visuals and sound. Tone.Draw makes it easy to schedule\n\t\t * callbacks using the AudioContext time and uses requestAnimationFrame.\n\t\t * \n\t\t * @singleton\n\t\t * @extends {Tone}\n\t\t * @example\n\t\t * Tone.Transport.schedule(function(time){\n\t\t * \t//use the time argument to schedule a callback with Tone.Draw\n\t\t * \tTone.Draw.schedule(function(){\n\t\t * \t\t//do drawing or DOM manipulation here\n\t\t * \t}, time)\n\t\t * }, \"+0.5\")\n\t\t */\n\t Tone.Draw = function () {\n\t Tone.call(this);\n\t /**\n\t\t\t * All of the events.\n\t\t\t * @type {Tone.Timeline}\n\t\t\t * @private\n\t\t\t */\n\t this._events = new Tone.Timeline();\n\t /**\n\t\t\t * The duration after which events are not invoked.\n\t\t\t * @type {Number}\n\t\t\t * @default 0.25\n\t\t\t */\n\t this.expiration = 0.25;\n\t /**\n\t\t\t * The amount of time before the scheduled time \n\t\t\t * that the callback can be invoked. Default is\n\t\t\t * half the time of an animation frame (0.008 seconds).\n\t\t\t * @type {Number}\n\t\t\t * @default 0.008\n\t\t\t */\n\t this.anticipation = 0.008;\n\t /**\n\t\t\t * The draw loop\n\t\t\t * @type {Function}\n\t\t\t * @private\n\t\t\t */\n\t this._boundDrawLoop = this._drawLoop.bind(this);\n\t };\n\t Tone.extend(Tone.Draw);\n\t /**\n\t\t * Schedule a function at the given time to be invoked\n\t\t * on the nearest animation frame.\n\t\t * @param {Function} callback Callback is invoked at the given time.\n\t\t * @param {Time} time The time relative to the AudioContext time\n\t\t * to invoke the callback.\n\t\t * @return {Tone.Draw} this\n\t\t */\n\t Tone.Draw.prototype.schedule = function (callback, time) {\n\t this._events.add({\n\t callback: callback,\n\t time: this.toSeconds(time)\n\t });\n\t //start the draw loop on the first event\n\t if (this._events.length === 1) {\n\t requestAnimationFrame(this._boundDrawLoop);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Cancel events scheduled after the given time\n\t\t * @param {Time=} after Time after which scheduled events will \n\t\t * be removed from the scheduling timeline.\n\t\t * @return {Tone.Draw} this\n\t\t */\n\t Tone.Draw.prototype.cancel = function (after) {\n\t this._events.cancel(this.toSeconds(after));\n\t return this;\n\t };\n\t /**\n\t\t * The draw loop\n\t\t * @private\n\t\t */\n\t Tone.Draw.prototype._drawLoop = function () {\n\t var now = Tone.now();\n\t while (this._events.length && this._events.peek().time - this.anticipation <= now) {\n\t var event = this._events.shift();\n\t if (now - event.time <= this.expiration) {\n\t event.callback();\n\t }\n\t }\n\t if (this._events.length > 0) {\n\t requestAnimationFrame(this._boundDrawLoop);\n\t }\n\t };\n\t //make a singleton\n\t Tone.Draw = new Tone.Draw();\n\t return Tone.Draw;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Both Tone.Panner3D and Tone.Listener have a position in 3D space\n\t\t * using a right-handed cartesian coordinate system.\n\t\t * The units used in the coordinate system are not defined;\n\t\t * these coordinates are independent/invariant of any particular\n\t\t * units such as meters or feet. Tone.Panner3D objects have an forward\n\t\t * vector representing the direction the sound is projecting. Additionally,\n\t\t * they have a sound cone representing how directional the sound is.\n\t\t * For example, the sound could be omnidirectional, in which case it would\n\t\t * be heard anywhere regardless of its forward, or it can be more directional\n\t\t * and heard only if it is facing the listener. Tone.Listener objects\n\t\t * (representing a person's ears) have an forward and up vector\n\t\t * representing in which direction the person is facing. Because both the\n\t\t * source stream and the listener can be moving, they both have a velocity\n\t\t * vector representing both the speed and direction of movement. Taken together,\n\t\t * these two velocities can be used to generate a doppler shift effect which changes the pitch.\n\t\t * <br><br>\n\t\t * Note: the position of the Listener will have no effect on nodes not connected to a Tone.Panner3D\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone}\n\t\t * @singleton\n\t\t */\n\t Tone.Listener = function () {\n\t Tone.call(this);\n\t /**\n\t\t\t * Holds the current forward orientation\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._orientation = [\n\t 0,\n\t 0,\n\t 0,\n\t 0,\n\t 0,\n\t 0\n\t ];\n\t /**\n\t\t\t * Holds the current position\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._position = [\n\t 0,\n\t 0,\n\t 0\n\t ];\n\t Tone.getContext(function () {\n\t // set the default position/forward\n\t this.set(ListenerConstructor.defaults);\n\t }.bind(this));\n\t };\n\t Tone.extend(Tone.Listener);\n\t /**\n\t\t * Defaults according to the specification\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Listener.defaults = {\n\t 'positionX': 0,\n\t 'positionY': 0,\n\t 'positionZ': 0,\n\t 'forwardX': 0,\n\t 'forwardY': 0,\n\t 'forwardZ': 1,\n\t 'upX': 0,\n\t 'upY': 1,\n\t 'upZ': 0\n\t };\n\t /**\n\t\t * The ramp time which is applied to the setTargetAtTime\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t Tone.Listener.prototype._rampTimeConstant = 0.01;\n\t /**\n\t\t * Sets the position of the listener in 3d space.\n\t\t * @param {Number} x\n\t\t * @param {Number} y\n\t\t * @param {Number} z\n\t\t * @return {Tone.Listener} this\n\t\t */\n\t Tone.Listener.prototype.setPosition = function (x, y, z) {\n\t if (this.context.listener.positionX) {\n\t var now = this.now();\n\t this.context.listener.positionX.setTargetAtTime(x, now, this._rampTimeConstant);\n\t this.context.listener.positionY.setTargetAtTime(y, now, this._rampTimeConstant);\n\t this.context.listener.positionZ.setTargetAtTime(z, now, this._rampTimeConstant);\n\t } else {\n\t this.context.listener.setPosition(x, y, z);\n\t }\n\t this._position = Array.prototype.slice.call(arguments);\n\t return this;\n\t };\n\t /**\n\t\t * Sets the orientation of the listener using two vectors, the forward\n\t\t * vector (which direction the listener is facing) and the up vector\n\t\t * (which the up direction of the listener). An up vector\n\t\t * of 0, 0, 1 is equivalent to the listener standing up in the Z direction.\n\t\t * @param {Number} x\n\t\t * @param {Number} y\n\t\t * @param {Number} z\n\t\t * @param {Number} upX\n\t\t * @param {Number} upY\n\t\t * @param {Number} upZ\n\t\t * @return {Tone.Listener} this\n\t\t */\n\t Tone.Listener.prototype.setOrientation = function (x, y, z, upX, upY, upZ) {\n\t if (this.context.listener.forwardX) {\n\t var now = this.now();\n\t this.context.listener.forwardX.setTargetAtTime(x, now, this._rampTimeConstant);\n\t this.context.listener.forwardY.setTargetAtTime(y, now, this._rampTimeConstant);\n\t this.context.listener.forwardZ.setTargetAtTime(z, now, this._rampTimeConstant);\n\t this.context.listener.upX.setTargetAtTime(upX, now, this._rampTimeConstant);\n\t this.context.listener.upY.setTargetAtTime(upY, now, this._rampTimeConstant);\n\t this.context.listener.upZ.setTargetAtTime(upZ, now, this._rampTimeConstant);\n\t } else {\n\t this.context.listener.setOrientation(x, y, z, upX, upY, upZ);\n\t }\n\t this._orientation = Array.prototype.slice.call(arguments);\n\t return this;\n\t };\n\t /**\n\t\t * The x position of the panner object.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Listener#\n\t\t * @name positionX\n\t\t */\n\t Object.defineProperty(Tone.Listener.prototype, 'positionX', {\n\t set: function (pos) {\n\t this._position[0] = pos;\n\t this.setPosition.apply(this, this._position);\n\t },\n\t get: function () {\n\t return this._position[0];\n\t }\n\t });\n\t /**\n\t\t * The y position of the panner object.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Listener#\n\t\t * @name positionY\n\t\t */\n\t Object.defineProperty(Tone.Listener.prototype, 'positionY', {\n\t set: function (pos) {\n\t this._position[1] = pos;\n\t this.setPosition.apply(this, this._position);\n\t },\n\t get: function () {\n\t return this._position[1];\n\t }\n\t });\n\t /**\n\t\t * The z position of the panner object.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Listener#\n\t\t * @name positionZ\n\t\t */\n\t Object.defineProperty(Tone.Listener.prototype, 'positionZ', {\n\t set: function (pos) {\n\t this._position[2] = pos;\n\t this.setPosition.apply(this, this._position);\n\t },\n\t get: function () {\n\t return this._position[2];\n\t }\n\t });\n\t /**\n\t\t * The x coordinate of the listeners front direction. i.e.\n\t\t * which way they are facing.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Listener#\n\t\t * @name forwardX\n\t\t */\n\t Object.defineProperty(Tone.Listener.prototype, 'forwardX', {\n\t set: function (pos) {\n\t this._orientation[0] = pos;\n\t this.setOrientation.apply(this, this._orientation);\n\t },\n\t get: function () {\n\t return this._orientation[0];\n\t }\n\t });\n\t /**\n\t\t * The y coordinate of the listeners front direction. i.e.\n\t\t * which way they are facing.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Listener#\n\t\t * @name forwardY\n\t\t */\n\t Object.defineProperty(Tone.Listener.prototype, 'forwardY', {\n\t set: function (pos) {\n\t this._orientation[1] = pos;\n\t this.setOrientation.apply(this, this._orientation);\n\t },\n\t get: function () {\n\t return this._orientation[1];\n\t }\n\t });\n\t /**\n\t\t * The z coordinate of the listeners front direction. i.e.\n\t\t * which way they are facing.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Listener#\n\t\t * @name forwardZ\n\t\t */\n\t Object.defineProperty(Tone.Listener.prototype, 'forwardZ', {\n\t set: function (pos) {\n\t this._orientation[2] = pos;\n\t this.setOrientation.apply(this, this._orientation);\n\t },\n\t get: function () {\n\t return this._orientation[2];\n\t }\n\t });\n\t /**\n\t\t * The x coordinate of the listener's up direction. i.e.\n\t\t * the direction the listener is standing in.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Listener#\n\t\t * @name upX\n\t\t */\n\t Object.defineProperty(Tone.Listener.prototype, 'upX', {\n\t set: function (pos) {\n\t this._orientation[3] = pos;\n\t this.setOrientation.apply(this, this._orientation);\n\t },\n\t get: function () {\n\t return this._orientation[3];\n\t }\n\t });\n\t /**\n\t\t * The y coordinate of the listener's up direction. i.e.\n\t\t * the direction the listener is standing in.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Listener#\n\t\t * @name upY\n\t\t */\n\t Object.defineProperty(Tone.Listener.prototype, 'upY', {\n\t set: function (pos) {\n\t this._orientation[4] = pos;\n\t this.setOrientation.apply(this, this._orientation);\n\t },\n\t get: function () {\n\t return this._orientation[4];\n\t }\n\t });\n\t /**\n\t\t * The z coordinate of the listener's up direction. i.e.\n\t\t * the direction the listener is standing in.\n\t\t * @type {Number}\n\t\t * @memberOf Tone.Listener#\n\t\t * @name upZ\n\t\t */\n\t Object.defineProperty(Tone.Listener.prototype, 'upZ', {\n\t set: function (pos) {\n\t this._orientation[5] = pos;\n\t this.setOrientation.apply(this, this._orientation);\n\t },\n\t get: function () {\n\t return this._orientation[5];\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Listener} this\n\t\t */\n\t Tone.Listener.prototype.dispose = function () {\n\t this._orientation = null;\n\t this._position = null;\n\t return this;\n\t };\n\t //SINGLETON SETUP\n\t var ListenerConstructor = Tone.Listener;\n\t Tone.Listener = new ListenerConstructor();\n\t Tone.Context.on('init', function (context) {\n\t if (context.Listener instanceof ListenerConstructor) {\n\t //a single listener object\n\t Tone.Listener = context.Listener;\n\t } else {\n\t //make new Listener insides\n\t Tone.Listener = new ListenerConstructor();\n\t }\n\t context.Listener = Tone.Listener;\n\t });\n\t //END SINGLETON SETUP\n\t return Tone.Listener;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * Because of a bug in iOS causing the currentTime to increment\n\t\t * before the rendering is started, sometimes it takes multiple\n\t\t * attempts to render the audio correctly.\n\t\t * @private\n\t\t */\n\t function attemptRender(callback, duration, sampleRate, tries) {\n\t tries = Tone.defaultArg(tries, 0);\n\t var context = new Tone.OfflineContext(2, duration, sampleRate);\n\t Tone.context = context;\n\t //invoke the callback/scheduling\n\t var response = callback(Tone.Transport);\n\t if (context.currentTime > 0 && tries < 1000) {\n\t return attemptRender(callback, duration, sampleRate, ++tries);\n\t } else {\n\t return {\n\t 'response': response,\n\t 'context': context\n\t };\n\t }\n\t }\n\t /**\n\t\t * Generate a buffer by rendering all of the Tone.js code within the callback using the OfflineAudioContext.\n\t\t * The OfflineAudioContext is capable of rendering much faster than real time in many cases.\n\t\t * The callback function also passes in an offline instance of Tone.Transport which can be used\n\t\t * to schedule events along the Transport. **NOTE** OfflineAudioContext has the same restrictions\n\t\t * as the AudioContext in that on certain platforms (like iOS) it must be invoked by an explicit\n\t\t * user action like a click or tap. \n\t\t * @param {Function} callback All Tone.js nodes which are created and scheduled within this callback are recorded into the output Buffer.\n\t\t * @param {Time} duration the amount of time to record for.\n\t\t * @return {Promise} The promise which is invoked with the Tone.Buffer of the recorded output.\n\t\t * @example\n\t\t * //render 2 seconds of the oscillator\n\t\t * Tone.Offline(function(){\n\t\t * \t//only nodes created in this callback will be recorded\n\t\t * \tvar oscillator = new Tone.Oscillator().toMaster().start(0)\n\t\t * \t//schedule their events\n\t\t * }, 2).then(function(buffer){\n\t\t * \t//do something with the output buffer\n\t\t * })\n\t\t * @example\n\t\t * //can also schedule events along the Transport\n\t\t * //using the passed in Offline Transport\n\t\t * Tone.Offline(function(Transport){\n\t\t * \tvar osc = new Tone.Oscillator().toMaster()\n\t\t * \tTransport.schedule(function(time){\n\t\t * \t\tosc.start(time).stop(time + 0.1)\n\t\t * \t}, 1)\n\t\t * \tTransport.start(0.2)\n\t\t * }, 4).then(function(buffer){\n\t\t * \t//do something with the output buffer\n\t\t * })\n\t\t */\n\t Tone.Offline = function (callback, duration) {\n\t //set the OfflineAudioContext\n\t var sampleRate = Tone.context.sampleRate;\n\t var originalContext = Tone.context;\n\t var renderRet = attemptRender(callback, duration, sampleRate);\n\t var response = renderRet.response;\n\t var context = renderRet.context;\n\t var ret;\n\t if (response instanceof Promise) {\n\t //wait for the promise to resolve\n\t ret = response.then(function () {\n\t //then render the audio\n\t return context.render();\n\t });\n\t } else {\n\t //process the audio\n\t ret = context.render();\n\t }\n\t //return the original AudioContext\n\t Tone.context = originalContext;\n\t //return the audio\n\t return ret.then(function (buffer) {\n\t //wrap it in a Tone.Buffer\n\t return new Tone.Buffer(buffer);\n\t });\n\t };\n\t return Tone.Offline;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * \t@class Tone.Effect is the base class for effects. Connect the effect between\n\t\t * \t the effectSend and effectReturn GainNodes, then control the amount of\n\t\t * \t effect which goes to the output using the wet control.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {NormalRange|Object} [wet] The starting wet value.\n\t\t */\n\t Tone.Effect = function () {\n\t var options = Tone.defaults(arguments, ['wet'], Tone.Effect);\n\t Tone.AudioNode.call(this);\n\t this.createInsOuts(1, 1);\n\t /**\n\t\t\t * the drywet knob to control the amount of effect\n\t\t\t * @type {Tone.CrossFade}\n\t\t\t * @private\n\t\t\t */\n\t this._dryWet = new Tone.CrossFade(options.wet);\n\t /**\n\t\t\t * The wet control is how much of the effected\n\t\t\t * will pass through to the output. 1 = 100% effected\n\t\t\t * signal, 0 = 100% dry signal.\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.wet = this._dryWet.fade;\n\t /**\n\t\t\t * connect the effectSend to the input of hte effect\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this.effectSend = new Tone.Gain();\n\t /**\n\t\t\t * connect the output of the effect to the effectReturn\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this.effectReturn = new Tone.Gain();\n\t //connections\n\t this.input.connect(this._dryWet.a);\n\t this.input.connect(this.effectSend);\n\t this.effectReturn.connect(this._dryWet.b);\n\t this._dryWet.connect(this.output);\n\t this._readOnly(['wet']);\n\t };\n\t Tone.extend(Tone.Effect, Tone.AudioNode);\n\t /**\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.Effect.defaults = { 'wet': 1 };\n\t /**\n\t\t * chains the effect in between the effectSend and effectReturn\n\t\t * @param {Tone} effect\n\t\t * @private\n\t\t * @returns {Tone.Effect} this\n\t\t */\n\t Tone.Effect.prototype.connectEffect = function (effect) {\n\t this.effectSend.chain(effect, this.effectReturn);\n\t return this;\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Effect} this\n\t\t */\n\t Tone.Effect.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._dryWet.dispose();\n\t this._dryWet = null;\n\t this.effectSend.dispose();\n\t this.effectSend = null;\n\t this.effectReturn.dispose();\n\t this.effectReturn = null;\n\t this._writable(['wet']);\n\t this.wet = null;\n\t return this;\n\t };\n\t return Tone.Effect;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.AutoFilter is a Tone.Filter with a Tone.LFO connected to the filter cutoff frequency.\n\t\t * Setting the LFO rate and depth allows for control over the filter modulation rate \n\t\t * and depth.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Effect}\n\t\t * @param {Time|Object} [frequency] The rate of the LFO.\n\t\t * @param {Frequency=} baseFrequency The lower value of the LFOs oscillation\n\t \t * @param {Frequency=} octaves The number of octaves above the baseFrequency\n\t\t * @example\n\t\t * //create an autofilter and start it's LFO\n\t\t * var autoFilter = new Tone.AutoFilter(\"4n\").toMaster().start();\n\t\t * //route an oscillator through the filter and start it\n\t\t * var oscillator = new Tone.Oscillator().connect(autoFilter).start();\n\t\t */\n\t Tone.AutoFilter = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'baseFrequency',\n\t 'octaves'\n\t ], Tone.AutoFilter);\n\t Tone.Effect.call(this, options);\n\t /**\n\t\t\t * the lfo which drives the filter cutoff\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._lfo = new Tone.LFO({\n\t 'frequency': options.frequency,\n\t 'amplitude': options.depth\n\t });\n\t /**\n\t\t\t * The range of the filter modulating between the min and max frequency. \n\t\t\t * 0 = no modulation. 1 = full modulation.\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.depth = this._lfo.amplitude;\n\t /**\n\t\t\t * How fast the filter modulates between min and max. \n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = this._lfo.frequency;\n\t /**\n\t\t\t * The filter node\n\t\t\t * @type {Tone.Filter}\n\t\t\t */\n\t this.filter = new Tone.Filter(options.filter);\n\t /**\n\t\t\t * The octaves placeholder\n\t\t\t * @type {Positive}\n\t\t\t * @private\n\t\t\t */\n\t this._octaves = 0;\n\t //connections\n\t this.connectEffect(this.filter);\n\t this._lfo.connect(this.filter.frequency);\n\t this.type = options.type;\n\t this._readOnly([\n\t 'frequency',\n\t 'depth'\n\t ]);\n\t this.octaves = options.octaves;\n\t this.baseFrequency = options.baseFrequency;\n\t };\n\t //extend Effect\n\t Tone.extend(Tone.AutoFilter, Tone.Effect);\n\t /**\n\t\t * defaults\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.AutoFilter.defaults = {\n\t 'frequency': 1,\n\t 'type': 'sine',\n\t 'depth': 1,\n\t 'baseFrequency': 200,\n\t 'octaves': 2.6,\n\t 'filter': {\n\t 'type': 'lowpass',\n\t 'rolloff': -12,\n\t 'Q': 1\n\t }\n\t };\n\t /**\n\t\t * Start the effect.\n\t\t * @param {Time} [time=now] When the LFO will start. \n\t\t * @returns {Tone.AutoFilter} this\n\t\t */\n\t Tone.AutoFilter.prototype.start = function (time) {\n\t this._lfo.start(time);\n\t return this;\n\t };\n\t /**\n\t\t * Stop the effect.\n\t\t * @param {Time} [time=now] When the LFO will stop. \n\t\t * @returns {Tone.AutoFilter} this\n\t\t */\n\t Tone.AutoFilter.prototype.stop = function (time) {\n\t this._lfo.stop(time);\n\t return this;\n\t };\n\t /**\n\t\t * Sync the filter to the transport.\n\t\t * @param {Time} [delay=0] Delay time before starting the effect after the\n\t\t * Transport has started. \n\t\t * @returns {Tone.AutoFilter} this\n\t\t */\n\t Tone.AutoFilter.prototype.sync = function (delay) {\n\t this._lfo.sync(delay);\n\t return this;\n\t };\n\t /**\n\t\t * Unsync the filter from the transport.\n\t\t * @returns {Tone.AutoFilter} this\n\t\t */\n\t Tone.AutoFilter.prototype.unsync = function () {\n\t this._lfo.unsync();\n\t return this;\n\t };\n\t /**\n\t\t * Type of oscillator attached to the AutoFilter. \n\t\t * Possible values: \"sine\", \"square\", \"triangle\", \"sawtooth\".\n\t\t * @memberOf Tone.AutoFilter#\n\t\t * @type {string}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.AutoFilter.prototype, 'type', {\n\t get: function () {\n\t return this._lfo.type;\n\t },\n\t set: function (type) {\n\t this._lfo.type = type;\n\t }\n\t });\n\t /**\n\t\t * The minimum value of the filter's cutoff frequency.\n\t\t * @memberOf Tone.AutoFilter#\n\t\t * @type {Frequency}\n\t\t * @name min\n\t\t */\n\t Object.defineProperty(Tone.AutoFilter.prototype, 'baseFrequency', {\n\t get: function () {\n\t return this._lfo.min;\n\t },\n\t set: function (freq) {\n\t this._lfo.min = this.toFrequency(freq);\n\t //and set the max\n\t this.octaves = this._octaves;\n\t }\n\t });\n\t /**\n\t\t * The maximum value of the filter's cutoff frequency. \n\t\t * @memberOf Tone.AutoFilter#\n\t\t * @type {Positive}\n\t\t * @name octaves\n\t\t */\n\t Object.defineProperty(Tone.AutoFilter.prototype, 'octaves', {\n\t get: function () {\n\t return this._octaves;\n\t },\n\t set: function (oct) {\n\t this._octaves = oct;\n\t this._lfo.max = this.baseFrequency * Math.pow(2, oct);\n\t }\n\t });\n\t /**\n\t\t * Clean up. \n\t\t * @returns {Tone.AutoFilter} this\n\t\t */\n\t Tone.AutoFilter.prototype.dispose = function () {\n\t Tone.Effect.prototype.dispose.call(this);\n\t this._lfo.dispose();\n\t this._lfo = null;\n\t this.filter.dispose();\n\t this.filter = null;\n\t this._writable([\n\t 'frequency',\n\t 'depth'\n\t ]);\n\t this.frequency = null;\n\t this.depth = null;\n\t return this;\n\t };\n\t return Tone.AutoFilter;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.AutoPanner is a Tone.Panner with an LFO connected to the pan amount. \n\t\t * More on using autopanners [here](https://www.ableton.com/en/blog/autopan-chopper-effect-and-more-liveschool/).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Effect}\n\t\t * @param {Frequency|Object} [frequency] Rate of left-right oscillation. \n\t\t * @example\n\t\t * //create an autopanner and start it's LFO\n\t\t * var autoPanner = new Tone.AutoPanner(\"4n\").toMaster().start();\n\t\t * //route an oscillator through the panner and start it\n\t\t * var oscillator = new Tone.Oscillator().connect(autoPanner).start();\n\t\t */\n\t Tone.AutoPanner = function () {\n\t var options = Tone.defaults(arguments, ['frequency'], Tone.AutoPanner);\n\t Tone.Effect.call(this, options);\n\t /**\n\t\t\t * the lfo which drives the panning\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._lfo = new Tone.LFO({\n\t 'frequency': options.frequency,\n\t 'amplitude': options.depth,\n\t 'min': -1,\n\t 'max': 1\n\t });\n\t /**\n\t\t\t * The amount of panning between left and right. \n\t\t\t * 0 = always center. 1 = full range between left and right. \n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.depth = this._lfo.amplitude;\n\t /**\n\t\t\t * the panner node which does the panning\n\t\t\t * @type {Tone.Panner}\n\t\t\t * @private\n\t\t\t */\n\t this._panner = new Tone.Panner();\n\t /**\n\t\t\t * How fast the panner modulates between left and right. \n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = this._lfo.frequency;\n\t //connections\n\t this.connectEffect(this._panner);\n\t this._lfo.connect(this._panner.pan);\n\t this.type = options.type;\n\t this._readOnly([\n\t 'depth',\n\t 'frequency'\n\t ]);\n\t };\n\t //extend Effect\n\t Tone.extend(Tone.AutoPanner, Tone.Effect);\n\t /**\n\t\t * defaults\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.AutoPanner.defaults = {\n\t 'frequency': 1,\n\t 'type': 'sine',\n\t 'depth': 1\n\t };\n\t /**\n\t\t * Start the effect.\n\t\t * @param {Time} [time=now] When the LFO will start. \n\t\t * @returns {Tone.AutoPanner} this\n\t\t */\n\t Tone.AutoPanner.prototype.start = function (time) {\n\t this._lfo.start(time);\n\t return this;\n\t };\n\t /**\n\t\t * Stop the effect.\n\t\t * @param {Time} [time=now] When the LFO will stop. \n\t\t * @returns {Tone.AutoPanner} this\n\t\t */\n\t Tone.AutoPanner.prototype.stop = function (time) {\n\t this._lfo.stop(time);\n\t return this;\n\t };\n\t /**\n\t\t * Sync the panner to the transport.\n\t\t * @param {Time} [delay=0] Delay time before starting the effect after the\n\t\t * Transport has started. \n\t\t * @returns {Tone.AutoPanner} this\n\t\t */\n\t Tone.AutoPanner.prototype.sync = function (delay) {\n\t this._lfo.sync(delay);\n\t return this;\n\t };\n\t /**\n\t\t * Unsync the panner from the transport\n\t\t * @returns {Tone.AutoPanner} this\n\t\t */\n\t Tone.AutoPanner.prototype.unsync = function () {\n\t this._lfo.unsync();\n\t return this;\n\t };\n\t /**\n\t\t * Type of oscillator attached to the AutoFilter. \n\t\t * Possible values: \"sine\", \"square\", \"triangle\", \"sawtooth\".\n\t\t * @memberOf Tone.AutoFilter#\n\t\t * @type {string}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.AutoPanner.prototype, 'type', {\n\t get: function () {\n\t return this._lfo.type;\n\t },\n\t set: function (type) {\n\t this._lfo.type = type;\n\t }\n\t });\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.AutoPanner} this\n\t\t */\n\t Tone.AutoPanner.prototype.dispose = function () {\n\t Tone.Effect.prototype.dispose.call(this);\n\t this._lfo.dispose();\n\t this._lfo = null;\n\t this._panner.dispose();\n\t this._panner = null;\n\t this._writable([\n\t 'depth',\n\t 'frequency'\n\t ]);\n\t this.frequency = null;\n\t this.depth = null;\n\t return this;\n\t };\n\t return Tone.AutoPanner;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.AutoWah connects a Tone.Follower to a bandpass filter (Tone.Filter).\n\t\t * The frequency of the filter is adjusted proportionally to the\n\t\t * incoming signal's amplitude. Inspiration from [Tuna.js](https://github.com/Dinahmoe/tuna).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Effect}\n\t\t * @param {Frequency|Object} [baseFrequency] The frequency the filter is set\n\t\t * to at the low point of the wah\n\t\t * @param {Positive} [octaves] The number of octaves above the baseFrequency\n\t\t * the filter will sweep to when fully open\n\t\t * @param {Decibels} [sensitivity] The decibel threshold sensitivity for\n\t\t * the incoming signal. Normal range of -40 to 0.\n\t\t * @example\n\t\t * var autoWah = new Tone.AutoWah(50, 6, -30).toMaster();\n\t\t * //initialize the synth and connect to autowah\n\t\t * var synth = new Synth.connect(autoWah);\n\t\t * //Q value influences the effect of the wah - default is 2\n\t\t * autoWah.Q.value = 6;\n\t\t * //more audible on higher notes\n\t\t * synth.triggerAttackRelease(\"C4\", \"8n\")\n\t\t */\n\t Tone.AutoWah = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'baseFrequency',\n\t 'octaves',\n\t 'sensitivity'\n\t ], Tone.AutoWah);\n\t Tone.Effect.call(this, options);\n\t /**\n\t\t\t * The envelope follower. Set the attack/release\n\t\t\t * timing to adjust how the envelope is followed.\n\t\t\t * @type {Tone.Follower}\n\t\t\t * @private\n\t\t\t */\n\t this.follower = new Tone.Follower(options.follower);\n\t /**\n\t\t\t * scales the follower value to the frequency domain\n\t\t\t * @type {Tone}\n\t\t\t * @private\n\t\t\t */\n\t this._sweepRange = new Tone.ScaleExp(0, 1, 0.5);\n\t /**\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._baseFrequency = options.baseFrequency;\n\t /**\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._octaves = options.octaves;\n\t /**\n\t\t\t * the input gain to adjust the sensitivity\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._inputBoost = new Tone.Gain();\n\t /**\n\t\t\t * @type {BiquadFilterNode}\n\t\t\t * @private\n\t\t\t */\n\t this._bandpass = new Tone.Filter({\n\t 'rolloff': -48,\n\t 'frequency': 0,\n\t 'Q': options.Q\n\t });\n\t /**\n\t\t\t * @type {Tone.Filter}\n\t\t\t * @private\n\t\t\t */\n\t this._peaking = new Tone.Filter(0, 'peaking');\n\t this._peaking.gain.value = options.gain;\n\t /**\n\t\t\t * The gain of the filter.\n\t\t\t * @type {Number}\n\t\t\t * @signal\n\t\t\t */\n\t this.gain = this._peaking.gain;\n\t /**\n\t\t\t * The quality of the filter.\n\t\t\t * @type {Positive}\n\t\t\t * @signal\n\t\t\t */\n\t this.Q = this._bandpass.Q;\n\t //the control signal path\n\t this.effectSend.chain(this._inputBoost, this.follower, this._sweepRange);\n\t this._sweepRange.connect(this._bandpass.frequency);\n\t this._sweepRange.connect(this._peaking.frequency);\n\t //the filtered path\n\t this.effectSend.chain(this._bandpass, this._peaking, this.effectReturn);\n\t //set the initial value\n\t this._setSweepRange();\n\t this.sensitivity = options.sensitivity;\n\t this._readOnly([\n\t 'gain',\n\t 'Q'\n\t ]);\n\t };\n\t Tone.extend(Tone.AutoWah, Tone.Effect);\n\t /**\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.AutoWah.defaults = {\n\t 'baseFrequency': 100,\n\t 'octaves': 6,\n\t 'sensitivity': 0,\n\t 'Q': 2,\n\t 'gain': 2,\n\t 'follower': {\n\t 'attack': 0.3,\n\t 'release': 0.5\n\t }\n\t };\n\t /**\n\t\t * The number of octaves that the filter will sweep above the\n\t\t * baseFrequency.\n\t\t * @memberOf Tone.AutoWah#\n\t\t * @type {Number}\n\t\t * @name octaves\n\t\t */\n\t Object.defineProperty(Tone.AutoWah.prototype, 'octaves', {\n\t get: function () {\n\t return this._octaves;\n\t },\n\t set: function (octaves) {\n\t this._octaves = octaves;\n\t this._setSweepRange();\n\t }\n\t });\n\t /**\n\t\t * The base frequency from which the sweep will start from.\n\t\t * @memberOf Tone.AutoWah#\n\t\t * @type {Frequency}\n\t\t * @name baseFrequency\n\t\t */\n\t Object.defineProperty(Tone.AutoWah.prototype, 'baseFrequency', {\n\t get: function () {\n\t return this._baseFrequency;\n\t },\n\t set: function (baseFreq) {\n\t this._baseFrequency = baseFreq;\n\t this._setSweepRange();\n\t }\n\t });\n\t /**\n\t\t * The sensitivity to control how responsive to the input signal the filter is.\n\t\t * @memberOf Tone.AutoWah#\n\t\t * @type {Decibels}\n\t\t * @name sensitivity\n\t\t */\n\t Object.defineProperty(Tone.AutoWah.prototype, 'sensitivity', {\n\t get: function () {\n\t return Tone.gainToDb(1 / this._inputBoost.gain.value);\n\t },\n\t set: function (sensitivy) {\n\t this._inputBoost.gain.value = 1 / Tone.dbToGain(sensitivy);\n\t }\n\t });\n\t /**\n\t\t * sets the sweep range of the scaler\n\t\t * @private\n\t\t */\n\t Tone.AutoWah.prototype._setSweepRange = function () {\n\t this._sweepRange.min = this._baseFrequency;\n\t this._sweepRange.max = Math.min(this._baseFrequency * Math.pow(2, this._octaves), this.context.sampleRate / 2);\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.AutoWah} this\n\t\t */\n\t Tone.AutoWah.prototype.dispose = function () {\n\t Tone.Effect.prototype.dispose.call(this);\n\t this.follower.dispose();\n\t this.follower = null;\n\t this._sweepRange.dispose();\n\t this._sweepRange = null;\n\t this._bandpass.dispose();\n\t this._bandpass = null;\n\t this._peaking.dispose();\n\t this._peaking = null;\n\t this._inputBoost.dispose();\n\t this._inputBoost = null;\n\t this._writable([\n\t 'gain',\n\t 'Q'\n\t ]);\n\t this.gain = null;\n\t this.Q = null;\n\t return this;\n\t };\n\t return Tone.AutoWah;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Signal-rate modulo operator. Only works in AudioRange [-1, 1] and for modulus\n\t\t * values in the NormalRange.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.SignalBase}\n\t\t * @param {NormalRange} modulus The modulus to apply.\n\t\t * @example\n\t\t * var mod = new Tone.Modulo(0.2)\n\t\t * var sig = new Tone.Signal(0.5).connect(mod);\n\t\t * //mod outputs 0.1\n\t\t */\n\t Tone.Modulo = function (modulus) {\n\t Tone.SignalBase.call(this);\n\t this.createInsOuts(1, 0);\n\t /**\n\t\t\t * A waveshaper gets the integer multiple of\n\t\t\t * the input signal and the modulus.\n\t\t\t * @private\n\t\t\t * @type {Tone.WaveShaper}\n\t\t\t */\n\t this._shaper = new Tone.WaveShaper(Math.pow(2, 16));\n\t /**\n\t\t\t * the integer multiple is multiplied by the modulus\n\t\t\t * @type {Tone.Multiply}\n\t\t\t * @private\n\t\t\t */\n\t this._multiply = new Tone.Multiply();\n\t /**\n\t\t\t * and subtracted from the input signal\n\t\t\t * @type {Tone.Subtract}\n\t\t\t * @private\n\t\t\t */\n\t this._subtract = this.output = new Tone.Subtract();\n\t /**\n\t\t\t * the modulus signal\n\t\t\t * @type {Tone.Signal}\n\t\t\t * @private\n\t\t\t */\n\t this._modSignal = new Tone.Signal(modulus);\n\t //connections\n\t this.input.fan(this._shaper, this._subtract);\n\t this._modSignal.connect(this._multiply, 0, 0);\n\t this._shaper.connect(this._multiply, 0, 1);\n\t this._multiply.connect(this._subtract, 0, 1);\n\t this._setWaveShaper(modulus);\n\t };\n\t Tone.extend(Tone.Modulo, Tone.SignalBase);\n\t /**\n\t\t * @param {number} mod the modulus to apply\n\t\t * @private\n\t\t */\n\t Tone.Modulo.prototype._setWaveShaper = function (mod) {\n\t this._shaper.setMap(function (val) {\n\t var multiple = Math.floor((val + 0.0001) / mod);\n\t return multiple;\n\t });\n\t };\n\t /**\n\t\t * The modulus value.\n\t\t * @memberOf Tone.Modulo#\n\t\t * @type {NormalRange}\n\t\t * @name value\n\t\t */\n\t Object.defineProperty(Tone.Modulo.prototype, 'value', {\n\t get: function () {\n\t return this._modSignal.value;\n\t },\n\t set: function (mod) {\n\t this._modSignal.value = mod;\n\t this._setWaveShaper(mod);\n\t }\n\t });\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.Modulo} this\n\t\t */\n\t Tone.Modulo.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._shaper.dispose();\n\t this._shaper = null;\n\t this._multiply.dispose();\n\t this._multiply = null;\n\t this._subtract.dispose();\n\t this._subtract = null;\n\t this._modSignal.dispose();\n\t this._modSignal = null;\n\t return this;\n\t };\n\t return Tone.Modulo;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Bitcrusher downsamples the incoming signal to a different bitdepth.\n\t\t * Lowering the bitdepth of the signal creates distortion. Read more about Bitcrushing\n\t\t * on [Wikipedia](https://en.wikipedia.org/wiki/Bitcrusher).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Effect}\n\t\t * @param {Number} bits The number of bits to downsample the signal. Nominal range\n\t\t * of 1 to 8.\n\t\t * @example\n\t\t * //initialize crusher and route a synth through it\n\t\t * var crusher = new Tone.BitCrusher(4).toMaster();\n\t\t * var synth = new Tone.MonoSynth().connect(crusher);\n\t\t */\n\t Tone.BitCrusher = function () {\n\t var options = Tone.defaults(arguments, ['bits'], Tone.BitCrusher);\n\t Tone.Effect.call(this, options);\n\t var invStepSize = 1 / Math.pow(2, options.bits - 1);\n\t /**\n\t\t\t * Subtract the input signal and the modulus of the input signal\n\t\t\t * @type {Tone.Subtract}\n\t\t\t * @private\n\t\t\t */\n\t this._subtract = new Tone.Subtract();\n\t /**\n\t\t\t * The mod function\n\t\t\t * @type {Tone.Modulo}\n\t\t\t * @private\n\t\t\t */\n\t this._modulo = new Tone.Modulo(invStepSize);\n\t /**\n\t\t\t * keeps track of the bits\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._bits = options.bits;\n\t //connect it up\n\t this.effectSend.fan(this._subtract, this._modulo);\n\t this._modulo.connect(this._subtract, 0, 1);\n\t this._subtract.connect(this.effectReturn);\n\t };\n\t Tone.extend(Tone.BitCrusher, Tone.Effect);\n\t /**\n\t\t * the default values\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.BitCrusher.defaults = { 'bits': 4 };\n\t /**\n\t\t * The bit depth of the effect. Nominal range of 1-8.\n\t\t * @memberOf Tone.BitCrusher#\n\t\t * @type {number}\n\t\t * @name bits\n\t\t */\n\t Object.defineProperty(Tone.BitCrusher.prototype, 'bits', {\n\t get: function () {\n\t return this._bits;\n\t },\n\t set: function (bits) {\n\t this._bits = bits;\n\t var invStepSize = 1 / Math.pow(2, bits - 1);\n\t this._modulo.value = invStepSize;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.BitCrusher} this\n\t\t */\n\t Tone.BitCrusher.prototype.dispose = function () {\n\t Tone.Effect.prototype.dispose.call(this);\n\t this._subtract.dispose();\n\t this._subtract = null;\n\t this._modulo.dispose();\n\t this._modulo = null;\n\t return this;\n\t };\n\t return Tone.BitCrusher;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.ChebyShev is a Chebyshev waveshaper, an effect which is good \n\t\t * for making different types of distortion sounds.\n\t\t * Note that odd orders sound very different from even ones, \n\t\t * and order = 1 is no change. \n\t\t * Read more at [music.columbia.edu](http://music.columbia.edu/cmc/musicandcomputers/chapter4/04_06.php).\n\t\t *\n\t\t * @extends {Tone.Effect}\n\t\t * @constructor\n\t\t * @param {Positive|Object} [order] The order of the chebyshev polynomial. Normal range between 1-100. \n\t\t * @example\n\t\t * //create a new cheby\n\t\t * var cheby = new Tone.Chebyshev(50);\n\t\t * //create a monosynth connected to our cheby\n\t\t * synth = new Tone.MonoSynth().connect(cheby);\n\t\t */\n\t Tone.Chebyshev = function () {\n\t var options = Tone.defaults(arguments, ['order'], Tone.Chebyshev);\n\t Tone.Effect.call(this, options);\n\t /**\n\t\t\t * @type {WaveShaperNode}\n\t\t\t * @private\n\t\t\t */\n\t this._shaper = new Tone.WaveShaper(4096);\n\t /**\n\t\t\t * holds onto the order of the filter\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._order = options.order;\n\t this.connectEffect(this._shaper);\n\t this.order = options.order;\n\t this.oversample = options.oversample;\n\t };\n\t Tone.extend(Tone.Chebyshev, Tone.Effect);\n\t /**\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Chebyshev.defaults = {\n\t 'order': 1,\n\t 'oversample': 'none'\n\t };\n\t /**\n\t\t * get the coefficient for that degree\n\t\t * @param {number} x the x value\n\t\t * @param {number} degree \n\t\t * @param {Object} memo memoize the computed value. \n\t\t * this speeds up computation greatly. \n\t\t * @return {number} the coefficient \n\t\t * @private\n\t\t */\n\t Tone.Chebyshev.prototype._getCoefficient = function (x, degree, memo) {\n\t if (memo.hasOwnProperty(degree)) {\n\t return memo[degree];\n\t } else if (degree === 0) {\n\t memo[degree] = 0;\n\t } else if (degree === 1) {\n\t memo[degree] = x;\n\t } else {\n\t memo[degree] = 2 * x * this._getCoefficient(x, degree - 1, memo) - this._getCoefficient(x, degree - 2, memo);\n\t }\n\t return memo[degree];\n\t };\n\t /**\n\t\t * The order of the Chebyshev polynomial which creates\n\t\t * the equation which is applied to the incoming \n\t\t * signal through a Tone.WaveShaper. The equations\n\t\t * are in the form:<br>\n\t\t * order 2: 2x^2 + 1<br>\n\t\t * order 3: 4x^3 + 3x <br>\n\t\t * @memberOf Tone.Chebyshev#\n\t\t * @type {Positive}\n\t\t * @name order\n\t\t */\n\t Object.defineProperty(Tone.Chebyshev.prototype, 'order', {\n\t get: function () {\n\t return this._order;\n\t },\n\t set: function (order) {\n\t this._order = order;\n\t var curve = new Array(4096);\n\t var len = curve.length;\n\t for (var i = 0; i < len; ++i) {\n\t var x = i * 2 / len - 1;\n\t if (x === 0) {\n\t //should output 0 when input is 0\n\t curve[i] = 0;\n\t } else {\n\t curve[i] = this._getCoefficient(x, order, {});\n\t }\n\t }\n\t this._shaper.curve = curve;\n\t }\n\t });\n\t /**\n\t\t * The oversampling of the effect. Can either be \"none\", \"2x\" or \"4x\".\n\t\t * @memberOf Tone.Chebyshev#\n\t\t * @type {string}\n\t\t * @name oversample\n\t\t */\n\t Object.defineProperty(Tone.Chebyshev.prototype, 'oversample', {\n\t get: function () {\n\t return this._shaper.oversample;\n\t },\n\t set: function (oversampling) {\n\t this._shaper.oversample = oversampling;\n\t }\n\t });\n\t /**\n\t\t * Clean up. \n\t\t * @returns {Tone.Chebyshev} this\n\t\t */\n\t Tone.Chebyshev.prototype.dispose = function () {\n\t Tone.Effect.prototype.dispose.call(this);\n\t this._shaper.dispose();\n\t this._shaper = null;\n\t return this;\n\t };\n\t return Tone.Chebyshev;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Base class for Stereo effects. Provides effectSendL/R and effectReturnL/R.\n\t\t *\n\t\t *\t@constructor\n\t\t *\t@extends {Tone.Effect}\n\t\t */\n\t Tone.StereoEffect = function () {\n\t //get the defaults\n\t Tone.AudioNode.call(this);\n\t var options = Tone.defaults(arguments, ['wet'], Tone.Effect);\n\t this.createInsOuts(1, 1);\n\t /**\n\t\t\t * the drywet knob to control the amount of effect\n\t\t\t * @type {Tone.CrossFade}\n\t\t\t * @private\n\t\t\t */\n\t this._dryWet = new Tone.CrossFade(options.wet);\n\t /**\n\t\t\t * The wet control, i.e. how much of the effected\n\t\t\t * will pass through to the output.\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.wet = this._dryWet.fade;\n\t /**\n\t\t\t * then split it\n\t\t\t * @type {Tone.Split}\n\t\t\t * @private\n\t\t\t */\n\t this._split = new Tone.Split();\n\t /**\n\t\t\t * the effects send LEFT\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this.effectSendL = this._split.left;\n\t /**\n\t\t\t * the effects send RIGHT\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this.effectSendR = this._split.right;\n\t /**\n\t\t\t * the stereo effect merger\n\t\t\t * @type {Tone.Merge}\n\t\t\t * @private\n\t\t\t */\n\t this._merge = new Tone.Merge();\n\t /**\n\t\t\t * the effect return LEFT\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this.effectReturnL = this._merge.left;\n\t /**\n\t\t\t * the effect return RIGHT\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this.effectReturnR = this._merge.right;\n\t //connections\n\t this.input.connect(this._split);\n\t //dry wet connections\n\t this.input.connect(this._dryWet, 0, 0);\n\t this._merge.connect(this._dryWet, 0, 1);\n\t this._dryWet.connect(this.output);\n\t this._readOnly(['wet']);\n\t };\n\t Tone.extend(Tone.StereoEffect, Tone.Effect);\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.StereoEffect} this\n\t\t */\n\t Tone.StereoEffect.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._dryWet.dispose();\n\t this._dryWet = null;\n\t this._split.dispose();\n\t this._split = null;\n\t this._merge.dispose();\n\t this._merge = null;\n\t this.effectSendL = null;\n\t this.effectSendR = null;\n\t this.effectReturnL = null;\n\t this.effectReturnR = null;\n\t this._writable(['wet']);\n\t this.wet = null;\n\t return this;\n\t };\n\t return Tone.StereoEffect;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Chorus is a stereo chorus effect composed of\n\t\t * a left and right delay with a Tone.LFO applied to the delayTime of each channel.\n\t\t * Inspiration from [Tuna.js](https://github.com/Dinahmoe/tuna/blob/master/tuna.js).\n\t\t * Read more on the chorus effect on [SoundOnSound](http://www.soundonsound.com/sos/jun04/articles/synthsecrets.htm).\n\t\t *\n\t\t *\t@constructor\n\t\t *\t@extends {Tone.StereoEffect}\n\t\t *\t@param {Frequency|Object} [frequency] The frequency of the LFO.\n\t\t *\t@param {Milliseconds} [delayTime] The delay of the chorus effect in ms.\n\t\t *\t@param {NormalRange} [depth] The depth of the chorus.\n\t\t *\t@example\n\t\t * var chorus = new Tone.Chorus(4, 2.5, 0.5);\n\t\t * var synth = new Tone.PolySynth(4, Tone.MonoSynth).connect(chorus);\n\t\t * synth.triggerAttackRelease([\"C3\",\"E3\",\"G3\"], \"8n\");\n\t\t */\n\t Tone.Chorus = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'delayTime',\n\t 'depth'\n\t ], Tone.Chorus);\n\t Tone.StereoEffect.call(this, options);\n\t /**\n\t\t\t * the depth of the chorus\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._depth = options.depth;\n\t /**\n\t\t\t * the delayTime\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._delayTime = options.delayTime / 1000;\n\t /**\n\t\t\t * the lfo which controls the delayTime\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._lfoL = new Tone.LFO({\n\t 'frequency': options.frequency,\n\t 'min': 0,\n\t 'max': 1\n\t });\n\t /**\n\t\t\t * another LFO for the right side with a 180 degree phase diff\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._lfoR = new Tone.LFO({\n\t 'frequency': options.frequency,\n\t 'min': 0,\n\t 'max': 1,\n\t 'phase': 180\n\t });\n\t /**\n\t\t\t * delay for left\n\t\t\t * @type {Tone.Delay}\n\t\t\t * @private\n\t\t\t */\n\t this._delayNodeL = new Tone.Delay();\n\t /**\n\t\t\t * delay for right\n\t\t\t * @type {Tone.Delay}\n\t\t\t * @private\n\t\t\t */\n\t this._delayNodeR = new Tone.Delay();\n\t /**\n\t\t\t * The frequency of the LFO which modulates the delayTime.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = this._lfoL.frequency;\n\t //connections\n\t this.effectSendL.chain(this._delayNodeL, this.effectReturnL);\n\t this.effectSendR.chain(this._delayNodeR, this.effectReturnR);\n\t //and pass through to make the detune apparent\n\t this.effectSendL.connect(this.effectReturnL);\n\t this.effectSendR.connect(this.effectReturnR);\n\t //lfo setup\n\t this._lfoL.connect(this._delayNodeL.delayTime);\n\t this._lfoR.connect(this._delayNodeR.delayTime);\n\t //start the lfo\n\t this._lfoL.start();\n\t this._lfoR.start();\n\t //have one LFO frequency control the other\n\t this._lfoL.frequency.connect(this._lfoR.frequency);\n\t //set the initial values\n\t this.depth = this._depth;\n\t this.frequency.value = options.frequency;\n\t this.type = options.type;\n\t this._readOnly(['frequency']);\n\t this.spread = options.spread;\n\t };\n\t Tone.extend(Tone.Chorus, Tone.StereoEffect);\n\t /**\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.Chorus.defaults = {\n\t 'frequency': 1.5,\n\t 'delayTime': 3.5,\n\t 'depth': 0.7,\n\t 'type': 'sine',\n\t 'spread': 180\n\t };\n\t /**\n\t\t * The depth of the effect. A depth of 1 makes the delayTime\n\t\t * modulate between 0 and 2*delayTime (centered around the delayTime).\n\t\t * @memberOf Tone.Chorus#\n\t\t * @type {NormalRange}\n\t\t * @name depth\n\t\t */\n\t Object.defineProperty(Tone.Chorus.prototype, 'depth', {\n\t get: function () {\n\t return this._depth;\n\t },\n\t set: function (depth) {\n\t this._depth = depth;\n\t var deviation = this._delayTime * depth;\n\t this._lfoL.min = Math.max(this._delayTime - deviation, 0);\n\t this._lfoL.max = this._delayTime + deviation;\n\t this._lfoR.min = Math.max(this._delayTime - deviation, 0);\n\t this._lfoR.max = this._delayTime + deviation;\n\t }\n\t });\n\t /**\n\t\t * The delayTime in milliseconds of the chorus. A larger delayTime\n\t\t * will give a more pronounced effect. Nominal range a delayTime\n\t\t * is between 2 and 20ms.\n\t\t * @memberOf Tone.Chorus#\n\t\t * @type {Milliseconds}\n\t\t * @name delayTime\n\t\t */\n\t Object.defineProperty(Tone.Chorus.prototype, 'delayTime', {\n\t get: function () {\n\t return this._delayTime * 1000;\n\t },\n\t set: function (delayTime) {\n\t this._delayTime = delayTime / 1000;\n\t this.depth = this._depth;\n\t }\n\t });\n\t /**\n\t\t * The oscillator type of the LFO.\n\t\t * @memberOf Tone.Chorus#\n\t\t * @type {string}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.Chorus.prototype, 'type', {\n\t get: function () {\n\t return this._lfoL.type;\n\t },\n\t set: function (type) {\n\t this._lfoL.type = type;\n\t this._lfoR.type = type;\n\t }\n\t });\n\t /**\n\t\t * Amount of stereo spread. When set to 0, both LFO's will be panned centrally.\n\t\t * When set to 180, LFO's will be panned hard left and right respectively.\n\t\t * @memberOf Tone.Chorus#\n\t\t * @type {Degrees}\n\t\t * @name spread\n\t\t */\n\t Object.defineProperty(Tone.Chorus.prototype, 'spread', {\n\t get: function () {\n\t return this._lfoR.phase - this._lfoL.phase;\n\t },\n\t set: function (spread) {\n\t this._lfoL.phase = 90 - spread / 2;\n\t this._lfoR.phase = spread / 2 + 90;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Chorus} this\n\t\t */\n\t Tone.Chorus.prototype.dispose = function () {\n\t Tone.StereoEffect.prototype.dispose.call(this);\n\t this._lfoL.dispose();\n\t this._lfoL = null;\n\t this._lfoR.dispose();\n\t this._lfoR = null;\n\t this._delayNodeL.dispose();\n\t this._delayNodeL = null;\n\t this._delayNodeR.dispose();\n\t this._delayNodeR = null;\n\t this._writable('frequency');\n\t this.frequency = null;\n\t return this;\n\t };\n\t return Tone.Chorus;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Convolver is a wrapper around the Native Web Audio\n\t\t * [ConvolverNode](http://webaudio.github.io/web-audio-api/#the-convolvernode-interface).\n\t\t * Convolution is useful for reverb and filter emulation. Read more about convolution reverb on\n\t\t * [Wikipedia](https://en.wikipedia.org/wiki/Convolution_reverb).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Effect}\n\t\t * @param {string|Tone.Buffer|Object} [url] The URL of the impulse response or the Tone.Buffer\n\t\t * contianing the impulse response.\n\t\t * @param {Function=} onload The callback to invoke when the url is loaded.\n\t\t * @example\n\t\t * //initializing the convolver with an impulse response\n\t\t * var convolver = new Tone.Convolver(\"./path/to/ir.wav\").toMaster();\n\t\t */\n\t Tone.Convolver = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'url',\n\t 'onload'\n\t ], Tone.Convolver);\n\t Tone.Effect.call(this, options);\n\t /**\n\t\t\t * convolver node\n\t\t\t * @type {ConvolverNode}\n\t\t\t * @private\n\t\t\t */\n\t this._convolver = this.context.createConvolver();\n\t /**\n\t\t\t * the convolution buffer\n\t\t\t * @type {Tone.Buffer}\n\t\t\t * @private\n\t\t\t */\n\t this._buffer = new Tone.Buffer(options.url, function (buffer) {\n\t this._convolver.buffer = buffer.get();\n\t options.onload();\n\t }.bind(this));\n\t this.connectEffect(this._convolver);\n\t };\n\t Tone.extend(Tone.Convolver, Tone.Effect);\n\t /**\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Convolver.defaults = { 'onload': Tone.noOp };\n\t /**\n\t\t * The convolver's buffer\n\t\t * @memberOf Tone.Convolver#\n\t\t * @type {AudioBuffer}\n\t\t * @name buffer\n\t\t */\n\t Object.defineProperty(Tone.Convolver.prototype, 'buffer', {\n\t get: function () {\n\t return this._buffer.get();\n\t },\n\t set: function (buffer) {\n\t this._buffer.set(buffer);\n\t this._convolver.buffer = this._buffer.get();\n\t }\n\t });\n\t /**\n\t\t * Load an impulse response url as an audio buffer.\n\t\t * Decodes the audio asynchronously and invokes\n\t\t * the callback once the audio buffer loads.\n\t\t * @param {string} url The url of the buffer to load.\n\t\t * filetype support depends on the\n\t\t * browser.\n\t\t * @param {function=} callback\n\t\t * @returns {Promise}\n\t\t */\n\t Tone.Convolver.prototype.load = function (url, callback) {\n\t return this._buffer.load(url, function (buff) {\n\t this.buffer = buff;\n\t if (callback) {\n\t callback();\n\t }\n\t }.bind(this));\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Convolver} this\n\t\t */\n\t Tone.Convolver.prototype.dispose = function () {\n\t Tone.Effect.prototype.dispose.call(this);\n\t this._convolver.disconnect();\n\t this._convolver = null;\n\t this._buffer.dispose();\n\t this._buffer = null;\n\t return this;\n\t };\n\t return Tone.Convolver;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Distortion is a simple distortion effect using Tone.WaveShaper.\n\t\t * Algorithm from [a stackoverflow answer](http://stackoverflow.com/a/22313408).\n\t\t *\n\t\t * @extends {Tone.Effect}\n\t\t * @constructor\n\t\t * @param {Number|Object} [distortion] The amount of distortion (nominal range of 0-1)\n\t\t * @example\n\t\t * var dist = new Tone.Distortion(0.8).toMaster();\n\t\t * var fm = new Tone.SimpleFM().connect(dist);\n\t\t * //this sounds good on bass notes\n\t\t * fm.triggerAttackRelease(\"A1\", \"8n\");\n\t\t */\n\t Tone.Distortion = function () {\n\t var options = Tone.defaults(arguments, ['distortion'], Tone.Distortion);\n\t Tone.Effect.call(this, options);\n\t /**\n\t\t\t * @type {Tone.WaveShaper}\n\t\t\t * @private\n\t\t\t */\n\t this._shaper = new Tone.WaveShaper(4096);\n\t /**\n\t\t\t * holds the distortion amount\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._distortion = options.distortion;\n\t this.connectEffect(this._shaper);\n\t this.distortion = options.distortion;\n\t this.oversample = options.oversample;\n\t };\n\t Tone.extend(Tone.Distortion, Tone.Effect);\n\t /**\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Distortion.defaults = {\n\t 'distortion': 0.4,\n\t 'oversample': 'none'\n\t };\n\t /**\n\t\t * The amount of distortion.\n\t\t * @memberOf Tone.Distortion#\n\t\t * @type {NormalRange}\n\t\t * @name distortion\n\t\t */\n\t Object.defineProperty(Tone.Distortion.prototype, 'distortion', {\n\t get: function () {\n\t return this._distortion;\n\t },\n\t set: function (amount) {\n\t this._distortion = amount;\n\t var k = amount * 100;\n\t var deg = Math.PI / 180;\n\t this._shaper.setMap(function (x) {\n\t if (Math.abs(x) < 0.001) {\n\t //should output 0 when input is 0\n\t return 0;\n\t } else {\n\t return (3 + k) * x * 20 * deg / (Math.PI + k * Math.abs(x));\n\t }\n\t });\n\t }\n\t });\n\t /**\n\t\t * The oversampling of the effect. Can either be \"none\", \"2x\" or \"4x\".\n\t\t * @memberOf Tone.Distortion#\n\t\t * @type {string}\n\t\t * @name oversample\n\t\t */\n\t Object.defineProperty(Tone.Distortion.prototype, 'oversample', {\n\t get: function () {\n\t return this._shaper.oversample;\n\t },\n\t set: function (oversampling) {\n\t this._shaper.oversample = oversampling;\n\t }\n\t });\n\t /**\n\t\t * Clean up. \n\t\t * @returns {Tone.Distortion} this\n\t\t */\n\t Tone.Distortion.prototype.dispose = function () {\n\t Tone.Effect.prototype.dispose.call(this);\n\t this._shaper.dispose();\n\t this._shaper = null;\n\t return this;\n\t };\n\t return Tone.Distortion;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * \t@class Tone.FeedbackEffect provides a loop between an \n\t\t * \t audio source and its own output. This is a base-class\n\t\t * \t for feedback effects. \n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Effect}\n\t\t * @param {NormalRange|Object} [feedback] The initial feedback value.\n\t\t */\n\t Tone.FeedbackEffect = function () {\n\t var options = Tone.defaults(arguments, ['feedback'], Tone.FeedbackEffect);\n\t Tone.Effect.call(this, options);\n\t /**\n\t\t\t * the gain which controls the feedback\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._feedbackGain = new Tone.Gain(options.feedback, Tone.Type.NormalRange);\n\t /**\n\t\t\t * The amount of signal which is fed back into the effect input. \n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.feedback = this._feedbackGain.gain;\n\t //the feedback loop\n\t this.effectReturn.chain(this._feedbackGain, this.effectSend);\n\t this._readOnly(['feedback']);\n\t };\n\t Tone.extend(Tone.FeedbackEffect, Tone.Effect);\n\t /**\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.FeedbackEffect.defaults = { 'feedback': 0.125 };\n\t /**\n\t\t * Clean up. \n\t\t * @returns {Tone.FeedbackEffect} this\n\t\t */\n\t Tone.FeedbackEffect.prototype.dispose = function () {\n\t Tone.Effect.prototype.dispose.call(this);\n\t this._writable(['feedback']);\n\t this._feedbackGain.dispose();\n\t this._feedbackGain = null;\n\t this.feedback = null;\n\t return this;\n\t };\n\t return Tone.FeedbackEffect;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.FeedbackDelay is a DelayNode in which part of output\n\t\t * signal is fed back into the delay.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.FeedbackEffect}\n\t\t * @param {Time|Object} [delayTime] The delay applied to the incoming signal.\n\t\t * @param {NormalRange=} feedback The amount of the effected signal which\n\t\t * is fed back through the delay.\n\t\t * @example\n\t\t * var feedbackDelay = new Tone.FeedbackDelay(\"8n\", 0.5).toMaster();\n\t\t * var tom = new Tone.DrumSynth({\n\t\t * \t\"octaves\" : 4,\n\t\t * \t\"pitchDecay\" : 0.1\n\t\t * }).connect(feedbackDelay);\n\t\t * tom.triggerAttackRelease(\"A2\",\"32n\");\n\t\t */\n\t Tone.FeedbackDelay = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'delayTime',\n\t 'feedback'\n\t ], Tone.FeedbackDelay);\n\t Tone.FeedbackEffect.call(this, options);\n\t /**\n\t\t\t * the delay node\n\t\t\t * @type {Tone.Delay}\n\t\t\t * @private\n\t\t\t */\n\t this._delayNode = new Tone.Delay(options.delayTime, options.maxDelay);\n\t /**\n\t\t\t * The delayTime of the DelayNode.\n\t\t\t * @type {Time}\n\t\t\t * @signal\n\t\t\t */\n\t this.delayTime = this._delayNode.delayTime;\n\t // connect it up\n\t this.connectEffect(this._delayNode);\n\t this._readOnly(['delayTime']);\n\t };\n\t Tone.extend(Tone.FeedbackDelay, Tone.FeedbackEffect);\n\t /**\n\t\t * The default values.\n\t\t * @const\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.FeedbackDelay.defaults = {\n\t 'delayTime': 0.25,\n\t 'maxDelay': 1\n\t };\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.FeedbackDelay} this\n\t\t */\n\t Tone.FeedbackDelay.prototype.dispose = function () {\n\t Tone.FeedbackEffect.prototype.dispose.call(this);\n\t this._delayNode.dispose();\n\t this._delayNode = null;\n\t this._writable(['delayTime']);\n\t this.delayTime = null;\n\t return this;\n\t };\n\t return Tone.FeedbackDelay;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * an array of comb filter delay values from Freeverb implementation\n\t\t * @static\n\t\t * @private\n\t\t * @type {Array}\n\t\t */\n\t var combFilterTunings = [\n\t 1557 / 44100,\n\t 1617 / 44100,\n\t 1491 / 44100,\n\t 1422 / 44100,\n\t 1277 / 44100,\n\t 1356 / 44100,\n\t 1188 / 44100,\n\t 1116 / 44100\n\t ];\n\t /**\n\t\t * an array of allpass filter frequency values from Freeverb implementation\n\t\t * @private\n\t\t * @static\n\t\t * @type {Array}\n\t\t */\n\t var allpassFilterFrequencies = [\n\t 225,\n\t 556,\n\t 441,\n\t 341\n\t ];\n\t /**\n\t\t * @class Tone.Freeverb is a reverb based on [Freeverb](https://ccrma.stanford.edu/~jos/pasp/Freeverb.html).\n\t\t * Read more on reverb on [Sound On Sound](https://web.archive.org/web/20160404083902/http://www.soundonsound.com:80/sos/feb01/articles/synthsecrets.asp).\n\t\t *\n\t\t * @extends {Tone.Effect}\n\t\t * @constructor\n\t\t * @param {NormalRange|Object} [roomSize] Correlated to the decay time.\n\t\t * @param {Frequency} [dampening] The cutoff frequency of a lowpass filter as part\n\t\t * of the reverb.\n\t\t * @example\n\t\t * var freeverb = new Tone.Freeverb().toMaster();\n\t\t * freeverb.dampening.value = 1000;\n\t\t * //routing synth through the reverb\n\t\t * var synth = new Tone.AMSynth().connect(freeverb);\n\t\t */\n\t Tone.Freeverb = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'roomSize',\n\t 'dampening'\n\t ], Tone.Freeverb);\n\t Tone.StereoEffect.call(this, options);\n\t /**\n\t\t\t * The roomSize value between. A larger roomSize\n\t\t\t * will result in a longer decay.\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.roomSize = new Tone.Signal(options.roomSize, Tone.Type.NormalRange);\n\t /**\n\t\t\t * The amount of dampening of the reverberant signal.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.dampening = new Tone.Signal(options.dampening, Tone.Type.Frequency);\n\t /**\n\t\t\t * the comb filters\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._combFilters = [];\n\t /**\n\t\t\t * the allpass filters on the left\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._allpassFiltersL = [];\n\t /**\n\t\t\t * the allpass filters on the right\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._allpassFiltersR = [];\n\t //make the allpass filters on the right\n\t for (var l = 0; l < allpassFilterFrequencies.length; l++) {\n\t var allpassL = this.context.createBiquadFilter();\n\t allpassL.type = 'allpass';\n\t allpassL.frequency.value = allpassFilterFrequencies[l];\n\t this._allpassFiltersL.push(allpassL);\n\t }\n\t //make the allpass filters on the left\n\t for (var r = 0; r < allpassFilterFrequencies.length; r++) {\n\t var allpassR = this.context.createBiquadFilter();\n\t allpassR.type = 'allpass';\n\t allpassR.frequency.value = allpassFilterFrequencies[r];\n\t this._allpassFiltersR.push(allpassR);\n\t }\n\t //make the comb filters\n\t for (var c = 0; c < combFilterTunings.length; c++) {\n\t var lfpf = new Tone.LowpassCombFilter(combFilterTunings[c]);\n\t if (c < combFilterTunings.length / 2) {\n\t this.effectSendL.chain(lfpf, this._allpassFiltersL[0]);\n\t } else {\n\t this.effectSendR.chain(lfpf, this._allpassFiltersR[0]);\n\t }\n\t this.roomSize.connect(lfpf.resonance);\n\t this.dampening.connect(lfpf.dampening);\n\t this._combFilters.push(lfpf);\n\t }\n\t //chain the allpass filters togetehr\n\t Tone.connectSeries.apply(Tone, this._allpassFiltersL);\n\t Tone.connectSeries.apply(Tone, this._allpassFiltersR);\n\t this._allpassFiltersL[this._allpassFiltersL.length - 1].connect(this.effectReturnL);\n\t this._allpassFiltersR[this._allpassFiltersR.length - 1].connect(this.effectReturnR);\n\t this._readOnly([\n\t 'roomSize',\n\t 'dampening'\n\t ]);\n\t };\n\t Tone.extend(Tone.Freeverb, Tone.StereoEffect);\n\t /**\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.Freeverb.defaults = {\n\t 'roomSize': 0.7,\n\t 'dampening': 3000\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Freeverb} this\n\t\t */\n\t Tone.Freeverb.prototype.dispose = function () {\n\t Tone.StereoEffect.prototype.dispose.call(this);\n\t for (var al = 0; al < this._allpassFiltersL.length; al++) {\n\t this._allpassFiltersL[al].disconnect();\n\t this._allpassFiltersL[al] = null;\n\t }\n\t this._allpassFiltersL = null;\n\t for (var ar = 0; ar < this._allpassFiltersR.length; ar++) {\n\t this._allpassFiltersR[ar].disconnect();\n\t this._allpassFiltersR[ar] = null;\n\t }\n\t this._allpassFiltersR = null;\n\t for (var cf = 0; cf < this._combFilters.length; cf++) {\n\t this._combFilters[cf].dispose();\n\t this._combFilters[cf] = null;\n\t }\n\t this._combFilters = null;\n\t this._writable([\n\t 'roomSize',\n\t 'dampening'\n\t ]);\n\t this.roomSize.dispose();\n\t this.roomSize = null;\n\t this.dampening.dispose();\n\t this.dampening = null;\n\t return this;\n\t };\n\t return Tone.Freeverb;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * an array of the comb filter delay time values\n\t\t * @private\n\t\t * @static\n\t\t * @type {Array}\n\t\t */\n\t var combFilterDelayTimes = [\n\t 1687 / 25000,\n\t 1601 / 25000,\n\t 2053 / 25000,\n\t 2251 / 25000\n\t ];\n\t /**\n\t\t * the resonances of each of the comb filters\n\t\t * @private\n\t\t * @static\n\t\t * @type {Array}\n\t\t */\n\t var combFilterResonances = [\n\t 0.773,\n\t 0.802,\n\t 0.753,\n\t 0.733\n\t ];\n\t /**\n\t\t * the allpass filter frequencies\n\t\t * @private\n\t\t * @static\n\t\t * @type {Array}\n\t\t */\n\t var allpassFilterFreqs = [\n\t 347,\n\t 113,\n\t 37\n\t ];\n\t /**\n\t\t * @class Tone.JCReverb is a simple [Schroeder Reverberator](https://ccrma.stanford.edu/~jos/pasp/Schroeder_Reverberators.html)\n\t\t * tuned by John Chowning in 1970.\n\t\t * It is made up of three allpass filters and four Tone.FeedbackCombFilter.\n\t\t *\n\t\t *\n\t\t * @extends {Tone.Effect}\n\t\t * @constructor\n\t\t * @param {NormalRange|Object} [roomSize] Coorelates to the decay time.\n\t\t * @example\n\t\t * var reverb = new Tone.JCReverb(0.4).connect(Tone.Master);\n\t\t * var delay = new Tone.FeedbackDelay(0.5);\n\t\t * //connecting the synth to reverb through delay\n\t\t * var synth = new Tone.DuoSynth().chain(delay, reverb);\n\t\t * synth.triggerAttackRelease(\"A4\",\"8n\");\n\t\t */\n\t Tone.JCReverb = function () {\n\t var options = Tone.defaults(arguments, ['roomSize'], Tone.JCReverb);\n\t Tone.StereoEffect.call(this, options);\n\t /**\n\t\t\t * room size control values between [0,1]\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.roomSize = new Tone.Signal(options.roomSize, Tone.Type.NormalRange);\n\t /**\n\t\t\t * scale the room size\n\t\t\t * @type {Tone.Scale}\n\t\t\t * @private\n\t\t\t */\n\t this._scaleRoomSize = new Tone.Scale(-0.733, 0.197);\n\t /**\n\t\t\t * a series of allpass filters\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._allpassFilters = [];\n\t /**\n\t\t\t * parallel feedback comb filters\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._feedbackCombFilters = [];\n\t //make the allpass filters\n\t for (var af = 0; af < allpassFilterFreqs.length; af++) {\n\t var allpass = this.context.createBiquadFilter();\n\t allpass.type = 'allpass';\n\t allpass.frequency.value = allpassFilterFreqs[af];\n\t this._allpassFilters.push(allpass);\n\t }\n\t //and the comb filters\n\t for (var cf = 0; cf < combFilterDelayTimes.length; cf++) {\n\t var fbcf = new Tone.FeedbackCombFilter(combFilterDelayTimes[cf], 0.1);\n\t this._scaleRoomSize.connect(fbcf.resonance);\n\t fbcf.resonance.value = combFilterResonances[cf];\n\t this._allpassFilters[this._allpassFilters.length - 1].connect(fbcf);\n\t if (cf < combFilterDelayTimes.length / 2) {\n\t fbcf.connect(this.effectReturnL);\n\t } else {\n\t fbcf.connect(this.effectReturnR);\n\t }\n\t this._feedbackCombFilters.push(fbcf);\n\t }\n\t //chain the allpass filters together\n\t this.roomSize.connect(this._scaleRoomSize);\n\t Tone.connectSeries.apply(Tone, this._allpassFilters);\n\t this.effectSendL.connect(this._allpassFilters[0]);\n\t this.effectSendR.connect(this._allpassFilters[0]);\n\t this._readOnly(['roomSize']);\n\t };\n\t Tone.extend(Tone.JCReverb, Tone.StereoEffect);\n\t /**\n\t\t * the default values\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.JCReverb.defaults = { 'roomSize': 0.5 };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.JCReverb} this\n\t\t */\n\t Tone.JCReverb.prototype.dispose = function () {\n\t Tone.StereoEffect.prototype.dispose.call(this);\n\t for (var apf = 0; apf < this._allpassFilters.length; apf++) {\n\t this._allpassFilters[apf].disconnect();\n\t this._allpassFilters[apf] = null;\n\t }\n\t this._allpassFilters = null;\n\t for (var fbcf = 0; fbcf < this._feedbackCombFilters.length; fbcf++) {\n\t this._feedbackCombFilters[fbcf].dispose();\n\t this._feedbackCombFilters[fbcf] = null;\n\t }\n\t this._feedbackCombFilters = null;\n\t this._writable(['roomSize']);\n\t this.roomSize.dispose();\n\t this.roomSize = null;\n\t this._scaleRoomSize.dispose();\n\t this._scaleRoomSize = null;\n\t return this;\n\t };\n\t return Tone.JCReverb;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Mid/Side processing separates the the 'mid' signal\n\t\t * (which comes out of both the left and the right channel)\n\t\t * and the 'side' (which only comes out of the the side channels)\n\t\t * and effects them separately before being recombined.\n\t\t * Applies a Mid/Side seperation and recombination.\n\t\t * Algorithm found in [kvraudio forums](http://www.kvraudio.com/forum/viewtopic.php?t=212587).\n\t\t * <br><br>\n\t\t * This is a base-class for Mid/Side Effects.\n\t\t *\n\t\t * @extends {Tone.Effect}\n\t\t * @constructor\n\t\t */\n\t Tone.MidSideEffect = function () {\n\t Tone.Effect.apply(this, arguments);\n\t /**\n\t\t\t * The mid/side split\n\t\t\t * @type {Tone.MidSideSplit}\n\t\t\t * @private\n\t\t\t */\n\t this._midSideSplit = new Tone.MidSideSplit();\n\t /**\n\t\t\t * The mid/side merge\n\t\t\t * @type {Tone.MidSideMerge}\n\t\t\t * @private\n\t\t\t */\n\t this._midSideMerge = new Tone.MidSideMerge();\n\t /**\n\t\t\t * The mid send. Connect to mid processing\n\t\t\t * @type {Tone}\n\t\t\t * @private\n\t\t\t */\n\t this.midSend = this._midSideSplit.mid;\n\t /**\n\t\t\t * The side send. Connect to side processing\n\t\t\t * @type {Tone}\n\t\t\t * @private\n\t\t\t */\n\t this.sideSend = this._midSideSplit.side;\n\t /**\n\t\t\t * The mid return connection\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this.midReturn = this._midSideMerge.mid;\n\t /**\n\t\t\t * The side return connection\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this.sideReturn = this._midSideMerge.side;\n\t //the connections\n\t this.effectSend.connect(this._midSideSplit);\n\t this._midSideMerge.connect(this.effectReturn);\n\t };\n\t Tone.extend(Tone.MidSideEffect, Tone.Effect);\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.MidSideEffect} this\n\t\t */\n\t Tone.MidSideEffect.prototype.dispose = function () {\n\t Tone.Effect.prototype.dispose.call(this);\n\t this._midSideSplit.dispose();\n\t this._midSideSplit = null;\n\t this._midSideMerge.dispose();\n\t this._midSideMerge = null;\n\t this.midSend = null;\n\t this.sideSend = null;\n\t this.midReturn = null;\n\t this.sideReturn = null;\n\t return this;\n\t };\n\t return Tone.MidSideEffect;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Phaser is a phaser effect. Phasers work by changing the phase\n\t\t * of different frequency components of an incoming signal. Read more on\n\t\t * [Wikipedia](https://en.wikipedia.org/wiki/Phaser_(effect)).\n\t\t * Inspiration for this phaser comes from [Tuna.js](https://github.com/Dinahmoe/tuna/).\n\t\t *\n\t\t *\t@extends {Tone.StereoEffect}\n\t\t *\t@constructor\n\t\t *\t@param {Frequency|Object} [frequency] The speed of the phasing.\n\t\t *\t@param {number} [octaves] The octaves of the effect.\n\t\t *\t@param {Frequency} [baseFrequency] The base frequency of the filters.\n\t\t *\t@example\n\t\t * var phaser = new Tone.Phaser({\n\t\t * \t\"frequency\" : 15,\n\t\t * \t\"octaves\" : 5,\n\t\t * \t\"baseFrequency\" : 1000\n\t\t * }).toMaster();\n\t\t * var synth = new Tone.FMSynth().connect(phaser);\n\t\t * synth.triggerAttackRelease(\"E3\", \"2n\");\n\t\t */\n\t Tone.Phaser = function () {\n\t //set the defaults\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'octaves',\n\t 'baseFrequency'\n\t ], Tone.Phaser);\n\t Tone.StereoEffect.call(this, options);\n\t /**\n\t\t\t * the lfo which controls the frequency on the left side\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._lfoL = new Tone.LFO(options.frequency, 0, 1);\n\t /**\n\t\t\t * the lfo which controls the frequency on the right side\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._lfoR = new Tone.LFO(options.frequency, 0, 1);\n\t this._lfoR.phase = 180;\n\t /**\n\t\t\t * the base modulation frequency\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._baseFrequency = options.baseFrequency;\n\t /**\n\t\t\t * the octaves of the phasing\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._octaves = options.octaves;\n\t /**\n\t\t\t * The quality factor of the filters\n\t\t\t * @type {Positive}\n\t\t\t * @signal\n\t\t\t */\n\t this.Q = new Tone.Signal(options.Q, Tone.Type.Positive);\n\t /**\n\t\t\t * the array of filters for the left side\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._filtersL = this._makeFilters(options.stages, this._lfoL, this.Q);\n\t /**\n\t\t\t * the array of filters for the left side\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._filtersR = this._makeFilters(options.stages, this._lfoR, this.Q);\n\t /**\n\t\t\t * the frequency of the effect\n\t\t\t * @type {Tone.Signal}\n\t\t\t */\n\t this.frequency = this._lfoL.frequency;\n\t this.frequency.value = options.frequency;\n\t //connect them up\n\t this.effectSendL.connect(this._filtersL[0]);\n\t this.effectSendR.connect(this._filtersR[0]);\n\t this._filtersL[options.stages - 1].connect(this.effectReturnL);\n\t this._filtersR[options.stages - 1].connect(this.effectReturnR);\n\t //control the frequency with one LFO\n\t this._lfoL.frequency.connect(this._lfoR.frequency);\n\t //set the options\n\t this.baseFrequency = options.baseFrequency;\n\t this.octaves = options.octaves;\n\t //start the lfo\n\t this._lfoL.start();\n\t this._lfoR.start();\n\t this._readOnly([\n\t 'frequency',\n\t 'Q'\n\t ]);\n\t };\n\t Tone.extend(Tone.Phaser, Tone.StereoEffect);\n\t /**\n\t\t * defaults\n\t\t * @static\n\t\t * @type {object}\n\t\t */\n\t Tone.Phaser.defaults = {\n\t 'frequency': 0.5,\n\t 'octaves': 3,\n\t 'stages': 10,\n\t 'Q': 10,\n\t 'baseFrequency': 350\n\t };\n\t /**\n\t\t * @param {number} stages\n\t\t * @returns {Array} the number of filters all connected together\n\t\t * @private\n\t\t */\n\t Tone.Phaser.prototype._makeFilters = function (stages, connectToFreq, Q) {\n\t var filters = new Array(stages);\n\t //make all the filters\n\t for (var i = 0; i < stages; i++) {\n\t var filter = this.context.createBiquadFilter();\n\t filter.type = 'allpass';\n\t Q.connect(filter.Q);\n\t connectToFreq.connect(filter.frequency);\n\t filters[i] = filter;\n\t }\n\t Tone.connectSeries.apply(Tone, filters);\n\t return filters;\n\t };\n\t /**\n\t\t * The number of octaves the phase goes above\n\t\t * the baseFrequency\n\t\t * @memberOf Tone.Phaser#\n\t\t * @type {Positive}\n\t\t * @name octaves\n\t\t */\n\t Object.defineProperty(Tone.Phaser.prototype, 'octaves', {\n\t get: function () {\n\t return this._octaves;\n\t },\n\t set: function (octaves) {\n\t this._octaves = octaves;\n\t var max = this._baseFrequency * Math.pow(2, octaves);\n\t this._lfoL.max = max;\n\t this._lfoR.max = max;\n\t }\n\t });\n\t /**\n\t\t * The the base frequency of the filters.\n\t\t * @memberOf Tone.Phaser#\n\t\t * @type {number}\n\t\t * @name baseFrequency\n\t\t */\n\t Object.defineProperty(Tone.Phaser.prototype, 'baseFrequency', {\n\t get: function () {\n\t return this._baseFrequency;\n\t },\n\t set: function (freq) {\n\t this._baseFrequency = freq;\n\t this._lfoL.min = freq;\n\t this._lfoR.min = freq;\n\t this.octaves = this._octaves;\n\t }\n\t });\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.Phaser} this\n\t\t */\n\t Tone.Phaser.prototype.dispose = function () {\n\t Tone.StereoEffect.prototype.dispose.call(this);\n\t this._writable([\n\t 'frequency',\n\t 'Q'\n\t ]);\n\t this.Q.dispose();\n\t this.Q = null;\n\t this._lfoL.dispose();\n\t this._lfoL = null;\n\t this._lfoR.dispose();\n\t this._lfoR = null;\n\t for (var i = 0; i < this._filtersL.length; i++) {\n\t this._filtersL[i].disconnect();\n\t this._filtersL[i] = null;\n\t }\n\t this._filtersL = null;\n\t for (var j = 0; j < this._filtersR.length; j++) {\n\t this._filtersR[j].disconnect();\n\t this._filtersR[j] = null;\n\t }\n\t this._filtersR = null;\n\t this.frequency = null;\n\t return this;\n\t };\n\t return Tone.Phaser;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Just like a stereo feedback effect, but the feedback is routed from left to right\n\t\t * and right to left instead of on the same channel.\n\t\t *\n\t\t *\t@constructor\n\t\t *\t@extends {Tone.StereoEffect}\n\t\t */\n\t Tone.StereoXFeedbackEffect = function () {\n\t var options = Tone.defaults(arguments, ['feedback'], Tone.FeedbackEffect);\n\t Tone.StereoEffect.call(this, options);\n\t /**\n\t\t\t * The amount of feedback from the output\n\t\t\t * back into the input of the effect (routed\n\t\t\t * across left and right channels).\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.feedback = new Tone.Signal(options.feedback, Tone.Type.NormalRange);\n\t /**\n\t\t\t * the left side feeback\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._feedbackLR = new Tone.Gain();\n\t /**\n\t\t\t * the right side feeback\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._feedbackRL = new Tone.Gain();\n\t //connect it up\n\t this.effectReturnL.chain(this._feedbackLR, this.effectSendR);\n\t this.effectReturnR.chain(this._feedbackRL, this.effectSendL);\n\t this.feedback.fan(this._feedbackLR.gain, this._feedbackRL.gain);\n\t this._readOnly(['feedback']);\n\t };\n\t Tone.extend(Tone.StereoXFeedbackEffect, Tone.StereoEffect);\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.StereoXFeedbackEffect} this\n\t\t */\n\t Tone.StereoXFeedbackEffect.prototype.dispose = function () {\n\t Tone.StereoEffect.prototype.dispose.call(this);\n\t this._writable(['feedback']);\n\t this.feedback.dispose();\n\t this.feedback = null;\n\t this._feedbackLR.dispose();\n\t this._feedbackLR = null;\n\t this._feedbackRL.dispose();\n\t this._feedbackRL = null;\n\t return this;\n\t };\n\t return Tone.StereoXFeedbackEffect;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.PingPongDelay is a feedback delay effect where the echo is heard\n\t\t * first in one channel and next in the opposite channel. In a stereo\n\t\t * system these are the right and left channels.\n\t\t * PingPongDelay in more simplified terms is two Tone.FeedbackDelays\n\t\t * with independent delay values. Each delay is routed to one channel\n\t\t * (left or right), and the channel triggered second will always\n\t\t * trigger at the same interval after the first.\n\t\t *\n\t\t * \t@constructor\n\t\t * \t@extends {Tone.StereoXFeedbackEffect}\n\t\t * @param {Time|Object} [delayTime] The delayTime between consecutive echos.\n\t\t * @param {NormalRange=} feedback The amount of the effected signal which\n\t\t * is fed back through the delay.\n\t\t * @example\n\t\t * var pingPong = new Tone.PingPongDelay(\"4n\", 0.2).toMaster();\n\t\t * var drum = new Tone.DrumSynth().connect(pingPong);\n\t\t * drum.triggerAttackRelease(\"C4\", \"32n\");\n\t\t */\n\t Tone.PingPongDelay = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'delayTime',\n\t 'feedback'\n\t ], Tone.PingPongDelay);\n\t Tone.StereoXFeedbackEffect.call(this, options);\n\t /**\n\t\t\t * the delay node on the left side\n\t\t\t * @type {Tone.Delay}\n\t\t\t * @private\n\t\t\t */\n\t this._leftDelay = new Tone.Delay(0, options.maxDelayTime);\n\t /**\n\t\t\t * the delay node on the right side\n\t\t\t * @type {Tone.Delay}\n\t\t\t * @private\n\t\t\t */\n\t this._rightDelay = new Tone.Delay(0, options.maxDelayTime);\n\t /**\n\t\t\t * the predelay on the right side\n\t\t\t * @type {Tone.Delay}\n\t\t\t * @private\n\t\t\t */\n\t this._rightPreDelay = new Tone.Delay(0, options.maxDelayTime);\n\t /**\n\t\t\t * the delay time signal\n\t\t\t * @type {Time}\n\t\t\t * @signal\n\t\t\t */\n\t this.delayTime = new Tone.Signal(options.delayTime, Tone.Type.Time);\n\t //connect it up\n\t this.effectSendL.chain(this._leftDelay, this.effectReturnL);\n\t this.effectSendR.chain(this._rightPreDelay, this._rightDelay, this.effectReturnR);\n\t this.delayTime.fan(this._leftDelay.delayTime, this._rightDelay.delayTime, this._rightPreDelay.delayTime);\n\t //rearranged the feedback to be after the rightPreDelay\n\t this._feedbackLR.disconnect();\n\t this._feedbackLR.connect(this._rightDelay);\n\t this._readOnly(['delayTime']);\n\t };\n\t Tone.extend(Tone.PingPongDelay, Tone.StereoXFeedbackEffect);\n\t /**\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.PingPongDelay.defaults = {\n\t 'delayTime': 0.25,\n\t 'maxDelayTime': 1\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.PingPongDelay} this\n\t\t */\n\t Tone.PingPongDelay.prototype.dispose = function () {\n\t Tone.StereoXFeedbackEffect.prototype.dispose.call(this);\n\t this._leftDelay.dispose();\n\t this._leftDelay = null;\n\t this._rightDelay.dispose();\n\t this._rightDelay = null;\n\t this._rightPreDelay.dispose();\n\t this._rightPreDelay = null;\n\t this._writable(['delayTime']);\n\t this.delayTime.dispose();\n\t this.delayTime = null;\n\t return this;\n\t };\n\t return Tone.PingPongDelay;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.PitchShift does near-realtime pitch shifting to the incoming signal.\n\t\t * The effect is achieved by speeding up or slowing down the delayTime\n\t\t * of a DelayNode using a sawtooth wave.\n\t\t * Algorithm found in [this pdf](http://dsp-book.narod.ru/soundproc.pdf).\n\t\t * Additional reference by [Miller Pucket](http://msp.ucsd.edu/techniques/v0.11/book-html/node115.html).\n\t\t *\n\t\t * @extends {Tone.FeedbackEffect}\n\t\t * @param {Interval=} pitch The interval to transpose the incoming signal by.\n\t\t */\n\t Tone.PitchShift = function () {\n\t var options = Tone.defaults(arguments, ['pitch'], Tone.PitchShift);\n\t Tone.FeedbackEffect.call(this, options);\n\t /**\n\t\t\t * The pitch signal\n\t\t\t * @type {Tone.Signal}\n\t\t\t * @private\n\t\t\t */\n\t this._frequency = new Tone.Signal(0);\n\t /**\n\t\t\t * Uses two DelayNodes to cover up the jump in\n\t\t\t * the sawtooth wave.\n\t\t\t * @type {DelayNode}\n\t\t\t * @private\n\t\t\t */\n\t this._delayA = new Tone.Delay(0, 1);\n\t /**\n\t\t\t * The first LFO.\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._lfoA = new Tone.LFO({\n\t 'min': 0,\n\t 'max': 0.1,\n\t 'type': 'sawtooth'\n\t }).connect(this._delayA.delayTime);\n\t /**\n\t\t\t * The second DelayNode\n\t\t\t * @type {DelayNode}\n\t\t\t * @private\n\t\t\t */\n\t this._delayB = new Tone.Delay(0, 1);\n\t /**\n\t\t\t * The first LFO.\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._lfoB = new Tone.LFO({\n\t 'min': 0,\n\t 'max': 0.1,\n\t 'type': 'sawtooth',\n\t 'phase': 180\n\t }).connect(this._delayB.delayTime);\n\t /**\n\t\t\t * Crossfade quickly between the two delay lines\n\t\t\t * to cover up the jump in the sawtooth wave\n\t\t\t * @type {Tone.CrossFade}\n\t\t\t * @private\n\t\t\t */\n\t this._crossFade = new Tone.CrossFade();\n\t /**\n\t\t\t * LFO which alternates between the two\n\t\t\t * delay lines to cover up the disparity in the\n\t\t\t * sawtooth wave.\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._crossFadeLFO = new Tone.LFO({\n\t 'min': 0,\n\t 'max': 1,\n\t 'type': 'triangle',\n\t 'phase': 90\n\t }).connect(this._crossFade.fade);\n\t /**\n\t\t\t * The delay node\n\t\t\t * @type {Tone.Delay}\n\t\t\t * @private\n\t\t\t */\n\t this._feedbackDelay = new Tone.Delay(options.delayTime);\n\t /**\n\t\t\t * The amount of delay on the input signal\n\t\t\t * @type {Time}\n\t\t\t * @signal\n\t\t\t */\n\t this.delayTime = this._feedbackDelay.delayTime;\n\t this._readOnly('delayTime');\n\t /**\n\t\t\t * Hold the current pitch\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._pitch = options.pitch;\n\t /**\n\t\t\t * Hold the current windowSize\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._windowSize = options.windowSize;\n\t //connect the two delay lines up\n\t this._delayA.connect(this._crossFade.a);\n\t this._delayB.connect(this._crossFade.b);\n\t //connect the frequency\n\t this._frequency.fan(this._lfoA.frequency, this._lfoB.frequency, this._crossFadeLFO.frequency);\n\t //route the input\n\t this.effectSend.fan(this._delayA, this._delayB);\n\t this._crossFade.chain(this._feedbackDelay, this.effectReturn);\n\t //start the LFOs at the same time\n\t var now = this.now();\n\t this._lfoA.start(now);\n\t this._lfoB.start(now);\n\t this._crossFadeLFO.start(now);\n\t //set the initial value\n\t this.windowSize = this._windowSize;\n\t };\n\t Tone.extend(Tone.PitchShift, Tone.FeedbackEffect);\n\t /**\n\t\t * default values\n\t\t * @static\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.PitchShift.defaults = {\n\t 'pitch': 0,\n\t 'windowSize': 0.1,\n\t 'delayTime': 0,\n\t 'feedback': 0\n\t };\n\t /**\n\t\t * Repitch the incoming signal by some interval (measured\n\t\t * in semi-tones).\n\t\t * @memberOf Tone.PitchShift#\n\t\t * @type {Interval}\n\t\t * @name pitch\n\t\t * @example\n\t\t * pitchShift.pitch = -12; //down one octave\n\t\t * pitchShift.pitch = 7; //up a fifth\n\t\t */\n\t Object.defineProperty(Tone.PitchShift.prototype, 'pitch', {\n\t get: function () {\n\t return this._pitch;\n\t },\n\t set: function (interval) {\n\t this._pitch = interval;\n\t var factor = 0;\n\t if (interval < 0) {\n\t this._lfoA.min = 0;\n\t this._lfoA.max = this._windowSize;\n\t this._lfoB.min = 0;\n\t this._lfoB.max = this._windowSize;\n\t factor = Tone.intervalToFrequencyRatio(interval - 1) + 1;\n\t } else {\n\t this._lfoA.min = this._windowSize;\n\t this._lfoA.max = 0;\n\t this._lfoB.min = this._windowSize;\n\t this._lfoB.max = 0;\n\t factor = Tone.intervalToFrequencyRatio(interval) - 1;\n\t }\n\t this._frequency.value = factor * (1.2 / this._windowSize);\n\t }\n\t });\n\t /**\n\t\t * The window size corresponds roughly to the sample length in a looping sampler.\n\t\t * Smaller values are desirable for a less noticeable delay time of the pitch shifted\n\t\t * signal, but larger values will result in smoother pitch shifting for larger intervals.\n\t\t * A nominal range of 0.03 to 0.1 is recommended.\n\t\t * @memberOf Tone.PitchShift#\n\t\t * @type {Time}\n\t\t * @name windowSize\n\t\t * @example\n\t\t * pitchShift.windowSize = 0.1;\n\t\t */\n\t Object.defineProperty(Tone.PitchShift.prototype, 'windowSize', {\n\t get: function () {\n\t return this._windowSize;\n\t },\n\t set: function (size) {\n\t this._windowSize = this.toSeconds(size);\n\t this.pitch = this._pitch;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.PitchShift} this\n\t\t */\n\t Tone.PitchShift.prototype.dispose = function () {\n\t Tone.FeedbackEffect.prototype.dispose.call(this);\n\t this._frequency.dispose();\n\t this._frequency = null;\n\t this._delayA.disconnect();\n\t this._delayA = null;\n\t this._delayB.disconnect();\n\t this._delayB = null;\n\t this._lfoA.dispose();\n\t this._lfoA = null;\n\t this._lfoB.dispose();\n\t this._lfoB = null;\n\t this._crossFade.dispose();\n\t this._crossFade = null;\n\t this._crossFadeLFO.dispose();\n\t this._crossFadeLFO = null;\n\t this._writable('delayTime');\n\t this._feedbackDelay.dispose();\n\t this._feedbackDelay = null;\n\t this.delayTime = null;\n\t return this;\n\t };\n\t return Tone.PitchShift;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Wrapper around the native BufferSourceNode.\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {AudioBuffer|Tone.Buffer} buffer The buffer to play\n\t\t * @param {Function} onload The callback to invoke when the\n\t\t * buffer is done playing.\n\t\t */\n\t Tone.BufferSource = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'buffer',\n\t 'onload'\n\t ], Tone.BufferSource);\n\t Tone.AudioNode.call(this, options);\n\t /**\n\t\t\t * The callback to invoke after the\n\t\t\t * buffer source is done playing.\n\t\t\t * @type {Function}\n\t\t\t */\n\t this.onended = options.onended;\n\t /**\n\t\t\t * The time that the buffer was started.\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._startTime = -1;\n\t /**\n\t\t\t * An additional flag if the actual BufferSourceNode\n\t\t\t * has been started. b/c stopping an unstarted buffer\n\t\t\t * will throw it into an invalid state\n\t\t\t * @type {Boolean}\n\t\t\t * @private\n\t\t\t */\n\t this._sourceStarted = false;\n\t /**\n\t\t\t * Flag if the source has already been stopped\n\t\t\t * @type {Boolean}\n\t\t\t * @private\n\t\t\t */\n\t this._sourceStopped = false;\n\t /**\n\t\t\t * The time that the buffer is scheduled to stop.\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._stopTime = -1;\n\t /**\n\t\t\t * The gain node which envelopes the BufferSource\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._gainNode = this.output = new Tone.Gain();\n\t /**\n\t\t\t * The buffer source\n\t\t\t * @type {AudioBufferSourceNode}\n\t\t\t * @private\n\t\t\t */\n\t this._source = this.context.createBufferSource();\n\t this._source.connect(this._gainNode);\n\t this._source.onended = this._onended.bind(this);\n\t /**\n\t\t\t * The private buffer instance\n\t\t\t * @type {Tone.Buffer}\n\t\t\t * @private\n\t\t\t */\n\t this._buffer = new Tone.Buffer(options.buffer, options.onload);\n\t /**\n\t\t\t * The playbackRate of the buffer\n\t\t\t * @type {Positive}\n\t\t\t * @signal\n\t\t\t */\n\t this.playbackRate = new Tone.Param(this._source.playbackRate, Tone.Type.Positive);\n\t /**\n\t\t\t * The fadeIn time of the amplitude envelope.\n\t\t\t * @type {Time}\n\t\t\t */\n\t this.fadeIn = options.fadeIn;\n\t /**\n\t\t\t * The fadeOut time of the amplitude envelope.\n\t\t\t * @type {Time}\n\t\t\t */\n\t this.fadeOut = options.fadeOut;\n\t /**\n\t\t\t * The curve applied to the fades, either \"linear\" or \"exponential\"\n\t\t\t * @type {String}\n\t\t\t */\n\t this.curve = options.curve;\n\t /**\n\t\t\t * The value that the buffer ramps to\n\t\t\t * @type {Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._gain = 1;\n\t /**\n\t\t\t * The onended timeout\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._onendedTimeout = -1;\n\t //set some values initially\n\t this.loop = options.loop;\n\t this.loopStart = options.loopStart;\n\t this.loopEnd = options.loopEnd;\n\t this.playbackRate.value = options.playbackRate;\n\t };\n\t Tone.extend(Tone.BufferSource, Tone.AudioNode);\n\t /**\n\t\t * The defaults\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.BufferSource.defaults = {\n\t 'onended': Tone.noOp,\n\t 'onload': Tone.noOp,\n\t 'loop': false,\n\t 'loopStart': 0,\n\t 'loopEnd': 0,\n\t 'fadeIn': 0,\n\t 'fadeOut': 0,\n\t 'curve': 'linear',\n\t 'playbackRate': 1\n\t };\n\t /**\n\t\t * Returns the playback state of the source, either \"started\" or \"stopped\".\n\t\t * @type {Tone.State}\n\t\t * @readOnly\n\t\t * @memberOf Tone.BufferSource#\n\t\t * @name state\n\t\t */\n\t Object.defineProperty(Tone.BufferSource.prototype, 'state', {\n\t get: function () {\n\t return this.getStateAtTime(this.now());\n\t }\n\t });\n\t /**\n\t\t * Get the playback state at the given time\n\t\t * @param {Time} time The time to test the state at\n\t\t * @return {Tone.State} The playback state. \n\t\t */\n\t Tone.BufferSource.prototype.getStateAtTime = function (time) {\n\t time = this.toSeconds(time);\n\t if (this._startTime !== -1 && time >= this._startTime && !this._sourceStopped) {\n\t return Tone.State.Started;\n\t } else {\n\t return Tone.State.Stopped;\n\t }\n\t };\n\t /**\n\t\t * Start the buffer\n\t\t * @param {Time} [startTime=now] When the player should start.\n\t\t * @param {Time} [offset=0] The offset from the beginning of the sample\n\t\t * to start at.\n\t\t * @param {Time=} duration How long the sample should play. If no duration\n\t\t * is given, it will default to the full length\n\t\t * of the sample (minus any offset)\n\t\t * @param {Gain} [gain=1] The gain to play the buffer back at.\n\t\t * @param {Time=} fadeInTime The optional fadeIn ramp time.\n\t\t * @return {Tone.BufferSource} this\n\t\t */\n\t Tone.BufferSource.prototype.start = function (time, offset, duration, gain, fadeInTime) {\n\t if (this._startTime !== -1) {\n\t throw new Error('Tone.BufferSource can only be started once.');\n\t }\n\t if (!this.buffer.loaded) {\n\t throw new Error('Tone.BufferSource: buffer is either not set or not loaded.');\n\t }\n\t time = this.toSeconds(time);\n\t //if it's a loop the default offset is the loopstart point\n\t if (this.loop) {\n\t offset = Tone.defaultArg(offset, this.loopStart);\n\t } else {\n\t //otherwise the default offset is 0\n\t offset = Tone.defaultArg(offset, 0);\n\t }\n\t offset = this.toSeconds(offset);\n\t gain = Tone.defaultArg(gain, 1);\n\t this._gain = gain;\n\t fadeInTime = this.toSeconds(Tone.defaultArg(fadeInTime, this.fadeIn));\n\t this.fadeIn = fadeInTime;\n\t if (fadeInTime > 0) {\n\t this._gainNode.gain.setValueAtTime(0, time);\n\t if (this.curve === 'linear') {\n\t this._gainNode.gain.linearRampToValueAtTime(this._gain, time + fadeInTime);\n\t } else {\n\t this._gainNode.gain.exponentialApproachValueAtTime(this._gain, time, fadeInTime);\n\t }\n\t } else {\n\t this._gainNode.gain.setValueAtTime(gain, time);\n\t }\n\t this._startTime = time;\n\t var computedDur = this.toSeconds(Tone.defaultArg(duration, this.buffer.duration - offset % this.buffer.duration));\n\t computedDur = Math.max(computedDur, 0);\n\t if (Tone.isDefined(duration)) {\n\t //clip the duration when not looping\n\t if (!this.loop) {\n\t computedDur = Math.min(computedDur, this.buffer.duration - offset % this.buffer.duration);\n\t }\n\t this.stop(time + computedDur, this.fadeOut);\n\t }\n\t //start the buffer source\n\t if (this.loop) {\n\t //modify the offset if it's greater than the loop time\n\t var loopEnd = this.loopEnd || this.buffer.duration;\n\t var loopStart = this.loopStart;\n\t var loopDuration = loopEnd - loopStart;\n\t //move the offset back\n\t if (offset >= loopEnd) {\n\t offset = (offset - loopStart) % loopDuration + loopStart;\n\t }\n\t }\n\t this._source.buffer = this.buffer.get();\n\t this._source.loopEnd = this.loopEnd || this.buffer.duration;\n\t if (offset < this.buffer.duration) {\n\t this._sourceStarted = true;\n\t this._source.start(time, offset);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Stop the buffer. Optionally add a ramp time to fade the\n\t\t * buffer out.\n\t\t * @param {Time=} time The time the buffer should stop.\n\t\t * @param {Time=} fadeOutTime How long the gain should fade out for\n\t\t * @return {Tone.BufferSource} this\n\t\t */\n\t Tone.BufferSource.prototype.stop = function (time, fadeOutTime) {\n\t if (!this.buffer.loaded) {\n\t throw new Error('Tone.BufferSource: buffer is either not set or not loaded.');\n\t }\n\t if (this._sourceStopped) {\n\t return;\n\t }\n\t time = this.toSeconds(time);\n\t //if the event has already been scheduled, clear it\n\t if (this._stopTime !== -1) {\n\t this.cancelStop();\n\t }\n\t //stop if it's schedule before the start time\n\t if (time <= this._startTime) {\n\t this._gainNode.gain.cancelScheduledValues(time);\n\t this._gainNode.gain.value = 0;\n\t return this;\n\t }\n\t time = Math.max(this._startTime + this.fadeIn + this.sampleTime, time);\n\t //cancel the previous curve\n\t this._gainNode.gain.cancelScheduledValues(time);\n\t this._stopTime = time;\n\t //the fadeOut time\n\t fadeOutTime = this.toSeconds(Tone.defaultArg(fadeOutTime, this.fadeOut));\n\t var heldDuration = time - this._startTime - this.fadeIn - this.sampleTime;\n\t if (!this.loop) {\n\t //make sure the fade does not go beyond the length of the buffer\n\t heldDuration = Math.min(heldDuration, this.buffer.duration);\n\t }\n\t fadeOutTime = Math.min(heldDuration, fadeOutTime);\n\t var startFade = time - fadeOutTime;\n\t if (fadeOutTime > this.sampleTime) {\n\t this._gainNode.gain.setValueAtTime(this._gain, startFade);\n\t if (this.curve === 'linear') {\n\t this._gainNode.gain.linearRampToValueAtTime(0, time);\n\t } else {\n\t this._gainNode.gain.exponentialApproachValueAtTime(0, startFade, fadeOutTime);\n\t }\n\t } else {\n\t this._gainNode.gain.setValueAtTime(0, time);\n\t }\n\t Tone.context.clearTimeout(this._onendedTimeout);\n\t this._onendedTimeout = Tone.context.setTimeout(this._onended.bind(this), this._stopTime - this.now());\n\t return this;\n\t };\n\t /**\n\t\t * Cancel a scheduled stop event\n\t\t * @return {Tone.BufferSource} this\n\t\t */\n\t Tone.BufferSource.prototype.cancelStop = function () {\n\t if (this._startTime !== -1 && !this._sourceStopped) {\n\t //cancel the stop envelope\n\t var fadeInTime = this.toSeconds(this.fadeIn);\n\t this._gainNode.gain.cancelScheduledValues(this._startTime + fadeInTime + this.sampleTime);\n\t this._gainNode.gain.setValueAtTime(1, Math.max(this.now(), this._startTime + fadeInTime + this.sampleTime));\n\t this.context.clearTimeout(this._onendedTimeout);\n\t this._stopTime = -1;\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Internal callback when the buffer is ended.\n\t\t * Invokes `onended` and disposes the node.\n\t\t * @private\n\t\t */\n\t Tone.BufferSource.prototype._onended = function () {\n\t if (!this._sourceStopped) {\n\t this._sourceStopped = true;\n\t //allow additional time for the exponential curve to fully decay\n\t var additionalTail = this.curve === 'exponential' ? this.fadeOut * 2 : 0;\n\t if (this._sourceStarted && this._stopTime !== -1) {\n\t this._source.stop(this._stopTime + additionalTail);\n\t }\n\t this.onended(this);\n\t }\n\t };\n\t /**\n\t\t * If loop is true, the loop will start at this position.\n\t\t * @memberOf Tone.BufferSource#\n\t\t * @type {Time}\n\t\t * @name loopStart\n\t\t */\n\t Object.defineProperty(Tone.BufferSource.prototype, 'loopStart', {\n\t get: function () {\n\t return this._source.loopStart;\n\t },\n\t set: function (loopStart) {\n\t this._source.loopStart = this.toSeconds(loopStart);\n\t }\n\t });\n\t /**\n\t\t * If loop is true, the loop will end at this position.\n\t\t * @memberOf Tone.BufferSource#\n\t\t * @type {Time}\n\t\t * @name loopEnd\n\t\t */\n\t Object.defineProperty(Tone.BufferSource.prototype, 'loopEnd', {\n\t get: function () {\n\t return this._source.loopEnd;\n\t },\n\t set: function (loopEnd) {\n\t this._source.loopEnd = this.toSeconds(loopEnd);\n\t }\n\t });\n\t /**\n\t\t * The audio buffer belonging to the player.\n\t\t * @memberOf Tone.BufferSource#\n\t\t * @type {Tone.Buffer}\n\t\t * @name buffer\n\t\t */\n\t Object.defineProperty(Tone.BufferSource.prototype, 'buffer', {\n\t get: function () {\n\t return this._buffer;\n\t },\n\t set: function (buffer) {\n\t this._buffer.set(buffer);\n\t }\n\t });\n\t /**\n\t\t * If the buffer should loop once it's over.\n\t\t * @memberOf Tone.BufferSource#\n\t\t * @type {Boolean}\n\t\t * @name loop\n\t\t */\n\t Object.defineProperty(Tone.BufferSource.prototype, 'loop', {\n\t get: function () {\n\t return this._source.loop;\n\t },\n\t set: function (loop) {\n\t this._source.loop = loop;\n\t this.cancelStop();\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.BufferSource} this\n\t\t */\n\t Tone.BufferSource.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this.onended = null;\n\t this._source.onended = null;\n\t this._source.disconnect();\n\t this._source = null;\n\t this._gainNode.dispose();\n\t this._gainNode = null;\n\t this._buffer.dispose();\n\t this._buffer = null;\n\t this._startTime = -1;\n\t this.playbackRate = null;\n\t Tone.context.clearTimeout(this._onendedTimeout);\n\t return this;\n\t };\n\t return Tone.BufferSource;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Noise is a noise generator. It uses looped noise buffers to save on performance.\n\t\t * Tone.Noise supports the noise types: \"pink\", \"white\", and \"brown\". Read more about\n\t\t * colors of noise on [Wikipedia](https://en.wikipedia.org/wiki/Colors_of_noise).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Source}\n\t\t * @param {string} type the noise type (white|pink|brown)\n\t\t * @example\n\t\t * //initialize the noise and start\n\t\t * var noise = new Tone.Noise(\"pink\").start();\n\t\t *\n\t\t * //make an autofilter to shape the noise\n\t\t * var autoFilter = new Tone.AutoFilter({\n\t\t * \t\"frequency\" : \"8m\",\n\t\t * \t\"min\" : 800,\n\t\t * \t\"max\" : 15000\n\t\t * }).connect(Tone.Master);\n\t\t *\n\t\t * //connect the noise\n\t\t * noise.connect(autoFilter);\n\t\t * //start the autofilter LFO\n\t\t * autoFilter.start()\n\t\t */\n\t Tone.Noise = function () {\n\t var options = Tone.defaults(arguments, ['type'], Tone.Noise);\n\t Tone.Source.call(this, options);\n\t /**\n\t\t\t * @private\n\t\t\t * @type {AudioBufferSourceNode}\n\t\t\t */\n\t this._source = null;\n\t /**\n\t\t\t * the buffer\n\t\t\t * @private\n\t\t\t * @type {AudioBuffer}\n\t\t\t */\n\t this._type = options.type;\n\t /**\n\t\t\t * The playback rate of the noise. Affects\n\t\t\t * the \"frequency\" of the noise.\n\t\t\t * @type {Positive}\n\t\t\t * @signal\n\t\t\t */\n\t this._playbackRate = options.playbackRate;\n\t };\n\t Tone.extend(Tone.Noise, Tone.Source);\n\t /**\n\t\t * the default parameters\n\t\t *\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Noise.defaults = {\n\t 'type': 'white',\n\t 'playbackRate': 1\n\t };\n\t /**\n\t\t * The type of the noise. Can be \"white\", \"brown\", or \"pink\".\n\t\t * @memberOf Tone.Noise#\n\t\t * @type {string}\n\t\t * @name type\n\t\t * @example\n\t\t * noise.type = \"white\";\n\t\t */\n\t Object.defineProperty(Tone.Noise.prototype, 'type', {\n\t get: function () {\n\t return this._type;\n\t },\n\t set: function (type) {\n\t if (this._type !== type) {\n\t if (type in _noiseBuffers) {\n\t this._type = type;\n\t //if it's playing, stop and restart it\n\t if (this.state === Tone.State.Started) {\n\t var now = this.now();\n\t this._stop(now);\n\t this._start(now);\n\t }\n\t } else {\n\t throw new TypeError('Tone.Noise: invalid type: ' + type);\n\t }\n\t }\n\t }\n\t });\n\t /**\n\t\t * The playback rate of the noise. Affects\n\t\t * the \"frequency\" of the noise.\n\t\t * @type {Positive}\n\t\t * @signal\n\t\t */\n\t Object.defineProperty(Tone.Noise.prototype, 'playbackRate', {\n\t get: function () {\n\t return this._playbackRate;\n\t },\n\t set: function (rate) {\n\t this._playbackRate = rate;\n\t if (this._source) {\n\t this._source.playbackRate.value = rate;\n\t }\n\t }\n\t });\n\t /**\n\t\t * internal start method\n\t\t *\n\t\t * @param {Time} time\n\t\t * @private\n\t\t */\n\t Tone.Noise.prototype._start = function (time) {\n\t var buffer = _noiseBuffers[this._type];\n\t this._source = new Tone.BufferSource(buffer).connect(this.output);\n\t this._source.loop = true;\n\t this._source.playbackRate.value = this._playbackRate;\n\t this._source.start(this.toSeconds(time), Math.random() * (buffer.duration - 0.001));\n\t };\n\t /**\n\t\t * internal stop method\n\t\t *\n\t\t * @param {Time} time\n\t\t * @private\n\t\t */\n\t Tone.Noise.prototype._stop = function (time) {\n\t if (this._source) {\n\t this._source.stop(this.toSeconds(time));\n\t this._source = null;\n\t }\n\t };\n\t /**\n\t\t * Restarts the noise.\n\t\t * @param {[type]} time [description]\n\t\t * @return {[type]} [description]\n\t\t */\n\t Tone.Noise.prototype.restart = function (time) {\n\t //TODO could be optimized by cancelling the buffer source 'stop'\n\t //stop and restart\n\t this._stop(time);\n\t this._start(time);\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Noise} this\n\t\t */\n\t Tone.Noise.prototype.dispose = function () {\n\t Tone.Source.prototype.dispose.call(this);\n\t if (this._source !== null) {\n\t this._source.disconnect();\n\t this._source = null;\n\t }\n\t this._buffer = null;\n\t return this;\n\t };\n\t ///////////////////////////////////////////////////////////////////////////\n\t // THE BUFFERS\n\t ///////////////////////////////////////////////////////////////////////////\n\t //Noise buffer stats\n\t var bufferLength = 44100 * 5;\n\t var channels = 2;\n\t /**\n\t\t *\tThe noise arrays. Generated on initialization.\n\t\t * borrowed heavily from https://github.com/zacharydenton/noise.js\n\t\t * (c) 2013 Zach Denton (MIT)\n\t\t * @static\n\t\t * @private\n\t\t * @type {Array}\n\t\t */\n\t var _noiseArrays = {\n\t 'pink': function () {\n\t var buffer = [];\n\t for (var channelNum = 0; channelNum < channels; channelNum++) {\n\t var channel = new Float32Array(bufferLength);\n\t buffer[channelNum] = channel;\n\t var b0, b1, b2, b3, b4, b5, b6;\n\t b0 = b1 = b2 = b3 = b4 = b5 = b6 = 0;\n\t for (var i = 0; i < bufferLength; i++) {\n\t var white = Math.random() * 2 - 1;\n\t b0 = 0.99886 * b0 + white * 0.0555179;\n\t b1 = 0.99332 * b1 + white * 0.0750759;\n\t b2 = 0.969 * b2 + white * 0.153852;\n\t b3 = 0.8665 * b3 + white * 0.3104856;\n\t b4 = 0.55 * b4 + white * 0.5329522;\n\t b5 = -0.7616 * b5 - white * 0.016898;\n\t channel[i] = b0 + b1 + b2 + b3 + b4 + b5 + b6 + white * 0.5362;\n\t channel[i] *= 0.11;\n\t // (roughly) compensate for gain\n\t b6 = white * 0.115926;\n\t }\n\t }\n\t return buffer;\n\t }(),\n\t 'brown': function () {\n\t var buffer = [];\n\t for (var channelNum = 0; channelNum < channels; channelNum++) {\n\t var channel = new Float32Array(bufferLength);\n\t buffer[channelNum] = channel;\n\t var lastOut = 0;\n\t for (var i = 0; i < bufferLength; i++) {\n\t var white = Math.random() * 2 - 1;\n\t channel[i] = (lastOut + 0.02 * white) / 1.02;\n\t lastOut = channel[i];\n\t channel[i] *= 3.5; // (roughly) compensate for gain\n\t }\n\t }\n\t return buffer;\n\t }(),\n\t 'white': function () {\n\t var buffer = [];\n\t for (var channelNum = 0; channelNum < channels; channelNum++) {\n\t var channel = new Float32Array(bufferLength);\n\t buffer[channelNum] = channel;\n\t for (var i = 0; i < bufferLength; i++) {\n\t channel[i] = Math.random() * 2 - 1;\n\t }\n\t }\n\t return buffer;\n\t }()\n\t };\n\t /**\n\t\t *\tstatic noise buffers\n\t\t * @static\n\t\t * @private\n\t\t * @type {Tone.Buffer}\n\t\t */\n\t var _noiseBuffers = {};\n\t //create the Tone.Buffers\n\t function createBuffers() {\n\t for (var type in _noiseArrays) {\n\t _noiseBuffers[type] = new Tone.Buffer().fromArray(_noiseArrays[type]);\n\t }\n\t }\n\t //create the noise buffers\n\t Tone.getContext(createBuffers);\n\t Tone.Context.on('init', createBuffers);\n\t return Tone.Noise;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Simple convolution created with decaying noise.\n\t\t * \t\tGenerates an Impulse Response Buffer\n\t\t * \t\t\twith Tone.Offline then feeds the IR into ConvolverNode.\n\t\t * \t\t\tNote: the Reverb will not make any sound until [generate](#generate)\n\t\t * \t\t\thas been invoked and resolved.\n\t\t *\n\t\t * \t\t\tInspiration from [ReverbGen](https://github.com/adelespinasse/reverbGen).\n\t\t * \t\t\tCopyright (c) 2014 Alan deLespinasse Apache 2.0 License.\n\t\t *\n\t\t * @extends {Tone.Convolver}\n\t\t * @param {Time=} decay The amount of time it will reverberate for.\n\t\t */\n\t Tone.Reverb = function () {\n\t var options = Tone.defaults(arguments, ['decay'], Tone.Reverb);\n\t Tone.Effect.call(this, options);\n\t /**\n\t\t\t * Convolver node\n\t\t\t * @type {ConvolverNode}\n\t\t\t * @private\n\t\t\t */\n\t this._convolver = this.context.createConvolver();\n\t /**\n\t\t\t * The duration of the reverb\n\t\t\t * @type {Time}\n\t\t\t */\n\t this.decay = options.decay;\n\t /**\n\t\t\t * The amount of time before the reverb is fully\n\t\t\t * ramped in.\n\t\t\t * @type {Time}\n\t\t\t */\n\t this.preDelay = options.preDelay;\n\t this.connectEffect(this._convolver);\n\t };\n\t Tone.extend(Tone.Reverb, Tone.Effect);\n\t /**\n\t\t * The defaults\n\t\t * @type {Object}\n\t\t * @static\n\t\t */\n\t Tone.Reverb.defaults = {\n\t 'decay': 1.5,\n\t 'preDelay': 0.01\n\t };\n\t /**\n\t\t * Generate the Impulse Response. Returns a promise while the IR is being\n\t\t * generated.\n\t\t * @return {Promise<Tone.Reverb>} Promise which returns this object.\n\t\t */\n\t Tone.Reverb.prototype.generate = function () {\n\t return Tone.Offline(function () {\n\t //create a noise burst which decays over the duration\n\t var noiseL = new Tone.Noise();\n\t var noiseR = new Tone.Noise();\n\t var merge = new Tone.Merge();\n\t noiseL.connect(merge.left);\n\t noiseR.connect(merge.right);\n\t var gainNode = new Tone.Gain().toMaster();\n\t merge.connect(gainNode);\n\t noiseL.start(0);\n\t noiseR.start(0);\n\t //short fade in\n\t gainNode.gain.setValueAtTime(0, 0);\n\t gainNode.gain.linearRampToValueAtTime(1, this.preDelay);\n\t //decay\n\t gainNode.gain.exponentialApproachValueAtTime(0, this.preDelay, this.decay - this.preDelay);\n\t }.bind(this), this.decay).then(function (buffer) {\n\t this._convolver.buffer = buffer.get();\n\t return this;\n\t }.bind(this));\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.Reverb} this\n\t\t */\n\t Tone.Reverb.prototype.dispose = function () {\n\t Tone.Effect.prototype.dispose.call(this);\n\t this._convolver.disconnect();\n\t this._convolver = null;\n\t return this;\n\t };\n\t return Tone.Reverb;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Base class for stereo feedback effects where the effectReturn\n\t\t * is fed back into the same channel.\n\t\t *\n\t\t *\t@constructor\n\t\t *\t@extends {Tone.StereoEffect}\n\t\t */\n\t Tone.StereoFeedbackEffect = function () {\n\t var options = Tone.defaults(arguments, ['feedback'], Tone.FeedbackEffect);\n\t Tone.StereoEffect.call(this, options);\n\t /**\n\t\t\t * controls the amount of feedback\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.feedback = new Tone.Signal(options.feedback, Tone.Type.NormalRange);\n\t /**\n\t\t\t * the left side feeback\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._feedbackL = new Tone.Gain();\n\t /**\n\t\t\t * the right side feeback\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._feedbackR = new Tone.Gain();\n\t //connect it up\n\t this.effectReturnL.chain(this._feedbackL, this.effectSendL);\n\t this.effectReturnR.chain(this._feedbackR, this.effectSendR);\n\t this.feedback.fan(this._feedbackL.gain, this._feedbackR.gain);\n\t this._readOnly(['feedback']);\n\t };\n\t Tone.extend(Tone.StereoFeedbackEffect, Tone.StereoEffect);\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.StereoFeedbackEffect} this\n\t\t */\n\t Tone.StereoFeedbackEffect.prototype.dispose = function () {\n\t Tone.StereoEffect.prototype.dispose.call(this);\n\t this._writable(['feedback']);\n\t this.feedback.dispose();\n\t this.feedback = null;\n\t this._feedbackL.dispose();\n\t this._feedbackL = null;\n\t this._feedbackR.dispose();\n\t this._feedbackR = null;\n\t return this;\n\t };\n\t return Tone.StereoFeedbackEffect;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Applies a width factor to the mid/side seperation.\n\t\t * 0 is all mid and 1 is all side.\n\t\t * Algorithm found in [kvraudio forums](http://www.kvraudio.com/forum/viewtopic.php?t=212587).\n\t\t * <br><br>\n\t\t * <code>\n\t\t * Mid *= 2*(1-width)<br>\n\t\t * Side *= 2*width\n\t\t * </code>\n\t\t *\n\t\t * @extends {Tone.MidSideEffect}\n\t\t * @constructor\n\t\t * @param {NormalRange|Object} [width] The stereo width. A width of 0 is mono and 1 is stereo. 0.5 is no change.\n\t\t */\n\t Tone.StereoWidener = function () {\n\t var options = Tone.defaults(arguments, ['width'], Tone.StereoWidener);\n\t Tone.MidSideEffect.call(this, options);\n\t /**\n\t\t\t * The width control. 0 = 100% mid. 1 = 100% side. 0.5 = no change.\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.width = new Tone.Signal(options.width, Tone.Type.NormalRange);\n\t this._readOnly(['width']);\n\t /**\n\t\t\t * Two times the (1-width) for the mid channel\n\t\t\t * @type {Tone.Multiply}\n\t\t\t * @private\n\t\t\t */\n\t this._twoTimesWidthMid = new Tone.Multiply(2);\n\t /**\n\t\t\t * Two times the width for the side channel\n\t\t\t * @type {Tone.Multiply}\n\t\t\t * @private\n\t\t\t */\n\t this._twoTimesWidthSide = new Tone.Multiply(2);\n\t /**\n\t\t\t * Mid multiplier\n\t\t\t * @type {Tone.Multiply}\n\t\t\t * @private\n\t\t\t */\n\t this._midMult = new Tone.Multiply();\n\t this._twoTimesWidthMid.connect(this._midMult, 0, 1);\n\t this.midSend.chain(this._midMult, this.midReturn);\n\t /**\n\t\t\t * 1 - width\n\t\t\t * @type {Tone}\n\t\t\t */\n\t this._oneMinusWidth = new Tone.Subtract();\n\t this._oneMinusWidth.connect(this._twoTimesWidthMid);\n\t this.context.getConstant(1).connect(this._oneMinusWidth, 0, 0);\n\t this.width.connect(this._oneMinusWidth, 0, 1);\n\t /**\n\t\t\t * Side multiplier\n\t\t\t * @type {Tone.Multiply}\n\t\t\t * @private\n\t\t\t */\n\t this._sideMult = new Tone.Multiply();\n\t this.width.connect(this._twoTimesWidthSide);\n\t this._twoTimesWidthSide.connect(this._sideMult, 0, 1);\n\t this.sideSend.chain(this._sideMult, this.sideReturn);\n\t };\n\t Tone.extend(Tone.StereoWidener, Tone.MidSideEffect);\n\t /**\n\t\t * the default values\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.StereoWidener.defaults = { 'width': 0.5 };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.StereoWidener} this\n\t\t */\n\t Tone.StereoWidener.prototype.dispose = function () {\n\t Tone.MidSideEffect.prototype.dispose.call(this);\n\t this._writable(['width']);\n\t this.width.dispose();\n\t this.width = null;\n\t this._midMult.dispose();\n\t this._midMult = null;\n\t this._sideMult.dispose();\n\t this._sideMult = null;\n\t this._twoTimesWidthMid.dispose();\n\t this._twoTimesWidthMid = null;\n\t this._twoTimesWidthSide.dispose();\n\t this._twoTimesWidthSide = null;\n\t this._oneMinusWidth.dispose();\n\t this._oneMinusWidth = null;\n\t return this;\n\t };\n\t return Tone.StereoWidener;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Tremolo modulates the amplitude of an incoming signal using a Tone.LFO.\n\t\t * The type, frequency, and depth of the LFO is controllable.\n\t\t *\n\t\t * @extends {Tone.StereoEffect}\n\t\t * @constructor\n\t\t * @param {Frequency} [frequency] The rate of the effect.\n\t\t * @param {NormalRange} [depth] The depth of the effect.\n\t\t * @example\n\t\t * //create a tremolo and start it's LFO\n\t\t * var tremolo = new Tone.Tremolo(9, 0.75).toMaster().start();\n\t\t * //route an oscillator through the tremolo and start it\n\t\t * var oscillator = new Tone.Oscillator().connect(tremolo).start();\n\t\t */\n\t Tone.Tremolo = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'depth'\n\t ], Tone.Tremolo);\n\t Tone.StereoEffect.call(this, options);\n\t /**\n\t\t\t * The tremelo LFO in the left channel\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._lfoL = new Tone.LFO({\n\t 'phase': options.spread,\n\t 'min': 1,\n\t 'max': 0\n\t });\n\t /**\n\t\t\t * The tremelo LFO in the left channel\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._lfoR = new Tone.LFO({\n\t 'phase': options.spread,\n\t 'min': 1,\n\t 'max': 0\n\t });\n\t /**\n\t\t\t * Where the gain is multiplied\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._amplitudeL = new Tone.Gain();\n\t /**\n\t\t\t * Where the gain is multiplied\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._amplitudeR = new Tone.Gain();\n\t /**\n\t\t\t * The frequency of the tremolo.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency);\n\t /**\n\t\t\t * The depth of the effect. A depth of 0, has no effect\n\t\t\t * on the amplitude, and a depth of 1 makes the amplitude\n\t\t\t * modulate fully between 0 and 1.\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.depth = new Tone.Signal(options.depth, Tone.Type.NormalRange);\n\t this._readOnly([\n\t 'frequency',\n\t 'depth'\n\t ]);\n\t this.effectSendL.chain(this._amplitudeL, this.effectReturnL);\n\t this.effectSendR.chain(this._amplitudeR, this.effectReturnR);\n\t this._lfoL.connect(this._amplitudeL.gain);\n\t this._lfoR.connect(this._amplitudeR.gain);\n\t this.frequency.fan(this._lfoL.frequency, this._lfoR.frequency);\n\t this.depth.fan(this._lfoR.amplitude, this._lfoL.amplitude);\n\t this.type = options.type;\n\t this.spread = options.spread;\n\t };\n\t Tone.extend(Tone.Tremolo, Tone.StereoEffect);\n\t /**\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Tremolo.defaults = {\n\t 'frequency': 10,\n\t 'type': 'sine',\n\t 'depth': 0.5,\n\t 'spread': 180\n\t };\n\t /**\n\t\t * Start the tremolo.\n\t\t * @param {Time} [time=now] When the tremolo begins.\n\t\t * @returns {Tone.Tremolo} this\n\t\t */\n\t Tone.Tremolo.prototype.start = function (time) {\n\t this._lfoL.start(time);\n\t this._lfoR.start(time);\n\t return this;\n\t };\n\t /**\n\t\t * Stop the tremolo.\n\t\t * @param {Time} [time=now] When the tremolo stops.\n\t\t * @returns {Tone.Tremolo} this\n\t\t */\n\t Tone.Tremolo.prototype.stop = function (time) {\n\t this._lfoL.stop(time);\n\t this._lfoR.stop(time);\n\t return this;\n\t };\n\t /**\n\t\t * Sync the effect to the transport.\n\t\t * @param {Time} [delay=0] Delay time before starting the effect after the\n\t\t * Transport has started.\n\t\t * @returns {Tone.AutoFilter} this\n\t\t */\n\t Tone.Tremolo.prototype.sync = function (delay) {\n\t this._lfoL.sync(delay);\n\t this._lfoR.sync(delay);\n\t Tone.Transport.syncSignal(this.frequency);\n\t return this;\n\t };\n\t /**\n\t\t * Unsync the filter from the transport\n\t\t * @returns {Tone.Tremolo} this\n\t\t */\n\t Tone.Tremolo.prototype.unsync = function () {\n\t this._lfoL.unsync();\n\t this._lfoR.unsync();\n\t Tone.Transport.unsyncSignal(this.frequency);\n\t return this;\n\t };\n\t /**\n\t\t * The Tremolo's oscillator type.\n\t\t * @memberOf Tone.Tremolo#\n\t\t * @type {string}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.Tremolo.prototype, 'type', {\n\t get: function () {\n\t return this._lfoL.type;\n\t },\n\t set: function (type) {\n\t this._lfoL.type = type;\n\t this._lfoR.type = type;\n\t }\n\t });\n\t /**\n\t\t * Amount of stereo spread. When set to 0, both LFO's will be panned centrally.\n\t\t * When set to 180, LFO's will be panned hard left and right respectively.\n\t\t * @memberOf Tone.Tremolo#\n\t\t * @type {Degrees}\n\t\t * @name spread\n\t\t */\n\t Object.defineProperty(Tone.Tremolo.prototype, 'spread', {\n\t get: function () {\n\t return this._lfoR.phase - this._lfoL.phase; //180\n\t },\n\t set: function (spread) {\n\t this._lfoL.phase = 90 - spread / 2;\n\t this._lfoR.phase = spread / 2 + 90;\n\t }\n\t });\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.Tremolo} this\n\t\t */\n\t Tone.Tremolo.prototype.dispose = function () {\n\t Tone.StereoEffect.prototype.dispose.call(this);\n\t this._writable([\n\t 'frequency',\n\t 'depth'\n\t ]);\n\t this._lfoL.dispose();\n\t this._lfoL = null;\n\t this._lfoR.dispose();\n\t this._lfoR = null;\n\t this._amplitudeL.dispose();\n\t this._amplitudeL = null;\n\t this._amplitudeR.dispose();\n\t this._amplitudeR = null;\n\t this.frequency = null;\n\t this.depth = null;\n\t return this;\n\t };\n\t return Tone.Tremolo;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class A Vibrato effect composed of a Tone.Delay and a Tone.LFO. The LFO\n\t\t * modulates the delayTime of the delay, causing the pitch to rise\n\t\t * and fall. \n\t\t * @extends {Tone.Effect}\n\t\t * @param {Frequency} frequency The frequency of the vibrato.\n\t\t * @param {NormalRange} depth The amount the pitch is modulated.\n\t\t */\n\t Tone.Vibrato = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'depth'\n\t ], Tone.Vibrato);\n\t Tone.Effect.call(this, options);\n\t /**\n\t\t\t * The delay node used for the vibrato effect\n\t\t\t * @type {Tone.Delay}\n\t\t\t * @private\n\t\t\t */\n\t this._delayNode = new Tone.Delay(0, options.maxDelay);\n\t /**\n\t\t\t * The LFO used to control the vibrato\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._lfo = new Tone.LFO({\n\t 'type': options.type,\n\t 'min': 0,\n\t 'max': options.maxDelay,\n\t 'frequency': options.frequency,\n\t 'phase': -90 //offse the phase so the resting position is in the center\n\t }).start().connect(this._delayNode.delayTime);\n\t /**\n\t\t\t * The frequency of the vibrato\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = this._lfo.frequency;\n\t /**\n\t\t\t * The depth of the vibrato. \n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.depth = this._lfo.amplitude;\n\t this.depth.value = options.depth;\n\t this._readOnly([\n\t 'frequency',\n\t 'depth'\n\t ]);\n\t this.effectSend.chain(this._delayNode, this.effectReturn);\n\t };\n\t Tone.extend(Tone.Vibrato, Tone.Effect);\n\t /**\n\t\t * The defaults\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.Vibrato.defaults = {\n\t 'maxDelay': 0.005,\n\t 'frequency': 5,\n\t 'depth': 0.1,\n\t 'type': 'sine'\n\t };\n\t /**\n\t\t * Type of oscillator attached to the Vibrato.\n\t\t * @memberOf Tone.Vibrato#\n\t\t * @type {string}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.Vibrato.prototype, 'type', {\n\t get: function () {\n\t return this._lfo.type;\n\t },\n\t set: function (type) {\n\t this._lfo.type = type;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.Vibrato} this\n\t\t */\n\t Tone.Vibrato.prototype.dispose = function () {\n\t Tone.Effect.prototype.dispose.call(this);\n\t this._delayNode.dispose();\n\t this._delayNode = null;\n\t this._lfo.dispose();\n\t this._lfo = null;\n\t this._writable([\n\t 'frequency',\n\t 'depth'\n\t ]);\n\t this.frequency = null;\n\t this.depth = null;\n\t };\n\t return Tone.Vibrato;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Event abstracts away Tone.Transport.schedule and provides a schedulable\n\t\t * callback for a single or repeatable events along the timeline.\n\t\t *\n\t\t * @extends {Tone}\n\t\t * @param {function} callback The callback to invoke at the time.\n\t\t * @param {*} value The value or values which should be passed to\n\t\t * the callback function on invocation.\n\t\t * @example\n\t\t * var chord = new Tone.Event(function(time, chord){\n\t\t * \t//the chord as well as the exact time of the event\n\t\t * \t//are passed in as arguments to the callback function\n\t\t * }, [\"D4\", \"E4\", \"F4\"]);\n\t\t * //start the chord at the beginning of the transport timeline\n\t\t * chord.start();\n\t\t * //loop it every measure for 8 measures\n\t\t * chord.loop = 8;\n\t\t * chord.loopEnd = \"1m\";\n\t\t */\n\t Tone.Event = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'callback',\n\t 'value'\n\t ], Tone.Event);\n\t Tone.call(this);\n\t /**\n\t\t\t * Loop value\n\t\t\t * @type {Boolean|Positive}\n\t\t\t * @private\n\t\t\t */\n\t this._loop = options.loop;\n\t /**\n\t\t\t * The callback to invoke.\n\t\t\t * @type {Function}\n\t\t\t */\n\t this.callback = options.callback;\n\t /**\n\t\t\t * The value which is passed to the\n\t\t\t * callback function.\n\t\t\t * @type {*}\n\t\t\t * @private\n\t\t\t */\n\t this.value = options.value;\n\t /**\n\t\t\t * When the note is scheduled to start.\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._loopStart = this.toTicks(options.loopStart);\n\t /**\n\t\t\t * When the note is scheduled to start.\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._loopEnd = this.toTicks(options.loopEnd);\n\t /**\n\t\t\t * Tracks the scheduled events\n\t\t\t * @type {Tone.TimelineState}\n\t\t\t * @private\n\t\t\t */\n\t this._state = new Tone.TimelineState(Tone.State.Stopped);\n\t /**\n\t\t\t * The playback speed of the note. A speed of 1\n\t\t\t * is no change.\n\t\t\t * @private\n\t\t\t * @type {Positive}\n\t\t\t */\n\t this._playbackRate = 1;\n\t /**\n\t\t\t * A delay time from when the event is scheduled to start\n\t\t\t * @type {Ticks}\n\t\t\t * @private\n\t\t\t */\n\t this._startOffset = 0;\n\t /**\n\t\t\t * private holder of probability value\n\t\t\t * @type {NormalRange}\n\t\t\t * @private\n\t\t\t */\n\t this._probability = options.probability;\n\t /**\n\t\t\t * the amount of variation from the\n\t\t\t * given time.\n\t\t\t * @type {Boolean|Time}\n\t\t\t * @private\n\t\t\t */\n\t this._humanize = options.humanize;\n\t /**\n\t\t\t * If mute is true, the callback won't be\n\t\t\t * invoked.\n\t\t\t * @type {Boolean}\n\t\t\t */\n\t this.mute = options.mute;\n\t //set the initial values\n\t this.playbackRate = options.playbackRate;\n\t };\n\t Tone.extend(Tone.Event);\n\t /**\n\t\t * The default values\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.Event.defaults = {\n\t 'callback': Tone.noOp,\n\t 'loop': false,\n\t 'loopEnd': '1m',\n\t 'loopStart': 0,\n\t 'playbackRate': 1,\n\t 'value': null,\n\t 'probability': 1,\n\t 'mute': false,\n\t 'humanize': false\n\t };\n\t /**\n\t\t * Reschedule all of the events along the timeline\n\t\t * with the updated values.\n\t\t * @param {Time} after Only reschedules events after the given time.\n\t\t * @return {Tone.Event} this\n\t\t * @private\n\t\t */\n\t Tone.Event.prototype._rescheduleEvents = function (after) {\n\t //if no argument is given, schedules all of the events\n\t after = Tone.defaultArg(after, -1);\n\t this._state.forEachFrom(after, function (event) {\n\t var duration;\n\t if (event.state === Tone.State.Started) {\n\t if (Tone.isDefined(event.id)) {\n\t Tone.Transport.clear(event.id);\n\t }\n\t var startTick = event.time + Math.round(this.startOffset / this._playbackRate);\n\t if (this._loop) {\n\t duration = Infinity;\n\t if (Tone.isNumber(this._loop)) {\n\t duration = this._loop * this._getLoopDuration();\n\t }\n\t var nextEvent = this._state.getAfter(startTick);\n\t if (nextEvent !== null) {\n\t duration = Math.min(duration, nextEvent.time - startTick);\n\t }\n\t if (duration !== Infinity) {\n\t //schedule a stop since it's finite duration\n\t this._state.setStateAtTime(Tone.State.Stopped, startTick + duration + 1);\n\t duration = Tone.Ticks(duration);\n\t }\n\t var interval = Tone.Ticks(this._getLoopDuration());\n\t event.id = Tone.Transport.scheduleRepeat(this._tick.bind(this), interval, Tone.Ticks(startTick), duration);\n\t } else {\n\t event.id = Tone.Transport.schedule(this._tick.bind(this), Tone.Ticks(startTick));\n\t }\n\t }\n\t }.bind(this));\n\t return this;\n\t };\n\t /**\n\t\t * Returns the playback state of the note, either \"started\" or \"stopped\".\n\t\t * @type {String}\n\t\t * @readOnly\n\t\t * @memberOf Tone.Event#\n\t\t * @name state\n\t\t */\n\t Object.defineProperty(Tone.Event.prototype, 'state', {\n\t get: function () {\n\t return this._state.getValueAtTime(Tone.Transport.ticks);\n\t }\n\t });\n\t /**\n\t\t * The start from the scheduled start time\n\t\t * @type {Ticks}\n\t\t * @memberOf Tone.Event#\n\t\t * @name startOffset\n\t\t * @private\n\t\t */\n\t Object.defineProperty(Tone.Event.prototype, 'startOffset', {\n\t get: function () {\n\t return this._startOffset;\n\t },\n\t set: function (offset) {\n\t this._startOffset = offset;\n\t }\n\t });\n\t /**\n\t\t * The probability of the notes being triggered.\n\t\t * @memberOf Tone.Event#\n\t\t * @type {NormalRange}\n\t\t * @name probability\n\t\t */\n\t Object.defineProperty(Tone.Event.prototype, 'probability', {\n\t get: function () {\n\t return this._probability;\n\t },\n\t set: function (prob) {\n\t this._probability = prob;\n\t }\n\t });\n\t /**\n\t\t * If set to true, will apply small random variation\n\t\t * to the callback time. If the value is given as a time, it will randomize\n\t\t * by that amount.\n\t\t * @example\n\t\t * event.humanize = true;\n\t\t * @type {Boolean|Time}\n\t\t * @name humanize\n\t\t */\n\t Object.defineProperty(Tone.Event.prototype, 'humanize', {\n\t get: function () {\n\t return this._humanize;\n\t },\n\t set: function (variation) {\n\t this._humanize = variation;\n\t }\n\t });\n\t /**\n\t\t * Start the note at the given time.\n\t\t * @param {TimelinePosition} time When the note should start.\n\t\t * @return {Tone.Event} this\n\t\t */\n\t Tone.Event.prototype.start = function (time) {\n\t time = this.toTicks(time);\n\t if (this._state.getValueAtTime(time) === Tone.State.Stopped) {\n\t this._state.add({\n\t 'state': Tone.State.Started,\n\t 'time': time,\n\t 'id': undefined\n\t });\n\t this._rescheduleEvents(time);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Stop the Event at the given time.\n\t\t * @param {TimelinePosition} time When the note should stop.\n\t\t * @return {Tone.Event} this\n\t\t */\n\t Tone.Event.prototype.stop = function (time) {\n\t this.cancel(time);\n\t time = this.toTicks(time);\n\t if (this._state.getValueAtTime(time) === Tone.State.Started) {\n\t this._state.setStateAtTime(Tone.State.Stopped, time);\n\t var previousEvent = this._state.getBefore(time);\n\t var reschedulTime = time;\n\t if (previousEvent !== null) {\n\t reschedulTime = previousEvent.time;\n\t }\n\t this._rescheduleEvents(reschedulTime);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Cancel all scheduled events greater than or equal to the given time\n\t\t * @param {TimelinePosition} [time=0] The time after which events will be cancel.\n\t\t * @return {Tone.Event} this\n\t\t */\n\t Tone.Event.prototype.cancel = function (time) {\n\t time = Tone.defaultArg(time, -Infinity);\n\t time = this.toTicks(time);\n\t this._state.forEachFrom(time, function (event) {\n\t Tone.Transport.clear(event.id);\n\t });\n\t this._state.cancel(time);\n\t return this;\n\t };\n\t /**\n\t\t * The callback function invoker. Also\n\t\t * checks if the Event is done playing\n\t\t * @param {Number} time The time of the event in seconds\n\t\t * @private\n\t\t */\n\t Tone.Event.prototype._tick = function (time) {\n\t var ticks = Tone.Transport.getTicksAtTime(time);\n\t if (!this.mute && this._state.getValueAtTime(ticks) === Tone.State.Started) {\n\t if (this.probability < 1 && Math.random() > this.probability) {\n\t return;\n\t }\n\t if (this.humanize) {\n\t var variation = 0.02;\n\t if (!Tone.isBoolean(this.humanize)) {\n\t variation = this.toSeconds(this.humanize);\n\t }\n\t time += (Math.random() * 2 - 1) * variation;\n\t }\n\t this.callback(time, this.value);\n\t }\n\t };\n\t /**\n\t\t * Get the duration of the loop.\n\t\t * @return {Ticks}\n\t\t * @private\n\t\t */\n\t Tone.Event.prototype._getLoopDuration = function () {\n\t return Math.round((this._loopEnd - this._loopStart) / this._playbackRate);\n\t };\n\t /**\n\t\t * If the note should loop or not\n\t\t * between Tone.Event.loopStart and\n\t\t * Tone.Event.loopEnd. An integer\n\t\t * value corresponds to the number of\n\t\t * loops the Event does after it starts.\n\t\t * @memberOf Tone.Event#\n\t\t * @type {Boolean|Positive}\n\t\t * @name loop\n\t\t */\n\t Object.defineProperty(Tone.Event.prototype, 'loop', {\n\t get: function () {\n\t return this._loop;\n\t },\n\t set: function (loop) {\n\t this._loop = loop;\n\t this._rescheduleEvents();\n\t }\n\t });\n\t /**\n\t\t * \tThe playback rate of the note. Defaults to 1.\n\t\t * @memberOf Tone.Event#\n\t\t * @type {Positive}\n\t\t * @name playbackRate\n\t\t * @example\n\t\t * note.loop = true;\n\t\t * //repeat the note twice as fast\n\t\t * note.playbackRate = 2;\n\t\t */\n\t Object.defineProperty(Tone.Event.prototype, 'playbackRate', {\n\t get: function () {\n\t return this._playbackRate;\n\t },\n\t set: function (rate) {\n\t this._playbackRate = rate;\n\t this._rescheduleEvents();\n\t }\n\t });\n\t /**\n\t\t * The loopEnd point is the time the event will loop\n\t\t * if Tone.Event.loop is true.\n\t\t * @memberOf Tone.Event#\n\t\t * @type {Time}\n\t\t * @name loopEnd\n\t\t */\n\t Object.defineProperty(Tone.Event.prototype, 'loopEnd', {\n\t get: function () {\n\t return Tone.Ticks(this._loopEnd).toSeconds();\n\t },\n\t set: function (loopEnd) {\n\t this._loopEnd = this.toTicks(loopEnd);\n\t if (this._loop) {\n\t this._rescheduleEvents();\n\t }\n\t }\n\t });\n\t /**\n\t\t * The time when the loop should start.\n\t\t * @memberOf Tone.Event#\n\t\t * @type {Time}\n\t\t * @name loopStart\n\t\t */\n\t Object.defineProperty(Tone.Event.prototype, 'loopStart', {\n\t get: function () {\n\t return Tone.Ticks(this._loopStart).toSeconds();\n\t },\n\t set: function (loopStart) {\n\t this._loopStart = this.toTicks(loopStart);\n\t if (this._loop) {\n\t this._rescheduleEvents();\n\t }\n\t }\n\t });\n\t /**\n\t\t * The current progress of the loop interval.\n\t\t * Returns 0 if the event is not started yet or\n\t\t * it is not set to loop.\n\t\t * @memberOf Tone.Event#\n\t\t * @type {NormalRange}\n\t\t * @name progress\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Event.prototype, 'progress', {\n\t get: function () {\n\t if (this._loop) {\n\t var ticks = Tone.Transport.ticks;\n\t var lastEvent = this._state.get(ticks);\n\t if (lastEvent !== null && lastEvent.state === Tone.State.Started) {\n\t var loopDuration = this._getLoopDuration();\n\t var progress = (ticks - lastEvent.time) % loopDuration;\n\t return progress / loopDuration;\n\t } else {\n\t return 0;\n\t }\n\t } else {\n\t return 0;\n\t }\n\t }\n\t });\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.Event} this\n\t\t */\n\t Tone.Event.prototype.dispose = function () {\n\t this.cancel();\n\t this._state.dispose();\n\t this._state = null;\n\t this.callback = null;\n\t this.value = null;\n\t };\n\t return Tone.Event;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.Loop creates a looped callback at the \n\t\t * specified interval. The callback can be \n\t\t * started, stopped and scheduled along\n\t\t * the Transport's timeline. \n\t\t * @example\n\t\t * var loop = new Tone.Loop(function(time){\n\t\t * \t//triggered every eighth note. \n\t\t * \tconsole.log(time);\n\t\t * }, \"8n\").start(0);\n\t\t * Tone.Transport.start();\n\t\t * @extends {Tone}\n\t\t * @param {Function} callback The callback to invoke with the event.\n\t\t * @param {Time} interval The time between successive callback calls. \n\t\t */\n\t Tone.Loop = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'callback',\n\t 'interval'\n\t ], Tone.Loop);\n\t Tone.call(this);\n\t /**\n\t\t\t * The event which produces the callbacks\n\t\t\t */\n\t this._event = new Tone.Event({\n\t 'callback': this._tick.bind(this),\n\t 'loop': true,\n\t 'loopEnd': options.interval,\n\t 'playbackRate': options.playbackRate,\n\t 'probability': options.probability\n\t });\n\t /**\n\t\t\t * The callback to invoke with the next event in the pattern\n\t\t\t * @type {Function}\n\t\t\t */\n\t this.callback = options.callback;\n\t //set the iterations\n\t this.iterations = options.iterations;\n\t };\n\t Tone.extend(Tone.Loop);\n\t /**\n\t\t * The defaults\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Loop.defaults = {\n\t 'interval': '4n',\n\t 'callback': Tone.noOp,\n\t 'playbackRate': 1,\n\t 'iterations': Infinity,\n\t 'probability': true,\n\t 'mute': false\n\t };\n\t /**\n\t\t * Start the loop at the specified time along the Transport's\n\t\t * timeline.\n\t\t * @param {TimelinePosition=} time When to start the Loop.\n\t\t * @return {Tone.Loop} this\n\t\t */\n\t Tone.Loop.prototype.start = function (time) {\n\t this._event.start(time);\n\t return this;\n\t };\n\t /**\n\t\t * Stop the loop at the given time.\n\t\t * @param {TimelinePosition=} time When to stop the Arpeggio\n\t\t * @return {Tone.Loop} this\n\t\t */\n\t Tone.Loop.prototype.stop = function (time) {\n\t this._event.stop(time);\n\t return this;\n\t };\n\t /**\n\t\t * Cancel all scheduled events greater than or equal to the given time\n\t\t * @param {TimelinePosition} [time=0] The time after which events will be cancel.\n\t\t * @return {Tone.Loop} this\n\t\t */\n\t Tone.Loop.prototype.cancel = function (time) {\n\t this._event.cancel(time);\n\t return this;\n\t };\n\t /**\n\t\t * Internal function called when the notes should be called\n\t\t * @param {Number} time The time the event occurs\n\t\t * @private\n\t\t */\n\t Tone.Loop.prototype._tick = function (time) {\n\t this.callback(time);\n\t };\n\t /**\n\t\t * The state of the Loop, either started or stopped.\n\t\t * @memberOf Tone.Loop#\n\t\t * @type {String}\n\t\t * @name state\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Loop.prototype, 'state', {\n\t get: function () {\n\t return this._event.state;\n\t }\n\t });\n\t /**\n\t\t * The progress of the loop as a value between 0-1. 0, when\n\t\t * the loop is stopped or done iterating. \n\t\t * @memberOf Tone.Loop#\n\t\t * @type {NormalRange}\n\t\t * @name progress\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Loop.prototype, 'progress', {\n\t get: function () {\n\t return this._event.progress;\n\t }\n\t });\n\t /**\n\t\t * The time between successive callbacks. \n\t\t * @example\n\t\t * loop.interval = \"8n\"; //loop every 8n\n\t\t * @memberOf Tone.Loop#\n\t\t * @type {Time}\n\t\t * @name interval\n\t\t */\n\t Object.defineProperty(Tone.Loop.prototype, 'interval', {\n\t get: function () {\n\t return this._event.loopEnd;\n\t },\n\t set: function (interval) {\n\t this._event.loopEnd = interval;\n\t }\n\t });\n\t /**\n\t\t * The playback rate of the loop. The normal playback rate is 1 (no change). \n\t\t * A `playbackRate` of 2 would be twice as fast. \n\t\t * @memberOf Tone.Loop#\n\t\t * @type {Time}\n\t\t * @name playbackRate\n\t\t */\n\t Object.defineProperty(Tone.Loop.prototype, 'playbackRate', {\n\t get: function () {\n\t return this._event.playbackRate;\n\t },\n\t set: function (rate) {\n\t this._event.playbackRate = rate;\n\t }\n\t });\n\t /**\n\t\t * Random variation +/-0.01s to the scheduled time. \n\t\t * Or give it a time value which it will randomize by.\n\t\t * @type {Boolean|Time}\n\t\t * @memberOf Tone.Loop#\n\t\t * @name humanize\n\t\t */\n\t Object.defineProperty(Tone.Loop.prototype, 'humanize', {\n\t get: function () {\n\t return this._event.humanize;\n\t },\n\t set: function (variation) {\n\t this._event.humanize = variation;\n\t }\n\t });\n\t /**\n\t\t * The probably of the callback being invoked.\n\t\t * @memberOf Tone.Loop#\n\t\t * @type {NormalRange}\n\t\t * @name probability\n\t\t */\n\t Object.defineProperty(Tone.Loop.prototype, 'probability', {\n\t get: function () {\n\t return this._event.probability;\n\t },\n\t set: function (prob) {\n\t this._event.probability = prob;\n\t }\n\t });\n\t /**\n\t\t * Muting the Loop means that no callbacks are invoked.\n\t\t * @memberOf Tone.Loop#\n\t\t * @type {Boolean}\n\t\t * @name mute\n\t\t */\n\t Object.defineProperty(Tone.Loop.prototype, 'mute', {\n\t get: function () {\n\t return this._event.mute;\n\t },\n\t set: function (mute) {\n\t this._event.mute = mute;\n\t }\n\t });\n\t /**\n\t\t * The number of iterations of the loop. The default\n\t\t * value is Infinity (loop forever).\n\t\t * @memberOf Tone.Loop#\n\t\t * @type {Positive}\n\t\t * @name iterations\n\t\t */\n\t Object.defineProperty(Tone.Loop.prototype, 'iterations', {\n\t get: function () {\n\t if (this._event.loop === true) {\n\t return Infinity;\n\t } else {\n\t return this._event.loop;\n\t }\n\t },\n\t set: function (iters) {\n\t if (iters === Infinity) {\n\t this._event.loop = true;\n\t } else {\n\t this._event.loop = iters;\n\t }\n\t }\n\t });\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.Loop} this\n\t\t */\n\t Tone.Loop.prototype.dispose = function () {\n\t this._event.dispose();\n\t this._event = null;\n\t this.callback = null;\n\t };\n\t return Tone.Loop;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Part is a collection Tone.Events which can be\n\t\t * started/stopped and looped as a single unit.\n\t\t *\n\t\t * @extends {Tone.Event}\n\t\t * @param {Function} callback The callback to invoke on each event\n\t\t * @param {Array} events the array of events\n\t\t * @example\n\t\t * var part = new Tone.Part(function(time, note){\n\t\t * \t//the notes given as the second element in the array\n\t\t * \t//will be passed in as the second argument\n\t\t * \tsynth.triggerAttackRelease(note, \"8n\", time);\n\t\t * }, [[0, \"C2\"], [\"0:2\", \"C3\"], [\"0:3:2\", \"G2\"]]);\n\t\t * @example\n\t\t * //use an array of objects as long as the object has a \"time\" attribute\n\t\t * var part = new Tone.Part(function(time, value){\n\t\t * \t//the value is an object which contains both the note and the velocity\n\t\t * \tsynth.triggerAttackRelease(value.note, \"8n\", time, value.velocity);\n\t\t * }, [{\"time\" : 0, \"note\" : \"C3\", \"velocity\": 0.9},\n\t\t * \t {\"time\" : \"0:2\", \"note\" : \"C4\", \"velocity\": 0.5}\n\t\t * ]).start(0);\n\t\t */\n\t Tone.Part = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'callback',\n\t 'events'\n\t ], Tone.Part);\n\t Tone.Event.call(this, options);\n\t /**\n\t\t\t * An array of Objects.\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._events = [];\n\t //add the events\n\t for (var i = 0; i < options.events.length; i++) {\n\t if (Array.isArray(options.events[i])) {\n\t this.add(options.events[i][0], options.events[i][1]);\n\t } else {\n\t this.add(options.events[i]);\n\t }\n\t }\n\t };\n\t Tone.extend(Tone.Part, Tone.Event);\n\t /**\n\t\t * The default values\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.Part.defaults = {\n\t 'callback': Tone.noOp,\n\t 'loop': false,\n\t 'loopEnd': '1m',\n\t 'loopStart': 0,\n\t 'playbackRate': 1,\n\t 'probability': 1,\n\t 'humanize': false,\n\t 'mute': false,\n\t 'events': []\n\t };\n\t /**\n\t\t * Start the part at the given time.\n\t\t * @param {TransportTime} time When to start the part.\n\t\t * @param {Time=} offset The offset from the start of the part\n\t\t * to begin playing at.\n\t\t * @return {Tone.Part} this\n\t\t */\n\t Tone.Part.prototype.start = function (time, offset) {\n\t var ticks = this.toTicks(time);\n\t if (this._state.getValueAtTime(ticks) !== Tone.State.Started) {\n\t if (this._loop) {\n\t offset = Tone.defaultArg(offset, this._loopStart);\n\t } else {\n\t offset = Tone.defaultArg(offset, 0);\n\t }\n\t offset = this.toTicks(offset);\n\t this._state.add({\n\t 'state': Tone.State.Started,\n\t 'time': ticks,\n\t 'offset': offset\n\t });\n\t this._forEach(function (event) {\n\t this._startNote(event, ticks, offset);\n\t });\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Start the event in the given event at the correct time given\n\t\t * the ticks and offset and looping.\n\t\t * @param {Tone.Event} event\n\t\t * @param {Ticks} ticks\n\t\t * @param {Ticks} offset\n\t\t * @private\n\t\t */\n\t Tone.Part.prototype._startNote = function (event, ticks, offset) {\n\t ticks -= offset;\n\t if (this._loop) {\n\t if (event.startOffset >= this._loopStart && event.startOffset < this._loopEnd) {\n\t if (event.startOffset < offset) {\n\t //start it on the next loop\n\t ticks += this._getLoopDuration();\n\t }\n\t event.start(Tone.Ticks(ticks));\n\t } else if (event.startOffset < this._loopStart && event.startOffset >= offset) {\n\t event.loop = false;\n\t event.start(Tone.Ticks(ticks));\n\t }\n\t } else if (event.startOffset >= offset) {\n\t event.start(Tone.Ticks(ticks));\n\t }\n\t };\n\t /**\n\t\t * The start from the scheduled start time\n\t\t * @type {Ticks}\n\t\t * @memberOf Tone.Part#\n\t\t * @name startOffset\n\t\t * @private\n\t\t */\n\t Object.defineProperty(Tone.Part.prototype, 'startOffset', {\n\t get: function () {\n\t return this._startOffset;\n\t },\n\t set: function (offset) {\n\t this._startOffset = offset;\n\t this._forEach(function (event) {\n\t event.startOffset += this._startOffset;\n\t });\n\t }\n\t });\n\t /**\n\t\t * Stop the part at the given time.\n\t\t * @param {TimelinePosition} time When to stop the part.\n\t\t * @return {Tone.Part} this\n\t\t */\n\t Tone.Part.prototype.stop = function (time) {\n\t var ticks = this.toTicks(time);\n\t this._state.cancel(ticks);\n\t this._state.setStateAtTime(Tone.State.Stopped, ticks);\n\t this._forEach(function (event) {\n\t event.stop(time);\n\t });\n\t return this;\n\t };\n\t /**\n\t\t * Get/Set an Event's value at the given time.\n\t\t * If a value is passed in and no event exists at\n\t\t * the given time, one will be created with that value.\n\t\t * If two events are at the same time, the first one will\n\t\t * be returned.\n\t\t * @example\n\t\t * part.at(\"1m\"); //returns the part at the first measure\n\t\t *\n\t\t * part.at(\"2m\", \"C2\"); //set the value at \"2m\" to C2.\n\t\t * //if an event didn't exist at that time, it will be created.\n\t\t * @param {TransportTime} time The time of the event to get or set.\n\t\t * @param {*=} value If a value is passed in, the value of the\n\t\t * event at the given time will be set to it.\n\t\t * @return {Tone.Event} the event at the time\n\t\t */\n\t Tone.Part.prototype.at = function (time, value) {\n\t time = Tone.TransportTime(time);\n\t var tickTime = Tone.Ticks(1).toSeconds();\n\t for (var i = 0; i < this._events.length; i++) {\n\t var event = this._events[i];\n\t if (Math.abs(time.toTicks() - event.startOffset) < tickTime) {\n\t if (Tone.isDefined(value)) {\n\t event.value = value;\n\t }\n\t return event;\n\t }\n\t }\n\t //if there was no event at that time, create one\n\t if (Tone.isDefined(value)) {\n\t this.add(time, value);\n\t //return the new event\n\t return this._events[this._events.length - 1];\n\t } else {\n\t return null;\n\t }\n\t };\n\t /**\n\t\t * Add a an event to the part.\n\t\t * @param {Time} time The time the note should start.\n\t\t * If an object is passed in, it should\n\t\t * have a 'time' attribute and the rest\n\t\t * of the object will be used as the 'value'.\n\t\t * @param {Tone.Event|*} value\n\t\t * @returns {Tone.Part} this\n\t\t * @example\n\t\t * part.add(\"1m\", \"C#+11\");\n\t\t */\n\t Tone.Part.prototype.add = function (time, value) {\n\t //extract the parameters\n\t if (time.hasOwnProperty('time')) {\n\t value = time;\n\t time = value.time;\n\t }\n\t time = this.toTicks(time);\n\t var event;\n\t if (value instanceof Tone.Event) {\n\t event = value;\n\t event.callback = this._tick.bind(this);\n\t } else {\n\t event = new Tone.Event({\n\t 'callback': this._tick.bind(this),\n\t 'value': value\n\t });\n\t }\n\t //the start offset\n\t event.startOffset = time;\n\t //initialize the values\n\t event.set({\n\t 'loopEnd': this.loopEnd,\n\t 'loopStart': this.loopStart,\n\t 'loop': this.loop,\n\t 'humanize': this.humanize,\n\t 'playbackRate': this.playbackRate,\n\t 'probability': this.probability\n\t });\n\t this._events.push(event);\n\t //start the note if it should be played right now\n\t this._restartEvent(event);\n\t return this;\n\t };\n\t /**\n\t\t * Restart the given event\n\t\t * @param {Tone.Event} event\n\t\t * @private\n\t\t */\n\t Tone.Part.prototype._restartEvent = function (event) {\n\t this._state.forEach(function (stateEvent) {\n\t if (stateEvent.state === Tone.State.Started) {\n\t this._startNote(event, stateEvent.time, stateEvent.offset);\n\t } else {\n\t //stop the note\n\t event.stop(Tone.Ticks(stateEvent.time));\n\t }\n\t }.bind(this));\n\t };\n\t /**\n\t\t * Remove an event from the part. Will recursively iterate\n\t\t * into nested parts to find the event.\n\t\t * @param {Time} time The time of the event\n\t\t * @param {*} value Optionally select only a specific event value\n\t\t * @return {Tone.Part} this\n\t\t */\n\t Tone.Part.prototype.remove = function (time, value) {\n\t //extract the parameters\n\t if (time.hasOwnProperty('time')) {\n\t value = time;\n\t time = value.time;\n\t }\n\t time = this.toTicks(time);\n\t for (var i = this._events.length - 1; i >= 0; i--) {\n\t var event = this._events[i];\n\t if (event instanceof Tone.Part) {\n\t event.remove(time, value);\n\t } else if (event.startOffset === time) {\n\t if (Tone.isUndef(value) || Tone.isDefined(value) && event.value === value) {\n\t this._events.splice(i, 1);\n\t event.dispose();\n\t }\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Remove all of the notes from the group.\n\t\t * @return {Tone.Part} this\n\t\t */\n\t Tone.Part.prototype.removeAll = function () {\n\t this._forEach(function (event) {\n\t event.dispose();\n\t });\n\t this._events = [];\n\t return this;\n\t };\n\t /**\n\t\t * Cancel scheduled state change events: i.e. \"start\" and \"stop\".\n\t\t * @param {TimelinePosition} after The time after which to cancel the scheduled events.\n\t\t * @return {Tone.Part} this\n\t\t */\n\t Tone.Part.prototype.cancel = function (after) {\n\t this._forEach(function (event) {\n\t event.cancel(after);\n\t });\n\t this._state.cancel(this.toTicks(after));\n\t return this;\n\t };\n\t /**\n\t\t * Iterate over all of the events\n\t\t * @param {Function} callback\n\t\t * @param {Object} ctx The context\n\t\t * @private\n\t\t */\n\t Tone.Part.prototype._forEach = function (callback, ctx) {\n\t if (this._events) {\n\t ctx = Tone.defaultArg(ctx, this);\n\t for (var i = this._events.length - 1; i >= 0; i--) {\n\t var e = this._events[i];\n\t if (e instanceof Tone.Part) {\n\t e._forEach(callback, ctx);\n\t } else {\n\t callback.call(ctx, e);\n\t }\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Set the attribute of all of the events\n\t\t * @param {String} attr the attribute to set\n\t\t * @param {*} value The value to set it to\n\t\t * @private\n\t\t */\n\t Tone.Part.prototype._setAll = function (attr, value) {\n\t this._forEach(function (event) {\n\t event[attr] = value;\n\t });\n\t };\n\t /**\n\t\t * Internal tick method\n\t\t * @param {Number} time The time of the event in seconds\n\t\t * @private\n\t\t */\n\t Tone.Part.prototype._tick = function (time, value) {\n\t if (!this.mute) {\n\t this.callback(time, value);\n\t }\n\t };\n\t /**\n\t\t * Determine if the event should be currently looping\n\t\t * given the loop boundries of this Part.\n\t\t * @param {Tone.Event} event The event to test\n\t\t * @private\n\t\t */\n\t Tone.Part.prototype._testLoopBoundries = function (event) {\n\t if (event.startOffset < this._loopStart || event.startOffset >= this._loopEnd) {\n\t event.cancel(0);\n\t } else if (event.state === Tone.State.Stopped) {\n\t //reschedule it if it's stopped\n\t this._restartEvent(event);\n\t }\n\t };\n\t /**\n\t\t * The probability of the notes being triggered.\n\t\t * @memberOf Tone.Part#\n\t\t * @type {NormalRange}\n\t\t * @name probability\n\t\t */\n\t Object.defineProperty(Tone.Part.prototype, 'probability', {\n\t get: function () {\n\t return this._probability;\n\t },\n\t set: function (prob) {\n\t this._probability = prob;\n\t this._setAll('probability', prob);\n\t }\n\t });\n\t /**\n\t\t * If set to true, will apply small random variation\n\t\t * to the callback time. If the value is given as a time, it will randomize\n\t\t * by that amount.\n\t\t * @example\n\t\t * event.humanize = true;\n\t\t * @type {Boolean|Time}\n\t\t * @name humanize\n\t\t */\n\t Object.defineProperty(Tone.Part.prototype, 'humanize', {\n\t get: function () {\n\t return this._humanize;\n\t },\n\t set: function (variation) {\n\t this._humanize = variation;\n\t this._setAll('humanize', variation);\n\t }\n\t });\n\t /**\n\t\t * If the part should loop or not\n\t\t * between Tone.Part.loopStart and\n\t\t * Tone.Part.loopEnd. An integer\n\t\t * value corresponds to the number of\n\t\t * loops the Part does after it starts.\n\t\t * @memberOf Tone.Part#\n\t\t * @type {Boolean|Positive}\n\t\t * @name loop\n\t\t * @example\n\t\t * //loop the part 8 times\n\t\t * part.loop = 8;\n\t\t */\n\t Object.defineProperty(Tone.Part.prototype, 'loop', {\n\t get: function () {\n\t return this._loop;\n\t },\n\t set: function (loop) {\n\t this._loop = loop;\n\t this._forEach(function (event) {\n\t event._loopStart = this._loopStart;\n\t event._loopEnd = this._loopEnd;\n\t event.loop = loop;\n\t this._testLoopBoundries(event);\n\t });\n\t }\n\t });\n\t /**\n\t\t * The loopEnd point determines when it will\n\t\t * loop if Tone.Part.loop is true.\n\t\t * @memberOf Tone.Part#\n\t\t * @type {Time}\n\t\t * @name loopEnd\n\t\t */\n\t Object.defineProperty(Tone.Part.prototype, 'loopEnd', {\n\t get: function () {\n\t return Tone.Ticks(this._loopEnd).toSeconds();\n\t },\n\t set: function (loopEnd) {\n\t this._loopEnd = this.toTicks(loopEnd);\n\t if (this._loop) {\n\t this._forEach(function (event) {\n\t event.loopEnd = loopEnd;\n\t this._testLoopBoundries(event);\n\t });\n\t }\n\t }\n\t });\n\t /**\n\t\t * The loopStart point determines when it will\n\t\t * loop if Tone.Part.loop is true.\n\t\t * @memberOf Tone.Part#\n\t\t * @type {Time}\n\t\t * @name loopStart\n\t\t */\n\t Object.defineProperty(Tone.Part.prototype, 'loopStart', {\n\t get: function () {\n\t return Tone.Ticks(this._loopStart).toSeconds();\n\t },\n\t set: function (loopStart) {\n\t this._loopStart = this.toTicks(loopStart);\n\t if (this._loop) {\n\t this._forEach(function (event) {\n\t event.loopStart = this.loopStart;\n\t this._testLoopBoundries(event);\n\t });\n\t }\n\t }\n\t });\n\t /**\n\t\t * \tThe playback rate of the part\n\t\t * @memberOf Tone.Part#\n\t\t * @type {Positive}\n\t\t * @name playbackRate\n\t\t */\n\t Object.defineProperty(Tone.Part.prototype, 'playbackRate', {\n\t get: function () {\n\t return this._playbackRate;\n\t },\n\t set: function (rate) {\n\t this._playbackRate = rate;\n\t this._setAll('playbackRate', rate);\n\t }\n\t });\n\t /**\n\t\t * \tThe number of scheduled notes in the part.\n\t\t * @memberOf Tone.Part#\n\t\t * @type {Positive}\n\t\t * @name length\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Part.prototype, 'length', {\n\t get: function () {\n\t return this._events.length;\n\t }\n\t });\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.Part} this\n\t\t */\n\t Tone.Part.prototype.dispose = function () {\n\t this.removeAll();\n\t this._state.dispose();\n\t this._state = null;\n\t this.callback = null;\n\t this._events = null;\n\t return this;\n\t };\n\t return Tone.Part;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.Pattern arpeggiates between the given notes\n\t\t * in a number of patterns. See Tone.CtrlPattern for\n\t\t * a full list of patterns.\n\t\t * @example\n\t\t * var pattern = new Tone.Pattern(function(time, note){\n\t\t * //the order of the notes passed in depends on the pattern\n\t\t * }, [\"C2\", \"D4\", \"E5\", \"A6\"], \"upDown\");\n\t\t * @extends {Tone.Loop}\n\t\t * @param {Function} callback The callback to invoke with the\n\t\t * event.\n\t\t * @param {Array} values The values to arpeggiate over.\n\t\t */\n\t Tone.Pattern = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'callback',\n\t 'values',\n\t 'pattern'\n\t ], Tone.Pattern);\n\t Tone.Loop.call(this, options);\n\t /**\n\t\t\t * The pattern manager\n\t\t\t * @type {Tone.CtrlPattern}\n\t\t\t * @private\n\t\t\t */\n\t this._pattern = new Tone.CtrlPattern({\n\t 'values': options.values,\n\t 'type': options.pattern,\n\t 'index': options.index\n\t });\n\t };\n\t Tone.extend(Tone.Pattern, Tone.Loop);\n\t /**\n\t\t * The defaults\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Pattern.defaults = {\n\t 'pattern': Tone.CtrlPattern.Type.Up,\n\t 'callback': Tone.noOp,\n\t 'values': []\n\t };\n\t /**\n\t\t * Internal function called when the notes should be called\n\t\t * @param {Number} time The time the event occurs\n\t\t * @private\n\t\t */\n\t Tone.Pattern.prototype._tick = function (time) {\n\t this.callback(time, this._pattern.value);\n\t this._pattern.next();\n\t };\n\t /**\n\t\t * The current index in the values array.\n\t\t * @memberOf Tone.Pattern#\n\t\t * @type {Positive}\n\t\t * @name index\n\t\t */\n\t Object.defineProperty(Tone.Pattern.prototype, 'index', {\n\t get: function () {\n\t return this._pattern.index;\n\t },\n\t set: function (i) {\n\t this._pattern.index = i;\n\t }\n\t });\n\t /**\n\t\t * The array of events.\n\t\t * @memberOf Tone.Pattern#\n\t\t * @type {Array}\n\t\t * @name values\n\t\t */\n\t Object.defineProperty(Tone.Pattern.prototype, 'values', {\n\t get: function () {\n\t return this._pattern.values;\n\t },\n\t set: function (vals) {\n\t this._pattern.values = vals;\n\t }\n\t });\n\t /**\n\t\t * The current value of the pattern.\n\t\t * @memberOf Tone.Pattern#\n\t\t * @type {*}\n\t\t * @name value\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Pattern.prototype, 'value', {\n\t get: function () {\n\t return this._pattern.value;\n\t }\n\t });\n\t /**\n\t\t * The pattern type. See Tone.CtrlPattern for the full list of patterns.\n\t\t * @memberOf Tone.Pattern#\n\t\t * @type {String}\n\t\t * @name pattern\n\t\t */\n\t Object.defineProperty(Tone.Pattern.prototype, 'pattern', {\n\t get: function () {\n\t return this._pattern.type;\n\t },\n\t set: function (pattern) {\n\t this._pattern.type = pattern;\n\t }\n\t });\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.Pattern} this\n\t\t */\n\t Tone.Pattern.prototype.dispose = function () {\n\t Tone.Loop.prototype.dispose.call(this);\n\t this._pattern.dispose();\n\t this._pattern = null;\n\t };\n\t return Tone.Pattern;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class A sequence is an alternate notation of a part. Instead\n\t\t * of passing in an array of [time, event] pairs, pass\n\t\t * in an array of events which will be spaced at the\n\t\t * given subdivision. Sub-arrays will subdivide that beat\n\t\t * by the number of items are in the array.\n\t\t * Sequence notation inspiration from [Tidal](http://yaxu.org/tidal/)\n\t\t * @param {Function} callback The callback to invoke with every note\n\t\t * @param {Array} events The sequence\n\t\t * @param {Time} subdivision The subdivision between which events are placed.\n\t\t * @extends {Tone.Part}\n\t\t * @example\n\t\t * var seq = new Tone.Sequence(function(time, note){\n\t\t * \tconsole.log(note);\n\t\t * //straight quater notes\n\t\t * }, [\"C4\", \"E4\", \"G4\", \"A4\"], \"4n\");\n\t\t * @example\n\t\t * var seq = new Tone.Sequence(function(time, note){\n\t\t * \tconsole.log(note);\n\t\t * //subdivisions are given as subarrays\n\t\t * }, [\"C4\", [\"E4\", \"D4\", \"E4\"], \"G4\", [\"A4\", \"G4\"]]);\n\t\t */\n\t Tone.Sequence = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'callback',\n\t 'events',\n\t 'subdivision'\n\t ], Tone.Sequence);\n\t //remove the events\n\t var events = options.events;\n\t delete options.events;\n\t Tone.Part.call(this, options);\n\t /**\n\t\t\t * The subdivison of each note\n\t\t\t * @type {Ticks}\n\t\t\t * @private\n\t\t\t */\n\t this._subdivision = this.toTicks(options.subdivision);\n\t //if no time was passed in, the loop end is the end of the cycle\n\t if (Tone.isUndef(options.loopEnd) && Tone.isDefined(events)) {\n\t this._loopEnd = events.length * this._subdivision;\n\t }\n\t //defaults to looping\n\t this._loop = true;\n\t //add all of the events\n\t if (Tone.isDefined(events)) {\n\t for (var i = 0; i < events.length; i++) {\n\t this.add(i, events[i]);\n\t }\n\t }\n\t };\n\t Tone.extend(Tone.Sequence, Tone.Part);\n\t /**\n\t\t * The default values.\n\t\t * @type {Object}\n\t\t */\n\t Tone.Sequence.defaults = { 'subdivision': '4n' };\n\t /**\n\t\t * The subdivision of the sequence. This can only be\n\t\t * set in the constructor. The subdivision is the\n\t\t * interval between successive steps.\n\t\t * @type {Time}\n\t\t * @memberOf Tone.Sequence#\n\t\t * @name subdivision\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Sequence.prototype, 'subdivision', {\n\t get: function () {\n\t return Tone.Ticks(this._subdivision).toSeconds();\n\t }\n\t });\n\t /**\n\t\t * Get/Set an index of the sequence. If the index contains a subarray,\n\t\t * a Tone.Sequence representing that sub-array will be returned.\n\t\t * @example\n\t\t * var sequence = new Tone.Sequence(playNote, [\"E4\", \"C4\", \"F#4\", [\"A4\", \"Bb3\"]])\n\t\t * sequence.at(0)// => returns \"E4\"\n\t\t * //set a value\n\t\t * sequence.at(0, \"G3\");\n\t\t * //get a nested sequence\n\t\t * sequence.at(3).at(1)// => returns \"Bb3\"\n\t\t * @param {Positive} index The index to get or set\n\t\t * @param {*} value Optionally pass in the value to set at the given index.\n\t\t */\n\t Tone.Sequence.prototype.at = function (index, value) {\n\t //if the value is an array,\n\t if (Tone.isArray(value)) {\n\t //remove the current event at that index\n\t this.remove(index);\n\t }\n\t //call the parent's method\n\t return Tone.Part.prototype.at.call(this, this._indexTime(index), value);\n\t };\n\t /**\n\t\t * Add an event at an index, if there's already something\n\t\t * at that index, overwrite it. If `value` is an array,\n\t\t * it will be parsed as a subsequence.\n\t\t * @param {Number} index The index to add the event to\n\t\t * @param {*} value The value to add at that index\n\t\t * @returns {Tone.Sequence} this\n\t\t */\n\t Tone.Sequence.prototype.add = function (index, value) {\n\t if (value === null) {\n\t return this;\n\t }\n\t if (Tone.isArray(value)) {\n\t //make a subsequence and add that to the sequence\n\t var subSubdivision = Math.round(this._subdivision / value.length);\n\t value = new Tone.Sequence(this._tick.bind(this), value, Tone.Ticks(subSubdivision));\n\t }\n\t Tone.Part.prototype.add.call(this, this._indexTime(index), value);\n\t return this;\n\t };\n\t /**\n\t\t * Remove a value from the sequence by index\n\t\t * @param {Number} index The index of the event to remove\n\t\t * @returns {Tone.Sequence} this\n\t\t */\n\t Tone.Sequence.prototype.remove = function (index, value) {\n\t Tone.Part.prototype.remove.call(this, this._indexTime(index), value);\n\t return this;\n\t };\n\t /**\n\t\t * Get the time of the index given the Sequence's subdivision\n\t\t * @param {Number} index\n\t\t * @return {Time} The time of that index\n\t\t * @private\n\t\t */\n\t Tone.Sequence.prototype._indexTime = function (index) {\n\t if (index instanceof Tone.TransportTime) {\n\t return index;\n\t } else {\n\t return Tone.Ticks(index * this._subdivision + this.startOffset).toSeconds();\n\t }\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.Sequence} this\n\t\t */\n\t Tone.Sequence.prototype.dispose = function () {\n\t Tone.Part.prototype.dispose.call(this);\n\t return this;\n\t };\n\t return Tone.Sequence;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.PulseOscillator is a pulse oscillator with control over pulse width,\n\t\t * also known as the duty cycle. At 50% duty cycle (width = 0.5) the wave is\n\t\t * a square and only odd-numbered harmonics are present. At all other widths\n\t\t * even-numbered harmonics are present. Read more\n\t\t * [here](https://wigglewave.wordpress.com/2014/08/16/pulse-waveforms-and-harmonics/).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Source}\n\t\t * @param {Frequency} [frequency] The frequency of the oscillator\n\t\t * @param {NormalRange} [width] The width of the pulse\n\t\t * @example\n\t\t * var pulse = new Tone.PulseOscillator(\"E5\", 0.4).toMaster().start();\n\t\t */\n\t Tone.PulseOscillator = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'width'\n\t ], Tone.Oscillator);\n\t Tone.Source.call(this, options);\n\t /**\n\t\t\t * The width of the pulse.\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.width = new Tone.Signal(options.width, Tone.Type.NormalRange);\n\t /**\n\t\t\t * gate the width amount\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._widthGate = new Tone.Gain();\n\t /**\n\t\t\t * the sawtooth oscillator\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t * @private\n\t\t\t */\n\t this._sawtooth = new Tone.Oscillator({\n\t frequency: options.frequency,\n\t detune: options.detune,\n\t type: 'sawtooth',\n\t phase: options.phase\n\t });\n\t /**\n\t\t\t * The frequency control.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = this._sawtooth.frequency;\n\t /**\n\t\t\t * The detune in cents.\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = this._sawtooth.detune;\n\t /**\n\t\t\t * Threshold the signal to turn it into a square\n\t\t\t * @type {Tone.WaveShaper}\n\t\t\t * @private\n\t\t\t */\n\t this._thresh = new Tone.WaveShaper(function (val) {\n\t if (val < 0) {\n\t return -1;\n\t } else {\n\t return 1;\n\t }\n\t });\n\t //connections\n\t this._sawtooth.chain(this._thresh, this.output);\n\t this.width.chain(this._widthGate, this._thresh);\n\t this._readOnly([\n\t 'width',\n\t 'frequency',\n\t 'detune'\n\t ]);\n\t };\n\t Tone.extend(Tone.PulseOscillator, Tone.Source);\n\t /**\n\t\t * The default parameters.\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.PulseOscillator.defaults = {\n\t 'frequency': 440,\n\t 'detune': 0,\n\t 'phase': 0,\n\t 'width': 0.2\n\t };\n\t /**\n\t\t * start the oscillator\n\t\t * @param {Time} time\n\t\t * @private\n\t\t */\n\t Tone.PulseOscillator.prototype._start = function (time) {\n\t time = this.toSeconds(time);\n\t this._sawtooth.start(time);\n\t this._widthGate.gain.setValueAtTime(1, time);\n\t };\n\t /**\n\t\t * stop the oscillator\n\t\t * @param {Time} time\n\t\t * @private\n\t\t */\n\t Tone.PulseOscillator.prototype._stop = function (time) {\n\t time = this.toSeconds(time);\n\t this._sawtooth.stop(time);\n\t //the width is still connected to the output.\n\t //that needs to be stopped also\n\t this._widthGate.gain.setValueAtTime(0, time);\n\t };\n\t /**\n\t\t * restart the oscillator\n\t\t * @param {Time} time (optional) timing parameter\n\t\t * @private\n\t\t */\n\t Tone.PulseOscillator.prototype.restart = function (time) {\n\t this._sawtooth.restart(time);\n\t };\n\t /**\n\t\t * The phase of the oscillator in degrees.\n\t\t * @memberOf Tone.PulseOscillator#\n\t\t * @type {Degrees}\n\t\t * @name phase\n\t\t */\n\t Object.defineProperty(Tone.PulseOscillator.prototype, 'phase', {\n\t get: function () {\n\t return this._sawtooth.phase;\n\t },\n\t set: function (phase) {\n\t this._sawtooth.phase = phase;\n\t }\n\t });\n\t /**\n\t\t * The type of the oscillator. Always returns \"pulse\".\n\t\t * @readOnly\n\t\t * @memberOf Tone.PulseOscillator#\n\t\t * @type {string}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.PulseOscillator.prototype, 'type', {\n\t get: function () {\n\t return 'pulse';\n\t }\n\t });\n\t /**\n\t\t * The partials of the waveform. Cannot set partials for this waveform type\n\t\t * @memberOf Tone.PulseOscillator#\n\t\t * @type {Array}\n\t\t * @name partials\n\t\t * @private\n\t\t */\n\t Object.defineProperty(Tone.PulseOscillator.prototype, 'partials', {\n\t get: function () {\n\t return [];\n\t }\n\t });\n\t /**\n\t\t * Clean up method.\n\t\t * @return {Tone.PulseOscillator} this\n\t\t */\n\t Tone.PulseOscillator.prototype.dispose = function () {\n\t Tone.Source.prototype.dispose.call(this);\n\t this._sawtooth.dispose();\n\t this._sawtooth = null;\n\t this._writable([\n\t 'width',\n\t 'frequency',\n\t 'detune'\n\t ]);\n\t this.width.dispose();\n\t this.width = null;\n\t this._widthGate.dispose();\n\t this._widthGate = null;\n\t this._thresh.dispose();\n\t this._thresh = null;\n\t this.frequency = null;\n\t this.detune = null;\n\t return this;\n\t };\n\t return Tone.PulseOscillator;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.PWMOscillator modulates the width of a Tone.PulseOscillator\n\t\t * at the modulationFrequency. This has the effect of continuously\n\t\t * changing the timbre of the oscillator by altering the harmonics\n\t\t * generated.\n\t\t *\n\t\t * @extends {Tone.Source}\n\t\t * @constructor\n\t\t * @param {Frequency} frequency The starting frequency of the oscillator.\n\t\t * @param {Frequency} modulationFrequency The modulation frequency of the width of the pulse.\n\t\t * @example\n\t\t * var pwm = new Tone.PWMOscillator(\"Ab3\", 0.3).toMaster().start();\n\t\t */\n\t Tone.PWMOscillator = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'modulationFrequency'\n\t ], Tone.PWMOscillator);\n\t Tone.Source.call(this, options);\n\t /**\n\t\t\t * the pulse oscillator\n\t\t\t * @type {Tone.PulseOscillator}\n\t\t\t * @private\n\t\t\t */\n\t this._pulse = new Tone.PulseOscillator(options.modulationFrequency);\n\t //change the pulse oscillator type\n\t this._pulse._sawtooth.type = 'sine';\n\t /**\n\t\t\t * the modulator\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t * @private\n\t\t\t */\n\t this._modulator = new Tone.Oscillator({\n\t 'frequency': options.frequency,\n\t 'detune': options.detune,\n\t 'phase': options.phase\n\t });\n\t /**\n\t\t\t * Scale the oscillator so it doesn't go silent\n\t\t\t * at the extreme values.\n\t\t\t * @type {Tone.Multiply}\n\t\t\t * @private\n\t\t\t */\n\t this._scale = new Tone.Multiply(2);\n\t /**\n\t\t\t * The frequency control.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = this._modulator.frequency;\n\t /**\n\t\t\t * The detune of the oscillator.\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = this._modulator.detune;\n\t /**\n\t\t\t * The modulation rate of the oscillator.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.modulationFrequency = this._pulse.frequency;\n\t //connections\n\t this._modulator.chain(this._scale, this._pulse.width);\n\t this._pulse.connect(this.output);\n\t this._readOnly([\n\t 'modulationFrequency',\n\t 'frequency',\n\t 'detune'\n\t ]);\n\t };\n\t Tone.extend(Tone.PWMOscillator, Tone.Source);\n\t /**\n\t\t * default values\n\t\t * @static\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.PWMOscillator.defaults = {\n\t 'frequency': 440,\n\t 'detune': 0,\n\t 'phase': 0,\n\t 'modulationFrequency': 0.4\n\t };\n\t /**\n\t\t * start the oscillator\n\t\t * @param {Time} [time=now]\n\t\t * @private\n\t\t */\n\t Tone.PWMOscillator.prototype._start = function (time) {\n\t time = this.toSeconds(time);\n\t this._modulator.start(time);\n\t this._pulse.start(time);\n\t };\n\t /**\n\t\t * stop the oscillator\n\t\t * @param {Time} time (optional) timing parameter\n\t\t * @private\n\t\t */\n\t Tone.PWMOscillator.prototype._stop = function (time) {\n\t time = this.toSeconds(time);\n\t this._modulator.stop(time);\n\t this._pulse.stop(time);\n\t };\n\t /**\n\t\t * restart the oscillator\n\t\t * @param {Time} time (optional) timing parameter\n\t\t * @private\n\t\t */\n\t Tone.PWMOscillator.prototype.restart = function (time) {\n\t this._modulator.restart(time);\n\t this._pulse.restart(time);\n\t };\n\t /**\n\t\t * The type of the oscillator. Always returns \"pwm\".\n\t\t * @readOnly\n\t\t * @memberOf Tone.PWMOscillator#\n\t\t * @type {string}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.PWMOscillator.prototype, 'type', {\n\t get: function () {\n\t return 'pwm';\n\t }\n\t });\n\t /**\n\t\t * The partials of the waveform. Cannot set partials for this waveform type\n\t\t * @memberOf Tone.PWMOscillator#\n\t\t * @type {Array}\n\t\t * @name partials\n\t\t * @private\n\t\t */\n\t Object.defineProperty(Tone.PWMOscillator.prototype, 'partials', {\n\t get: function () {\n\t return [];\n\t }\n\t });\n\t /**\n\t\t * The phase of the oscillator in degrees.\n\t\t * @memberOf Tone.PWMOscillator#\n\t\t * @type {number}\n\t\t * @name phase\n\t\t */\n\t Object.defineProperty(Tone.PWMOscillator.prototype, 'phase', {\n\t get: function () {\n\t return this._modulator.phase;\n\t },\n\t set: function (phase) {\n\t this._modulator.phase = phase;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.PWMOscillator} this\n\t\t */\n\t Tone.PWMOscillator.prototype.dispose = function () {\n\t Tone.Source.prototype.dispose.call(this);\n\t this._pulse.dispose();\n\t this._pulse = null;\n\t this._scale.dispose();\n\t this._scale = null;\n\t this._modulator.dispose();\n\t this._modulator = null;\n\t this._writable([\n\t 'modulationFrequency',\n\t 'frequency',\n\t 'detune'\n\t ]);\n\t this.frequency = null;\n\t this.detune = null;\n\t this.modulationFrequency = null;\n\t return this;\n\t };\n\t return Tone.PWMOscillator;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.FMOscillator\n\t\t *\n\t\t * @extends {Tone.Source}\n\t\t * @constructor\n\t\t * @param {Frequency} frequency The starting frequency of the oscillator.\n\t\t * @param {String} type The type of the carrier oscillator.\n\t\t * @param {String} modulationType The type of the modulator oscillator.\n\t\t * @example\n\t\t * //a sine oscillator frequency-modulated by a square wave\n\t\t * var fmOsc = new Tone.FMOscillator(\"Ab3\", \"sine\", \"square\").toMaster().start();\n\t\t */\n\t Tone.FMOscillator = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'type',\n\t 'modulationType'\n\t ], Tone.FMOscillator);\n\t Tone.Source.call(this, options);\n\t /**\n\t\t\t * The carrier oscillator\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t * @private\n\t\t\t */\n\t this._carrier = new Tone.Oscillator(options.frequency, options.type);\n\t /**\n\t\t\t * The oscillator's frequency\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency);\n\t /**\n\t\t\t * The detune control signal.\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = this._carrier.detune;\n\t this.detune.value = options.detune;\n\t /**\n\t\t\t * The modulation index which is in essence the depth or amount of the modulation. In other terms it is the\n\t\t\t * ratio of the frequency of the modulating signal (mf) to the amplitude of the\n\t\t\t * modulating signal (ma) -- as in ma/mf.\n\t\t\t *\t@type {Positive}\n\t\t\t *\t@signal\n\t\t\t */\n\t this.modulationIndex = new Tone.Multiply(options.modulationIndex);\n\t this.modulationIndex.units = Tone.Type.Positive;\n\t /**\n\t\t\t * The modulating oscillator\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t * @private\n\t\t\t */\n\t this._modulator = new Tone.Oscillator(options.frequency, options.modulationType);\n\t /**\n\t\t\t * Harmonicity is the frequency ratio between the carrier and the modulator oscillators.\n\t\t\t * A harmonicity of 1 gives both oscillators the same frequency.\n\t\t\t * Harmonicity = 2 means a change of an octave.\n\t\t\t * @type {Positive}\n\t\t\t * @signal\n\t\t\t * @example\n\t\t\t * //pitch the modulator an octave below carrier\n\t\t\t * synth.harmonicity.value = 0.5;\n\t\t\t */\n\t this.harmonicity = new Tone.Multiply(options.harmonicity);\n\t this.harmonicity.units = Tone.Type.Positive;\n\t /**\n\t\t\t * the node where the modulation happens\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._modulationNode = new Tone.Gain(0);\n\t //connections\n\t this.frequency.connect(this._carrier.frequency);\n\t this.frequency.chain(this.harmonicity, this._modulator.frequency);\n\t this.frequency.chain(this.modulationIndex, this._modulationNode);\n\t this._modulator.connect(this._modulationNode.gain);\n\t this._modulationNode.connect(this._carrier.frequency);\n\t this._carrier.connect(this.output);\n\t this.detune.connect(this._modulator.detune);\n\t this.phase = options.phase;\n\t this._readOnly([\n\t 'modulationIndex',\n\t 'frequency',\n\t 'detune',\n\t 'harmonicity'\n\t ]);\n\t };\n\t Tone.extend(Tone.FMOscillator, Tone.Source);\n\t /**\n\t\t * default values\n\t\t * @static\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.FMOscillator.defaults = {\n\t 'frequency': 440,\n\t 'detune': 0,\n\t 'phase': 0,\n\t 'modulationIndex': 2,\n\t 'modulationType': 'square',\n\t 'harmonicity': 1\n\t };\n\t /**\n\t\t * start the oscillator\n\t\t * @param {Time} [time=now]\n\t\t * @private\n\t\t */\n\t Tone.FMOscillator.prototype._start = function (time) {\n\t this._modulator.start(time);\n\t this._carrier.start(time);\n\t };\n\t /**\n\t\t * stop the oscillator\n\t\t * @param {Time} time (optional) timing parameter\n\t\t * @private\n\t\t */\n\t Tone.FMOscillator.prototype._stop = function (time) {\n\t this._modulator.stop(time);\n\t this._carrier.stop(time);\n\t };\n\t /**\n\t\t * stop the oscillator\n\t\t * @param {Time} time (optional) timing parameter\n\t\t * @private\n\t\t */\n\t Tone.FMOscillator.prototype.restart = function (time) {\n\t this._modulator.restart(time);\n\t this._carrier.restart(time);\n\t };\n\t /**\n\t\t * The type of the carrier oscillator\n\t\t * @memberOf Tone.FMOscillator#\n\t\t * @type {string}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.FMOscillator.prototype, 'type', {\n\t get: function () {\n\t return this._carrier.type;\n\t },\n\t set: function (type) {\n\t this._carrier.type = type;\n\t }\n\t });\n\t /**\n\t\t * The type of the modulator oscillator\n\t\t * @memberOf Tone.FMOscillator#\n\t\t * @type {String}\n\t\t * @name modulationType\n\t\t */\n\t Object.defineProperty(Tone.FMOscillator.prototype, 'modulationType', {\n\t get: function () {\n\t return this._modulator.type;\n\t },\n\t set: function (type) {\n\t this._modulator.type = type;\n\t }\n\t });\n\t /**\n\t\t * The phase of the oscillator in degrees.\n\t\t * @memberOf Tone.FMOscillator#\n\t\t * @type {number}\n\t\t * @name phase\n\t\t */\n\t Object.defineProperty(Tone.FMOscillator.prototype, 'phase', {\n\t get: function () {\n\t return this._carrier.phase;\n\t },\n\t set: function (phase) {\n\t this._carrier.phase = phase;\n\t this._modulator.phase = phase;\n\t }\n\t });\n\t /**\n\t\t * The partials of the carrier waveform. A partial represents\n\t\t * the amplitude at a harmonic. The first harmonic is the\n\t\t * fundamental frequency, the second is the octave and so on\n\t\t * following the harmonic series.\n\t\t * Setting this value will automatically set the type to \"custom\".\n\t\t * The value is an empty array when the type is not \"custom\".\n\t\t * @memberOf Tone.FMOscillator#\n\t\t * @type {Array}\n\t\t * @name partials\n\t\t * @example\n\t\t * osc.partials = [1, 0.2, 0.01];\n\t\t */\n\t Object.defineProperty(Tone.FMOscillator.prototype, 'partials', {\n\t get: function () {\n\t return this._carrier.partials;\n\t },\n\t set: function (partials) {\n\t this._carrier.partials = partials;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.FMOscillator} this\n\t\t */\n\t Tone.FMOscillator.prototype.dispose = function () {\n\t Tone.Source.prototype.dispose.call(this);\n\t this._writable([\n\t 'modulationIndex',\n\t 'frequency',\n\t 'detune',\n\t 'harmonicity'\n\t ]);\n\t this.frequency.dispose();\n\t this.frequency = null;\n\t this.detune = null;\n\t this.harmonicity.dispose();\n\t this.harmonicity = null;\n\t this._carrier.dispose();\n\t this._carrier = null;\n\t this._modulator.dispose();\n\t this._modulator = null;\n\t this._modulationNode.dispose();\n\t this._modulationNode = null;\n\t this.modulationIndex.dispose();\n\t this.modulationIndex = null;\n\t return this;\n\t };\n\t return Tone.FMOscillator;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.AMOscillator\n\t\t *\n\t\t * @extends {Tone.Oscillator}\n\t\t * @constructor\n\t\t * @param {Frequency} frequency The starting frequency of the oscillator.\n\t\t * @param {String} type The type of the carrier oscillator.\n\t\t * @param {String} modulationType The type of the modulator oscillator.\n\t\t * @example\n\t\t * //a sine oscillator frequency-modulated by a square wave\n\t\t * var fmOsc = new Tone.AMOscillator(\"Ab3\", \"sine\", \"square\").toMaster().start();\n\t\t */\n\t Tone.AMOscillator = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'type',\n\t 'modulationType'\n\t ], Tone.AMOscillator);\n\t Tone.Source.call(this, options);\n\t /**\n\t\t\t * The carrier oscillator\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t * @private\n\t\t\t */\n\t this._carrier = new Tone.Oscillator(options.frequency, options.type);\n\t /**\n\t\t\t * The oscillator's frequency\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = this._carrier.frequency;\n\t /**\n\t\t\t * The detune control signal.\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = this._carrier.detune;\n\t this.detune.value = options.detune;\n\t /**\n\t\t\t * The modulating oscillator\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t * @private\n\t\t\t */\n\t this._modulator = new Tone.Oscillator(options.frequency, options.modulationType);\n\t /**\n\t\t\t * convert the -1,1 output to 0,1\n\t\t\t * @type {Tone.AudioToGain}\n\t\t\t * @private\n\t\t\t */\n\t this._modulationScale = new Tone.AudioToGain();\n\t /**\n\t\t\t * Harmonicity is the frequency ratio between the carrier and the modulator oscillators.\n\t\t\t * A harmonicity of 1 gives both oscillators the same frequency.\n\t\t\t * Harmonicity = 2 means a change of an octave.\n\t\t\t * @type {Positive}\n\t\t\t * @signal\n\t\t\t * @example\n\t\t\t * //pitch the modulator an octave below carrier\n\t\t\t * synth.harmonicity.value = 0.5;\n\t\t\t */\n\t this.harmonicity = new Tone.Multiply(options.harmonicity);\n\t this.harmonicity.units = Tone.Type.Positive;\n\t /**\n\t\t\t * the node where the modulation happens\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._modulationNode = new Tone.Gain(0);\n\t //connections\n\t this.frequency.chain(this.harmonicity, this._modulator.frequency);\n\t this.detune.connect(this._modulator.detune);\n\t this._modulator.chain(this._modulationScale, this._modulationNode.gain);\n\t this._carrier.chain(this._modulationNode, this.output);\n\t this.phase = options.phase;\n\t this._readOnly([\n\t 'frequency',\n\t 'detune',\n\t 'harmonicity'\n\t ]);\n\t };\n\t Tone.extend(Tone.AMOscillator, Tone.Oscillator);\n\t /**\n\t\t * default values\n\t\t * @static\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.AMOscillator.defaults = {\n\t 'frequency': 440,\n\t 'detune': 0,\n\t 'phase': 0,\n\t 'modulationType': 'square',\n\t 'harmonicity': 1\n\t };\n\t /**\n\t\t * start the oscillator\n\t\t * @param {Time} [time=now]\n\t\t * @private\n\t\t */\n\t Tone.AMOscillator.prototype._start = function (time) {\n\t this._modulator.start(time);\n\t this._carrier.start(time);\n\t };\n\t /**\n\t\t * stop the oscillator\n\t\t * @param {Time} time (optional) timing parameter\n\t\t * @private\n\t\t */\n\t Tone.AMOscillator.prototype._stop = function (time) {\n\t this._modulator.stop(time);\n\t this._carrier.stop(time);\n\t };\n\t /**\n\t\t * restart the oscillator\n\t\t * @param {Time} time (optional) timing parameter\n\t\t * @private\n\t\t */\n\t Tone.AMOscillator.prototype.restart = function (time) {\n\t this._modulator.restart(time);\n\t this._carrier.restart(time);\n\t };\n\t /**\n\t\t * The type of the carrier oscillator\n\t\t * @memberOf Tone.AMOscillator#\n\t\t * @type {string}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.AMOscillator.prototype, 'type', {\n\t get: function () {\n\t return this._carrier.type;\n\t },\n\t set: function (type) {\n\t this._carrier.type = type;\n\t }\n\t });\n\t /**\n\t\t * The type of the modulator oscillator\n\t\t * @memberOf Tone.AMOscillator#\n\t\t * @type {string}\n\t\t * @name modulationType\n\t\t */\n\t Object.defineProperty(Tone.AMOscillator.prototype, 'modulationType', {\n\t get: function () {\n\t return this._modulator.type;\n\t },\n\t set: function (type) {\n\t this._modulator.type = type;\n\t }\n\t });\n\t /**\n\t\t * The phase of the oscillator in degrees.\n\t\t * @memberOf Tone.AMOscillator#\n\t\t * @type {number}\n\t\t * @name phase\n\t\t */\n\t Object.defineProperty(Tone.AMOscillator.prototype, 'phase', {\n\t get: function () {\n\t return this._carrier.phase;\n\t },\n\t set: function (phase) {\n\t this._carrier.phase = phase;\n\t this._modulator.phase = phase;\n\t }\n\t });\n\t /**\n\t\t * The partials of the carrier waveform. A partial represents\n\t\t * the amplitude at a harmonic. The first harmonic is the\n\t\t * fundamental frequency, the second is the octave and so on\n\t\t * following the harmonic series.\n\t\t * Setting this value will automatically set the type to \"custom\".\n\t\t * The value is an empty array when the type is not \"custom\".\n\t\t * @memberOf Tone.AMOscillator#\n\t\t * @type {Array}\n\t\t * @name partials\n\t\t * @example\n\t\t * osc.partials = [1, 0.2, 0.01];\n\t\t */\n\t Object.defineProperty(Tone.AMOscillator.prototype, 'partials', {\n\t get: function () {\n\t return this._carrier.partials;\n\t },\n\t set: function (partials) {\n\t this._carrier.partials = partials;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.AMOscillator} this\n\t\t */\n\t Tone.AMOscillator.prototype.dispose = function () {\n\t Tone.Source.prototype.dispose.call(this);\n\t this._writable([\n\t 'frequency',\n\t 'detune',\n\t 'harmonicity'\n\t ]);\n\t this.frequency = null;\n\t this.detune = null;\n\t this.harmonicity.dispose();\n\t this.harmonicity = null;\n\t this._carrier.dispose();\n\t this._carrier = null;\n\t this._modulator.dispose();\n\t this._modulator = null;\n\t this._modulationNode.dispose();\n\t this._modulationNode = null;\n\t this._modulationScale.dispose();\n\t this._modulationScale = null;\n\t return this;\n\t };\n\t return Tone.AMOscillator;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.FatOscillator\n\t\t *\n\t\t * @extends {Tone.Source}\n\t\t * @constructor\n\t\t * @param {Frequency} frequency The starting frequency of the oscillator.\n\t\t * @param {String} type The type of the carrier oscillator.\n\t\t * @param {String} modulationType The type of the modulator oscillator.\n\t\t * @example\n\t\t * //a sine oscillator frequency-modulated by a square wave\n\t\t * var fmOsc = new Tone.FatOscillator(\"Ab3\", \"sine\", \"square\").toMaster().start();\n\t\t */\n\t Tone.FatOscillator = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'type',\n\t 'spread'\n\t ], Tone.FatOscillator);\n\t Tone.Source.call(this, options);\n\t /**\n\t\t\t * The oscillator's frequency\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency);\n\t /**\n\t\t\t * The detune control signal.\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = new Tone.Signal(options.detune, Tone.Type.Cents);\n\t /**\n\t\t\t * The array of oscillators\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._oscillators = [];\n\t /**\n\t\t\t * The total spread of the oscillators\n\t\t\t * @type {Cents}\n\t\t\t * @private\n\t\t\t */\n\t this._spread = options.spread;\n\t /**\n\t\t\t * The type of the oscillator\n\t\t\t * @type {String}\n\t\t\t * @private\n\t\t\t */\n\t this._type = options.type;\n\t /**\n\t\t\t * The phase of the oscillators\n\t\t\t * @type {Degrees}\n\t\t\t * @private\n\t\t\t */\n\t this._phase = options.phase;\n\t /**\n\t\t\t * The partials array\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._partials = Tone.defaultArg(options.partials, []);\n\t //set the count initially\n\t this.count = options.count;\n\t this._readOnly([\n\t 'frequency',\n\t 'detune'\n\t ]);\n\t };\n\t Tone.extend(Tone.FatOscillator, Tone.Source);\n\t /**\n\t\t * default values\n\t\t * @static\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.FatOscillator.defaults = {\n\t 'frequency': 440,\n\t 'detune': 0,\n\t 'phase': 0,\n\t 'spread': 20,\n\t 'count': 3,\n\t 'type': 'sawtooth'\n\t };\n\t /**\n\t\t * start the oscillator\n\t\t * @param {Time} [time=now]\n\t\t * @private\n\t\t */\n\t Tone.FatOscillator.prototype._start = function (time) {\n\t time = this.toSeconds(time);\n\t this._forEach(function (osc) {\n\t osc.start(time);\n\t });\n\t };\n\t /**\n\t\t * stop the oscillator\n\t\t * @param {Time} [time=now]\n\t\t * @private\n\t\t */\n\t Tone.FatOscillator.prototype._stop = function (time) {\n\t time = this.toSeconds(time);\n\t this._forEach(function (osc) {\n\t osc.stop(time);\n\t });\n\t };\n\t /**\n\t\t * restart the oscillator\n\t\t * @param {Time} time (optional) timing parameter\n\t\t * @private\n\t\t */\n\t Tone.FatOscillator.prototype.restart = function (time) {\n\t time = this.toSeconds(time);\n\t this._forEach(function (osc) {\n\t osc.restart(time);\n\t });\n\t };\n\t /**\n\t\t * Iterate over all of the oscillators\n\t\t * @param {Function} iterator The iterator function\n\t\t * @private\n\t\t */\n\t Tone.FatOscillator.prototype._forEach = function (iterator) {\n\t for (var i = 0; i < this._oscillators.length; i++) {\n\t iterator.call(this, this._oscillators[i], i);\n\t }\n\t };\n\t /**\n\t\t * The type of the carrier oscillator\n\t\t * @memberOf Tone.FatOscillator#\n\t\t * @type {string}\n\t\t * @name type\n\t\t */\n\t Object.defineProperty(Tone.FatOscillator.prototype, 'type', {\n\t get: function () {\n\t return this._type;\n\t },\n\t set: function (type) {\n\t this._type = type;\n\t this._forEach(function (osc) {\n\t osc.type = type;\n\t });\n\t }\n\t });\n\t /**\n\t\t * The detune spread between the oscillators. If \"count\" is\n\t\t * set to 3 oscillators and the \"spread\" is set to 40,\n\t\t * the three oscillators would be detuned like this: [-20, 0, 20]\n\t\t * for a total detune spread of 40 cents.\n\t\t * @memberOf Tone.FatOscillator#\n\t\t * @type {Cents}\n\t\t * @name spread\n\t\t */\n\t Object.defineProperty(Tone.FatOscillator.prototype, 'spread', {\n\t get: function () {\n\t return this._spread;\n\t },\n\t set: function (spread) {\n\t this._spread = spread;\n\t if (this._oscillators.length > 1) {\n\t var start = -spread / 2;\n\t var step = spread / (this._oscillators.length - 1);\n\t this._forEach(function (osc, i) {\n\t osc.detune.value = start + step * i;\n\t });\n\t }\n\t }\n\t });\n\t /**\n\t\t * The number of detuned oscillators\n\t\t * @memberOf Tone.FatOscillator#\n\t\t * @type {Number}\n\t\t * @name count\n\t\t */\n\t Object.defineProperty(Tone.FatOscillator.prototype, 'count', {\n\t get: function () {\n\t return this._oscillators.length;\n\t },\n\t set: function (count) {\n\t count = Math.max(count, 1);\n\t if (this._oscillators.length !== count) {\n\t // var partials = this.partials;\n\t // var type = this.type;\n\t //dispose the previous oscillators\n\t this._forEach(function (osc) {\n\t osc.dispose();\n\t });\n\t this._oscillators = [];\n\t for (var i = 0; i < count; i++) {\n\t var osc = new Tone.Oscillator();\n\t if (this.type === Tone.Oscillator.Type.Custom) {\n\t osc.partials = this._partials;\n\t } else {\n\t osc.type = this._type;\n\t }\n\t osc.phase = this._phase;\n\t osc.volume.value = -6 - count * 1.1;\n\t this.frequency.connect(osc.frequency);\n\t this.detune.connect(osc.detune);\n\t osc.connect(this.output);\n\t this._oscillators[i] = osc;\n\t }\n\t //set the spread\n\t this.spread = this._spread;\n\t if (this.state === Tone.State.Started) {\n\t this._forEach(function (osc) {\n\t osc.start();\n\t });\n\t }\n\t }\n\t }\n\t });\n\t /**\n\t\t * The phase of the oscillator in degrees.\n\t\t * @memberOf Tone.FatOscillator#\n\t\t * @type {Number}\n\t\t * @name phase\n\t\t */\n\t Object.defineProperty(Tone.FatOscillator.prototype, 'phase', {\n\t get: function () {\n\t return this._phase;\n\t },\n\t set: function (phase) {\n\t this._phase = phase;\n\t this._forEach(function (osc) {\n\t osc.phase = phase;\n\t });\n\t }\n\t });\n\t /**\n\t\t * The partials of the carrier waveform. A partial represents\n\t\t * the amplitude at a harmonic. The first harmonic is the\n\t\t * fundamental frequency, the second is the octave and so on\n\t\t * following the harmonic series.\n\t\t * Setting this value will automatically set the type to \"custom\".\n\t\t * The value is an empty array when the type is not \"custom\".\n\t\t * @memberOf Tone.FatOscillator#\n\t\t * @type {Array}\n\t\t * @name partials\n\t\t * @example\n\t\t * osc.partials = [1, 0.2, 0.01];\n\t\t */\n\t Object.defineProperty(Tone.FatOscillator.prototype, 'partials', {\n\t get: function () {\n\t return this._partials;\n\t },\n\t set: function (partials) {\n\t this._partials = partials;\n\t this._type = Tone.Oscillator.Type.Custom;\n\t this._forEach(function (osc) {\n\t osc.partials = partials;\n\t });\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.FatOscillator} this\n\t\t */\n\t Tone.FatOscillator.prototype.dispose = function () {\n\t Tone.Source.prototype.dispose.call(this);\n\t this._writable([\n\t 'frequency',\n\t 'detune'\n\t ]);\n\t this.frequency.dispose();\n\t this.frequency = null;\n\t this.detune.dispose();\n\t this.detune = null;\n\t this._forEach(function (osc) {\n\t osc.dispose();\n\t });\n\t this._oscillators = null;\n\t this._partials = null;\n\t return this;\n\t };\n\t return Tone.FatOscillator;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.OmniOscillator aggregates Tone.Oscillator, Tone.PulseOscillator,\n\t\t * Tone.PWMOscillator, Tone.FMOscillator, Tone.AMOscillator, and Tone.FatOscillator\n\t\t * into one class. The oscillator class can be changed by setting the `type`.\n\t\t * `omniOsc.type = \"pwm\"` will set it to the Tone.PWMOscillator. Prefixing\n\t\t * any of the basic types (\"sine\", \"square4\", etc.) with \"fm\", \"am\", or \"fat\"\n\t\t * will use the FMOscillator, AMOscillator or FatOscillator respectively.\n\t\t * For example: `omniOsc.type = \"fatsawtooth\"` will create set the oscillator\n\t\t * to a FatOscillator of type \"sawtooth\".\n\t\t *\n\t\t * @extends {Tone.Source}\n\t\t * @constructor\n\t\t * @param {Frequency} frequency The initial frequency of the oscillator.\n\t\t * @param {String} type The type of the oscillator.\n\t\t * @example\n\t\t * var omniOsc = new Tone.OmniOscillator(\"C#4\", \"pwm\");\n\t\t */\n\t Tone.OmniOscillator = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'frequency',\n\t 'type'\n\t ], Tone.OmniOscillator);\n\t Tone.Source.call(this, options);\n\t /**\n\t\t\t * The frequency control.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency);\n\t /**\n\t\t\t * The detune control\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = new Tone.Signal(options.detune, Tone.Type.Cents);\n\t /**\n\t\t\t * the type of the oscillator source\n\t\t\t * @type {String}\n\t\t\t * @private\n\t\t\t */\n\t this._sourceType = undefined;\n\t /**\n\t\t\t * the oscillator\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t * @private\n\t\t\t */\n\t this._oscillator = null;\n\t //set the oscillator\n\t this.type = options.type;\n\t this._readOnly([\n\t 'frequency',\n\t 'detune'\n\t ]);\n\t //set the options\n\t this.set(options);\n\t };\n\t Tone.extend(Tone.OmniOscillator, Tone.Source);\n\t /**\n\t\t * default values\n\t\t * @static\n\t\t * @type {Object}\n\t\t * @const\n\t\t */\n\t Tone.OmniOscillator.defaults = {\n\t 'frequency': 440,\n\t 'detune': 0,\n\t 'type': 'sine',\n\t 'phase': 0\n\t };\n\t /**\n\t\t * @enum {String}\n\t\t * @private\n\t\t */\n\t var OmniOscType = {\n\t Pulse: 'PulseOscillator',\n\t PWM: 'PWMOscillator',\n\t Osc: 'Oscillator',\n\t FM: 'FMOscillator',\n\t AM: 'AMOscillator',\n\t Fat: 'FatOscillator'\n\t };\n\t /**\n\t\t * start the oscillator\n\t\t * @param {Time} [time=now] the time to start the oscillator\n\t\t * @private\n\t\t */\n\t Tone.OmniOscillator.prototype._start = function (time) {\n\t this._oscillator.start(time);\n\t };\n\t /**\n\t\t * start the oscillator\n\t\t * @param {Time} [time=now] the time to start the oscillator\n\t\t * @private\n\t\t */\n\t Tone.OmniOscillator.prototype._stop = function (time) {\n\t this._oscillator.stop(time);\n\t };\n\t Tone.OmniOscillator.prototype.restart = function (time) {\n\t this._oscillator.restart(time);\n\t };\n\t /**\n\t\t * The type of the oscillator. Can be any of the basic types: sine, square, triangle, sawtooth. Or\n\t\t * prefix the basic types with \"fm\", \"am\", or \"fat\" to use the FMOscillator, AMOscillator or FatOscillator\n\t\t * types. The oscillator could also be set to \"pwm\" or \"pulse\". All of the parameters of the\n\t\t * oscillator's class are accessible when the oscillator is set to that type, but throws an error\n\t\t * when it's not.\n\t\t *\n\t\t * @memberOf Tone.OmniOscillator#\n\t\t * @type {String}\n\t\t * @name type\n\t\t * @example\n\t\t * omniOsc.type = \"pwm\";\n\t\t * //modulationFrequency is parameter which is available\n\t\t * //only when the type is \"pwm\".\n\t\t * omniOsc.modulationFrequency.value = 0.5;\n\t\t * @example\n\t\t * //an square wave frequency modulated by a sawtooth\n\t\t * omniOsc.type = \"fmsquare\";\n\t\t * omniOsc.modulationType = \"sawtooth\";\n\t\t */\n\t Object.defineProperty(Tone.OmniOscillator.prototype, 'type', {\n\t get: function () {\n\t var prefix = '';\n\t if (this._sourceType === OmniOscType.FM) {\n\t prefix = 'fm';\n\t } else if (this._sourceType === OmniOscType.AM) {\n\t prefix = 'am';\n\t } else if (this._sourceType === OmniOscType.Fat) {\n\t prefix = 'fat';\n\t }\n\t return prefix + this._oscillator.type;\n\t },\n\t set: function (type) {\n\t if (type.substr(0, 2) === 'fm') {\n\t this._createNewOscillator(OmniOscType.FM);\n\t this._oscillator.type = type.substr(2);\n\t } else if (type.substr(0, 2) === 'am') {\n\t this._createNewOscillator(OmniOscType.AM);\n\t this._oscillator.type = type.substr(2);\n\t } else if (type.substr(0, 3) === 'fat') {\n\t this._createNewOscillator(OmniOscType.Fat);\n\t this._oscillator.type = type.substr(3);\n\t } else if (type === 'pwm') {\n\t this._createNewOscillator(OmniOscType.PWM);\n\t } else if (type === 'pulse') {\n\t this._createNewOscillator(OmniOscType.Pulse);\n\t } else {\n\t this._createNewOscillator(OmniOscType.Osc);\n\t this._oscillator.type = type;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The partials of the waveform. A partial represents\n\t\t * the amplitude at a harmonic. The first harmonic is the\n\t\t * fundamental frequency, the second is the octave and so on\n\t\t * following the harmonic series.\n\t\t * Setting this value will automatically set the type to \"custom\".\n\t\t * The value is an empty array when the type is not \"custom\".\n\t\t * This is not available on \"pwm\" and \"pulse\" oscillator types.\n\t\t * @memberOf Tone.OmniOscillator#\n\t\t * @type {Array}\n\t\t * @name partials\n\t\t * @example\n\t\t * osc.partials = [1, 0.2, 0.01];\n\t\t */\n\t Object.defineProperty(Tone.OmniOscillator.prototype, 'partials', {\n\t get: function () {\n\t return this._oscillator.partials;\n\t },\n\t set: function (partials) {\n\t this._oscillator.partials = partials;\n\t }\n\t });\n\t /**\n\t\t * Set a member/attribute of the oscillator.\n\t\t * @param {Object|String} params\n\t\t * @param {number=} value\n\t\t * @param {Time=} rampTime\n\t\t * @returns {Tone.OmniOscillator} this\n\t\t */\n\t Tone.OmniOscillator.prototype.set = function (params, value) {\n\t //make sure the type is set first\n\t if (params === 'type') {\n\t this.type = value;\n\t } else if (Tone.isObject(params) && params.hasOwnProperty('type')) {\n\t this.type = params.type;\n\t }\n\t //then set the rest\n\t Tone.prototype.set.apply(this, arguments);\n\t return this;\n\t };\n\t /**\n\t\t * connect the oscillator to the frequency and detune signals\n\t\t * @private\n\t\t */\n\t Tone.OmniOscillator.prototype._createNewOscillator = function (oscType) {\n\t if (oscType !== this._sourceType) {\n\t this._sourceType = oscType;\n\t var OscillatorConstructor = Tone[oscType];\n\t //short delay to avoid clicks on the change\n\t var now = this.now();\n\t if (this._oscillator !== null) {\n\t var oldOsc = this._oscillator;\n\t oldOsc.stop(now);\n\t //dispose the old one\n\t this.context.setTimeout(function () {\n\t oldOsc.dispose();\n\t oldOsc = null;\n\t }, this.blockTime);\n\t }\n\t this._oscillator = new OscillatorConstructor();\n\t this.frequency.connect(this._oscillator.frequency);\n\t this.detune.connect(this._oscillator.detune);\n\t this._oscillator.connect(this.output);\n\t if (this.state === Tone.State.Started) {\n\t this._oscillator.start(now);\n\t }\n\t }\n\t };\n\t /**\n\t\t * The phase of the oscillator in degrees.\n\t\t * @memberOf Tone.OmniOscillator#\n\t\t * @type {Degrees}\n\t\t * @name phase\n\t\t */\n\t Object.defineProperty(Tone.OmniOscillator.prototype, 'phase', {\n\t get: function () {\n\t return this._oscillator.phase;\n\t },\n\t set: function (phase) {\n\t this._oscillator.phase = phase;\n\t }\n\t });\n\t /**\n\t\t * The width of the oscillator (only if the oscillator is set to \"pulse\")\n\t\t * @memberOf Tone.OmniOscillator#\n\t\t * @type {NormalRange}\n\t\t * @signal\n\t\t * @name width\n\t\t * @example\n\t\t * var omniOsc = new Tone.OmniOscillator(440, \"pulse\");\n\t\t * //can access the width attribute only if type === \"pulse\"\n\t\t * omniOsc.width.value = 0.2;\n\t\t */\n\t Object.defineProperty(Tone.OmniOscillator.prototype, 'width', {\n\t get: function () {\n\t if (this._sourceType === OmniOscType.Pulse) {\n\t return this._oscillator.width;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The number of detuned oscillators\n\t\t * @memberOf Tone.OmniOscillator#\n\t\t * @type {Number}\n\t\t * @name count\n\t\t */\n\t Object.defineProperty(Tone.OmniOscillator.prototype, 'count', {\n\t get: function () {\n\t if (this._sourceType === OmniOscType.Fat) {\n\t return this._oscillator.count;\n\t }\n\t },\n\t set: function (count) {\n\t if (this._sourceType === OmniOscType.Fat) {\n\t this._oscillator.count = count;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The detune spread between the oscillators. If \"count\" is\n\t\t * set to 3 oscillators and the \"spread\" is set to 40,\n\t\t * the three oscillators would be detuned like this: [-20, 0, 20]\n\t\t * for a total detune spread of 40 cents. See Tone.FatOscillator\n\t\t * for more info.\n\t\t * @memberOf Tone.OmniOscillator#\n\t\t * @type {Cents}\n\t\t * @name spread\n\t\t */\n\t Object.defineProperty(Tone.OmniOscillator.prototype, 'spread', {\n\t get: function () {\n\t if (this._sourceType === OmniOscType.Fat) {\n\t return this._oscillator.spread;\n\t }\n\t },\n\t set: function (spread) {\n\t if (this._sourceType === OmniOscType.Fat) {\n\t this._oscillator.spread = spread;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The type of the modulator oscillator. Only if the oscillator\n\t\t * is set to \"am\" or \"fm\" types. see. Tone.AMOscillator or Tone.FMOscillator\n\t\t * for more info.\n\t\t * @memberOf Tone.OmniOscillator#\n\t\t * @type {String}\n\t\t * @name modulationType\n\t\t */\n\t Object.defineProperty(Tone.OmniOscillator.prototype, 'modulationType', {\n\t get: function () {\n\t if (this._sourceType === OmniOscType.FM || this._sourceType === OmniOscType.AM) {\n\t return this._oscillator.modulationType;\n\t }\n\t },\n\t set: function (mType) {\n\t if (this._sourceType === OmniOscType.FM || this._sourceType === OmniOscType.AM) {\n\t this._oscillator.modulationType = mType;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The modulation index which is in essence the depth or amount of the modulation. In other terms it is the\n\t\t * ratio of the frequency of the modulating signal (mf) to the amplitude of the\n\t\t * modulating signal (ma) -- as in ma/mf.\n\t\t * See Tone.FMOscillator for more info.\n\t\t * @type {Positive}\n\t\t * @signal\n\t\t * @name modulationIndex\n\t\t */\n\t Object.defineProperty(Tone.OmniOscillator.prototype, 'modulationIndex', {\n\t get: function () {\n\t if (this._sourceType === OmniOscType.FM) {\n\t return this._oscillator.modulationIndex;\n\t }\n\t }\n\t });\n\t /**\n\t\t * Harmonicity is the frequency ratio between the carrier and the modulator oscillators.\n\t\t * A harmonicity of 1 gives both oscillators the same frequency.\n\t\t * Harmonicity = 2 means a change of an octave. See Tone.AMOscillator or Tone.FMOscillator\n\t\t * for more info.\n\t\t * @memberOf Tone.OmniOscillator#\n\t\t * @signal\n\t\t * @type {Positive}\n\t\t * @name harmonicity\n\t\t */\n\t Object.defineProperty(Tone.OmniOscillator.prototype, 'harmonicity', {\n\t get: function () {\n\t if (this._sourceType === OmniOscType.FM || this._sourceType === OmniOscType.AM) {\n\t return this._oscillator.harmonicity;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The modulationFrequency Signal of the oscillator\n\t\t * (only if the oscillator type is set to pwm). See\n\t\t * Tone.PWMOscillator for more info.\n\t\t * @memberOf Tone.OmniOscillator#\n\t\t * @type {Frequency}\n\t\t * @signal\n\t\t * @name modulationFrequency\n\t\t * @example\n\t\t * var omniOsc = new Tone.OmniOscillator(440, \"pwm\");\n\t\t * //can access the modulationFrequency attribute only if type === \"pwm\"\n\t\t * omniOsc.modulationFrequency.value = 0.2;\n\t\t */\n\t Object.defineProperty(Tone.OmniOscillator.prototype, 'modulationFrequency', {\n\t get: function () {\n\t if (this._sourceType === OmniOscType.PWM) {\n\t return this._oscillator.modulationFrequency;\n\t }\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.OmniOscillator} this\n\t\t */\n\t Tone.OmniOscillator.prototype.dispose = function () {\n\t Tone.Source.prototype.dispose.call(this);\n\t this._writable([\n\t 'frequency',\n\t 'detune'\n\t ]);\n\t this.detune.dispose();\n\t this.detune = null;\n\t this.frequency.dispose();\n\t this.frequency = null;\n\t this._oscillator.dispose();\n\t this._oscillator = null;\n\t this._sourceType = null;\n\t return this;\n\t };\n\t return Tone.OmniOscillator;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Base-class for all instruments\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t */\n\t Tone.Instrument = function (options) {\n\t //get the defaults\n\t options = Tone.defaultArg(options, Tone.Instrument.defaults);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The output and volume triming node\n\t\t\t * @type {Tone.Volume}\n\t\t\t * @private\n\t\t\t */\n\t this._volume = this.output = new Tone.Volume(options.volume);\n\t /**\n\t\t\t * The volume of the output in decibels.\n\t\t\t * @type {Decibels}\n\t\t\t * @signal\n\t\t\t * @example\n\t\t\t * source.volume.value = -6;\n\t\t\t */\n\t this.volume = this._volume.volume;\n\t this._readOnly('volume');\n\t /**\n\t\t\t * Keep track of all events scheduled to the transport\n\t\t\t * when the instrument is 'synced'\n\t\t\t * @type {Array<Number>}\n\t\t\t * @private\n\t\t\t */\n\t this._scheduledEvents = [];\n\t };\n\t Tone.extend(Tone.Instrument, Tone.AudioNode);\n\t /**\n\t\t * the default attributes\n\t\t * @type {object}\n\t\t */\n\t Tone.Instrument.defaults = {\n\t /** the volume of the output in decibels */\n\t 'volume': 0\n\t };\n\t /**\n\t\t * @abstract\n\t\t * @param {string|number} note the note to trigger\n\t\t * @param {Time} [time=now] the time to trigger the ntoe\n\t\t * @param {number} [velocity=1] the velocity to trigger the note\n\t\t */\n\t Tone.Instrument.prototype.triggerAttack = Tone.noOp;\n\t /**\n\t\t * @abstract\n\t\t * @param {Time} [time=now] when to trigger the release\n\t\t */\n\t Tone.Instrument.prototype.triggerRelease = Tone.noOp;\n\t /**\n\t\t * Sync the instrument to the Transport. All subsequent calls of\n\t\t * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease)\n\t\t * will be scheduled along the transport.\n\t\t * @example\n\t\t * instrument.sync()\n\t\t * //schedule 3 notes when the transport first starts\n\t\t * instrument.triggerAttackRelease('C4', '8n', 0)\n\t\t * instrument.triggerAttackRelease('E4', '8n', '8n')\n\t\t * instrument.triggerAttackRelease('G4', '8n', '4n')\n\t\t * //start the transport to hear the notes\n\t\t * Transport.start()\n\t\t * @returns {Tone.Instrument} this\n\t\t */\n\t Tone.Instrument.prototype.sync = function () {\n\t this._syncMethod('triggerAttack', 1);\n\t this._syncMethod('triggerRelease', 0);\n\t return this;\n\t };\n\t /**\n\t\t * Wrap the given method so that it can be synchronized\n\t\t * @param {String} method Which method to wrap and sync\n\t\t * @param {Number} timePosition What position the time argument appears in\n\t\t * @private\n\t\t */\n\t Tone.Instrument.prototype._syncMethod = function (method, timePosition) {\n\t var originalMethod = this['_original_' + method] = this[method];\n\t this[method] = function () {\n\t var args = Array.prototype.slice.call(arguments);\n\t var time = args[timePosition];\n\t var id = Tone.Transport.schedule(function (t) {\n\t args[timePosition] = t;\n\t originalMethod.apply(this, args);\n\t }.bind(this), time);\n\t this._scheduledEvents.push(id);\n\t }.bind(this);\n\t };\n\t /**\n\t\t * Unsync the instrument from the Transport\n\t\t * @returns {Tone.Instrument} this\n\t\t */\n\t Tone.Instrument.prototype.unsync = function () {\n\t this._scheduledEvents.forEach(function (id) {\n\t Tone.Transport.clear(id);\n\t });\n\t this._scheduledEvents = [];\n\t if (this._original_triggerAttack) {\n\t this.triggerAttack = this._original_triggerAttack;\n\t this.triggerRelease = this._original_triggerRelease;\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Trigger the attack and then the release after the duration.\n\t\t * @param {Frequency} note The note to trigger.\n\t\t * @param {Time} duration How long the note should be held for before\n\t\t * triggering the release. This value must be greater than 0.\n\t\t * @param {Time} [time=now] When the note should be triggered.\n\t\t * @param {NormalRange} [velocity=1] The velocity the note should be triggered at.\n\t\t * @returns {Tone.Instrument} this\n\t\t * @example\n\t\t * //trigger \"C4\" for the duration of an 8th note\n\t\t * synth.triggerAttackRelease(\"C4\", \"8n\");\n\t\t */\n\t Tone.Instrument.prototype.triggerAttackRelease = function (note, duration, time, velocity) {\n\t time = this.toSeconds(time);\n\t duration = this.toSeconds(duration);\n\t this.triggerAttack(note, time, velocity);\n\t this.triggerRelease(time + duration);\n\t return this;\n\t };\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.Instrument} this\n\t\t */\n\t Tone.Instrument.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._volume.dispose();\n\t this._volume = null;\n\t this._writable(['volume']);\n\t this.volume = null;\n\t this.unsync();\n\t this._scheduledEvents = null;\n\t return this;\n\t };\n\t return Tone.Instrument;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class This is an abstract base class for other monophonic instruments to \n\t\t * extend. IMPORTANT: It does not make any sound on its own and\n\t\t * shouldn't be directly instantiated.\n\t\t *\n\t\t * @constructor\n\t\t * @abstract\n\t\t * @extends {Tone.Instrument}\n\t\t */\n\t Tone.Monophonic = function (options) {\n\t //get the defaults\n\t options = Tone.defaultArg(options, Tone.Monophonic.defaults);\n\t Tone.Instrument.call(this, options);\n\t /**\n\t\t\t * The glide time between notes. \n\t\t\t * @type {Time}\n\t\t\t */\n\t this.portamento = options.portamento;\n\t };\n\t Tone.extend(Tone.Monophonic, Tone.Instrument);\n\t /**\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Monophonic.defaults = { 'portamento': 0 };\n\t /**\n\t\t * Trigger the attack of the note optionally with a given velocity. \n\t\t * \n\t\t * \n\t\t * @param {Frequency} note The note to trigger.\n\t\t * @param {Time} [time=now] When the note should start.\n\t\t * @param {number} [velocity=1] velocity The velocity scaler \n\t\t * determines how \"loud\" the note \n\t\t * will be triggered.\n\t\t * @returns {Tone.Monophonic} this\n\t\t * @example\n\t\t * synth.triggerAttack(\"C4\");\n\t\t * @example\n\t\t * //trigger the note a half second from now at half velocity\n\t\t * synth.triggerAttack(\"C4\", \"+0.5\", 0.5);\n\t\t */\n\t Tone.Monophonic.prototype.triggerAttack = function (note, time, velocity) {\n\t time = this.toSeconds(time);\n\t this._triggerEnvelopeAttack(time, velocity);\n\t this.setNote(note, time);\n\t return this;\n\t };\n\t /**\n\t\t * Trigger the release portion of the envelope\n\t\t * @param {Time} [time=now] If no time is given, the release happens immediatly\n\t\t * @returns {Tone.Monophonic} this\n\t\t * @example\n\t\t * synth.triggerRelease();\n\t\t */\n\t Tone.Monophonic.prototype.triggerRelease = function (time) {\n\t time = this.toSeconds(time);\n\t this._triggerEnvelopeRelease(time);\n\t return this;\n\t };\n\t /**\n\t\t * override this method with the actual method\n\t\t * @abstract\n\t\t * @private\n\t\t */\n\t Tone.Monophonic.prototype._triggerEnvelopeAttack = function () {\n\t };\n\t /**\n\t\t * override this method with the actual method\n\t\t * @abstract\n\t\t * @private\n\t\t */\n\t Tone.Monophonic.prototype._triggerEnvelopeRelease = function () {\n\t };\n\t /**\n\t\t * Get the level of the output at the given time. Measures\n\t\t * the envelope(s) value at the time. \n\t\t * @param {Time} time The time to query the envelope value\n\t\t * @return {NormalRange} The output level between 0-1\n\t\t */\n\t Tone.Monophonic.prototype.getLevelAtTime = function (time) {\n\t time = this.toSeconds(time);\n\t return this.envelope.getValueAtTime(time);\n\t };\n\t /**\n\t\t * Set the note at the given time. If no time is given, the note\n\t\t * will set immediately. \n\t\t * @param {Frequency} note The note to change to.\n\t\t * @param {Time} [time=now] The time when the note should be set. \n\t\t * @returns {Tone.Monophonic} this\n\t\t * @example\n\t\t * //change to F#6 in one quarter note from now.\n\t\t * synth.setNote(\"F#6\", \"+4n\");\n\t\t * @example\n\t\t * //change to Bb4 right now\n\t\t * synth.setNote(\"Bb4\");\n\t\t */\n\t Tone.Monophonic.prototype.setNote = function (note, time) {\n\t time = this.toSeconds(time);\n\t if (this.portamento > 0 && this.getLevelAtTime(time) > 0.05) {\n\t var portTime = this.toSeconds(this.portamento);\n\t this.frequency.exponentialRampTo(note, portTime, time);\n\t } else {\n\t this.frequency.setValueAtTime(note, time);\n\t }\n\t return this;\n\t };\n\t return Tone.Monophonic;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Synth is composed simply of a Tone.OmniOscillator\n\t\t * routed through a Tone.AmplitudeEnvelope.\n\t\t * <img src=\"https://docs.google.com/drawings/d/1-1_0YW2Z1J2EPI36P8fNCMcZG7N1w1GZluPs4og4evo/pub?w=1163&h=231\">\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Monophonic}\n\t\t * @param {Object} [options] the options available for the synth\n\t\t * see defaults below\n\t\t * @example\n\t\t * var synth = new Tone.Synth().toMaster();\n\t\t * synth.triggerAttackRelease(\"C4\", \"8n\");\n\t\t */\n\t Tone.Synth = function (options) {\n\t //get the defaults\n\t options = Tone.defaultArg(options, Tone.Synth.defaults);\n\t Tone.Monophonic.call(this, options);\n\t /**\n\t\t\t * The oscillator.\n\t\t\t * @type {Tone.OmniOscillator}\n\t\t\t */\n\t this.oscillator = new Tone.OmniOscillator(options.oscillator);\n\t /**\n\t\t\t * The frequency control.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = this.oscillator.frequency;\n\t /**\n\t\t\t * The detune control.\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = this.oscillator.detune;\n\t /**\n\t\t\t * The amplitude envelope.\n\t\t\t * @type {Tone.AmplitudeEnvelope}\n\t\t\t */\n\t this.envelope = new Tone.AmplitudeEnvelope(options.envelope);\n\t //connect the oscillators to the output\n\t this.oscillator.chain(this.envelope, this.output);\n\t this._readOnly([\n\t 'oscillator',\n\t 'frequency',\n\t 'detune',\n\t 'envelope'\n\t ]);\n\t };\n\t Tone.extend(Tone.Synth, Tone.Monophonic);\n\t /**\n\t\t * @const\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.Synth.defaults = {\n\t 'oscillator': { 'type': 'triangle' },\n\t 'envelope': {\n\t 'attack': 0.005,\n\t 'decay': 0.1,\n\t 'sustain': 0.3,\n\t 'release': 1\n\t }\n\t };\n\t /**\n\t\t * start the attack portion of the envelope\n\t\t * @param {Time} [time=now] the time the attack should start\n\t\t * @param {number} [velocity=1] the velocity of the note (0-1)\n\t\t * @returns {Tone.Synth} this\n\t\t * @private\n\t\t */\n\t Tone.Synth.prototype._triggerEnvelopeAttack = function (time, velocity) {\n\t //the envelopes\n\t this.envelope.triggerAttack(time, velocity);\n\t this.oscillator.start(time);\n\t //if there is no release portion, stop the oscillator\n\t if (this.envelope.sustain === 0) {\n\t this.oscillator.stop(time + this.envelope.attack + this.envelope.decay);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * start the release portion of the envelope\n\t\t * @param {Time} [time=now] the time the release should start\n\t\t * @returns {Tone.Synth} this\n\t\t * @private\n\t\t */\n\t Tone.Synth.prototype._triggerEnvelopeRelease = function (time) {\n\t time = this.toSeconds(time);\n\t this.envelope.triggerRelease(time);\n\t this.oscillator.stop(time + this.envelope.release);\n\t return this;\n\t };\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.Synth} this\n\t\t */\n\t Tone.Synth.prototype.dispose = function () {\n\t Tone.Monophonic.prototype.dispose.call(this);\n\t this._writable([\n\t 'oscillator',\n\t 'frequency',\n\t 'detune',\n\t 'envelope'\n\t ]);\n\t this.oscillator.dispose();\n\t this.oscillator = null;\n\t this.envelope.dispose();\n\t this.envelope = null;\n\t this.frequency = null;\n\t this.detune = null;\n\t return this;\n\t };\n\t return Tone.Synth;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class AMSynth uses the output of one Tone.Synth to modulate the\n\t\t * amplitude of another Tone.Synth. The harmonicity (the ratio between\n\t\t * the two signals) affects the timbre of the output signal greatly.\n\t\t * Read more about Amplitude Modulation Synthesis on\n\t\t * [SoundOnSound](https://web.archive.org/web/20160404103653/http://www.soundonsound.com:80/sos/mar00/articles/synthsecrets.htm).\n\t\t * <img src=\"https://docs.google.com/drawings/d/1TQu8Ed4iFr1YTLKpB3U1_hur-UwBrh5gdBXc8BxfGKw/pub?w=1009&h=457\">\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Monophonic}\n\t\t * @param {Object} [options] the options available for the synth\n\t\t * see defaults below\n\t\t * @example\n\t\t * var synth = new Tone.AMSynth().toMaster();\n\t\t * synth.triggerAttackRelease(\"C4\", \"4n\");\n\t\t */\n\t Tone.AMSynth = function (options) {\n\t options = Tone.defaultArg(options, Tone.AMSynth.defaults);\n\t Tone.Monophonic.call(this, options);\n\t /**\n\t\t\t * The carrier voice.\n\t\t\t * @type {Tone.Synth}\n\t\t\t * @private\n\t\t\t */\n\t this._carrier = new Tone.Synth();\n\t this._carrier.volume.value = -10;\n\t /**\n\t\t\t * The carrier's oscillator\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t */\n\t this.oscillator = this._carrier.oscillator;\n\t /**\n\t\t\t * The carrier's envelope\n\t\t\t * @type {Tone.AmplitudeEnvelope}\n\t\t\t */\n\t this.envelope = this._carrier.envelope.set(options.envelope);\n\t /**\n\t\t\t * The modulator voice.\n\t\t\t * @type {Tone.Synth}\n\t\t\t * @private\n\t\t\t */\n\t this._modulator = new Tone.Synth();\n\t this._modulator.volume.value = -10;\n\t /**\n\t\t\t * The modulator's oscillator which is applied\n\t\t\t * to the amplitude of the oscillator\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t */\n\t this.modulation = this._modulator.oscillator.set(options.modulation);\n\t /**\n\t\t\t * The modulator's envelope\n\t\t\t * @type {Tone.AmplitudeEnvelope}\n\t\t\t */\n\t this.modulationEnvelope = this._modulator.envelope.set(options.modulationEnvelope);\n\t /**\n\t\t\t * The frequency.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = new Tone.Signal(440, Tone.Type.Frequency);\n\t /**\n\t\t\t * The detune in cents\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = new Tone.Signal(options.detune, Tone.Type.Cents);\n\t /**\n\t\t\t * Harmonicity is the ratio between the two voices. A harmonicity of\n\t\t\t * 1 is no change. Harmonicity = 2 means a change of an octave.\n\t\t\t * @type {Positive}\n\t\t\t * @signal\n\t\t\t * @example\n\t\t\t * //pitch voice1 an octave below voice0\n\t\t\t * synth.harmonicity.value = 0.5;\n\t\t\t */\n\t this.harmonicity = new Tone.Multiply(options.harmonicity);\n\t this.harmonicity.units = Tone.Type.Positive;\n\t /**\n\t\t\t * convert the -1,1 output to 0,1\n\t\t\t * @type {Tone.AudioToGain}\n\t\t\t * @private\n\t\t\t */\n\t this._modulationScale = new Tone.AudioToGain();\n\t /**\n\t\t\t * the node where the modulation happens\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._modulationNode = new Tone.Gain();\n\t //control the two voices frequency\n\t this.frequency.connect(this._carrier.frequency);\n\t this.frequency.chain(this.harmonicity, this._modulator.frequency);\n\t this.detune.fan(this._carrier.detune, this._modulator.detune);\n\t this._modulator.chain(this._modulationScale, this._modulationNode.gain);\n\t this._carrier.chain(this._modulationNode, this.output);\n\t this._readOnly([\n\t 'frequency',\n\t 'harmonicity',\n\t 'oscillator',\n\t 'envelope',\n\t 'modulation',\n\t 'modulationEnvelope',\n\t 'detune'\n\t ]);\n\t };\n\t Tone.extend(Tone.AMSynth, Tone.Monophonic);\n\t /**\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.AMSynth.defaults = {\n\t 'harmonicity': 3,\n\t 'detune': 0,\n\t 'oscillator': { 'type': 'sine' },\n\t 'envelope': {\n\t 'attack': 0.01,\n\t 'decay': 0.01,\n\t 'sustain': 1,\n\t 'release': 0.5\n\t },\n\t 'modulation': { 'type': 'square' },\n\t 'modulationEnvelope': {\n\t 'attack': 0.5,\n\t 'decay': 0,\n\t 'sustain': 1,\n\t 'release': 0.5\n\t }\n\t };\n\t /**\n\t\t * trigger the attack portion of the note\n\t\t *\n\t\t * @param {Time} [time=now] the time the note will occur\n\t\t * @param {NormalRange} [velocity=1] the velocity of the note\n\t\t * @private\n\t\t * @returns {Tone.AMSynth} this\n\t\t */\n\t Tone.AMSynth.prototype._triggerEnvelopeAttack = function (time, velocity) {\n\t //the port glide\n\t time = this.toSeconds(time);\n\t //the envelopes\n\t this._carrier._triggerEnvelopeAttack(time, velocity);\n\t this._modulator._triggerEnvelopeAttack(time);\n\t return this;\n\t };\n\t /**\n\t\t * trigger the release portion of the note\n\t\t *\n\t\t * @param {Time} [time=now] the time the note will release\n\t\t * @private\n\t\t * @returns {Tone.AMSynth} this\n\t\t */\n\t Tone.AMSynth.prototype._triggerEnvelopeRelease = function (time) {\n\t this._carrier._triggerEnvelopeRelease(time);\n\t this._modulator._triggerEnvelopeRelease(time);\n\t return this;\n\t };\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.AMSynth} this\n\t\t */\n\t Tone.AMSynth.prototype.dispose = function () {\n\t Tone.Monophonic.prototype.dispose.call(this);\n\t this._writable([\n\t 'frequency',\n\t 'harmonicity',\n\t 'oscillator',\n\t 'envelope',\n\t 'modulation',\n\t 'modulationEnvelope',\n\t 'detune'\n\t ]);\n\t this._carrier.dispose();\n\t this._carrier = null;\n\t this._modulator.dispose();\n\t this._modulator = null;\n\t this.frequency.dispose();\n\t this.frequency = null;\n\t this.detune.dispose();\n\t this.detune = null;\n\t this.harmonicity.dispose();\n\t this.harmonicity = null;\n\t this._modulationScale.dispose();\n\t this._modulationScale = null;\n\t this._modulationNode.dispose();\n\t this._modulationNode = null;\n\t this.oscillator = null;\n\t this.envelope = null;\n\t this.modulationEnvelope = null;\n\t this.modulation = null;\n\t return this;\n\t };\n\t return Tone.AMSynth;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.MonoSynth is composed of one oscillator, one filter, and two envelopes.\n\t\t * The amplitude of the Tone.Oscillator and the cutoff frequency of the\n\t\t * Tone.Filter are controlled by Tone.Envelopes.\n\t\t * <img src=\"https://docs.google.com/drawings/d/1gaY1DF9_Hzkodqf8JI1Cg2VZfwSElpFQfI94IQwad38/pub?w=924&h=240\">\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Monophonic}\n\t\t * @param {Object} [options] the options available for the synth\n\t\t * see defaults below\n\t\t * @example\n\t\t * var synth = new Tone.MonoSynth({\n\t\t * \t\"oscillator\" : {\n\t\t * \t\t\"type\" : \"square\"\n\t\t * },\n\t\t * \"envelope\" : {\n\t\t * \t\"attack\" : 0.1\n\t\t * }\n\t\t * }).toMaster();\n\t\t * synth.triggerAttackRelease(\"C4\", \"8n\");\n\t\t */\n\t Tone.MonoSynth = function (options) {\n\t //get the defaults\n\t options = Tone.defaultArg(options, Tone.MonoSynth.defaults);\n\t Tone.Monophonic.call(this, options);\n\t /**\n\t\t\t * The oscillator.\n\t\t\t * @type {Tone.OmniOscillator}\n\t\t\t */\n\t this.oscillator = new Tone.OmniOscillator(options.oscillator);\n\t /**\n\t\t\t * The frequency control.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = this.oscillator.frequency;\n\t /**\n\t\t\t * The detune control.\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = this.oscillator.detune;\n\t /**\n\t\t\t * The filter.\n\t\t\t * @type {Tone.Filter}\n\t\t\t */\n\t this.filter = new Tone.Filter(options.filter);\n\t /**\n\t\t\t * The filter envelope.\n\t\t\t * @type {Tone.FrequencyEnvelope}\n\t\t\t */\n\t this.filterEnvelope = new Tone.FrequencyEnvelope(options.filterEnvelope);\n\t /**\n\t\t\t * The amplitude envelope.\n\t\t\t * @type {Tone.AmplitudeEnvelope}\n\t\t\t */\n\t this.envelope = new Tone.AmplitudeEnvelope(options.envelope);\n\t //connect the oscillators to the output\n\t this.oscillator.chain(this.filter, this.envelope, this.output);\n\t //connect the filter envelope\n\t this.filterEnvelope.connect(this.filter.frequency);\n\t this._readOnly([\n\t 'oscillator',\n\t 'frequency',\n\t 'detune',\n\t 'filter',\n\t 'filterEnvelope',\n\t 'envelope'\n\t ]);\n\t };\n\t Tone.extend(Tone.MonoSynth, Tone.Monophonic);\n\t /**\n\t\t * @const\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.MonoSynth.defaults = {\n\t 'frequency': 'C4',\n\t 'detune': 0,\n\t 'oscillator': { 'type': 'square' },\n\t 'filter': {\n\t 'Q': 6,\n\t 'type': 'lowpass',\n\t 'rolloff': -24\n\t },\n\t 'envelope': {\n\t 'attack': 0.005,\n\t 'decay': 0.1,\n\t 'sustain': 0.9,\n\t 'release': 1\n\t },\n\t 'filterEnvelope': {\n\t 'attack': 0.06,\n\t 'decay': 0.2,\n\t 'sustain': 0.5,\n\t 'release': 2,\n\t 'baseFrequency': 200,\n\t 'octaves': 7,\n\t 'exponent': 2\n\t }\n\t };\n\t /**\n\t\t * start the attack portion of the envelope\n\t\t * @param {Time} [time=now] the time the attack should start\n\t\t * @param {NormalRange} [velocity=1] the velocity of the note (0-1)\n\t\t * @returns {Tone.MonoSynth} this\n\t\t * @private\n\t\t */\n\t Tone.MonoSynth.prototype._triggerEnvelopeAttack = function (time, velocity) {\n\t time = this.toSeconds(time);\n\t //the envelopes\n\t this.envelope.triggerAttack(time, velocity);\n\t this.filterEnvelope.triggerAttack(time);\n\t this.oscillator.start(time);\n\t if (this.envelope.sustain === 0) {\n\t this.oscillator.stop(time + this.envelope.attack + this.envelope.decay);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * start the release portion of the envelope\n\t\t * @param {Time} [time=now] the time the release should start\n\t\t * @returns {Tone.MonoSynth} this\n\t\t * @private\n\t\t */\n\t Tone.MonoSynth.prototype._triggerEnvelopeRelease = function (time) {\n\t this.envelope.triggerRelease(time);\n\t this.filterEnvelope.triggerRelease(time);\n\t this.oscillator.stop(time + this.envelope.release);\n\t return this;\n\t };\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.MonoSynth} this\n\t\t */\n\t Tone.MonoSynth.prototype.dispose = function () {\n\t Tone.Monophonic.prototype.dispose.call(this);\n\t this._writable([\n\t 'oscillator',\n\t 'frequency',\n\t 'detune',\n\t 'filter',\n\t 'filterEnvelope',\n\t 'envelope'\n\t ]);\n\t this.oscillator.dispose();\n\t this.oscillator = null;\n\t this.envelope.dispose();\n\t this.envelope = null;\n\t this.filterEnvelope.dispose();\n\t this.filterEnvelope = null;\n\t this.filter.dispose();\n\t this.filter = null;\n\t this.frequency = null;\n\t this.detune = null;\n\t return this;\n\t };\n\t return Tone.MonoSynth;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.DuoSynth is a monophonic synth composed of two\n\t\t * MonoSynths run in parallel with control over the\n\t\t * frequency ratio between the two voices and vibrato effect.\n\t\t * <img src=\"https://docs.google.com/drawings/d/1bL4GXvfRMMlqS7XyBm9CjL9KJPSUKbcdBNpqOlkFLxk/pub?w=1012&h=448\">\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Monophonic}\n\t\t * @param {Object} [options] the options available for the synth\n\t\t * see defaults below\n\t\t * @example\n\t\t * var duoSynth = new Tone.DuoSynth().toMaster();\n\t\t * duoSynth.triggerAttackRelease(\"C4\", \"2n\");\n\t\t */\n\t Tone.DuoSynth = function (options) {\n\t options = Tone.defaultArg(options, Tone.DuoSynth.defaults);\n\t Tone.Monophonic.call(this, options);\n\t /**\n\t\t\t * the first voice\n\t\t\t * @type {Tone.MonoSynth}\n\t\t\t */\n\t this.voice0 = new Tone.MonoSynth(options.voice0);\n\t this.voice0.volume.value = -10;\n\t /**\n\t\t\t * the second voice\n\t\t\t * @type {Tone.MonoSynth}\n\t\t\t */\n\t this.voice1 = new Tone.MonoSynth(options.voice1);\n\t this.voice1.volume.value = -10;\n\t /**\n\t\t\t * The vibrato LFO.\n\t\t\t * @type {Tone.LFO}\n\t\t\t * @private\n\t\t\t */\n\t this._vibrato = new Tone.LFO(options.vibratoRate, -50, 50);\n\t this._vibrato.start();\n\t /**\n\t\t\t * the vibrato frequency\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.vibratoRate = this._vibrato.frequency;\n\t /**\n\t\t\t * the vibrato gain\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._vibratoGain = new Tone.Gain(options.vibratoAmount, Tone.Type.Positive);\n\t /**\n\t\t\t * The amount of vibrato\n\t\t\t * @type {Positive}\n\t\t\t * @signal\n\t\t\t */\n\t this.vibratoAmount = this._vibratoGain.gain;\n\t /**\n\t\t\t * the frequency control\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = new Tone.Signal(440, Tone.Type.Frequency);\n\t /**\n\t\t\t * Harmonicity is the ratio between the two voices. A harmonicity of\n\t\t\t * 1 is no change. Harmonicity = 2 means a change of an octave.\n\t\t\t * @type {Positive}\n\t\t\t * @signal\n\t\t\t * @example\n\t\t\t * //pitch voice1 an octave below voice0\n\t\t\t * duoSynth.harmonicity.value = 0.5;\n\t\t\t */\n\t this.harmonicity = new Tone.Multiply(options.harmonicity);\n\t this.harmonicity.units = Tone.Type.Positive;\n\t //control the two voices frequency\n\t this.frequency.connect(this.voice0.frequency);\n\t this.frequency.chain(this.harmonicity, this.voice1.frequency);\n\t this._vibrato.connect(this._vibratoGain);\n\t this._vibratoGain.fan(this.voice0.detune, this.voice1.detune);\n\t this.voice0.connect(this.output);\n\t this.voice1.connect(this.output);\n\t this._readOnly([\n\t 'voice0',\n\t 'voice1',\n\t 'frequency',\n\t 'vibratoAmount',\n\t 'vibratoRate'\n\t ]);\n\t };\n\t Tone.extend(Tone.DuoSynth, Tone.Monophonic);\n\t /**\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.DuoSynth.defaults = {\n\t 'vibratoAmount': 0.5,\n\t 'vibratoRate': 5,\n\t 'harmonicity': 1.5,\n\t 'voice0': {\n\t 'volume': -10,\n\t 'portamento': 0,\n\t 'oscillator': { 'type': 'sine' },\n\t 'filterEnvelope': {\n\t 'attack': 0.01,\n\t 'decay': 0,\n\t 'sustain': 1,\n\t 'release': 0.5\n\t },\n\t 'envelope': {\n\t 'attack': 0.01,\n\t 'decay': 0,\n\t 'sustain': 1,\n\t 'release': 0.5\n\t }\n\t },\n\t 'voice1': {\n\t 'volume': -10,\n\t 'portamento': 0,\n\t 'oscillator': { 'type': 'sine' },\n\t 'filterEnvelope': {\n\t 'attack': 0.01,\n\t 'decay': 0,\n\t 'sustain': 1,\n\t 'release': 0.5\n\t },\n\t 'envelope': {\n\t 'attack': 0.01,\n\t 'decay': 0,\n\t 'sustain': 1,\n\t 'release': 0.5\n\t }\n\t }\n\t };\n\t /**\n\t\t * start the attack portion of the envelopes\n\t\t *\n\t\t * @param {Time} [time=now] the time the attack should start\n\t\t * @param {NormalRange} [velocity=1] the velocity of the note (0-1)\n\t\t * @returns {Tone.DuoSynth} this\n\t\t * @private\n\t\t */\n\t Tone.DuoSynth.prototype._triggerEnvelopeAttack = function (time, velocity) {\n\t time = this.toSeconds(time);\n\t this.voice0._triggerEnvelopeAttack(time, velocity);\n\t this.voice1._triggerEnvelopeAttack(time, velocity);\n\t return this;\n\t };\n\t /**\n\t\t * start the release portion of the envelopes\n\t\t *\n\t\t * @param {Time} [time=now] the time the release should start\n\t\t * @returns {Tone.DuoSynth} this\n\t\t * @private\n\t\t */\n\t Tone.DuoSynth.prototype._triggerEnvelopeRelease = function (time) {\n\t this.voice0._triggerEnvelopeRelease(time);\n\t this.voice1._triggerEnvelopeRelease(time);\n\t return this;\n\t };\n\t /**\n\t\t * Get the level of the output at the given time. Measures\n\t\t * the envelope(s) value at the time. \n\t\t * @param {Time} time The time to query the envelope value\n\t\t * @return {NormalRange} The output level between 0-1\n\t\t */\n\t Tone.DuoSynth.prototype.getLevelAtTime = function (time) {\n\t return (this.voice0.getLevelAtTime(time) + this.voice1.getLevelAtTime(time)) / 2;\n\t };\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.DuoSynth} this\n\t\t */\n\t Tone.DuoSynth.prototype.dispose = function () {\n\t Tone.Monophonic.prototype.dispose.call(this);\n\t this._writable([\n\t 'voice0',\n\t 'voice1',\n\t 'frequency',\n\t 'vibratoAmount',\n\t 'vibratoRate'\n\t ]);\n\t this.voice0.dispose();\n\t this.voice0 = null;\n\t this.voice1.dispose();\n\t this.voice1 = null;\n\t this.frequency.dispose();\n\t this.frequency = null;\n\t this._vibratoGain.dispose();\n\t this._vibratoGain = null;\n\t this._vibrato = null;\n\t this.harmonicity.dispose();\n\t this.harmonicity = null;\n\t this.vibratoAmount.dispose();\n\t this.vibratoAmount = null;\n\t this.vibratoRate = null;\n\t return this;\n\t };\n\t return Tone.DuoSynth;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class FMSynth is composed of two Tone.Synths where one Tone.Synth modulates\n\t\t * the frequency of a second Tone.Synth. A lot of spectral content\n\t\t * can be explored using the modulationIndex parameter. Read more about\n\t\t * frequency modulation synthesis on Sound On Sound: [Part 1](https://web.archive.org/web/20160403123704/http://www.soundonsound.com/sos/apr00/articles/synthsecrets.htm), [Part 2](https://web.archive.org/web/20160403115835/http://www.soundonsound.com/sos/may00/articles/synth.htm).\n\t\t * <img src=\"https://docs.google.com/drawings/d/1h0PUDZXPgi4Ikx6bVT6oncrYPLluFKy7lj53puxj-DM/pub?w=902&h=462\">\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Monophonic}\n\t\t * @param {Object} [options] the options available for the synth\n\t\t * see defaults below\n\t\t * @example\n\t\t * var fmSynth = new Tone.FMSynth().toMaster();\n\t\t * fmSynth.triggerAttackRelease(\"C5\", \"4n\");\n\t\t */\n\t Tone.FMSynth = function (options) {\n\t options = Tone.defaultArg(options, Tone.FMSynth.defaults);\n\t Tone.Monophonic.call(this, options);\n\t /**\n\t\t\t * The carrier voice.\n\t\t\t * @type {Tone.Synth}\n\t\t\t * @private\n\t\t\t */\n\t this._carrier = new Tone.Synth(options.carrier);\n\t this._carrier.volume.value = -10;\n\t /**\n\t\t\t * The carrier's oscillator\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t */\n\t this.oscillator = this._carrier.oscillator;\n\t /**\n\t\t\t * The carrier's envelope\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t */\n\t this.envelope = this._carrier.envelope.set(options.envelope);\n\t /**\n\t\t\t * The modulator voice.\n\t\t\t * @type {Tone.Synth}\n\t\t\t * @private\n\t\t\t */\n\t this._modulator = new Tone.Synth(options.modulator);\n\t this._modulator.volume.value = -10;\n\t /**\n\t\t\t * The modulator's oscillator which is applied\n\t\t\t * to the amplitude of the oscillator\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t */\n\t this.modulation = this._modulator.oscillator.set(options.modulation);\n\t /**\n\t\t\t * The modulator's envelope\n\t\t\t * @type {Tone.Oscillator}\n\t\t\t */\n\t this.modulationEnvelope = this._modulator.envelope.set(options.modulationEnvelope);\n\t /**\n\t\t\t * The frequency control.\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = new Tone.Signal(440, Tone.Type.Frequency);\n\t /**\n\t\t\t * The detune in cents\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = new Tone.Signal(options.detune, Tone.Type.Cents);\n\t /**\n\t\t\t * Harmonicity is the ratio between the two voices. A harmonicity of\n\t\t\t * 1 is no change. Harmonicity = 2 means a change of an octave.\n\t\t\t * @type {Positive}\n\t\t\t * @signal\n\t\t\t * @example\n\t\t\t * //pitch voice1 an octave below voice0\n\t\t\t * synth.harmonicity.value = 0.5;\n\t\t\t */\n\t this.harmonicity = new Tone.Multiply(options.harmonicity);\n\t this.harmonicity.units = Tone.Type.Positive;\n\t /**\n\t\t\t * The modulation index which essentially the depth or amount of the modulation. It is the\n\t\t\t * ratio of the frequency of the modulating signal (mf) to the amplitude of the\n\t\t\t * modulating signal (ma) -- as in ma/mf.\n\t\t\t *\t@type {Positive}\n\t\t\t *\t@signal\n\t\t\t */\n\t this.modulationIndex = new Tone.Multiply(options.modulationIndex);\n\t this.modulationIndex.units = Tone.Type.Positive;\n\t /**\n\t\t\t * the node where the modulation happens\n\t\t\t * @type {GainNode}\n\t\t\t * @private\n\t\t\t */\n\t this._modulationNode = new Tone.Gain(0);\n\t //control the two voices frequency\n\t this.frequency.connect(this._carrier.frequency);\n\t this.frequency.chain(this.harmonicity, this._modulator.frequency);\n\t this.frequency.chain(this.modulationIndex, this._modulationNode);\n\t this.detune.fan(this._carrier.detune, this._modulator.detune);\n\t this._modulator.connect(this._modulationNode.gain);\n\t this._modulationNode.connect(this._carrier.frequency);\n\t this._carrier.connect(this.output);\n\t this._readOnly([\n\t 'frequency',\n\t 'harmonicity',\n\t 'modulationIndex',\n\t 'oscillator',\n\t 'envelope',\n\t 'modulation',\n\t 'modulationEnvelope',\n\t 'detune'\n\t ]);\n\t };\n\t Tone.extend(Tone.FMSynth, Tone.Monophonic);\n\t /**\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.FMSynth.defaults = {\n\t 'harmonicity': 3,\n\t 'modulationIndex': 10,\n\t 'detune': 0,\n\t 'oscillator': { 'type': 'sine' },\n\t 'envelope': {\n\t 'attack': 0.01,\n\t 'decay': 0.01,\n\t 'sustain': 1,\n\t 'release': 0.5\n\t },\n\t 'modulation': { 'type': 'square' },\n\t 'modulationEnvelope': {\n\t 'attack': 0.5,\n\t 'decay': 0,\n\t 'sustain': 1,\n\t 'release': 0.5\n\t }\n\t };\n\t /**\n\t\t * \ttrigger the attack portion of the note\n\t\t *\n\t\t * @param {Time} [time=now] the time the note will occur\n\t\t * @param {number} [velocity=1] the velocity of the note\n\t\t * @returns {Tone.FMSynth} this\n\t\t * @private\n\t\t */\n\t Tone.FMSynth.prototype._triggerEnvelopeAttack = function (time, velocity) {\n\t time = this.toSeconds(time);\n\t //the envelopes\n\t this._carrier._triggerEnvelopeAttack(time, velocity);\n\t this._modulator._triggerEnvelopeAttack(time);\n\t return this;\n\t };\n\t /**\n\t\t * trigger the release portion of the note\n\t\t *\n\t\t * @param {Time} [time=now] the time the note will release\n\t\t * @returns {Tone.FMSynth} this\n\t\t * @private\n\t\t */\n\t Tone.FMSynth.prototype._triggerEnvelopeRelease = function (time) {\n\t time = this.toSeconds(time);\n\t this._carrier._triggerEnvelopeRelease(time);\n\t this._modulator._triggerEnvelopeRelease(time);\n\t return this;\n\t };\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.FMSynth} this\n\t\t */\n\t Tone.FMSynth.prototype.dispose = function () {\n\t Tone.Monophonic.prototype.dispose.call(this);\n\t this._writable([\n\t 'frequency',\n\t 'harmonicity',\n\t 'modulationIndex',\n\t 'oscillator',\n\t 'envelope',\n\t 'modulation',\n\t 'modulationEnvelope',\n\t 'detune'\n\t ]);\n\t this._carrier.dispose();\n\t this._carrier = null;\n\t this._modulator.dispose();\n\t this._modulator = null;\n\t this.frequency.dispose();\n\t this.frequency = null;\n\t this.detune.dispose();\n\t this.detune = null;\n\t this.modulationIndex.dispose();\n\t this.modulationIndex = null;\n\t this.harmonicity.dispose();\n\t this.harmonicity = null;\n\t this._modulationNode.dispose();\n\t this._modulationNode = null;\n\t this.oscillator = null;\n\t this.envelope = null;\n\t this.modulationEnvelope = null;\n\t this.modulation = null;\n\t return this;\n\t };\n\t return Tone.FMSynth;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.MembraneSynth makes kick and tom sounds using a single oscillator\n\t\t * with an amplitude envelope and frequency ramp. A Tone.OmniOscillator\n\t\t * is routed through a Tone.AmplitudeEnvelope to the output. The drum\n\t\t * quality of the sound comes from the frequency envelope applied\n\t\t * during Tone.MembraneSynth.triggerAttack(note). The frequency envelope\n\t\t * starts at <code>note * .octaves</code> and ramps to <code>note</code>\n\t\t * over the duration of <code>.pitchDecay</code>.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Instrument}\n\t\t * @param {Object} [options] the options available for the synth\n\t\t * see defaults below\n\t\t * @example\n\t\t * var synth = new Tone.MembraneSynth().toMaster();\n\t\t * synth.triggerAttackRelease(\"C2\", \"8n\");\n\t\t */\n\t Tone.MembraneSynth = function (options) {\n\t options = Tone.defaultArg(options, Tone.MembraneSynth.defaults);\n\t Tone.Instrument.call(this, options);\n\t /**\n\t\t\t * The oscillator.\n\t\t\t * @type {Tone.OmniOscillator}\n\t\t\t */\n\t this.oscillator = new Tone.OmniOscillator(options.oscillator);\n\t /**\n\t\t\t * The amplitude envelope.\n\t\t\t * @type {Tone.AmplitudeEnvelope}\n\t\t\t */\n\t this.envelope = new Tone.AmplitudeEnvelope(options.envelope);\n\t /**\n\t\t\t * The number of octaves the pitch envelope ramps.\n\t\t\t * @type {Positive}\n\t\t\t */\n\t this.octaves = options.octaves;\n\t /**\n\t\t\t * The amount of time the frequency envelope takes.\n\t\t\t * @type {Time}\n\t\t\t */\n\t this.pitchDecay = options.pitchDecay;\n\t this.oscillator.chain(this.envelope, this.output);\n\t this._readOnly([\n\t 'oscillator',\n\t 'envelope'\n\t ]);\n\t };\n\t Tone.extend(Tone.MembraneSynth, Tone.Instrument);\n\t /**\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.MembraneSynth.defaults = {\n\t 'pitchDecay': 0.05,\n\t 'octaves': 10,\n\t 'oscillator': { 'type': 'sine' },\n\t 'envelope': {\n\t 'attack': 0.001,\n\t 'decay': 0.4,\n\t 'sustain': 0.01,\n\t 'release': 1.4,\n\t 'attackCurve': 'exponential'\n\t }\n\t };\n\t /**\n\t\t * Trigger the note at the given time with the given velocity.\n\t\t *\n\t\t * @param {Frequency} note the note\n\t\t * @param {Time} [time=now] the time, if not given is now\n\t\t * @param {number} [velocity=1] velocity defaults to 1\n\t\t * @returns {Tone.MembraneSynth} this\n\t\t * @example\n\t\t * kick.triggerAttack(60);\n\t\t */\n\t Tone.MembraneSynth.prototype.triggerAttack = function (note, time, velocity) {\n\t time = this.toSeconds(time);\n\t note = this.toFrequency(note);\n\t var maxNote = note * this.octaves;\n\t this.oscillator.frequency.setValueAtTime(maxNote, time);\n\t this.oscillator.frequency.exponentialRampToValueAtTime(note, time + this.toSeconds(this.pitchDecay));\n\t this.envelope.triggerAttack(time, velocity);\n\t this.oscillator.start(time);\n\t return this;\n\t };\n\t /**\n\t\t * Trigger the release portion of the note.\n\t\t *\n\t\t * @param {Time} [time=now] the time the note will release\n\t\t * @returns {Tone.MembraneSynth} this\n\t\t */\n\t Tone.MembraneSynth.prototype.triggerRelease = function (time) {\n\t time = this.toSeconds(time);\n\t this.envelope.triggerRelease(time);\n\t this.oscillator.stop(time + this.envelope.release);\n\t return this;\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.MembraneSynth} this\n\t\t */\n\t Tone.MembraneSynth.prototype.dispose = function () {\n\t Tone.Instrument.prototype.dispose.call(this);\n\t this._writable([\n\t 'oscillator',\n\t 'envelope'\n\t ]);\n\t this.oscillator.dispose();\n\t this.oscillator = null;\n\t this.envelope.dispose();\n\t this.envelope = null;\n\t return this;\n\t };\n\t return Tone.MembraneSynth;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * Inharmonic ratio of frequencies based on the Roland TR-808\n\t\t * Taken from https://ccrma.stanford.edu/papers/tr-808-cymbal-physically-informed-circuit-bendable-digital-model\n\t\t * @private\n\t\t * @static\n\t\t * @type {Array}\n\t\t */\n\t var inharmRatios = [\n\t 1,\n\t 1.483,\n\t 1.932,\n\t 2.546,\n\t 2.63,\n\t 3.897\n\t ];\n\t /**\n\t\t * @class A highly inharmonic and spectrally complex source with a highpass filter\n\t\t * and amplitude envelope which is good for making metalophone sounds. Based\n\t\t * on CymbalSynth by [@polyrhythmatic](https://github.com/polyrhythmatic).\n\t\t * Inspiration from [Sound on Sound](https://web.archive.org/web/20160610143924/https://www.soundonsound.com/sos/jul02/articles/synthsecrets0702.asp).\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Instrument}\n\t\t * @param {Object} [options] The options availble for the synth\n\t\t * see defaults below\n\t\t */\n\t Tone.MetalSynth = function (options) {\n\t options = Tone.defaultArg(options, Tone.MetalSynth.defaults);\n\t Tone.Instrument.call(this, options);\n\t /**\n\t\t\t * The frequency of the cymbal\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency);\n\t /**\n\t\t\t * The array of FMOscillators\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._oscillators = [];\n\t /**\n\t\t\t * The frequency multipliers\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._freqMultipliers = [];\n\t /**\n\t\t\t * The amplitude for the body\n\t\t\t * @type {Tone.Gain}\n\t\t\t * @private\n\t\t\t */\n\t this._amplitue = new Tone.Gain(0).connect(this.output);\n\t /**\n\t\t\t * highpass the output\n\t\t\t * @type {Tone.Filter}\n\t\t\t * @private\n\t\t\t */\n\t this._highpass = new Tone.Filter({\n\t 'type': 'highpass',\n\t 'Q': -3.0102999566398125\n\t }).connect(this._amplitue);\n\t /**\n\t\t\t * The number of octaves the highpass\n\t\t\t * filter frequency ramps\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._octaves = options.octaves;\n\t /**\n\t\t\t * Scale the body envelope\n\t\t\t * for the bandpass\n\t\t\t * @type {Tone.Scale}\n\t\t\t * @private\n\t\t\t */\n\t this._filterFreqScaler = new Tone.Scale(options.resonance, 7000);\n\t /**\n\t\t\t * The envelope which is connected both to the\n\t\t\t * amplitude and highpass filter's cutoff frequency\n\t\t\t * @type {Tone.Envelope}\n\t\t\t */\n\t this.envelope = new Tone.Envelope({\n\t 'attack': options.envelope.attack,\n\t 'attackCurve': 'linear',\n\t 'decay': options.envelope.decay,\n\t 'sustain': 0,\n\t 'release': options.envelope.release\n\t }).chain(this._filterFreqScaler, this._highpass.frequency);\n\t this.envelope.connect(this._amplitue.gain);\n\t for (var i = 0; i < inharmRatios.length; i++) {\n\t var osc = new Tone.FMOscillator({\n\t 'type': 'square',\n\t 'modulationType': 'square',\n\t 'harmonicity': options.harmonicity,\n\t 'modulationIndex': options.modulationIndex\n\t });\n\t osc.connect(this._highpass);\n\t this._oscillators[i] = osc;\n\t var mult = new Tone.Multiply(inharmRatios[i]);\n\t this._freqMultipliers[i] = mult;\n\t this.frequency.chain(mult, osc.frequency);\n\t }\n\t //set the octaves\n\t this.octaves = options.octaves;\n\t };\n\t Tone.extend(Tone.MetalSynth, Tone.Instrument);\n\t /**\n\t\t * default values\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.MetalSynth.defaults = {\n\t 'frequency': 200,\n\t 'envelope': {\n\t 'attack': 0.001,\n\t 'decay': 1.4,\n\t 'release': 0.2\n\t },\n\t 'harmonicity': 5.1,\n\t 'modulationIndex': 32,\n\t 'resonance': 4000,\n\t 'octaves': 1.5\n\t };\n\t /**\n\t\t * Trigger the attack.\n\t\t * @param {Time} time When the attack should be triggered.\n\t\t * @param {NormalRange} [velocity=1] The velocity that the envelope should be triggered at.\n\t\t * @return {Tone.MetalSynth} this\n\t\t */\n\t Tone.MetalSynth.prototype.triggerAttack = function (time, vel) {\n\t time = this.toSeconds(time);\n\t vel = Tone.defaultArg(vel, 1);\n\t this.envelope.triggerAttack(time, vel);\n\t this._oscillators.forEach(function (osc) {\n\t osc.start(time);\n\t });\n\t //if the sustain is 0, stop the oscillator as well\n\t if (this.envelope.sustain === 0) {\n\t this._oscillators.forEach(function (osc) {\n\t osc.stop(time + this.envelope.attack + this.envelope.decay);\n\t }.bind(this));\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Trigger the release of the envelope.\n\t\t * @param {Time} time When the release should be triggered.\n\t\t * @return {Tone.MetalSynth} this\n\t\t */\n\t Tone.MetalSynth.prototype.triggerRelease = function (time) {\n\t time = this.toSeconds(time);\n\t this.envelope.triggerRelease(time);\n\t this._oscillators.forEach(function (osc) {\n\t osc.stop(time + this.envelope.release);\n\t }.bind(this));\n\t return this;\n\t };\n\t /**\n\t\t * Sync the instrument to the Transport. All subsequent calls of\n\t\t * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease)\n\t\t * will be scheduled along the transport.\n\t\t * @example\n\t\t * synth.sync()\n\t\t * //schedule 3 notes when the transport first starts\n\t\t * synth.triggerAttackRelease('8n', 0)\n\t\t * synth.triggerAttackRelease('8n', '8n')\n\t\t * synth.triggerAttackRelease('8n', '4n')\n\t\t * //start the transport to hear the notes\n\t\t * Transport.start()\n\t\t * @returns {Tone.Instrument} this\n\t\t */\n\t Tone.MetalSynth.prototype.sync = function () {\n\t this._syncMethod('triggerAttack', 0);\n\t this._syncMethod('triggerRelease', 0);\n\t return this;\n\t };\n\t /**\n\t\t * Trigger the attack and release of the envelope after the given\n\t\t * duration.\n\t\t * @param {Time} duration The duration before triggering the release\n\t\t * @param {Time} time When the attack should be triggered.\n\t\t * @param {NormalRange} [velocity=1] The velocity that the envelope should be triggered at.\n\t\t * @return {Tone.MetalSynth} this\n\t\t */\n\t Tone.MetalSynth.prototype.triggerAttackRelease = function (duration, time, velocity) {\n\t time = this.toSeconds(time);\n\t duration = this.toSeconds(duration);\n\t this.triggerAttack(time, velocity);\n\t this.triggerRelease(time + duration);\n\t return this;\n\t };\n\t /**\n\t\t * The modulationIndex of the oscillators which make up the source.\n\t\t * see Tone.FMOscillator.modulationIndex\n\t\t * @memberOf Tone.MetalSynth#\n\t\t * @type {Positive}\n\t\t * @name modulationIndex\n\t\t */\n\t Object.defineProperty(Tone.MetalSynth.prototype, 'modulationIndex', {\n\t get: function () {\n\t return this._oscillators[0].modulationIndex.value;\n\t },\n\t set: function (val) {\n\t for (var i = 0; i < this._oscillators.length; i++) {\n\t this._oscillators[i].modulationIndex.value = val;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The harmonicity of the oscillators which make up the source.\n\t\t * see Tone.FMOscillator.harmonicity\n\t\t * @memberOf Tone.MetalSynth#\n\t\t * @type {Positive}\n\t\t * @name harmonicity\n\t\t */\n\t Object.defineProperty(Tone.MetalSynth.prototype, 'harmonicity', {\n\t get: function () {\n\t return this._oscillators[0].harmonicity.value;\n\t },\n\t set: function (val) {\n\t for (var i = 0; i < this._oscillators.length; i++) {\n\t this._oscillators[i].harmonicity.value = val;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The frequency of the highpass filter attached to the envelope\n\t\t * @memberOf Tone.MetalSynth#\n\t\t * @type {Frequency}\n\t\t * @name resonance\n\t\t */\n\t Object.defineProperty(Tone.MetalSynth.prototype, 'resonance', {\n\t get: function () {\n\t return this._filterFreqScaler.min;\n\t },\n\t set: function (val) {\n\t this._filterFreqScaler.min = val;\n\t this.octaves = this._octaves;\n\t }\n\t });\n\t /**\n\t\t * The number of octaves above the \"resonance\" frequency\n\t\t * that the filter ramps during the attack/decay envelope\n\t\t * @memberOf Tone.MetalSynth#\n\t\t * @type {Number}\n\t\t * @name octaves\n\t\t */\n\t Object.defineProperty(Tone.MetalSynth.prototype, 'octaves', {\n\t get: function () {\n\t return this._octaves;\n\t },\n\t set: function (octs) {\n\t this._octaves = octs;\n\t this._filterFreqScaler.max = this._filterFreqScaler.min * Math.pow(2, octs);\n\t }\n\t });\n\t /**\n\t\t * Clean up\n\t\t * @returns {Tone.MetalSynth} this\n\t\t */\n\t Tone.MetalSynth.prototype.dispose = function () {\n\t Tone.Instrument.prototype.dispose.call(this);\n\t for (var i = 0; i < this._oscillators.length; i++) {\n\t this._oscillators[i].dispose();\n\t this._freqMultipliers[i].dispose();\n\t }\n\t this._oscillators = null;\n\t this._freqMultipliers = null;\n\t this.frequency.dispose();\n\t this.frequency = null;\n\t this._filterFreqScaler.dispose();\n\t this._filterFreqScaler = null;\n\t this._amplitue.dispose();\n\t this._amplitue = null;\n\t this.envelope.dispose();\n\t this.envelope = null;\n\t this._highpass.dispose();\n\t this._highpass = null;\n\t };\n\t return Tone.MetalSynth;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.NoiseSynth is composed of a noise generator (Tone.Noise), one filter (Tone.Filter),\n\t\t * and two envelopes (Tone.Envelop). One envelope controls the amplitude\n\t\t * of the noise and the other is controls the cutoff frequency of the filter.\n\t\t * <img src=\"https://docs.google.com/drawings/d/1rqzuX9rBlhT50MRvD2TKml9bnZhcZmzXF1rf_o7vdnE/pub?w=918&h=242\">\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Instrument}\n\t\t * @param {Object} [options] the options available for the synth\n\t\t * see defaults below\n\t\t * @example\n\t\t * var noiseSynth = new Tone.NoiseSynth().toMaster();\n\t\t * noiseSynth.triggerAttackRelease(\"8n\");\n\t\t */\n\t Tone.NoiseSynth = function (options) {\n\t //get the defaults\n\t options = Tone.defaultArg(options, Tone.NoiseSynth.defaults);\n\t Tone.Instrument.call(this, options);\n\t /**\n\t\t\t * The noise source.\n\t\t\t * @type {Tone.Noise}\n\t\t\t * @example\n\t\t\t * noiseSynth.set(\"noise.type\", \"brown\");\n\t\t\t */\n\t this.noise = new Tone.Noise();\n\t /**\n\t\t\t * The amplitude envelope.\n\t\t\t * @type {Tone.AmplitudeEnvelope}\n\t\t\t */\n\t this.envelope = new Tone.AmplitudeEnvelope(options.envelope);\n\t //connect the noise to the output\n\t this.noise.chain(this.envelope, this.output);\n\t this._readOnly([\n\t 'noise',\n\t 'envelope'\n\t ]);\n\t };\n\t Tone.extend(Tone.NoiseSynth, Tone.Instrument);\n\t /**\n\t\t * @const\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.NoiseSynth.defaults = {\n\t 'noise': { 'type': 'white' },\n\t 'envelope': {\n\t 'attack': 0.005,\n\t 'decay': 0.1,\n\t 'sustain': 0\n\t }\n\t };\n\t /**\n\t\t * Start the attack portion of the envelopes. Unlike other\n\t\t * instruments, Tone.NoiseSynth doesn't have a note.\n\t\t * @param {Time} [time=now] the time the attack should start\n\t\t * @param {number} [velocity=1] the velocity of the note (0-1)\n\t\t * @returns {Tone.NoiseSynth} this\n\t\t * @example\n\t\t * noiseSynth.triggerAttack();\n\t\t */\n\t Tone.NoiseSynth.prototype.triggerAttack = function (time, velocity) {\n\t //the envelopes\n\t this.envelope.triggerAttack(time, velocity);\n\t //start the noise\n\t this.noise.start(time);\n\t if (this.envelope.sustain === 0) {\n\t this.noise.stop(time = this.envelope.attack + this.envelope.decay);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Start the release portion of the envelopes.\n\t\t * @param {Time} [time=now] the time the release should start\n\t\t * @returns {Tone.NoiseSynth} this\n\t\t */\n\t Tone.NoiseSynth.prototype.triggerRelease = function (time) {\n\t this.envelope.triggerRelease(time);\n\t this.noise.stop(time + this.envelope.release);\n\t return this;\n\t };\n\t /**\n\t\t * Sync the instrument to the Transport. All subsequent calls of\n\t\t * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease)\n\t\t * will be scheduled along the transport.\n\t\t * @example\n\t\t * synth.sync()\n\t\t * //schedule 3 notes when the transport first starts\n\t\t * synth.triggerAttackRelease('8n', 0)\n\t\t * synth.triggerAttackRelease('8n', '8n')\n\t\t * synth.triggerAttackRelease('8n', '4n')\n\t\t * //start the transport to hear the notes\n\t\t * Transport.start()\n\t\t * @returns {Tone.Instrument} this\n\t\t */\n\t Tone.NoiseSynth.prototype.sync = function () {\n\t this._syncMethod('triggerAttack', 0);\n\t this._syncMethod('triggerRelease', 0);\n\t return this;\n\t };\n\t /**\n\t\t * Trigger the attack and then the release.\n\t\t * @param {Time} duration the duration of the note\n\t\t * @param {Time} [time=now] the time of the attack\n\t\t * @param {number} [velocity=1] the velocity\n\t\t * @returns {Tone.NoiseSynth} this\n\t\t */\n\t Tone.NoiseSynth.prototype.triggerAttackRelease = function (duration, time, velocity) {\n\t time = this.toSeconds(time);\n\t duration = this.toSeconds(duration);\n\t this.triggerAttack(time, velocity);\n\t this.triggerRelease(time + duration);\n\t return this;\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.NoiseSynth} this\n\t\t */\n\t Tone.NoiseSynth.prototype.dispose = function () {\n\t Tone.Instrument.prototype.dispose.call(this);\n\t this._writable([\n\t 'noise',\n\t 'envelope'\n\t ]);\n\t this.noise.dispose();\n\t this.noise = null;\n\t this.envelope.dispose();\n\t this.envelope = null;\n\t return this;\n\t };\n\t return Tone.NoiseSynth;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Karplus-String string synthesis. Often out of tune.\n\t\t * Will change when the AudioWorkerNode is available across\n\t\t * browsers.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Instrument}\n\t\t * @param {Object} [options] see the defaults\n\t\t * @example\n\t\t * var plucky = new Tone.PluckSynth().toMaster();\n\t\t * plucky.triggerAttack(\"C4\");\n\t\t */\n\t Tone.PluckSynth = function (options) {\n\t options = Tone.defaultArg(options, Tone.PluckSynth.defaults);\n\t Tone.Instrument.call(this, options);\n\t /**\n\t\t\t * @type {Tone.Noise}\n\t\t\t * @private\n\t\t\t */\n\t this._noise = new Tone.Noise('pink');\n\t /**\n\t\t\t * The amount of noise at the attack.\n\t\t\t * Nominal range of [0.1, 20]\n\t\t\t * @type {number}\n\t\t\t */\n\t this.attackNoise = options.attackNoise;\n\t /**\n\t\t\t * the LFCF\n\t\t\t * @type {Tone.LowpassCombFilter}\n\t\t\t * @private\n\t\t\t */\n\t this._lfcf = new Tone.LowpassCombFilter({\n\t 'resonance': options.resonance,\n\t 'dampening': options.dampening\n\t });\n\t /**\n\t\t\t * The resonance control.\n\t\t\t * @type {NormalRange}\n\t\t\t * @signal\n\t\t\t */\n\t this.resonance = this._lfcf.resonance;\n\t /**\n\t\t\t * The dampening control. i.e. the lowpass filter frequency of the comb filter\n\t\t\t * @type {Frequency}\n\t\t\t * @signal\n\t\t\t */\n\t this.dampening = this._lfcf.dampening;\n\t //connections\n\t this._noise.connect(this._lfcf);\n\t this._lfcf.connect(this.output);\n\t this._readOnly([\n\t 'resonance',\n\t 'dampening'\n\t ]);\n\t };\n\t Tone.extend(Tone.PluckSynth, Tone.Instrument);\n\t /**\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.PluckSynth.defaults = {\n\t 'attackNoise': 1,\n\t 'dampening': 4000,\n\t 'resonance': 0.7\n\t };\n\t /**\n\t\t * Trigger the note.\n\t\t * @param {Frequency} note The note to trigger.\n\t\t * @param {Time} [time=now] When the note should be triggered.\n\t\t * @returns {Tone.PluckSynth} this\n\t\t */\n\t Tone.PluckSynth.prototype.triggerAttack = function (note, time) {\n\t note = this.toFrequency(note);\n\t time = this.toSeconds(time);\n\t var delayAmount = 1 / note;\n\t this._lfcf.delayTime.setValueAtTime(delayAmount, time);\n\t this._noise.start(time);\n\t this._noise.stop(time + delayAmount * this.attackNoise);\n\t return this;\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.PluckSynth} this\n\t\t */\n\t Tone.PluckSynth.prototype.dispose = function () {\n\t Tone.Instrument.prototype.dispose.call(this);\n\t this._noise.dispose();\n\t this._lfcf.dispose();\n\t this._noise = null;\n\t this._lfcf = null;\n\t this._writable([\n\t 'resonance',\n\t 'dampening'\n\t ]);\n\t this.dampening = null;\n\t this.resonance = null;\n\t return this;\n\t };\n\t return Tone.PluckSynth;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.PolySynth handles voice creation and allocation for any\n\t\t * instruments passed in as the second paramter. PolySynth is\n\t\t * not a synthesizer by itself, it merely manages voices of\n\t\t * one of the other types of synths, allowing any of the\n\t\t * monophonic synthesizers to be polyphonic.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Instrument}\n\t\t * @param {number|Object} [polyphony=4] The number of voices to create\n\t\t * @param {function} [voice=Tone.Synth] The constructor of the voices\n\t\t * uses Tone.Synth by default.\n\t\t * @example\n\t\t * //a polysynth composed of 6 Voices of Synth\n\t\t * var synth = new Tone.PolySynth(6, Tone.Synth).toMaster();\n\t\t * //set the attributes using the set interface\n\t\t * synth.set(\"detune\", -1200);\n\t\t * //play a chord\n\t\t * synth.triggerAttackRelease([\"C4\", \"E4\", \"A4\"], \"4n\");\n\t\t */\n\t Tone.PolySynth = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'polyphony',\n\t 'voice'\n\t ], Tone.PolySynth);\n\t Tone.Instrument.call(this, options);\n\t options = Tone.defaultArg(options, Tone.Instrument.defaults);\n\t //max polyphony\n\t options.polyphony = Math.min(Tone.PolySynth.MAX_POLYPHONY, options.polyphony);\n\t /**\n\t\t\t * the array of voices\n\t\t\t * @type {Array}\n\t\t\t */\n\t this.voices = new Array(options.polyphony);\n\t /**\n\t\t\t * The queue of voices with data about last trigger\n\t\t\t * and the triggered note\n\t\t\t * @private\n\t\t\t * @type {Array}\n\t\t\t */\n\t this._triggers = new Array(options.polyphony);\n\t /**\n\t\t\t * The detune in cents\n\t\t\t * @type {Cents}\n\t\t\t * @signal\n\t\t\t */\n\t this.detune = new Tone.Signal(options.detune, Tone.Type.Cents);\n\t this._readOnly('detune');\n\t //create the voices\n\t for (var i = 0; i < options.polyphony; i++) {\n\t var v = new options.voice(arguments[2], arguments[3]);\n\t if (!(v instanceof Tone.Monophonic)) {\n\t throw new Error('Synth constructor must be instance of Tone.Monophonic');\n\t }\n\t this.voices[i] = v;\n\t v.connect(this.output);\n\t if (v.hasOwnProperty('detune')) {\n\t this.detune.connect(v.detune);\n\t }\n\t this._triggers[i] = {\n\t release: -1,\n\t note: null,\n\t voice: v\n\t };\n\t }\n\t };\n\t Tone.extend(Tone.PolySynth, Tone.Instrument);\n\t /**\n\t\t * the defaults\n\t\t * @const\n\t\t * @static\n\t\t * @type {Object}\n\t\t */\n\t Tone.PolySynth.defaults = {\n\t 'polyphony': 4,\n\t 'volume': 0,\n\t 'detune': 0,\n\t 'voice': Tone.Synth\n\t };\n\t /**\n\t\t * Trigger the attack portion of the note\n\t\t * @param {Frequency|Array} notes The notes to play. Accepts a single\n\t\t * Frequency or an array of frequencies.\n\t\t * @param {Time} [time=now] The start time of the note.\n\t\t * @param {number} [velocity=1] The velocity of the note.\n\t\t * @returns {Tone.PolySynth} this\n\t\t * @example\n\t\t * //trigger a chord immediately with a velocity of 0.2\n\t\t * poly.triggerAttack([\"Ab3\", \"C4\", \"F5\"], undefined, 0.2);\n\t\t */\n\t Tone.PolySynth.prototype.triggerAttack = function (notes, time, velocity) {\n\t if (!Array.isArray(notes)) {\n\t notes = [notes];\n\t }\n\t time = this.toSeconds(time);\n\t for (var i = 0; i < notes.length; i++) {\n\t var val = notes[i];\n\t //trigger the oldest voice\n\t var oldest = this._triggers[0];\n\t for (var j = 1; j < this._triggers.length; j++) {\n\t if (this._triggers[j].release < oldest.release) {\n\t oldest = this._triggers[j];\n\t }\n\t }\n\t oldest.release = Infinity;\n\t oldest.note = JSON.stringify(val);\n\t oldest.voice.triggerAttack(val, time, velocity);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Trigger the attack and release after the specified duration\n\t\t *\n\t\t * @param {Frequency|Array} notes The notes to play. Accepts a single\n\t\t * Frequency or an array of frequencies.\n\t\t * @param {Time} duration the duration of the note\n\t\t * @param {Time} [time=now] if no time is given, defaults to now\n\t\t * @param {number} [velocity=1] the velocity of the attack (0-1)\n\t\t * @returns {Tone.PolySynth} this\n\t\t * @example\n\t\t * //trigger a chord for a duration of a half note\n\t\t * poly.triggerAttackRelease([\"Eb3\", \"G4\", \"C5\"], \"2n\");\n\t\t * @example\n\t\t * //can pass in an array of durations as well\n\t\t * poly.triggerAttackRelease([\"Eb3\", \"G4\", \"C5\"], [\"2n\", \"4n\", \"4n\"]);\n\t\t */\n\t Tone.PolySynth.prototype.triggerAttackRelease = function (notes, duration, time, velocity) {\n\t time = this.toSeconds(time);\n\t this.triggerAttack(notes, time, velocity);\n\t if (Tone.isArray(duration) && Tone.isArray(notes)) {\n\t for (var i = 0; i < notes.length; i++) {\n\t var d = duration[Math.min(i, duration.length - 1)];\n\t this.triggerRelease(notes[i], time + this.toSeconds(d));\n\t }\n\t } else {\n\t this.triggerRelease(notes, time + this.toSeconds(duration));\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Trigger the release of the note. Unlike monophonic instruments,\n\t\t * a note (or array of notes) needs to be passed in as the first argument.\n\t\t * @param {Frequency|Array} notes The notes to play. Accepts a single\n\t\t * Frequency or an array of frequencies.\n\t\t * @param {Time} [time=now] When the release will be triggered.\n\t\t * @returns {Tone.PolySynth} this\n\t\t * @example\n\t\t * poly.triggerRelease([\"Ab3\", \"C4\", \"F5\"], \"+2n\");\n\t\t */\n\t Tone.PolySynth.prototype.triggerRelease = function (notes, time) {\n\t if (!Array.isArray(notes)) {\n\t notes = [notes];\n\t }\n\t time = this.toSeconds(time);\n\t for (var i = 0; i < notes.length; i++) {\n\t //get the voice\n\t var stringified = JSON.stringify(notes[i]);\n\t for (var v = 0; v < this._triggers.length; v++) {\n\t var desc = this._triggers[v];\n\t if (desc.note === stringified && desc.release > time) {\n\t desc.voice.triggerRelease(time);\n\t desc.release = time;\n\t }\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Sync the instrument to the Transport. All subsequent calls of\n\t\t * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease)\n\t\t * will be scheduled along the transport.\n\t\t * @example\n\t\t * synth.sync()\n\t\t * //schedule 3 notes when the transport first starts\n\t\t * synth.triggerAttackRelease('8n', 0)\n\t\t * synth.triggerAttackRelease('8n', '8n')\n\t\t * synth.triggerAttackRelease('8n', '4n')\n\t\t * //start the transport to hear the notes\n\t\t * Transport.start()\n\t\t * @returns {Tone.Instrument} this\n\t\t */\n\t Tone.PolySynth.prototype.sync = function () {\n\t this._syncMethod('triggerAttack', 1);\n\t this._syncMethod('triggerRelease', 1);\n\t return this;\n\t };\n\t /**\n\t\t * Set a member/attribute of the voices.\n\t\t * @param {Object|string} params\n\t\t * @param {number=} value\n\t\t * @param {Time=} rampTime\n\t\t * @returns {Tone.PolySynth} this\n\t\t * @example\n\t\t * poly.set({\n\t\t * \t\"filter\" : {\n\t\t * \t\t\"type\" : \"highpass\"\n\t\t * \t},\n\t\t * \t\"envelope\" : {\n\t\t * \t\t\"attack\" : 0.25\n\t\t * \t}\n\t\t * });\n\t\t */\n\t Tone.PolySynth.prototype.set = function (params, value, rampTime) {\n\t for (var i = 0; i < this.voices.length; i++) {\n\t this.voices[i].set(params, value, rampTime);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Get the synth's attributes. Given no arguments get\n\t\t * will return all available object properties and their corresponding\n\t\t * values. Pass in a single attribute to retrieve or an array\n\t\t * of attributes. The attribute strings can also include a \".\"\n\t\t * to access deeper properties.\n\t\t * @param {Array=} params the parameters to get, otherwise will return\n\t\t * \t\t\t\t\t all available.\n\t\t */\n\t Tone.PolySynth.prototype.get = function (params) {\n\t return this.voices[0].get(params);\n\t };\n\t /**\n\t\t * Trigger the release portion of all the currently active voices.\n\t\t * @param {Time} [time=now] When the notes should be released.\n\t\t * @return {Tone.PolySynth} this\n\t\t */\n\t Tone.PolySynth.prototype.releaseAll = function (time) {\n\t time = this.toSeconds(time);\n\t for (var i = 0; i < this._triggers.length; i++) {\n\t var desc = this._triggers[i];\n\t if (desc.release > time) {\n\t desc.release = time;\n\t desc.voice.triggerRelease(time);\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Clean up.\n\t\t * @returns {Tone.PolySynth} this\n\t\t */\n\t Tone.PolySynth.prototype.dispose = function () {\n\t Tone.Instrument.prototype.dispose.call(this);\n\t for (var i = 0; i < this.voices.length; i++) {\n\t this.voices[i].dispose();\n\t this.voices[i] = null;\n\t }\n\t this._writable('detune');\n\t this.detune.dispose();\n\t this.detune = null;\n\t this.voices = null;\n\t this._triggers = null;\n\t return this;\n\t };\n\t /**\n\t\t * The maximum number of notes that can be allocated\n\t\t * to a polysynth.\n\t\t * @type {Number}\n\t\t * @static\n\t\t */\n\t Tone.PolySynth.MAX_POLYPHONY = 20;\n\t return Tone.PolySynth;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Automatically interpolates between a set of pitched samples. Pass in an object which maps the note's pitch or midi value to the url, then you can trigger the attack and release of that note like other instruments. By automatically repitching the samples, it is possible to play pitches which were not explicitly included which can save loading time.\n\t\t * For sample or buffer playback where repitching is not necessary, use [Tone.Player](https://tonejs.github.io/docs/Player).\n\t\t * @param {Object} samples An object of samples mapping either Midi\n\t\t * Note Numbers or Scientific Pitch Notation\n\t\t * to the url of that sample.\n\t\t * @param {Function=} onload The callback to invoke when all of the samples are loaded.\n\t\t * @param {String=} baseUrl The root URL of all of the samples, which is prepended to all the URLs.\n\t\t * @example\n\t\t * var sampler = new Tone.Sampler({\n\t\t * \t\"C3\" : \"path/to/C3.mp3\",\n\t\t * \t\"D#3\" : \"path/to/Dsharp3.mp3\",\n\t\t * \t\"F#3\" : \"path/to/Fsharp3.mp3\",\n\t\t * \t\"A3\" : \"path/to/A3.mp3\",\n\t\t * }, function(){\n\t\t * \t//sampler will repitch the closest sample\n\t\t * \tsampler.triggerAttack(\"D3\")\n\t\t * })\n\t\t * @extends {Tone.Instrument}\n\t\t */\n\t Tone.Sampler = function (urls) {\n\t // shift arguments over one. Those are the remainder of the options\n\t var args = Array.prototype.slice.call(arguments);\n\t args.shift();\n\t var options = Tone.defaults(args, [\n\t 'onload',\n\t 'baseUrl'\n\t ], Tone.Sampler);\n\t Tone.Instrument.call(this, options);\n\t var urlMap = {};\n\t for (var note in urls) {\n\t if (Tone.isNote(note)) {\n\t //convert the note name to MIDI\n\t var mid = Tone.Frequency(note).toMidi();\n\t urlMap[mid] = urls[note];\n\t } else if (!isNaN(parseFloat(note))) {\n\t //otherwise if it's numbers assume it's midi\n\t urlMap[note] = urls[note];\n\t } else {\n\t throw new Error('Tone.Sampler: url keys must be the note\\'s pitch');\n\t }\n\t }\n\t /**\n\t\t\t * The stored and loaded buffers\n\t\t\t * @type {Tone.Buffers}\n\t\t\t * @private\n\t\t\t */\n\t this._buffers = new Tone.Buffers(urlMap, options.onload, options.baseUrl);\n\t /**\n\t\t\t * The object of all currently playing BufferSources\n\t\t\t * @type {Object}\n\t\t\t * @private\n\t\t\t */\n\t this._activeSources = {};\n\t /**\n\t\t\t * The envelope applied to the beginning of the sample.\n\t\t\t * @type {Time}\n\t\t\t */\n\t this.attack = options.attack;\n\t /**\n\t\t\t * The envelope applied to the end of the envelope.\n\t\t\t * @type {Time}\n\t\t\t */\n\t this.release = options.release;\n\t };\n\t Tone.extend(Tone.Sampler, Tone.Instrument);\n\t /**\n\t\t * The defaults\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Sampler.defaults = {\n\t attack: 0,\n\t release: 0.1,\n\t onload: Tone.noOp,\n\t baseUrl: ''\n\t };\n\t /**\n\t\t * Returns the difference in steps between the given midi note at the closets sample.\n\t\t * @param {Midi} midi\n\t\t * @return {Interval}\n\t\t * @private\n\t\t */\n\t Tone.Sampler.prototype._findClosest = function (midi) {\n\t //searches within 8 octaves of the given midi note\n\t var MAX_INTERVAL = 96;\n\t var interval = 0;\n\t while (interval < MAX_INTERVAL) {\n\t // check above and below\n\t if (this._buffers.has(midi + interval)) {\n\t return -interval;\n\t } else if (this._buffers.has(midi - interval)) {\n\t return interval;\n\t }\n\t interval++;\n\t }\n\t return null;\n\t };\n\t /**\n\t\t * @param {Frequency} note The note to play\n\t\t * @param {Time=} time When to play the note\n\t\t * @param {NormalRange=} velocity The velocity to play the sample back.\n\t\t * @return {Tone.Sampler} this\n\t\t */\n\t Tone.Sampler.prototype.triggerAttack = function (note, time, velocity) {\n\t var midi = Tone.Frequency(note).toMidi();\n\t // find the closest note pitch\n\t var difference = this._findClosest(midi);\n\t if (difference !== null) {\n\t var closestNote = midi - difference;\n\t var buffer = this._buffers.get(closestNote);\n\t // play that note\n\t var source = new Tone.BufferSource({\n\t 'buffer': buffer,\n\t 'playbackRate': Tone.intervalToFrequencyRatio(difference),\n\t 'fadeIn': this.attack,\n\t 'fadeOut': this.release,\n\t 'curve': 'exponential'\n\t }).connect(this.output);\n\t source.start(time, 0, buffer.duration, velocity);\n\t // add it to the active sources\n\t if (!Tone.isArray(this._activeSources[midi])) {\n\t this._activeSources[midi] = [];\n\t }\n\t this._activeSources[midi].push({\n\t note: midi,\n\t source: source\n\t });\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * @param {Frequency} note The note to release.\n\t\t * @param {Time=} time \tWhen to release the note.\n\t\t * @return {Tone.Sampler}\tthis\n\t\t */\n\t Tone.Sampler.prototype.triggerRelease = function (note, time) {\n\t var midi = Tone.Frequency(note).toMidi();\n\t // find the note\n\t if (this._activeSources[midi] && this._activeSources[midi].length) {\n\t var source = this._activeSources[midi].shift().source;\n\t time = this.toSeconds(time);\n\t source.stop(time + this.release, this.release);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Release all currently active notes.\n\t\t * @param {Time=} time \tWhen to release the notes.\n\t\t * @return {Tone.Sampler}\tthis\n\t\t */\n\t Tone.Sampler.prototype.releaseAll = function (time) {\n\t time = this.toSeconds(time);\n\t for (var note in this._activeSources) {\n\t var sources = this._activeSources[note];\n\t while (sources.length) {\n\t var source = sources.shift().source;\n\t source.stop(time + this.release, this.release);\n\t }\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Sync the instrument to the Transport. All subsequent calls of\n\t\t * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease)\n\t\t * will be scheduled along the transport.\n\t\t * @example\n\t\t * synth.sync()\n\t\t * //schedule 3 notes when the transport first starts\n\t\t * synth.triggerAttackRelease('8n', 0)\n\t\t * synth.triggerAttackRelease('8n', '8n')\n\t\t * synth.triggerAttackRelease('8n', '4n')\n\t\t * //start the transport to hear the notes\n\t\t * Transport.start()\n\t\t * @returns {Tone.Instrument} this\n\t\t */\n\t Tone.Sampler.prototype.sync = function () {\n\t this._syncMethod('triggerAttack', 1);\n\t this._syncMethod('triggerRelease', 1);\n\t return this;\n\t };\n\t /**\n\t\t * Invoke the attack phase, then after the duration, invoke the release.\n\t\t * @param {Frequency} note The note to play\n\t\t * @param {Time} duration The time the note should be held\n\t\t * @param {Time=} time When to start the attack\n\t\t * @param {NormalRange} [velocity=1] The velocity of the attack\n\t\t * @return {Tone.Sampler} this\n\t\t */\n\t Tone.Sampler.prototype.triggerAttackRelease = function (note, duration, time, velocity) {\n\t time = this.toSeconds(time);\n\t duration = this.toSeconds(duration);\n\t this.triggerAttack(note, time, velocity);\n\t this.triggerRelease(note, time + duration);\n\t return this;\n\t };\n\t /**\n\t\t * Add a note to the sampler.\n\t\t * @param {Note|Midi} note The buffer's pitch.\n\t\t * @param {String|Tone.Buffer|Audiobuffer} url Either the url of the bufer,\n\t\t * or a buffer which will be added\n\t\t * with the given name.\n\t\t * @param {Function=} callback The callback to invoke\n\t\t * when the url is loaded.\n\t\t */\n\t Tone.Sampler.prototype.add = function (note, url, callback) {\n\t if (Tone.isNote(note)) {\n\t //convert the note name to MIDI\n\t var mid = Tone.Frequency(note).toMidi();\n\t this._buffers.add(mid, url, callback);\n\t } else if (!isNaN(parseFloat(note))) {\n\t //otherwise if it's numbers assume it's midi\n\t this._buffers.add(note, url, callback);\n\t } else {\n\t throw new Error('Tone.Sampler: note must be the note\\'s pitch. Instead got ' + note);\n\t }\n\t };\n\t /**\n\t\t * If the buffers are loaded or not\n\t\t * @memberOf Tone.Sampler#\n\t\t * @type {Boolean}\n\t\t * @name loaded\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Sampler.prototype, 'loaded', {\n\t get: function () {\n\t return this._buffers.loaded;\n\t }\n\t });\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.Sampler} this\n\t\t */\n\t Tone.Sampler.prototype.dispose = function () {\n\t Tone.Instrument.prototype.dispose.call(this);\n\t this._buffers.dispose();\n\t this._buffers = null;\n\t for (var midi in this._activeSources) {\n\t this._activeSources[midi].forEach(function (event) {\n\t event.source.dispose();\n\t });\n\t }\n\t this._activeSources = null;\n\t return this;\n\t };\n\t return Tone.Sampler;\n\t});\n\tModule(function (Tone) {\n\t if (Tone.supported) {\n\t if (!OscillatorNode.prototype.setPeriodicWave) {\n\t OscillatorNode.prototype.setPeriodicWave = OscillatorNode.prototype.setWaveTable;\n\t }\n\t if (!AudioContext.prototype.createPeriodicWave) {\n\t AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable;\n\t }\n\t }\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Maps a NormalRange [0, 1] to an AudioRange [-1, 1]. \n\t\t * See also Tone.AudioToGain. \n\t\t *\n\t\t * @extends {Tone.SignalBase}\n\t\t * @constructor\n\t\t * @example\n\t\t * var g2a = new Tone.GainToAudio();\n\t\t */\n\t Tone.GainToAudio = function () {\n\t Tone.SignalBase.call(this);\n\t /**\n\t\t\t * @type {WaveShaperNode}\n\t\t\t * @private\n\t\t\t */\n\t this._norm = this.input = this.output = new Tone.WaveShaper(function (x) {\n\t return Math.abs(x) * 2 - 1;\n\t });\n\t };\n\t Tone.extend(Tone.GainToAudio, Tone.SignalBase);\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.GainToAudio} this\n\t\t */\n\t Tone.GainToAudio.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._norm.dispose();\n\t this._norm = null;\n\t return this;\n\t };\n\t return Tone.GainToAudio;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Normalize takes an input min and max and maps it linearly to NormalRange [0,1]\n\t\t *\n\t\t * @extends {Tone.SignalBase}\n\t\t * @constructor\n\t\t * @param {number} inputMin the min input value\n\t\t * @param {number} inputMax the max input value\n\t\t * @example\n\t\t * var norm = new Tone.Normalize(2, 4);\n\t\t * var sig = new Tone.Signal(3).connect(norm);\n\t\t * //output of norm is 0.5. \n\t\t */\n\t Tone.Normalize = function (inputMin, inputMax) {\n\t Tone.SignalBase.call(this);\n\t /**\n\t\t\t * the min input value\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._inputMin = Tone.defaultArg(inputMin, 0);\n\t /**\n\t\t\t * the max input value\n\t\t\t * @type {number}\n\t\t\t * @private\n\t\t\t */\n\t this._inputMax = Tone.defaultArg(inputMax, 1);\n\t /**\n\t\t\t * subtract the min from the input\n\t\t\t * @type {Tone.Add}\n\t\t\t * @private\n\t\t\t */\n\t this._sub = this.input = new Tone.Add(0);\n\t /**\n\t\t\t * divide by the difference between the input and output\n\t\t\t * @type {Tone.Multiply}\n\t\t\t * @private\n\t\t\t */\n\t this._div = this.output = new Tone.Multiply(1);\n\t this._sub.connect(this._div);\n\t this._setRange();\n\t };\n\t Tone.extend(Tone.Normalize, Tone.SignalBase);\n\t /**\n\t\t * The minimum value the input signal will reach.\n\t\t * @memberOf Tone.Normalize#\n\t\t * @type {number}\n\t\t * @name min\n\t\t */\n\t Object.defineProperty(Tone.Normalize.prototype, 'min', {\n\t get: function () {\n\t return this._inputMin;\n\t },\n\t set: function (min) {\n\t this._inputMin = min;\n\t this._setRange();\n\t }\n\t });\n\t /**\n\t\t * The maximum value the input signal will reach.\n\t\t * @memberOf Tone.Normalize#\n\t\t * @type {number}\n\t\t * @name max\n\t\t */\n\t Object.defineProperty(Tone.Normalize.prototype, 'max', {\n\t get: function () {\n\t return this._inputMax;\n\t },\n\t set: function (max) {\n\t this._inputMax = max;\n\t this._setRange();\n\t }\n\t });\n\t /**\n\t\t * set the values\n\t\t * @private\n\t\t */\n\t Tone.Normalize.prototype._setRange = function () {\n\t this._sub.value = -this._inputMin;\n\t this._div.value = 1 / (this._inputMax - this._inputMin);\n\t };\n\t /**\n\t\t * clean up\n\t\t * @returns {Tone.Normalize} this\n\t\t */\n\t Tone.Normalize.prototype.dispose = function () {\n\t Tone.SignalBase.prototype.dispose.call(this);\n\t this._sub.dispose();\n\t this._sub = null;\n\t this._div.dispose();\n\t this._div = null;\n\t return this;\n\t };\n\t return Tone.Normalize;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.TransportTimelineSignal extends Tone.Signal, but adds the ability to synchronize the signal to the signal to the Tone.Transport\n\t\t * @extends {Tone.Signal}\n\t\t */\n\t Tone.TransportTimelineSignal = function () {\n\t Tone.Signal.apply(this, arguments);\n\t /**\n\t\t\t * The real signal output\n\t\t\t * @type {Tone.Signal}\n\t\t\t * @private\n\t\t\t */\n\t this.output = this._outputSig = new Tone.Signal(this._initialValue);\n\t /**\n\t\t\t * Keep track of the last value. (small optimization)\n\t\t\t * @private\n\t\t\t * @type {Number}\n\t\t\t */\n\t this._lastVal = this.value;\n\t /**\n\t\t\t * The event id of the tick update loop\n\t\t\t * @private\n\t\t\t * @type {Number}\n\t\t\t */\n\t this._synced = Tone.Transport.scheduleRepeat(this._onTick.bind(this), '1i');\n\t /**\n\t\t\t * A bound version of the anchor value methods\n\t\t\t * @type {Function}\n\t\t\t * @private\n\t\t\t */\n\t this._bindAnchorValue = this._anchorValue.bind(this);\n\t Tone.Transport.on('start stop pause', this._bindAnchorValue);\n\t this._events.memory = Infinity;\n\t };\n\t Tone.extend(Tone.TransportTimelineSignal, Tone.Signal);\n\t /**\n\t\t * Callback which is invoked every tick.\n\t\t * @private\n\t\t * @param {Number} time\n\t\t * @return {Tone.TransportTimelineSignal} this\n\t\t */\n\t Tone.TransportTimelineSignal.prototype._onTick = function (time) {\n\t var val = this.getValueAtTime(Tone.Transport.seconds);\n\t if (this._lastVal !== val) {\n\t this._lastVal = val;\n\t //approximate ramp curves with linear ramps\n\t this._outputSig.linearRampToValueAtTime(val, time);\n\t }\n\t };\n\t /**\n\t\t * Anchor the value at the start and stop of the Transport\n\t\t * @param {Number} time The time of the event\n\t\t * @return {Tone.TransportTimelineSignal} this\n\t\t * @private\n\t\t */\n\t Tone.TransportTimelineSignal.prototype._anchorValue = function (time) {\n\t var val = this.getValueAtTime(Tone.Transport.seconds);\n\t this._lastVal = val;\n\t this._outputSig.cancelScheduledValues(time);\n\t this._outputSig.setValueAtTime(val, time);\n\t return this;\n\t };\n\t /**\n\t\t * Get the scheduled value at the given time. This will\n\t\t * return the unconverted (raw) value.\n\t\t * @param {TransportTime} time The time in seconds.\n\t\t * @return {Number} The scheduled value at the given time.\n\t\t */\n\t Tone.TransportTimelineSignal.prototype.getValueAtTime = function (time) {\n\t time = Tone.TransportTime(time);\n\t return Tone.Signal.prototype.getValueAtTime.call(this, time);\n\t };\n\t /**\n\t\t * Set the output of the signal at the given time\n\t\t * @param {Number} value The value to change to at the given time\n\t\t * @param {TransportTime} time The time to change the signal\n\t\t * @return {Tone.TransportTimelineSignal} this\n\t\t */\n\t Tone.TransportTimelineSignal.prototype.setValueAtTime = function (value, time) {\n\t time = Tone.TransportTime(time);\n\t Tone.Signal.prototype.setValueAtTime.call(this, value, time);\n\t return this;\n\t };\n\t /**\n\t\t * Linear ramp to the given value from the previous scheduled point to the given value\n\t\t * @param {Number} value The value to change to at the given time\n\t\t * @param {TransportTime} time The time to change the signal\n\t\t * @return {Tone.TransportTimelineSignal} this\n\t\t */\n\t Tone.TransportTimelineSignal.prototype.linearRampToValueAtTime = function (value, time) {\n\t time = Tone.TransportTime(time);\n\t Tone.Signal.prototype.linearRampToValueAtTime.call(this, value, time);\n\t return this;\n\t };\n\t /**\n\t\t * Exponential ramp to the given value from the previous scheduled point to the given value\n\t\t * @param {Number} value The value to change to at the given time\n\t\t * @param {TransportTime} time The time to change the signal\n\t\t * @return {Tone.TransportTimelineSignal} this\n\t\t */\n\t Tone.TransportTimelineSignal.prototype.exponentialRampToValueAtTime = function (value, time) {\n\t time = Tone.TransportTime(time);\n\t Tone.Signal.prototype.exponentialRampToValueAtTime.call(this, value, time);\n\t return this;\n\t };\n\t /**\n\t\t * Start exponentially approaching the target value at the given time with\n\t\t * a rate having the given time constant.\n\t\t * @param {number} value\n\t\t * @param {TransportTime} startTime\n\t\t * @param {number} timeConstant\n\t\t * @return {Tone.TransportTimelineSignal} this\n\t\t */\n\t Tone.TransportTimelineSignal.prototype.setTargetAtTime = function (value, startTime, timeConstant) {\n\t startTime = Tone.TransportTime(startTime);\n\t Tone.Signal.prototype.setTargetAtTime.call(this, value, startTime, timeConstant);\n\t return this;\n\t };\n\t /**\n\t\t * Cancels all scheduled parameter changes with times greater than or\n\t\t * equal to startTime.\n\t\t * @param {TransportTime} startTime\n\t\t * @returns {Tone.Param} this\n\t\t */\n\t Tone.TransportTimelineSignal.prototype.cancelScheduledValues = function (startTime) {\n\t startTime = Tone.TransportTime(startTime);\n\t Tone.Signal.prototype.cancelScheduledValues.call(this, startTime);\n\t return this;\n\t };\n\t /**\n\t\t * Set an array of arbitrary values starting at the given time for the given duration.\n\t\t * @param {Float32Array} values\n\t\t * @param {Time} startTime\n\t\t * @param {Time} duration\n\t\t * @param {NormalRange} [scaling=1] If the values in the curve should be scaled by some value\n\t\t * @returns {Tone.Signal} this\n\t\t */\n\t Tone.TransportTimelineSignal.prototype.setValueCurveAtTime = function (values, startTime, duration, scaling) {\n\t startTime = Tone.TransportTime(startTime);\n\t duration = Tone.TransportTime(duration);\n\t Tone.Signal.prototype.setValueCurveAtTime.call(this, values, startTime, duration, scaling);\n\t return this;\n\t };\n\t /**\n\t\t * This is similar to [cancelScheduledValues](#cancelScheduledValues) except\n\t\t * it holds the automated value at time until the next automated event.\n\t\t * @param {Time} time\n\t\t * @returns {Tone.TransportTimelineSignal} this\n\t\t */\n\t Tone.TransportTimelineSignal.prototype.cancelAndHoldAtTime = function (time) {\n\t return Tone.Signal.prototype.cancelAndHoldAtTime.call(this, Tone.TransportTime(time));\n\t };\n\t /**\n\t\t * Dispose and disconnect\n\t\t * @return {Tone.TransportTimelineSignal} this\n\t\t */\n\t Tone.TransportTimelineSignal.prototype.dispose = function () {\n\t Tone.Transport.clear(this._synced);\n\t Tone.Transport.off('start stop pause', this._syncedCallback);\n\t this._events.cancel(0);\n\t Tone.Signal.prototype.dispose.call(this);\n\t this._outputSig.dispose();\n\t this._outputSig = null;\n\t };\n\t return Tone.TransportTimelineSignal;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.GrainPlayer implements [granular synthesis](https://en.wikipedia.org/wiki/Granular_synthesis).\n\t\t * Granular Synthesis enables you to adjust pitch and playback rate independently. The grainSize is the\n\t\t * amount of time each small chunk of audio is played for and the overlap is the\n\t\t * amount of crossfading transition time between successive grains.\n\t\t * @extends {Tone.Source}\n\t\t * @param {String|Tone.Buffer} url\tThe url to load, or the Tone.Buffer to play.\n\t\t * @param {Function=} callback The callback to invoke after the url is loaded.\n\t\t */\n\t Tone.GrainPlayer = function () {\n\t var options = Tone.defaults(arguments, [\n\t 'url',\n\t 'onload'\n\t ], Tone.GrainPlayer);\n\t Tone.Source.call(this, options);\n\t /**\n\t\t\t * The audio buffer belonging to the player.\n\t\t\t * @type {Tone.Buffer}\n\t\t\t */\n\t this.buffer = new Tone.Buffer(options.url, options.onload);\n\t /**\n\t\t\t * Create a repeating tick to schedule\n\t\t\t * the grains.\n\t\t\t * @type {Tone.Clock}\n\t\t\t * @private\n\t\t\t */\n\t this._clock = new Tone.Clock(this._tick.bind(this), options.grainSize);\n\t /**\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._loopStart = 0;\n\t /**\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._loopEnd = 0;\n\t /**\n\t\t\t * All of the currently playing BufferSources\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t this._activeSources = [];\n\t /**\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._playbackRate = options.playbackRate;\n\t /**\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._grainSize = options.grainSize;\n\t /**\n\t\t\t * @private\n\t\t\t * @type {Number}\n\t\t\t */\n\t this._overlap = options.overlap;\n\t /**\n\t\t\t * Adjust the pitch independently of the playbackRate.\n\t\t\t * @type {Cents}\n\t\t\t */\n\t this.detune = options.detune;\n\t //setup\n\t this.overlap = options.overlap;\n\t this.loop = options.loop;\n\t this.playbackRate = options.playbackRate;\n\t this.grainSize = options.grainSize;\n\t this.loopStart = options.loopStart;\n\t this.loopEnd = options.loopEnd;\n\t this.reverse = options.reverse;\n\t this._clock.on('stop', this._onstop.bind(this));\n\t };\n\t Tone.extend(Tone.GrainPlayer, Tone.Source);\n\t /**\n\t\t * the default parameters\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.GrainPlayer.defaults = {\n\t 'onload': Tone.noOp,\n\t 'overlap': 0.1,\n\t 'grainSize': 0.2,\n\t 'playbackRate': 1,\n\t 'detune': 0,\n\t 'loop': false,\n\t 'loopStart': 0,\n\t 'loopEnd': 0,\n\t 'reverse': false\n\t };\n\t /**\n\t\t * Play the buffer at the given startTime. Optionally add an offset\n\t\t * and/or duration which will play the buffer from a position\n\t\t * within the buffer for the given duration.\n\t\t *\n\t\t * @param {Time} [startTime=now] When the player should start.\n\t\t * @param {Time} [offset=0] The offset from the beginning of the sample\n\t\t * to start at.\n\t\t * @param {Time=} duration How long the sample should play. If no duration\n\t\t * is given, it will default to the full length\n\t\t * of the sample (minus any offset)\n\t\t * @returns {Tone.GrainPlayer} this\n\t\t * @memberOf Tone.GrainPlayer#\n\t\t * @method start\n\t\t * @name start\n\t\t */\n\t /**\n\t\t * Internal start method\n\t\t * @param {Time} time\n\t\t * @param {Time} offset\n\t\t * @private\n\t\t */\n\t Tone.GrainPlayer.prototype._start = function (time, offset, duration) {\n\t offset = Tone.defaultArg(offset, 0);\n\t offset = this.toSeconds(offset);\n\t time = this.toSeconds(time);\n\t this._offset = offset;\n\t this._clock.start(time);\n\t if (duration) {\n\t this.stop(time + this.toSeconds(duration));\n\t }\n\t };\n\t /**\n\t\t * Internal start method\n\t\t * @param {Time} time\n\t\t * @private\n\t\t */\n\t Tone.GrainPlayer.prototype._stop = function (time) {\n\t this._clock.stop(time);\n\t };\n\t /**\n\t\t * Invoked when the clock is stopped\n\t\t * @param {Number} time\n\t\t * @private\n\t\t */\n\t Tone.GrainPlayer.prototype._onstop = function (time) {\n\t //stop the players\n\t this._activeSources.forEach(function (source) {\n\t source.stop(time, 0);\n\t });\n\t };\n\t /**\n\t\t * Invoked on each clock tick. scheduled a new\n\t\t * grain at this time.\n\t\t * @param {Time} time\n\t\t * @private\n\t\t */\n\t Tone.GrainPlayer.prototype._tick = function (time) {\n\t var fadeIn = this._offset < this._overlap ? 0 : this._overlap;\n\t var source = new Tone.BufferSource({\n\t 'buffer': this.buffer,\n\t 'fadeIn': fadeIn,\n\t 'fadeOut': this._overlap,\n\t 'loop': this.loop,\n\t 'loopStart': this._loopStart,\n\t 'loopEnd': this._loopEnd,\n\t 'playbackRate': Tone.intervalToFrequencyRatio(this.detune / 100)\n\t }).connect(this.output);\n\t source.start(time, this._offset);\n\t this._offset += this.grainSize;\n\t source.stop(time + this.grainSize);\n\t //add it to the active sources\n\t this._activeSources.push(source);\n\t //remove it when it's done\n\t source.onended = function () {\n\t var index = this._activeSources.indexOf(source);\n\t if (index !== -1) {\n\t this._activeSources.splice(index, 1);\n\t }\n\t }.bind(this);\n\t };\n\t /**\n\t\t * Jump to a specific time and play it.\n\t\t * @param {Time} offset The offset to jump to.\n\t\t * @param {Time=} time When to make the jump.\n\t\t * @return {Tone.GrainPlayer} this\n\t\t */\n\t Tone.GrainPlayer.prototype.seek = function (offset, time) {\n\t this._offset = this.toSeconds(offset);\n\t this._tick(this.toSeconds(time));\n\t return this;\n\t };\n\t /**\n\t\t * The playback rate of the sample\n\t\t * @memberOf Tone.GrainPlayer#\n\t\t * @type {Positive}\n\t\t * @name playbackRate\n\t\t */\n\t Object.defineProperty(Tone.GrainPlayer.prototype, 'playbackRate', {\n\t get: function () {\n\t return this._playbackRate;\n\t },\n\t set: function (rate) {\n\t this._playbackRate = rate;\n\t this.grainSize = this._grainSize;\n\t }\n\t });\n\t /**\n\t\t * The loop start time.\n\t\t * @memberOf Tone.GrainPlayer#\n\t\t * @type {Time}\n\t\t * @name loopStart\n\t\t */\n\t Object.defineProperty(Tone.GrainPlayer.prototype, 'loopStart', {\n\t get: function () {\n\t return this._loopStart;\n\t },\n\t set: function (time) {\n\t this._loopStart = this.toSeconds(time);\n\t }\n\t });\n\t /**\n\t\t * The loop end time.\n\t\t * @memberOf Tone.GrainPlayer#\n\t\t * @type {Time}\n\t\t * @name loopEnd\n\t\t */\n\t Object.defineProperty(Tone.GrainPlayer.prototype, 'loopEnd', {\n\t get: function () {\n\t return this._loopEnd;\n\t },\n\t set: function (time) {\n\t this._loopEnd = this.toSeconds(time);\n\t }\n\t });\n\t /**\n\t\t * The direction the buffer should play in\n\t\t * @memberOf Tone.GrainPlayer#\n\t\t * @type {boolean}\n\t\t * @name reverse\n\t\t */\n\t Object.defineProperty(Tone.GrainPlayer.prototype, 'reverse', {\n\t get: function () {\n\t return this.buffer.reverse;\n\t },\n\t set: function (rev) {\n\t this.buffer.reverse = rev;\n\t }\n\t });\n\t /**\n\t\t * The size of each chunk of audio that the\n\t\t * buffer is chopped into and played back at.\n\t\t * @memberOf Tone.GrainPlayer#\n\t\t * @type {Time}\n\t\t * @name grainSize\n\t\t */\n\t Object.defineProperty(Tone.GrainPlayer.prototype, 'grainSize', {\n\t get: function () {\n\t return this._grainSize;\n\t },\n\t set: function (size) {\n\t this._grainSize = this.toSeconds(size);\n\t this._clock.frequency.value = this._playbackRate / this._grainSize;\n\t }\n\t });\n\t /**\n\t\t * This is the duration of the cross-fade between\n\t\t * sucessive grains.\n\t\t * @memberOf Tone.GrainPlayer#\n\t\t * @type {Time}\n\t\t * @name overlap\n\t\t */\n\t Object.defineProperty(Tone.GrainPlayer.prototype, 'overlap', {\n\t get: function () {\n\t return this._overlap;\n\t },\n\t set: function (time) {\n\t this._overlap = this.toSeconds(time);\n\t }\n\t });\n\t /**\n\t\t * Clean up\n\t\t * @return {Tone.GrainPlayer} this\n\t\t */\n\t Tone.GrainPlayer.prototype.dispose = function () {\n\t Tone.Source.prototype.dispose.call(this);\n\t this.buffer.dispose();\n\t this.buffer = null;\n\t this._clock.dispose();\n\t this._clock = null;\n\t this._activeSources.forEach(function (source) {\n\t source.dispose();\n\t });\n\t this._activeSources = null;\n\t return this;\n\t };\n\t return Tone.GrainPlayer;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Player is an audio file player with start, loop, and stop functions.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.Source}\n\t\t * @param {string|AudioBuffer} url Either the AudioBuffer or the url from\n\t\t * which to load the AudioBuffer\n\t\t * @param {Function=} onload The function to invoke when the buffer is loaded.\n\t\t * Recommended to use Tone.Buffer.on('load') instead.\n\t\t * @example\n\t\t * var player = new Tone.Player(\"./path/to/sample.mp3\").toMaster();\n\t\t * //play as soon as the buffer is loaded\n\t\t * player.autostart = true;\n\t\t */\n\t Tone.Player = function (url) {\n\t var options;\n\t if (url instanceof Tone.Buffer && url.loaded) {\n\t url = url.get();\n\t options = Tone.Player.defaults;\n\t } else {\n\t options = Tone.defaults(arguments, [\n\t 'url',\n\t 'onload'\n\t ], Tone.Player);\n\t }\n\t Tone.Source.call(this, options);\n\t /**\n\t\t\t * If the file should play as soon\n\t\t\t * as the buffer is loaded.\n\t\t\t * @type {Boolean}\n\t\t\t * @example\n\t\t\t * //will play as soon as it's loaded\n\t\t\t * var player = new Tone.Player({\n\t\t\t * \t\"url\" : \"./path/to/sample.mp3\",\n\t\t\t * \t\"autostart\" : true,\n\t\t\t * }).toMaster();\n\t\t\t */\n\t this.autostart = options.autostart;\n\t /**\n\t\t\t * the buffer\n\t\t\t * @private\n\t\t\t * @type {Tone.Buffer}\n\t\t\t */\n\t this._buffer = new Tone.Buffer({\n\t 'url': options.url,\n\t 'onload': this._onload.bind(this, options.onload),\n\t 'reverse': options.reverse\n\t });\n\t if (url instanceof AudioBuffer) {\n\t this._buffer.set(url);\n\t }\n\t /**\n\t\t\t * if the buffer should loop once it's over\n\t\t\t * @type {Boolean}\n\t\t\t * @private\n\t\t\t */\n\t this._loop = options.loop;\n\t /**\n\t\t\t * if 'loop' is true, the loop will start at this position\n\t\t\t * @type {Time}\n\t\t\t * @private\n\t\t\t */\n\t this._loopStart = options.loopStart;\n\t /**\n\t\t\t * if 'loop' is true, the loop will end at this position\n\t\t\t * @type {Time}\n\t\t\t * @private\n\t\t\t */\n\t this._loopEnd = options.loopEnd;\n\t /**\n\t\t\t * the playback rate\n\t\t\t * @private\n\t\t\t * @type {Number}\n\t\t\t */\n\t this._playbackRate = options.playbackRate;\n\t /**\n\t\t\t * All of the active buffer source nodes\n\t\t\t * @type {Array<Tone.BufferSource>}\n\t\t\t * @private\n\t\t\t */\n\t this._activeSources = [];\n\t /**\n\t\t\t * The elapsed time counter.\n\t\t\t * @type {Tone.TickSource}\n\t\t\t * @private\n\t\t\t */\n\t this._elapsedTime = new Tone.TickSource(options.playbackRate);\n\t /**\n\t\t\t * The fadeIn time of the amplitude envelope.\n\t\t\t * @type {Time}\n\t\t\t */\n\t this.fadeIn = options.fadeIn;\n\t /**\n\t\t\t * The fadeOut time of the amplitude envelope.\n\t\t\t * @type {Time}\n\t\t\t */\n\t this.fadeOut = options.fadeOut;\n\t };\n\t Tone.extend(Tone.Player, Tone.Source);\n\t /**\n\t\t * the default parameters\n\t\t * @static\n\t\t * @const\n\t\t * @type {Object}\n\t\t */\n\t Tone.Player.defaults = {\n\t 'onload': Tone.noOp,\n\t 'playbackRate': 1,\n\t 'loop': false,\n\t 'autostart': false,\n\t 'loopStart': 0,\n\t 'loopEnd': 0,\n\t 'retrigger': false,\n\t 'reverse': false,\n\t 'fadeIn': 0,\n\t 'fadeOut': 0\n\t };\n\t /**\n\t\t * Load the audio file as an audio buffer.\n\t\t * Decodes the audio asynchronously and invokes\n\t\t * the callback once the audio buffer loads.\n\t\t * Note: this does not need to be called if a url\n\t\t * was passed in to the constructor. Only use this\n\t\t * if you want to manually load a new url.\n\t\t * @param {string} url The url of the buffer to load.\n\t\t * Filetype support depends on the\n\t\t * browser.\n\t\t * @param {Function=} callback The function to invoke once\n\t\t * the sample is loaded.\n\t\t * @returns {Promise}\n\t\t */\n\t Tone.Player.prototype.load = function (url, callback) {\n\t return this._buffer.load(url, this._onload.bind(this, callback));\n\t };\n\t /**\n\t\t * Internal callback when the buffer is loaded.\n\t\t * @private\n\t\t */\n\t Tone.Player.prototype._onload = function (callback) {\n\t callback = Tone.defaultArg(callback, Tone.noOp);\n\t callback(this);\n\t if (this.autostart) {\n\t this.start();\n\t }\n\t };\n\t /**\n\t\t * Internal callback when the buffer is done playing.\n\t\t * @private\n\t\t */\n\t Tone.Player.prototype._onSourceEnd = function (source) {\n\t var index = this._activeSources.indexOf(source);\n\t this._activeSources.splice(index, 1);\n\t };\n\t /**\n\t\t * Play the buffer at the given startTime. Optionally add an offset\n\t\t * and/or duration which will play the buffer from a position\n\t\t * within the buffer for the given duration.\n\t\t *\n\t\t * @param {Time} [startTime=now] When the player should start.\n\t\t * @param {Time} [offset=0] The offset from the beginning of the sample\n\t\t * to start at.\n\t\t * @param {Time=} duration How long the sample should play. If no duration\n\t\t * is given, it will default to the full length\n\t\t * of the sample (minus any offset)\n\t\t * @returns {Tone.Player} this\n\t\t * @memberOf Tone.Player#\n\t\t * @method start\n\t\t * @name start\n\t\t */\n\t /**\n\t\t * Internal start method\n\t\t * @private\n\t\t */\n\t Tone.Player.prototype._start = function (startTime, offset, duration) {\n\t //if it's a loop the default offset is the loopstart point\n\t if (this._loop) {\n\t offset = Tone.defaultArg(offset, this._loopStart);\n\t } else {\n\t //otherwise the default offset is 0\n\t offset = Tone.defaultArg(offset, 0);\n\t }\n\t //compute the values in seconds\n\t offset = this.toSeconds(offset);\n\t var computedDuration = Tone.defaultArg(duration, Math.max(this._buffer.duration - offset, 0));\n\t computedDuration = this.toSeconds(computedDuration);\n\t startTime = this.toSeconds(startTime);\n\t //start the elapsed time counter\n\t this._elapsedTime.start(startTime, offset);\n\t //make the source\n\t var source = new Tone.BufferSource({\n\t 'buffer': this._buffer,\n\t 'loop': this._loop,\n\t 'loopStart': this._loopStart,\n\t 'loopEnd': this._loopEnd,\n\t 'onended': this._onSourceEnd.bind(this),\n\t 'playbackRate': this._playbackRate,\n\t 'fadeIn': this.fadeIn,\n\t 'fadeOut': this.fadeOut\n\t }).connect(this.output);\n\t //set the looping properties\n\t if (!this._loop && !this._synced) {\n\t //if it's not looping, set the state change at the end of the sample\n\t this._state.setStateAtTime(Tone.State.Stopped, startTime + computedDuration / this._playbackRate);\n\t }\n\t //add it to the array of active sources\n\t this._activeSources.push(source);\n\t //start it\n\t if (this._loop && Tone.isUndef(duration)) {\n\t source.start(startTime, offset);\n\t } else {\n\t source.start(startTime, offset, computedDuration);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Stop playback.\n\t\t * @private\n\t\t * @param {Time} [time=now]\n\t\t * @returns {Tone.Player} this\n\t\t */\n\t Tone.Player.prototype._stop = function (time) {\n\t time = this.toSeconds(time);\n\t this._elapsedTime.stop(time);\n\t this._activeSources.forEach(function (source) {\n\t source.stop(time);\n\t });\n\t return this;\n\t };\n\t /**\n\t\t * Stop and then restart the player from the beginning (or offset)\n\t\t * @param {Time} [startTime=now] When the player should start.\n\t\t * @param {Time} [offset=0] The offset from the beginning of the sample\n\t\t * to start at.\n\t\t * @param {Time=} duration How long the sample should play. If no duration\n\t\t * is given, it will default to the full length\n\t\t * of the sample (minus any offset)\n\t\t * @returns {Tone.Player} this\n\t\t */\n\t Tone.Player.prototype.restart = function (time, offset, duration) {\n\t this._stop(time);\n\t this._start(time, offset, duration);\n\t return this;\n\t };\n\t /**\n\t\t * Seek to a specific time in the player's buffer. If the\n\t\t * source is no longer playing at that time, it will stop.\n\t\t * If you seek to a time that\n\t\t * @param {Time} offset The time to seek to.\n\t\t * @param {Time=} time The time for the seek event to occur.\n\t\t * @return {Tone.Player} this\n\t\t * @example\n\t\t * source.start(0.2);\n\t\t * source.stop(0.4);\n\t\t */\n\t Tone.Player.prototype.seek = function (offset, time) {\n\t time = this.toSeconds(time);\n\t if (this._state.getValueAtTime(time) === Tone.State.Started) {\n\t offset = this.toSeconds(offset);\n\t // if it's currently playing, stop it\n\t this._stop(time);\n\t //restart it at the given time\n\t this._start(time, offset);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * Set the loop start and end. Will only loop if loop is\n\t\t * set to true.\n\t\t * @param {Time} loopStart The loop end time\n\t\t * @param {Time} loopEnd The loop end time\n\t\t * @returns {Tone.Player} this\n\t\t * @example\n\t\t * //loop 0.1 seconds of the file.\n\t\t * player.setLoopPoints(0.2, 0.3);\n\t\t * player.loop = true;\n\t\t */\n\t Tone.Player.prototype.setLoopPoints = function (loopStart, loopEnd) {\n\t this.loopStart = loopStart;\n\t this.loopEnd = loopEnd;\n\t return this;\n\t };\n\t /**\n\t\t * If loop is true, the loop will start at this position.\n\t\t * @memberOf Tone.Player#\n\t\t * @type {Time}\n\t\t * @name loopStart\n\t\t */\n\t Object.defineProperty(Tone.Player.prototype, 'loopStart', {\n\t get: function () {\n\t return this._loopStart;\n\t },\n\t set: function (loopStart) {\n\t this._loopStart = loopStart;\n\t //get the current source\n\t this._activeSources.forEach(function (source) {\n\t source.loopStart = loopStart;\n\t });\n\t }\n\t });\n\t /**\n\t\t * If loop is true, the loop will end at this position.\n\t\t * @memberOf Tone.Player#\n\t\t * @type {Time}\n\t\t * @name loopEnd\n\t\t */\n\t Object.defineProperty(Tone.Player.prototype, 'loopEnd', {\n\t get: function () {\n\t return this._loopEnd;\n\t },\n\t set: function (loopEnd) {\n\t this._loopEnd = loopEnd;\n\t //get the current source\n\t this._activeSources.forEach(function (source) {\n\t source.loopEnd = loopEnd;\n\t });\n\t }\n\t });\n\t /**\n\t\t * The audio buffer belonging to the player.\n\t\t * @memberOf Tone.Player#\n\t\t * @type {Tone.Buffer}\n\t\t * @name buffer\n\t\t */\n\t Object.defineProperty(Tone.Player.prototype, 'buffer', {\n\t get: function () {\n\t return this._buffer;\n\t },\n\t set: function (buffer) {\n\t this._buffer.set(buffer);\n\t }\n\t });\n\t /**\n\t\t * If the buffer should loop once it's over.\n\t\t * @memberOf Tone.Player#\n\t\t * @type {Boolean}\n\t\t * @name loop\n\t\t */\n\t Object.defineProperty(Tone.Player.prototype, 'loop', {\n\t get: function () {\n\t return this._loop;\n\t },\n\t set: function (loop) {\n\t //if no change, do nothing\n\t if (this._loop === loop) {\n\t return;\n\t }\n\t this._loop = loop;\n\t var now = this.now();\n\t if (!loop) {\n\t //stop the playback on the next cycle\n\t this._stopAtNextIteration(now);\n\t } else {\n\t //remove the next stopEvent\n\t var stopEvent = this._state.getNextState(Tone.State.Stopped, now);\n\t if (stopEvent) {\n\t this._activeSources.forEach(function (source) {\n\t source.loop = loop;\n\t });\n\t this._state.cancel(stopEvent.time);\n\t this._elapsedTime.cancel(stopEvent.time);\n\t }\n\t }\n\t }\n\t });\n\t /**\n\t\t * Schedules a stop event at the next full iteration. Used\n\t\t * for scheduling stop when the loop state or playbackRate changes\n\t\t * @param {Number} now The current time\n\t\t * @private\n\t\t */\n\t Tone.Player.prototype._stopAtNextIteration = function (now) {\n\t if (this._state.getValueAtTime(now) === Tone.State.Started) {\n\t var nextStop = this._state.getNextState(Tone.State.Stopped, now);\n\t var position = this._elapsedTime.getTicksAtTime(now);\n\t var iterations = Math.max(Math.ceil(position / this.buffer.duration), 1);\n\t var stopTime = this._elapsedTime.getTimeOfTick(iterations * this.buffer.duration, nextStop ? nextStop.time - this.sampleTime : Infinity);\n\t this.stop(stopTime);\n\t }\n\t };\n\t /**\n\t\t * The playback speed. 1 is normal speed. This is not a signal because\n\t\t * Safari and iOS currently don't support playbackRate as a signal.\n\t\t * @memberOf Tone.Player#\n\t\t * @type {Number}\n\t\t * @name playbackRate\n\t\t */\n\t Object.defineProperty(Tone.Player.prototype, 'playbackRate', {\n\t get: function () {\n\t return this._playbackRate;\n\t },\n\t set: function (rate) {\n\t this._playbackRate = rate;\n\t var now = this.now();\n\t this._elapsedTime.frequency.setValueAtTime(rate, now);\n\t //if it's not looping\n\t if (!this._loop) {\n\t this._stopAtNextIteration(now);\n\t }\n\t //set all the sources\n\t this._activeSources.forEach(function (source) {\n\t source.playbackRate.setValueAtTime(rate, now);\n\t });\n\t }\n\t });\n\t /**\n\t\t * The current playback position of the buffer. \n\t\t * @memberOf Tone.Player#\n\t\t * @type {Number}\n\t\t * @name position\n\t\t */\n\t Object.defineProperty(Tone.Player.prototype, 'position', {\n\t get: function () {\n\t var now = this.now();\n\t if (this._state.getValueAtTime(now) === Tone.State.Started && this.loaded) {\n\t var duration = this.buffer.duration;\n\t var position = this._elapsedTime.getTicksAtTime(now);\n\t return position % duration;\n\t } else {\n\t return 0;\n\t }\n\t }\n\t });\n\t /**\n\t\t * The direction the buffer should play in\n\t\t * @memberOf Tone.Player#\n\t\t * @type {Boolean}\n\t\t * @name reverse\n\t\t */\n\t Object.defineProperty(Tone.Player.prototype, 'reverse', {\n\t get: function () {\n\t return this._buffer.reverse;\n\t },\n\t set: function (rev) {\n\t this._buffer.reverse = rev;\n\t }\n\t });\n\t /**\n\t\t * If all the buffer is loaded\n\t\t * @memberOf Tone.Player#\n\t\t * @type {Boolean}\n\t\t * @name loaded\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Player.prototype, 'loaded', {\n\t get: function () {\n\t return this._buffer.loaded;\n\t }\n\t });\n\t /**\n\t\t * Dispose and disconnect.\n\t\t * @return {Tone.Player} this\n\t\t */\n\t Tone.Player.prototype.dispose = function () {\n\t //disconnect all of the players\n\t this._activeSources.forEach(function (source) {\n\t source.dispose();\n\t });\n\t this._activeSources = null;\n\t Tone.Source.prototype.dispose.call(this);\n\t this._buffer.dispose();\n\t this._buffer = null;\n\t this._elapsedTime.dispose();\n\t this._elapsedTime = null;\n\t return this;\n\t };\n\t return Tone.Player;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.Players combines multiple [Tone.Player](Player) objects.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {Object} urls An object mapping a name to a url.\n\t\t * @param {function=} onload The function to invoke when all buffers are loaded.\n\t\t */\n\t Tone.Players = function (urls) {\n\t var args = Array.prototype.slice.call(arguments);\n\t args.shift();\n\t var options = Tone.defaults(args, ['onload'], Tone.Players);\n\t Tone.call(this);\n\t /**\n\t\t\t * The output volume node\n\t\t\t * @type {Tone.Volume}\n\t\t\t * @private\n\t\t\t */\n\t this._volume = this.output = new Tone.Volume(options.volume);\n\t /**\n\t\t\t * The volume of the output in decibels.\n\t\t\t * @type {Decibels}\n\t\t\t * @signal\n\t\t\t * @example\n\t\t\t * source.volume.value = -6;\n\t\t\t */\n\t this.volume = this._volume.volume;\n\t this._readOnly('volume');\n\t //make the output explicitly stereo\n\t this._volume.output.output.channelCount = 2;\n\t this._volume.output.output.channelCountMode = 'explicit';\n\t //mute initially\n\t this.mute = options.mute;\n\t /**\n\t\t\t * The container of all of the players\n\t\t\t * @type {Object}\n\t\t\t * @private\n\t\t\t */\n\t this._players = {};\n\t /**\n\t\t\t * The loading count\n\t\t\t * @type {Number}\n\t\t\t * @private\n\t\t\t */\n\t this._loadingCount = 0;\n\t /**\n\t\t\t * private holder of the fadeIn time\n\t\t\t * @type {Time}\n\t\t\t * @private\n\t\t\t */\n\t this._fadeIn = options.fadeIn;\n\t /**\n\t\t\t * private holder of the fadeOut time\n\t\t\t * @type {Time}\n\t\t\t * @private\n\t\t\t */\n\t this._fadeOut = options.fadeOut;\n\t //add all of the players\n\t for (var name in urls) {\n\t this._loadingCount++;\n\t this.add(name, urls[name], this._bufferLoaded.bind(this, options.onload));\n\t }\n\t };\n\t Tone.extend(Tone.Players, Tone.AudioNode);\n\t /**\n\t\t * The default values\n\t\t * @type {Object}\n\t\t */\n\t Tone.Players.defaults = {\n\t 'volume': 0,\n\t 'mute': false,\n\t 'onload': Tone.noOp,\n\t 'fadeIn': 0,\n\t 'fadeOut': 0\n\t };\n\t /**\n\t\t * A buffer was loaded. decrement the counter.\n\t\t * @param {Function} callback\n\t\t * @private\n\t\t */\n\t Tone.Players.prototype._bufferLoaded = function (callback) {\n\t this._loadingCount--;\n\t if (this._loadingCount === 0 && callback) {\n\t callback(this);\n\t }\n\t };\n\t /**\n\t\t * Mute the output.\n\t\t * @memberOf Tone.Source#\n\t\t * @type {boolean}\n\t\t * @name mute\n\t\t * @example\n\t\t * //mute the output\n\t\t * source.mute = true;\n\t\t */\n\t Object.defineProperty(Tone.Players.prototype, 'mute', {\n\t get: function () {\n\t return this._volume.mute;\n\t },\n\t set: function (mute) {\n\t this._volume.mute = mute;\n\t }\n\t });\n\t /**\n\t\t * The fadeIn time of the amplitude envelope.\n\t\t * @memberOf Tone.Source#\n\t\t * @type {Time}\n\t\t * @name fadeIn\n\t\t */\n\t Object.defineProperty(Tone.Players.prototype, 'fadeIn', {\n\t get: function () {\n\t return this._fadeIn;\n\t },\n\t set: function (fadeIn) {\n\t this._fadeIn = fadeIn;\n\t this._forEach(function (player) {\n\t player.fadeIn = fadeIn;\n\t });\n\t }\n\t });\n\t /**\n\t\t * The fadeOut time of the amplitude envelope.\n\t\t * @memberOf Tone.Source#\n\t\t * @type {Time}\n\t\t * @name fadeOut\n\t\t */\n\t Object.defineProperty(Tone.Players.prototype, 'fadeOut', {\n\t get: function () {\n\t return this._fadeOut;\n\t },\n\t set: function (fadeOut) {\n\t this._fadeOut = fadeOut;\n\t this._forEach(function (player) {\n\t player.fadeOut = fadeOut;\n\t });\n\t }\n\t });\n\t /**\n\t\t * The state of the players object. Returns \"started\" if any of the players are playing.\n\t\t * @memberOf Tone.Players#\n\t\t * @type {String}\n\t\t * @name state\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Players.prototype, 'state', {\n\t get: function () {\n\t var playing = false;\n\t this._forEach(function (player) {\n\t playing = playing || player.state === Tone.State.Started;\n\t });\n\t return playing ? Tone.State.Started : Tone.State.Stopped;\n\t }\n\t });\n\t /**\n\t\t * True if the buffers object has a buffer by that name.\n\t\t * @param {String|Number} name The key or index of the\n\t\t * buffer.\n\t\t * @return {Boolean}\n\t\t */\n\t Tone.Players.prototype.has = function (name) {\n\t return this._players.hasOwnProperty(name);\n\t };\n\t /**\n\t\t * Get a player by name.\n\t\t * @param {String} name The players name as defined in\n\t\t * the constructor object or `add` method.\n\t\t * @return {Tone.Player}\n\t\t */\n\t Tone.Players.prototype.get = function (name) {\n\t if (this.has(name)) {\n\t return this._players[name];\n\t } else {\n\t throw new Error('Tone.Players: no player named ' + name);\n\t }\n\t };\n\t /**\n\t\t * Iterate over all of the players\n\t\t * @param {Function} callback\n\t\t * @return {Tone.Players} this\n\t\t * @private\n\t\t */\n\t Tone.Players.prototype._forEach = function (callback) {\n\t for (var playerName in this._players) {\n\t callback(this._players[playerName], playerName);\n\t }\n\t return this;\n\t };\n\t /**\n\t\t * If all the buffers are loaded or not\n\t\t * @memberOf Tone.Players#\n\t\t * @type {Boolean}\n\t\t * @name loaded\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.Players.prototype, 'loaded', {\n\t get: function () {\n\t var isLoaded = true;\n\t this._forEach(function (player) {\n\t isLoaded = isLoaded && player.loaded;\n\t });\n\t return isLoaded;\n\t }\n\t });\n\t /**\n\t\t * Add a player by name and url to the Players\n\t\t * @param {String} name A unique name to give the player\n\t\t * @param {String|Tone.Buffer|Audiobuffer} url Either the url of the bufer,\n\t\t * or a buffer which will be added\n\t\t * with the given name.\n\t\t * @param {Function=} callback The callback to invoke\n\t\t * when the url is loaded.\n\t\t */\n\t Tone.Players.prototype.add = function (name, url, callback) {\n\t this._players[name] = new Tone.Player(url, callback).connect(this.output);\n\t this._players[name].fadeIn = this._fadeIn;\n\t this._players[name].fadeOut = this._fadeOut;\n\t return this;\n\t };\n\t /**\n\t\t * Stop all of the players at the given time\n\t\t * @param {Time} time The time to stop all of the players.\n\t\t * @return {Tone.Players} this\n\t\t */\n\t Tone.Players.prototype.stopAll = function (time) {\n\t this._forEach(function (player) {\n\t player.stop(time);\n\t });\n\t };\n\t /**\n\t\t * Dispose and disconnect.\n\t\t * @return {Tone.Players} this\n\t\t */\n\t Tone.Players.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this._volume.dispose();\n\t this._volume = null;\n\t this._writable('volume');\n\t this.volume = null;\n\t this.output = null;\n\t this._forEach(function (player) {\n\t player.dispose();\n\t });\n\t this._players = null;\n\t return this;\n\t };\n\t return Tone.Players;\n\t});\n\tModule(function (Tone) {\n\t \n\t /**\n\t\t * @class Tone.UserMedia uses MediaDevices.getUserMedia to open up\n\t\t * and external microphone or audio input. Check\n\t\t * [MediaDevices API Support](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia)\n\t\t * to see which browsers are supported. Access to an external input\n\t\t * is limited to secure (HTTPS) connections.\n\t\t *\n\t\t * @constructor\n\t\t * @extends {Tone.AudioNode}\n\t\t * @param {Decibels=} volume The level of the input\n\t\t * @example\n\t\t * //list the inputs and open the third one\n\t\t * var motu = new Tone.UserMedia();\n\t\t *\n\t\t * //opening the input asks the user to activate their mic\n\t\t * motu.open().then(function(){\n\t\t * \t//promise resolves when input is available\n\t\t * });\n\t\t */\n\t Tone.UserMedia = function () {\n\t var options = Tone.defaults(arguments, ['volume'], Tone.UserMedia);\n\t Tone.AudioNode.call(this);\n\t /**\n\t\t\t * The MediaStreamNode\n\t\t\t * @type {MediaStreamAudioSourceNode}\n\t\t\t * @private\n\t\t\t */\n\t this._mediaStream = null;\n\t /**\n\t\t\t * The media stream created by getUserMedia.\n\t\t\t * @type {LocalMediaStream}\n\t\t\t * @private\n\t\t\t */\n\t this._stream = null;\n\t /**\n\t\t\t * The open device\n\t\t\t * @type {MediaDeviceInfo}\n\t\t\t * @private\n\t\t\t */\n\t this._device = null;\n\t /**\n\t\t\t * The output volume node\n\t\t\t * @type {Tone.Volume}\n\t\t\t * @private\n\t\t\t */\n\t this._volume = this.output = new Tone.Volume(options.volume);\n\t /**\n\t\t\t * The volume of the output in decibels.\n\t\t\t * @type {Decibels}\n\t\t\t * @signal\n\t\t\t * @example\n\t\t\t * input.volume.value = -6;\n\t\t\t */\n\t this.volume = this._volume.volume;\n\t this._readOnly('volume');\n\t this.mute = options.mute;\n\t };\n\t Tone.extend(Tone.UserMedia, Tone.AudioNode);\n\t /**\n\t\t * the default parameters\n\t\t * @type {Object}\n\t\t */\n\t Tone.UserMedia.defaults = {\n\t 'volume': 0,\n\t 'mute': false\n\t };\n\t /**\n\t\t * Open the media stream. If a string is passed in, it is assumed\n\t\t * to be the label or id of the stream, if a number is passed in,\n\t\t * it is the input number of the stream.\n\t\t * @param {String|Number} [labelOrId=\"default\"] The label or id of the audio input media device.\n\t\t * With no argument, the default stream is opened.\n\t\t * @return {Promise} The promise is resolved when the stream is open.\n\t\t */\n\t Tone.UserMedia.prototype.open = function (labelOrId) {\n\t return Tone.UserMedia.enumerateDevices().then(function (devices) {\n\t var device;\n\t if (Tone.isNumber(labelOrId)) {\n\t device = devices[labelOrId];\n\t } else {\n\t device = devices.find(function (device) {\n\t return device.label === labelOrId || device.deviceId === labelOrId;\n\t });\n\t //didn't find a matching device\n\t if (!device && devices.length > 0) {\n\t device = devices[0];\n\t } else if (!device && Tone.isDefined(labelOrId)) {\n\t throw new Error('Tone.UserMedia: no matching device: ' + labelOrId);\n\t }\n\t }\n\t this._device = device;\n\t //do getUserMedia\n\t var constraints = {\n\t audio: {\n\t 'echoCancellation': false,\n\t 'sampleRate': this.context.sampleRate\n\t }\n\t };\n\t if (device) {\n\t constraints.audio.deviceId = device.deviceId;\n\t }\n\t return navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n\t //start a new source only if the previous one is closed\n\t if (!this._stream) {\n\t this._stream = stream;\n\t //Wrap a MediaStreamSourceNode around the live input stream.\n\t this._mediaStream = this.context.createMediaStreamSource(stream);\n\t //Connect the MediaStreamSourceNode to a gate gain node\n\t this._mediaStream.connect(this.output);\n\t }\n\t return this;\n\t }.bind(this));\n\t }.bind(this));\n\t };\n\t /**\n\t\t * Close the media stream\n\t\t * @return {Tone.UserMedia} this\n\t\t */\n\t Tone.UserMedia.prototype.close = function () {\n\t if (this._stream) {\n\t this._stream.getAudioTracks().forEach(function (track) {\n\t track.stop();\n\t });\n\t this._stream = null;\n\t //remove the old media stream\n\t this._mediaStream.disconnect();\n\t this._mediaStream = null;\n\t }\n\t this._device = null;\n\t return this;\n\t };\n\t /**\n\t\t * Returns a promise which resolves with the list of audio input devices available.\n\t\t * @return {Promise} The promise that is resolved with the devices\n\t\t * @static\n\t\t * @example\n\t\t * Tone.UserMedia.enumerateDevices().then(function(devices){\n\t\t * \tconsole.log(devices)\n\t\t * })\n\t\t */\n\t Tone.UserMedia.enumerateDevices = function () {\n\t return navigator.mediaDevices.enumerateDevices().then(function (devices) {\n\t return devices.filter(function (device) {\n\t return device.kind === 'audioinput';\n\t });\n\t });\n\t };\n\t /**\n\t\t * Returns the playback state of the source, \"started\" when the microphone is open\n\t\t * and \"stopped\" when the mic is closed.\n\t\t * @type {Tone.State}\n\t\t * @readOnly\n\t\t * @memberOf Tone.UserMedia#\n\t\t * @name state\n\t\t */\n\t Object.defineProperty(Tone.UserMedia.prototype, 'state', {\n\t get: function () {\n\t return this._stream && this._stream.active ? Tone.State.Started : Tone.State.Stopped;\n\t }\n\t });\n\t /**\n\t\t * \tReturns an identifier for the represented device that is\n\t\t * \tpersisted across sessions. It is un-guessable by other applications and\n\t\t * \tunique to the origin of the calling application. It is reset when the\n\t\t * \tuser clears cookies (for Private Browsing, a different identifier is\n\t\t * \tused that is not persisted across sessions). Returns undefined when the\n\t\t * \tdevice is not open.\n\t\t * @type {String}\n\t\t * @readOnly\n\t\t * @memberOf Tone.UserMedia#\n\t\t * @name deviceId\n\t\t */\n\t Object.defineProperty(Tone.UserMedia.prototype, 'deviceId', {\n\t get: function () {\n\t if (this._device) {\n\t return this._device.deviceId;\n\t }\n\t }\n\t });\n\t /**\n\t\t * \tReturns a group identifier. Two devices have the\n\t\t * \tsame group identifier if they belong to the same physical device.\n\t\t * \tReturns undefined when the device is not open.\n\t\t * @type {String}\n\t\t * @readOnly\n\t\t * @memberOf Tone.UserMedia#\n\t\t * @name groupId\n\t\t */\n\t Object.defineProperty(Tone.UserMedia.prototype, 'groupId', {\n\t get: function () {\n\t if (this._device) {\n\t return this._device.groupId;\n\t }\n\t }\n\t });\n\t /**\n\t\t * \tReturns a label describing this device (for example \"Built-in Microphone\").\n\t\t * \tReturns undefined when the device is not open or label is not available\n\t\t * \tbecause of permissions.\n\t\t * @type {String}\n\t\t * @readOnly\n\t\t * @memberOf Tone.UserMedia#\n\t\t * @name groupId\n\t\t */\n\t Object.defineProperty(Tone.UserMedia.prototype, 'label', {\n\t get: function () {\n\t if (this._device) {\n\t return this._device.label;\n\t }\n\t }\n\t });\n\t /**\n\t\t * Mute the output.\n\t\t * @memberOf Tone.UserMedia#\n\t\t * @type {boolean}\n\t\t * @name mute\n\t\t * @example\n\t\t * //mute the output\n\t\t * userMedia.mute = true;\n\t\t */\n\t Object.defineProperty(Tone.UserMedia.prototype, 'mute', {\n\t get: function () {\n\t return this._volume.mute;\n\t },\n\t set: function (mute) {\n\t this._volume.mute = mute;\n\t }\n\t });\n\t /**\n\t\t * Clean up.\n\t\t * @return {Tone.UserMedia} this\n\t\t */\n\t Tone.UserMedia.prototype.dispose = function () {\n\t Tone.AudioNode.prototype.dispose.call(this);\n\t this.close();\n\t this._writable('volume');\n\t this._volume.dispose();\n\t this._volume = null;\n\t this.volume = null;\n\t return this;\n\t };\n\t /**\n\t\t * If getUserMedia is supported by the browser.\n\t\t * @type {Boolean}\n\t\t * @memberOf Tone.UserMedia#\n\t\t * @name supported\n\t\t * @static\n\t\t * @readOnly\n\t\t */\n\t Object.defineProperty(Tone.UserMedia, 'supported', {\n\t get: function () {\n\t return Tone.isDefined(navigator.mediaDevices) && Tone.isFunction(navigator.mediaDevices.getUserMedia);\n\t }\n\t });\n\t return Tone.UserMedia;\n\t});\n\tModule(function (Tone) {\n\t /**\n\t\t * @class Tone.Midi is a primitive type for encoding Time values.\n\t\t * Tone.Midi can be constructed with or without the `new` keyword. Tone.Midi can be passed\n\t\t * into the parameter of any method which takes time as an argument.\n\t\t * @constructor\n\t\t * @extends {Tone.Frequency}\n\t\t * @param {String|Number} val The time value.\n\t\t * @param {String=} units The units of the value.\n\t\t * @example\n\t\t * var t = Tone.Midi(\"4n\");//a quarter note\n\t\t */\n\t Tone.Midi = function (val, units) {\n\t if (this instanceof Tone.Midi) {\n\t Tone.Frequency.call(this, val, units);\n\t } else {\n\t return new Tone.Midi(val, units);\n\t }\n\t };\n\t Tone.extend(Tone.Midi, Tone.Frequency);\n\t /**\n\t\t * The default units if none are given.\n\t\t * @type {String}\n\t\t * @private\n\t\t */\n\t Tone.Midi.prototype._defaultUnits = 'midi';\n\t /**\n\t\t * Returns the value of a frequency in the current units\n\t\t * @param {Frequency} freq\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.Midi.prototype._frequencyToUnits = function (freq) {\n\t return Tone.Frequency.ftom(Tone.Frequency.prototype._frequencyToUnits.call(this, freq));\n\t };\n\t /**\n\t\t * Returns the value of a tick in the current time units\n\t\t * @param {Ticks} ticks\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.Midi.prototype._ticksToUnits = function (ticks) {\n\t return Tone.Frequency.ftom(Tone.Frequency.prototype._ticksToUnits.call(this, ticks));\n\t };\n\t /**\n\t\t * Return the value of the beats in the current units\n\t\t * @param {Number} beats\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.Midi.prototype._beatsToUnits = function (beats) {\n\t return Tone.Frequency.ftom(Tone.Frequency.prototype._beatsToUnits.call(this, beats));\n\t };\n\t /**\n\t\t * Returns the value of a second in the current units\n\t\t * @param {Seconds} seconds\n\t\t * @return {Number}\n\t\t * @private\n\t\t */\n\t Tone.Midi.prototype._secondsToUnits = function (seconds) {\n\t return Tone.Frequency.ftom(Tone.Frequency.prototype._secondsToUnits.call(this, seconds));\n\t };\n\t /**\n\t\t * Return the value of the frequency as a MIDI note\n\t\t * @return {MIDI}\n\t\t * @example\n\t\t * Tone.Midi(60).toMidi(); //60\n\t\t */\n\t Tone.Midi.prototype.toMidi = function () {\n\t return this.valueOf();\n\t };\n\t /**\n\t\t * Return the value of the frequency as a MIDI note\n\t\t * @return {MIDI}\n\t\t * @example\n\t\t * Tone.Midi(60).toMidi(); //60\n\t\t */\n\t Tone.Midi.prototype.toFrequency = function () {\n\t return Tone.Frequency.mtof(this.toMidi());\n\t };\n\t /**\n\t\t * Transposes the frequency by the given number of semitones.\n\t\t * @param {Interval} interval\n\t\t * @return {Tone.Frequency} A new transposed frequency\n\t\t * @example\n\t\t * Tone.Frequency(\"A4\").transpose(3); //\"C5\"\n\t\t */\n\t Tone.Midi.prototype.transpose = function (interval) {\n\t return new this.constructor(this.toMidi() + interval);\n\t };\n\t return Tone.Midi;\n\t});\n\t\n\treturn Tone;\n}));\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/tone/build/Tone.js\n// module id = 4\n// module chunks = 0","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.requestAudioContext = exports.browser = exports.mod = exports.choice = undefined;\n\nvar _tone = require('tone');\n\nvar _tone2 = _interopRequireDefault(_tone);\n\nvar _startAudioContext = require('./startAudioContext');\n\nvar _startAudioContext2 = _interopRequireDefault(_startAudioContext);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar isIphone = navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i);\nvar isIpad = navigator.userAgent.match(/iPad/i);\nvar isAndroid = navigator.userAgent.match(/Android/i);\nvar isMobile = isIphone || isIpad || isAndroid;\nvar isDesktop = !isMobile;\n\ndocument.body.classList.add(isMobile ? 'mobile' : 'desktop');\n\nvar browser = { isIphone: isIphone, isIpad: isIpad, isMobile: isMobile, isDesktop: isDesktop };\n\nfunction choice(a) {\n return a[Math.floor(Math.random() * a.length)];\n}\nfunction mod(n, m) {\n return n - m * Math.floor(n / m);\n}\n\nfunction requestAudioContext(fn) {\n if (isMobile) {\n var container = document.createElement('div');\n var button = document.createElement('div');\n button.innerHTML = 'Tap to start - please unmute your phone';\n Object.assign(container.style, {\n position: 'absolute',\n width: '100%',\n height: '100%',\n zIndex: '10000',\n top: '0px',\n left: '0px',\n backgroundColor: 'rgba(0, 0, 0, 0.8)'\n });\n Object.assign(button.style, {\n position: 'absolute',\n left: '50%',\n top: '50%',\n padding: '20px',\n backgroundColor: '#7F33ED',\n color: 'white',\n fontFamily: 'monospace',\n borderRadius: '3px',\n transform: 'translate3D(-50%,-50%,0)',\n textAlign: 'center',\n lineHeight: '1.5'\n });\n container.appendChild(button);\n document.body.appendChild(container);\n _startAudioContext2.default.setContext(_tone2.default.context);\n _startAudioContext2.default.on(button);\n _startAudioContext2.default.onStarted(function (_) {\n container.remove();\n fn();\n });\n } else {\n fn();\n }\n}\n\nexports.choice = choice;\nexports.mod = mod;\nexports.browser = browser;\nexports.requestAudioContext = requestAudioContext;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/lib/util.js\n// module id = 5\n// module chunks = 0","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nfunction EventEmitter() {\n this._events = this._events || {};\n this._maxListeners = this._maxListeners || undefined;\n}\nmodule.exports = EventEmitter;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nEventEmitter.defaultMaxListeners = 10;\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function(n) {\n if (!isNumber(n) || n < 0 || isNaN(n))\n throw TypeError('n must be a positive number');\n this._maxListeners = n;\n return this;\n};\n\nEventEmitter.prototype.emit = function(type) {\n var er, handler, len, args, i, listeners;\n\n if (!this._events)\n this._events = {};\n\n // If there is no 'error' event listener then throw.\n if (type === 'error') {\n if (!this._events.error ||\n (isObject(this._events.error) && !this._events.error.length)) {\n er = arguments[1];\n if (er instanceof Error) {\n throw er; // Unhandled 'error' event\n } else {\n // At least give some kind of context to the user\n var err = new Error('Uncaught, unspecified \"error\" event. (' + er + ')');\n err.context = er;\n throw err;\n }\n }\n }\n\n handler = this._events[type];\n\n if (isUndefined(handler))\n return false;\n\n if (isFunction(handler)) {\n switch (arguments.length) {\n // fast cases\n case 1:\n handler.call(this);\n break;\n case 2:\n handler.call(this, arguments[1]);\n break;\n case 3:\n handler.call(this, arguments[1], arguments[2]);\n break;\n // slower\n default:\n args = Array.prototype.slice.call(arguments, 1);\n handler.apply(this, args);\n }\n } else if (isObject(handler)) {\n args = Array.prototype.slice.call(arguments, 1);\n listeners = handler.slice();\n len = listeners.length;\n for (i = 0; i < len; i++)\n listeners[i].apply(this, args);\n }\n\n return true;\n};\n\nEventEmitter.prototype.addListener = function(type, listener) {\n var m;\n\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n if (!this._events)\n this._events = {};\n\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (this._events.newListener)\n this.emit('newListener', type,\n isFunction(listener.listener) ?\n listener.listener : listener);\n\n if (!this._events[type])\n // Optimize the case of one listener. Don't need the extra array object.\n this._events[type] = listener;\n else if (isObject(this._events[type]))\n // If we've already got an array, just append.\n this._events[type].push(listener);\n else\n // Adding the second element, need to change to array.\n this._events[type] = [this._events[type], listener];\n\n // Check for listener leak\n if (isObject(this._events[type]) && !this._events[type].warned) {\n if (!isUndefined(this._maxListeners)) {\n m = this._maxListeners;\n } else {\n m = EventEmitter.defaultMaxListeners;\n }\n\n if (m && m > 0 && this._events[type].length > m) {\n this._events[type].warned = true;\n console.error('(node) warning: possible EventEmitter memory ' +\n 'leak detected. %d listeners added. ' +\n 'Use emitter.setMaxListeners() to increase limit.',\n this._events[type].length);\n if (typeof console.trace === 'function') {\n // not supported in IE 10\n console.trace();\n }\n }\n }\n\n return this;\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.once = function(type, listener) {\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n var fired = false;\n\n function g() {\n this.removeListener(type, g);\n\n if (!fired) {\n fired = true;\n listener.apply(this, arguments);\n }\n }\n\n g.listener = listener;\n this.on(type, g);\n\n return this;\n};\n\n// emits a 'removeListener' event iff the listener was removed\nEventEmitter.prototype.removeListener = function(type, listener) {\n var list, position, length, i;\n\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n if (!this._events || !this._events[type])\n return this;\n\n list = this._events[type];\n length = list.length;\n position = -1;\n\n if (list === listener ||\n (isFunction(list.listener) && list.listener === listener)) {\n delete this._events[type];\n if (this._events.removeListener)\n this.emit('removeListener', type, listener);\n\n } else if (isObject(list)) {\n for (i = length; i-- > 0;) {\n if (list[i] === listener ||\n (list[i].listener && list[i].listener === listener)) {\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (list.length === 1) {\n list.length = 0;\n delete this._events[type];\n } else {\n list.splice(position, 1);\n }\n\n if (this._events.removeListener)\n this.emit('removeListener', type, listener);\n }\n\n return this;\n};\n\nEventEmitter.prototype.removeAllListeners = function(type) {\n var key, listeners;\n\n if (!this._events)\n return this;\n\n // not listening for removeListener, no need to emit\n if (!this._events.removeListener) {\n if (arguments.length === 0)\n this._events = {};\n else if (this._events[type])\n delete this._events[type];\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n for (key in this._events) {\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = {};\n return this;\n }\n\n listeners = this._events[type];\n\n if (isFunction(listeners)) {\n this.removeListener(type, listeners);\n } else if (listeners) {\n // LIFO order\n while (listeners.length)\n this.removeListener(type, listeners[listeners.length - 1]);\n }\n delete this._events[type];\n\n return this;\n};\n\nEventEmitter.prototype.listeners = function(type) {\n var ret;\n if (!this._events || !this._events[type])\n ret = [];\n else if (isFunction(this._events[type]))\n ret = [this._events[type]];\n else\n ret = this._events[type].slice();\n return ret;\n};\n\nEventEmitter.prototype.listenerCount = function(type) {\n if (this._events) {\n var evlistener = this._events[type];\n\n if (isFunction(evlistener))\n return 1;\n else if (evlistener)\n return evlistener.length;\n }\n return 0;\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n return emitter.listenerCount(type);\n};\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/events/events.js\n// module id = 6\n// module chunks = 0","\n/** @class utils \n Shared utility functions. These functions are exposed as methods of nx in NexusUI projects, i.e. .mtof() here can be accessed in your project with nx.mtof().\n*/\n\n\n/** @method findPosition \n Returns the offset of an HTML element. Returns an object with 'top' and 'left' properties.\n @param {DOM element} [element] \n ```js\n var button1Offset = nx.findPosition(button1.canvas)\n ```\n*/\nexports.findPosition = function(element) {\n var body = document.body,\n win = document.defaultView,\n docElem = document.documentElement,\n box = document.createElement('div');\n box.style.paddingLeft = box.style.width = \"1px\";\n body.appendChild(box);\n var isBoxModel = box.offsetWidth == 2;\n body.removeChild(box);\n box = element.getBoundingClientRect();\n var clientTop = docElem.clientTop || body.clientTop || 0,\n clientLeft = docElem.clientLeft || body.clientLeft || 0,\n scrollTop = win.pageYOffset || isBoxModel && docElem.scrollTop || body.scrollTop,\n scrollLeft = win.pageXOffset || isBoxModel && docElem.scrollLeft || body.scrollLeft;\n return {\n top : box.top + scrollTop - clientTop,\n left: box.left + scrollLeft - clientLeft\n };\n}\n\nexports.getCursorPosition = function(e, canvas_offset) {\n var x;\n var y;\n if (e.pageX != undefined && e.pageY != undefined) {\n x = e.pageX;\n y = e.pageY;\n } else {\n x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;\n y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;\n }\n x -= canvas_offset.left;\n y -= canvas_offset.top;\n var click_position = {x: x, y: y};\n click_position.touches = [ {x: x, y: y } ];\n return click_position;\n}\n\nexports.getTouchPosition = function(e, canvas_offset) {\n var x;\n var y;\n x = e.targetTouches[0].pageX;\n y = e.targetTouches[0].pageY;\n x -= canvas_offset.left;\n y -= canvas_offset.top;\n var click_position = {x: x, y: y};\n\n click_position.touches = new Array();\n for (var i=0;i<e.targetTouches.length;i++) {\n click_position.touches.push({\n x: e.targetTouches[i].pageX - canvas_offset.left,\n y: e.targetTouches[i].pageY - canvas_offset.top\n });\n }\n click_position.changed = new Array();\n for (var i=0;i<e.changedTouches.length;i++) {\n click_position.changed.push({\n x: e.changedTouches[i].pageX - canvas_offset.left,\n y: e.changedTouches[i].pageY - canvas_offset.top\n });\n }\n return click_position;\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/utils/dom.js\n// module id = 7\n// module chunks = 0","\n\nexports.throttle = function(func, wait) {\n var timeout;\n return function() {\n var context = this, args = arguments;\n if (!timeout) {\n // the first time the event fires, we setup a timer, which \n // is used as a guard to block subsequent calls; once the \n // timer's handler fires, we reset it and create a new one\n timeout = setTimeout(function() {\n timeout = null;\n try {\n func.apply(context, args);\n } catch (err) {\n console.log(err);\n }\n }, wait);\n }\n }\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/utils/timing.js\n// module id = 8\n// module chunks = 0","exports.defineTransmit = function(protocol) {\n \n var newTransmit;\n\n if (typeof(protocol)==\"function\") {\n return protocol;\n } else {\n switch (protocol) {\n case 'js':\n newTransmit = function(data,passive) {\n this.makeOSC(this.emit, data, passive);\n this.emit('*',data, passive);\n }\n return newTransmit\n \n case 'ajax':\n newTransmit = function(data) {\n this.makeOSC(exports.ajaxTransmit, data);\n }\n return newTransmit\n \n case 'node':\n newTransmit = function(data) {\n this.makeOSC(exports.nodeTransmit, data);\n }\n return newTransmit\n \n case 'ios':\n newTransmit = function(data) {\n \n }\n return newTransmit\n \n case 'max':\n newTransmit = function(data) {\n this.makeOSC(exports.maxTransmit, data);\n }\n return newTransmit\n\n case 'wc':\n newTransmit = function(data, passive) {\n this.emit('internal',data, passive);\n }\n return newTransmit\n }\n }\n}\n\nexports.setGlobalTransmit = function(protocol) {\n var newTransmit = exports.defineTransmit(protocol)\n this.transmit = newTransmit\n this.destination = protocol\n for (var key in nx.widgets) {\n this.widgets[key].transmit = newTransmit;\n this.widgets[key].destination = protocol;\n }\n}\n\nexports.setWidgetTransmit = function(protocol) {\n var newTransmit = exports.defineTransmit(protocol)\n this.transmit = newTransmit\n this.destination = protocol\n}\n\n\nexports.ajaxTransmit = function(subPath, data) {\n\n var oscPath = subPath=='value' ? this.oscPath : this.oscPath+\"/\"+subPath;\n \n xmlhttp=new XMLHttpRequest();\n xmlhttp.open(\"POST\",nx.ajaxPath,true);\n xmlhttp.setRequestHeader(\"Content-type\",\"application/x-www-form-urlencoded\");\n xmlhttp.send('oscName='+oscPath+'&data='+data);\n\n}\n\nexports.setAjaxPath = function(path) {\n this.ajaxPath = path;\n}\n\nexports.nodeTransmit = function(subPath, data) {\n \n var msg = {\n oscName: subPath=='value' ? this.oscPath : this.oscPath+\"/\"+subPath,\n value: data\n }\n socket.emit('nx', msg)\n\n}\n\nexports.maxTransmit = function (subPath, data) {\n var oscPath = subPath=='value' ? this.oscPath : this.oscPath+\"/\"+subPath;\n window.max.outlet(oscPath + \" \" + data);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/utils/transmit.js\n// module id = 9\n// module chunks = 0","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar palettes = [[[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 1.0], [0.00, 0.33, 0.67]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 1.0], [0.00, 0.10, 0.20]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 1.0], [0.30, 0.20, 0.20]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 0.5], [0.80, 0.90, 0.30]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 0.7, 0.4], [0.00, 0.15, 0.20]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [2.0, 1.0, 0.0], [0.50, 0.20, 0.25]], [[0.8, 0.5, 0.4], [0.2, 0.4, 0.2], [2.0, 1.0, 1.0], [0.00, 0.25, 0.25]]];\n\nvar palette = palettes[0];\n\nfunction channel(t, a, b, c, d, add, mul) {\n return a + b * Math.cos(2 * Math.PI * (c * t + d)) * mul + add;\n}\n\nfunction color(t, add, mul) {\n var a = void 0,\n b = void 0,\n c = void 0,\n d = void 0;\n var rgb = [];\n for (var i = 0; i < 3; i++) {\n a = palette[0][i];\n b = palette[1][i];\n c = palette[2][i];\n d = palette[3][i];\n rgb[i] = Math.round(channel(t, a, b, c, d, add, mul) * 255);\n }\n return 'rgb(' + rgb + ')';\n}\n\nexports.default = color;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/lib/color.js\n// module id = 10\n// module chunks = 0","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _tone = require('tone');\n\nvar _tone2 = _interopRequireDefault(_tone);\n\nvar _util = require('./util');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar player_count = 2;\n\nvar compressor = new _tone2.default.Compressor(-30, 3).toMaster();\n\nvar samples = [{ root: 226, fn: 'samples/380737__cabled-mess__sansula-01-a-raw.wav' }, { root: 267, fn: 'samples/380736__cabled-mess__sansula-02-c-raw.wav' }, { root: 340, fn: 'samples/380735__cabled-mess__sansula-03-e-raw.wav' }, { root: 452, fn: 'samples/380733__cabled-mess__sansula-06-a-02-raw.wav' }];\n\nsamples.forEach(function (sample) {\n sample.players = [];\n sample.index = -1;\n for (var i = 0; i < player_count; i++) {\n var fn = sample.fn;\n if (window.location.href.match(/asdf.us/)) {\n fn = '//asdf.us/kalimba/' + fn;\n }\n var player = new _tone2.default.Player({\n url: fn,\n retrigger: true,\n playbackRate: 1\n });\n player.connect(compressor);\n sample.players.push(player);\n }\n});\n\nfunction play(freq) {\n var best = { sample: (0, _util.choice)(samples) };\n best.sample.index = (best.sample.index + 1) % player_count;\n\n var player = best.sample.players[best.sample.index];\n player.playbackRate = freq / best.sample.root;\n player.start();\n}\n\nexports.default = { play: play };\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/lib/kalimba.js\n// module id = 11\n// module chunks = 0","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nvar keys = {};\nvar key_numbers = {};\nvar letters = \"zxcvbnmasdfghjklqwertyuiop\";\nvar numbers = \"1234567890\";\n\nvar callback = function callback() {};\n\nletters.toUpperCase().split(\"\").map(function (k, i) {\n keys[k.charCodeAt(0)] = i;\n});\n\nnumbers.split(\"\").map(function (k, i) {\n keys[k.charCodeAt(0)] = i + letters.length;\n key_numbers[k.charCodeAt(0)] = true;\n});\n\nwindow.addEventListener(\"keydown\", keydown, true);\nfunction keydown(e) {\n if (e.altKey || e.ctrlKey || e.metaKey) {\n e.stopPropagation();\n return;\n }\n if (document.activeElement instanceof HTMLInputElement && e.keyCode in key_numbers) {\n e.stopPropagation();\n return;\n }\n if (!(e.keyCode in keys)) return;\n var index = keys[e.keyCode];\n if (e.shiftKey) index += letters.length;\n index -= 7;\n callback(index);\n}\n\nfunction listen(fn) {\n callback = fn;\n}\n\nexports.default = { listen: listen };\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/lib/keys.js\n// module id = 12\n// module chunks = 0","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _intonation = require('./intonation');\n\nvar _intonation2 = _interopRequireDefault(_intonation);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar meantone = '! meanquar.scl\\n!\\n1/4-comma meantone scale. Pietro Aaron\\'s temperament (1523)\\n 12\\n!\\n 76.04900\\n 193.15686\\n 310.26471\\n 5/4\\n 503.42157\\n 579.47057\\n 696.57843\\n 25/16\\n 889.73529\\n 1006.84314\\n 1082.89214\\n 2/1\\n';\n\nvar mavila = '! mavila12.scl\\n!\\nA 12-note mavila scale (for warping meantone-based music), 5-limit TOP\\n 12\\n!\\n-30.99719\\n 163.50770\\n 358.01258\\n 327.01540\\n 521.52028\\n 490.52310\\n 685.02798\\n 654.03080\\n 848.53568\\n 1043.04057\\n 1012.04338\\n 1206.54826\\n';\n\nvar carlos_alpha = '! carlos_alpha.scl\\n!\\nWendy Carlos\\' Alpha scale with perfect fifth divided in nine\\n 18\\n!\\n 78.00000\\n 156.00000\\n 234.00000\\n 312.00000\\n 390.00000\\n 468.00000\\n 546.00000\\n 624.00000\\n 702.00000\\n 780.00000\\n 858.00000\\n 936.00000\\n 1014.00000\\n 1092.00000\\n 1170.00000\\n 1248.00000\\n 1326.00000\\n 1404.00000\\n';\n\nvar lamonte = '! young-lm_piano.scl\\n!\\nLaMonte Young\\'s Well-Tempered Piano\\n12\\n!\\n567/512\\n9/8\\n147/128\\n21/16\\n1323/1024\\n189/128\\n3/2\\n49/32\\n7/4\\n441/256\\n63/32\\n2/1\\n';\n\nvar colundi = '! colundi.scl\\n!\\nColundi scale\\n10\\n!\\n9/8\\n171/140\\n137/112\\n43/35\\n3/2\\n421/280\\n213/140\\n263/150\\n66/35\\n2/1\\n';\n\nvar scales = [{\n intervals: '1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1',\n name: \"harmonic scale\"\n}, {\n root: 450,\n intervals: '1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1',\n name: \"harmonic scale @ 450\"\n}, {\n tet: 5\n}, {\n tet: 12\n}, {\n tet: 17\n}, {\n intervals: '1/1 81/80 33/32 21/20 16/15 12/11 11/10 10/9 9/8 8/7 7/6 32/27 6/5 11/9 5/4 14/11 9/7 21/16 4/3 27/20 11/8 7/5 10/7 16/11 40/27 3/2 32/21 14/9 11/7 8/5 18/11 5/3 27/16 12/7 7/4 16/9 9/5 20/11 11/6 15/8 40/21 64/33 160/81 2/1',\n name: \"harry partch scale\"\n}, {\n scl: lamonte\n}, {\n scl: meantone\n}, {\n scl: mavila\n}, {\n scl: carlos_alpha\n}, {\n scl: colundi\n}].map(function (opt) {\n return new _intonation2.default(opt);\n});\n\nvar scale = scales[0];\nvar handleChange = function handleChange() {};\n\nfunction build() {\n scales.forEach(function (scale, i) {\n scale.heading = document.createElement('div');\n scale.heading.innerHTML = scale.name;\n scale.heading.classList.add('heading');\n scale.heading.addEventListener('click', function () {\n pick(i);\n });\n scale_list.appendChild(scale.heading);\n });\n\n pick(0);\n}\n\nfunction pick(i) {\n if (scale) {\n scale.heading && scale.heading.classList.remove('selected');\n }\n scale = scales[i];\n scale.heading && scale.heading.classList.add('selected');\n handleChange(scale);\n}\n\nfunction current() {\n return scale;\n}\n\nfunction onChange(fn) {\n handleChange = fn;\n}\n\nfunction names() {\n return scales.map(function (scale) {\n return scale.name;\n });\n}\n\nexports.default = { scales: scales, current: current, build: build, pick: pick, names: names, onChange: onChange };\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/lib/scales.js\n// module id = 13\n// module chunks = 0","var manager = require('./lib/core/manager');\nvar domUtils = require('./lib/utils/dom');\nvar drawingUtils = require('./lib/utils/drawing');\nvar mathUtils = require('./lib/utils/math');\nvar extend = require('extend');\nvar WebFont = require('webfontloader');\n\n/************************************************\n* INSTANTIATE NX MANAGER AND CREATE ELEMENTS *\n************************************************/\n\nwindow.nx = new manager();\nwindow.nx.onload = function() {};\nwindow.nx = extend(window.nx,domUtils)\nwindow.nx = extend(window.nx,drawingUtils)\nwindow.nx = extend(window.nx,mathUtils)\n\n/* this onload function turns canvases into nexus elements,\n * using the canvas's id as its var name */\n\nwindow.onload = function() {\n try {\n WebFont.load({\n google: {\n families: ['Open Sans']\n }\n });\n } catch(e) {\n console.log(\"font not loaded\")\n }\n\n nx.addStylesheet();\n\n // get all canvases on the page and add them to the manager\n var allcanvi = document.getElementsByTagName(\"canvas\");\n for (i=0;i<allcanvi.length;i++) nx.transform(allcanvi[i]);\n\n if (nx.isTouchDevice) {\n document.addEventListener(\"touchmove\", nx.blockMove, true);\n document.addEventListener(\"touchstart\", nx.blockMove, true);\n }\n \n nx.onload();\n\n nx.startPulse();\n \n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/index.js\n// module id = 14\n// module chunks = 0","/*\n\nWebMidi v2.2.0\n\nWebMidi.js helps you tame the Web MIDI API. Send and receive MIDI messages with ease. Control instruments with user-friendly functions (playNote, sendPitchBend, etc.). React to MIDI input with simple event listeners (noteon, pitchbend, controlchange, etc.).\nhttps://github.com/djipco/webmidi\n\n\nThe MIT License (MIT)\n\nCopyright (c) 2015-2018, Jean-Philippe Côté\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and\nassociated documentation files (the \"Software\"), to deal in the Software without restriction,\nincluding without limitation the rights to use, copy, modify, merge, publish, distribute,\nsublicense, and/or sell copies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial\nportions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT\nNOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES\nOR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n*/\n\n!function(scope){\"use strict\";function WebMidi(){if(WebMidi.prototype._singleton)throw new Error(\"WebMidi is a singleton, it cannot be instantiated directly.\");WebMidi.prototype._singleton=this,this._inputs=[],this._outputs=[],this._userHandlers={},this._stateChangeQueue=[],this._processingStateChange=!1,this._midiInterfaceEvents=[\"connected\",\"disconnected\"],this._notes=[\"C\",\"C#\",\"D\",\"D#\",\"E\",\"F\",\"F#\",\"G\",\"G#\",\"A\",\"A#\",\"B\"],this._semitones={C:0,D:2,E:4,F:5,G:7,A:9,B:11},Object.defineProperties(this,{MIDI_SYSTEM_MESSAGES:{value:{sysex:240,timecode:241,songposition:242,songselect:243,tuningrequest:246,sysexend:247,clock:248,start:250,\"continue\":251,stop:252,activesensing:254,reset:255,midimessage:0,unknownsystemmessage:-1},writable:!1,enumerable:!0,configurable:!1},MIDI_CHANNEL_MESSAGES:{value:{noteoff:8,noteon:9,keyaftertouch:10,controlchange:11,channelmode:11,programchange:12,channelaftertouch:13,pitchbend:14},writable:!1,enumerable:!0,configurable:!1},MIDI_REGISTERED_PARAMETER:{value:{pitchbendrange:[0,0],channelfinetuning:[0,1],channelcoarsetuning:[0,2],tuningprogram:[0,3],tuningbank:[0,4],modulationrange:[0,5],azimuthangle:[61,0],elevationangle:[61,1],gain:[61,2],distanceratio:[61,3],maximumdistance:[61,4],maximumdistancegain:[61,5],referencedistanceratio:[61,6],panspreadangle:[61,7],rollangle:[61,8]},writable:!1,enumerable:!0,configurable:!1},MIDI_CONTROL_CHANGE_MESSAGES:{value:{bankselectcoarse:0,modulationwheelcoarse:1,breathcontrollercoarse:2,footcontrollercoarse:4,portamentotimecoarse:5,dataentrycoarse:6,volumecoarse:7,balancecoarse:8,pancoarse:10,expressioncoarse:11,effectcontrol1coarse:12,effectcontrol2coarse:13,generalpurposeslider1:16,generalpurposeslider2:17,generalpurposeslider3:18,generalpurposeslider4:19,bankselectfine:32,modulationwheelfine:33,breathcontrollerfine:34,footcontrollerfine:36,portamentotimefine:37,dataentryfine:38,volumefine:39,balancefine:40,panfine:42,expressionfine:43,effectcontrol1fine:44,effectcontrol2fine:45,holdpedal:64,portamento:65,sustenutopedal:66,softpedal:67,legatopedal:68,hold2pedal:69,soundvariation:70,resonance:71,soundreleasetime:72,soundattacktime:73,brightness:74,soundcontrol6:75,soundcontrol7:76,soundcontrol8:77,soundcontrol9:78,soundcontrol10:79,generalpurposebutton1:80,generalpurposebutton2:81,generalpurposebutton3:82,generalpurposebutton4:83,reverblevel:91,tremololevel:92,choruslevel:93,celestelevel:94,phaserlevel:95,databuttonincrement:96,databuttondecrement:97,nonregisteredparametercoarse:98,nonregisteredparameterfine:99,registeredparametercoarse:100,registeredparameterfine:101},writable:!1,enumerable:!0,configurable:!1},MIDI_CHANNEL_MODE_MESSAGES:{value:{allsoundoff:120,resetallcontrollers:121,localcontrol:122,allnotesoff:123,omnimodeoff:124,omnimodeon:125,monomodeon:126,polymodeon:127},writable:!1,enumerable:!0,configurable:!1},octaveOffset:{value:0,writable:!0,enumerable:!0,configurable:!1}}),Object.defineProperties(this,{supported:{enumerable:!0,get:function(){return\"requestMIDIAccess\"in navigator}},enabled:{enumerable:!0,get:function(){return void 0!==this[\"interface\"]}.bind(this)},inputs:{enumerable:!0,get:function(){return this._inputs}.bind(this)},outputs:{enumerable:!0,get:function(){return this._outputs}.bind(this)},sysexEnabled:{enumerable:!0,get:function(){return!(!this[\"interface\"]||!this[\"interface\"].sysexEnabled)}.bind(this)},time:{enumerable:!0,get:function(){return performance.now()}}})}function Input(midiInput){var that=this;this._userHandlers={channel:{},system:{}},this._midiInput=midiInput,Object.defineProperties(this,{connection:{enumerable:!0,get:function(){return that._midiInput.connection}},id:{enumerable:!0,get:function(){return that._midiInput.id}},manufacturer:{enumerable:!0,get:function(){return that._midiInput.manufacturer}},name:{enumerable:!0,get:function(){return that._midiInput.name}},state:{enumerable:!0,get:function(){return that._midiInput.state}},type:{enumerable:!0,get:function(){return that._midiInput.type}}}),this._initializeUserHandlers(),this._midiInput.onmidimessage=this._onMidiMessage.bind(this)}function Output(midiOutput){var that=this;this._midiOutput=midiOutput,Object.defineProperties(this,{connection:{enumerable:!0,get:function(){return that._midiOutput.connection}},id:{enumerable:!0,get:function(){return that._midiOutput.id}},manufacturer:{enumerable:!0,get:function(){return that._midiOutput.manufacturer}},name:{enumerable:!0,get:function(){return that._midiOutput.name}},state:{enumerable:!0,get:function(){return that._midiOutput.state}},type:{enumerable:!0,get:function(){return that._midiOutput.type}}})}var wm=new WebMidi;WebMidi.prototype.enable=function(callback,sysex){return this.enabled?void 0:this.supported?void navigator.requestMIDIAccess({sysex:sysex}).then(function(midiAccess){function onPortsOpen(){clearTimeout(promiseTimeout),this._updateInputsAndOutputs(),this[\"interface\"].onstatechange=this._onInterfaceStateChange.bind(this),\"function\"==typeof callback&&callback.call(this),events.forEach(function(event){this._onInterfaceStateChange(event)}.bind(this))}var promiseTimeout,events=[],promises=[];this[\"interface\"]=midiAccess,this._resetInterfaceUserHandlers(),this[\"interface\"].onstatechange=function(e){events.push(e)};for(var inputs=midiAccess.inputs.values(),input=inputs.next();input&&!input.done;input=inputs.next())promises.push(input.value.open());for(var outputs=midiAccess.outputs.values(),output=outputs.next();output&&!output.done;output=outputs.next())promises.push(output.value.open());promiseTimeout=setTimeout(onPortsOpen.bind(this),200),Promise&&Promise.all(promises)[\"catch\"](function(err){}).then(onPortsOpen.bind(this))}.bind(this),function(err){\"function\"==typeof callback&&callback.call(this,err)}.bind(this)):void(\"function\"==typeof callback&&callback(new Error(\"The Web MIDI API is not supported by your browser.\")))},WebMidi.prototype.disable=function(){if(!this.supported)throw new Error(\"The Web MIDI API is not supported by your browser.\");this[\"interface\"]&&(this[\"interface\"].onstatechange=void 0),this[\"interface\"]=void 0,this._inputs=[],this._outputs=[],this._resetInterfaceUserHandlers()},WebMidi.prototype.addListener=function(type,listener){if(!this.enabled)throw new Error(\"WebMidi must be enabled before adding event listeners.\");if(\"function\"!=typeof listener)throw new TypeError(\"The 'listener' parameter must be a function.\");if(!(this._midiInterfaceEvents.indexOf(type)>=0))throw new TypeError(\"The specified event type is not supported.\");return this._userHandlers[type].push(listener),this},WebMidi.prototype.hasListener=function(type,listener){if(!this.enabled)throw new Error(\"WebMidi must be enabled before checking event listeners.\");if(\"function\"!=typeof listener)throw new TypeError(\"The 'listener' parameter must be a function.\");if(!(this._midiInterfaceEvents.indexOf(type)>=0))throw new TypeError(\"The specified event type is not supported.\");for(var o=0;o<this._userHandlers[type].length;o++)if(this._userHandlers[type][o]===listener)return!0;return!1},WebMidi.prototype.removeListener=function(type,listener){if(!this.enabled)throw new Error(\"WebMidi must be enabled before removing event listeners.\");if(void 0!==listener&&\"function\"!=typeof listener)throw new TypeError(\"The 'listener' parameter must be a function.\");if(this._midiInterfaceEvents.indexOf(type)>=0)if(listener)for(var o=0;o<this._userHandlers[type].length;o++)this._userHandlers[type][o]===listener&&this._userHandlers[type].splice(o,1);else this._userHandlers[type]=[];else{if(void 0!==type)throw new TypeError(\"The specified event type is not supported.\");this._resetInterfaceUserHandlers()}return this},WebMidi.prototype.toMIDIChannels=function(channel){var channels;return channels=\"all\"===channel||void 0===channel?[\"all\"]:Array.isArray(channel)?channel:[channel],channels.indexOf(\"all\")>-1&&(channels=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),channels.map(function(ch){return parseInt(ch)}).filter(function(ch){return ch>=1&&16>=ch})},WebMidi.prototype.getInputById=function(id){if(!this.enabled)throw new Error(\"WebMidi is not enabled.\");for(var i=0;i<this.inputs.length;i++)if(this.inputs[i].id===id)return this.inputs[i];return!1},WebMidi.prototype.getOutputById=function(id){if(!this.enabled)throw new Error(\"WebMidi is not enabled.\");for(var i=0;i<this.outputs.length;i++)if(this.outputs[i].id===id)return this.outputs[i];return!1},WebMidi.prototype.getInputByName=function(name){if(!this.enabled)throw new Error(\"WebMidi is not enabled.\");for(var i=0;i<this.inputs.length;i++)if(~this.inputs[i].name.indexOf(name))return this.inputs[i];return!1},WebMidi.prototype.getOctave=function(number){return null!=number&&number>=0&&127>=number?Math.floor(Math.floor(number)/12-1)+Math.floor(wm.octaveOffset):void 0},WebMidi.prototype.getOutputByName=function(name){if(!this.enabled)throw new Error(\"WebMidi is not enabled.\");for(var i=0;i<this.outputs.length;i++)if(~this.outputs[i].name.indexOf(name))return this.outputs[i];return!1},WebMidi.prototype.guessNoteNumber=function(input){var output=!1;if(input&&input.toFixed&&input>=0&&127>=input?output=Math.round(input):parseInt(input)>=0&&parseInt(input)<=127?output=parseInt(input):(\"string\"==typeof input||input instanceof String)&&(output=this.noteNameToNumber(input)),output===!1)throw new Error(\"Invalid input value (\"+input+\").\");return output},WebMidi.prototype.noteNameToNumber=function(name){\"string\"!=typeof name&&(name=\"\");var matches=name.match(/([CDEFGAB])(#{0,2}|b{0,2})(-?\\d+)/i);if(!matches)throw new RangeError(\"Invalid note name.\");var semitones=wm._semitones[matches[1].toUpperCase()],octave=parseInt(matches[3]),result=12*(octave+1-Math.floor(wm.octaveOffset))+semitones;if(matches[2].toLowerCase().indexOf(\"b\")>-1?result-=matches[2].length:matches[2].toLowerCase().indexOf(\"#\")>-1&&(result+=matches[2].length),0>result||result>127)throw new RangeError(\"Invalid note name or note outside valid range.\");return result},WebMidi.prototype._updateInputsAndOutputs=function(){this._updateInputs(),this._updateOutputs()},WebMidi.prototype._updateInputs=function(){for(var i=0;i<this._inputs.length;i++){for(var remove=!0,updated=this[\"interface\"].inputs.values(),input=updated.next();input&&!input.done;input=updated.next())if(this._inputs[i]._midiInput===input.value){remove=!1;break}remove&&this._inputs.splice(i,1)}this[\"interface\"]&&this[\"interface\"].inputs.forEach(function(nInput){for(var add=!0,j=0;j<this._inputs.length;j++)this._inputs[j]._midiInput===nInput&&(add=!1);add&&this._inputs.push(new Input(nInput))}.bind(this))},WebMidi.prototype._updateOutputs=function(){for(var i=0;i<this._outputs.length;i++){for(var remove=!0,updated=this[\"interface\"].outputs.values(),output=updated.next();output&&!output.done;output=updated.next())if(this._outputs[i]._midiOutput===output.value){remove=!1;break}remove&&this._outputs.splice(i,1)}this[\"interface\"]&&this[\"interface\"].outputs.forEach(function(nOutput){for(var add=!0,j=0;j<this._outputs.length;j++)this._outputs[j]._midiOutput===nOutput&&(add=!1);add&&this._outputs.push(new Output(nOutput))}.bind(this))},WebMidi.prototype._onInterfaceStateChange=function(e){this._updateInputsAndOutputs();var event={timestamp:e.timeStamp,type:e.port.state};this[\"interface\"]&&\"connected\"===e.port.state?\"output\"===e.port.type?event.port=this.getOutputById(e.port.id):\"input\"===e.port.type&&(event.port=this.getInputById(e.port.id)):event.port={connection:\"closed\",id:e.port.id,manufacturer:e.port.manufacturer,name:e.port.name,state:e.port.state,type:e.port.type},this._userHandlers[e.port.state].forEach(function(handler){handler(event)})},WebMidi.prototype._resetInterfaceUserHandlers=function(){for(var i=0;i<this._midiInterfaceEvents.length;i++)this._userHandlers[this._midiInterfaceEvents[i]]=[]},Input.prototype.addListener=function(type,channel,listener){var that=this;if(void 0===channel&&(channel=\"all\"),Array.isArray(channel)||(channel=[channel]),channel.forEach(function(item){if(\"all\"!==item&&!(item>=1&&16>=item))throw new RangeError(\"The 'channel' parameter is invalid.\")}),\"function\"!=typeof listener)throw new TypeError(\"The 'listener' parameter must be a function.\");if(void 0!==wm.MIDI_SYSTEM_MESSAGES[type])this._userHandlers.system[type]||(this._userHandlers.system[type]=[]),this._userHandlers.system[type].push(listener);else{if(void 0===wm.MIDI_CHANNEL_MESSAGES[type])throw new TypeError(\"The specified event type is not supported.\");if(channel.indexOf(\"all\")>-1){channel=[];for(var j=1;16>=j;j++)channel.push(j)}this._userHandlers.channel[type]||(this._userHandlers.channel[type]=[]),channel.forEach(function(ch){that._userHandlers.channel[type][ch]||(that._userHandlers.channel[type][ch]=[]),that._userHandlers.channel[type][ch].push(listener)})}return this},Input.prototype.on=Input.prototype.addListener,Input.prototype.hasListener=function(type,channel,listener){var that=this;if(\"function\"!=typeof listener)throw new TypeError(\"The 'listener' parameter must be a function.\");if(void 0===channel&&(channel=\"all\"),channel.constructor!==Array&&(channel=[channel]),void 0!==wm.MIDI_SYSTEM_MESSAGES[type]){for(var o=0;o<this._userHandlers.system[type].length;o++)if(this._userHandlers.system[type][o]===listener)return!0}else if(void 0!==wm.MIDI_CHANNEL_MESSAGES[type]){if(channel.indexOf(\"all\")>-1){channel=[];for(var j=1;16>=j;j++)channel.push(j)}return this._userHandlers.channel[type]?channel.every(function(chNum){var listeners=that._userHandlers.channel[type][chNum];return listeners&&listeners.indexOf(listener)>-1}):!1}return!1},Input.prototype.removeListener=function(type,channel,listener){var that=this;if(void 0!==listener&&\"function\"!=typeof listener)throw new TypeError(\"The 'listener' parameter must be a function.\");if(void 0===channel&&(channel=\"all\"),channel.constructor!==Array&&(channel=[channel]),void 0!==wm.MIDI_SYSTEM_MESSAGES[type])if(void 0===listener)this._userHandlers.system[type]=[];else for(var o=0;o<this._userHandlers.system[type].length;o++)this._userHandlers.system[type][o]===listener&&this._userHandlers.system[type].splice(o,1);else if(void 0!==wm.MIDI_CHANNEL_MESSAGES[type]){if(channel.indexOf(\"all\")>-1){channel=[];for(var j=1;16>=j;j++)channel.push(j)}if(!this._userHandlers.channel[type])return this;channel.forEach(function(chNum){var listeners=that._userHandlers.channel[type][chNum];if(listeners)if(void 0===listener)that._userHandlers.channel[type][chNum]=[];else for(var l=0;l<listeners.length;l++)listeners[l]===listener&&listeners.splice(l,1)})}else{if(void 0!==type)throw new TypeError(\"The specified event type is not supported.\");this._initializeUserHandlers()}return this},Input.prototype._initializeUserHandlers=function(){for(var prop1 in wm.MIDI_CHANNEL_MESSAGES)wm.MIDI_CHANNEL_MESSAGES.hasOwnProperty(prop1)&&(this._userHandlers.channel[prop1]={});for(var prop2 in wm.MIDI_SYSTEM_MESSAGES)wm.MIDI_SYSTEM_MESSAGES.hasOwnProperty(prop2)&&(this._userHandlers.system[prop2]=[])},Input.prototype._onMidiMessage=function(e){if(this._userHandlers.system.midimessage.length>0){var event={target:this,data:e.data,timestamp:e.timeStamp,type:\"midimessage\"};this._userHandlers.system.midimessage.forEach(function(callback){callback(event)})}e.data[0]<240?this._parseChannelEvent(e):e.data[0]<=255&&this._parseSystemEvent(e)},Input.prototype._parseChannelEvent=function(e){var data1,data2,command=e.data[0]>>4,channel=(15&e.data[0])+1;e.data.length>1&&(data1=e.data[1],data2=e.data.length>2?e.data[2]:void 0);var event={target:this,data:e.data,timestamp:e.timeStamp,channel:channel};command===wm.MIDI_CHANNEL_MESSAGES.noteoff||command===wm.MIDI_CHANNEL_MESSAGES.noteon&&0===data2?(event.type=\"noteoff\",event.note={number:data1,name:wm._notes[data1%12],octave:wm.getOctave(data1)},event.velocity=data2/127,event.rawVelocity=data2):command===wm.MIDI_CHANNEL_MESSAGES.noteon?(event.type=\"noteon\",event.note={number:data1,name:wm._notes[data1%12],octave:wm.getOctave(data1)},event.velocity=data2/127,event.rawVelocity=data2):command===wm.MIDI_CHANNEL_MESSAGES.keyaftertouch?(event.type=\"keyaftertouch\",event.note={number:data1,name:wm._notes[data1%12],octave:wm.getOctave(data1)},event.value=data2/127):command===wm.MIDI_CHANNEL_MESSAGES.controlchange&&data1>=0&&119>=data1?(event.type=\"controlchange\",event.controller={number:data1,name:this.getCcNameByNumber(data1)},event.value=data2):command===wm.MIDI_CHANNEL_MESSAGES.channelmode&&data1>=120&&127>=data1?(event.type=\"channelmode\",event.controller={number:data1,name:this.getChannelModeByNumber(data1)},event.value=data2):command===wm.MIDI_CHANNEL_MESSAGES.programchange?(event.type=\"programchange\",event.value=data1):command===wm.MIDI_CHANNEL_MESSAGES.channelaftertouch?(event.type=\"channelaftertouch\",event.value=data1/127):command===wm.MIDI_CHANNEL_MESSAGES.pitchbend?(event.type=\"pitchbend\",event.value=((data2<<7)+data1-8192)/8192):event.type=\"unknownchannelmessage\",this._userHandlers.channel[event.type]&&this._userHandlers.channel[event.type][channel]&&this._userHandlers.channel[event.type][channel].forEach(function(callback){callback(event)})},Input.prototype.getCcNameByNumber=function(number){if(number=Math.floor(number),!(number>=0&&119>=number))throw new RangeError(\"The control change number must be between 0 and 119.\");for(var cc in wm.MIDI_CONTROL_CHANGE_MESSAGES)if(wm.MIDI_CONTROL_CHANGE_MESSAGES.hasOwnProperty(cc)&&number===wm.MIDI_CONTROL_CHANGE_MESSAGES[cc])return cc;return void 0},Input.prototype.getChannelModeByNumber=function(number){if(number=Math.floor(number),!(number>=120&&status<=127))throw new RangeError(\"The control change number must be between 120 and 127.\");for(var cm in wm.MIDI_CHANNEL_MODE_MESSAGES)if(wm.MIDI_CHANNEL_MODE_MESSAGES.hasOwnProperty(cm)&&number===wm.MIDI_CHANNEL_MODE_MESSAGES[cm])return cm},Input.prototype._parseSystemEvent=function(e){var command=e.data[0],event={target:this,data:e.data,timestamp:e.timeStamp};command===wm.MIDI_SYSTEM_MESSAGES.sysex?event.type=\"sysex\":command===wm.MIDI_SYSTEM_MESSAGES.timecode?event.type=\"timecode\":command===wm.MIDI_SYSTEM_MESSAGES.songposition?event.type=\"songposition\":command===wm.MIDI_SYSTEM_MESSAGES.songselect?(event.type=\"songselect\",event.song=e.data[1]):command===wm.MIDI_SYSTEM_MESSAGES.tuningrequest?event.type=\"tuningrequest\":command===wm.MIDI_SYSTEM_MESSAGES.clock?event.type=\"clock\":command===wm.MIDI_SYSTEM_MESSAGES.start?event.type=\"start\":command===wm.MIDI_SYSTEM_MESSAGES[\"continue\"]?event.type=\"continue\":command===wm.MIDI_SYSTEM_MESSAGES.stop?event.type=\"stop\":command===wm.MIDI_SYSTEM_MESSAGES.activesensing?event.type=\"activesensing\":command===wm.MIDI_SYSTEM_MESSAGES.reset?event.type=\"reset\":event.type=\"unknownsystemmessage\",this._userHandlers.system[event.type]&&this._userHandlers.system[event.type].forEach(function(callback){callback(event)})},Output.prototype.send=function(status,data,timestamp){if(!(status>=128&&255>=status))throw new RangeError(\"The status byte must be an integer between 128 (0x80) and 255 (0xFF).\");void 0===data&&(data=[]),Array.isArray(data)||(data=[data]);var message=[];return data.forEach(function(item,index){var parsed=Math.floor(item);if(!(parsed>=0&&255>=parsed))throw new RangeError(\"Data bytes must be integers between 0 (0x00) and 255 (0xFF).\");message.push(parsed)}),this._midiOutput.send([status].concat(message),parseFloat(timestamp)||0),this},Output.prototype.sendSysex=function(manufacturer,data,options){if(!wm.sysexEnabled)throw new Error(\"Sysex message support must first be activated.\");return options=options||{},manufacturer=[].concat(manufacturer),data.forEach(function(item){if(0>item||item>127)throw new RangeError(\"The data bytes of a sysex message must be integers between 0 (0x00) and 127 (0x7F).\")}),data=manufacturer.concat(data,wm.MIDI_SYSTEM_MESSAGES.sysexend),this.send(wm.MIDI_SYSTEM_MESSAGES.sysex,data,this._parseTimeParameter(options.time)),this},Output.prototype.sendTimecodeQuarterFrame=function(value,options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.timecode,value,this._parseTimeParameter(options.time)),this},Output.prototype.sendSongPosition=function(value,options){value=Math.floor(value)||0,options=options||{};var msb=value>>7&127,lsb=127&value;return this.send(wm.MIDI_SYSTEM_MESSAGES.songposition,[msb,lsb],this._parseTimeParameter(options.time)),this},Output.prototype.sendSongSelect=function(value,options){if(value=Math.floor(value),options=options||{},!(value>=0&&127>=value))throw new RangeError(\"The song number must be between 0 and 127.\");return this.send(wm.MIDI_SYSTEM_MESSAGES.songselect,[value],this._parseTimeParameter(options.time)),this},Output.prototype.sendTuningRequest=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.tuningrequest,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendClock=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.clock,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendStart=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.start,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendContinue=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES[\"continue\"],void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendStop=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.stop,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendActiveSensing=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.activesensing,[],this._parseTimeParameter(options.time)),this},Output.prototype.sendReset=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.reset,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.stopNote=function(note,channel,options){if(\"all\"===note)return this.sendChannelMode(\"allnotesoff\",0,channel,options);var nVelocity=64;return options=options||{},options.rawVelocity?!isNaN(options.velocity)&&options.velocity>=0&&options.velocity<=127&&(nVelocity=options.velocity):!isNaN(options.velocity)&&options.velocity>=0&&options.velocity<=1&&(nVelocity=127*options.velocity),this._convertNoteToArray(note).forEach(function(item){wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.noteoff<<4)+(ch-1),[item,Math.round(nVelocity)],this._parseTimeParameter(options.time))}.bind(this))}.bind(this)),this},Output.prototype.playNote=function(note,channel,options){var nVelocity=64;if(options=options||{},options.rawVelocity?!isNaN(options.velocity)&&options.velocity>=0&&options.velocity<=127&&(nVelocity=options.velocity):!isNaN(options.velocity)&&options.velocity>=0&&options.velocity<=1&&(nVelocity=127*options.velocity),options.time=this._parseTimeParameter(options.time),this._convertNoteToArray(note).forEach(function(item){wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.noteon<<4)+(ch-1),[item,Math.round(nVelocity)],options.time)}.bind(this))}.bind(this)),!isNaN(options.duration)){options.duration<=0&&(options.duration=0);var nRelease=64;options.rawVelocity?!isNaN(options.release)&&options.release>=0&&options.release<=127&&(nRelease=options.release):!isNaN(options.release)&&options.release>=0&&options.release<=1&&(nRelease=127*options.release),this._convertNoteToArray(note).forEach(function(item){wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.noteoff<<4)+(ch-1),[item,Math.round(nRelease)],(options.time||wm.time)+options.duration)}.bind(this))}.bind(this))}return this},Output.prototype.sendKeyAftertouch=function(note,channel,pressure,options){var that=this;if(options=options||{},1>channel||channel>16)throw new RangeError(\"The channel must be between 1 and 16.\");(isNaN(pressure)||0>pressure||pressure>1)&&(pressure=.5);var nPressure=Math.round(127*pressure);return this._convertNoteToArray(note).forEach(function(item){wm.toMIDIChannels(channel).forEach(function(ch){that.send((wm.MIDI_CHANNEL_MESSAGES.keyaftertouch<<4)+(ch-1),[item,nPressure],that._parseTimeParameter(options.time))})}),this},Output.prototype.sendControlChange=function(controller,value,channel,options){if(options=options||{},\"string\"==typeof controller){if(controller=wm.MIDI_CONTROL_CHANGE_MESSAGES[controller],!controller)throw new TypeError(\"Invalid controller name.\")}else if(controller=Math.floor(controller),!(controller>=0&&119>=controller))throw new RangeError(\"Controller numbers must be between 0 and 119.\");if(value=Math.floor(value)||0,!(value>=0&&127>=value))throw new RangeError(\"Controller value must be between 0 and 127.\");return wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.controlchange<<4)+(ch-1),[controller,value],this._parseTimeParameter(options.time))}.bind(this)),this},Output.prototype._selectRegisteredParameter=function(parameter,channel,time){var that=this;if(parameter[0]=Math.floor(parameter[0]),!(parameter[0]>=0&¶meter[0]<=127))throw new RangeError(\"The control65 value must be between 0 and 127\");if(parameter[1]=Math.floor(parameter[1]),!(parameter[1]>=0&¶meter[1]<=127))throw new RangeError(\"The control64 value must be between 0 and 127\");return wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(101,parameter[0],channel,{time:time}),that.sendControlChange(100,parameter[1],channel,{time:time})}),this},Output.prototype._selectNonRegisteredParameter=function(parameter,channel,time){var that=this;if(parameter[0]=Math.floor(parameter[0]),!(parameter[0]>=0&¶meter[0]<=127))throw new RangeError(\"The control63 value must be between 0 and 127\");if(parameter[1]=Math.floor(parameter[1]),!(parameter[1]>=0&¶meter[1]<=127))throw new RangeError(\"The control62 value must be between 0 and 127\");return wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(99,parameter[0],channel,{time:time}),that.sendControlChange(98,parameter[1],channel,{time:time})}),this},Output.prototype._setCurrentRegisteredParameter=function(data,channel,time){var that=this;if(data=[].concat(data),data[0]=Math.floor(data[0]),!(data[0]>=0&&data[0]<=127))throw new RangeError(\"The msb value must be between 0 and 127\");return wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(6,data[0],channel,{time:time})}),data[1]=Math.floor(data[1]),data[1]>=0&&data[1]<=127&&wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(38,data[1],channel,{time:time})}),this},Output.prototype._deselectRegisteredParameter=function(channel,time){var that=this;return wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(101,127,channel,{time:time}),that.sendControlChange(100,127,channel,{time:time})}),this},Output.prototype.setRegisteredParameter=function(parameter,data,channel,options){var that=this;if(options=options||{},!Array.isArray(parameter)){if(!wm.MIDI_REGISTERED_PARAMETER[parameter])throw new Error(\"The specified parameter is not available.\");parameter=wm.MIDI_REGISTERED_PARAMETER[parameter]}return wm.toMIDIChannels(channel).forEach(function(ch){that._selectRegisteredParameter(parameter,channel,options.time),that._setCurrentRegisteredParameter(data,channel,options.time),that._deselectRegisteredParameter(channel,options.time)}),this},Output.prototype.setNonRegisteredParameter=function(parameter,data,channel,options){var that=this;if(options=options||{},!(parameter[0]>=0&¶meter[0]<=127&¶meter[1]>=0&¶meter[1]<=127))throw new Error(\"Position 0 and 1 of the 2-position parameter array must both be between 0 and 127.\");return data=[].concat(data),wm.toMIDIChannels(channel).forEach(function(ch){that._selectNonRegisteredParameter(parameter,channel,options.time),that._setCurrentRegisteredParameter(data,channel,options.time),that._deselectRegisteredParameter(channel,options.time)}),this},Output.prototype.incrementRegisteredParameter=function(parameter,channel,options){var that=this;if(options=options||{},!Array.isArray(parameter)){if(!wm.MIDI_REGISTERED_PARAMETER[parameter])throw new Error(\"The specified parameter is not available.\");parameter=wm.MIDI_REGISTERED_PARAMETER[parameter]}return wm.toMIDIChannels(channel).forEach(function(ch){that._selectRegisteredParameter(parameter,channel,options.time),that.sendControlChange(96,0,channel,{time:options.time}),that._deselectRegisteredParameter(channel,options.time)}),this},Output.prototype.decrementRegisteredParameter=function(parameter,channel,options){if(options=options||{},!Array.isArray(parameter)){if(!wm.MIDI_REGISTERED_PARAMETER[parameter])throw new TypeError(\"The specified parameter is not available.\");parameter=wm.MIDI_REGISTERED_PARAMETER[parameter]}return wm.toMIDIChannels(channel).forEach(function(ch){this._selectRegisteredParameter(parameter,channel,options.time),this.sendControlChange(97,0,channel,{time:options.time}),this._deselectRegisteredParameter(channel,options.time)}.bind(this)),this},Output.prototype.setPitchBendRange=function(semitones,cents,channel,options){var that=this;if(options=options||{},semitones=Math.floor(semitones)||0,!(semitones>=0&&127>=semitones))throw new RangeError(\"The semitones value must be between 0 and 127\");if(cents=Math.floor(cents)||0,!(cents>=0&&127>=cents))throw new RangeError(\"The cents value must be between 0 and 127\");return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter(\"pitchbendrange\",[semitones,cents],channel,{time:options.time})}),this},Output.prototype.setModulationRange=function(semitones,cents,channel,options){var that=this;if(options=options||{},semitones=Math.floor(semitones)||0,!(semitones>=0&&127>=semitones))throw new RangeError(\"The semitones value must be between 0 and 127\");if(cents=Math.floor(cents)||0,!(cents>=0&&127>=cents))throw new RangeError(\"The cents value must be between 0 and 127\");return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter(\"modulationrange\",[semitones,cents],channel,{time:options.time})}),this},Output.prototype.setMasterTuning=function(value,channel,options){var that=this;if(options=options||{},value=parseFloat(value)||0,-65>=value||value>=64)throw new RangeError(\"The value must be a decimal number larger than -65 and smaller than 64.\");var coarse=Math.floor(value)+64,fine=value-Math.floor(value);fine=Math.round((fine+1)/2*16383);var msb=fine>>7&127,lsb=127&fine;return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter(\"channelcoarsetuning\",coarse,channel,{time:options.time}),that.setRegisteredParameter(\"channelfinetuning\",[msb,lsb],channel,{time:options.time})}),this},Output.prototype.setTuningProgram=function(value,channel,options){var that=this;if(options=options||{},value=Math.floor(value),!(value>=0&&127>=value))throw new RangeError(\"The program value must be between 0 and 127\");return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter(\"tuningprogram\",value,channel,{time:options.time})}),this},Output.prototype.setTuningBank=function(value,channel,options){var that=this;if(options=options||{},value=Math.floor(value)||0,!(value>=0&&127>=value))throw new RangeError(\"The bank value must be between 0 and 127\");return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter(\"tuningbank\",value,channel,{time:options.time})}),this},Output.prototype.sendChannelMode=function(command,value,channel,options){if(options=options||{},\"string\"==typeof command){if(command=wm.MIDI_CHANNEL_MODE_MESSAGES[command],!command)throw new TypeError(\"Invalid channel mode message name.\")}else if(command=Math.floor(command),!(command>=120&&127>=command))throw new RangeError(\"Channel mode numerical identifiers must be between 120 and 127.\");if(value=Math.floor(value)||0,0>value||value>127)throw new RangeError(\"Value must be an integer between 0 and 127.\");return wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.channelmode<<4)+(ch-1),[command,value],this._parseTimeParameter(options.time))}.bind(this)),this},Output.prototype.sendProgramChange=function(program,channel,options){\nvar that=this;if(options=options||{},program=Math.floor(program),isNaN(program)||0>program||program>127)throw new RangeError(\"Program numbers must be between 0 and 127.\");return wm.toMIDIChannels(channel).forEach(function(ch){that.send((wm.MIDI_CHANNEL_MESSAGES.programchange<<4)+(ch-1),[program],that._parseTimeParameter(options.time))}),this},Output.prototype.sendChannelAftertouch=function(pressure,channel,options){var that=this;options=options||{},pressure=parseFloat(pressure),(isNaN(pressure)||0>pressure||pressure>1)&&(pressure=.5);var nPressure=Math.round(127*pressure);return wm.toMIDIChannels(channel).forEach(function(ch){that.send((wm.MIDI_CHANNEL_MESSAGES.channelaftertouch<<4)+(ch-1),[nPressure],that._parseTimeParameter(options.time))}),this},Output.prototype.sendPitchBend=function(bend,channel,options){var that=this;if(options=options||{},isNaN(bend)||-1>bend||bend>1)throw new RangeError(\"Pitch bend value must be between -1 and 1.\");var nLevel=Math.round((bend+1)/2*16383),msb=nLevel>>7&127,lsb=127&nLevel;return wm.toMIDIChannels(channel).forEach(function(ch){that.send((wm.MIDI_CHANNEL_MESSAGES.pitchbend<<4)+(ch-1),[lsb,msb],that._parseTimeParameter(options.time))}),this},Output.prototype._parseTimeParameter=function(time){var parsed,value;return\"string\"==typeof time&&\"+\"===time.substring(0,1)?(parsed=parseFloat(time),parsed&&parsed>0&&(value=wm.time+parsed)):(parsed=parseFloat(time),parsed>wm.time&&(value=parsed)),value},Output.prototype._convertNoteToArray=function(note){var notes=[];return Array.isArray(note)||(note=[note]),note.forEach(function(item){notes.push(wm.guessNoteNumber(item))}),notes},\"function\"==typeof define&&\"object\"==typeof define.amd?define([],function(){return wm}):\"undefined\"!=typeof module&&module.exports?module.exports=wm:scope.WebMidi||(scope.WebMidi=wm)}(this);\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/webmidi/webmidi.min.js\n// module id = 15\n// module chunks = 0","'use strict';\n\nvar _tone = require('tone');\n\nvar _tone2 = _interopRequireDefault(_tone);\n\nvar _webmidi = require('webmidi');\n\nvar _webmidi2 = _interopRequireDefault(_webmidi);\n\nrequire('nexusui');\n\nvar _keys = require('./lib/keys');\n\nvar _keys2 = _interopRequireDefault(_keys);\n\nvar _color = require('./lib/color');\n\nvar _color2 = _interopRequireDefault(_color);\n\nvar _kalimba = require('./lib/kalimba');\n\nvar _kalimba2 = _interopRequireDefault(_kalimba);\n\nvar _scales = require('./lib/scales');\n\nvar _scales2 = _interopRequireDefault(_scales);\n\nvar _util = require('./lib/util');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar nx = window.nx;\n\nvar noteCount = _util.browser.isMobile ? 18 : 36;\nvar stepCount = 16;\nvar cellSize = _util.browser.isMobile ? 20 : 27;\nvar baseTone = _util.browser.isMobile ? 8 : 12;\n\nvar grid = void 0,\n midi = void 0;\n\n_webmidi2.default.enable(midi_ready);\n\nfunction midi_ready(err) {\n\tif (err) {\n\t\tconsole.error('webmidi failed to initialize');\n\t\treturn;\n\t}\n\tif (!_webmidi2.default.outputs.length) {\n\t\tconsole.error('no MIDI output found');\n\t}\n\tconsole.log(_webmidi2.default.inputs);\n\tconsole.log(_webmidi2.default.outputs);\n\tmidi = _webmidi2.default.outputs[0];\n}\n\nvar loop = new _tone2.default.Sequence(function (time, col) {\n\tvar column = grid.matrix[col];\n\tgrid.jumpToCol(col);\n\tfor (var i = 0; i < noteCount; i++) {\n\t\tif (column[i] === 1) {\n\t\t\tvar index = noteCount - i - baseTone;\n\t\t\tvar freq = _scales2.default.current().index(index);\n\t\t\tvar midi_note = _tone2.default.Frequency.ftom(freq);\n\t\t\tvar midi_freq = _tone2.default.Frequency.mtof(midi_note);\n\t\t\tconsole.log(midi_note, freq, midi_freq, freq - midi_freq);\n\t\t\tif (midi) {\n\t\t\t\tmidi.playNote(_tone2.default.Frequency(midi_note, \"midi\").toNote(), 3, { duration: 90000 / _tone2.default.Transport.bpm.value });\n\t\t\t} else {\n\t\t\t\t_kalimba2.default.play(freq);\n\t\t\t}\n\t\t}\n\t}\n}, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], \"16n\");\n\nnx.onload = function () {\n\treturn (0, _util.requestAudioContext)(ready);\n};\n\nfunction ready() {\n\tgrid = nx.widgets.grid;\n\tgrid.sequenceMode = true;\n\tgrid.bpm = 1;\n\tgrid.col = stepCount;\n\tgrid.row = noteCount;\n\n\tgrid.init();\n\tgrid.resize(cellSize * stepCount, cellSize * noteCount);\n\tgrid.draw();\n\n\tnx.widgets.scale.choices = _scales2.default.names();\n\tnx.widgets.scale.init();\n\tnx.widgets.scale.on('*', function (e) {\n\t\treturn _scales2.default.pick(e.value);\n\t});\n\t_scales2.default.onChange(function (s) {\n\t\tbuildLabels();\n\t});\n\tbuildLabels();\n\n\tgrid.on('*', function (e) {\n\t\treturn 'level' in e && buildLabels();\n\t});\n\tnx.widgets.shiftUp.on('*', tap(shiftUp));\n\tnx.widgets.shiftDown.on('*', tap(shiftDown));\n\tnx.widgets.slideUp.on('*', tap(slideUp));\n\tnx.widgets.slideDown.on('*', tap(slideDown));\n\tnx.widgets.slideLeft.on('*', tap(slideLeft));\n\tnx.widgets.slideRight.on('*', tap(slideRight));\n\tnx.widgets.rotateUp.on('*', tap(function () {\n\t\treturn rotateVertical(-1);\n\t}));\n\tnx.widgets.rotateDown.on('*', tap(function () {\n\t\treturn rotateVertical(1);\n\t}));\n\tnx.widgets.rotateLeft.on('*', tap(function () {\n\t\treturn rotateHorizontal(-1);\n\t}));\n\tnx.widgets.rotateRight.on('*', tap(function () {\n\t\treturn rotateHorizontal(1);\n\t}));\n\tnx.widgets.flip.on('*', tap(flip));\n\tnx.widgets.flop.on('*', tap(flop));\n\n\tnx.colorize('#f4d142');\n\n\tloop.start();\n\t_tone2.default.Transport.bpm.value = 108;\n\tnx.widgets.tempo.min = 10;\n\tnx.widgets.tempo.max = 1000;\n\tnx.widgets.tempo.set({ value: 108 });\n\tnx.widgets.tempo.on('*', function (e) {\n\t\treturn _tone2.default.Transport.bpm.value = nx.widgets.tempo.val.value;\n\t});\n\t_tone2.default.Transport.start();\n}\nfunction tap(fn) {\n\treturn function (e) {\n\t\tif (_util.browser.isMobile) fn();else if (e.press) fn();\n\t};\n}\nfunction draw() {\n\tgrid.draw();\n\tbuildLabels();\n}\nfunction buildLabels() {\n\tvar labels = document.querySelector('#labels');\n\tvar scaleCount = _scales2.default.current().scale.length;\n\tvar subScale = findSubScale();\n\tvar str = '';\n\tfor (var i = 0; i < noteCount; i++) {\n\t\tvar index = noteCount - i - baseTone;\n\t\tvar n = (0, _util.mod)(index, scaleCount);\n\t\tvar ns = n + 1;\n\t\t/*\n if (ns == 1) {\n \tlet octave = (index / scaleCount)\n \tns = ns + '<small>' + octave + '</small>'\n }\n */\n\t\tif (subScale.includes(n)) {\n\t\t\tstr += '<b>' + ns + '</b><br>';\n\t\t} else {\n\t\t\tstr += ns + '<br>';\n\t\t}\n\t}\n\tlabels.innerHTML = str;\n}\nfunction findSubScale(notes) {\n\tnotes = notes || findNotes();\n\tvar scaleCount = _scales2.default.current().scale.length;\n\treturn notes.reduce(function (acc, n) {\n\t\tvar scaleNote = (0, _util.mod)(noteCount - n - baseTone, scaleCount);\n\t\tif (!acc.includes(scaleNote)) acc.push(scaleNote);\n\t\treturn acc;\n\t}, []).sort();\n}\n\nfunction shiftUp() {\n\tvar notes = findNotes();\n\tvar subScale = findSubScale(notes);\n\tvar scaleCount = _scales2.default.current().scale.length;\n\tassignNotes(mapFunction(notes, function (n) {\n\t\tvar index = noteCount - n - baseTone;\n\t\tvar note = (0, _util.mod)(index, scaleCount);\n\t\tvar scaleIndex = subScale.indexOf(note) + 1;\n\t\tvar octave = Math.floor(index / scaleCount);\n\t\twhile (scaleIndex >= subScale.length) {\n\t\t\tscaleIndex -= subScale.length;\n\t\t\toctave += 1;\n\t\t}\n\t\treturn noteCount - baseTone - (subScale[scaleIndex] + octave * scaleCount);\n\t}));\n}\nfunction shiftDown() {\n\tvar notes = findNotes();\n\tvar subScale = findSubScale(notes);\n\tvar scaleCount = _scales2.default.current().scale.length;\n\tassignNotes(mapFunction(notes, function (n) {\n\t\tvar index = noteCount - n - baseTone;\n\t\tvar note = (0, _util.mod)(index, scaleCount);\n\t\tvar scaleIndex = subScale.indexOf(note) - 1;\n\t\tvar octave = Math.floor(index / scaleCount);\n\t\twhile (scaleIndex < 0) {\n\t\t\tscaleIndex += subScale.length;\n\t\t\toctave -= 1;\n\t\t}\n\t\treturn noteCount - baseTone - (subScale[scaleIndex] + octave * scaleCount);\n\t}));\n}\nfunction slideUp() {\n\tassignNotes(mapFunction(findNotes(), function (n) {\n\t\treturn (n - 1 + noteCount) % noteCount;\n\t}));\n}\nfunction slideDown() {\n\tassignNotes(mapFunction(findNotes(), function (n) {\n\t\treturn (n + 1 + noteCount) % noteCount;\n\t}));\n}\nfunction slideLeft() {\n\tassignPositions(mapFunction(findPositions(), function (n) {\n\t\treturn (n - 1 + stepCount) % stepCount;\n\t}));\n}\nfunction slideRight() {\n\tassignPositions(mapFunction(findPositions(), function (n) {\n\t\treturn (n + 1 + stepCount) % stepCount;\n\t}));\n}\nfunction flip() {\n\tassignNotes(mapReverse(findNotes()));\n}\nfunction flop() {\n\tassignPositions(mapReverse(findPositions()));\n}\nfunction rotateHorizontal(n) {\n\tassignPositions(remapArray(findPositions(), n));\n}\nfunction rotateVertical(n) {\n\tassignNotes(remapArray(findNotes(), n));\n}\nfunction assignPositions(positions) {\n\tif (!positions) return;\n\tvar a = grid.matrix;\n\tvar b = iota();\n\tstride(a, function (i, j, v) {\n\t\tif (i in positions) {\n\t\t\tb[positions[i]][j] = v;\n\t\t}\n\t});\n\tassign(grid.matrix, b);\n\tdraw();\n}\nfunction assignNotes(noteMap) {\n\tif (!noteMap) return;\n\tvar a = grid.matrix;\n\tvar b = iota();\n\tstride(a, function (i, j, v) {\n\t\tif (j in noteMap) {\n\t\t\tb[i][noteMap[j]] = v;\n\t\t}\n\t});\n\tassign(grid.matrix, b);\n\tdraw();\n}\n\nfunction stride(a, f) {\n\tvar w = stepCount,\n\t h = noteCount;\n\tfor (var i = 0; i < w; i++) {\n\t\tfor (var j = 0; j < h; j++) {\n\t\t\tf(i, j, a[i][j]);\n\t\t}\n\t}\n\treturn a;\n}\n\n// assign b -> a\nfunction assign(a, b) {\n\treturn stride(b, function (i, j, v) {\n\t\treturn a[i][j] = b[i][j];\n\t});\n}\nfunction clone(a) {\n\tvar b = iota(a.length, a[0].length);\n\treturn assign(b, a);\n}\nfunction iota() {\n\tvar w = grid.matrix.length,\n\t h = grid.matrix[0].length;\n\tvar a = new Array(w);\n\tfor (var i = 0; i < w; i++) {\n\t\ta[i] = new Array(h);\n\t\tfor (var j = 0; j < h; j++) {\n\t\t\ta[i][j] = 0;\n\t\t}\n\t}\n\treturn a;\n}\nfunction findNotes() {\n\tvar a = new Array(noteCount);\n\tstride(grid.matrix, function (i, j, v) {\n\t\tif (v) a[j] = 1;\n\t});\n\treturn a.reduce(function (acc, v, i) {\n\t\tif (v === 1) acc.push(i);\n\t\treturn acc;\n\t}, []);\n}\nfunction findPositions() {\n\treturn grid.matrix.reduce(function (acc, row, i) {\n\t\tif (row.some(function (x) {\n\t\t\treturn x === 1;\n\t\t})) acc.push(i);\n\t\treturn acc;\n\t}, []);\n}\nfunction remapArray(a, n) {\n\tif (!a.length) return;\n\tvar h = {};\n\tvar b = rotate(a, n);\n\tfor (var i = 0; i < b.length; i++) {\n\t\th[b[i]] = a[i];\n\t}\n\treturn h;\n}\nfunction rotate(a, n) {\n\tvar b = a.slice(0);\n\tb.unshift.apply(b, b.splice(-n, b.length));\n\treturn b;\n}\nfunction mapFunction(a, f) {\n\tif (!a.length) return;\n\tvar h = {};\n\tfor (var i = 0; i < a.length; i++) {\n\t\th[a[i]] = f(a[i]);\n\t}\n\treturn h;\n}\nfunction mapReverse(a) {\n\tif (!a.length) return;\n\tvar h = {};\n\tvar b = a.slice(0).reverse();\n\tfor (var i = 0; i < b.length; i++) {\n\t\th[b[i]] = a[i];\n\t}\n\treturn h;\n}\n\n_keys2.default.listen(function (index) {\n\tvar freq = _scales2.default.current().index(index);\n\t_kalimba2.default.play(freq);\n});\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/index.js\n// module id = 16\n// module chunks = 0","\"use strict\";\n\nmodule.exports = function () {\n var Intonation = function Intonation(opt) {\n opt = this.opt = Object.assign({\n name: \"\",\n root: 440,\n octave: 0,\n interval: 2,\n tet: 0,\n intervals: null\n }, opt || {});\n this.generate();\n };\n Intonation.prototype.generate = function (opt) {\n opt = Object.assign(this.opt, opt || {});\n if (opt.scl) {\n this.generate_scl();\n } else if (opt.tet) {\n this.generate_tet();\n } else if (opt.intervals) {\n this.generate_intervals();\n }\n };\n Intonation.prototype.generate_intervals = function () {\n var root = this.opt.root;\n var interval_list = this.opt.intervals;\n if (typeof interval_list == \"string\") {\n interval_list = interval_list.split(\" \");\n }\n this.name = this.opt.name || \"interval list\";\n this.intervals = interval_list;\n this.interval = this.opt.interval = parseInterval.call(this, interval_list.pop());\n this.scale = interval_list.map(parseIntervalString.bind(this)).filter(function (v) {\n return !!v;\n });\n };\n Intonation.prototype.generate_tet = function () {\n var scale = this.scale = [];\n var root = this.opt.root;\n var tet = this.opt.tet;\n var interval = this.interval = this.opt.interval;\n var ratio = Math.pow(interval, 1 / tet);\n var n = root;\n scale.push(n);\n for (var i = 0; i < tet - 1; i++) {\n n *= ratio;\n scale.push(n);\n }\n this.name = this.opt.name || tet + \"-tone equal temperament\";\n this.intervals = null;\n };\n Intonation.prototype.generate_scl = function () {\n var root = this.opt.root;\n var scl = this.parse_scl(this.opt.scl);\n this.intervals = scl.notes;\n this.interval = scl.notes.pop();\n this.name = this.opt.name || scl.description;\n this.scale = scl.notes.map(function (v) {\n return v * root;\n });\n };\n Intonation.prototype.parse_scl = function (s) {\n var scl = {};\n scl.comments = [];\n scl.notes = [];\n s.trim().split(\"\\n\").forEach(function (line) {\n // Lines beginning with an exclamation mark are regarded as comments\n // and are to be ignored.\n if (line.indexOf(\"!\") !== -1) {\n scl.comments.push(line);\n }\n // The first (non comment) line contains a short description of the scale.\n // If there is no description, there should be an empty line. (nb: which is falsey)\n else if (!('description' in scl)) {\n scl.description = line;\n }\n // The second line contains the number of notes.\n // The first note of 1/1 or 0.0 cents is implicit and not in the files.\n else if (!scl.notes.length) {\n scl.notes.push(1);\n } else {\n // If the value contains a period, it is a cents value, otherwise a ratio.\n var note = line.replace(/^[^-\\.0-9]+/, \"\").replace(/[^-\\/\\.0-9]+$/, \"\");\n if (note.indexOf(\".\") !== -1) {\n note = Math.pow(2, parseFloat(note) / 1200);\n } else {\n note = parseInterval(note);\n }\n if (note) {\n scl.notes.push(note);\n }\n }\n });\n return scl;\n };\n Intonation.prototype.index = function (i, octave) {\n octave = octave || this.opt.octave;\n var f = this.scale[mod(i, this.scale.length) | 0];\n var pow = Math.floor(norm(i, 0, this.scale.length)) + octave;\n f *= Math.pow(this.interval, pow);\n return f;\n };\n Intonation.prototype.range = function (min, max) {\n var a = [];\n for (var i = min; i < max; i++) {\n a.push(this.index(i));\n }\n return a;\n };\n Intonation.prototype.set_root = function (f) {\n this.opt.root = f;\n this.generate();\n };\n Intonation.prototype.quantize_frequency = function (f) {\n if (f == 0) return 0;\n var scale_f = f;\n var pow = 0;\n var interval = this.interval;\n var scale = this.scale;\n while (scale_f < root) {\n scale_f *= interval;\n pow -= 1;\n }\n while (scale_f > root * interval) {\n scale_f /= interval;\n pow += 1;\n }\n for (var i = 0; i < scale.length; i++) {\n if (scale_f > scale[i]) continue;\n scale_f = scale[i];\n break;\n }\n scale_f *= Math.pow(2, pow);\n return scale_f;\n };\n Intonation.prototype.quantize_index = function (i) {\n return mod(index - 1, this.scale.length) | 0;\n };\n var parseInterval = Intonation.prototype.parse_interval = function (s) {\n if (typeof s == \"number\") return s;\n if (!s.indexOf(\"/\") == -1) return parseInt(s);\n var pp = s.split(\"/\");\n var num = parseInt(pp[0]);\n var den = parseInt(pp[1]);\n if (isNaN(num)) return 1;\n if (isNaN(den) || den == 0) return num;\n if (num == den) return 1;\n return num / den;\n };\n var parseIntervalString = Intonation.prototype.parse_interval_string = function (s) {\n if (s.indexOf(\"/\") !== -1) return parseInterval(s) * this.opt.root; // intervals\n if (s.indexOf(\"f\") !== -1) return parseFloat(s); // pure frequencies\n return parseFloat(s);\n };\n function norm(n, a, b) {\n return (n - a) / (b - a);\n }\n function mod(n, m) {\n return n - m * Math.floor(n / m);\n }\n\n return Intonation;\n}();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/lib/intonation.js\n// module id = 17\n// module chunks = 0","\"use strict\";\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\n/**\n * StartAudioContext.js\n * @author Yotam Mann\n * @license http://opensource.org/licenses/MIT MIT License\n * @copyright 2016 Yotam Mann\n */\n(function (root, factory) {\n if (typeof define === \"function\" && define.amd) {\n define([], factory);\n } else if ((typeof module === \"undefined\" ? \"undefined\" : _typeof(module)) === 'object' && module.exports) {\n module.exports = factory();\n } else {\n root.StartAudioContext = factory();\n }\n})(undefined, function () {\n\n /**\n * The StartAudioContext object\n */\n var StartAudioContext = {\n /**\n * The audio context passed in by the user\n * @type {AudioContext}\n */\n context: null,\n /**\n * The TapListeners bound to the elements\n * @type {Array}\n * @private\n */\n _tapListeners: [],\n /**\n * Callbacks to invoke when the audio context is started\n * @type {Array}\n * @private\n */\n _onStarted: []\n };\n\n /**\n * Set the context\n * @param {AudioContext} ctx\n * @returns {StartAudioContext}\n */\n StartAudioContext.setContext = function (ctx) {\n StartAudioContext.context = ctx;\n return StartAudioContext;\n };\n\n /**\n * Add a tap listener to the audio context\n * @param {Array|Element|String|jQuery} element\n * @returns {StartAudioContext}\n */\n StartAudioContext.on = function (element) {\n if (Array.isArray(element) || NodeList && element instanceof NodeList) {\n for (var i = 0; i < element.length; i++) {\n StartAudioContext.on(element[i]);\n }\n } else if (typeof element === \"string\") {\n StartAudioContext.on(document.querySelectorAll(element));\n } else if (element.jquery && typeof element.toArray === \"function\") {\n StartAudioContext.on(element.toArray());\n } else if (Element && element instanceof Element) {\n //if it's an element, create a TapListener\n var tap = new TapListener(element, onTap);\n StartAudioContext._tapListeners.push(tap);\n }\n return StartAudioContext;\n };\n\n /**\n * Bind a callback to when the audio context is started. \n * @param {Function} cb\n * @return {StartAudioContext}\n */\n StartAudioContext.onStarted = function (cb) {\n //if it's already started, invoke the callback\n if (StartAudioContext.isStarted()) {\n cb();\n } else {\n StartAudioContext._onStarted.push(cb);\n }\n return StartAudioContext;\n };\n\n /**\n * returns true if the context is started\n * @return {Boolean}\n */\n StartAudioContext.isStarted = function () {\n return StartAudioContext.context !== null && StartAudioContext.context.state === \"running\";\n };\n\n /**\n * @class Listens for non-dragging tap ends on the given element\n * @param {Element} element\n * @internal\n */\n var TapListener = function TapListener(element) {\n\n this._dragged = false;\n\n this._element = element;\n\n this._bindedMove = this._moved.bind(this);\n this._bindedEnd = this._ended.bind(this);\n\n element.addEventListener(\"touchmove\", this._bindedMove);\n element.addEventListener(\"touchend\", this._bindedEnd);\n element.addEventListener(\"mouseup\", this._bindedEnd);\n };\n\n /**\n * drag move event\n */\n TapListener.prototype._moved = function (e) {\n this._dragged = true;\n };\n\n /**\n * tap ended listener\n */\n TapListener.prototype._ended = function (e) {\n if (!this._dragged) {\n onTap();\n }\n this._dragged = false;\n };\n\n /**\n * remove all the bound events\n */\n TapListener.prototype.dispose = function () {\n this._element.removeEventListener(\"touchmove\", this._bindedMove);\n this._element.removeEventListener(\"touchend\", this._bindedEnd);\n this._element.removeEventListener(\"mouseup\", this._bindedEnd);\n this._bindedMove = null;\n this._bindedEnd = null;\n this._element = null;\n };\n\n /**\n * Invoked the first time of the elements is tapped.\n * Creates a silent oscillator when a non-dragging touchend \n * event has been triggered.\n */\n function onTap() {\n //start the audio context with a silent oscillator\n if (StartAudioContext.context && !StartAudioContext.isStarted()) {\n var osc = StartAudioContext.context.createOscillator();\n var silent = StartAudioContext.context.createGain();\n silent.gain.value = 0;\n osc.connect(silent);\n silent.connect(StartAudioContext.context.destination);\n var now = StartAudioContext.context.currentTime;\n osc.start(now);\n osc.stop(now + 0.5);\n }\n\n //dispose all the tap listeners\n if (StartAudioContext._tapListeners) {\n for (var i = 0; i < StartAudioContext._tapListeners.length; i++) {\n StartAudioContext._tapListeners[i].dispose();\n }\n StartAudioContext._tapListeners = null;\n }\n //the onstarted callbacks\n if (StartAudioContext._onStarted) {\n for (var j = 0; j < StartAudioContext._onStarted.length; j++) {\n StartAudioContext._onStarted[j]();\n }\n StartAudioContext._onStarted = null;\n }\n }\n\n return StartAudioContext;\n});\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/lib/startAudioContext.js\n// module id = 18\n// module chunks = 0","var hasOwn = Object.prototype.hasOwnProperty;\nvar toStr = Object.prototype.toString;\nvar undefined;\n\nvar isArray = function isArray(arr) {\n\tif (typeof Array.isArray === 'function') {\n\t\treturn Array.isArray(arr);\n\t}\n\n\treturn toStr.call(arr) === '[object Array]';\n};\n\nvar isPlainObject = function isPlainObject(obj) {\n\t'use strict';\n\tif (!obj || toStr.call(obj) !== '[object Object]') {\n\t\treturn false;\n\t}\n\n\tvar has_own_constructor = hasOwn.call(obj, 'constructor');\n\tvar has_is_property_of_method = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');\n\t// Not own constructor property must be Object\n\tif (obj.constructor && !has_own_constructor && !has_is_property_of_method) {\n\t\treturn false;\n\t}\n\n\t// Own properties are enumerated firstly, so to speed up,\n\t// if last one is own, then all properties are own.\n\tvar key;\n\tfor (key in obj) {}\n\n\treturn key === undefined || hasOwn.call(obj, key);\n};\n\nmodule.exports = function extend() {\n\t'use strict';\n\tvar options, name, src, copy, copyIsArray, clone,\n\t\ttarget = arguments[0],\n\t\ti = 1,\n\t\tlength = arguments.length,\n\t\tdeep = false;\n\n\t// Handle a deep copy situation\n\tif (typeof target === 'boolean') {\n\t\tdeep = target;\n\t\ttarget = arguments[1] || {};\n\t\t// skip the boolean and the target\n\t\ti = 2;\n\t} else if ((typeof target !== 'object' && typeof target !== 'function') || target == null) {\n\t\ttarget = {};\n\t}\n\n\tfor (; i < length; ++i) {\n\t\toptions = arguments[i];\n\t\t// Only deal with non-null/undefined values\n\t\tif (options != null) {\n\t\t\t// Extend the base object\n\t\t\tfor (name in options) {\n\t\t\t\tsrc = target[name];\n\t\t\t\tcopy = options[name];\n\n\t\t\t\t// Prevent never-ending loop\n\t\t\t\tif (target === copy) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Recurse if we're merging plain objects or arrays\n\t\t\t\tif (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {\n\t\t\t\t\tif (copyIsArray) {\n\t\t\t\t\t\tcopyIsArray = false;\n\t\t\t\t\t\tclone = src && isArray(src) ? src : [];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tclone = src && isPlainObject(src) ? src : {};\n\t\t\t\t\t}\n\n\t\t\t\t\t// Never move original objects, clone them\n\t\t\t\t\ttarget[name] = extend(deep, clone, copy);\n\n\t\t\t\t// Don't bring in undefined values\n\t\t\t\t} else if (copy !== undefined) {\n\t\t\t\t\ttarget[name] = copy;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return the modified object\n\treturn target;\n};\n\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/extend/index.js\n// module id = 19\n// module chunks = 0","\n/**\n @title NexusUI API\n @overview NexusUI is a JavaScript toolkit for easily creating musical interfaces in web browsers. Interfaces are rendered on HTML5 canvases and are ideal for web audio projects, mobile apps, or for sending OSC to external audio applications like Max.\n @author Ben Taylor, Jesse Allison, Yemin Oh, Sébastien Piquemal\n @copyright © 2011-2014\n @license MIT\n */\n\n\nvar timingUtils = require('../utils/timing');\nvar drawingUtils = require('../utils/drawing');\nvar EventEmitter = require('events').EventEmitter;\nvar util = require('util');\nvar transmit = require('../utils/transmit');\n//var WAAClock = require('waaclock');\n\n\nvar manager = module.exports = function() {\n\n/**\n\n @class nx\n @description Central nexusUI manager with shared utility functions for all nexusUI objects\n\n*/\n\n EventEmitter.apply(this)\n\n /**@property {object} widgets Contains all interface widgets (e.g. nx.widgets.dial1, nx.widgets.toggle1) */\n this.widgets = new Object();\n\n this.elemTypeArr = new Array();\n this.aniItems = new Array();\n /* @property {boolean} showLabels Whether or not to draw an automatic text label on each interface component. */\n this.showLabels = false;\n this.starttime = new Date().getTime();\n if (transmit) {\n /**\n @method sendsTo\n @param {string or function} [destination] Protocol for transmitting data from interfaces (i.e. \"js\", \"ajax\", \"ios\", \"max\", or \"node\"). Also accepts custom functions.\n ```js\n nx.sendsTo(\"ajax\")\n\n // or\n\n nx.sendsTo(function(data) {\n //define a custom transmission function\n })\n ```\n */\n this.sendsTo = transmit.setGlobalTransmit;\n /**\n @method setAjaxPath\n @param {string} [path] If sending via AJAX, define the path to ajax destination\n */\n this.setAjaxPath = transmit.setAjaxPath;\n /** @property {string} destination NexusUI's transmission protocol (i.e. \"js\" or \"ajax\"). Defaults to \"js\". We recommend setting this property using nx.sendsTo() which ensures that all widgets receive this setting. */\n this.destination = \"js\";\n /** @property {string} ajaxPath If sending via AJAX, the destination path. Defaults to \"lib/nexusOSCRelay.php\". We recommend setting this property using nx.setAjaxPath() which ensures that all widgets receive this setting. */\n this.ajaxPath = \"lib/nexusOSCRelay.php\";\n }\n\n /** @property {boolean} isTouchDevice Returns true if page is loaded on a touch device. */\n this.isTouchDevice = ('ontouchstart' in document.documentElement)? true:false;\n this.metas = document.getElementsByTagName('meta');\n\n /** @property {boolean} globalWidgets Whether or not to instantiate a global variable for each widget (i.e. button1). Defaults to true. Designers of other softwares who wish to keep nexusUI entirely encapsulated in the nx object may set this property to false. In that case, all widgets are accessible in nx.widgets */\n this.globalWidgets = true;\n\n this.font = \"'open sans'\";\n this.fontSize = 14;\n this.fontWeight = \"normal\";\n\n var audioContext = window.AudioContext || window.webkitAudioContext;\n this.context = new audioContext();\n\n this.sys = navigator.userAgent.toLowerCase();\n this.isAndroid = this.sys.indexOf(\"android\") > -1;\n this.isMobile = this.sys.indexOf(\"mobile\") > -1;\n\n /** @property {integer} throttlePeriod Throttle time in ms (for nx.throttle). */\n this.throttlePeriod = 20;\n\n\n /* extra colors */\n\n this.colors.borderhl = drawingUtils.shadeBlendConvert(-0.5,this.colors.border); // colors.border + [20% Darker] => colors.darkborder\n this.colors.accenthl = drawingUtils.shadeBlendConvert(0.15,this.colors.accent);\n\n}\n\nutil.inherits(manager, EventEmitter)\n\n\n/**\n @method add\n Adds a NexusUI element to the webpage. This will create an HTML5 canvas and draw the interface on it.\n @param {string} [type] NexusUI widget type (i.e. \"dial\").\n @param {object} [settings] (Optional.) Extra settings for the new widget. This settings object may have any of the following properties: x (integer in px), y, w (width), h (height), name (widget's OSC name and canvas ID), parent (the ID of the element you wish to add the canvas into). If no settings are provided, the element will be at default size and appended to the body of the HTML document.\n */\nmanager.prototype.add = function(type, args) {\n //args may have optional properties: x, y, w, h, name, parent\n\n if(type) {\n var canv = document.createElement(\"canvas\");\n canv.setAttribute('nx', type);\n if (args) {\n if (args.x || args.y) {\n canv.style.position = \"absolute\";\n }\n if (args.x) {\n canv.style.left = args.x + \"px\";\n }\n if (args.y) {\n canv.style.top = args.y + \"px\";\n }\n if (args.w) {\n canv.style.width = args.w;\n if (typeof args.w != \"string\")\n canv.width = args.w;\n }\n if (args.h) {\n canv.style.height = args.h;\n if (typeof args.h != \"string\")\n canv.height = args.h;\n }\n if (args.parent) {\n var parent;\n if (typeof args.parent === \"string\") {\n parent = document.getElementById(args.parent);\n } else if (args.parent instanceof HTMLElement){\n parent = args.parent;\n } else if (args.parent instanceof jQuery){\n parent = args.parent[0];\n }\n }\n if (args.name) {\n canv.id = args.name\n }\n }\n if (!parent) {\n var parent = document.body\n }\n parent.appendChild(canv);\n return this.transform(canv);\n }\n}\n\n/** @method transform\nTransform an existing canvas into a NexusUI widget.\n@param {string} [canvasID] The ID of the canvas to be transformed.\n@param {string} [type] (Optional.) Specify which type of widget the canvas will become. If no type is given, the canvas must have an nx attribute with a valid widget type.\n*/\nmanager.prototype.transform = function(canvas, type) {\n for (var key in nx.widgets) {\n if (nx.widgets[key].canvasID == canvas.id) {\n return;\n }\n }\n if (type) {\n var nxType = type;\n } else {\n var nxType = canvas.getAttribute(\"nx\");\n }\n\n if (!nxType) {\n return;\n }\n var elemCount = 0;\n var newObj;\n\n /* find out how many of the same elem type have come before\n i.e. nx.elemTypeArr will look like [ dial, dial, toggle, toggle ]\n allowing you to count how many dials already exist on the page\n and give your new dial the appropriate index and id: dial3 */\n\n for (j=0;j<this.elemTypeArr.length;j++) {\n if (this.elemTypeArr[j] === nxType) {\n elemCount++;\n }\n }\n\n // add your new nexus element type to the element list\n this.elemTypeArr.push(nxType);\n\n // check to see if it has a pre-given ID\n // and use that as its id if so\n if (!canvas.id) {\n var idNum = elemCount + 1;\n canvas.id = nxType + idNum;\n }\n\n if(nxType) {\n try {\n var newObj = new (require('../widgets')[nxType])(canvas.id);\n } catch (err) {\n console.log(\"creation of \" + nxType + \" failed\");\n return;\n }\n }\n\n newObj.type = nxType;\n\n this.widgets[newObj.canvasID] = newObj;\n if (this.globalWidgets) {\n window[newObj.canvasID] = this.widgets[newObj.canvasID]\n }\n\n newObj.init();\n return newObj;\n}\n\n/** @method transmit\nThe \"output\" instructions for sending a widget's data to another application or to a JS callback. Inherited by each widget and executed when each widget is interacted with or its value changes. Set using nx.sendsTo() to ensure that all widgets inherit the new function correctly.\n@param {object} [data] The data to be transmitted. Each property of the object will become its own OSC message. (This works with objects nested to up to 2 levels).\n*/\n\nmanager.prototype.transmit = function(data, passive) {\n //console.log(passive + \" manager.transmit\")\n this.makeOSC(this.emit, data, passive);\n this.emit('*',data, passive);\n}\n\n/**\n @method colorize\n @param {string} [aspect] Which part of ui to change, i.e. \"accent\" \"fill\", \"border\"\n @param {string} [color] Hex or rgb color code\n Change the color of all nexus objects, by aspect ([fill, accent, border, accentborder]\n\n ```js\n nx.colorize(\"#00ff00\") // changes the accent color by default\n nx.colorize(\"border\", \"#000000\") // changes the border color\n ```\n\n**/\nmanager.prototype.colorize = function(aspect, newCol) {\n\n if (!newCol) {\n // just sending in a color value colorizes the accent\n newCol = aspect;\n aspect = \"accent\";\n }\n\n this.colors[aspect] = newCol;\n\n this.colors.borderhl = drawingUtils.shadeBlendConvert(0.1,this.colors.border,this.colors.black); // colors.border + [20% Darker] => colors.darkborder\n this.colors.accenthl = drawingUtils.shadeBlendConvert(0.3,this.colors.accent);\n\n for (var key in this.widgets) {\n this.widgets[key].colors[aspect] = newCol;\n this.widgets[key].colors[\"borderhl\"] = this.colors.borderhl;\n this.widgets[key].colors[\"accenthl\"] = this.colors.accenthl;\n\n this.widgets[key].draw();\n }\n\n}\n\n\n/** @method setThrottlePeriod\nSet throttle time of nx.throttle, which controls rapid network transmissions of widget data.\n@param {integer} [throttle time] Throttle time in milliseconds.\n*/\nmanager.prototype.setThrottlePeriod = function(newThrottle) {\n this.throttlePeriod = newThrottle;\n for (var key in this.widgets) {\n this.widgets[key].throttlePeriod = this.throttlePeriod;\n }\n}\n\n\n\n /*\n * GUI\n */\n\n/** @property {object} colors The interface's color settings. Set with nx.colorize(). */\nmanager.prototype.colors = {\n \"accent\": \"#ff5500\",\n \"fill\": \"#eeeeee\",\n \"border\": \"#e3e3e3\",\n \"mid\": \"#1af\",\n \"black\": \"#000000\",\n \"white\": \"#FFFFFF\"\n};\n\n/** @method startPulse\n Start an animation interval for animated widgets (calls nx.pulse() every 30 ms). Executed by default when NexusUI loads.\n*/\nmanager.prototype.startPulse = function() {\n this.pulseInt = setInterval(\"nx.pulse()\", 30);\n}\n\n/** @method stopPulse\n Stop the animation pulse interval.\n*/\nmanager.prototype.stopPulse = function() {\n clearInterval(this.pulseInt);\n}\n\n/** @method pulse\n Animation pulse which executes all functions stored in the nx.aniItems array.\n*/\nmanager.prototype.pulse = function() {\n for (var i=0;i<this.aniItems.length;i++) {\n this.aniItems[i]();\n }\n}\n\nmanager.prototype.addAni = function(fn) {\n\n}\n\nmanager.prototype.removeAni = function(fn) {\n this.aniItems.splice(this.aniItems.indexOf(fn));\n}\n\nmanager.prototype.addStylesheet = function() {\n var cssString = 'select {'\n + 'width: 150px;'\n + 'padding: 5px 5px;'\n + 'font-size: 16px;'\n + 'color:#666666;'\n + 'border: solid 2px #e4e4e4;'\n + 'border-radius: 0;'\n + '-webkit-appearance: none;'\n + 'outline: none;'\n + 'cursor:pointer;'\n + 'background-color:#EEE;'\n + 'font-family:\"open sans\";'\n + '}'\n + ''\n + 'input[type=text]::-moz-selection { background: transparent; }'\n + 'input[type=text]::selection { background: transparent; }'\n + 'input[type=text]::-webkit-selection { background: transparent; }'\n + ''\n + 'canvas { '\n + 'cursor:pointer;'\n + 'border-radius:0px;'\n + 'moz-border-radius:0px;'\n + 'webkit-border-radius:0px;'\n + 'box-sizing:border-box;'\n + '-moz-box-sizing:border-box;'\n + '-webkit-box-sizing:border-box;'\n + '}'\n + ''\n + 'input[type=text] { '\n + 'border-radius:5px;'\n + 'moz-border-radius:5px;'\n + 'webkit-border-radius:5px;'\n + 'box-sizing:border-box;'\n + '-moz-box-sizing:border-box;'\n + '-webkit-box-sizing:border-box;'\n + '}';\n\n var head = document.head;\n var style = document.createElement('style');\n\n style.type = 'text/css';\n if (style.styleSheet){\n style.styleSheet.cssText = cssString;\n } else {\n style.appendChild(document.createTextNode(cssString));\n }\n head.appendChild(style);\n}\n\n/** @method setViewport\n Set mobile viewport scale (similar to a zoom)\n @param {integer} [scale] Zoom ratio (i.e. 0.5, 1, 2) */\nmanager.prototype.setViewport = function(scale) {\n for (i=0; i<this.metas.length; i++) {\n if (this.metas[i].name == \"viewport\") {\n this.metas[i].content = \"minimum-scale=\"+scale+\", maximum-scale=\"+scale;\n }\n }\n}\n\n/* @method setLabels\n Tell all widgets whether or not draw text labels on widgets\n @param {boolean} [on/off] true to add labels, false to remove labels\n */\nmanager.prototype.setLabels = function(onoff) {\n if (onoff==\"on\") {\n this.showLabels = true;\n } else {\n this.showLabels = false;\n }\n for (var key in this.widgets) {\n this.widgets[key].draw()\n }\n}\n\nmanager.prototype.setProp = function(prop,val) {\n if (prop && val) {\n nx[prop] = val;\n for (var key in this.widgets) {\n this.widgets[key][prop] = val;\n this.widgets[key].draw()\n }\n }\n}\n\nmanager.prototype.blockMove = function(e) {\n if (e.target.attributes[\"nx\"]) {\n e.preventDefault();\n if (this.isAndroid) {\n e.stopPropagation ? e.stopPropagation() : false;\n }\n }\n}\n\nmanager.prototype.calculateDigits = function(value) {\n var nondecimals = this.max ? Math.floor(this.max).toString().length : 1\n if (nondecimals < this.maxdigits) {\n var decimals = 3-nondecimals\n } else {\n var decimals = 0\n }\n var valdigits = nondecimals + decimals\n return {\n wholes: nondecimals,\n decimals: decimals,\n total: nondecimals + decimals,\n }\n}\n\nmanager.prototype.themes = {\n \"light\": {\n \"fill\": \"#DDDDDD\",\n \"border\": \"#DADADA\",\n \"black\": \"#000000\",\n \"white\": \"#FFFFFF\",\n \"body\": \"#F3F3F3\"\n },\n \"dark\": {\n \"fill\": \"#222\",\n \"border\": \"#292929\",\n \"black\": \"#FFFFFF\",\n \"white\": \"#000000\",\n \"body\": \"#111\"\n },\n \"red\": \"#f24\",\n \"orange\": \"#f50\",\n \"yellow\": \"#ec1\",\n \"green\": \"#1c9\",\n \"blue\": \"#09d\",\n \"purple\": \"#40a\",\n}\n\nmanager.prototype.skin = function(name) {\n\n var names = name.split(\"-\")\n\n nx.colorize(\"fill\", nx.themes[names[0]].fill)\n nx.colorize(\"border\", nx.themes[names[0]].border)\n nx.colorize(\"black\", nx.themes[names[0]].black)\n nx.colorize(\"white\", nx.themes[names[0]].white)\n\n nx.colorize(\"accent\", nx.themes[names[1]])\n\n document.body.style.backgroundColor = nx.themes[names[0]].body\n}\n\n\nmanager.prototype.labelSize = function(size) {\n for (var key in this.widgets) {\n var widget = this.widgets[key]\n\n if (widget.label) {\n var newheight = widget.GUI.h + size\n widget.labelSize = size\n if ([\"select\",\"number\",\"text\"].indexOf(widget.type)<0) {\n widget.resize(false,newheight)\n }\n }\n }\n var textLabels = document.querySelectorAll(\".nxlabel\");\n console.log(textLabels)\n\n for (var i = 0; i < textLabels.length; i++) {\n console.log(textLabels[i])\n textLabels[i].style.fontSize = size/2.8+\"px\"\n console.log(textLabels[i].style.fontSize)\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/core/manager.js\n// module id = 20\n// module chunks = 0","var util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class banner \n\t\"Powered by NexusUI\" tag with a link to our website. Use it if you want to share the positive vibes of NexusUI. Thanks for using!\n\t```html\n\t<canvas nx=\"banner\"></canvas>\n\t```\n\t<canvas nx=\"banner\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar banner = module.exports = function (target) {\n\tthis.defaultSize = { width: 100, height: 40 };\n\twidget.call(this, target);\n\t\n\t//unique attributes\n\t/** @property {string} message1 The first line of text on the banner. */\n\tthis.message1 = \"Powered By\";\n\t/** @property {string} message2 The second line of text on the banner. */\n\tthis.message2 = \"NexusUI\";\n\t/** @property {string} link The URL the banner will link to. */\n\tthis.link = \"http://www.nexusosc.com\";\n\t/** @property {boolean} isLink Whether or not the banner is a hyperlink. Defaults to true. */\n\tthis.isLink = true;\n}\nutil.inherits(banner, widget);\n\nbanner.prototype.init = function() {\n\tthis.draw();\n}\n\nbanner.prototype.draw = function() {\n\twith (this.context) {\n\n\t\tglobalAlpha = 0.1;\n\t\tfillStyle = this.colors.accent;\n\t\tbeginPath();\n\t\t\tmoveTo(0,10);\n\t\t\tlineTo(10,this.GUI.h/2+5);\n\t\t\tlineTo(0,this.GUI.h);\n\t\t\tlineTo(30,this.GUI.h);\n\t\t\tlineTo(30,10);\n\t\t\tfill();\n\t\t\tmoveTo(this.GUI.w-30,10);\n\t\t\tlineTo(this.GUI.w-30,this.GUI.h);\n\t\t\tlineTo(this.GUI.w,this.GUI.h);\n\t\t\tlineTo(this.GUI.w-10,this.GUI.h/2+5);\n\t\t\tlineTo(this.GUI.w,10);\n\t\t\tfill();\n\t\tclosePath();\n\t\tglobalAlpha = 1;\n\n\t\tfillStyle = this.colors.accent;\n\t\tfillRect(15,0,this.GUI.w-30,this.GUI.h-10);\n\t\t\n\t\tfillStyle = this.colors.white;\n\t\tfont = this.fontWeight + \" \" +this.GUI.h/5+\"px \"+this.font;\n\t\ttextAlign = \"center\";\n\t\tfillText(this.message1, this.GUI.w/2, this.GUI.h/3.3);\n\t\tfillText(this.message2, this.GUI.w/2, (this.GUI.h/3.3)*2);\n\n\t\tfillStyle = this.colors.black;\n\t\tbeginPath();\n\t\t\tmoveTo(15,this.GUI.h-10);\n\t\t\tlineTo(30,this.GUI.h);\n\t\t\tlineTo(30,this.GUI.h-10);\n\t\t\tlineTo(15,this.GUI.h-10);\n\t\t\tfill();\n\t\t\tmoveTo(this.GUI.w-15,this.GUI.h-10);\n\t\t\tlineTo(this.GUI.w-30,this.GUI.h);\n\t\t\tlineTo(this.GUI.w-30,this.GUI.h-10);\n\t\t\tlineTo(this.GUI.w-15,this.GUI.h-10);\n\t\t\tfill();\n\t\tclosePath();\n\t\n\t}\n}\n\nbanner.prototype.click = function() {\n\tif (this.isLink) {\n\t\twindow.location = this.link;\n\t}\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/banner.js\n// module id = 21\n// module chunks = 0","var util = require('util');\nvar widget = require('../core/widget');\nvar drawing = require('../utils/drawing');\n\nvar button = module.exports = function(target) {\n\n/** \n\t\n\t@public\n\t@class button \n\n\tTouch button with three modes of interaction (\"toggle\", \"impulse\", and \"aftertouch\").\n\t```html\n\t<canvas nx=\"button\"></canvas>\n\t```\n\t<canvas nx=\"button\" style=\"margin-left:25px\"></canvas>\n*/\n\n\tthis.defaultSize = { width: 50, height: 50 };\n\twidget.call(this, target);\n\n\t/** \n\t\t@property {object} val Main value set and output, with sub-properties:\n\t\t| | data\n\t\t| --- | ---\n\t\t| *press* | 0 (clicked) or 1 (unclicked)\n\t\t| *x* | 0-1 float of x-position of click (\"aftertouch\" mode only)\n\t\t| *y* | 0-1 float of y-position of click (\"aftertouch\" mode only) \n\t\t\n\t\tWhen the widget is interacted with, val is sent as the output data for the widget.\n\t\t```js \n\t\tbutton1.on('*', function(data) {\n\t\t\t// some code using data.press, data.x, and data.y\n\t\t});\n\t\t```\n\t\tOr, if NexusUI is outputting OSC (e.g. if nx.sendsTo(\"ajax\")), val will be broken into OSC messages: \n\t\t```html \n\t\t/button1/press 1\n\t\t/button1/x 37\n\t\t/button1/y 126\n\t\t```\n\t\t*/\n\tthis.val = {\n\t\tpress: 0\n\t}\n\t\n\t/** @property {string} mode Interaction mode. Options:\n\t<b>impulse</b> 1 on click <br>\n\t<b>toggle</b> 1 on click, 0 on release<br>\n\t<b>aftertouch</b> 1, x, y on click; x, y on move; 0, x, y on release _(default)_ <br> \n\t```js \n\tbutton1.mode = \"aftertouch\" \n\t```\n\t*/\n\tthis.mode = \"aftertouch\";\n\n\tthis.lockResize = true;\n\n\tthis.image = null;\n\tthis.imageHover = null;\n\tthis.imageTouch = null;\n\n\tthis.subval = new Object();\n\n\tthis.init();\n\n}\nutil.inherits(button, widget);\n\nbutton.prototype.init = function() {\n\tthis.center = {\n\t\tx: this.GUI.w/2,\n\t\ty: this.GUI.h/2\n\t}\n\tthis.strokeWidth = this.GUI.w/20;\n\tthis.radius = (Math.min(this.center.x, this.center.y))\n\tthis.draw();\n}\n\nbutton.prototype.draw = function() {\n\n\tthis.erase();\n\t\n\twith (this.context) {\n\t\t\n\t\tif (this.image !== null) {\n\t\t\t// Image Button\n\t\t\tif (!this.val.press) {\n\t\t\t\t// Draw Image if not touched\n\t\t\t\tdrawImage(this.image, 0, 0);\n\t\t\t} else {\n\t\t\t\tif (this.imageTouch) {\n\t\t\t\t\t// Draw Touch Image\n\t\t\t\t\tdrawImage(this.imageTouch, 0, 0)\n\n\t\t\t\t} else {\n\n\t\t\t\t\tdrawImage(this.image, 0, 0)\n\n\t\t\t\t\t// No touch image, apply highlighting\n\t\t\t\t\tglobalAlpha = 0.5;\n\t\t\t\t\tfillStyle = this.colors.accent;\n\t\t\t\t\tfillRect (0, 0, this.GUI.w, this.GUI.h);\n\t\t\t\t\tglobalAlpha = 1;\n\t\t\t\t\t\n\t\t\t\t} \n\t\t\t}\n\t\t\t\n\t\t} else {\n\t\n\t\t\t// Regular Button\n\t\t\t\n\t\t\tif (!this.val.press) {\n\t\t\t\tfillStyle = this.colors.fill\n\t\t\t\tstrokeStyle = this.colors.border\n\t\t\t//\tvar strokealpha = 1\n\t\t\t} else if (this.val.press) {\n\t\t\t\tfillStyle = this.colors.accent;\n\t\t\t//\tstrokeStyle = this.colors.accentborder || \"#fff\"\n\t\t\t\tstrokeStyle = this.colors.accenthl\n\t\t\t//\tvar strokealpha = 0.2\n\t\t\t}\n\n\t\t\tlineWidth = this.strokeWidth;\n\n\t\t\tbeginPath();\n\t\t\t\tarc(this.center.x, this.center.y, this.radius, 0, Math.PI*2, true);\n\t\t\t\tfill()\n\t\t\tclosePath()\n\n\t\t\tbeginPath();\n\t\t\t\tarc(this.center.x, this.center.y, this.radius-lineWidth/2, 0, Math.PI*2, true);\n\t\t\t//\tglobalAlpha = strokealpha\n\t\t\t\tstroke()\n\t\t\t\tglobalAlpha = 1\n\t\t\tclosePath()\n\n\t\t\tif (this.val.press && this.mode==\"aftertouch\") {\n\n\t\t\t\tvar x = nx.clip(this.clickPos.x,this.GUI.w*.2,this.GUI.w/1.3)\n\t\t\t\tvar y = nx.clip(this.clickPos.y,this.GUI.h*.2,this.GUI.h/1.3)\n\n\t\t\t\tvar gradient = this.context.createRadialGradient(x,y,this.GUI.w/6,this.center.x,this.center.y,this.radius*1.3);\n\t\t\t\tgradient.addColorStop(0,this.colors.accent);\n\t\t\t\tgradient.addColorStop(1,\"white\");\n\n\t\t\t\tstrokeStyle = gradient;\n\t\t\t\tlineWidth = this.GUI.w/20;\n\n\t\t\t\tbeginPath()\n\t\t\t\t\tarc(this.center.x, this.center.y, this.radius-this.GUI.w/40, 0, Math.PI*2, true);\n\t\t\t\t\tstroke()\n\t\t\t\tclosePath()\n\n\t\t\t}\n\t\t}\n\n\t\tthis.drawLabel();\n\t\t\n\t}\n}\n\nbutton.prototype.click = function(e) {\n\tif (drawing.isInside(this.clickPos,{x: this.center.x-this.radius, y:this.center.y-this.radius, w:this.radius*2, h:this.radius*2})) {\n\t\tthis.val[\"press\"] = 1;\n\t\tif (this.mode==\"aftertouch\") {\n\t\t\tthis.val[\"x\"] = this.clickPos.x;\n\t\t\tthis.val[\"y\"] = this.clickPos.y;\n\t\t}\n\t\tthis.transmit(this.val);\n\t\tthis.draw();\n\t}\n}\n\nbutton.prototype.move = function () {\n\t// use to track movement on the button\n\tif (this.mode==\"aftertouch\") {\n\t\tthis.val[\"x\"] = this.clickPos.x;\n\t\tthis.val[\"y\"] = this.clickPos.y;\n\t\tthis.subval[\"x\"] = this.clickPos.x;\n\t\tthis.subval[\"y\"] = this.clickPos.y;\n\t\tthis.transmit(this.subval);\n\t\tthis.draw();\n\t}\n}\n\nbutton.prototype.release = function() {\n\tthis.val[\"press\"] = 0;\n\tif (this.mode==\"toggle\" || this.mode==\"aftertouch\") { \n\t\tthis.transmit(this.val);\n\t}\n\tthis.draw();\n}\n\n\n/** @method setImage \n\tTurns the button into an image button with custom image. Sets the default (unclicked) button image.\n\t@param {string} [src] Image source */\nbutton.prototype.setImage = function(image) {\n\tthis.image = new Image();\n\tthis.image.onload = this.draw.bind(this)\n\tthis.image.src = image;\n}\n\nbutton.prototype.setHoverImage = function(image) {\n\tthis.imageHover = new Image();\n\tthis.imageHover.onload = this.draw.bind(this)\n\tthis.imageHover.src = image;\n}\n\n/** @method setTouchImage \n\tSets the image that will show when the button is clicked.\n\t@param {string} [src] Image source */\nbutton.prototype.setTouchImage = function(image) {\n\tthis.imageTouch = new Image();\n\tthis.imageTouch.onload = this.draw.bind(this)\n\tthis.imageTouch.src = image;\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/button.js\n// module id = 22\n// module chunks = 0","var util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class colors \n\tColor picker that outputs RBG values\n\t```html\n\t<canvas nx=\"colors\"></canvas>\n\t```\n\t<canvas nx=\"colors\" style=\"margin-left:25px\"></canvas>\n*/\n\t\t\t\t\nvar colors = module.exports = function (target) {\n\t\n\tthis.defaultSize = { width: 100, height: 100 };\t\n\twidget.call(this, target);\n\n\tthis.init();\n\t\n}\nutil.inherits(colors, widget);\n\ncolors.prototype.init = function() {\n\n\t/* new tactic */\n\n\tthis.gradient1 = this.context.createLinearGradient(0,0,this.GUI.w,0)\n \tthis.gradient1.addColorStop(0, '#F00'); \n \tthis.gradient1.addColorStop(0.17, '#FF0'); \n \tthis.gradient1.addColorStop(0.34, '#0F0'); \n \tthis.gradient1.addColorStop(0.51, '#0FF'); \n \tthis.gradient1.addColorStop(0.68, '#00F'); \n \tthis.gradient1.addColorStop(0.85, '#F0F'); \n \tthis.gradient1.addColorStop(1, '#F00'); \n\n\tthis.gradient2 = this.context.createLinearGradient(0,0,0,this.GUI.h)\n \tthis.gradient2.addColorStop(0, 'rgba(0,0,0,255)'); \n \tthis.gradient2.addColorStop(0.49, 'rgba(0,0,0,0)'); \n \tthis.gradient2.addColorStop(0.51, 'rgba(255,255,255,0)'); \n \tthis.gradient2.addColorStop(0.95, 'rgba(255,255,255,255)'); \n\n\tthis.draw();\n}\n\ncolors.prototype.draw = function() {\n\tthis.erase();\n\n\twith(this.context) {\n\t\tfillStyle = this.gradient1;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h)\n\t\tfillStyle = this.gradient2;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h)\n\t}\n\n\tthis.drawLabel();\n}\n\ncolors.prototype.drawColor = function() {\n\twith(this.context) {\n\t\tfillStyle = \"rgb(\"+this.val.r+\",\"+this.val.g+\",\"+this.val.b+\")\"\n\t\tfillRect(0,this.GUI.h * 0.95,this.GUI.w,this.GUI.h* 0.05)\n\n\t}\n}\n\ncolors.prototype.click = function(e) {\n\tif (this.clickPos.x > 0 && this.clickPos.y > 0 && this.clickPos.x < this.GUI.w && this.clickPos.y < this.GUI.h) {\n\t\tvar imgData = this.context.getImageData(this.clickPos.x*2,this.clickPos.y*2,1,1);\n\t} else {\n\t\treturn;\n\t}\n\t\n\n\t/** @property {object} val RGB color value at mouse position. <br> This is also the widget's data output (See <a href=\"#nexusui-api-widget-widgetval\">widget.val</a>). <br> Properties:\n\t| | data\n\t| --- | ---\n\t| *r* | red value 0-256\n\t| *g* | green value 0-256\n\t| *b* | blue value 0-256 \n\t```js \n\tcolors1.on('*', function(data) {\n\t\t// some code using data.r, data.g, and data.b\n\t}\n\t```\n\t*/\n\n\tthis.val = {\n\t\tr: imgData.data[0], \n\t\tg: imgData.data[1], \n\t\tb: imgData.data[2]\n\t}\n\tthis.transmit(this.val);\n\tthis.drawColor();\n}\n\n\ncolors.prototype.move = function(e) {\n\tthis.click(e);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/colors.js\n// module id = 23\n// module chunks = 0","var util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class comment \n\tText comment\n\t```html\n\t<canvas nx=\"comment\"></canvas>\n\t```\n\t<canvas nx=\"comment\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar comment = module.exports = function (target) {\n\t\n\tthis.defaultSize = { width: 100, height: 20 };\n\twidget.call(this, target);\n\n\t/** @property {object} val \n\t\t| | data\n\t\t| --- | ---\n\t\t| *text* | text of comment area (as string)\n\t\t```js \n\t\tcomment1.val.text = \"This is my comment\"\n\t\tcomment1.draw()\n\t\t```\n\t*/\n\t\n\tthis.val = {\n\t\ttext: \"comment\"\n\t}\n\tthis.sizeSet = false;\n\n\tthis.init();\n}\nutil.inherits(comment, widget);\n\n/** @method setSize\n\tSet the font size of the comment text\n\t@param {integer} [size] Text size in pixels\n*/\ncomment.prototype.setSize = function(size) {\n\tthis.size = size;\n\tthis.sizeSet = true;\n\tthis.draw();\n}\n\ncomment.prototype.init = function() {\n\tthis.draw();\n}\n\ncomment.prototype.draw = function() {\n\tif (!this.sizeSet) {\n\t\tthis.size = Math.sqrt((this.GUI.w * this.GUI.h) / (this.val.text.length*2));\n\t}\n\n\tthis.erase();\n\twith (this.context) {\n\t\t\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h);\n\t\t\n\t\tfillStyle = this.colors.black;\n\t\ttextAlign = \"left\";\n\t\tfont = this.size+\"px 'Open Sans'\";\n\t}\n\tthis.wrapText(this.val.text, 6, 3+this.size, this.GUI.w-6, this.size);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/comment.js\n// module id = 24\n// module chunks = 0","var math = require('../utils/math')\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class crossfade \n\tCrossfade for panning or mixing\n\t```html\n\t<canvas nx=\"crossfade\"></canvas>\n\t```\n\t<canvas nx=\"crossfade\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar crossfade = module.exports = function (target) {\n\tthis.defaultSize = { width: 100, height: 30 };\n\twidget.call(this, target);\n\n\t/** @property {object} val \n\t\t| | data\n\t\t| --- | ---\n\t\t| *value* | Crossfade value (float -1 to 1)\n\t*/\n\tthis.val = {\n\t\tR: 0.75,\n\t\tL: 0.75\n\t}\n\n\tthis.location = 0.5\n\n\tthis.init();\n}\nutil.inherits(crossfade, widget);\n\ncrossfade.prototype.init = function() {\n\tthis.draw();\n}\n\ncrossfade.prototype.draw = function() {\n\t\n\tthis.erase();\n\n\tthis.location = Math.pow(this.val.R,2)\n\t\t\n\twith (this.context) {\n\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h);\n\n\t\tvar y1 = 0;\n\t\tvar y2 = this.GUI.h;\n\t\tvar x1 = this.location*this.GUI.w;\n\t\t//var x2 = this.GUI.w/5;\n\t\t//\n\t\tfillStyle = this.colors.accent;\n\t\tfillRect(x1,y1,this.GUI.w-x1,y2);\n\n\t\ttextBaseline=\"middle\"\n\t\tfont = this.GUI.h/3 + \"px 'Open Sans'\"\n\n\t\tfillStyle = this.colors.accent;\n\t\ttextAlign=\"right\"\n\t\tfillText(this.val.R.toFixed(2), x1-2, this.GUI.h/4)\n\n\t\tfillStyle = this.colors.fill;\n\t\ttextAlign=\"left\"\n\t\tfillText(this.val.L.toFixed(2), x1+2, this.GUI.h* 0.75)\n\n\n\t}\n\n\tthis.drawLabel()\n\t\n}\n\ncrossfade.prototype.click = function() {\n\tthis.move();\n}\n\ncrossfade.prototype.move = function() {\n\tvar R = math.clip(this.clickPos.x/this.GUI.w,0,1)\n\tvar L = 1 - R\n\tthis.location = R\n\tthis.val.R = math.prune(Math.sqrt(R),3)\n\tthis.val.L = math.prune(Math.sqrt(L),3)\n\tthis.draw();\n\tthis.transmit(this.val);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/crossfade.js\n// module id = 25\n// module chunks = 0","var math = require('../utils/math');\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class dial \n\tCircular dial\n\t```html\n\t<canvas nx=\"dial\"></canvas>\n\t```\n\t<canvas nx=\"dial\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar dial = module.exports = function(target) {\n\t\n\tthis.defaultSize = { width: 100, height: 100 };\n\twidget.call(this, target);\n\t\n\t//define unique attributes\n\tthis.circleSize;\n\tthis.handleLength;\n\n\t/** @property {object} val\n\t | | data\n\t\t| --- | ---\n\t\t| *value* | Current value of dial as float 0-1\n\t*/\n\tthis.val = {\n\t\tvalue: 0\n\t}\n\t/** @property {float} responsivity How much the dial increments on drag. Default: 0.004<br>\n\t*/\n\tthis.responsivity = 0.004;\n\t\n\tthis.aniStart = 0;\n\tthis.aniStop = 1;\n\tthis.aniMove = 0.01;\n\n\tthis.lockResize = true;\n\n if (this.canvas.getAttribute(\"min\")!=null) {\n this.min = parseFloat(this.canvas.getAttribute(\"min\"));\n } else {\n \tthis.min = 0\n }\n if (this.canvas.getAttribute(\"max\")!=null) {\n this.max = parseFloat(this.canvas.getAttribute(\"max\"));\n } else {\n \tthis.max = 1\n }\n if (this.canvas.getAttribute(\"step\")!=null) {\n this.step = parseFloat(this.canvas.getAttribute(\"step\"));\n } else {\n \tthis.step = 0.001\n }\n\n\tthis.maxdigits = 3\n\tthis.calculateDigits = nx.calculateDigits\n\n\tthis.init();\n\t\n}\n\nutil.inherits(dial, widget);\n\ndial.prototype.init = function() {\n\n\tthis.circleSize = (Math.min(this.center.x, this.center.y));\n\tthis.handleLength = this.circleSize;\n\tthis.mindim = Math.min(this.GUI.w,this.GUI.h)\n\t\n\tif (this.mindim<101 || this.mindim<101) {\n\t\tthis.accentWidth = this.lineWidth * 1;\n\t} else {\n\t\tthis.accentWidth = this.lineWidth * 2;\n\t}\n\t\n\tthis.draw();\n\n}\n\ndial.prototype.draw = function() {\n\n\tvar normalval = this.normalize(this.val.value)\n\n\t//var dial_angle = (((1.0 - this.val.value) * 2 * Math.PI) + (1.5 * Math.PI));\n\tvar dial_position = (normalval + 0.25) * 2 * Math.PI\n\t//var point = math.toCartesian(this.handleLength, dial_angle);\n\n\tthis.erase();\n\t\n\twith (this.context) {\n\t\t\n\t\tlineCap = 'butt';\n\t\tbeginPath();\n\t\t\tlineWidth = this.circleSize/2;\n\t\t\tarc(this.center.x, this.center.y, this.circleSize-lineWidth/2, Math.PI * 0, Math.PI * 2, false);\n\t\t\tstrokeStyle = this.colors.fill;\n\t\t\tstroke();\n\t\tclosePath(); \n\n\t\t//draw round accent\n\t\tlineCap = 'butt';\n\t\tbeginPath();\n\t\t\tlineWidth = this.circleSize/2;\n\t\t\tarc(this.center.x, this.center.y, this.circleSize-lineWidth/2, Math.PI * 0.5, dial_position, false);\n\t\t\tstrokeStyle = this.colors.accent;\n\t\t\tstroke();\n\t\tclosePath(); \n\n\t\tclearRect(this.center.x-this.GUI.w/40,this.center.y,this.GUI.w/20,this.GUI.h/2)\n\n\t\tif (normalval > 0) {\n\t\t\tbeginPath();\n\t\t\tlineWidth = 1.5;\n\t\t\tmoveTo(this.center.x-this.GUI.w/40,this.center.y+this.circleSize/2) //this.radius-this.circleSize/4\n\t\t\tlineTo(this.center.x-this.GUI.w/40,this.center.y+this.circleSize) //this.radius+this.circleSize/4\n\t\t\tstrokeStyle = this.colors.accent\n\t\t\tstroke();\n\t\t\tclosePath();\n\t\t}\n\n //figure out text size\n //\n //\n //\n this.val.value = math.prune(this.rangify(normalval),3)\n\t\t\n\n\t\t//var valdigits = this.max ? Math.floor(this.max).toString().length : 1\n\t\t//valdigits += this.step ? this.step < 1 ? 1 : 2 : 2\n\t\tthis.digits = this.calculateDigits()\n\n\t\tvaltextsize = (this.mindim / this.digits.total) * 0.55\n\n\t\tif (valtextsize > 7) {\n\n\t var valtext = this.val.value.toFixed(this.digits.decimals)\n\n\t\t\tfillStyle = this.colors.borderhl\n\t textAlign = \"center\"\n\t textBaseline = \"middle\"\n\t font = valtextsize+\"px 'Open Sans'\"\n\t fillText(valtext,this.GUI.w/2,this.GUI.h/2);\n\n\t }\n\n\t}\n\n\tthis.drawLabel();\n}\n\n\ndial.prototype.click = function(e) {\n\tthis.val.value = math.prune(this.val.value, 4)\n\tthis.transmit(this.val);\n\tthis.draw();\n\tthis.aniStart = this.val.value;\n}\n\n\ndial.prototype.move = function() {\t\n\tvar normalval = this.normalize(this.val.value)\n\tnormalval = math.clip((normalval - (this.deltaMove.y * this.responsivity)), 0, 1);\n\tthis.val.value = math.prune(this.rangify(normalval), 4)\n\tthis.transmit(this.val);\n\t\n\tthis.draw();\n}\n\n\ndial.prototype.release = function() {\n\tthis.aniStop = this.val.value;\n}\n\n/** @method animate \n\tAnimates the dial\n\t@param {string} [type] Type of animation. Currently accepts \"bounce\" (bounces between mousedown and mouserelease points) or \"none\" */\ndial.prototype.animate = function(aniType) {\n\t\n\tswitch (aniType) {\n\t\tcase \"bounce\":\n\t\t\tnx.aniItems.push(this.aniBounce.bind(this));\n\t\t\tbreak;\n\t\tcase \"none\":\n\t\t\tnx.aniItems.splice(nx.aniItems.indexOf(this.aniBounce));\n\t\t\tbreak;\n\t}\n\t\n}\n\ndial.prototype.aniBounce = function() {\n\tif (!this.clicked) {\n\t\tthis.val.value += this.aniMove;\n\t\tif (this.aniStop < this.aniStart) {\n\t\t\tthis.stopPlaceholder = this.aniStop;\n\t\t\tthis.aniStop = this.aniStart;\n\t\t\tthis.aniStart = this.stopPlaceholder;\n\t\t}\n\t\tthis.aniMove = math.bounce(this.val.value, this.aniStart, this.aniStop, this.aniMove);\t\n\t\tthis.draw();\n\t\tthis.val.value = math.prune(this.val.value, 4)\n\t\tthis.transmit(this.val);\n\t}\n}\n\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/dial.js\n// module id = 26\n// module chunks = 0","var startTime = 0;\n\nvar math = require('../utils/math')\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class envelope \n\tMulti-point line ramp generator\n\t```html\n\t<canvas nx=\"envelope\"></canvas>\n\t```\n\t<canvas nx=\"envelope\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar envelope = module.exports = function (target) {\n\tthis.defaultSize = { width: 200, height: 100 };\n\twidget.call(this, target);\n\t\n\tthis.nodeSize = 1;\n\t/** @property {boolean} active Whether or not the envelope is currently animating. */\n\tthis.active = false;\n\t/** @property {integer} duration The envelope's duration in ms. */\n\tthis.duration = 1000; // 1000 ms\n\t/** @property {boolean} looping Whether or not the envelope loops. */\n\tthis.looping = false\n\n\n\tthis.scanIndex = 0\n\n\t//define unique attributes\n\t\n\t/** @property {object} val \n\t\t| | data\n\t\t| --- | ---\n\t\t| *amp* | amplitude at current point of ramp (float 0-1)\n\t\t| *index* | current progress through ramp (float 0-1)\n\t\t| *points* | array containing x/y coordinates of each node.\n\t*/\n\n\tthis.val = {\n\t\tindex: 0,\n\t\tamp: 0,\n\t\tpoints: [\n\t\t\t{\n\t\t\t\tx: 0.1,\n\t\t\t\ty: 0.4\n\t\t\t},\n\t\t\t{\n\t\t\t\tx: 0.35,\n\t\t\t\ty: 0.6\n\t\t\t},\n\t\t\t{\n\t\t\t\tx: 0.65,\n\t\t\t\ty: 0.2\n\t\t\t},\n\t\t\t{\n\t\t\t\tx: 0.9,\n\t\t\t\ty: 0.4\n\t\t\t}\n\t\t]\n\t}\n\n\t// Index of which node was clicked\n\tthis.selectedNode = null;\n\n\tnx.aniItems.push(this.pulse.bind(this));\n\n\tthis.init();\n}\n\nutil.inherits(envelope, widget);\n\nenvelope.prototype.init = function() {\n\tthis.mindim = this.GUI.w < this.GUI.h ? this.GUI.w : this.GUI.h;\n\tthis.draw();\n}\n\nenvelope.prototype.draw = function() {\n\tthis.erase();\n\twith (this.context) {\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h);\n\t\tfillStyle = this.colors.accent;\n\t\tvar centerx = this.mindim/10\n\t\tvar centery = this.GUI.h-this.mindim/10\n\t\tbeginPath()\n\t\t\tmoveTo(centerx,centery)\n\t\t\tarc(centerx,centery,this.mindim/10,Math.PI*1.5,Math.PI*2*this.val.index+Math.PI*1.5,false);\n\t\t\tfill()\n\t\tclosePath()\n\n\t\t// draw all the points\n\t\tvar drawingX = [];\n\t\tvar drawingY = [];\n\n\t\tfor (var i = 0; i < this.val.points.length; i++) {\n\t\t\tdrawingX[i] = this.val.points[i].x * this.GUI.w;\n\t\t\tdrawingY[i] = (1 - this.val.points[i].y) * this.GUI.h;\n\n\t\t\t//stay within right/left bounds\n\t\t\tif (drawingX[i]<(this.bgLeft+this.nodeSize)) {\n\t\t\t\tdrawingX[i] = this.bgLeft + this.nodeSize;\n\t\t\t} else if (drawingX[i]>(this.bgRight-this.nodeSize)) {\n\t\t\t\tdrawingX[i] = this.bgRight - this.nodeSize;\n\t\t\t}\n\t\t\t//stay within top/bottom bounds\n\t\t\tif (drawingY[i]<(this.bgTop+this.nodeSize)) {\n\t\t\t\tdrawingY[i] = this.bgTop + this.nodeSize;\n\t\t\t} else if (drawingY[i]>(this.bgBottom-this.nodeSize)) {\n\t\t\t\tdrawingY[i] = this.bgBottom - this.nodeSize;\n\t\t\t}\n\t\t}\n\n\t\t// draw rectangles\n\t\tfor (var j = 0; j < drawingX.length; j++) {\n\t\t\tvar size = this.mindim/35 + 2;\n\t\t\tbeginPath()\n\t\t\tarc(drawingX[j],drawingY[j],size,0,Math.PI*2,false);\n\t\t\tfillStyle = this.colors.accent\n\t\t\tfill()\n\t\t\tclosePath()\n\t\t}\n\n\n\t\t// draw shape\n\t\tbeginPath();\n\t\t\tstrokeStyle = this.colors.accent;\n\t\t\tmoveTo(-5,this.GUI.h);\n\t\t\tlineTo(-5,(1-this.val.points[0].y)*this.GUI.h);\n\n\t\t\t// draw each line\n\t\t\tfor (var j = 0; j < drawingX.length; j++) {\n\t\t\t\tlineTo(drawingX[j],drawingY[j]);\n\t\t\t}\n\n\t\t\tlineTo(this.GUI.w+5,(1-this.val.points[this.val.points.length-1].y)*this.GUI.h);\n\t\t\tlineTo(this.GUI.w+5,this.GUI.h);\n\t\t\tstroke();\n\t\t\tglobalAlpha = 0.2;\n\t\t\tfillStyle = this.colors.accent;\n\t\t\tfill();\n\t\t\tglobalAlpha = 1\n\t\tclosePath();\n\t\n\n\n\t}\n\t\n\tthis.drawLabel();\n}\n\nenvelope.prototype.scaleNode = function(nodeIndex) {\n\tvar i = nodeIndex;\n\tvar prevX = 0;\n\tvar nextX = this.GUI.w;\n\t\n\tvar actualX = this.val.points[i].x;\n\tvar actualY = (this.GUI.h - this.val.points[i].y);\n\tvar clippedX = math.clip(actualX/this.GUI.w, 0, 1);\n\tvar clippedY = math.clip(actualY/this.GUI.h, 0, 1);\n\n\tthis.val.points[i].x = math.prune(clippedX, 3);\n\tthis.val.points[i].y = math.prune(clippedY, 3);\n\n\t// find x value of nodes to the right and left\n\tif (i > 0) {\n\t\tprevX = this.val.points[i-1].x;\n\t}\n\tif (this.val.points.length > i+1) {\n\t\tnextX = this.val.points[i+1].x;\n\t}\n\n\tif (this.val.points[i].x < prevX) {\n\t\tthis.val.points.splice(i-1, 0, this.val.points.splice(i, 1)[0])\n\t\ti = i-1;\n\t\tthis.selectedNode = i;\n\t}\n\n\tif (this.val.points[i].x > nextX) {\n\t\tthis.val.points.splice(i+1, 0, this.val.points.splice(i, 1)[0])\n\t\ti = i+1;\n\t\tthis.selectedNode = i;\n\t}\n\n}\n\nenvelope.prototype.click = function() {\n\n\t// find nearest node and set this.selectedNode (index)\n\tthis.selectedNode = this.findNearestNode(this.clickPos.x/this.GUI.w, this.clickPos.y/this.GUI.h, this.val.points);\n\n\tthis.transmit(this.val);\n\tthis.draw();\n}\n\nenvelope.prototype.move = function() {\n\tif (this.clicked) {\n\t\tthis.val.points[this.selectedNode].x = this.clickPos.x;\n\t\tthis.val.points[this.selectedNode].y = this.clickPos.y;\n\t\tthis.scaleNode(this.selectedNode);\n\t\tthis.transmit(this.val);\n\t\tthis.draw();\n\t}\n}\n\nenvelope.prototype.release = function() {\n\n\tif (!this.hasMoved) {\n\t\tthis.val.points.splice(this.selectedNode,1)\n\t}\n\n\tthis.draw();\n\n\t// reset the this.selectedNode\n\tthis.selectedNode = null;\n}\n\n// update index and amp\nenvelope.prototype.pulse = function() {\n\tif (this.active) {\n\n\t\t// calculate index based on audio context\n\t\tvar percentDone = (nx.context.currentTime - startTime) / (this.duration/1000);\n\t\tif (percentDone >= 1) {\n\t\t\tif (this.looping) {\n\t\t\t\tpercentDone -= 1;\n\t\t\t\tstartTime += this.duration/1000;\n\t\t\t\tthis.val.index = 0\n\t\t\t\tthis.scanIndex = 0\n\t\t\t} else {\n\t\t\t\tthis.stop();\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tthis.val.index = percentDone;\n\t\n\t\tif (this.val.index > this.val.points[this.val.points.length-1].x) {\n\t\t\tthis.val.amp = this.val.points[this.val.points.length-1].y\n\t\t} else if (this.val.index < this.val.points[0].x) {\n\t\t\tthis.val.amp = this.val.points[0].y\n\t\t} else {\t\t\t\t\n\t\t\tthis.scanIndex = 0;\n\t\t\twhile (this.val.index > this.val.points[this.scanIndex].x) {\n\t\t\t\tthis.scanIndex++;\n\t\t\t}\n\n\t\t\tvar nextPX = this.val.points[this.scanIndex].x;\n\t\t\tvar prevPX = this.val.points[this.scanIndex-1].x;\n\t\t\tvar nextPY = this.val.points[this.scanIndex].y;\n\t\t\tvar prevPY = this.val.points[this.scanIndex-1].y;\n\t\t\n\t\t\tthis.val.amp = math.interp((this.val.index-prevPX)/(nextPX - prevPX),prevPY,nextPY);\n\n\t\t}\n\t\n\t\tthis.transmit(this.val);\n\t\tthis.draw();\n\t}\n}\n\n/** @method start\n\tStart ramp from beginning. If set to loop, will loop the ramp until stopped. */\nenvelope.prototype.start = function() {\n\tthis.active = true;\n\tthis.val.index = 0;\n\t\n\t// set startTime\n\tstartTime = nx.context.currentTime;\n}\n\n/** @method stop\n\tStop the ramp and set progress to 0. */\nenvelope.prototype.stop = function() {\n\tthis.active = false;\n\tthis.val.index = 0;\n\tthis.draw();\n}\n\nenvelope.prototype.findNearestNode = function(x, y, nodes) {\n\tvar nearestIndex = null;\n\tvar nearestDist = 1000;\n\tvar before = false;\n\ty = 1 - y;\n\tfor (var i = 0; i<nodes.length; i++) {\n\t\tvar distance = Math.sqrt( Math.pow( (nodes[i].x - x), 2), Math.pow((nodes[i].y - (-y)), 2) );\n\n\t\tif (distance < nearestDist) {\n\t\t\tnearestDist = distance;\n\t\t\tnearestIndex = i;\n\t\t\tbefore = x > nodes[i].x\n\t\t}\n\t}\n\n\tif (nearestDist>.1) {\n\t\tif (before) { nearestIndex++ }\n\t\tthis.val.points.splice(nearestIndex,0,{\n\t\t\tx: this.clickPos.x/this.GUI.w,\n\t\t\ty: (this.GUI.h-this.clickPos.y)/this.GUI.h\n\t\t})\n\t\t//nearestIndex++;\n\t}\n\n\treturn nearestIndex;\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/envelope.js\n// module id = 27\n// module chunks = 0","module.exports = {\n banner: require('./banner'),\n button: require('./button'),\n colors: require('./colors'),\n comment: require('./comment'),\n crossfade: require('./crossfade'),\n dial: require('./dial'),\n envelope: require('./envelope'),\n joints: require('./joints'),\n keyboard: require('./keyboard'),\n matrix: require('./matrix'),\n message: require('./message'),\n meter: require('./meter'),\n metro: require('./metro'),\n motion: require('./motion'),\n mouse: require('./mouse'),\n multislider: require('./multislider'),\n multitouch: require('./multitouch'),\n number: require('./number'),\n position: require('./position'),\n range: require('./range'),\n select: require('./select'),\n slider: require('./slider'),\n string: require('./string'),\n tabs: require('./tabs'),\n text: require('./text'),\n tilt: require('./tilt'),\n toggle: require('./toggle'),\n typewriter: require('./typewriter'),\n vinyl: require('./vinyl'),\n waveform: require('./waveform'),\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/index.js\n// module id = 28\n// module chunks = 0","var math = require('../utils/math')\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class joints \n\t2D slider with connections to several points; a proximity-based multislider.\n\t```html\n\t<canvas nx=\"joints\"></canvas>\n\t```\n\t<canvas nx=\"joints\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar joints = module.exports = function (target) {\n\tthis.defaultSize = { width: 150, height: 150 };\n\twidget.call(this, target);\n\t\n\t/* @property {integer} nodeSize The size of the proximity points in pixels */\n\tthis.nodeSize = this.GUI.w/14; \n\tthis.values = [0,0];\n\n\t/** @property {object} val \n\t\t| | data\n\t\t| --- | ---\n\t\t| *x* | x position of touch/mouse\n\t\t| *y* | y position of touch/mouse\n\t\t| *node0* | nearness to first node if within range (float 0-1)\n\t\t| *node1* | nearness to second node if within range (float 0-1)\n\t\t| *node2* | nearness to third node if within range (float 0-1)\n\t\t| etc... | \n\t\t\n\t*/\n\tthis.val = {\n\t\tx: 0.35,\n\t\ty: 0.35,\n\t\tnode1: 0\n\t}\n\t/** @property {array} joints An array of objects with x and y properties detailing coordinates of each proximity node. Coordinates are 0-1 floats which are decimal fractions of the width and height.\n\t```js\n\t\t// The widget will now have 2 proximity points instead of 8\n\t\tjoints1.joints = [\n\t\t { x: 0.5 , y: 0.2 },\n\t\t { x: 0.5 , y: 0.7 }\n\t\t]\n\t```\n\t */\n\tthis.joints = [\n\t\t{ x: .1, y: .2 },\n\t { x: .2, y: .1 },\n\t { x: .3, y: .7 },\n\t { x: .4, y: .4 },\n\t { x: .5, y: .9 },\n\t { x: .6, y: .15 },\n\t { x: .7, y: .3 },\n\t { x: .8, y: .8 },\n\t]\n\tthis.threshold = this.GUI.w / 3;\n}\nutil.inherits(joints, widget);\n\njoints.prototype.init = function() {\n this.nodeSize = this.GUI.w/14;\n this.threshold = this.GUI.w/3;\n this.draw();\n}\n\njoints.prototype.draw = function() {\n\tthis.erase();\n\n\tthis.drawingX = this.val.x * this.GUI.w;\n\tthis.drawingY = this.val.y * this.GUI.h;\n\n\twith (this.context) {\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h);\n\t\tif (this.val.x != null) {\n\t\t\tthis.drawNode();\n\t\t}\n\t\telse {\n\t\t\tfillStyle = this.colors.border;\n\t\t\tfont = \"14px courier\";\n\t\t\tfillText(this.default_text, 10, 20);\n\t\t}\t\n\t\tfillStyle = this.colors.accent;\n\t\tstrokeStyle = this.colors.border;\n\t\tfor (var i in this.joints) {\n\t\t\tbeginPath();\n\t\t\t\tarc(this.joints[i].x*this.GUI.w, this.joints[i].y*this.GUI.h, this.nodeSize/2, 0, Math.PI*2, true);\t\t\t\t\t\n\t\t\t\tfill();\n\t\t\tclosePath();\n\t\t\tvar cnctX = Math.abs(this.joints[i].x*this.GUI.w-this.drawingX);\n\t\t\tvar cnctY = Math.abs(this.joints[i].y*this.GUI.h-this.drawingY);\n\t\t\tvar strength = cnctX + cnctY;\n\t\t\tif (strength < this.threshold) {\n\t\t\t\tbeginPath();\n\t\t\t\t\tmoveTo(this.joints[i].x*this.GUI.w, this.joints[i].y*this.GUI.h);\n\t\t\t\t\tlineTo(this.drawingX,this.drawingY);\n\t\t\t\t\tstrokeStyle = this.colors.accent;\n\t\t\t\t\tlineWidth = math.scale( strength, 0, this.threshold, this.nodeSize/2, 5 );\n\t\t\t\t\tstroke();\n\t\t\t\tclosePath();\n\t\t\t\tvar scaledstrength = math.scale( strength, 0, this.threshold, 1, 0 );\n\t\t\t\tthis.val[\"node\"+i] = scaledstrength;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tthis.drawLabel();\n}\n\njoints.prototype.drawNode = function() {\n\t//stay within right/left bounds\n\tif (this.drawingX<(this.nodeSize)) {\n\t\tthis.drawingX = this.nodeSize;\n\t} else if (this.drawingX>(this.GUI.w-this.nodeSize)) {\n\t\tthis.drawingX = this.GUI.w - this.nodeSize;\n\t}\n\t//stay within top/bottom bounds\n\tif (this.drawingY < this.nodeSize) {\n\t\tthis.drawingY = this.nodeSize;\n\t} else if (this.drawingY>(this.GUI.h-this.nodeSize)) {\n\t\tthis.drawingY = this.GUI.h - this.nodeSize;\n\t}\n\n\twith (this.context) {\n\t\tglobalAlpha=1;\n\t\tbeginPath();\n\t\t\tfillStyle = this.colors.accent;\n\t\t\tstrokeStyle = this.colors.border;\n\t\t\tlineWidth = this.lineWidth;\n\t\t\tarc(this.drawingX, this.drawingY, this.nodeSize, 0, Math.PI*2, true);\t\t\t\t\t\n\t\t\tfill();\n\t\tclosePath();\n\t}\n}\n\njoints.prototype.click = function() {\n\tthis.val = new Object();\n\tthis.val.x = this.clickPos.x/this.GUI.w;\n\tthis.val.y = this.clickPos.y/this.GUI.h;\n\tthis.draw();\n\tthis.transmit(this.val);\n\tthis.connections = new Array();\n \n}\n\njoints.prototype.move = function() {\n\tthis.val = new Object();\n\tif (this.clicked) {\n\t\tthis.val.x = this.clickPos.x/this.GUI.w;\n\t\tthis.val.y = this.clickPos.y/this.GUI.h;\n\t\tthis.draw();\n\t\tthis.transmit(this.val);\n\t\tthis.connections = new Array();\n\t}\n}\n\n\njoints.prototype.release = function() {\n\t\tthis.anix = this.deltaMove.x/this.GUI.w;\n\t\tthis.aniy = (this.deltaMove.y)/this.GUI.h;\n\t\n}\n\n/** @method animate\n\tAdd simple physics to the widget\n\t@param {string} [type] Currently accepts \"bounce\" or \"none\".\n*/\n\njoints.prototype.animate = function(aniType) {\n\t\n\tswitch (aniType) {\n\t\tcase \"bounce\":\n\t\t\tnx.aniItems.push(this.aniBounce.bind(this));\n\t\t\tbreak;\n\t\tcase \"none\":\n\t\t\tnx.aniItems.splice(nx.aniItems.indexOf(this.aniBounce));\n\t\t\tbreak;\n\t}\n\t\n}\n\njoints.prototype.anix = 0;\njoints.prototype.aniy = 0;\n\njoints.prototype.aniBounce = function() {\n\tif (!this.clicked && this.val.x) {\n\t\tthis.val.x += (this.anix);\n\t\tthis.val.y += (this.aniy);\n\t\tthis.anix = math.bounce(this.val.x, 0.1, 0.9, this.anix);\n\t\tthis.aniy = math.bounce(this.val.y, 0.1, 0.9, this.aniy);\n\t\tthis.draw();\n\t\tthis.transmit(this.val);\n\t}\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/joints.js\n// module id = 29\n// module chunks = 0","var util = require('util');\nvar widget = require('../core/widget');\nvar drawing = require('../utils/drawing');\nvar math = require('../utils/math');\n\n/** \n\t@class keyboard \n\tPiano keyboard which outputs MIDI\n\t```html\n\t<canvas nx=\"keyboard\"></canvas>\n\t```\n\t<canvas nx=\"keyboard\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar keyboard = module.exports = function (target) {\n\n\tthis.defaultSize = { width: 300, height: 75 };\n\twidget.call(this, target);\n\n\t/** @property {integer} octaves Number of octaves on the keyboard \n\t\t```js\n\t\t\t//This key pattern would put a black key between every white key\n\t\t\tkeyboard1.octaves = 1\n\t\t\tkeyboard1.init()\n\t\t```\n\n\t*/\n\t\n\tthis.octaves = 3;\n\n\tthis.white = {\n\t\twidth:0,\n\t\theight:0\n\t}\n\tthis.black = {\n\t\twidth:0,\n\t\theight:0\n\t}\n\tthis.wkeys = new Array();\n\tthis.bkeys = new Array();\n\n\t/** @property {array} keypattern Array of 'w' and 'b' denoting the pattern of white and black keys. This can be customized! The pattern can be any number of keys, however each black key must be surrounded by two white keys.\n\t```js\n\t\t//This key pattern would put a black key between every white key\n\t\tkeyboard1.keypattern = ['w','b','w','b','w','b','w','b','w','b','w','b']\n\t\tkeyboard1.init()\n\n\t\t//This key pattern uses only white keys\n\t\tkeyboard2.keypattern = ['w','w','w','w','w','w','w','w','w','w','w','w']\n\t\tkeyboard2.init()\n\t```\n\n\n\t */\n\tthis.keypattern = ['w','b','w','b','w','w','b','w','b','w','b','w']\n\tthis.keys = new Array();\n\t/** @property {integer} midibase The MIDI note value of the lowest note on the keyboard. Defaults to 48. */\n\tthis.midibase = 48;\n\tthis.lineWidth = 1;\n\n\t//to enable multitouch\n\tthis.fingers = [\n\t\t{ \n\t\t\tkey: -1,\n\t\t\tpkey: -1\n\n\t\t}\n\t]\n\tthis.multitouch = false; // will auto switch to true if experiences 2 simultaneous touches\n\tthis.oneleft = false;\n\n\t/** @property {string} mode Play mode. Currently accepts \"button\" (default) or \"sustain\" in which each key acts as a toggle. */\t\n\tthis.mode = \"button\" // modes: \"button\", \"sustain\" and, possibly in future, \"aftertouch\"\n\n\t// for each key: x, y, w, h, color, on, note\n\n\t/** @property {object} val Core interactive values and data output\n\t\t| | data\n\t\t| --- | ---\n\t\t| *on* | 0 if noteon, 1 if noteoff\n\t\t| *note* | MIDI value of key pressed\n\t\t| *midi* | paired MIDI message as a string - example \"20 0\" - This is to allow for simultaneous arrival of the MIDI pair if sent as an OSC message. \n\t*/\n\tthis.val = {\n\t\ton: 0,\n\t\tnote: 0,\n\t\tmidi: \"0 0\"\n\t};\n\n\tthis.init();\n\t\n}\nutil.inherits(keyboard, widget);\n\nkeyboard.prototype.init = function() {\n\n\t//recap from header\n\tthis.white = {\n\t\twidth:0,\n\t\theight:0\n\t}\n\tthis.black = {\n\t\twidth:0,\n\t\theight:0\n\t}\n\tthis.wkeys = new Array();\n\tthis.bkeys = new Array();\n\n\t/** @property {array} keys Array of key objects. This may be of use in combination with the keyboard.toggle method. */\n\tthis.keys = new Array();\n\n\t//new stuff\n\tthis.white.num = 0;\n\tfor (var i=0;i<this.keypattern.length;i++) {\n\t\tthis.keypattern[i]=='w' ? this.white.num++ : null;\n\t}\n\tthis.white.num *= this.octaves;\n\n\tthis.white.width = this.GUI.w/this.white.num\n\tthis.white.height = this.GUI.h\n\n\tthis.black.width = this.white.width*0.6\n\tthis.black.height = this.GUI.h*0.6\n\n\tfor (var i=0;i<this.keypattern.length*this.octaves;i++) {\n\t\tthis.keys[i] = {\n\t\t\tnote: i+this.midibase,\n\t\t\ton: false\n\t\t}\n\t\tswitch (this.keypattern[i%this.keypattern.length]) {\n\t\t\tcase 'w':\n\t\t\t\tthis.keys[i].x = this.wkeys.length*this.white.width,\n\t\t\t\tthis.keys[i].y = 0,\n\t\t\t\tthis.keys[i].w = this.white.width,\n\t\t\t\tthis.keys[i].h = this.white.height,\n\t\t\t\tthis.keys[i].type = 'w';\n\t\t\t\tthis.keys[i].index = i;\n\t\t\t\tthis.wkeys.push(this.keys[i]);\n\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\t\tthis.keys[i].x = this.wkeys.length*this.white.width - this.black.width/2,\n\t\t\t\tthis.keys[i].y = 0,\n\t\t\t\tthis.keys[i].w = this.black.width,\n\t\t\t\tthis.keys[i].h = this.black.height,\n\t\t\t\tthis.keys[i].type = 'b';\n\t\t\t\tthis.keys[i].index = i;\n\t\t\t\tthis.bkeys.push(this.keys[i]);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\n\tthis.draw();\n}\n\nkeyboard.prototype.draw = function() {\n\n\twith (this.context) {\n\t\tstrokeStyle = this.colors.borderhl;\n\t\tlineWidth = 1;\n\t\t\t\n\t\tfor (var i in this.wkeys) {\n\t\t\tfillStyle = this.wkeys[i].on ? this.colors.borderhl : this.colors.fill\n\t\t\tstrokeRect(this.wkeys[i].x,0,this.white.width,this.white.height);\n\t\t\tfillRect(this.wkeys[i].x,0,this.white.width,this.white.height);\n\t\t}\n\t\tfor (var i in this.bkeys) {\n\t\t\tfillStyle = this.bkeys[i].on ? this.colors.borderhl : this.colors.black\n\t\t\tfillRect(this.bkeys[i].x,0,this.black.width,this.black.height);\n\t\t}\n\t\t//strokeRect(0,0,this.GUI.w,this.GUI.h);\n\t}\n\tthis.drawLabel();\n}\n\n/** @method toggle\n\tManually toggle a key on or off, and transmit the new state.\n\t@param {object} [key] A key object (from the .keys array) to be turned on or off\n\t@param {boolean} [on/off] (Optional) Whether the key should be turned on (true) or off (false). If this parameter is left out, the key will switch to its opposite state.\n\t```js\n\t// Turns the first key on\n\tkeyboard1.toggle( keyboard1.keys[0], true );\n\t```\n*/\nkeyboard.prototype.toggle = function(key, data) {\n\tif (this.mode==\"button\") {\n\t\tif (key) {\n\t\t\tif (data || data===false) {\n\t\t\t\tkey.on = data;\n\t\t\t} else {\n\t\t\t\tkey.on = !key.on;\n\t\t\t}\n\n\t\t\tvar on = key.on ? 1 : 0;\n\t\t\tvar amp = math.invert(this.clickPos.y/this.GUI.h) * 128;\n\t\t\tamp = math.prune(math.clip(amp,5,128),0);\n\n\t\t\tthis.val = { \n\t\t\t\ton: on*amp,\n\t\t\t\tnote: key.note,\n\t\t\t\tmidi: key.note + \" \" + on\n\t\t\t};\n\t\t\tthis.transmit(this.val);\n\t\t\tthis.draw();\n\t\t}\n\t} else if (this.mode==\"sustain\") {\n\t\tif (key) {\n\t\t\tif (data) {\n\t\t\t\tkey.on = data;\n\t\t\t} else {\n\t\t\t\tkey.on = !key.on;\n\t\t\t}\n\n\t\t\tvar on = key.on ? 1 : 0;\n\t\t\tvar amp = math.invert(this.clickPos.y/this.GUI.h) * 128;\n\t\t\tamp = math.prune(math.clip(amp,5,128),0);\n\n\t\t\tthis.val = { \n\t\t\t\ton: on*amp,\n\t\t\t\tnote: key.note,\n\t\t\t\tmidi: key.note + \" \" + on\n\t\t\t};\n\t\t\tthis.transmit(this.val);\n\t\t\tthis.draw();\n\t\t}\n\n\t}\n\n}\n\nkeyboard.prototype.whichKey = function (x, y){\n\n\tfor (var i in this.bkeys) {\n\t\tif (drawing.isInside({\"x\":x,\"y\":y}, this.bkeys[i])) {\n\t\t\treturn this.bkeys[i]\n\t\t}\n\t}\n\n\tvar keyx = ~~(x/this.white.width);\n\tif (keyx>=this.wkeys.length) { keyx = this.wkeys.length-1 }\n\tif (keyx<0) { keyx = 0 }\n\treturn this.wkeys[keyx];\n}\n\nkeyboard.prototype.click = function(e) {\n\n\tif (this.clickPos.touches.length>1 || this.multitouch) {\n\t\tthis.multitouch = true;\n\t\tif (this.clickPos.touches.length>=2 && this.oneleft) {\n\t\t\tthis.oneleft = false;\n\t\t}\n\t\tthis.keysinuse = new Array();\n\t\tfor (var j=0;j<this.clickPos.touches.length;j++) {\n\t\t\tthis.fingers[j] = {\n\t\t\t\tkey: this.whichKey(this.clickPos.touches[j].x, this.clickPos.touches[j].y)\n\t\t\t}\n\t\t\tif (!this.fingers[j].key.on) {\n\t\t\t\tthis.toggle(this.fingers[j].key, true)\n\t\t\t}\n\t\t\tthis.keysinuse.push(this.fingers[j].key.index)\n\t\t}\n\t\tfor (var j=0;j<this.keys.length;j++) {\n\t\t\tif (this.keys[j].on && this.keysinuse.indexOf(this.keys[j].index)<0) {\n\t\t\t\tthis.toggle(this.keys[j], false);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tthis.fingers[0].pkey = this.fingers[0].key;\n\t\tthis.fingers[0].key = this.whichKey(this.clickPos.x, this.clickPos.y);\n\t\tthis.toggle(this.fingers[0].key)\n\t}\n\n}\n\nkeyboard.prototype.move = function(e) {\n\tif (this.clickPos.touches.length>1 || this.multitouch) {\n\t\tthis.keysinuse = new Array();\n\t\tfor (var j=0;j<this.clickPos.touches.length;j++) {\n\t\t\tthis.fingers[j] = {\n\t\t\t\tkey: this.whichKey(this.clickPos.touches[j].x, this.clickPos.touches[j].y)\n\t\t\t}\n\t\t\tif (!this.fingers[j].key.on) {\n\t\t\t\tthis.toggle(this.fingers[j].key, true)\n\t\t\t}\n\t\t\tthis.keysinuse.push(this.fingers[j].key.index)\n\t\t}\n\t\tfor (var j=0;j<this.keys.length;j++) {\n\t\t\tif (this.keys[j].on && this.keysinuse.indexOf(this.keys[j].index)<0) {\n\t\t\t\tthis.toggle(this.keys[j], false);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tthis.fingers[0].pkey = this.fingers[0].key;\n\t\tthis.fingers[0].key = this.whichKey(this.clickPos.x, this.clickPos.y);\n\t\tif (this.fingers[0].key && this.fingers[0].key.index != this.fingers[0].pkey.index) {\n\t\t\tthis.toggle(this.fingers[0].pkey, false);\n\t\t\tthis.toggle(this.fingers[0].key, true);\n\t\t}\n\t}\n}\n\nkeyboard.prototype.release = function(e) {\n\tif (this.clickPos.touches.length>1 || this.multitouch) {\n\t\tthis.keysinuse = new Array();\n\t\tfor (var j=0;j<this.clickPos.touches.length;j++) { \n\t\t\tif (this.oneleft && this.clickPos.touches.length==1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tthis.fingers[j] = {\n\t\t\t\tkey: this.whichKey(this.clickPos.touches[j].x, this.clickPos.touches[j].y)\n\t\t\t}\n\t\t\tthis.keysinuse.push(this.fingers[j].key.index)\n\t\t}\n\t\tfor (var j=0;j<this.keys.length;j++) {\n\t\t\tif (this.keys[j].on && this.keysinuse.indexOf(this.keys[j].index)<0) {\n\t\t\t\tthis.toggle(this.keys[j], false);\n\t\t\t}\n\t\t}\n\t\tif (this.clickPos.touches.length==1) { this.oneleft = true }\n\t} else {\n\t\tif (this.mode==\"button\") {\n\t\t\tthis.toggle(this.fingers[0].key, false);\n\t\t}\n\t}\n}\n\n\n\n\n\n\n\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/keyboard.js\n// module id = 30\n// module chunks = 0","var math = require('../utils/math');\nvar drawing = require('../utils/drawing');\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class matrix \n\tMatrix of toggles, with sequencer functionality.\n\t```html\n\t<canvas nx=\"matrix\"></canvas>\n\t```\n\t<canvas nx=\"matrix\" style=\"margin-left:25px\"></canvas>\n*/\n\n\nvar matrix = module.exports = function (target) {\n\tthis.defaultSize = { width: 100, height: 100 };\n\twidget.call(this, target);\n\t\n\n\t/** @property {integer} row Number of rows in the matrix\n\t```js\n\t\tmatrix1.row = 2;\n\t\tmatrix1.init()\n\t```\n\t*/\n\tthis.row = 4;\n\n\t/** @property {integer} col Number of columns in the matrix\n\t```js\n\t\tmatrix1.col = 10;\n\t\tmatrix1.init()\n\t```\n\t*/\n\tthis.col = 4;\n\t\n\tthis.cellHgt;\n\tthis.cellWid;\n\n\t/** @property {array} matrix Nested array of matrix values. Cells can be manually altered using .matrix (see code), however this will *not* cause the new value to be transmit. See .setCell() to set/transmit cell values.\n\t```js\n\t\t//Turn on the cell at row 1 column 2\n\t\tmatrix1.matrix[1][2] = 1\n\t\tmatrix1.draw()\n\n\n\t\t//Turn off the cell at row 3 column 0\n\t\tmatrix1.matrix[3][0] = 0\n\t\tmatrix1.draw()\n\t```\n\t*/\n\tthis.matrix;\n\n\t/** @property {object} val Core values and data output\n\t\t| | data\n\t\t| --- | ---\n\t\t| *row* | Current row being changed\n\t\t| *col* | Current column being changed\n\t\t| *level* | Whether cell is on or off (0 or 1)\n\t\t| *list * | Array of values in highlighted column (if sequencing)\n\t*/\n\tthis.val = {\n\t\trow: 0,\n\t\tcol: 0,\n\t\tlevel: 0,\n\t\tlist: new Array()\n\t}\n\n\t//for mouse logic\n\tthis.cur;\n\tthis.prev;\n\n\t/** @property {boolean} erasing Whether or not mouse clicks will erase cells. Set to true automatically if you click on an \"on\" cell. */\n\tthis.erasing = false;\n\n\t/** @property {integer} place When sequencing, the current column. */\n\tthis.place = null;\n\n\tthis.starttime;\n\tthis.lastbeat;\n\tthis.thisframe = 0;\n\tthis.lastframe = 0;\n\tthis.context.lineWidth = 1;\n\n\tthis.sequencing = false;\n\n\t/** @property {integer} cellBuffer How much padding between matrix cells, in pixels */\n\tthis.cellBuffer = 4;\n\t\n\t/** @property {string} sequenceMode Sequence pattern (currently accepts \"linear\" which is default, or \"random\") */\n\tthis.sequenceMode = \"linear\"; // \"linear\" or \"random\". future options would be \"wander\" (drunk) or \"markov\"\n\n\t/** @property {integer} bpm Beats per minute (if sequencing)\n\t```js\n\t\tmatrix1.bpm = 120;\n\t```\n\t*/\n\tthis.bpm = 120;\n\tthis.pbpm = this.bpm\n\n\tthis.starttime = nx.starttime;\n\n\tthis.init();\n\t\n}\nutil.inherits(matrix, widget);\n\n\n\nmatrix.prototype.init = function() {\n\n\n\tthis.pmatrix = this.matrix ? this.matrix : false;\n\n\tthis.matrix = null;\n\t// generate 2D matrix array\n\tthis.matrix = new Array(this.col)\n\tfor (var i=0;i<this.col;i++) {\n\t\tthis.matrix[i] = new Array(this.row)\n\t\tfor (var j=0;j<this.row;j++) {\n\t\t\tthis.matrix[i][j] = this.pmatrix ? this.pmatrix[i] ? this.pmatrix[i][j] : 0 : 0; // set value of each matrix cell\n\t\t}\n\t}\n\n\tthis.draw();\n\n \tthis.life = this.unboundlife.bind(this)\n\t\n}\n\nmatrix.prototype.draw = function() {\n\n\tthis.erase();\n\n\tthis.cellWid = this.GUI.w/this.col;\n\tthis.cellHgt = this.GUI.h/this.row;\n\n\twith (this.context) {\n\t\tstrokeStyle = this.colors.fill\n\t\t//lineWidth = 0\n\t\t//strokeRect(0,0,this.GUI.w,this.GUI.h)\n\t}\n\n\tfor (var i=0;i<this.row;i++){\n\t\tfor (var j=0;j<this.col;j++) {\n\t\t\tvar st_x = j*this.cellWid // starting point(left)\n\t\t\tj==0 ? st_x += 0 : null;\n\t\t\tvar st_y = i*this.cellHgt; // starting point(top)\n\t\t\ti==0 ? st_y += 0 : null;\n\t\t\tvar boxwid = this.cellWid;\n\t\t\tvar boxhgt = this.cellHgt;\n\n\t\t\t\n\t\t\twith (this.context) {\n\t\t\t\tstrokeStyle = this.colors.border;\n\t\t\t\tlineWidth = this.cellBuffer;\n\t\t\t\tif (this.matrix[j][i] > 0) {\n\t\t\t\t\tfillStyle = this.colors.accent;\n\t\t\t\t} else {\n\t\t\t\t\tfillStyle = this.colors.fill;\n\t\t\t\t}\n\t\t\t\tfillRect(st_x+this.cellBuffer/2, st_y+this.cellBuffer/2, boxwid-this.cellBuffer, boxhgt-this.cellBuffer);\n\t\t\t\n\t\t\t\t// sequencer highlight\n\t\t\t\tif (this.place == j) {\n\t\t\t\t\tglobalAlpha = 0.4;\n\t\t\t\t\tfillStyle = this.colors.border;\n\t\t\t\t\tfillRect(st_x, st_y, boxwid, boxhgt);\n\t\t\t\t\tglobalAlpha = 1;\n\t\t\t\t}\n\n\t\t\t}\n\t\t} \n\t}\n\n\tthis.drawLabel();\n}\n\n\n\nmatrix.prototype.click = function(e) {\n\n\tthis.cur = {\n\t\tcol: ~~(this.clickPos.x/this.cellWid),\n\t\trow: ~~(this.clickPos.y/this.cellHgt)\n\t}\n\n\tif (this.matrix[this.cur.col][this.cur.row]) {\n\t\tthis.matrix[this.cur.col][this.cur.row] = 0;\n\t\tthis.erasing = true;\n\t} else {\n\t\tthis.matrix[this.cur.col][this.cur.row] = 1;\n\t\tthis.erasing = false;\n\t}\n\n\tthis.cur.value = this.matrix[this.cur.col][this.cur.row]\n\tthis.prev = this.cur;\n\n//\tvar data = this.matrix[this.cur.col];\n//\tdata = data.join();\n//\tdata = data.replace(/\\,/g,\" \");\n\n\tthis.val = {\n\t\trow: this.cur.row,\n\t\tcol: this.cur.col,\n\t\tlevel: this.cur.value\n\t}\n\n\tthis.transmit(this.val);\n\tthis.draw();\n}\n\nmatrix.prototype.move = function(e) {\n\tif (this.clicked) {\n\t\t\n\t\tthis.cur = {\n\t\t\tcol: ~~(this.clickPos.x/this.cellWid),\n\t\t\trow: ~~(this.clickPos.y/this.cellHgt)\n\t\t}\n\n\t\tif (this.cur.row < this.row && this.cur.col < this.col && this.cur.row >= 0 && this.cur.col >=0) {\n\t\t\tif (this.cur.col!=this.prev.col || this.cur.row != this.prev.row) {\n\t\t\t\tif (this.erasing) {\n\t\t\t\t\tthis.matrix[this.cur.col][this.cur.row] = 0;\n\t\t\t\t} else {\n\t\t\t\t\tthis.matrix[this.cur.col][this.cur.row] = 1;\n\t\t\t\t}\n\n\t\t\t\tthis.cur.value = this.matrix[this.cur.col][this.cur.row]\n\t\t\t\tthis.prev = this.cur;\n\n\t\t\t\tthis.val = {\n\t\t\t\t\trow: this.cur.row,\n\t\t\t\t\tcol: this.cur.col,\n\t\t\t\t\tlevel: this.cur.value\n\t\t\t\t}\n\n\t\t\t\tthis.transmit(this.val);\n\t\t\t\tthis.draw();\n\t\t\t}\n\t\t}\n\n\t}\n}\n\n\n/** @method setCell\nManually set an individual cell on/off and transmit the new value.\n@param {integer} [col] The column of the cell to be turned on/off\n@param {integer} [row] The row of the cell to be turned on/off\n@param {boolean} [on/off] Whether the cell should be turned on/off\n\n```js\n\t// Turns cell on at column 1 row 3\n\tmatrix1.setCell(1,3,true);\n```\n*/\nmatrix.prototype.setCell = function(col,row,on) {\n\n\tvar value = on ? 1 : 0;\n\tthis.matrix[col][row] = value\n\n\tthis.val = {\n\t\trow: row,\n\t\tcol: col,\n\t\tlevel: value\n\t}\n\n\tthis.transmit(this.val);\n\tthis.draw();\n\n}\n\n/** @method sequence\n@param {float} [bpm] Beats per minute of the pulse\nTurns the matrix into a sequencer.\n\n```js\n\tmatrix1.sequence(240);\n```\n*/\nmatrix.prototype.sequence = function(bpm) {\n\n\tif (bpm) {\n\t\tthis.bpm = bpm;\n\t}\t\n\tthis.sequencing = true;\n\trequestAnimationFrame(this.seqStep.bind(this));\n\n}\n\nmatrix.prototype.setBPM = function(bpm) {\n\tthis.bpm = bpm\n\t//console.log(bpm)\n\t//nx.interval.bpm(this.pulse,bpm)\n}\n\n/** @method stop\nStops the matrix sequencer.\n\n```js\n\tmatrix1.stop();\n```\n*/\nmatrix.prototype.stop = function() {\n\tthis.sequencing = false;\n}\n\nmatrix.prototype.seqStep = function() {\n\n\tif (this.bpm == 0) { this.bpm = 1 }\n\n\t//current time\n\tvar now = new Date().getTime();\n\n\t//delta time since start\n\tvar dt = now - this.starttime;\n\n\tif (this.bpm != this.pbpm) {\n\n\t\t//frame + decimal since last beat, in old bpm\n\t\tvar timeP = (dt/(60000/this.pbpm))\n\n\t\t// scale to new bpm\n\t\tdt = timeP * (60000/this.bpm)\n\n\t\t//adjust the starttime reference point\n\t\tthis.starttime = now - dt\n\n\t\t//calculate new frame #\n\t\tthis.thisframe = ~~(dt/(60000/this.bpm));\n\n\t} else {\n\n\t //this.thisframe is a constantly ascending integer counter\n\t //to compare with this.lastframe to determine when to increment this.place\n\t //this.thisframe IS NOT the current column.\n\t //the current column is this.place, which is set conditionally below.\n\t\tthis.thisframe = ~~(dt/(60000/this.bpm));\n\n\t}\n\n\tthis.pbpm = this.bpm;\n\n if (this.thisframe != this.lastframe) {\n\n\t\tthis.lastbeat = now;\n\n\t\tif (this.sequenceMode==\"linear\") {\n\t\t\tthis.place++;\n\t\t} else if (this.sequenceMode==\"random\") {\n\t\t\tthis.place = math.random(this.col);\n\t\t}\n\t\tif (this.place>=this.col) {\n\t\t\tthis.place = 0;\n\t\t}\n\n\t\tif (this.place==null) {\n\t\t\tthis.place = 0;\n\t\t}\n\n\t\tthis.jumpToCol(this.place);\n\n }\n\n\tthis.lastframe = this.thisframe;\n if (this.sequencing) {\n\t\trequestAnimationFrame(this.seqStep.bind(this));\n\t} \n}\n\n/** @method jumpToCol\nJump to a certain column of the matrix, highlight it, and output its values as an array. Column numbers start at 0.\n\n```js\n\tmatrix1.jumpToCol(1);\n```\n*/\n\nmatrix.prototype.jumpToCol = function(place) {\n\t\tthis.place = place\n\t\tthis.val = {\n\t\t\tlist: this.matrix[this.place]\n\t\t}\n\t\tthis.transmit(this.val);\n\t\tthis.draw();\n}\n\n\nmatrix.prototype.customDestroy = function() {\n\tthis.stop();\n}\n\nmatrix.prototype.unboundlife = function() {\n if (!this.clicked) {\n this.newmatrix = []\n for (var i=0;i<this.col;i++) {\n this.newmatrix[i] = []\n for (var j=0;j<this.row;j++) {\n var total = 0\n if (i-1 >= 0) {\n total += this.matrix[i-1][j-1] ? this.matrix[i-1][j-1] : 0\n total += this.matrix[i-1][j] ? this.matrix[i-1][j] : 0\n total += this.matrix[i-1][j+1] ? this.matrix[i-1][j+1] : 0\n }\n total += this.matrix[i][j-1] ? this.matrix[i][j-1] : 0\n total += this.matrix[i][j+1] ? this.matrix[i][j+1] : 0\n if (i+1 < this.col) {\n total += this.matrix[i+1][j-1] ? this.matrix[i+1][j-1] : 0\n total += this.matrix[i+1][j] ? this.matrix[i+1][j] : 0\n total += this.matrix[i+1][j+1] ? this.matrix[i+1][j+1] : 0\n }\n\n if (this.matrix[i][j]) {\n if (total < 2) {\n this.newmatrix[i][j] = 0\n } else if (total ==2 || total == 3) {\n this.newmatrix[i][j] = 1\n } else if (total > 3) {\n this.newmatrix[i][j] = 0\n }\n } else if (!this.matrix[i][j] && total == 3) {\n this.newmatrix[i][j] = 1\n } else {\n this.newmatrix[i][j] = this.matrix[i][j]\n }\n }\n }\n this.matrix = this.newmatrix\n }\n this.transmit({ grid: this.matrix})\n this.draw()\n}\n\n/** @method life\nAlters the matrix according to Conway's Game of Life. Matrix.life() constitutes one tick through the game. To simulate the game, you might use setInterval.\n\n```js\n //one tick\n matrix1.life();\n\n //repeated ticks at 80ms\n setInterval(matrix1.life,80)\n```\n*/\nmatrix.prototype.life = function() { \n return false;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/matrix.js\n// module id = 31\n// module chunks = 0","var util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class message \n\tSend a string of text.\n\t```html\n\t<canvas nx=\"message\"></canvas>\n\t```\n\t<canvas nx=\"message\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar message = module.exports = function (target) {\n\t\n\tthis.defaultSize = { width: 100, height: 30 };\n\twidget.call(this, target);\n\t\n\n\t/** @property {object} val \n\t\t| | data\n\t\t| --- | ---\n\t\t| *value* | Text of message, as string\n\t*/\n\n\tthis.val = {\n\t\tvalue: \"send a message\"\n\t}\n\n\t/** @property {integer} size Text size in px */\n\tthis.size = 14;\n\t\n}\nutil.inherits(message, widget);\n\nmessage.prototype.init = function() {\n\tif (this.canvas.getAttribute(\"label\")) {\n\t\tthis.val.value = this.canvas.getAttribute(\"label\");\n\t}\n\t//this.size = Math.sqrt((this.GUI.w * this.GUI.h) / (this.val.message.length));\n\tthis.draw();\n}\n\nmessage.prototype.draw = function() {\n\tthis.erase();\n\twith (this.context) {\n\t\tif (this.clicked) {\n\t\t\tfillStyle = this.colors.border;\n\t\t} else {\n\t\t\tfillStyle = this.colors.fill;\n\t\t}\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h)\n\t\t\n\t\tif (this.clicked) {\n\t\t\tfillStyle = this.colors.black;\n\t\t} else {\n\t\t\tfillStyle = this.colors.black;\n\t\t}\n\t\ttextAlign = \"left\";\n\t\tfont = this.size+\"px \"+nx.font;\n\t}\n\tthis.wrapText(this.val.value, 5, 1+this.size, this.GUI.w-6, this.size);\n}\n\nmessage.prototype.click = function(e) {\n\tthis.draw();\n\tthis.transmit(this.val);\n}\n\nmessage.prototype.release = function(e) {\n\tthis.draw();\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/message.js\n// module id = 32\n// module chunks = 0","var util = require('util');\nvar drawing = require('../utils/drawing');\nvar widget = require('../core/widget');\n\n/** \n \n @public\n @class meter \n\n Decibel level meter.\n\n ```html\n <canvas nx=\"meter\"></canvas>\n ```\n <canvas nx=\"meter\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar meter = module.exports = function(target) {\n\n // to update, eventually (note to self)\n // possibly a less-frequent animation request, to lighten the graphics load\n // option for stereo meter? i.e. optional third .setup(ctx,s1,s2) argument\n\n this.defaultSize = { width: 20, height: 50 };\n widget.call(this, target);\n\n this.val = {\n level: 0\n }\n this.dataArray;\n this.bars = 8;\n\n this.init();\n\n}\nutil.inherits(meter, widget);\n\n\nmeter.prototype.init = function(){\n this.bar = {\n x: 0,\n y: 0,\n w: this.GUI.w,\n h: this.GUI.h/this.bars\n }\n with (this.context) {\n fillStyle = this.colors.fill;\n fillRect(0,0,this.GUI.w, this.GUI.h);\n }\n}\n\n\n\n/** @method setup \n Connect the meter to an audio source and start the meter's graphics.\n @param {audio context} [context] The audio context hosting the source node\n @param {audio node} [source] The audio source node to analyze\n */\nmeter.prototype.setup = function(actx,source){\n this.actx = actx; \n this.source = source;\n\n this.analyser = this.actx.createAnalyser();\n this.analyser.smoothingTimeConstant = 0.85;\n this.analyser.fftsize = 1024;\n this.bufferLength = this.analyser.frequencyBinCount;\n this.dataArray = new Uint8Array(this.bufferLength);\n this.source.connect(this.analyser);\n \n this.draw();\n}\n\nmeter.prototype.draw = function(){\n \n if(this.dataArray) {\n this.analyser.getByteTimeDomainData(this.dataArray);\n\n var max = Math.max.apply(null, this.dataArray);\n var min = Math.min.apply(null, this.dataArray);\n var amp = max - min;\n amp /= 240\n\n //converts amps to db\n var db = 20 * (Math.log(amp) / Math.log(10))\n\n with (this.context){\n fillStyle = this.colors.fill;\n fillRect(0,0,this.GUI.w, this.GUI.h);\n\n //scales: -40 to +10 db range => a number of bars\n var dboffset = Math.floor((db + 40) / (50/this.bars) );\n \n for (var i = 0; i<this.bars; i++) {\n\n // 0+ db is red\n if(i >= this.bars*.8) {\n fillStyle = 'rgb(255,0,0)';\n\n // -5 to 0 db is yellow\n } else if (i < this.bars*.8 && i >= this.bars*.69) {\n fillStyle = 'rgb(255,255,0)';\n\n // -40 to -5 db is green\n } else if (i < this.bars*.69) {\n fillStyle = 'rgb(0,255,0)';\n }\n\n // draw bar\n if (i<dboffset)\n fillRect(1,this.GUI.h-this.bar.h*i,this.GUI.w-2,this.bar.h-2);\n\n }\n }\n }\n\n setTimeout(function() {\n window.requestAnimationFrame(this.draw.bind(this));\n }.bind(this), 80)\n \n}\n \n \n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/meter.js\n// module id = 33\n// module chunks = 0","var math = require('../utils/math')\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class metro \n\tBouncing ball metronome\n\t```html\n\t<canvas nx=\"metro\"></canvas>\n\t```\n\t<canvas nx=\"metro\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar metro = module.exports = function (target) {\n\tthis.defaultSize = { width: 100, height: 20 };\n\twidget.call(this, target);\n\n\t//define unique attributes\n\t\n\t/** @property {object} val \n\t\t| | data\n\t\t| --- | ---\n\t\t| *beat* | Which side the ball is bouncing on (0 if left, 1 if right)\n\t*/\n\tthis.val = {\n\t\tbeat: 0\n\t}\n\n\tthis.x = 10;\n\tthis.y = 10;\n\tthis.loc = 10;\n\tthis.nodeSize = 10;\n\t/** @property {float} speed Speed of the ball (default 1) */\n\tthis.speed = 1;\n\tthis.direction = 1;\n\t/** @property {string} orientation Orientation of metro. Default is \"horizontal\". */\n\tthis.orientation = \"horizontal\"\n\tthis.boundary = this.GUI.w\n\n\tnx.aniItems.push(this.advance.bind(this));\n\tthis.active = true;\n\t\n\tthis.init();\n}\nutil.inherits(metro, widget);\n\nmetro.prototype.init = function() {\n\tthis.nodeSize = Math.min(this.GUI.w,this.GUI.h)/2;\n\tif (this.GUI.w<this.GUI.h) {\n\t\tthis.orientation = \"vertical\"\n\t\tthis.boundary = this.GUI.h\n\t} else {\n\t\tthis.orientation = \"horizontal\"\n\t\tthis.boundary = this.GUI.w\n\t}\n\tthis.x = this.nodeSize;\n\tthis.y = this.nodeSize;\n\tthis.loc = this.nodeSize;\n\n\tthis.draw();\n\n}\n\nmetro.prototype.draw = function() {\n\tthis.erase()\n\twith (this.context) {\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h); \n\n\t\tbeginPath();\n\t\tfillStyle = this.colors.accent;\n\t\tarc(this.x, this.y, this.nodeSize, 0, Math.PI*2, true);\t\t\t\t\t\n\t\tfill();\n\t\tclosePath();\n\t}\n\t\n\tthis.drawLabel();\n}\n\nmetro.prototype.click = function() {\n}\n\nmetro.prototype.move = function() {\n\tif (this.clicked) {\n\t\tthis.speed -= (this.deltaMove.y / 50);\n\t}\n}\n\nmetro.prototype.release = function() {\n}\n\nmetro.prototype.advance = function() {\n\tif (this.speed>=0) {\n\t\tthis.loc += this.speed * this.direction;\n\t} else {\n\t\tthis.loc += this.speed * this.direction;\n\t}\n\tif (this.loc-this.nodeSize<0 || this.loc+this.nodeSize>this.boundary) {\n\t\tthis.val.beat = math.scale(this.direction,-1,1,0,1)\n\t\tthis.transmit(this.val);\n\t\tthis.direction *= -1\n\t}\n\tif (this.orientation == \"vertical\") {\n\t\tthis.y = this.loc\n\t} else {\n\t\tthis.x = this.loc\n\t}\n\tthis.draw();\n}\n\nmetro.prototype.customDestroy = function() {\n\tnx.removeAni(this.advance.bind(this))\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/metro.js\n// module id = 34\n// module chunks = 0","var math = require('../utils/math')\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class motion \n\tMobile motion sensor. Does not work on all devices! <br> **Notes:** Clicking on this widget toggles it inactive or active. <br>\n\tWe recommend not calling .init() on this object after the original initialization, because it will add additional redundant motion listeners to your document.\n\t```html\n\t<canvas nx=\"motion\"></canvas>\n\t```\n\t<canvas nx=\"motion\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar motion = module.exports = function (target) {\n\tthis.defaultSize = { width: 75, height: 75 };\n\twidget.call(this, target);\n\t\n\tthis.motionLR;\n\tthis.motionFB;\n\tthis.z;\n\t/** @property {boolean} active Whether or not the motion widget is on (animating and transmitting data). */\n\tthis.active = true;\n\n\tthis.px = 0;\n\tthis.py = 0;\n\tthis.pz = 0;\n\n\t/** @property {object} val Object containing the core interactive aspects of the widget, which are also its data output. Has the following properties: \n\t\t| | data\n\t\t| --- | ---\n\t\t| *x* | X-axis motion if supported (-1 to 1)\n\t\t| *y* | Y-axis motion if supported (-1 to 1)\n\t\t| *z* | Z-axis motion if supported (-1 to 1 or 0 to 360 depending on device)\n\t*/\n\tthis.val = {\n\t\tx: 0,\n\t\ty: 0,\n\t\tz: 0\n\t}\n\n\t/** @property {string} text Text shown on motion object\n\t*/\n\t\n\tthis.text = \"Motion\";\n\tthis.init();\n\n\tthis.boundMotion = this.motionlistener.bind(this)\n\n\tif (window.DeviceMotionEvent) {\n\t\twindow.addEventListener('devicemotion', this.boundMotion, false);\n\t} else {\n\t\twith (this.context) {\n\t\t\tfillText(\"incompatible\",0,0)\n\t\t\tthis.active = false;\n\t\t}\n\t}\n\t\n}\nutil.inherits(motion, widget);\n\nmotion.prototype.deviceMotionHandler = function() {\n\t\n\tthis.val = {\n\t\tx: math.prune(this.motionLR/10,4),\n\t\ty: math.prune(this.motionFB/10,4),\n\t\tz: math.prune(this.z/10,4)\n\t}\n\n\tthis.transmit(this.val);\n\t\n}\n\nmotion.prototype.motionlistener = function(e) {\n\tvar data = e.acceleration\n\t\n\tif (this.active) {\n\n\n\t\tthis.motionLR = nx.lp(this.canvasID+\"motionx\",data.x,20)\n\t\tthis.motionFB = nx.lp(this.canvasID+\"motiony\",data.y,20)\n\t\tthis.z = nx.lp(this.canvasID+\"motionz\",data.z,20)\n \tthis.deviceMotionHandler()\n\n \t\tthis.draw();\n\n\t\tif (data.x===null || data.x===undefined) {\n\t\t\tthis.erase()\n\t\t\twith (this.context) {\n\t\t\t\tfillStyle = this.colors.fill\n\t\t\t\tfillRect(0,0,this.GUI.w,this.GUI.h)\n\t\t\t\tfillStyle = this.colors.black\n\t\t\t\tfont=\"12px courier\";\n\t\t\t\ttextAlign = \"center\"\n\t\t\t\tfillText(\"no data\",this.GUI.w/2,this.GUI.h/2)\t\n\t\t\t}\n\t\t\tthis.active = false;\n\t\t}\n \t}\n}\n\nmotion.prototype.init = function() {\n\tthis.draw()\n}\n\nmotion.prototype.draw = function() {\n\t\n\tthis.erase()\n\n\twith (this.context) {\n\t fillStyle = this.colors.fill;\n\t fillRect(0,0,this.GUI.w,this.GUI.h);\n\t fillStyle = this.colors.accent;\n\t var eighth = Math.PI/4\n\t if (this.motionFB<0) {\n\t\t\tbeginPath()\n\t\t\t\tmoveTo(this.GUI.w/2,this.GUI.h/2)\n\t\t\t\tarc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,eighth*5,eighth*7,false)\n\t\t\t\tglobalAlpha = Math.pow(this.motionFB, 2)\n\t\t\t\tfill()\n\t\t\tclosePath()\n\t } else {\n\t\t\tbeginPath()\n\t\t\t\tmoveTo(this.GUI.w/2,this.GUI.h/2)\n\t\t\t\tarc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,eighth*1,eighth*3,false)\n\t\t\t\tglobalAlpha = Math.pow(this.motionFB, 2)\n\t\t\t\tfill()\n\t\t\tclosePath()\n\t }\n\t if (this.motionLR<0) {\n\t\t\tbeginPath()\n\t\t\t\tmoveTo(this.GUI.w/2,this.GUI.h/2)\n\t\t\t\tarc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,eighth*7,eighth*1,false)\n\t\t\t\tglobalAlpha = Math.pow(this.motionLR, 2)\n\t\t\t\tfill()\n\t\t\tclosePath()\n\t } else {\n\t\t\tbeginPath()\n\t\t\t\tmoveTo(this.GUI.w/2,this.GUI.h/2)\n\t\t\t\tarc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/2,eighth*3,eighth*5,false)\n\t\t\t\tglobalAlpha = Math.pow(this.motionLR, 2)\n\t\t\t\tfill()\n\t\t\tclosePath()\n\t }\n\t\tbeginPath()\n\t\t\tmoveTo(this.GUI.w/2,this.GUI.h/2)\n\t\t\tarc(this.GUI.w/2,this.GUI.h/2,this.GUI.w/6,0,Math.PI*2,false)\n\t\t\tglobalAlpha = Math.pow(this.z, 2)\n\t\t\tfill()\n\t\tclosePath()\n\t\tglobalAlpha = 1\n\t}\n\tthis.drawLabel();\n}\n\nmotion.prototype.click = function() {\n\tthis.active = !this.active;\n\tthis.draw()\n}\n\nmotion.prototype.customDestroy = function() {\n\tthis.active = false;\n\twindow.removeEventListener(\"devicemotion\",this.motionlistener,false);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/motion.js\n// module id = 35\n// module chunks = 0","var util = require('util');\nvar widget = require('../core/widget');\nvar math = require('../utils/math');\n\n/** \n\t@class mouse \n\tMouse tracker, relative to web browser window.\n\t```html\n\t<canvas nx=\"mouse\"></canvas>\n\t```\n\t<canvas nx=\"mouse\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar mouse = module.exports = function (target) {\n\t\n\tthis.defaultSize = { width: 98, height: 100 };\n\twidget.call(this, target);\n\n\t/** @property {object} val \n\t\t| | data\n\t\t| --- | ---\n\t\t| *x* | x value of mouse relative to browser\n\t\t| *y* | y value of mouse relative to browser\n\t\t| *deltax* | x change in mouse from last position\n\t\t| *deltay* | y change in mouse from last position\n\t*/\n\tthis.val = {\n\t\tx: 0,\n\t\ty: 0,\n\t\tdeltax: 0, \n\t\tdeltay: 0\n\t}\n\tthis.inside = new Object();\n\tthis.boundmove = this.preMove.bind(this)\n\tthis.mousing = window.addEventListener(\"mousemove\", this.boundmove, false);\n\t\n\tthis.init();\n}\nutil.inherits(mouse, widget);\n\nmouse.prototype.init = function() {\n\t\n\tthis.inside.height = this.GUI.h;\n\tthis.inside.width = this.GUI.w;\n\tthis.inside.left = 0;\n\tthis.inside.top = 0;\n\tthis.inside.quarterwid = (this.inside.width)/4;\n\t \n\tthis.draw();\n}\n\nmouse.prototype.draw = function() {\n\tthis.erase();\n\n\twith (this.context) {\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h); \n\n\t\tvar scaledx = -(this.val.x) * this.GUI.h;\n\t\tvar scaledy = -(this.val.y) * this.GUI.h;\n\t\tvar scaleddx = -(this.val.deltax) * this.GUI.h - this.GUI.h/2;\n\t\tvar scaleddy = -(this.val.deltay) * this.GUI.h - this.GUI.h/2;\n\n\t\tfillStyle = this.colors.accent;\n\t\tfillRect(this.inside.left, this.inside.height, this.inside.quarterwid, scaledx);\n\t\tfillRect(this.inside.quarterwid, this.inside.height, this.inside.quarterwid, scaledy);\n\t\tfillRect(this.inside.quarterwid*2, this.inside.height, this.inside.quarterwid, scaleddx);\n\t\tfillRect(this.inside.quarterwid*3, this.inside.height, this.inside.quarterwid, scaleddy);\n\n\t\tglobalAlpha = 1;\n\t\tfillStyle = this.colors.fill;\n\t\ttextAlign = \"center\";\n\t\tfont = this.GUI.w/7+\"px \"+this.font;\n/* fillText(\"x\", this.inside.quarterwid*0 + this.inside.quarterwid/2, this.GUI.h-7);\n\t\tfillText(\"y\", this.inside.quarterwid*1 + this.inside.quarterwid/2, this.GUI.h-7);\n\t\tfillText(\"dx\", this.inside.quarterwid*2 + this.inside.quarterwid/2, this.GUI.h-7);\n\t\tfillText(\"dy\", this.inside.quarterwid*3 + this.inside.quarterwid/2, this.GUI.h-7);\n*/\n\t\tglobalAlpha = 1;\n\t}\n\t\n\tthis.drawLabel();\n}\n\nmouse.prototype.move = function(e) {\n\tthis.val = {\n\t\tdeltax: e.clientX/window.innerWidth - this.val.x,\n\t\tdeltay: math.invert(e.clientY/window.innerHeight) - this.val.y,\n\t\tx: e.clientX/window.innerWidth,\n\t\ty: math.invert(e.clientY/window.innerHeight)\n\t}\n\tthis.draw();\n\tthis.transmit(this.val);\n\n}\n\nmouse.prototype.customDestroy = function() {\n\twindow.removeEventListener(\"mousemove\", this.boundmove, false);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/mouse.js\n// module id = 36\n// module chunks = 0","var math = require('../utils/math')\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class multislider \n\tMultiple vertical sliders in one interface.\n\t```html\n\t<canvas nx=\"multislider\"></canvas>\n\t```\n\t<canvas nx=\"multislider\" style=\"margin-left:25px\"></canvas>\n*/\nvar multislider = module.exports = function (target) {\n\t\n\tthis.defaultSize = { width: 100, height: 75 };\n\twidget.call(this, target);\n\t\n\t/** @property {integer} sliders Number of sliders in the multislider. (Must call .init() after changing this setting, or set with .setNumberOfSliders) */\n\tthis.sliders = 15;\n\n\t/** @property {array} val Array of slider values. <br> **Note:** This widget's output is not .val! Transmitted output is:\t\n\n\t\t| | data\n\t\t| --- | ---\n\t\t| *(slider index)* | value of currently changed slider\n\t\t| list | all multislider values as list. (if the interface sends to js or node, this list will be an array. if sending to ajax, max7, etc, the list will be a string of space-separated values)\n\n\t*/\n\t\n\tthis.sliderClicked = 0;\n\tthis.oldSliderToMove;\n\tthis.init();\n}\nutil.inherits(multislider, widget);\n\nmultislider.prototype.init = function() {\n\tthis.val = new Array();\n\tfor (var i=0;i<this.sliders;i++) {\n\t\tthis.val[i] = 0.7;\n\t}\n\tthis.realSpace = { x: this.GUI.w, y: this.GUI.h }\n\tthis.sliderWidth = this.realSpace.x/this.sliders;\n\tthis.draw();\n}\n\nmultislider.prototype.draw = function() {\n\tthis.erase();\n\twith (this.context) {\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h);\n\t\t\n\t\tstrokeStyle = this.colors.accent;\n\t\tfillStyle = this.colors.accent;\n\t\tlineWidth = 5;\n \t\n\t\tfor(var i=0; i<this.sliders; i++) {\n\t\t\tbeginPath();\n\t\t\tmoveTo(i*this.sliderWidth, this.GUI.h-this.val[i]*this.GUI.h);\n\t\t\tlineTo(i*this.sliderWidth + this.sliderWidth, this.GUI.h-this.val[i]*this.GUI.h);\n\t\t\tstroke();\n\t\t\tlineTo(i*this.sliderWidth + this.sliderWidth, this.GUI.h);\n\t\t\tlineTo(i*this.sliderWidth, this.GUI.h);\n\t\t\tglobalAlpha = 0.3 - (i%3)*0.1;\n\t\t\tfill();\n\t\t\tclosePath(); \n\t\t\tglobalAlpha = 1;\n\t\t//\tvar separation = i==this.sliders-1 ? 0 : 1;\n\t\t//\tfillRect(i*this.sliderWidth, this.GUI.h-this.val[i]*this.GUI.h, this.sliderWidth-separation, this.val[i]*this.GUI.h)\n\t\t}\n\t}\n\tthis.drawLabel();\n}\n\nmultislider.prototype.click = function() {\n\tthis.oldSliderToMove = false;\n\tthis.move(true);\n}\n\nmultislider.prototype.move = function(firstclick) {\n\tif (this.clicked) {\n\n\n\t\tif (this.clickPos.touches.length>1) {\n\n\t\t\tfor (var i=0;i<this.clickPos.touches.length;i++) {\n\t\t\t\tvar sliderToMove = Math.floor(this.clickPos.touches[i].x / this.sliderWidth);\n\t\t\t\tsliderToMove = math.clip(sliderToMove,0,this.sliders-1);\n\t\t\t\tthis.val[sliderToMove] = math.clip(math.invert((this.clickPos.touches[i].y / this.GUI.h)),0,1);\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tvar sliderToMove = Math.floor(this.clickPos.x / this.sliderWidth);\n\t\t\tsliderToMove = math.clip(sliderToMove,0,this.sliders-1);\n\t\t\tthis.val[sliderToMove] = math.clip(math.invert(this.clickPos.y / this.GUI.h),0,1);\n\n\t\t\tif (this.oldSliderToMove && this.oldSliderToMove > sliderToMove + 1) {\n\t\t\t\tvar missed = this.oldSliderToMove - sliderToMove - 1;\n\t\t\t\tfor (var i=1;i<=missed;i++) {\n\t\t\t\t\tthis.val[sliderToMove+i] = this.val[sliderToMove] + (this.val[this.oldSliderToMove] - this.val[sliderToMove]) * ((i/(missed+1)));\n\t\t\t\t}\n\t\t\t} else if (this.oldSliderToMove && sliderToMove > this.oldSliderToMove + 1) {\n\t\t\t\tvar missed = sliderToMove - this.oldSliderToMove - 1;\n\t\t\t\tfor (var i=1;i<=missed;i++) {\n\t\t\t\t\tthis.val[this.oldSliderToMove+i] = this.val[this.oldSliderToMove] + (this.val[sliderToMove] - this.val[this.oldSliderToMove]) * ((i/(missed+1)));\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t}\n\t\tthis.draw();\n\t}\n\tvar msg = new Object()\n\tmsg[sliderToMove] = this.val[sliderToMove]\n\tif (this.destination==\"js\" || this.destination==\"node\") {\n\t\tmsg[\"list\"] = this.val;\n\t} else {\n\t\tmsg[\"list\"] = new String();\n\t\tfor (var key in this.val) { msg[\"list\"] += this.val[key] + \" \" }\n\t}\n\tthis.transmit(msg);\n\tthis.oldSliderToMove = sliderToMove;\n\t\n}\n\n/** @method setNumberOfSliders\n@param {integer} [num] New number of sliders in the multislider */\nmultislider.prototype.setNumberOfSliders = function(numOfSliders) {\n\tthis.sliders = numOfSliders;\n\tthis.val = new Array();\n\tfor (var i=0;i<this.sliders;i++) {\n\t\tthis.val.push(0.7);\n\t}\n\tthis.sliderWidth = this.realSpace.x/this.sliders;\n\tthis.init();\n}\n\n/** @method setSliderValue\nSets a slider to new value and transmits.\n@param {integer} [slider] Slider to set (slider index starts at 0)\n@param {integer} [value] New slider value */\nmultislider.prototype.setSliderValue = function(slider,value) {\n\tthis.val[slider] = value;\n\tthis.draw();\n\tvar msg = new Object();\n\tmsg[slider] = this.val[slider]\n\tif (this.destination==\"js\" || this.destination==\"node\") {\n\t\tmsg[\"list\"] = this.val;\n\t} else {\n\t\tmsg[\"list\"] = new String();\n\t\tfor (var key in this.val) { msg[\"list\"] += this.val[key] + \" \" }\n\t}\n\tthis.transmit(msg);\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/multislider.js\n// module id = 37\n// module chunks = 0","var math = require('../utils/math');\nvar drawing = require('../utils/drawing');\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class multitouch \n\tMultitouch 2d-slider with up to 5 points of touch.\n\t```html\n\t<canvas nx=\"multitouch\"></canvas>\n\t```\n\t<canvas nx=\"multitouch\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar multitouch = module.exports = function (target) {\n\t\n\tthis.defaultSize = { width: 200, height: 200 };\n\twidget.call(this, target);\n\t\n\t//unique attributes\n\tthis.nodeSize = this.GUI.w/10;\n\n\t/** @property {object} val \n\t\t| | data\n\t\t| --- | ---\n\t\t| *touch1.x* | x position of first touch\n\t\t| *touch1.y* | y position of first touch\n\t\t| *touch2.x* | x position of second touch (if 2 touches)\n\t\t| *touch2.y* | y position of second touch (if 2 touches)\n\t\t| *etc* | \n\t*/\n\tthis.val = {\n\t\ttouch1: {\n\t\t\tx: 0,\n\t\t\ty: 0\n\t\t}\n\t}\n\t\n\tthis.nodes = new Array();\n\t\n\t/** @property {string} text Text that will show when object is static */\n\tthis.text = \"multitouch\";\n\n\tthis.rainbow = [\"#00f\", \"#04f\", \"#08F\", \"0AF\", \"0FF\"];\n\t\n\t/** @property {string} mode \"normal\" or \"matrix\" mode. \"matrix\" mode has a GUI of discrete touch areas.\n\t*/\n\tthis.mode = \"normal\";\n\n\t/** @property {integer} rows How many rows in the matrix (matrix mode only)\n\t*/\n\tthis.rows = 10;\n\n\t/** @property {integer} cols How many rows in the matrix (matrix mode only)\n\t*/\n\tthis.cols = 10;\n\n\t/** @property {array} matrixLabels An array of strings that can provide text labels on cells of the matrix. If shorter than the matrix cells, the array will repeat.\n\t```\n\t\tthis.mode = \"matrix\"\n\t\tthis.matrixLabels = [ \"A\", \"A#\", \"B\", \"C\" ]\n\t\tthis.init();\n\t```\n\t*/\n\tthis.matrixLabels = false;\n\n\tthis.init();\n}\nutil.inherits(multitouch, widget);\n\nmultitouch.prototype.init = function() {\n\tthis.nodeSize = this.GUI.w/10;\n\tthis.draw();\n}\n\nmultitouch.prototype.draw = function() {\n\tthis.erase();\n\twith (this.context) {\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h);\n\n\t\tvar count = 0;\n\n\t\tif (this.mode == \"matrix\") {\n\t\t\tfor (var j=0;j<this.rows;j++) {\n\t\t\t\tfor (var i=0;i<this.cols;i++) {\n\t\t\t\t\twith (this.context) {\n\t\t\t\t\t\tbeginPath();\n\t\t\t\t\t\t\tfillStyle = this.colors.accent;\n\t\t\t\t\t\t\tstrokeStyle = this.colors.border;\n\t\t\t\t\t\t\tlineWidth = 1;\n\t\t\t\t\t\t\tvar circx = i*this.GUI.w/this.cols + (this.GUI.w/this.cols)/2;\n\t\t\t\t\t\t\tvar circy = j*this.GUI.h/this.rows + (this.GUI.h/this.rows)/2;\n\t\t\t\t\t\t\tarc(circx, circy, (this.GUI.h/this.rows)/2, 0, Math.PI*2, true);\t\t\t\t\t\n\t\t\t\t\t\t\tstroke();\n\t\t\t\t\t\t\tfillStyle = this.colors.border;\n\t\t\t\t\t\t\ttextAlign = \"center\";\n\t\t\t\t\t\t\ttextBaseline = \"middle\";\n\t\t\t\t\t\t\tif (this.matrixLabels) {\n\t\t\t\t\t\t\t\tfillText(this.matrixLabels[count%this.matrixLabels.length], circx, circy);\n\t\t\t\t\t\t\t\tcount++\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\tvar thisarea = {\n\t\t\t\t\t\t\t\tx: i*this.GUI.w/this.cols,\n\t\t\t\t\t\t\t\ty: j*this.GUI.h/this.rows,\n\t\t\t\t\t\t\t\tw: this.GUI.w/this.cols,\n\t\t\t\t\t\t\t\th: this.GUI.h/this.rows\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (this.clickPos.touches.length>=1) {\n\t\t\t\t\t\t\t\tfor (var k=0;k<this.clickPos.touches.length;k++) {\n\t\t\t\t\t\t\t\t\tif (drawing.isInside(this.clickPos.touches[k],thisarea)) {\n\t\t\t\t\t\t\t\t\t\tglobalAlpha=0.5;\n\t\t\t\t\t\t\t\t\t\tfillStyle = this.colors.accent;\n\t\t\t\t\t\t\t\t\t\tfill();\n\t\t\t\t\t\t\t\t\t\tglobalAlpha=0.3;\n\t\t\t\t\t\t\t\t\t\tfillStyle = this.rainbow[k];\n\t\t\t\t\t\t\t\t\t\tfill();\n\t\t\t\t\t\t\t\t\t\tglobalAlpha=1;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tclosePath();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (this.clickPos.touches.length>=1) {\n\t\t\t\tfor (var i=0;i<this.clickPos.touches.length;i++) {\n\t\t\t\t\t\n\t\t\t\t\twith (this.context) {\n\t\t\t\t\t\tglobalAlpha=0.5;\n\t\t\t\t\t\tbeginPath();\n\t\t\t\t\t\tfillStyle = this.colors.accent;\n\t\t\t\t\t\tstrokeStyle = this.colors.border;\n\t\t\t\t\t\tlineWidth = this.lineWidth;\n\t\t\t\t\t\tarc(this.clickPos.touches[i].x, this.clickPos.touches[i].y, this.nodeSize, 0, Math.PI*2, true);\t\t\t\t\t\n\t\t\t\t\t\tfill();\n\t\t\t\t\t\t//\tstroke();\n\t\t\t\t\t\tclosePath();\n\t\t\t\t\t\tglobalAlpha=0.3;\n\t\t\t\t\t\tbeginPath();\n\t\t\t\t\t\tfillStyle = this.rainbow[i];\n\t\t\t\t\t\tstrokeStyle = this.colors.border;\n\t\t\t\t\t\tlineWidth = this.lineWidth;\n\t\t\t\t\t\tarc(this.clickPos.touches[i].x, this.clickPos.touches[i].y, this.nodeSize, 0, Math.PI*2, true);\t\t\t\t\t\n\t\t\t\t\t\tfill();\n\t\t\t\t\t\t//\tstroke();\n\t\t\t\t\t\tclosePath(); \n\t\t\t\t\t\tglobalAlpha=1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tclearRect(0,this.GUI.h,this.GUI.w,this.height - this.GUI.h)\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.setFont()\n\t\t\t\tfillStyle = this.colors.border;\n\t\t\t\tfillText(this.text, this.GUI.w/2, this.GUI.h/2);\n\t\t\t\tglobalAlpha = 1;\n\t\t\t}\n\t\t}\n\t}\n\tthis.drawLabel();\n}\n\nmultitouch.prototype.click = function() {\n\tthis.draw();\n\tthis.sendit();\n}\n\nmultitouch.prototype.move = function() {\n\tif (this.clicked) {\n\t\tthis.draw();\n\t\tthis.sendit();\n\t}\n}\n\nmultitouch.prototype.release = function() {\n\n\tif(!this.clicked) {\n\t\tthis.clickPos.touches = new Array();\n\t\tfor (var i=0;i<5;i++) {\n\t\t\tthis.val[\"touch\"+i] = {\n\t\t\t\tx: 0,\n\t\t\t\ty: 0\n\t\t\t}\n\t\t}\n\t\tthis.transmit(this.val);\n\t}\n\t\n\tthis.draw();\n\tthis.sendit();\n\t\n}\n\nmultitouch.prototype.sendit = function() {\n\tthis.val = new Object();\n\tfor (var i=0;i<this.clickPos.touches.length;i++) {\n\t\tthis.val[\"touch\"+i] = {\n\t\t\tx: this.clickPos.touches[i].x/this.canvas.width,\n\t\t\ty: math.invert(this.clickPos.touches[i].y/this.canvas.height)\n\t\t}\n\t}\n\tthis.transmit(this.val);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/multitouch.js\n// module id = 38\n// module chunks = 0","var math = require('../utils/math')\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class number \n\tNumber box\n\t```html\n\t<canvas nx=\"number\"></canvas>\n\t```\n\t<canvas nx=\"number\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar number = module.exports = function (target) {\n\tthis.defaultSize = { width: 50, height: 20 };\n\twidget.call(this, target);\n\t\n\t/** @property {object} val \n\t\t| | data\n\t\t| --- | ---\n\t\t| *value* | Number value\n\t\t\n\t\t```js\n\t\t\t// Sets number1.val.value to 20\n\t\t\tnumber1.set({\n\t\t\t value: 20\n\t\t\t})\n\t\t```\n\t*/\n\tthis.val = {\n\t\tvalue: 0\n\t}\n\n\t/** @property {float} min The minimum number allowed. Default is -20000.\n\n\t\t```js\n\t\t // only allow positive numbers\n\t\t\tnumber1.min = 0;\n\t\t```\n\t*/\n\tthis.min = -20000\n\n\t/** @property {float} max The maximum number allowed. Default is 20000.\n\n\t\t```js\n\t\t // only allow negative numbers\n\t\t\tnumber1.max = 0;\n\t\t```\n\t*/\n\tthis.max = 20000\n\n\t/** @property {float} step The increment. Default is 1.\n\n\t\t```js\n\t\t // count by 10s\n\t\t\tnumber1.step = 10;\n\t\t```\n\t*/\n\tthis.step = 1\n\n\n\t/** @property {float} rate Sensitivity of dragging. Default is .25\n\n\t\t```js\n\t\t // For fine tuning \n\t\t\tnumber1.rate = .001;\n\t\t```\n\t*/\n\tthis.rate = .25\n\n\t/** @property {integer} decimalPlaces How many decimal places on the number. This applies to both the output and the interface text. Default is 2. To achieve an int (non-float), set decimalPlaces to 0.\n\n\t\t```js\n\t\t\t// For an int counter\n\t\t\tnumber1.decimalPlaces = 0;\n\t\t```\n\t*/ \n\tthis.decimalPlaces = 3;\n\tthis.lostdata = 0;\n\tthis.actual = 0;\n\n\t// SWAP\n\t// \n\tthis.canvas.ontouchstart = null;\n\tthis.canvas.ontouchmove = null;\n\tthis.canvas.ontouchend = null;\n\n\tvar htmlstr = '<input type=\"text\" nx=\"number\" id=\"'+this.canvasID+'\" style=\"height:'+this.GUI.h+'px;width:'+this.GUI.w+'px;font-size:'+this.GUI.h/2+'px;\"></input><canvas height=\"1px\" width=\"1px\" style=\"display:none\"></canvas>' \n\tvar canv = this.canvas\n\tvar cstyle = this.canvas.style\n\tvar parent = canv.parentNode\n\tvar newdiv = document.createElement(\"span\")\n\tnewdiv.innerHTML = htmlstr\n\tnewdiv.className = \"nx\"\n\tparent.replaceChild(newdiv,canv)\n\n\tthis.el = document.getElementById(this.canvasID)\n\tfor (var prop in cstyle) {\n\t\t\tif (prop != \"height\" && prop != \"width\") {\n \t\tthis.el.style[prop] = cstyle[prop]\n \t\t\t}\n }\n\n if (this.label) {\n\t var labeldiv = document.createElement(\"div\")\n\t labeldiv.innerHTML = this.label\n\t labeldiv.style.fontSize = this.labelSize/2.8+\"px\"\n\t labeldiv.style.fontFamily = this.labelFont\n\t labeldiv.style.textAlign = this.labelAlign\n\t labeldiv.style.lineHeight = this.labelSize+\"px\"\n\t labeldiv.style.width = this.GUI.w+\"px\"\n\t labeldiv.style.color = nx.colors.black\n\t labeldiv.className = \"nxlabel\"\n\t newdiv.appendChild(labeldiv)\n }\n\n\tthis.canvas = document.getElementById(this.canvasID);\n\tthis.canvas.style.height = this.GUI.h + \"px\"\n\tthis.canvas.style.fontSize = this.GUI.h * .6 + \"px\"\n\tthis.canvas.style.textAlign = \"left\"\n\tthis.canvas.style.backgroundColor = this.colors.fill\n\tthis.canvas.style.highlight = this.colors.fill\n\tthis.canvas.style.border = \"none\"\n\tthis.canvas.style.outline = \"none\"\n\tthis.canvas.style.padding = \"4px 10px\"\n\tthis.canvas.style.cursor = \"pointer\"\n\tthis.canvas.style.display = \"block\"\n\tthis.canvas.className = \"\"\n\n\tthis.canvas.addEventListener(\"blur\", function () {\n\t //this.canvas.style.border = \"none\";\n\n\t this.canvas.style.backgroundColor = this.colors.fill;\n\t this.canvas.style.color = this.colors.black;\n\t if (this.canvas.value != this.val.value) {\n\t \tthis.actual = parseFloat(this.canvas.value)\n\t \tthis.actual = math.clip(this.actual,this.min,this.max)\n\t\tthis.actual = math.prune(this.actual,this.decimalPlaces);\n\t \tthis.set({\"value\": this.actual}, true)\n\t }\n\t}.bind(this));\n\n\tthis.canvas.addEventListener(\"keydown\", function (e) {\n\t if (e.which < 48 || e.which > 57) {\n\t \tif (e.which != 189 && e.which != 190 && e.which != 8) {\n\t \t\te.preventDefault();\n\t \t}\n\t }\n\t if (e.which==13) {\n\t /*\tthis.actual = parseFloat(this.canvas.value)\n\t \tthis.actual = math.clip(this.actual,this.min,this.max)\n\t\tthis.actual = math.prune(this.actual,this.decimalPlaces);\n\t \tthis.set({\"value\": this.actual}, true) */\n\t \t//this.canvas.style.outline = \"none\";\n\t \tthis.canvas.blur()\n\t }\n\t}.bind(this));\n\n\t\n // Setup interaction\n if (nx.isTouchDevice) {\n this.canvas.ontouchstart = this.preTouch;\n this.canvas.ontouchmove = this.preTouchMove;\n this.canvas.ontouchend = this.preTouchRelease;\n } else {\n this.canvas.addEventListener('mousedown', this.preClick, false);\n }\n\n\n this.canvas.style.userSelect = \"none !important\";\n this.canvas.style.mozUserSelect = \"none !important\";\n this.canvas.style.webkitUserSelect = \"none !important\";\n\n\n\n\n\n\n\tthis.init();\n}\nutil.inherits(number, widget);\n\nnumber.prototype.init = function() {\n\n\n this.draw();\n}\n\nnumber.prototype.draw = function() {\n\n\tthis.canvas.value = this.val.value;\n\n}\n\n\nnumber.prototype.click = function(e) {\n\tthis.canvas.readOnly = true\n\tthis.actual = this.val.value\n}\n\nnumber.prototype.move = function(e) {\n\tif (this.clicked) {\n\t \tthis.canvas.style.border = \"none\";\n\n\t\tthis.actual -= (this.deltaMove.y*(this.rate*this.step));\n\t\tthis.actual = math.clip(this.actual,this.min,this.max)\n\t\tthis.val.value = Math.floor(this.actual / this.step) * this.step;\n\t\tthis.val.value = math.prune(this.val.value,this.decimalPlaces);\n\t\tthis.draw();\n\t\tthis.transmit(this.val);\n\t}\n}\n\n\nnumber.prototype.release = function(e) {\n\tif (!this.hasMoved && this.canvas.readOnly) {\n\t\tthis.canvas.readOnly = false;\n\t\tthis.canvas.focus()\n\t\tthis.canvas.setSelectionRange(0, this.canvas.value.length)\n\t\tthis.canvas.style.backgroundColor = this.colors.accent;\n\t\tthis.canvas.style.color = this.colors.fill;\n\t}\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/number.js\n// module id = 39\n// module chunks = 0","var math = require('../utils/math')\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class position \n\tTwo-dimensional touch slider.\n\t```html\n\t<canvas nx=\"position\"></canvas>\n\t```\n\t<canvas nx=\"position\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar position = module.exports = function (target) {\n\n\t// define a default size\n\tthis.defaultSize = { width: 150, height: 100 };\n\n\twidget.call(this, target);\n\t\n\t/** @property {integer} nodeSize Size of touch node graphic. */\n\tthis.nodeSize = 15;\n\n\t/** @property {object} val val is an object containing the main interactive / actionable aspects of the widget.\n\t\t| | data\n\t\t| --- | ---\n\t\t| *x* | x position of slider (float 0-1)\n\t\t| *y* | y position of slider (float 0-1)\n\t*/\n\tthis.val = {\n\t\tx: 0.5,\n\t\ty: 0.5\n\t}\n\t\n\tthis.init();\n}\n\n// inherit the widget object template\nutil.inherits(position, widget);\n\n// .init() is called automatically when the widget is created on a webpage.\nposition.prototype.init = function() {\n\tthis.nodeSize = Math.min(this.GUI.h,this.GUI.w)/10;\n\tthis.nodeSize = Math.max(this.nodeSize,10)\n\tthis.actualWid = this.GUI.w - this.nodeSize*2;\n\tthis.actualHgt = this.GUI.h - this.nodeSize*2;\n\tthis.draw();\n}\n\n// .draw() should be used for any graphics activity\nposition.prototype.draw = function() {\n\tthis.erase();\n\twith (this.context) {\n\n\t\t// use this.colors.fill for the widget background color (default: very light gray)\n\t\t// use this.colors.border for any extra structural needs (default: light gray)\n\t\t// use this.colors.accent for important or highlighted parts (default: a bright color)\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h);\n\n\t\tvar drawingX = this.val.x * this.actualWid + this.nodeSize\n\t\tvar drawingY = math.invert(this.val.y) * this.actualHgt + this.nodeSize\n\n\t\t//stay within right/left bounds\n\t\tif (drawingX<(this.nodeSize)) {\n\t\t\tdrawingX = this.nodeSize;\n\t\t} else if (drawingX>(this.GUI.w-this.nodeSize)) {\n\t\t\tdrawingX = this.GUI.w - this.nodeSize;\n\t\t}\n\t\t//stay within top/bottom bounds\n\t\tif (drawingY<(this.nodeSize)) {\n\t\t\tdrawingY = this.nodeSize;\n\t\t} else if (drawingY>(this.GUI.h-this.nodeSize)) {\n\t\t\tdrawingY = this.GUI.h - this.nodeSize;\n\t\t}\n\t\n\t\twith (this.context) {\n\n\t\t\t// draw the touch point\n\t\t\tbeginPath();\n\t\t\tfillStyle = this.colors.accent;\n\t\t\tarc(drawingX, drawingY, this.nodeSize, 0, Math.PI*2, true);\t\t\t\t\t\n\t\t\tfill();\n\t\t\tclosePath();\n\n\t\t\tif (this.clicked) {\n\t\t\t\t// draw the emphasis circle\n\t\t\t\tbeginPath();\n\t\t\t\tfillStyle = this.colors.accent;\n\t\t\t\tarc(drawingX, drawingY, this.nodeSize*2, 0, Math.PI*2, true);\t\t\t\t\t\n\t\t\t\tfill();\n\t\t\t\tclosePath();clearRect(0,this.GUI.h,this.GUI.w,this.height - this.GUI.h)\n\t\t\t}\n\t\t}\n\t}\n\t\n\tthis.drawLabel();\n}\n\n// .click() will be fired when the interface is interacted with\n// this.clicked is automatically set to true\n// this.clickPos is already and object with x and y properties detailing click point.\nposition.prototype.click = function() {\n\tthis.val.x = this.clickPos.x;\n\tthis.val.y = this.clickPos.y;\n\tthis.scaleNode();\n\tthis.val[\"state\"] = \"click\"\n\tthis.transmit(this.val);\n\tthis.draw();\n}\n\n// .move() will be fired when the interface is moved over after being clicked\n// this.clickPos is already and object with x and y properties detailing click point.\nposition.prototype.move = function() {\n\tthis.val.x = this.clickPos.x;\n\tthis.val.y = this.clickPos.y;\n\tthis.scaleNode();\n\tthis.val[\"state\"] = \"move\"\n\tthis.transmit(this.val);\n\tthis.draw();\n}\n\n// .release() will be fired on mouse up (unclick)\nposition.prototype.release = function() {\n\tthis.val.x = this.clickPos.x;\n\tthis.val.y = this.clickPos.y;\n\tthis.scaleNode();\n\tthis.val[\"state\"] = \"release\"\n\tthis.transmit(this.val);\n\tthis.draw();\n}\n\n/* TOUCH SPECIFIC EVENTS\n currently, ontouch, ontouchmove, and ontouchrelease automatically execute .click, .move, and .release\n so you only need to write one function for these events, and they will be touch compatible by default\n however if you would like to create a touch-specific event you may define the following functions.\n in these functions, .clickPos and .clicked will refer to your touch interactions.\n\nposition.prototype.touch = function() {\n\n}\n\nposition.prototype.touchmove = function() {\n\t\n}\n\nposition.prototype.touchrelease = function() {\n\t\n}\n\n\n\n\n*/\n\n\n\n/* \n extra functions pertaining only to this widget \n*/\n\nposition.prototype.scaleNode = function() {\n\tvar actualX = this.val.x - this.nodeSize;\n\tvar actualY = this.val.y - this.nodeSize;\n\tvar clippedX = math.clip(actualX/this.actualWid, 0, 1);\n\tvar clippedY = math.clip(actualY/this.actualHgt, 0, 1);\n\tthis.val.x = math.prune(clippedX, 3)\n\tthis.val.y = math.prune(clippedY, 3)\n\tthis.val.y = math.invert(this.val.y);\n}\n\n/** @method animate\n\tAdds animation to the widget.\n\t@param {string} [type] Type of animation. Currently accepts \"none\" or \"bounce\", in which case the touch node can be tossed and bounces.\n*/\nposition.prototype.animate = function(aniType) {\n\t\n\tswitch (aniType) {\n\t\tcase \"bounce\":\n\t\t\tnx.aniItems.push(this.aniBounce.bind(this));\n\t\t\tbreak;\n\t\tcase \"none\":\n\t\t\tnx.aniItems.splice(nx.aniItems.indexOf(this.aniBounce));\n\t\t\tbreak;\n\t}\n\t\n}\n\nposition.prototype.aniBounce = function() {\n\tif (!this.clicked && this.val.x) {\n\t\tthis.val.x += (this.deltaMove.x/2)/this.GUI.w;\n\t\tthis.val.y -= (this.deltaMove.y/2)/this.GUI.h;\n\t\tthis.val[\"state\"] = \"animated\";\n\t\tif (math.bounce(this.val.x, 0, 1, this.deltaMove.x) != this.deltaMove.x) {\n\t\t\tthis.deltaMove.x = math.bounce(this.val.x, 0, 1, this.deltaMove.x);\n\t\t\tthis.val[\"state\"] = \"bounce\";\n\t\t}\n\t\tif (this.val.y >= 1 || this.val.y <= 0) {\n\t\t\tthis.deltaMove.y = math.bounce(this.val.y, 0, 1, this.deltaMove.y) * -1;\n\t\t\tthis.val[\"state\"] = \"bounce\";\n\t\t}\n\t\tthis.transmit(this.val);\n\t\tthis.draw();\n\t}\n}\n\nposition.prototype.customDestroy = function() {\n\tnx.removeAni(this.aniBounce);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/position.js\n// module id = 40\n// module chunks = 0","var util = require('util');\nvar widget = require('../core/widget');\nvar math = require('../utils/math')\n\n/** \n\t@class range \n\tRange slider\n\t```html\n\t<canvas nx=\"range\"></canvas>\n\t```\n\t<canvas nx=\"range\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar range = module.exports = function (target) {\n\tthis.defaultSize = { width: 110, height: 35 };\n\twidget.call(this, target);\n\n\t/** @property {object} val Object containing core interactive aspects of widget, which are also its data output. Has the following properties: \n\t\t| | data\n\t\t| --- | ---\n\t\t| *start* | Range start value (float 0-1)\n\t\t| *stop* | Range end value (float 0-1)\n\t\t| *size* | Distance between ends (float 0-1)\n\t*/\n\tthis.val = {\n\t\tstart: 0.3,\n\t\tstop: 0.7,\n\t\tsize: 0.4\n\t}\n\n\n\t// handling horiz possibility\n\t/** @property {boolean} hslider Whether or not the slider is a horizontal slider. Default is false, but set automatically to true if the slider is wider than it is tall. */ \n\tthis.hslider = false;\n\tthis.handle;\n\tthis.relhandle;\n\tthis.cap;\n\tthis.firsttouch = \"start\";\n\n\t/** @property {string} mode Mode of interaction. \"edge\" mode lets you drag each edge of the range individually. \"area\" mode (default) lets you drag the range as a whole (with parallel mouse movement) or scale the range as a whole (with transverse mouse movement) */\n\tthis.mode = \"area\" // modes: \"edge\", \"area\"\n\tthis.touchdown = new Object();\n\tthis.init();\n}\nutil.inherits(range, widget);\n\nrange.prototype.init = function() {\n\n\t//decide if hslider or vslider\n\tif (this.GUI.h>=this.GUI.w) {\n\t\tthis.hslider = false;\n\t} else {\n\t\tthis.hslider = true;\n\t}\n\n\tif (this.canvas.getAttribute(\"label\")!=null) {\n\t\tthis.label = this.canvas.getAttribute(\"label\");\n\t}\n\n\tthis.draw();\n}\n\nrange.prototype.draw = function() {\n\tthis.erase();\n\t\t\n\twith (this.context) {\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h);\n\t\n\t\tif (!this.hslider) {\n\n\t\t\tvar x1 = 0;\n\t\t\tvar y1 = this.GUI.h-this.val.stop*this.GUI.h;\n\t\t\tvar x2 = this.GUI.w;\n\t\t\tvar y2 = this.GUI.h-this.val.start*this.GUI.h;\n\n\t\t\tfillStyle = this.colors.accent;\n\t\t\tfillRect(x1,y1,x2-x1,y2-y1);\n\n\t\t} else {\n\n\t\t\tvar x1 = this.val.start*this.GUI.w;\n\t\t\tvar y1 = 0;\n\t\t\tvar x2 = this.val.stop*this.GUI.w;\n\t\t\tvar y2 = this.GUI.h;\n\t\t \n\t\t\tfillStyle = this.colors.accent;\n\t\t\tfillRect(x1,y1,x2-x1,y2-y1);\n\t\t}\n\t}\n\tthis.drawLabel();\n}\n\nrange.prototype.click = function() {\n\tif (this.mode==\"edge\") {\n\t\tif (this.hslider) {\n\t\t\tif (Math.abs(this.clickPos.x-this.val.start*this.GUI.w) < Math.abs(this.clickPos.x-this.val.stop*this.GUI.w)) {\n\t\t\t\tthis.firsttouch = \"start\"\n\t\t\t} else {\n\t\t\t\tthis.firsttouch = \"stop\"\n\t\t\t}\n\t\t} else {\n\t\t\tif (Math.abs(Math.abs(this.clickPos.y-this.GUI.h)-this.val.start*this.GUI.h) < Math.abs(Math.abs(this.clickPos.y-this.GUI.h)-this.val.stop*this.GUI.h)) {\n\t\t\t\tthis.firsttouch = \"start\"\n\t\t\t} else {\n\t\t\t\tthis.firsttouch = \"stop\"\n\t\t\t}\n\t\t}\n\t} else if (this.mode==\"area\") {\n\t\tthis.touchdown = {\n\t\t\tx: this.clickPos.x,\n\t\t\ty: this.clickPos.y\n\t\t}\n\t\tthis.startval = new Object();\n\t\tthis.startval.size = this.val.stop - this.val.start;\n\t\tthis.startval.loc = this.val.start + this.startval.size/2;\n\t}\n\tthis.move();\n}\n\nrange.prototype.move = function() {\n\n\tif (this.mode==\"edge\") {\n\t\tif (this.hslider) {\n\t\t\tif (this.firsttouch==\"start\") {\n\t\t\t\tthis.val.start = this.clickPos.x/this.GUI.w;\n\t\t\t\tif (this.clickPos.touches.length>1) {\n\t\t\t\t\tthis.val.stop = this.clickPos.touches[1].x/this.GUI.w;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.val.stop = this.clickPos.x/this.GUI.w;\n\t\t\t\tif (this.clickPos.touches.length>1) {\n\t\t\t\t\tthis.val.start = this.clickPos.touches[1].x/this.GUI.w;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (this.firsttouch==\"start\") {\n\t\t\t\tthis.val.start = math.invert(this.clickPos.y/this.GUI.h);\n\t\t\t\tif (this.clickPos.touches.length>1) {\n\t\t\t\t\tthis.val.stop = math.invert(this.clickPos.touches[1].y/this.GUI.h);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.val.stop = math.invert(this.clickPos.y/this.GUI.h);\n\t\t\t\tif (this.clickPos.touches.length>1) {\n\t\t\t\t\tthis.val.start = math.invert(this.clickPos.touches[1].y/this.GUI.h);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.val.stop < this.val.start) {\n\t\t\tthis.tempstart = this.val.start;\n\t\t\tthis.val.start = this.val.stop;\n\t\t\tthis.val.stop = this.tempstart;\n\t\t\tif (this.firsttouch==\"start\") {\n\t\t\t\tthis.firsttouch = \"stop\";\n\t\t\t} else {\n\t\t\t\tthis.firsttouch = \"start\";\n\t\t\t}\n\t\t} \n\t\tthis.val = {\n\t\t\tstart: math.clip(this.val.start, 0, 1),\n\t\t\tstop: math.clip(this.val.stop, 0, 1),\n\t\t} \n\t\tthis.val['size'] = math.prune(math.clip(Math.abs(this.val.stop - this.val.start), 0, 1), 3)\n\t\n\t\tthis.draw();\n\n\t\tthis.transmit(this.val);\n\n\t} else if (this.mode==\"area\") {\n\n\t\tif (this.hslider) {\n\t\t\tvar moveloc = this.clickPos.x/this.GUI.w;\n\t\t\tvar movesize = (this.touchdown.y - this.clickPos.y)/this.GUI.h;\n\t\t} else {\n\t\t\tvar moveloc = nx.invert(this.clickPos.y/this.GUI.h);\n\t\t\tvar movesize = (this.touchdown.x - this.clickPos.x)/this.GUI.w;\n\t\t//\tmoveloc *= -1;\n\t\t\tmovesize *= -1;\n\t\t}\n\t\tmovesize /= 3;\n\t\tvar size = this.startval.size + movesize;\n\t\tsize = math.clip(size,0.001,1);\n\n\t\tthis.val = {\n\t\t\tstart: moveloc - size/2,\n\t\t\tstop: moveloc + size/2\n\t\t}\n\n\t\tthis.val.start = math.clip(this.val.start,0,1);\n\t\tthis.val.stop = math.clip(this.val.stop,0,1);\n\n\t\tthis.draw();\n\n\t\tthis.transmit(this.val);\n\n\t}\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/range.js\n// module id = 41\n// module chunks = 0","var util = require('util');\nvar widget = require('../core/widget');\n\n/**\n\t@class select\n\tHTML-style option selector. Outputs the chosen text string. <br> **Note:** Currently the canvas is actaully replaced by an HTML select object. Any inline style on your canvas may be lost in this transformation. To style the resultant select element, we recommend creating CSS styles for the select object using its ID or the select tag.\n\t```html\n\t<canvas nx=\"select\" choices=\"sine,saw,square\"></canvas>\n\t```\n\t<canvas nx=\"select\" choices=\"sine,saw,square\"></canvas>\n*/\n\nvar select = module.exports = function (target) {\n\tthis.defaultSize = { width: 200, height: 30 };\n\twidget.call(this, target);\n\n\t/** @property {array} choices Desired choices, as an array of strings. Can be initialized with a \"choices\" HTML attribute of comma-separated text (see example above).\n\t```js\n\tselect1.choices = [\"PartA\", \"PartB\", \"GoNuts\"]\n\tselect1.init()\n\t```\n\t*/\n\tthis.choices = [ ];\n\n\t/** @property {object} val\n\t\t| | data\n\t\t| --- | ---\n\t\t| *value* | Text string of option chosen\n\t*/\n\tthis.val = new Object();\n\n\n\tthis.canvas.ontouchstart = null;\n\tthis.canvas.ontouchmove = null;\n\tthis.canvas.ontouchend = null;\n\n\tif (this.canvas.getAttribute(\"choices\")) {\n\t\tthis.choices = this.canvas.getAttribute(\"choices\");\n\t\tthis.choices = this.choices.split(\",\");\n\t}\n\tvar htmlstr = '<select id=\"'+this.canvasID+'\" class=\"nx\" nx=\"select\" style=\"height:'+this.GUI.h+'px;width:'+this.GUI.w+'px;\" onchange=\"'+this.canvasID+'.change(this)\"></select><canvas height=\"1px\" width=\"1px\" style=\"display:none\"></canvas>'\n\tvar canv = this.canvas\n\tvar cstyle = this.canvas.style\n\tvar parent = canv.parentNode\n\tvar newdiv = document.createElement(\"span\")\n\tnewdiv.innerHTML = htmlstr\n\tnewdiv.className = \"nx\"\n\tparent.replaceChild(newdiv,canv)\n\tthis.sel = document.getElementById(this.canvasID)\n\tfor (var prop in cstyle)\n \tthis.sel.style[prop] = cstyle[prop];\n\n\tthis.canvas = document.getElementById(this.canvasID);\n\n this.canvas.style.backgroundColor = this.colors.fill;\n this.canvas.style.border = \"solid 2px \"+this.colors.border;\n this.canvas.style.color = this.colors.black;\n this.canvas.style.fontSize = Math.round(this.GUI.h/2.3) + \"px\"\n\n this.canvas.className = \"\"\n\n}\nutil.inherits(select, widget);\n\nselect.prototype.init = function() {\n\n this.canvas.style.backgroundColor = this.colors.fill;\n this.canvas.style.border = \"solid 2px \"+this.colors.border;\n this.canvas.style.color = this.colors.black;\n\n var optlength = this.canvas.options.length;\n\tfor (i = 0; i < optlength; i++) {\n\t this.canvas.options[i] = null;\n\t}\n\n\tfor (var i=0;i<this.choices.length;i++) {\n\t\tvar option=document.createElement(\"option\");\n\t\toption.text = this.choices[i];\n\t\toption.value = this.choices[i];\n\t\tthis.canvas.add(option,null);\n\t}\n\n\tthis.val.text = this.choices[0]\n\n}\n\nselect.prototype.change = function(thisselect) {\n\tthis.val.text = thisselect.value;\n\tthis.val.value = thisselect.selectedIndex;\n\tthis.transmit(this.val);\n}\n\nselect.prototype.draw = function() {\n\n\t\t// included so that when .set() calls .draw(), this widget updates its value\n\t\tthis.canvas.value = this.val.text\n this.canvas.style.backgroundColor = this.colors.fill;\n this.canvas.style.color = this.colors.black;\n this.canvas.style.border = \"solid 2px \"+this.colors.border;\n\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/select.js\n// module id = 42\n// module chunks = 0","var math = require('../utils/math')\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class slider \n\tSlider (vertical or horizontal)\n\t```html\n\t<canvas nx=\"slider\"></canvas>\n\t```\n\t<canvas nx=\"slider\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar slider = module.exports = function (target) {\n\tthis.defaultSize = { width: 35, height: 110 };\n\twidget.call(this, target);\n\n if (this.canvas.getAttribute(\"min\")!=null) {\n this.min = parseFloat(this.canvas.getAttribute(\"min\"));\n } else {\n \tthis.min = 0\n }\n if (this.canvas.getAttribute(\"max\")!=null) {\n this.max = parseFloat(this.canvas.getAttribute(\"max\"));\n } else {\n \tthis.max = 1\n }\n if (this.canvas.getAttribute(\"step\")!=null) {\n this.step = parseFloat(this.canvas.getAttribute(\"step\"));\n } else {\n \tthis.step = 0.001\n }\n\n\t/** @property {object} val \n\t\t| | data\n\t\t| --- | ---\n\t\t| *value* | Slider value (float 0-1)\n\t*/\n\tthis.val.value = nx.scale(0.7,0,1,this.min,this.max)\n\t\n\n\t/** @property {string} mode Set \"absolute\" or \"relative\" mode. In absolute mode, slider will jump to click/touch position. In relative mode, it will not.\n\t```js\n\tnx.onload = function() {\n\t // Slider will not jump to touch position.\n\t slider1.mode = \"relative\" \n\t}\n\t```\n\t*/\n\tthis.mode = \"absolute\";\n\n\t/** @property {boolean} hslider Whether or not the slider should be horizontal. This is set to true automatically if the canvas is wider than it is tall. To override the default decision, set this property to true to create a horizontal slider, or false to create a vertical slider.\n\t\n\t```js\n\tnx.onload = function() {\n\t //forces horizontal slider \n\t slider1.hslider = true\n\t slider1.draw();\n\t //forces vertical slider \n\t slider2.hslider = false\n\t slider2.draw();\n\t}\n\t```\n\t*/\n\tthis.hslider = false;\n\tthis.handle;\n\tthis.relhandle;\n\tthis.cap;\n\n\tthis.maxdigits = 3\n\n\tthis.calculateDigits = nx.calculateDigits;\n\n\tthis.init();\n}\nutil.inherits(slider, widget);\n\nslider.prototype.init = function() {\n\n\t//decide if hslider or vslider\n\tif (this.GUI.h>=this.GUI.w) {\n\t\tthis.hslider = false;\n\t} else {\n\t\tthis.hslider = true;\n\t}\n\n\n\tthis.draw();\n}\n\n\nslider.prototype.draw = function() {\n\n\tvar normalval = this.normalize(this.val.value)\n\n\t//figure out text size\n\tthis.digits = this.calculateDigits()\n\n\tthis.erase();\n\t\t\n\twith (this.context) {\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h);\n\t\n\t\tif (!this.hslider) {\n\n\t\t\tvar x1 = 0;\n\t\t\tvar y1 = this.GUI.h-normalval*this.GUI.h;\n\t\t\tvar x2 = this.GUI.w;\n\t\t\tvar y2 = this.GUI.h;\n\t\t\n\t\t\tfillStyle = this.colors.accent;\n\t\t\tfillRect(x1,y1,x2-x1,y2-y1);\n\t\t\t\n\t\t\t//text\n\t\t\tvar valtextsize = (this.GUI.w / this.digits.total) * 1.2\n\t\t\tif (valtextsize > 6) {\n\n\t\t\t\t// figure out val text location\n\t\t if (y1 < this.GUI.h - valtextsize/2-5) {\n\t\t\t\t\tfillStyle = this.colors.white\n\t\t \tvar texty = this.GUI.h-valtextsize/2-5\n\t\t } else {\n\t\t\t\t\tfillStyle = this.colors.accent\n\t\t \tvar texty = y1 - valtextsize/2-5\n\t\t }\n\t\t var textx = this.GUI.w/2\n\t\t var valtextAlign = \"center\"\n\t\t var valtextBaseline = \"middle\"\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tvar x1 = 0;\n\t\t\tvar y1 = 0;\n\t\t\tvar x2 = normalval*this.GUI.w;\n\t\t\tvar y2 = this.GUI.h;\n\t\t\n\t\t\tfillStyle = this.colors.accent\n\t\t\tfillRect(x1,y1,x2-x1,y2-y1)\n\n\t\t\t//text\n\t\t\tvar valtextsize = this.GUI.h/2\n\t\t\tif (valtextsize > 6) {\n\n\t\t\t\t// figure out val text location\n\t\t if (x2 > this.digits.total*valtextsize/2) {\n\t\t\t\t\tfillStyle = this.colors.white\n\t\t \tvar textx = 5\n\t\t } else {\n\t\t\t\t\tfillStyle = this.colors.accent\n\t\t \tvar textx = x2 + 5\n\t\t }\n\t\t var texty = this.GUI.h/2\n\t\t var valtextAlign = \"left\"\n\t\t var valtextBaseline = \"middle\"\n\t\t\t}\n\n\t\t}\n\n\n var valtext = this.val.value.toFixed(this.digits.decimals)\n textBaseline = valtextBaseline\n\t\ttextAlign = valtextAlign\n font = valtextsize+\"px 'Open Sans'\"\n fillText(valtext,textx,texty);\n\n\n\t\tif (this.label) {\n\t\t\tthis.drawLabel()\n\t\t}\n\t}\n}\n\nslider.prototype.click = function() {\n\tthis.move();\n}\n\nslider.prototype.move = function() {\n\n\tvar normalval = this.normalize(this.val.value)\n\n\tif (this.hslider) {\n\t\tthis.handle = this.clickPos.x;\n\t\tthis.relhandle = this.deltaMove.x;\n\t\tthis.cap = this.GUI.w;\n\t} else {\n\t\tthis.handle = this.clickPos.y;\n\t\tthis.relhandle = this.deltaMove.y*-1;\n\t\tthis.cap = this.GUI.h\n\t}\n\n\tif (this.mode==\"absolute\") {\n\t\tif (this.clicked) {\n\t\t\tif (!this.hslider) {\n\t\t\t\tnormalval = Math.abs((math.clip(this.clickPos.y/this.GUI.h, 0, 1) - 1));\n\t\t\t} else {\t\n\t\t\t\tnormalval = math.clip(this.clickPos.x/this.GUI.w, 0, 1);\n\t\t\t}\n\t\t\tthis.draw();\n\t\t}\n\t} else if (this.mode==\"relative\") {\n\t\tif (this.clicked) {\n\t\t\tif (!this.hslider) {\n\t\t\t\tnormalval = math.clip(normalval + ((this.deltaMove.y*-1)/this.GUI.h),0,1);\n\t\t\t} else {\n\t\t\t\tnormalval = math.clip(normalval + ((this.deltaMove.x)/this.GUI.w),0,1);\n\t\t\t}\n\t\t\tthis.draw();\n\t\t}\n\t}\n\n\tthis.val.value = math.prune(this.rangify(normalval),3)\n\tthis.transmit(this.val);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/slider.js\n// module id = 43\n// module chunks = 0","var util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class string \n\tAnimated model of a plucked string interface.\n\t```html\n\t<canvas nx=\"string\"></canvas>\n\t```\n\t<canvas nx=\"string\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar string = module.exports = function (target) {\n\tthis.defaultSize = { width: 150, height: 75 };\n\twidget.call(this, target);\n\t\n\t/** @property {object} val Object containing the core interactive aspects of the widget, which are also its data output. Has the following properties: \n\t\t| | data\n\t\t| --- | ---\n\t\t| *string* | Index of the string that is plucked (starts at 0)\n\t\t| *x* | Where on the string the pluck occured (float 0-1);\n\t*/\n\tthis.val = {\n\t\tstring: 0,\n\t\tx: 0\n\t}\n\t/** @property {integer} numberOfStrings How many strings in the widget. We recommend setting this property with .setStrings() */\n\tthis.numberOfStrings = 10;\n\tthis.strings = new Array();\n\tthis.abovestring = new Array();\n\t/** @property {integer} friction How quickly the string slows down */\n\tthis.friction = 1;\n\t\n\tvar stringdiv;\n\n\tthis.init();\n\n\tnx.aniItems.push(this.draw.bind(this));\n}\nutil.inherits(string, widget);\n\nstring.prototype.init = function() {\n\tstringdiv = this.GUI.h/(this.numberOfStrings + 1);\n\tfor (var i=0;i<this.numberOfStrings;i++) {\n\t\tthis.strings[i] = {\n\t\t\tx1: this.lineWidth,\n\t\t\ty1: stringdiv*(1+i),\n\t\t\tx2: this.GUI.w - this.lineWidth,\n\t\t\ty2: stringdiv*(i+1),\n\t\t\theld: false, // whether or not it's gripped\n\t\t\tvibrating: false, // whether or not its vibrating\n\t\t\tforce: 0, // amount of force of pull on string\n\t\t\tmaxstretch: 0, // vibration cap (in Y domain)\n\t\t\tstretch: 0, // current point vibrating in y domain\n\t\t\tdirection: 0, // which direction it's vibrating\n\t\t\tabove: false // is mouse above or below string\n\t\t};\n\t}\n\tthis.draw();\n}\n\nstring.prototype.pulse = function() {\n\tthis.draw();\n}\n\n/* @method setStrings Sets how many strings are in the widget.\n\t```js\n\tstring1.setStrings(20);\n\t``` \n\t*/\nstring.prototype.setStrings = function(val) {\n\tthis.numberOfStrings = val;\n\tthis.strings = new Array();\n\tthis.init();\n}\n\nstring.prototype.draw = function() {\n\tthis.erase();\n\twith (this.context) {\n\t\tstrokeStyle = this.colors.border;\n\t\tfillStyle = this.colors.fill;\n\t\tlineWidth = this.lineWidth;\n\t//\tstroke();\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h);\n\t\tstrokeStyle = this.colors.accent;\n\n\t\tfor (var i = 0;i<this.strings.length;i++) {\n\n\t\t\tvar st = this.strings[i];\n\n\t\t\tif (st.vibrating) {\n\t\t\t\tif (st.maxstretch < 0) {\n\t\t\t\t\tst.vibrating = false;\n\t\t\t\t\tst.held = false;\n\t\t\t\t}\n\t\t\t\tst.stretch = st.stretch + st.direction;\n\t\t\t\t\n\t\t\t\tif (Math.abs(st.stretch) > st.maxstretch) {\n\t\t\t\t\t//st.direction *= (-0.99);\n\t\t\t\t\tst.direction *= -1;\n\t\t\t\t\tst.stretch = st.stretch + st.direction;\n\t\t\t\t\tst.maxstretch = st.maxstretch - this.friction;\n\n\t\t\t\t\tst.direction = (st.direction / Math.abs(st.direction)) * (st.maxstretch/1)\n\t\t\t\t}\n\n\t\t\t\tbeginPath();\n\t\t\t\tmoveTo(st.x1, st.y1);\n\t\t\t\tquadraticCurveTo(this.GUI.w/2, st.y1+st.stretch, st.x2, st.y2);\n\t\t\t\tstroke();\n\t\t\t\tclosePath();\n\t\t\t\tst.on = true;\n\n\n\t\t\t} else if (st.held) {\n\t\t\t\t\t//will draw rounded\n\t\t\t\t\t//if mouse is higher than string and gripup\n\t\t\t\t\t//or if mouse is \n\t\t\t\t\t//\tif (this.clickPos.y-st.y1<0 && st.gripup || this.clickPos.y-st.y1>0 && !st.gripup) {\n\t\t\t\t\tbeginPath();\n\t\t\t\t\tmoveTo(st.x1, st.y1);\n\t\t\t\t\tquadraticCurveTo(this.clickPos.x, this.clickPos.y, st.x2, st.y2);\n\t\t\t\t\tstroke();\n\t\t\t\t\tclosePath();\n\t\t\t\t\tst.on = true;\t\n\t\t\t\t\t/*\t} else {\n\t\t\t\t\tbeginPath();\n\t\t\t\t\tmoveTo(st.x1, st.y1);\n\t\t\t\t\tlineTo(st.x2, st.y2);\n\t\t\t\t\tstroke();\n\t\t\t\t\tclosePath();\n\t\t\t\t} */\n\t\t\t} else {\n\t\t\t\tbeginPath();\n\t\t\t\tmoveTo(st.x1, st.y1);\n\t\t\t\tlineTo(st.x2, st.y2);\n\t\t\t\tstroke();\n\t\t\t\tclosePath();\n\t\t\t\tif (st.on) {\n\t\t\t\t\tst.on = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tthis.drawLabel();\n}\n\nstring.prototype.click = function() {\n\tfor (var i = 0;i<this.numberOfStrings;i++) {\n\t\tthis.strings[i].above = (this.clickPos.y<this.strings[i].y1);\n\t}\n\tthis.draw();\n}\n\nstring.prototype.move = function() {\n\tif (this.clicked) {\n\t\tfor (var i = 0;i<this.strings.length;i++) {\n\n\t\t\t//if crosses string\n\t\t\tif (this.strings[i].above != (this.clickPos.y<this.strings[i].y1) ) {\n\t\t\t\tthis.strings[i].held = true;\n\t\t\t\tthis.strings[i].above ^= true;\n\t\t\t}\n\n\t\t\tif (this.strings[i].held && Math.abs(this.clickPos.y - this.strings[i].y1) > this.GUI.h/(this.strings.length*3)) {\n\n\t\t\t\tthis.pluck(i)\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n}\n\nstring.prototype.release = function() {\n\tfor (var i = 0;i<this.strings.length;i++) {\n\t\tif (this.strings[i].held) {\n\t\t\tthis.pluck(i);\n\t\t}\n\t}\t\n}\n\nstring.prototype.pluck = function(which) {\n\tvar i = which;\n\tthis.val = {\n\t\tstring: i,\n\t\tx: this.clickPos.x/this.GUI.w\n\t}\n\tthis.transmit(this.val);\n\tthis.strings[i].held = false;\n\tthis.strings[i].force = this.clickPos.y - this.strings[i].y1;\n\tthis.strings[i].maxstretch = Math.abs(this.clickPos.y - this.strings[i].y1);\n\tthis.strings[i].stretch = this.clickPos.y - this.strings[i].y1;\n\tthis.strings[i].vibrating = true;\n\tthis.strings[i].direction = (this.clickPos.y - this.strings[i].y1)/Math.abs(this.clickPos.y - this.strings[i].y1) * ((this.clickPos.y - this.strings[i].y1)/-1.2);\n}\n\nstring.prototype.customDestroy = function() {\n\tnx.removeAni(this.draw.bind(this));\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/string.js\n// module id = 44\n// module chunks = 0","var math = require('../utils/math')\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class tabs \n\t\n\t```html\n\t<canvas nx=\"tabs\"></canvas>\n\t```\n\t<canvas nx=\"tabs\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar tabs = module.exports = function(target) {\n\t\n\tthis.defaultSize = { width: 150, height: 50 };\n\twidget.call(this, target);\n\t\n\t//define unique attributes\n\tthis.choice = 0;\n\tthis.val = {\n\t\tindex: 0,\n\t\ttext: \"\"\n\t}\n\tthis.tabwid = 0;\n\tthis.options = [\"one\", \"two\", \"three\"]\n\t//init\n\tthis.init();\n\n}\n\nutil.inherits(tabs, widget);\n\n\ntabs.prototype.init = function() {\n\tthis.draw();\n}\n\n\ntabs.prototype.draw = function() {\n\n\twith (this.context) {\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h)\n\n\t\ttextAlign = \"center\"\n\t\ttextBaseline = \"middle\"\n\t\tfont = \"normal \"+this.GUI.h/5+\"px courier\"\n\t}\n\n\tthis.tabwid = this.GUI.w/this.options.length\n\n\tfor (var i=0;i<this.options.length;i++) {\n\t\tif (i==this.choice) {\n\t\t\tvar tabcol = this.colors.accent;\n\t\t\tvar textcol = this.colors.white;\n\t\t} else {\n\t\t\tvar tabcol = this.colors.fill;\n\t\t\tvar textcol = this.colors.black;\n\t\t\tglobalAlpha = 0.7;\n\t\t}\n\t\twith (this.context) {\n\t\t\tfillStyle=tabcol;\n\t\t\tfillRect(this.tabwid*i,0,this.tabwid,this.GUI.h)\n\t\t\tif (i!=this.options.length-1) {\n\t\t\t\tbeginPath();\n\t\t\t\tmoveTo(this.tabwid*(i+1),0)\n\t\t\t\tlineTo(this.tabwid*(i+1),this.GUI.h)\n\t\t\t\tlineWidth = 1;\n\t\t\t\tstrokeStyle = this.colors.border\n\t\t\t\tstroke()\n\t\t\t\tclosePath()\n\t\t\t}\n\t\t\tfillStyle=textcol;\n\t\t\tfont = this.fontSize+\"px \"+this.font;\n\t\t\tfillText(this.options[i],this.tabwid*i+this.tabwid/2,this.GUI.h/2)\n\t\t}\n\t\t\n\t}\n}\n\n\ntabs.prototype.click = function() {\n\tthis.choice = ~~(this.clickPos.x / this.tabwid);\n\tthis.val = {\n\t\tindex: this.choice,\n\t\ttext: this.options[this.choice]\n\t}\n\tthis.transmit(this.val)\n\tthis.draw();\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/tabs.js\n// module id = 45\n// module chunks = 0","var util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class text \n\tText editor. Outputs the typed text string when Enter is pressed. <br> **Note:** Currently the canvas is actaully replaced by an HTML textarea object. Any inline style on your canvas may be lost in this transformation. To style the resultant textarea element, we recommend creating CSS styles for the textarea element using its ID or the textarea tag.\n\t```html\n\t<canvas nx=\"text\"></canvas>\n\t```\n\t<canvas nx=\"text\"></canvas>\n*/\n\nvar text = module.exports = function (target) {\n\tthis.defaultSize = { width: 200, height: 100 };\n\twidget.call(this, target);\n\n\t/** @property {object} val \n\t\t| | data\n\t\t| --- | ---\n\t\t| *text* | Text string\n\t*/\n\tthis.val = {\n\t\ttext: \"\"\n\t}\n\n\tvar htmlstr = '<textarea id=\"'+this.canvasID+'\" style=\"height:'+this.GUI.h+'px;width:'+this.GUI.w+'px;\" onkeydown=\"'+this.canvasID+'.change(event,this)\"></textarea><canvas height=\"1px\" width=\"1px\" style=\"display:none\"></canvas>' \n\tvar canv = this.canvas\n\tvar cstyle = this.canvas.style\n\tvar parent = canv.parentNode;\n\tvar newdiv = document.createElement(\"span\");\n\tnewdiv.innerHTML = htmlstr;\n\tnewdiv.className = \"nx\"\n\tparent.replaceChild(newdiv,canv)\n\tthis.el = document.getElementById(this.canvasID)\n\n\tfor (var prop in cstyle)\n \tthis.el.style[prop] = cstyle[prop];\n\n\tthis.el.style.display = \"block\"\n\tthis.el.style.backgroundColor = this.colors.fill\n\tthis.el.style.border = \"none\"\n\tthis.el.style.color = this.colors.black\n\tthis.el.style.outline = \"none\"\n\tthis.el.style.resize = \"none\"\n\tthis.el.style.boxSizing = \"border-box\"\n\tthis.el.style.padding = \"5px\"\n\tthis.el.style.fontFamily = nx.font\n\tthis.el.style.fontSize = \"16px\"\n\tthis.el.className = \"\"\n\n\n\tthis.canvas = document.getElementById(this.canvasID);\n\n\n}\nutil.inherits(text, widget);\n\ntext.prototype.init = function() {\n\t\n\tthis.canvas.ontouchstart = null;\n\tthis.canvas.ontouchmove = null;\n\tthis.canvas.ontouchend = null;\n\n this.canvas.style.backgroundColor = this.colors.fill;\n this.canvas.style.color = this.colors.black;\n\t\n}\n\n// should have a modified \"set\" function\ntext.prototype.change = function(e,el) {\n\tthis.val.text = el.value\n\tif (e.which==\"13\") {\n\t\tthis.transmit(this.val)\n\t\tthis.val.text = \"\"\n\t\tthis.draw()\n\t\te.preventDefault()\n\t}\n}\n\ntext.prototype.draw = function() {\n\t// needed especially for ghost\n\tthis.el.value = this.val.text \n\t\n this.canvas.style.backgroundColor = this.colors.fill;\n this.canvas.style.color = this.colors.black;\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/text.js\n// module id = 46\n// module chunks = 0","var math = require('../utils/math')\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class tilt \n\tMobile and Mac/Chrome-compatible tilt sensor. May not work on all devices! <br> **Notes:** Clicking on this widget toggles it inactive or active. <br>\n\tWe recommend not calling .init() on this object after the original initialization, because it will add additional redundant tilt listeners to your document.\n\t```html\n\t<canvas nx=\"tilt\"></canvas>\n\t```\n\t<canvas nx=\"tilt\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar tilt = module.exports = function (target) {\n\tthis.defaultSize = { width: 50, height: 50 };\n\twidget.call(this, target);\n\t\n\tthis.tiltLR;\n\tthis.tiltFB;\n\tthis.z;\n\t/** @property {boolean} active Whether or not the tilt widget is on (animating and transmitting data). */\n\tthis.active = true;\n\n\t/** @property {object} val Object containing the core interactive aspects of the widget, which are also its data output. Has the following properties: \n\t\t| | data\n\t\t| --- | ---\n\t\t| *x* | X-axis rotation if supported (-1 to 1)\n\t\t| *y* | Y-axis rotation if supported (-1 to 1)\n\t\t| *z* | Z-axis rotation if supported (-1 to 1 or possibly 0 to 360 depending on device)\n\t*/\n\tthis.val = {\n\t\tx: 0,\n\t\ty: 0,\n\t\tz: 0\n\t}\n\n\t/** @property {string} text Text shown on tilt object\n\t*/\n\t\n\tthis.text = \"TILT\";\n\tthis.init();\n\n\tthis.boundChromeTilt = this.chromeTilt.bind(this)\n\tthis.boundMozTilt = this.mozTilt.bind(this)\n\n\tif (window.DeviceOrientationEvent) {\n\t\twindow.addEventListener('deviceorientation', this.boundChromeTilt, false);\n\t} else if (window.OrientationEvent) {\n\t \twindow.addEventListener('MozOrientation', this.boundMozTilt, false);\n\t} else {\n\t \tconsole.log(\"Not supported on your device or browser.\")\n\t}\n\t\n}\nutil.inherits(tilt, widget);\n\ntilt.prototype.deviceOrientationHandler = function() {\n\t\n\tthis.val = {\n\t\tx: math.prune(this.tiltLR/90,3),\n\t\ty: math.prune(this.tiltFB/90,3),\n\t\tz: math.prune(this.z,3)\n\t}\n\n\tif (this.active) {\n\t\tthis.transmit(this.val);\n\t}\n\t\n}\n\ntilt.prototype.chromeTilt = function(eventData) {\n this.tiltLR = eventData.gamma;\n\t\tthis.tiltFB = eventData.beta;\n\t\tthis.z = eventData.alpha\n this.deviceOrientationHandler();\n this.draw();\n}\n\ntilt.prototype.mozTilt = function(eventData) {\n this.tiltLR = eventData.x * 90;\n // y is the front-to-back tilt from -1 to +1, so we need to convert to degrees\n // We also need to invert the value so tilting the device towards us (forward) \n // results in a positive value. \n this.tiltFB = eventData.y * -90;\n this.z = eventData.z;\n this.deviceOrientationHandler();\n this.draw();\n}\n\ntilt.prototype.init = function() {\n\tthis.draw();\n}\n\ntilt.prototype.draw = function() {\n\t\n\tthis.erase();\n\n\twith (this.context) {\n\t\tfillStyle = this.colors.fill;\n\t fillRect(0,0,this.GUI.w,this.GUI.h);\n\n\t\tsave(); \n\t\ttranslate(this.GUI.w/2,this.GUI.h/2)\n\t\trotate(-this.val.x*Math.PI/2);\n\t\ttranslate(-this.GUI.w/2,-this.GUI.h/2)\n\t globalAlpha = 0.4;\n\n\t if (this.active) {\n\t \tfillStyle = this.colors.accent;\n\t } else {\n\t \tfillStyle = this.colors.border;\n\t }\n\n\t\tfillRect(-this.GUI.w,this.GUI.h*(this.val.y/2)+this.GUI.h/2,this.GUI.w*3,this.GUI.h*2)\n\t\tfont = \"bold \"+this.GUI.h/5+\"px \"+this.font;\n\t\ttextAlign = \"center\";\n\t\ttextBaseline = \"middle\";\n\t\tfillText(this.text, this.GUI.w/2, this.GUI.h*(this.val.y/2)+this.GUI.h/2-this.GUI.h/15);\n\t\tglobalAlpha = 1;\n\t\trestore();\n\n\t\tclearRect(0,this.GUI.h,this.GUI.w,this.height - this.GUI.h)\n\t}\n\tthis.drawLabel();\n}\n\ntilt.prototype.click = function() {\n\tthis.active = !this.active;\n}\n\ntilt.prototype.customDestroy = function() {\n\tthis.active = false;\n\twindow.removeEventListener(\"deviceorientation\",this.boundChromeTilt,false);\n\twindow.removeEventListener(\"mozOrientation\",this.boundMozTilt,false);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/tilt.js\n// module id = 47\n// module chunks = 0","var drawing = require('../utils/drawing');\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class toggle \n\tOn/off toggle\n\t```html\n\t<canvas nx=\"toggle\"></canvas>\n\t```\n\t<canvas nx=\"toggle\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar toggle = module.exports = function (target) {\n\tthis.defaultSize = { width: 50, height: 50 };\n\twidget.call(this, target);\n\n\t/** @property {object} val Object containing the core interactive aspects of the widget, which are also its data output. Has the following properties: \n\t\t| | data\n\t\t| --- | ---\n\t\t| *value*| 1 if on, 0 if off\n\t*/\n\tthis.val = {\n\t\tvalue: 0\n\t}\n\tthis.init();\n}\nutil.inherits(toggle, widget);\n\ntoggle.prototype.init = function() {\n\tthis.draw();\n}\n\ntoggle.prototype.draw = function() {\n\t\n\tthis.erase()\n\n\twith (this.context) {\n\t\tif (this.val.value) {\n\t\t\tfillStyle = this.colors.accent;\n\t\t//\tstrokeStyle = this.colors.white;\n\t\t//\tstrokeAlpha = 0.3\n\t\t\tstrokeStyle = this.colors.accenthl;\n\t\t\tstrokeAlpha = 1\n\t\t} else {\n\t\t\tfillStyle = this.colors.fill;\n\t\t\tstrokeStyle = this.colors.border;\n\t\t\tstrokeAlpha = 1\n\t\t}\n\t\tlineWidth = Math.sqrt(this.GUI.w)/2;\n\t\t//lineWidth = this.GUI.w / 20;\n\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h);\n\t\tglobalAlpha = strokeAlpha\n\t\tstrokeRect(lineWidth/2,lineWidth/2,this.GUI.w-lineWidth,this.GUI.h-lineWidth);\n\t\tglobalAlpha = 1\n\t}\n\n\tthis.drawLabel();\n\t\n}\n\ntoggle.prototype.click = function() {\n\tif (!this.val.value) {\n\t\tthis.val.value = 1;\n\t} else {\n\t\tthis.val.value = 0;\n\t}\n\tthis.draw();\n\tthis.transmit(this.val);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/toggle.js\n// module id = 48\n// module chunks = 0","var drawing = require('../utils/drawing');\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class typewriter \n\tComputer keyboard listener and visualization. (Desktop only) <br> **Note:** Clicking on the widget toggles it inactive or active, which can be useful if you need to temporarily type without triggering the widget's events.\n\t```html\n\t<canvas nx=\"typewriter\"></canvas>\n\t```\n\t<canvas nx=\"typewriter\" style=\"margin-left:25px\"></canvas>\n*/\n\nvar typewriter = module.exports = function(target) {\n\tthis.defaultSize = { width: 300, height: 100 };\n\twidget.call(this, target);\n\n\t\n\tthis.letter = \"\"\n\tthis.keywid = this.GUI.w/14.5;\n\tthis.keyhgt = this.GUI.h/5\n\n\t/** @property {boolean} active Whether or not the widget is on (listening for events and transmitting values).*/ \n\tthis.active = true;\n\n\t/** @property {object} val Object containing the core interactive aspects of the widget, which are also its data output. Has the following properties: \n\t\t| | data\n\t\t| --- | ---\n\t\t| *key* | symbol of key pressed (example: \"a\")\n\t\t| *ascii* | ascii value of key pressed (example: 48)\n\t\t| *on* | 0 if key is being pressed, 1 if key is being released\n\t*/\n\tthis.val = {\n\t\tkey: \"\",\n\t\tascii: 0,\n\t\ton: 0\n\t}\n\n\tthis.rows = [\n\t\t[\n\t\t\t{ symbol: \"`\", value: 192, width: 1, on: false },\n\t\t\t{ symbol: \"1\", value: 49, width: 1, on: false },\n\t\t\t{ symbol: \"2\", value: 50, width: 1, on: false },\n\t\t\t{ symbol: \"3\", value: 51, width: 1, on: false },\n\t\t\t{ symbol: \"4\", value: 52, width: 1, on: false },\n\t\t\t{ symbol: \"5\", value: 53, width: 1, on: false },\n\t\t\t{ symbol: \"6\", value: 54, width: 1, on: false },\n\t\t\t{ symbol: \"7\", value: 55, width: 1, on: false },\n\t\t\t{ symbol: \"8\", value: 56, width: 1, on: false },\n\t\t\t{ symbol: \"9\", value: 57, width: 1, on: false },\n\t\t\t{ symbol: \"0\", value: 48, width: 1, on: false },\n\t\t\t{ symbol: \"-\", value: 189, width: 1, on: false },\n\t\t\t{ symbol: \"=\", value: 187, width: 1, on: false },\n\t\t\t{ symbol: \"delete\", value: 46, width: 1.5, on: false }\n\t\t],\n\t\t[\n\t\t\t{ symbol: \"tab\", value: 9, width: 1.5, on: false },\n\t\t\t{ symbol: \"q\", value: 81, width: 1, on: false },\n\t\t\t{ symbol: \"w\", value: 87, width: 1, on: false },\n\t\t\t{ symbol: \"e\", value: 69, width: 1, on: false },\n\t\t\t{ symbol: \"r\", value: 82, width: 1, on: false },\n\t\t\t{ symbol: \"t\", value: 84, width: 1, on: false },\n\t\t\t{ symbol: \"y\", value: 89, width: 1, on: false },\n\t\t\t{ symbol: \"u\", value: 85, width: 1, on: false },\n\t\t\t{ symbol: \"i\", value: 73, width: 1, on: false },\n\t\t\t{ symbol: \"o\", value: 79, width: 1, on: false },\n\t\t\t{ symbol: \"p\", value: 80, width: 1, on: false },\n\t\t\t{ symbol: \"[\", value: 219, width: 1, on: false },\n\t\t\t{ symbol: \"]\", value: 221, width: 1, on: false },\n\t\t\t{ symbol: \"\\\\\", value: 220, width: 1, on: false }\n\t\t],\n\t\t[\n\t\t\t{ symbol: \"caps\", value: 20, width: 1.75, on: false },\n\t\t\t{ symbol: \"a\", value: 65, width: 1, on: false },\n\t\t\t{ symbol: \"s\", value: 83, width: 1, on: false },\n\t\t\t{ symbol: \"d\", value: 68, width: 1, on: false },\n\t\t\t{ symbol: \"f\", value: 70, width: 1, on: false },\n\t\t\t{ symbol: \"g\", value: 71, width: 1, on: false },\n\t\t\t{ symbol: \"h\", value: 72, width: 1, on: false },\n\t\t\t{ symbol: \"j\", value: 74, width: 1, on: false },\n\t\t\t{ symbol: \"k\", value: 75, width: 1, on: false },\n\t\t\t{ symbol: \"l\", value: 76, width: 1, on: false },\n\t\t\t{ symbol: \";\", value: 186, width: 1, on: false },\n\t\t\t{ symbol: \"'\", value: 222, width: 1, on: false },\n\t\t\t{ symbol: \"enter\", value: 13, width: 1.75, on: false }\n\t\t],\n\t\t[\n\t\t\t{ symbol: \"shift\", value: 16, width: 2.25, on: false },\n\t\t\t{ symbol: \"z\", value: 90, width: 1, on: false },\n\t\t\t{ symbol: \"x\", value: 88, width: 1, on: false },\n\t\t\t{ symbol: \"c\", value: 67, width: 1, on: false },\n\t\t\t{ symbol: \"v\", value: 86, width: 1, on: false },\n\t\t\t{ symbol: \"b\", value: 66, width: 1, on: false },\n\t\t\t{ symbol: \"n\", value: 78, width: 1, on: false },\n\t\t\t{ symbol: \"m\", value: 77, width: 1, on: false },\n\t\t\t{ symbol: \",\", value: 188, width: 1, on: false },\n\t\t\t{ symbol: \".\", value: 190, width: 1, on: false },\n\t\t\t{ symbol: \"/\", value: 191, width: 1, on: false },\n\t\t\t{ symbol: \"shift\", value: 16, width: 2.25, on: false }\n\t\t],\n\t\t[\n\t\t\t{ symbol: \"fn\", value: 10, width: 1, on: false },\n\t\t\t{ symbol: \"ctrl\", value: 17, width: 1, on: false },\n\t\t\t{ symbol: \"opt\", value: 10, width: 1, on: false },\n\t\t\t{ symbol: \"cmd\", value: 10, width: 1.25, on: false },\n\t\t\t{ symbol: \"space\", value: 32, width: 5, on: false },\n\t\t\t{ symbol: \"cmd\", value: 10, width: 1, on: false },\n\t\t\t{ symbol: \"opt\", value: 10, width: 1, on: false },\n\t\t\t{ symbol: \"left\", value: 37, width: .81, on: false },\n\t\t\t{ symbol: \"up\", value: 38, width: .81, on: false },\n\t\t\t{ symbol: \"down\", value: 40, width: .81, on: false },\n\t\t\t{ symbol: \"right\", value: 39, width: .81, on: false }\n\t\t]\n\t]\n\n\tthis.boundType = this.typekey.bind(this);\n\tthis.boundUntype = this.untype.bind(this);\n\twindow.addEventListener(\"keydown\", this.boundType);\n\twindow.addEventListener(\"keyup\", this.boundUntype);\n\n\tthis.init();\n}\nutil.inherits(typewriter, widget);\n\t\ntypewriter.prototype.init = function() {\n\n\tthis.keywid = this.GUI.w/14.5;\n\tthis.keyhgt = this.GUI.h/5\n\t\n\tthis.draw();\n}\n\ntypewriter.prototype.draw = function() {\t// erase\n\tthis.erase();\n\n\tif (!this.active) {\n\t\tthis.context.globalAlpha = 0.4\n\t} else {\n\t\tthis.context.globalAlpha = 1\n\t}\n\n\twith (this.context) {\n\n\t\tstrokeStyle = this.colors.borderhl\n\t\tfillStyle = this.colors.accent \n\t\tlineWidth = 1\n\n\t\tfor (var i=0;i<this.rows.length;i++) {\n\t\t\tvar currkeyL = 0;\n\t\t\tfor (var j=0;j<this.rows[i].length;j++) {\n\n\t\t\t\tif (this.val.key==this.rows[i][j].symbol) {\n\t\t\t\t\tif (this.val.on) {\n\t\t\t\t\t\tthis.rows[i][j].on = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rows[i][j].on = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tdrawing.makeRoundRect(this.context, currkeyL , i*this.keyhgt,this.keywid*this.rows[i][j].width,this.keyhgt,4);\n\t\t\t\t\t\n\t\t\t\tif (this.rows[i][j].on) {\n\t\t\t\t\tfillStyle = this.colors.accent \n\t\t\t\t\tstrokeStyle = this.colors.accent \n\t\t\t\t\tfill()\n\t\t\t\t\tstroke()\n\t\t\t\t} else {\n\t\t\t\t\tfillStyle = this.colors.fill \n\t\t\t\t\tstrokeStyle = this.colors.borderhl\n\n\t\t\t\t\tfill()\n\t\t\t\t\tstroke()\n\t\t\t\t}\n\t\n\t\t\t\tcurrkeyL += this.keywid*this.rows[i][j].width;\n\n\t\t\t}\n\t\t}\n\n\t\tif (this.val.on) {\n\t\t\tthis.setFont();\n\t\t\tfillStyle = this.colors.borderhl;\n\t\t\tfont = this.GUI.h+\"px \"+this.font;\n\t\t\tfillText(this.val.key, this.GUI.w/2, this.GUI.h/2);\n\t\t\t\n\t\t\tglobalAlpha = 1\n\t\t}\n\n\t\tif (!this.active) {\n\t\t\tglobalAlpha = 0.7\n\t\t\tfillStyle = this.colors.borderhl;\n\t\t\tfont = (this.GUI.h/2)+\"px courier\";\n\t\t\ttextAlign = \"center\";\n\t\t\ttextBaseline = \"middle\"\n\t\t\tfillText(\"inactive\", this.GUI.w/2, this.GUI.h/2);\n\t\t}\n\t}\n\n\tthis.drawLabel();\n}\n\ntypewriter.prototype.click = function(e) {\n\tthis.active = !this.active;\n\tthis.draw();\n}\n\ntypewriter.prototype.typekey = function(e) {\n\tif (this.active) {\n\t\tvar currKey = e.which;\n\t\tfor (var i=0;i<this.rows.length;i++) {\n\t\t\tfor (var j=0;j<this.rows[i].length;j++) {\n\t\t\t\tif (currKey == this.rows[i][j].value) {\n\t\t\t\t\tthis.val.key = this.rows[i][j].symbol;\n\t\t\t\t\tthis.val.on = 1;\n\t\t\t\t\tthis.val.ascii = e.which;\n\t\t\t\t\tthis.transmit(this.val);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.draw();\n\t}\t\n}\n\ntypewriter.prototype.untype = function(e) {\n\tif (this.active) {\n\t\tvar currKey = e.which;\n\t\tfor (var i=0;i<this.rows.length;i++) {\n\t\t\tfor (var j=0;j<this.rows[i].length;j++) {\n\t\t\t\tif (currKey == this.rows[i][j].value) {\n\t\t\t\t//\tthis.rows[i][j].on = false;\n\t\t\t\t\tthis.val.key = this.rows[i][j].symbol;\n\t\t\t\t\tthis.val.on = 0;\n\t\t\t\t\tthis.val.ascii = e.which;\n\t\t\t\t\tthis.transmit(this.val);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.draw();\n\t}\n}\n\ntypewriter.prototype.customDestroy = function() {\n\twindow.removeEventListener(\"keydown\", this.boundType);\n\twindow.removeEventListener(\"keyup\", this.boundUntype);\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/typewriter.js\n// module id = 49\n// module chunks = 0","var math = require('../utils/math')\nvar util = require('util');\nvar widget = require('../core/widget');\n\n/** \n\t@class vinyl \n\tFor the boom bap\n\t```html\n\t<canvas nx=\"vinyl\"></canvas>\n\t```\n<!--\t<canvas nx=\"vinyl\" style=\"margin-left:25px\"></canvas> -->\n*/\n\nvar vinyl = module.exports = function (target) {\n\tthis.defaultSize = { width: 100, height: 100 };\n\twidget.call(this, target);\n\t\n\tthis.circleSize;\n\n\t/** @property speed The rotation increment. Default is 0.05. Not to be confused with .val.speed (see below) which is the data output. During rotation, .speed will always move towards .defaultSpeed */\n\tthis.speed = 0.05;\n\t/** @property defaultSpeed The \"steady-state\" rotation increment. Default is 0.05. During rotation, if .speed is changed, it will gradually move towards this. */\n\tthis.defaultspeed = 0.05\n\tthis.rotation = 0;\n\tthis.hasMovedOnce = false;\n\n\tthis.lockResize = true;\n\t\n\t/** @property {object} val Object containing the core interactive aspects of the widget, which are also its data output. Has the following properties: \n\t\t| | data\n\t\t| --- | ---\n\t\t| *speed*| Current speed of the record player's rotation. (Normal is 1.)\n\t*/\n\tthis.val = {\n\t\tspeed: 0\n\t}\n\tthis.init();\n\tnx.aniItems.push(this.spin.bind(this));\n}\nutil.inherits(vinyl, widget);\n\nvinyl.prototype.init = function() {\n\n\tthis.circleSize = (Math.min(this.center.x, this.center.y)-this.lineWidth);\n\tthis.draw();\n}\n\nvinyl.prototype.draw = function() {\n\tthis.erase()\n\n\twith (this.context) {\n\t\tstrokeStyle = this.colors.border;\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h)\n\t\t\n\t\t//draw main circle\n\t\tbeginPath();\n\t\tfillStyle = this.colors.black;\n\t\tarc(this.center.x, this.center.y, this.circleSize-5, 0, Math.PI*2, true);\n\t\tfill();\n\t\tclosePath();\n\n\n\t\t//draw circle in center\n\t\tbeginPath();\n\t\tfillStyle = this.colors.accent;\n\t\tarc(this.center.x, this.center.y*1, this.circleSize/4, 0, Math.PI*2, false);\n\t\tfill()\n\t\tclosePath();\n\n\n\t\t//draw tint\n\t\tbeginPath();\n\t\tglobalAlpha = 0.5;\n\t\tfillStyle = this.colors.fill;\n\t\tarc(this.center.x, this.center.y, this.circleSize, this.rotation, this.rotation + 0.4, false);\n\t\tlineTo(this.center.x, this.center.y);\n\t\tarc(this.center.x, this.center.y, this.circleSize, this.rotation+Math.PI, this.rotation +Math.PI+ 0.4, false);\n\t\tlineTo(this.center.x, this.center.y);\n\t\tfill();\n\t\tglobalAlpha = 1;\n\t\tclosePath(); \n\n\n\t\t//draw white circle in center\n\t\tbeginPath();\n\t\tfillStyle = this.colors.white;\n\t\tarc(this.center.x, this.center.y*1, this.circleSize/16, 0, Math.PI*2, false);\n\t\tfill()\n\t\tclosePath(); \n\n\t}\n\n\tthis.drawLabel();\n}\n\nvinyl.prototype.click = function(e) {\n\tthis.hasMovedOnce = false;\n\tthis.lastRotation = this.rotation\n\tthis.grabAngle = this.rotation % (Math.PI*2)\n\tthis.grabPos = math.toPolar(this.clickPos.x-this.center.x,this.clickPos.y-this.center.y).angle\n\n}\n\nvinyl.prototype.move = function() {\n\n\tif (!this.hasMovedOnce) {\n\t\tthis.hasMovedOnce = true;\n\t\tthis.grabAngle = this.rotation % (Math.PI*2)\n\t\tthis.grabPos = math.toPolar(this.clickPos.x-this.center.x,this.clickPos.y-this.center.y).angle\n\t}\n\n\tthis.rotation = math.toPolar(this.clickPos.x-this.center.x,this.clickPos.y-this.center.y).angle + this.grabAngle - this.grabPos\t\n\n\n}\n\nvinyl.prototype.release = function() {\n\tthis.speed = ((this.rotation - this.lastRotation) + (this.lastRotation-this.lastRotation2))/2 ;\n}\n\nvinyl.prototype.spin = function() {\n\n\tif (this.clicked) { \n\t\tthis.speed /= 1.1;\n\t} else {\n\t\tthis.speed = this.speed*0.9 + this.defaultspeed*0.1\n\t}\n\n\t// may need to math.clip(this.val.speed,-10,10);\n\tthis.val.speed = (this.rotation - this.lastRotation) * 20; // normalizes it to 1\n\n\tthis.lastRotation2 = this.lastRotation\n\tthis.lastRotation = this.rotation\n\n\tthis.rotation += this.speed\n\n\tthis.draw();\n\n\tthis.transmit(this.val)\n\t\n}\n\nvinyl.prototype.customDestroy = function() {\n\tnx.removeAni(this.spin.bind(this));\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/vinyl.js\n// module id = 50\n// module chunks = 0","var util = require('util');\nvar widget = require('../core/widget');\nvar math = require('../utils/math')\n\n/** \n\t@class waveform \n\tWaveform visualizer and selecter\n\t```html\n\t<canvas nx=\"waveform\"></canvas>\n\t```\n*/\n\nvar waveform = module.exports = function (target) {\n\tthis.defaultSize = { width: 400, height: 125 };\n\twidget.call(this, target);\n\n\t/** @property {object} val Object containing core interactive aspects of widget, which are also its data output. Has the following properties: \n\t\t| | data\n\t\t| --- | ---\n\t\t| *starttime* | Waveform selection start position in milliseconds (integer)\n\t\t| *stoptime* | Waveform selection end position in milliseconds (integer)\n\t\t| *looptime* | Selection size, in milliseconds (integer)\n\t\t| *start* | Waveform selection start, as fraction of waveform (float 0-1)\n\t\t| *stop* | Waveform selection end, as fraction of waveform (float 0-1)\n\t\t| *size* | Selection size, as fraction of waveform (float 0-1)\n\t*/\n\tthis.val = {\n\t\tstart: 0,\n\t\tstop: 0,\n\t\tsize: 0,\n\t\tstarttime: 0,\n\t\tstoptime: 0,\n\t\tlooptime: 0\n\t}\n\n\tthis.handle;\n\tthis.relhandle;\n\tthis.cap;\n\tthis.firsttouch = \"start\";\n\n\t/** @property {Array} buffer Contains multiple arrays of reduced buffer data, for visualization */\n\tthis.buffer = []\n\n\tif (nx.isMobile) {\n\t\t/** @property {integer} definition Horizontal definition of the visualization. Value of 3 means the waveform will be represented in 3 pixel chunks. Higher numbers (4+) lead to a smaller graphics load. Smaller numbers (1-3) look better. Default is 1 for desktop renders, 3 for mobile renders. */\n\t\tthis.definition = 3;\n\t} else {\n\t\tthis.definition = 1;\n\t}\n\n\tthis.pieces = false;\n\n\t/** @property {integer} channels How many channels in the waveform */\n\tthis.channels = 1\n\tthis.rawbuffer = []\n\n\tthis.times = [\n\t\t{ dur: 10 , format: 1 },\n\t\t{ dur: 50 , format: 1 },\n\t\t{ dur: 100 , format: 1 },\n\t\t{ dur: 200 , format: 1 },\n\t\t{ dur: 500 , format: 1 },\n\t\t{ dur: 1000 , format: 1 },\n\t\t{ dur: 2000 , format: 1 },\n\t\t{ dur: 5000 , format: 1 },\n\t\t{ dur: 10000 , format: 3 },\n\t\t{ dur: 15000 , format: 3 },\n\t\t{ dur: 60000 , format: 3 }, // 1 min\n\t\t{ dur: 120000 , format: 3 }, // 2 mins\n\t\t{ dur: 300000 , format: 3 }, // 5 mins\n\t\t{ dur: 600000 , format: 3 }, // 10 mins\n\t]\n\tthis.timescale = false\n\n\t// to do --\n\t// // sample rate adjustments\n\t// .select(500,1000)\n\n\t/** @property {string} mode Mode of interaction. \"edge\" mode lets you drag each edge of the waveform individually. \"area\" mode (default) lets you drag the waveform as a whole (with parallel mouse movement) or scale the waveform as a whole (with transverse mouse movement) */\n\tthis.mode = \"area\" // modes: \"edge\", \"area\"\n\tthis.touchdown = new Object();\n\tthis.init();\n}\nutil.inherits(waveform, widget);\n\nwaveform.prototype.init = function() {\n\n\tthis.pieces = ~~(this.GUI.w/this.definition);\n\n\tthis.draw();\n}\n\n\n/** \n @method setBuffer \n Load a web audio AudioBuffer into the waveform ui, for analysis and visualization.\n @param {AudioBuffer} [buffer] The buffer to be loaded.\n */\nwaveform.prototype.setBuffer = function(prebuff) {\n\n\tthis.channels = prebuff.numberOfChannels\n\tthis.duration = prebuff.duration\n\tthis.sampleRate = prebuff.sampleRate\n\tthis.waveHeight = this.GUI.h / this.channels\n\n\t// timescale\n\tthis.durationMS = (this.duration * 1000) \n\tthis.timescale = 0\n\twhile (~~(this.durationMS/this.times[this.timescale].dur) > 7 && this.timescale < this.times.length ) {\n\t\tthis.timescale++;\n\t}\n\tthis.timescale = this.times[this.timescale]\n\n\tthis.rawbuffer = []\n\tthis.buffer = []\n\n\t// reduce/crush buffers\n\tfor (var i=0;i<this.channels;i++) {\n\t\tthis.rawbuffer.push(prebuff.getChannelData(0))\n\t\tthis.buffer.push([])\n\n\t\t// counts faster (& less accurately) through larger buffers.\n\t\t// for every 5 seconds in the buffer, our counter skips 1.\n\t\t// so a 10 second buffer will only look at every 3rd sample\n\t\t// when calculating waveform.\n\t\tvar countinc = ~~(this.rawbuffer[0].length / (this.sampleRate*5)) + 1\n\n\t\tvar groupsize = ~~(this.rawbuffer[i].length/this.pieces)\n\t\tvar cmax = 0\n\t\tvar cmin = 0\n\t\tvar group = 0\n\t\tvar vis = []\n\t\tfor (var j=0;j<this.rawbuffer[i].length;j += countinc) {\n\t\t\tif (this.rawbuffer[i][j]>0) {\n\t\t\t\tcmax = Math.max(cmax,this.rawbuffer[i][j])\n\t\t\t} else {\n\t\t\t\tcmin = Math.min(cmin,this.rawbuffer[i][j])\n\t\t\t}\n\t\t\tif (j > group * groupsize) {\n\t\t\t\tthis.buffer[i].push([cmax,cmin])\n\t\t\t\tgroup++\n\t\t\t\tcmin = 0\n\t\t\t\tcmax = 0\n\t\t\t}\n\t\t}\n\t}\n\n\tif (this.val.start && this.val.stop) {\n\n\t}\n\n\tthis.val.starttime = Math.round(this.val.start * this.durationMS)\n\tthis.val.stoptime = Math.round(this.val.stop * this.durationMS)\n\tthis.val.looptime = Math.round(this.val.size * this.durationMS)\n\t\n\n\tthis.draw()\n\n}\n\n/** \n @method select \n Set the selection start and end points.\n @param {integer} [start] Selection start point in milliseconds\n @param {integer} [end] Selection end point in milliseconds\n */\nwaveform.prototype.select = function(start,stop) {\n\tthis.val.start = math.clip(start / this.durationMS,0,1)\n\tthis.val.stop = math.clip(stop / this.durationMS,0,1)\n\tthis.val.size = this.val.stop - this.val.start\n\tthis.val.starttime = start\n\tthis.val.stoptime = stop\n\tthis.val.looptime = start - stop\n\tthis.transmit(this.val)\n\tthis.draw()\n}\n\n\nwaveform.prototype.draw = function() {\n\t//this.erase();\n\n\twith (this.context) {\n\t\t//bg\n\t\tfillStyle = this.colors.fill;\n\t\tfillRect(0,0,this.GUI.w,this.GUI.h);\n\n\t\t//waveform\n\t\tfor (var i=0;i<this.buffer.length;i++) {\n\t\t\tfillStyle = this.colors.black\n\t\t\tthis.waveTop = i*this.waveHeight;\n\t\t\tthis.waveCenter = this.waveTop + this.waveHeight/2\n\t\t\tfor (var j=0;j<this.buffer[i].length;j++) {\n\t\t\t\tvar ht1 = this.waveCenter - this.buffer[i][j][0]*this.waveHeight\n\t\t\t\tvar ht2 = this.waveCenter + Math.abs(this.buffer[i][j][1]*this.waveHeight)\n\t\t\t\tht2 = ht2 - ht1\n\t\t\t\tfillRect( j*this.definition, ht1 , this.definition, ht2)\n\t\t\t}\n\t\t\tthis.buffer[i]\n\n\t\t}\n\n\t\t//time bar - top\n\t\tglobalAlpha = 0.3\n\t\tfillStyle = this.colors.border\n\t\tfillRect(0,0,this.GUI.w,16)\n\t\tglobalAlpha = 1\n\n\n\t\ttextBaseline = \"middle\"\n\t\ttextAlign = \"left\"\n\t\tfontSize = \"8px\"\n\n\t\t//time lines\n\t\tif (this.timescale) {\n\t\t\tfor (var i=1; i<this.durationMS/this.timescale.dur; i++) {\n\t\t\t\tvar x = (i * this.timescale.dur) / this.durationMS\n\t\t\t\tx *= this.GUI.w\n\t\t\t\tfillStyle = this.colors.border\n\t\t\t\tfillRect(x,0,1,this.GUI.h)\n\t\t\t\tfillStyle = this.colors.black\n\t\t\t\tglobalAlpha = 0.6\n\t\t\t\tfillText(this.msToTime(i * this.timescale.dur,this.timescale.format),x+5,8)\n\t\t\t\tglobalAlpha = 1\n\t\t\t}\t\n\t\t} \n\t\t\n\n\t\t// range selection\n\t\tvar x1 = this.val.start*this.GUI.w;\n\t\tvar y1 = 0;\n\t\tvar x2 = this.val.stop*this.GUI.w;\n\t\tvar y2 = this.GUI.h;\n\t \n\t\tfillStyle = this.colors.accent;\n\t\tstrokeStyle = this.colors.accent;\n\t\tlineWidth = 2\n\t\tglobalAlpha = 0.3\n\t\tfillRect(x1,y1,x2-x1,y2-y1);\n\t\tglobalAlpha = 0.7\n\t\tstrokeRect(x1,y1-2,x2-x1,y2-y1+4);\n\t\tif (this.durationMS && this.val.looptime) {\n\t\t\tthis.val.size = this.val.stop - this.val.start\n\t\t\ttextAlign = \"center\"\n\t\t\tvar dur = this.val.looptime\n\t\t\tif (dur > 1000) {\n\t\t\t\tdur /= 1000\n\t\t\t\tmath.prune(dur,2)\n\t\t\t\tdur += ' s'\n\t\t\t} else {\n\t\t\t\tmath.prune(dur,0)\n\t\t\t\tdur += ' ms'\n\t\t\t}\n\t\t\tfillText(dur,x1 + (x2-x1)/2,this.GUI.h/2)\n\t\t}\n\t\t\n\t\tglobalAlpha = 1\n\n\t\t\n\t}\n\n}\n\nwaveform.prototype.msToTime = function(rawms,format) {\n\n var format = format ? format : 2\n\n var s = ~~(rawms / 1000)\n var secs = s % 60;\n s = (s - secs) / 60;\n var mins = s % 60;\n var hrs = (s - mins) / 60;\n var ms = rawms % 1000\n\n //correct digits\n secs = (secs < 10 && mins) ? secs + '0' : secs;\n //ms = (ms < 10 && secs) ? ms + '0' : ms;\n\n if (format==1) {\n \treturn secs + '.' + ms;\n } else if (format==2) {\n \treturn mins + ':' + secs + '.' + ms;\n } else if (format==3) {\n \treturn mins + ':' + secs;\n }\n\n}\n\nwaveform.prototype.click = function() {\n\tif (this.mode==\"edge\") {\n\t\tif (Math.abs(this.clickPos.x-this.val.start*this.GUI.w) < Math.abs(this.clickPos.x-this.val.stop*this.GUI.w)) {\n\t\t\tthis.firsttouch = \"start\"\n\t\t} else {\n\t\t\tthis.firsttouch = \"stop\"\n\t\t}\n\t} else if (this.mode==\"area\") {\n\t\tthis.touchdown = {\n\t\t\tx: this.clickPos.x,\n\t\t\ty: this.clickPos.y\n\t\t}\n\t\tthis.startval = new Object();\n\t\tthis.startval.size = this.val.stop - this.val.start;\n\t\tthis.startval.loc = this.val.start + this.startval.size/2;\n\t}\n\tthis.move();\n}\n\nwaveform.prototype.move = function() {\n\n\tif (this.mode==\"edge\") {\n\t\tif (this.firsttouch==\"start\") {\n\t\t\tthis.val.start = this.clickPos.x/this.GUI.w;\n\t\t\tif (this.clickPos.touches.length>1) {\n\t\t\t\tthis.val.stop = this.clickPos.touches[1].x/this.GUI.w;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.val.stop = this.clickPos.x/this.GUI.w;\n\t\t\tif (this.clickPos.touches.length>1) {\n\t\t\t\tthis.val.start = this.clickPos.touches[1].x/this.GUI.w;\n\t\t\t}\n\t\t}\n\t\n\n\t\tif (this.val.stop < this.val.start) {\n\t\t\tthis.tempstart = this.val.start;\n\t\t\tthis.val.start = this.val.stop;\n\t\t\tthis.val.stop = this.tempstart;\n\t\t\tif (this.firsttouch==\"start\") {\n\t\t\t\tthis.firsttouch = \"stop\";\n\t\t\t} else {\n\t\t\t\tthis.firsttouch = \"start\";\n\t\t\t}\n\t\t} \n\t\t\n\t} else if (this.mode==\"area\") {\n\n\t\tvar moveloc = this.clickPos.x/this.GUI.w;\n\t\tvar movesize = (this.touchdown.y - this.clickPos.y)/this.GUI.h;\n\t\n\t\tmovesize /= 4;\n\t\tvar size = this.startval.size + movesize;\n\t\tsize = math.clip(size,0.001,1);\n\n\t\tthis.val = {\n\t\t\tstart: moveloc - size/2,\n\t\t\tstop: moveloc + size/2,\n\t\t}\n\n\t}\n\n\tthis.val.start = math.clip(this.val.start,0,1);\n\tthis.val.stop = math.clip(this.val.stop,0,1);\n\n\tthis.val['size'] = math.clip(Math.abs(this.val.stop - this.val.start), 0, 1)\n\n\tif (this.durationMS) {\n\t\tthis.val[\"starttime\"] = Math.round(this.val.start * this.durationMS)\n\t\tthis.val[\"stoptime\"] = Math.round(this.val.stop * this.durationMS)\n\t\tthis.val[\"looptime\"] = Math.round(this.val.size * this.durationMS)\n\t}\n\n\tthis.transmit(this.val);\n\tthis.draw();\n\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/nexusui/lib/widgets/waveform.js\n// module id = 51\n// module chunks = 0","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/process/browser.js\n// module id = 52\n// module chunks = 0","if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/util/~/inherits/inherits_browser.js\n// module id = 53\n// module chunks = 0","module.exports = function isBuffer(arg) {\n return arg && typeof arg === 'object'\n && typeof arg.copy === 'function'\n && typeof arg.fill === 'function'\n && typeof arg.readUInt8 === 'function';\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/util/support/isBufferBrowser.js\n// module id = 54\n// module chunks = 0","/* Web Font Loader v1.6.27 - (c) Adobe Systems, Google. License: Apache 2.0 */(function(){function aa(a,b,c){return a.call.apply(a.bind,arguments)}function ba(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function p(a,b,c){p=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf(\"native code\")?aa:ba;return p.apply(null,arguments)}var q=Date.now||function(){return+new Date};function ca(a,b){this.a=a;this.m=b||a;this.c=this.m.document}var da=!!window.FontFace;function t(a,b,c,d){b=a.c.createElement(b);if(c)for(var e in c)c.hasOwnProperty(e)&&(\"style\"==e?b.style.cssText=c[e]:b.setAttribute(e,c[e]));d&&b.appendChild(a.c.createTextNode(d));return b}function u(a,b,c){a=a.c.getElementsByTagName(b)[0];a||(a=document.documentElement);a.insertBefore(c,a.lastChild)}function v(a){a.parentNode&&a.parentNode.removeChild(a)}\nfunction w(a,b,c){b=b||[];c=c||[];for(var d=a.className.split(/\\s+/),e=0;e<b.length;e+=1){for(var f=!1,g=0;g<d.length;g+=1)if(b[e]===d[g]){f=!0;break}f||d.push(b[e])}b=[];for(e=0;e<d.length;e+=1){f=!1;for(g=0;g<c.length;g+=1)if(d[e]===c[g]){f=!0;break}f||b.push(d[e])}a.className=b.join(\" \").replace(/\\s+/g,\" \").replace(/^\\s+|\\s+$/,\"\")}function y(a,b){for(var c=a.className.split(/\\s+/),d=0,e=c.length;d<e;d++)if(c[d]==b)return!0;return!1}\nfunction z(a){if(\"string\"===typeof a.f)return a.f;var b=a.m.location.protocol;\"about:\"==b&&(b=a.a.location.protocol);return\"https:\"==b?\"https:\":\"http:\"}function ea(a){return a.m.location.hostname||a.a.location.hostname}\nfunction A(a,b,c){function d(){k&&e&&f&&(k(g),k=null)}b=t(a,\"link\",{rel:\"stylesheet\",href:b,media:\"all\"});var e=!1,f=!0,g=null,k=c||null;da?(b.onload=function(){e=!0;d()},b.onerror=function(){e=!0;g=Error(\"Stylesheet failed to load\");d()}):setTimeout(function(){e=!0;d()},0);u(a,\"head\",b)}\nfunction B(a,b,c,d){var e=a.c.getElementsByTagName(\"head\")[0];if(e){var f=t(a,\"script\",{src:b}),g=!1;f.onload=f.onreadystatechange=function(){g||this.readyState&&\"loaded\"!=this.readyState&&\"complete\"!=this.readyState||(g=!0,c&&c(null),f.onload=f.onreadystatechange=null,\"HEAD\"==f.parentNode.tagName&&e.removeChild(f))};e.appendChild(f);setTimeout(function(){g||(g=!0,c&&c(Error(\"Script load timeout\")))},d||5E3);return f}return null};function C(){this.a=0;this.c=null}function D(a){a.a++;return function(){a.a--;E(a)}}function F(a,b){a.c=b;E(a)}function E(a){0==a.a&&a.c&&(a.c(),a.c=null)};function G(a){this.a=a||\"-\"}G.prototype.c=function(a){for(var b=[],c=0;c<arguments.length;c++)b.push(arguments[c].replace(/[\\W_]+/g,\"\").toLowerCase());return b.join(this.a)};function H(a,b){this.c=a;this.f=4;this.a=\"n\";var c=(b||\"n4\").match(/^([nio])([1-9])$/i);c&&(this.a=c[1],this.f=parseInt(c[2],10))}function fa(a){return I(a)+\" \"+(a.f+\"00\")+\" 300px \"+J(a.c)}function J(a){var b=[];a=a.split(/,\\s*/);for(var c=0;c<a.length;c++){var d=a[c].replace(/['\"]/g,\"\");-1!=d.indexOf(\" \")||/^\\d/.test(d)?b.push(\"'\"+d+\"'\"):b.push(d)}return b.join(\",\")}function K(a){return a.a+a.f}function I(a){var b=\"normal\";\"o\"===a.a?b=\"oblique\":\"i\"===a.a&&(b=\"italic\");return b}\nfunction ga(a){var b=4,c=\"n\",d=null;a&&((d=a.match(/(normal|oblique|italic)/i))&&d[1]&&(c=d[1].substr(0,1).toLowerCase()),(d=a.match(/([1-9]00|normal|bold)/i))&&d[1]&&(/bold/i.test(d[1])?b=7:/[1-9]00/.test(d[1])&&(b=parseInt(d[1].substr(0,1),10))));return c+b};function ha(a,b){this.c=a;this.f=a.m.document.documentElement;this.h=b;this.a=new G(\"-\");this.j=!1!==b.events;this.g=!1!==b.classes}function ia(a){a.g&&w(a.f,[a.a.c(\"wf\",\"loading\")]);L(a,\"loading\")}function M(a){if(a.g){var b=y(a.f,a.a.c(\"wf\",\"active\")),c=[],d=[a.a.c(\"wf\",\"loading\")];b||c.push(a.a.c(\"wf\",\"inactive\"));w(a.f,c,d)}L(a,\"inactive\")}function L(a,b,c){if(a.j&&a.h[b])if(c)a.h[b](c.c,K(c));else a.h[b]()};function ja(){this.c={}}function ka(a,b,c){var d=[],e;for(e in b)if(b.hasOwnProperty(e)){var f=a.c[e];f&&d.push(f(b[e],c))}return d};function N(a,b){this.c=a;this.f=b;this.a=t(this.c,\"span\",{\"aria-hidden\":\"true\"},this.f)}function O(a){u(a.c,\"body\",a.a)}function P(a){return\"display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:\"+J(a.c)+\";\"+(\"font-style:\"+I(a)+\";font-weight:\"+(a.f+\"00\")+\";\")};function Q(a,b,c,d,e,f){this.g=a;this.j=b;this.a=d;this.c=c;this.f=e||3E3;this.h=f||void 0}Q.prototype.start=function(){var a=this.c.m.document,b=this,c=q(),d=new Promise(function(d,e){function k(){q()-c>=b.f?e():a.fonts.load(fa(b.a),b.h).then(function(a){1<=a.length?d():setTimeout(k,25)},function(){e()})}k()}),e=new Promise(function(a,d){setTimeout(d,b.f)});Promise.race([e,d]).then(function(){b.g(b.a)},function(){b.j(b.a)})};function R(a,b,c,d,e,f,g){this.v=a;this.B=b;this.c=c;this.a=d;this.s=g||\"BESbswy\";this.f={};this.w=e||3E3;this.u=f||null;this.o=this.j=this.h=this.g=null;this.g=new N(this.c,this.s);this.h=new N(this.c,this.s);this.j=new N(this.c,this.s);this.o=new N(this.c,this.s);a=new H(this.a.c+\",serif\",K(this.a));a=P(a);this.g.a.style.cssText=a;a=new H(this.a.c+\",sans-serif\",K(this.a));a=P(a);this.h.a.style.cssText=a;a=new H(\"serif\",K(this.a));a=P(a);this.j.a.style.cssText=a;a=new H(\"sans-serif\",K(this.a));a=\nP(a);this.o.a.style.cssText=a;O(this.g);O(this.h);O(this.j);O(this.o)}var S={D:\"serif\",C:\"sans-serif\"},T=null;function U(){if(null===T){var a=/AppleWebKit\\/([0-9]+)(?:\\.([0-9]+))/.exec(window.navigator.userAgent);T=!!a&&(536>parseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}return T}R.prototype.start=function(){this.f.serif=this.j.a.offsetWidth;this.f[\"sans-serif\"]=this.o.a.offsetWidth;this.A=q();la(this)};\nfunction ma(a,b,c){for(var d in S)if(S.hasOwnProperty(d)&&b===a.f[S[d]]&&c===a.f[S[d]])return!0;return!1}function la(a){var b=a.g.a.offsetWidth,c=a.h.a.offsetWidth,d;(d=b===a.f.serif&&c===a.f[\"sans-serif\"])||(d=U()&&ma(a,b,c));d?q()-a.A>=a.w?U()&&ma(a,b,c)&&(null===a.u||a.u.hasOwnProperty(a.a.c))?V(a,a.v):V(a,a.B):na(a):V(a,a.v)}function na(a){setTimeout(p(function(){la(this)},a),50)}function V(a,b){setTimeout(p(function(){v(this.g.a);v(this.h.a);v(this.j.a);v(this.o.a);b(this.a)},a),0)};function W(a,b,c){this.c=a;this.a=b;this.f=0;this.o=this.j=!1;this.s=c}var X=null;W.prototype.g=function(a){var b=this.a;b.g&&w(b.f,[b.a.c(\"wf\",a.c,K(a).toString(),\"active\")],[b.a.c(\"wf\",a.c,K(a).toString(),\"loading\"),b.a.c(\"wf\",a.c,K(a).toString(),\"inactive\")]);L(b,\"fontactive\",a);this.o=!0;oa(this)};\nW.prototype.h=function(a){var b=this.a;if(b.g){var c=y(b.f,b.a.c(\"wf\",a.c,K(a).toString(),\"active\")),d=[],e=[b.a.c(\"wf\",a.c,K(a).toString(),\"loading\")];c||d.push(b.a.c(\"wf\",a.c,K(a).toString(),\"inactive\"));w(b.f,d,e)}L(b,\"fontinactive\",a);oa(this)};function oa(a){0==--a.f&&a.j&&(a.o?(a=a.a,a.g&&w(a.f,[a.a.c(\"wf\",\"active\")],[a.a.c(\"wf\",\"loading\"),a.a.c(\"wf\",\"inactive\")]),L(a,\"active\")):M(a.a))};function pa(a){this.j=a;this.a=new ja;this.h=0;this.f=this.g=!0}pa.prototype.load=function(a){this.c=new ca(this.j,a.context||this.j);this.g=!1!==a.events;this.f=!1!==a.classes;qa(this,new ha(this.c,a),a)};\nfunction ra(a,b,c,d,e){var f=0==--a.h;(a.f||a.g)&&setTimeout(function(){var a=e||null,k=d||null||{};if(0===c.length&&f)M(b.a);else{b.f+=c.length;f&&(b.j=f);var h,m=[];for(h=0;h<c.length;h++){var l=c[h],n=k[l.c],r=b.a,x=l;r.g&&w(r.f,[r.a.c(\"wf\",x.c,K(x).toString(),\"loading\")]);L(r,\"fontloading\",x);r=null;if(null===X)if(window.FontFace){var x=/Gecko.*Firefox\\/(\\d+)/.exec(window.navigator.userAgent),ya=/OS X.*Version\\/10\\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);\nX=x?42<parseInt(x[1],10):ya?!1:!0}else X=!1;X?r=new Q(p(b.g,b),p(b.h,b),b.c,l,b.s,n):r=new R(p(b.g,b),p(b.h,b),b.c,l,b.s,a,n);m.push(r)}for(h=0;h<m.length;h++)m[h].start()}},0)}function qa(a,b,c){var d=[],e=c.timeout;ia(b);var d=ka(a.a,c,a.c),f=new W(a.c,b,e);a.h=d.length;b=0;for(c=d.length;b<c;b++)d[b].load(function(b,d,c){ra(a,f,b,d,c)})};function sa(a,b){this.c=a;this.a=b}function ta(a,b,c){var d=z(a.c);a=(a.a.api||\"fast.fonts.net/jsapi\").replace(/^.*http(s?):(\\/\\/)?/,\"\");return d+\"//\"+a+\"/\"+b+\".js\"+(c?\"?v=\"+c:\"\")}\nsa.prototype.load=function(a){function b(){if(f[\"__mti_fntLst\"+d]){var c=f[\"__mti_fntLst\"+d](),e=[],h;if(c)for(var m=0;m<c.length;m++){var l=c[m].fontfamily;void 0!=c[m].fontStyle&&void 0!=c[m].fontWeight?(h=c[m].fontStyle+c[m].fontWeight,e.push(new H(l,h))):e.push(new H(l))}a(e)}else setTimeout(function(){b()},50)}var c=this,d=c.a.projectId,e=c.a.version;if(d){var f=c.c.m;B(this.c,ta(c,d,e),function(e){e?a([]):(f[\"__MonotypeConfiguration__\"+d]=function(){return c.a},b())}).id=\"__MonotypeAPIScript__\"+\nd}else a([])};function ua(a,b){this.c=a;this.a=b}ua.prototype.load=function(a){var b,c,d=this.a.urls||[],e=this.a.families||[],f=this.a.testStrings||{},g=new C;b=0;for(c=d.length;b<c;b++)A(this.c,d[b],D(g));var k=[];b=0;for(c=e.length;b<c;b++)if(d=e[b].split(\":\"),d[1])for(var h=d[1].split(\",\"),m=0;m<h.length;m+=1)k.push(new H(d[0],h[m]));else k.push(new H(d[0]));F(g,function(){a(k,f)})};function va(a,b,c){a?this.c=a:this.c=b+wa;this.a=[];this.f=[];this.g=c||\"\"}var wa=\"//fonts.googleapis.com/css\";function xa(a,b){for(var c=b.length,d=0;d<c;d++){var e=b[d].split(\":\");3==e.length&&a.f.push(e.pop());var f=\"\";2==e.length&&\"\"!=e[1]&&(f=\":\");a.a.push(e.join(f))}}\nfunction za(a){if(0==a.a.length)throw Error(\"No fonts to load!\");if(-1!=a.c.indexOf(\"kit=\"))return a.c;for(var b=a.a.length,c=[],d=0;d<b;d++)c.push(a.a[d].replace(/ /g,\"+\"));b=a.c+\"?family=\"+c.join(\"%7C\");0<a.f.length&&(b+=\"&subset=\"+a.f.join(\",\"));0<a.g.length&&(b+=\"&text=\"+encodeURIComponent(a.g));return b};function Aa(a){this.f=a;this.a=[];this.c={}}\nvar Ba={latin:\"BESbswy\",\"latin-ext\":\"\\u00e7\\u00f6\\u00fc\\u011f\\u015f\",cyrillic:\"\\u0439\\u044f\\u0416\",greek:\"\\u03b1\\u03b2\\u03a3\",khmer:\"\\u1780\\u1781\\u1782\",Hanuman:\"\\u1780\\u1781\\u1782\"},Ca={thin:\"1\",extralight:\"2\",\"extra-light\":\"2\",ultralight:\"2\",\"ultra-light\":\"2\",light:\"3\",regular:\"4\",book:\"4\",medium:\"5\",\"semi-bold\":\"6\",semibold:\"6\",\"demi-bold\":\"6\",demibold:\"6\",bold:\"7\",\"extra-bold\":\"8\",extrabold:\"8\",\"ultra-bold\":\"8\",ultrabold:\"8\",black:\"9\",heavy:\"9\",l:\"3\",r:\"4\",b:\"7\"},Da={i:\"i\",italic:\"i\",n:\"n\",normal:\"n\"},\nEa=/^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/;\nfunction Fa(a){for(var b=a.f.length,c=0;c<b;c++){var d=a.f[c].split(\":\"),e=d[0].replace(/\\+/g,\" \"),f=[\"n4\"];if(2<=d.length){var g;var k=d[1];g=[];if(k)for(var k=k.split(\",\"),h=k.length,m=0;m<h;m++){var l;l=k[m];if(l.match(/^[\\w-]+$/)){var n=Ea.exec(l.toLowerCase());if(null==n)l=\"\";else{l=n[2];l=null==l||\"\"==l?\"n\":Da[l];n=n[1];if(null==n||\"\"==n)n=\"4\";else var r=Ca[n],n=r?r:isNaN(n)?\"4\":n.substr(0,1);l=[l,n].join(\"\")}}else l=\"\";l&&g.push(l)}0<g.length&&(f=g);3==d.length&&(d=d[2],g=[],d=d?d.split(\",\"):\ng,0<d.length&&(d=Ba[d[0]])&&(a.c[e]=d))}a.c[e]||(d=Ba[e])&&(a.c[e]=d);for(d=0;d<f.length;d+=1)a.a.push(new H(e,f[d]))}};function Ga(a,b){this.c=a;this.a=b}var Ha={Arimo:!0,Cousine:!0,Tinos:!0};Ga.prototype.load=function(a){var b=new C,c=this.c,d=new va(this.a.api,z(c),this.a.text),e=this.a.families;xa(d,e);var f=new Aa(e);Fa(f);A(c,za(d),D(b));F(b,function(){a(f.a,f.c,Ha)})};function Ia(a,b){this.c=a;this.a=b}Ia.prototype.load=function(a){var b=this.a.id,c=this.c.m;b?B(this.c,(this.a.api||\"https://use.typekit.net\")+\"/\"+b+\".js\",function(b){if(b)a([]);else if(c.Typekit&&c.Typekit.config&&c.Typekit.config.fn){b=c.Typekit.config.fn;for(var e=[],f=0;f<b.length;f+=2)for(var g=b[f],k=b[f+1],h=0;h<k.length;h++)e.push(new H(g,k[h]));try{c.Typekit.load({events:!1,classes:!1,async:!0})}catch(m){}a(e)}},2E3):a([])};function Ja(a,b){this.c=a;this.f=b;this.a=[]}Ja.prototype.load=function(a){var b=this.f.id,c=this.c.m,d=this;b?(c.__webfontfontdeckmodule__||(c.__webfontfontdeckmodule__={}),c.__webfontfontdeckmodule__[b]=function(b,c){for(var g=0,k=c.fonts.length;g<k;++g){var h=c.fonts[g];d.a.push(new H(h.name,ga(\"font-weight:\"+h.weight+\";font-style:\"+h.style)))}a(d.a)},B(this.c,z(this.c)+(this.f.api||\"//f.fontdeck.com/s/css/js/\")+ea(this.c)+\"/\"+b+\".js\",function(b){b&&a([])})):a([])};var Y=new pa(window);Y.a.c.custom=function(a,b){return new ua(b,a)};Y.a.c.fontdeck=function(a,b){return new Ja(b,a)};Y.a.c.monotype=function(a,b){return new sa(b,a)};Y.a.c.typekit=function(a,b){return new Ia(b,a)};Y.a.c.google=function(a,b){return new Ga(b,a)};var Z={load:p(Y.load,Y)};\"function\"===typeof define&&define.amd?define(function(){return Z}):\"undefined\"!==typeof module&&module.exports?module.exports=Z:(window.WebFont=Z,window.WebFontConfig&&Y.load(window.WebFontConfig));}());\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/webfontloader/webfontloader.js\n// module id = 55\n// module chunks = 0","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 56\n// module chunks = 0"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;AChEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACzkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACnlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC/LA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC7FA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC7zvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC7EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC7SA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC1EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACpBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC7FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC9BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC/CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC5FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC9CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC/BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AClWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACnKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACrLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACxFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACteA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACzNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AClGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AClEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACtFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC7MA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AChTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC/BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AClMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC5UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC/bA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACtEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACzHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AChHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACnKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AClGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACxJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC3MA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC9NA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AChNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACrMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACpGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACtNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACtMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC1FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACrFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACvIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACtEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACtPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACjJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC3WA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACnLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACtBA;AACA;AACA;AACA;AACA;AACA;;;;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;;;;;;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;A","sourceRoot":""}
\ No newline at end of file diff --git a/client/index.js b/client/index.js index 65e7ddd..da07d12 100644 --- a/client/index.js +++ b/client/index.js @@ -1,4 +1,5 @@ import Tone from 'tone' +import WebMidi from 'webmidi' import 'nexusui' import keys from './lib/keys' import color from './lib/color' @@ -8,20 +9,43 @@ import { mod, browser, requestAudioContext } from './lib/util' const nx = window.nx -const noteCount = browser.isMobile ? 18 : 24 +const noteCount = browser.isMobile ? 18 : 36 const stepCount = 16 const cellSize = browser.isMobile ? 20 : 27 const baseTone = browser.isMobile ? 8 : 12 -let grid +let grid, midi + +WebMidi.enable(midi_ready) + +function midi_ready(err) { + if (err) { + console.error('webmidi failed to initialize') + return + } + if (!WebMidi.outputs.length) { + console.error('no MIDI output found') + } + console.log(WebMidi.inputs) + console.log(WebMidi.outputs) + midi = WebMidi.outputs[0] +} var loop = new Tone.Sequence(function(time, col){ var column = grid.matrix[col] grid.jumpToCol(col) for (var i = 0; i < noteCount; i++){ if (column[i] === 1){ - const freq = scales.current().index(noteCount - i - baseTone) - kalimba.play(freq) + const index = noteCount - i - baseTone + const freq = scales.current().index(index) + const midi_note = Tone.Frequency.ftom(freq) + const midi_freq = Tone.Frequency.mtof(midi_note) + console.log(midi_note, freq, midi_freq, freq - midi_freq) + if (midi) { + midi.playNote(Tone.Frequency(midi_note, "midi").toNote(), 3, { duration: 90000 / Tone.Transport.bpm.value }) + } else { + kalimba.play(freq) + } } } }, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], "16n") diff --git a/img/imBreak_1340193016_tumblr_m5vynpMYYg1qiluqao1_500_.png b/img/imBreak_1340193016_tumblr_m5vynpMYYg1qiluqao1_500_.png Binary files differnew file mode 100644 index 0000000..c0cde60 --- /dev/null +++ b/img/imBreak_1340193016_tumblr_m5vynpMYYg1qiluqao1_500_.png @@ -7,9 +7,10 @@ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 13px; transition: background-color 100ms; - background-image: url(http://i.asdf.us/im/84/imBreak_1340193016_tumblr_m5vynpMYYg1qiluqao1_500_.png); + background-image: url(./img/imBreak_1340193016_tumblr_m5vynpMYYg1qiluqao1_500_.png); background-position: top right; background-repeat: no-repeat; + background-attachment: fixed; } div { display: inline-block; @@ -23,6 +24,23 @@ div { .desktop body { user-select: none; } +.top { + display: block; + margin-top: 10px; + margin-bottom: 10px; +} +@media only screen and (min-device-width: 800px) { + .tools { + position: fixed; + top: 0; + left: 468px; + width: 400px; + height: 100vh; + display: flex; + flex-direction: column; + justify-content: space-between; + } +} @media only screen and (max-device-width: 800px) { html,body { margin: 0; @@ -43,11 +61,6 @@ div { br { display: none; } - .top { - display: block; - margin-top: 10px; - margin-bottom: 10px; - } } </style> </head> @@ -56,33 +69,28 @@ div { <div id='labels'></div> <canvas nx="matrix" id="grid"></canvas> </div> -<div> +<div class='tools'> <span class="top"> <canvas nx="number" label="tempo" id="tempo"></canvas> <br><br> <canvas nx="select" id="scale"></canvas> </span> - <br> - <br><br><br> - <br><br><br> - <br><br><br> - <br><br><br> - <br><br><br> - <br><br><br> - <canvas nx="button" label="shift ↑" id="shiftUp"></canvas> - <canvas nx="button" label="shift ↓" id="shiftDown"></canvas> - <br> - <canvas nx="button" label="slide ↑" id="slideUp"></canvas> - <canvas nx="button" label="slide ↓" id="slideDown"></canvas> - <canvas nx="button" label="slide ←" id="slideLeft"></canvas> - <canvas nx="button" label="slide →" id="slideRight"></canvas> - <br> - <canvas nx="button" label="rotate ↑" id="rotateUp"></canvas> - <canvas nx="button" label="rotate ↓" id="rotateDown"></canvas> - <canvas nx="button" label="rotate ←" id="rotateLeft"></canvas> - <canvas nx="button" label="rotate →" id="rotateRight"></canvas> - <canvas nx="button" label="flip ↕" id="flip"></canvas> - <canvas nx="button" label="flop ↔" id="flop"></canvas> + <span> + <canvas nx="button" label="shift ↑" id="shiftUp"></canvas> + <canvas nx="button" label="shift ↓" id="shiftDown"></canvas> + <br> + <canvas nx="button" label="slide ↑" id="slideUp"></canvas> + <canvas nx="button" label="slide ↓" id="slideDown"></canvas> + <canvas nx="button" label="slide ←" id="slideLeft"></canvas> + <canvas nx="button" label="slide →" id="slideRight"></canvas> + <br> + <canvas nx="button" label="rotate ↑" id="rotateUp"></canvas> + <canvas nx="button" label="rotate ↓" id="rotateDown"></canvas> + <canvas nx="button" label="rotate ←" id="rotateLeft"></canvas> + <canvas nx="button" label="rotate →" id="rotateRight"></canvas> + <canvas nx="button" label="flip ↕" id="flip"></canvas> + <canvas nx="button" label="flop ↔" id="flop"></canvas> + </span> </div> </body> <script> diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..a5c77ca --- /dev/null +++ b/package-lock.json @@ -0,0 +1,4190 @@ +{ + "name": "cells", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "acorn": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.0.3.tgz", + "integrity": "sha1-xGDfCEkUY/AozLguqzcwvwEIez0=", + "dev": true + }, + "acorn-dynamic-import": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-2.0.2.tgz", + "integrity": "sha1-x1K9IQvvZ5UBtsbLf8hPj0cVjMQ=", + "dev": true, + "requires": { + "acorn": "^4.0.3" + }, + "dependencies": { + "acorn": { + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.11.tgz", + "integrity": "sha1-7c2jvZN+dVZBDULtWGD2c5nHlMA=", + "dev": true + } + } + }, + "ajv": { + "version": "4.11.7", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.7.tgz", + "integrity": "sha1-hlWl2G0IJJhcxHGh2RP7Zymg7Eg=", + "dev": true, + "requires": { + "co": "^4.6.0", + "json-stable-stringify": "^1.0.1" + } + }, + "ajv-keywords": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", + "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", + "dev": true + }, + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "dev": true, + "requires": { + "kind-of": "^3.0.2", + "longest": "^1.0.1", + "repeat-string": "^1.5.2" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "anymatch": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.0.tgz", + "integrity": "sha1-o+Uvo5FoyCX/V7AkgSbOWo/5VQc=", + "dev": true, + "requires": { + "arrify": "^1.0.0", + "micromatch": "^2.1.5" + } + }, + "arr-diff": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", + "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", + "dev": true, + "requires": { + "arr-flatten": "^1.0.1" + } + }, + "arr-flatten": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.0.3.tgz", + "integrity": "sha1-onTthawIhJtr14R8RYB0XcUa37E=", + "dev": true + }, + "array-unique": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", + "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", + "dev": true + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, + "asn1.js": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.1.tgz", + "integrity": "sha1-SLokC0WpKA6UdImQull9IWYX/UA=", + "dev": true, + "requires": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "assert": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", + "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", + "dev": true, + "requires": { + "util": "0.10.3" + } + }, + "async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.3.0.tgz", + "integrity": "sha1-EBPRBRBH3TIP4k5JTVxm7K9hR9k=", + "dev": true, + "requires": { + "lodash": "^4.14.0" + } + }, + "async-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", + "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", + "dev": true + }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "dev": true, + "requires": { + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + } + }, + "babel-core": { + "version": "6.26.3", + "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.3.tgz", + "integrity": "sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA==", + "dev": true, + "requires": { + "babel-code-frame": "^6.26.0", + "babel-generator": "^6.26.0", + "babel-helpers": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-register": "^6.26.0", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "convert-source-map": "^1.5.1", + "debug": "^2.6.9", + "json5": "^0.5.1", + "lodash": "^4.17.4", + "minimatch": "^3.0.4", + "path-is-absolute": "^1.0.1", + "private": "^0.1.8", + "slash": "^1.0.0", + "source-map": "^0.5.7" + }, + "dependencies": { + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "private": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==", + "dev": true + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + } + } + }, + "babel-generator": { + "version": "6.26.1", + "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", + "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", + "dev": true, + "requires": { + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "detect-indent": "^4.0.0", + "jsesc": "^1.3.0", + "lodash": "^4.17.4", + "source-map": "^0.5.7", + "trim-right": "^1.0.1" + }, + "dependencies": { + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" + } + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + } + } + }, + "babel-helper-builder-binary-assignment-operator-visitor": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz", + "integrity": "sha1-zORReto1b0IgvK6KAsKzRvmlZmQ=", + "dev": true, + "requires": { + "babel-helper-explode-assignable-expression": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "babel-helper-call-delegate": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz", + "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=", + "dev": true, + "requires": { + "babel-helper-hoist-variables": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "babel-helper-define-map": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz", + "integrity": "sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8=", + "dev": true, + "requires": { + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" + }, + "dependencies": { + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" + } + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + } + } + }, + "babel-helper-explode-assignable-expression": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz", + "integrity": "sha1-8luCz33BBDPFX3BZLVdGQArCLKo=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "babel-helper-function-name": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz", + "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", + "dev": true, + "requires": { + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "babel-helper-get-function-arity": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz", + "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "babel-helper-hoist-variables": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz", + "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "babel-helper-optimise-call-expression": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz", + "integrity": "sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "babel-helper-regex": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz", + "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" + }, + "dependencies": { + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" + } + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + } + } + }, + "babel-helper-remap-async-to-generator": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz", + "integrity": "sha1-XsWBgnrXI/7N04HxySg5BnbkVRs=", + "dev": true, + "requires": { + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "babel-helper-replace-supers": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz", + "integrity": "sha1-v22/5Dk40XNpohPKiov3S2qQqxo=", + "dev": true, + "requires": { + "babel-helper-optimise-call-expression": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "babel-helpers": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helpers/-/babel-helpers-6.24.1.tgz", + "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" + } + }, + "babel-loader": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-7.0.0.tgz", + "integrity": "sha1-LkOma+4f/0RwUz0EAsikUy+vuvc=", + "dev": true, + "requires": { + "find-cache-dir": "^0.1.1", + "loader-utils": "^1.0.2", + "mkdirp": "^0.5.1" + } + }, + "babel-messages": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", + "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-check-es2015-constants": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz", + "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-syntax-async-functions": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz", + "integrity": "sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU=", + "dev": true + }, + "babel-plugin-syntax-exponentiation-operator": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz", + "integrity": "sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4=", + "dev": true + }, + "babel-plugin-syntax-trailing-function-commas": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz", + "integrity": "sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM=", + "dev": true + }, + "babel-plugin-transform-async-to-generator": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz", + "integrity": "sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E=", + "dev": true, + "requires": { + "babel-helper-remap-async-to-generator": "^6.24.1", + "babel-plugin-syntax-async-functions": "^6.8.0", + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-transform-es2015-arrow-functions": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz", + "integrity": "sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-transform-es2015-block-scoped-functions": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz", + "integrity": "sha1-u8UbSflk1wy42OC5ToICRs46YUE=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-transform-es2015-block-scoping": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz", + "integrity": "sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" + }, + "dependencies": { + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" + } + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + } + } + }, + "babel-plugin-transform-es2015-classes": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz", + "integrity": "sha1-WkxYpQyclGHlZLSyo7+ryXolhNs=", + "dev": true, + "requires": { + "babel-helper-define-map": "^6.24.1", + "babel-helper-function-name": "^6.24.1", + "babel-helper-optimise-call-expression": "^6.24.1", + "babel-helper-replace-supers": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "babel-plugin-transform-es2015-computed-properties": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz", + "integrity": "sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" + } + }, + "babel-plugin-transform-es2015-destructuring": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz", + "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-transform-es2015-duplicate-keys": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz", + "integrity": "sha1-c+s9MQypaePvnskcU3QabxV2Qj4=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "babel-plugin-transform-es2015-for-of": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz", + "integrity": "sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-transform-es2015-function-name": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz", + "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=", + "dev": true, + "requires": { + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "babel-plugin-transform-es2015-literals": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz", + "integrity": "sha1-T1SgLWzWbPkVKAAZox0xklN3yi4=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-transform-es2015-modules-amd": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz", + "integrity": "sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ=", + "dev": true, + "requires": { + "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" + } + }, + "babel-plugin-transform-es2015-modules-commonjs": { + "version": "6.26.2", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz", + "integrity": "sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q==", + "dev": true, + "requires": { + "babel-plugin-transform-strict-mode": "^6.24.1", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-types": "^6.26.0" + }, + "dependencies": { + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" + } + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + } + } + }, + "babel-plugin-transform-es2015-modules-systemjs": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz", + "integrity": "sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM=", + "dev": true, + "requires": { + "babel-helper-hoist-variables": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" + } + }, + "babel-plugin-transform-es2015-modules-umd": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz", + "integrity": "sha1-rJl+YoXNGO1hdq22B9YCNErThGg=", + "dev": true, + "requires": { + "babel-plugin-transform-es2015-modules-amd": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" + } + }, + "babel-plugin-transform-es2015-object-super": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz", + "integrity": "sha1-JM72muIcuDp/hgPa0CH1cusnj40=", + "dev": true, + "requires": { + "babel-helper-replace-supers": "^6.24.1", + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-transform-es2015-parameters": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz", + "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=", + "dev": true, + "requires": { + "babel-helper-call-delegate": "^6.24.1", + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "babel-plugin-transform-es2015-shorthand-properties": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz", + "integrity": "sha1-JPh11nIch2YbvZmkYi5R8U3jiqA=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "babel-plugin-transform-es2015-spread": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz", + "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-transform-es2015-sticky-regex": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz", + "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=", + "dev": true, + "requires": { + "babel-helper-regex": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "babel-plugin-transform-es2015-template-literals": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz", + "integrity": "sha1-qEs0UPfp+PH2g51taH2oS7EjbY0=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-transform-es2015-typeof-symbol": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz", + "integrity": "sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-transform-es2015-unicode-regex": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz", + "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=", + "dev": true, + "requires": { + "babel-helper-regex": "^6.24.1", + "babel-runtime": "^6.22.0", + "regexpu-core": "^2.0.0" + } + }, + "babel-plugin-transform-exponentiation-operator": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz", + "integrity": "sha1-KrDJx/MJj6SJB3cruBP+QejeOg4=", + "dev": true, + "requires": { + "babel-helper-builder-binary-assignment-operator-visitor": "^6.24.1", + "babel-plugin-syntax-exponentiation-operator": "^6.8.0", + "babel-runtime": "^6.22.0" + } + }, + "babel-plugin-transform-regenerator": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.24.1.tgz", + "integrity": "sha1-uNowWtQ8PJm0hI5P5AN7dw0jxBg=", + "dev": true, + "requires": { + "regenerator-transform": "0.9.11" + } + }, + "babel-plugin-transform-strict-mode": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz", + "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "babel-preset-env": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.7.0.tgz", + "integrity": "sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg==", + "dev": true, + "requires": { + "babel-plugin-check-es2015-constants": "^6.22.0", + "babel-plugin-syntax-trailing-function-commas": "^6.22.0", + "babel-plugin-transform-async-to-generator": "^6.22.0", + "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoping": "^6.23.0", + "babel-plugin-transform-es2015-classes": "^6.23.0", + "babel-plugin-transform-es2015-computed-properties": "^6.22.0", + "babel-plugin-transform-es2015-destructuring": "^6.23.0", + "babel-plugin-transform-es2015-duplicate-keys": "^6.22.0", + "babel-plugin-transform-es2015-for-of": "^6.23.0", + "babel-plugin-transform-es2015-function-name": "^6.22.0", + "babel-plugin-transform-es2015-literals": "^6.22.0", + "babel-plugin-transform-es2015-modules-amd": "^6.22.0", + "babel-plugin-transform-es2015-modules-commonjs": "^6.23.0", + "babel-plugin-transform-es2015-modules-systemjs": "^6.23.0", + "babel-plugin-transform-es2015-modules-umd": "^6.23.0", + "babel-plugin-transform-es2015-object-super": "^6.22.0", + "babel-plugin-transform-es2015-parameters": "^6.23.0", + "babel-plugin-transform-es2015-shorthand-properties": "^6.22.0", + "babel-plugin-transform-es2015-spread": "^6.22.0", + "babel-plugin-transform-es2015-sticky-regex": "^6.22.0", + "babel-plugin-transform-es2015-template-literals": "^6.22.0", + "babel-plugin-transform-es2015-typeof-symbol": "^6.23.0", + "babel-plugin-transform-es2015-unicode-regex": "^6.22.0", + "babel-plugin-transform-exponentiation-operator": "^6.22.0", + "babel-plugin-transform-regenerator": "^6.22.0", + "browserslist": "^3.2.6", + "invariant": "^2.2.2", + "semver": "^5.3.0" + } + }, + "babel-preset-es2015": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz", + "integrity": "sha1-1EBQ1rwsn+6nAqrzjXJ6AhBTiTk=", + "dev": true, + "requires": { + "babel-plugin-check-es2015-constants": "^6.22.0", + "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoping": "^6.24.1", + "babel-plugin-transform-es2015-classes": "^6.24.1", + "babel-plugin-transform-es2015-computed-properties": "^6.24.1", + "babel-plugin-transform-es2015-destructuring": "^6.22.0", + "babel-plugin-transform-es2015-duplicate-keys": "^6.24.1", + "babel-plugin-transform-es2015-for-of": "^6.22.0", + "babel-plugin-transform-es2015-function-name": "^6.24.1", + "babel-plugin-transform-es2015-literals": "^6.22.0", + "babel-plugin-transform-es2015-modules-amd": "^6.24.1", + "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", + "babel-plugin-transform-es2015-modules-systemjs": "^6.24.1", + "babel-plugin-transform-es2015-modules-umd": "^6.24.1", + "babel-plugin-transform-es2015-object-super": "^6.24.1", + "babel-plugin-transform-es2015-parameters": "^6.24.1", + "babel-plugin-transform-es2015-shorthand-properties": "^6.24.1", + "babel-plugin-transform-es2015-spread": "^6.22.0", + "babel-plugin-transform-es2015-sticky-regex": "^6.24.1", + "babel-plugin-transform-es2015-template-literals": "^6.22.0", + "babel-plugin-transform-es2015-typeof-symbol": "^6.22.0", + "babel-plugin-transform-es2015-unicode-regex": "^6.24.1", + "babel-plugin-transform-regenerator": "^6.24.1" + } + }, + "babel-register": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz", + "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", + "dev": true, + "requires": { + "babel-core": "^6.26.0", + "babel-runtime": "^6.26.0", + "core-js": "^2.5.0", + "home-or-tmp": "^2.0.0", + "lodash": "^4.17.4", + "mkdirp": "^0.5.1", + "source-map-support": "^0.4.15" + }, + "dependencies": { + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "core-js": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz", + "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==", + "dev": true + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + } + } + }, + "babel-runtime": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.23.0.tgz", + "integrity": "sha1-CpSJ8UTecO+zzkMArM2zKeL8VDs=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.10.0" + } + }, + "babel-template": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-6.26.0.tgz", + "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "lodash": "^4.17.4" + }, + "dependencies": { + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" + } + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + } + } + }, + "babel-traverse": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz", + "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", + "dev": true, + "requires": { + "babel-code-frame": "^6.26.0", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "debug": "^2.6.8", + "globals": "^9.18.0", + "invariant": "^2.2.2", + "lodash": "^4.17.4" + }, + "dependencies": { + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" + } + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + } + } + }, + "babel-types": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.24.1.tgz", + "integrity": "sha1-oTaHncFbNga9oNkMH8dDBML/CXU=", + "dev": true, + "requires": { + "babel-runtime": "^6.22.0", + "esutils": "^2.0.2", + "lodash": "^4.2.0", + "to-fast-properties": "^1.0.1" + } + }, + "babylon": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", + "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==", + "dev": true + }, + "balanced-match": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", + "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=", + "dev": true + }, + "base64-js": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.0.tgz", + "integrity": "sha1-o5mS1yNYSBGYK+XikLtqU9hnAPE=", + "dev": true + }, + "big.js": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.1.3.tgz", + "integrity": "sha1-TK2iGTZS6zyp7I5VyQFWacmAaXg=", + "dev": true + }, + "binary-extensions": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.8.0.tgz", + "integrity": "sha1-SOyNFt9Dd+rl+liEaCSAr02Vx3Q=", + "dev": true + }, + "bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.7.tgz", + "integrity": "sha1-Pv/DxQ4ABTH7cg6v+A8K6O8jz1k=", + "dev": true, + "requires": { + "balanced-match": "^0.4.1", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", + "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", + "dev": true, + "requires": { + "expand-range": "^1.8.1", + "preserve": "^0.2.0", + "repeat-element": "^1.1.2" + } + }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", + "dev": true + }, + "browserify-aes": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.0.6.tgz", + "integrity": "sha1-Xncl297x/Vkw1OurSFZ85FHEigo=", + "dev": true, + "requires": { + "buffer-xor": "^1.0.2", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.0", + "inherits": "^2.0.1" + } + }, + "browserify-cipher": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.0.tgz", + "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", + "dev": true, + "requires": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "browserify-des": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.0.tgz", + "integrity": "sha1-2qJ3cXRwki7S/hhZQRihdUOXId0=", + "dev": true, + "requires": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1" + } + }, + "browserify-rsa": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "randombytes": "^2.0.1" + } + }, + "browserify-sign": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", + "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", + "dev": true, + "requires": { + "bn.js": "^4.1.1", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.2", + "elliptic": "^6.0.0", + "inherits": "^2.0.1", + "parse-asn1": "^5.0.0" + } + }, + "browserify-zlib": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", + "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", + "dev": true, + "requires": { + "pako": "~0.2.0" + } + }, + "browserslist": { + "version": "3.2.8", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-3.2.8.tgz", + "integrity": "sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==", + "dev": true, + "requires": { + "caniuse-lite": "^1.0.30000844", + "electron-to-chromium": "^1.3.47" + } + }, + "buffer": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" + } + }, + "buffer-shims": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", + "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", + "dev": true + }, + "buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", + "dev": true + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + }, + "builtin-status-codes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", + "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", + "dev": true + }, + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true + }, + "caniuse-lite": { + "version": "1.0.30000874", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000874.tgz", + "integrity": "sha512-29nr1EPiHwrJTAHHsEmTt2h+55L8j2GNFdAcYPlRy2NX6iFz7ZZiepVI7kP/QqlnHLq3KvfWpbmGa0d063U09w==", + "dev": true + }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "dev": true, + "requires": { + "align-text": "^0.1.3", + "lazy-cache": "^1.0.3" + } + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "chokidar": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.6.1.tgz", + "integrity": "sha1-L0RHq16W5Q+z14n9kNTHLg5McMI=", + "dev": true, + "requires": { + "anymatch": "^1.3.0", + "async-each": "^1.0.0", + "fsevents": "^1.0.0", + "glob-parent": "^2.0.0", + "inherits": "^2.0.1", + "is-binary-path": "^1.0.0", + "is-glob": "^2.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.0.0" + } + }, + "cipher-base": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.3.tgz", + "integrity": "sha1-7qvxlEGc6QDaMBjCB9IS8qbfCgc=", + "dev": true, + "requires": { + "inherits": "^2.0.1" + } + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "requires": { + "center-align": "^0.1.1", + "right-align": "^0.1.1", + "wordwrap": "0.0.2" + } + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "console-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", + "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", + "dev": true, + "requires": { + "date-now": "^0.1.4" + } + }, + "constants-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", + "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", + "dev": true + }, + "convert-source-map": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz", + "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=", + "dev": true + }, + "core-js": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.4.1.tgz", + "integrity": "sha1-TekR5mew6ukSTjQlS1OupvxhjT4=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "create-ecdh": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.0.tgz", + "integrity": "sha1-iIxyNZbN92EvZJgjPuvXo1MBc30=", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "elliptic": "^6.0.0" + } + }, + "create-hash": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.2.tgz", + "integrity": "sha1-USEAYte7dHn2xlu0GpIgix1hq60=", + "dev": true, + "requires": { + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "ripemd160": "^1.0.0", + "sha.js": "^2.3.6" + } + }, + "create-hmac": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.4.tgz", + "integrity": "sha1-0/tLolPriz9W456i+8uK90e9MXA=", + "dev": true, + "requires": { + "create-hash": "^1.1.0", + "inherits": "^2.0.1" + } + }, + "crypto-browserify": { + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.11.0.tgz", + "integrity": "sha1-NlKgkGq5sqfgw85mpAjpV6JIVSI=", + "dev": true, + "requires": { + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0" + } + }, + "date-now": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", + "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "dev": true + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "des.js": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", + "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "detect-indent": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", + "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", + "dev": true, + "requires": { + "repeating": "^2.0.0" + } + }, + "diffie-hellman": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.2.tgz", + "integrity": "sha1-tYNXOScM/ias9jIJn97SoH8gnl4=", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } + }, + "domain-browser": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", + "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=", + "dev": true + }, + "electron-to-chromium": { + "version": "1.3.56", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.56.tgz", + "integrity": "sha512-h4FnvXgyfJaA1egXqCwfpecFu1k6U4sPqwvCeux2yEWbu+Avlsa9i07iB5M+M1M2iyfEUnuQDWYCkPCkfO5cpg==", + "dev": true + }, + "elliptic": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", + "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "dev": true, + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" + } + }, + "emojis-list": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", + "dev": true + }, + "enhanced-resolve": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-3.1.0.tgz", + "integrity": "sha1-n0tib1dyRe3PSyrYPYbhf09CHew=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "memory-fs": "^0.4.0", + "object-assign": "^4.0.1", + "tapable": "^0.2.5" + } + }, + "errno": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.4.tgz", + "integrity": "sha1-uJbiOp5ei6M4cfyZar02NfyaHH0=", + "dev": true, + "requires": { + "prr": "~0.0.0" + } + }, + "error-ex": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", + "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "events": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", + "dev": true + }, + "evp_bytestokey": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.0.tgz", + "integrity": "sha1-SXtmrZ/vZc18CKYYCCS6FHa2blM=", + "dev": true, + "requires": { + "create-hash": "^1.1.1" + } + }, + "expand-brackets": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", + "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", + "dev": true, + "requires": { + "is-posix-bracket": "^0.1.0" + } + }, + "expand-range": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", + "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", + "dev": true, + "requires": { + "fill-range": "^2.1.0" + } + }, + "extend": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-2.0.1.tgz", + "integrity": "sha1-HugBBonnOV/5RIJByYZSvHWagmA=" + }, + "extglob": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", + "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", + "dev": true, + "requires": { + "is-extglob": "^1.0.0" + } + }, + "filename-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.0.tgz", + "integrity": "sha1-mW4+gEebmLmJfxWopYs9CE6SZ3U=", + "dev": true + }, + "fill-range": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", + "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", + "dev": true, + "requires": { + "is-number": "^2.1.0", + "isobject": "^2.0.0", + "randomatic": "^1.1.3", + "repeat-element": "^1.1.2", + "repeat-string": "^1.5.2" + } + }, + "find-cache-dir": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-0.1.1.tgz", + "integrity": "sha1-yN765XyKUqinhPnjHFfHQumToLk=", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "mkdirp": "^0.5.1", + "pkg-dir": "^1.0.0" + } + }, + "find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "dev": true, + "requires": { + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "for-own": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", + "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", + "dev": true, + "requires": { + "for-in": "^1.0.1" + } + }, + "fsevents": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.1.tgz", + "integrity": "sha1-8Z/Sj0Pur3YWgOUZogPE0LPTGv8=", + "dev": true, + "optional": true, + "requires": { + "nan": "^2.3.0", + "node-pre-gyp": "^0.6.29" + }, + "dependencies": { + "abbrev": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz", + "integrity": "sha1-0FVMIlZjbi9W58LlrRg/hZQo2B8=", + "dev": true, + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true, + "optional": true + }, + "aproba": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.1.1.tgz", + "integrity": "sha1-ldNgDwdxCqDpKYxyatXs8urLq6s=", + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz", + "integrity": "sha1-gORw6VoIR5T+GJkmLFZnxuiN4bM=", + "dev": true, + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.0 || ^1.1.13" + } + }, + "asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", + "dev": true, + "optional": true + }, + "assert-plus": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", + "dev": true, + "optional": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true, + "optional": true + }, + "aws-sign2": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", + "dev": true, + "optional": true + }, + "aws4": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", + "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", + "dev": true, + "optional": true + }, + "balanced-match": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", + "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=", + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", + "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", + "dev": true, + "optional": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "block-stream": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", + "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", + "dev": true, + "requires": { + "inherits": "~2.0.0" + } + }, + "boom": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", + "dev": true, + "requires": { + "hoek": "2.x.x" + } + }, + "brace-expansion": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz", + "integrity": "sha1-cZfX6qm4fmSDkOph/GbIRCdCDfk=", + "dev": true, + "requires": { + "balanced-match": "^0.4.1", + "concat-map": "0.0.1" + } + }, + "buffer-shims": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", + "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", + "dev": true + }, + "caseless": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", + "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", + "dev": true, + "optional": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "optional": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, + "combined-stream": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "dev": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "dev": true, + "optional": true, + "requires": { + "graceful-readlink": ">= 1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "cryptiles": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", + "dev": true, + "optional": true, + "requires": { + "boom": "2.x.x" + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "optional": true, + "requires": { + "assert-plus": "^1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true, + "optional": true + } + } + }, + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "dev": true, + "optional": true, + "requires": { + "ms": "0.7.1" + } + }, + "deep-extend": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.1.tgz", + "integrity": "sha1-7+QRPQgIX05vlod1mBD4B0aeIlM=", + "dev": true, + "optional": true + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "dev": true, + "optional": true + }, + "ecc-jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", + "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", + "dev": true, + "optional": true, + "requires": { + "jsbn": "~0.1.0" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true, + "optional": true + }, + "extend": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", + "integrity": "sha1-WkdDU7nzNT3dgXbf03uRyDpG8dQ=", + "dev": true, + "optional": true + }, + "extsprintf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", + "integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA=", + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true, + "optional": true + }, + "form-data": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.2.tgz", + "integrity": "sha1-icNTQAi5fq2ky7FX1Y9vXfAl6uQ=", + "dev": true, + "optional": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.5", + "mime-types": "^2.1.12" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fstream": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.10.tgz", + "integrity": "sha1-YE6Kkv4m/9n2+uMDmdSYThqyKCI=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "inherits": "~2.0.0", + "mkdirp": ">=0.5 0", + "rimraf": "2" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/fstream-ignore/-/fstream-ignore-1.0.5.tgz", + "integrity": "sha1-nDHa40dnAY/h0kmyTa2mfQktoQU=", + "dev": true, + "optional": true, + "requires": { + "fstream": "^1.0.0", + "inherits": "2", + "minimatch": "^3.0.0" + } + }, + "gauge": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.3.tgz", + "integrity": "sha1-HCOFX5YvF7OtPQ3HRD8wRULt/gk=", + "dev": true, + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "generate-function": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", + "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", + "dev": true, + "optional": true + }, + "generate-object-property": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", + "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", + "dev": true, + "optional": true, + "requires": { + "is-property": "^1.0.0" + } + }, + "getpass": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.6.tgz", + "integrity": "sha1-KD/9n8ElaECHUxHBtg6MQBhxEOY=", + "dev": true, + "optional": true, + "requires": { + "assert-plus": "^1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true, + "optional": true + } + } + }, + "glob": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", + "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.2", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", + "dev": true, + "optional": true + }, + "har-validator": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", + "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", + "dev": true, + "optional": true, + "requires": { + "chalk": "^1.1.1", + "commander": "^2.9.0", + "is-my-json-valid": "^2.12.4", + "pinkie-promise": "^2.0.0" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "optional": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "dev": true, + "optional": true + }, + "hawk": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "dev": true, + "optional": true, + "requires": { + "boom": "2.x.x", + "cryptiles": "2.x.x", + "hoek": "2.x.x", + "sntp": "1.x.x" + } + }, + "hoek": { + "version": "2.16.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", + "dev": true + }, + "http-signature": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "dev": true, + "optional": true, + "requires": { + "assert-plus": "^0.2.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "ini": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", + "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-my-json-valid": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz", + "integrity": "sha1-k27do8o8IR/ZjzstPgjaQ/eykVs=", + "dev": true, + "optional": true, + "requires": { + "generate-function": "^2.0.0", + "generate-object-property": "^1.1.0", + "jsonpointer": "^4.0.0", + "xtend": "^4.0.0" + } + }, + "is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", + "dev": true, + "optional": true + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true, + "optional": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true, + "optional": true + }, + "jodid25519": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/jodid25519/-/jodid25519-1.0.2.tgz", + "integrity": "sha1-BtSRIlUJNBlHfUJWM2BuDpB4KWc=", + "dev": true, + "optional": true, + "requires": { + "jsbn": "~0.1.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true, + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "dev": true, + "optional": true + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true, + "optional": true + }, + "jsonpointer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", + "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", + "dev": true, + "optional": true + }, + "jsprim": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.3.1.tgz", + "integrity": "sha1-KnJW9wQSop7jZwqspiWZTE3P8lI=", + "dev": true, + "optional": true, + "requires": { + "extsprintf": "1.0.2", + "json-schema": "0.2.3", + "verror": "1.3.6" + } + }, + "mime-db": { + "version": "1.26.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.26.0.tgz", + "integrity": "sha1-6v/NDk/Gk1z4E02iRuLmw1MFrf8=", + "dev": true + }, + "mime-types": { + "version": "2.1.14", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz", + "integrity": "sha1-9+99l1g/yvO30oK2+LVnnaselO4=", + "dev": true, + "requires": { + "mime-db": "~1.26.0" + } + }, + "minimatch": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz", + "integrity": "sha1-Kk5AkLlrLbBqnX3wEFWmKnfJt3Q=", + "dev": true, + "requires": { + "brace-expansion": "^1.0.0" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "dev": true, + "optional": true + }, + "node-pre-gyp": { + "version": "0.6.33", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.33.tgz", + "integrity": "sha1-ZArFUZj2qSWXLgwWxKwmoDTV7Mk=", + "dev": true, + "optional": true, + "requires": { + "mkdirp": "~0.5.1", + "nopt": "~3.0.6", + "npmlog": "^4.0.1", + "rc": "~1.1.6", + "request": "^2.79.0", + "rimraf": "~2.5.4", + "semver": "~5.3.0", + "tar": "~2.2.1", + "tar-pack": "~3.3.0" + } + }, + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dev": true, + "optional": true, + "requires": { + "abbrev": "1" + } + }, + "npmlog": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.0.2.tgz", + "integrity": "sha1-0DlQ4OeM4VJ7om0qdZLpNIrD518=", + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.1", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true, + "optional": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "optional": true, + "requires": { + "pinkie": "^2.0.0" + } + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true, + "optional": true + }, + "qs": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.3.1.tgz", + "integrity": "sha1-kYwLO802Z5dyuvE1say0wWUe150=", + "dev": true, + "optional": true + }, + "rc": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.1.7.tgz", + "integrity": "sha1-xepWS7B6/5/TpbMukGwdOmWUD+o=", + "dev": true, + "optional": true, + "requires": { + "deep-extend": "~0.4.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz", + "integrity": "sha1-qeb+w8fdqF+LsbO6cChgRVb8gl4=", + "dev": true, + "optional": true, + "requires": { + "buffer-shims": "^1.0.0", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~0.10.x", + "util-deprecate": "~1.0.1" + } + }, + "request": { + "version": "2.79.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.79.0.tgz", + "integrity": "sha1-Tf5b9r6LjNw3/Pk+BLZVd3InEN4=", + "dev": true, + "optional": true, + "requires": { + "aws-sign2": "~0.6.0", + "aws4": "^1.2.1", + "caseless": "~0.11.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.0", + "forever-agent": "~0.6.1", + "form-data": "~2.1.1", + "har-validator": "~2.0.6", + "hawk": "~3.1.3", + "http-signature": "~1.1.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.7", + "oauth-sign": "~0.8.1", + "qs": "~6.3.0", + "stringstream": "~0.0.4", + "tough-cookie": "~2.3.0", + "tunnel-agent": "~0.4.1", + "uuid": "^3.0.0" + } + }, + "rimraf": { + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz", + "integrity": "sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ=", + "dev": true, + "requires": { + "glob": "^7.0.5" + } + }, + "semver": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true, + "optional": true + }, + "sntp": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", + "dev": true, + "optional": true, + "requires": { + "hoek": "2.x.x" + } + }, + "sshpk": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.10.2.tgz", + "integrity": "sha1-1agEziJpVRVjjnmNviMnPeBwpfo=", + "dev": true, + "optional": true, + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jodid25519": "^1.0.0", + "jsbn": "~0.1.0", + "tweetnacl": "~0.14.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true, + "optional": true + } + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "stringstream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", + "dev": true, + "optional": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true, + "optional": true + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true, + "optional": true + }, + "tar": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", + "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", + "dev": true, + "requires": { + "block-stream": "*", + "fstream": "^1.0.2", + "inherits": "2" + } + }, + "tar-pack": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/tar-pack/-/tar-pack-3.3.0.tgz", + "integrity": "sha1-MJMYFkGPVa/E0hd1r91nIM7kXa4=", + "dev": true, + "optional": true, + "requires": { + "debug": "~2.2.0", + "fstream": "~1.0.10", + "fstream-ignore": "~1.0.5", + "once": "~1.3.3", + "readable-stream": "~2.1.4", + "rimraf": "~2.5.1", + "tar": "~2.2.1", + "uid-number": "~0.0.6" + }, + "dependencies": { + "once": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", + "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", + "dev": true, + "optional": true, + "requires": { + "wrappy": "1" + } + }, + "readable-stream": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "integrity": "sha1-ZvqLcg4UOLNkaB8q0aY8YYRIydA=", + "dev": true, + "optional": true, + "requires": { + "buffer-shims": "^1.0.0", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~0.10.x", + "util-deprecate": "~1.0.1" + } + } + } + }, + "tough-cookie": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", + "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=", + "dev": true, + "optional": true, + "requires": { + "punycode": "^1.4.1" + } + }, + "tunnel-agent": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", + "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", + "dev": true, + "optional": true + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true, + "optional": true + }, + "uid-number": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz", + "integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE=", + "dev": true, + "optional": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "uuid": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz", + "integrity": "sha1-ZUS7ot/ajBzxfmKaOjBeK7H+5sE=", + "dev": true, + "optional": true + }, + "verror": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", + "integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=", + "dev": true, + "optional": true, + "requires": { + "extsprintf": "1.0.2" + } + }, + "wide-align": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.0.tgz", + "integrity": "sha1-QO3egCpx/qHwcNo+YtzaLnrdlq0=", + "dev": true, + "optional": true, + "requires": { + "string-width": "^1.0.1" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true, + "optional": true + } + } + }, + "get-caller-file": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz", + "integrity": "sha1-9wLmMSfn4jHBYKgMFVSstw1QR+U=", + "dev": true + }, + "glob-base": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", + "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", + "dev": true, + "requires": { + "glob-parent": "^2.0.0", + "is-glob": "^2.0.0" + } + }, + "glob-parent": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", + "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", + "dev": true, + "requires": { + "is-glob": "^2.0.0" + } + }, + "globals": { + "version": "9.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", + "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", + "dev": true + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, + "hash.js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz", + "integrity": "sha1-EzL/ABVsCg/92CNgE9B7d6BFFXM=", + "dev": true, + "requires": { + "inherits": "^2.0.1" + } + }, + "hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "dev": true, + "requires": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "home-or-tmp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", + "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=", + "dev": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.1" + } + }, + "hosted-git-info": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.4.2.tgz", + "integrity": "sha1-AHa59GonBQbduq6lZJaJdGBhKmc=", + "dev": true + }, + "https-browserify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-0.0.1.tgz", + "integrity": "sha1-P5E2XKvmC3ftDruiS0VOPgnZWoI=", + "dev": true + }, + "ieee754": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", + "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=", + "dev": true + }, + "indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", + "dev": true + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "interpret": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.3.tgz", + "integrity": "sha1-y8NcYu7uc/Gat7EKgBURQBr8D5A=", + "dev": true + }, + "invariant": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", + "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "dev": true, + "requires": { + "loose-envify": "^1.0.0" + } + }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", + "dev": true + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "requires": { + "binary-extensions": "^1.0.0" + } + }, + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "dev": true + }, + "is-builtin-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", + "dev": true, + "requires": { + "builtin-modules": "^1.0.0" + } + }, + "is-dotfile": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.2.tgz", + "integrity": "sha1-LBMjg/ORmfjtwmjKAbmwB9IFzE0=", + "dev": true + }, + "is-equal-shallow": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", + "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", + "dev": true, + "requires": { + "is-primitive": "^2.0.0" + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", + "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", + "dev": true + }, + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-glob": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", + "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", + "dev": true, + "requires": { + "is-extglob": "^1.0.0" + } + }, + "is-number": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", + "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + } + }, + "is-posix-bracket": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", + "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", + "dev": true + }, + "is-primitive": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", + "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", + "dev": true + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + }, + "jsesc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", + "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=", + "dev": true + }, + "json-loader": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/json-loader/-/json-loader-0.5.4.tgz", + "integrity": "sha1-i6oTZaYy9Yo8RtIBdfxgAsluN94=", + "dev": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "~0.0.0" + } + }, + "json5": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", + "dev": true + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, + "kind-of": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.0.tgz", + "integrity": "sha1-tYq+TVwEStM3JqjBUltIz4kb/wc=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "dev": true, + "requires": { + "invert-kv": "^1.0.0" + } + }, + "load-json-file": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" + } + }, + "loader-runner": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.3.0.tgz", + "integrity": "sha1-9IKuqC1UPgeSFwDVpG7yb9rGuKI=", + "dev": true + }, + "loader-utils": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", + "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", + "dev": true, + "requires": { + "big.js": "^3.1.3", + "emojis-list": "^2.0.0", + "json5": "^0.5.0" + } + }, + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", + "dev": true + }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "memory-fs": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz", + "integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=", + "dev": true, + "requires": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" + } + }, + "micromatch": { + "version": "2.3.11", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", + "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", + "dev": true, + "requires": { + "arr-diff": "^2.0.0", + "array-unique": "^0.2.1", + "braces": "^1.8.2", + "expand-brackets": "^0.1.4", + "extglob": "^0.3.1", + "filename-regex": "^2.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.1", + "kind-of": "^3.0.2", + "normalize-path": "^2.0.1", + "object.omit": "^2.0.0", + "parse-glob": "^3.0.4", + "regex-cache": "^0.4.2" + } + }, + "miller-rabin": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.0.tgz", + "integrity": "sha1-SmL7HUKTPAVYOYL0xxb2+55sbT0=", + "dev": true, + "requires": { + "bn.js": "^4.0.0", + "brorand": "^1.0.1" + } + }, + "minimalistic-assert": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz", + "integrity": "sha1-cCvi3aazf0g2vLP121ZkG2Sh09M=", + "dev": true + }, + "minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", + "dev": true + }, + "minimatch": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz", + "integrity": "sha1-Kk5AkLlrLbBqnX3wEFWmKnfJt3Q=", + "dev": true, + "requires": { + "brace-expansion": "^1.0.0" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "nan": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.6.2.tgz", + "integrity": "sha1-5P805slf37WuzAjeZZb0NgWn20U=", + "dev": true, + "optional": true + }, + "nexusui": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/nexusui/-/nexusui-1.2.0.tgz", + "integrity": "sha1-d2drkuFDoENdxEw47SkrJJqiRjE=", + "requires": { + "extend": "2.0.x" + } + }, + "node-libs-browser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.0.0.tgz", + "integrity": "sha1-o6WeyXAkmFtG6Vg3lkb5bEthZkY=", + "dev": true, + "requires": { + "assert": "^1.1.1", + "browserify-zlib": "^0.1.4", + "buffer": "^4.3.0", + "console-browserify": "^1.1.0", + "constants-browserify": "^1.0.0", + "crypto-browserify": "^3.11.0", + "domain-browser": "^1.1.1", + "events": "^1.0.0", + "https-browserify": "0.0.1", + "os-browserify": "^0.2.0", + "path-browserify": "0.0.0", + "process": "^0.11.0", + "punycode": "^1.2.4", + "querystring-es3": "^0.2.0", + "readable-stream": "^2.0.5", + "stream-browserify": "^2.0.1", + "stream-http": "^2.3.1", + "string_decoder": "^0.10.25", + "timers-browserify": "^2.0.2", + "tty-browserify": "0.0.0", + "url": "^0.11.0", + "util": "^0.10.3", + "vm-browserify": "0.0.4" + }, + "dependencies": { + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + } + } + }, + "normalize-package-data": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.3.8.tgz", + "integrity": "sha1-2Bntoqne29H/pWPqQHHZNngilbs=", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "is-builtin-module": "^1.0.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "object.omit": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", + "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", + "dev": true, + "requires": { + "for-own": "^0.1.4", + "is-extendable": "^0.1.1" + } + }, + "os-browserify": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.2.1.tgz", + "integrity": "sha1-Y/xMzuXS13Y9Jrv4YBB45sLgBE8=", + "dev": true + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "dev": true + }, + "os-locale": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "dev": true, + "requires": { + "lcid": "^1.0.0" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "pako": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", + "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", + "dev": true + }, + "parse-asn1": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.0.tgz", + "integrity": "sha1-N8T5t+06tlx0gXtfJICTf7+XxxI=", + "dev": true, + "requires": { + "asn1.js": "^4.0.0", + "browserify-aes": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3" + } + }, + "parse-glob": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", + "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", + "dev": true, + "requires": { + "glob-base": "^0.3.0", + "is-dotfile": "^1.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.0" + } + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, + "path-browserify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", + "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", + "dev": true + }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true, + "requires": { + "pinkie-promise": "^2.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "pbkdf2": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.9.tgz", + "integrity": "sha1-8sSyWmAAWLPDdzwIbDfbvuH/5pM=", + "dev": true, + "requires": { + "create-hmac": "^1.1.2" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "^2.0.0" + } + }, + "pkg-dir": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", + "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", + "dev": true, + "requires": { + "find-up": "^1.0.0" + } + }, + "preserve": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", + "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", + "dev": true + }, + "private": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", + "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=", + "dev": true + }, + "process": { + "version": "0.11.9", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.9.tgz", + "integrity": "sha1-e9WtIapiU+fahoImTx4R0RwDGME=", + "dev": true + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "prr": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz", + "integrity": "sha1-GoS4WQgyVQFBGFPQCB7j+obikmo=", + "dev": true + }, + "public-encrypt": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.0.tgz", + "integrity": "sha1-OfaZ86RlYN1eusvKaTyvfGXBjMY=", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1" + } + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", + "dev": true + }, + "querystring-es3": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", + "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", + "dev": true + }, + "randomatic": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.6.tgz", + "integrity": "sha1-EQ3Kv/OX6dz/fAeJzMCkmt8exbs=", + "dev": true, + "requires": { + "is-number": "^2.0.2", + "kind-of": "^3.0.2" + } + }, + "randombytes": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.3.tgz", + "integrity": "sha1-Z0yZdgkBw8QRJ3GjHlIdw0nMCew=", + "dev": true + }, + "read-pkg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "dev": true, + "requires": { + "load-json-file": "^1.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^1.0.0" + } + }, + "read-pkg-up": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "dev": true, + "requires": { + "find-up": "^1.0.0", + "read-pkg": "^1.0.0" + } + }, + "readable-stream": { + "version": "2.2.9", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.9.tgz", + "integrity": "sha1-z3jsb0ptHrQ9JkiMrJfwQudLf8g=", + "dev": true, + "requires": { + "buffer-shims": "~1.0.0", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~1.0.0", + "util-deprecate": "~1.0.1" + } + }, + "readdirp": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", + "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "minimatch": "^3.0.2", + "readable-stream": "^2.0.2", + "set-immediate-shim": "^1.0.1" + } + }, + "regenerate": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.3.2.tgz", + "integrity": "sha1-0ZQcZ7rUN+G+dkM63Vs4X5WxkmA=", + "dev": true + }, + "regenerator-runtime": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.3.tgz", + "integrity": "sha1-jENnqQS1HqYqkIrDEL+Z/5CoKj4=", + "dev": true + }, + "regenerator-transform": { + "version": "0.9.11", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.9.11.tgz", + "integrity": "sha1-On0GdSDLe3F2dp61/4aGkb7+EoM=", + "dev": true, + "requires": { + "babel-runtime": "^6.18.0", + "babel-types": "^6.19.0", + "private": "^0.1.6" + } + }, + "regex-cache": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz", + "integrity": "sha1-mxpsNdTQ3871cRrmUejp09cRQUU=", + "dev": true, + "requires": { + "is-equal-shallow": "^0.1.3", + "is-primitive": "^2.0.0" + } + }, + "regexpu-core": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", + "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", + "dev": true, + "requires": { + "regenerate": "^1.2.1", + "regjsgen": "^0.2.0", + "regjsparser": "^0.1.4" + } + }, + "regjsgen": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", + "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=", + "dev": true + }, + "regjsparser": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", + "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", + "dev": true, + "requires": { + "jsesc": "~0.5.0" + }, + "dependencies": { + "jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", + "dev": true + } + } + }, + "remove-trailing-separator": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.0.1.tgz", + "integrity": "sha1-YV67lq9VlVLUv0BXyENtSGq2PMQ=", + "dev": true + }, + "repeat-element": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", + "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "repeating": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", + "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "dev": true, + "requires": { + "is-finite": "^1.0.0" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "dev": true, + "requires": { + "align-text": "^0.1.1" + } + }, + "ripemd160": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-1.0.1.tgz", + "integrity": "sha1-k6S71JQrxXS2mo+lfHHeEOzKfW4=", + "dev": true + }, + "semver": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", + "dev": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "set-immediate-shim": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", + "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", + "dev": true + }, + "setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", + "dev": true + }, + "sha.js": { + "version": "2.4.8", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.8.tgz", + "integrity": "sha1-NwaMLEdra69ALRSknGf1l5IfY08=", + "dev": true, + "requires": { + "inherits": "^2.0.1" + } + }, + "slash": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", + "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", + "dev": true + }, + "source-list-map": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-1.1.1.tgz", + "integrity": "sha1-GjOsIQyhRNHlYfkG68yrVmn/TLQ=", + "dev": true + }, + "source-map": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", + "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", + "dev": true + }, + "source-map-support": { + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", + "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", + "dev": true, + "requires": { + "source-map": "^0.5.6" + } + }, + "spdx-correct": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", + "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=", + "dev": true, + "requires": { + "spdx-license-ids": "^1.0.2" + } + }, + "spdx-expression-parse": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz", + "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=", + "dev": true + }, + "spdx-license-ids": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz", + "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", + "dev": true + }, + "stream-browserify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", + "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", + "dev": true, + "requires": { + "inherits": "~2.0.1", + "readable-stream": "^2.0.2" + } + }, + "stream-http": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.0.tgz", + "integrity": "sha1-zsH047SUvEqBtFGAiXD4sgtO1fY=", + "dev": true, + "requires": { + "builtin-status-codes": "^3.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.2.6", + "to-arraybuffer": "^1.0.0", + "xtend": "^4.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.0.tgz", + "integrity": "sha1-8G9BFXtmTYYGn4S9vcmw2KsoFmc=", + "dev": true, + "requires": { + "buffer-shims": "~1.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "dev": true, + "requires": { + "is-utf8": "^0.2.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + }, + "tapable": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.6.tgz", + "integrity": "sha1-IGvo4YiGC1FEJTdebxrom/sB/Y0=", + "dev": true + }, + "timers-browserify": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.2.tgz", + "integrity": "sha1-q0iDz1l9zVCvIRNJoA+8pWrIa4Y=", + "dev": true, + "requires": { + "setimmediate": "^1.0.4" + } + }, + "to-arraybuffer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", + "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", + "dev": true + }, + "to-fast-properties": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.2.tgz", + "integrity": "sha1-8/XAw7pymafvmUJ+RGMyV63kMyA=", + "dev": true + }, + "tone": { + "version": "0.12.80", + "resolved": "https://registry.npmjs.org/tone/-/tone-0.12.80.tgz", + "integrity": "sha512-xCriTn1may1ZzfYYwxXW8pNj0W1XScc21ZLSd/itoTa3s0vMO1LlN23UYvHwUduL45xuY+Rw/e87LmqP3mW43Q==" + }, + "trim-right": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", + "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", + "dev": true + }, + "tty-browserify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", + "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", + "dev": true + }, + "uglify-js": { + "version": "2.8.22", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.22.tgz", + "integrity": "sha1-1Uk0d4qNoUkD+imjJvskwKtRoaA=", + "dev": true, + "requires": { + "source-map": "~0.5.1", + "uglify-to-browserify": "~1.0.0", + "yargs": "~3.10.0" + }, + "dependencies": { + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "requires": { + "camelcase": "^1.0.2", + "cliui": "^2.1.0", + "decamelize": "^1.0.0", + "window-size": "0.1.0" + } + } + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true, + "optional": true + }, + "url": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", + "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", + "dev": true, + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + }, + "dependencies": { + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + } + } + }, + "util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "dev": true, + "requires": { + "inherits": "2.0.1" + }, + "dependencies": { + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", + "dev": true + } + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "validate-npm-package-license": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", + "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=", + "dev": true, + "requires": { + "spdx-correct": "~1.0.0", + "spdx-expression-parse": "~1.0.0" + } + }, + "vm-browserify": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", + "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", + "dev": true, + "requires": { + "indexof": "0.0.1" + } + }, + "watchpack": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.3.1.tgz", + "integrity": "sha1-fYaTkHsozmAT5/NhCqKhrPB9rYc=", + "dev": true, + "requires": { + "async": "^2.1.2", + "chokidar": "^1.4.3", + "graceful-fs": "^4.1.2" + } + }, + "webfontloader": { + "version": "1.6.27", + "resolved": "https://registry.npmjs.org/webfontloader/-/webfontloader-1.6.27.tgz", + "integrity": "sha1-w4mWSbBlOqV9CiM4j4JAng3yJLo=" + }, + "webmidi": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/webmidi/-/webmidi-2.2.0.tgz", + "integrity": "sha512-/HncJbftTyijTAhk/oKAZFBk5sE3UgWFlBUcd82YVEz1epAXMk0thXLpSKe3nGPR8V4R/LLBCbdzqQ9ZeBQOsw==" + }, + "webpack": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-2.4.1.tgz", + "integrity": "sha1-FakdvjSWbYpLmcfWVu/ZKi5ab2o=", + "dev": true, + "requires": { + "acorn": "^5.0.0", + "acorn-dynamic-import": "^2.0.0", + "ajv": "^4.7.0", + "ajv-keywords": "^1.1.1", + "async": "^2.1.2", + "enhanced-resolve": "^3.0.0", + "interpret": "^1.0.0", + "json-loader": "^0.5.4", + "json5": "^0.5.1", + "loader-runner": "^2.3.0", + "loader-utils": "^0.2.16", + "memory-fs": "~0.4.1", + "mkdirp": "~0.5.0", + "node-libs-browser": "^2.0.0", + "source-map": "^0.5.3", + "supports-color": "^3.1.0", + "tapable": "~0.2.5", + "uglify-js": "^2.8.5", + "watchpack": "^1.3.1", + "webpack-sources": "^0.2.3", + "yargs": "^6.0.0" + }, + "dependencies": { + "loader-utils": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz", + "integrity": "sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g=", + "dev": true, + "requires": { + "big.js": "^3.1.3", + "emojis-list": "^2.0.0", + "json5": "^0.5.0", + "object-assign": "^4.0.1" + } + }, + "supports-color": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", + "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "dev": true, + "requires": { + "has-flag": "^1.0.0" + } + } + } + }, + "webpack-sources": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-0.2.3.tgz", + "integrity": "sha1-F8Yr+vE8cH+dAsR54Nzd6DgGl/s=", + "dev": true, + "requires": { + "source-list-map": "^1.1.1", + "source-map": "~0.5.3" + } + }, + "which-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", + "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", + "dev": true + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true + }, + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + } + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + }, + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "dev": true + }, + "yargs": { + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-6.6.0.tgz", + "integrity": "sha1-eC7CHvQDNF+DCoCMo9UTr1YGUgg=", + "dev": true, + "requires": { + "camelcase": "^3.0.0", + "cliui": "^3.2.0", + "decamelize": "^1.1.1", + "get-caller-file": "^1.0.1", + "os-locale": "^1.4.0", + "read-pkg-up": "^1.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^1.0.2", + "which-module": "^1.0.0", + "y18n": "^3.2.1", + "yargs-parser": "^4.2.0" + }, + "dependencies": { + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", + "dev": true + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + } + } + } + }, + "yargs-parser": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-4.2.1.tgz", + "integrity": "sha1-KczqwNxPA8bIe0qfIX3RjJ90hxw=", + "dev": true, + "requires": { + "camelcase": "^3.0.0" + }, + "dependencies": { + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", + "dev": true + } + } + } + } +} diff --git a/package.json b/package.json index 97cae36..264d0d1 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "triangle", + "name": "cells", "version": "1.0.0", "description": "", "main": "index.js", @@ -9,15 +9,16 @@ "author": "", "license": "UNLICENSED", "devDependencies": { - "babel-core": "^6.24.1", + "babel-core": "^6.26.3", "babel-loader": "^7.0.0", - "babel-preset-env": "^1.4.0", + "babel-preset-env": "^1.7.0", "babel-preset-es2015": "^6.24.1", "webpack": "^2.4.1" }, "dependencies": { "nexusui": "^1.2.0", - "tone": "^0.10.0", - "webfontloader": "^1.6.27" + "tone": "^0.12.80", + "webfontloader": "^1.6.27", + "webmidi": "^2.2.0" } } |
