xsound 2.26.4 → 2.26.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/xsound.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see xsound.js.LICENSE.txt */
2
- (()=>{"use strict";function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var e=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e)}var r,n;return r=e,(n=[{key:"INPUT",value:function(){}},{key:"OUTPUT",value:function(){}}])&&t(r.prototype,n),e}();function r(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw s}}}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var s=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.sampleRate=e,this.isActive=!1,this.graphics="",this.canvas=null,this.context=null,this.svg=null,this.interval=1e3,this.timerid=null,this.styles={shape:"line",grad:[{offset:0,color:"rgba(0, 128, 255, 1.0)"},{offset:1,color:"rgba(0, 0, 255, 1.0)"}],wave:"rgba(0, 0, 255, 1.0)",grid:"rgba(255, 0, 0, 1.0)",text:"rgba(255, 255, 255, 1.0)",font:{family:"Arial",size:"13px",style:"normal"},width:1.5,cap:"round",join:"miter",top:15,right:30,bottom:15,left:30}}var e,n;return e=t,(n=[{key:"setup",value:function(e){return e instanceof HTMLCanvasElement?(this.graphics=t.CANVAS,this.canvas=e,this.context=this.canvas.getContext("2d")):e instanceof SVGElement&&(this.graphics=t.SVG,this.svg=e),this}},{key:"param",value:function(t,e){var n=String(t).replace(/-/g,"").toLowerCase(),i=null;switch(n){case"interval":if(void 0===e)return this.interval;"auto"===String(e).toLowerCase()?this.interval="auto":(i=parseFloat(e))>=0&&(this.interval=i);break;case"shape":if(void 0===e)return this.styles.shape;"line"!==(i=String(e).toLowerCase())&&"rect"!==i||(this.styles.shape="gradient"!==this.styles.wave?i:"rect");break;case"grad":if(void 0===e)return this.styles.grad;Array.isArray(e)||(e=[e]);var o,s=!1,a=r(e);try{for(a.s();!(o=a.n()).done;){var c=o.value;if(!("offset"in c)||!("color"in c)){s=!0;break}var u=parseFloat(c.offset);if(isNaN(u)||u<0||u>1){s=!0;break}}}catch(t){a.e(t)}finally{a.f()}s||(this.styles.grad=e);break;case"font":if(void 0===e)return this.styles[n];if("[object Object]"===Object.prototype.toString.call(e))for(var l in e)/(?:family|size|style)/i.test(l)&&(this.styles.font[l]=String(e[l]));break;case"wave":case"grid":case"text":case"cap":case"join":if(void 0===e)return this.styles[n];"string"==typeof e&&("wave"===n&&"gradient"===e&&(this.styles.shape="rect"),this.styles[n]=e.toLowerCase());break;case"width":case"top":case"right":case"bottom":case"left":if(void 0===e)return this.styles[n];(i="width"===n?parseFloat(e):parseInt(e,10))>=0&&(this.styles[n]=i)}}},{key:"start",value:function(e,r,n){switch(this.graphics){case t.CANVAS:this.drawOnCanvas(e,r,n);break;case t.SVG:this.drawBySVG(e,r,n)}return this}},{key:"create",value:function(){switch(this.graphics){case t.CANVAS:return this.canvas.toDataURL("image/png").replace("image/png","image/octet-stream");case t.SVG:return this.svg.outerHTML;default:return this}}},{key:"state",value:function(t){return void 0===t?this.isActive:("toggle"===String(t).toLowerCase()?this.isActive=!this.isActive:this.isActive=Boolean(t),this)}},{key:"drawTimeDomainFloat32ArrayOnCanvas",value:function(t,e,n,i,o,s){if(!(t instanceof CanvasRenderingContext2D))return this;if(!(e instanceof Float32Array))return this;var a=parseInt(n,10),c=parseInt(i,10),u=parseInt(o,10);switch(isNaN(a)&&(a=0),isNaN(c)&&(c=0),isNaN(u)&&(u=0),this.styles.shape){case"line":t.strokeStyle=this.styles.wave,t.lineWidth=this.styles.width,t.lineCap=this.styles.cap,t.lineJoin=this.styles.join,t.beginPath();for(var l=0,f=e.length;l<f;l++)if(null==s||l%s==0){var h=l/f*a+this.styles.left,p=(1-e[l])*(c/2)+this.styles.top;0===l?t.moveTo(h+this.styles.width/2,p):t.lineTo(h,p)}t.stroke();break;case"rect":"gradient"!==this.styles.wave&&(t.fillStyle=this.styles.wave);for(var y=0,v=e.length;y<v;y++)if(null==s||y%s==0){var d=y/v*a+this.styles.left,b=e[y]*(c/2)*-1;if("gradient"===this.styles.wave){var m,g=i/2+this.styles.top,w=t.createLinearGradient(0,g,0,g+b),S=r(this.styles.grad);try{for(S.s();!(m=S.n()).done;){var O=m.value;w.addColorStop(O.offset,O.color)}}catch(t){S.e(t)}finally{S.f()}t.fillStyle=w}t.fillRect(d,u,this.styles.width,b)}}return this}},{key:"drawTimeDomainFloat32ArrayBySVG",value:function(e,r,n,i,o,s){var a=parseInt(r,10),c=parseInt(n,10),u=parseInt(i,10);switch(isNaN(a)&&(a=0),isNaN(c)&&(c=0),isNaN(u)&&(u=0),this.styles.shape){case"line":for(var l=document.createElementNS(t.XMLNS,"path"),f="",h=0,p=e.length;h<p;h++)if(null==o||h%o==0){var y=h/p*a+this.styles.left,v=(1-e[h])*(c/2)+this.styles.top;f+=0===h?"M".concat(y+this.styles.width/2," ").concat(v):" L".concat(y," ").concat(v)}return l.setAttribute("d",f),l.setAttribute("stroke",this.styles.wave),l.setAttribute("fill","none"),l.setAttribute("stroke-width",this.styles.width),l.setAttribute("stroke-linecap",this.styles.cap),l.setAttribute("stroke-linejoin",this.styles.join),l;case"rect":var d=null;"gradient"===this.styles.wave&&(d=this.createSVGLinearGradient(s));var b=document.createElementNS(t.XMLNS,"g");null!==d&&b.appendChild(d);for(var m=0,g=e.length;m<g;m++)if(null==o||m%o==0){var w=document.createElementNS(t.XMLNS,"rect"),S=m/g*a+this.styles.left,O=e[m]*(n/2);w.setAttribute("x",S),w.setAttribute("y",u),w.setAttribute("width",this.styles.width),O<0?w.setAttribute("height",-O):(w.setAttribute("height",O),w.setAttribute("transform","rotate(180 ".concat(S+this.styles.width/2," ").concat(u,")"))),w.setAttribute("stroke","none"),w.setAttribute("fill",null===d?this.styles.wave:"url(#".concat(s,")")),b.appendChild(w)}return b;default:return null}}},{key:"createSVGLinearGradient",value:function(e){var n=document.createElementNS(t.XMLNS,"defs"),i=document.createElementNS(t.XMLNS,"linearGradient");i.setAttribute("id",String(e)),i.setAttribute("x1","0%"),i.setAttribute("y1","0%"),i.setAttribute("x2","0%"),i.setAttribute("y2","100%");var o,s=r(this.styles.grad);try{for(s.s();!(o=s.n()).done;){var a=o.value,c=document.createElementNS(t.XMLNS,"stop");c.setAttribute("offset",a.offset),c.setAttribute("stop-color",a.color),i.appendChild(c)}}catch(t){s.e(t)}finally{s.f()}return n.appendChild(i),n}},{key:"createFontString",value:function(){var t=this.styles.font,e=t.size,r=t.style,n=t.family;return"".concat(r," ").concat(e,' "').concat(n,'"')}},{key:"drawOnCanvas",value:function(){return this}},{key:"drawBySVG",value:function(){return this}},{key:"clear",value:function(){if(this.context){var t=this.canvas,e=t.width,r=t.height;this.context.clearRect(0,0,e,r)}return this.svg&&(this.svg.innerHTML=""),this}},{key:"toString",value:function(){return"[SoundModule Analyser Visualizer]"}}])&&i(e.prototype,n),t}();function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function c(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function u(t,e,r){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=p(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},u(t,e,r||t)}function l(t,e){return l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},l(t,e)}function f(t,e){if(e&&("object"===a(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return h(t)}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function p(t){return p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},p(t)}function y(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}o(s,"CANVAS","canvas"),o(s,"SVG","svg"),o(s,"XMLNS","http://www.w3.org/2000/svg"),o(s,"XLINK","http://www.w3.org/1999/xlink"),o(s,"SVG_LINEAR_GRADIENT_ID_TIME_OVERVIEW","svg-linear-gradient-time-overview"),o(s,"SVG_LINEAR_GRADIENT_ID_TIME","svg-linear-gradient-time"),o(s,"SVG_LINEAR_GRADIENT_ID_FFT","svg-linear-gradient-fft");var v=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&l(t,e)}(a,t);var e,r,n,i,o=(n=a,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=p(n);if(i){var r=p(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return f(this,t)});function a(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(e=o.call(this,t)).savedImage=null,e.length=0,e.currentTime="rgba(0, 0, 0, 0.5)",e.sprite="rgba(255, 255, 255, 0.25)",e.plotInterval=.0625,e.textInterval=60,e.isDown=!1,e.mode=a.DRAG_MODE_UPDATE,e.offsetX=0,e.startTime=0,e.endTime=0,e.onStart=e.onStart.bind(h(e)),e.onMove=e.onMove.bind(h(e)),e.onEnd=e.onEnd.bind(h(e)),e}return e=a,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=u(p(a.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;var o=null;switch(n){case"currenttime":if(void 0===e)return this.currentTime;this.currentTime=String(e).toLowerCase();break;case"sprite":if(void 0===e)return this.sprite;this.sprite=String(e).toLowerCase();break;case"plotinterval":case"textinterval":if(void 0===e)return this[n.replace("interval","Interval")];(o=parseFloat(e))>0&&(this[n.replace("interval","Interval")]=o);break;case"mode":if(void 0===e)return this.mode;if(((o=String(e).toLowerCase())===a.DRAG_MODE_UPDATE||o===a.DRAG_MODE_SPRITE)&&(this.mode=o,this.offsetX=0,this.startTime=0,this.endTime=0,this.svg instanceof SVGElement)){var s=this.svg.querySelector(".".concat(a.SVG_SPRITE_CLASS_NAME));s instanceof SVGElement&&this.svg.removeChild(s)}}}return this}},{key:"drawOnCanvas",value:function(t){if(!(this.canvas instanceof HTMLCanvasElement&&this.isActive))return this;var e=this.context,r=this.canvas,n=r.width,i=r.height,o=n-(this.styles.left+this.styles.right),s=i-(this.styles.top+this.styles.bottom),a=Math.floor(s/2)+this.styles.top,c=Math.floor(this.plotInterval*this.sampleRate),u=Math.floor(this.textInterval*this.sampleRate);if(e.clearRect(0,0,n,i),this.drawTimeDomainFloat32ArrayOnCanvas(e,t,o,s,a,c),"none"!==this.styles.grid||"none"!==this.styles.text){for(var l=0,f=t.length;l<f;l++)if(l%u==0){var h=Math.floor(l/f*o)+this.styles.left,p="".concat(Math.floor(l/this.sampleRate/60)," min");"none"!==this.styles.grid&&(e.fillStyle=this.styles.grid,e.fillRect(h,this.styles.top,1,s)),"none"!==this.styles.text&&(e.fillStyle=this.styles.text,e.font=this.createFontString(),e.fillText(p,h-e.measureText(p).width/2,this.styles.top+s+parseInt(this.styles.font.size,10)))}for(var y=0,v=["-1.00","-0.50"," 0.00"," 0.50"," 1.00"];y<v.length;y++){var d=v[y],b=Math.floor(this.styles.left-e.measureText(d).width),m=Math.floor((1-parseFloat(d.trim()))*(s/2))+this.styles.top;"none"!==this.styles.grid&&(e.fillStyle=this.styles.grid,e.fillRect(this.styles.left,m,o,1)),"none"!==this.styles.text&&(e.fillStyle=this.styles.text,e.font=this.createFontString(),e.fillText(d,b,m-Math.floor(parseInt(this.styles.font.size,10)/4)))}}return this.savedImage=e.getImageData(0,0,n,i),this.length=t.length,e.fillStyle=this.currentTime,e.fillRect(this.styles.left,this.styles.top,1,s),this}},{key:"drawBySVG",value:function(t){if(!(this.svg instanceof SVGElement&&this.isActive))return this;var e=this.svg,r=parseInt(e.getAttribute("width"),10),n=parseInt(e.getAttribute("height"),10),i=r-(this.styles.left+this.styles.right),o=n-(this.styles.top+this.styles.bottom),c=Math.floor(o/2)+this.styles.top,u=Math.floor(this.plotInterval*this.sampleRate),l=Math.floor(this.textInterval*this.sampleRate);if(e.innerHTML="",e.appendChild(this.drawTimeDomainFloat32ArrayBySVG(t,i,o,c,u,s.SVG_LINEAR_GRADIENT_ID_TIME_OVERVIEW)),"none"!==this.styles.grid||"none"!==this.styles.text){for(var f=0,h=t.length;f<h;f++)if(f%l==0){var p=Math.floor(f/h*i)+this.styles.left,y=Math.floor(f/this.sampleRate/60)+" min";if("none"!==this.styles.grid){var v=document.createElementNS(s.XMLNS,"rect");v.setAttribute("x",p),v.setAttribute("y",this.styles.top),v.setAttribute("width",1),v.setAttribute("height",o),v.setAttribute("stroke","none"),v.setAttribute("fill",this.styles.grid),e.appendChild(v)}if("none"!==this.styles.text){var d=document.createElementNS(s.XMLNS,"text");d.textContent=y,d.setAttribute("x",p),d.setAttribute("y",this.styles.top+o+parseInt(this.styles.font.size,10)),d.setAttribute("text-anchor","middle"),d.setAttribute("stroke","none"),d.setAttribute("fill",this.styles.text),d.setAttribute("font-family",this.styles.font.family),d.setAttribute("font-size",this.styles.font.size),d.setAttribute("font-style",this.styles.font.style),d.setAttribute("font-weight",this.styles.font.weight),e.appendChild(d)}}for(var b=0,m=["-1.00","-0.50"," 0.00"," 0.50"," 1.00"];b<m.length;b++){var g=m[b],w=this.styles.left,S=Math.floor((1-parseFloat(g.trim()))*(o/2))+this.styles.top;if("none"!==this.styles.grid){var O=document.createElementNS(s.XMLNS,"rect");O.setAttribute("x",w),O.setAttribute("y",S),O.setAttribute("width",i),O.setAttribute("height",1),O.setAttribute("stroke","none"),O.setAttribute("fill",this.styles.grid),e.appendChild(O)}if("none"!==this.styles.text){var A=document.createElementNS(s.XMLNS,"text");A.textContent=g,A.setAttribute("x",w),A.setAttribute("y",S-Math.floor(parseInt(this.styles.font.size,10)/4)),A.setAttribute("text-anchor","end"),A.setAttribute("stroke","none"),A.setAttribute("fill",this.styles.text),A.setAttribute("font-family",this.styles.font.family),A.setAttribute("font-size",this.styles.font.size),A.setAttribute("font-style",this.styles.font.style),A.setAttribute("font-weight",this.styles.font.weight),e.appendChild(A)}}}var k=document.createElementNS(s.XMLNS,"rect");return k.classList.add(a.SVG_CURRENT_TIME_CLASS_NAME),k.setAttribute("y",this.styles.top+1),k.setAttribute("height",o-1),k.setAttribute("stroke","none"),k.setAttribute("fill",this.currentTime),e.appendChild(k),this.savedImage=e,this.length=t.length,this}},{key:"update",value:function(t){var e=parseFloat(t);if(isNaN(e)||e<0)return this;switch(this.graphics){case s.CANVAS:if(this.savedImage instanceof ImageData){var r=this.context,n=this.canvas,i=n.width,o=n.height,c=i-(this.styles.left+this.styles.right),u=o-(this.styles.top+this.styles.bottom),l=e*this.sampleRate/this.length*c;if(r.clearRect(0,0,i,o),r.putImageData(this.savedImage,0,0),this.mode===a.DRAG_MODE_UPDATE)r.fillStyle=this.currentTime,r.fillRect(this.styles.left,this.styles.top+1,l,u-1);else if(this.mode===a.DRAG_MODE_SPRITE){if(0!==this.endTime){var f=Math.floor(Math.abs(this.endTime-this.startTime)*this.sampleRate/this.length*c);r.fillStyle=this.sprite,l>=this.offsetX?r.fillRect(this.styles.left+this.offsetX,this.styles.top+1,f,u-1):r.fillRect(this.styles.left+this.offsetX-f,this.styles.top+1,f,u-1)}r.fillStyle=this.currentTime,l>=this.offsetX?r.fillRect(this.styles.left+this.offsetX,this.styles.top+1,Math.abs(l-this.offsetX),u-1):r.fillRect(this.styles.left+l,this.styles.top+1,Math.abs(l-this.offsetX),u-1)}}break;case s.SVG:var h=this.svg.querySelector(".".concat(a.SVG_CURRENT_TIME_CLASS_NAME));if(h instanceof SVGElement){var p=parseInt(this.svg.getAttribute("width"),10)-(this.styles.left+this.styles.right),y=e*this.sampleRate/this.length*p;if(this.mode===a.DRAG_MODE_UPDATE)h.setAttribute("x",this.styles.left),h.setAttribute("width",y),h.setAttribute("aria-label","current time");else if(this.mode===a.DRAG_MODE_SPRITE){if(0!==this.endTime){var v=document.createElementNS(s.XMLNS,"rect");v.classList.add(a.SVG_SPRITE_CLASS_NAME),this.svg.lastElementChild.previousElementSibling instanceof SVGElement&&this.svg.removeChild(this.svg.lastElementChild.previousElementSibling);var d=Math.floor(Math.abs(this.endTime-this.startTime)*this.sampleRate/this.length*p);v.setAttribute("y",this.styles.top+1),v.setAttribute("height",h.getAttribute("height")),v.setAttribute("stroke","none"),v.setAttribute("fill",this.sprite),v.setAttribute("aria-label","current time"),y>=this.offsetX?v.setAttribute("x",this.styles.left+this.offsetX):v.setAttribute("x",this.styles.left+this.offsetX-d),v.setAttribute("width",d),this.svg.appendChild(v),this.svg.appendChild(h)}y>=this.offsetX?h.setAttribute("x",this.styles.left+this.offsetX):h.setAttribute("x",this.styles.left+y),h.setAttribute("width",Math.abs(y-this.offsetX)),h.setAttribute("aria-label","sprite time")}}}return this}},{key:"drag",value:function(t){var e=null,r="",n="",i="";switch(/iPhone|iPad|iPod|Android/.test(navigator.userAgent)?(r="touchstart",n="touchmove",i="touchend"):(r="mousedown",n="mousemove",i="mouseup"),this.graphics){case s.CANVAS:e=this.canvas;break;case s.SVG:e=this.svg;break;default:return this}return this.callback="[object Function]"===Object.prototype.toString.call(t)?t:function(){},e.removeEventListener(r,this.onStart,!0),e.removeEventListener(n,this.onMove,!0),window.removeEventListener(i,this.onEnd,!0),e.addEventListener(r,this.onStart,!0),e.addEventListener(n,this.onMove,!0),window.addEventListener(i,this.onEnd,!0),this}},{key:"draw",value:function(t,e,r){var n=0,i=0;switch(this.graphics){case s.CANVAS:n=this.canvas.offsetLeft,i=this.canvas.width;break;case s.SVG:n=this.svg.parentNode.offsetLeft,i=parseInt(this.svg.getAttribute("width"),10)}var o=r-(n+this.styles.left);this.canvas.parentNode instanceof Element&&(o+=this.canvas.parentNode.scrollLeft),o<0&&(o=0),o>(i-=this.styles.left+this.styles.right)&&(o=i);var a=o/i*this.length/this.sampleRate;return"mousedown"!==e&&"touchstart"!==e||(this.offsetX=o,this.startTime=a,this.endTime=0),"mouseup"!==e&&"touchend"!==e||(this.endTime=a),this.update(a),this.startTime<=a?this.callback(t,this.startTime,a,this.mode,!0):this.startTime>a&&this.callback(t,a,this.startTime,this.mode,!1),this}},{key:"onStart",value:function(t){this.draw(t,t.type,this.getOffsetX(t)),this.isDown=!0}},{key:"onMove",value:function(t){this.isDown&&(t.preventDefault(),this.draw(t,t.type,this.getOffsetX(t)))}},{key:"onEnd",value:function(t){this.isDown&&(this.draw(t,t.type,this.getOffsetX(t)),this.isDown=!1)}},{key:"getOffsetX",value:function(t){return t.pageX?t.pageX:t.touches[0]?t.touches[0].pageX:this}},{key:"toString",value:function(){return"[SoundModule Analyser TimeOverview]"}}],r&&c(e.prototype,r),a}(s);function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function b(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function g(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function w(t,e,r){return w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=A(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},w(t,e,r||t)}function S(t,e){return S=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},S(t,e)}function O(t,e){if(e&&("object"===d(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function A(t){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},A(t)}function k(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}y(v,"SVG_CURRENT_TIME_CLASS_NAME","xsound-svg-current-time"),y(v,"SVG_SPRITE_CLASS_NAME","xsound-svg-sprite"),y(v,"DRAG_MODE_UPDATE","update"),y(v,"DRAG_MODE_SPRITE","sprite");var T=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&S(t,e)}(a,t);var e,r,n,i,o=(n=a,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=A(n);if(i){var r=A(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return O(this,t)});function a(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(e=o.call(this,t)).type=a.UINT,e.textInterval=.005,e}return e=a,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=w(A(a.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;var o=null;switch(n){case"type":if(void 0===e)return this.type;(o=String(e).toLowerCase())!==a.UINT&&o!==a.FLOAT||(this.type=o);break;case"textinterval":if(void 0===e)return this.textInterval;(o=parseFloat(e))>0&&(this.textInterval=o)}}return this}},{key:"drawOnCanvas",value:function(t){if(!(this.canvas instanceof HTMLCanvasElement&&this.isActive))return this;var e=this.context,r=this.canvas,n=r.width,i=r.height,o=n-(this.styles.left+this.styles.right),s=i-(this.styles.top+this.styles.bottom),c=Math.floor(s/2)+this.styles.top,u=Math.floor(this.textInterval*this.sampleRate);switch(e.clearRect(0,0,n,i),this.type){case a.FLOAT:this.drawTimeDomainFloat32ArrayOnCanvas(e,t,o,s,c);break;case a.UINT:default:switch(this.styles.shape){case"line":e.strokeStyle=this.styles.wave,e.lineWidth=this.styles.width,e.lineCap=this.styles.cap,e.lineJoin=this.styles.join,e.beginPath();for(var l=0,f=t.length;l<f;l++){var h=l/f*o+this.styles.left,p=(1-t[l]/255)*s+this.styles.top;0===l?e.moveTo(h+this.styles.width/2,p):e.lineTo(h,p)}e.stroke();break;case"rect":"gradient"!==this.styles.wave&&(e.fillStyle=this.styles.wave);for(var y=0,v=t.length;y<v;y++){var d=y/v*o+this.styles.left,m=(.5-t[y]/255)*s;if("gradient"===this.styles.wave){var g,w=s/2+this.styles.top,S=e.createLinearGradient(0,w,0,w+m),O=b(this.styles.grad);try{for(O.s();!(g=O.n()).done;){var A=g.value;S.addColorStop(A.offset,A.color)}}catch(t){O.e(t)}finally{O.f()}e.fillStyle=S}e.fillRect(d,c,this.styles.width,m)}}}if("none"!==this.styles.grid||"none"!==this.styles.text){for(var k=0,T=t.length;k<T;k++)if(k%u==0){var E=Math.ceil(k/T*o)+this.styles.left,j="".concat(Math.ceil(k/this.sampleRate*1e3)," ms");"none"!==this.styles.grid&&(e.fillStyle=this.styles.grid,e.fillRect(E,this.styles.top,1,s)),"none"!==this.styles.text&&(e.fillStyle=this.styles.text,e.font=this.createFontString(),e.fillText(j,E-e.measureText(j).width/2,this.styles.top+s+parseInt(this.styles.font.size,10)))}for(var R=0,P=["-1.00","-0.50"," 0.00"," 0.50"," 1.00"];R<P.length;R++){var x=P[R],_=Math.floor(this.styles.left-e.measureText(x).width),M=Math.floor((1-parseFloat(x.trim()))*(s/2))+this.styles.top;"none"!==this.styles.grid&&(e.fillStyle=this.styles.grid,e.fillRect(this.styles.left,M,o,1)),"none"!==this.styles.text&&(e.fillStyle=this.styles.text,e.font=this.createFontString(),e.fillText(x,_,M-Math.floor(parseInt(this.styles.font.size,10)/4)))}}return this}},{key:"drawBySVG",value:function(t){if(!(this.svg instanceof SVGElement&&this.isActive))return this;var e=this.svg,r=parseInt(e.getAttribute("width"),10),n=parseInt(e.getAttribute("height"),10),i=r-(this.styles.left+this.styles.right),o=n-(this.styles.top+this.styles.bottom),c=Math.floor(o/2)+this.styles.top,u=Math.floor(this.textInterval*this.sampleRate);switch(e.innerHTML="",this.type){case a.FLOAT:e.appendChild(this.drawTimeDomainFloat32ArrayBySVG(t,i,o,c,null,s.SVG_LINEAR_GRADIENT_ID_TIME));break;case a.UINT:default:switch(this.styles.shape){case"line":for(var l=document.createElementNS(s.XMLNS,"path"),f="",h=0,p=t.length;h<p;h++){var y=h/p*i+this.styles.left,v=(1-t[h]/255)*o+this.styles.top;f+=0===h?"M".concat(y+this.styles.width/2," ").concat(v):" L".concat(y," ").concat(v)}l.setAttribute("d",f),l.setAttribute("stroke",this.styles.wave),l.setAttribute("fill","none"),l.setAttribute("stroke-width",this.styles.width),l.setAttribute("stroke-linecap",this.styles.cap),l.setAttribute("stroke-linejoin",this.styles.join),e.appendChild(l);break;case"rect":var d=null;"gradient"===this.styles.wave&&(d=this.createSVGLinearGradient(s.SVG_LINEAR_GRADIENT_ID_TIME));var b=document.createElementNS(s.XMLNS,"g");null!==d&&b.appendChild(d);for(var m=0,g=t.length;m<g;m++){var w=document.createElementNS(s.XMLNS,"rect"),S=m/g*i+this.styles.left,O=(t[m]/255-.5)*o;w.setAttribute("x",S),w.setAttribute("y",c),w.setAttribute("width",this.styles.width),O<0?w.setAttribute("height",-O):(w.setAttribute("height",O),w.setAttribute("transform","rotate(180 ".concat(S+this.styles.width/2," ").concat(c,")"))),w.setAttribute("stroke","none"),w.setAttribute("fill",null===d?this.styles.wave:"url(#".concat(s.SVG_LINEAR_GRADIENT_ID_TIME,")")),b.appendChild(w)}e.appendChild(b)}}if("none"!==this.styles.grid||"none"!==this.styles.text){for(var A=0,k=t.length;A<k;A++)if(A%u==0){var T=Math.ceil(A/k*i)+this.styles.left,E="".concat(Math.ceil(A/this.sampleRate*1e3)," ms");if("none"!==this.styles.grid){var j=document.createElementNS(s.XMLNS,"rect");j.setAttribute("x",T),j.setAttribute("y",this.styles.top),j.setAttribute("width",1),j.setAttribute("height",o),j.setAttribute("stroke","none"),j.setAttribute("fill",this.styles.grid),e.appendChild(j)}if("none"!==this.styles.text){var R=document.createElementNS(s.XMLNS,"text");R.textContent=E,R.setAttribute("x",T),R.setAttribute("y",this.styles.top+o+parseInt(this.styles.font.size,10)),R.setAttribute("text-anchor","middle"),R.setAttribute("stroke","none"),R.setAttribute("fill",this.styles.text),R.setAttribute("font-family",this.styles.font.family),R.setAttribute("font-size",this.styles.font.size),R.setAttribute("font-style",this.styles.font.style),R.setAttribute("font-weight",this.styles.font.weight),e.appendChild(R)}}for(var P=0,x=["-1.00","-0.50"," 0.00"," 0.50"," 1.00"];P<x.length;P++){var _=x[P],M=this.styles.left,C=Math.floor((1-parseFloat(_.trim()))*(o/2))+this.styles.top;if("none"!==this.styles.grid){var F=document.createElementNS(s.XMLNS,"rect");F.setAttribute("x",M),F.setAttribute("y",C),F.setAttribute("width",i),F.setAttribute("height",1),F.setAttribute("stroke","none"),F.setAttribute("fill",this.styles.grid),e.appendChild(F)}if("none"!==this.styles.text){var I=document.createElementNS(s.XMLNS,"text");I.textContent=_,I.setAttribute("x",M),I.setAttribute("y",C-Math.floor(parseInt(this.styles.font.size,10)/4)),I.setAttribute("text-anchor","end"),I.setAttribute("stroke","none"),I.setAttribute("fill",this.styles.text),I.setAttribute("font-family",this.styles.font.family),I.setAttribute("font-size",this.styles.font.size),I.setAttribute("font-style",this.styles.font.style),I.setAttribute("font-weight",this.styles.font.weight),e.appendChild(I)}}}return this}},{key:"toString",value:function(){return"[SoundModule Analyser Time]"}}],r&&g(e.prototype,r),a}(s);function E(t){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},E(t)}function j(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return R(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?R(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function R(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function P(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function x(t,e,r){return x="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=C(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},x(t,e,r||t)}function _(t,e){return _=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},_(t,e)}function M(t,e){if(e&&("object"===E(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function C(t){return C=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},C(t)}function F(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}k(T,"UINT","uint"),k(T,"FLOAT","float");var I=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_(t,e)}(a,t);var e,r,n,i,o=(n=a,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=C(n);if(i){var r=C(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return M(this,t)});function a(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(e=o.call(this,t)).type=a.UINT,e.size=256,e.textInterval=1e3,e}return e=a,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=x(C(a.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;var o=null,s=null;switch(n){case"type":if(void 0===e)return this.type;(o=String(e).toLowerCase())!==a.UINT&&o!==a.FLOAT||(this.type=o);break;case"size":if(void 0===e)return this.size;s=1024,(o=parseInt(e,10))>0&&o<=s&&(this.size=o);break;case"textinterval":if(void 0===e)return this.textInterval;(o=parseFloat(e))>0&&(this.textInterval=o)}}return this}},{key:"drawOnCanvas",value:function(t,e,r){if(!(this.canvas instanceof HTMLCanvasElement&&this.isActive))return this;var n=parseFloat(e),i=parseFloat(r),o=i-n,s=this.context,c=this.canvas,u=c.width,l=c.height,f=u-(this.styles.left+this.styles.right),h=l-(this.styles.top+this.styles.bottom),p=this.size>t.length?t.length:this.size,y=this.sampleRate/(2*t.length),v=Math.floor(this.textInterval/y);switch(s.clearRect(0,0,u,l),this.type){case a.FLOAT:s.strokeStyle="gradient"!==this.styles.wave?this.styles.wave:"rgba(0, 0, 255, 1.0)",s.lineWidth=this.styles.width,s.lineCap=this.styles.cap,s.lineJoin=this.styles.join,s.beginPath();for(var d=0;d<p;d++){var b=d/p*f+this.styles.left,m=Math.abs(t[d]-i)*(h/o)+this.styles.top;0===d?s.moveTo(b+this.styles.width/2,m):s.lineTo(b,m)}s.stroke();break;case a.UINT:default:switch(this.styles.shape){case"line":s.strokeStyle=this.styles.wave,s.lineWidth=this.styles.width,s.lineCap=this.styles.cap,s.lineJoin=this.styles.join,s.beginPath();for(var g=0;g<p;g++){var w=g/p*f+this.styles.left,S=(1-t[g]/255)*h+this.styles.top;0===g?s.moveTo(w+this.styles.width/2,S):s.lineTo(w,S)}s.stroke();break;case"rect":"gradient"!==this.styles.wave&&(s.fillStyle=this.styles.wave);for(var O=0;O<p;O++){var A=O/p*f+this.styles.left,k=t[O]/255*h*-1;if("gradient"===this.styles.wave){var T,E=h+this.styles.top,R=s.createLinearGradient(0,E,0,E+k),P=j(this.styles.grad);try{for(P.s();!(T=P.n()).done;){var x=T.value;R.addColorStop(x.offset,x.color)}}catch(t){P.e(t)}finally{P.f()}s.fillStyle=R}s.fillRect(A,h+this.styles.top,this.styles.width,k)}}}if("none"!==this.styles.grid||"none"!==this.styles.text){for(var _=0;_<p;_++)if(_%v==0){var M=Math.floor(_/p*f)+this.styles.left,C=Math.floor(this.textInterval*(_/v)),F=C<1e3?"".concat(C," Hz"):"".concat(String(C/1e3).slice(0,3)," kHz");"none"!==this.styles.grid&&(s.fillStyle=this.styles.grid,s.fillRect(M,this.styles.top,1,h)),"none"!==this.styles.text&&(s.fillStyle=this.styles.text,s.font=this.createFontString(),s.fillText(F,M-s.measureText(F).width/2,this.styles.top+h+parseInt(this.styles.font.size,10)))}switch(this.type){case a.FLOAT:for(var I=n;I<=i;I+=10){var N="".concat(I," dB"),L=Math.floor(this.styles.left-s.measureText(N).width),D=Math.floor(-1*(I-i)/o*h)+this.styles.top;"none"!==this.styles.grid&&(s.fillStyle=this.styles.grid,s.fillRect(this.styles.left,D,f,1)),"none"!==this.styles.text&&(s.fillStyle=this.styles.text,s.font=this.createFontString(),s.fillText(N,L,D-Math.floor(parseInt(this.styles.font.size,10)/4)))}break;case a.UINT:default:for(var B=0,U=["0.00","0.25","0.50","0.75","1.00"];B<U.length;B++){var q=U[B],V=Math.floor(this.styles.left-s.measureText(q).width),G=(1-parseFloat(q))*h+this.styles.top;"none"!==this.styles.grid&&(s.fillStyle=this.styles.grid,s.fillRect(this.styles.left,G,f,1)),"none"!==this.styles.text&&(s.fillStyle=this.styles.text,s.font=this.createFontString(),s.fillText(q,V,G-Math.floor(parseInt(this.styles.font.size,10)/4)))}}}return this}},{key:"drawBySVG",value:function(t,e,r){if(!(this.svg instanceof SVGElement&&this.isActive))return this;var n=parseFloat(e),i=parseFloat(r),o=i-n,c=this.svg,u=parseInt(c.getAttribute("width"),10),l=parseInt(c.getAttribute("height"),10),f=u-(this.styles.left+this.styles.right),h=l-(this.styles.top+this.styles.bottom),p=this.size>t.length?t.length:this.size,y=this.sampleRate/(2*t.length),v=Math.floor(this.textInterval/y);switch(c.innerHTML="",this.type){case a.FLOAT:for(var d=document.createElementNS(s.XMLNS,"path"),b="",m=0;m<p;m++){var g=Math.floor(m/p*f)+this.styles.left,w=Math.floor(-1*(t[m]-i)*(h/o))+this.styles.top;b+=0===m?"M".concat(g+this.styles.width/2," ").concat(w):" L".concat(g," ").concat(w)}d.setAttribute("d",b),d.setAttribute("stroke","gradient"!==this.styles.wave?this.styles.wave:"rgba(0, 0, 255, 1.0)"),d.setAttribute("fill","none"),d.setAttribute("stroke-width",this.styles.width),d.setAttribute("stroke-linecap",this.styles.cap),d.setAttribute("stroke-linejoin",this.styles.join),c.appendChild(d);break;case a.UINT:default:switch(this.styles.shape){case"line":for(var S=document.createElementNS(s.XMLNS,"path"),O="",A=0;A<p;A++){var k=Math.floor(A/p*f)+this.styles.left,T=Math.floor((1-t[A]/255)*h)+this.styles.top;O+=0===A?"M".concat(k+this.styles.width/2," ").concat(T):" L".concat(k," ").concat(T)}S.setAttribute("d",O),S.setAttribute("stroke",this.styles.wave),S.setAttribute("fill","none"),S.setAttribute("stroke-width",this.styles.width),S.setAttribute("stroke-linecap",this.styles.cap),S.setAttribute("stroke-linejoin",this.styles.join),c.appendChild(S);break;case"rect":var E=null;"gradient"===this.styles.wave&&(E=this.createSVGLinearGradient(s.SVG_LINEAR_GRADIENT_ID_FFT));var j=document.createElementNS(s.XMLNS,"g");null!==E&&j.appendChild(E);for(var R=0;R<p;R++){var P=document.createElementNS(s.XMLNS,"rect"),x=Math.floor(R/p*f)+this.styles.left,_=Math.floor(t[R]/255*h);P.setAttribute("x",x),P.setAttribute("y",this.styles.top+h),P.setAttribute("width",this.styles.width),_<0?P.setAttribute("height",-_):(P.setAttribute("height",_),P.setAttribute("transform","rotate(180 ".concat(x+this.styles.width/2," ").concat(this.styles.top+h,")"))),P.setAttribute("stroke","none"),P.setAttribute("fill",null===E?this.styles.wave:"url(#".concat(s.SVG_LINEAR_GRADIENT_ID_FFT,")")),j.appendChild(P)}c.appendChild(j)}}if("none"!==this.styles.grid||"none"!==this.styles.text){for(var M=0;M<p;M++)if(M%v==0){var C=Math.floor(M/p*f)+this.styles.left,F=Math.floor(this.textInterval*(M/v)),I=F<1e3?"".concat(F," Hz"):"".concat(String(F/1e3).slice(0,3)," kHz");if("none"!==this.styles.grid){var N=document.createElementNS(s.XMLNS,"rect");N.setAttribute("x",C),N.setAttribute("y",this.styles.top),N.setAttribute("width",1),N.setAttribute("height",h),N.setAttribute("stroke","none"),N.setAttribute("fill",this.styles.grid),c.appendChild(N)}if("none"!==this.styles.text){var L=document.createElementNS(s.XMLNS,"text");L.textContent=I,L.setAttribute("x",C),L.setAttribute("y",this.styles.top+h+parseInt(this.styles.font.size,10)),L.setAttribute("text-anchor","middle"),L.setAttribute("stroke","none"),L.setAttribute("fill",this.styles.text),L.setAttribute("font-family",this.styles.font.family),L.setAttribute("font-size",this.styles.font.size),L.setAttribute("font-style",this.styles.font.style),L.setAttribute("font-weight",this.styles.font.weight),c.appendChild(L)}}switch(this.type){case a.FLOAT:for(var D=n;D<=i;D+=10){var B="".concat(D,"dB"),U=this.styles.left,q=Math.floor(-1*(D-i)/o*h)+this.styles.top;if("none"!==this.styles.grid){var V=document.createElementNS(s.XMLNS,"rect");V.setAttribute("x",U),V.setAttribute("y",q),V.setAttribute("width",f),V.setAttribute("height",1),V.setAttribute("stroke","none"),V.setAttribute("fill",this.styles.grid),c.appendChild(V)}if("none"!==this.styles.text){var G=document.createElementNS(s.XMLNS,"text");G.textContent=B,G.setAttribute("x",U),G.setAttribute("y",q-Math.floor(parseInt(this.styles.font.size,10)/4)),G.setAttribute("text-anchor","end"),G.setAttribute("stroke","none"),G.setAttribute("fill",this.styles.text),G.setAttribute("font-family",this.styles.font.family),G.setAttribute("font-size",this.styles.font.size),G.setAttribute("font-style",this.styles.font.style),G.setAttribute("font-weight",this.styles.font.weight),c.appendChild(G)}}break;case a.UINT:default:for(var z=0,X=["0.00","0.25","0.50","0.75","1.00"];z<X.length;z++){var W=X[z],H=this.styles.left,Y=(1-parseFloat(W))*h+this.styles.top;if("none"!==this.styles.grid){var Q=document.createElementNS(s.XMLNS,"rect");Q.setAttribute("x",H),Q.setAttribute("y",Y),Q.setAttribute("width",f),Q.setAttribute("height",1),Q.setAttribute("stroke","none"),Q.setAttribute("fill",this.styles.grid),c.appendChild(Q)}if("none"!==this.styles.text){var Z=document.createElementNS(s.XMLNS,"text");Z.textContent=W,Z.setAttribute("x",H),Z.setAttribute("y",Y-Math.floor(parseInt(this.styles.font.size,10)/4)),Z.setAttribute("text-anchor","end"),Z.setAttribute("stroke","none"),Z.setAttribute("fill",this.styles.text),Z.setAttribute("font-family",this.styles.font.family),Z.setAttribute("font-size",this.styles.font.size),Z.setAttribute("font-style",this.styles.font.style),Z.setAttribute("font-weight",this.styles.font.weight),c.appendChild(Z)}}}}return this}},{key:"toString",value:function(){return"[SoundModule Analyser FFT]"}}],r&&P(e.prototype,r),a}(s);function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}function L(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function D(t,e){return D=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},D(t,e)}function B(t,e){if(e&&("object"===N(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function U(t){return U=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},U(t)}F(I,"UINT","uint"),F(I,"FLOAT","float");var q=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&D(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=U(n);if(i){var r=U(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return B(this,t)});function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=o.call(this)).analyser=t.createAnalyser(),e.input=t.createGain(),e.input.connect(e.analyser),e.timeOverviewL=new v(t.sampleRate),e.timeOverviewR=new v(t.sampleRate),e.time=new T(t.sampleRate),e.fft=new I(t.sampleRate),e.analyser.fftSize=2048,e.analyser.minDecibels=-100,e.analyser.maxDecibels=-30,e.analyser.smoothingTimeConstant=.8,e}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null;switch(n){case"fftsize":if(void 0===e)return this.analyser.fftSize;switch(i=parseInt(e,10)){case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:this.analyser.fftSize=i}break;case"frequencybincount":return this.analyser.frequencyBinCount;case"mindecibels":if(void 0===e)return this.analyser.minDecibels;(i=parseFloat(e))<(o=-30)&&(this.analyser.minDecibels=i);break;case"maxdecibels":if(void 0===e)return this.analyser.maxDecibels;(i=parseFloat(e))>-100&&(this.analyser.maxDecibels=i);break;case"smoothingtimeconstant":if(void 0===e)return this.analyser.smoothingTimeConstant;o=1,(i=parseFloat(e))>=0&&i<=o&&(this.analyser.smoothingTimeConstant=i)}}return this}},{key:"start",value:function(t,e,r){var n=this,i=String(t).replace(/-/g,"").toLowerCase(),o=parseInt(e,10),s=null;switch(i){case"timeoverview":switch(o){case 0:r instanceof AudioBuffer&&r.numberOfChannels>o&&((s=new Float32Array(r.length)).set(r.getChannelData(o)),this.timeOverviewL.start(s));break;case 1:r instanceof AudioBuffer&&r.numberOfChannels>o&&((s=new Float32Array(r.length)).set(r.getChannelData(o)),this.timeOverviewR.start(s))}break;case"timeoverviewl":r instanceof AudioBuffer&&r.numberOfChannels>0&&((s=new Float32Array(r.length)).set(r.getChannelData(0)),this.timeOverviewL.start(s));break;case"timeoverviewr":r instanceof AudioBuffer&&r.numberOfChannels>1&&((s=new Float32Array(r.length)).set(r.getChannelData(1)),this.timeOverviewR.start(s));break;case"time":"uint"===this.time.param("type")?(s=new Uint8Array(this.analyser.fftSize),this.analyser.getByteTimeDomainData(s),this.time.start(s)):(s=new Float32Array(this.analyser.fftSize),this.analyser.getFloatTimeDomainData(s),this.time.start(s)),"auto"===this.time.param("interval")?this.time.timerid=window.requestAnimationFrame((function(){n.start(t)})):this.time.timerid=window.setTimeout((function(){n.start(t)}),this.time.param("interval"));break;case"fft":"uint"===this.fft.param("type")?(s=new Uint8Array(this.analyser.frequencyBinCount),this.analyser.getByteFrequencyData(s),this.fft.start(s)):(s=new Float32Array(this.analyser.frequencyBinCount),this.analyser.getFloatFrequencyData(s),this.fft.start(s,this.analyser.minDecibels,this.analyser.maxDecibels)),"auto"===this.fft.param("interval")?this.fft.timerid=window.requestAnimationFrame((function(){n.start(t)})):this.fft.timerid=window.setTimeout((function(){n.start(t)}),this.fft.param("interval"))}return this}},{key:"stop",value:function(t){switch(String(t).replace(/-/g,"").toLowerCase()){case"timeoverviewl":case"timeoverviewr":break;case"time":"auto"===this.time.param("interval")?window.cancelAnimationFrame(this.time.timerid):window.clearTimeout(this.time.timerid),this.time.timerid=null;break;case"fft":"auto"===this.fft.param("interval")?window.cancelAnimationFrame(this.fft.timerid):window.clearTimeout(this.fft.timerid),this.fft.timerid=null}return this}},{key:"domain",value:function(t,e){var r=String(t).replace(/-/g,"").toLowerCase(),n=parseInt(e,10);switch(r){case"timeoverview":switch(n){case 0:return this.timeOverviewL;case 1:return this.timeOverviewR;default:return this}case"timeoverviewl":case"timeoverviewr":return this["timeOverview".concat(r.slice(-1).toUpperCase())];case"time":case"fft":return this[r];default:return this}}},{key:"get",value:function(){return this.analyser}},{key:"INPUT",get:function(){return this.input}},{key:"OUTPUT",get:function(){return this.input}},{key:"toString",value:function(){return"[SoundModule Analyser]"}}],r&&L(e.prototype,r),s}(e);function V(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var G=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.trackNumber=e>=0?e:0,this.dataBlocks=[]}var e,r;return e=t,(r=[{key:"get",value:function(){return this.dataBlocks}},{key:"append",value:function(t){t instanceof Float32Array&&this.dataBlocks.push(t)}},{key:"has",value:function(){return this.dataBlocks.length>0}},{key:"clear",value:function(){this.dataBlocks.length=0}}])&&V(e.prototype,r),t}();function z(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var X=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.channelNumber=e>=0?e:0,this.tracks=[],this.channelGain=1}var e,r;return e=t,(r=[{key:"get",value:function(t){var e=parseInt(t,10);return e>=0&&e<this.tracks.length?this.tracks[e]:this.tracks}},{key:"append",value:function(t){t instanceof G&&this.tracks.push(t)}},{key:"length",value:function(){return this.tracks.length}},{key:"gain",value:function(t){if(void 0===t)return this.channelGain;var e=parseFloat(t);e>=0&&e<=1&&(this.channelGain=e)}}])&&z(e.prototype,r),t}();function W(t){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},W(t)}function H(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Y(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Y(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Y(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Q(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Z(t,e){return Z=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Z(t,e)}function $(t,e){if(e&&("object"===W(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function J(t){return J=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},J(t)}var K=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Z(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=J(n);if(i){var r=J(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return $(this,t)});function s(t,e,r,n){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(i=o.call(this)).sampleRate=t.sampleRate,i.context=t,i.processor=t.createScriptProcessor(e,r,n),i.channels=[new X(0),new X(1)],i.activeTrack=-1,i.paused=!0,i}return e=s,r=[{key:"setup",value:function(t){var e=parseInt(t,10);if(e>0)for(var r=0;r<e;r++)this.channels[0].append(new G(r)),this.channels[1].append(new G(r));else this.channels[0].append(new G(0)),this.channels[1].append(new G(0));return this}},{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase();switch(n){case"0":case"left":if(void 0===e)return this.channels[0].gain();this.channels[0].gain(e);break;case"1":case"right":if(void 0===e)return this.channels[1].gain();this.channels[1].gain(e)}}return this}},{key:"ready",value:function(t){return this.hasTrack(t)?this.activeTrack=t:this.activeTrack=-1,this}},{key:"start",value:function(){var t=this;if(-1!==this.activeTrack&&this.paused){this.paused=!1;var e=this.channels[0].gain(),r=this.channels[1].gain(),n=this.channels[0].get(this.activeTrack),i=this.channels[1].get(this.activeTrack),o=this.processor.bufferSize;this.processor.onaudioprocess=function(s){if(-1!==t.activeTrack){for(var a=s.inputBuffer.getChannelData(0),c=s.inputBuffer.getChannelData(1),u=new Float32Array(o),l=new Float32Array(o),f=0;f<o;f++)u[f]=e*a[f],l[f]=r*c[f];n.append(u),i.append(l)}else t.processor.disconnect(0),t.processor.onaudioprocess=null}}return this}},{key:"stop",value:function(){return this.activeTrack=-1,this.paused=!0,this.processor.disconnect(0),this.processor.onaudioprocess=null,this}},{key:"hasChannel",value:function(t){var e=parseInt(t,10);return e>=0&&e<this.channels.length}},{key:"hasTrack",value:function(t){var e=parseInt(t,10);return e>=0&&this.channels.every((function(t){return e<t.length()}))}},{key:"has",value:function(t,e){if(!this.hasChannel(t))return this.channels.some((function(t){return t.get().some((function(t){return t.has()}))}));var r=parseInt(t,10),n=this.channels[r].get();return this.hasTrack(e)?n[parseInt(e,10)].has():n.some((function(t){return t.has()}))}},{key:"get",value:function(){return this.activeTrack}},{key:"flatTrack",value:function(t,e){if(!this.hasChannel(t)||!this.hasTrack(e))return null;for(var r=this.channels[t].get(e).get(),n=this.processor.bufferSize,i=new Float32Array(r.length*n),o=0,s=r.length;o<s;o++)for(var a=r[o],c=0;c<n;c++)i[o*n+c]=a[c];return i}},{key:"mixTrack",value:function(t){if(!this.hasChannel(t))return null;var e,r=this.channels[t].get(),n=this.processor.bufferSize,i=0,o=0,s=0,a=0,c=0,u=H(r);try{for(u.s();!(e=u.n()).done;){var l=e.value.get();c<l.length&&(c=l.length)}}catch(t){u.e(t)}finally{u.f()}for(var f=new Float32Array(c*n);;){for(var h=0,p=r.length;h<p;h++){var y=r[h].get()[s];y instanceof Float32Array&&(i+=y[a],o++)}if(o<=0)return f;f[s*n+a]=i/o,i=0,o=0,a<n-1?a++:(s++,a=0)}}},{key:"clear",value:function(t){-1!==this.activeTrack&&this.stop();var e=parseInt(t,10);if(-1===e){var r,n=H(this.channels);try{for(n.s();!(r=n.n()).done;){var i,o=H(r.value.get());try{for(o.s();!(i=o.n()).done;)i.value.clear()}catch(t){o.e(t)}finally{o.f()}}}catch(t){n.e(t)}finally{n.f()}}else if(this.hasTrack(e)){var s,a=H(this.channels);try{for(a.s();!(s=a.n()).done;)s.value.get(e).clear()}catch(t){a.e(t)}finally{a.f()}}return this}},{key:"create",value:function(t,e,r,n){-1!==this.activeTrack&&this.stop();var i=null,o=null;if(-1===t&&this.has())i=this.mixTrack(0),o=this.mixTrack(1);else{if(!this.has(0,t)||!this.has(1,t))return"";i=this.flatTrack(0,t),o=this.flatTrack(1,t)}var s=1===e?1:2,a=8===r?8:16,c=1===s?Math.min(i.length,o.length):2*Math.min(i.length,o.length),u=36+c*(a/8),l=8+c*(a/8)+28+8,f=this.sampleRate,h=f*s*(a/8),p=c*(a/8),y=null;switch(a){case 8:y=new Uint8Array(c);for(var v=0;v<c;v++){var d=0;(d=v%s==0?(i[Math.floor(v/s)]+1)/2*(Math.pow(2,8)-1):(o[Math.floor(v/s)]+1)/2*(Math.pow(2,8)-1))>Math.pow(2,8)-1&&(d=Math.pow(2,8)-1),d<Math.pow(2,0)-1&&(d=Math.pow(2,0)-1),y[v]=d}break;case 16:y=new Int16Array(c);for(var b=0;b<c;b++){var m=0;(m=b%s==0?i[Math.floor(b/s)]*Math.pow(2,15):o[Math.floor(b/s)]*Math.pow(2,15))>+Math.pow(2,15)-1&&(m=+Math.pow(2,15)-1),m<-Math.pow(2,15)-0&&(m=-Math.pow(2,15)-0),y[b]=m}}var g=new Uint8Array(44+p);g[0]=82,g[1]=73,g[2]=70,g[3]=70,g[4]=u>>0&255,g[5]=u>>8&255,g[6]=u>>16&255,g[7]=u>>24&255,g[8]=87,g[9]=65,g[10]=86,g[11]=69,g[12]=102,g[13]=109,g[14]=116,g[15]=32,g[16]=16,g[17]=0,g[18]=0,g[19]=0,g[20]=1,g[21]=0,g[22]=s,g[23]=0,g[24]=f>>0&255,g[25]=f>>8&255,g[26]=f>>16&255,g[27]=f>>24&255,g[28]=h>>0&255,g[29]=h>>8&255,g[30]=h>>16&255,g[31]=h>>24&255,g[32]=s*(a/8),g[33]=0,g[34]=a,g[35]=0,g[36]=100,g[37]=97,g[38]=116,g[39]=97,g[40]=p>>0&255,g[41]=p>>8&255,g[42]=p>>16&255,g[43]=p>>24&255;for(var w=0;w<c;w++)switch(a){case 8:g[l-p+w]=y[w];break;case 16:g[l-p+2*w+0]=y[w]>>0&255,g[l-p+2*w+1]=y[w]>>8&255}var S=String(n).toLowerCase();switch(S){case"base64":case"dataurl":var O=window.btoa(g.map((function(t){return String.fromCodePoint(t)})).join(""));return"base64"===S?O:"data:audio/wav;base64,".concat(O);default:var A=new Blob([g],{type:"audio/wav"});return"blob"===S?A:window.URL.createObjectURL(A)}}},{key:"INPUT",get:function(){return this.processor}},{key:"OUTPUT",get:function(){return this.processor}},{key:"toString",value:function(){return"[SoundModule Recorder]"}}],r&&Q(e.prototype,r),s}(e);function tt(t){return tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tt(t)}function et(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function rt(t,e){return rt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},rt(t,e)}function nt(t,e){if(e&&("object"===tt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function it(t){return it=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},it(t)}var ot,st,at=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&rt(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=it(n);if(i){var r=it(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return nt(this,t)});function s(t,e,r,n,i){var a;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(a=o.call(this)).isActive=!1,a.context=t,a.analyser=i,a.sender=t.createScriptProcessor(s.BUFFER_SIZE,r,n),a.receiver=t.createScriptProcessor(s.BUFFER_SIZE,r,n),a.websocket=null,a.paused=!0,a}return e=s,r=[{key:"setup",value:function(t,e,r,n,i,o,s){var a=this;if("[object Object]"===Object.prototype.toString.call(arguments[0])){var c=arguments[0];"tls"in c&&(t=c.tls),"host"in c&&(e=c.host),"port"in c&&(r=c.port),"path"in c&&(n=c.path),"open"in c&&(i=c.open),"close"in c&&(o=c.close),"error"in c&&(s=c.error)}var u=t?"wss://":"ws://";"/"!==n.charAt(0)&&(n="/".concat(n));var l=parseInt(r,10);return isNaN(l)||l<0||l>65535||(this.websocket=new WebSocket("".concat(u).concat(e,":").concat(l).concat(n)),this.websocket.binaryType="arraybuffer",this.websocket.onopen=function(t){"[object Function]"===Object.prototype.toString.call(i)&&i(t)},this.websocket.onclose=function(t){a.isActive=!1,a.paused=!0,a.connect(),"[object Function]"===Object.prototype.toString.call(o)&&o(t)},this.websocket.onerror=function(t){a.isActive=!1,a.paused=!0,a.connect(),"[object Function]"===Object.prototype.toString.call(s)&&s(t)},this.websocket.onmessage=function(t){if(!a.isActive)return a.analyser.stop("time"),void a.analyser.stop("fft");if(t.data instanceof ArrayBuffer){var e=t.data.byteLength/Float32Array.BYTES_PER_ELEMENT,r=Math.floor(e/2),n=r*Float32Array.BYTES_PER_ELEMENT,i=new Float32Array(t.data,0,r),o=new Float32Array(t.data,n,r);a.analyser.start("time"),a.analyser.start("fft"),a.receiver.onaudioprocess=function(t){var e=t.outputBuffer.getChannelData(0),r=t.outputBuffer.getChannelData(1);i instanceof Float32Array&&e.set(i),o instanceof Float32Array&&r.set(o),a.isActive&&null!==a.websocket||(a.analyser.stop("time"),a.analyser.stop("fft"))}}}),this}},{key:"connect",value:function(){return this.receiver.disconnect(0),this.sender.disconnect(0),this.receiver.onaudioprocess=null,this.sender.onaudioprocess=null,this.isActive?(this.receiver.connect(this.analyser.input),this.receiver.connect(this.context.destination)):this.paused=!0,this}},{key:"start",value:function(){var t=this;if(this.isActive&&this.isConnected()&&this.paused){this.paused=!1;var e=this.sender.bufferSize;this.sender.onaudioprocess=function(r){if(t.isActive&&t.isConnected()){for(var n=r.inputBuffer.getChannelData(0),i=r.inputBuffer.getChannelData(1),o=new Float32Array(2*e),s=parseInt(o.length/2,10),a=0;a<e;a++)o[a]=n[a],o[s+a]=i[a];0===t.websocket.bufferedAmount&&t.websocket.send(o)}}}return this}},{key:"close",value:function(){return this.websocket instanceof WebSocket&&(this.isActive=!1,this.paused=!0,this.connect(),this.websocket.close(),this.websocket=null),this}},{key:"isConnected",value:function(){return this.websocket instanceof WebSocket&&this.websocket.readyState===WebSocket.OPEN}},{key:"state",value:function(t,e,r){var n=this;if(void 0===t)return this.isActive;"[object Function]"===Object.prototype.toString.call(r)&&r();var i=window.setInterval((function(){n.websocket instanceof WebSocket&&0!==n.websocket.bufferedAmount||("toggle"===String(t).toLowerCase()?n.isActive=!n.isActive:n.isActive=Boolean(t),n.connect(),"[object Function]"===Object.prototype.toString.call(e)&&e(),window.clearInterval(i))}),10);return this}},{key:"get",value:function(){return this.websocket}},{key:"INPUT",get:function(){return this.sender}},{key:"OUTPUT",get:function(){return this.sender}},{key:"toString",value:function(){return"[SoundModule Session]"}}],r&&et(e.prototype,r),s}(e);function ct(t){return ct="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ct(t)}function ut(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function lt(t,e){return lt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},lt(t,e)}function ft(t,e){if(e&&("object"===ct(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function ht(t){return ht=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ht(t)}(st="BUFFER_SIZE")in(ot=at)?Object.defineProperty(ot,st,{value:2048,enumerable:!0,configurable:!0,writable:!0}):ot[st]=2048;var pt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&lt(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=ht(n);if(i){var r=ht(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return ft(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this)).isActive=!0,r.context=t,r.input=t.createGain(),r.output=t.createGain(),r.lfo=t.createOscillator(),r.depth=t.createGain(),r.rate=r.lfo.frequency,r.processor=t.createScriptProcessor(e,2,2),r.lfo.start=r.lfo.start||r.lfo.noteOn,r.lfo.stop=r.lfo.stop||r.lfo.noteOff,r.values={},r.isStop=!0,r}return e=s,(r=[{key:"param",value:function(){return this}},{key:"connect",value:function(){return this}},{key:"start",value:function(t){if(this.isActive&&this.isStop){var e=parseFloat(t);(isNaN(e)||e<this.context.currentTime)&&(e=this.context.currentTime),this.lfo.start(e),this.isStop=!1}return this}},{key:"stop",value:function(t,e){if(this.isActive&&!this.isStop){var r=parseFloat(t),n=parseFloat(e);(isNaN(r)||r<this.context.currentTime)&&(r=this.context.currentTime),(isNaN(n)||n<0)&&(n=0);var i=this.lfo.type,o=this.lfo.frequency.value;this.lfo.stop(r+n),this.lfo=this.context.createOscillator(),this.lfo.start=this.lfo.start||this.lfo.noteOn,this.lfo.stop=this.lfo.stop||this.lfo.noteOff,this.lfo.type=i,this.lfo.frequency.value=o,this.rate=this.lfo.frequency,this.isStop=!0}return this}},{key:"state",value:function(t){return void 0===t?this.isActive:("toggle"===String(t).toLowerCase()?this.isActive=!this.isActive:this.isActive=Boolean(t),this.connect(),this.start(this.context.currentTime),this)}},{key:"params",value:function(){return{}}},{key:"toJSON",value:function(){return JSON.stringify(this.params())}},{key:"INPUT",get:function(){return this.input}},{key:"OUTPUT",get:function(){return this.output}},{key:"toString",value:function(){return"[SoundModule Effector]"}}])&&ut(e.prototype,r),s}(e);function yt(t){return yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yt(t)}function vt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function dt(t,e,r){return dt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=gt(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},dt(t,e,r||t)}function bt(t,e){return bt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},bt(t,e)}function mt(t,e){if(e&&("object"===yt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function gt(t){return gt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},gt(t)}var wt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&bt(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=gt(n);if(i){var r=gt(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return mt(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).panner=t.createStereoPanner(),r.panner.pan.value=0,r.depth.gain.value=0,r.rate.value=0,r.state(!1),r.lfo.connect(r.depth),r.depth.connect(r.panner.pan),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"depth":if(void 0===e)return this.depth.gain.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.depth.gain.value=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.rate.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.panner.disconnect(0),this.isActive?(this.input.connect(this.panner),this.panner.connect(this.output)):this.input.connect(this.output),this}},{key:"stop",value:function(t,e){return dt(gt(s.prototype),"stop",this).call(this,t,e),this.isActive&&(this.lfo.connect(this.depth),this.depth.connect(this.panner.pan)),this}},{key:"params",value:function(){return{state:this.isActive,depth:this.depth.gain.value,rate:this.rate.value}}},{key:"toString",value:function(){return"[SoundModule Autopanner]"}}],r&&vt(e.prototype,r),s}(pt);function St(t){return St="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},St(t)}function Ot(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function At(t,e,r){return At="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Et(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},At(t,e,r||t)}function kt(t,e){return kt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},kt(t,e)}function Tt(t,e){if(e&&("object"===St(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Et(t){return Et=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Et(t)}var jt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&kt(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Et(n);if(i){var r=Et(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Tt(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).amplitudeL=t.createGain(),r.amplitudeR=t.createGain(),r.splitter=t.createChannelSplitter(2),r.merger=t.createChannelMerger(2),r.amplitudeL.gain.value=1,r.amplitudeR.gain.value=1,r.depth.gain.value=0,r.rate.value=0,r.state(!1),r.lfoSplitter=t.createChannelSplitter(2),r.lfo.connect(r.depth),r.depth.connect(r.processor),r.processor.connect(r.lfoSplitter),r.lfoSplitter.connect(r.amplitudeL.gain,0),r.lfoSplitter.connect(r.amplitudeR.gain,1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"depth":if(void 0===e)return this.depth.gain.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.depth.gain.value=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.rate.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.amplitudeL.disconnect(0),this.amplitudeR.disconnect(0),this.splitter.disconnect(0),this.splitter.disconnect(1),this.merger.disconnect(0),this.isActive?(this.input.connect(this.splitter),this.splitter.connect(this.amplitudeL,0,0),this.splitter.connect(this.amplitudeR,1,0),this.amplitudeL.connect(this.merger,0,0),this.amplitudeR.connect(this.merger,0,1),this.merger.connect(this.output)):this.input.connect(this.output),this}},{key:"start",value:function(t){var e=this;if(this.isActive&&this.isStop){var r=parseFloat(t);(isNaN(r)||r<this.context.currentTime)&&(r=this.context.currentTime),this.lfo.start(r),this.isStop=!1;var n=this.processor.bufferSize;this.processor.onaudioprocess=function(t){var r=t.inputBuffer.getChannelData(0),i=t.outputBuffer.getChannelData(0),o=t.outputBuffer.getChannelData(1);if(e.isActive&&0!==e.depth.gain.value&&0!==e.rate.value)for(var s=0;s<n;s++)i[s]=r[s],o[s]=-r[s];else for(var a=0;a<n;a++)i[a]=0,o[a]=0}}return this}},{key:"stop",value:function(t,e){return At(Et(s.prototype),"stop",this).call(this,t,e),this.isActive&&(this.processor.disconnect(0),this.processor.onaudioprocess=null,this.lfo.connect(this.depth),this.depth.connect(this.processor),this.processor.connect(this.lfoSplitter),this.lfoSplitter.connect(this.amplitudeL.gain,0),this.lfoSplitter.connect(this.amplitudeR.gain,1)),this}},{key:"params",value:function(){return{state:this.isActive,depth:this.depth.gain.value,rate:this.rate.value}}},{key:"toString",value:function(){return"[SoundModule AutopannerFallback]"}}],r&&Ot(e.prototype,r),s}(pt);function Rt(t){return Rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Rt(t)}function Pt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function xt(t,e,r){return xt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Ct(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},xt(t,e,r||t)}function _t(t,e){return _t=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},_t(t,e)}function Mt(t,e){if(e&&("object"===Rt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Ct(t){return Ct=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Ct(t)}var Ft=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_t(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Ct(n);if(i){var r=Ct(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Mt(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).delay=t.createDelay(),r.mix=t.createGain(),r.tone=t.createBiquadFilter(),r.feedback=t.createGain(),r.delay.delayTime.value=0,r.depth.gain.value=0,r.rate.value=0,r.mix.gain.value=0,r.tone.type="string"==typeof r.tone.type?"lowpass":r.tone.LOWPASS||0,r.tone.frequency.value=350,r.tone.Q.value=Math.SQRT1_2,r.tone.gain.value=0,r.feedback.gain.value=0,r.depthRate=0,r.state(!1),r.lfo.connect(r.depth),r.depth.connect(r.delay.delayTime),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"delaytime":case"time":if(void 0===e)return this.delay.delayTime.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.delay.delayTime.value=i,this.depth.gain.value=this.delay.delayTime.value*this.depthRate);break;case"depth":if(void 0===e)return this.depthRate;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.depth.gain.value=this.delay.delayTime.value*i,this.depthRate=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.rate.value=i);break;case"mix":case"feedback":if(void 0===e)return this[n].gain.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this[n].gain.value=i);break;case"tone":if(void 0===e)return this.tone.frequency.value;i=parseFloat(e),o=10,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.tone.frequency.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.delay.disconnect(0),this.mix.disconnect(0),this.tone.disconnect(0),this.feedback.disconnect(0),this.input.connect(this.output),this.isActive&&(this.input.connect(this.tone),this.tone.connect(this.delay),this.delay.connect(this.mix),this.mix.connect(this.output),this.delay.connect(this.feedback),this.feedback.connect(this.delay)),this}},{key:"stop",value:function(t,e){return xt(Ct(s.prototype),"stop",this).call(this,t,e),this.isActive&&(this.lfo.connect(this.depth),this.depth.connect(this.delay.delayTime)),this}},{key:"params",value:function(){return{state:this.isActive,time:this.delay.delayTime.value,depth:this.depthRate,rate:this.rate.value,mix:this.mix.gain.value,tone:this.tone.frequency.value,feedback:this.feedback.gain.value}}},{key:"toString",value:function(){return"[SoundModule Chorus]"}}],r&&Pt(e.prototype,r),s}(pt);function It(t){return It="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},It(t)}function Nt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Lt(t,e){return Lt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Lt(t,e)}function Dt(t,e){if(e&&("object"===It(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Bt(t){return Bt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Bt(t)}var Ut=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Lt(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Bt(n);if(i){var r=Bt(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Dt(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).compressor=t.createDynamicsCompressor(),r.compressor.threshold.value=-24,r.compressor.knee.value=30,r.compressor.ratio.value=12,r.compressor.attack.value=.003,r.compressor.release.value=.25,r.state(!0),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase();if(n in this.compressor){if(void 0===e)return this.compressor[n].value;var i=parseFloat(e),o={threshold:-100,knee:0,ratio:1,attack:0,release:0},s={threshold:0,knee:40,ratio:20,attack:1,release:1},a=o[n],c=s[n];i>=a&&i<=c&&(this.compressor[n].value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.compressor.disconnect(0),this.isActive?(this.input.connect(this.compressor),this.compressor.connect(this.output)):this.input.connect(this.output),this}},{key:"params",value:function(){return{state:this.isActive,threshold:this.compressor.threshold.value,knee:this.compressor.knee.value,ratio:this.compressor.ratio.value,attack:this.compressor.attack.value,release:this.compressor.release.value}}},{key:"toString",value:function(){return"[SoundModule Compressor]"}}],r&&Nt(e.prototype,r),s}(pt);function qt(t){return qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qt(t)}function Vt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Gt(t,e){return Gt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Gt(t,e)}function zt(t,e){if(e&&("object"===qt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Xt(t){return Xt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Xt(t)}var Wt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Gt(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Xt(n);if(i){var r=Xt(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return zt(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).delay=t.createDelay(s.MAX_DELAY_TIME),r.dry=t.createGain(),r.wet=t.createGain(),r.tone=t.createBiquadFilter(),r.feedback=t.createGain(),r.delay.delayTime.value=0,r.dry.gain.value=1,r.wet.gain.value=0,r.tone.type="string"==typeof r.tone.type?"lowpass":r.tone.LOWPASS||0,r.tone.frequency.value=350,r.tone.Q.value=Math.SQRT1_2,r.tone.gain.value=0,r.feedback.gain.value=0,r.state(!1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,a=null;switch(n){case"delaytime":case"time":if(void 0===e)return this.delay.delayTime.value;i=parseFloat(e),o=0,a=s.MAX_DELAY_TIME,i>=o&&i<=a&&(this.delay.delayTime.value=i);break;case"dry":case"wet":case"feedback":if(void 0===e)return this[n].gain.value;a=1,(i=parseFloat(e))>=(o=0)&&i<=a&&(this[n].gain.value=i);break;case"tone":if(void 0===e)return this.tone.frequency.value;i=parseFloat(e),o=10,a=this.context.sampleRate/2,i>=o&&i<=a&&(this.tone.frequency.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.delay.disconnect(0),this.dry.disconnect(0),this.wet.disconnect(0),this.tone.disconnect(0),this.feedback.disconnect(0),this.isActive?(this.input.connect(this.dry),this.dry.connect(this.output),this.input.connect(this.tone),this.tone.connect(this.delay),this.delay.connect(this.wet),this.wet.connect(this.output),this.delay.connect(this.feedback),this.feedback.connect(this.delay)):this.input.connect(this.output),this}},{key:"params",value:function(){return{state:this.isActive,time:this.delay.delayTime.value,dry:this.dry.gain.value,wet:this.wet.gain.value,tone:this.tone.frequency.value,feedback:this.feedback.gain.value}}},{key:"toString",value:function(){return"[SoundModule Delay]"}}],r&&Vt(e.prototype,r),s}(pt);function Ht(t){return Ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ht(t)}function Yt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Qt(t,e){return Qt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Qt(t,e)}function Zt(t,e){if(e&&("object"===Ht(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function $t(t){return $t=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},$t(t)}function Jt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:5,enumerable:!0,configurable:!0,writable:!0}):t[e]=5}(Wt,"MAX_DELAY_TIME");var Kt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Qt(t,e)}(a,t);var e,r,n,i,o,s=(i=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=$t(i);if(o){var r=$t(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Zt(this,t)});function a(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(r=s.call(this,t,e)).distortion=t.createWaveShaper(),r.drive=t.createGain(),r.color=t.createBiquadFilter(),r.tone=t.createBiquadFilter(),r.type=a.CLEAN,r.amount=.5,r.numberOfSamples=4096,r.drive.gain.value=1,r.color.type="string"==typeof r.color.type?"bandpass":r.color.BANDPASS||2,r.color.frequency.value=350,r.color.Q.value=Math.SQRT1_2,r.color.gain.value=0,r.tone.type="string"==typeof r.tone.type?"lowpass":r.tone.LOWPASS||0,r.tone.frequency.value=350,r.tone.Q.value=Math.SQRT1_2,r.tone.gain.value=0,r.state(!1),r}return e=a,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"curve":if(void 0===e)return this.distortion.curve;var c=null;switch(String(e).toLowerCase()){case a.CLEAN:this.type=a.CLEAN,c=a.createCurve(a.CLEAN,this.amount,this.numberOfSamples);break;case a.CRUNCH:this.type=a.CRUNCH,c=a.createCurve(a.CRUNCH,this.amount,this.numberOfSamples);break;case a.OVERDRIVE:this.type=a.OVERDRIVE,c=a.createCurve(a.OVERDRIVE,this.amount,this.numberOfSamples);break;case a.DISTORTION:this.type=a.DISTORTION,c=a.createCurve(a.DISTORTION,this.amount,this.numberOfSamples);break;case a.FUZZ:this.type=a.FUZZ,c=a.createCurve(a.FUZZ,this.amount,this.numberOfSamples);break;default:e instanceof Float32Array&&(c=e)}this.distortion.curve=c;break;case"amount":if(void 0===e)return this.amount;(i=parseFloat(e))>0&&i<1&&(this.amount=i,this.param("curve",this.type));break;case"samples":if(void 0===e)return this.numberOfSamples;(i=parseInt(e,10))>=0&&(this.numberOfSamples=i,this.param("curve",this.type));break;case"drive":if(void 0===e)return this.drive.gain.value;s=100,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.drive.gain.value=i);break;case"color":case"tone":if(void 0===e)return this[n].frequency.value;i=parseFloat(e),o=10,s=this.context.sampleRate/2,i>=o&&i<=s&&(this[n].frequency.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.color.disconnect(0),this.drive.disconnect(0),this.distortion.disconnect(0),this.tone.disconnect(0),this.isActive?(this.input.connect(this.color),this.color.connect(this.drive),this.drive.connect(this.distortion),this.distortion.connect(this.tone),this.tone.connect(this.output)):this.input.connect(this.output),this}},{key:"params",value:function(){return{state:this.isActive,curve:this.type,amount:this.amount,samples:this.numberOfSamples,drive:this.drive.gain.value,color:this.color.frequency.value,tone:this.tone.frequency.value}}},{key:"toString",value:function(){return"[SoundModule Distortion]"}}],n=[{key:"createCurve",value:function(t,e,r){if(e>0&&e<1){var n=new Float32Array(r),i=0,o=0,s=0,c=0,u=0;switch(t){case a.CRUNCH:s=1-e>.99?.99:1-e;for(var l=0;l<r;l++)i=2*l/r-1,(u=Math.abs(i))<s?o=u:u>s?o=s+(u-s)/(1+Math.pow((u-s)/(1-s),2)):u>1&&(o=u),n[l]=(0===i?1:Math.abs(i)/i)*o*(1/((s+1)/2));break;case a.OVERDRIVE:c=2*e/(1-e);for(var f=0;f<r;f++){var h=2*(f-0)/(r-0)-1;n[f]=(1+c)*h/(1+c*Math.abs(h))}break;case a.DISTORTION:s=1-e;for(var p=0;p<r;p++)o=(i=2*p/r-1)<0?-Math.pow(Math.abs(i),s+.04):Math.pow(i,s),n[p]=(Math.exp(2*o)-Math.exp(-2*o))/(Math.exp(2*o)+Math.exp(-2*o));break;case a.FUZZ:for(var y=0;y<r;y++)i=2*y/r-1,o=(.5*Math.pow(i+1.4,2)-1)*o>=0?5.8:1.2,n[y]=(Math.exp(o)-Math.exp(-o))/(Math.exp(o)+Math.exp(-o));break;case a.CLEAN:default:return null}return n}return null}}],r&&Yt(e.prototype,r),n&&Yt(e,n),a}(pt);function te(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return ee(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ee(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function ee(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function re(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}Jt(Kt,"CLEAN","clean"),Jt(Kt,"CRUNCH","crunch"),Jt(Kt,"OVERDRIVE","overdrive"),Jt(Kt,"DISTORTION","distortion"),Jt(Kt,"FUZZ","fuzz");var ne=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.context=e,this.generators=[],this.activeIndexes=[],this.activeCounter=0,this.attack=.01,this.decay=.3,this.sustain=.5,this.release=1}var e,r;return e=t,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null;switch(n){case"attack":case"sustain":if(void 0===e)return this[n];(i=parseFloat(e))>=0&&(this[n]=i);break;case"decay":case"release":if(void 0===e)return this[n];(i=parseFloat(e))>0&&(this[n]=i)}}return this}},{key:"ready",value:function(t,e,r){var n=parseInt(t,10)>=0?parseInt(t,10):0;return e instanceof AudioNode&&r instanceof AudioNode?(e.connect(this.generators[n]),this.generators[n].connect(r)):e instanceof AudioNode?e.connect(this.generators[n]):r instanceof AudioNode&&this.generators[n].connect(r),this.activeIndexes[n]=n,this.activeCounter++,this}},{key:"start",value:function(t){var e=parseFloat(t);(isNaN(e)||e<this.context.currentTime)&&(e=this.context.currentTime);var r,n=e,i=n+this.attack,o=this.decay,s=this.sustain,a=te(this.activeIndexes);try{for(a.s();!(r=a.n()).done;){var c=r.value;void 0!==c&&(this.generators[c].gain.cancelScheduledValues(n),this.generators[c].gain.setValueAtTime(0,n),this.generators[c].gain.linearRampToValueAtTime(1,i),this.generators[c].gain.setTargetAtTime(s,i,o))}}catch(t){a.e(t)}finally{a.f()}return this}},{key:"stop",value:function(t,e){var r=parseFloat(t)-this.release;(isNaN(r)||r<this.context.currentTime)&&(r=this.context.currentTime);var n,i=r,o=this.release,s=te(this.activeIndexes);try{for(s.s();!(n=s.n()).done;){var a=n.value;void 0!==a&&(this.generators[a].gain.cancelScheduledValues(i),e?this.generators[a].gain.setValueCurveAtTime(new Float32Array([1,.5,.25,0]),i,o):this.generators[a].gain.setTargetAtTime(0,i,o))}}catch(t){s.e(t)}finally{s.f()}return this}},{key:"getGenerator",value:function(t){var e=parseInt(t,10)>=0?parseInt(t,10):0;return this.generators[e]}},{key:"setGenerator",value:function(t){var e=parseInt(t,10)>=0?parseInt(t,10):0;return this.generators[e]=this.context.createGain(),this.generators[e].gain.setTargetAtTime=this.generators[e].gain.setTargetAtTime||this.generators[e].gain.setTargetValueAtTime,this}},{key:"isStop",value:function(){var e,r=0,n=te(this.activeIndexes);try{for(n.s();!(e=n.n()).done;){var i=e.value;if(void 0!==i){if(this.generators[i].gain.value>t.MIN_GAIN)return!1;if(++r===this.activeCounter)return!0}}}catch(t){n.e(t)}finally{n.f()}}},{key:"clear",value:function(t){this.activeIndexes.length=0,this.activeCounter=0;var e,r=te(this.generators);try{for(r.s();!(e=r.n()).done;){var n=e.value;n.gain.cancelScheduledValues(this.context.currentTime),n.gain.value=1,t&&n.disconnect(0)}}catch(t){r.e(t)}finally{r.f()}return this}},{key:"params",value:function(){return{attack:this.attack,decay:this.decay,sustain:this.sustain,release:this.release}}},{key:"toJSON",value:function(){return JSON.stringify(this.params())}},{key:"toString",value:function(){return"[SoundModule EnvelopeGenerator]"}}],r&&re(e.prototype,r),t}();function ie(t){return ie="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ie(t)}function oe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function se(t,e){return se=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},se(t,e)}function ae(t,e){if(e&&("object"===ie(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function ce(t){return ce=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ce(t)}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:.001,enumerable:!0,configurable:!0,writable:!0}):t[e]=.001}(ne,"MIN_GAIN");var ue=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&se(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=ce(n);if(i){var r=ce(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return ae(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).bass=t.createBiquadFilter(),r.middle=t.createBiquadFilter(),r.treble=t.createBiquadFilter(),r.presence=t.createBiquadFilter(),r.bass.type="string"==typeof r.bass.type?"lowshelf":r.bass.LOWSHELF||3,r.middle.type="string"==typeof r.middle.type?"peaking":r.middle.PEAKING||5,r.treble.type="string"==typeof r.treble.type?"peaking":r.treble.PEAKING||5,r.presence.type="string"==typeof r.presence.type?"highshelf":r.presence.HIGHSHELF||4,r.bass.frequency.value=500,r.middle.frequency.value=1e3,r.treble.frequency.value=2e3,r.presence.frequency.value=4e3,r.middle.Q.value=Math.SQRT1_2,r.treble.Q.value=Math.SQRT1_2,r.bass.gain.value=0,r.middle.gain.value=0,r.treble.gain.value=0,r.presence.gain.value=0,r.state(!1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null;switch(n){case"bass":case"middle":case"treble":case"presence":if(void 0===e)return this[n].gain.value;o=40,(i=parseFloat(e))>=-40&&i<=o&&(this[n].gain.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.bass.disconnect(0),this.middle.disconnect(0),this.treble.disconnect(0),this.presence.disconnect(0),this.isActive?(this.input.connect(this.bass),this.bass.connect(this.middle),this.middle.connect(this.treble),this.treble.connect(this.presence),this.presence.connect(this.output)):this.input.connect(this.output),this}},{key:"params",value:function(){return{state:this.isActive,bass:this.bass.gain.value,middle:this.middle.gain.value,treble:this.treble.gain.value,presence:this.presence.gain.value}}},{key:"toString",value:function(){return"[SoundModule Equalizer]"}}],r&&oe(e.prototype,r),s}(pt);function le(t){return le="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},le(t)}function fe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function he(t,e){return he=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},he(t,e)}function pe(t,e){if(e&&("object"===le(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function ye(t){return ye=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ye(t)}var ve=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&he(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=ye(n);if(i){var r=ye(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return pe(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).filter=t.createBiquadFilter(),r.filter.frequency.setTargetAtTime=r.filter.frequency.setTargetAtTime||r.filter.frequency.setTargetValueAtTime,r.filter.type="string"==typeof r.filter.type?"lowpass":r.filter.LOWPASS||0,r.filter.frequency.value=350,r.filter.Q.value=1,r.filter.gain.value=0,r.maxFrequency=r.filter.frequency.value,r.range=.1,r.attack=.01,r.decay=.3,r.sustain=1,r.release=1,r.state(!1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,a=null;switch(n){case"type":if(void 0===e)return this.filter.type;(i=String(e).toLowerCase())in s.FILTER_TYPES&&(this.filter.type="string"==typeof this.filter.type?i:s.FILTER_TYPES[i]);break;case"frequency":case"cutoff":if(void 0===e)return this.filter.frequency.value;i=parseFloat(e),o=10,a=this.context.sampleRate/2,i>=o&&i<=a&&(this.maxFrequency=i,this.filter.frequency.value=i);break;case"gain":if(void 0===e)return this.filter.gain.value;a=40,(i=parseFloat(e))>=(o=-40)&&i<=a&&(this.filter.gain.value=i);break;case"q":if(void 0===e)return this.filter.Q.value;a=1e3,(i=parseFloat(e))>=(o=1e-4)&&i<=a&&(this.filter.Q.value=i);break;case"range":if(void 0===e)return this.range;a=1,(i=parseFloat(e))>=(o=0)&&i<=a&&(this.range=i);break;case"attack":case"sustain":if(void 0===e)return this[n];(i=parseFloat(e))>=0&&(this[n]=i);break;case"decay":case"release":if(void 0===e)return this[n];(i=parseFloat(e))>0&&(this[n]=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.filter.disconnect(0),this.isActive?(this.input.connect(this.filter),this.filter.connect(this.output)):this.input.connect(this.output),this}},{key:"start",value:function(t){if(this.isActive){var e=parseFloat(t);(isNaN(e)||e<this.context.currentTime)&&(e=this.context.currentTime);var r=e,n=r+this.attack,i=this.decay,o=this.sustain*this.maxFrequency,s=this.maxFrequency*this.range;this.filter.frequency.cancelScheduledValues(r),this.filter.frequency.setValueAtTime(s,r),this.filter.frequency.linearRampToValueAtTime(this.maxFrequency,n),this.filter.frequency.setTargetAtTime(o,n,i)}return this}},{key:"stop",value:function(t){if(this.isActive){var e=parseFloat(t)-this.release;(isNaN(e)||e<this.context.currentTime)&&(e=this.context.currentTime);var r=e,n=this.release,i=this.maxFrequency*this.range;this.filter.frequency.cancelScheduledValues(r),this.filter.frequency.setValueAtTime(this.filter.frequency.value,r),this.filter.frequency.setTargetAtTime(i,r,n)}return this}},{key:"state",value:function(t){return void 0===t?this.isActive:("toggle"===String(t).toLowerCase()?this.isActive=!this.isActive:this.isActive=Boolean(t),this.connect(),this)}},{key:"params",value:function(){return{state:this.isActive,type:this.filter.type,frequency:this.filter.frequency.value,Q:this.filter.Q.value,gain:this.filter.gain.value,range:this.range,attack:this.attack,decay:this.decay,sustain:this.sustain,release:this.release}}},{key:"toString",value:function(){return"[SoundModule Filter]"}}],r&&fe(e.prototype,r),s}(pt);function de(t){return de="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},de(t)}function be(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function me(t,e,r){return me="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Se(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},me(t,e,r||t)}function ge(t,e){return ge=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},ge(t,e)}function we(t,e){if(e&&("object"===de(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Se(t){return Se=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Se(t)}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(ve,"FILTER_TYPES",{lowpass:0,highpass:1,bandpass:2,lowshelf:3,highshelf:4,peaking:5,notch:6,allpass:7});var Oe=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ge(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Se(n);if(i){var r=Se(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return we(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).delay=t.createDelay(),r.mix=t.createGain(),r.tone=t.createBiquadFilter(),r.feedback=t.createGain(),r.delay.delayTime.value=0,r.depth.gain.value=0,r.rate.value=0,r.mix.gain.value=0,r.tone.type="string"==typeof r.tone.type?"lowpass":r.tone.LOWPASS||0,r.tone.frequency.value=350,r.tone.Q.value=Math.SQRT1_2,r.tone.gain.value=0,r.feedback.gain.value=0,r.depthRate=0,r.state(!1),r.lfo.connect(r.depth),r.depth.connect(r.delay.delayTime),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"delaytime":case"time":if(void 0===e)return this.delay.delayTime.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.delay.delayTime.value=i,this.depth.gain.value=this.delay.delayTime.value*this.depthRate);break;case"depth":if(void 0===e)return this.depthRate;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.depth.gain.value=this.delay.delayTime.value*i,this.depthRate=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.rate.value=i);break;case"mix":case"feedback":if(void 0===e)return this[n].gain.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this[n].gain.value=i);break;case"tone":if(void 0===e)return this.tone.frequency.value;i=parseFloat(e),o=10,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.tone.frequency.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.delay.disconnect(0),this.mix.disconnect(0),this.tone.disconnect(0),this.feedback.disconnect(0),this.input.connect(this.output),this.isActive&&(this.input.connect(this.tone),this.tone.connect(this.delay),this.delay.connect(this.mix),this.mix.connect(this.output),this.delay.connect(this.feedback),this.feedback.connect(this.delay)),this}},{key:"stop",value:function(t,e){return me(Se(s.prototype),"stop",this).call(this,t,e),this.isActive&&(this.lfo.connect(this.depth),this.depth.connect(this.delay.delayTime)),this}},{key:"params",value:function(){return{state:this.isActive,time:this.delay.delayTime.value,depth:this.depthRate,rate:this.rate.value,mix:this.mix.gain.value,tone:this.tone.frequency.value,feedback:this.feedback.gain.value}}},{key:"toString",value:function(){return"[SoundModule Flanger]"}}],r&&be(e.prototype,r),s}(pt);function Ae(t){return Ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ae(t)}function ke(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Te(t,e){return Te=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Te(t,e)}function Ee(t,e){if(e&&("object"===Ae(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function je(t){return je=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},je(t)}var Re=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Te(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=je(n);if(i){var r=je(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Ee(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).listener=t.listener,r.positions={x:0,y:0,z:0},r.forwards={x:0,y:0,z:-1},r.ups={x:0,y:1,z:0},r.listener.positionX instanceof AudioParam&&r.listener.positionY instanceof AudioParam&&r.listener.positionZ instanceof AudioParam?(r.listener.positionX.setValueAtTime(r.positions.x,t.currentTime),r.listener.positionY.setValueAtTime(r.positions.y,t.currentTime),r.listener.positionZ.setValueAtTime(r.positions.z,t.currentTime)):r.listener.setPosition(r.positions.x,r.positions.y,r.positions.z),r.listener.forwardX instanceof AudioParam&&r.listener.forwardY instanceof AudioParam&&r.listener.forwardZ instanceof AudioParam&&r.listener.upX instanceof AudioParam&&r.listener.upY instanceof AudioParam&&r.listener.upZ instanceof AudioParam?(r.listener.forwardX.setValueAtTime(r.forwards.x,t.currentTime),r.listener.forwardY.setValueAtTime(r.forwards.y,t.currentTime),r.listener.forwardZ.setValueAtTime(r.forwards.z,t.currentTime),r.listener.upX.setValueAtTime(r.ups.x,t.currentTime),r.listener.upY.setValueAtTime(r.ups.y,t.currentTime),r.listener.upZ.setValueAtTime(r.ups.z,t.currentTime)):r.listener.setOrientation(r.forwards.x,r.forwards.y,r.forwards.z,r.ups.x,r.ups.y,r.ups.z),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null;switch(n){case"x":case"y":case"z":if(void 0===e)return this.positions[n];i=parseFloat(e),isNaN(i)||(this.positions[n]=i,this.listener.positionX instanceof AudioParam&&this.listener.positionY instanceof AudioParam&&this.listener.positionZ instanceof AudioParam?(this.listener.positionX.setValueAtTime(this.positions.x,this.context.currentTime),this.listener.positionY.setValueAtTime(this.positions.y,this.context.currentTime),this.listener.positionZ.setValueAtTime(this.positions.z,this.context.currentTime)):this.listener.setPosition(this.positions.x,this.positions.y,this.positions.z));break;case"fx":case"fy":case"fz":if(void 0===e)return this.forwards[n.charAt(1)];i=parseFloat(e),isNaN(i)||(this.forwards[n.charAt(1)]=i,this.listener.forwardX instanceof AudioParam&&this.listener.forwardY instanceof AudioParam&&this.listener.forwardZ instanceof AudioParam&&this.listener.upX instanceof AudioParam&&this.listener.upY instanceof AudioParam&&this.listener.upZ instanceof AudioParam?(this.listener.forwardX.setValueAtTime(this.forwards.x,this.context.currentTime),this.listener.forwardY.setValueAtTime(this.forwards.y,this.context.currentTime),this.listener.forwardZ.setValueAtTime(this.forwards.z,this.context.currentTime),this.listener.upX.setValueAtTime(this.ups.x,this.context.currentTime),this.listener.upY.setValueAtTime(this.ups.y,this.context.currentTime),this.listener.upZ.setValueAtTime(this.ups.z,this.context.currentTime)):this.listener.setOrientation(this.forwards.x,this.forwards.y,this.forwards.z,this.ups.x,this.ups.y,this.ups.z));break;case"ux":case"uy":case"uz":if(void 0===e)return this.ups[n.charAt(1)];i=parseFloat(e),isNaN(i)||(this.ups[n.charAt(1)]=i,this.listener.forwardX instanceof AudioParam&&this.listener.forwardY instanceof AudioParam&&this.listener.forwardZ instanceof AudioParam&&this.listener.upX instanceof AudioParam&&this.listener.upY instanceof AudioParam&&this.listener.upZ instanceof AudioParam?(this.listener.forwardX.setValueAtTime(this.forwards.x,this.context.currentTime),this.listener.forwardY.setValueAtTime(this.forwards.y,this.context.currentTime),this.listener.forwardZ.setValueAtTime(this.forwards.z,this.context.currentTime),this.listener.upX.setValueAtTime(this.ups.x,this.context.currentTime),this.listener.upY.setValueAtTime(this.ups.y,this.context.currentTime),this.listener.upZ.setValueAtTime(this.ups.z,this.context.currentTime)):this.listener.setOrientation(this.forwards.x,this.forwards.y,this.forwards.z,this.ups.x,this.ups.y,this.ups.z))}}return this}},{key:"params",value:function(){return{state:this.isActive,positions:this.positions,forwards:this.forwards,ups:this.ups}}},{key:"toJSON",value:function(){return JSON.stringify(this.params())}},{key:"toString",value:function(){return"[SoundModule Listener]"}}],r&&ke(e.prototype,r),s}(pt);function Pe(t){return Pe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pe(t)}function xe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _e(t,e){return _e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},_e(t,e)}function Me(t,e){if(e&&("object"===Pe(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Ce(t){return Ce=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Ce(t)}function Fe(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ie=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_e(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Ce(n);if(i){var r=Ce(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Me(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).panner=t.createPanner(),r.positions={x:0,y:0,z:0},r.orientations={x:1,y:0,z:0},r.panner.refDistance=1,r.panner.maxDistance=1e4,r.panner.rolloffFactor=1,r.panner.coneInnerAngle=360,r.panner.coneOuterAngle=360,r.panner.coneOuterGain=0,r.panner.panningModel="string"==typeof r.panner.panningModel?"HRTF":r.panner.HRTF||1,r.panner.distanceModel="string"==typeof r.panner.distanceModel?"inverse":r.panner.INVERSE_DISTANCE||1,r.panner.positionX instanceof AudioParam&&r.panner.positionY instanceof AudioParam&&r.panner.positionZ instanceof AudioParam?(r.panner.positionX.setValueAtTime(r.positions.x,t.currentTime),r.panner.positionY.setValueAtTime(r.positions.y,t.currentTime),r.panner.positionZ.setValueAtTime(r.positions.z,t.currentTime)):r.panner.setPosition(r.positions.x,r.positions.y,r.positions.z),r.panner.orientationX instanceof AudioParam&&r.panner.orientationY instanceof AudioParam&&r.panner.orientationZ instanceof AudioParam?(r.panner.orientationX.setValueAtTime(r.orientations.x,t.currentTime),r.panner.orientationY.setValueAtTime(r.orientations.y,t.currentTime),r.panner.orientationZ.setValueAtTime(r.orientations.z,t.currentTime)):r.panner.setOrientation(r.orientations.x,r.orientations.y,r.orientations.z),r.state(!1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null;switch(n){case"x":case"y":case"z":if(void 0===e)return this.positions[n];i=parseFloat(e),isNaN(i)||(this.positions[n]=i,this.panner.positionX instanceof AudioParam&&this.panner.positionY instanceof AudioParam&&this.panner.positionZ instanceof AudioParam?(this.panner.positionX.setValueAtTime(this.positions.x,this.context.currentTime),this.panner.positionY.setValueAtTime(this.positions.y,this.context.currentTime),this.panner.positionZ.setValueAtTime(this.positions.z,this.context.currentTime)):this.panner.setPosition(this.positions.x,this.positions.y,this.positions.z));break;case"ox":case"oy":case"oz":if(void 0===e)return this.orientations[n.charAt(1)];i=parseFloat(e),isNaN(i)||(this.orientations[n.charAt(1)]=i,this.panner.orientationX instanceof AudioParam&&this.panner.orientationY instanceof AudioParam&&this.panner.orientationZ instanceof AudioParam?(this.panner.orientationX.setValueAtTime(this.orientations.x,this.context.currentTime),this.panner.orientationY.setValueAtTime(this.orientations.y,this.context.currentTime),this.panner.orientationZ.setValueAtTime(this.orientations.z,this.context.currentTime)):this.panner.setOrientation(this.orientations.x,this.orientations.y,this.orientations.z));break;case"refdistance":if(void 0===e)return this.panner.refDistance;(i=parseFloat(e))>=0&&(this.panner.refDistance=i);break;case"maxdistance":if(void 0===e)return this.panner.maxDistance;(i=parseFloat(e))>0&&(this.panner.maxDistance=i);break;case"rollofffactor":if(void 0===e)return this.panner.rolloffFactor;(i=parseFloat(e))>=0&&(this.panner.rolloffFactor=i);break;case"coneinnerangle":if(void 0===e)return this.panner.coneInnerAngle;(i=parseFloat(e))>=0&&i<=360&&(this.panner.coneInnerAngle=i);break;case"coneouterangle":if(void 0===e)return this.panner.coneOuterAngle;(i=parseFloat(e))>=0&&i<=360&&(this.panner.coneOuterAngle=i);break;case"coneoutergain":if(i>=0&&i<=1)return this.panner.coneOuterGain;i=parseFloat(e),isNaN(i)||(this.panner.coneOuterGain=i);break;case"panningmodel":if(void 0===e)return this.panner.panningModel;(i=/HRTF/i.test(e)?String(e).toUpperCase():String(e).toLowerCase())in s.PANNING_MODELS&&(this.panner.panningModel="string"==typeof this.panner.panningModel?i:s.PANNING_MODELS[i]);break;case"distancemodel":if(void 0===e)return this.panner.distanceModel;(i=String(e).replace(/-/g,"").toLowerCase())in s.DISTANCE_MODELS&&(this.panner.distanceModel="string"==typeof this.panner.distanceModel?i:s.DISTANCE_MODELS[i])}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.panner.disconnect(0),this.isActive?(this.input.connect(this.panner),this.panner.connect(this.output)):this.input.connect(this.output),this}},{key:"params",value:function(){return{state:this.isActive,positions:this.positions,orientations:this.orientations,refDistance:this.panner.refDistance,maxDistance:this.panner.maxDistance,rolloffFactor:this.panner.rolloffFactor,coneInnerAngle:this.panner.coneInnerAngle,coneOuterAngle:this.panner.coneOuterAngle,coneOuterGain:this.panner.coneOuterGain,panningModel:this.panner.panningModel,distanceModel:this.panner.distanceModel}}},{key:"toString",value:function(){return"[SoundModule Panner]"}}],r&&xe(e.prototype,r),s}(pt);function Ne(t){return Ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ne(t)}function Le(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function De(t,e,r){return De="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=qe(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},De(t,e,r||t)}function Be(t,e){return Be=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Be(t,e)}function Ue(t,e){if(e&&("object"===Ne(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function qe(t){return qe=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},qe(t)}Fe(Ie,"PANNING_MODELS",{equalpower:0,HRTF:1}),Fe(Ie,"DISTANCE_MODELS",{linear:0,inverse:1,exponential:2});var Ve=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Be(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=qe(n);if(i){var r=qe(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Ue(this,t)});function s(t,e){var r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).numberOfStages=12,r.filters=new Array(s.MAXIMUM_STAGES);for(var n=0;n<s.MAXIMUM_STAGES;n++)r.filters[n]=t.createBiquadFilter(),r.filters[n].type="string"==typeof r.filters[n].type?"allpass":r.filters[n].ALLPASS||7,r.filters[n].frequency.value=350,r.filters[n].Q.value=1,r.filters[n].gain.value=0;r.mix=t.createGain(),r.feedback=t.createGain(),r.depth.gain.value=0,r.rate.value=0,r.mix.gain.value=0,r.feedback.gain.value=0,r.depthRate=0,r.state(!1),r.lfo.connect(r.depth);for(var i=0;i<s.MAXIMUM_STAGES;i++)r.depth.connect(r.filters[i].frequency);return r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,a=null;switch(n){case"stage":if(void 0===e)return this.numberOfStages;switch(i=parseInt(e,10)){case 0:case 2:case 4:case 8:case 12:case 24:this.numberOfStages=i,this.connect()}break;case"frequency":case"cutoff":if(void 0===e)return this.filters[0].frequency.value;if(i=parseFloat(e),o=10,a=this.context.sampleRate/2,i>=o&&i<=a){for(var c=0;c<s.MAXIMUM_STAGES;c++)this.filters[c].frequency.value=i;this.depth.gain.value=this.filters[0].frequency.value*this.depthRate}break;case"resonance":if(void 0===e)return this.filters[0].Q.value;if(a=1e3,(i=parseFloat(e))>=(o=1e-4)&&i<=a)for(var u=0;u<s.MAXIMUM_STAGES;u++)this.filters[0].Q.value=i;break;case"depth":if(void 0===e)return this.depthRate;a=1,(i=parseFloat(e))>=(o=0)&&i<=a&&(this.depth.gain.value=this.filters[0].frequency.value*i,this.depthRate=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,a=this.context.sampleRate/2,i>=o&&i<=a&&(this.rate.value=i);break;case"mix":case"feedback":if(void 0===e)return this[n].gain.value;a=1,(i=parseFloat(e))>=(o=0)&&i<=a&&(this[n].gain.value=i)}}return this}},{key:"connect",value:function(){this.input.disconnect(0);for(var t=0;t<s.MAXIMUM_STAGES;t++)this.filters[t].disconnect(0);if(this.mix.disconnect(0),this.feedback.disconnect(0),this.input.connect(this.output),this.isActive&&this.numberOfStages>0){this.input.connect(this.filters[0]);for(var e=0;e<this.numberOfStages;e++)e<this.numberOfStages-1?this.filters[e].connect(this.filters[e+1]):(this.filters[e].connect(this.mix),this.mix.connect(this.output),this.filters[e].connect(this.feedback),this.feedback.connect(this.filters[0]))}return this}},{key:"stop",value:function(t,e){if(De(qe(s.prototype),"stop",this).call(this,t,e),this.isActive){this.lfo.connect(this.depth);for(var r=0;r<s.MAXIMUM_STAGES;r++)this.depth.connect(this.filters[r].frequency)}return this}},{key:"params",value:function(){return{state:this.isActive,stage:this.numberOfStages,frequency:this.filters[0].frequency.value,resonance:this.filters[0].Q.value,depth:this.depthRate,rate:this.rate.value,mix:this.mix.gain.value,feedback:this.feedback.gain.value}}},{key:"toString",value:function(){return"[SoundModule Phaser]"}}],r&&Le(e.prototype,r),s}(pt);function Ge(t){return Ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ge(t)}function ze(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Xe(t,e){return Xe=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Xe(t,e)}function We(t,e){if(e&&("object"===Ge(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function He(t){return He=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},He(t)}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:24,enumerable:!0,configurable:!0,writable:!0}):t[e]=24}(Ve,"MAXIMUM_STAGES");var Ye=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Xe(t,e)}(a,t);var e,r,n,i,o,s=(i=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=He(i);if(o){var r=He(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return We(this,t)});function a(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(r=s.call(this,t,e)).pitch=1,r.state(!1),r.connect(),r}return e=a,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null;if("pitch"===n){if(void 0===e)return this.pitch;(i=parseFloat(e))>0&&(this.pitch=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.processor.disconnect(0),this.isActive?(this.input.connect(this.processor),this.processor.connect(this.output)):this.input.connect(this.output),this}},{key:"start",value:function(){var t=this;if(this.isActive&&this.isStop){this.isStop=!1;var e=this.processor.bufferSize;this.processor.onaudioprocess=function(r){var n=r.inputBuffer.getChannelData(0),i=r.inputBuffer.getChannelData(1),o=r.outputBuffer.getChannelData(0),s=r.outputBuffer.getChannelData(1);if(t.isActive&&1!==t.pitch){var c=new Float32Array(n),u=new Float32Array(i),l=new Float32Array(e),f=new Float32Array(e);a.FFT(c,l,e),a.FFT(u,f,e);for(var h=new Float32Array(e),p=new Float32Array(e),y=new Float32Array(e),v=new Float32Array(e),d=0;d<e;d++){var b=Math.floor(t.pitch*d),m=1;d>e/2&&(m=0),b>=0&&b<e&&(h[b]+=m*c[d],y[b]+=m*l[d],p[b]+=m*u[d],v[b]+=m*f[d])}a.IFFT(h,y,e),a.IFFT(p,v,e),o.set(h),s.set(p)}else o.set(n),s.set(i)}}return this}},{key:"stop",value:function(){return this.isActive&&(this.processor.disconnect(0),this.processor.onaudioprocess=null,this.connect()),this}},{key:"params",value:function(){return{state:this.isActive,pitch:this.pitch}}},{key:"toString",value:function(){return"[SoundModule PitchShifter]"}}],n=[{key:"FFT",value:function(t,e,r){for(var n=function(t){return Math.pow(2,t)},i=new Float32Array(r),o=Math.log2(r),s=1;s<=o;s++)for(var a=0;a<n(s-1);a++)for(var c=o-s,u=0;u<n(c);u++){var l=a*n(c+1)+u,f=n(c)+l,h=u*n(s-1),p=t[l],y=e[l],v=t[f],d=e[f],b=Math.cos(2*Math.PI*h/r),m=-1*Math.sin(2*Math.PI*h/r);s<o?(t[l]=p+v,e[l]=y+d,t[f]=b*(p-v)-m*(y-d),e[f]=b*(y-d)+m*(p-v)):(t[l]=p+v,e[l]=y+d,t[f]=p-v,e[f]=y-d)}for(var g=1;g<=o;g++)for(var w=o-g,S=0;S<n(g-1);S++)i[n(g-1)+S]=i[S]+n(w);for(var O=0;O<r;O++)if(!(i[O]<=O)){var A=t[i[O]],k=e[i[O]];t[i[O]]=t[O],e[i[O]]=e[O],t[O]=A,e[O]=k}}},{key:"IFFT",value:function(t,e,r){for(var n=function(t){return Math.pow(2,t)},i=new Float32Array(r),o=Math.log2(r),s=1;s<=o;s++)for(var a=0;a<n(s-1);a++)for(var c=o-s,u=0;u<n(c);u++){var l=a*n(c+1)+u,f=n(c)+l,h=u*n(s-1),p=t[l],y=e[l],v=t[f],d=e[f],b=Math.cos(2*Math.PI*h/r),m=Math.sin(2*Math.PI*h/r);s<o?(t[l]=p+v,e[l]=y+d,t[f]=b*(p-v)-m*(y-d),e[f]=b*(y-d)+m*(p-v)):(t[l]=p+v,e[l]=y+d,t[f]=p-v,e[f]=y-d)}for(var g=1;g<=o;g++)for(var w=o-g,S=0;S<n(g-1);S++)i[n(g-1)+S]=i[S]+n(w);for(var O=0;O<r;O++)if(!(i[O]<=O)){var A=t[i[O]],k=e[i[O]];t[i[O]]=t[O],e[i[O]]=e[O],t[O]=A,e[O]=k}for(var T=0;T<r;T++)t[T]/=r,e[T]/=r}}],r&&ze(e.prototype,r),n&&ze(e,n),a}(pt);function Qe(t){return Qe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qe(t)}function Ze(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function $e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Je(t,e){return Je=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Je(t,e)}function Ke(t,e){if(e&&("object"===Qe(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function tr(t){return tr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},tr(t)}function er(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var rr=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Je(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=tr(n);if(i){var r=tr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Ke(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).isLoadError=!1,r.rirs=[],r.convolver=t.createConvolver(),r.dry=t.createGain(),r.wet=t.createGain(),r.tone=t.createBiquadFilter(),r.dry.gain.value=1,r.wet.gain.value=0,r.tone.type="string"==typeof r.tone.type?"lowpass":r.tone.LOWPASS||0,r.tone.frequency.value=350,r.tone.Q.value=Math.SQRT1_2,r.tone.gain.value=0,r.state(!1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"type":if(void 0===e)return this.convolver.buffer;i=parseInt(e,10),o=0,s=this.rirs.length-1,null===e?(this.convolver.buffer=null,this.input.disconnect(0),this.input.connect(this.output)):i>=o&&i<=s&&(this.convolver.buffer=this.rirs[i],this.connect());break;case"dry":case"wet":if(void 0===e)return this[n].gain.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this[n].gain.value=i);break;case"tone":if(void 0===e)return this.tone.frequency.value;i=parseFloat(e),o=10,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.tone.frequency.value=i);break;case"rirs":return this.rirs}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.convolver.disconnect(0),this.dry.disconnect(0),this.wet.disconnect(0),this.tone.disconnect(0),this.isActive?(this.input.connect(this.dry),this.dry.connect(this.output),this.input.connect(this.tone),this.tone.connect(this.convolver),this.convolver.connect(this.wet),this.wet.connect(this.output)):this.input.connect(this.output),this}},{key:"start",value:function(t,e){var r=this;return t instanceof AudioBuffer||null===t?(this.convolver.buffer=t,this.rirs.push(t)):t instanceof ArrayBuffer&&("[object Function]"!==Object.prototype.toString.call(e)&&(e=function(){}),this.context.decodeAudioData(t,(function(t){r.convolver.buffer=t,r.rirs.push(t)}),e)),this}},{key:"preset",value:function(t,e,r,n,i){if("[object Object]"===Object.prototype.toString.call(arguments[0])){var o=arguments[0];"rirs"in o&&(t=o.rirs),"timeout"in o&&(e=o.timeout),"success"in o&&(r=o.success),"error"in o&&(n=o.error),"progress"in o&&(i=o.progress)}Array.isArray(t)||(t=[t]),this.rirs=new Array(t.length);for(var s=parseInt(e,10),a=0,c=t.length;a<c;a++)"string"==typeof t[a]?this.load(t[a],a,s,r,n,i):t[a]instanceof AudioBuffer&&(this.rirs[a]=t[a]);return this}},{key:"load",value:function(t,e,r,n,i,o){var a=this,c=new XMLHttpRequest;return c.timeout=r>0?r:6e4,c.ontimeout=function(t){a.isLoadError||"[object Function]"!==Object.prototype.toString.call(i)||i(t,s.ERROR_AJAX_TIMEOUT),a.isLoadError=!0},c.onprogress=function(t){a.isLoadError?c.abort():"[object Function]"===Object.prototype.toString.call(o)&&o(t)},c.onerror=function(t){a.isLoadError||"[object Function]"!==Object.prototype.toString.call(i)||i(t,s.ERROR_AJAX),a.isLoadError=!0},c.onload=function(t){if(200===c.status){var r=c.response;if(!(r instanceof ArrayBuffer))return;a.context.decodeAudioData(r,(function(r){a.rirs[e]=r;var i,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Ze(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ze(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}(a.rirs);try{for(o.s();!(i=o.n()).done;)if(void 0===i.value)return}catch(t){o.e(t)}finally{o.f()}"[object Function]"===Object.prototype.toString.call(n)&&n(t)}),(function(t){"[object Function]"===Object.prototype.toString.call(i)&&i(t,s.ERROR_DECODE)}))}},c.open("GET",t,!0),c.responseType="arraybuffer",c.send(null),this}},{key:"state",value:function(t){return void 0===t?this.isActive:("toggle"===String(t).toLowerCase()?this.isActive=!this.isActive:this.isActive=Boolean(t),this.connect(),this)}},{key:"params",value:function(){return{state:this.isActive,dry:this.dry.gain.value,wet:this.wet.gain.value,tone:this.tone.frequency.value}}},{key:"toString",value:function(){return"[SoundModule Reverb]"}}],r&&$e(e.prototype,r),s}(pt);function nr(t){return nr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nr(t)}function ir(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function or(t,e,r){return or="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=cr(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},or(t,e,r||t)}function sr(t,e){return sr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},sr(t,e)}function ar(t,e){if(e&&("object"===nr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function cr(t){return cr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},cr(t)}er(rr,"ERROR_AJAX","error"),er(rr,"ERROR_AJAX_TIMEOUT","timeout"),er(rr,"ERROR_DECODE","decode");var ur=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&sr(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=cr(n);if(i){var r=cr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return ar(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).amplitude=t.createGain(),r.amplitude.gain.value=0,r.depth.gain.value=1,r.rate.value=0,r.state(!1),r.lfo.connect(r.depth),r.depth.connect(r.amplitude.gain),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"depth":if(void 0===e)return this.depth.gain.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.depth.gain.value=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.rate.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.amplitude.disconnect(0),this.isActive?(this.input.connect(this.amplitude),this.amplitude.connect(this.output)):this.input.connect(this.output),this}},{key:"stop",value:function(t,e){return or(cr(s.prototype),"stop",this).call(this,t,e),this.isActive&&(this.lfo.connect(this.depth),this.depth.connect(this.amplitude.gain)),this}},{key:"params",value:function(){return{state:this.isActive,depth:this.depth.gain.value,rate:this.rate.value}}},{key:"toString",value:function(){return"[SoundModule Ringmodulator]"}}],r&&ir(e.prototype,r),s}(pt);function lr(t){return lr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lr(t)}function fr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function hr(t,e){return hr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},hr(t,e)}function pr(t,e){if(e&&("object"===lr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function yr(t){return yr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},yr(t)}var vr=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&hr(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=yr(n);if(i){var r=yr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return pr(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).splitter=t.createChannelSplitter(2),r.merger=t.createScriptProcessor(e,2,2),r.delayL=t.createDelay(s.MAX_DELAY_TIME),r.delayR=t.createDelay(s.MAX_DELAY_TIME),r.delayL.delayTime.value=0,r.delayR.delayTime.value=0,r.state(!1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,a=null;switch(n){case"delaytime":case"time":if(void 0===e)return this.delayL.delayTime.value;i=parseFloat(e),o=0,a=s.MAX_DELAY_TIME,i>=o&&i<=a&&(this.delayL.delayTime.value=i,this.delayR.delayTime.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.splitter.disconnect(0),this.delayL.disconnect(0),this.delayR.disconnect(0),this.merger.disconnect(0),this.isActive?(this.input.connect(this.splitter),this.splitter.connect(this.delayL,0,0),this.splitter.connect(this.delayR,1,0),this.delayL.connect(this.merger),this.delayR.connect(this.merger),this.merger.connect(this.output)):this.input.connect(this.output),this}},{key:"start",value:function(){var t=this;if(this.isActive&&this.isStop){this.isStop=!1;var e=this.merger.bufferSize;this.merger.onaudioprocess=function(r){var n=r.inputBuffer.getChannelData(0),i=r.inputBuffer.getChannelData(1),o=r.outputBuffer.getChannelData(0),s=r.outputBuffer.getChannelData(1);if(t.isActive&&0!==t.delayL.delayTime.value&&0!==t.delayR.delayTime.value)for(var a=0;a<e;a++)o[a]=n[a],s[a]=-i[a];else o.set(n),s.set(i)}}return this}},{key:"stop",value:function(){return this.isActive&&(this.merger.disconnect(0),this.merger.onaudioprocess=null),this}},{key:"params",value:function(){return{state:this.isActive,time:this.delayL.delayTime.value}}},{key:"toString",value:function(){return"[SoundModule Stereo]"}}],r&&fr(e.prototype,r),s}(pt);function dr(t){return dr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dr(t)}function br(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function mr(t,e,r){return mr="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Sr(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},mr(t,e,r||t)}function gr(t,e){return gr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},gr(t,e)}function wr(t,e){if(e&&("object"===dr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Sr(t){return Sr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Sr(t)}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:1,enumerable:!0,configurable:!0,writable:!0}):t[e]=1}(vr,"MAX_DELAY_TIME");var Or=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&gr(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Sr(n);if(i){var r=Sr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return wr(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).amplitude=t.createGain(),r.amplitude.gain.value=1,r.depth.gain.value=0,r.rate.value=0,r.state(!1),r.lfo.connect(r.depth),r.depth.connect(r.amplitude.gain),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,a=null;switch(n){case"depth":if(void 0===e)return this.depth.gain.value;a=1,(i=parseFloat(e))>=(o=0)&&i<=a&&(this.depth.gain.value=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,a=this.context.sampleRate/2,i>=o&&i<=a&&(this.rate.value=i);break;case"wave":if(void 0===e)return this.lfo.type;(i=String(e).toLowerCase())in s.WAVE_TYPES&&(this.lfo.type="string"==typeof this.lfo.type?i:s.WAVE_TYPES[i])}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.amplitude.disconnect(0),this.isActive?(this.input.connect(this.amplitude),this.amplitude.connect(this.output)):this.input.connect(this.output),this}},{key:"stop",value:function(t,e){return mr(Sr(s.prototype),"stop",this).call(this,t,e),this.isActive&&(this.lfo.connect(this.depth),this.depth.connect(this.amplitude.gain)),this}},{key:"params",value:function(){return{state:this.isActive,depth:this.depth.gain.value,rate:this.rate.value,wave:this.lfo.type}}},{key:"toString",value:function(){return"[SoundModule Tremolo]"}}],r&&br(e.prototype,r),s}(pt);function Ar(t){return Ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ar(t)}function kr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Tr(t,e,r){return Tr="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Rr(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},Tr(t,e,r||t)}function Er(t,e){return Er=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Er(t,e)}function jr(t,e){if(e&&("object"===Ar(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Rr(t){return Rr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Rr(t)}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(Or,"WAVE_TYPES",{sine:0,square:1,sawtooth:2,triangle:3});var Pr=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Er(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Rr(n);if(i){var r=Rr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return jr(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).autoWah=!1,r.lowpass=t.createBiquadFilter(),r.envelopeFollower=t.createWaveShaper(),r.sensitivity=t.createBiquadFilter(),r.lowpass.type="string"==typeof r.lowpass.type?"lowpass":r.lowpass.LOWPASS||0,r.lowpass.frequency.value=r.autoWah?20:350,r.lowpass.Q.value=1,r.lowpass.gain.value=0,r.envelopeFollower.curve=new Float32Array([1,0,1]),r.sensitivity.type="string"==typeof r.lowpass.type?"lowpass":r.lowpass.LOWPASS||0,r.sensitivity.frequency.value=350,r.sensitivity.Q.value=1,r.sensitivity.gain.value=0,r.depth.gain.value=0,r.rate.value=0,r.depthRate=0,r.state(!1),r.connect(),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"auto":if(void 0===e)return this.autoWah;this.autoWah=Boolean(e),this.connect();break;case"frequency":case"cutoff":if(void 0===e)return this.autoWah?this.sensitivity.frequency.value:this.lowpass.frequency.value;i=parseFloat(e),o=10,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.autoWah?(this.sensitivity.frequency.value=i,this.lowpass.frequency.value=20):this.lowpass.frequency.value=i);break;case"depth":if(void 0===e)return this.depthRate;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.depth.gain.value=this.autoWah?1e4*i:this.lowpass.frequency.value*i,this.depthRate=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.rate.value=i);break;case"resonance":if(void 0===e)return this.autoWah?this.sensitivity.Q.value:this.lowpass.Q.value;s=1e3,(i=parseFloat(e))>=(o=1e-4)&&i<=s&&(this.autoWah?(this.sensitivity.Q.value=i,this.lowpass.Q.value=1):this.lowpass.Q.value=i)}}return this}},{key:"stop",value:function(t,e){return Tr(Rr(s.prototype),"stop",this).call(this,t,e),!this.autoWah&&this.isActive&&(this.lfo.connect(this.depth),this.depth.connect(this.lowpass.frequency)),this}},{key:"connect",value:function(){return this.input.disconnect(0),this.sensitivity.disconnect(0),this.envelopeFollower.disconnect(0),this.lowpass.disconnect(0),this.depth.disconnect(0),this.isActive?this.autoWah?(this.input.connect(this.sensitivity),this.sensitivity.connect(this.output),this.input.connect(this.envelopeFollower),this.envelopeFollower.connect(this.lowpass),this.lowpass.connect(this.depth),this.depth.connect(this.sensitivity.frequency)):(this.input.connect(this.lowpass),this.lowpass.connect(this.output),this.lfo.connect(this.depth),this.depth.connect(this.lowpass.frequency)):this.input.connect(this.output),this}},{key:"params",value:function(){return{state:this.isActive,auto:this.autoWah,cutoff:this.autoWah?this.sensitivity.frequency.value:this.lowpass.frequency.value,depth:this.autoWah?this.depth.gain.value:this.depthRate,rate:this.rate.value,resonance:this.autoWah?this.sensitivity.Q.value:this.lowpass.Q.value}}},{key:"toString",value:function(){return"[SoundModule Wah]"}}],r&&kr(e.prototype,r),s}(pt);function xr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _r(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Mr=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.init(e,r)}var e,r;return e=t,r=[{key:"init",value:function(e,r){Array.isArray(this.modules)&&this.modules.length>0&&(this.mastervolume.disconnect(0),this.mastervolume=null,this.processor.disconnect(0),this.processor=null,this.analyser.INPUT.disconnect(0),this.analyser=null,this.recorder.INPUT.disconnect(0),this.recorder=null,this.session.INPUT.disconnect(0),this.session=null,this.modules.forEach((function(t){t.INPUT.disconnect(0),t.OUTPUT.disconnect(0),t=null})),this.modules=[]),this.context=e,this.sampleRate=e.sampleRate;var n=parseInt(r,10);switch(n){case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:break;default:n=0}this.mastervolume=e.createGain(),this.processor=e.createScriptProcessor(n,t.NUMBER_OF_INPUTS,t.NUMBER_OF_OUTPUTS),this.analyser=new q(e),this.recorder=new K(e,n,t.NUMBER_OF_INPUTS,t.NUMBER_OF_OUTPUTS),this.session=new at(e,n,t.NUMBER_OF_INPUTS,t.NUMBER_OF_OUTPUTS,this.analyser),this.stereo=new vr(e,n),this.compressor=new Ut(e,n),this.distortion=new Kt(e,n),this.wah=new Pr(e,n),this.pitchshifter=new Ye(e,n),this.equalizer=new ue(e,n),this.filter=new ve(e,n),this.autopanner=e.createStereoPanner?new wt(e,n):new jt(e,n),this.tremolo=new Or(e,n),this.ringmodulator=new ur(e,n),this.phaser=new Ve(e,n),this.flanger=new Oe(e,n),this.chorus=new Ft(e,n),this.delay=new Wt(e,n),this.reverb=new rr(e,n),this.panner=new Ie(e,n),this.listener=new Re(e,n),this.envelopegenerator=new ne(e),this.modules=[this.stereo,this.compressor,this.distortion,this.wah,this.pitchshifter,this.equalizer,this.filter,this.autopanner,this.tremolo,this.ringmodulator,this.phaser,this.flanger,this.chorus,this.delay,this.reverb,this.panner]}},{key:"setup",value:function(){return this}},{key:"param",value:function(t,e){var r=null;if("mastervolume"===String(t).replace(/-/g,"").toLowerCase()){if(void 0===e)return this.mastervolume.gain.value;(r=parseFloat(e))>=0&&r<=1&&(this.mastervolume.gain.value=r)}}},{key:"ready",value:function(){return this}},{key:"start",value:function(){return this}},{key:"stop",value:function(){return this}},{key:"get",value:function(){return this}},{key:"resize",value:function(t){return this.init(this.context,t),this}},{key:"getBufferSize",value:function(){return this.processor.bufferSize}},{key:"install",value:function(t,e){return e instanceof pt?(String(t)in this||(this[t]=e,this.modules.every((function(t){return t!==e}))&&this.modules.push(e)),this):this}},{key:"connect",value:function(t,e){Array.isArray(e)&&(this.modules=e),t.disconnect(0),this.modules.length>0?t.connect(this.modules[0].INPUT):t.connect(this.mastervolume);for(var r=0,n=this.modules.length;r<n;r++)this.modules[r].OUTPUT.disconnect(0),r<this.modules.length-1?this.modules[r].OUTPUT.connect(this.modules[r+1].INPUT):this.modules[r].OUTPUT.connect(this.mastervolume);return this.mastervolume.connect(this.context.destination),this.mastervolume.connect(this.analyser.INPUT),this.mastervolume.connect(this.recorder.INPUT),this.recorder.INPUT.connect(this.context.destination),this.mastervolume.connect(this.session.INPUT),this.session.INPUT.connect(this.context.destination),this}},{key:"module",value:function(t){var e=String(t).replace(/-/g,"").toLowerCase();switch(e){case"analyser":case"recorder":case"session":case"stereo":case"compressor":case"distortion":case"wah":case"pitchshifter":case"equalizer":case"filter":case"autopanner":case"tremolo":case"ringmodulator":case"phaser":case"flanger":case"chorus":case"delay":case"reverb":case"panner":case"listener":return this[e];case"envelopegenerator":case"eg":return this.envelopegenerator;case"glide":if(e in this)return this[e];case"vocalcanceler":if(e in this)return this[e];case"noisegate":case"noisesuppressor":if(e in this)return this[e];default:return this[e]}}},{key:"on",value:function(t){var e=parseFloat(t);return(isNaN(e)||e<this.context.currentTime)&&(e=this.context.currentTime),this.stereo.start(e),this.chorus.start(e),this.flanger.start(e),this.phaser.start(e),this.autopanner.start(e),this.tremolo.start(e),this.ringmodulator.start(e),this.wah.start(e),this.filter.start(e),this}},{key:"off",value:function(t){var e=parseFloat(t);return(isNaN(e)||e<this.context.currentTime)&&(e=this.context.currentTime),this.stereo.stop(e),this.chorus.stop(e),this.flanger.stop(e),this.phaser.stop(e),this.autopanner.stop(e),this.tremolo.stop(e),this.ringmodulator.stop(e),this.wah.stop(e),this}},{key:"params",value:function(){var t={};for(var e in this)if("[object Function]"!==Object.prototype.toString.call(this[e])){var r=e.toLowerCase();"mastervolume"===r?t[r]=this[e].gain.value:"[object Object]"===Object.prototype.toString.call(this[e])&&"params"in this[e]&&(t[r]=this[e].params())}return t}},{key:"toJSON",value:function(){return JSON.stringify(this.params())}},{key:"toString",value:function(){return"[SoundModule]"}}],r&&xr(e.prototype,r),t}();function Cr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Fr(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}_r(Mr,"NUMBER_OF_INPUTS",2),_r(Mr,"NUMBER_OF_OUTPUTS",2);var Ir=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.isActive=r,this.context=e,this.source=e.createOscillator(),this.source.setPeriodicWave=this.source.setPeriodicWave||this.source.setWaveTable,this.source.start=this.source.start||this.source.noteOn,this.source.stop=this.source.stop||this.source.noteOff,this.volume=e.createGain(),this.isStop=!0,this.octave=0,this.fine=0,this.customs={real:new Float32Array([0,1]),imag:new Float32Array([0,1])}}var e,r;return e=t,r=[{key:"param",value:function(e,r){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var n in arguments[0])this.param(n,arguments[0][n]);else{var i=String(e).replace(/-/g,"").toLowerCase(),o=null,s=null,a=null;switch(i){case"type":if(void 0===r)return this.source.type;if("[object Object]"!==Object.prototype.toString.call(r))(o=String(r).toLowerCase())in t.WAVE_TYPES&&(this.source.type="string"==typeof this.source.type?o:t.WAVE_TYPES[o]);else if("real"in r&&"imag"in r){var c=null,u=null;if(r.real instanceof Float32Array?c=r.real:Array.isArray(r.real)&&(c=new Float32Array(r.real)),r.imag instanceof Float32Array?u=r.imag:Array.isArray(r.imag)&&(u=new Float32Array(r.imag)),c instanceof Float32Array&&u instanceof Float32Array){var l=4096;c.length>l&&(c=c.subarray(0,l)),u.length>l&&(u=u.subarray(0,l)),0!==c[0]&&(c[0]=0),0!==u[0]&&(u[0]=0);var f=this.context.createPeriodicWave(c,u);this.source.setPeriodicWave(f),this.customs.real=c,this.customs.imag=u}}break;case"octave":if(void 0===r)return this.octave;o=parseFloat(r),s=-4800/t.OCTAVE,a=4800/t.OCTAVE,o>=s&&o<=a&&(this.octave=o,this.source.detune.value=this.fine+o*t.OCTAVE);break;case"fine":if(void 0===r)return this.fine;o=parseFloat(r),s=-t.OCTAVE,a=t.OCTAVE,o>=s&&o<=a&&(this.fine=o,this.source.detune.value=o+this.octave*t.OCTAVE);break;case"volume":case"gain":if(void 0===r)return this.volume.gain.value;a=1,(o=parseFloat(r))>=(s=0)&&o<=a&&(this.volume.gain.value=o)}}return this}},{key:"ready",value:function(t){if(this.isActive){var e={type:this.source.type,frequency:this.source.frequency.value,detune:this.source.detune.value};if(this.isStop||(this.source.stop(this.context.currentTime),this.source.disconnect(0)),this.source=this.context.createOscillator(),this.source.setPeriodicWave=this.source.setPeriodicWave||this.source.setWaveTable,this.source.start=this.source.start||this.source.noteOn,this.source.stop=this.source.stop||this.source.noteOff,"custom"===e.type){var r=this.customs.real,n=this.customs.imag,i=this.context.createPeriodicWave(r,n);this.source.setPeriodicWave(i)}else this.source.type=e.type;this.source.frequency.value=e.frequency,this.source.detune.value=e.detune,this.volume.connect(t)}return this}},{key:"start",value:function(t){return this.isActive?(this.source.start(t),this.isStop=!1):(this.isStop||(this.source.stop(this.context.currentTime),this.isStop=!0),this.source.disconnect(0)),this}},{key:"stop",value:function(t){return this.isStop||(this.source.stop(t),this.source.disconnect(0),this.isStop=!0),this}},{key:"state",value:function(t){return void 0===t?this.isActive:("toggle"===String(t).toLowerCase()?this.isActive=!this.isActive:this.isActive=Boolean(t),this)}},{key:"get",value:function(){return this.source}},{key:"toString",value:function(){return"[OscillatorModule Oscillator]"}}],r&&Cr(e.prototype,r),t}();function Nr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Lr(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}Fr(Ir,"OCTAVE",1200),Fr(Ir,"WAVE_TYPES",{sine:0,square:1,sawtooth:2,triangle:3});var Dr=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.context=e,this.frequencies={start:-1,end:0},this.time=0,this.type=t.LINEAR}var e,r;return e=t,r=[{key:"param",value:function(e,r){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var n in arguments[0])this.param(n,arguments[0][n]);else{var i=String(e).replace(/-/g,"").toLowerCase(),o=null;switch(i){case"time":if(void 0===r)return this.time;(o=parseFloat(r))>=0&&(this.time=o);break;case"type":if(void 0===r)return this.type;(o=String(r).toLowerCase())!==t.LINEAR&&o!==t.EXPONENTIAL||(this.type=o)}}return this}},{key:"ready",value:function(t){this.frequencies.end=t;var e=-1===this.frequencies.start?0:this.frequencies.end-this.frequencies.start;return-1!==this.frequencies.start&&0!==this.time&&0!==e||(this.frequencies.start=this.frequencies.end),this}},{key:"start",value:function(t,e){var r=parseFloat(e);(isNaN(r)||r<this.context.currentTime)&&(r=this.context.currentTime);var n=r,i=n+this.time;return t.frequency.cancelScheduledValues(n),t.frequency.setValueAtTime(this.frequencies.start,n),t.frequency["".concat(this.type,"RampToValueAtTime")](this.frequencies.end,i),this}},{key:"stop",value:function(){return this.frequencies.start=this.frequencies.end,this}},{key:"toString",value:function(){return"[OscillatorModule Glide]"}}],r&&Nr(e.prototype,r),t}();function Br(t){return Br="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Br(t)}function Ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function qr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Vr(t,e,r){return Vr="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Xr(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},Vr(t,e,r||t)}function Gr(t,e){return Gr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Gr(t,e)}function zr(t,e){if(e&&("object"===Br(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Xr(t){return Xr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Xr(t)}Lr(Dr,"LINEAR","linear"),Lr(Dr,"EXPONENTIAL","exponential");var Wr=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Gr(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Xr(n);if(i){var r=Xr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return zr(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).sources=[],r.times={start:0,duration:0},r.isAnalyser=!1,r.glide=new Dr(t),r}return e=s,r=[{key:"setup",value:function(t){this.sources.length=0,Array.isArray(t)||(t=[t]);for(var e=0,r=t.length;e<r;e++)this.sources[e]=new Ir(this.context,Boolean(t[e])),this.envelopegenerator.setGenerator(e);return this}},{key:"param",value:function(t,e){if("[object Object]"!==Object.prototype.toString.call(arguments[0])){var r=String(t).replace(/-/g,"").toLowerCase(),n=Vr(Xr(s.prototype),"param",this).call(this,r,e);return void 0===n?this:n}for(var i in arguments[0])this.param(i,arguments[0][i])}},{key:"ready",value:function(t,e){var r=parseFloat(t),n=parseFloat(e);return this.times.start=r>=0?r:0,this.times.duration=n>=0?n:0,this.envelopegenerator.clear(!0),this}},{key:"start",value:function(t,e,r){var n=this,i=this.context.currentTime+this.times.start;Array.isArray(t)||(t=[t]);for(var o=0,s=t.length;o<s;o++){var a=parseFloat(t[o]);t[o]=a>=0?a:0}this.envelopegenerator.clear(!0),this.processor.disconnect(0),this.processor.onaudioprocess=null,this.connect(this.processor,e);for(var c=0,u=t.length;c<u&&!(c>=this.sources.length);c++){var l=this.sources[c],f=t[c];l.ready(this.processor),this.envelopegenerator.ready(c,l.source,l.volume),this.glide.ready(f).start(l.source,i),l.start(i)}return this.envelopegenerator.start(i),this.on(i),this.isAnalyser||(this.analyser.start("time"),this.analyser.start("fft"),this.isAnalyser=!0),"[object Function]"===Object.prototype.toString.call(r)?this.processor.onaudioprocess=r:this.processor.onaudioprocess=function(t){var e=t.inputBuffer.getChannelData(0),r=t.inputBuffer.getChannelData(1),i=t.outputBuffer.getChannelData(0),o=t.outputBuffer.getChannelData(1);if(n.envelopegenerator.isStop()){var s,a=n.context.currentTime,c=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ur(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}(n.sources);try{for(c.s();!(s=c.n()).done;)s.value.stop(a)}catch(t){c.e(t)}finally{c.f()}n.off(a),n.analyser.stop("time"),n.analyser.stop("fft"),n.isAnalyser=!1,n.processor.disconnect(0),n.processor.onaudioprocess=null}else i.set(e),o.set(r)},this}},{key:"stop",value:function(){var t=this.context.currentTime+this.times.start+this.times.duration;return this.envelopegenerator.stop(t),this.glide.stop(),this.filter.stop(t),this}},{key:"get",value:function(t){var e=parseInt(t,10);return e>=0&&e<this.sources.length?this.sources[e]:this.sources}},{key:"length",value:function(){return this.sources.length}},{key:"params",value:function(){var t=Vr(Xr(s.prototype),"params",this).call(this);t.oscillator={glide:{type:this.glide.param("type"),time:this.glide.param("time")}};for(var e=0,r=this.sources.length;e<r;e++){var n=this.sources[e];t.oscillator["oscillator".concat(e)]={state:n.state(),gain:n.param("gain"),type:n.param("type"),octave:n.param("octave"),fine:n.param("fine")}}return t}},{key:"toString",value:function(){return"[OscillatorModule]"}}],r&&qr(e.prototype,r),s}(Mr);function Hr(t){return Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hr(t)}function Yr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Qr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Zr(t,e,r){return Zr="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Kr(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},Zr(t,e,r||t)}function $r(t,e){return $r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},$r(t,e)}function Jr(t,e){if(e&&("object"===Hr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Kr(t){return Kr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Kr(t)}function tn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var en=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&$r(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Kr(n);if(i){var r=Kr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Jr(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).sources=[],r.resources=[],r.buffers=[],r.volumes=[],r.isStops=[],r.settings=[],r.times={start:0,duration:0},r.transpose=1,r.isStop=!0,r.isLoadError=!1,r.isAnalyser=!1,r}return e=s,r=[{key:"setup",value:function(t,e,r,n,i,o){if("[object Object]"===Object.prototype.toString.call(arguments[0])){var s=arguments[0];"resources"in s&&(t=s.resources),"settings"in s&&(e=s.settings),"timeout"in s&&(r=s.timeout),"success"in s&&(n=s.success),"error"in s&&(i=s.error),"progress"in s&&(o=s.progress)}Array.isArray(t)||(t=[t]),this.resources=t,Array.isArray(e)||(e=[e]),this.buffers.length=t.length;for(var a=0,c=e.length;a<c;a++){if(!("buffer"in e[a]))return this;var u=parseInt(e[a].buffer,10);if(!(u>=0&&u<this.buffers.length))return this;e[a].buffer=u,e[a].rate="rate"in e[a]&&e[a].rate>=0?parseFloat(e[a].rate):1,e[a].loop="loop"in e[a]&&Boolean(e[a].loop),e[a].start="start"in e[a]&&e[a].start>=0?parseFloat(e[a].start):0,e[a].end="end"in e[a]&&e[a].end>=0?parseFloat(e[a].end):0,e[a].volume="volume"in e[a]&&e[a].volume>=0&&e[a].volume<=1?parseFloat(e[a].volume):1,this.isStops[a]=!0,this.volumes[a]=this.context.createGain(),this.envelopegenerator.setGenerator(a)}this.settings=e;for(var l=parseInt(r,10),f=0,h=this.resources.length;f<h;f++)"string"==typeof this.resources[f]?this.load(this.resources[f],f,l,n,i,o):this.resources[f]instanceof AudioBuffer&&(this.buffers[f]=this.resources[f]);return this}},{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=Zr(Kr(s.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;var o=null;if("transpose"===n){if(void 0===e)return this.transpose;(o=parseFloat(e))>0&&(this.transpose=o)}}return this}},{key:"ready",value:function(t,e){var r=parseFloat(t),n=parseFloat(e);return this.times.start=r>=0?r:0,this.times.duration=n>=0?n:0,this.envelopegenerator.clear(!1),this}},{key:"start",value:function(t,e,r){var n=this,i=parseInt(t,10);if(isNaN(i)||i<0||i>=this.settings.length)return this;var o=this.settings[i].buffer,s=this.settings[i].rate,a=this.settings[i].loop,c=this.settings[i].start,u=this.settings[i].end,l=this.settings[i].volume;if(!(this.buffers[o]instanceof AudioBuffer))return this;var f=this.context.createBufferSource();f.start=f.start||f.noteGrainOn,f.stop=f.stop||f.noteOff,f.buffer=this.buffers[o],f.playbackRate.value=s*this.transpose,f.loop=a,f.loopStart=c,f.loopEnd=u,this.volumes[i].gain.value=l,this.envelopegenerator.clear(!1),this.envelopegenerator.ready(i,f,this.volumes[i]),this.volumes[i].connect(this.processor),this.connect(this.processor,e);var h=this.context.currentTime+this.times.start;return f.loop?f.start(h,h+f.loopStart,f.loopEnd-h):f.start(h),this.sources[i]=f,this.envelopegenerator.start(h),this.on(h),this.isAnalyser||(this.analyser.start("time"),this.analyser.start("fft"),this.isAnalyser=!0),this.isStops[i]=!1,this.times.stop>0&&window.setTimeout((function(){n.stop(i)}),1e3*this.times.stop),f.onended=function(){n.isStops[i]=!0},"[object Function]"===Object.prototype.toString.call(r)?this.processor.onaudioprocess=r:this.processor.onaudioprocess=function(t){if(n.isStop=n.isStops.every((function(t){return t})),n.isStop)n.off(n.context.currentTime),n.envelopegenerator.clear(!1),n.analyser.stop("time"),n.analyser.stop("fft"),n.isAnalyser=!1,n.processor.disconnect(0),n.processor.onaudioprocess=null;else{var e=t.inputBuffer.getChannelData(0),r=t.inputBuffer.getChannelData(1),i=t.outputBuffer.getChannelData(0),o=t.outputBuffer.getChannelData(1);i.set(e),o.set(r)}},this}},{key:"stop",value:function(t){var e=parseInt(t,10);if(isNaN(e)||e<0||e>=this.settings.length)return this;var r=this.settings[e].buffer;if(!(this.buffers[r]instanceof AudioBuffer&&this.sources[e]instanceof AudioBufferSourceNode))return this;var n=this.context.currentTime+this.times.start+this.times.duration;return this.envelopegenerator.stop(n),this.filter.stop(n),this}},{key:"get",value:function(t){var e=parseInt(t,10);return e>=0&&e<this.buffers.length?this.buffers[e]:this.buffers}},{key:"params",value:function(){var t=Zr(Kr(s.prototype),"params",this).call(this);return t.oneshot={transpose:this.transpose},t}},{key:"load",value:function(t,e,r,n,i,o){var a=this,c=new XMLHttpRequest;return c.timeout=r>0?r:6e4,c.ontimeout=function(t){a.isLoadError||"[object Function]"!==Object.prototype.toString.call(i)||i(t,s.ERROR_AJAX_TIMEOUT),a.isLoadError=!0},c.onprogress=function(t){a.isLoadError?c.abort():"[object Function]"===Object.prototype.toString.call(o)&&o(t)},c.onerror=function(t){a.isLoadError||"[object Function]"!==Object.prototype.toString.call(i)||i(t,s.ERROR_AJAX),a.isLoadError=!0},c.onload=function(t){if(200===c.status){var r=c.response;if(!(r instanceof ArrayBuffer))return;a.context.decodeAudioData(r,(function(r){a.buffers[e]=r;var i,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Yr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yr(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}(a.buffers);try{for(o.s();!(i=o.n()).done;)if(void 0===i.value)return}catch(t){o.e(t)}finally{o.f()}"[object Function]"===Object.prototype.toString.call(n)&&n(t,a.buffers)}),(function(t){"[object Function]"===Object.prototype.toString.call(i)&&i(t,s.ERROR_DECODE)}))}},c.open("GET",t,!0),c.responseType="arraybuffer",c.send(null),this}},{key:"reset",value:function(t,e,r){var n=parseInt(t,10);return String(e).toLowerCase()in this.settings[n]&&(this.settings[n][e.toLowerCase()]=r),this}},{key:"toString",value:function(){return"[OneshotModule]"}}],r&&Qr(e.prototype,r),s}(Mr);function rn(t){return rn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rn(t)}function nn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function on(t,e,r){return on="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=cn(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},on(t,e,r||t)}function sn(t,e){return sn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},sn(t,e)}function an(t,e){if(e&&("object"===rn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function cn(t){return cn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},cn(t)}function un(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}tn(en,"ERROR_AJAX","error"),tn(en,"ERROR_AJAX_TIMEOUT","timeout"),tn(en,"ERROR_DECODE","decode");var ln=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&sn(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=cn(n);if(i){var r=cn(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return an(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).type=s.WHITE_NOISE,r.envelopegenerator.setGenerator(0),r.isAnalyser=!1,r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=on(cn(s.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;var o="";if("type"===n){if(void 0===e)return this.type;(o=String(e).toLowerCase())!==s.WHITE_NOISE&&o!==s.PINK_NOISE&&o!==s.BROWNIAN_NOISE||(this.type=o)}}return this}},{key:"start",value:function(t){var e=this,r=this.context.currentTime;this.envelopegenerator.clear(!0),this.processor.disconnect(0),this.processor.onaudioprocess=null,this.connect(this.envelopegenerator.getGenerator(0),t),this.envelopegenerator.ready(0,this.processor),this.envelopegenerator.start(r),this.isAnalyser||(this.analyser.start("time"),this.analyser.start("fft"),this.isAnalyser=!0),this.on(r);var n=this.processor.bufferSize,i=0;return this.processor.onaudioprocess=function(t){var r=t.outputBuffer.getChannelData(0),o=t.outputBuffer.getChannelData(1);if(e.envelopegenerator.isStop())e.processor.disconnect(0),e.processor.onaudioprocess=null,e.analyser.stop("time"),e.analyser.stop("fft"),e.isAnalyser=!1;else switch(e.type){case s.WHITE_NOISE:for(var a=0;a<n;a++)r[a]=2*(Math.random()-.5),o[a]=2*(Math.random()-.5);break;case s.PINK_NOISE:for(var c=0,u=0,l=0,f=0,h=0,p=0,y=0,v=0;v<n;v++){var d=2*Math.random()-1;c=.99886*c+.0555179*d,u=.99332*u+.0750759*d,l=.969*l+.153852*d,f=.8665*f+.3104856*d,h=.55*h+.5329522*d,p=-.7616*p-.016898*d,r[v]=c+u+l+f+h+p+y+.5362*d,o[v]=c+u+l+f+h+p+y+.5362*d,r[v]*=.11,o[v]*=.11,y=.115926*d}break;case s.BROWNIAN_NOISE:for(var b=0;b<n;b++){var m=2*Math.random()-1;r[b]=(i+.02*m)/1.02,o[b]=(i+.02*m)/1.02,i=(i+.02*m)/1.02,r[b]*=3.5,o[b]*=3.5}}},this}},{key:"stop",value:function(){var t=this.context.currentTime;return this.envelopegenerator.stop(t),this.off(t),this}},{key:"toString",value:function(){return"[NoiseModule]"}}],r&&nn(e.prototype,r),s}(Mr);function fn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}un(ln,"WHITE_NOISE","whitenoise"),un(ln,"PINK_NOISE","pinknoise"),un(ln,"BROWNIAN_NOISE","browniannoise");var hn=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.depth=0}var e,r;return e=t,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null;if("depth"===n){if(void 0===e)return this.depth;o=1,(i=parseFloat(e))>=0&&i<=o&&(this.depth=i)}}return this}},{key:"start",value:function(t,e){return t-this.depth*e}},{key:"toString",value:function(){return"[AudioModule VocalCanceler]"}}],r&&fn(e.prototype,r),t}();function pn(t){return pn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pn(t)}function yn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function vn(t,e,r){return vn="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=mn(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},vn(t,e,r||t)}function dn(t,e){return dn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},dn(t,e)}function bn(t,e){if(e&&("object"===pn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function mn(t){return mn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},mn(t)}var gn=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&dn(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=mn(n);if(i){var r=mn(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return bn(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).source=t.createBufferSource(),r.buffer=null,r.currentTime=0,r.paused=!0,r.callbacks={decode:function(){},ready:function(){},start:function(){},stop:function(){},update:function(){},ended:function(){},error:function(){}},r.vocalcanceler=new hn,r}return e=s,r=[{key:"setup",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.setup(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase();n in this.callbacks&&"[object Function]"===Object.prototype.toString.call(e)&&(this.callbacks[n]=e)}return this.envelopegenerator.setGenerator(0),this.envelopegenerator.param({attack:0,decay:.01,sustain:1,release:.01}),this}},{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=vn(mn(s.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;var o=0,a=0;switch(n){case"playbackrate":if(void 0===e)return this.source.playbackRate.value;if(a=1024,(o=parseFloat(e))>=0&&o<=a){this.source.playbackRate.value=o;var c=this.context.currentTime,u=this.param("currentTime"),l=this.param("duration");this.envelopegenerator.start(c),this.envelopegenerator.stop(c+(l-u)/o,!0)}break;case"loop":case"looping":if(void 0===e)return this.source.loop;this.source.loop=Boolean(e);break;case"currenttime":if(void 0===e)return this.currentTime;this.buffer instanceof AudioBuffer?(o=parseFloat(e),a=this.buffer.duration,o>=0&&o<=a&&(this.paused?this.currentTime=o:(this.stop(),this.start(o)))):this.currentTime=0;break;case"duration":return this.buffer instanceof AudioBuffer?this.buffer.duration:0;case"samplerate":return this.buffer instanceof AudioBuffer?this.buffer.sampleRate:this.sampleRate;case"channels":return this.buffer instanceof AudioBuffer?this.buffer.numberOfChannels:0}}return this}},{key:"ready",value:function(t){var e=this;return t instanceof ArrayBuffer?(this.buffer=null,this.context.decodeAudioData(t,(function(t){e.buffer=t,e.analyser.start("timeoverview",0,e.buffer),e.analyser.start("timeoverview",1,e.buffer),e.callbacks.ready(e.buffer)}),this.callbacks.error),this.callbacks.decode(t)):t instanceof AudioBuffer&&(this.buffer=t),this}},{key:"start",value:function(t,e,r,n){var i=this;if(this.buffer instanceof AudioBuffer&&this.paused){var o=this.context.currentTime,s=parseFloat(t),a=parseFloat(e);this.currentTime=a>=0?s>=0&&s<=a?s:0:s>=0&&s<=this.buffer.duration?s:0;var c=this.source.playbackRate.value,u=this.source.loop;this.source=this.context.createBufferSource(),this.source.start=this.source.start||this.source.noteGrainOn,this.source.stop=this.source.stop||this.source.noteOff,this.source.buffer=this.buffer,this.source.playbackRate.value=c,this.source.loop=u,this.source.loopStart=this.currentTime,this.source.loopEnd=a>=0?a:this.buffer.duration,this.envelopegenerator.ready(0,this.source,this.processor),this.connect(this.processor,r),isNaN(s)?this.source.start(o):a>=0?this.source.start(o,this.currentTime,a-s):this.source.start(o,this.currentTime,this.buffer.duration-this.currentTime),this.analyser.start("time"),this.analyser.start("fft"),this.paused=!1,this.envelopegenerator.start(o),a>=0?this.envelopegenerator.stop(o+(a-s)/this.source.playbackRate.value,!0):this.envelopegenerator.stop(o+(this.buffer.duration-s)/this.source.playbackRate.value,!0),this.on(o),this.callbacks.start(this.source,this.currentTime);var l=this.processor.bufferSize;"[object Function]"===Object.prototype.toString.call(n)?this.processor.onaudioprocess=n:this.processor.onaudioprocess=function(t){var e=t.inputBuffer.getChannelData(0),o=t.inputBuffer.getChannelData(1),s=t.outputBuffer.getChannelData(0),a=t.outputBuffer.getChannelData(1);if(i.currentTime<Math.floor(i.source.loopEnd)){for(var c=0;c<l;c++)s[c]=i.vocalcanceler.start(e[c],o[c]),a[c]=i.vocalcanceler.start(o[c],e[c]),i.currentTime+=1*i.source.playbackRate.value/i.source.buffer.sampleRate,i.callbacks.update(i.source,i.currentTime);i.analyser.domain("timeoverview",0).update(i.currentTime),i.analyser.domain("timeoverview",1).update(i.currentTime)}else i.source.loop?(i.stop(),"sprite"===i.analyser.domain("timeoverview",0).param("mode")||"sprite"===i.analyser.domain("timeoverview",1).param("mode")?i.start(i.source.loopStart,i.source.loopEnd,r,n):i.start(0,i.buffer.duration,r,n)):i.end()}}return this}},{key:"stop",value:function(){if(this.buffer instanceof AudioBuffer&&!this.paused){var t=this.context.currentTime;this.source.stop(t),this.off(t),this.analyser.stop("time"),this.analyser.stop("fft"),this.processor.disconnect(0),this.processor.onaudioprocess=null,this.paused=!0,this.callbacks.stop(this.source,this.currentTime)}return this}},{key:"get",value:function(){return this.source}},{key:"toggle",value:function(t,e,r,n){return this.paused?this.start(t,e,r,n):this.stop(),this}},{key:"end",value:function(){return this.stop(),this.currentTime=0,this.callbacks.ended(this.source,this.currentTime),this}},{key:"isBuffer",value:function(){return this.buffer instanceof AudioBuffer}},{key:"isSource",value:function(){return this.source instanceof AudioBufferSourceNode&&this.source.buffer instanceof AudioBuffer}},{key:"isPaused",value:function(){return this.paused}},{key:"fadeIn",value:function(t){if(void 0===t)return this.envelopegenerator.param("attack");this.envelopegenerator.param("attack",t);var e=this.context.currentTime,r=this.param("currentTime"),n=this.param("duration"),i=this.param("playbackRate");return this.envelopegenerator.start(e),this.envelopegenerator.stop(e+(n-r)/i,!0),this}},{key:"fadeOut",value:function(t){if(void 0===t)return this.envelopegenerator.param("release");this.envelopegenerator.param("release",t);var e=this.context.currentTime,r=this.param("currentTime"),n=this.param("duration"),i=this.param("playbackRate");return this.envelopegenerator.start(e),this.envelopegenerator.stop(e+(n-r)/i,!0),this}},{key:"slice",value:function(t,e){if(!this.isBuffer())return null;var r=this.buffer,n=r.sampleRate,i=r.length,o=r.numberOfChannels,s=Math.floor(t*n),a=Math.floor(e*n);(isNaN(s)||s<0)&&(s=0),(isNaN(a)||a>i)&&(a=i);var c=null,u=null;o>0&&(c=this.buffer.getChannelData(0)),o>1&&(u=this.buffer.getChannelData(1));var l=null,f=null,h=null,p=a-s;switch(o){case 1:l=new Float32Array(p);for(var y=s;y<a;y++)l[y-s]=c[y];return(h=this.context.createBuffer(1,p,n)).copyToChannel(l,0),h;case 2:l=new Float32Array(p),f=new Float32Array(p);for(var v=s;v<a;v++)l[v-s]=c[v],f[v-s]=u[v];return(h=this.context.createBuffer(2,p,n)).copyToChannel(l,0),h.copyToChannel(f,1),h;default:return null}}},{key:"sprite",value:function(t){var e=this;return this.isBuffer()?"[object Object]"!==Object.prototype.toString.call(t)?null:Object.keys(t).reduce((function(r,n){var i=t[n];return Array.isArray(i)&&2===i.length?(r[n]=e.slice(parseFloat(i[0]),parseFloat(i[1])),r):r}),{}):null}},{key:"params",value:function(){var t=vn(mn(s.prototype),"params",this).call(this);return t.audio={playbackrate:this.isSource()?this.source.playbackRate.value:1,vocalcanceler:{depth:this.vocalcanceler.param("depth")}},t}},{key:"toString",value:function(){return"[AudioModule]"}}],r&&yn(e.prototype,r),s}(Mr);function wn(t){return wn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wn(t)}function Sn(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return On(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?On(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function On(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function An(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function kn(t,e,r){return kn="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=jn(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},kn(t,e,r||t)}function Tn(t,e){return Tn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Tn(t,e)}function En(t,e){if(e&&("object"===wn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function jn(t){return jn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},jn(t)}function Rn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Pn=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Tn(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=jn(n);if(i){var r=jn(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return En(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).source=null,r.media=null,r.ext="",r.mse=null,r.sb=null,r.file="",r.mimeType="",r.playbackRate=1,r.controls=!1,r.loop=!1,r.muted=!1,r.autoplay=!1,r.listeners={},r}return e=s,r=[{key:"setup",value:function(t,e,r,n){var i=this;if(this.envelopegenerator.setGenerator(0),this.envelopegenerator.param({attack:0,decay:.01,sustain:1,release:.01}),"[object Object]"===Object.prototype.toString.call(arguments[0])){var o=arguments[0];"media"in o&&(t=o.media),"formats"in o&&(e=o.formats),"listeners"in o&&(r=o.listeners),"autoplay"in o&&(n=o.autoplay)}var a="";if(t instanceof HTMLAudioElement)a=s.AUDIO;else{if(!(t instanceof HTMLVideoElement))return this;a=s.VIDEO}this.media=t,Array.isArray(e)||(e=[e]);var c,u=Sn(e);try{for(u.s();!(c=u.n()).done;){var l=c.value,f="".concat(a,"/").concat(String(l).toLowerCase());if(/^(?:maybe|probably)/.test(this.media.canPlayType(f))){this.ext=l;break}}}catch(t){u.e(t)}finally{u.f()}if("[object Object]"===Object.prototype.toString.call(r))for(var h in r)this.listeners[h.toLowerCase()]="[object Function]"===Object.prototype.toString.call(r[h])?r[h]:function(){};for(var p in this.autoplay=Boolean(n),!this.autoplay||this.source instanceof MediaElementAudioSourceNode||(this.source=this.context.createMediaElementSource(this.media)),this.autoplay&&this.media.src&&this.context.resume().then((function(){i.start(i.media.currentTime)})).catch((function(){throw new Error("Autoplay is failed")})),this.media.addEventListener("loadstart",(function(t){i.source instanceof MediaElementAudioSourceNode||(i.source=i.context.createMediaElementSource(i.media)),"loadstart"in i.listeners&&i.listeners.loadstart(t)}),!1),this.media.addEventListener("ended",(function(t){i.media.pause(),i.off(i.context.currentTime),i.analyser.stop("time"),i.analyser.stop("fft"),i.processor.disconnect(0),i.processor.onaudioprocess=null,"ended"in i.listeners&&i.listeners.ended(t)}),!1),this.listeners)this.media.addEventListener(p,(function(t){i.listeners[t.type.toLowerCase()](t)}),!1);return this}},{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n,i=String(t).replace(/-/g,"").toLowerCase();if("mastervolume"===i&&(n=kn(jn(s.prototype),"param",this).call(this,i,e)),void 0!==n)return n;var o=null,a=null,c=null;switch(i){case"playbackrate":if(void 0===e)return this.media instanceof HTMLMediaElement?this.media.playbackRate:this.playbackRate;if((o=parseFloat(e))>=(a=.5)){this.media instanceof HTMLMediaElement&&(this.media.playbackRate=o),this.playbackRate=o;var u=this.context.currentTime,l=this.param("currentTime"),f=this.param("duration");this.envelopegenerator.start(u),isFinite(f)&&this.envelopegenerator.stop(u+(f-l)/o,!0)}break;case"currenttime":if(void 0===e)return this.media instanceof HTMLMediaElement?this.media.currentTime:0;if(this.media instanceof HTMLMediaElement&&(o=parseFloat(e),a=0,c=this.media.duration,o>=a&&o<=c)){this.media.currentTime=o;var h=this.context.currentTime,p=this.param("duration"),y=this.param("playbackRate");this.envelopegenerator.start(h),isFinite(p)&&this.envelopegenerator.stop(h+(p-o)/y,!0)}break;case"loop":case"muted":case"controls":if(void 0===e)return this.media instanceof HTMLMediaElement?this.media[i]:this[i];this.media instanceof HTMLMediaElement&&(this.media[i]=Boolean(e)),this[i]=Boolean(e);break;case"width":case"height":if(void 0===e)return this.media instanceof HTMLVideoElement?this.media[i]:0;(o=parseInt(e,10))>=(a=0)&&this.media instanceof HTMLVideoElement&&(this.media[i]=o);break;case"duration":return this.media&&this.media.duration?this.media.duration:0;case"channels":return this.source instanceof MediaElementAudioSourceNode?this.source.channelCount:0}}return this}},{key:"ready",value:function(t,e){var r=String(t);this.mse&&"open"===this.mse.readyState&&(this.mse.endOfStream(),window.URL.revokeObjectURL(this.media.src),this.mse.removeEventListener("sourceopen",this.onSourceOpen,!1),this.mse.removeEventListener("sourceended",this.onSourceEnded,!1),this.mse.removeEventListener("sourceclose",this.onSourceClose,!1),this.sb.removeEventListener("updateend",this.onSourceBufferUpdateEnd,!1),this.sb.removeEventListener("error",this.onSourceBufferError,!1));try{if(e){if(!MediaSource||!MediaSource.isTypeSupported(e))throw new Error("This Browser does not support `MediaSource` or MIME type");this.media.removeAttribute("src"),this.media.load(),this.mse=new MediaSource,this.media.src=window.URL.createObjectURL(this.mse),this.mimeType=e,this.file=r,this.onSourceOpen=this.onSourceOpen.bind(this),this.onSourceEnded=this.onSourceEnded.bind(this),this.onSourceClose=this.onSourceClose.bind(this),this.mse.addEventListener("sourceopen",this.onSourceOpen,!1),this.mse.addEventListener("sourceended",this.onSourceEnded,!1),this.mse.addEventListener("sourceclose",this.onSourceClose,!1)}else-1!==r.indexOf("data:")||-1!==r.indexOf("blob:")||""===this.ext?this.media.src=r:this.media.src="".concat(r,".").concat(this.ext)}catch(t){throw new Error(t.message)}return this}},{key:"start",value:function(t,e,r){var n=this;return this.source instanceof MediaElementAudioSourceNode&&(this.envelopegenerator.ready(0,this.source,this.processor),this.connect(this.processor,e),this.media.play().then((function(){var e=n.context.currentTime,i=parseFloat(t);n.media.currentTime=i>=0&&i<=n.media.duration?i:0,n.media.playbackRate=n.playbackRate,n.media.controls=n.controls,n.media.loop=n.loop,n.media.muted=n.muted,n.envelopegenerator.start(e),isFinite(n.media.duration)&&n.envelopegenerator.stop(e+(n.media.duration-i)/n.media.playbackRate,!0),n.on(e),n.analyser.start("time"),n.analyser.start("fft");var o=n.processor.bufferSize;"[object Function]"===Object.prototype.toString.call(r)?n.processor.onaudioprocess=r:n.processor.onaudioprocess=function(t){for(var e=t.inputBuffer.getChannelData(0),r=t.inputBuffer.getChannelData(1),i=t.outputBuffer.getChannelData(0),s=t.outputBuffer.getChannelData(1),a=0;a<o;a++)i[a]=n.vocalcanceler.start(e[a],r[a]),s[a]=n.vocalcanceler.start(r[a],e[a])}})).catch((function(){n.stop((function(){n.autoplay&&(n.media.muted=n.muted=!0,n.media.volume=0),n.start(t,e,r)}),(function(){}))}))),this}},{key:"stop",value:function(t,e){var r=this;return this.source instanceof MediaElementAudioSourceNode&&this.media.play().then((function(){return r.media.pause(),r.off(r.context.currentTime),r.analyser.stop("time"),r.analyser.stop("fft"),r.processor.disconnect(0),r.processor.onaudioprocess=null,"[object Function]"===Object.prototype.toString.call(t)&&t(),Promise.resolve()})).catch((function(t){return"[object Function]"===Object.prototype.toString.call(e)&&e(t),Promise.reject(t)})),this}},{key:"get",value:function(){return this.source}},{key:"toggle",value:function(t,e,r){return this.media.paused?this.start(t,e,r):this.stop(),this}},{key:"isMedia",value:function(){return this.media instanceof HTMLMediaElement}},{key:"isSource",value:function(){return this.source instanceof MediaElementAudioSourceNode}},{key:"isPaused",value:function(){return!(this.media instanceof HTMLMediaElement)||this.media.paused}},{key:"onSourceOpen",value:function(t){var e=this;this.sb=this.mse.addSourceBuffer(this.mimeType),this.sb.mode="sequence",this.onSourceBufferUpdateEnd=this.onSourceBufferUpdateEnd.bind(this),this.onSourceBufferError=this.onSourceBufferError.bind(this),this.sb.addEventListener("updateend",this.onSourceBufferUpdateEnd,!1),this.sb.addEventListener("error",this.onSourceBufferError,!1),"sourceopen"in this.listeners&&this.listeners.sourceopen(t);var r=new Request(this.file);fetch(r).then((function(t){return t.arrayBuffer()})).then((function(t){e.sb.appendBuffer(t)})).catch((function(r){"error"in e.listeners&&e.listeners.error(t,r)}))}},{key:"onSourceEnded",value:function(t){"sourceended"in this.listeners&&this.listeners.sourceended(t)}},{key:"onSourceClose",value:function(t){"sourceclose"in this.listeners&&this.listeners.sourceclose(t)}},{key:"onSourceBufferUpdateEnd",value:function(t){"updateend"in this.listeners&&this.listeners.updateend(t)}},{key:"onSourceBufferError",value:function(t){"error"in this.listeners&&this.listeners.error(t)}},{key:"params",value:function(){var t=kn(jn(s.prototype),"params",this).call(this);return t.media={playbackrate:this.playbackRate,vocalcanceler:{depth:this.vocalcanceler.param("depth")}},delete t.audio,t}},{key:"requestPictureInPicture",value:function(){return this.media instanceof HTMLVideoElement&&"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled?this.media.disablePictureInPicture||0===this.media.readyState||this.media===document.pictureInPictureElement?Promise.reject():this.media.requestPictureInPicture():Promise.reject()}},{key:"exitPictureInPicture",value:function(){return this.media instanceof HTMLVideoElement&&"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled?this.media.disablePictureInPicture||0===this.media.readyState||this.media!==document.pictureInPictureElement?Promise.reject():document.exitPictureInPicture():Promise.reject()}},{key:"toString",value:function(){return"[MediaModule]"}}],r&&An(e.prototype,r),s}(gn);function xn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}Rn(Pn,"AUDIO","audio"),Rn(Pn,"VIDEO","video");var _n=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.level=0}var e,r;return e=t,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null;if("level"===n){if(void 0===e)return this.level;o=1,(i=parseFloat(e))>=0&&i<=o&&(this.level=i)}}return this}},{key:"start",value:function(t){return Math.abs(parseFloat(t))>this.level?t:0}},{key:"toString",value:function(){return"[StreamModule NoiseGate]"}}],r&&xn(e.prototype,r),t}();function Mn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var Cn=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.threshold=0}var e,r,n;return e=t,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null;if("threshold"===n){if(void 0===e)return this.threshold;o=1,(i=parseFloat(e))>=0&&i<=o&&(this.threshold=i)}}return this}},{key:"start",value:function(e,r,n){if(this.threshold>0){var i=new Float32Array(e),o=new Float32Array(n),s=new Float32Array(n),a=new Float32Array(n),c=new Float32Array(n),u=new Float32Array(n);t.FFT(i,o,n);for(var l=0;l<n;l++)c[l]=Math.sqrt(Math.pow(i[l],2)+Math.pow(o[l],2)),0!==i[l]&&0!==o[l]&&(u[l]=Math.atan2(o[l],i[l])),c[l]-=this.threshold,c[l]<0&&(c[l]=0),s[l]=c[l]*Math.cos(u[l]),a[l]=c[l]*Math.sin(u[l]);t.IFFT(s,a,n),r.set(s)}else r.set(e);return this}},{key:"toString",value:function(){return"[StreamModule NoiseSuppressor]"}}],n=[{key:"FFT",value:function(t,e,r){for(var n=function(t){return Math.pow(2,t)},i=new Float32Array(r),o=Math.log2(r),s=1;s<=o;s++)for(var a=0;a<n(s-1);a++)for(var c=o-s,u=0;u<n(c);u++){var l=a*n(c+1)+u,f=n(c)+l,h=u*n(s-1),p=t[l],y=e[l],v=t[f],d=e[f],b=Math.cos(2*Math.PI*h/r),m=-1*Math.sin(2*Math.PI*h/r);s<o?(t[l]=p+v,e[l]=y+d,t[f]=b*(p-v)-m*(y-d),e[f]=b*(y-d)+m*(p-v)):(t[l]=p+v,e[l]=y+d,t[f]=p-v,e[f]=y-d)}for(var g=1;g<=o;g++)for(var w=o-g,S=0;S<n(g-1);S++)i[n(g-1)+S]=i[S]+n(w);for(var O=0;O<r;O++)if(!(i[O]<=O)){var A=t[i[O]],k=e[i[O]];t[i[O]]=t[O],e[i[O]]=e[O],t[O]=A,e[O]=k}}},{key:"IFFT",value:function(t,e,r){for(var n=function(t){return Math.pow(2,t)},i=new Float32Array(r),o=Math.log2(r),s=1;s<=o;s++)for(var a=0;a<n(s-1);a++)for(var c=o-s,u=0;u<n(c);u++){var l=a*n(c+1)+u,f=n(c)+l,h=u*n(s-1),p=t[l],y=e[l],v=t[f],d=e[f],b=Math.cos(2*Math.PI*h/r),m=Math.sin(2*Math.PI*h/r);s<o?(t[l]=p+v,e[l]=y+d,t[f]=b*(p-v)-m*(y-d),e[f]=b*(y-d)+m*(p-v)):(t[l]=p+v,e[l]=y+d,t[f]=p-v,e[f]=y-d)}for(var g=1;g<=o;g++)for(var w=o-g,S=0;S<n(g-1);S++)i[n(g-1)+S]=i[S]+n(w);for(var O=0;O<r;O++)if(!(i[O]<=O)){var A=t[i[O]],k=e[i[O]];t[i[O]]=t[O],e[i[O]]=e[O],t[O]=A,e[O]=k}for(var T=0;T<r;T++)t[T]/=r,e[T]/=r}}],r&&Mn(e.prototype,r),n&&Mn(e,n),t}();function Fn(t){return Fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fn(t)}function In(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Nn(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Nn(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Nn(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Ln(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Dn(t,e,r){return Dn="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=qn(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},Dn(t,e,r||t)}function Bn(t,e){return Bn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Bn(t,e)}function Un(t,e){if(e&&("object"===Fn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function qn(t){return qn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},qn(t)}var Vn=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Bn(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=qn(n);if(i){var r=qn(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Un(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).sources=[],r.stream=null,r.constraints={audio:!0,video:!1},r.callbacks={stream:function(){},error:function(){}},r.each=!1,r.output=!0,r.isStop=!0,r.noisegate=new _n,r.noisesuppressor=new Cn,r}return e=s,r=[{key:"setup",value:function(t,e,r){return"[object Object]"===Object.prototype.toString.call(t)&&(this.constraints=t),"[object Function]"===Object.prototype.toString.call(e)&&(this.callbacks.stream=e),"[object Function]"===Object.prototype.toString.call(r)&&(this.callbacks.error=r),this}},{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=Dn(qn(s.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;switch(n){case"each":if(void 0===e)return this.each;this.each=Boolean(e);break;case"output":if(void 0===e)return this.output;this.output=Boolean(e)}}return this}},{key:"ready",value:function(t){var e=this;return navigator.mediaDevices&&navigator.mediaDevices.getUserMedia&&window.MediaStream?(this.isStop=!1,t instanceof MediaStream?(this.stream=t,Promise.resolve()):navigator.mediaDevices.getUserMedia(this.constraints).then((function(t){e.isStop||(e.stream=t,e.callbacks.stream(t))})).catch((function(t){e.callbacks.error(t)}))):Promise.reject("Cannot use WebRTC.")}},{key:"start",value:function(t,e){var r=this;if(null===this.stream)return this;var n=this.processor.bufferSize,i=!1;if(this.each)for(var o=this.stream.getAudioTracks(),s=0,a=o.length;s<a;s++)this.sources[s]=this.context.createMediaStreamTrackSource(o[s]),this.sources[s].connect(this.processor),this.connect(this.processor,t);else this.sources[0]=this.context.createMediaStreamSource(this.stream),this.sources[0].connect(this.processor),this.connect(this.processor,t);return this.output||(this.mastervolume.disconnect(0),this.mastervolume.connect(this.analyser.input),this.mastervolume.connect(this.recorder.processor),this.recorder.processor.connect(this.context.destination),this.mastervolume.connect(this.session.sender),this.session.sender.connect(this.context.destination)),this.on(this.context.currentTime),i||(this.analyser.start("time"),this.analyser.start("fft"),i=!0),"[object Function]"===Object.prototype.toString.call(e)?this.processor.onaudioprocess=e:this.processor.onaudioprocess=function(t){for(var e=t.inputBuffer.getChannelData(0),i=t.inputBuffer.getChannelData(1),o=t.outputBuffer.getChannelData(0),s=t.outputBuffer.getChannelData(1),a=0;a<n;a++)o[a]=r.noisegate.start(e[a]),s[a]=r.noisegate.start(i[a]);r.noisesuppressor.start(e,o,n),r.noisesuppressor.start(i,s,n)},this}},{key:"stop",value:function(){return this.sources.length=0,this.off(this.context.currentTime,!0),this.analyser.stop("time"),this.analyser.stop("fft"),this.processor.disconnect(0),this.processor.onaudioprocess=null,this.isStop=!0,this}},{key:"get",value:function(t){var e=parseInt(t,10);return e>=0&&e<this.sources.length?this.sources[e]:this.sources}},{key:"getStream",value:function(){return this.stream}},{key:"toggle",value:function(t,e){return this.isStreaming()?this.stop():this.start(t,e),this}},{key:"clear",value:function(){return this.stop(),this.clearAudio(),this.clearVideo(),this.stream=null,this}},{key:"clearAudio",value:function(){if(null===this.stream)return this;this.stop();var t,e=In(this.stream.getAudioTracks());try{for(e.s();!(t=e.n()).done;)t.value.stop()}catch(t){e.e(t)}finally{e.f()}return this}},{key:"clearVideo",value:function(){if(null===this.stream)return this;this.stop();var t,e=In(this.stream.getVideoTracks());try{for(e.s();!(t=e.n()).done;)t.value.stop()}catch(t){e.e(t)}finally{e.f()}return this.stream=null,this}},{key:"devices",value:function(){return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?navigator.mediaDevices.enumerateDevices():Promise.reject("No devices.")}},{key:"isStreaming",value:function(){return!this.isStop}},{key:"params",value:function(){var t=Dn(qn(s.prototype),"params",this).call(this);return t.stream={output:this.output,noisegate:{level:this.noisegate.param("level")},noisesuppressor:{threshold:this.noisesuppressor.param("threshold")}},t}},{key:"toString",value:function(){return"[StreamModule]"}}],r&&Ln(e.prototype,r),s}(Mr);function Gn(t){return Gn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gn(t)}function zn(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Xn(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Xn(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Xn(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Wn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Hn(t,e){return Hn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Hn(t,e)}function Yn(t,e){if(e&&("object"===Gn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Qn(t){return Qn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Qn(t)}var Zn=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Hn(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Qn(n);if(i){var r=Qn(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Yn(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).sources=[],r.isAnalyser=!1,r}return e=s,r=[{key:"mix",value:function(t){var e=this;Array.isArray(t)||(t=[t]),this.sources=t;var r,n=zn(this.sources);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(!(i instanceof Wr||i instanceof en||i instanceof gn||i instanceof Pn||i instanceof Vn))return this;var o=this.context.currentTime;this.off(o,!1),i.analyser.stop("time"),i.analyser.stop("fft"),i.isAnalyser=!1,i.recorder.stop(),i.session.close(),i.processor.disconnect(0),i.processor.connect(this.processor)}}catch(t){n.e(t)}finally{n.f()}this.connect(this.processor);var s=this.context.currentTime;return this.on(s),this.isAnalyser||(this.analyser.start("time"),this.analyser.start("fft"),this.isAnalyser=!0),this.processor.onaudioprocess=function(r){var n,i=r.inputBuffer.getChannelData(0),o=r.inputBuffer.getChannelData(1),s=r.outputBuffer.getChannelData(0),a=r.outputBuffer.getChannelData(1),c=!1,u=zn(t);try{for(u.s();!(n=u.n()).done;){var l=n.value;(l instanceof Wr&&l.envelopegenerator.isStop()||l instanceof en&&l.isStop||l instanceof gn&&l.paused||l instanceof Pn&&l.media.paused||l instanceof Vn&&l.isStop)&&(c=!0)}}catch(t){u.e(t)}finally{u.f()}if(c){var f=e.context.currentTime;e.on(f,!0),e.analyser.stop("time"),e.analyser.stop("fft"),e.isAnalyser=!1,e.processor.disconnect(0),e.processor.onaudioprocess=null}else s.set(i),a.set(o)},this}},{key:"get",value:function(t){var e=parseInt(t,10);return e>=0&&e<this.sources.length?this.sources[e]:this.sources}},{key:"toString",value:function(){return"[MixerModule]"}}],r&&Wn(e.prototype,r),s}(Mr);function $n(t){return $n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$n(t)}function Jn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Kn(t,e){return Kn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Kn(t,e)}function ti(t,e){if(e&&("object"===$n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function ei(t){return ei=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ei(t)}var ri=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Kn(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=ei(n);if(i){var r=ei(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return ti(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).envelopegenerator.setGenerator(0),r.processor=null,r.name="",r.options={},r.moduleURL="",r.promise=null,r.map=null,r.runAnalyser=!1,r}return e=s,r=[{key:"setup",value:function(t,e){return this.name=String(t),"[object Object]"===Object.prototype.toString.call(e)&&(this.options=e),window.AudioWorkletNode||(this.processor=this.context.createScriptProcessor(this.bufferSize,Mr.NUMBER_OF_INPUTS,Mr.NUMBER_OF_OUTPUTS),this.map=new Map),this}},{key:"ready",value:function(t,e){var r=this;return window.AudioWorkletNode?(this.moduleURL=String(t),"[object Object]"===Object.prototype.toString.call(e)?this.promise=this.context.audioWorklet.addModule(this.moduleURL,e):this.promise=this.context.audioWorklet.addModule(this.moduleURL),this.promise.then((function(){Object.keys(r.options).length>0?r.processor=new AudioWorkletNode(r.context,r.name,r.options):r.processor=new AudioWorkletNode(r.context,r.name)}))):Promise.reject("Cannot use AudioWorklet")}},{key:"start",value:function(t,e){var r=this.context.currentTime;return this.envelopegenerator.clear(!0),this.processor.disconnect(0),this.processor.onaudioprocess instanceof ScriptProcessorNode&&(this.processor.onaudioprocess=null),this.connect(this.envelopegenerator.getGenerator(0),e),this.envelopegenerator.ready(0,this.processor),this.envelopegenerator.start(r),this.runAnalyser||(this.analyser.start("time"),this.analyser.start("fft"),this.runAnalyser=!0),this.on(r),this.processor instanceof ScriptProcessorNode&&"[object Function]"===Object.prototype.toString.call(t)&&(this.processor.onaudioprocess=t),this}},{key:"stop",value:function(t){var e=this.context.currentTime;return this.processor.disconnect(0),this.envelopegenerator.stop(e),this.off(e),this.processor instanceof ScriptProcessorNode&&"[object Function]"===Object.prototype.toString.call(t)&&(this.processor.onaudioprocess=t),this}},{key:"postMessage",value:function(t){return this.processor instanceof AudioWorkletNode&&this.processor.port.postMessage(t),this}},{key:"onMessage",value:function(t){return this.processor instanceof AudioWorkletNode&&("[object Function]"!==Object.prototype.toString.call(t)&&null!==t||(this.processor.port.onmessage=t)),this}},{key:"onMessageError",value:function(t){return this.processor instanceof AudioWorkletNode&&("[object Function]"!==Object.prototype.toString.call(t)&&null!==t||(this.processor.port.onmessageerror=t)),this}},{key:"map",value:function(){return this.processor instanceof AudioWorkletNode?this.processor.parameters:this.map}},{key:"param",value:function(t){return this.processor instanceof AudioWorkletNode?this.processor.parameters.get(t):null}},{key:"get",value:function(){return this.processor}},{key:"toString",value:function(){return"[ProcessorModule]"}}],r&&Jn(e.prototype,r),s}(Mr);function ni(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var ii=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.context=e,this.midiAccess=null,this.inputs=[],this.outputs=[]}var e,r;return e=t,(r=[{key:"setup",value:function(t,e,r){var n=this;if(!navigator.requestMIDIAccess)throw new Error("Cannot use Web MIDI API.");return navigator.requestMIDIAccess({sysex:Boolean(t)}).then((function(t){if(n.midiAccess=t,"[object Function]"===Object.prototype.toString.call(t))n.inputs=t.inputs(),n.outputs=t.outputs();else{for(var r=t.inputs.values(),i=t.outputs.values(),o=r.next();!o.done;o=r.next())n.inputs.push(o.value);for(var s=i.next();!s.done;s=i.next())n.outputs.push(s.value)}"[object Function]"===Object.prototype.toString.call(e)&&e(n.midiAccess,n.inputs,n.outputs)})).catch((function(t){"[object Function]"===Object.prototype.toString.call(r)&&r(t)})),this}},{key:"get",value:function(){return this.midiAccess}},{key:"toString",value:function(){return"[MIDI]"}}])&&ni(e.prototype,r),t}();function oi(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var si=new Map([["T","TEMPO"],["O","OCTAVE"],["C","NOTE"],["D","NOTE"],["E","NOTE"],["F","NOTE"],["G","NOTE"],["A","NOTE"],["B","NOTE"],["+","NOTE"],["-","NOTE"],["#","NOTE"],["R","REST"],["0","NUMBER"],["1","NUMBER"],["2","NUMBER"],["3","NUMBER"],["4","NUMBER"],["5","NUMBER"],["6","NUMBER"],["7","NUMBER"],["8","NUMBER"],["9","NUMBER"],[".","NUMBER"],["&","TIE"],[" ","SPACE"],[void 0,"EOS"]]),ai={TEMPO:1,OCTAVE:2,NOTE:3,REST:4,NUMBER:5,TIE:6,SPACE:7,EOS:8,UNKNOWN:9},ci=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.type=e,this.token=r,this.value=parseInt(r,10)}var e,r;return e=t,(r=[{key:"getType",value:function(){return this.type||null}},{key:"getToken",value:function(){return this.token}},{key:"getValue",value:function(){return isNaN(this.value)?null:this.value}}])&&oi(e.prototype,r),t}();function ui(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var li=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.tokens="string"==typeof e?e.trim().toUpperCase().split("").reverse():[],this.notes=[],this.numbers=[]}var e,r;return e=t,(r=[{key:"get",value:function(){for(var t=this.tokens.pop();ai[si.get(t)]===ai.SPACE;)t=this.tokens.pop();if(ai[si.get(t)]===ai.EOS)return new ci(ai.EOS,t);switch(this.notes.length=0,this.numbers.length=0,ai[si.get(t)]){case ai.TEMPO:return new ci(ai.TEMPO,t);case ai.OCTAVE:return new ci(ai.OCTAVE,t);case ai.NOTE:for(this.notes.push(t),t=this.tokens.pop();ai[si.get(t)]===ai.NOTE;)this.notes.push(t),t=this.tokens.pop();return this.tokens.push(t),new ci(ai.NOTE,this.notes.join(""));case ai.REST:return new ci(ai.REST,t);case ai.NUMBER:for(this.numbers.push(t),t=this.tokens.pop();ai[si.get(t)]===ai.NUMBER;)this.numbers.push(t),t=this.tokens.pop();return this.tokens.push(t),new ci(ai.NUMBER,this.numbers.join(""));case ai.TIE:return new ci(ai.TIE,t);default:return new ci(ai.UNKNOWN,t)}}}])&&ui(e.prototype,r),t}();function fi(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var hi=function(){function t(e,r,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.operator=e,this.left=r,this.right=n}var e,r;return e=t,(r=[{key:"concat",value:function(t){this.right=t}},{key:"getOperator",value:function(){return this.operator}},{key:"getLeft",value:function(){return this.left}},{key:"getRight",value:function(){return this.right}},{key:"toString",value:function(){for(var e="",r=0;r<t.indent;r++)e+=" ";return t.indent++,"\n ".concat(e," ").concat(this.operator.getToken(),"\n ").concat(e," /\\\n ").concat(e).concat(null!==this.left?this.left.getOperator().getToken():"","\n ").concat(e).concat(null!==this.right&&void 0!==this.right.getOperator().getToken()?this.toString.call(this.right):"EOS","\n ")}}])&&fi(e.prototype,r),t}();function pi(t){return pi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pi(t)}function yi(t,e){if(e&&("object"===pi(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function vi(t){var e="function"==typeof Map?new Map:void 0;return vi=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return di(t,arguments,gi(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),mi(n,t)},vi(t)}function di(t,e,r){return di=bi()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&mi(i,r.prototype),i},di.apply(null,arguments)}function bi(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function mi(t,e){return mi=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},mi(t,e)}function gi(t){return gi=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},gi(t)}function wi(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Si(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:0,enumerable:!0,configurable:!0,writable:!0}):t[e]=0}(hi,"indent");var Oi=function(){function t(e){wi(this,t),this.tokenizer=e,this.syntaxTree=[]}var e,r;return e=t,(r=[{key:"parse",value:function(){for(var t=this.tokenizer.get(),e=this.tokenizer.get();;){switch(t.getType()){case ai.TEMPO:if(e.getType()===ai.NUMBER){var r=new hi(e,null,null),n=new hi(t,r,null);this.syntaxTree.push(n);break}return new Ai(Ai.ERRORS.TEMPO,t);case ai.OCTAVE:if(this.syntaxTree.length>0&&e.getType()===ai.NUMBER){var i=new hi(e,null,null),o=new hi(t,i,null);this.syntaxTree[this.syntaxTree.length-1].concat(o),this.syntaxTree.push(o);break}return new Ai(Ai.ERRORS.OCTAVE,t);case ai.NOTE:if(this.syntaxTree.length>0&&e.getType()===ai.NUMBER){var s=new hi(e,null,null),a=new hi(t,s,null);this.syntaxTree[this.syntaxTree.length-1].concat(a),this.syntaxTree.push(a);break}return new Ai(Ai.ERRORS.NOTE,t);case ai.REST:if(this.syntaxTree.length>0&&e.getType()===ai.NUMBER){var c=new hi(e,null,null),u=new hi(t,c,null);this.syntaxTree[this.syntaxTree.length-1].concat(u),this.syntaxTree.push(u);break}return new Ai(Ai.ERRORS.REST,t);case ai.NUMBER:break;case ai.TIE:if(this.syntaxTree.length>0){var l=new hi(t,null,null);this.syntaxTree[this.syntaxTree.length-1].concat(l),this.syntaxTree.push(l);break}return new Ai(Ai.ERRORS.TIE,t);case ai.EOS:if(this.syntaxTree.length>0){var f=new hi(t,null,null);this.syntaxTree[this.syntaxTree.length-1].concat(f),this.syntaxTree.push(f)}else{var h=new hi(t,null,null);this.syntaxTree.push(h)}return this.syntaxTree;default:return new Ai(Ai.ERRORS.UNKNOWN,t)}t=e,e=this.tokenizer.get()}}},{key:"free",value:function(){this.syntaxTree.length=0}}])&&Si(e.prototype,r),t}(),Ai=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&mi(t,e)}(i,t);var e,r,n=(e=i,r=bi(),function(){var t,n=gi(e);if(r){var i=gi(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return yi(this,t)});function i(t,e){var r;return wi(this,i),(r=n.call(this,t)).token=e,r.error=t,r}return i}(vi(Error));function ki(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(Ai,"ERRORS",{TEMPO:"tempo",OCTAVE:"octave",NOTE:"note",REST:"rest",TIE:"tie",UNKNOWN:"unknown"});var Ti=function(){function t(e,r,n,i,o,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.note=e,this.indexes=r,this.frequencies=n,this.start=i,this.stop=o,this.duration=s}var e,r;return e=t,(r=[{key:"concat",value:function(t){var e=t.toPlainObject();this.note+="&".concat(e.note),this.duration+=e.duration,this.stop=this.start+this.duration}},{key:"toPlainObject",value:function(){return{note:this.note,indexes:this.indexes,frequencies:this.frequencies,start:this.start,stop:this.stop,duration:this.duration}}}])&&ki(e.prototype,r),t}();function Ei(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function ji(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ri=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.sequences=[],this.treeConstructor=e,this.timeOf4note=0,this.octave=-1,this.currentTime=0}var e,r,n;return e=t,r=[{key:"get",value:function(){var t=this.treeConstructor.parse();this.timeOf4note=0,this.octave=-1,this.currentTime=0;for(var e=t[0];null!==e;){if(!(e instanceof hi))return e instanceof Ai?e:new Ai(Ai.ERRORS.UNKNOWN,null);var r=e.getOperator(),n=r.getType(),i=e.getLeft(),o=e.getRight(),s=null!==i?i.getOperator().getValue():-1;switch(n){case ai.TEMPO:if(s<=0)return new Ai(Ai.ERRORS.TEMPO,r.getToken());this.timeOf4note=60/s,e=o;break;case ai.OCTAVE:if(s<0)return new Ai(Ai.ERRORS.OCTAVE,r.getToken());this.octave=s,e=o;break;case ai.NOTE:case ai.REST:case ai.TIE:var a=this.push(n===ai.TIE?o:e);if(a instanceof Ai)return a;n===ai.TIE?(this.concat(),e=o.getRight()):e=o;break;case ai.EOS:e=o;break;default:return new Ai(Ai.ERRORS.UNKNOWN,null)}}return this.treeConstructor.free(),this.sequences}},{key:"push",value:function(e){var r=e.getLeft(),n=e.getRight();if(null!==r&&null!==n){var i=r.getOperator(),o=n.getOperator();if(!(i instanceof ci||o instanceof ci))return this.push(r),void this.push(n);for(var s=e.getOperator().getToken(),a=i.getValue(),c=i.getToken(),u=[],l=[],f=0,h=s.length;f<h;f++){var p=s.charAt(f),y=t.computeIndex(this.octave,p);switch(s.charAt(f+1)){case t.HALF_UP:case t.SHARP:y++,f++;break;case t.HALF_DOWN:y--,f++}if(y>=u[0]&&(y-=t.EQUAL_TEMPERAMENT),-1!==y&&y<0)return void console.assert();u.push(y)}for(var v=0,d=u;v<d.length;v++){var b=d[v],m=t.computeFrequency(b);if(m<0)return void console.assert();l.push(m)}var g=0;switch(a){case 1:case 2:case 4:case 8:case 16:case 32:case 64:case 128:case 256:var w=t.QUARTER_NOTE/a;c.includes(t.DOT)?g+=w*this.timeOf4note*1.5:g+=w*this.timeOf4note;break;case 6:g+=2*this.timeOf4note/3;break;case 12:g+=this.timeOf4note/3;break;case 18:g+=2*this.timeOf4note/9;break;case 24:g+=.5*this.timeOf4note/3;break;case 36:g+=this.timeOf4note/9;break;case 48:g+=.25*this.timeOf4note/3;break;case 72:g+=.5*this.timeOf4note/9;break;case 96:g+=.125*this.timeOf4note/3;break;case 144:g+=.25*this.timeOf4note/9;break;case 192:g+=.0625*this.timeOf4note/3;break;default:console.assert()}this.sequences.push(new Ti("".concat(s).concat(c),u,l,this.currentTime,this.currentTime+g,g)),this.currentTime+=g}}},{key:"concat",value:function(){var t=this.sequences.pop(),e=this.sequences.pop();e.concat(t),this.sequences.push(e)}}],n=[{key:"computeIndex",value:function(e,r){var n=0;switch(r){case t.C:n=3;break;case t.D:n=5;break;case t.E:n=7;break;case t.F:n=8;break;case t.G:n=10;break;case t.A:n=12;break;case t.B:n=14;break;case t.R:return-1;default:console.assert()}var i=t.EQUAL_TEMPERAMENT*(e-1)+n;return i>=0?i:-1}},{key:"computeFrequency",value:function(e){return e>=0?t.MIN_A*Math.pow(t.FREQUENCY_RATIO,e):0}}],r&&Ei(e.prototype,r),n&&Ei(e,n),t}();function Pi(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function xi(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}ji(Ri,"FREQUENCY_RATIO",Math.pow(2,1/12)),ji(Ri,"MIN_A",27.5),ji(Ri,"EQUAL_TEMPERAMENT",12),ji(Ri,"QUARTER_NOTE",4),ji(Ri,"C","C"),ji(Ri,"D","D"),ji(Ri,"E","E"),ji(Ri,"F","F"),ji(Ri,"G","G"),ji(Ri,"A","A"),ji(Ri,"B","B"),ji(Ri,"R","R"),ji(Ri,"SHARP","#"),ji(Ri,"HALF_UP","+"),ji(Ri,"HALF_DOWN","-"),ji(Ri,"DOT",".");var _i=function(){function t(e,r,n,i){var o=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.source=null,this.mml="",this.previous=null,this.timerid=null,this.currentIndex=0,this.currentPosition=0,this.offset=0,(e instanceof Wr||e instanceof en||e instanceof ln)&&(this.source=e),"string"==typeof r&&(this.mml=r),this.callbacks={start:function(){},stop:function(){},ended:function(){},error:function(){}},"[object Object]"===Object.prototype.toString.call(n)&&Object.keys(n).forEach((function(t){var e=t.toLowerCase();e in o.callbacks&&"[object Function]"===Object.prototype.toString.call(n[e])&&(o.callbacks[e]=n[e])}));var s=parseInt(i,10);!isNaN(s)&&s>=0&&(this.offset=s);var a=new li(r),c=new Oi(a),u=new Ri(c);this.sequences=u.get(),this.sequences instanceof Ai&&this.callbacks.error&&this.callbacks.error(this.sequences)}var e,r;return e=t,(r=[{key:"start",value:function(t,e){var r=this;if(!this.sequences[this.currentIndex])return this.stop(),void this.callbacks.ended();var n=this.sequences[this.currentIndex++].toPlainObject();if(t){var i=this.mml.slice(0,this.currentPosition),o=this.mml.slice(this.currentPosition).replace(n.note,'<span class="x-highlight">'.concat(n.note,"</span>"));this.mml="".concat(i).concat(o),this.currentPosition+=this.mml.slice(this.currentPosition).indexOf("</span>")+"</span>".length}else{var s=this.mml.slice(0,this.currentPosition),a=n.note;this.mml="".concat(s).concat(a),this.currentPosition+=a.length}if(this.source instanceof Wr)this.source.ready(0,n.duration).start(n.frequencies),this.callbacks.start(n);else if(this.source instanceof en){for(var c=0,u=n.indexes.length;c<u;c++)-1!==n.indexes[c]&&this.source.ready(0,n.duration).start(n.indexes[c]+this.offset);this.callbacks.start(n,this.offset)}else this.source instanceof ln&&(this.source.start(e),this.callbacks.start(n));this.timerid=window.setTimeout((function(){r.source instanceof Wr?r.callbacks.stop(n):r.source instanceof en?r.callbacks.stop(n,r.offset):r.source instanceof ln&&(r.source.stop(),r.callbacks.stop(n)),r.previous=n,r.start(t,e)}),1e3*n.duration)}},{key:"stop",value:function(){if(null!==this.previous){if(this.source instanceof Wr)this.source.stop(),this.callbacks.stop(this.previous);else if(this.source instanceof en){var t,e=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Pi(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Pi(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}(this.previous.indexes);try{for(e.s();!(t=e.n()).done;){var r=t.value;-1!==r&&this.source.stop(r+this.offset)}}catch(t){e.e(t)}finally{e.f()}this.callbacks.stop(this.previous,this.offset)}else this.source instanceof ln&&(this.source.stop(),this.callbacks.stop(this.previous));window.clearTimeout(this.timerid),this.timerid=null}}},{key:"getMML",value:function(){return this.mml}},{key:"getSequence",value:function(){return this.sequences}},{key:"hasSequence",value:function(){return this.sequences.length>0}},{key:"paused",value:function(){return null===this.timerid}},{key:"getCurrentIndex",value:function(){return this.currentIndex}},{key:"setCurrentIndex",value:function(t){var e=parseInt(t,10);e>=0&&e<this.sequences.length&&(this.currentIndex=e)}}])&&xi(e.prototype,r),t}();function Mi(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Ci(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ci(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Ci(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Fi(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var Ii=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.context=e,this.parts=[],this.callbacks={start:function(){},stop:function(){},ended:function(){},error:function(){}}}var e,r;return e=t,r=[{key:"setup",value:function(t,e){if(arguments.length>0&&"[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.setup(r,arguments[0][r]);else if(arguments.length>1){var n=String(t).toLowerCase();n in this.callbacks&&"[object Function]"===Object.prototype.toString.call(e)&&(this.callbacks[n]=e)}return this}},{key:"ready",value:function(t,e,r){if(Array.isArray(e)||"string"!=typeof e||(e=[e]),!Array.isArray(e))return this;this.stop(),this.clear(),this.mmls=e;var n,i=Mi(e);try{for(i.s();!(n=i.n()).done;){var o=n.value;this.parts.push(new _i(t,o,this.callbacks,r))}}catch(t){i.e(t)}finally{i.f()}return this}},{key:"start",value:function(t,e,r){var n=parseInt(t,10);return n>=0&&n<this.parts.length&&this.parts[n].start(e,r),this}},{key:"stop",value:function(){var t,e=Mi(this.parts);try{for(e.s();!(t=e.n()).done;)t.value.stop()}catch(t){e.e(t)}finally{e.f()}return this}},{key:"get",value:function(t,e){var r,n=parseInt(t,10),i=[],o=[],s=Mi(this.parts);try{for(s.s();!(r=s.n()).done;){var a=r.value;i.push(a.getMML()),o.push(a.getSequence())}}catch(t){s.e(t)}finally{s.f()}return e?n>=0&&n<this.parts.length?this.parts[n].getMML():i:n>=0&&n<this.parts.length?this.parts[n].getSequence():o}},{key:"toggle",value:function(t,e,r){return this.isPaused()?this.start(t,e,r):this.stop(),this}},{key:"isSequences",value:function(){return this.parts.length>0&&this.parts.every((function(t){return t.hasSequence()}))}},{key:"isPaused",value:function(){return 0===this.parts.length||this.parts.every((function(t){return t.paused()}))}},{key:"currentIndex",value:function(t,e){var r=parseInt(t,10);return r<0||r>=this.parts.length?this:void 0===e?this.parts[r].getCurrentIndex():(this.parts[r].setCurrentIndex(e),this)}},{key:"toABC",value:function(t,e,r,n,i,o){var s="";s+="X:".concat(e||1,"\n"),s+="T:".concat(r||"","\n"),s+="M:".concat(n||"4/4","\n"),s+="L:".concat(i||"1/256","\n"),s+="K:".concat(o||"","\n");var a=t.match(/\s*(?:T\d+)\s*|\s*(?:O\d+)\s*|\s*(?:(?:[CDEFGABR][#+-]?)+(?:256|192|144|128|96|72|64|48|36|32|24|18|16|12|8|6|4|2|1)\.?)(?:&(?:[CDEFGABR][#+-]?)+(?:256|192|144|128|96|72|64|48|36|32|24|18|16|12|8|6|4|2|1)\.?)*\s*/gi);if(null===a)return s;for(var c=null,u=0;a.length>0;){var l=a.shift().trim();if(/T\d+/i.test(l)){var f=parseInt(l.slice(1),10);if(f<=0)return s;s+="Q:1/4=".concat(f,"\n")}else if(/O\d+/i.test(l)){if((c=parseInt(l.slice(1),10))<0)return s}else if(/(?:(?:[CDEFGABR][#+-]?)+)(?:256|192|144|128|96|72|64|48|36|32|24|18|16|12|8|6|4|2|1)(?:&(?:[CDEFGABR][#+-]?)+(?:256|192|144|128|96|72|64|48|36|32|24|18|16|12|8|6|4|2|1)\.?)*/i.test(l)){if(null===c)return s;var h=null;h=-1===l.indexOf("&")?[l]:l.split("&");for(var p="";h.length>0;){var y=h.shift(),v="",d=0;switch(parseInt(y.replace(/^.+?(\d+)\.*$/,"$1"),10)){case 1:v=y.replace("1","256");break;case 2:v=y.replace("2","128");break;case 4:v=y.replace("4","64");break;case 8:v=y.replace("8","32");break;case 16:v=y.replace("16","16");break;case 32:v=y.replace("32","8");break;case 64:v=y.replace("64","4");break;case 128:v=y.replace("128","2");break;case 256:v=y.replace("256","1");break;case 6:v="(3".concat(y.replace("6","128")),d=128/3;break;case 12:v="(3".concat(y.replace("12","64")),d=64/3;break;case 18:v="(9".concat(y.replace("18","128")),d=128/9;break;case 24:v="(3".concat(y.replace("24","32")),d=32/3;break;case 36:v="(9".concat(y.replace("36","64")),d=64/9;break;case 48:v="(3".concat(y.replace("48","16")),d=16/3;break;case 72:v="(9".concat(y.replace("72","32")),d=32/9;break;case 96:v="(3".concat(y.replace("96","8")),d=8/3;break;case 144:v="(9".concat(y.replace("144","16")),d=16/9;break;case 192:v="(3".concat(y.replace("192","4")),d=4/3;break;default:return s}if(-1!==v.indexOf(".")&&(v=v.replace(/^(.+?)\d+\.+$/,"$1".concat(1.5*parseInt(v.replace(/^.+?(\d+)\.+$/,"$1"),10)))),-1===v.indexOf("(")?u+=parseInt(v.replace(/^.+?(\d+)\.*$/i,"$1"),10):u+=d,u>=256&&(v+=" | ",u=0),/R/i.test(v))s+="".concat(v," ");else{var b="";switch(c){case 0:b=",,,,";break;case 1:b=",,,";break;case 2:b=",,";break;case 3:b=",";break;case 5:b="'";break;case 6:b="''";break;case 7:b="'''"}var m=v.match(/^(\(\d+)?((?:[CDEFGAB][#+-]?)+)(.*)$/i);if(null===m)return s;var g=m[1]?m[1]:"",w=m[2].length,S=m[3]?m[3]:"",O=0;if(g.length>0&&(v=v.replace(/^(?:\(\d+)?((?:[CDEFGAB][#+-]?)+)(.*)$/i,"$1$2")),1===w)p+="".concat(g).concat(v.slice(0,1)).concat(b).concat(S);else if(2===w&&/[#+-]/.test(v.charAt(1)))p+="".concat(g).concat(v.slice(1,2)).concat(v.slice(0,1)).concat(b).concat(S);else for(;O<w;)0===O&&(p+="".concat(g,"[")),/[#+-]/.test(v.charAt(O+1))?(p+="".concat(v.slice(O+1,O+2)).concat(v.slice(O,O+1)).concat(b),O+=2):(p+="".concat(v.slice(O,O+1)).concat(b),O++),O===w&&(p+="]".concat(S));h.length>0?p+="&":s+="".concat(p," ")}}}}return s.replace(/R/gi,"z").replace(/[#+]/g,"^").replace(/-/g,"_").replace(/&/g,"-").replace(/\s{2}/g," ").trim()}},{key:"clear",value:function(){var t,e=Mi(this.parts);try{for(e.s();!(t=e.n()).done;)t.value.stop()}catch(t){e.e(t)}finally{e.f()}return this.parts.length=0,this}},{key:"toString",value:function(){return"[MML]"}}],r&&Fi(e.prototype,r),t}();function Ni(t,e,r,n,i){if("[object Object]"===Object.prototype.toString.call(arguments[0])){var o=arguments[0];"file"in o&&(t=o.file),"type"in o&&(e=o.type),"success"in o&&(r=o.success),"error"in o&&(n=o.error),"progress"in o&&(i=o.progress)}if(t instanceof Blob){var s=new FileReader;s.onprogress=function(t){"[object Function]"===Object.prototype.toString.call(i)&&i(t)},s.onerror=function(t){if("[object Function]"===Object.prototype.toString.call(n)){var e="";switch(s.error.code){case s.error.NOT_FOUND_ERR:e="NOT_FOUND_ERR";break;case s.error.SECURITY_ERR:e="SECURITY_ERR";break;case s.error.ABORT_ERR:e="ABORT_ERR";break;case s.error.NOT_READABLE_ERR:e="NOT_READABLE_ERR";break;case s.error.ENCODING_ERR:e="ENCODING_ERR";break;default:e="ERR"}n(t,e)}},s.onload=function(t){if("[object Function]"===Object.prototype.toString.call(r)){var e=s.result;"string"!=typeof e||e.includes("data:")||e.indexOf("blob:")||(e=e.replace(/<(\/?script.*?)>/gi,"&lt;$1&gt;")),r(t,e)}},/arraybuffer/i.test(e)?s.readAsArrayBuffer(t):/dataurl/i.test(e)?s.readAsDataURL(t):/text|json/i.test(e)&&s.readAsText(t,"UTF-8")}else"[object Function]"===Object.prototype.toString.call(n)&&n(null,"FILE_IS_NOT_BLOB")}function Li(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Di(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Di(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Di(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Bi,Ui="undefined"!=typeof window?window:{};Ui.AudioContext=Ui.AudioContext||Ui.webkitAudioContext,Ui.MediaSource=Ui.MediaSource||Ui.WebkitMediaSource,Ui.URL=Ui.URL||Ui.webkitURL||Ui.mozURL,Ui.requestAnimationFrame=Ui.requestAnimationFrame||Ui.webkitRequestAnimationFrame||Ui.mozRequestAnimationFrame||function(t){return Ui.setTimeout(t,1e3/60)},Ui.cancelAnimationFrame=Ui.cancelAnimationFrame||Ui.webkitCancelAnimationFrame||Ui.mozCancelAnimationFrame||Ui.clearTimeout;var qi=Boolean(Ui.AudioContext);if(qi){var Vi=new AudioContext;Vi.createScriptProcessor=Vi.createScriptProcessor||Vi.createJavaScriptNode,Vi.createGain=Vi.createGain||Vi.createGainNode,Vi.createDelay=Vi.createDelay||Vi.createDelayNode,Vi.createPeriodicWave=Vi.createPeriodicWave||Vi.createWaveTable;var Gi={oscillator:new Wr(Vi),oneshot:new en(Vi),noise:new ln(Vi),audio:new gn(Vi),media:new Pn(Vi),stream:new Vn(Vi),mixer:new Zn(Vi),processor:new ri(Vi),midi:new ii(Vi),mml:new Ii(Vi)};(Bi=function(t,e){var r=String(t).replace(/-/g,"").toLowerCase();switch(r){case"oscillator":if(void 0===e)return Gi.oscillator;var n=parseInt(e,10);return n>=0&&n<Gi.oscillator.length()?Gi.oscillator.get(n):null;case"oneshot":case"noise":case"audio":case"media":case"stream":case"mixer":case"processor":case"midi":case"mml":return Gi[r];default:return null}}).IS_XSOUND=qi,Bi.SAMPLE_RATE=Vi.sampleRate,Bi.NUMBER_OF_INPUTS=Mr.NUMBER_OF_INPUTS,Bi.NUMBER_OF_OUTPUTS=Mr.NUMBER_OF_OUTPUTS,Bi.FFT=function(t,e,r){for(var n=function(t){return Math.pow(2,t)},i=new Float32Array(r),o=Math.log2(r),s=1;s<=o;s++)for(var a=0;a<n(s-1);a++)for(var c=o-s,u=0;u<n(c);u++){var l=a*n(c+1)+u,f=n(c)+l,h=u*n(s-1),p=t[l],y=e[l],v=t[f],d=e[f],b=Math.cos(2*Math.PI*h/r),m=-1*Math.sin(2*Math.PI*h/r);s<o?(t[l]=p+v,e[l]=y+d,t[f]=b*(p-v)-m*(y-d),e[f]=b*(y-d)+m*(p-v)):(t[l]=p+v,e[l]=y+d,t[f]=p-v,e[f]=y-d)}for(var g=1;g<=o;g++)for(var w=o-g,S=0;S<n(g-1);S++)i[n(g-1)+S]=i[S]+n(w);for(var O=0;O<r;O++)if(!(i[O]<=O)){var A=t[i[O]],k=e[i[O]];t[i[O]]=t[O],e[i[O]]=e[O],t[O]=A,e[O]=k}},Bi.IFFT=function(t,e,r){for(var n=function(t){return Math.pow(2,t)},i=new Float32Array(r),o=Math.log2(r),s=1;s<=o;s++)for(var a=0;a<n(s-1);a++)for(var c=o-s,u=0;u<n(c);u++){var l=a*n(c+1)+u,f=n(c)+l,h=u*n(s-1),p=t[l],y=e[l],v=t[f],d=e[f],b=Math.cos(2*Math.PI*h/r),m=Math.sin(2*Math.PI*h/r);s<o?(t[l]=p+v,e[l]=y+d,t[f]=b*(p-v)-m*(y-d),e[f]=b*(y-d)+m*(p-v)):(t[l]=p+v,e[l]=y+d,t[f]=p-v,e[f]=y-d)}for(var g=1;g<=o;g++)for(var w=o-g,S=0;S<n(g-1);S++)i[n(g-1)+S]=i[S]+n(w);for(var O=0;O<r;O++)if(!(i[O]<=O)){var A=t[i[O]],k=e[i[O]];t[i[O]]=t[O],e[i[O]]=e[O],t[O]=A,e[O]=k}for(var T=0;T<r;T++)t[T]/=r,e[T]/=r},Bi.ajax=function(t,e,r,n,i,o){if("[object Object]"===Object.prototype.toString.call(arguments[0])){var s=arguments[0];"url"in s&&(t=s.url),"type"in s&&(e=s.type),"timeout"in s&&(r=s.timeout),"success"in s&&(n=s.success),"error"in s&&(i=s.error),"progress"in s&&(o=s.progress)}var a="error",c="timeout",u=new XMLHttpRequest,l=parseInt(r,10);u.timeout=l>0?l:6e4,u.ontimeout=function(t){"[object Function]"===Object.prototype.toString.call(i)&&i(t,c)},u.onprogress=function(t){"[object Function]"===Object.prototype.toString.call(o)&&o(t)},u.onerror=function(t){"[object Function]"===Object.prototype.toString.call(i)&&i(t,a)},u.onload=function(t){200===u.status&&"[object Function]"===Object.prototype.toString.call(n)&&n(t,u.response)},u.open("GET",t,!0),u.responseType=/text|arraybuffer|blob|document|json/.test(String(e).toLowerCase())?String(e).toLowerCase():"arraybuffer",u.send(null)},Bi.convertTime=function(t){var e=parseFloat(t);if(e>=0)return{minutes:Math.floor(e/60),seconds:Math.floor(e%60),milliseconds:e-Math.floor(e)}},Bi.decode=function(t,e,r,n){if(t instanceof AudioContext&&e instanceof ArrayBuffer)return"[object Function]"!==Object.prototype.toString.call(r)&&(r=function(){}),"[object Function]"!==Object.prototype.toString.call(n)&&(n=function(){}),t.decodeAudioData(e,r,n)},Bi.exitFullscreen=function(){return document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen?document.msExitFullscreen():document.cancelFullScreen?document.cancelFullScreen():Promise.reject("Cannot exit from full screen.")},Bi.file=function(t,e,r,n,i){if("[object Object]"===Object.prototype.toString.call(arguments[0])){var o=arguments[0];"event"in o&&(t=o.event),"type"in o&&(e=o.type),"success"in o&&(r=o.success),"error"in o&&(n=o.error),"progress"in o&&(i=o.progress)}if(t instanceof Event){var s=null;if("drop"===t.type)t.stopPropagation(),t.preventDefault(),s=t.dataTransfer.files[0];else{if("change"!==t.type||!("files"in t.target))return;s=t.target.files[0]}if(s instanceof File){if(/text/i.test(e)&&!s.type.includes("text"))throw new Error("Please upload text file.");if(/json/i.test(e)&&!s.type.includes("application/json"))throw new Error("Please upload JSON file.");if(/arraybuffer|dataurl/i.test(e)&&!/audio|video/.test(s.type))throw new Error("Please upload audio or video file.");return/objecturl/i.test(e)?window.URL.createObjectURL(s):(Ni({file:s,type:e,success:r,error:n,progress:i}),s)}throw new Error("Please upload file.")}},Bi.requestFullscreen=function(t){return t instanceof Element?t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen?t.msRequestFullscreen():Promise.reject("Cannot change to full screen."):Promise.reject("Invalid argument.")},Bi.read=Ni,Bi.toFrequencies=function(t){var e=Math.pow(2,1/12);Array.isArray(t)||(t=[t]);for(var r=new Array(t.length),n=0,i=t.length;n<i;n++){var o=parseInt(t[n],10);r[n]=o>=0?27.5*Math.pow(e,o):0}return r},Bi.toTextFile=function(t){var e=window.btoa(function(t){for(var e="",r=0,n=t.length;r<n;r++){var i=t.charCodeAt(r);e+=i>255?"&#".concat(i,";"):t.charAt(r)}return e}(String(t)));return"data:text/plain;base64,".concat(e)},Bi.Analyser=q,Bi.Recorder=K,Bi.Session=at,Bi.Effector=pt,Bi.Autopanner=wt,Bi.Chorus=Ft,Bi.Compressor=Ut,Bi.Delay=Wt,Bi.Distortion=Kt,Bi.Equalizer=ue,Bi.Filter=ve,Bi.Flanger=Oe,Bi.Listener=Re,Bi.Panner=Ie,Bi.Phaser=Ve,Bi.PitchShifter=Ye,Bi.Reverb=rr,Bi.Ringmodulator=ur,Bi.Stereo=vr,Bi.Tremolo=Or,Bi.Wah=Pr,Bi.setup=function(){return"running"!==Vi.state?Vi.resume():Promise.reject()},Bi.clone=function(){var t={oscillator:new Wr(Vi),oneshot:new en(Vi),noise:new ln(Vi),audio:new gn(Vi),media:new Pn(Vi),stream:new Vn(Vi),mixer:new Zn(Vi),processor:new ri(Vi),midi:new ii(Vi),mml:new Ii(Vi)},e=function(e,r){var n=String(e).replace(/-/g,"").toLowerCase();switch(n){case"oscillator":if(void 0===r)return t.oscillator;var i=parseInt(r,10);return i>=0&&i<t.oscillator.length()?t.oscillator.get(i):null;case"oneshot":case"noise":case"audio":case"media":case"stream":case"mixer":case"processor":case"midi":case"mml":return t[n];default:return null}};return e.free=function(e){Array.isArray(e)||(e=[e]);var r,n=Li(e);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(null!==i)for(var o in t)i===t[o]&&(t[o]=null)}}catch(t){n.e(t)}finally{n.f()}},e},Bi.free=function(t){Array.isArray(t)||(t=[t]);var e,r=Li(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;if(null!==n)for(var i in Gi)n===Gi[i]&&(Gi[i]=null)}}catch(t){r.e(t)}finally{r.f()}},Bi.noConflict=function(t){return window.X===Bi&&(window.X=void 0),t&&window.XSound===Bi&&(window.XSound=void 0),Bi},Bi.get=function(){return Vi},Bi.getCurrentTime=function(){return Vi.currentTime},Bi.toString=function(){return"[XSound]"};var zi=function t(){Bi.setup().then((function(){})).catch((function(){})),document.removeEventListener("click",t,!0),document.removeEventListener("mousedown",t,!0),document.removeEventListener("mouseup",t,!0),document.removeEventListener("touchstart",t,!0),document.removeEventListener("touchend",t,!0)};document.addEventListener("click",zi,!0),document.addEventListener("mousedown",zi,!0),document.addEventListener("mouseup",zi,!0),document.addEventListener("touchstart",zi,!0),document.addEventListener("touchend",zi,!0)}else(Bi=function(){return null}).IS_XSOUND=qi;Ui.XSound=Bi,Ui.X=Bi,"undefined"!=typeof exports&&(exports.XSound=Bi,exports.X=Bi)})();
2
+ (()=>{"use strict";function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var e=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e)}var r,n;return r=e,(n=[{key:"INPUT",value:function(){}},{key:"OUTPUT",value:function(){}}])&&t(r.prototype,n),e}();function r(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw s}}}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var s=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.sampleRate=e,this.isActive=!1,this.graphics="",this.canvas=null,this.context=null,this.svg=null,this.interval=1e3,this.timerid=null,this.styles={shape:"line",grad:[{offset:0,color:"rgba(0, 128, 255, 1.0)"},{offset:1,color:"rgba(0, 0, 255, 1.0)"}],wave:"rgba(0, 0, 255, 1.0)",grid:"rgba(255, 0, 0, 1.0)",text:"rgba(255, 255, 255, 1.0)",font:{family:"Arial",size:"13px",style:"normal"},width:1.5,cap:"round",join:"miter",top:15,right:30,bottom:15,left:30}}var e,n;return e=t,(n=[{key:"setup",value:function(e){return e instanceof HTMLCanvasElement?(this.graphics=t.CANVAS,this.canvas=e,this.context=this.canvas.getContext("2d")):e instanceof SVGElement&&(this.graphics=t.SVG,this.svg=e),this}},{key:"param",value:function(t,e){var n=String(t).replace(/-/g,"").toLowerCase(),i=null;switch(n){case"interval":if(void 0===e)return this.interval;"auto"===String(e).toLowerCase()?this.interval="auto":(i=parseFloat(e))>=0&&(this.interval=i);break;case"shape":if(void 0===e)return this.styles.shape;"line"!==(i=String(e).toLowerCase())&&"rect"!==i||(this.styles.shape="gradient"!==this.styles.wave?i:"rect");break;case"grad":if(void 0===e)return this.styles.grad;Array.isArray(e)||(e=[e]);var o,s=!1,a=r(e);try{for(a.s();!(o=a.n()).done;){var c=o.value;if(!("offset"in c)||!("color"in c)){s=!0;break}var u=parseFloat(c.offset);if(isNaN(u)||u<0||u>1){s=!0;break}}}catch(t){a.e(t)}finally{a.f()}s||(this.styles.grad=e);break;case"font":if(void 0===e)return this.styles[n];if("[object Object]"===Object.prototype.toString.call(e))for(var l in e)/(?:family|size|style)/i.test(l)&&(this.styles.font[l]=String(e[l]));break;case"wave":case"grid":case"text":case"cap":case"join":if(void 0===e)return this.styles[n];"string"==typeof e&&("wave"===n&&"gradient"===e&&(this.styles.shape="rect"),this.styles[n]=e.toLowerCase());break;case"width":case"top":case"right":case"bottom":case"left":if(void 0===e)return this.styles[n];(i="width"===n?parseFloat(e):parseInt(e,10))>=0&&(this.styles[n]=i)}}},{key:"start",value:function(e,r,n){switch(this.graphics){case t.CANVAS:this.drawOnCanvas(e,r,n);break;case t.SVG:this.drawBySVG(e,r,n)}return this}},{key:"create",value:function(){switch(this.graphics){case t.CANVAS:return this.canvas.toDataURL("image/png").replace("image/png","image/octet-stream");case t.SVG:return this.svg.outerHTML;default:return this}}},{key:"state",value:function(t){return void 0===t?this.isActive:("toggle"===String(t).toLowerCase()?this.isActive=!this.isActive:this.isActive=Boolean(t),this)}},{key:"drawTimeDomainFloat32ArrayOnCanvas",value:function(t,e,n,i,o,s){if(!(t instanceof CanvasRenderingContext2D))return this;if(!(e instanceof Float32Array))return this;var a=parseInt(n,10),c=parseInt(i,10),u=parseInt(o,10);switch(isNaN(a)&&(a=0),isNaN(c)&&(c=0),isNaN(u)&&(u=0),this.styles.shape){case"line":t.strokeStyle=this.styles.wave,t.lineWidth=this.styles.width,t.lineCap=this.styles.cap,t.lineJoin=this.styles.join,t.beginPath();for(var l=0,f=e.length;l<f;l++)if(null==s||l%s==0){var h=l/f*a+this.styles.left,p=(1-e[l])*(c/2)+this.styles.top;0===l?t.moveTo(h+this.styles.width/2,p):t.lineTo(h,p)}t.stroke();break;case"rect":"gradient"!==this.styles.wave&&(t.fillStyle=this.styles.wave);for(var y=0,v=e.length;y<v;y++)if(null==s||y%s==0){var d=y/v*a+this.styles.left,b=e[y]*(c/2)*-1;if("gradient"===this.styles.wave){var m,g=i/2+this.styles.top,w=t.createLinearGradient(0,g,0,g+b),S=r(this.styles.grad);try{for(S.s();!(m=S.n()).done;){var O=m.value;w.addColorStop(O.offset,O.color)}}catch(t){S.e(t)}finally{S.f()}t.fillStyle=w}t.fillRect(d,u,this.styles.width,b)}}return this}},{key:"drawTimeDomainFloat32ArrayBySVG",value:function(e,r,n,i,o,s){var a=parseInt(r,10),c=parseInt(n,10),u=parseInt(i,10);switch(isNaN(a)&&(a=0),isNaN(c)&&(c=0),isNaN(u)&&(u=0),this.styles.shape){case"line":for(var l=document.createElementNS(t.XMLNS,"path"),f="",h=0,p=e.length;h<p;h++)if(null==o||h%o==0){var y=h/p*a+this.styles.left,v=(1-e[h])*(c/2)+this.styles.top;f+=0===h?"M".concat(y+this.styles.width/2," ").concat(v):" L".concat(y," ").concat(v)}return l.setAttribute("d",f),l.setAttribute("stroke",this.styles.wave),l.setAttribute("fill","none"),l.setAttribute("stroke-width",this.styles.width),l.setAttribute("stroke-linecap",this.styles.cap),l.setAttribute("stroke-linejoin",this.styles.join),l;case"rect":var d=null;"gradient"===this.styles.wave&&(d=this.createSVGLinearGradient(s));var b=document.createElementNS(t.XMLNS,"g");null!==d&&b.appendChild(d);for(var m=0,g=e.length;m<g;m++)if(null==o||m%o==0){var w=document.createElementNS(t.XMLNS,"rect"),S=m/g*a+this.styles.left,O=e[m]*(n/2);w.setAttribute("x",S),w.setAttribute("y",u),w.setAttribute("width",this.styles.width),O<0?w.setAttribute("height",-O):(w.setAttribute("height",O),w.setAttribute("transform","rotate(180 ".concat(S+this.styles.width/2," ").concat(u,")"))),w.setAttribute("stroke","none"),w.setAttribute("fill",null===d?this.styles.wave:"url(#".concat(s,")")),b.appendChild(w)}return b;default:return null}}},{key:"createSVGLinearGradient",value:function(e){var n=document.createElementNS(t.XMLNS,"defs"),i=document.createElementNS(t.XMLNS,"linearGradient");i.setAttribute("id",String(e)),i.setAttribute("x1","0%"),i.setAttribute("y1","0%"),i.setAttribute("x2","0%"),i.setAttribute("y2","100%");var o,s=r(this.styles.grad);try{for(s.s();!(o=s.n()).done;){var a=o.value,c=document.createElementNS(t.XMLNS,"stop");c.setAttribute("offset",a.offset),c.setAttribute("stop-color",a.color),i.appendChild(c)}}catch(t){s.e(t)}finally{s.f()}return n.appendChild(i),n}},{key:"createFontString",value:function(){var t=this.styles.font,e=t.size,r=t.style,n=t.family;return"".concat(r," ").concat(e,' "').concat(n,'"')}},{key:"drawOnCanvas",value:function(){return this}},{key:"drawBySVG",value:function(){return this}},{key:"clear",value:function(){if(this.context){var t=this.canvas,e=t.width,r=t.height;this.context.clearRect(0,0,e,r)}return this.svg&&(this.svg.innerHTML=""),this}},{key:"toString",value:function(){return"[SoundModule Analyser Visualizer]"}}])&&i(e.prototype,n),t}();function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function c(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function u(t,e,r){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=p(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},u(t,e,r||t)}function l(t,e){return l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},l(t,e)}function f(t,e){if(e&&("object"===a(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return h(t)}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function p(t){return p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},p(t)}function y(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}o(s,"CANVAS","canvas"),o(s,"SVG","svg"),o(s,"XMLNS","http://www.w3.org/2000/svg"),o(s,"XLINK","http://www.w3.org/1999/xlink"),o(s,"SVG_LINEAR_GRADIENT_ID_TIME_OVERVIEW","svg-linear-gradient-time-overview"),o(s,"SVG_LINEAR_GRADIENT_ID_TIME","svg-linear-gradient-time"),o(s,"SVG_LINEAR_GRADIENT_ID_FFT","svg-linear-gradient-fft");var v=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&l(t,e)}(a,t);var e,r,n,i,o=(n=a,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=p(n);if(i){var r=p(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return f(this,t)});function a(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(e=o.call(this,t)).savedImage=null,e.length=0,e.currentTime="rgba(0, 0, 0, 0.5)",e.sprite="rgba(255, 255, 255, 0.25)",e.plotInterval=.0625,e.textInterval=60,e.isDown=!1,e.mode=a.DRAG_MODE_UPDATE,e.offsetX=0,e.startTime=0,e.endTime=0,e.onStart=e.onStart.bind(h(e)),e.onMove=e.onMove.bind(h(e)),e.onEnd=e.onEnd.bind(h(e)),e}return e=a,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=u(p(a.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;var o=null;switch(n){case"currenttime":if(void 0===e)return this.currentTime;this.currentTime=String(e).toLowerCase();break;case"sprite":if(void 0===e)return this.sprite;this.sprite=String(e).toLowerCase();break;case"plotinterval":case"textinterval":if(void 0===e)return this[n.replace("interval","Interval")];(o=parseFloat(e))>0&&(this[n.replace("interval","Interval")]=o);break;case"mode":if(void 0===e)return this.mode;if(((o=String(e).toLowerCase())===a.DRAG_MODE_UPDATE||o===a.DRAG_MODE_SPRITE)&&(this.mode=o,this.offsetX=0,this.startTime=0,this.endTime=0,this.svg instanceof SVGElement)){var s=this.svg.querySelector(".".concat(a.SVG_SPRITE_CLASS_NAME));s instanceof SVGElement&&this.svg.removeChild(s)}}}return this}},{key:"drawOnCanvas",value:function(t){if(!(this.canvas instanceof HTMLCanvasElement&&this.isActive))return this;var e=this.context,r=this.canvas,n=r.width,i=r.height,o=n-(this.styles.left+this.styles.right),s=i-(this.styles.top+this.styles.bottom),a=Math.floor(s/2)+this.styles.top,c=Math.floor(this.plotInterval*this.sampleRate),u=Math.floor(this.textInterval*this.sampleRate);if(e.clearRect(0,0,n,i),this.drawTimeDomainFloat32ArrayOnCanvas(e,t,o,s,a,c),"none"!==this.styles.grid||"none"!==this.styles.text){for(var l=0,f=t.length;l<f;l++)if(l%u==0){var h=Math.floor(l/f*o)+this.styles.left,p="".concat(Math.floor(l/this.sampleRate/60)," min");"none"!==this.styles.grid&&(e.fillStyle=this.styles.grid,e.fillRect(h,this.styles.top,1,s)),"none"!==this.styles.text&&(e.fillStyle=this.styles.text,e.font=this.createFontString(),e.fillText(p,h-e.measureText(p).width/2,this.styles.top+s+parseInt(this.styles.font.size,10)))}for(var y=0,v=["-1.00","-0.50"," 0.00"," 0.50"," 1.00"];y<v.length;y++){var d=v[y],b=Math.floor(this.styles.left-e.measureText(d).width),m=Math.floor((1-parseFloat(d.trim()))*(s/2))+this.styles.top;"none"!==this.styles.grid&&(e.fillStyle=this.styles.grid,e.fillRect(this.styles.left,m,o,1)),"none"!==this.styles.text&&(e.fillStyle=this.styles.text,e.font=this.createFontString(),e.fillText(d,b,m-Math.floor(parseInt(this.styles.font.size,10)/4)))}}return this.savedImage=e.getImageData(0,0,n,i),this.length=t.length,e.fillStyle=this.currentTime,e.fillRect(this.styles.left,this.styles.top,1,s),this}},{key:"drawBySVG",value:function(t){if(!(this.svg instanceof SVGElement&&this.isActive))return this;var e=this.svg,r=parseInt(e.getAttribute("width"),10),n=parseInt(e.getAttribute("height"),10),i=r-(this.styles.left+this.styles.right),o=n-(this.styles.top+this.styles.bottom),c=Math.floor(o/2)+this.styles.top,u=Math.floor(this.plotInterval*this.sampleRate),l=Math.floor(this.textInterval*this.sampleRate);if(e.innerHTML="",e.appendChild(this.drawTimeDomainFloat32ArrayBySVG(t,i,o,c,u,s.SVG_LINEAR_GRADIENT_ID_TIME_OVERVIEW)),"none"!==this.styles.grid||"none"!==this.styles.text){for(var f=0,h=t.length;f<h;f++)if(f%l==0){var p=Math.floor(f/h*i)+this.styles.left,y=Math.floor(f/this.sampleRate/60)+" min";if("none"!==this.styles.grid){var v=document.createElementNS(s.XMLNS,"rect");v.setAttribute("x",p),v.setAttribute("y",this.styles.top),v.setAttribute("width",1),v.setAttribute("height",o),v.setAttribute("stroke","none"),v.setAttribute("fill",this.styles.grid),e.appendChild(v)}if("none"!==this.styles.text){var d=document.createElementNS(s.XMLNS,"text");d.textContent=y,d.setAttribute("x",p),d.setAttribute("y",this.styles.top+o+parseInt(this.styles.font.size,10)),d.setAttribute("text-anchor","middle"),d.setAttribute("stroke","none"),d.setAttribute("fill",this.styles.text),d.setAttribute("font-family",this.styles.font.family),d.setAttribute("font-size",this.styles.font.size),d.setAttribute("font-style",this.styles.font.style),d.setAttribute("font-weight",this.styles.font.weight),e.appendChild(d)}}for(var b=0,m=["-1.00","-0.50"," 0.00"," 0.50"," 1.00"];b<m.length;b++){var g=m[b],w=this.styles.left,S=Math.floor((1-parseFloat(g.trim()))*(o/2))+this.styles.top;if("none"!==this.styles.grid){var O=document.createElementNS(s.XMLNS,"rect");O.setAttribute("x",w),O.setAttribute("y",S),O.setAttribute("width",i),O.setAttribute("height",1),O.setAttribute("stroke","none"),O.setAttribute("fill",this.styles.grid),e.appendChild(O)}if("none"!==this.styles.text){var A=document.createElementNS(s.XMLNS,"text");A.textContent=g,A.setAttribute("x",w),A.setAttribute("y",S-Math.floor(parseInt(this.styles.font.size,10)/4)),A.setAttribute("text-anchor","end"),A.setAttribute("stroke","none"),A.setAttribute("fill",this.styles.text),A.setAttribute("font-family",this.styles.font.family),A.setAttribute("font-size",this.styles.font.size),A.setAttribute("font-style",this.styles.font.style),A.setAttribute("font-weight",this.styles.font.weight),e.appendChild(A)}}}var k=document.createElementNS(s.XMLNS,"rect");return k.classList.add(a.SVG_CURRENT_TIME_CLASS_NAME),k.setAttribute("y",this.styles.top+1),k.setAttribute("height",o-1),k.setAttribute("stroke","none"),k.setAttribute("fill",this.currentTime),e.appendChild(k),this.savedImage=e,this.length=t.length,this}},{key:"update",value:function(t){var e=parseFloat(t);if(isNaN(e)||e<0)return this;switch(this.graphics){case s.CANVAS:if(this.savedImage instanceof ImageData){var r=this.context,n=this.canvas,i=n.width,o=n.height,c=i-(this.styles.left+this.styles.right),u=o-(this.styles.top+this.styles.bottom),l=e*this.sampleRate/this.length*c;if(r.clearRect(0,0,i,o),r.putImageData(this.savedImage,0,0),this.mode===a.DRAG_MODE_UPDATE)r.fillStyle=this.currentTime,r.fillRect(this.styles.left,this.styles.top+1,l,u-1);else if(this.mode===a.DRAG_MODE_SPRITE){if(0!==this.endTime){var f=Math.floor(Math.abs(this.endTime-this.startTime)*this.sampleRate/this.length*c);r.fillStyle=this.sprite,l>=this.offsetX?r.fillRect(this.styles.left+this.offsetX,this.styles.top+1,f,u-1):r.fillRect(this.styles.left+this.offsetX-f,this.styles.top+1,f,u-1)}r.fillStyle=this.currentTime,l>=this.offsetX?r.fillRect(this.styles.left+this.offsetX,this.styles.top+1,Math.abs(l-this.offsetX),u-1):r.fillRect(this.styles.left+l,this.styles.top+1,Math.abs(l-this.offsetX),u-1)}}break;case s.SVG:var h=this.svg.querySelector(".".concat(a.SVG_CURRENT_TIME_CLASS_NAME));if(h instanceof SVGElement){var p=parseInt(this.svg.getAttribute("width"),10)-(this.styles.left+this.styles.right),y=e*this.sampleRate/this.length*p;if(this.mode===a.DRAG_MODE_UPDATE)h.setAttribute("x",this.styles.left),h.setAttribute("width",y),h.setAttribute("aria-label","current time");else if(this.mode===a.DRAG_MODE_SPRITE){if(0!==this.endTime){var v=document.createElementNS(s.XMLNS,"rect");v.classList.add(a.SVG_SPRITE_CLASS_NAME),this.svg.lastElementChild.previousElementSibling instanceof SVGElement&&this.svg.removeChild(this.svg.lastElementChild.previousElementSibling);var d=Math.floor(Math.abs(this.endTime-this.startTime)*this.sampleRate/this.length*p);v.setAttribute("y",this.styles.top+1),v.setAttribute("height",h.getAttribute("height")),v.setAttribute("stroke","none"),v.setAttribute("fill",this.sprite),v.setAttribute("aria-label","current time"),y>=this.offsetX?v.setAttribute("x",this.styles.left+this.offsetX):v.setAttribute("x",this.styles.left+this.offsetX-d),v.setAttribute("width",d),this.svg.appendChild(v),this.svg.appendChild(h)}y>=this.offsetX?h.setAttribute("x",this.styles.left+this.offsetX):h.setAttribute("x",this.styles.left+y),h.setAttribute("width",Math.abs(y-this.offsetX)),h.setAttribute("aria-label","sprite time")}}}return this}},{key:"drag",value:function(t){var e=null,r="",n="",i="";switch(/iPhone|iPad|iPod|Android/.test(navigator.userAgent)?(r="touchstart",n="touchmove",i="touchend"):(r="mousedown",n="mousemove",i="mouseup"),this.graphics){case s.CANVAS:e=this.canvas;break;case s.SVG:e=this.svg;break;default:return this}return this.callback="[object Function]"===Object.prototype.toString.call(t)?t:function(){},e.removeEventListener(r,this.onStart,!0),e.removeEventListener(n,this.onMove,!0),window.removeEventListener(i,this.onEnd,!0),e.addEventListener(r,this.onStart,!0),e.addEventListener(n,this.onMove,!0),window.addEventListener(i,this.onEnd,!0),this}},{key:"draw",value:function(t,e,r){var n=0,i=0;switch(this.graphics){case s.CANVAS:n=this.canvas.offsetLeft,i=this.canvas.width;break;case s.SVG:n=this.svg.parentNode.offsetLeft,i=parseInt(this.svg.getAttribute("width"),10)}var o=r-(n+this.styles.left);this.canvas.parentNode instanceof Element&&(o+=this.canvas.parentNode.scrollLeft),o<0&&(o=0),o>(i-=this.styles.left+this.styles.right)&&(o=i);var a=o/i*this.length/this.sampleRate;return"mousedown"!==e&&"touchstart"!==e||(this.offsetX=o,this.startTime=a,this.endTime=0),"mouseup"!==e&&"touchend"!==e||(this.endTime=a),this.update(a),this.startTime<=a?this.callback(t,this.startTime,a,this.mode,!0):this.startTime>a&&this.callback(t,a,this.startTime,this.mode,!1),this}},{key:"onStart",value:function(t){this.draw(t,t.type,this.getOffsetX(t)),this.isDown=!0}},{key:"onMove",value:function(t){this.isDown&&(t.preventDefault(),this.draw(t,t.type,this.getOffsetX(t)))}},{key:"onEnd",value:function(t){this.isDown&&(this.draw(t,t.type,this.getOffsetX(t)),this.isDown=!1)}},{key:"getOffsetX",value:function(t){return t.pageX?t.pageX:t.touches[0]?t.touches[0].pageX:this}},{key:"toString",value:function(){return"[SoundModule Analyser TimeOverview]"}}],r&&c(e.prototype,r),a}(s);function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function b(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function g(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function w(t,e,r){return w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=A(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},w(t,e,r||t)}function S(t,e){return S=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},S(t,e)}function O(t,e){if(e&&("object"===d(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function A(t){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},A(t)}function k(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}y(v,"SVG_CURRENT_TIME_CLASS_NAME","xsound-svg-current-time"),y(v,"SVG_SPRITE_CLASS_NAME","xsound-svg-sprite"),y(v,"DRAG_MODE_UPDATE","update"),y(v,"DRAG_MODE_SPRITE","sprite");var T=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&S(t,e)}(a,t);var e,r,n,i,o=(n=a,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=A(n);if(i){var r=A(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return O(this,t)});function a(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(e=o.call(this,t)).type=a.UINT,e.textInterval=.005,e}return e=a,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=w(A(a.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;var o=null;switch(n){case"type":if(void 0===e)return this.type;(o=String(e).toLowerCase())!==a.UINT&&o!==a.FLOAT||(this.type=o);break;case"textinterval":if(void 0===e)return this.textInterval;(o=parseFloat(e))>0&&(this.textInterval=o)}}return this}},{key:"drawOnCanvas",value:function(t){if(!(this.canvas instanceof HTMLCanvasElement&&this.isActive))return this;var e=this.context,r=this.canvas,n=r.width,i=r.height,o=n-(this.styles.left+this.styles.right),s=i-(this.styles.top+this.styles.bottom),c=Math.floor(s/2)+this.styles.top,u=Math.floor(this.textInterval*this.sampleRate);switch(e.clearRect(0,0,n,i),this.type){case a.FLOAT:this.drawTimeDomainFloat32ArrayOnCanvas(e,t,o,s,c);break;case a.UINT:default:switch(this.styles.shape){case"line":e.strokeStyle=this.styles.wave,e.lineWidth=this.styles.width,e.lineCap=this.styles.cap,e.lineJoin=this.styles.join,e.beginPath();for(var l=0,f=t.length;l<f;l++){var h=l/f*o+this.styles.left,p=(1-t[l]/255)*s+this.styles.top;0===l?e.moveTo(h+this.styles.width/2,p):e.lineTo(h,p)}e.stroke();break;case"rect":"gradient"!==this.styles.wave&&(e.fillStyle=this.styles.wave);for(var y=0,v=t.length;y<v;y++){var d=y/v*o+this.styles.left,m=(.5-t[y]/255)*s;if("gradient"===this.styles.wave){var g,w=s/2+this.styles.top,S=e.createLinearGradient(0,w,0,w+m),O=b(this.styles.grad);try{for(O.s();!(g=O.n()).done;){var A=g.value;S.addColorStop(A.offset,A.color)}}catch(t){O.e(t)}finally{O.f()}e.fillStyle=S}e.fillRect(d,c,this.styles.width,m)}}}if("none"!==this.styles.grid||"none"!==this.styles.text){for(var k=0,T=t.length;k<T;k++)if(k%u==0){var E=Math.ceil(k/T*o)+this.styles.left,j="".concat(Math.ceil(k/this.sampleRate*1e3)," ms");"none"!==this.styles.grid&&(e.fillStyle=this.styles.grid,e.fillRect(E,this.styles.top,1,s)),"none"!==this.styles.text&&(e.fillStyle=this.styles.text,e.font=this.createFontString(),e.fillText(j,E-e.measureText(j).width/2,this.styles.top+s+parseInt(this.styles.font.size,10)))}for(var R=0,P=["-1.00","-0.50"," 0.00"," 0.50"," 1.00"];R<P.length;R++){var x=P[R],_=Math.floor(this.styles.left-e.measureText(x).width),M=Math.floor((1-parseFloat(x.trim()))*(s/2))+this.styles.top;"none"!==this.styles.grid&&(e.fillStyle=this.styles.grid,e.fillRect(this.styles.left,M,o,1)),"none"!==this.styles.text&&(e.fillStyle=this.styles.text,e.font=this.createFontString(),e.fillText(x,_,M-Math.floor(parseInt(this.styles.font.size,10)/4)))}}return this}},{key:"drawBySVG",value:function(t){if(!(this.svg instanceof SVGElement&&this.isActive))return this;var e=this.svg,r=parseInt(e.getAttribute("width"),10),n=parseInt(e.getAttribute("height"),10),i=r-(this.styles.left+this.styles.right),o=n-(this.styles.top+this.styles.bottom),c=Math.floor(o/2)+this.styles.top,u=Math.floor(this.textInterval*this.sampleRate);switch(e.innerHTML="",this.type){case a.FLOAT:e.appendChild(this.drawTimeDomainFloat32ArrayBySVG(t,i,o,c,null,s.SVG_LINEAR_GRADIENT_ID_TIME));break;case a.UINT:default:switch(this.styles.shape){case"line":for(var l=document.createElementNS(s.XMLNS,"path"),f="",h=0,p=t.length;h<p;h++){var y=h/p*i+this.styles.left,v=(1-t[h]/255)*o+this.styles.top;f+=0===h?"M".concat(y+this.styles.width/2," ").concat(v):" L".concat(y," ").concat(v)}l.setAttribute("d",f),l.setAttribute("stroke",this.styles.wave),l.setAttribute("fill","none"),l.setAttribute("stroke-width",this.styles.width),l.setAttribute("stroke-linecap",this.styles.cap),l.setAttribute("stroke-linejoin",this.styles.join),e.appendChild(l);break;case"rect":var d=null;"gradient"===this.styles.wave&&(d=this.createSVGLinearGradient(s.SVG_LINEAR_GRADIENT_ID_TIME));var b=document.createElementNS(s.XMLNS,"g");null!==d&&b.appendChild(d);for(var m=0,g=t.length;m<g;m++){var w=document.createElementNS(s.XMLNS,"rect"),S=m/g*i+this.styles.left,O=(t[m]/255-.5)*o;w.setAttribute("x",S),w.setAttribute("y",c),w.setAttribute("width",this.styles.width),O<0?w.setAttribute("height",-O):(w.setAttribute("height",O),w.setAttribute("transform","rotate(180 ".concat(S+this.styles.width/2," ").concat(c,")"))),w.setAttribute("stroke","none"),w.setAttribute("fill",null===d?this.styles.wave:"url(#".concat(s.SVG_LINEAR_GRADIENT_ID_TIME,")")),b.appendChild(w)}e.appendChild(b)}}if("none"!==this.styles.grid||"none"!==this.styles.text){for(var A=0,k=t.length;A<k;A++)if(A%u==0){var T=Math.ceil(A/k*i)+this.styles.left,E="".concat(Math.ceil(A/this.sampleRate*1e3)," ms");if("none"!==this.styles.grid){var j=document.createElementNS(s.XMLNS,"rect");j.setAttribute("x",T),j.setAttribute("y",this.styles.top),j.setAttribute("width",1),j.setAttribute("height",o),j.setAttribute("stroke","none"),j.setAttribute("fill",this.styles.grid),e.appendChild(j)}if("none"!==this.styles.text){var R=document.createElementNS(s.XMLNS,"text");R.textContent=E,R.setAttribute("x",T),R.setAttribute("y",this.styles.top+o+parseInt(this.styles.font.size,10)),R.setAttribute("text-anchor","middle"),R.setAttribute("stroke","none"),R.setAttribute("fill",this.styles.text),R.setAttribute("font-family",this.styles.font.family),R.setAttribute("font-size",this.styles.font.size),R.setAttribute("font-style",this.styles.font.style),R.setAttribute("font-weight",this.styles.font.weight),e.appendChild(R)}}for(var P=0,x=["-1.00","-0.50"," 0.00"," 0.50"," 1.00"];P<x.length;P++){var _=x[P],M=this.styles.left,C=Math.floor((1-parseFloat(_.trim()))*(o/2))+this.styles.top;if("none"!==this.styles.grid){var F=document.createElementNS(s.XMLNS,"rect");F.setAttribute("x",M),F.setAttribute("y",C),F.setAttribute("width",i),F.setAttribute("height",1),F.setAttribute("stroke","none"),F.setAttribute("fill",this.styles.grid),e.appendChild(F)}if("none"!==this.styles.text){var I=document.createElementNS(s.XMLNS,"text");I.textContent=_,I.setAttribute("x",M),I.setAttribute("y",C-Math.floor(parseInt(this.styles.font.size,10)/4)),I.setAttribute("text-anchor","end"),I.setAttribute("stroke","none"),I.setAttribute("fill",this.styles.text),I.setAttribute("font-family",this.styles.font.family),I.setAttribute("font-size",this.styles.font.size),I.setAttribute("font-style",this.styles.font.style),I.setAttribute("font-weight",this.styles.font.weight),e.appendChild(I)}}}return this}},{key:"toString",value:function(){return"[SoundModule Analyser Time]"}}],r&&g(e.prototype,r),a}(s);function E(t){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},E(t)}function j(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return R(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?R(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function R(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function P(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function x(t,e,r){return x="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=C(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},x(t,e,r||t)}function _(t,e){return _=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},_(t,e)}function M(t,e){if(e&&("object"===E(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function C(t){return C=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},C(t)}function F(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}k(T,"UINT","uint"),k(T,"FLOAT","float");var I=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_(t,e)}(a,t);var e,r,n,i,o=(n=a,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=C(n);if(i){var r=C(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return M(this,t)});function a(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(e=o.call(this,t)).type=a.UINT,e.size=256,e.textInterval=1e3,e}return e=a,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=x(C(a.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;var o=null,s=null;switch(n){case"type":if(void 0===e)return this.type;(o=String(e).toLowerCase())!==a.UINT&&o!==a.FLOAT||(this.type=o);break;case"size":if(void 0===e)return this.size;s=1024,(o=parseInt(e,10))>0&&o<=s&&(this.size=o);break;case"textinterval":if(void 0===e)return this.textInterval;(o=parseFloat(e))>0&&(this.textInterval=o)}}return this}},{key:"drawOnCanvas",value:function(t,e,r){if(!(this.canvas instanceof HTMLCanvasElement&&this.isActive))return this;var n=parseFloat(e),i=parseFloat(r),o=i-n,s=this.context,c=this.canvas,u=c.width,l=c.height,f=u-(this.styles.left+this.styles.right),h=l-(this.styles.top+this.styles.bottom),p=this.size>t.length?t.length:this.size,y=this.sampleRate/(2*t.length),v=Math.floor(this.textInterval/y);switch(s.clearRect(0,0,u,l),this.type){case a.FLOAT:s.strokeStyle="gradient"!==this.styles.wave?this.styles.wave:"rgba(0, 0, 255, 1.0)",s.lineWidth=this.styles.width,s.lineCap=this.styles.cap,s.lineJoin=this.styles.join,s.beginPath();for(var d=0;d<p;d++){var b=d/p*f+this.styles.left,m=Math.abs(t[d]-i)*(h/o)+this.styles.top;0===d?s.moveTo(b+this.styles.width/2,m):s.lineTo(b,m)}s.stroke();break;case a.UINT:default:switch(this.styles.shape){case"line":s.strokeStyle=this.styles.wave,s.lineWidth=this.styles.width,s.lineCap=this.styles.cap,s.lineJoin=this.styles.join,s.beginPath();for(var g=0;g<p;g++){var w=g/p*f+this.styles.left,S=(1-t[g]/255)*h+this.styles.top;0===g?s.moveTo(w+this.styles.width/2,S):s.lineTo(w,S)}s.stroke();break;case"rect":"gradient"!==this.styles.wave&&(s.fillStyle=this.styles.wave);for(var O=0;O<p;O++){var A=O/p*f+this.styles.left,k=t[O]/255*h*-1;if("gradient"===this.styles.wave){var T,E=h+this.styles.top,R=s.createLinearGradient(0,E,0,E+k),P=j(this.styles.grad);try{for(P.s();!(T=P.n()).done;){var x=T.value;R.addColorStop(x.offset,x.color)}}catch(t){P.e(t)}finally{P.f()}s.fillStyle=R}s.fillRect(A,h+this.styles.top,this.styles.width,k)}}}if("none"!==this.styles.grid||"none"!==this.styles.text){for(var _=0;_<p;_++)if(_%v==0){var M=Math.floor(_/p*f)+this.styles.left,C=Math.floor(this.textInterval*(_/v)),F=C<1e3?"".concat(C," Hz"):"".concat(String(C/1e3).slice(0,3)," kHz");"none"!==this.styles.grid&&(s.fillStyle=this.styles.grid,s.fillRect(M,this.styles.top,1,h)),"none"!==this.styles.text&&(s.fillStyle=this.styles.text,s.font=this.createFontString(),s.fillText(F,M-s.measureText(F).width/2,this.styles.top+h+parseInt(this.styles.font.size,10)))}switch(this.type){case a.FLOAT:for(var I=n;I<=i;I+=10){var N="".concat(I," dB"),L=Math.floor(this.styles.left-s.measureText(N).width),D=Math.floor(-1*(I-i)/o*h)+this.styles.top;"none"!==this.styles.grid&&(s.fillStyle=this.styles.grid,s.fillRect(this.styles.left,D,f,1)),"none"!==this.styles.text&&(s.fillStyle=this.styles.text,s.font=this.createFontString(),s.fillText(N,L,D-Math.floor(parseInt(this.styles.font.size,10)/4)))}break;case a.UINT:default:for(var B=0,U=["0.00","0.25","0.50","0.75","1.00"];B<U.length;B++){var q=U[B],V=Math.floor(this.styles.left-s.measureText(q).width),G=(1-parseFloat(q))*h+this.styles.top;"none"!==this.styles.grid&&(s.fillStyle=this.styles.grid,s.fillRect(this.styles.left,G,f,1)),"none"!==this.styles.text&&(s.fillStyle=this.styles.text,s.font=this.createFontString(),s.fillText(q,V,G-Math.floor(parseInt(this.styles.font.size,10)/4)))}}}return this}},{key:"drawBySVG",value:function(t,e,r){if(!(this.svg instanceof SVGElement&&this.isActive))return this;var n=parseFloat(e),i=parseFloat(r),o=i-n,c=this.svg,u=parseInt(c.getAttribute("width"),10),l=parseInt(c.getAttribute("height"),10),f=u-(this.styles.left+this.styles.right),h=l-(this.styles.top+this.styles.bottom),p=this.size>t.length?t.length:this.size,y=this.sampleRate/(2*t.length),v=Math.floor(this.textInterval/y);switch(c.innerHTML="",this.type){case a.FLOAT:for(var d=document.createElementNS(s.XMLNS,"path"),b="",m=0;m<p;m++){var g=Math.floor(m/p*f)+this.styles.left,w=Math.floor(-1*(t[m]-i)*(h/o))+this.styles.top;b+=0===m?"M".concat(g+this.styles.width/2," ").concat(w):" L".concat(g," ").concat(w)}d.setAttribute("d",b),d.setAttribute("stroke","gradient"!==this.styles.wave?this.styles.wave:"rgba(0, 0, 255, 1.0)"),d.setAttribute("fill","none"),d.setAttribute("stroke-width",this.styles.width),d.setAttribute("stroke-linecap",this.styles.cap),d.setAttribute("stroke-linejoin",this.styles.join),c.appendChild(d);break;case a.UINT:default:switch(this.styles.shape){case"line":for(var S=document.createElementNS(s.XMLNS,"path"),O="",A=0;A<p;A++){var k=Math.floor(A/p*f)+this.styles.left,T=Math.floor((1-t[A]/255)*h)+this.styles.top;O+=0===A?"M".concat(k+this.styles.width/2," ").concat(T):" L".concat(k," ").concat(T)}S.setAttribute("d",O),S.setAttribute("stroke",this.styles.wave),S.setAttribute("fill","none"),S.setAttribute("stroke-width",this.styles.width),S.setAttribute("stroke-linecap",this.styles.cap),S.setAttribute("stroke-linejoin",this.styles.join),c.appendChild(S);break;case"rect":var E=null;"gradient"===this.styles.wave&&(E=this.createSVGLinearGradient(s.SVG_LINEAR_GRADIENT_ID_FFT));var j=document.createElementNS(s.XMLNS,"g");null!==E&&j.appendChild(E);for(var R=0;R<p;R++){var P=document.createElementNS(s.XMLNS,"rect"),x=Math.floor(R/p*f)+this.styles.left,_=Math.floor(t[R]/255*h);P.setAttribute("x",x),P.setAttribute("y",this.styles.top+h),P.setAttribute("width",this.styles.width),_<0?P.setAttribute("height",-_):(P.setAttribute("height",_),P.setAttribute("transform","rotate(180 ".concat(x+this.styles.width/2," ").concat(this.styles.top+h,")"))),P.setAttribute("stroke","none"),P.setAttribute("fill",null===E?this.styles.wave:"url(#".concat(s.SVG_LINEAR_GRADIENT_ID_FFT,")")),j.appendChild(P)}c.appendChild(j)}}if("none"!==this.styles.grid||"none"!==this.styles.text){for(var M=0;M<p;M++)if(M%v==0){var C=Math.floor(M/p*f)+this.styles.left,F=Math.floor(this.textInterval*(M/v)),I=F<1e3?"".concat(F," Hz"):"".concat(String(F/1e3).slice(0,3)," kHz");if("none"!==this.styles.grid){var N=document.createElementNS(s.XMLNS,"rect");N.setAttribute("x",C),N.setAttribute("y",this.styles.top),N.setAttribute("width",1),N.setAttribute("height",h),N.setAttribute("stroke","none"),N.setAttribute("fill",this.styles.grid),c.appendChild(N)}if("none"!==this.styles.text){var L=document.createElementNS(s.XMLNS,"text");L.textContent=I,L.setAttribute("x",C),L.setAttribute("y",this.styles.top+h+parseInt(this.styles.font.size,10)),L.setAttribute("text-anchor","middle"),L.setAttribute("stroke","none"),L.setAttribute("fill",this.styles.text),L.setAttribute("font-family",this.styles.font.family),L.setAttribute("font-size",this.styles.font.size),L.setAttribute("font-style",this.styles.font.style),L.setAttribute("font-weight",this.styles.font.weight),c.appendChild(L)}}switch(this.type){case a.FLOAT:for(var D=n;D<=i;D+=10){var B="".concat(D,"dB"),U=this.styles.left,q=Math.floor(-1*(D-i)/o*h)+this.styles.top;if("none"!==this.styles.grid){var V=document.createElementNS(s.XMLNS,"rect");V.setAttribute("x",U),V.setAttribute("y",q),V.setAttribute("width",f),V.setAttribute("height",1),V.setAttribute("stroke","none"),V.setAttribute("fill",this.styles.grid),c.appendChild(V)}if("none"!==this.styles.text){var G=document.createElementNS(s.XMLNS,"text");G.textContent=B,G.setAttribute("x",U),G.setAttribute("y",q-Math.floor(parseInt(this.styles.font.size,10)/4)),G.setAttribute("text-anchor","end"),G.setAttribute("stroke","none"),G.setAttribute("fill",this.styles.text),G.setAttribute("font-family",this.styles.font.family),G.setAttribute("font-size",this.styles.font.size),G.setAttribute("font-style",this.styles.font.style),G.setAttribute("font-weight",this.styles.font.weight),c.appendChild(G)}}break;case a.UINT:default:for(var z=0,X=["0.00","0.25","0.50","0.75","1.00"];z<X.length;z++){var W=X[z],H=this.styles.left,Y=(1-parseFloat(W))*h+this.styles.top;if("none"!==this.styles.grid){var Q=document.createElementNS(s.XMLNS,"rect");Q.setAttribute("x",H),Q.setAttribute("y",Y),Q.setAttribute("width",f),Q.setAttribute("height",1),Q.setAttribute("stroke","none"),Q.setAttribute("fill",this.styles.grid),c.appendChild(Q)}if("none"!==this.styles.text){var Z=document.createElementNS(s.XMLNS,"text");Z.textContent=W,Z.setAttribute("x",H),Z.setAttribute("y",Y-Math.floor(parseInt(this.styles.font.size,10)/4)),Z.setAttribute("text-anchor","end"),Z.setAttribute("stroke","none"),Z.setAttribute("fill",this.styles.text),Z.setAttribute("font-family",this.styles.font.family),Z.setAttribute("font-size",this.styles.font.size),Z.setAttribute("font-style",this.styles.font.style),Z.setAttribute("font-weight",this.styles.font.weight),c.appendChild(Z)}}}}return this}},{key:"toString",value:function(){return"[SoundModule Analyser FFT]"}}],r&&P(e.prototype,r),a}(s);function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}function L(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function D(t,e){return D=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},D(t,e)}function B(t,e){if(e&&("object"===N(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function U(t){return U=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},U(t)}F(I,"UINT","uint"),F(I,"FLOAT","float");var q=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&D(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=U(n);if(i){var r=U(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return B(this,t)});function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=o.call(this)).analyser=t.createAnalyser(),e.input=t.createGain(),e.input.connect(e.analyser),e.timeOverviewL=new v(t.sampleRate),e.timeOverviewR=new v(t.sampleRate),e.time=new T(t.sampleRate),e.fft=new I(t.sampleRate),e.analyser.fftSize=2048,e.analyser.minDecibels=-100,e.analyser.maxDecibels=-30,e.analyser.smoothingTimeConstant=.8,e}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null;switch(n){case"fftsize":if(void 0===e)return this.analyser.fftSize;switch(i=parseInt(e,10)){case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:this.analyser.fftSize=i}break;case"frequencybincount":return this.analyser.frequencyBinCount;case"mindecibels":if(void 0===e)return this.analyser.minDecibels;(i=parseFloat(e))<(o=-30)&&(this.analyser.minDecibels=i);break;case"maxdecibels":if(void 0===e)return this.analyser.maxDecibels;(i=parseFloat(e))>-100&&(this.analyser.maxDecibels=i);break;case"smoothingtimeconstant":if(void 0===e)return this.analyser.smoothingTimeConstant;o=1,(i=parseFloat(e))>=0&&i<=o&&(this.analyser.smoothingTimeConstant=i)}}return this}},{key:"start",value:function(t,e,r){var n=this,i=String(t).replace(/-/g,"").toLowerCase(),o=parseInt(e,10),s=null;switch(i){case"timeoverview":switch(o){case 0:r instanceof AudioBuffer&&r.numberOfChannels>o&&((s=new Float32Array(r.length)).set(r.getChannelData(o)),this.timeOverviewL.start(s));break;case 1:r instanceof AudioBuffer&&r.numberOfChannels>o&&((s=new Float32Array(r.length)).set(r.getChannelData(o)),this.timeOverviewR.start(s))}break;case"timeoverviewl":r instanceof AudioBuffer&&r.numberOfChannels>0&&((s=new Float32Array(r.length)).set(r.getChannelData(0)),this.timeOverviewL.start(s));break;case"timeoverviewr":r instanceof AudioBuffer&&r.numberOfChannels>1&&((s=new Float32Array(r.length)).set(r.getChannelData(1)),this.timeOverviewR.start(s));break;case"time":"uint"===this.time.param("type")?(s=new Uint8Array(this.analyser.fftSize),this.analyser.getByteTimeDomainData(s),this.time.start(s)):(s=new Float32Array(this.analyser.fftSize),this.analyser.getFloatTimeDomainData(s),this.time.start(s)),"auto"===this.time.param("interval")?this.time.timerid=window.requestAnimationFrame((function(){n.start(t)})):this.time.timerid=window.setTimeout((function(){n.start(t)}),this.time.param("interval"));break;case"fft":"uint"===this.fft.param("type")?(s=new Uint8Array(this.analyser.frequencyBinCount),this.analyser.getByteFrequencyData(s),this.fft.start(s)):(s=new Float32Array(this.analyser.frequencyBinCount),this.analyser.getFloatFrequencyData(s),this.fft.start(s,this.analyser.minDecibels,this.analyser.maxDecibels)),"auto"===this.fft.param("interval")?this.fft.timerid=window.requestAnimationFrame((function(){n.start(t)})):this.fft.timerid=window.setTimeout((function(){n.start(t)}),this.fft.param("interval"))}return this}},{key:"stop",value:function(t){switch(String(t).replace(/-/g,"").toLowerCase()){case"timeoverviewl":case"timeoverviewr":break;case"time":"auto"===this.time.param("interval")?window.cancelAnimationFrame(this.time.timerid):window.clearTimeout(this.time.timerid),this.time.timerid=null;break;case"fft":"auto"===this.fft.param("interval")?window.cancelAnimationFrame(this.fft.timerid):window.clearTimeout(this.fft.timerid),this.fft.timerid=null}return this}},{key:"domain",value:function(t,e){var r=String(t).replace(/-/g,"").toLowerCase(),n=parseInt(e,10);switch(r){case"timeoverview":switch(n){case 0:return this.timeOverviewL;case 1:return this.timeOverviewR;default:return this}case"timeoverviewl":case"timeoverviewr":return this["timeOverview".concat(r.slice(-1).toUpperCase())];case"time":case"fft":return this[r];default:return this}}},{key:"get",value:function(){return this.analyser}},{key:"INPUT",get:function(){return this.input}},{key:"OUTPUT",get:function(){return this.input}},{key:"toString",value:function(){return"[SoundModule Analyser]"}}],r&&L(e.prototype,r),s}(e);function V(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var G=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.trackNumber=e>=0?e:0,this.dataBlocks=[]}var e,r;return e=t,(r=[{key:"get",value:function(){return this.dataBlocks}},{key:"append",value:function(t){t instanceof Float32Array&&this.dataBlocks.push(t)}},{key:"has",value:function(){return this.dataBlocks.length>0}},{key:"clear",value:function(){this.dataBlocks.length=0}}])&&V(e.prototype,r),t}();function z(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var X=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.channelNumber=e>=0?e:0,this.tracks=[],this.channelGain=1}var e,r;return e=t,(r=[{key:"get",value:function(t){var e=parseInt(t,10);return e>=0&&e<this.tracks.length?this.tracks[e]:this.tracks}},{key:"append",value:function(t){t instanceof G&&this.tracks.push(t)}},{key:"length",value:function(){return this.tracks.length}},{key:"gain",value:function(t){if(void 0===t)return this.channelGain;var e=parseFloat(t);e>=0&&e<=1&&(this.channelGain=e)}}])&&z(e.prototype,r),t}();function W(t){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},W(t)}function H(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Y(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Y(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Y(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Q(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Z(t,e){return Z=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Z(t,e)}function $(t,e){if(e&&("object"===W(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function J(t){return J=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},J(t)}var K=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Z(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=J(n);if(i){var r=J(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return $(this,t)});function s(t,e,r,n){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(i=o.call(this)).sampleRate=t.sampleRate,i.context=t,i.processor=t.createScriptProcessor(e,r,n),i.channels=[],i.activeTrack=-1,i.paused=!0,i}return e=s,r=[{key:"setup",value:function(t,e){var r=parseInt(e,10),n=r>0?r:1;this.channels.push(new X(0)),this.channels.push(new X(1));var i,o=H(this.channels);try{for(o.s();!(i=o.n()).done;)for(var s=i.value,a=0;a<n;a++)s.append(new G(a))}catch(t){o.e(t)}finally{o.f()}return this}},{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase();switch(n){case"0":case"left":if(void 0===e)return this.channels[0].gain();this.channels[0].gain(e);break;case"1":case"right":if(void 0===e)return this.channels[1].gain();this.channels[1].gain(e)}}return this}},{key:"ready",value:function(t){return this.hasTrack(t)?this.activeTrack=t:this.activeTrack=-1,this}},{key:"start",value:function(){var t=this;if(-1!==this.activeTrack&&this.paused){this.paused=!1;var e=this.channels[0].gain(),r=this.channels[1].gain(),n=this.channels[0].get(this.activeTrack),i=this.channels[1].get(this.activeTrack),o=this.processor.bufferSize;this.processor.onaudioprocess=function(s){if(-1!==t.activeTrack){for(var a=s.inputBuffer.getChannelData(0),c=s.inputBuffer.getChannelData(1),u=new Float32Array(o),l=new Float32Array(o),f=0;f<o;f++)u[f]=e*a[f],l[f]=r*c[f];n.append(u),i.append(l)}else t.processor.disconnect(0),t.processor.onaudioprocess=null}}return this}},{key:"stop",value:function(){return this.activeTrack=-1,this.paused=!0,this.processor.disconnect(0),this.processor.onaudioprocess=null,this}},{key:"hasChannel",value:function(t){var e=parseInt(t,10);return e>=0&&e<this.channels.length}},{key:"hasTrack",value:function(t){var e=parseInt(t,10);return e>=0&&this.channels.every((function(t){return e<t.length()}))}},{key:"has",value:function(t,e){if(!this.hasChannel(t))return this.channels.some((function(t){return t.get().some((function(t){return t.has()}))}));var r=parseInt(t,10),n=this.channels[r].get();return this.hasTrack(e)?n[parseInt(e,10)].has():n.some((function(t){return t.has()}))}},{key:"get",value:function(){return this.activeTrack}},{key:"flatTrack",value:function(t,e){if(!this.hasChannel(t)||!this.hasTrack(e))return null;for(var r=this.channels[t].get(e).get(),n=this.processor.bufferSize,i=new Float32Array(r.length*n),o=0,s=r.length;o<s;o++)for(var a=r[o],c=0;c<n;c++)i[o*n+c]=a[c];return i}},{key:"mixTrack",value:function(t){if(!this.hasChannel(t))return null;var e,r=this.channels[t].get(),n=this.processor.bufferSize,i=0,o=0,s=0,a=0,c=0,u=H(r);try{for(u.s();!(e=u.n()).done;){var l=e.value.get();c<l.length&&(c=l.length)}}catch(t){u.e(t)}finally{u.f()}for(var f=new Float32Array(c*n);;){for(var h=0,p=r.length;h<p;h++){var y=r[h].get()[s];y instanceof Float32Array&&(i+=y[a],o++)}if(o<=0)return f;f[s*n+a]=i/o,i=0,o=0,a<n-1?a++:(s++,a=0)}}},{key:"clear",value:function(t){-1!==this.activeTrack&&this.stop();var e=parseInt(t,10);if(-1===e){var r,n=H(this.channels);try{for(n.s();!(r=n.n()).done;){var i,o=H(r.value.get());try{for(o.s();!(i=o.n()).done;)i.value.clear()}catch(t){o.e(t)}finally{o.f()}}}catch(t){n.e(t)}finally{n.f()}}else if(this.hasTrack(e)){var s,a=H(this.channels);try{for(a.s();!(s=a.n()).done;)s.value.get(e).clear()}catch(t){a.e(t)}finally{a.f()}}return this}},{key:"create",value:function(t,e,r,n){-1!==this.activeTrack&&this.stop();var i=null,o=null;if(-1===t&&this.has())i=this.mixTrack(0),o=this.mixTrack(1);else{if(!this.has(0,t)||!this.has(1,t))return"";i=this.flatTrack(0,t),o=this.flatTrack(1,t)}var s=1===e?1:2,a=8===r?8:16,c=1===s?Math.min(i.length,o.length):2*Math.min(i.length,o.length),u=36+c*(a/8),l=8+c*(a/8)+28+8,f=this.sampleRate,h=f*s*(a/8),p=c*(a/8),y=null;switch(a){case 8:y=new Uint8Array(c);for(var v=0;v<c;v++){var d=0;(d=v%s==0?(i[Math.floor(v/s)]+1)/2*(Math.pow(2,8)-1):(o[Math.floor(v/s)]+1)/2*(Math.pow(2,8)-1))>Math.pow(2,8)-1&&(d=Math.pow(2,8)-1),d<Math.pow(2,0)-1&&(d=Math.pow(2,0)-1),y[v]=d}break;case 16:y=new Int16Array(c);for(var b=0;b<c;b++){var m=0;(m=b%s==0?i[Math.floor(b/s)]*Math.pow(2,15):o[Math.floor(b/s)]*Math.pow(2,15))>+Math.pow(2,15)-1&&(m=+Math.pow(2,15)-1),m<-Math.pow(2,15)-0&&(m=-Math.pow(2,15)-0),y[b]=m}}var g=new Uint8Array(44+p);g[0]=82,g[1]=73,g[2]=70,g[3]=70,g[4]=u>>0&255,g[5]=u>>8&255,g[6]=u>>16&255,g[7]=u>>24&255,g[8]=87,g[9]=65,g[10]=86,g[11]=69,g[12]=102,g[13]=109,g[14]=116,g[15]=32,g[16]=16,g[17]=0,g[18]=0,g[19]=0,g[20]=1,g[21]=0,g[22]=s,g[23]=0,g[24]=f>>0&255,g[25]=f>>8&255,g[26]=f>>16&255,g[27]=f>>24&255,g[28]=h>>0&255,g[29]=h>>8&255,g[30]=h>>16&255,g[31]=h>>24&255,g[32]=s*(a/8),g[33]=0,g[34]=a,g[35]=0,g[36]=100,g[37]=97,g[38]=116,g[39]=97,g[40]=p>>0&255,g[41]=p>>8&255,g[42]=p>>16&255,g[43]=p>>24&255;for(var w=0;w<c;w++)switch(a){case 8:g[l-p+w]=y[w];break;case 16:g[l-p+2*w+0]=y[w]>>0&255,g[l-p+2*w+1]=y[w]>>8&255}var S=String(n).toLowerCase(),O=window.btoa(Array.from(g).map((function(t){return String.fromCodePoint(t)})).join("")),A=new Blob([g],{type:"audio/wav"});switch(S){case"base64":case"dataurl":return"base64"===S?O:"data:audio/wav;base64,".concat(O);default:return"blob"===S?A:window.URL.createObjectURL(A)}}},{key:"INPUT",get:function(){return this.processor}},{key:"OUTPUT",get:function(){return this.processor}},{key:"toString",value:function(){return"[SoundModule Recorder]"}}],r&&Q(e.prototype,r),s}(e);function tt(t){return tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tt(t)}function et(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function rt(t,e){return rt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},rt(t,e)}function nt(t,e){if(e&&("object"===tt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function it(t){return it=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},it(t)}var ot,st,at=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&rt(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=it(n);if(i){var r=it(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return nt(this,t)});function s(t,e,r,n,i){var a;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(a=o.call(this)).isActive=!1,a.context=t,a.analyser=i,a.sender=t.createScriptProcessor(s.BUFFER_SIZE,r,n),a.receiver=t.createScriptProcessor(s.BUFFER_SIZE,r,n),a.websocket=null,a.paused=!0,a}return e=s,r=[{key:"setup",value:function(t,e,r,n,i,o,s){var a=this;if("[object Object]"===Object.prototype.toString.call(arguments[0])){var c=arguments[0];"tls"in c&&(t=c.tls),"host"in c&&(e=c.host),"port"in c&&(r=c.port),"path"in c&&(n=c.path),"open"in c&&(i=c.open),"close"in c&&(o=c.close),"error"in c&&(s=c.error)}var u=t?"wss://":"ws://";"/"!==n.charAt(0)&&(n="/".concat(n));var l=parseInt(r,10);return isNaN(l)||l<0||l>65535||(this.websocket=new WebSocket("".concat(u).concat(e,":").concat(l).concat(n)),this.websocket.binaryType="arraybuffer",this.websocket.onopen=function(t){"[object Function]"===Object.prototype.toString.call(i)&&i(t)},this.websocket.onclose=function(t){a.isActive=!1,a.paused=!0,a.connect(),"[object Function]"===Object.prototype.toString.call(o)&&o(t)},this.websocket.onerror=function(t){a.isActive=!1,a.paused=!0,a.connect(),"[object Function]"===Object.prototype.toString.call(s)&&s(t)},this.websocket.onmessage=function(t){if(!a.isActive)return a.analyser.stop("time"),void a.analyser.stop("fft");if(t.data instanceof ArrayBuffer){var e=t.data.byteLength/Float32Array.BYTES_PER_ELEMENT,r=Math.floor(e/2),n=r*Float32Array.BYTES_PER_ELEMENT,i=new Float32Array(t.data,0,r),o=new Float32Array(t.data,n,r);a.analyser.start("time"),a.analyser.start("fft"),a.receiver.onaudioprocess=function(t){var e=t.outputBuffer.getChannelData(0),r=t.outputBuffer.getChannelData(1);i instanceof Float32Array&&e.set(i),o instanceof Float32Array&&r.set(o),a.isActive&&null!==a.websocket||(a.analyser.stop("time"),a.analyser.stop("fft"))}}}),this}},{key:"connect",value:function(){return this.receiver.disconnect(0),this.sender.disconnect(0),this.receiver.onaudioprocess=null,this.sender.onaudioprocess=null,this.isActive?(this.receiver.connect(this.analyser.input),this.receiver.connect(this.context.destination)):this.paused=!0,this}},{key:"start",value:function(){var t=this;if(this.isActive&&this.isConnected()&&this.paused){this.paused=!1;var e=this.sender.bufferSize;this.sender.onaudioprocess=function(r){if(t.isActive&&t.isConnected()){for(var n=r.inputBuffer.getChannelData(0),i=r.inputBuffer.getChannelData(1),o=new Float32Array(2*e),s=parseInt(o.length/2,10),a=0;a<e;a++)o[a]=n[a],o[s+a]=i[a];0===t.websocket.bufferedAmount&&t.websocket.send(o)}}}return this}},{key:"close",value:function(){return this.websocket instanceof WebSocket&&(this.isActive=!1,this.paused=!0,this.connect(),this.websocket.close(),this.websocket=null),this}},{key:"isConnected",value:function(){return this.websocket instanceof WebSocket&&this.websocket.readyState===WebSocket.OPEN}},{key:"state",value:function(t,e,r){var n=this;if(void 0===t)return this.isActive;"[object Function]"===Object.prototype.toString.call(r)&&r();var i=window.setInterval((function(){n.websocket instanceof WebSocket&&0!==n.websocket.bufferedAmount||("toggle"===String(t).toLowerCase()?n.isActive=!n.isActive:n.isActive=Boolean(t),n.connect(),"[object Function]"===Object.prototype.toString.call(e)&&e(),window.clearInterval(i))}),10);return this}},{key:"get",value:function(){return this.websocket}},{key:"INPUT",get:function(){return this.sender}},{key:"OUTPUT",get:function(){return this.sender}},{key:"toString",value:function(){return"[SoundModule Session]"}}],r&&et(e.prototype,r),s}(e);function ct(t){return ct="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ct(t)}function ut(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function lt(t,e){return lt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},lt(t,e)}function ft(t,e){if(e&&("object"===ct(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function ht(t){return ht=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ht(t)}(st="BUFFER_SIZE")in(ot=at)?Object.defineProperty(ot,st,{value:2048,enumerable:!0,configurable:!0,writable:!0}):ot[st]=2048;var pt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&lt(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=ht(n);if(i){var r=ht(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return ft(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this)).isActive=!0,r.context=t,r.input=t.createGain(),r.output=t.createGain(),r.lfo=t.createOscillator(),r.depth=t.createGain(),r.rate=r.lfo.frequency,r.processor=t.createScriptProcessor(e,2,2),r.lfo.start=r.lfo.start||r.lfo.noteOn,r.lfo.stop=r.lfo.stop||r.lfo.noteOff,r.values={},r.isStop=!0,r}return e=s,(r=[{key:"param",value:function(){return this}},{key:"connect",value:function(){return this}},{key:"start",value:function(t){if(this.isActive&&this.isStop){var e=parseFloat(t);(isNaN(e)||e<this.context.currentTime)&&(e=this.context.currentTime),this.lfo.start(e),this.isStop=!1}return this}},{key:"stop",value:function(t,e){if(this.isActive&&!this.isStop){var r=parseFloat(t),n=parseFloat(e);(isNaN(r)||r<this.context.currentTime)&&(r=this.context.currentTime),(isNaN(n)||n<0)&&(n=0);var i=this.lfo.type,o=this.lfo.frequency.value;this.lfo.stop(r+n),this.lfo=this.context.createOscillator(),this.lfo.start=this.lfo.start||this.lfo.noteOn,this.lfo.stop=this.lfo.stop||this.lfo.noteOff,this.lfo.type=i,this.lfo.frequency.value=o,this.rate=this.lfo.frequency,this.isStop=!0}return this}},{key:"state",value:function(t){return void 0===t?this.isActive:("toggle"===String(t).toLowerCase()?this.isActive=!this.isActive:this.isActive=Boolean(t),this.connect(),this.start(this.context.currentTime),this)}},{key:"params",value:function(){return{}}},{key:"toJSON",value:function(){return JSON.stringify(this.params())}},{key:"INPUT",get:function(){return this.input}},{key:"OUTPUT",get:function(){return this.output}},{key:"toString",value:function(){return"[SoundModule Effector]"}}])&&ut(e.prototype,r),s}(e);function yt(t){return yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yt(t)}function vt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function dt(t,e,r){return dt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=gt(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},dt(t,e,r||t)}function bt(t,e){return bt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},bt(t,e)}function mt(t,e){if(e&&("object"===yt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function gt(t){return gt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},gt(t)}var wt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&bt(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=gt(n);if(i){var r=gt(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return mt(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).panner=t.createStereoPanner(),r.panner.pan.value=0,r.depth.gain.value=0,r.rate.value=0,r.state(!1),r.lfo.connect(r.depth),r.depth.connect(r.panner.pan),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"depth":if(void 0===e)return this.depth.gain.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.depth.gain.value=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.rate.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.panner.disconnect(0),this.isActive?(this.input.connect(this.panner),this.panner.connect(this.output)):this.input.connect(this.output),this}},{key:"stop",value:function(t,e){return dt(gt(s.prototype),"stop",this).call(this,t,e),this.isActive&&(this.lfo.connect(this.depth),this.depth.connect(this.panner.pan)),this}},{key:"params",value:function(){return{state:this.isActive,depth:this.depth.gain.value,rate:this.rate.value}}},{key:"toString",value:function(){return"[SoundModule Autopanner]"}}],r&&vt(e.prototype,r),s}(pt);function St(t){return St="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},St(t)}function Ot(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function At(t,e,r){return At="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Et(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},At(t,e,r||t)}function kt(t,e){return kt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},kt(t,e)}function Tt(t,e){if(e&&("object"===St(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Et(t){return Et=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Et(t)}var jt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&kt(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Et(n);if(i){var r=Et(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Tt(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).amplitudeL=t.createGain(),r.amplitudeR=t.createGain(),r.splitter=t.createChannelSplitter(2),r.merger=t.createChannelMerger(2),r.amplitudeL.gain.value=1,r.amplitudeR.gain.value=1,r.depth.gain.value=0,r.rate.value=0,r.state(!1),r.lfoSplitter=t.createChannelSplitter(2),r.lfo.connect(r.depth),r.depth.connect(r.processor),r.processor.connect(r.lfoSplitter),r.lfoSplitter.connect(r.amplitudeL.gain,0),r.lfoSplitter.connect(r.amplitudeR.gain,1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"depth":if(void 0===e)return this.depth.gain.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.depth.gain.value=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.rate.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.amplitudeL.disconnect(0),this.amplitudeR.disconnect(0),this.splitter.disconnect(0),this.splitter.disconnect(1),this.merger.disconnect(0),this.isActive?(this.input.connect(this.splitter),this.splitter.connect(this.amplitudeL,0,0),this.splitter.connect(this.amplitudeR,1,0),this.amplitudeL.connect(this.merger,0,0),this.amplitudeR.connect(this.merger,0,1),this.merger.connect(this.output)):this.input.connect(this.output),this}},{key:"start",value:function(t){var e=this;if(this.isActive&&this.isStop){var r=parseFloat(t);(isNaN(r)||r<this.context.currentTime)&&(r=this.context.currentTime),this.lfo.start(r),this.isStop=!1;var n=this.processor.bufferSize;this.processor.onaudioprocess=function(t){var r=t.inputBuffer.getChannelData(0),i=t.outputBuffer.getChannelData(0),o=t.outputBuffer.getChannelData(1);if(e.isActive&&0!==e.depth.gain.value&&0!==e.rate.value)for(var s=0;s<n;s++)i[s]=r[s],o[s]=-r[s];else for(var a=0;a<n;a++)i[a]=0,o[a]=0}}return this}},{key:"stop",value:function(t,e){return At(Et(s.prototype),"stop",this).call(this,t,e),this.isActive&&(this.processor.disconnect(0),this.processor.onaudioprocess=null,this.lfo.connect(this.depth),this.depth.connect(this.processor),this.processor.connect(this.lfoSplitter),this.lfoSplitter.connect(this.amplitudeL.gain,0),this.lfoSplitter.connect(this.amplitudeR.gain,1)),this}},{key:"params",value:function(){return{state:this.isActive,depth:this.depth.gain.value,rate:this.rate.value}}},{key:"toString",value:function(){return"[SoundModule AutopannerFallback]"}}],r&&Ot(e.prototype,r),s}(pt);function Rt(t){return Rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Rt(t)}function Pt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function xt(t,e,r){return xt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Ct(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},xt(t,e,r||t)}function _t(t,e){return _t=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},_t(t,e)}function Mt(t,e){if(e&&("object"===Rt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Ct(t){return Ct=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Ct(t)}var Ft=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_t(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Ct(n);if(i){var r=Ct(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Mt(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).delay=t.createDelay(),r.mix=t.createGain(),r.tone=t.createBiquadFilter(),r.feedback=t.createGain(),r.delay.delayTime.value=0,r.depth.gain.value=0,r.rate.value=0,r.mix.gain.value=0,r.tone.type="string"==typeof r.tone.type?"lowpass":r.tone.LOWPASS||0,r.tone.frequency.value=350,r.tone.Q.value=Math.SQRT1_2,r.tone.gain.value=0,r.feedback.gain.value=0,r.depthRate=0,r.state(!1),r.lfo.connect(r.depth),r.depth.connect(r.delay.delayTime),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"delaytime":case"time":if(void 0===e)return this.delay.delayTime.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.delay.delayTime.value=i,this.depth.gain.value=this.delay.delayTime.value*this.depthRate);break;case"depth":if(void 0===e)return this.depthRate;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.depth.gain.value=this.delay.delayTime.value*i,this.depthRate=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.rate.value=i);break;case"mix":case"feedback":if(void 0===e)return this[n].gain.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this[n].gain.value=i);break;case"tone":if(void 0===e)return this.tone.frequency.value;i=parseFloat(e),o=10,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.tone.frequency.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.delay.disconnect(0),this.mix.disconnect(0),this.tone.disconnect(0),this.feedback.disconnect(0),this.input.connect(this.output),this.isActive&&(this.input.connect(this.tone),this.tone.connect(this.delay),this.delay.connect(this.mix),this.mix.connect(this.output),this.delay.connect(this.feedback),this.feedback.connect(this.delay)),this}},{key:"stop",value:function(t,e){return xt(Ct(s.prototype),"stop",this).call(this,t,e),this.isActive&&(this.lfo.connect(this.depth),this.depth.connect(this.delay.delayTime)),this}},{key:"params",value:function(){return{state:this.isActive,time:this.delay.delayTime.value,depth:this.depthRate,rate:this.rate.value,mix:this.mix.gain.value,tone:this.tone.frequency.value,feedback:this.feedback.gain.value}}},{key:"toString",value:function(){return"[SoundModule Chorus]"}}],r&&Pt(e.prototype,r),s}(pt);function It(t){return It="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},It(t)}function Nt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Lt(t,e){return Lt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Lt(t,e)}function Dt(t,e){if(e&&("object"===It(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Bt(t){return Bt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Bt(t)}var Ut=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Lt(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Bt(n);if(i){var r=Bt(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Dt(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).compressor=t.createDynamicsCompressor(),r.compressor.threshold.value=-24,r.compressor.knee.value=30,r.compressor.ratio.value=12,r.compressor.attack.value=.003,r.compressor.release.value=.25,r.state(!0),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase();if(n in this.compressor){if(void 0===e)return this.compressor[n].value;var i=parseFloat(e),o={threshold:-100,knee:0,ratio:1,attack:0,release:0},s={threshold:0,knee:40,ratio:20,attack:1,release:1},a=o[n],c=s[n];i>=a&&i<=c&&(this.compressor[n].value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.compressor.disconnect(0),this.isActive?(this.input.connect(this.compressor),this.compressor.connect(this.output)):this.input.connect(this.output),this}},{key:"params",value:function(){return{state:this.isActive,threshold:this.compressor.threshold.value,knee:this.compressor.knee.value,ratio:this.compressor.ratio.value,attack:this.compressor.attack.value,release:this.compressor.release.value}}},{key:"toString",value:function(){return"[SoundModule Compressor]"}}],r&&Nt(e.prototype,r),s}(pt);function qt(t){return qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qt(t)}function Vt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Gt(t,e){return Gt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Gt(t,e)}function zt(t,e){if(e&&("object"===qt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Xt(t){return Xt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Xt(t)}var Wt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Gt(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Xt(n);if(i){var r=Xt(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return zt(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).delay=t.createDelay(s.MAX_DELAY_TIME),r.dry=t.createGain(),r.wet=t.createGain(),r.tone=t.createBiquadFilter(),r.feedback=t.createGain(),r.delay.delayTime.value=0,r.dry.gain.value=1,r.wet.gain.value=0,r.tone.type="string"==typeof r.tone.type?"lowpass":r.tone.LOWPASS||0,r.tone.frequency.value=350,r.tone.Q.value=Math.SQRT1_2,r.tone.gain.value=0,r.feedback.gain.value=0,r.state(!1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,a=null;switch(n){case"delaytime":case"time":if(void 0===e)return this.delay.delayTime.value;i=parseFloat(e),o=0,a=s.MAX_DELAY_TIME,i>=o&&i<=a&&(this.delay.delayTime.value=i);break;case"dry":case"wet":case"feedback":if(void 0===e)return this[n].gain.value;a=1,(i=parseFloat(e))>=(o=0)&&i<=a&&(this[n].gain.value=i);break;case"tone":if(void 0===e)return this.tone.frequency.value;i=parseFloat(e),o=10,a=this.context.sampleRate/2,i>=o&&i<=a&&(this.tone.frequency.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.delay.disconnect(0),this.dry.disconnect(0),this.wet.disconnect(0),this.tone.disconnect(0),this.feedback.disconnect(0),this.isActive?(this.input.connect(this.dry),this.dry.connect(this.output),this.input.connect(this.tone),this.tone.connect(this.delay),this.delay.connect(this.wet),this.wet.connect(this.output),this.delay.connect(this.feedback),this.feedback.connect(this.delay)):this.input.connect(this.output),this}},{key:"params",value:function(){return{state:this.isActive,time:this.delay.delayTime.value,dry:this.dry.gain.value,wet:this.wet.gain.value,tone:this.tone.frequency.value,feedback:this.feedback.gain.value}}},{key:"toString",value:function(){return"[SoundModule Delay]"}}],r&&Vt(e.prototype,r),s}(pt);function Ht(t){return Ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ht(t)}function Yt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Qt(t,e){return Qt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Qt(t,e)}function Zt(t,e){if(e&&("object"===Ht(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function $t(t){return $t=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},$t(t)}function Jt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:5,enumerable:!0,configurable:!0,writable:!0}):t[e]=5}(Wt,"MAX_DELAY_TIME");var Kt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Qt(t,e)}(a,t);var e,r,n,i,o,s=(i=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=$t(i);if(o){var r=$t(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Zt(this,t)});function a(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(r=s.call(this,t,e)).distortion=t.createWaveShaper(),r.drive=t.createGain(),r.color=t.createBiquadFilter(),r.tone=t.createBiquadFilter(),r.type=a.CLEAN,r.amount=.5,r.numberOfSamples=4096,r.drive.gain.value=1,r.color.type="string"==typeof r.color.type?"bandpass":r.color.BANDPASS||2,r.color.frequency.value=350,r.color.Q.value=Math.SQRT1_2,r.color.gain.value=0,r.tone.type="string"==typeof r.tone.type?"lowpass":r.tone.LOWPASS||0,r.tone.frequency.value=350,r.tone.Q.value=Math.SQRT1_2,r.tone.gain.value=0,r.state(!1),r}return e=a,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"curve":if(void 0===e)return this.distortion.curve;var c=null;switch(String(e).toLowerCase()){case a.CLEAN:this.type=a.CLEAN,c=a.createCurve(a.CLEAN,this.amount,this.numberOfSamples);break;case a.CRUNCH:this.type=a.CRUNCH,c=a.createCurve(a.CRUNCH,this.amount,this.numberOfSamples);break;case a.OVERDRIVE:this.type=a.OVERDRIVE,c=a.createCurve(a.OVERDRIVE,this.amount,this.numberOfSamples);break;case a.DISTORTION:this.type=a.DISTORTION,c=a.createCurve(a.DISTORTION,this.amount,this.numberOfSamples);break;case a.FUZZ:this.type=a.FUZZ,c=a.createCurve(a.FUZZ,this.amount,this.numberOfSamples);break;default:e instanceof Float32Array&&(c=e)}this.distortion.curve=c;break;case"amount":if(void 0===e)return this.amount;(i=parseFloat(e))>0&&i<1&&(this.amount=i,this.param("curve",this.type));break;case"samples":if(void 0===e)return this.numberOfSamples;(i=parseInt(e,10))>=0&&(this.numberOfSamples=i,this.param("curve",this.type));break;case"drive":if(void 0===e)return this.drive.gain.value;s=100,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.drive.gain.value=i);break;case"color":case"tone":if(void 0===e)return this[n].frequency.value;i=parseFloat(e),o=10,s=this.context.sampleRate/2,i>=o&&i<=s&&(this[n].frequency.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.color.disconnect(0),this.drive.disconnect(0),this.distortion.disconnect(0),this.tone.disconnect(0),this.isActive?(this.input.connect(this.color),this.color.connect(this.drive),this.drive.connect(this.distortion),this.distortion.connect(this.tone),this.tone.connect(this.output)):this.input.connect(this.output),this}},{key:"params",value:function(){return{state:this.isActive,curve:this.type,amount:this.amount,samples:this.numberOfSamples,drive:this.drive.gain.value,color:this.color.frequency.value,tone:this.tone.frequency.value}}},{key:"toString",value:function(){return"[SoundModule Distortion]"}}],n=[{key:"createCurve",value:function(t,e,r){if(e>0&&e<1){var n=new Float32Array(r),i=0,o=0,s=0,c=0,u=0;switch(t){case a.CRUNCH:s=1-e>.99?.99:1-e;for(var l=0;l<r;l++)i=2*l/r-1,(u=Math.abs(i))<s?o=u:u>s?o=s+(u-s)/(1+Math.pow((u-s)/(1-s),2)):u>1&&(o=u),n[l]=(0===i?1:Math.abs(i)/i)*o*(1/((s+1)/2));break;case a.OVERDRIVE:c=2*e/(1-e);for(var f=0;f<r;f++){var h=2*(f-0)/(r-0)-1;n[f]=(1+c)*h/(1+c*Math.abs(h))}break;case a.DISTORTION:s=1-e;for(var p=0;p<r;p++)o=(i=2*p/r-1)<0?-Math.pow(Math.abs(i),s+.04):Math.pow(i,s),n[p]=(Math.exp(2*o)-Math.exp(-2*o))/(Math.exp(2*o)+Math.exp(-2*o));break;case a.FUZZ:for(var y=0;y<r;y++)i=2*y/r-1,o=(.5*Math.pow(i+1.4,2)-1)*o>=0?5.8:1.2,n[y]=(Math.exp(o)-Math.exp(-o))/(Math.exp(o)+Math.exp(-o));break;case a.CLEAN:default:return null}return n}return null}}],r&&Yt(e.prototype,r),n&&Yt(e,n),a}(pt);function te(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return ee(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ee(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function ee(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function re(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}Jt(Kt,"CLEAN","clean"),Jt(Kt,"CRUNCH","crunch"),Jt(Kt,"OVERDRIVE","overdrive"),Jt(Kt,"DISTORTION","distortion"),Jt(Kt,"FUZZ","fuzz");var ne=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.context=e,this.generators=[],this.activeIndexes=[],this.activeCounter=0,this.attack=.01,this.decay=.3,this.sustain=.5,this.release=1}var e,r;return e=t,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null;switch(n){case"attack":case"sustain":if(void 0===e)return this[n];(i=parseFloat(e))>=0&&(this[n]=i);break;case"decay":case"release":if(void 0===e)return this[n];(i=parseFloat(e))>0&&(this[n]=i)}}return this}},{key:"ready",value:function(t,e,r){var n=parseInt(t,10)>=0?parseInt(t,10):0;return e instanceof AudioNode&&r instanceof AudioNode?(e.connect(this.generators[n]),this.generators[n].connect(r)):e instanceof AudioNode?e.connect(this.generators[n]):r instanceof AudioNode&&this.generators[n].connect(r),this.activeIndexes[n]=n,this.activeCounter++,this}},{key:"start",value:function(t){var e=parseFloat(t);(isNaN(e)||e<this.context.currentTime)&&(e=this.context.currentTime);var r,n=e,i=n+this.attack,o=this.decay,s=this.sustain,a=te(this.activeIndexes);try{for(a.s();!(r=a.n()).done;){var c=r.value;void 0!==c&&(this.generators[c].gain.cancelScheduledValues(n),this.generators[c].gain.setValueAtTime(0,n),this.generators[c].gain.linearRampToValueAtTime(1,i),this.generators[c].gain.setTargetAtTime(s,i,o))}}catch(t){a.e(t)}finally{a.f()}return this}},{key:"stop",value:function(t,e){var r=parseFloat(t)-this.release;(isNaN(r)||r<this.context.currentTime)&&(r=this.context.currentTime);var n,i=r,o=this.release,s=te(this.activeIndexes);try{for(s.s();!(n=s.n()).done;){var a=n.value;void 0!==a&&(this.generators[a].gain.cancelScheduledValues(i),e?this.generators[a].gain.setValueCurveAtTime(new Float32Array([1,.5,.25,0]),i,o):this.generators[a].gain.setTargetAtTime(0,i,o))}}catch(t){s.e(t)}finally{s.f()}return this}},{key:"getGenerator",value:function(t){var e=parseInt(t,10)>=0?parseInt(t,10):0;return this.generators[e]}},{key:"setGenerator",value:function(t){var e=parseInt(t,10)>=0?parseInt(t,10):0;return this.generators[e]=this.context.createGain(),this.generators[e].gain.setTargetAtTime=this.generators[e].gain.setTargetAtTime||this.generators[e].gain.setTargetValueAtTime,this}},{key:"isStop",value:function(){var e,r=0,n=te(this.activeIndexes);try{for(n.s();!(e=n.n()).done;){var i=e.value;if(void 0!==i){if(this.generators[i].gain.value>t.MIN_GAIN)return!1;if(++r===this.activeCounter)return!0}}}catch(t){n.e(t)}finally{n.f()}}},{key:"clear",value:function(t){this.activeIndexes.length=0,this.activeCounter=0;var e,r=te(this.generators);try{for(r.s();!(e=r.n()).done;){var n=e.value;n.gain.cancelScheduledValues(this.context.currentTime),n.gain.value=1,t&&n.disconnect(0)}}catch(t){r.e(t)}finally{r.f()}return this}},{key:"params",value:function(){return{attack:this.attack,decay:this.decay,sustain:this.sustain,release:this.release}}},{key:"toJSON",value:function(){return JSON.stringify(this.params())}},{key:"toString",value:function(){return"[SoundModule EnvelopeGenerator]"}}],r&&re(e.prototype,r),t}();function ie(t){return ie="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ie(t)}function oe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function se(t,e){return se=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},se(t,e)}function ae(t,e){if(e&&("object"===ie(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function ce(t){return ce=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ce(t)}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:.001,enumerable:!0,configurable:!0,writable:!0}):t[e]=.001}(ne,"MIN_GAIN");var ue=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&se(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=ce(n);if(i){var r=ce(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return ae(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).bass=t.createBiquadFilter(),r.middle=t.createBiquadFilter(),r.treble=t.createBiquadFilter(),r.presence=t.createBiquadFilter(),r.bass.type="string"==typeof r.bass.type?"lowshelf":r.bass.LOWSHELF||3,r.middle.type="string"==typeof r.middle.type?"peaking":r.middle.PEAKING||5,r.treble.type="string"==typeof r.treble.type?"peaking":r.treble.PEAKING||5,r.presence.type="string"==typeof r.presence.type?"highshelf":r.presence.HIGHSHELF||4,r.bass.frequency.value=500,r.middle.frequency.value=1e3,r.treble.frequency.value=2e3,r.presence.frequency.value=4e3,r.middle.Q.value=Math.SQRT1_2,r.treble.Q.value=Math.SQRT1_2,r.bass.gain.value=0,r.middle.gain.value=0,r.treble.gain.value=0,r.presence.gain.value=0,r.state(!1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null;switch(n){case"bass":case"middle":case"treble":case"presence":if(void 0===e)return this[n].gain.value;o=40,(i=parseFloat(e))>=-40&&i<=o&&(this[n].gain.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.bass.disconnect(0),this.middle.disconnect(0),this.treble.disconnect(0),this.presence.disconnect(0),this.isActive?(this.input.connect(this.bass),this.bass.connect(this.middle),this.middle.connect(this.treble),this.treble.connect(this.presence),this.presence.connect(this.output)):this.input.connect(this.output),this}},{key:"params",value:function(){return{state:this.isActive,bass:this.bass.gain.value,middle:this.middle.gain.value,treble:this.treble.gain.value,presence:this.presence.gain.value}}},{key:"toString",value:function(){return"[SoundModule Equalizer]"}}],r&&oe(e.prototype,r),s}(pt);function le(t){return le="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},le(t)}function fe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function he(t,e){return he=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},he(t,e)}function pe(t,e){if(e&&("object"===le(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function ye(t){return ye=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ye(t)}var ve=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&he(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=ye(n);if(i){var r=ye(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return pe(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).filter=t.createBiquadFilter(),r.filter.frequency.setTargetAtTime=r.filter.frequency.setTargetAtTime||r.filter.frequency.setTargetValueAtTime,r.filter.type="string"==typeof r.filter.type?"lowpass":r.filter.LOWPASS||0,r.filter.frequency.value=350,r.filter.Q.value=1,r.filter.gain.value=0,r.maxFrequency=r.filter.frequency.value,r.range=.1,r.attack=.01,r.decay=.3,r.sustain=1,r.release=1,r.state(!1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,a=null;switch(n){case"type":if(void 0===e)return this.filter.type;(i=String(e).toLowerCase())in s.FILTER_TYPES&&(this.filter.type="string"==typeof this.filter.type?i:s.FILTER_TYPES[i]);break;case"frequency":case"cutoff":if(void 0===e)return this.filter.frequency.value;i=parseFloat(e),o=10,a=this.context.sampleRate/2,i>=o&&i<=a&&(this.maxFrequency=i,this.filter.frequency.value=i);break;case"gain":if(void 0===e)return this.filter.gain.value;a=40,(i=parseFloat(e))>=(o=-40)&&i<=a&&(this.filter.gain.value=i);break;case"q":if(void 0===e)return this.filter.Q.value;a=1e3,(i=parseFloat(e))>=(o=1e-4)&&i<=a&&(this.filter.Q.value=i);break;case"range":if(void 0===e)return this.range;a=1,(i=parseFloat(e))>=(o=0)&&i<=a&&(this.range=i);break;case"attack":case"sustain":if(void 0===e)return this[n];(i=parseFloat(e))>=0&&(this[n]=i);break;case"decay":case"release":if(void 0===e)return this[n];(i=parseFloat(e))>0&&(this[n]=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.filter.disconnect(0),this.isActive?(this.input.connect(this.filter),this.filter.connect(this.output)):this.input.connect(this.output),this}},{key:"start",value:function(t){if(this.isActive){var e=parseFloat(t);(isNaN(e)||e<this.context.currentTime)&&(e=this.context.currentTime);var r=e,n=r+this.attack,i=this.decay,o=this.sustain*this.maxFrequency,s=this.maxFrequency*this.range;this.filter.frequency.cancelScheduledValues(r),this.filter.frequency.setValueAtTime(s,r),this.filter.frequency.linearRampToValueAtTime(this.maxFrequency,n),this.filter.frequency.setTargetAtTime(o,n,i)}return this}},{key:"stop",value:function(t){if(this.isActive){var e=parseFloat(t)-this.release;(isNaN(e)||e<this.context.currentTime)&&(e=this.context.currentTime);var r=e,n=this.release,i=this.maxFrequency*this.range;this.filter.frequency.cancelScheduledValues(r),this.filter.frequency.setValueAtTime(this.filter.frequency.value,r),this.filter.frequency.setTargetAtTime(i,r,n)}return this}},{key:"state",value:function(t){return void 0===t?this.isActive:("toggle"===String(t).toLowerCase()?this.isActive=!this.isActive:this.isActive=Boolean(t),this.connect(),this)}},{key:"params",value:function(){return{state:this.isActive,type:this.filter.type,frequency:this.filter.frequency.value,Q:this.filter.Q.value,gain:this.filter.gain.value,range:this.range,attack:this.attack,decay:this.decay,sustain:this.sustain,release:this.release}}},{key:"toString",value:function(){return"[SoundModule Filter]"}}],r&&fe(e.prototype,r),s}(pt);function de(t){return de="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},de(t)}function be(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function me(t,e,r){return me="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Se(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},me(t,e,r||t)}function ge(t,e){return ge=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},ge(t,e)}function we(t,e){if(e&&("object"===de(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Se(t){return Se=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Se(t)}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(ve,"FILTER_TYPES",{lowpass:0,highpass:1,bandpass:2,lowshelf:3,highshelf:4,peaking:5,notch:6,allpass:7});var Oe=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ge(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Se(n);if(i){var r=Se(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return we(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).delay=t.createDelay(),r.mix=t.createGain(),r.tone=t.createBiquadFilter(),r.feedback=t.createGain(),r.delay.delayTime.value=0,r.depth.gain.value=0,r.rate.value=0,r.mix.gain.value=0,r.tone.type="string"==typeof r.tone.type?"lowpass":r.tone.LOWPASS||0,r.tone.frequency.value=350,r.tone.Q.value=Math.SQRT1_2,r.tone.gain.value=0,r.feedback.gain.value=0,r.depthRate=0,r.state(!1),r.lfo.connect(r.depth),r.depth.connect(r.delay.delayTime),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"delaytime":case"time":if(void 0===e)return this.delay.delayTime.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.delay.delayTime.value=i,this.depth.gain.value=this.delay.delayTime.value*this.depthRate);break;case"depth":if(void 0===e)return this.depthRate;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.depth.gain.value=this.delay.delayTime.value*i,this.depthRate=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.rate.value=i);break;case"mix":case"feedback":if(void 0===e)return this[n].gain.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this[n].gain.value=i);break;case"tone":if(void 0===e)return this.tone.frequency.value;i=parseFloat(e),o=10,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.tone.frequency.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.delay.disconnect(0),this.mix.disconnect(0),this.tone.disconnect(0),this.feedback.disconnect(0),this.input.connect(this.output),this.isActive&&(this.input.connect(this.tone),this.tone.connect(this.delay),this.delay.connect(this.mix),this.mix.connect(this.output),this.delay.connect(this.feedback),this.feedback.connect(this.delay)),this}},{key:"stop",value:function(t,e){return me(Se(s.prototype),"stop",this).call(this,t,e),this.isActive&&(this.lfo.connect(this.depth),this.depth.connect(this.delay.delayTime)),this}},{key:"params",value:function(){return{state:this.isActive,time:this.delay.delayTime.value,depth:this.depthRate,rate:this.rate.value,mix:this.mix.gain.value,tone:this.tone.frequency.value,feedback:this.feedback.gain.value}}},{key:"toString",value:function(){return"[SoundModule Flanger]"}}],r&&be(e.prototype,r),s}(pt);function Ae(t){return Ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ae(t)}function ke(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Te(t,e){return Te=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Te(t,e)}function Ee(t,e){if(e&&("object"===Ae(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function je(t){return je=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},je(t)}var Re=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Te(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=je(n);if(i){var r=je(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Ee(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).listener=t.listener,r.positions={x:0,y:0,z:0},r.forwards={x:0,y:0,z:-1},r.ups={x:0,y:1,z:0},r.listener.positionX instanceof AudioParam&&r.listener.positionY instanceof AudioParam&&r.listener.positionZ instanceof AudioParam?(r.listener.positionX.setValueAtTime(r.positions.x,t.currentTime),r.listener.positionY.setValueAtTime(r.positions.y,t.currentTime),r.listener.positionZ.setValueAtTime(r.positions.z,t.currentTime)):r.listener.setPosition(r.positions.x,r.positions.y,r.positions.z),r.listener.forwardX instanceof AudioParam&&r.listener.forwardY instanceof AudioParam&&r.listener.forwardZ instanceof AudioParam&&r.listener.upX instanceof AudioParam&&r.listener.upY instanceof AudioParam&&r.listener.upZ instanceof AudioParam?(r.listener.forwardX.setValueAtTime(r.forwards.x,t.currentTime),r.listener.forwardY.setValueAtTime(r.forwards.y,t.currentTime),r.listener.forwardZ.setValueAtTime(r.forwards.z,t.currentTime),r.listener.upX.setValueAtTime(r.ups.x,t.currentTime),r.listener.upY.setValueAtTime(r.ups.y,t.currentTime),r.listener.upZ.setValueAtTime(r.ups.z,t.currentTime)):r.listener.setOrientation(r.forwards.x,r.forwards.y,r.forwards.z,r.ups.x,r.ups.y,r.ups.z),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null;switch(n){case"x":case"y":case"z":if(void 0===e)return this.positions[n];i=parseFloat(e),isNaN(i)||(this.positions[n]=i,this.listener.positionX instanceof AudioParam&&this.listener.positionY instanceof AudioParam&&this.listener.positionZ instanceof AudioParam?(this.listener.positionX.setValueAtTime(this.positions.x,this.context.currentTime),this.listener.positionY.setValueAtTime(this.positions.y,this.context.currentTime),this.listener.positionZ.setValueAtTime(this.positions.z,this.context.currentTime)):this.listener.setPosition(this.positions.x,this.positions.y,this.positions.z));break;case"fx":case"fy":case"fz":if(void 0===e)return this.forwards[n.charAt(1)];i=parseFloat(e),isNaN(i)||(this.forwards[n.charAt(1)]=i,this.listener.forwardX instanceof AudioParam&&this.listener.forwardY instanceof AudioParam&&this.listener.forwardZ instanceof AudioParam&&this.listener.upX instanceof AudioParam&&this.listener.upY instanceof AudioParam&&this.listener.upZ instanceof AudioParam?(this.listener.forwardX.setValueAtTime(this.forwards.x,this.context.currentTime),this.listener.forwardY.setValueAtTime(this.forwards.y,this.context.currentTime),this.listener.forwardZ.setValueAtTime(this.forwards.z,this.context.currentTime),this.listener.upX.setValueAtTime(this.ups.x,this.context.currentTime),this.listener.upY.setValueAtTime(this.ups.y,this.context.currentTime),this.listener.upZ.setValueAtTime(this.ups.z,this.context.currentTime)):this.listener.setOrientation(this.forwards.x,this.forwards.y,this.forwards.z,this.ups.x,this.ups.y,this.ups.z));break;case"ux":case"uy":case"uz":if(void 0===e)return this.ups[n.charAt(1)];i=parseFloat(e),isNaN(i)||(this.ups[n.charAt(1)]=i,this.listener.forwardX instanceof AudioParam&&this.listener.forwardY instanceof AudioParam&&this.listener.forwardZ instanceof AudioParam&&this.listener.upX instanceof AudioParam&&this.listener.upY instanceof AudioParam&&this.listener.upZ instanceof AudioParam?(this.listener.forwardX.setValueAtTime(this.forwards.x,this.context.currentTime),this.listener.forwardY.setValueAtTime(this.forwards.y,this.context.currentTime),this.listener.forwardZ.setValueAtTime(this.forwards.z,this.context.currentTime),this.listener.upX.setValueAtTime(this.ups.x,this.context.currentTime),this.listener.upY.setValueAtTime(this.ups.y,this.context.currentTime),this.listener.upZ.setValueAtTime(this.ups.z,this.context.currentTime)):this.listener.setOrientation(this.forwards.x,this.forwards.y,this.forwards.z,this.ups.x,this.ups.y,this.ups.z))}}return this}},{key:"params",value:function(){return{state:this.isActive,positions:this.positions,forwards:this.forwards,ups:this.ups}}},{key:"toJSON",value:function(){return JSON.stringify(this.params())}},{key:"toString",value:function(){return"[SoundModule Listener]"}}],r&&ke(e.prototype,r),s}(pt);function Pe(t){return Pe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pe(t)}function xe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _e(t,e){return _e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},_e(t,e)}function Me(t,e){if(e&&("object"===Pe(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Ce(t){return Ce=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Ce(t)}function Fe(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ie=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_e(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Ce(n);if(i){var r=Ce(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Me(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).panner=t.createPanner(),r.positions={x:0,y:0,z:0},r.orientations={x:1,y:0,z:0},r.panner.refDistance=1,r.panner.maxDistance=1e4,r.panner.rolloffFactor=1,r.panner.coneInnerAngle=360,r.panner.coneOuterAngle=360,r.panner.coneOuterGain=0,r.panner.panningModel="string"==typeof r.panner.panningModel?"HRTF":r.panner.HRTF||1,r.panner.distanceModel="string"==typeof r.panner.distanceModel?"inverse":r.panner.INVERSE_DISTANCE||1,r.panner.positionX instanceof AudioParam&&r.panner.positionY instanceof AudioParam&&r.panner.positionZ instanceof AudioParam?(r.panner.positionX.setValueAtTime(r.positions.x,t.currentTime),r.panner.positionY.setValueAtTime(r.positions.y,t.currentTime),r.panner.positionZ.setValueAtTime(r.positions.z,t.currentTime)):r.panner.setPosition(r.positions.x,r.positions.y,r.positions.z),r.panner.orientationX instanceof AudioParam&&r.panner.orientationY instanceof AudioParam&&r.panner.orientationZ instanceof AudioParam?(r.panner.orientationX.setValueAtTime(r.orientations.x,t.currentTime),r.panner.orientationY.setValueAtTime(r.orientations.y,t.currentTime),r.panner.orientationZ.setValueAtTime(r.orientations.z,t.currentTime)):r.panner.setOrientation(r.orientations.x,r.orientations.y,r.orientations.z),r.state(!1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null;switch(n){case"x":case"y":case"z":if(void 0===e)return this.positions[n];i=parseFloat(e),isNaN(i)||(this.positions[n]=i,this.panner.positionX instanceof AudioParam&&this.panner.positionY instanceof AudioParam&&this.panner.positionZ instanceof AudioParam?(this.panner.positionX.setValueAtTime(this.positions.x,this.context.currentTime),this.panner.positionY.setValueAtTime(this.positions.y,this.context.currentTime),this.panner.positionZ.setValueAtTime(this.positions.z,this.context.currentTime)):this.panner.setPosition(this.positions.x,this.positions.y,this.positions.z));break;case"ox":case"oy":case"oz":if(void 0===e)return this.orientations[n.charAt(1)];i=parseFloat(e),isNaN(i)||(this.orientations[n.charAt(1)]=i,this.panner.orientationX instanceof AudioParam&&this.panner.orientationY instanceof AudioParam&&this.panner.orientationZ instanceof AudioParam?(this.panner.orientationX.setValueAtTime(this.orientations.x,this.context.currentTime),this.panner.orientationY.setValueAtTime(this.orientations.y,this.context.currentTime),this.panner.orientationZ.setValueAtTime(this.orientations.z,this.context.currentTime)):this.panner.setOrientation(this.orientations.x,this.orientations.y,this.orientations.z));break;case"refdistance":if(void 0===e)return this.panner.refDistance;(i=parseFloat(e))>=0&&(this.panner.refDistance=i);break;case"maxdistance":if(void 0===e)return this.panner.maxDistance;(i=parseFloat(e))>0&&(this.panner.maxDistance=i);break;case"rollofffactor":if(void 0===e)return this.panner.rolloffFactor;(i=parseFloat(e))>=0&&(this.panner.rolloffFactor=i);break;case"coneinnerangle":if(void 0===e)return this.panner.coneInnerAngle;(i=parseFloat(e))>=0&&i<=360&&(this.panner.coneInnerAngle=i);break;case"coneouterangle":if(void 0===e)return this.panner.coneOuterAngle;(i=parseFloat(e))>=0&&i<=360&&(this.panner.coneOuterAngle=i);break;case"coneoutergain":if(i>=0&&i<=1)return this.panner.coneOuterGain;i=parseFloat(e),isNaN(i)||(this.panner.coneOuterGain=i);break;case"panningmodel":if(void 0===e)return this.panner.panningModel;(i=/HRTF/i.test(e)?String(e).toUpperCase():String(e).toLowerCase())in s.PANNING_MODELS&&(this.panner.panningModel="string"==typeof this.panner.panningModel?i:s.PANNING_MODELS[i]);break;case"distancemodel":if(void 0===e)return this.panner.distanceModel;(i=String(e).replace(/-/g,"").toLowerCase())in s.DISTANCE_MODELS&&(this.panner.distanceModel="string"==typeof this.panner.distanceModel?i:s.DISTANCE_MODELS[i])}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.panner.disconnect(0),this.isActive?(this.input.connect(this.panner),this.panner.connect(this.output)):this.input.connect(this.output),this}},{key:"params",value:function(){return{state:this.isActive,positions:this.positions,orientations:this.orientations,refDistance:this.panner.refDistance,maxDistance:this.panner.maxDistance,rolloffFactor:this.panner.rolloffFactor,coneInnerAngle:this.panner.coneInnerAngle,coneOuterAngle:this.panner.coneOuterAngle,coneOuterGain:this.panner.coneOuterGain,panningModel:this.panner.panningModel,distanceModel:this.panner.distanceModel}}},{key:"toString",value:function(){return"[SoundModule Panner]"}}],r&&xe(e.prototype,r),s}(pt);function Ne(t){return Ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ne(t)}function Le(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function De(t,e,r){return De="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=qe(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},De(t,e,r||t)}function Be(t,e){return Be=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Be(t,e)}function Ue(t,e){if(e&&("object"===Ne(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function qe(t){return qe=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},qe(t)}Fe(Ie,"PANNING_MODELS",{equalpower:0,HRTF:1}),Fe(Ie,"DISTANCE_MODELS",{linear:0,inverse:1,exponential:2});var Ve=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Be(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=qe(n);if(i){var r=qe(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Ue(this,t)});function s(t,e){var r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).numberOfStages=12,r.filters=new Array(s.MAXIMUM_STAGES);for(var n=0;n<s.MAXIMUM_STAGES;n++)r.filters[n]=t.createBiquadFilter(),r.filters[n].type="string"==typeof r.filters[n].type?"allpass":r.filters[n].ALLPASS||7,r.filters[n].frequency.value=350,r.filters[n].Q.value=1,r.filters[n].gain.value=0;r.mix=t.createGain(),r.feedback=t.createGain(),r.depth.gain.value=0,r.rate.value=0,r.mix.gain.value=0,r.feedback.gain.value=0,r.depthRate=0,r.state(!1),r.lfo.connect(r.depth);for(var i=0;i<s.MAXIMUM_STAGES;i++)r.depth.connect(r.filters[i].frequency);return r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,a=null;switch(n){case"stage":if(void 0===e)return this.numberOfStages;switch(i=parseInt(e,10)){case 0:case 2:case 4:case 8:case 12:case 24:this.numberOfStages=i,this.connect()}break;case"frequency":case"cutoff":if(void 0===e)return this.filters[0].frequency.value;if(i=parseFloat(e),o=10,a=this.context.sampleRate/2,i>=o&&i<=a){for(var c=0;c<s.MAXIMUM_STAGES;c++)this.filters[c].frequency.value=i;this.depth.gain.value=this.filters[0].frequency.value*this.depthRate}break;case"resonance":if(void 0===e)return this.filters[0].Q.value;if(a=1e3,(i=parseFloat(e))>=(o=1e-4)&&i<=a)for(var u=0;u<s.MAXIMUM_STAGES;u++)this.filters[0].Q.value=i;break;case"depth":if(void 0===e)return this.depthRate;a=1,(i=parseFloat(e))>=(o=0)&&i<=a&&(this.depth.gain.value=this.filters[0].frequency.value*i,this.depthRate=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,a=this.context.sampleRate/2,i>=o&&i<=a&&(this.rate.value=i);break;case"mix":case"feedback":if(void 0===e)return this[n].gain.value;a=1,(i=parseFloat(e))>=(o=0)&&i<=a&&(this[n].gain.value=i)}}return this}},{key:"connect",value:function(){this.input.disconnect(0);for(var t=0;t<s.MAXIMUM_STAGES;t++)this.filters[t].disconnect(0);if(this.mix.disconnect(0),this.feedback.disconnect(0),this.input.connect(this.output),this.isActive&&this.numberOfStages>0){this.input.connect(this.filters[0]);for(var e=0;e<this.numberOfStages;e++)e<this.numberOfStages-1?this.filters[e].connect(this.filters[e+1]):(this.filters[e].connect(this.mix),this.mix.connect(this.output),this.filters[e].connect(this.feedback),this.feedback.connect(this.filters[0]))}return this}},{key:"stop",value:function(t,e){if(De(qe(s.prototype),"stop",this).call(this,t,e),this.isActive){this.lfo.connect(this.depth);for(var r=0;r<s.MAXIMUM_STAGES;r++)this.depth.connect(this.filters[r].frequency)}return this}},{key:"params",value:function(){return{state:this.isActive,stage:this.numberOfStages,frequency:this.filters[0].frequency.value,resonance:this.filters[0].Q.value,depth:this.depthRate,rate:this.rate.value,mix:this.mix.gain.value,feedback:this.feedback.gain.value}}},{key:"toString",value:function(){return"[SoundModule Phaser]"}}],r&&Le(e.prototype,r),s}(pt);function Ge(t){return Ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ge(t)}function ze(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Xe(t,e){return Xe=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Xe(t,e)}function We(t,e){if(e&&("object"===Ge(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function He(t){return He=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},He(t)}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:24,enumerable:!0,configurable:!0,writable:!0}):t[e]=24}(Ve,"MAXIMUM_STAGES");var Ye=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Xe(t,e)}(a,t);var e,r,n,i,o,s=(i=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=He(i);if(o){var r=He(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return We(this,t)});function a(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(r=s.call(this,t,e)).pitch=1,r.state(!1),r.connect(),r}return e=a,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null;if("pitch"===n){if(void 0===e)return this.pitch;(i=parseFloat(e))>0&&(this.pitch=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.processor.disconnect(0),this.isActive?(this.input.connect(this.processor),this.processor.connect(this.output)):this.input.connect(this.output),this}},{key:"start",value:function(){var t=this;if(this.isActive&&this.isStop){this.isStop=!1;var e=this.processor.bufferSize;this.processor.onaudioprocess=function(r){var n=r.inputBuffer.getChannelData(0),i=r.inputBuffer.getChannelData(1),o=r.outputBuffer.getChannelData(0),s=r.outputBuffer.getChannelData(1);if(t.isActive&&1!==t.pitch){var c=new Float32Array(n),u=new Float32Array(i),l=new Float32Array(e),f=new Float32Array(e);a.FFT(c,l,e),a.FFT(u,f,e);for(var h=new Float32Array(e),p=new Float32Array(e),y=new Float32Array(e),v=new Float32Array(e),d=0;d<e;d++){var b=Math.floor(t.pitch*d),m=1;d>e/2&&(m=0),b>=0&&b<e&&(h[b]+=m*c[d],y[b]+=m*l[d],p[b]+=m*u[d],v[b]+=m*f[d])}a.IFFT(h,y,e),a.IFFT(p,v,e),o.set(h),s.set(p)}else o.set(n),s.set(i)}}return this}},{key:"stop",value:function(){return this.isActive&&(this.processor.disconnect(0),this.processor.onaudioprocess=null,this.connect()),this}},{key:"params",value:function(){return{state:this.isActive,pitch:this.pitch}}},{key:"toString",value:function(){return"[SoundModule PitchShifter]"}}],n=[{key:"FFT",value:function(t,e,r){for(var n=function(t){return Math.pow(2,t)},i=new Float32Array(r),o=Math.log2(r),s=1;s<=o;s++)for(var a=0;a<n(s-1);a++)for(var c=o-s,u=0;u<n(c);u++){var l=a*n(c+1)+u,f=n(c)+l,h=u*n(s-1),p=t[l],y=e[l],v=t[f],d=e[f],b=Math.cos(2*Math.PI*h/r),m=-1*Math.sin(2*Math.PI*h/r);s<o?(t[l]=p+v,e[l]=y+d,t[f]=b*(p-v)-m*(y-d),e[f]=b*(y-d)+m*(p-v)):(t[l]=p+v,e[l]=y+d,t[f]=p-v,e[f]=y-d)}for(var g=1;g<=o;g++)for(var w=o-g,S=0;S<n(g-1);S++)i[n(g-1)+S]=i[S]+n(w);for(var O=0;O<r;O++)if(!(i[O]<=O)){var A=t[i[O]],k=e[i[O]];t[i[O]]=t[O],e[i[O]]=e[O],t[O]=A,e[O]=k}}},{key:"IFFT",value:function(t,e,r){for(var n=function(t){return Math.pow(2,t)},i=new Float32Array(r),o=Math.log2(r),s=1;s<=o;s++)for(var a=0;a<n(s-1);a++)for(var c=o-s,u=0;u<n(c);u++){var l=a*n(c+1)+u,f=n(c)+l,h=u*n(s-1),p=t[l],y=e[l],v=t[f],d=e[f],b=Math.cos(2*Math.PI*h/r),m=Math.sin(2*Math.PI*h/r);s<o?(t[l]=p+v,e[l]=y+d,t[f]=b*(p-v)-m*(y-d),e[f]=b*(y-d)+m*(p-v)):(t[l]=p+v,e[l]=y+d,t[f]=p-v,e[f]=y-d)}for(var g=1;g<=o;g++)for(var w=o-g,S=0;S<n(g-1);S++)i[n(g-1)+S]=i[S]+n(w);for(var O=0;O<r;O++)if(!(i[O]<=O)){var A=t[i[O]],k=e[i[O]];t[i[O]]=t[O],e[i[O]]=e[O],t[O]=A,e[O]=k}for(var T=0;T<r;T++)t[T]/=r,e[T]/=r}}],r&&ze(e.prototype,r),n&&ze(e,n),a}(pt);function Qe(t){return Qe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qe(t)}function Ze(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function $e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Je(t,e){return Je=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Je(t,e)}function Ke(t,e){if(e&&("object"===Qe(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function tr(t){return tr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},tr(t)}function er(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var rr=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Je(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=tr(n);if(i){var r=tr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Ke(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).isLoadError=!1,r.rirs=[],r.convolver=t.createConvolver(),r.dry=t.createGain(),r.wet=t.createGain(),r.tone=t.createBiquadFilter(),r.dry.gain.value=1,r.wet.gain.value=0,r.tone.type="string"==typeof r.tone.type?"lowpass":r.tone.LOWPASS||0,r.tone.frequency.value=350,r.tone.Q.value=Math.SQRT1_2,r.tone.gain.value=0,r.state(!1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"type":if(void 0===e)return this.convolver.buffer;i=parseInt(e,10),o=0,s=this.rirs.length-1,null===e?(this.convolver.buffer=null,this.input.disconnect(0),this.input.connect(this.output)):i>=o&&i<=s&&(this.convolver.buffer=this.rirs[i],this.connect());break;case"dry":case"wet":if(void 0===e)return this[n].gain.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this[n].gain.value=i);break;case"tone":if(void 0===e)return this.tone.frequency.value;i=parseFloat(e),o=10,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.tone.frequency.value=i);break;case"rirs":return this.rirs}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.convolver.disconnect(0),this.dry.disconnect(0),this.wet.disconnect(0),this.tone.disconnect(0),this.isActive?(this.input.connect(this.dry),this.dry.connect(this.output),this.input.connect(this.tone),this.tone.connect(this.convolver),this.convolver.connect(this.wet),this.wet.connect(this.output)):this.input.connect(this.output),this}},{key:"start",value:function(t,e){var r=this;return t instanceof AudioBuffer||null===t?(this.convolver.buffer=t,this.rirs.push(t)):t instanceof ArrayBuffer&&("[object Function]"!==Object.prototype.toString.call(e)&&(e=function(){}),this.context.decodeAudioData(t,(function(t){r.convolver.buffer=t,r.rirs.push(t)}),e)),this}},{key:"preset",value:function(t,e,r,n,i){if("[object Object]"===Object.prototype.toString.call(arguments[0])){var o=arguments[0];"rirs"in o&&(t=o.rirs),"timeout"in o&&(e=o.timeout),"success"in o&&(r=o.success),"error"in o&&(n=o.error),"progress"in o&&(i=o.progress)}Array.isArray(t)||(t=[t]),this.rirs=new Array(t.length);for(var s=parseInt(e,10),a=0,c=t.length;a<c;a++)"string"==typeof t[a]?this.load(t[a],a,s,r,n,i):t[a]instanceof AudioBuffer&&(this.rirs[a]=t[a]);return this}},{key:"load",value:function(t,e,r,n,i,o){var a=this,c=new XMLHttpRequest;return c.timeout=r>0?r:6e4,c.ontimeout=function(t){a.isLoadError||"[object Function]"!==Object.prototype.toString.call(i)||i(t,s.ERROR_AJAX_TIMEOUT),a.isLoadError=!0},c.onprogress=function(t){a.isLoadError?c.abort():"[object Function]"===Object.prototype.toString.call(o)&&o(t)},c.onerror=function(t){a.isLoadError||"[object Function]"!==Object.prototype.toString.call(i)||i(t,s.ERROR_AJAX),a.isLoadError=!0},c.onload=function(t){if(200===c.status){var r=c.response;if(!(r instanceof ArrayBuffer))return;a.context.decodeAudioData(r,(function(r){a.rirs[e]=r;var i,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Ze(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ze(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}(a.rirs);try{for(o.s();!(i=o.n()).done;)if(void 0===i.value)return}catch(t){o.e(t)}finally{o.f()}"[object Function]"===Object.prototype.toString.call(n)&&n(t)}),(function(t){"[object Function]"===Object.prototype.toString.call(i)&&i(t,s.ERROR_DECODE)}))}},c.open("GET",t,!0),c.responseType="arraybuffer",c.send(null),this}},{key:"state",value:function(t){return void 0===t?this.isActive:("toggle"===String(t).toLowerCase()?this.isActive=!this.isActive:this.isActive=Boolean(t),this.connect(),this)}},{key:"params",value:function(){return{state:this.isActive,dry:this.dry.gain.value,wet:this.wet.gain.value,tone:this.tone.frequency.value}}},{key:"toString",value:function(){return"[SoundModule Reverb]"}}],r&&$e(e.prototype,r),s}(pt);function nr(t){return nr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nr(t)}function ir(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function or(t,e,r){return or="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=cr(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},or(t,e,r||t)}function sr(t,e){return sr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},sr(t,e)}function ar(t,e){if(e&&("object"===nr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function cr(t){return cr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},cr(t)}er(rr,"ERROR_AJAX","error"),er(rr,"ERROR_AJAX_TIMEOUT","timeout"),er(rr,"ERROR_DECODE","decode");var ur=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&sr(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=cr(n);if(i){var r=cr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return ar(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).amplitude=t.createGain(),r.amplitude.gain.value=0,r.depth.gain.value=1,r.rate.value=0,r.state(!1),r.lfo.connect(r.depth),r.depth.connect(r.amplitude.gain),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"depth":if(void 0===e)return this.depth.gain.value;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.depth.gain.value=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.rate.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.amplitude.disconnect(0),this.isActive?(this.input.connect(this.amplitude),this.amplitude.connect(this.output)):this.input.connect(this.output),this}},{key:"stop",value:function(t,e){return or(cr(s.prototype),"stop",this).call(this,t,e),this.isActive&&(this.lfo.connect(this.depth),this.depth.connect(this.amplitude.gain)),this}},{key:"params",value:function(){return{state:this.isActive,depth:this.depth.gain.value,rate:this.rate.value}}},{key:"toString",value:function(){return"[SoundModule Ringmodulator]"}}],r&&ir(e.prototype,r),s}(pt);function lr(t){return lr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lr(t)}function fr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function hr(t,e){return hr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},hr(t,e)}function pr(t,e){if(e&&("object"===lr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function yr(t){return yr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},yr(t)}var vr=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&hr(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=yr(n);if(i){var r=yr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return pr(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).splitter=t.createChannelSplitter(2),r.merger=t.createScriptProcessor(e,2,2),r.delayL=t.createDelay(s.MAX_DELAY_TIME),r.delayR=t.createDelay(s.MAX_DELAY_TIME),r.delayL.delayTime.value=0,r.delayR.delayTime.value=0,r.state(!1),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,a=null;switch(n){case"delaytime":case"time":if(void 0===e)return this.delayL.delayTime.value;i=parseFloat(e),o=0,a=s.MAX_DELAY_TIME,i>=o&&i<=a&&(this.delayL.delayTime.value=i,this.delayR.delayTime.value=i)}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.splitter.disconnect(0),this.delayL.disconnect(0),this.delayR.disconnect(0),this.merger.disconnect(0),this.isActive?(this.input.connect(this.splitter),this.splitter.connect(this.delayL,0,0),this.splitter.connect(this.delayR,1,0),this.delayL.connect(this.merger),this.delayR.connect(this.merger),this.merger.connect(this.output)):this.input.connect(this.output),this}},{key:"start",value:function(){var t=this;if(this.isActive&&this.isStop){this.isStop=!1;var e=this.merger.bufferSize;this.merger.onaudioprocess=function(r){var n=r.inputBuffer.getChannelData(0),i=r.inputBuffer.getChannelData(1),o=r.outputBuffer.getChannelData(0),s=r.outputBuffer.getChannelData(1);if(t.isActive&&0!==t.delayL.delayTime.value&&0!==t.delayR.delayTime.value)for(var a=0;a<e;a++)o[a]=n[a],s[a]=-i[a];else o.set(n),s.set(i)}}return this}},{key:"stop",value:function(){return this.isActive&&(this.merger.disconnect(0),this.merger.onaudioprocess=null),this}},{key:"params",value:function(){return{state:this.isActive,time:this.delayL.delayTime.value}}},{key:"toString",value:function(){return"[SoundModule Stereo]"}}],r&&fr(e.prototype,r),s}(pt);function dr(t){return dr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dr(t)}function br(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function mr(t,e,r){return mr="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Sr(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},mr(t,e,r||t)}function gr(t,e){return gr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},gr(t,e)}function wr(t,e){if(e&&("object"===dr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Sr(t){return Sr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Sr(t)}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:1,enumerable:!0,configurable:!0,writable:!0}):t[e]=1}(vr,"MAX_DELAY_TIME");var Or=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&gr(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Sr(n);if(i){var r=Sr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return wr(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).amplitude=t.createGain(),r.amplitude.gain.value=1,r.depth.gain.value=0,r.rate.value=0,r.state(!1),r.lfo.connect(r.depth),r.depth.connect(r.amplitude.gain),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,a=null;switch(n){case"depth":if(void 0===e)return this.depth.gain.value;a=1,(i=parseFloat(e))>=(o=0)&&i<=a&&(this.depth.gain.value=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,a=this.context.sampleRate/2,i>=o&&i<=a&&(this.rate.value=i);break;case"wave":if(void 0===e)return this.lfo.type;(i=String(e).toLowerCase())in s.WAVE_TYPES&&(this.lfo.type="string"==typeof this.lfo.type?i:s.WAVE_TYPES[i])}}return this}},{key:"connect",value:function(){return this.input.disconnect(0),this.amplitude.disconnect(0),this.isActive?(this.input.connect(this.amplitude),this.amplitude.connect(this.output)):this.input.connect(this.output),this}},{key:"stop",value:function(t,e){return mr(Sr(s.prototype),"stop",this).call(this,t,e),this.isActive&&(this.lfo.connect(this.depth),this.depth.connect(this.amplitude.gain)),this}},{key:"params",value:function(){return{state:this.isActive,depth:this.depth.gain.value,rate:this.rate.value,wave:this.lfo.type}}},{key:"toString",value:function(){return"[SoundModule Tremolo]"}}],r&&br(e.prototype,r),s}(pt);function Ar(t){return Ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ar(t)}function kr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Tr(t,e,r){return Tr="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Rr(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},Tr(t,e,r||t)}function Er(t,e){return Er=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Er(t,e)}function jr(t,e){if(e&&("object"===Ar(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Rr(t){return Rr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Rr(t)}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(Or,"WAVE_TYPES",{sine:0,square:1,sawtooth:2,triangle:3});var Pr=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Er(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Rr(n);if(i){var r=Rr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return jr(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).autoWah=!1,r.lowpass=t.createBiquadFilter(),r.envelopeFollower=t.createWaveShaper(),r.sensitivity=t.createBiquadFilter(),r.lowpass.type="string"==typeof r.lowpass.type?"lowpass":r.lowpass.LOWPASS||0,r.lowpass.frequency.value=r.autoWah?20:350,r.lowpass.Q.value=1,r.lowpass.gain.value=0,r.envelopeFollower.curve=new Float32Array([1,0,1]),r.sensitivity.type="string"==typeof r.lowpass.type?"lowpass":r.lowpass.LOWPASS||0,r.sensitivity.frequency.value=350,r.sensitivity.Q.value=1,r.sensitivity.gain.value=0,r.depth.gain.value=0,r.rate.value=0,r.depthRate=0,r.state(!1),r.connect(),r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null,s=null;switch(n){case"auto":if(void 0===e)return this.autoWah;this.autoWah=Boolean(e),this.connect();break;case"frequency":case"cutoff":if(void 0===e)return this.autoWah?this.sensitivity.frequency.value:this.lowpass.frequency.value;i=parseFloat(e),o=10,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.autoWah?(this.sensitivity.frequency.value=i,this.lowpass.frequency.value=20):this.lowpass.frequency.value=i);break;case"depth":if(void 0===e)return this.depthRate;s=1,(i=parseFloat(e))>=(o=0)&&i<=s&&(this.depth.gain.value=this.autoWah?1e4*i:this.lowpass.frequency.value*i,this.depthRate=i);break;case"rate":if(void 0===e)return this.rate.value;i=parseFloat(e),o=0,s=this.context.sampleRate/2,i>=o&&i<=s&&(this.rate.value=i);break;case"resonance":if(void 0===e)return this.autoWah?this.sensitivity.Q.value:this.lowpass.Q.value;s=1e3,(i=parseFloat(e))>=(o=1e-4)&&i<=s&&(this.autoWah?(this.sensitivity.Q.value=i,this.lowpass.Q.value=1):this.lowpass.Q.value=i)}}return this}},{key:"stop",value:function(t,e){return Tr(Rr(s.prototype),"stop",this).call(this,t,e),!this.autoWah&&this.isActive&&(this.lfo.connect(this.depth),this.depth.connect(this.lowpass.frequency)),this}},{key:"connect",value:function(){return this.input.disconnect(0),this.sensitivity.disconnect(0),this.envelopeFollower.disconnect(0),this.lowpass.disconnect(0),this.depth.disconnect(0),this.isActive?this.autoWah?(this.input.connect(this.sensitivity),this.sensitivity.connect(this.output),this.input.connect(this.envelopeFollower),this.envelopeFollower.connect(this.lowpass),this.lowpass.connect(this.depth),this.depth.connect(this.sensitivity.frequency)):(this.input.connect(this.lowpass),this.lowpass.connect(this.output),this.lfo.connect(this.depth),this.depth.connect(this.lowpass.frequency)):this.input.connect(this.output),this}},{key:"params",value:function(){return{state:this.isActive,auto:this.autoWah,cutoff:this.autoWah?this.sensitivity.frequency.value:this.lowpass.frequency.value,depth:this.autoWah?this.depth.gain.value:this.depthRate,rate:this.rate.value,resonance:this.autoWah?this.sensitivity.Q.value:this.lowpass.Q.value}}},{key:"toString",value:function(){return"[SoundModule Wah]"}}],r&&kr(e.prototype,r),s}(pt);function xr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _r(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Mr=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.init(e,r)}var e,r;return e=t,r=[{key:"init",value:function(e,r){Array.isArray(this.modules)&&this.modules.length>0&&(this.mastervolume.disconnect(0),this.mastervolume=null,this.processor.disconnect(0),this.processor=null,this.analyser.INPUT.disconnect(0),this.analyser=null,this.recorder.INPUT.disconnect(0),this.recorder=null,this.session.INPUT.disconnect(0),this.session=null,this.modules.forEach((function(t){t.INPUT.disconnect(0),t.OUTPUT.disconnect(0),t=null})),this.modules=[]),this.context=e,this.sampleRate=e.sampleRate;var n=parseInt(r,10);switch(n){case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:break;default:n=0}this.mastervolume=e.createGain(),this.processor=e.createScriptProcessor(n,t.NUMBER_OF_INPUTS,t.NUMBER_OF_OUTPUTS),this.analyser=new q(e),this.recorder=new K(e,n,t.NUMBER_OF_INPUTS,t.NUMBER_OF_OUTPUTS),this.session=new at(e,n,t.NUMBER_OF_INPUTS,t.NUMBER_OF_OUTPUTS,this.analyser),this.stereo=new vr(e,n),this.compressor=new Ut(e,n),this.distortion=new Kt(e,n),this.wah=new Pr(e,n),this.pitchshifter=new Ye(e,n),this.equalizer=new ue(e,n),this.filter=new ve(e,n),this.autopanner=e.createStereoPanner?new wt(e,n):new jt(e,n),this.tremolo=new Or(e,n),this.ringmodulator=new ur(e,n),this.phaser=new Ve(e,n),this.flanger=new Oe(e,n),this.chorus=new Ft(e,n),this.delay=new Wt(e,n),this.reverb=new rr(e,n),this.panner=new Ie(e,n),this.listener=new Re(e,n),this.envelopegenerator=new ne(e),this.modules=[this.stereo,this.compressor,this.distortion,this.wah,this.pitchshifter,this.equalizer,this.filter,this.autopanner,this.tremolo,this.ringmodulator,this.phaser,this.flanger,this.chorus,this.delay,this.reverb,this.panner]}},{key:"setup",value:function(){return this}},{key:"param",value:function(t,e){var r=null;if("mastervolume"===String(t).replace(/-/g,"").toLowerCase()){if(void 0===e)return this.mastervolume.gain.value;(r=parseFloat(e))>=0&&r<=1&&(this.mastervolume.gain.value=r)}}},{key:"ready",value:function(){return this}},{key:"start",value:function(){return this}},{key:"stop",value:function(){return this}},{key:"get",value:function(){return this}},{key:"resize",value:function(t){return this.init(this.context,t),this}},{key:"getBufferSize",value:function(){return this.processor.bufferSize}},{key:"install",value:function(t,e){return e instanceof pt?(String(t)in this||(this[t]=e,this.modules.every((function(t){return t!==e}))&&this.modules.push(e)),this):this}},{key:"connect",value:function(t,e){Array.isArray(e)&&(this.modules=e),t.disconnect(0),this.modules.length>0?t.connect(this.modules[0].INPUT):t.connect(this.mastervolume);for(var r=0,n=this.modules.length;r<n;r++)this.modules[r].OUTPUT.disconnect(0),r<this.modules.length-1?this.modules[r].OUTPUT.connect(this.modules[r+1].INPUT):this.modules[r].OUTPUT.connect(this.mastervolume);return this.mastervolume.connect(this.context.destination),this.mastervolume.connect(this.analyser.INPUT),this.mastervolume.connect(this.recorder.INPUT),this.recorder.INPUT.connect(this.context.destination),this.mastervolume.connect(this.session.INPUT),this.session.INPUT.connect(this.context.destination),this}},{key:"module",value:function(t){var e=String(t).replace(/-/g,"").toLowerCase();switch(e){case"analyser":case"recorder":case"session":case"stereo":case"compressor":case"distortion":case"wah":case"pitchshifter":case"equalizer":case"filter":case"autopanner":case"tremolo":case"ringmodulator":case"phaser":case"flanger":case"chorus":case"delay":case"reverb":case"panner":case"listener":return this[e];case"envelopegenerator":case"eg":return this.envelopegenerator;case"glide":if(e in this)return this[e];case"vocalcanceler":if(e in this)return this[e];case"noisegate":case"noisesuppressor":if(e in this)return this[e];default:return this[e]}}},{key:"on",value:function(t){var e=parseFloat(t);return(isNaN(e)||e<this.context.currentTime)&&(e=this.context.currentTime),this.stereo.start(e),this.chorus.start(e),this.flanger.start(e),this.phaser.start(e),this.autopanner.start(e),this.tremolo.start(e),this.ringmodulator.start(e),this.wah.start(e),this.filter.start(e),this}},{key:"off",value:function(t){var e=parseFloat(t);return(isNaN(e)||e<this.context.currentTime)&&(e=this.context.currentTime),this.stereo.stop(e),this.chorus.stop(e),this.flanger.stop(e),this.phaser.stop(e),this.autopanner.stop(e),this.tremolo.stop(e),this.ringmodulator.stop(e),this.wah.stop(e),this}},{key:"params",value:function(){var t={};for(var e in this)if("[object Function]"!==Object.prototype.toString.call(this[e])){var r=e.toLowerCase();"mastervolume"===r?t[r]=this[e].gain.value:"[object Object]"===Object.prototype.toString.call(this[e])&&"params"in this[e]&&(t[r]=this[e].params())}return t}},{key:"toJSON",value:function(){return JSON.stringify(this.params())}},{key:"toString",value:function(){return"[SoundModule]"}}],r&&xr(e.prototype,r),t}();function Cr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Fr(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}_r(Mr,"NUMBER_OF_INPUTS",2),_r(Mr,"NUMBER_OF_OUTPUTS",2);var Ir=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.isActive=r,this.context=e,this.source=e.createOscillator(),this.source.setPeriodicWave=this.source.setPeriodicWave||this.source.setWaveTable,this.source.start=this.source.start||this.source.noteOn,this.source.stop=this.source.stop||this.source.noteOff,this.volume=e.createGain(),this.isStop=!0,this.octave=0,this.fine=0,this.customs={real:new Float32Array([0,1]),imag:new Float32Array([0,1])}}var e,r;return e=t,r=[{key:"param",value:function(e,r){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var n in arguments[0])this.param(n,arguments[0][n]);else{var i=String(e).replace(/-/g,"").toLowerCase(),o=null,s=null,a=null;switch(i){case"type":if(void 0===r)return this.source.type;if("[object Object]"!==Object.prototype.toString.call(r))(o=String(r).toLowerCase())in t.WAVE_TYPES&&(this.source.type="string"==typeof this.source.type?o:t.WAVE_TYPES[o]);else if("real"in r&&"imag"in r){var c=null,u=null;if(r.real instanceof Float32Array?c=r.real:Array.isArray(r.real)&&(c=new Float32Array(r.real)),r.imag instanceof Float32Array?u=r.imag:Array.isArray(r.imag)&&(u=new Float32Array(r.imag)),c instanceof Float32Array&&u instanceof Float32Array){var l=4096;c.length>l&&(c=c.subarray(0,l)),u.length>l&&(u=u.subarray(0,l)),0!==c[0]&&(c[0]=0),0!==u[0]&&(u[0]=0);var f=this.context.createPeriodicWave(c,u);this.source.setPeriodicWave(f),this.customs.real=c,this.customs.imag=u}}break;case"octave":if(void 0===r)return this.octave;o=parseFloat(r),s=-4800/t.OCTAVE,a=4800/t.OCTAVE,o>=s&&o<=a&&(this.octave=o,this.source.detune.value=this.fine+o*t.OCTAVE);break;case"fine":if(void 0===r)return this.fine;o=parseFloat(r),s=-t.OCTAVE,a=t.OCTAVE,o>=s&&o<=a&&(this.fine=o,this.source.detune.value=o+this.octave*t.OCTAVE);break;case"volume":case"gain":if(void 0===r)return this.volume.gain.value;a=1,(o=parseFloat(r))>=(s=0)&&o<=a&&(this.volume.gain.value=o)}}return this}},{key:"ready",value:function(t){if(this.isActive){var e={type:this.source.type,frequency:this.source.frequency.value,detune:this.source.detune.value};if(this.isStop||(this.source.stop(this.context.currentTime),this.source.disconnect(0)),this.source=this.context.createOscillator(),this.source.setPeriodicWave=this.source.setPeriodicWave||this.source.setWaveTable,this.source.start=this.source.start||this.source.noteOn,this.source.stop=this.source.stop||this.source.noteOff,"custom"===e.type){var r=this.customs.real,n=this.customs.imag,i=this.context.createPeriodicWave(r,n);this.source.setPeriodicWave(i)}else this.source.type=e.type;this.source.frequency.value=e.frequency,this.source.detune.value=e.detune,this.volume.connect(t)}return this}},{key:"start",value:function(t){return this.isActive?(this.source.start(t),this.isStop=!1):(this.isStop||(this.source.stop(this.context.currentTime),this.isStop=!0),this.source.disconnect(0)),this}},{key:"stop",value:function(t){return this.isStop||(this.source.stop(t),this.source.disconnect(0),this.isStop=!0),this}},{key:"state",value:function(t){return void 0===t?this.isActive:("toggle"===String(t).toLowerCase()?this.isActive=!this.isActive:this.isActive=Boolean(t),this)}},{key:"get",value:function(){return this.source}},{key:"toString",value:function(){return"[OscillatorModule Oscillator]"}}],r&&Cr(e.prototype,r),t}();function Nr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Lr(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}Fr(Ir,"OCTAVE",1200),Fr(Ir,"WAVE_TYPES",{sine:0,square:1,sawtooth:2,triangle:3});var Dr=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.context=e,this.frequencies={start:-1,end:0},this.time=0,this.type=t.LINEAR}var e,r;return e=t,r=[{key:"param",value:function(e,r){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var n in arguments[0])this.param(n,arguments[0][n]);else{var i=String(e).replace(/-/g,"").toLowerCase(),o=null;switch(i){case"time":if(void 0===r)return this.time;(o=parseFloat(r))>=0&&(this.time=o);break;case"type":if(void 0===r)return this.type;(o=String(r).toLowerCase())!==t.LINEAR&&o!==t.EXPONENTIAL||(this.type=o)}}return this}},{key:"ready",value:function(t){this.frequencies.end=t;var e=-1===this.frequencies.start?0:this.frequencies.end-this.frequencies.start;return-1!==this.frequencies.start&&0!==this.time&&0!==e||(this.frequencies.start=this.frequencies.end),this}},{key:"start",value:function(t,e){var r=parseFloat(e);(isNaN(r)||r<this.context.currentTime)&&(r=this.context.currentTime);var n=r,i=n+this.time;return t.frequency.cancelScheduledValues(n),t.frequency.setValueAtTime(this.frequencies.start,n),t.frequency["".concat(this.type,"RampToValueAtTime")](this.frequencies.end,i),this}},{key:"stop",value:function(){return this.frequencies.start=this.frequencies.end,this}},{key:"toString",value:function(){return"[OscillatorModule Glide]"}}],r&&Nr(e.prototype,r),t}();function Br(t){return Br="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Br(t)}function Ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function qr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Vr(t,e,r){return Vr="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Xr(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},Vr(t,e,r||t)}function Gr(t,e){return Gr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Gr(t,e)}function zr(t,e){if(e&&("object"===Br(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Xr(t){return Xr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Xr(t)}Lr(Dr,"LINEAR","linear"),Lr(Dr,"EXPONENTIAL","exponential");var Wr=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Gr(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Xr(n);if(i){var r=Xr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return zr(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).sources=[],r.times={start:0,duration:0},r.isAnalyser=!1,r.glide=new Dr(t),r}return e=s,r=[{key:"setup",value:function(t){this.sources.length=0,Array.isArray(t)||(t=[t]);for(var e=0,r=t.length;e<r;e++)this.sources[e]=new Ir(this.context,Boolean(t[e])),this.envelopegenerator.setGenerator(e);return this}},{key:"param",value:function(t,e){if("[object Object]"!==Object.prototype.toString.call(arguments[0])){var r=String(t).replace(/-/g,"").toLowerCase(),n=Vr(Xr(s.prototype),"param",this).call(this,r,e);return void 0===n?this:n}for(var i in arguments[0])this.param(i,arguments[0][i])}},{key:"ready",value:function(t,e){var r=parseFloat(t),n=parseFloat(e);return this.times.start=r>=0?r:0,this.times.duration=n>=0?n:0,this.envelopegenerator.clear(!0),this}},{key:"start",value:function(t,e,r){var n=this,i=this.context.currentTime+this.times.start;Array.isArray(t)||(t=[t]);for(var o=0,s=t.length;o<s;o++){var a=parseFloat(t[o]);t[o]=a>=0?a:0}this.envelopegenerator.clear(!0),this.processor.disconnect(0),this.processor.onaudioprocess=null,this.connect(this.processor,e);for(var c=0,u=t.length;c<u&&!(c>=this.sources.length);c++){var l=this.sources[c],f=t[c];l.ready(this.processor),this.envelopegenerator.ready(c,l.source,l.volume),this.glide.ready(f).start(l.source,i),l.start(i)}return this.envelopegenerator.start(i),this.on(i),this.isAnalyser||(this.analyser.start("time"),this.analyser.start("fft"),this.isAnalyser=!0),"[object Function]"===Object.prototype.toString.call(r)?this.processor.onaudioprocess=r:this.processor.onaudioprocess=function(t){var e=t.inputBuffer.getChannelData(0),r=t.inputBuffer.getChannelData(1),i=t.outputBuffer.getChannelData(0),o=t.outputBuffer.getChannelData(1);if(n.envelopegenerator.isStop()){var s,a=n.context.currentTime,c=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ur(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}(n.sources);try{for(c.s();!(s=c.n()).done;)s.value.stop(a)}catch(t){c.e(t)}finally{c.f()}n.off(a),n.analyser.stop("time"),n.analyser.stop("fft"),n.isAnalyser=!1,n.processor.disconnect(0),n.processor.onaudioprocess=null}else i.set(e),o.set(r)},this}},{key:"stop",value:function(){var t=this.context.currentTime+this.times.start+this.times.duration;return this.envelopegenerator.stop(t),this.glide.stop(),this.filter.stop(t),this}},{key:"get",value:function(t){var e=parseInt(t,10);return e>=0&&e<this.sources.length?this.sources[e]:this.sources}},{key:"length",value:function(){return this.sources.length}},{key:"params",value:function(){var t=Vr(Xr(s.prototype),"params",this).call(this);t.oscillator={glide:{type:this.glide.param("type"),time:this.glide.param("time")}};for(var e=0,r=this.sources.length;e<r;e++){var n=this.sources[e];t.oscillator["oscillator".concat(e)]={state:n.state(),gain:n.param("gain"),type:n.param("type"),octave:n.param("octave"),fine:n.param("fine")}}return t}},{key:"toString",value:function(){return"[OscillatorModule]"}}],r&&qr(e.prototype,r),s}(Mr);function Hr(t){return Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hr(t)}function Yr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Qr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Zr(t,e,r){return Zr="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Kr(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},Zr(t,e,r||t)}function $r(t,e){return $r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},$r(t,e)}function Jr(t,e){if(e&&("object"===Hr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Kr(t){return Kr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Kr(t)}function tn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var en=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&$r(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Kr(n);if(i){var r=Kr(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Jr(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).sources=[],r.resources=[],r.buffers=[],r.volumes=[],r.isStops=[],r.settings=[],r.times={start:0,duration:0},r.transpose=1,r.isStop=!0,r.isLoadError=!1,r.isAnalyser=!1,r}return e=s,r=[{key:"setup",value:function(t,e,r,n,i,o){if("[object Object]"===Object.prototype.toString.call(arguments[0])){var s=arguments[0];"resources"in s&&(t=s.resources),"settings"in s&&(e=s.settings),"timeout"in s&&(r=s.timeout),"success"in s&&(n=s.success),"error"in s&&(i=s.error),"progress"in s&&(o=s.progress)}Array.isArray(t)||(t=[t]),this.resources=t,Array.isArray(e)||(e=[e]),this.buffers.length=t.length;for(var a=0,c=e.length;a<c;a++){if(!("buffer"in e[a]))return this;var u=parseInt(e[a].buffer,10);if(!(u>=0&&u<this.buffers.length))return this;e[a].buffer=u,e[a].rate="rate"in e[a]&&e[a].rate>=0?parseFloat(e[a].rate):1,e[a].loop="loop"in e[a]&&Boolean(e[a].loop),e[a].start="start"in e[a]&&e[a].start>=0?parseFloat(e[a].start):0,e[a].end="end"in e[a]&&e[a].end>=0?parseFloat(e[a].end):0,e[a].volume="volume"in e[a]&&e[a].volume>=0&&e[a].volume<=1?parseFloat(e[a].volume):1,this.isStops[a]=!0,this.volumes[a]=this.context.createGain(),this.envelopegenerator.setGenerator(a)}this.settings=e;for(var l=parseInt(r,10),f=0,h=this.resources.length;f<h;f++)"string"==typeof this.resources[f]?this.load(this.resources[f],f,l,n,i,o):this.resources[f]instanceof AudioBuffer&&(this.buffers[f]=this.resources[f]);return this}},{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=Zr(Kr(s.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;var o=null;if("transpose"===n){if(void 0===e)return this.transpose;(o=parseFloat(e))>0&&(this.transpose=o)}}return this}},{key:"ready",value:function(t,e){var r=parseFloat(t),n=parseFloat(e);return this.times.start=r>=0?r:0,this.times.duration=n>=0?n:0,this.envelopegenerator.clear(!1),this}},{key:"start",value:function(t,e,r){var n=this,i=parseInt(t,10);if(isNaN(i)||i<0||i>=this.settings.length)return this;var o=this.settings[i].buffer,s=this.settings[i].rate,a=this.settings[i].loop,c=this.settings[i].start,u=this.settings[i].end,l=this.settings[i].volume;if(!(this.buffers[o]instanceof AudioBuffer))return this;var f=this.context.createBufferSource();f.start=f.start||f.noteGrainOn,f.stop=f.stop||f.noteOff,f.buffer=this.buffers[o],f.playbackRate.value=s*this.transpose,f.loop=a,f.loopStart=c,f.loopEnd=u,this.volumes[i].gain.value=l,this.envelopegenerator.clear(!1),this.envelopegenerator.ready(i,f,this.volumes[i]),this.volumes[i].connect(this.processor),this.connect(this.processor,e);var h=this.context.currentTime+this.times.start;return f.loop?f.start(h,h+f.loopStart,f.loopEnd-h):f.start(h),this.sources[i]=f,this.envelopegenerator.start(h),this.on(h),this.isAnalyser||(this.analyser.start("time"),this.analyser.start("fft"),this.isAnalyser=!0),this.isStops[i]=!1,this.times.stop>0&&window.setTimeout((function(){n.stop(i)}),1e3*this.times.stop),f.onended=function(){n.isStops[i]=!0},"[object Function]"===Object.prototype.toString.call(r)?this.processor.onaudioprocess=r:this.processor.onaudioprocess=function(t){if(n.isStop=n.isStops.every((function(t){return t})),n.isStop)n.off(n.context.currentTime),n.envelopegenerator.clear(!1),n.analyser.stop("time"),n.analyser.stop("fft"),n.isAnalyser=!1,n.processor.disconnect(0),n.processor.onaudioprocess=null;else{var e=t.inputBuffer.getChannelData(0),r=t.inputBuffer.getChannelData(1),i=t.outputBuffer.getChannelData(0),o=t.outputBuffer.getChannelData(1);i.set(e),o.set(r)}},this}},{key:"stop",value:function(t){var e=parseInt(t,10);if(isNaN(e)||e<0||e>=this.settings.length)return this;var r=this.settings[e].buffer;if(!(this.buffers[r]instanceof AudioBuffer&&this.sources[e]instanceof AudioBufferSourceNode))return this;var n=this.context.currentTime+this.times.start+this.times.duration;return this.envelopegenerator.stop(n),this.filter.stop(n),this}},{key:"get",value:function(t){var e=parseInt(t,10);return e>=0&&e<this.buffers.length?this.buffers[e]:this.buffers}},{key:"params",value:function(){var t=Zr(Kr(s.prototype),"params",this).call(this);return t.oneshot={transpose:this.transpose},t}},{key:"load",value:function(t,e,r,n,i,o){var a=this,c=new XMLHttpRequest;return c.timeout=r>0?r:6e4,c.ontimeout=function(t){a.isLoadError||"[object Function]"!==Object.prototype.toString.call(i)||i(t,s.ERROR_AJAX_TIMEOUT),a.isLoadError=!0},c.onprogress=function(t){a.isLoadError?c.abort():"[object Function]"===Object.prototype.toString.call(o)&&o(t)},c.onerror=function(t){a.isLoadError||"[object Function]"!==Object.prototype.toString.call(i)||i(t,s.ERROR_AJAX),a.isLoadError=!0},c.onload=function(t){if(200===c.status){var r=c.response;if(!(r instanceof ArrayBuffer))return;a.context.decodeAudioData(r,(function(r){a.buffers[e]=r;var i,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Yr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yr(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}(a.buffers);try{for(o.s();!(i=o.n()).done;)if(void 0===i.value)return}catch(t){o.e(t)}finally{o.f()}"[object Function]"===Object.prototype.toString.call(n)&&n(t,a.buffers)}),(function(t){"[object Function]"===Object.prototype.toString.call(i)&&i(t,s.ERROR_DECODE)}))}},c.open("GET",t,!0),c.responseType="arraybuffer",c.send(null),this}},{key:"reset",value:function(t,e,r){var n=parseInt(t,10);return String(e).toLowerCase()in this.settings[n]&&(this.settings[n][e.toLowerCase()]=r),this}},{key:"toString",value:function(){return"[OneshotModule]"}}],r&&Qr(e.prototype,r),s}(Mr);function rn(t){return rn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rn(t)}function nn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function on(t,e,r){return on="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=cn(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},on(t,e,r||t)}function sn(t,e){return sn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},sn(t,e)}function an(t,e){if(e&&("object"===rn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function cn(t){return cn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},cn(t)}function un(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}tn(en,"ERROR_AJAX","error"),tn(en,"ERROR_AJAX_TIMEOUT","timeout"),tn(en,"ERROR_DECODE","decode");var ln=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&sn(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=cn(n);if(i){var r=cn(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return an(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).type=s.WHITE_NOISE,r.envelopegenerator.setGenerator(0),r.isAnalyser=!1,r}return e=s,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=on(cn(s.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;var o="";if("type"===n){if(void 0===e)return this.type;(o=String(e).toLowerCase())!==s.WHITE_NOISE&&o!==s.PINK_NOISE&&o!==s.BROWNIAN_NOISE||(this.type=o)}}return this}},{key:"start",value:function(t){var e=this,r=this.context.currentTime;this.envelopegenerator.clear(!0),this.processor.disconnect(0),this.processor.onaudioprocess=null,this.connect(this.envelopegenerator.getGenerator(0),t),this.envelopegenerator.ready(0,this.processor),this.envelopegenerator.start(r),this.isAnalyser||(this.analyser.start("time"),this.analyser.start("fft"),this.isAnalyser=!0),this.on(r);var n=this.processor.bufferSize,i=0;return this.processor.onaudioprocess=function(t){var r=t.outputBuffer.getChannelData(0),o=t.outputBuffer.getChannelData(1);if(e.envelopegenerator.isStop())e.processor.disconnect(0),e.processor.onaudioprocess=null,e.analyser.stop("time"),e.analyser.stop("fft"),e.isAnalyser=!1;else switch(e.type){case s.WHITE_NOISE:for(var a=0;a<n;a++)r[a]=2*(Math.random()-.5),o[a]=2*(Math.random()-.5);break;case s.PINK_NOISE:for(var c=0,u=0,l=0,f=0,h=0,p=0,y=0,v=0;v<n;v++){var d=2*Math.random()-1;c=.99886*c+.0555179*d,u=.99332*u+.0750759*d,l=.969*l+.153852*d,f=.8665*f+.3104856*d,h=.55*h+.5329522*d,p=-.7616*p-.016898*d,r[v]=c+u+l+f+h+p+y+.5362*d,o[v]=c+u+l+f+h+p+y+.5362*d,r[v]*=.11,o[v]*=.11,y=.115926*d}break;case s.BROWNIAN_NOISE:for(var b=0;b<n;b++){var m=2*Math.random()-1;r[b]=(i+.02*m)/1.02,o[b]=(i+.02*m)/1.02,i=(i+.02*m)/1.02,r[b]*=3.5,o[b]*=3.5}}},this}},{key:"stop",value:function(){var t=this.context.currentTime;return this.envelopegenerator.stop(t),this.off(t),this}},{key:"toString",value:function(){return"[NoiseModule]"}}],r&&nn(e.prototype,r),s}(Mr);function fn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}un(ln,"WHITE_NOISE","whitenoise"),un(ln,"PINK_NOISE","pinknoise"),un(ln,"BROWNIAN_NOISE","browniannoise");var hn=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.depth=0}var e,r;return e=t,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null;if("depth"===n){if(void 0===e)return this.depth;o=1,(i=parseFloat(e))>=0&&i<=o&&(this.depth=i)}}return this}},{key:"start",value:function(t,e){return t-this.depth*e}},{key:"toString",value:function(){return"[AudioModule VocalCanceler]"}}],r&&fn(e.prototype,r),t}();function pn(t){return pn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pn(t)}function yn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function vn(t,e,r){return vn="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=mn(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},vn(t,e,r||t)}function dn(t,e){return dn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},dn(t,e)}function bn(t,e){if(e&&("object"===pn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function mn(t){return mn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},mn(t)}var gn=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&dn(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=mn(n);if(i){var r=mn(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return bn(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).source=t.createBufferSource(),r.buffer=null,r.currentTime=0,r.paused=!0,r.callbacks={decode:function(){},ready:function(){},start:function(){},stop:function(){},update:function(){},ended:function(){},error:function(){}},r.vocalcanceler=new hn,r}return e=s,r=[{key:"setup",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.setup(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase();n in this.callbacks&&"[object Function]"===Object.prototype.toString.call(e)&&(this.callbacks[n]=e)}return this.envelopegenerator.setGenerator(0),this.envelopegenerator.param({attack:0,decay:.01,sustain:1,release:.01}),this}},{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=vn(mn(s.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;var o=0,a=0;switch(n){case"playbackrate":if(void 0===e)return this.source.playbackRate.value;if(a=1024,(o=parseFloat(e))>=0&&o<=a){this.source.playbackRate.value=o;var c=this.context.currentTime,u=this.param("currentTime"),l=this.param("duration");this.envelopegenerator.start(c),this.envelopegenerator.stop(c+(l-u)/o,!0)}break;case"loop":case"looping":if(void 0===e)return this.source.loop;this.source.loop=Boolean(e);break;case"currenttime":if(void 0===e)return this.currentTime;this.buffer instanceof AudioBuffer?(o=parseFloat(e),a=this.buffer.duration,o>=0&&o<=a&&(this.paused?this.currentTime=o:(this.stop(),this.start(o)))):this.currentTime=0;break;case"duration":return this.buffer instanceof AudioBuffer?this.buffer.duration:0;case"samplerate":return this.buffer instanceof AudioBuffer?this.buffer.sampleRate:this.sampleRate;case"channels":return this.buffer instanceof AudioBuffer?this.buffer.numberOfChannels:0}}return this}},{key:"ready",value:function(t){var e=this;return t instanceof ArrayBuffer?(this.buffer=null,this.context.decodeAudioData(t,(function(t){e.buffer=t,e.analyser.start("timeoverview",0,e.buffer),e.analyser.start("timeoverview",1,e.buffer),e.callbacks.ready(e.buffer)}),this.callbacks.error),this.callbacks.decode(t)):t instanceof AudioBuffer&&(this.buffer=t),this}},{key:"start",value:function(t,e,r,n){var i=this;if(this.buffer instanceof AudioBuffer&&this.paused){var o=this.context.currentTime,s=parseFloat(t),a=parseFloat(e);this.currentTime=a>=0?s>=0&&s<=a?s:0:s>=0&&s<=this.buffer.duration?s:0;var c=this.source.playbackRate.value,u=this.source.loop;this.source=this.context.createBufferSource(),this.source.start=this.source.start||this.source.noteGrainOn,this.source.stop=this.source.stop||this.source.noteOff,this.source.buffer=this.buffer,this.source.playbackRate.value=c,this.source.loop=u,this.source.loopStart=this.currentTime,this.source.loopEnd=a>=0?a:this.buffer.duration,this.envelopegenerator.ready(0,this.source,this.processor),this.connect(this.processor,r),isNaN(s)?this.source.start(o):a>=0?this.source.start(o,this.currentTime,a-s):this.source.start(o,this.currentTime,this.buffer.duration-this.currentTime),this.analyser.start("time"),this.analyser.start("fft"),this.paused=!1,this.envelopegenerator.start(o),a>=0?this.envelopegenerator.stop(o+(a-s)/this.source.playbackRate.value,!0):this.envelopegenerator.stop(o+(this.buffer.duration-s)/this.source.playbackRate.value,!0),this.on(o),this.callbacks.start(this.source,this.currentTime);var l=this.processor.bufferSize;"[object Function]"===Object.prototype.toString.call(n)?this.processor.onaudioprocess=n:this.processor.onaudioprocess=function(t){var e=t.inputBuffer.getChannelData(0),o=t.inputBuffer.getChannelData(1),s=t.outputBuffer.getChannelData(0),a=t.outputBuffer.getChannelData(1);if(i.currentTime<Math.floor(i.source.loopEnd)){for(var c=0;c<l;c++)s[c]=i.vocalcanceler.start(e[c],o[c]),a[c]=i.vocalcanceler.start(o[c],e[c]),i.currentTime+=1*i.source.playbackRate.value/i.source.buffer.sampleRate,i.callbacks.update(i.source,i.currentTime);i.analyser.domain("timeoverview",0).update(i.currentTime),i.analyser.domain("timeoverview",1).update(i.currentTime)}else i.source.loop?(i.stop(),"sprite"===i.analyser.domain("timeoverview",0).param("mode")||"sprite"===i.analyser.domain("timeoverview",1).param("mode")?i.start(i.source.loopStart,i.source.loopEnd,r,n):i.start(0,i.buffer.duration,r,n)):i.end()}}return this}},{key:"stop",value:function(){if(this.buffer instanceof AudioBuffer&&!this.paused){var t=this.context.currentTime;this.source.stop(t),this.off(t),this.analyser.stop("time"),this.analyser.stop("fft"),this.processor.disconnect(0),this.processor.onaudioprocess=null,this.paused=!0,this.callbacks.stop(this.source,this.currentTime)}return this}},{key:"get",value:function(){return this.source}},{key:"toggle",value:function(t,e,r,n){return this.paused?this.start(t,e,r,n):this.stop(),this}},{key:"end",value:function(){return this.stop(),this.currentTime=0,this.callbacks.ended(this.source,this.currentTime),this}},{key:"isBuffer",value:function(){return this.buffer instanceof AudioBuffer}},{key:"isSource",value:function(){return this.source instanceof AudioBufferSourceNode&&this.source.buffer instanceof AudioBuffer}},{key:"isPaused",value:function(){return this.paused}},{key:"fadeIn",value:function(t){if(void 0===t)return this.envelopegenerator.param("attack");this.envelopegenerator.param("attack",t);var e=this.context.currentTime,r=this.param("currentTime"),n=this.param("duration"),i=this.param("playbackRate");return this.envelopegenerator.start(e),this.envelopegenerator.stop(e+(n-r)/i,!0),this}},{key:"fadeOut",value:function(t){if(void 0===t)return this.envelopegenerator.param("release");this.envelopegenerator.param("release",t);var e=this.context.currentTime,r=this.param("currentTime"),n=this.param("duration"),i=this.param("playbackRate");return this.envelopegenerator.start(e),this.envelopegenerator.stop(e+(n-r)/i,!0),this}},{key:"slice",value:function(t,e){if(!this.isBuffer())return null;var r=this.buffer,n=r.sampleRate,i=r.length,o=r.numberOfChannels,s=Math.floor(t*n),a=Math.floor(e*n);(isNaN(s)||s<0)&&(s=0),(isNaN(a)||a>i)&&(a=i);var c=null,u=null;o>0&&(c=this.buffer.getChannelData(0)),o>1&&(u=this.buffer.getChannelData(1));var l=null,f=null,h=null,p=a-s;switch(o){case 1:l=new Float32Array(p);for(var y=s;y<a;y++)l[y-s]=c[y];return(h=this.context.createBuffer(1,p,n)).copyToChannel(l,0),h;case 2:l=new Float32Array(p),f=new Float32Array(p);for(var v=s;v<a;v++)l[v-s]=c[v],f[v-s]=u[v];return(h=this.context.createBuffer(2,p,n)).copyToChannel(l,0),h.copyToChannel(f,1),h;default:return null}}},{key:"sprite",value:function(t){var e=this;return this.isBuffer()?"[object Object]"!==Object.prototype.toString.call(t)?null:Object.keys(t).reduce((function(r,n){var i=t[n];return Array.isArray(i)&&2===i.length?(r[n]=e.slice(parseFloat(i[0]),parseFloat(i[1])),r):r}),{}):null}},{key:"params",value:function(){var t=vn(mn(s.prototype),"params",this).call(this);return t.audio={playbackrate:this.isSource()?this.source.playbackRate.value:1,vocalcanceler:{depth:this.vocalcanceler.param("depth")}},t}},{key:"toString",value:function(){return"[AudioModule]"}}],r&&yn(e.prototype,r),s}(Mr);function wn(t){return wn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wn(t)}function Sn(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return On(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?On(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function On(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function An(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function kn(t,e,r){return kn="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=jn(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},kn(t,e,r||t)}function Tn(t,e){return Tn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Tn(t,e)}function En(t,e){if(e&&("object"===wn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function jn(t){return jn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},jn(t)}function Rn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Pn=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Tn(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=jn(n);if(i){var r=jn(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return En(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).source=null,r.media=null,r.ext="",r.mse=null,r.sb=null,r.file="",r.mimeType="",r.playbackRate=1,r.controls=!1,r.loop=!1,r.muted=!1,r.autoplay=!1,r.listeners={},r}return e=s,r=[{key:"setup",value:function(t,e,r,n){var i=this;if(this.envelopegenerator.setGenerator(0),this.envelopegenerator.param({attack:0,decay:.01,sustain:1,release:.01}),"[object Object]"===Object.prototype.toString.call(arguments[0])){var o=arguments[0];"media"in o&&(t=o.media),"formats"in o&&(e=o.formats),"listeners"in o&&(r=o.listeners),"autoplay"in o&&(n=o.autoplay)}var a="";if(t instanceof HTMLAudioElement)a=s.AUDIO;else{if(!(t instanceof HTMLVideoElement))return this;a=s.VIDEO}this.media=t,Array.isArray(e)||(e=[e]);var c,u=Sn(e);try{for(u.s();!(c=u.n()).done;){var l=c.value,f="".concat(a,"/").concat(String(l).toLowerCase());if(/^(?:maybe|probably)/.test(this.media.canPlayType(f))){this.ext=l;break}}}catch(t){u.e(t)}finally{u.f()}if("[object Object]"===Object.prototype.toString.call(r))for(var h in r)this.listeners[h.toLowerCase()]="[object Function]"===Object.prototype.toString.call(r[h])?r[h]:function(){};for(var p in this.autoplay=Boolean(n),!this.autoplay||this.source instanceof MediaElementAudioSourceNode||(this.source=this.context.createMediaElementSource(this.media)),this.autoplay&&this.media.src&&this.context.resume().then((function(){i.start(i.media.currentTime)})).catch((function(){throw new Error("Autoplay is failed")})),this.media.addEventListener("loadstart",(function(t){i.source instanceof MediaElementAudioSourceNode||(i.source=i.context.createMediaElementSource(i.media)),"loadstart"in i.listeners&&i.listeners.loadstart(t)}),!1),this.media.addEventListener("ended",(function(t){i.media.pause(),i.off(i.context.currentTime),i.analyser.stop("time"),i.analyser.stop("fft"),i.processor.disconnect(0),i.processor.onaudioprocess=null,"ended"in i.listeners&&i.listeners.ended(t)}),!1),this.listeners)this.media.addEventListener(p,(function(t){i.listeners[t.type.toLowerCase()](t)}),!1);return this}},{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n,i=String(t).replace(/-/g,"").toLowerCase();if("mastervolume"===i&&(n=kn(jn(s.prototype),"param",this).call(this,i,e)),void 0!==n)return n;var o=null,a=null,c=null;switch(i){case"playbackrate":if(void 0===e)return this.media instanceof HTMLMediaElement?this.media.playbackRate:this.playbackRate;if((o=parseFloat(e))>=(a=.5)){this.media instanceof HTMLMediaElement&&(this.media.playbackRate=o),this.playbackRate=o;var u=this.context.currentTime,l=this.param("currentTime"),f=this.param("duration");this.envelopegenerator.start(u),isFinite(f)&&this.envelopegenerator.stop(u+(f-l)/o,!0)}break;case"currenttime":if(void 0===e)return this.media instanceof HTMLMediaElement?this.media.currentTime:0;if(this.media instanceof HTMLMediaElement&&(o=parseFloat(e),a=0,c=this.media.duration,o>=a&&o<=c)){this.media.currentTime=o;var h=this.context.currentTime,p=this.param("duration"),y=this.param("playbackRate");this.envelopegenerator.start(h),isFinite(p)&&this.envelopegenerator.stop(h+(p-o)/y,!0)}break;case"loop":case"muted":case"controls":if(void 0===e)return this.media instanceof HTMLMediaElement?this.media[i]:this[i];this.media instanceof HTMLMediaElement&&(this.media[i]=Boolean(e)),this[i]=Boolean(e);break;case"width":case"height":if(void 0===e)return this.media instanceof HTMLVideoElement?this.media[i]:0;(o=parseInt(e,10))>=(a=0)&&this.media instanceof HTMLVideoElement&&(this.media[i]=o);break;case"duration":return this.media&&this.media.duration?this.media.duration:0;case"channels":return this.source instanceof MediaElementAudioSourceNode?this.source.channelCount:0}}return this}},{key:"ready",value:function(t,e){var r=String(t);this.mse&&"open"===this.mse.readyState&&(this.mse.endOfStream(),window.URL.revokeObjectURL(this.media.src),this.mse.removeEventListener("sourceopen",this.onSourceOpen,!1),this.mse.removeEventListener("sourceended",this.onSourceEnded,!1),this.mse.removeEventListener("sourceclose",this.onSourceClose,!1),this.sb.removeEventListener("updateend",this.onSourceBufferUpdateEnd,!1),this.sb.removeEventListener("error",this.onSourceBufferError,!1));try{if(e){if(!MediaSource||!MediaSource.isTypeSupported(e))throw new Error("This Browser does not support `MediaSource` or MIME type");this.media.removeAttribute("src"),this.media.load(),this.mse=new MediaSource,this.media.src=window.URL.createObjectURL(this.mse),this.mimeType=e,this.file=r,this.onSourceOpen=this.onSourceOpen.bind(this),this.onSourceEnded=this.onSourceEnded.bind(this),this.onSourceClose=this.onSourceClose.bind(this),this.mse.addEventListener("sourceopen",this.onSourceOpen,!1),this.mse.addEventListener("sourceended",this.onSourceEnded,!1),this.mse.addEventListener("sourceclose",this.onSourceClose,!1)}else-1!==r.indexOf("data:")||-1!==r.indexOf("blob:")||""===this.ext?this.media.src=r:this.media.src="".concat(r,".").concat(this.ext)}catch(t){throw new Error(t.message)}return this}},{key:"start",value:function(t,e,r){var n=this;return this.source instanceof MediaElementAudioSourceNode&&(this.envelopegenerator.ready(0,this.source,this.processor),this.connect(this.processor,e),this.media.play().then((function(){var e=n.context.currentTime,i=parseFloat(t);n.media.currentTime=i>=0&&i<=n.media.duration?i:0,n.media.playbackRate=n.playbackRate,n.media.controls=n.controls,n.media.loop=n.loop,n.media.muted=n.muted,n.envelopegenerator.start(e),isFinite(n.media.duration)&&n.envelopegenerator.stop(e+(n.media.duration-i)/n.media.playbackRate,!0),n.on(e),n.analyser.start("time"),n.analyser.start("fft");var o=n.processor.bufferSize;"[object Function]"===Object.prototype.toString.call(r)?n.processor.onaudioprocess=r:n.processor.onaudioprocess=function(t){for(var e=t.inputBuffer.getChannelData(0),r=t.inputBuffer.getChannelData(1),i=t.outputBuffer.getChannelData(0),s=t.outputBuffer.getChannelData(1),a=0;a<o;a++)i[a]=n.vocalcanceler.start(e[a],r[a]),s[a]=n.vocalcanceler.start(r[a],e[a])}})).catch((function(){n.stop((function(){n.autoplay&&(n.media.muted=n.muted=!0,n.media.volume=0),n.start(t,e,r)}),(function(){}))}))),this}},{key:"stop",value:function(t,e){var r=this;return this.source instanceof MediaElementAudioSourceNode&&this.media.play().then((function(){return r.media.pause(),r.off(r.context.currentTime),r.analyser.stop("time"),r.analyser.stop("fft"),r.processor.disconnect(0),r.processor.onaudioprocess=null,"[object Function]"===Object.prototype.toString.call(t)&&t(),Promise.resolve()})).catch((function(t){return"[object Function]"===Object.prototype.toString.call(e)&&e(t),Promise.reject(t)})),this}},{key:"get",value:function(){return this.source}},{key:"toggle",value:function(t,e,r){return this.media.paused?this.start(t,e,r):this.stop(),this}},{key:"isMedia",value:function(){return this.media instanceof HTMLMediaElement}},{key:"isSource",value:function(){return this.source instanceof MediaElementAudioSourceNode}},{key:"isPaused",value:function(){return!(this.media instanceof HTMLMediaElement)||this.media.paused}},{key:"onSourceOpen",value:function(t){var e=this;this.sb=this.mse.addSourceBuffer(this.mimeType),this.sb.mode="sequence",this.onSourceBufferUpdateEnd=this.onSourceBufferUpdateEnd.bind(this),this.onSourceBufferError=this.onSourceBufferError.bind(this),this.sb.addEventListener("updateend",this.onSourceBufferUpdateEnd,!1),this.sb.addEventListener("error",this.onSourceBufferError,!1),"sourceopen"in this.listeners&&this.listeners.sourceopen(t);var r=new Request(this.file);fetch(r).then((function(t){return t.arrayBuffer()})).then((function(t){e.sb.appendBuffer(t)})).catch((function(r){"error"in e.listeners&&e.listeners.error(t,r)}))}},{key:"onSourceEnded",value:function(t){"sourceended"in this.listeners&&this.listeners.sourceended(t)}},{key:"onSourceClose",value:function(t){"sourceclose"in this.listeners&&this.listeners.sourceclose(t)}},{key:"onSourceBufferUpdateEnd",value:function(t){"updateend"in this.listeners&&this.listeners.updateend(t)}},{key:"onSourceBufferError",value:function(t){"error"in this.listeners&&this.listeners.error(t)}},{key:"params",value:function(){var t=kn(jn(s.prototype),"params",this).call(this);return t.media={playbackrate:this.playbackRate,vocalcanceler:{depth:this.vocalcanceler.param("depth")}},delete t.audio,t}},{key:"requestPictureInPicture",value:function(){return this.media instanceof HTMLVideoElement&&"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled?this.media.disablePictureInPicture||0===this.media.readyState||this.media===document.pictureInPictureElement?Promise.reject():this.media.requestPictureInPicture():Promise.reject()}},{key:"exitPictureInPicture",value:function(){return this.media instanceof HTMLVideoElement&&"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled?this.media.disablePictureInPicture||0===this.media.readyState||this.media!==document.pictureInPictureElement?Promise.reject():document.exitPictureInPicture():Promise.reject()}},{key:"toString",value:function(){return"[MediaModule]"}}],r&&An(e.prototype,r),s}(gn);function xn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}Rn(Pn,"AUDIO","audio"),Rn(Pn,"VIDEO","video");var _n=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.level=0}var e,r;return e=t,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null;if("level"===n){if(void 0===e)return this.level;o=1,(i=parseFloat(e))>=0&&i<=o&&(this.level=i)}}return this}},{key:"start",value:function(t){return Math.abs(parseFloat(t))>this.level?t:0}},{key:"toString",value:function(){return"[StreamModule NoiseGate]"}}],r&&xn(e.prototype,r),t}();function Mn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var Cn=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.threshold=0}var e,r,n;return e=t,r=[{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=null,o=null;if("threshold"===n){if(void 0===e)return this.threshold;o=1,(i=parseFloat(e))>=0&&i<=o&&(this.threshold=i)}}return this}},{key:"start",value:function(e,r,n){if(this.threshold>0){var i=new Float32Array(e),o=new Float32Array(n),s=new Float32Array(n),a=new Float32Array(n),c=new Float32Array(n),u=new Float32Array(n);t.FFT(i,o,n);for(var l=0;l<n;l++)c[l]=Math.sqrt(Math.pow(i[l],2)+Math.pow(o[l],2)),0!==i[l]&&0!==o[l]&&(u[l]=Math.atan2(o[l],i[l])),c[l]-=this.threshold,c[l]<0&&(c[l]=0),s[l]=c[l]*Math.cos(u[l]),a[l]=c[l]*Math.sin(u[l]);t.IFFT(s,a,n),r.set(s)}else r.set(e);return this}},{key:"toString",value:function(){return"[StreamModule NoiseSuppressor]"}}],n=[{key:"FFT",value:function(t,e,r){for(var n=function(t){return Math.pow(2,t)},i=new Float32Array(r),o=Math.log2(r),s=1;s<=o;s++)for(var a=0;a<n(s-1);a++)for(var c=o-s,u=0;u<n(c);u++){var l=a*n(c+1)+u,f=n(c)+l,h=u*n(s-1),p=t[l],y=e[l],v=t[f],d=e[f],b=Math.cos(2*Math.PI*h/r),m=-1*Math.sin(2*Math.PI*h/r);s<o?(t[l]=p+v,e[l]=y+d,t[f]=b*(p-v)-m*(y-d),e[f]=b*(y-d)+m*(p-v)):(t[l]=p+v,e[l]=y+d,t[f]=p-v,e[f]=y-d)}for(var g=1;g<=o;g++)for(var w=o-g,S=0;S<n(g-1);S++)i[n(g-1)+S]=i[S]+n(w);for(var O=0;O<r;O++)if(!(i[O]<=O)){var A=t[i[O]],k=e[i[O]];t[i[O]]=t[O],e[i[O]]=e[O],t[O]=A,e[O]=k}}},{key:"IFFT",value:function(t,e,r){for(var n=function(t){return Math.pow(2,t)},i=new Float32Array(r),o=Math.log2(r),s=1;s<=o;s++)for(var a=0;a<n(s-1);a++)for(var c=o-s,u=0;u<n(c);u++){var l=a*n(c+1)+u,f=n(c)+l,h=u*n(s-1),p=t[l],y=e[l],v=t[f],d=e[f],b=Math.cos(2*Math.PI*h/r),m=Math.sin(2*Math.PI*h/r);s<o?(t[l]=p+v,e[l]=y+d,t[f]=b*(p-v)-m*(y-d),e[f]=b*(y-d)+m*(p-v)):(t[l]=p+v,e[l]=y+d,t[f]=p-v,e[f]=y-d)}for(var g=1;g<=o;g++)for(var w=o-g,S=0;S<n(g-1);S++)i[n(g-1)+S]=i[S]+n(w);for(var O=0;O<r;O++)if(!(i[O]<=O)){var A=t[i[O]],k=e[i[O]];t[i[O]]=t[O],e[i[O]]=e[O],t[O]=A,e[O]=k}for(var T=0;T<r;T++)t[T]/=r,e[T]/=r}}],r&&Mn(e.prototype,r),n&&Mn(e,n),t}();function Fn(t){return Fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fn(t)}function In(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Nn(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Nn(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Nn(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Ln(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Dn(t,e,r){return Dn="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=qn(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},Dn(t,e,r||t)}function Bn(t,e){return Bn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Bn(t,e)}function Un(t,e){if(e&&("object"===Fn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function qn(t){return qn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},qn(t)}var Vn=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Bn(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=qn(n);if(i){var r=qn(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Un(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).sources=[],r.stream=null,r.constraints={audio:!0,video:!1},r.callbacks={stream:function(){},error:function(){}},r.each=!1,r.output=!0,r.isStop=!0,r.noisegate=new _n,r.noisesuppressor=new Cn,r}return e=s,r=[{key:"setup",value:function(t,e,r){return"[object Object]"===Object.prototype.toString.call(t)&&(this.constraints=t),"[object Function]"===Object.prototype.toString.call(e)&&(this.callbacks.stream=e),"[object Function]"===Object.prototype.toString.call(r)&&(this.callbacks.error=r),this}},{key:"param",value:function(t,e){if("[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.param(r,arguments[0][r]);else{var n=String(t).replace(/-/g,"").toLowerCase(),i=Dn(qn(s.prototype),"param",this).call(this,n,e);if(void 0!==i)return i;switch(n){case"each":if(void 0===e)return this.each;this.each=Boolean(e);break;case"output":if(void 0===e)return this.output;this.output=Boolean(e)}}return this}},{key:"ready",value:function(t){var e=this;return navigator.mediaDevices&&navigator.mediaDevices.getUserMedia&&window.MediaStream?(this.isStop=!1,t instanceof MediaStream?(this.stream=t,Promise.resolve()):navigator.mediaDevices.getUserMedia(this.constraints).then((function(t){e.isStop||(e.stream=t,e.callbacks.stream(t))})).catch((function(t){e.callbacks.error(t)}))):Promise.reject("Cannot use WebRTC.")}},{key:"start",value:function(t,e){var r=this;if(null===this.stream)return this;var n=this.processor.bufferSize,i=!1;if(this.each)for(var o=this.stream.getAudioTracks(),s=0,a=o.length;s<a;s++)this.sources[s]=this.context.createMediaStreamTrackSource(o[s]),this.sources[s].connect(this.processor),this.connect(this.processor,t);else this.sources[0]=this.context.createMediaStreamSource(this.stream),this.sources[0].connect(this.processor),this.connect(this.processor,t);return this.output||(this.mastervolume.disconnect(0),this.mastervolume.connect(this.analyser.input),this.mastervolume.connect(this.recorder.processor),this.recorder.processor.connect(this.context.destination),this.mastervolume.connect(this.session.sender),this.session.sender.connect(this.context.destination)),this.on(this.context.currentTime),i||(this.analyser.start("time"),this.analyser.start("fft"),i=!0),"[object Function]"===Object.prototype.toString.call(e)?this.processor.onaudioprocess=e:this.processor.onaudioprocess=function(t){for(var e=t.inputBuffer.getChannelData(0),i=t.inputBuffer.getChannelData(1),o=t.outputBuffer.getChannelData(0),s=t.outputBuffer.getChannelData(1),a=0;a<n;a++)o[a]=r.noisegate.start(e[a]),s[a]=r.noisegate.start(i[a]);r.noisesuppressor.start(e,o,n),r.noisesuppressor.start(i,s,n)},this}},{key:"stop",value:function(){return this.sources.length=0,this.off(this.context.currentTime,!0),this.analyser.stop("time"),this.analyser.stop("fft"),this.processor.disconnect(0),this.processor.onaudioprocess=null,this.isStop=!0,this}},{key:"get",value:function(t){var e=parseInt(t,10);return e>=0&&e<this.sources.length?this.sources[e]:this.sources}},{key:"getStream",value:function(){return this.stream}},{key:"toggle",value:function(t,e){return this.isStreaming()?this.stop():this.start(t,e),this}},{key:"clear",value:function(){return this.stop(),this.clearAudio(),this.clearVideo(),this.stream=null,this}},{key:"clearAudio",value:function(){if(null===this.stream)return this;this.stop();var t,e=In(this.stream.getAudioTracks());try{for(e.s();!(t=e.n()).done;)t.value.stop()}catch(t){e.e(t)}finally{e.f()}return this}},{key:"clearVideo",value:function(){if(null===this.stream)return this;this.stop();var t,e=In(this.stream.getVideoTracks());try{for(e.s();!(t=e.n()).done;)t.value.stop()}catch(t){e.e(t)}finally{e.f()}return this.stream=null,this}},{key:"devices",value:function(){return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?navigator.mediaDevices.enumerateDevices():Promise.reject("No devices.")}},{key:"isStreaming",value:function(){return!this.isStop}},{key:"params",value:function(){var t=Dn(qn(s.prototype),"params",this).call(this);return t.stream={output:this.output,noisegate:{level:this.noisegate.param("level")},noisesuppressor:{threshold:this.noisesuppressor.param("threshold")}},t}},{key:"toString",value:function(){return"[StreamModule]"}}],r&&Ln(e.prototype,r),s}(Mr);function Gn(t){return Gn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gn(t)}function zn(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Xn(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Xn(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Xn(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Wn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Hn(t,e){return Hn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Hn(t,e)}function Yn(t,e){if(e&&("object"===Gn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Qn(t){return Qn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Qn(t)}var Zn=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Hn(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Qn(n);if(i){var r=Qn(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return Yn(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).sources=[],r.isAnalyser=!1,r}return e=s,r=[{key:"mix",value:function(t){var e=this;Array.isArray(t)||(t=[t]),this.sources=t;var r,n=zn(this.sources);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(!(i instanceof Wr||i instanceof en||i instanceof gn||i instanceof Pn||i instanceof Vn))return this;var o=this.context.currentTime;this.off(o,!1),i.analyser.stop("time"),i.analyser.stop("fft"),i.isAnalyser=!1,i.recorder.stop(),i.session.close(),i.processor.disconnect(0),i.processor.connect(this.processor)}}catch(t){n.e(t)}finally{n.f()}this.connect(this.processor);var s=this.context.currentTime;return this.on(s),this.isAnalyser||(this.analyser.start("time"),this.analyser.start("fft"),this.isAnalyser=!0),this.processor.onaudioprocess=function(r){var n,i=r.inputBuffer.getChannelData(0),o=r.inputBuffer.getChannelData(1),s=r.outputBuffer.getChannelData(0),a=r.outputBuffer.getChannelData(1),c=!1,u=zn(t);try{for(u.s();!(n=u.n()).done;){var l=n.value;(l instanceof Wr&&l.envelopegenerator.isStop()||l instanceof en&&l.isStop||l instanceof gn&&l.paused||l instanceof Pn&&l.media.paused||l instanceof Vn&&l.isStop)&&(c=!0)}}catch(t){u.e(t)}finally{u.f()}if(c){var f=e.context.currentTime;e.on(f,!0),e.analyser.stop("time"),e.analyser.stop("fft"),e.isAnalyser=!1,e.processor.disconnect(0),e.processor.onaudioprocess=null}else s.set(i),a.set(o)},this}},{key:"get",value:function(t){var e=parseInt(t,10);return e>=0&&e<this.sources.length?this.sources[e]:this.sources}},{key:"toString",value:function(){return"[MixerModule]"}}],r&&Wn(e.prototype,r),s}(Mr);function $n(t){return $n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$n(t)}function Jn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Kn(t,e){return Kn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Kn(t,e)}function ti(t,e){if(e&&("object"===$n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function ei(t){return ei=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ei(t)}var ri=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Kn(t,e)}(s,t);var e,r,n,i,o=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=ei(n);if(i){var r=ei(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return ti(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this,t,e)).envelopegenerator.setGenerator(0),r.processor=null,r.name="",r.options={},r.moduleURL="",r.promise=null,r.map=null,r.runAnalyser=!1,r}return e=s,r=[{key:"setup",value:function(t,e){return this.name=String(t),"[object Object]"===Object.prototype.toString.call(e)&&(this.options=e),window.AudioWorkletNode||(this.processor=this.context.createScriptProcessor(this.bufferSize,Mr.NUMBER_OF_INPUTS,Mr.NUMBER_OF_OUTPUTS),this.map=new Map),this}},{key:"ready",value:function(t,e){var r=this;return window.AudioWorkletNode?(this.moduleURL=String(t),"[object Object]"===Object.prototype.toString.call(e)?this.promise=this.context.audioWorklet.addModule(this.moduleURL,e):this.promise=this.context.audioWorklet.addModule(this.moduleURL),this.promise.then((function(){Object.keys(r.options).length>0?r.processor=new AudioWorkletNode(r.context,r.name,r.options):r.processor=new AudioWorkletNode(r.context,r.name)}))):Promise.reject("Cannot use AudioWorklet")}},{key:"start",value:function(t,e){var r=this.context.currentTime;return this.envelopegenerator.clear(!0),this.processor.disconnect(0),this.processor.onaudioprocess instanceof ScriptProcessorNode&&(this.processor.onaudioprocess=null),this.connect(this.envelopegenerator.getGenerator(0),e),this.envelopegenerator.ready(0,this.processor),this.envelopegenerator.start(r),this.runAnalyser||(this.analyser.start("time"),this.analyser.start("fft"),this.runAnalyser=!0),this.on(r),this.processor instanceof ScriptProcessorNode&&"[object Function]"===Object.prototype.toString.call(t)&&(this.processor.onaudioprocess=t),this}},{key:"stop",value:function(t){var e=this.context.currentTime;return this.processor.disconnect(0),this.envelopegenerator.stop(e),this.off(e),this.processor instanceof ScriptProcessorNode&&"[object Function]"===Object.prototype.toString.call(t)&&(this.processor.onaudioprocess=t),this}},{key:"postMessage",value:function(t){return this.processor instanceof AudioWorkletNode&&this.processor.port.postMessage(t),this}},{key:"onMessage",value:function(t){return this.processor instanceof AudioWorkletNode&&("[object Function]"!==Object.prototype.toString.call(t)&&null!==t||(this.processor.port.onmessage=t)),this}},{key:"onMessageError",value:function(t){return this.processor instanceof AudioWorkletNode&&("[object Function]"!==Object.prototype.toString.call(t)&&null!==t||(this.processor.port.onmessageerror=t)),this}},{key:"map",value:function(){return this.processor instanceof AudioWorkletNode?this.processor.parameters:this.map}},{key:"param",value:function(t){return this.processor instanceof AudioWorkletNode?this.processor.parameters.get(t):null}},{key:"get",value:function(){return this.processor}},{key:"toString",value:function(){return"[ProcessorModule]"}}],r&&Jn(e.prototype,r),s}(Mr);function ni(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var ii=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.context=e,this.midiAccess=null,this.inputs=[],this.outputs=[]}var e,r;return e=t,(r=[{key:"setup",value:function(t,e,r){var n=this;if(!navigator.requestMIDIAccess)throw new Error("Cannot use Web MIDI API.");return navigator.requestMIDIAccess({sysex:Boolean(t)}).then((function(t){if(n.midiAccess=t,"[object Function]"===Object.prototype.toString.call(t))n.inputs=t.inputs(),n.outputs=t.outputs();else{for(var r=t.inputs.values(),i=t.outputs.values(),o=r.next();!o.done;o=r.next())n.inputs.push(o.value);for(var s=i.next();!s.done;s=i.next())n.outputs.push(s.value)}"[object Function]"===Object.prototype.toString.call(e)&&e(n.midiAccess,n.inputs,n.outputs)})).catch((function(t){"[object Function]"===Object.prototype.toString.call(r)&&r(t)})),this}},{key:"get",value:function(){return this.midiAccess}},{key:"toString",value:function(){return"[MIDI]"}}])&&ni(e.prototype,r),t}();function oi(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var si=new Map([["T","TEMPO"],["O","OCTAVE"],["C","NOTE"],["D","NOTE"],["E","NOTE"],["F","NOTE"],["G","NOTE"],["A","NOTE"],["B","NOTE"],["+","NOTE"],["-","NOTE"],["#","NOTE"],["R","REST"],["0","NUMBER"],["1","NUMBER"],["2","NUMBER"],["3","NUMBER"],["4","NUMBER"],["5","NUMBER"],["6","NUMBER"],["7","NUMBER"],["8","NUMBER"],["9","NUMBER"],[".","NUMBER"],["&","TIE"],[" ","SPACE"],[void 0,"EOS"]]),ai={TEMPO:1,OCTAVE:2,NOTE:3,REST:4,NUMBER:5,TIE:6,SPACE:7,EOS:8,UNKNOWN:9},ci=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.type=e,this.token=r,this.value=parseInt(r,10)}var e,r;return e=t,(r=[{key:"getType",value:function(){return this.type||null}},{key:"getToken",value:function(){return this.token}},{key:"getValue",value:function(){return isNaN(this.value)?null:this.value}}])&&oi(e.prototype,r),t}();function ui(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var li=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.tokens="string"==typeof e?e.trim().toUpperCase().split("").reverse():[],this.notes=[],this.numbers=[]}var e,r;return e=t,(r=[{key:"get",value:function(){for(var t=this.tokens.pop();ai[si.get(t)]===ai.SPACE;)t=this.tokens.pop();if(ai[si.get(t)]===ai.EOS)return new ci(ai.EOS,t);switch(this.notes.length=0,this.numbers.length=0,ai[si.get(t)]){case ai.TEMPO:return new ci(ai.TEMPO,t);case ai.OCTAVE:return new ci(ai.OCTAVE,t);case ai.NOTE:for(this.notes.push(t),t=this.tokens.pop();ai[si.get(t)]===ai.NOTE;)this.notes.push(t),t=this.tokens.pop();return this.tokens.push(t),new ci(ai.NOTE,this.notes.join(""));case ai.REST:return new ci(ai.REST,t);case ai.NUMBER:for(this.numbers.push(t),t=this.tokens.pop();ai[si.get(t)]===ai.NUMBER;)this.numbers.push(t),t=this.tokens.pop();return this.tokens.push(t),new ci(ai.NUMBER,this.numbers.join(""));case ai.TIE:return new ci(ai.TIE,t);default:return new ci(ai.UNKNOWN,t)}}}])&&ui(e.prototype,r),t}();function fi(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var hi=function(){function t(e,r,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.operator=e,this.left=r,this.right=n}var e,r;return e=t,(r=[{key:"concat",value:function(t){this.right=t}},{key:"getOperator",value:function(){return this.operator}},{key:"getLeft",value:function(){return this.left}},{key:"getRight",value:function(){return this.right}},{key:"toString",value:function(){for(var e="",r=0;r<t.indent;r++)e+=" ";return t.indent++,"\n ".concat(e," ").concat(this.operator.getToken(),"\n ").concat(e," /\\\n ").concat(e).concat(null!==this.left?this.left.getOperator().getToken():"","\n ").concat(e).concat(null!==this.right&&void 0!==this.right.getOperator().getToken()?this.toString.call(this.right):"EOS","\n ")}}])&&fi(e.prototype,r),t}();function pi(t){return pi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pi(t)}function yi(t,e){if(e&&("object"===pi(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function vi(t){var e="function"==typeof Map?new Map:void 0;return vi=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return di(t,arguments,gi(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),mi(n,t)},vi(t)}function di(t,e,r){return di=bi()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&mi(i,r.prototype),i},di.apply(null,arguments)}function bi(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function mi(t,e){return mi=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},mi(t,e)}function gi(t){return gi=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},gi(t)}function wi(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Si(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:0,enumerable:!0,configurable:!0,writable:!0}):t[e]=0}(hi,"indent");var Oi=function(){function t(e){wi(this,t),this.tokenizer=e,this.syntaxTree=[]}var e,r;return e=t,(r=[{key:"parse",value:function(){for(var t=this.tokenizer.get(),e=this.tokenizer.get();;){switch(t.getType()){case ai.TEMPO:if(e.getType()===ai.NUMBER){var r=new hi(e,null,null),n=new hi(t,r,null);this.syntaxTree.push(n);break}return new Ai(Ai.ERRORS.TEMPO,t);case ai.OCTAVE:if(this.syntaxTree.length>0&&e.getType()===ai.NUMBER){var i=new hi(e,null,null),o=new hi(t,i,null);this.syntaxTree[this.syntaxTree.length-1].concat(o),this.syntaxTree.push(o);break}return new Ai(Ai.ERRORS.OCTAVE,t);case ai.NOTE:if(this.syntaxTree.length>0&&e.getType()===ai.NUMBER){var s=new hi(e,null,null),a=new hi(t,s,null);this.syntaxTree[this.syntaxTree.length-1].concat(a),this.syntaxTree.push(a);break}return new Ai(Ai.ERRORS.NOTE,t);case ai.REST:if(this.syntaxTree.length>0&&e.getType()===ai.NUMBER){var c=new hi(e,null,null),u=new hi(t,c,null);this.syntaxTree[this.syntaxTree.length-1].concat(u),this.syntaxTree.push(u);break}return new Ai(Ai.ERRORS.REST,t);case ai.NUMBER:break;case ai.TIE:if(this.syntaxTree.length>0){var l=new hi(t,null,null);this.syntaxTree[this.syntaxTree.length-1].concat(l),this.syntaxTree.push(l);break}return new Ai(Ai.ERRORS.TIE,t);case ai.EOS:if(this.syntaxTree.length>0){var f=new hi(t,null,null);this.syntaxTree[this.syntaxTree.length-1].concat(f),this.syntaxTree.push(f)}else{var h=new hi(t,null,null);this.syntaxTree.push(h)}return this.syntaxTree;default:return new Ai(Ai.ERRORS.UNKNOWN,t)}t=e,e=this.tokenizer.get()}}},{key:"free",value:function(){this.syntaxTree.length=0}}])&&Si(e.prototype,r),t}(),Ai=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&mi(t,e)}(i,t);var e,r,n=(e=i,r=bi(),function(){var t,n=gi(e);if(r){var i=gi(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return yi(this,t)});function i(t,e){var r;return wi(this,i),(r=n.call(this,t)).token=e,r.error=t,r}return i}(vi(Error));function ki(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}!function(t,e,r){e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(Ai,"ERRORS",{TEMPO:"tempo",OCTAVE:"octave",NOTE:"note",REST:"rest",TIE:"tie",UNKNOWN:"unknown"});var Ti=function(){function t(e,r,n,i,o,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.note=e,this.indexes=r,this.frequencies=n,this.start=i,this.stop=o,this.duration=s}var e,r;return e=t,(r=[{key:"concat",value:function(t){var e=t.toPlainObject();this.note+="&".concat(e.note),this.duration+=e.duration,this.stop=this.start+this.duration}},{key:"toPlainObject",value:function(){return{note:this.note,indexes:this.indexes,frequencies:this.frequencies,start:this.start,stop:this.stop,duration:this.duration}}}])&&ki(e.prototype,r),t}();function Ei(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function ji(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ri=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.sequences=[],this.treeConstructor=e,this.timeOf4note=0,this.octave=-1,this.currentTime=0}var e,r,n;return e=t,r=[{key:"get",value:function(){var t=this.treeConstructor.parse();this.timeOf4note=0,this.octave=-1,this.currentTime=0;for(var e=t[0];null!==e;){if(!(e instanceof hi))return e instanceof Ai?e:new Ai(Ai.ERRORS.UNKNOWN,null);var r=e.getOperator(),n=r.getType(),i=e.getLeft(),o=e.getRight(),s=null!==i?i.getOperator().getValue():-1;switch(n){case ai.TEMPO:if(s<=0)return new Ai(Ai.ERRORS.TEMPO,r.getToken());this.timeOf4note=60/s,e=o;break;case ai.OCTAVE:if(s<0)return new Ai(Ai.ERRORS.OCTAVE,r.getToken());this.octave=s,e=o;break;case ai.NOTE:case ai.REST:case ai.TIE:var a=this.push(n===ai.TIE?o:e);if(a instanceof Ai)return a;n===ai.TIE?(this.concat(),e=o.getRight()):e=o;break;case ai.EOS:e=o;break;default:return new Ai(Ai.ERRORS.UNKNOWN,null)}}return this.treeConstructor.free(),this.sequences}},{key:"push",value:function(e){var r=e.getLeft(),n=e.getRight();if(null!==r&&null!==n){var i=r.getOperator(),o=n.getOperator();if(!(i instanceof ci||o instanceof ci))return this.push(r),void this.push(n);for(var s=e.getOperator().getToken(),a=i.getValue(),c=i.getToken(),u=[],l=[],f=0,h=s.length;f<h;f++){var p=s.charAt(f),y=t.computeIndex(this.octave,p);switch(s.charAt(f+1)){case t.HALF_UP:case t.SHARP:y++,f++;break;case t.HALF_DOWN:y--,f++}if(y>=u[0]&&(y-=t.EQUAL_TEMPERAMENT),-1!==y&&y<0)return void console.assert();u.push(y)}for(var v=0,d=u;v<d.length;v++){var b=d[v],m=t.computeFrequency(b);if(m<0)return void console.assert();l.push(m)}var g=0;switch(a){case 1:case 2:case 4:case 8:case 16:case 32:case 64:case 128:case 256:var w=t.QUARTER_NOTE/a;c.includes(t.DOT)?g+=w*this.timeOf4note*1.5:g+=w*this.timeOf4note;break;case 6:g+=2*this.timeOf4note/3;break;case 12:g+=this.timeOf4note/3;break;case 18:g+=2*this.timeOf4note/9;break;case 24:g+=.5*this.timeOf4note/3;break;case 36:g+=this.timeOf4note/9;break;case 48:g+=.25*this.timeOf4note/3;break;case 72:g+=.5*this.timeOf4note/9;break;case 96:g+=.125*this.timeOf4note/3;break;case 144:g+=.25*this.timeOf4note/9;break;case 192:g+=.0625*this.timeOf4note/3;break;default:console.assert()}this.sequences.push(new Ti("".concat(s).concat(c),u,l,this.currentTime,this.currentTime+g,g)),this.currentTime+=g}}},{key:"concat",value:function(){var t=this.sequences.pop(),e=this.sequences.pop();e.concat(t),this.sequences.push(e)}}],n=[{key:"computeIndex",value:function(e,r){var n=0;switch(r){case t.C:n=3;break;case t.D:n=5;break;case t.E:n=7;break;case t.F:n=8;break;case t.G:n=10;break;case t.A:n=12;break;case t.B:n=14;break;case t.R:return-1;default:console.assert()}var i=t.EQUAL_TEMPERAMENT*(e-1)+n;return i>=0?i:-1}},{key:"computeFrequency",value:function(e){return e>=0?t.MIN_A*Math.pow(t.FREQUENCY_RATIO,e):0}}],r&&Ei(e.prototype,r),n&&Ei(e,n),t}();function Pi(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function xi(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}ji(Ri,"FREQUENCY_RATIO",Math.pow(2,1/12)),ji(Ri,"MIN_A",27.5),ji(Ri,"EQUAL_TEMPERAMENT",12),ji(Ri,"QUARTER_NOTE",4),ji(Ri,"C","C"),ji(Ri,"D","D"),ji(Ri,"E","E"),ji(Ri,"F","F"),ji(Ri,"G","G"),ji(Ri,"A","A"),ji(Ri,"B","B"),ji(Ri,"R","R"),ji(Ri,"SHARP","#"),ji(Ri,"HALF_UP","+"),ji(Ri,"HALF_DOWN","-"),ji(Ri,"DOT",".");var _i=function(){function t(e,r,n,i){var o=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.source=null,this.mml="",this.previous=null,this.timerid=null,this.currentIndex=0,this.currentPosition=0,this.offset=0,(e instanceof Wr||e instanceof en||e instanceof ln)&&(this.source=e),"string"==typeof r&&(this.mml=r),this.callbacks={start:function(){},stop:function(){},ended:function(){},error:function(){}},"[object Object]"===Object.prototype.toString.call(n)&&Object.keys(n).forEach((function(t){var e=t.toLowerCase();e in o.callbacks&&"[object Function]"===Object.prototype.toString.call(n[e])&&(o.callbacks[e]=n[e])}));var s=parseInt(i,10);!isNaN(s)&&s>=0&&(this.offset=s);var a=new li(r),c=new Oi(a),u=new Ri(c);this.sequences=u.get(),this.sequences instanceof Ai&&this.callbacks.error&&this.callbacks.error(this.sequences)}var e,r;return e=t,(r=[{key:"start",value:function(t,e){var r=this;if(!this.sequences[this.currentIndex])return this.stop(),void this.callbacks.ended();var n=this.sequences[this.currentIndex++].toPlainObject();if(t){var i=this.mml.slice(0,this.currentPosition),o=this.mml.slice(this.currentPosition).replace(n.note,'<span class="x-highlight">'.concat(n.note,"</span>"));this.mml="".concat(i).concat(o),this.currentPosition+=this.mml.slice(this.currentPosition).indexOf("</span>")+"</span>".length}else{var s=this.mml.slice(0,this.currentPosition),a=n.note;this.mml="".concat(s).concat(a),this.currentPosition+=a.length}if(this.source instanceof Wr)this.source.ready(0,n.duration).start(n.frequencies),this.callbacks.start(n);else if(this.source instanceof en){for(var c=0,u=n.indexes.length;c<u;c++)-1!==n.indexes[c]&&this.source.ready(0,n.duration).start(n.indexes[c]+this.offset);this.callbacks.start(n,this.offset)}else this.source instanceof ln&&(this.source.start(e),this.callbacks.start(n));this.timerid=window.setTimeout((function(){r.source instanceof Wr?r.callbacks.stop(n):r.source instanceof en?r.callbacks.stop(n,r.offset):r.source instanceof ln&&(r.source.stop(),r.callbacks.stop(n)),r.previous=n,r.start(t,e)}),1e3*n.duration)}},{key:"stop",value:function(){if(null!==this.previous){if(this.source instanceof Wr)this.source.stop(),this.callbacks.stop(this.previous);else if(this.source instanceof en){var t,e=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Pi(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Pi(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}(this.previous.indexes);try{for(e.s();!(t=e.n()).done;){var r=t.value;-1!==r&&this.source.stop(r+this.offset)}}catch(t){e.e(t)}finally{e.f()}this.callbacks.stop(this.previous,this.offset)}else this.source instanceof ln&&(this.source.stop(),this.callbacks.stop(this.previous));window.clearTimeout(this.timerid),this.timerid=null}}},{key:"getMML",value:function(){return this.mml}},{key:"getSequence",value:function(){return this.sequences}},{key:"hasSequence",value:function(){return this.sequences.length>0}},{key:"paused",value:function(){return null===this.timerid}},{key:"getCurrentIndex",value:function(){return this.currentIndex}},{key:"setCurrentIndex",value:function(t){var e=parseInt(t,10);e>=0&&e<this.sequences.length&&(this.currentIndex=e)}}])&&xi(e.prototype,r),t}();function Mi(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Ci(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ci(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Ci(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Fi(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var Ii=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.context=e,this.parts=[],this.callbacks={start:function(){},stop:function(){},ended:function(){},error:function(){}}}var e,r;return e=t,r=[{key:"setup",value:function(t,e){if(arguments.length>0&&"[object Object]"===Object.prototype.toString.call(arguments[0]))for(var r in arguments[0])this.setup(r,arguments[0][r]);else if(arguments.length>1){var n=String(t).toLowerCase();n in this.callbacks&&"[object Function]"===Object.prototype.toString.call(e)&&(this.callbacks[n]=e)}return this}},{key:"ready",value:function(t,e,r){if(Array.isArray(e)||"string"!=typeof e||(e=[e]),!Array.isArray(e))return this;this.stop(),this.clear(),this.mmls=e;var n,i=Mi(e);try{for(i.s();!(n=i.n()).done;){var o=n.value;this.parts.push(new _i(t,o,this.callbacks,r))}}catch(t){i.e(t)}finally{i.f()}return this}},{key:"start",value:function(t,e,r){var n=parseInt(t,10);return n>=0&&n<this.parts.length&&this.parts[n].start(e,r),this}},{key:"stop",value:function(){var t,e=Mi(this.parts);try{for(e.s();!(t=e.n()).done;)t.value.stop()}catch(t){e.e(t)}finally{e.f()}return this}},{key:"get",value:function(t,e){var r,n=parseInt(t,10),i=[],o=[],s=Mi(this.parts);try{for(s.s();!(r=s.n()).done;){var a=r.value;i.push(a.getMML()),o.push(a.getSequence())}}catch(t){s.e(t)}finally{s.f()}return e?n>=0&&n<this.parts.length?this.parts[n].getMML():i:n>=0&&n<this.parts.length?this.parts[n].getSequence():o}},{key:"toggle",value:function(t,e,r){return this.isPaused()?this.start(t,e,r):this.stop(),this}},{key:"isSequences",value:function(){return this.parts.length>0&&this.parts.every((function(t){return t.hasSequence()}))}},{key:"isPaused",value:function(){return 0===this.parts.length||this.parts.every((function(t){return t.paused()}))}},{key:"currentIndex",value:function(t,e){var r=parseInt(t,10);return r<0||r>=this.parts.length?this:void 0===e?this.parts[r].getCurrentIndex():(this.parts[r].setCurrentIndex(e),this)}},{key:"toABC",value:function(t,e,r,n,i,o){var s="";s+="X:".concat(e||1,"\n"),s+="T:".concat(r||"","\n"),s+="M:".concat(n||"4/4","\n"),s+="L:".concat(i||"1/256","\n"),s+="K:".concat(o||"","\n");var a=t.match(/\s*(?:T\d+)\s*|\s*(?:O\d+)\s*|\s*(?:(?:[CDEFGABR][#+-]?)+(?:256|192|144|128|96|72|64|48|36|32|24|18|16|12|8|6|4|2|1)\.?)(?:&(?:[CDEFGABR][#+-]?)+(?:256|192|144|128|96|72|64|48|36|32|24|18|16|12|8|6|4|2|1)\.?)*\s*/gi);if(null===a)return s;for(var c=null,u=0;a.length>0;){var l=a.shift().trim();if(/T\d+/i.test(l)){var f=parseInt(l.slice(1),10);if(f<=0)return s;s+="Q:1/4=".concat(f,"\n")}else if(/O\d+/i.test(l)){if((c=parseInt(l.slice(1),10))<0)return s}else if(/(?:(?:[CDEFGABR][#+-]?)+)(?:256|192|144|128|96|72|64|48|36|32|24|18|16|12|8|6|4|2|1)(?:&(?:[CDEFGABR][#+-]?)+(?:256|192|144|128|96|72|64|48|36|32|24|18|16|12|8|6|4|2|1)\.?)*/i.test(l)){if(null===c)return s;var h=null;h=-1===l.indexOf("&")?[l]:l.split("&");for(var p="";h.length>0;){var y=h.shift(),v="",d=0;switch(parseInt(y.replace(/^.+?(\d+)\.*$/,"$1"),10)){case 1:v=y.replace("1","256");break;case 2:v=y.replace("2","128");break;case 4:v=y.replace("4","64");break;case 8:v=y.replace("8","32");break;case 16:v=y.replace("16","16");break;case 32:v=y.replace("32","8");break;case 64:v=y.replace("64","4");break;case 128:v=y.replace("128","2");break;case 256:v=y.replace("256","1");break;case 6:v="(3".concat(y.replace("6","128")),d=128/3;break;case 12:v="(3".concat(y.replace("12","64")),d=64/3;break;case 18:v="(9".concat(y.replace("18","128")),d=128/9;break;case 24:v="(3".concat(y.replace("24","32")),d=32/3;break;case 36:v="(9".concat(y.replace("36","64")),d=64/9;break;case 48:v="(3".concat(y.replace("48","16")),d=16/3;break;case 72:v="(9".concat(y.replace("72","32")),d=32/9;break;case 96:v="(3".concat(y.replace("96","8")),d=8/3;break;case 144:v="(9".concat(y.replace("144","16")),d=16/9;break;case 192:v="(3".concat(y.replace("192","4")),d=4/3;break;default:return s}if(-1!==v.indexOf(".")&&(v=v.replace(/^(.+?)\d+\.+$/,"$1".concat(1.5*parseInt(v.replace(/^.+?(\d+)\.+$/,"$1"),10)))),-1===v.indexOf("(")?u+=parseInt(v.replace(/^.+?(\d+)\.*$/i,"$1"),10):u+=d,u>=256&&(v+=" | ",u=0),/R/i.test(v))s+="".concat(v," ");else{var b="";switch(c){case 0:b=",,,,";break;case 1:b=",,,";break;case 2:b=",,";break;case 3:b=",";break;case 5:b="'";break;case 6:b="''";break;case 7:b="'''"}var m=v.match(/^(\(\d+)?((?:[CDEFGAB][#+-]?)+)(.*)$/i);if(null===m)return s;var g=m[1]?m[1]:"",w=m[2].length,S=m[3]?m[3]:"",O=0;if(g.length>0&&(v=v.replace(/^(?:\(\d+)?((?:[CDEFGAB][#+-]?)+)(.*)$/i,"$1$2")),1===w)p+="".concat(g).concat(v.slice(0,1)).concat(b).concat(S);else if(2===w&&/[#+-]/.test(v.charAt(1)))p+="".concat(g).concat(v.slice(1,2)).concat(v.slice(0,1)).concat(b).concat(S);else for(;O<w;)0===O&&(p+="".concat(g,"[")),/[#+-]/.test(v.charAt(O+1))?(p+="".concat(v.slice(O+1,O+2)).concat(v.slice(O,O+1)).concat(b),O+=2):(p+="".concat(v.slice(O,O+1)).concat(b),O++),O===w&&(p+="]".concat(S));h.length>0?p+="&":s+="".concat(p," ")}}}}return s.replace(/R/gi,"z").replace(/[#+]/g,"^").replace(/-/g,"_").replace(/&/g,"-").replace(/\s{2}/g," ").trim()}},{key:"clear",value:function(){var t,e=Mi(this.parts);try{for(e.s();!(t=e.n()).done;)t.value.stop()}catch(t){e.e(t)}finally{e.f()}return this.parts.length=0,this}},{key:"toString",value:function(){return"[MML]"}}],r&&Fi(e.prototype,r),t}();function Ni(t,e,r,n,i){if("[object Object]"===Object.prototype.toString.call(arguments[0])){var o=arguments[0];"file"in o&&(t=o.file),"type"in o&&(e=o.type),"success"in o&&(r=o.success),"error"in o&&(n=o.error),"progress"in o&&(i=o.progress)}if(t instanceof Blob){var s=new FileReader;s.onprogress=function(t){"[object Function]"===Object.prototype.toString.call(i)&&i(t)},s.onerror=function(t){if("[object Function]"===Object.prototype.toString.call(n)){var e="";switch(s.error.code){case s.error.NOT_FOUND_ERR:e="NOT_FOUND_ERR";break;case s.error.SECURITY_ERR:e="SECURITY_ERR";break;case s.error.ABORT_ERR:e="ABORT_ERR";break;case s.error.NOT_READABLE_ERR:e="NOT_READABLE_ERR";break;case s.error.ENCODING_ERR:e="ENCODING_ERR";break;default:e="ERR"}n(t,e)}},s.onload=function(t){if("[object Function]"===Object.prototype.toString.call(r)){var e=s.result;"string"!=typeof e||e.includes("data:")||e.indexOf("blob:")||(e=e.replace(/<(\/?script.*?)>/gi,"&lt;$1&gt;")),r(t,e)}},/arraybuffer/i.test(e)?s.readAsArrayBuffer(t):/dataurl/i.test(e)?s.readAsDataURL(t):/text|json/i.test(e)&&s.readAsText(t,"UTF-8")}else"[object Function]"===Object.prototype.toString.call(n)&&n(null,"FILE_IS_NOT_BLOB")}function Li(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Di(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Di(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Di(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Bi,Ui="undefined"!=typeof window?window:{};Ui.AudioContext=Ui.AudioContext||Ui.webkitAudioContext,Ui.MediaSource=Ui.MediaSource||Ui.WebkitMediaSource,Ui.URL=Ui.URL||Ui.webkitURL||Ui.mozURL,Ui.requestAnimationFrame=Ui.requestAnimationFrame||Ui.webkitRequestAnimationFrame||Ui.mozRequestAnimationFrame||function(t){return Ui.setTimeout(t,1e3/60)},Ui.cancelAnimationFrame=Ui.cancelAnimationFrame||Ui.webkitCancelAnimationFrame||Ui.mozCancelAnimationFrame||Ui.clearTimeout;var qi=Boolean(Ui.AudioContext);if(qi){var Vi=new AudioContext;Vi.createScriptProcessor=Vi.createScriptProcessor||Vi.createJavaScriptNode,Vi.createGain=Vi.createGain||Vi.createGainNode,Vi.createDelay=Vi.createDelay||Vi.createDelayNode,Vi.createPeriodicWave=Vi.createPeriodicWave||Vi.createWaveTable;var Gi={oscillator:new Wr(Vi),oneshot:new en(Vi),noise:new ln(Vi),audio:new gn(Vi),media:new Pn(Vi),stream:new Vn(Vi),mixer:new Zn(Vi),processor:new ri(Vi),midi:new ii(Vi),mml:new Ii(Vi)};(Bi=function(t,e){var r=String(t).replace(/-/g,"").toLowerCase();switch(r){case"oscillator":if(void 0===e)return Gi.oscillator;var n=parseInt(e,10);return n>=0&&n<Gi.oscillator.length()?Gi.oscillator.get(n):null;case"oneshot":case"noise":case"audio":case"media":case"stream":case"mixer":case"processor":case"midi":case"mml":return Gi[r];default:return null}}).IS_XSOUND=qi,Bi.SAMPLE_RATE=Vi.sampleRate,Bi.NUMBER_OF_INPUTS=Mr.NUMBER_OF_INPUTS,Bi.NUMBER_OF_OUTPUTS=Mr.NUMBER_OF_OUTPUTS,Bi.FFT=function(t,e,r){for(var n=function(t){return Math.pow(2,t)},i=new Float32Array(r),o=Math.log2(r),s=1;s<=o;s++)for(var a=0;a<n(s-1);a++)for(var c=o-s,u=0;u<n(c);u++){var l=a*n(c+1)+u,f=n(c)+l,h=u*n(s-1),p=t[l],y=e[l],v=t[f],d=e[f],b=Math.cos(2*Math.PI*h/r),m=-1*Math.sin(2*Math.PI*h/r);s<o?(t[l]=p+v,e[l]=y+d,t[f]=b*(p-v)-m*(y-d),e[f]=b*(y-d)+m*(p-v)):(t[l]=p+v,e[l]=y+d,t[f]=p-v,e[f]=y-d)}for(var g=1;g<=o;g++)for(var w=o-g,S=0;S<n(g-1);S++)i[n(g-1)+S]=i[S]+n(w);for(var O=0;O<r;O++)if(!(i[O]<=O)){var A=t[i[O]],k=e[i[O]];t[i[O]]=t[O],e[i[O]]=e[O],t[O]=A,e[O]=k}},Bi.IFFT=function(t,e,r){for(var n=function(t){return Math.pow(2,t)},i=new Float32Array(r),o=Math.log2(r),s=1;s<=o;s++)for(var a=0;a<n(s-1);a++)for(var c=o-s,u=0;u<n(c);u++){var l=a*n(c+1)+u,f=n(c)+l,h=u*n(s-1),p=t[l],y=e[l],v=t[f],d=e[f],b=Math.cos(2*Math.PI*h/r),m=Math.sin(2*Math.PI*h/r);s<o?(t[l]=p+v,e[l]=y+d,t[f]=b*(p-v)-m*(y-d),e[f]=b*(y-d)+m*(p-v)):(t[l]=p+v,e[l]=y+d,t[f]=p-v,e[f]=y-d)}for(var g=1;g<=o;g++)for(var w=o-g,S=0;S<n(g-1);S++)i[n(g-1)+S]=i[S]+n(w);for(var O=0;O<r;O++)if(!(i[O]<=O)){var A=t[i[O]],k=e[i[O]];t[i[O]]=t[O],e[i[O]]=e[O],t[O]=A,e[O]=k}for(var T=0;T<r;T++)t[T]/=r,e[T]/=r},Bi.ajax=function(t,e,r,n,i,o){if("[object Object]"===Object.prototype.toString.call(arguments[0])){var s=arguments[0];"url"in s&&(t=s.url),"type"in s&&(e=s.type),"timeout"in s&&(r=s.timeout),"success"in s&&(n=s.success),"error"in s&&(i=s.error),"progress"in s&&(o=s.progress)}var a="error",c="timeout",u=new XMLHttpRequest,l=parseInt(r,10);u.timeout=l>0?l:6e4,u.ontimeout=function(t){"[object Function]"===Object.prototype.toString.call(i)&&i(t,c)},u.onprogress=function(t){"[object Function]"===Object.prototype.toString.call(o)&&o(t)},u.onerror=function(t){"[object Function]"===Object.prototype.toString.call(i)&&i(t,a)},u.onload=function(t){200===u.status&&"[object Function]"===Object.prototype.toString.call(n)&&n(t,u.response)},u.open("GET",t,!0),u.responseType=/text|arraybuffer|blob|document|json/.test(String(e).toLowerCase())?String(e).toLowerCase():"arraybuffer",u.send(null)},Bi.convertTime=function(t){var e=parseFloat(t);if(e>=0)return{minutes:Math.floor(e/60),seconds:Math.floor(e%60),milliseconds:e-Math.floor(e)}},Bi.decode=function(t,e,r,n){if(t instanceof AudioContext&&e instanceof ArrayBuffer)return"[object Function]"!==Object.prototype.toString.call(r)&&(r=function(){}),"[object Function]"!==Object.prototype.toString.call(n)&&(n=function(){}),t.decodeAudioData(e,r,n)},Bi.exitFullscreen=function(){return document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen?document.msExitFullscreen():document.cancelFullScreen?document.cancelFullScreen():Promise.reject("Cannot exit from full screen.")},Bi.file=function(t,e,r,n,i){if("[object Object]"===Object.prototype.toString.call(arguments[0])){var o=arguments[0];"event"in o&&(t=o.event),"type"in o&&(e=o.type),"success"in o&&(r=o.success),"error"in o&&(n=o.error),"progress"in o&&(i=o.progress)}if(t instanceof Event){var s=null;if("drop"===t.type)t.stopPropagation(),t.preventDefault(),s=t.dataTransfer.files[0];else{if("change"!==t.type||!("files"in t.target))return;s=t.target.files[0]}if(s instanceof File){if(/text/i.test(e)&&!s.type.includes("text"))throw new Error("Please upload text file.");if(/json/i.test(e)&&!s.type.includes("application/json"))throw new Error("Please upload JSON file.");if(/arraybuffer|dataurl/i.test(e)&&!/audio|video/.test(s.type))throw new Error("Please upload audio or video file.");return/objecturl/i.test(e)?window.URL.createObjectURL(s):(Ni({file:s,type:e,success:r,error:n,progress:i}),s)}throw new Error("Please upload file.")}},Bi.requestFullscreen=function(t){return t instanceof Element?t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen?t.msRequestFullscreen():Promise.reject("Cannot change to full screen."):Promise.reject("Invalid argument.")},Bi.read=Ni,Bi.toFrequencies=function(t){var e=Math.pow(2,1/12);Array.isArray(t)||(t=[t]);for(var r=new Array(t.length),n=0,i=t.length;n<i;n++){var o=parseInt(t[n],10);r[n]=o>=0?27.5*Math.pow(e,o):0}return r},Bi.toTextFile=function(t){var e=window.btoa(function(t){for(var e="",r=0,n=t.length;r<n;r++){var i=t.charCodeAt(r);e+=i>255?"&#".concat(i,";"):t.charAt(r)}return e}(String(t)));return"data:text/plain;base64,".concat(e)},Bi.Analyser=q,Bi.Recorder=K,Bi.Session=at,Bi.Effector=pt,Bi.Autopanner=wt,Bi.Chorus=Ft,Bi.Compressor=Ut,Bi.Delay=Wt,Bi.Distortion=Kt,Bi.Equalizer=ue,Bi.Filter=ve,Bi.Flanger=Oe,Bi.Listener=Re,Bi.Panner=Ie,Bi.Phaser=Ve,Bi.PitchShifter=Ye,Bi.Reverb=rr,Bi.Ringmodulator=ur,Bi.Stereo=vr,Bi.Tremolo=Or,Bi.Wah=Pr,Bi.setup=function(){return"running"!==Vi.state?Vi.resume():Promise.reject()},Bi.clone=function(){var t={oscillator:new Wr(Vi),oneshot:new en(Vi),noise:new ln(Vi),audio:new gn(Vi),media:new Pn(Vi),stream:new Vn(Vi),mixer:new Zn(Vi),processor:new ri(Vi),midi:new ii(Vi),mml:new Ii(Vi)},e=function(e,r){var n=String(e).replace(/-/g,"").toLowerCase();switch(n){case"oscillator":if(void 0===r)return t.oscillator;var i=parseInt(r,10);return i>=0&&i<t.oscillator.length()?t.oscillator.get(i):null;case"oneshot":case"noise":case"audio":case"media":case"stream":case"mixer":case"processor":case"midi":case"mml":return t[n];default:return null}};return e.free=function(e){Array.isArray(e)||(e=[e]);var r,n=Li(e);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(null!==i)for(var o in t)i===t[o]&&(t[o]=null)}}catch(t){n.e(t)}finally{n.f()}},e},Bi.free=function(t){Array.isArray(t)||(t=[t]);var e,r=Li(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;if(null!==n)for(var i in Gi)n===Gi[i]&&(Gi[i]=null)}}catch(t){r.e(t)}finally{r.f()}},Bi.noConflict=function(t){return window.X===Bi&&(window.X=void 0),t&&window.XSound===Bi&&(window.XSound=void 0),Bi},Bi.get=function(){return Vi},Bi.getCurrentTime=function(){return Vi.currentTime},Bi.toString=function(){return"[XSound]"};var zi=function t(){Bi.setup().then((function(){})).catch((function(){})),document.removeEventListener("click",t,!0),document.removeEventListener("mousedown",t,!0),document.removeEventListener("mouseup",t,!0),document.removeEventListener("touchstart",t,!0),document.removeEventListener("touchend",t,!0)};document.addEventListener("click",zi,!0),document.addEventListener("mousedown",zi,!0),document.addEventListener("mouseup",zi,!0),document.addEventListener("touchstart",zi,!0),document.addEventListener("touchend",zi,!0)}else(Bi=function(){return null}).IS_XSOUND=qi;Ui.XSound=Bi,Ui.X=Bi,"undefined"!=typeof exports&&(exports.XSound=Bi,exports.X=Bi)})();
3
3
  //# sourceMappingURL=xsound.js.map