diff --git a/all.js b/all.js new file mode 100644 index 0000000..6d7b1b3 --- /dev/null +++ b/all.js @@ -0,0 +1,21 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Tone=e():t.Tone=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=8)}([function(t,e,n){!function(t,e,n,o){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,n=n&&n.hasOwnProperty("default")?n.default:n,o=o&&o.hasOwnProperty("default")?o.default:o;var i=function(t,e,n){return{endTime:e,insertTime:n,type:"exponentialRampToValue",value:t}},r=function(t,e,n){return{endTime:e,insertTime:n,type:"linearRampToValue",value:t}},s=function(t,e){return{startTime:e,type:"setValue",value:t}},a=function(t,e,n){return{duration:n,startTime:e,type:"setValueCurve",values:t}},u=function(t,e,n){var o=n.startTime,i=n.target,r=n.timeConstant;return i+(e-i)*Math.exp((o-t)/r)},c=function(t){return"exponentialRampToValue"===t.type},l=function(t){return"linearRampToValue"===t.type},h=function(t){return c(t)||l(t)},p=function(t){return"setValue"===t.type},f=function(t){return"setValueCurve"===t.type},d=function t(e,n,o,i){var r=e[n];return void 0===r?i:h(r)||p(r)?r.value:f(r)?r.values[r.values.length-1]:u(o,t(e,n-1,r.startTime,i),r)},m=function(t,e,n,o,i){return void 0===n?[o.insertTime,i]:h(n)?[n.endTime,n.value]:p(n)?[n.startTime,n.value]:f(n)?[n.startTime+n.duration,n.values[n.values.length-1]]:[n.startTime,d(t,e-1,n.startTime,i)]},y=function(t){return"cancelAndHold"===t.type},_=function(t){return"cancelScheduledValues"===t.type},g=function(t){return y(t)||_(t)?t.cancelTime:c(t)||l(t)?t.endTime:t.startTime},v=function(t,e,n,o){var i=o.endTime,r=o.value;return n===r?r:0=e})),o=this._automationEvents[n];if(-1!==n&&(this._automationEvents=this._automationEvents.slice(0,n)),y(t)){var u=this._automationEvents[this._automationEvents.length-1];if(void 0!==o&&h(o)){if(x(u))throw new Error("The internal list is malformed.");var p=f(u)?u.startTime+u.duration:g(u),d=f(u)?u.values[u.values.length-1]:u.value,m=c(o)?v(e,p,d,o):b(e,p,d,o),w=c(o)?i(m,e,this._currenTime):r(m,e,this._currenTime);this._automationEvents.push(w)}void 0!==u&&x(u)&&this._automationEvents.push(s(this.getValue(e),e)),void 0!==u&&f(u)&&u.startTime+u.duration>e&&(this._automationEvents[this._automationEvents.length-1]=a(new Float32Array([6,7]),u.startTime,e-u.startTime))}}else{var T=this._automationEvents.findIndex((function(t){return g(t)>e})),O=-1===T?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[T-1];if(void 0!==O&&f(O)&&g(O)+O.duration>e)return!1;var S=c(t)?i(t.value,t.endTime,this._currenTime):l(t)?r(t.value,e,this._currenTime):t;if(-1===T)this._automationEvents.push(S);else{if(f(t)&&e+t.duration>g(this._automationEvents[T]))return!1;this._automationEvents.splice(T,0,S)}}return!0}},{key:"flush",value:function(t){var e=this._automationEvents.findIndex((function(e){return g(e)>t}));if(e>1){var n=this._automationEvents.slice(e-1),o=n[0];x(o)&&n.unshift(s(d(this._automationEvents,e-2,o.startTime,this._defaultValue),o.startTime)),this._automationEvents=n}}},{key:"getValue",value:function(t){if(0===this._automationEvents.length)return this._defaultValue;var n=this._automationEvents[this._automationEvents.length-1],o=this._automationEvents.findIndex((function(e){return g(e)>t})),i=this._automationEvents[o],r=g(n)<=t?n:this._automationEvents[o-1];if(void 0!==r&&x(r)&&(void 0===i||!h(i)||i.insertTime>t))return u(t,d(this._automationEvents,o-2,r.startTime,this._defaultValue),r);if(void 0!==r&&p(r)&&(void 0===i||!h(i)))return r.value;if(void 0!==r&&f(r)&&(void 0===i||!h(i)||r.startTime+r.duration>t))return t{try{return new DOMException("","AbortError")}catch(t){return t.code=20,t.name="AbortError",t}},s=new WeakSet,a=new WeakMap,u=new WeakMap,c=new WeakMap,l=new WeakMap,h=new WeakMap,p=new WeakMap,f=new WeakMap,d=new WeakMap,m=new WeakMap,y=new WeakMap,_=new WeakMap,g={construct:()=>g},v=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,b=(t,e)=>{const n=[];let o=t.replace(/^[\s]+/,""),i=o.match(v);for(;null!==i;){const t=i[1].slice(1,-1),r=i[0].replace(/([\s]+)?;?$/,"").replace(t,new URL(t,e).toString());n.push(r),o=o.slice(i[0].length).replace(/^[\s]+/,""),i=o.match(v)}return[n.join(";"),o]},x=t=>{if(void 0!==t&&!Array.isArray(t))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},w=t=>{if(!(t=>{try{new new Proxy(t,g)}catch(t){return!1}return!0})(t))throw new TypeError("The given value for processorCtor should be a constructor.");if(null===t.prototype||"object"!=typeof t.prototype)throw new TypeError("The given value for processorCtor should have a prototype.");if("function"!=typeof t.prototype.process)throw new TypeError("The given value for processorCtor should have a callable process() function.")},T={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},O=(t,e)=>t.context===e,S=t=>{try{t.copyToChannel(new Float32Array(1),0,-1)}catch(t){return!1}return!0},k=()=>{try{return new DOMException("","IndexSizeError")}catch(t){return t.code=1,t.name="IndexSizeError",t}},C=t=>{t.getChannelData=(e=>n=>{try{return e.call(t,n)}catch(t){if(12===t.code)throw k();throw t}})(t.getChannelData)},A={numberOfChannels:1},D=(t,e)=>{const n=t.get(e);if(void 0===n)throw new Error("A value with the given key could not be found.");return n},E=t=>D(f,t),M=t=>{if(s.has(t))throw new Error("The AudioNode is already stored.");s.add(t),E(t).forEach((t=>t(!0)))},P=t=>{if(!s.has(t))throw new Error("The AudioNode is not stored.");s.delete(t),E(t).forEach((t=>t(!1)))},R=(t,e)=>"function"==typeof e?n=>{const o={value:t};return Object.defineProperties(n,{currentTarget:o,target:o}),e.call(t,n)}:e,j={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},q=t=>void 0===t||"number"==typeof t||"string"==typeof t&&("balanced"===t||"interactive"===t||"playback"===t);class I{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(t,e,n){let o=this._listeners.get(e);return void 0===o&&(o=R(this,e),"function"==typeof e&&this._listeners.set(e,o)),this._nativeEventTarget.addEventListener(t,o,n)}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,e,n){const o=this._listeners.get(e);return this._nativeEventTarget.removeEventListener(t,void 0===o?null:o,n)}}const V=t=>"context"in t,F=t=>V(t[0]),N=t=>"port"in t,L=t=>"inputs"in t,z=(t,e,n,o)=>{if(L(e)){const i=e.inputs[o];return t.connect(i,n,0),[i,n,0]}return t.connect(e,n,o),[e,n,o]},B=(t,e)=>{if(!E(t).delete(e))throw new Error("Missing the expected event listener.")},U=(t,e,n,o)=>{L(e)?t.disconnect(e.inputs[o],n,0):t.disconnect(e,n,o)},W=t=>D(a,t),G=t=>D(c,t),H=t=>D(u,t),X=t=>D(l,t),Y=(t,e,n,o)=>{for(const e of t)if(n(e)){if(o)return!1;throw Error("The set contains at least one similar element.")}return t.add(e),!0},Q=t=>s.has(t),Z=t=>d.has(t),$=t=>!s.has(t),J=(t,e)=>{const n=Array.from(t).filter(e);if(n.length>1)throw Error("More than one element was found.");if(0===n.length)throw Error("No element was found.");const[o]=n;return t.delete(o),o},K=(t,e)=>{!N(t)&&e.every((t=>0===t.size))&&P(t)},tt=t=>new Promise((e=>{const n=t.createScriptProcessor(256,1,1),o=t.createGain(),i=t.createBuffer(1,2,44100),r=i.getChannelData(0);r[0]=1,r[1]=1;const s=t.createBufferSource();s.buffer=i,s.loop=!0,s.connect(n).connect(t.destination),s.connect(o),s.disconnect(o),n.onaudioprocess=o=>{const i=o.inputBuffer.getChannelData(0);Array.prototype.some.call(i,(t=>1===t))?e(!0):e(!1),s.stop(),n.onaudioprocess=null,s.disconnect(n),n.disconnect(t.destination)},s.start()})),et=(t,e)=>{const n=new Map;for(const e of t)for(const t of e){const e=n.get(t);n.set(t,void 0===e?1:e+1)}n.forEach(((t,n)=>e(n,t)))},nt=t=>"context"in t,ot=(t,e,[n,o,i],r)=>{Y(t[o],[e,n,i],(t=>t[0]===e&&t[1]===n),r)},it=(t,e,[n,o],i)=>{Y(t,[e,n,o],(t=>t[0]===e&&t[1]===n),i)},rt=(t,e,[n,o,i],r)=>{const s=t.get(n);void 0===s?t.set(n,new Set([[o,e,i]])):Y(s,[o,e,i],(t=>t[0]===o&&t[1]===e),r)},st=(t,[e,n,o],i)=>{const r=t.get(e);void 0===r?t.set(e,new Set([[n,o]])):Y(r,[n,o],(t=>t[0]===n),i)},at=(t,e,n,o)=>{const i=D(t,e),r=J(i,(t=>t[0]===n&&t[1]===o));return 0===i.size&&t.delete(e),r},ut=(t,e,n)=>{const o=D(t,e),i=J(o,(t=>t[0]===n));return 0===o.size&&t.delete(e),i},ct=(t,e,n)=>{for(const o of t)if(o[0]===e&&o[1]===n)return t.delete(o),o;return null},lt=(t,e,n,o)=>{const[i,r]=((t,e,n,o)=>{const{activeInputs:i,passiveInputs:r}=W(e),s=ct(i[o],t,n);return null===s?[at(r,t,n,o)[2],!1]:[s[2],!0]})(t,e,n,o);if(null!==i&&(B(t,i),r&&!Z(t)&&U(H(t),H(e),n,o)),Q(e)){const{activeInputs:t}=W(e);K(e,t)}},ht=(t,e,n)=>{const[o,i]=((t,e,n)=>{const{activeInputs:o,passiveInputs:i}=G(e),r=ct(o,t,n);return null===r?[ut(i,t,n)[1],!1]:[r[2],!0]})(t,e,n);null!==o&&(B(t,o),i&&!Z(t)&&H(t).disconnect(X(e),n))};class pt{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach(((n,o)=>t.call(e,n,o,this)))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}}const ft={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,outputChannelCount:void 0,parameterData:{},processorOptions:{}},dt=t=>{const e=[];for(let n=0;n{"function"==typeof t.copyToChannel?0!==e[n].byteLength&&t.copyToChannel(e[n],o,i):0!==e[n].byteLength&&t.getChannelData(o).set(e[n],i)},_t=(t,e)=>{const n=[];for(let o=0;o{const s=null===e?128*Math.ceil(t.context.length/128):e.length,a=o.channelCount*o.numberOfInputs,u=o.outputChannelCount.reduce(((t,e)=>t+e),0),c=0===u?null:n.createBuffer(u,s,n.sampleRate);if(void 0===i)throw new Error("Missing the processor constructor.");const l=W(t),h=await((t,e)=>{const n=D(y,t),o=H(e);return D(n,o)})(n,t),p=_t(o.numberOfInputs,o.channelCount),f=_t(o.numberOfOutputs,o.outputChannelCount),d=Array.from(t.parameters.keys()).reduce(((t,e)=>({...t,[e]:new Float32Array(128)})),{});for(let u=0;u0&&null!==e)for(let t=0;t{mt(e,d,t,a+n,u)}));for(let t=0;t0===l.activeInputs[e].size?[new Float32Array(0)]:t)),e=r(u/n.sampleRate,n.sampleRate,(()=>h.process(t,f,d)));if(null!==c)for(let t=0,e=0;t{const o=e[n];if(void 0===o)throw t();return o},kt={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Ct={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},At=()=>{try{return new DOMException("","InvalidStateError")}catch(t){return t.code=11,t.name="InvalidStateError",t}},Dt=()=>{try{return new DOMException("","InvalidAccessError")}catch(t){return t.code=15,t.name="InvalidAccessError",t}},Et={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},Mt=(t,e,n,o,i,r,s,a,u,c,l)=>{const h=c.length;let p=a;for(let a=0;a{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const n=t.decodeAudioData(e.buffer,(()=>{}));return void 0!==n&&(n.catch((()=>{})),!0)}catch(t){}return!1},Rt=(t,e,n)=>{const o=e[n];void 0!==o&&o!==t[n]&&(t[n]=o)},jt=(t,e)=>{Rt(t,e,"channelCount"),Rt(t,e,"channelCountMode"),Rt(t,e,"channelInterpretation")},qt=t=>"function"==typeof t.getFloatTimeDomainData,It=(t,e,n)=>{const o=e[n];void 0!==o&&o!==t[n].value&&(t[n].value=o)},Vt=t=>{t.start=(e=>(n=0,o=0,i)=>{if("number"==typeof i&&i<0||o<0||n<0)throw new RangeError("The parameters can't be negative.");e.call(t,n,o,i)})(t.start)},Ft=t=>{t.stop=(e=>(n=0)=>{if(n<0)throw new RangeError("The parameter can't be negative.");e.call(t,n)})(t.stop)},Nt=(t,e)=>null===t?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(t*e))))),Lt=(t,e)=>(t.connect=e.connect.bind(e),t.disconnect=e.disconnect.bind(e),t);function zt(t,e){const n=e[0]*e[0]+e[1]*e[1];return[(t[0]*e[0]+t[1]*e[1])/n,(t[1]*e[0]-t[0]*e[1])/n]}function Bt(t,e){let n=[0,0];for(let r=t.length-1;r>=0;r-=1)i=e,n=[(o=n)[0]*i[0]-o[1]*i[1],o[0]*i[1]+o[1]*i[0]],n[0]+=t[r];var o,i;return n}const Ut=()=>{try{return new DOMException("","NotSupportedError")}catch(t){return t.code=9,t.name="NotSupportedError",t}},Wt={numberOfChannels:1},Gt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,type:"sine"},Ht={channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:"inverse",maxDistance:1e4,orientationX:1,orientationY:0,orientationZ:0,panningModel:"equalpower",positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1},Xt={disableNormalization:!1},Yt={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},Qt=()=>{try{return new DOMException("","UnknownError")}catch(t){return t.name="UnknownError",t}},Zt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},$t=t=>{if(null===t)return!1;const e=t.length;return e%2!=0?0!==t[Math.floor(e/2)]:t[e/2-1]+t[e/2]!==0},Jt=(t,e,n,o)=>{let i=Object.getPrototypeOf(t);for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);const{get:r,set:s}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,{get:n(r),set:o(s)})},Kt=(t=>(e,n)=>{const o=_.get(e);if(void 0!==o)return o;const i=t.get(e);if(void 0!==i)return i;const r=n();return r instanceof Promise?(t.set(e,r),r.then((n=>(t.delete(e),_.set(e,n),n)))):(_.set(e,r),r)})(new Map),te="undefined"==typeof window?null:window,ee=(t=>null===t?null:t.hasOwnProperty("OfflineAudioContext")?t.OfflineAudioContext:t.hasOwnProperty("webkitOfflineAudioContext")?t.webkitOfflineAudioContext:null)(te),ne=(t=>e=>null!==t&&e instanceof t)(ee),oe=(t=>null===t?null:t.hasOwnProperty("AudioContext")?t.AudioContext:t.hasOwnProperty("webkitAudioContext")?t.webkitAudioContext:null)(te),ie=((t,e,n)=>o=>{if("closed"===o.state&&null!==e&&"webkitAudioContext"!==e.name){if(!t(o)){const t=h.get(o);if(void 0!==t)return t;const n=new e;return h.set(o,n),n}{const t=h.get(o);if(void 0!==t)return t;if(null!==n){const t=new n(1,1,44100);return h.set(o,t),t}}}return null})(ne,oe,ee),re=(t=>(e,n)=>{const o=t(e);return n(null!==o?o:e)})(ie),se=((t,e,n)=>(o,i)=>{const r=n(o,(t=>t.createAnalyser()));if(jt(r,i),!(i.maxDecibels>i.minDecibels))throw e();return Rt(r,i,"fftSize"),Rt(r,i,"maxDecibels"),Rt(r,i,"minDecibels"),Rt(r,i,"smoothingTimeConstant"),t(qt,(()=>qt(r)))||(t=>{t.getFloatTimeDomainData=e=>{const n=new Uint8Array(e.length);t.getByteTimeDomainData(n);const o=Math.max(n.length,t.fftSize);for(let t=0;te=>{const n=t(e);if(null===n.renderer)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return n.renderer})(W),ue=((t,e,n)=>async(o,i,r,s)=>{const a=t(o),u=[...s,o];await Promise.all(a.activeInputs.map(((t,s)=>Array.from(t).filter((([t])=>!u.includes(t))).map((async([t,a])=>{const c=e(t),l=await c.render(t,i,u);n(t)||o===o.context.destination&&n(o)||l.connect(r,a,s)})))).reduce(((t,e)=>[...t,...e]),[]))})(W,ae,Z),ce=((t,e,n)=>()=>{const o=new WeakMap;return{render(i,r,s){const a=o.get(r);return void 0!==a?Promise.resolve(a):(async(i,r,s)=>{let a=e(i);if(!O(a,r)){const e={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,fftSize:a.fftSize,maxDecibels:a.maxDecibels,minDecibels:a.minDecibels,smoothingTimeConstant:a.smoothingTimeConstant};a=t(r,e)}return o.set(r,a),await n(i,r,a,s),a})(i,r,s)}}})(se,H,ue),le=new WeakMap,he=(t=>e=>{const n=t.get(e);if(void 0===n)throw At();return n})(p),pe=new WeakMap,fe=(t=>e=>null!==t&&"function"==typeof t.AudioNode&&e instanceof t.AudioNode)(te),de=(t=>e=>null!==t&&"function"==typeof t.AudioParam&&e instanceof t.AudioParam)(te),me=((t,e,n,o,i,r,s,a,c,l,h,p,d)=>class extends I{constructor(e,o,i,r){super(i),this._context=e,this._nativeAudioNode=i;const s=l(e);d(s)||!0===n(tt,(()=>tt(s)))||(t=>{const e=new Map;t.connect=(t=>(n,o=0,i=0)=>{const r=nt(n)?t(n,o,i):t(n,o),s=e.get(n);return void 0===s?e.set(n,[{input:i,output:o}]):s.every((t=>t.input!==i||t.output!==o))&&s.push({input:i,output:o}),r})(t.connect.bind(t)),t.disconnect=(n=>(o,i,r)=>{if(n.apply(t),void 0===o)e.clear();else if("number"==typeof o)for(const[t,n]of e){const i=n.filter((t=>t.output!==o));0===i.length?e.delete(t):e.set(t,i)}else if(e.has(o))if(void 0===i)e.delete(o);else{const t=e.get(o);if(void 0!==t){const n=t.filter((t=>t.output!==i&&(t.input!==r||void 0===r)));0===n.length?e.delete(o):e.set(o,n)}}for(const[n,o]of e)o.forEach((e=>{nt(n)?t.connect(n,e.output,e.input):t.connect(n,e.output)}))})(t.disconnect)})(i),u.set(this,i),f.set(this,new Set),o&&M(this),t(this,r,i)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(t){this._nativeAudioNode.channelCount=t}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(t){this._nativeAudioNode.channelCountMode=t}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(t){this._nativeAudioNode.channelInterpretation=t}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(t,n=0,i=0){const a=l(this._context),u=d(a);if(h(t)||p(t))throw r();if(V(t)){const s=H(t);try{const o=z(this._nativeAudioNode,s,n,i);if(u||$(this)?this._nativeAudioNode.disconnect(...o):$(t)&&M(t),N(t)){const t=e.get(s);if(void 0===t){const t=a.createGain();t.connect(o[0],0,o[2]),e.set(s,new Map([[i,t]]))}else if(void 0===t.get(i)){const e=a.createGain();e.connect(o[0],0,o[2]),t.set(i,e)}}}catch(t){if(12===t.code)throw r();throw t}if(u?((t,e,n,o)=>{const{outputs:i}=W(t);if(Y(i,[e,n,o],(t=>t[0]===e&&t[1]===n&&t[2]===o),!0)){const{activeInputs:i}=W(e);return ot(i,t,[n,o,null],!0),!0}return!1})(this,t,n,i):((t,e,n,o)=>{const{activeInputs:i,passiveInputs:r}=W(e),{outputs:s}=W(t),a=E(t),u=s=>{const a=H(e),u=H(t);if(s){const s=at(r,t,n,o);ot(i,t,s,!1),Z(t)||z(u,a,n,o),$(e)&&M(e)}else{const s=((t,e,n,o)=>J(t[o],(t=>t[0]===e&&t[1]===n)))(i,t,n,o);rt(r,o,s,!1),Z(t)||U(u,a,n,o),Q(e)&&K(e,i)}};return!!Y(s,[e,n,o],(t=>t[0]===e&&t[1]===n&&t[2]===o),!0)&&(a.add(u),Q(t)?ot(i,t,[n,o,u],!0):rt(r,o,[t,n,u],!0),!0)})(this,t,n,i)){const e=c([this],t);et(e,o(u))}return t}const f=X(t);if("playbackRate"===f.name)throw s();try{this._nativeAudioNode.connect(f,n),(u||$(this))&&this._nativeAudioNode.disconnect(f,n)}catch(t){if(12===t.code)throw r();throw t}if(u?((t,e,n)=>{const{outputs:o}=W(t);if(Y(o,[e,n],(t=>t[0]===e&&t[1]===n),!0)){const{activeInputs:o}=G(e);return it(o,t,[n,null],!0),!0}return!1})(this,t,n):((t,e,n)=>{const{activeInputs:o,passiveInputs:i}=G(e),{outputs:r}=W(t),s=E(t),a=r=>{const s=H(t),a=X(e);if(r){const e=ut(i,t,n);it(o,t,e,!1),Z(t)||s.connect(a,n)}else{const e=((t,e,n)=>J(t,(t=>t[0]===e&&t[1]===n)))(o,t,n);st(i,e,!1),Z(t)||s.disconnect(a,n)}};return!!Y(r,[e,n],(t=>t[0]===e&&t[1]===n),!0)&&(s.add(a),Q(t)?it(o,t,[n,a],!0):st(i,[t,n,a],!0),!0)})(this,t,n)){const e=c([this],t);et(e,o(u))}}disconnect(t,e,n){let o;if(void 0===t)o=(t=>{const e=W(t),n=[];for(const o of e.outputs)F(o)?lt(t,...o):ht(t,...o),n.push(o[0]);return e.outputs.clear(),n})(this);else if("number"==typeof t){if(t<0||t>=this.numberOfOutputs)throw i();o=((t,e)=>{const n=W(t),o=[];for(const i of n.outputs)i[1]===e&&(F(i)?lt(t,...i):ht(t,...i),o.push(i[0]),n.outputs.delete(i));return o})(this,t)}else{if(void 0!==e&&(e<0||e>=this.numberOfOutputs))throw i();if(V(t)&&void 0!==n&&(n<0||n>=t.numberOfInputs))throw i();if(o=((t,e,n,o)=>{const i=W(t);return Array.from(i.outputs).filter((t=>!(t[0]!==e||void 0!==n&&t[1]!==n||void 0!==o&&t[2]!==o))).map((e=>(F(e)?lt(t,...e):ht(t,...e),i.outputs.delete(e),e[0])))})(this,t,e,n),0===o.length)throw r()}for(const t of o){const e=c([this],t);et(e,a)}}})((t=>(e,n,o)=>{const i=[];for(let t=0;ts=>(a,u)=>{const c=t.get(a);if(void 0===c){if(!s&&r(a)){const t=o(a),{outputs:r}=n(a);for(const n of r)if(F(n)){const i=o(n[0]);e(t,i,n[1],n[2])}else{const e=i(n[0]);t.disconnect(e,n[1])}}t.set(a,u)}else t.set(a,c+u)})(d,U,W,H,X,Q),k,Dt,Ut,((t,e,n,o,i,r,s,a)=>(u,c)=>{const l=e.get(u);if(void 0===l)throw new Error("Missing the expected cycle count.");const h=r(u.context),p=a(h);if(l===c){if(e.delete(u),!p&&s(u)){const e=o(u),{outputs:r}=n(u);for(const n of r)if(F(n)){const i=o(n[0]);t(e,i,n[1],n[2])}else{const t=i(n[0]);e.connect(t,n[1])}}}else e.set(u,l-c)})(z,d,W,H,X,he,Q,ne),((t,e,n)=>function o(i,r){const s=V(r)?r:n(t,r);if((t=>"delayTime"in t)(s))return[];if(i[0]===s)return[i];if(i.includes(s))return[];const{outputs:a}=e(s);return Array.from(a).map((t=>o([...i,s],t[0]))).reduce(((t,e)=>t.concat(e)),[])})(pe,W,D),he,fe,de,ne),ye=((t,e,n,o,i,r)=>class extends t{constructor(t,n=T){const s=i(t),a={...T,...n},u=o(s,a);super(t,!1,u,r(s)?e():null),this._nativeAnalyserNode=u}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(t){this._nativeAnalyserNode.fftSize=t}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(t){const e=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=t,!(t>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=e,n()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(t){const e=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=t,!(this._nativeAnalyserNode.maxDecibels>t))throw this._nativeAnalyserNode.minDecibels=e,n()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(t){this._nativeAnalyserNode.smoothingTimeConstant=t}getByteFrequencyData(t){this._nativeAnalyserNode.getByteFrequencyData(t)}getByteTimeDomainData(t){this._nativeAnalyserNode.getByteTimeDomainData(t)}getFloatFrequencyData(t){this._nativeAnalyserNode.getFloatFrequencyData(t)}getFloatTimeDomainData(t){this._nativeAnalyserNode.getFloatTimeDomainData(t)}})(me,ce,k,se,he,ne),_e=new WeakSet,ge=(t=>null===t?null:t.hasOwnProperty("AudioBuffer")?t.AudioBuffer:null)(te),ve=(t=>e=>(t[0]=e,t[0]))(new Uint32Array(1)),be=((t,e)=>n=>{n.copyFromChannel=(o,i,r=0)=>{const s=t(r),a=t(i);if(a>=n.numberOfChannels)throw e();const u=n.length,c=n.getChannelData(a),l=o.length;for(let t=s<0?-s:0;t+s{const s=t(r),a=t(i);if(a>=n.numberOfChannels)throw e();const u=n.length,c=n.getChannelData(a),l=o.length;for(let t=s<0?-s:0;t+se=>{e.copyFromChannel=(n=>(o,i,r=0)=>{const s=t(r),a=t(i);if(s(o,i,r=0)=>{const s=t(r),a=t(i);if(s{let u=null;return class c{constructor(c){if(null===i)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:l,numberOfChannels:h,sampleRate:p}={...A,...c};null===u&&(u=new i(1,1,44100));const f=null!==o&&e(r,r)?new o({length:l,numberOfChannels:h,sampleRate:p}):u.createBuffer(h,l,p);if(0===f.numberOfChannels)throw n();return"function"!=typeof f.copyFromChannel?(s(f),C(f)):e(S,(()=>S(f)))||a(f),t.add(f),f}static[Symbol.hasInstance](e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===c.prototype||t.has(e)}}})(_e,Kt,Ut,ge,ee,(t=>()=>{if(null===t)return!1;try{new t({length:1,sampleRate:44100})}catch(t){return!1}return!0})(ge),be,xe),Te=(t=>e=>{const n=t(e,(t=>t.createOscillator()));try{n.start(-1)}catch(t){return t instanceof RangeError}return!1})(re),Oe=(t=>e=>{const n=e.createBuffer(1,1,44100),o=t(e,(t=>t.createBufferSource()));o.buffer=n,o.start(),o.stop();try{return o.stop(),!0}catch(t){return!1}})(re),Se=(t=>e=>{const n=t(e,(t=>t.createOscillator()));try{n.stop(-1)}catch(t){return t instanceof RangeError}return!1})(re),ke=(t=>(e,n)=>{const o=t(n,(t=>t.createGain()));e.connect(o);const i=(t=>()=>{t.call(e,o),e.removeEventListener("ended",i)})(e.disconnect);e.addEventListener("ended",i),Lt(e,o),e.stop=(t=>{let n=!1;return(i=0)=>{if(n)try{t.call(e,i)}catch(t){o.gain.setValueAtTime(0,i)}else t.call(e,i),n=!0}})(e.stop)})(re),Ce=((t,e,n)=>async(o,i,r,s)=>{const a=e(o);await Promise.all(Array.from(a.activeInputs).map((async([e,o])=>{const a=t(e),u=await a.render(e,i,s);n(e)||u.connect(r,o)})))})(ae,G,Z),Ae=(t=>(e,n,o,i)=>t(n,e,o,i))(Ce),De=((t,e,n,o,i,r,s,a,u,c,l,h)=>(c,p={})=>{const f=e(c,(t=>t.createBufferSource()));return jt(f,p),It(f,p,"playbackRate"),Rt(f,p,"buffer"),Rt(f,p,"loop"),Rt(f,p,"loopEnd"),Rt(f,p,"loopStart"),t(n,(()=>n(c)))||(t=>{t.start=(e=>{let n=!1;return(o=0,i=0,r)=>{if(n)throw At();e.call(t,o,i,r),n=!0}})(t.start)})(f),t(o,o)||((t,e)=>{let n=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY;t.start=((i,r)=>(s=0,a=0,u=Number.POSITIVE_INFINITY)=>{if(i.call(t,s,a),u>=0&&u(r=0)=>{o=Math.max(r,e.currentTime),i.call(t,Math.min(n,o))})(t.stop)})(f,c),t(i,(()=>i(c)))||(t=>{t.start=(e=>(n=0,o=0,i)=>{const r=t.buffer,s=null===r?o:Math.min(r.duration,o);null!==r&&s>r.duration-.5/t.context.sampleRate?e.call(t,n,0,0):e.call(t,n,s,i)})(t.start)})(f),t(r,(()=>r(c)))||l(f,c),t(s,(()=>s(c)))||Vt(f),t(a,(()=>a(c)))||h(f,c),t(u,(()=>u(c)))||Ft(f),f})(Kt,re,(t=>e=>{const n=t(e,(t=>t.createBufferSource()));n.start();try{n.start()}catch(t){return!0}return!1})(re),(t=>()=>{if(null===t)return Promise.resolve(!1);const e=new t(1,1,44100),n=e.createBuffer(1,1,e.sampleRate),o=e.createBufferSource();return n.getChannelData(0)[0]=1,o.buffer=n,o.start(0,0,0),o.connect(e.destination),new Promise((t=>{e.oncomplete=({renderedBuffer:e})=>{t(0===e.getChannelData(0)[0])},e.startRendering()}))})(ee),(t=>e=>{const n=t(e,(t=>t.createBufferSource())),o=e.createBuffer(1,1,44100);n.buffer=o;try{n.start(0,1)}catch(t){return!1}return!0})(re),(t=>e=>{const n=t(e,(t=>t.createBufferSource()));n.start();try{n.stop()}catch(t){return!1}return!0})(re),Te,Oe,Se,0,(t=>(e,n)=>{const o=n.createBuffer(1,1,n.sampleRate);null===e.buffer&&(e.buffer=o),t(e,"buffer",(t=>()=>{const n=t.call(e);return n===o?null:n}),(t=>n=>t.call(e,null===n?o:n)))})(Jt),ke),Ee=((t,e)=>(n,o,i,r)=>(t(o).replay(i),e(o,n,i,r)))((t=>e=>{const n=t(e);if(null===n.renderer)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return n.renderer})(G),Ce),Me=((t,e,n,o,i)=>()=>{const r=new WeakMap;let s=null,a=null;return{set start(t){s=t},set stop(t){a=t},render(u,c,l){const h=r.get(c);return void 0!==h?Promise.resolve(h):(async(u,c,l)=>{let h=n(u);const p=O(h,c);if(!p){const t={buffer:h.buffer,channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,loop:h.loop,loopEnd:h.loopEnd,loopStart:h.loopStart,playbackRate:h.playbackRate.value};h=e(c,t),null!==s&&h.start(...s),null!==a&&h.stop(a)}return r.set(c,h),p?await t(c,u.playbackRate,h.playbackRate,l):await o(c,u.playbackRate,h.playbackRate,l),await i(u,c,h,l),h})(u,c,l)}}})(Ae,De,H,Ee,ue),Pe=((t,e,n,o,r,s,a,u,c,l,h,p)=>(o,f,d,m=null,y=null)=>{const _=new i.AutomationEventList(d.defaultValue),g=f?(t=>({replay(e){for(const n of t)if("exponentialRampToValue"===n.type){const{endTime:t,value:o}=n;e.exponentialRampToValueAtTime(o,t)}else if("linearRampToValue"===n.type){const{endTime:t,value:o}=n;e.linearRampToValueAtTime(o,t)}else if("setTarget"===n.type){const{startTime:t,target:o,timeConstant:i}=n;e.setTargetAtTime(o,t,i)}else if("setValue"===n.type){const{startTime:t,value:o}=n;e.setValueAtTime(o,t)}else{if("setValueCurve"!==n.type)throw new Error("Can't apply an unknown automation.");{const{duration:t,startTime:o,values:i}=n;e.setValueCurveAtTime(i,o,t)}}}}))(_):null,v={get defaultValue(){return d.defaultValue},get maxValue(){return null===m?d.maxValue:m},get minValue(){return null===y?d.minValue:y},get value(){return d.value},set value(t){d.value=t,v.setValueAtTime(t,o.context.currentTime)},cancelAndHoldAtTime(t){if("function"==typeof d.cancelAndHoldAtTime)null===g&&_.flush(o.context.currentTime),_.add(r(t)),d.cancelAndHoldAtTime(t);else{const e=Array.from(_).pop();null===g&&_.flush(o.context.currentTime),_.add(r(t));const n=Array.from(_).pop();d.cancelScheduledValues(t),e!==n&&void 0!==n&&("exponentialRampToValue"===n.type?d.exponentialRampToValueAtTime(n.value,n.endTime):"linearRampToValue"===n.type?d.linearRampToValueAtTime(n.value,n.endTime):"setValue"===n.type?d.setValueAtTime(n.value,n.startTime):"setValueCurve"===n.type&&d.setValueCurveAtTime(n.values,n.startTime,n.duration))}return v},cancelScheduledValues:t=>(null===g&&_.flush(o.context.currentTime),_.add(s(t)),d.cancelScheduledValues(t),v),exponentialRampToValueAtTime:(t,e)=>(null===g&&_.flush(o.context.currentTime),_.add(a(t,e)),d.exponentialRampToValueAtTime(t,e),v),linearRampToValueAtTime:(t,e)=>(null===g&&_.flush(o.context.currentTime),_.add(u(t,e)),d.linearRampToValueAtTime(t,e),v),setTargetAtTime:(t,e,n)=>(null===g&&_.flush(o.context.currentTime),_.add(c(t,e,n)),d.setTargetAtTime(t,e,n),v),setValueAtTime:(t,e)=>(null===g&&_.flush(o.context.currentTime),_.add(l(t,e)),d.setValueAtTime(t,e),v),setValueCurveAtTime(t,e,n){if(null!==p&&"webkitAudioContext"===p.name){const i=e+n,r=o.context.sampleRate,s=Math.ceil(e*r),a=Math.floor(i*r),u=a-s,c=new Float32Array(u);for(let o=0;o(e,n)=>{t.set(e,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:n})})(c),pe,l,0,i.createCancelAndHoldAutomationEvent,i.createCancelScheduledValuesAutomationEvent,i.createExponentialRampToValueAutomationEvent,i.createLinearRampToValueAutomationEvent,i.createSetTargetAutomationEvent,i.createSetValueAutomationEvent,i.createSetValueCurveAutomationEvent,oe),Re=((t,e,n,o,i,r,s)=>class extends t{constructor(t,o=j){const a=r(t),u={...j,...o},c=i(a,u),l=s(a),h=l?e():null;super(t,!1,c,h),this._audioBufferSourceNodeRenderer=h,this._isBufferNullified=!1,this._isBufferSet=null!==o.buffer&&void 0!==o.buffer,this._nativeAudioBufferSourceNode=c,this._onended=null,this._playbackRate=n(this,l,c.playbackRate,34028234663852886e22,-34028234663852886e22)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(t){try{this._nativeAudioBufferSourceNode.buffer=t}catch(e){if(null!==t||17!==e.code)throw e;if(null!==this._nativeAudioBufferSourceNode.buffer){const t=this._nativeAudioBufferSourceNode.buffer,e=t.numberOfChannels;for(let n=0;n{this._nativeAudioBufferSourceNode.removeEventListener("ended",t),setTimeout((()=>P(this)),1e3)};this._nativeAudioBufferSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeAudioBufferSourceNode.stop(t),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.stop=t)}})(me,Me,Pe,At,De,he,ne),je=(t=>(e,n)=>{const o=t(e,(t=>t.createGain()));return jt(o,n),It(o,n,"gain"),o})(re),qe=((t,e,n,o,i,r,s,a)=>class extends t{constructor(t,e){const n=r(t),o=s(n),u=i(n,e,o);super(t,!1,u,o?(t=>{let e=null;return{render:(n,o,i)=>(null===e&&(e=(async(e,n,o)=>{const i=n.destination;return await t(e,n,i,o),i})(n,o,i)),e)}})(a):null),this._isNodeOfNativeOfflineAudioContext=o,this._nativeAudioDestinationNode=u}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(t){if(this._isNodeOfNativeOfflineAudioContext)throw o();if(t>this._nativeAudioDestinationNode.maxChannelCount)throw n();this._nativeAudioDestinationNode.channelCount=t}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(t){if(this._isNodeOfNativeOfflineAudioContext)throw o();this._nativeAudioDestinationNode.channelCountMode=t}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}})(me,0,k,At,((t,e)=>(n,o,i)=>{const r=n.destination;if(r.channelCount!==o)try{r.channelCount=o}catch(t){}i&&"explicit"!==r.channelCountMode&&(r.channelCountMode="explicit"),0===r.maxChannelCount&&Object.defineProperty(r,"maxChannelCount",{value:o});const s=t(n,{channelCount:o,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,gain:1});return e(s,"channelCount",(t=>()=>t.call(s)),(t=>e=>{t.call(s,e);try{r.channelCount=e}catch(t){if(e>r.maxChannelCount)throw t}})),e(s,"channelCountMode",(t=>()=>t.call(s)),(t=>e=>{t.call(s,e),r.channelCountMode=e})),e(s,"channelInterpretation",(t=>()=>t.call(s)),(t=>e=>{t.call(s,e),r.channelInterpretation=e})),Object.defineProperty(s,"maxChannelCount",{get:()=>r.maxChannelCount}),s.connect(r),s})(je,Jt),he,ne,ue),Ie=(t=>(e,n)=>{const o=t(e,(t=>t.createBiquadFilter()));return jt(o,n),It(o,n,"Q"),It(o,n,"detune"),It(o,n,"frequency"),It(o,n,"gain"),Rt(o,n,"type"),o})(re),Ve=((t,e,n,o,i,r,s)=>class extends t{constructor(t,o=vt){const a=r(t),u={...vt,...o},c=i(a,u),l=s(a);super(t,!1,c,l?n():null),this._Q=e(this,l,c.Q,34028234663852886e22,-34028234663852886e22),this._detune=e(this,l,c.detune,1200*Math.log2(34028234663852886e22),-1200*Math.log2(34028234663852886e22)),this._frequency=e(this,l,c.frequency,t.sampleRate/2,0),this._gain=e(this,l,c.gain,40*Math.log10(34028234663852886e22),-40*Math.log10(34028234663852886e22)),this._nativeBiquadFilterNode=c}get Q(){return this._Q}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get type(){return this._nativeBiquadFilterNode.type}set type(t){this._nativeBiquadFilterNode.type=t}getFrequencyResponse(t,e,n){if(this._nativeBiquadFilterNode.getFrequencyResponse(t,e,n),t.length!==e.length||e.length!==n.length)throw o()}})(me,Pe,((t,e,n,o,i)=>()=>{const r=new WeakMap;return{render(s,a,u){const c=r.get(a);return void 0!==c?Promise.resolve(c):(async(s,a,u)=>{let c=n(s);const l=O(c,a);if(!l){const t={Q:c.Q.value,channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,detune:c.detune.value,frequency:c.frequency.value,gain:c.gain.value,type:c.type};c=e(a,t)}return r.set(a,c),l?(await t(a,s.Q,c.Q,u),await t(a,s.detune,c.detune,u),await t(a,s.frequency,c.frequency,u),await t(a,s.gain,c.gain,u)):(await o(a,s.Q,c.Q,u),await o(a,s.detune,c.detune,u),await o(a,s.frequency,c.frequency,u),await o(a,s.gain,c.gain,u)),await i(s,a,c,u),c})(s,a,u)}}})(Ae,Ie,H,Ee,ue),Dt,Ie,he,ne),Fe=((t,e)=>(n,o,i)=>{const r=new Set;return n.connect=(i=>(s,a=0,u=0)=>{const c=0===r.size;if(e(s))return i.call(n,s,a,u),t(r,[s,a,u],(t=>t[0]===s&&t[1]===a&&t[2]===u),!0),c&&o(),s;i.call(n,s,a),t(r,[s,a],(t=>t[0]===s&&t[1]===a),!0),c&&o()})(n.connect),n.disconnect=(t=>(o,s,a)=>{const u=r.size>0;if(void 0===o)t.apply(n),r.clear();else if("number"==typeof o){t.call(n,o);for(const t of r)t[1]===o&&r.delete(t)}else{e(o)?t.call(n,o,s,a):t.call(n,o,s);for(const t of r)t[0]!==o||void 0!==s&&t[1]!==s||void 0!==a&&t[2]!==a||r.delete(t)}const c=0===r.size;u&&c&&i()})(n.disconnect),n})(Y,fe),Ne=((t,e,n)=>(o,i)=>{i.channelCount=1,i.channelCountMode="explicit",Object.defineProperty(i,"channelCount",{get:()=>1,set:()=>{throw t()}}),Object.defineProperty(i,"channelCountMode",{get:()=>"explicit",set:()=>{throw t()}});const r=e(o,(t=>t.createBufferSource()));n(i,(()=>{const t=i.numberOfInputs;for(let e=0;er.disconnect(i)))})(At,re,Fe),Le=((t,e)=>(n,o)=>{const i=t(n,(t=>t.createChannelMerger(o.numberOfInputs)));jt(i,o),1!==i.channelCount&&"explicit"!==i.channelCountMode&&e(n,i);try{i.channelCount=void 0===o.numberOfInputs?6:o.numberOfInputs,e(n,i)}catch(t){}return i})(re,Ne),ze=((t,e,n,o,i)=>class extends t{constructor(t,r=bt){const s=o(t),a={...bt,...r};super(t,!1,n(s,a),i(s)?e():null)}})(me,((t,e,n)=>()=>{const o=new WeakMap;return{render(i,r,s){const a=o.get(r);return void 0!==a?Promise.resolve(a):(async(i,r,s)=>{let a=e(i);if(!O(a,r)){const e={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=t(r,e)}return o.set(r,a),await n(i,r,a,s),a})(i,r,s)}}})(Le,H,ue),Le,he,ne),Be=(t=>(e,n)=>{const o=t(e,(t=>t.createChannelSplitter(n.numberOfOutputs)));return jt(o,n),(t=>{const e=t.numberOfOutputs;Object.defineProperty(t,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw At()}}),Object.defineProperty(t,"channelCountMode",{get:()=>"explicit",set:t=>{if("explicit"!==t)throw At()}}),Object.defineProperty(t,"channelInterpretation",{get:()=>"discrete",set:t=>{if("discrete"!==t)throw At()}})})(o),o})(re),Ue=((t,e,n,o,i)=>class extends t{constructor(t,r=xt){const s=o(t),a=(t=>({...t,channelCount:t.numberOfOutputs}))({...xt,...r});super(t,!1,n(s,a),i(s)?e():null)}})(me,((t,e,n)=>()=>{const o=new WeakMap;return{render(i,r,s){const a=o.get(r);return void 0!==a?Promise.resolve(a):(async(i,r,s)=>{let a=e(i);if(!O(a,r)){const e={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=t(r,e)}return o.set(r,a),await n(i,r,a,s),a})(i,r,s)}}})(Be,H,ue),Be,he,ne),We=((t,e,n)=>(o,{offset:i,...r})=>{const s=o.createBuffer(1,2,o.sampleRate),a=t(o),u=e(o,{...r,gain:i}),c=s.getChannelData(0);return c[0]=1,c[1]=1,a.buffer=s,a.loop=!0,n(Lt({get bufferSize(){},get channelCount(){return u.channelCount},set channelCount(t){u.channelCount=t},get channelCountMode(){return u.channelCountMode},set channelCountMode(t){u.channelCountMode=t},get channelInterpretation(){return u.channelInterpretation},set channelInterpretation(t){u.channelInterpretation=t},get context(){return u.context},get inputs(){return[]},get numberOfInputs(){return a.numberOfInputs},get numberOfOutputs(){return u.numberOfOutputs},get offset(){return u.gain},get onended(){return a.onended},set onended(t){a.onended=t},addEventListener:(...t)=>a.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>a.dispatchEvent(t[0]),removeEventListener:(...t)=>a.removeEventListener(t[0],t[1],t[2]),start(t=0){a.start.call(a,t)},stop(t=0){a.stop.call(a,t)}},u),(()=>a.connect(u)),(()=>a.disconnect(u)))})(De,je,Fe),Ge=((t,e,n,o,i)=>(r,s)=>{if(void 0===r.createConstantSource)return n(r,s);const a=e(r,(t=>t.createConstantSource()));return jt(a,s),It(a,s,"offset"),t(o,(()=>o(r)))||Vt(a),t(i,(()=>i(r)))||Ft(a),a})(Kt,re,We,Te,Se),He=((t,e,n,o,i,r)=>class extends t{constructor(t,s=wt){const a=i(t),u={...wt,...s},c=o(a,u),l=r(a),h=l?n():null;super(t,!1,c,h),this._constantSourceNodeRenderer=h,this._nativeConstantSourceNode=c,this._offset=e(this,l,c.offset,34028234663852886e22,-34028234663852886e22),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(t){const e=R(this,t);this._nativeConstantSourceNode.onended=e;const n=this._nativeConstantSourceNode.onended;this._onended=n===e?t:n}start(t=0){if(this._nativeConstantSourceNode.start(t),null!==this._constantSourceNodeRenderer)this._constantSourceNodeRenderer.start=t;else{M(this);const t=()=>{this._nativeConstantSourceNode.removeEventListener("ended",t),setTimeout((()=>P(this)),1e3)};this._nativeConstantSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeConstantSourceNode.stop(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.stop=t)}})(me,Pe,((t,e,n,o,i)=>()=>{const r=new WeakMap;let s=null,a=null;return{set start(t){s=t},set stop(t){a=t},render(u,c,l){const h=r.get(c);return void 0!==h?Promise.resolve(h):(async(u,c,l)=>{let h=n(u);const p=O(h,c);if(!p){const t={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=e(c,t),null!==s&&h.start(s),null!==a&&h.stop(a)}return r.set(c,h),p?await t(c,u.offset,h.offset,l):await o(c,u.offset,h.offset,l),await i(u,c,h,l),h})(u,c,l)}}})(Ae,Ge,H,Ee,ue),Ge,he,ne),Xe=((t,e,n)=>(o,{buffer:i,channelCount:r,channelCountMode:s,channelInterpretation:a,disableNormalization:u})=>{const c=t(o,(t=>t.createConvolver()));jt(c,{channelCount:Math.max(r,2),channelCountMode:"max"===s?s:"clamped-max",channelInterpretation:a});const l=e(o,{channelCount:r,channelCountMode:s,channelInterpretation:a,gain:1}),h={get buffer(){return c.buffer},set buffer(t){c.buffer=t},get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(t){t>2&&(c.channelCount=t),l.channelCount=t},get channelCountMode(){return l.channelCountMode},set channelCountMode(t){"max"===t&&(c.channelCountMode=t),l.channelCountMode=t},get channelInterpretation(){return c.channelInterpretation},set channelInterpretation(t){c.channelInterpretation=t,l.channelInterpretation=t},get context(){return c.context},get inputs(){return[c]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return c.numberOfOutputs},get normalize(){return c.normalize},set normalize(t){c.normalize=t},addEventListener:(...t)=>c.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>c.dispatchEvent(t[0]),removeEventListener:(...t)=>c.removeEventListener(t[0],t[1],t[2])};return u===h.normalize&&(h.normalize=!u),i!==h.buffer&&(h.buffer=i),n(Lt(h,l),(()=>c.connect(l)),(()=>c.disconnect(l)))})(re,je,Fe),Ye=((t,e,n,o)=>(i,r)=>{const s=t(i,(t=>t.createConvolver()));try{s.channelCount=1}catch(t){return e(i,r)}if(jt(s,r),r.disableNormalization===s.normalize&&(s.normalize=!r.disableNormalization),Rt(s,r,"buffer"),r.channelCount>2)throw n();if(o(s,"channelCount",(t=>()=>t.call(s)),(t=>e=>{if(e>2)throw n();return t.call(s,e)})),"max"===r.channelCountMode)throw n();return o(s,"channelCountMode",(t=>()=>t.call(s)),(t=>e=>{if("max"===e)throw n();return t.call(s,e)})),s})(re,Xe,Ut,Jt),Qe=((t,e,n,o,i)=>class extends t{constructor(t,r=Tt){const s=o(t),a={...Tt,...r},u=n(s,a);super(t,!1,u,i(s)?e():null),this._isBufferNullified=!1,this._nativeConvolverNode=u}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(t){if(this._nativeConvolverNode.buffer=t,null===t&&null!==this._nativeConvolverNode.buffer){const t=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=t.createBuffer(1,1,t.sampleRate),this._isBufferNullified=!0}else this._isBufferNullified=!1}get normalize(){return this._nativeConvolverNode.normalize}set normalize(t){this._nativeConvolverNode.normalize=t}})(me,((t,e,n)=>()=>{const o=new WeakMap;return{render(i,r,s){const a=o.get(r);return void 0!==a?Promise.resolve(a):(async(i,r,s)=>{let a=e(i);if(!O(a,r)){const e={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=t(r,e)}return o.set(r,a),L(a)?await n(i,r,a.inputs[0],s):await n(i,r,a,s),a})(i,r,s)}}})(Ye,H,ue),Ye,he,ne),Ze=(t=>(e,n)=>{const o=t(e,(t=>t.createDelay(n.maxDelayTime)));return jt(o,n),It(o,n,"delayTime"),o})(re),$e=((t,e,n,o,i,r)=>class extends t{constructor(t,s=Ot){const a=i(t),u={...Ot,...s},c=o(a,u),l=r(a);super(t,!1,c,l?n(u.maxDelayTime):null),this._delayTime=e(this,l,c.delayTime,u.maxDelayTime,0)}get delayTime(){return this._delayTime}})(me,Pe,((t,e,n,o,i)=>r=>{const s=new WeakMap;return{render(a,u,c){const l=s.get(u);return void 0!==l?Promise.resolve(l):(async(a,u,c)=>{let l=n(a);const h=O(l,u);if(!h){const t={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,delayTime:l.delayTime.value,maxDelayTime:r};l=e(u,t)}return s.set(u,l),h?await t(u,a.delayTime,l.delayTime,c):await o(u,a.delayTime,l.delayTime,c),await i(a,u,l,c),l})(a,u,c)}}})(Ae,Ze,H,Ee,ue),Ze,he,ne),Je=((t,e)=>(n,o)=>{const i=t(n,(t=>t.createDynamicsCompressor()));if(jt(i,o),o.channelCount>2)throw e();if("max"===o.channelCountMode)throw e();return It(i,o,"attack"),It(i,o,"knee"),It(i,o,"ratio"),It(i,o,"release"),It(i,o,"threshold"),i})(re,Ut),Ke=((t,e,n,o,i,r,s)=>class extends t{constructor(t,i=kt){const a=r(t),u={...kt,...i},c=o(a,u),l=s(a);super(t,!1,c,l?n():null),this._attack=e(this,l,c.attack,1,0),this._knee=e(this,l,c.knee,40,0),this._nativeDynamicsCompressorNode=c,this._ratio=e(this,l,c.ratio,20,1),this._release=e(this,l,c.release,1,0),this._threshold=e(this,l,c.threshold,0,-100)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(t){const e=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=t,t>2)throw this._nativeDynamicsCompressorNode.channelCount=e,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(t){const e=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=t,"max"===t)throw this._nativeDynamicsCompressorNode.channelCountMode=e,i()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return"number"==typeof this._nativeDynamicsCompressorNode.reduction.value?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}})(me,Pe,((t,e,n,o,i)=>()=>{const r=new WeakMap;return{render(s,a,u){const c=r.get(a);return void 0!==c?Promise.resolve(c):(async(s,a,u)=>{let c=n(s);const l=O(c,a);if(!l){const t={attack:c.attack.value,channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,knee:c.knee.value,ratio:c.ratio.value,release:c.release.value,threshold:c.threshold.value};c=e(a,t)}return r.set(a,c),l?(await t(a,s.attack,c.attack,u),await t(a,s.knee,c.knee,u),await t(a,s.ratio,c.ratio,u),await t(a,s.release,c.release,u),await t(a,s.threshold,c.threshold,u)):(await o(a,s.attack,c.attack,u),await o(a,s.knee,c.knee,u),await o(a,s.ratio,c.ratio,u),await o(a,s.release,c.release,u),await o(a,s.threshold,c.threshold,u)),await i(s,a,c,u),c})(s,a,u)}}})(Ae,Je,H,Ee,ue),Je,Ut,he,ne),tn=((t,e,n,o,i,r)=>class extends t{constructor(t,s=Ct){const a=i(t),u={...Ct,...s},c=o(a,u),l=r(a);super(t,!1,c,l?n():null),this._gain=e(this,l,c.gain,34028234663852886e22,-34028234663852886e22)}get gain(){return this._gain}})(me,Pe,((t,e,n,o,i)=>()=>{const r=new WeakMap;return{render(s,a,u){const c=r.get(a);return void 0!==c?Promise.resolve(c):(async(s,a,u)=>{let c=n(s);const l=O(c,a);if(!l){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,gain:c.gain.value};c=e(a,t)}return r.set(a,c),l?await t(a,s.gain,c.gain,u):await o(a,s.gain,c.gain,u),await i(s,a,c,u),c})(s,a,u)}}})(Ae,je,H,Ee,ue),je,he,ne),en=(t=>(e,n,o,i)=>t(e,(t=>t.createScriptProcessor(n,o,i))))(re),nn=((t,e,n,o)=>(i,r,{channelCount:s,channelCountMode:a,channelInterpretation:u,feedback:c,feedforward:l})=>{const h=Nt(r,i.sampleRate),p=c.length,f=l.length,d=Math.min(p,f);if(0===c.length||c.length>20)throw o();if(0===c[0])throw e();if(0===l.length||l.length>20)throw o();if(0===l[0])throw e();if(1!==c[0]){for(let t=0;t{const e=t.inputBuffer,n=t.outputBuffer,o=e.numberOfChannels;for(let t=0;tm.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>m.dispatchEvent(t[0]),getFrequencyResponse(e,n,o){if(e.length!==n.length||n.length!==o.length)throw t();const i=e.length;for(let t=0;tm.removeEventListener(t[0],t[1],t[2])},m)})(Dt,At,en,Ut),on=((t,e,n,o)=>i=>t(Pt,(()=>Pt(i)))?Promise.resolve(t(o,o)).then((t=>{if(!t){const t=n(i,512,0,1);i.oncomplete=()=>{t.onaudioprocess=null,t.disconnect()},t.onaudioprocess=()=>i.currentTime,t.connect(i.destination)}return i.startRendering()})):new Promise((t=>{const n=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=e=>{n.disconnect(),t(e.renderedBuffer)},n.connect(i.destination),i.startRendering()})))(Kt,je,en,((t,e)=>()=>{if(null===e)return Promise.resolve(!1);const n=new e(1,1,44100),o=t(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise((t=>{n.oncomplete=()=>{o.disconnect(),t(0!==n.currentTime)},n.startRendering()}))})(je,ee)),rn=((t,e,n,o,i,r)=>(s,a)=>{const u=new WeakMap;let c=null;const l=async(l,h,p)=>{let f=n(l),d=null;const m=O(f,h);if(void 0===h.createIIRFilter?d=t(h):m||(f=e(h,(t=>t.createIIRFilter(a,s)))),u.set(h,null===d?f:d),null!==d){if(null===c){if(null===o)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new o(l.context.destination.channelCount,l.context.length,h.sampleRate);c=(async()=>(await i(l,t,t.destination,p),((t,e,n,o)=>{const i=n.length,r=o.length,s=Math.min(i,r);if(1!==n[0]){for(let t=0;tclass extends t{constructor(t,r){const s=o(t),a=i(s),u={...Et,...r},c=e(s,a?null:t.baseLatency,u);super(t,!1,c,a?n(u.feedback,u.feedforward):null),(t=>{t.getFrequencyResponse=(e=>(n,o,i)=>{if(n.length!==o.length||o.length!==i.length)throw Dt();return e.call(t,n,o,i)})(t.getFrequencyResponse)})(c),this._nativeIIRFilterNode=c}getFrequencyResponse(t,e,n){return this._nativeIIRFilterNode.getFrequencyResponse(t,e,n)}})(me,((t,e)=>(n,o,i)=>{if(void 0===n.createIIRFilter)return e(n,o,i);const r=t(n,(t=>t.createIIRFilter(i.feedforward,i.feedback)));return jt(r,i),r})(re,nn),rn,he,ne),an=((t,e)=>class extends I{constructor(n,o){super(n),this._nativeContext=n,p.set(this,n);const i=n.sampleRate;Object.defineProperty(n,"sampleRate",{get:()=>i}),this._destination=new t(this,o),this._listener=e(this,n),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(t){const e=R(this,t);this._nativeContext.onstatechange=e;const n=this._nativeContext.onstatechange;this._onstatechange=n===e?t:n}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}})(qe,((t,e,n,o,i)=>(r,s)=>{const a=s.listener,{forwardX:u,forwardY:c,forwardZ:l,positionX:h,positionY:p,positionZ:f,upX:d,upY:m,upZ:y}=void 0===a.forwardX?(()=>{const u=e(s,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),c=i(s),l=o(s,256,9,0),h=(e,o)=>{const i=n(s,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:o});return i.connect(u,0,e),i.start(),Object.defineProperty(i.offset,"defaultValue",{get:()=>o}),t({context:r},c,i.offset,34028234663852886e22,-34028234663852886e22)};let p=[0,0,-1,0,1,0],f=[0,0,0];return l.onaudioprocess=({inputBuffer:t})=>{const e=[t.getChannelData(0)[0],t.getChannelData(1)[0],t.getChannelData(2)[0],t.getChannelData(3)[0],t.getChannelData(4)[0],t.getChannelData(5)[0]];e.some(((t,e)=>t!==p[e]))&&(a.setOrientation(...e),p=e);const n=[t.getChannelData(6)[0],t.getChannelData(7)[0],t.getChannelData(8)[0]];n.some(((t,e)=>t!==f[e]))&&(a.setPosition(...n),f=n)},u.connect(l),{forwardX:h(0,0),forwardY:h(1,0),forwardZ:h(2,-1),positionX:h(6,0),positionY:h(7,0),positionZ:h(8,0),upX:h(3,0),upY:h(4,1),upZ:h(5,0)}})():a;return{get forwardX(){return u},get forwardY(){return c},get forwardZ(){return l},get positionX(){return h},get positionY(){return p},get positionZ(){return f},get upX(){return d},get upY(){return m},get upZ(){return y}}})(Pe,Le,Ge,en,ne)),un=((t,e,n,o,i,r)=>(s,a)=>{const u=e(s,(t=>t.createOscillator()));return jt(u,a),It(u,a,"detune"),It(u,a,"frequency"),void 0!==a.periodicWave?u.setPeriodicWave(a.periodicWave):Rt(u,a,"type"),t(n,(()=>n(s)))||Vt(u),t(o,(()=>o(s)))||r(u,s),t(i,(()=>i(s)))||Ft(u),u})(Kt,re,Te,Oe,Se,ke),cn=((t,e,n,o,i)=>()=>{const r=new WeakMap;let s=null,a=null,u=null;return{set periodicWave(t){s=t},set start(t){a=t},set stop(t){u=t},render(c,l,h){const p=r.get(l);return void 0!==p?Promise.resolve(p):(async(c,l,h)=>{let p=n(c);const f=O(p,l);if(!f){const t={channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,detune:p.detune.value,frequency:p.frequency.value,periodicWave:null===s?void 0:s,type:p.type};p=e(l,t),null!==a&&p.start(a),null!==u&&p.stop(u)}return r.set(l,p),f?(await t(l,c.detune,p.detune,h),await t(l,c.frequency,p.frequency,h)):(await o(l,c.detune,p.detune,h),await o(l,c.frequency,p.frequency,h)),await i(c,l,p,h),p})(c,l,h)}}})(Ae,un,H,Ee,ue),ln=((t,e,n,o,i,r,s)=>class extends t{constructor(t,n=Gt){const a=r(t),u={...Gt,...n},c=o(a,u),l=s(a),h=l?i():null,p=t.sampleRate/2;super(t,!1,c,h),this._detune=e(this,l,c.detune,153600,-153600),this._frequency=e(this,l,c.frequency,p,-p),this._nativeOscillatorNode=c,this._onended=null,this._oscillatorNodeRenderer=h,null!==this._oscillatorNodeRenderer&&void 0!==u.periodicWave&&(this._oscillatorNodeRenderer.periodicWave=u.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(t){const e=R(this,t);this._nativeOscillatorNode.onended=e;const n=this._nativeOscillatorNode.onended;this._onended=n===e?t:n}get type(){return this._nativeOscillatorNode.type}set type(t){if(this._nativeOscillatorNode.type=t,"custom"===t)throw n();null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(t){this._nativeOscillatorNode.setPeriodicWave(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=t)}start(t=0){if(this._nativeOscillatorNode.start(t),null!==this._oscillatorNodeRenderer)this._oscillatorNodeRenderer.start=t;else{M(this);const t=()=>{this._nativeOscillatorNode.removeEventListener("ended",t),setTimeout((()=>P(this)),1e3)};this._nativeOscillatorNode.addEventListener("ended",t)}}stop(t=0){this._nativeOscillatorNode.stop(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.stop=t)}})(me,Pe,At,un,cn,he,ne),hn=(t=>(e,n)=>{const o=t(e),i=e.createBuffer(1,2,e.sampleRate);return o.buffer=i,o.loop=!0,o.connect(n),o.start(),()=>{o.stop(),o.disconnect(n)}})(De),pn=((t,e,n,o,i,r)=>(s,{curve:a,oversample:u,...c})=>{const l=n(s,(t=>t.createWaveShaper())),h=n(s,(t=>t.createWaveShaper()));jt(l,c),jt(h,c);const p=o(s,{...c,gain:1}),f=o(s,{...c,gain:-1}),d=o(s,{...c,gain:1}),m=o(s,{...c,gain:-1});let y=null,_=!1,g=null;const v={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(t){p.channelCount=t,f.channelCount=t,l.channelCount=t,d.channelCount=t,h.channelCount=t,m.channelCount=t},get channelCountMode(){return l.channelCountMode},set channelCountMode(t){p.channelCountMode=t,f.channelCountMode=t,l.channelCountMode=t,d.channelCountMode=t,h.channelCountMode=t,m.channelCountMode=t},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(t){p.channelInterpretation=t,f.channelInterpretation=t,l.channelInterpretation=t,d.channelInterpretation=t,h.channelInterpretation=t,m.channelInterpretation=t},get context(){return l.context},get curve(){return g},set curve(n){if(null!==a&&a.length<2)throw e();if(null===n)l.curve=n,h.curve=n;else{const t=n.length,e=new Float32Array(t+2-t%2),o=new Float32Array(t+2-t%2);e[0]=n[0],o[0]=-n[t-1];const i=Math.ceil((t+1)/2),r=(t+1)/2-1;for(let s=1;sp.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>p.dispatchEvent(t[0]),removeEventListener:(...t)=>p.removeEventListener(t[0],t[1],t[2])};return a!==v.curve&&(v.curve=a),u!==v.oversample&&(v.oversample=u),r(Lt(v,d),(()=>{p.connect(l).connect(d),p.connect(f).connect(h).connect(m).connect(d),_=!0,i(g)&&(y=t(s,p))}),(()=>{p.disconnect(l),l.disconnect(d),p.disconnect(f),f.disconnect(h),h.disconnect(m),m.disconnect(d),_=!1,null!==y&&(y(),y=null)}))})(hn,At,re,je,$t,Fe),fn=((t,e,n,o,i,r,s)=>(a,u)=>{const c=n(a,(t=>t.createWaveShaper()));try{return c.curve=new Float32Array([1]),o(a,u)}catch(t){}jt(c,u);const l=u.curve;if(null!==l&&l.length<2)throw e();Rt(c,u,"curve"),Rt(c,u,"oversample");let h=null,p=!1;return s(c,"curve",(t=>()=>t.call(c)),(e=>n=>(e.call(c,n),p&&(i(n)&&null===h?h=t(a,c):i(n)||null===h||(h(),h=null)),n))),r(c,(()=>{p=!0,i(c.curve)&&(h=t(a,c))}),(()=>{p=!1,null!==h&&(h(),h=null)}))})(hn,At,re,pn,$t,Fe,Jt),dn=((t,e,n,o,i,r,s,a,u,c)=>(l,{coneInnerAngle:h,coneOuterAngle:p,coneOuterGain:f,distanceModel:d,maxDistance:m,orientationX:y,orientationY:_,orientationZ:g,panningModel:v,positionX:b,positionY:x,positionZ:w,refDistance:T,rolloffFactor:O,...S})=>{const k=n(l,(t=>t.createPanner()));if(S.channelCount>2)throw a();if("max"===S.channelCountMode)throw a();jt(k,S);const C={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},A=o(l,{...C,channelInterpretation:"speakers",numberOfInputs:6}),D=i(l,{...S,gain:1}),E=i(l,{...C,gain:1}),M=i(l,{...C,gain:0}),P=i(l,{...C,gain:0}),R=i(l,{...C,gain:0}),j=i(l,{...C,gain:0}),q=i(l,{...C,gain:0}),I=r(l,256,6,0),V=s(l,{...C,curve:new Float32Array([1,1]),oversample:"none"});let F=[1,0,0],N=[0,0,0];I.onaudioprocess=({inputBuffer:t})=>{const e=[t.getChannelData(0)[0],t.getChannelData(1)[0],t.getChannelData(2)[0]];e.some(((t,e)=>t!==F[e]))&&(k.setOrientation(...e),F=e);const n=[t.getChannelData(6)[0],t.getChannelData(7)[0],t.getChannelData(8)[0]];n.some(((t,e)=>t!==N[e]))&&(k.setPosition(...n),N=n)},Object.defineProperty(M.gain,"defaultValue",{get:()=>0}),Object.defineProperty(P.gain,"defaultValue",{get:()=>0}),Object.defineProperty(R.gain,"defaultValue",{get:()=>0}),Object.defineProperty(j.gain,"defaultValue",{get:()=>0}),Object.defineProperty(q.gain,"defaultValue",{get:()=>0});const L={get bufferSize(){},get channelCount(){return k.channelCount},set channelCount(t){if(t>2)throw a();D.channelCount=t,k.channelCount=t},get channelCountMode(){return k.channelCountMode},set channelCountMode(t){if("max"===t)throw a();D.channelCountMode=t,k.channelCountMode=t},get channelInterpretation(){return k.channelInterpretation},set channelInterpretation(t){D.channelInterpretation=t,k.channelInterpretation=t},get coneInnerAngle(){return k.coneInnerAngle},set coneInnerAngle(t){k.coneInnerAngle=t},get coneOuterAngle(){return k.coneOuterAngle},set coneOuterAngle(t){k.coneOuterAngle=t},get coneOuterGain(){return k.coneOuterGain},set coneOuterGain(t){if(t<0||t>1)throw e();k.coneOuterGain=t},get context(){return k.context},get distanceModel(){return k.distanceModel},set distanceModel(t){k.distanceModel=t},get inputs(){return[D]},get maxDistance(){return k.maxDistance},set maxDistance(t){if(t<0)throw new RangeError;k.maxDistance=t},get numberOfInputs(){return k.numberOfInputs},get numberOfOutputs(){return k.numberOfOutputs},get orientationX(){return E.gain},get orientationY(){return M.gain},get orientationZ(){return P.gain},get panningModel(){return k.panningModel},set panningModel(t){if(k.panningModel=t,k.panningModel!==t&&"HRTF"===t)throw a()},get positionX(){return R.gain},get positionY(){return j.gain},get positionZ(){return q.gain},get refDistance(){return k.refDistance},set refDistance(t){if(t<0)throw new RangeError;k.refDistance=t},get rolloffFactor(){return k.rolloffFactor},set rolloffFactor(t){if(t<0)throw new RangeError;k.rolloffFactor=t},addEventListener:(...t)=>D.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>D.dispatchEvent(t[0]),removeEventListener:(...t)=>D.removeEventListener(t[0],t[1],t[2])};return h!==L.coneInnerAngle&&(L.coneInnerAngle=h),p!==L.coneOuterAngle&&(L.coneOuterAngle=p),f!==L.coneOuterGain&&(L.coneOuterGain=f),d!==L.distanceModel&&(L.distanceModel=d),m!==L.maxDistance&&(L.maxDistance=m),y!==L.orientationX.value&&(L.orientationX.value=y),_!==L.orientationY.value&&(L.orientationY.value=_),g!==L.orientationZ.value&&(L.orientationZ.value=g),v!==L.panningModel&&(L.panningModel=v),b!==L.positionX.value&&(L.positionX.value=b),x!==L.positionY.value&&(L.positionY.value=x),w!==L.positionZ.value&&(L.positionZ.value=w),T!==L.refDistance&&(L.refDistance=T),O!==L.rolloffFactor&&(L.rolloffFactor=O),c(Lt(L,k),(()=>{D.connect(k),t(D,V,0,0),V.connect(E).connect(A),V.connect(M).connect(A),V.connect(P).connect(A),V.connect(R).connect(A),V.connect(j).connect(A),V.connect(q).connect(A),A.connect(I)}),(()=>{D.disconnect(k),u(D,V,0,0),V.disconnect(E),E.disconnect(A),V.disconnect(M),M.disconnect(A),V.disconnect(P),P.disconnect(A),V.disconnect(R),R.disconnect(A),V.disconnect(j),j.disconnect(A),V.disconnect(q),q.disconnect(A),A.disconnect(I)}))})(z,At,re,Le,je,en,fn,Ut,U,Fe),mn=((t,e)=>(n,o)=>{const i=t(n,(t=>t.createPanner()));return void 0===i.orientationX?e(n,o):(jt(i,o),It(i,o,"orientationX"),It(i,o,"orientationY"),It(i,o,"orientationZ"),It(i,o,"positionX"),It(i,o,"positionY"),It(i,o,"positionZ"),Rt(i,o,"coneInnerAngle"),Rt(i,o,"coneOuterAngle"),Rt(i,o,"coneOuterGain"),Rt(i,o,"distanceModel"),Rt(i,o,"maxDistance"),Rt(i,o,"panningModel"),Rt(i,o,"refDistance"),Rt(i,o,"rolloffFactor"),i)})(re,dn),yn=((t,e,n,o,i,r)=>class extends t{constructor(t,s=Ht){const a=i(t),u={...Ht,...s},c=n(a,u),l=r(a);super(t,!1,c,l?o():null),this._nativePannerNode=c,this._orientationX=e(this,l,c.orientationX,34028234663852886e22,-34028234663852886e22),this._orientationY=e(this,l,c.orientationY,34028234663852886e22,-34028234663852886e22),this._orientationZ=e(this,l,c.orientationZ,34028234663852886e22,-34028234663852886e22),this._positionX=e(this,l,c.positionX,34028234663852886e22,-34028234663852886e22),this._positionY=e(this,l,c.positionY,34028234663852886e22,-34028234663852886e22),this._positionZ=e(this,l,c.positionZ,34028234663852886e22,-34028234663852886e22)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(t){this._nativePannerNode.coneInnerAngle=t}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(t){this._nativePannerNode.coneOuterAngle=t}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(t){this._nativePannerNode.coneOuterGain=t}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(t){this._nativePannerNode.distanceModel=t}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(t){this._nativePannerNode.maxDistance=t}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(t){this._nativePannerNode.panningModel=t}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(t){this._nativePannerNode.refDistance=t}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(t){this._nativePannerNode.rolloffFactor=t}})(me,Pe,mn,((t,e,n,o,i)=>()=>{const r=new WeakMap;return{render(s,a,u){const c=r.get(a);return void 0!==c?Promise.resolve(c):(async(s,a,u)=>{let c=n(s);const l=O(c,a);if(!l){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,coneInnerAngle:c.coneInnerAngle,coneOuterAngle:c.coneOuterAngle,coneOuterGain:c.coneOuterGain,distanceModel:c.distanceModel,maxDistance:c.maxDistance,orientationX:c.orientationX.value,orientationY:c.orientationY.value,orientationZ:c.orientationZ.value,panningModel:c.panningModel,positionX:c.positionX.value,positionY:c.positionY.value,positionZ:c.positionZ.value,refDistance:c.refDistance,rolloffFactor:c.rolloffFactor};c=e(a,t)}return r.set(a,c),l?(await t(a,s.orientationX,c.orientationX,u),await t(a,s.orientationY,c.orientationY,u),await t(a,s.orientationZ,c.orientationZ,u),await t(a,s.positionX,c.positionX,u),await t(a,s.positionY,c.positionY,u),await t(a,s.positionZ,c.positionZ,u)):(await o(a,s.orientationX,c.orientationX,u),await o(a,s.orientationY,c.orientationY,u),await o(a,s.orientationZ,c.orientationZ,u),await o(a,s.positionX,c.positionX,u),await o(a,s.positionY,c.positionY,u),await o(a,s.positionZ,c.positionZ,u)),L(c)?await i(s,a,c.inputs[0],u):await i(s,a,c,u),c})(s,a,u)}}})(Ae,mn,H,Ee,ue),he,ne),_n=((t,e,n)=>class o{constructor(o,i){const r=e(o),s={...Xt,...i},a=t(r,s);return n.add(a),a}static[Symbol.hasInstance](t){return null!==t&&"object"==typeof t&&Object.getPrototypeOf(t)===o.prototype||n.has(t)}})((t=>(e,{disableNormalization:n,imag:o,real:i})=>{const r=t(e),s=new Float32Array(o),a=new Float32Array(i);return null!==r?r.createPeriodicWave(a,s,{disableNormalization:n}):e.createPeriodicWave(a,s,{disableNormalization:n})})(ie),he,new WeakSet),gn=((t,e,n,o,i,r)=>{const s=new Float32Array([1,1]),a=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},c={...u,oversample:"none"},l=(t,r,l,h,p)=>{if(1===r)return((t,e,i,r)=>{const l=new Float32Array(16385),h=new Float32Array(16385);for(let t=0;t<16385;t+=1){const e=t/16384*a;l[t]=Math.cos(e),h[t]=Math.sin(e)}const p=n(t,{...u,gain:0}),f=o(t,{...c,curve:l}),d=o(t,{...c,curve:s}),m=n(t,{...u,gain:0}),y=o(t,{...c,curve:h});return{connectGraph(){e.connect(p),e.connect(d.inputs[0]),e.connect(m),d.connect(i),i.connect(f.inputs[0]),i.connect(y.inputs[0]),f.connect(p.gain),y.connect(m.gain),p.connect(r,0,0),m.connect(r,0,1)},disconnectGraph(){e.disconnect(p),e.disconnect(d.inputs[0]),e.disconnect(m),d.disconnect(i),i.disconnect(f.inputs[0]),i.disconnect(y.inputs[0]),f.disconnect(p.gain),y.disconnect(m.gain),p.disconnect(r,0,0),m.disconnect(r,0,1)}}})(t,l,h,p);if(2===r)return((t,i,r,l)=>{const h=new Float32Array(16385),p=new Float32Array(16385),f=new Float32Array(16385),d=new Float32Array(16385),m=Math.floor(8192.5);for(let t=0;t<16385;t+=1)if(t>m){const e=(t-m)/(16384-m)*a;h[t]=Math.cos(e),p[t]=Math.sin(e),f[t]=0,d[t]=1}else{const e=t/(16384-m)*a;h[t]=1,p[t]=0,f[t]=Math.cos(e),d[t]=Math.sin(e)}const y=e(t,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),_=n(t,{...u,gain:0}),g=o(t,{...c,curve:h}),v=n(t,{...u,gain:0}),b=o(t,{...c,curve:p}),x=o(t,{...c,curve:s}),w=n(t,{...u,gain:0}),T=o(t,{...c,curve:f}),O=n(t,{...u,gain:0}),S=o(t,{...c,curve:d});return{connectGraph(){i.connect(y),i.connect(x.inputs[0]),y.connect(_,1),y.connect(v,1),y.connect(w,1),y.connect(O,1),x.connect(r),r.connect(g.inputs[0]),r.connect(b.inputs[0]),r.connect(T.inputs[0]),r.connect(S.inputs[0]),g.connect(_.gain),b.connect(v.gain),T.connect(w.gain),S.connect(O.gain),_.connect(l,0,0),w.connect(l,0,0),v.connect(l,0,1),O.connect(l,0,1)},disconnectGraph(){i.disconnect(y),i.disconnect(x.inputs[0]),y.disconnect(_,1),y.disconnect(v,1),y.disconnect(w,1),y.disconnect(O,1),x.disconnect(r),r.disconnect(g.inputs[0]),r.disconnect(b.inputs[0]),r.disconnect(T.inputs[0]),r.disconnect(S.inputs[0]),g.disconnect(_.gain),b.disconnect(v.gain),T.disconnect(w.gain),S.disconnect(O.gain),_.disconnect(l,0,0),w.disconnect(l,0,0),v.disconnect(l,0,1),O.disconnect(l,0,1)}}})(t,l,h,p);throw i()};return(e,{channelCount:o,channelCountMode:s,pan:a,...u})=>{if("max"===s)throw i();const c=t(e,{...u,channelCount:1,channelCountMode:s,numberOfInputs:2}),h=n(e,{...u,channelCount:o,channelCountMode:s,gain:1}),p=n(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:a});let{connectGraph:f,disconnectGraph:d}=l(e,o,h,p,c);Object.defineProperty(p.gain,"defaultValue",{get:()=>0});const m={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(t){h.channelCount!==t&&(y&&d(),({connectGraph:f,disconnectGraph:d}=l(e,t,h,p,c)),y&&f()),h.channelCount=t},get channelCountMode(){return h.channelCountMode},set channelCountMode(t){if("clamped-max"===t||"max"===t)throw i();h.channelCountMode=t},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(t){h.channelInterpretation=t},get context(){return h.context},get inputs(){return[h]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get pan(){return p.gain},addEventListener:(...t)=>h.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>h.dispatchEvent(t[0]),removeEventListener:(...t)=>h.removeEventListener(t[0],t[1],t[2])};let y=!1;return r(Lt(m,c),(()=>{f(),y=!0}),(()=>{d(),y=!1}))}})(Le,Be,je,fn,Ut,Fe),vn=((t,e,n)=>(o,i)=>t(o,(t=>{const r=i.channelCountMode;if("clamped-max"===r)throw n();if(void 0===o.createStereoPanner)return e(o,i);const s=t.createStereoPanner();return jt(s,i),It(s,i,"pan"),Object.defineProperty(s,"channelCountMode",{get:()=>r,set:t=>{if(t!==r)throw n()}}),s})))(re,gn,Ut),bn=((t,e,n,o,i,r)=>class extends t{constructor(t,s=Yt){const a=i(t),u={...Yt,...s},c=n(a,u),l=r(a);super(t,!1,c,l?o():null),this._pan=e(this,l,c.pan,1,-1)}get pan(){return this._pan}})(me,Pe,vn,((t,e,n,o,i)=>()=>{const r=new WeakMap;return{render(s,a,u){const c=r.get(a);return void 0!==c?Promise.resolve(c):(async(s,a,u)=>{let c=n(s);const l=O(c,a);if(!l){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,pan:c.pan.value};c=e(a,t)}return r.set(a,c),l?await t(a,s.pan,c.pan,u):await o(a,s.pan,c.pan,u),L(c)?await i(s,a,c.inputs[0],u):await i(s,a,c,u),c})(s,a,u)}}})(Ae,vn,H,Ee,ue),he,ne),xn=((t,e,n)=>()=>{const o=new WeakMap;return{render(i,r,s){const a=o.get(r);return void 0!==a?Promise.resolve(a):(async(i,r,s)=>{let a=e(i);if(!O(a,r)){const e={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=t(r,e)}return o.set(r,a),L(a)?await n(i,r,a.inputs[0],s):await n(i,r,a,s),a})(i,r,s)}}})(fn,H,ue),wn=((t,e,n,o,i,r)=>class extends t{constructor(t,e=Zt){const s=i(t),a={...Zt,...e},u=n(s,a);super(t,!0,u,r(s)?o():null),this._isCurveNullified=!1,this._nativeWaveShaperNode=u}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(t){if(null===t)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(t.length<2)throw e();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=t}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(t){this._nativeWaveShaperNode.oversample=t}})(me,At,fn,xn,he,ne),Tn=(t=>null!==t&&t.isSecureContext)(te),On=(t=>(e,n,o)=>{Object.defineProperties(t,{currentFrame:{configurable:!0,get:()=>Math.round(e*n)},currentTime:{configurable:!0,get:()=>e}});try{return o()}finally{null!==t&&(delete t.currentFrame,delete t.currentTime)}})(te),Sn=Tn?((t,e,n,o,i,r,s,a,u)=>(c,l,h={credentials:"omit"})=>{const p=s(c),f=new URL(l,location.href).toString();if(void 0!==p.audioWorklet)return i(l).then((t=>{const[e,n]=b(t,f),o=new Blob([`${e};(registerProcessor=>{${n}\n})((n,p)=>registerProcessor(n,class extends p{constructor(o){const{hasNoOutput,...q}=o.parameterData;if(hasNoOutput===1){super({...o,numberOfOutputs:0,outputChannelCount:[],parameterData:q});this._h=true}else{super(o);this._h=false}}process(i,o,p){return super.process(i,(this._h)?[]:o,p)}}))`],{type:"application/javascript; charset=utf-8"}),i=URL.createObjectURL(o),s=r(p);return(null!==s?s:p).audioWorklet.addModule(i,h).then((()=>URL.revokeObjectURL(i))).catch((t=>{throw URL.revokeObjectURL(i),t}))}));const d=u.get(c);if(void 0!==d&&d.has(l))return Promise.resolve();const y=a.get(c);if(void 0!==y){const t=y.get(l);if(void 0!==t)return t}const _=i(l).then((t=>{const[e,o]=b(t,f);return n(`${e};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${o}\n})})(window,'_AWGS')`)})).then((()=>{const t=window._AWGS.pop();if(void 0===t)throw new SyntaxError;o(p.currentTime,p.sampleRate,(()=>t(class{},void 0,((t,n)=>{if(""===t.trim())throw e();const o=m.get(p);if(void 0!==o){if(o.has(t))throw e();w(n),x(n.parameterDescriptors),o.set(t,n)}else w(n),x(n.parameterDescriptors),m.set(p,new Map([[t,n]]))}),p.sampleRate,void 0,void 0)))})).catch((e=>{if("SyntaxError"===e.name)throw t();throw e}));return void 0===y?a.set(c,new Map([[l,_]])):y.set(l,_),_.then((()=>{const t=u.get(c);void 0===t?u.set(c,new Set([l])):t.add(l)})).catch((()=>{})).then((()=>{const t=a.get(c);void 0!==t&&t.delete(l)})),_})(r,Ut,(t=>e=>new Promise(((n,o)=>{if(null===t)return void o(new SyntaxError);const i=t.document.head;if(null===i)o(new SyntaxError);else{const r=t.document.createElement("script"),s=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(s),u=t.onerror,c=()=>{t.onerror=u,URL.revokeObjectURL(a)};t.onerror=(t,e,n,i,r)=>e===a||e===location.href&&1===n&&1===i?(c(),o(r),!1):null!==u?u(t,e,n,i,r):void 0,r.onerror=()=>{c(),o(new SyntaxError)},r.onload=()=>{c(),n()},r.src=a,r.type="module",i.appendChild(r)}})))(te),On,(t=>async e=>{try{const t=await fetch(e);if(t.ok)return t.text()}catch(t){}throw t()})(r),ie,he,new WeakMap,new WeakMap):void 0,kn=(t=>e=>null!==t&&e instanceof t)(oe),Cn=((t,e)=>n=>t(n)||e(n))(kn,ne),An=((t,e,n,o,i,r,s,a,u,c,l,h,p,f,d,m,y,_,g,v)=>class extends d{constructor(e,n){super(e,n),this._nativeContext=e,this._audioWorklet=void 0===t?void 0:{addModule:(e,n)=>t(this,e,n)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(t,e,o){return new n({length:e,numberOfChannels:t,sampleRate:o})}createBufferSource(){return new o(this)}createChannelMerger(t=6){return new r(this,{numberOfInputs:t})}createChannelSplitter(t=6){return new s(this,{numberOfOutputs:t})}createConstantSource(){return new a(this)}createConvolver(){return new u(this)}createDelay(t=1){return new l(this,{maxDelayTime:t})}createDynamicsCompressor(){return new h(this)}createGain(){return new p(this)}createIIRFilter(t,e){return new f(this,{feedback:e,feedforward:t})}createOscillator(){return new m(this)}createPanner(){return new y(this)}createPeriodicWave(t,e,n={disableNormalization:!1}){return new _(this,{...n,imag:e,real:t})}createStereoPanner(){return new g(this)}createWaveShaper(){return new v(this)}decodeAudioData(t,e,n){return c(this._nativeContext,t).then((t=>("function"==typeof e&&e(t),t))).catch((t=>{throw"function"==typeof n&&n(t),t}))}})(Sn,ye,we,Re,Ve,ze,Ue,He,Qe,((t,e,n,o,i,r,s,a,u,c,l,h,p)=>(n,o)=>{const f=s(n)?n:r(n);if(i.has(o)){const t=(()=>{try{return new DOMException("","DataCloneError")}catch(t){return t.code=25,t.name="DataCloneError",t}})();return Promise.reject(t)}try{i.add(o)}catch(t){}return e(l,(()=>l(f)))?("closed"===f.state&&null!==u&&a(f)?new u(1,1,f.sampleRate):f).decodeAudioData(o).catch((t=>{if(t instanceof DOMException&&"NotSupportedError"===t.name)throw new TypeError;throw t})).then((n=>(e(c,(()=>c(n)))||p(n),t.add(n),n))):new Promise(((e,n)=>{const i=()=>{try{(t=>{const{port1:e}=new MessageChannel;e.postMessage(t,[t])})(o)}catch(t){}},r=t=>{n(t),i()};try{f.decodeAudioData(o,(n=>{"function"!=typeof n.copyFromChannel&&(h(n),C(n)),t.add(n),i(),e(n)}),(t=>{r(null===t?(()=>{try{return new DOMException("","EncodingError")}catch(t){return t.code=0,t.name="EncodingError",t}})():t)}))}catch(t){r(t)}}))})(_e,Kt,0,0,new WeakSet,he,Cn,ne,ee,S,Pt,be,xe),$e,Ke,tn,sn,an,ln,yn,_n,bn,wn),Dn=((t,e,n,o,i)=>class extends t{constructor(t,r){const s=o(t);if(i(s))throw n();const a=e(s,r);super(t,!0,a,null),this._mediaElement=r.mediaElement,this._nativeMediaElementAudioSourceNode=a}get mediaElement(){return void 0===this._nativeMediaElementAudioSourceNode.mediaElement?this._mediaElement:this._nativeMediaElementAudioSourceNode.mediaElement}})(me,(t=>(e,n)=>t(e,(t=>t.createMediaElementSource(n.mediaElement))))(re),Ut,he,ne),En=((t,e,n,o,i)=>class extends t{constructor(t,r){const s=o(t);if(i(s))throw n();const a=e(s,r);super(t,!0,a,null),this._nativeMediaStreamAudioSourceNode=a}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}})(me,(t=>(e,{mediaStream:n})=>{const o=n.getAudioTracks(),i=t(e,(t=>{const e=o.sort(((t,e)=>t.ide.id?1:0)).slice(0,1);return t.createMediaStreamSource(new MediaStream(e))}));return Object.defineProperty(i,"mediaStream",{value:n}),i})(re),Ut,he,ne),Mn=((t,e,n,o,i)=>class extends t{constructor(t,r){const s=o(t);if(i(s))throw n();super(t,!0,e(s,r),null)}})(me,((t,e)=>(n,{mediaStreamTrack:o})=>"function"==typeof n.createMediaStreamTrackSource?e(n,(t=>t.createMediaStreamTrackSource(o))):e(n,(e=>{const n=new MediaStream([o]),i=e.createMediaStreamSource(n);if("audio"!==o.kind)throw t();return i})))(At,re),Ut,he,ne),Pn=((t,e,n,o,i,r,s,a)=>class extends t{constructor(t={}){if(null===a)throw new Error("Missing the native AudioContext constructor.");const e=new a(t);if(null===e)throw o();if(!q(t.latencyHint))throw new TypeError(`The provided value '${t.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(void 0!==t.sampleRate&&e.sampleRate!==t.sampleRate)throw n();super(e,2);const{latencyHint:i}=t,{sampleRate:r}=e;if(this._baseLatency="number"==typeof e.baseLatency?e.baseLatency:"balanced"===i?512/r:"interactive"===i||void 0===i?256/r:"playback"===i?1024/r:128*Math.max(2,Math.min(128,Math.round(i*r/128)))/r,this._nativeAudioContext=e,this._state=null,"running"===e.state){this._state="suspended";const t=()=>{"suspended"===this._state&&(this._state=null),e.removeEventListener("statechange",t)};e.addEventListener("statechange",t)}}get baseLatency(){return this._baseLatency}get state(){return null!==this._state?this._state:this._nativeAudioContext.state}close(){return"closed"===this.state?this._nativeAudioContext.close().then((()=>{throw e()})):("suspended"===this._state&&(this._state=null),this._nativeAudioContext.close())}createMediaElementSource(t){return new i(this,{mediaElement:t})}createMediaStreamSource(t){return new r(this,{mediaStream:t})}createMediaStreamTrackSource(t){return new s(this,{mediaStreamTrack:t})}resume(){return"suspended"===this._state?new Promise(((t,e)=>{const n=()=>{this._nativeAudioContext.removeEventListener("statechange",n),"running"===this._nativeAudioContext.state?t():this.resume().then(t,e)};this._nativeAudioContext.addEventListener("statechange",n)})):this._nativeAudioContext.resume().catch((t=>{if(void 0===t||15===t.code)throw e();throw t}))}suspend(){return this._nativeAudioContext.suspend().catch((t=>{if(void 0===t)throw e();throw t}))}})(An,At,Ut,Qt,Dn,En,Mn,oe),Rn=(t=>(e,n,o=0,i=0)=>{const r=e[o];if(void 0===r)throw t();return nt(n)?r.connect(n,0,i):r.connect(n,0)})(k),jn=(t=>(e,n,o,i=0)=>void 0===n?e.forEach((t=>t.disconnect())):"number"==typeof n?St(t,e,n).disconnect():nt(n)?void 0===o?e.forEach((t=>t.disconnect(n))):void 0===i?St(t,e,o).disconnect(n,0):St(t,e,o).disconnect(n,0,i):void 0===o?e.forEach((t=>t.disconnect(n))):St(t,e,o).disconnect(n,0))(k),qn=((t,e,n,o,i,r,s,a,u,c,l,h,p)=>(f,d,m,_)=>{if(0===_.numberOfInputs&&0===_.numberOfOutputs)throw c();if(void 0!==_.outputChannelCount){if(_.outputChannelCount.length!==_.numberOfOutputs)throw n();if(_.outputChannelCount.some((t=>t<1)))throw c()}if("explicit"!==_.channelCountMode)throw c();const g=_.channelCount*_.numberOfInputs,v=_.outputChannelCount.reduce(((t,e)=>t+e),0),b=void 0===m.parameterDescriptors?0:m.parameterDescriptors.length;if(g+b>6||v>6)throw c();const x=new MessageChannel,w=[],T=[];for(let t=0;t<_.numberOfInputs;t+=1)w.push(a(f,{channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation,gain:1})),T.push(r(f,{channelCount:_.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:_.channelCount}));const O=[];if(void 0!==m.parameterDescriptors)for(const{defaultValue:t,maxValue:e,minValue:n,name:o}of m.parameterDescriptors){const i=s(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:void 0!==_.parameterData[o]?_.parameterData[o]:void 0===t?0:t});Object.defineProperties(i.offset,{defaultValue:{get:()=>void 0===t?0:t},maxValue:{get:()=>void 0===e?34028234663852886e22:e},minValue:{get:()=>void 0===n?-34028234663852886e22:n}}),O.push(i)}const S=i(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,g+b)}),k=Nt(d,f.sampleRate),C=u(f,k,g+b,Math.max(1,v)),A=r(f,{channelCount:Math.max(1,v),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,v)}),D=[];for(let t=0;t<_.numberOfOutputs;t+=1)D.push(i(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:_.outputChannelCount[t]}));for(let t=0;t<_.numberOfInputs;t+=1){w[t].connect(T[t]);for(let e=0;e<_.channelCount;e+=1)T[t].connect(S,e,t*_.channelCount+e)}const E=new pt(void 0===m.parameterDescriptors?[]:m.parameterDescriptors.map((({name:t},e)=>{const n=O[e];return n.connect(S,0,g+e),n.start(0),[t,n.offset]})));S.connect(C);let M=_.channelInterpretation,P=null;const R=0===_.numberOfOutputs?[C]:D,j={get bufferSize(){return k},get channelCount(){return _.channelCount},set channelCount(t){throw o()},get channelCountMode(){return _.channelCountMode},set channelCountMode(t){throw o()},get channelInterpretation(){return M},set channelInterpretation(t){for(const e of w)e.channelInterpretation=t;M=t},get context(){return C.context},get inputs(){return w},get numberOfInputs(){return _.numberOfInputs},get numberOfOutputs(){return _.numberOfOutputs},get onprocessorerror(){return P},set onprocessorerror(t){"function"==typeof P&&j.removeEventListener("processorerror",P),P="function"==typeof t?t:null,"function"==typeof P&&j.addEventListener("processorerror",P)},get parameters(){return E},get port(){return x.port2},addEventListener:(...t)=>C.addEventListener(t[0],t[1],t[2]),connect:e.bind(null,R),disconnect:l.bind(null,R),dispatchEvent:(...t)=>C.dispatchEvent(t[0]),removeEventListener:(...t)=>C.removeEventListener(t[0],t[1],t[2])},q=new Map;x.port1.addEventListener=(t=>(...e)=>{if("message"===e[0]){const t="function"==typeof e[1]?e[1]:"object"==typeof e[1]&&null!==e[1]&&"function"==typeof e[1].handleEvent?e[1].handleEvent:null;if(null!==t){const n=q.get(e[1]);void 0!==n?e[1]=n:(e[1]=e=>{h(f.currentTime,f.sampleRate,(()=>t(e)))},q.set(t,e[1]))}}return t.call(x.port1,e[0],e[1],e[2])})(x.port1.addEventListener),x.port1.removeEventListener=(t=>(...e)=>{if("message"===e[0]){const t=q.get(e[1]);void 0!==t&&(q.delete(e[1]),e[1]=t)}return t.call(x.port1,e[0],e[1],e[2])})(x.port1.removeEventListener);let I=null;Object.defineProperty(x.port1,"onmessage",{get:()=>I,set:t=>{"function"==typeof I&&x.port1.removeEventListener("message",I),I="function"==typeof t?t:null,"function"==typeof I&&(x.port1.addEventListener("message",I),x.port1.start())}}),m.prototype.port=x.port1;let V=null;((t,e,n,o)=>{let i=y.get(t);void 0===i&&(i=new WeakMap,y.set(t,i));const r=(async(t,e)=>new t(await(t=>new Promise(((e,n)=>{const{port1:o,port2:i}=new MessageChannel;o.onmessage=({data:t})=>{o.close(),i.close(),e(t)},o.onmessageerror=({data:t})=>{o.close(),i.close(),n(t)},i.postMessage(t)})))(e)))(n,o);return i.set(e,r),r})(f,j,m,_).then((t=>V=t));const F=_t(_.numberOfInputs,_.channelCount),N=_t(_.numberOfOutputs,_.outputChannelCount),L=void 0===m.parameterDescriptors?[]:m.parameterDescriptors.reduce(((t,{name:e})=>({...t,[e]:new Float32Array(128)})),{});let z=!0;const B=()=>{_.numberOfOutputs>0&&C.disconnect(A);for(let t=0,e=0;t<_.numberOfOutputs;t+=1){const n=D[t];for(let o=0;o<_.outputChannelCount[t];o+=1)A.disconnect(n,e+o,o);e+=_.outputChannelCount[t]}};C.onaudioprocess=({inputBuffer:e,outputBuffer:n})=>{if(null!==V)for(let o=0;o{mt(e,L,t,g+n,o)}));for(let t=0;t<_.numberOfInputs;t+=1)for(let e=0;e<_.outputChannelCount[t];e+=1)0===N[t][e].byteLength&&(N[t][e]=new Float32Array(128));try{const e=F.map(((e,n)=>{const o=t.get(j);return void 0===o||void 0===o.get(n)?[new Float32Array(0)]:e})),i=h(f.currentTime+o/f.sampleRate,f.sampleRate,(()=>V.process(e,N,L)));z=i;for(let t=0,e=0;t<_.numberOfOutputs;t+=1){for(let i=0;i<_.outputChannelCount[t];i+=1)yt(n,N[t],i,e+i,o);e+=_.outputChannelCount[t]}}catch(t){z=!1,j.dispatchEvent(new ErrorEvent("processorerror",{error:t}))}if(!z){for(let t=0;t<_.numberOfInputs;t+=1){w[t].disconnect(T[t]);for(let e=0;e<_.channelCount;e+=1)T[o].disconnect(S,e,t*_.channelCount+e)}if(void 0!==m.parameterDescriptors){const t=m.parameterDescriptors.length;for(let e=0;e{if(z){_.numberOfOutputs>0&&C.connect(A);for(let t=0,e=0;t<_.numberOfOutputs;t+=1){const n=D[t];for(let o=0;o<_.outputChannelCount[t];o+=1)A.connect(n,e+o,o);e+=_.outputChannelCount[t]}}U=!0}),(()=>{z&&B(),U=!1}))})(le,Rn,k,At,Le,Be,Ge,je,en,Ut,jn,On,Fe),In=((t,e,n,o,i)=>(r,s,a,u,c,l)=>{if(null!==a)try{const n=e(r,(t=>i(t)&&0!==l.numberOfInputs&&0===l.numberOfOutputs?new a(t,u,{...l,numberOfOutputs:1,outputChannelCount:[1],parameterData:{...l.parameterData,hasNoOutput:1}}):new a(t,u,l))),o=new Map;let s=null;return Object.defineProperties(n,{channelCount:{get:()=>l.channelCount,set:()=>{throw t()}},channelCountMode:{get:()=>"explicit",set:()=>{throw t()}},onprocessorerror:{get:()=>s,set:t=>{"function"==typeof s&&n.removeEventListener("processorerror",s),s="function"==typeof t?t:null,"function"==typeof s&&n.addEventListener("processorerror",s)}}}),n.addEventListener=(t=>(...e)=>{if("processorerror"===e[0]){const t="function"==typeof e[1]?e[1]:"object"==typeof e[1]&&null!==e[1]&&"function"==typeof e[1].handleEvent?e[1].handleEvent:null;if(null!==t){const n=o.get(e[1]);void 0!==n?e[1]=n:(e[1]=n=>{t(new ErrorEvent(e[0],{...n,error:new Error}))},o.set(t,e[1]))}}return t.call(n,e[0],e[1],e[2])})(n.addEventListener),n.removeEventListener=(t=>(...e)=>{if("processorerror"===e[0]){const t=o.get(e[1]);void 0!==t&&(o.delete(e[1]),e[1]=t)}return t.call(n,e[0],e[1],e[2])})(n.removeEventListener),n}catch(t){if(11===t.code)throw o();throw t}if(void 0===c)throw o();return(t=>{const{port1:e}=new MessageChannel;try{e.postMessage(t)}finally{e.close()}})(l),n(r,s,c,l)})(At,re,qn,Ut,ne),Vn=(t=>null===t?null:t.hasOwnProperty("AudioWorkletNode")?t.AudioWorkletNode:null)(te),Fn=((t,e,n,o,i,r,s,a,u,c,l,h,p,f,d)=>(m,y,_)=>{const g=new WeakMap;let v=null;return{render(b,x,w){const T=g.get(x);return void 0!==T?Promise.resolve(T):(async(b,x,w)=>{let T=c(b),S=null;const k=O(T,x);if(null===l){const t=y.outputChannelCount.reduce(((t,e)=>t+e),0),n=i(x,{channelCount:Math.max(1,t),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,t)}),r=[];for(let t=0;t{const a=new h(n,128*Math.ceil(b.context.length/128),x.sampleRate),u=[],c=[];for(let t=0;t{const e=r(a,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:t.value});return await p(a,t,e.offset,w),e}))),m=o(a,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,t+e)});for(let t=0;tf(b,a,t,w)))),d(a)};v=gt(b,0===n?null:await a(),x,y,_,u)}const t=await v,e=n(x),[a,c,l]=S;null!==t&&(e.buffer=t,e.start(0)),e.connect(a);for(let t=0,e=0;tclass extends t{constructor(t,u,c=ft){const l=r(t),h=s(l),p=(t=>({...t,outputChannelCount:void 0!==t.outputChannelCount?t.outputChannelCount:1===t.numberOfInputs&&1===t.numberOfOutputs?[t.channelCount]:dt(t.numberOfOutputs)}))({...ft,...c}),f=m.get(l),d=void 0===f?void 0:f.get(u),y=o(l,h?null:t.baseLatency,a,u,d,p);super(t,!0,y,h?n(u,p,d):null);const _=[];if(y.parameters.forEach(((t,n)=>{const o=e(this,h,t);_.push([n,o])})),this._nativeAudioWorkletNode=y,this._numberOfOutputs=0===c.numberOfOutputs?0:this._nativeAudioWorkletNode.numberOfOutputs,this._onprocessorerror=null,this._parameters=new pt(_),"closed"!==t.state){const e=new i(t,{gain:0});try{this.connect(e).connect(t.destination)}catch(t){if("IndexSizeError"!==t.name)throw t}}}get numberOfOutputs(){return this._numberOfOutputs}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(t){const e=R(this,t);this._nativeAudioWorkletNode.onprocessorerror=e;const n=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=n===e?t:n}get parameters(){return null===this._parameters?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}})(me,Pe,Fn,In,tn,he,ne,Vn):void 0,Ln=(((t,e,n,o,i)=>{})(At,Ut,Qt,an,oe),((t,e)=>(n,o,i)=>{if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(n,o,i)}catch(e){if("IndexSizeError"===e.name||"SyntaxError"===e.name)throw t();throw e}})(Ut,ee)),zn=((t,e,n,o,i,r,s)=>(a,u)=>n(a).render(a,u,[]).then((()=>o(u))).then((n=>("function"!=typeof n.copyFromChannel?(r(n),C(n)):e(i,(()=>i(n)))||s(n),t.add(n),n))))(_e,Kt,ae,on,S,be,xe),Bn=(((t,e,n,o,i)=>{})(Kt,At,Ln,an,zn),((t,e,n,o,i)=>class extends t{constructor(t,n,i){let r;if("number"==typeof t&&void 0!==n&&void 0!==i)r={length:n,numberOfChannels:t,sampleRate:i};else{if("object"!=typeof t)throw new Error("The given parameters are not valid.");r=t}const{length:s,numberOfChannels:a,sampleRate:u}={...Wt,...r},c=o(a,s,u);e(Pt,(()=>Pt(c)))||c.addEventListener("statechange",(()=>{let t=0;const e=n=>{"running"===this._state&&(t>0?(c.removeEventListener("statechange",e),n.stopImmediatePropagation(),this._waitForThePromiseToSettle(n)):t+=1)};return e})()),super(c,a),this._length=s,this._nativeOfflineAudioContext=c,this._state=null}get length(){return void 0===this._nativeOfflineAudioContext.length?this._length:this._nativeOfflineAudioContext.length}get state(){return null===this._state?this._nativeOfflineAudioContext.state:this._state}startRendering(){return"running"===this._state?Promise.reject(n()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).then((t=>(this._state=null,t))).catch((t=>{throw this._state=null,t})))}_waitForThePromiseToSettle(t){null===this._state?this._nativeOfflineAudioContext.dispatchEvent(t):setTimeout((()=>this._waitForThePromiseToSettle(t)))}})(An,Kt,At,Ln,zn)),Un=((t,e)=>n=>{const o=t.get(n);return e(o)||e(n)})(p,kn),Wn=((t,e)=>n=>t.has(n)||e(n))(u,fe),Gn=((t,e)=>n=>t.has(n)||e(n))(l,de),Hn=((t,e)=>n=>{const o=t.get(n);return e(o)||e(n)})(p,ne); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */var Xn=function(t,e){return(Xn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function Yn(t,e){function n(){this.constructor=t}Xn(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function Qn(t,e,n,o){var i,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(r<3?i(s):r>3?i(e,n,s):i(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s}function Zn(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{u(o.next(t))}catch(t){r(t)}}function a(t){try{u(o.throw(t))}catch(t){r(t)}}function u(t){t.done?i(t.value):new n((function(e){e(t.value)})).then(s,a)}u((o=o.apply(t,e||[])).next())}))}function $n(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;switch(o=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===r[0]||2===r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function Kn(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,i,r=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function to(){for(var t=[],e=0;ee+Po}function jo(t,e){return Ro(t,e)||Io(t,e)}function qo(t,e){return t+Pothis.memory){var o=this.length-this.memory;this._timeline.splice(0,o)}return this},e.prototype.remove=function(t){var e=this._timeline.indexOf(t);return-1!==e&&this._timeline.splice(e,1),this},e.prototype.get=function(t,e){void 0===e&&(e="time");var n=this._search(t,e);return-1!==n?this._timeline[n]:null},e.prototype.peek=function(){return this._timeline[0]},e.prototype.shift=function(){return this._timeline.shift()},e.prototype.getAfter=function(t,e){void 0===e&&(e="time");var n=this._search(t,e);return n+10&&this._timeline[e-1].time=0?this._timeline[n-1]:null},e.prototype.cancel=function(t){if(this._timeline.length>1){var e=this._search(t);if(e>=0)if(Io(this._timeline[e].time,t)){for(var n=e;n>=0&&Io(this._timeline[n].time,t);n--)e=n;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else 1===this._timeline.length&&jo(this._timeline[0].time,t)&&(this._timeline=[]);return this},e.prototype.cancelBefore=function(t){var e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this},e.prototype.previousEvent=function(t){var e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null},e.prototype._search=function(t,e){if(void 0===e&&(e="time"),0===this._timeline.length)return-1;var n=0,o=this._timeline.length,i=o;if(o>0&&this._timeline[o-1][e]<=t)return o-1;for(;n=0&&this._timeline[n].time>=t;)n--;return this._iterate(e,n+1),this},e.prototype.forEachAtTime=function(t,e){var n=this._search(t);return-1!==n&&this._iterate((function(n){n.time===t&&e(n)}),0,n),this},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._timeline=[],this},e}(Mo),No=[];function Lo(t){No.push(t)}var zo=[];function Bo(t){zo.push(t)}var Uo=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Emitter",e}return Yn(e,t),e.prototype.on=function(t,e){var n=this;return t.split(/\W+/).forEach((function(t){uo(n._events)&&(n._events={}),n._events.hasOwnProperty(t)||(n._events[t]=[]),n._events[t].push(e)})),this},e.prototype.once=function(t,e){var n=this,o=function(){for(var i=[],r=0;r0,n=e?t.length:1,o=e?t[0].length:t.length,i=ti(),r=i.createBuffer(n,o,i.sampleRate),s=e||1!==n?t:[t],a=0;a0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._buffer?this._buffer.duration:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._buffer?this._buffer.length:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numberOfChannels",{get:function(){return this._buffer?this._buffer.numberOfChannels:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reverse",{get:function(){return this._reversed},set:function(t){this._reversed!==t&&(this._reversed=t,this._reverse())},enumerable:!0,configurable:!0}),e.fromArray=function(t){return(new e).fromArray(t)},e.fromUrl=function(t){return Zn(this,void 0,void 0,(function(){return $n(this,(function(n){switch(n.label){case 0:return[4,(new e).load(t)];case 1:return[2,n.sent()]}}))}))},e.load=function(t){return Zn(this,void 0,void 0,(function(){var n,o,i,r,s,a,u,c,l,h,p;return $n(this,(function(f){switch(f.label){case 0:if(n=t.match(/\[(.+\|?)+\]$/)){o=n[1].split("|"),i=o[0];try{for(r=Jn(o),s=r.next();!s.done;s=r.next())if(a=s.value,e.supportsType(a)){i=a;break}}catch(t){h={error:t}}finally{try{s&&!s.done&&(p=r.return)&&p.call(r)}finally{if(h)throw h.error}}t=t.replace(n[0],i)}return u=""===e.baseUrl||e.baseUrl.endsWith("/")?e.baseUrl:e.baseUrl+"/",[4,fetch(u+t)];case 1:if(!(c=f.sent()).ok)throw new Error("could not load url: "+t);return[4,c.arrayBuffer()];case 2:return l=f.sent(),[4,ti().decodeAudioData(l)];case 3:return[2,f.sent()]}}))}))},e.supportsType=function(t){var e=t.split("."),n=e[e.length-1];return""!==document.createElement("audio").canPlayType("audio/"+n)},e.loaded=function(){return Zn(this,void 0,void 0,(function(){var t,n,o,i,r;return $n(this,(function(s){switch(s.label){case 0:s.trys.push([0,5,6,7]),t=Jn(e.downloads),n=t.next(),s.label=1;case 1:return n.done?[3,4]:[4,n.value];case 2:s.sent(),s.label=3;case 3:return n=t.next(),[3,1];case 4:return[3,7];case 5:return o=s.sent(),i={error:o},[3,7];case 6:try{n&&!n.done&&(r=t.return)&&r.call(t)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},e.baseUrl="",e.downloads=[],e}(Mo),$o=function(t){function e(){var e,n,o,i=t.call(this,{clockSource:"offline",context:To(arguments[0])?arguments[0]:(e=arguments[0],n=arguments[1]*arguments[2],o=arguments[2],new Bn(e,n,o)),lookAhead:0,updateInterval:To(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]})||this;return i.name="OfflineContext",i._currentTime=0,i.isOffline=!0,i._duration=To(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1],i}return Yn(e,t),e.prototype.now=function(){return this._currentTime},Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._currentTime},enumerable:!0,configurable:!0}),e.prototype._renderClock=function(t){return Zn(this,void 0,void 0,(function(){var e,n;return $n(this,(function(o){switch(o.label){case 0:e=0,o.label=1;case 1:return this._duration-this._currentTime>=0?(this.emit("tick"),this._currentTime+=128/this.sampleRate,e++,n=Math.floor(this.sampleRate/128),t&&e%n==0?[4,new Promise((function(t){return setTimeout(t,1)}))]:[3,3]):[3,4];case 2:o.sent(),o.label=3;case 3:return[3,1];case 4:return[2]}}))}))},e.prototype.render=function(t){return void 0===t&&(t=!0),Zn(this,void 0,void 0,(function(){var e;return $n(this,(function(n){switch(n.label){case 0:return[4,this.workletsAreReady()];case 1:return n.sent(),[4,this._renderClock(t)];case 2:return n.sent(),[4,this._context.startRendering()];case 3:return e=n.sent(),[2,new Zo(e)]}}))}))},e.prototype.close=function(){return Promise.resolve()},e}(Go),Jo=new Ho,Ko=Jo;function ti(){return Ko===Jo&&vo&&ei(new Go),Ko}function ei(t){Ko=Oo(t)?new Go(t):To(t)?new $o(t):t}function ni(){return Ko.resume()}if(go&&!go.TONE_SILENCE_LOGGING){console.log("%c * Tone.js v14.5.17 * ","background: #000; color: #fff")}function oi(t){return Math.pow(10,t/20)}function ii(t){return Math.log(t)/Math.LN10*20}function ri(t){return Math.pow(2,t/12)}var si=440;function ai(t){return Math.round(function(t){return 69+12*Math.log2(t/si)}(t))}function ui(t){return si*Math.pow(2,(t-69)/12)}var ci=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="TimeClass",e}return Yn(e,t),e.prototype._getExpressions=function(){var n=this;return Object.assign(t.prototype._getExpressions.call(this),{now:{method:function(t){return n._now()+new n.constructor(n.context,t).valueOf()},regexp:/^\+(.+)/},quantize:{method:function(t){var o=new e(n.context,t).valueOf();return n._secondsToUnits(n.context.transport.nextSubdivision(o))},regexp:/^@(.+)/}})},e.prototype.quantize=function(t,e){void 0===e&&(e=1);var n=new this.constructor(this.context,t).valueOf(),o=this.valueOf();return o+(Math.round(o/n)*n-o)*e},e.prototype.toNotation=function(){for(var t=this,n=this.toSeconds(),o=["1m"],i=1;i<9;i++){var r=Math.pow(2,i);o.push(r+"n."),o.push(r+"n"),o.push(r+"t")}o.push("0");var s=o[0],a=new e(this.context,o[0]).toSeconds();return o.forEach((function(o){var i=new e(t.context,o).toSeconds();Math.abs(i-n)3&&(o=parseFloat(parseFloat(i).toFixed(3))),[n,e,o].join(":")},e.prototype.toTicks=function(){var t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.round(e*this._getPPQ())},e.prototype.toSeconds=function(){return this.valueOf()},e.prototype.toMidi=function(){return ai(this.toFrequency())},e.prototype._now=function(){return this.context.now()},e}(function(t){function e(e,n,o){var i=t.call(this)||this;return i.defaultUnits="s",i._val=n,i._units=o,i.context=e,i._expressions=i._getExpressions(),i}return Yn(e,t),e.prototype._getExpressions=function(){var t=this;return{hz:{method:function(e){return t._frequencyToUnits(parseFloat(e))},regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:function(e){return t._ticksToUnits(parseInt(e,10))},regexp:/^(\d+)i$/i},m:{method:function(e){return t._beatsToUnits(parseInt(e,10)*t._getTimeSignature())},regexp:/^(\d+)m$/i},n:{method:function(e,n){var o=parseInt(e,10),i="."===n?1.5:1;return 1===o?t._beatsToUnits(t._getTimeSignature())*i:t._beatsToUnits(4/o)*i},regexp:/^(\d+)n(\.?)$/i},number:{method:function(e){return t._expressions[t.defaultUnits].method.call(t,e)},regexp:/^(\d+(?:\.\d+)?)$/},s:{method:function(e){return t._secondsToUnits(parseFloat(e))},regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:function(e){return parseInt(e,10)/t.context.sampleRate},regexp:/^(\d+)samples$/},t:{method:function(e){var n=parseInt(e,10);return t._beatsToUnits(8/(3*Math.floor(n)))},regexp:/^(\d+)t$/i},tr:{method:function(e,n,o){var i=0;return e&&"0"!==e&&(i+=t._beatsToUnits(t._getTimeSignature()*parseFloat(e))),n&&"0"!==n&&(i+=t._beatsToUnits(parseFloat(n))),o&&"0"!==o&&(i+=t._beatsToUnits(parseFloat(o)/4)),i},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}},e.prototype.valueOf=function(){if(this._val instanceof e&&this.fromType(this._val),uo(this._val))return this._noArg();if(yo(this._val)&&uo(this._units)){for(var t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(po(this._val)){var n=0;for(var o in this._val)if(co(this._val[o])){var i=this._val[o];n+=new this.constructor(this.context,o).valueOf()*i}return n}if(co(this._units)){var r=this._expressions[this._units],s=this._val.toString().trim().match(r.regexp);return s?r.method.apply(this,s.slice(1)):r.method.call(this,this._val)}return yo(this._val)?parseFloat(this._val):this._val},e.prototype._frequencyToUnits=function(t){return 1/t},e.prototype._beatsToUnits=function(t){return 60/this._getBpm()*t},e.prototype._secondsToUnits=function(t){return t},e.prototype._ticksToUnits=function(t){return t*this._beatsToUnits(1)/this._getPPQ()},e.prototype._noArg=function(){return this._now()},e.prototype._getBpm=function(){return this.context.transport.bpm.value},e.prototype._getTimeSignature=function(){return this.context.transport.timeSignature},e.prototype._getPPQ=function(){return this.context.transport.PPQ},e.prototype.fromType=function(t){switch(this._units=void 0,this.defaultUnits){case"s":this._val=t.toSeconds();break;case"i":this._val=t.toTicks();break;case"hz":this._val=t.toFrequency();break;case"midi":this._val=t.toMidi()}return this},e.prototype.toFrequency=function(){return 1/this.toSeconds()},e.prototype.toSamples=function(){return this.toSeconds()*this.context.sampleRate},e.prototype.toMilliseconds=function(){return 1e3*this.toSeconds()},e}(Mo));function li(t,e){return new ci(ti(),t,e)}var hi=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Frequency",e.defaultUnits="hz",e}return Yn(e,t),Object.defineProperty(e,"A4",{get:function(){return si},set:function(t){!function(t){si=t}(t)},enumerable:!0,configurable:!0}),e.prototype._getExpressions=function(){return Object.assign({},t.prototype._getExpressions.call(this),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method:function(t){return"midi"===this.defaultUnits?t:e.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,method:function(t,n){var o=pi[t.toLowerCase()]+12*(parseInt(n,10)+1);return"midi"===this.defaultUnits?o:e.mtof(o)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method:function(t,e,n){var o=1;return t&&"0"!==t&&(o*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(o*=this._beatsToUnits(parseFloat(e))),n&&"0"!==n&&(o*=this._beatsToUnits(parseFloat(n)/4)),o}}})},e.prototype.transpose=function(t){return new e(this.context,this.valueOf()*ri(t))},e.prototype.harmonize=function(t){var e=this;return t.map((function(t){return e.transpose(t)}))},e.prototype.toMidi=function(){return ai(this.valueOf())},e.prototype.toNote=function(){var t=this.toFrequency(),n=Math.log2(t/e.A4),o=Math.round(12*n)+57,i=Math.floor(o/12);return i<0&&(o+=-12*i),fi[o%12]+i.toString()},e.prototype.toSeconds=function(){return 1/t.prototype.toSeconds.call(this)},e.prototype.toTicks=function(){var t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())},e.prototype._noArg=function(){return 0},e.prototype._frequencyToUnits=function(t){return t},e.prototype._ticksToUnits=function(t){return 1/(60*t/(this._getBpm()*this._getPPQ()))},e.prototype._beatsToUnits=function(e){return 1/t.prototype._beatsToUnits.call(this,e)},e.prototype._secondsToUnits=function(t){return 1/t},e.mtof=function(t){return ui(t)},e.ftom=function(t){return ai(t)},e}(ci),pi={cbb:-2,cb:-1,c:0,"c#":1,cx:2,dbb:0,db:1,d:2,"d#":3,dx:4,ebb:2,eb:3,e:4,"e#":5,ex:6,fbb:3,fb:4,f:5,"f#":6,fx:7,gbb:5,gb:6,g:7,"g#":8,gx:9,abb:7,ab:8,a:9,"a#":10,ax:11,bbb:9,bb:10,b:11,"b#":12,bx:13},fi=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];function di(t,e){return new hi(ti(),t,e)}var mi=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="TransportTime",e}return Yn(e,t),e.prototype._now=function(){return this.context.transport.seconds},e}(ci);function yi(t,e){return new mi(ti(),t,e)}var _i=function(t){function e(){var n=t.call(this)||this,o=Ao(e.getDefaults(),arguments,["context"]);return n.defaultContext?n.context=n.defaultContext:n.context=o.context,n}return Yn(e,t),e.getDefaults=function(){return{context:ti()}},e.prototype.now=function(){return this.context.currentTime+this.context.lookAhead},e.prototype.immediate=function(){return this.context.currentTime},Object.defineProperty(e.prototype,"sampleTime",{get:function(){return 1/this.context.sampleRate},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blockTime",{get:function(){return 128/this.context.sampleRate},enumerable:!0,configurable:!0}),e.prototype.toSeconds=function(t){return new ci(this.context,t).toSeconds()},e.prototype.toFrequency=function(t){return new hi(this.context,t).toFrequency()},e.prototype.toTicks=function(t){return new mi(this.context,t).toTicks()},e.prototype._getPartialProperties=function(t){var e=this.get();return Object.keys(e).forEach((function(n){uo(t[n])&&delete e[n]})),e},e.prototype.get=function(){var t=this,n=this.constructor.getDefaults();return Object.keys(n).forEach((function(o){if(Reflect.has(t,o)){var i=t[o];co(i)&&co(i.value)&&co(i.setValueAtTime)?n[o]=i.value:i instanceof e?n[o]=i._getPartialProperties(n[o]):mo(i)||ho(i)||yo(i)||fo(i)?n[o]=i:delete n[o]}})),n},e.prototype.set=function(t){var n=this;return Object.keys(t).forEach((function(o){Reflect.has(n,o)&&co(n[o])&&(n[o]&&co(n[o].value)&&co(n[o].setValueAtTime)?n[o].value!==t[o]&&(n[o].value=t[o]):n[o]instanceof e?n[o].set(t[o]):n[o]=t[o])})),this},e}(Mo),gi=function(t){function e(e){void 0===e&&(e="stopped");var n=t.call(this)||this;return n.name="StateTimeline",n._initial=e,n.setStateAtTime(n._initial,0),n}return Yn(e,t),e.prototype.getValueAtTime=function(t){var e=this.get(t);return null!==e?e.state:this._initial},e.prototype.setStateAtTime=function(t,e,n){return no(e,0),this.add(Object.assign({},n,{state:t,time:e})),this},e.prototype.getLastState=function(t,e){for(var n=this._search(e);n>=0;n--){var o=this._timeline[n];if(o.state===t)return o}},e.prototype.getNextState=function(t,e){var n=this._search(e);if(-1!==n)for(var o=n;o0,"timeConstant must be a number greater than 0");var i=this.toSeconds(e);return this._assertRange(o),eo(isFinite(o)&&isFinite(i),"Invalid argument(s) to setTargetAtTime: "+JSON.stringify(t)+", "+JSON.stringify(e)),this._events.add({constant:n,time:i,type:"setTargetAtTime",value:o}),this.log(this.units,"setTargetAtTime",t,i,n),this._param.setTargetAtTime(o,i,n),this},e.prototype.setValueCurveAtTime=function(t,e,n,o){void 0===o&&(o=1),n=this.toSeconds(n),e=this.toSeconds(e);var i=this._fromType(t[0])*o;this.setValueAtTime(this._toType(i),e);for(var r=n/(t.length-1),s=1;s0,"ToneAudioNode does not have any internal nodes");var e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}},Object.defineProperty(e.prototype,"channelCount",{get:function(){return this._getChannelProperties().channelCount},set:function(t){var e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"channelCountMode",{get:function(){return this._getChannelProperties().channelCountMode},set:function(t){var e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"channelInterpretation",{get:function(){return this._getChannelProperties().channelInterpretation},set:function(t){var e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))},enumerable:!0,configurable:!0}),e.prototype.connect=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),wi(this,t,e,n),this},e.prototype.toDestination=function(){return this.connect(this.context.destination),this},e.prototype.toMaster=function(){return ao("toMaster() has been renamed toDestination()"),this.toDestination()},e.prototype.disconnect=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),Ti(this,t,e,n),this},e.prototype.chain=function(){for(var t=[],e=0;e0,"Cannot connect to node with no inputs"),eo(t.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof bi||e instanceof vi;)co(e.input)&&(e=e.input);for(;t instanceof bi;)co(t.output)&&(t=t.output);xo(e)?t.connect(e,n):t.connect(e,n,o)}function Ti(t,e,n,o){if(void 0===n&&(n=0),void 0===o&&(o=0),co(e))for(;e instanceof bi;)e=e.input;for(;!wo(t);)co(t.output)&&(t=t.output);xo(e)?t.disconnect(e,n):wo(e)?t.disconnect(e,n,o):t.disconnect()}var Oi=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["gain","units"]))||this;n.name="Gain",n._gainNode=n.context.createGain(),n.input=n._gainNode,n.output=n._gainNode;var o=Ao(e.getDefaults(),arguments,["gain","units"]);return n.gain=new vi({context:n.context,convert:o.convert,param:n._gainNode.gain,units:o.units,value:o.gain,minValue:o.minValue,maxValue:o.maxValue}),Xo(n,"gain"),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(bi.getDefaults(),{convert:!0,gain:1,units:"gain"})},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._gainNode.disconnect(),this.gain.dispose(),this},e}(bi),Si=function(t){function e(e){var n=t.call(this,e)||this;return n.onended=Qo,n._startTime=-1,n._stopTime=-1,n._timeout=-1,n.output=new Oi({context:n.context,gain:0}),n._gainNode=n.output,n.getStateAtTime=function(t){var e=this.toSeconds(t);return-1!==this._startTime&&e>=this._startTime&&(-1===this._stopTime||e<=this._stopTime)?"started":"stopped"},n._fadeIn=e.fadeIn,n._fadeOut=e.fadeOut,n._curve=e.curve,n.onended=e.onended,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(bi.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:Qo})},e.prototype._startGain=function(t,e){void 0===e&&(e=1),eo(-1===this._startTime,"Source cannot be started more than once");var n=this.toSeconds(this._fadeIn);return this._startTime=t+n,this._startTime=Math.max(this._startTime,this.context.currentTime),n>0?(this._gainNode.gain.setValueAtTime(0,t),"linear"===this._curve?this._gainNode.gain.linearRampToValueAtTime(e,t+n):this._gainNode.gain.exponentialApproachValueAtTime(e,t,n)):this._gainNode.gain.setValueAtTime(e,t),this},e.prototype.stop=function(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this},e.prototype._stopGain=function(t){var e=this;eo(-1!==this._startTime,"'start' must be called before 'stop'"),this.cancelStop();var n=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(t)+n,this._stopTime=Math.max(this._stopTime,this.context.currentTime),n>0?"linear"===this._curve?this._gainNode.gain.linearRampTo(0,n,t):this._gainNode.gain.targetRampTo(0,n,t):(this._gainNode.gain.cancelAndHoldAtTime(t),this._gainNode.gain.setValueAtTime(0,t)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout((function(){var t="exponential"===e._curve?2*n:0;e._stopSource(e.now()+t),e._onended()}),this._stopTime-this.context.now()),this},e.prototype._onended=function(){var t=this;this.onended!==Qo&&(this.onended(this),this.onended=Qo,this.context.isOffline||setTimeout((function(){return t.dispose()}),1e3))},Object.defineProperty(e.prototype,"state",{get:function(){return this.getStateAtTime(this.now())},enumerable:!0,configurable:!0}),e.prototype.cancelStop=function(){return this.log("cancelStop"),eo(-1!==this._startTime,"Source is not started"),this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this.context.clearTimeout(this._timeout),this._stopTime=-1,this},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._gainNode.disconnect(),this},e}(bi),ki=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["offset"]))||this;n.name="ToneConstantSource",n._source=n.context.createConstantSource();var o=Ao(e.getDefaults(),arguments,["offset"]);return wi(n._source,n._gainNode),n.offset=new vi({context:n.context,convert:o.convert,param:n._source.offset,units:o.units,value:o.offset,minValue:o.minValue,maxValue:o.maxValue}),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Si.getDefaults(),{convert:!0,offset:1,units:"number"})},e.prototype.start=function(t){var e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._source.start(e),this},e.prototype._stopSource=function(t){this._source.stop(t)},e.prototype.dispose=function(){return t.prototype.dispose.call(this),"started"===this.state&&this.stop(),this._source.disconnect(),this.offset.dispose(),this},e}(Si),Ci=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["value","units"]))||this;n.name="Signal",n.override=!0;var o=Ao(e.getDefaults(),arguments,["value","units"]);return n.output=n._constantSource=new ki({context:n.context,convert:o.convert,offset:o.value,units:o.units,minValue:o.minValue,maxValue:o.maxValue}),n._constantSource.start(0),n.input=n._param=n._constantSource.offset,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(bi.getDefaults(),{convert:!0,units:"number",value:0})},e.prototype.connect=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),Ai(this,t,e,n),this},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._param.dispose(),this._constantSource.dispose(),this},e.prototype.setValueAtTime=function(t,e){return this._param.setValueAtTime(t,e),this},e.prototype.getValueAtTime=function(t){return this._param.getValueAtTime(t)},e.prototype.setRampPoint=function(t){return this._param.setRampPoint(t),this},e.prototype.linearRampToValueAtTime=function(t,e){return this._param.linearRampToValueAtTime(t,e),this},e.prototype.exponentialRampToValueAtTime=function(t,e){return this._param.exponentialRampToValueAtTime(t,e),this},e.prototype.exponentialRampTo=function(t,e,n){return this._param.exponentialRampTo(t,e,n),this},e.prototype.linearRampTo=function(t,e,n){return this._param.linearRampTo(t,e,n),this},e.prototype.targetRampTo=function(t,e,n){return this._param.targetRampTo(t,e,n),this},e.prototype.exponentialApproachValueAtTime=function(t,e,n){return this._param.exponentialApproachValueAtTime(t,e,n),this},e.prototype.setTargetAtTime=function(t,e,n){return this._param.setTargetAtTime(t,e,n),this},e.prototype.setValueCurveAtTime=function(t,e,n,o){return this._param.setValueCurveAtTime(t,e,n,o),this},e.prototype.cancelScheduledValues=function(t){return this._param.cancelScheduledValues(t),this},e.prototype.cancelAndHoldAtTime=function(t){return this._param.cancelAndHoldAtTime(t),this},e.prototype.rampTo=function(t,e,n){return this._param.rampTo(t,e,n),this},Object.defineProperty(e.prototype,"value",{get:function(){return this._param.value},set:function(t){this._param.value=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"convert",{get:function(){return this._param.convert},set:function(t){this._param.convert=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"units",{get:function(){return this._param.units},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"overridden",{get:function(){return this._param.overridden},set:function(t){this._param.overridden=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxValue",{get:function(){return this._param.maxValue},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minValue",{get:function(){return this._param.minValue},enumerable:!0,configurable:!0}),e.prototype.apply=function(t){return this._param.apply(t),this},e}(bi);function Ai(t,e,n,o){(e instanceof vi||xo(e)||e instanceof Ci&&e.override)&&(e.cancelScheduledValues(0),e.setValueAtTime(0,0),e instanceof Ci&&(e.overridden=!0)),wi(t,e,n,o)}var Di=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["value"]))||this;n.name="TickParam",n._events=new Fo(1/0),n._multiplier=1;var o=Ao(e.getDefaults(),arguments,["value"]);return n._multiplier=o.multiplier,n._events.cancel(0),n._events.add({ticks:0,time:0,type:"setValueAtTime",value:n._fromType(o.value)}),n.setValueAtTime(o.value,0),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(vi.getDefaults(),{multiplier:1,units:"hertz",value:1})},e.prototype.setTargetAtTime=function(t,e,n){e=this.toSeconds(e),this.setRampPoint(e);for(var o=this._fromType(t),i=this._events.get(e),r=Math.round(Math.max(1/n,1)),s=0;s<=r;s++){var a=n*s+e,u=this._exponentialApproach(i.time,i.value,o,n,a);this.linearRampToValueAtTime(this._toType(u),a)}return this},e.prototype.setValueAtTime=function(e,n){var o=this.toSeconds(n);t.prototype.setValueAtTime.call(this,e,n);var i=this._events.get(o),r=this._events.previousEvent(i),s=this._getTicksUntilEvent(r,o);return i.ticks=Math.max(s,0),this},e.prototype.linearRampToValueAtTime=function(e,n){var o=this.toSeconds(n);t.prototype.linearRampToValueAtTime.call(this,e,n);var i=this._events.get(o),r=this._events.previousEvent(i),s=this._getTicksUntilEvent(r,o);return i.ticks=Math.max(s,0),this},e.prototype.exponentialRampToValueAtTime=function(t,e){e=this.toSeconds(e);for(var n=this._fromType(t),o=this._events.get(e),i=Math.round(Math.max(10*(e-o.time),1)),r=(e-o.time)/i,s=0;s<=i;s++){var a=r*s+o.time,u=this._exponentialInterpolate(o.time,o.value,e,n,a);this.linearRampToValueAtTime(this._toType(u),a)}return this},e.prototype._getTicksUntilEvent=function(t,e){if(null===t)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(uo(t.ticks)){var n=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(n,t.time)}var o=this._fromType(this.getValueAtTime(t.time)),i=this._fromType(this.getValueAtTime(e)),r=this._events.get(e);return r&&r.time===e&&"setValueAtTime"===r.type&&(i=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(o+i)+t.ticks},e.prototype.getTicksAtTime=function(t){var e=this.toSeconds(t),n=this._events.get(e);return Math.max(this._getTicksUntilEvent(n,e),0)},e.prototype.getDurationOfTicks=function(t,e){var n=this.toSeconds(e),o=this.getTicksAtTime(e);return this.getTimeOfTick(o+t)-n},e.prototype.getTimeOfTick=function(t){var e=this._events.get(t,"ticks"),n=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&n&&"linearRampToValueAtTime"===n.type&&e.value!==n.value){var o=this._fromType(this.getValueAtTime(e.time)),i=(this._fromType(this.getValueAtTime(n.time))-o)/(n.time-e.time),r=Math.sqrt(Math.pow(o,2)-2*i*(e.ticks-t)),s=(-o+r)/i;return(s>0?s:(-o-r)/i)+e.time}return e?0===e.value?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue},e.prototype.ticksToTime=function(t,e){return this.getDurationOfTicks(t,e)},e.prototype.timeToTicks=function(t,e){var n=this.toSeconds(e),o=this.toSeconds(t),i=this.getTicksAtTime(n);return this.getTicksAtTime(n+o)-i},e.prototype._fromType=function(e){return"bpm"===this.units&&this.multiplier?1/(60/e/this.multiplier):t.prototype._fromType.call(this,e)},e.prototype._toType=function(e){return"bpm"===this.units&&this.multiplier?e/this.multiplier*60:t.prototype._toType.call(this,e)},Object.defineProperty(e.prototype,"multiplier",{get:function(){return this._multiplier},set:function(t){var e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)},enumerable:!0,configurable:!0}),e}(vi),Ei=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["value"]))||this;n.name="TickSignal";var o=Ao(e.getDefaults(),arguments,["value"]);return n.input=n._param=new Di({context:n.context,convert:o.convert,multiplier:o.multiplier,param:n._constantSource.offset,units:o.units,value:o.value}),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Ci.getDefaults(),{multiplier:1,units:"hertz",value:1})},e.prototype.ticksToTime=function(t,e){return this._param.ticksToTime(t,e)},e.prototype.timeToTicks=function(t,e){return this._param.timeToTicks(t,e)},e.prototype.getTimeOfTick=function(t){return this._param.getTimeOfTick(t)},e.prototype.getDurationOfTicks=function(t,e){return this._param.getDurationOfTicks(t,e)},e.prototype.getTicksAtTime=function(t){return this._param.getTicksAtTime(t)},Object.defineProperty(e.prototype,"multiplier",{get:function(){return this._param.multiplier},set:function(t){this._param.multiplier=t},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._param.dispose(),this},e}(Ci),Mi=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["frequency"]))||this;n.name="TickSource",n._state=new gi,n._tickOffset=new Fo;var o=Ao(e.getDefaults(),arguments,["frequency"]);return n.frequency=new Ei({context:n.context,units:o.units,value:o.frequency}),Xo(n,"frequency"),n._state.setStateAtTime("stopped",0),n.setTicksAtTime(0,0),n}return Yn(e,t),e.getDefaults=function(){return Object.assign({frequency:1,units:"hertz"},_i.getDefaults())},Object.defineProperty(e.prototype,"state",{get:function(){return this.getStateAtTime(this.now())},enumerable:!0,configurable:!0}),e.prototype.start=function(t,e){var n=this.toSeconds(t);return"started"!==this._state.getValueAtTime(n)&&(this._state.setStateAtTime("started",n),co(e)&&this.setTicksAtTime(e,n)),this},e.prototype.stop=function(t){var e=this.toSeconds(t);if("stopped"===this._state.getValueAtTime(e)){var n=this._state.get(e);n&&n.time>0&&(this._tickOffset.cancel(n.time),this._state.cancel(n.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this},e.prototype.pause=function(t){var e=this.toSeconds(t);return"started"===this._state.getValueAtTime(e)&&this._state.setStateAtTime("paused",e),this},e.prototype.cancel=function(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this},e.prototype.getTicksAtTime=function(t){var e=this,n=this.toSeconds(t),o=this._state.getLastState("stopped",n),i={state:"paused",time:n};this._state.add(i);var r=o,s=0;return this._state.forEachBetween(o.time,n+this.sampleTime,(function(t){var n=r.time,o=e._tickOffset.get(t.time);o&&o.time>=r.time&&(s=o.ticks,n=o.time),"started"===r.state&&"started"!==t.state&&(s+=e.frequency.getTicksAtTime(t.time)-e.frequency.getTicksAtTime(n)),r=t})),this._state.remove(i),s},Object.defineProperty(e.prototype,"ticks",{get:function(){return this.getTicksAtTime(this.now())},set:function(t){this.setTicksAtTime(t,this.now())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"seconds",{get:function(){return this.getSecondsAtTime(this.now())},set:function(t){var e=this.now(),n=this.frequency.timeToTicks(t,e);this.setTicksAtTime(n,e)},enumerable:!0,configurable:!0}),e.prototype.getSecondsAtTime=function(t){var e=this;t=this.toSeconds(t);var n=this._state.getLastState("stopped",t),o={state:"paused",time:t};this._state.add(o);var i=n,r=0;return this._state.forEachBetween(n.time,t+this.sampleTime,(function(t){var n=i.time,o=e._tickOffset.get(t.time);o&&o.time>=i.time&&(r=o.seconds,n=o.time),"started"===i.state&&"started"!==t.state&&(r+=t.time-n),i=t})),this._state.remove(o),r},e.prototype.setTicksAtTime=function(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(t,e),ticks:t,time:e}),this},e.prototype.getStateAtTime=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)},e.prototype.getTimeOfTick=function(t,e){void 0===e&&(e=this.now());var n=this._tickOffset.get(e),o=this._state.get(e),i=Math.max(n.time,o.time),r=this.frequency.getTicksAtTime(i)+t-n.ticks;return this.frequency.getTimeOfTick(r)},e.prototype.forEachTickBetween=function(t,e,n){var o=this,i=this._state.get(t);this._state.forEachBetween(t,e,(function(e){i&&"started"===i.state&&"started"!==e.state&&o.forEachTickBetween(Math.max(i.time,t),e.time-o.sampleTime,n),i=e}));var r=null;if(i&&"started"===i.state)for(var s=Math.max(i.time,t),a=this.frequency.getTicksAtTime(s),u=a-this.frequency.getTicksAtTime(i.time),c=Math.ceil(u)-u,l=this.frequency.getTimeOfTick(a+c);l0)if(null===t.left.right)(e=t.left).right=t.right,n=e;else{for(e=t.left.right;null!==e.right;)e=e.right;e.parent&&(e.parent.right=e.left,n=e.parent,e.left=t.left,e.right=t.right)}else if(null===t.right.left)(e=t.right).left=t.left,n=e;else{for(e=t.right.left;null!==e.left;)e=e.left;e.parent&&(e.parent.left=e.right,n=e.parent,e.left=t.left,e.right=t.right)}null!==t.parent?t.isLeftChild()?t.parent.left=e:t.parent.right=e:this._setRoot(e),n&&this._rebalance(n)}t.dispose()},e.prototype._rotateLeft=function(t){var e=t.parent,n=t.isLeftChild(),o=t.right;o&&(t.right=o.left,o.left=t),null!==e?n?e.left=o:e.right=o:this._setRoot(o)},e.prototype._rotateRight=function(t){var e=t.parent,n=t.isLeftChild(),o=t.left;o&&(t.left=o.right,o.right=t),null!==e?n?e.left=o:e.right=o:this._setRoot(o)},e.prototype._rebalance=function(t){var e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))},e.prototype.get=function(t){if(null!==this._root){var e=[];if(this._root.search(t,e),e.length>0){for(var n=e[0],o=1;on.low&&(n=e[o]);return n.event}}return null},e.prototype.forEach=function(t){if(null!==this._root){var e=[];this._root.traverse((function(t){return e.push(t)})),e.forEach((function(e){e.event&&t(e.event)}))}return this},e.prototype.forEachAtTime=function(t,e){if(null!==this._root){var n=[];this._root.search(t,n),n.forEach((function(t){t.event&&e(t.event)}))}return this},e.prototype.forEachFrom=function(t,e){if(null!==this._root){var n=[];this._root.searchAfter(t,n),n.forEach((function(t){t.event&&e(t.event)}))}return this},e.prototype.dispose=function(){return t.prototype.dispose.call(this),null!==this._root&&this._root.traverse((function(t){return t.dispose()})),this._root=null,this},e}(Mo),Vi=function(){function t(t,e,n){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=n,this.low=t,this.high=e,this.max=this.high}return t.prototype.insert=function(t){t.low<=this.low?null===this.left?this.left=t:this.left.insert(t):null===this.right?this.right=t:this.right.insert(t)},t.prototype.search=function(t,e){t>this.max||(null!==this.left&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),this.low>t||null!==this.right&&this.right.search(t,e))},t.prototype.searchAfter=function(t,e){this.low>=t&&(e.push(this),null!==this.left&&this.left.searchAfter(t,e)),null!==this.right&&this.right.searchAfter(t,e)},t.prototype.traverse=function(t){t(this),null!==this.left&&this.left.traverse(t),null!==this.right&&this.right.traverse(t)},t.prototype.updateHeight=function(){null!==this.left&&null!==this.right?this.height=Math.max(this.left.height,this.right.height)+1:null!==this.right?this.height=this.right.height+1:null!==this.left?this.height=this.left.height+1:this.height=0},t.prototype.updateMax=function(){this.max=this.high,null!==this.left&&(this.max=Math.max(this.max,this.left.max)),null!==this.right&&(this.max=Math.max(this.max,this.right.max))},t.prototype.getBalance=function(){var t=0;return null!==this.left&&null!==this.right?t=this.left.height-this.right.height:null!==this.left?t=this.left.height+1:null!==this.right&&(t=-(this.right.height+1)),t},t.prototype.isLeftChild=function(){return null!==this.parent&&this.parent.left===this},Object.defineProperty(t.prototype,"left",{get:function(){return this._left},set:function(t){this._left=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._right},set:function(t){this._right=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.parent=null,this._left=null,this._right=null,this.event=null},t}(),Fi=function(){function t(e,n){this.id=t._eventId++;var o=Object.assign(t.getDefaults(),n);this.transport=e,this.callback=o.callback,this._once=o.once,this.time=o.time}return t.getDefaults=function(){return{callback:Qo,once:!1,time:0}},t.prototype.invoke=function(t){this.callback&&(this.callback(t),this._once&&this.transport.clear(this.id))},t.prototype.dispose=function(){return this.callback=void 0,this},t._eventId=0,t}(),Ni=function(t){function e(n,o){var i=t.call(this,n,o)||this;i._currentId=-1,i._nextId=-1,i._nextTick=i.time,i._boundRestart=i._restart.bind(i);var r=Object.assign(e.getDefaults(),o);return i.duration=new ji(n.context,r.duration).valueOf(),i._interval=new ji(n.context,r.interval).valueOf(),i._nextTick=r.time,i.transport.on("start",i._boundRestart),i.transport.on("loopStart",i._boundRestart),i.context=i.transport.context,i._restart(),i}return Yn(e,t),e.getDefaults=function(){return Object.assign({},Fi.getDefaults(),{duration:1/0,interval:1,once:!1})},e.prototype.invoke=function(e){this._createEvents(e),t.prototype.invoke.call(this,e)},e.prototype._createEvents=function(t){var e=this.transport.getTicksAtTime(t);e>=this.time&&e>=this._nextTick&&this._nextTick+this._intervalthis.time&&(this._nextTick=this.time+Math.ceil((e-this.time)/this._interval)*this._interval),this._currentId=this.transport.scheduleOnce(this.invoke.bind(this),new ji(this.context,this._nextTick).toSeconds()),this._nextTick+=this._interval,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new ji(this.context,this._nextTick).toSeconds())},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this},e}(Fi),Li=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments))||this;n.name="Transport",n._loop=new Ri(!1),n._loopStart=0,n._loopEnd=0,n._scheduledEvents={},n._timeline=new Fo,n._repeatedEvents=new Ii,n._syncedSignals=[],n._swingAmount=0;var o=Ao(e.getDefaults(),arguments);return n._ppq=o.ppq,n._clock=new Pi({callback:n._processTick.bind(n),context:n.context,frequency:0,units:"bpm"}),n._bindClockEvents(),n.bpm=n._clock.frequency,n._clock.frequency.multiplier=o.ppq,n.bpm.setValueAtTime(o.bpm,0),Xo(n,"bpm"),n._timeSignature=o.timeSignature,n._swingTicks=o.ppq/2,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(_i.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})},e.prototype._processTick=function(t,e){if(this._swingAmount>0&&e%this._ppq!=0&&e%(2*this._swingTicks)!=0){var n=e%(2*this._swingTicks)/(2*this._swingTicks),o=Math.sin(n*Math.PI)*this._swingAmount;t+=new ji(this.context,2*this._swingTicks/3).toSeconds()*o}this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._timeline.forEachAtTime(e,(function(e){return e.invoke(t)}))},e.prototype.schedule=function(t,e){var n=new Fi(this,{callback:t,time:new mi(this.context,e).toTicks()});return this._addEvent(n,this._timeline)},e.prototype.scheduleRepeat=function(t,e,n,o){void 0===o&&(o=1/0);var i=new Ni(this,{callback:t,duration:new ci(this.context,o).toTicks(),interval:new ci(this.context,e).toTicks(),time:new mi(this.context,n).toTicks()});return this._addEvent(i,this._repeatedEvents)},e.prototype.scheduleOnce=function(t,e){var n=new Fi(this,{callback:t,once:!0,time:new mi(this.context,e).toTicks()});return this._addEvent(n,this._timeline)},e.prototype.clear=function(t){if(this._scheduledEvents.hasOwnProperty(t)){var e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this},e.prototype._addEvent=function(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id},e.prototype.cancel=function(t){var e=this;void 0===t&&(t=0);var n=this.toTicks(t);return this._timeline.forEachFrom(n,(function(t){return e.clear(t.id)})),this._repeatedEvents.forEachFrom(n,(function(t){return e.clear(t.id)})),this},e.prototype._bindClockEvents=function(){var t=this;this._clock.on("start",(function(e,n){n=new ji(t.context,n).toSeconds(),t.emit("start",e,n)})),this._clock.on("stop",(function(e){t.emit("stop",e)})),this._clock.on("pause",(function(e){t.emit("pause",e)}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._clock.getStateAtTime(this.now())},enumerable:!0,configurable:!0}),e.prototype.start=function(t,e){var n;return co(e)&&(n=this.toTicks(e)),this._clock.start(t,n),this},e.prototype.stop=function(t){return this._clock.stop(t),this},e.prototype.pause=function(t){return this._clock.pause(t),this},e.prototype.toggle=function(t){return t=this.toSeconds(t),"started"!==this._clock.getStateAtTime(t)?this.start(t):this.stop(t),this},Object.defineProperty(e.prototype,"timeSignature",{get:function(){return this._timeSignature},set:function(t){mo(t)&&(t=t[0]/t[1]*4),this._timeSignature=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loopStart",{get:function(){return new ci(this.context,this._loopStart,"i").toSeconds()},set:function(t){this._loopStart=this.toTicks(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loopEnd",{get:function(){return new ci(this.context,this._loopEnd,"i").toSeconds()},set:function(t){this._loopEnd=this.toTicks(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loop",{get:function(){return this._loop.get(this.now())},set:function(t){this._loop.set(t,this.now())},enumerable:!0,configurable:!0}),e.prototype.setLoopPoints=function(t,e){return this.loopStart=t,this.loopEnd=e,this},Object.defineProperty(e.prototype,"swing",{get:function(){return this._swingAmount},set:function(t){this._swingAmount=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"swingSubdivision",{get:function(){return new ji(this.context,this._swingTicks).toNotation()},set:function(t){this._swingTicks=this.toTicks(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){var t=this.now(),e=this._clock.getTicksAtTime(t);return new ji(this.context,e).toBarsBeatsSixteenths()},set:function(t){var e=this.toTicks(t);this.ticks=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"seconds",{get:function(){return this._clock.seconds},set:function(t){var e=this.now(),n=this._clock.frequency.timeToTicks(t,e);this.ticks=n},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"progress",{get:function(){if(this.loop){var t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ticks",{get:function(){return this._clock.ticks},set:function(t){if(this._clock.ticks!==t){var e=this.now();if("started"===this.state){var n=this._clock.getTicksAtTime(e),o=this._clock.getTimeOfTick(Math.ceil(n));this.emit("stop",o),this._clock.setTicksAtTime(t,o),this.emit("start",o,this._clock.getSecondsAtTime(o))}else this._clock.setTicksAtTime(t,e)}},enumerable:!0,configurable:!0}),e.prototype.getTicksAtTime=function(t){return Math.round(this._clock.getTicksAtTime(t))},e.prototype.getSecondsAtTime=function(t){return this._clock.getSecondsAtTime(t)},Object.defineProperty(e.prototype,"PPQ",{get:function(){return this._clock.frequency.multiplier},set:function(t){this._clock.frequency.multiplier=t},enumerable:!0,configurable:!0}),e.prototype.nextSubdivision=function(t){if(t=this.toTicks(t),"started"!==this.state)return 0;var e=this.now(),n=t-this.getTicksAtTime(e)%t;return this._clock.nextTickTime(n,e)},e.prototype.syncSignal=function(t,e){if(!e){var n=this.now();if(0!==t.getValueAtTime(n)){var o=1/(60/this.bpm.getValueAtTime(n)/this.PPQ);e=t.getValueAtTime(n)/o}else e=0}var i=new Oi(e);return this.bpm.connect(i),i.connect(t._param),this._syncedSignals.push({initial:t.value,ratio:i,signal:t}),t.value=0,this},e.prototype.unsyncSignal=function(t){for(var e=this._syncedSignals.length-1;e>=0;e--){var n=this._syncedSignals[e];n.signal===t&&(n.ratio.dispose(),n.signal.value=n.initial,this._syncedSignals.splice(e,1))}return this},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._clock.dispose(),Yo(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this},e}(_i);Uo.mixin(Li),Lo((function(t){t.transport=new Li({context:t})})),Bo((function(t){t.transport.dispose()}));var zi=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["delayTime","maxDelay"]))||this;n.name="Delay";var o=Ao(e.getDefaults(),arguments,["delayTime","maxDelay"]),i=n.toSeconds(o.maxDelay);return n._maxDelay=Math.max(i,n.toSeconds(o.delayTime)),n._delayNode=n.input=n.output=n.context.createDelay(i),n.delayTime=new vi({context:n.context,param:n._delayNode.delayTime,units:"time",value:o.delayTime,minValue:0,maxValue:n.maxDelay}),Xo(n,"delayTime"),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(bi.getDefaults(),{delayTime:0,maxDelay:1})},Object.defineProperty(e.prototype,"maxDelay",{get:function(){return this._maxDelay},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._delayNode.disconnect(),this.delayTime.dispose(),this},e}(bi),Bi=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["volume"]))||this;n.name="Volume";var o=Ao(e.getDefaults(),arguments,["volume"]);return n.input=n.output=new Oi({context:n.context,gain:o.volume,units:"decibels"}),n.volume=n.output.gain,Xo(n,"volume"),n._unmutedVolume=o.volume,n.mute=o.mute,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(bi.getDefaults(),{mute:!1,volume:0})},Object.defineProperty(e.prototype,"mute",{get:function(){return this.volume.value===-1/0},set:function(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.input.dispose(),this.volume.dispose(),this},e}(bi),Ui=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments))||this;n.name="Destination",n.input=new Bi({context:n.context}),n.output=new Oi({context:n.context}),n.volume=n.input.volume;var o=Ao(e.getDefaults(),arguments);return xi(n.input,n.output,n.context.rawContext.destination),n.mute=o.mute,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(bi.getDefaults(),{mute:!1,volume:0})},Object.defineProperty(e.prototype,"mute",{get:function(){return this.input.mute},set:function(t){this.input.mute=t},enumerable:!0,configurable:!0}),e.prototype.chain=function(){for(var t=[],e=0;e0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this},e}(_i);Lo((function(t){t.draw=new Yi({context:t})})),Bo((function(t){t.draw.dispose()}));var Qi=n(1),Zi=function(t){function e(e){var n=t.call(this,e)||this;return n.input=void 0,n._state=new gi("stopped"),n._synced=!1,n._scheduled=[],n._syncedStart=Qo,n._syncedStop=Qo,n._state.memory=100,n._state.increasing=!0,n._volume=n.output=new Bi({context:n.context,mute:e.mute,volume:e.volume}),n.volume=n._volume.volume,Xo(n,"volume"),n.onstop=e.onstop,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(bi.getDefaults(),{mute:!1,onstop:Qo,volume:0})},Object.defineProperty(e.prototype,"state",{get:function(){return this._synced?"started"===this.context.transport.state?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mute",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t},enumerable:!0,configurable:!0}),e.prototype._clampToCurrentTime=function(t){return this._synced?t:Math.max(t,this.context.currentTime)},e.prototype.start=function(t,e,n){var o=this,i=uo(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(i=this._clampToCurrentTime(i),"started"===this._state.getValueAtTime(i))eo(Ro(i,this._state.get(i).time),"Start time must be strictly greater than previous start time"),this._state.cancel(i),this._state.setStateAtTime("started",i),this.log("restart",i),this.restart(i,e,n);else{if(this.log("start",i),this._state.setStateAtTime("started",i),this._synced){var r=this._state.get(i);r&&(r.offset=this.toSeconds(Do(e,0)),r.duration=n?this.toSeconds(n):void 0);var s=this.context.transport.schedule((function(t){o._start(t,e,n)}),i);this._scheduled.push(s),"started"===this.context.transport.state&&this._syncedStart(this.now(),this.context.transport.seconds)}else this._start(i,e,n);oo(this.context)}return this},e.prototype.stop=function(t){var e=uo(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),"started"===this._state.getValueAtTime(e)||co(this._state.getNextState("started",e))){if(this.log("stop",e),this._synced){var n=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(n)}else this._stop(e);this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this},e.prototype.restart=function(t,e,n){return t=this.toSeconds(t),"started"===this._state.getValueAtTime(t)&&(this._state.cancel(t),this._restart(t,e,n)),this},e.prototype.sync=function(){var t=this;return this._synced||(this._synced=!0,this._syncedStart=function(e,n){if(n>0){var o=t._state.get(n);if(o&&"started"===o.state&&o.time!==n){var i=n-t.toSeconds(o.time),r=void 0;o.duration&&(r=t.toSeconds(o.duration)-i),t._start(e,t.toSeconds(o.offset)+i,r)}}},this._syncedStop=function(e){var n=t.context.transport.getSecondsAtTime(Math.max(e-t.sampleTime,0));"started"===t._state.getValueAtTime(n)&&t._stop(e)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this},e.prototype.unsync=function(){var t=this;return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach((function(e){return t.context.transport.clear(e)})),this._scheduled=[],this._state.cancel(0),this},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.onstop=Qo,this.unsync(),this._volume.dispose(),this._state.dispose(),this},e}(bi),$i=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["buffer","onload"]))||this;n.name="ToneBufferSource",n._source=n.context.createBufferSource(),n._internalChannels=[n._source],n._sourceStarted=!1,n._sourceStopped=!1;var o=Ao(e.getDefaults(),arguments,["buffer","onload"]);return wi(n._source,n._gainNode),n._source.onended=function(){return n._stopSource()},n.playbackRate=new vi({context:n.context,param:n._source.playbackRate,units:"positive",value:o.playbackRate}),n.loop=o.loop,n.loopStart=o.loopStart,n.loopEnd=o.loopEnd,n._buffer=new Zo(o.buffer,o.onload),n._internalChannels.push(n._source),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Si.getDefaults(),{buffer:new Zo,loop:!1,loopEnd:0,loopStart:0,onload:Qo,playbackRate:1})},Object.defineProperty(e.prototype,"fadeIn",{get:function(){return this._fadeIn},set:function(t){this._fadeIn=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fadeOut",{get:function(){return this._fadeOut},set:function(t){this._fadeOut=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"curve",{get:function(){return this._curve},set:function(t){this._curve=t},enumerable:!0,configurable:!0}),e.prototype.start=function(t,e,n,o){void 0===o&&(o=1),eo(this.buffer.loaded,"buffer is either not set or not loaded");var i=this.toSeconds(t);this._startGain(i,o),e=this.loop?Do(e,this.loopStart):Do(e,0);var r=Math.max(this.toSeconds(e),0);if(this.loop){var s=this.toSeconds(this.loopEnd)||this.buffer.duration,a=this.toSeconds(this.loopStart),u=s-a;jo(r,s)&&(r=(r-a)%u+a)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,qo(r,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(i,r)),co(n)){var c=this.toSeconds(n);c=Math.max(c,0),this.stop(i+c)}return this},e.prototype._stopSource=function(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())},Object.defineProperty(e.prototype,"loopStart",{get:function(){return this._source.loopStart},set:function(t){this._source.loopStart=this.toSeconds(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loopEnd",{get:function(){return this._source.loopEnd},set:function(t){this._source.loopEnd=this.toSeconds(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._buffer},set:function(t){this._buffer.set(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loop",{get:function(){return this._source.loop},set:function(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this},e}(Si),Ji=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["type"]))||this;n.name="Noise",n._source=null;var o=Ao(e.getDefaults(),arguments,["type"]);return n._playbackRate=o.playbackRate,n.type=o.type,n._fadeIn=o.fadeIn,n._fadeOut=o.fadeOut,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Zi.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},set:function(t){if(eo(t in tr,"Noise: invalid type: "+t),this._type!==t&&(this._type=t,"started"===this.state)){var e=this.now();this._stop(e),this._start(e)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)},enumerable:!0,configurable:!0}),e.prototype._start=function(t){var e=this,n=tr[this._type];this._source=new $i({buffer:n,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:function(){return e.onstop(e)},playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(t),Math.random()*(n.duration-.001))},e.prototype._stop=function(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)},Object.defineProperty(e.prototype,"fadeIn",{get:function(){return this._fadeIn},set:function(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fadeOut",{get:function(){return this._fadeOut},set:function(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)},enumerable:!0,configurable:!0}),e.prototype._restart=function(t){this._stop(t),this._start(t)},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._source&&this._source.disconnect(),this},e}(Zi),Ki={brown:null,pink:null,white:null},tr={get brown(){if(!Ki.brown){for(var t=[],e=0;e<2;e++){var n=new Float32Array(220500);t[e]=n;for(var o=0,i=0;i<220500;i++){var r=2*Math.random()-1;n[i]=(o+.02*r)/1.02,o=n[i],n[i]*=3.5}}Ki.brown=(new Zo).fromArray(t)}return Ki.brown},get pink(){if(!Ki.pink){for(var t=[],e=0;e<2;e++){var n=new Float32Array(220500);t[e]=n;var o=void 0,i=void 0,r=void 0,s=void 0,a=void 0,u=void 0,c=void 0;o=i=r=s=a=u=c=0;for(var l=0;l<220500;l++){var h=2*Math.random()-1;o=.99886*o+.0555179*h,i=.99332*i+.0750759*h,r=.969*r+.153852*h,s=.8665*s+.3104856*h,a=.55*a+.5329522*h,u=-.7616*u-.016898*h,n[l]=o+i+r+s+a+u+c+.5362*h,n[l]*=.11,c=.115926*h}}Ki.pink=(new Zo).fromArray(t)}return Ki.pink},get white(){if(!Ki.white){for(var t=[],e=0;e<2;e++){var n=new Float32Array(220500);t[e]=n;for(var o=0;o<220500;o++)n[o]=2*Math.random()-1}Ki.white=(new Zo).fromArray(t)}return Ki.white}},er=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["channels"]))||this;n.name="Split";var o=Ao(e.getDefaults(),arguments,["channels"]);return n._splitter=n.input=n.output=n.context.createChannelSplitter(o.channels),n._internalChannels=[n._splitter],n}return Yn(e,t),e.getDefaults=function(){return Object.assign(bi.getDefaults(),{channels:2})},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._splitter.disconnect(),this},e}(bi),nr=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["type","size"]))||this;n.name="Analyser",n._analysers=[],n._buffers=[];var o=Ao(e.getDefaults(),arguments,["type","size"]);n.input=n.output=n._gain=new Oi({context:n.context}),n._split=new er({context:n.context,channels:o.channels}),n.input.connect(n._split),no(o.channels,1);for(var i=0;i0&&(n=(1-i)/(1/n)),n0){var n=this.toSeconds(this.release);n 1) {\n\t\t\t\t\t\treturn parameter[index];\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn parameter[0];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tprocess(inputs, outputs, parameters) {\n\t\t\t\t\tconst input = inputs[0];\n\t\t\t\t\tconst output = outputs[0];\n\t\t\t\t\tconst delayLength = this.delayBuffer.length;\n\t\t\t\t\tconst inputChannel = input[0];\n\t\t\t\t\tconst outputChannel = output[0];\n\t\t\t\t\tconst delayTimeParam = parameters.delayTime;\n\t\t\t\t\tconst feedbackParam = parameters.feedback;\n\t\t\t\t\tinputChannel.forEach((value, index) => {\n\t\t\t\t\t\tconst delayTime = this.getParameter(delayTimeParam, index);\n\t\t\t\t\t\tconst feedback = this.getParameter(feedbackParam, index);\n\t\t\t\t\t\tconst delaySamples = Math.floor(delayTime * sampleRate);\n\t\t\t\t\t\tconst currentIndex = (currentFrame + index) % delayLength;\n\t\t\t\t\t\tconst delayedIndex = (currentFrame + index + delaySamples) % delayLength;\n\t\t\t\t\t\t\n\t\t\t\t\t\t// the current value to output\n\t\t\t\t\t\tconst currentValue = this.delayBuffer[currentIndex];\n\t\t\t\t\t\t\n\t\t\t\t\t\t// write the current value to the delayBuffer in the future\n\t\t\t\t\t\tthis.delayBuffer[delayedIndex] = value + currentValue * feedback;\n\n\t\t\t\t\t\t// set all of the output channels to the same value\n\t\t\t\t\t\toutputChannel[index] = delaySamples > 0 ? currentValue : value;\n\t\t\t\t\t});\n\t\t\t\t\t// keep the processing alive\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t});\n\t\t'},e.getDefaults=function(){return Object.assign(bi.getDefaults(),{delayTime:.1,resonance:.5})},e.prototype.onReady=function(t){xi(this.input,t,this.output);var e=t.parameters.get("delayTime");this.delayTime.setParam(e);var n=t.parameters.get("feedback");this.resonance.setParam(n)},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.input.dispose(),this.output.dispose(),this.delayTime.dispose(),this.resonance.dispose(),this},e}(Gr),Xr=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["delayTime","resonance","dampening"]))||this;n.name="LowpassCombFilter";var o=Ao(e.getDefaults(),arguments,["delayTime","resonance","dampening"]);return n._combFilter=n.output=new Hr({context:n.context,delayTime:o.delayTime,resonance:o.resonance}),n.delayTime=n._combFilter.delayTime,n.resonance=n._combFilter.resonance,n._lowpass=n.input=new ur({context:n.context,frequency:o.dampening,type:"lowpass"}),n._lowpass.connect(n._combFilter),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(bi.getDefaults(),{dampening:3e3,delayTime:.1,resonance:.5})},Object.defineProperty(e.prototype,"dampening",{get:function(){return this._lowpass.frequency},set:function(t){this._lowpass.frequency=t},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._combFilter.dispose(),this._lowpass.dispose(),this},e}(bi),Yr=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["url","onload"]))||this;n.name="Convolver",n._convolver=n.context.createConvolver();var o=Ao(e.getDefaults(),arguments,["url","onload"]);return n._buffer=new Zo(o.url,(function(t){n.buffer=t,o.onload()})),n.input=new Oi({context:n.context}),n.output=new Oi({context:n.context}),n._buffer.loaded&&(n.buffer=n._buffer),n.normalize=o.normalize,n.input.chain(n._convolver,n.output),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(bi.getDefaults(),{normalize:!0,onload:Qo})},e.prototype.load=function(t){return Zn(this,void 0,void 0,(function(){var e;return $n(this,(function(n){switch(n.label){case 0:return e=this,[4,this._buffer.load(t)];case 1:return e.buffer=n.sent(),[2]}}))}))},Object.defineProperty(e.prototype,"buffer",{get:function(){return this._buffer.length?this._buffer:null},set:function(t){t&&this._buffer.set(t),this._convolver.buffer&&(this.input.disconnect(),this._convolver.disconnect(),this._convolver=this.context.createConvolver(),this.input.connect(this._convolver));var e=this._buffer.get();this._convolver.buffer=e||null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"normalize",{get:function(){return this._convolver.normalize},set:function(t){this._convolver.normalize=t},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._buffer.dispose(),this._convolver.disconnect(),this},e}(bi),Qr=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["volume"]))||this;n.name="UserMedia";var o=Ao(e.getDefaults(),arguments,["volume"]);return n._volume=n.output=new Bi({context:n.context,volume:o.volume}),n.volume=n._volume.volume,Xo(n,"volume"),n.mute=o.mute,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(bi.getDefaults(),{mute:!1,volume:0})},e.prototype.open=function(t){return Zn(this,void 0,void 0,(function(){var n,o,i,r;return $n(this,(function(s){switch(s.label){case 0:return eo(e.supported,"UserMedia is not supported"),"started"===this.state&&this.close(),[4,e.enumerateDevices()];case 1:return n=s.sent(),ho(t)?this._device=n[t]:(this._device=n.find((function(e){return e.label===t||e.deviceId===t})),!this._device&&n.length>0&&(this._device=n[0]),eo(co(this._device),"No matching device "+t)),o={audio:{echoCancellation:!1,sampleRate:this.context.sampleRate,noiseSuppression:!1,mozNoiseSuppression:!1}},this._device&&(o.audio.deviceId=this._device.deviceId),[4,navigator.mediaDevices.getUserMedia(o)];case 2:return i=s.sent(),this._stream||(this._stream=i,wi(r=this.context.createMediaStreamSource(i),this.output),this._mediaStream=r),[2,this]}}))}))},e.prototype.close=function(){return this._stream&&this._mediaStream&&(this._stream.getAudioTracks().forEach((function(t){t.stop()})),this._stream=void 0,this._mediaStream.disconnect(),this._mediaStream=void 0),this._device=void 0,this},e.enumerateDevices=function(){return Zn(this,void 0,void 0,(function(){return $n(this,(function(t){switch(t.label){case 0:return[4,navigator.mediaDevices.enumerateDevices()];case 1:return[2,t.sent().filter((function(t){return"audioinput"===t.kind}))]}}))}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._stream&&this._stream.active?"started":"stopped"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"deviceId",{get:function(){return this._device?this._device.deviceId:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groupId",{get:function(){return this._device?this._device.groupId:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"label",{get:function(){return this._device?this._device.label:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mute",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.close(),this._volume.dispose(),this.volume.dispose(),this},Object.defineProperty(e,"supported",{get:function(){return co(navigator.mediaDevices)&&co(navigator.mediaDevices.getUserMedia)},enumerable:!0,configurable:!0}),e}(bi);function Zr(t,e){return Zn(this,void 0,void 0,(function(){var n,o;return $n(this,(function(i){switch(i.label){case 0:return n=e/t.context.sampleRate,o=new $o(1,n,t.context.sampleRate),new t.constructor(Object.assign(t.get(),{frequency:2/n,detune:0,context:o})).toDestination().start(0),[4,o.render()];case 1:return[2,i.sent().getChannelData(0)]}}))}))}var $r=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["frequency","type"]))||this;n.name="ToneOscillatorNode",n._oscillator=n.context.createOscillator(),n._internalChannels=[n._oscillator];var o=Ao(e.getDefaults(),arguments,["frequency","type"]);return wi(n._oscillator,n._gainNode),n.type=o.type,n.frequency=new vi({context:n.context,param:n._oscillator.frequency,units:"frequency",value:o.frequency}),n.detune=new vi({context:n.context,param:n._oscillator.detune,units:"cents",value:o.detune}),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Si.getDefaults(),{detune:0,frequency:440,type:"sine"})},e.prototype.start=function(t){var e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._oscillator.start(e),this},e.prototype._stopSource=function(t){this._oscillator.stop(t)},e.prototype.setPeriodicWave=function(t){return this._oscillator.setPeriodicWave(t),this},Object.defineProperty(e.prototype,"type",{get:function(){return this._oscillator.type},set:function(t){this._oscillator.type=t},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),"started"===this.state&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this},e}(Si),Jr=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["frequency","type"]))||this;n.name="Oscillator",n._oscillator=null;var o=Ao(e.getDefaults(),arguments,["frequency","type"]);return n.frequency=new Ci({context:n.context,units:"frequency",value:o.frequency}),Xo(n,"frequency"),n.detune=new Ci({context:n.context,units:"cents",value:o.detune}),Xo(n,"detune"),n._partials=o.partials,n._partialCount=o.partialCount,n._type=o.type,o.partialCount&&"custom"!==o.type&&(n._type=n.baseType+o.partialCount.toString()),n.phase=o.phase,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Zi.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})},e.prototype._start=function(t){var e=this,n=this.toSeconds(t),o=new $r({context:this.context,onended:function(){return e.onstop(e)}});this._oscillator=o,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(n)},e.prototype._stop=function(t){var e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)},e.prototype._restart=function(t){var e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this},e.prototype.syncFrequency=function(){return this.context.transport.syncSignal(this.frequency),this},e.prototype.unsyncFrequency=function(){return this.context.transport.unsyncSignal(this.frequency),this},e.prototype._getCachedPeriodicWave=function(){var t=this;if("custom"===this._type)return e._periodicWaveCache.find((function(e){return e.phase===t._phase&&(n=e.partials,o=t._partials,n.length===o.length&&n.every((function(t,e){return o[e]===t})));var n,o}));var n=e._periodicWaveCache.find((function(e){return e.type===t._type&&e.phase===t._phase}));return this._partialCount=n?n.partialCount:this._partialCount,n},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},set:function(t){this._type=t;var n=-1!==["sine","square","sawtooth","triangle"].indexOf(t);if(0===this._phase&&n)this._wave=void 0,this._partialCount=0,null!==this._oscillator&&(this._oscillator.type=t);else{var o=this._getCachedPeriodicWave();if(co(o)){var i=o.partials,r=o.wave;this._wave=r,this._partials=i,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave)}else{var s=Kn(this._getRealImaginary(t,this._phase),2),a=s[0],u=s[1],c=this.context.createPeriodicWave(a,u);this._wave=c,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave),e._periodicWaveCache.push({imag:u,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:a,type:this._type,wave:this._wave}),e._periodicWaveCache.length>100&&e._periodicWaveCache.shift()}}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"baseType",{get:function(){return this._type.replace(this.partialCount.toString(),"")},set:function(t){this.partialCount&&"custom"!==this._type&&"custom"!==t?this.type=t+this.partialCount:this.type=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"partialCount",{get:function(){return this._partialCount},set:function(t){no(t,0);var e=this._type,n=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(n&&(e=n[1]),"custom"!==this._type)this.type=0===t?e:e+t.toString();else{var o=new Float32Array(t);this._partials.forEach((function(t,e){return o[e]=t})),this._partials=Array.from(o),this.type=this._type}},enumerable:!0,configurable:!0}),e.prototype._getRealImaginary=function(t,e){var n=2048,o=new Float32Array(n),i=new Float32Array(n),r=1;if("custom"===t){if(r=this._partials.length+1,this._partialCount=this._partials.length,n=r,0===this._partials.length)return[o,i]}else{var s=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(t);s?(r=parseInt(s[2],10)+1,this._partialCount=parseInt(s[2],10),t=s[1],n=r=Math.max(r,2)):this._partialCount=0,this._partials=[]}for(var a=1;a>1&1?-1:1):0,this._partials[a-1]=c;break;case"custom":c=this._partials[a-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}0!==c?(o[a]=-c*Math.sin(e*a),i[a]=c*Math.cos(e*a)):(o[a]=0,i[a]=0)}return[o,i]},e.prototype._inverseFFT=function(t,e,n){for(var o=0,i=t.length,r=0;r1){var e=-t/2,n=t/(this._oscillators.length-1);this._forEach((function(t,o){return t.detune.value=e+n*o}))}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this._oscillators.length},set:function(t){var e=this;if(no(t,1),this._oscillators.length!==t){this._forEach((function(t){return t.dispose()})),this._oscillators=[];for(var n=0;nthis.buffer.duration)this.stop(t);else{var i=o0&&this.getLevelAtTime(n)>.05){var i=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(o,i,n)}else this.frequency.setValueAtTime(o,n);return this},Qn([Vr(0)],e.prototype,"portamento",void 0),e}(ds),ys=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments))||this;n.name="Synth";var o=Ao(e.getDefaults(),arguments);return n.oscillator=new ss(Object.assign({context:n.context,detune:o.detune,onstop:function(){return n.onsilence(n)}},o.oscillator)),n.frequency=n.oscillator.frequency,n.detune=n.oscillator.detune,n.envelope=new Lr(Object.assign({context:n.context},o.envelope)),n.oscillator.chain(n.envelope,n.output),Xo(n,["oscillator","frequency","detune","envelope"]),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(ms.getDefaults(),{envelope:Object.assign(Eo(Fr.getDefaults(),Object.keys(bi.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(Eo(ss.getDefaults(),to(Object.keys(Zi.getDefaults()),["frequency","detune"])),{type:"triangle"})})},e.prototype._triggerEnvelopeAttack=function(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),0===this.envelope.sustain){var n=this.toSeconds(this.envelope.attack),o=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+n+o)}},e.prototype._triggerEnvelopeRelease=function(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))},e.prototype.getLevelAtTime=function(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.oscillator.dispose(),this.envelope.dispose(),this},e}(ms),_s=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments))||this;n.name="ModulationSynth";var o=Ao(e.getDefaults(),arguments);return n._carrier=new ys({context:n.context,oscillator:o.oscillator,envelope:o.envelope,onsilence:function(){return n.onsilence(n)},volume:-10}),n._modulator=new ys({context:n.context,oscillator:o.modulation,envelope:o.modulationEnvelope,volume:-10}),n.oscillator=n._carrier.oscillator,n.envelope=n._carrier.envelope,n.modulation=n._modulator.oscillator,n.modulationEnvelope=n._modulator.envelope,n.frequency=new Ci({context:n.context,units:"frequency"}),n.detune=new Ci({context:n.context,value:o.detune,units:"cents"}),n.harmonicity=new xr({context:n.context,value:o.harmonicity,minValue:0}),n._modulationNode=new Oi({context:n.context,gain:0}),Xo(n,["frequency","harmonicity","oscillator","envelope","modulation","modulationEnvelope","detune"]),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(ms.getDefaults(),{harmonicity:3,oscillator:Object.assign(Eo(ss.getDefaults(),to(Object.keys(Zi.getDefaults()),["frequency","detune"])),{type:"sine"}),envelope:Object.assign(Eo(Fr.getDefaults(),Object.keys(bi.getDefaults())),{attack:.01,decay:.01,sustain:1,release:.5}),modulation:Object.assign(Eo(ss.getDefaults(),to(Object.keys(Zi.getDefaults()),["frequency","detune"])),{type:"square"}),modulationEnvelope:Object.assign(Eo(Fr.getDefaults(),Object.keys(bi.getDefaults())),{attack:.5,decay:0,sustain:1,release:.5})})},e.prototype._triggerEnvelopeAttack=function(t,e){this._carrier._triggerEnvelopeAttack(t,e),this._modulator._triggerEnvelopeAttack(t,e)},e.prototype._triggerEnvelopeRelease=function(t){return this._carrier._triggerEnvelopeRelease(t),this._modulator._triggerEnvelopeRelease(t),this},e.prototype.getLevelAtTime=function(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._carrier.dispose(),this._modulator.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._modulationNode.dispose(),this},e}(ms),gs=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments))||this;return n.name="AMSynth",n._modulationScale=new Kr({context:n.context}),n.frequency.connect(n._carrier.frequency),n.frequency.chain(n.harmonicity,n._modulator.frequency),n.detune.fan(n._carrier.detune,n._modulator.detune),n._modulator.chain(n._modulationScale,n._modulationNode.gain),n._carrier.chain(n._modulationNode,n.output),n}return Yn(e,t),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._modulationScale.dispose(),this},e}(_s),vs=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments))||this;n.name="MonoSynth";var o=Ao(e.getDefaults(),arguments);return n.oscillator=new ss(Object.assign(o.oscillator,{context:n.context,detune:o.detune,onstop:function(){return n.onsilence(n)}})),n.frequency=n.oscillator.frequency,n.detune=n.oscillator.detune,n.filter=new kr(Object.assign(o.filter,{context:n.context})),n.filterEnvelope=new Ur(Object.assign(o.filterEnvelope,{context:n.context})),n.envelope=new Lr(Object.assign(o.envelope,{context:n.context})),n.oscillator.chain(n.filter,n.envelope,n.output),n.filterEnvelope.connect(n.filter.frequency),Xo(n,["oscillator","frequency","detune","filter","filterEnvelope","envelope"]),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(ms.getDefaults(),{envelope:Object.assign(Eo(Fr.getDefaults(),Object.keys(bi.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.9}),filter:Object.assign(Eo(kr.getDefaults(),Object.keys(bi.getDefaults())),{Q:1,rolloff:-12,type:"lowpass"}),filterEnvelope:Object.assign(Eo(Ur.getDefaults(),Object.keys(bi.getDefaults())),{attack:.6,baseFrequency:200,decay:.2,exponent:2,octaves:3,release:2,sustain:.5}),oscillator:Object.assign(Eo(ss.getDefaults(),Object.keys(Zi.getDefaults())),{type:"sawtooth"})})},e.prototype._triggerEnvelopeAttack=function(t,e){if(void 0===e&&(e=1),this.envelope.triggerAttack(t,e),this.filterEnvelope.triggerAttack(t),this.oscillator.start(t),0===this.envelope.sustain){var n=this.toSeconds(this.envelope.attack),o=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+n+o)}},e.prototype._triggerEnvelopeRelease=function(t){this.envelope.triggerRelease(t),this.filterEnvelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))},e.prototype.getLevelAtTime=function(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.oscillator.dispose(),this.envelope.dispose(),this.filterEnvelope.dispose(),this.filter.dispose(),this},e}(ms),bs=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments))||this;n.name="DuoSynth";var o=Ao(e.getDefaults(),arguments);return n.voice0=new vs(Object.assign(o.voice0,{context:n.context,onsilence:function(){return n.onsilence(n)}})),n.voice1=new vs(Object.assign(o.voice1,{context:n.context})),n.harmonicity=new xr({context:n.context,units:"positive",value:o.harmonicity}),n._vibrato=new us({frequency:o.vibratoRate,context:n.context,min:-50,max:50}),n._vibrato.start(),n.vibratoRate=n._vibrato.frequency,n._vibratoGain=new Oi({context:n.context,units:"normalRange",gain:o.vibratoAmount}),n.vibratoAmount=n._vibratoGain.gain,n.frequency=new Ci({context:n.context,units:"frequency",value:440}),n.detune=new Ci({context:n.context,units:"cents",value:o.detune}),n.frequency.connect(n.voice0.frequency),n.frequency.chain(n.harmonicity,n.voice1.frequency),n._vibrato.connect(n._vibratoGain),n._vibratoGain.fan(n.voice0.detune,n.voice1.detune),n.detune.fan(n.voice0.detune,n.voice1.detune),n.voice0.connect(n.output),n.voice1.connect(n.output),Xo(n,["voice0","voice1","frequency","vibratoAmount","vibratoRate"]),n}return Yn(e,t),e.prototype.getLevelAtTime=function(t){return t=this.toSeconds(t),this.voice0.envelope.getValueAtTime(t)+this.voice1.envelope.getValueAtTime(t)},e.getDefaults=function(){return Co(ms.getDefaults(),{vibratoAmount:.5,vibratoRate:5,harmonicity:1.5,voice0:Co(Eo(vs.getDefaults(),Object.keys(ms.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}),voice1:Co(Eo(vs.getDefaults(),Object.keys(ms.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}})})},e.prototype._triggerEnvelopeAttack=function(t,e){this.voice0._triggerEnvelopeAttack(t,e),this.voice1._triggerEnvelopeAttack(t,e)},e.prototype._triggerEnvelopeRelease=function(t){return this.voice0._triggerEnvelopeRelease(t),this.voice1._triggerEnvelopeRelease(t),this},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.voice0.dispose(),this.voice1.dispose(),this.frequency.dispose(),this.detune.dispose(),this._vibrato.dispose(),this.vibratoRate.dispose(),this._vibratoGain.dispose(),this.harmonicity.dispose(),this},e}(ms),xs=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments))||this;n.name="FMSynth";var o=Ao(e.getDefaults(),arguments);return n.modulationIndex=new xr({context:n.context,value:o.modulationIndex}),n.frequency.connect(n._carrier.frequency),n.frequency.chain(n.harmonicity,n._modulator.frequency),n.frequency.chain(n.modulationIndex,n._modulationNode),n.detune.fan(n._carrier.detune,n._modulator.detune),n._modulator.connect(n._modulationNode.gain),n._modulationNode.connect(n._carrier.frequency),n._carrier.connect(n.output),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(_s.getDefaults(),{modulationIndex:10})},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.modulationIndex.dispose(),this},e}(_s),ws=[1,1.483,1.932,2.546,2.63,3.897],Ts=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments))||this;n.name="MetalSynth",n._oscillators=[],n._freqMultipliers=[];var o=Ao(e.getDefaults(),arguments);n.detune=new Ci({context:n.context,units:"cents",value:o.detune}),n.frequency=new Ci({context:n.context,units:"frequency"}),n._amplitude=new Oi({context:n.context,gain:0}).connect(n.output),n._highpass=new kr({Q:0,context:n.context,type:"highpass"}).connect(n._amplitude);for(var i=0;iMath.ceil(this._averageActiveVoices+1)){var t=this._availableVoices.shift(),e=this._voices.indexOf(t);this._voices.splice(e,1),this.context.isOffline||t.dispose()}},e.prototype._triggerAttack=function(t,e,n){var o=this;t.forEach((function(t){var i=new Hi(o.context,t).toMidi(),r=o._getNextAvailableVoice();r&&(r.triggerAttack(t,e,n),o._activeVoices.push({midi:i,voice:r,released:!1}),o.log("triggerAttack",t,e))}))},e.prototype._triggerRelease=function(t,e){var n=this;t.forEach((function(t){var o=new Hi(n.context,t).toMidi(),i=n._activeVoices.find((function(t){var e=t.midi,n=t.released;return e===o&&!n}));i&&(i.voice.triggerRelease(e),i.released=!0,n.log("triggerRelease",t,e))}))},e.prototype._scheduleEvent=function(t,e,n,o){var i=this;eo(!this.disposed,"Synth was already disposed"),n<=this.now()?"attack"===t?this._triggerAttack(e,n,o):this._triggerRelease(e,n):this.context.setTimeout((function(){i._scheduleEvent(t,e,n,o)}),n-this.now())},e.prototype.triggerAttack=function(t,e,n){Array.isArray(t)||(t=[t]);var o=this.toSeconds(e);return this._scheduleEvent("attack",t,o,n),this},e.prototype.triggerRelease=function(t,e){Array.isArray(t)||(t=[t]);var n=this.toSeconds(e);return this._scheduleEvent("release",t,n),this},e.prototype.triggerAttackRelease=function(t,e,n,o){var i=this.toSeconds(n);if(this.triggerAttack(t,i,o),mo(e)){eo(mo(t),"If the duration is an array, the notes must also be an array");for(var r=0;r0,"The duration must be greater than 0"),this.triggerRelease(t[r],i+a)}}else{var a;eo((a=this.toSeconds(e))>0,"The duration must be greater than 0"),this.triggerRelease(t,i+a)}return this},e.prototype.sync=function(){return this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1),this},e.prototype.set=function(t){var e=Eo(t,["onsilence","context"]);return this.options=Co(this.options,e),this._voices.forEach((function(t){return t.set(e)})),this._dummyVoice.set(e),this},e.prototype.get=function(){return this._dummyVoice.get()},e.prototype.releaseAll=function(){var t=this.now();return this._activeVoices.forEach((function(e){e.voice.triggerRelease(t)})),this._activeVoices=[],this},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._dummyVoice.dispose(),this._voices.forEach((function(t){return t.dispose()})),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this},e}(ds),As=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["urls","onload","baseUrl"],"urls"))||this;n.name="Sampler",n._activeSources=new Map;var o=Ao(e.getDefaults(),arguments,["urls","onload","baseUrl"],"urls"),i={};return Object.keys(o.urls).forEach((function(t){var e=parseInt(t,10);if(eo(_o(t)||ho(e)&&isFinite(e),"url key is neither a note or midi pitch: "+t),_o(t)){var r=new hi(n.context,t).toMidi();i[r]=o.urls[t]}else ho(e)&&isFinite(e)&&(i[e]=o.urls[e])})),n._buffers=new Gi(i,o.onload,o.baseUrl),n.attack=o.attack,n.release=o.release,n.curve=o.curve,n._buffers.loaded&&Promise.resolve().then(o.onload),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(ds.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:Qo,release:.1,urls:{}})},e.prototype._findClosest=function(t){for(var e=0;e<96;){if(this._buffers.has(t+e))return-e;if(this._buffers.has(t-e))return e;e++}throw new Error("No available buffers for note: "+t)},e.prototype.triggerAttack=function(t,e,n){var o=this;return void 0===n&&(n=1),this.log("triggerAttack",t,e,n),Array.isArray(t)||(t=[t]),t.forEach((function(t){var i=new hi(o.context,t).toMidi(),r=o._findClosest(i),s=i-r,a=o._buffers.get(s),u=ri(r),c=new $i({buffer:a,context:o.context,curve:o.curve,fadeIn:o.attack,fadeOut:o.release,playbackRate:u}).connect(o.output);c.start(e,0,a.duration/u,n),mo(o._activeSources.get(i))||o._activeSources.set(i,[]),o._activeSources.get(i).push(c),c.onended=function(){if(o._activeSources&&o._activeSources.has(i)){var t=o._activeSources.get(i),e=t.indexOf(c);-1!==e&&t.splice(e,1)}}})),this},e.prototype.triggerRelease=function(t,e){var n=this;return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach((function(t){var o=new hi(n.context,t).toMidi();if(n._activeSources.has(o)&&n._activeSources.get(o).length){var i=n._activeSources.get(o);e=n.toSeconds(e),i.forEach((function(t){t.stop(e)})),n._activeSources.set(o,[])}})),this},e.prototype.releaseAll=function(t){var e=this.toSeconds(t);return this._activeSources.forEach((function(t){for(;t.length;)t.shift().stop(e)})),this},e.prototype.sync=function(){return this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1),this},e.prototype.triggerAttackRelease=function(t,e,n,o){var i=this;void 0===o&&(o=1);var r=this.toSeconds(n);return this.triggerAttack(t,r,o),mo(e)?(eo(mo(t),"notes must be an array when duration is array"),t.forEach((function(t,n){var o=e[Math.min(n,e.length-1)];i.triggerRelease(t,r+i.toSeconds(o))}))):this.triggerRelease(t,r+this.toSeconds(e)),this},e.prototype.add=function(t,e,n){if(eo(_o(t)||isFinite(t),"note must be a pitch or midi: "+t),_o(t)){var o=new hi(this.context,t).toMidi();this._buffers.add(o,e,n)}else this._buffers.add(t,e,n);return this},Object.defineProperty(e.prototype,"loaded",{get:function(){return this._buffers.loaded},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._buffers.dispose(),this._activeSources.forEach((function(t){t.forEach((function(t){return t.dispose()}))})),this._activeSources.clear(),this},Qn([Vr(0)],e.prototype,"attack",void 0),Qn([Vr(0)],e.prototype,"release",void 0),e}(ds),Ds=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["callback","value"]))||this;n.name="ToneEvent",n._state=new gi("stopped"),n._startOffset=0;var o=Ao(e.getDefaults(),arguments,["callback","value"]);return n._loop=o.loop,n.callback=o.callback,n.value=o.value,n._loopStart=n.toTicks(o.loopStart),n._loopEnd=n.toTicks(o.loopEnd),n._playbackRate=o.playbackRate,n._probability=o.probability,n._humanize=o.humanize,n.mute=o.mute,n._playbackRate=o.playbackRate,n._state.increasing=!0,n._rescheduleEvents(),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(_i.getDefaults(),{callback:Qo,humanize:!1,loop:!1,loopEnd:"1m",loopStart:0,mute:!1,playbackRate:1,probability:1,value:null})},e.prototype._rescheduleEvents=function(t){var e=this;void 0===t&&(t=-1),this._state.forEachFrom(t,(function(t){var n;if("started"===t.state){-1!==t.id&&e.context.transport.clear(t.id);var o=t.time+Math.round(e.startOffset/e._playbackRate);if(!0===e._loop||ho(e._loop)&&e._loop>1){n=1/0,ho(e._loop)&&(n=e._loop*e._getLoopDuration());var i=e._state.getAfter(o);null!==i&&(n=Math.min(n,i.time-o)),n!==1/0&&(e._state.setStateAtTime("stopped",o+n+1,{id:-1}),n=new ji(e.context,n));var r=new ji(e.context,e._getLoopDuration());t.id=e.context.transport.scheduleRepeat(e._tick.bind(e),r,new ji(e.context,o),n)}else t.id=e.context.transport.schedule(e._tick.bind(e),new ji(e.context,o))}}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._state.getValueAtTime(this.context.transport.ticks)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"startOffset",{get:function(){return this._startOffset},set:function(t){this._startOffset=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"probability",{get:function(){return this._probability},set:function(t){this._probability=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"humanize",{get:function(){return this._humanize},set:function(t){this._humanize=t},enumerable:!0,configurable:!0}),e.prototype.start=function(t){var e=this.toTicks(t);return"stopped"===this._state.getValueAtTime(e)&&(this._state.add({id:-1,state:"started",time:e}),this._rescheduleEvents(e)),this},e.prototype.stop=function(t){this.cancel(t);var e=this.toTicks(t);if("started"===this._state.getValueAtTime(e)){this._state.setStateAtTime("stopped",e,{id:-1});var n=this._state.getBefore(e),o=e;null!==n&&(o=n.time),this._rescheduleEvents(o)}return this},e.prototype.cancel=function(t){var e=this;t=Do(t,-1/0);var n=this.toTicks(t);return this._state.forEachFrom(n,(function(t){e.context.transport.clear(t.id)})),this._state.cancel(n),this},e.prototype._tick=function(t){var e=this.context.transport.getTicksAtTime(t);if(!this.mute&&"started"===this._state.getValueAtTime(e)){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){var n=.02;fo(this.humanize)||(n=this.toSeconds(this.humanize)),t+=(2*Math.random()-1)*n}this.callback(t,this.value)}},e.prototype._getLoopDuration=function(){return Math.round((this._loopEnd-this._loopStart)/this._playbackRate)},Object.defineProperty(e.prototype,"loop",{get:function(){return this._loop},set:function(t){this._loop=t,this._rescheduleEvents()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._rescheduleEvents()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loopEnd",{get:function(){return new ji(this.context,this._loopEnd).toSeconds()},set:function(t){this._loopEnd=this.toTicks(t),this._loop&&this._rescheduleEvents()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loopStart",{get:function(){return new ji(this.context,this._loopStart).toSeconds()},set:function(t){this._loopStart=this.toTicks(t),this._loop&&this._rescheduleEvents()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"progress",{get:function(){if(this._loop){var t=this.context.transport.ticks,e=this._state.get(t);if(null!==e&&"started"===e.state){var n=this._getLoopDuration();return(t-e.time)%n/n}return 0}return 0},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.cancel(),this._state.dispose(),this},e}(_i),Es=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["callback","interval"]))||this;n.name="Loop";var o=Ao(e.getDefaults(),arguments,["callback","interval"]);return n._event=new Ds({context:n.context,callback:n._tick.bind(n),loop:!0,loopEnd:o.interval,playbackRate:o.playbackRate,probability:o.probability}),n.callback=o.callback,n.iterations=o.iterations,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(_i.getDefaults(),{interval:"4n",callback:Qo,playbackRate:1,iterations:1/0,probability:1,mute:!1,humanize:!1})},e.prototype.start=function(t){return this._event.start(t),this},e.prototype.stop=function(t){return this._event.stop(t),this},e.prototype.cancel=function(t){return this._event.cancel(t),this},e.prototype._tick=function(t){this.callback(t)},Object.defineProperty(e.prototype,"state",{get:function(){return this._event.state},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"progress",{get:function(){return this._event.progress},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"interval",{get:function(){return this._event.loopEnd},set:function(t){this._event.loopEnd=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"playbackRate",{get:function(){return this._event.playbackRate},set:function(t){this._event.playbackRate=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"humanize",{get:function(){return this._event.humanize},set:function(t){this._event.humanize=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"probability",{get:function(){return this._event.probability},set:function(t){this._event.probability=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mute",{get:function(){return this._event.mute},set:function(t){this._event.mute=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"iterations",{get:function(){return!0===this._event.loop?1/0:this._event.loop},set:function(t){this._event.loop=t===1/0||t},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._event.dispose(),this},e}(_i),Ms=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["callback","events"]))||this;n.name="Part",n._state=new gi("stopped"),n._events=new Set;var o=Ao(e.getDefaults(),arguments,["callback","events"]);return n._state.increasing=!0,o.events.forEach((function(t){mo(t)?n.add(t[0],t[1]):n.add(t)})),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Ds.getDefaults(),{events:[]})},e.prototype.start=function(t,e){var n=this,o=this.toTicks(t);if("started"!==this._state.getValueAtTime(o)){e=Do(e,this._loop?this._loopStart:0),e=this._loop?Do(e,this._loopStart):Do(e,0);var i=this.toTicks(e);this._state.add({id:-1,offset:i,state:"started",time:o}),this._forEach((function(t){n._startNote(t,o,i)}))}return this},e.prototype._startNote=function(t,e,n){e-=n,this._loop?t.startOffset>=this._loopStart&&t.startOffset=n&&(t.loop=!1,t.start(new ji(this.context,e))):t.startOffset>=n&&t.start(new ji(this.context,e))},Object.defineProperty(e.prototype,"startOffset",{get:function(){return this._startOffset},set:function(t){var e=this;this._startOffset=t,this._forEach((function(t){t.startOffset+=e._startOffset}))},enumerable:!0,configurable:!0}),e.prototype.stop=function(t){var e=this.toTicks(t);return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._forEach((function(e){e.stop(t)})),this},e.prototype.at=function(t,e){for(var n=new mi(this.context,t).toTicks(),o=new ji(this.context,1).toSeconds(),i=this._events.values(),r=i.next();!r.done;){var s=r.value;if(Math.abs(n-s.startOffset)=this._loopEnd)?t.cancel(0):"stopped"===t.state&&this._restartEvent(t)},Object.defineProperty(e.prototype,"probability",{get:function(){return this._probability},set:function(t){this._probability=t,this._setAll("probability",t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"humanize",{get:function(){return this._humanize},set:function(t){this._humanize=t,this._setAll("humanize",t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loop",{get:function(){return this._loop},set:function(t){var e=this;this._loop=t,this._forEach((function(n){n.loopStart=e.loopStart,n.loopEnd=e.loopEnd,n.loop=t,e._testLoopBoundries(n)}))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loopEnd",{get:function(){return new ji(this.context,this._loopEnd).toSeconds()},set:function(t){var e=this;this._loopEnd=this.toTicks(t),this._loop&&this._forEach((function(n){n.loopEnd=t,e._testLoopBoundries(n)}))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loopStart",{get:function(){return new ji(this.context,this._loopStart).toSeconds()},set:function(t){var e=this;this._loopStart=this.toTicks(t),this._loop&&this._forEach((function(t){t.loopStart=e.loopStart,e._testLoopBoundries(t)}))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._setAll("playbackRate",t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._events.size},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.clear(),this},e}(Ds);function Ps(t){var e;return $n(this,(function(n){switch(n.label){case 0:e=0,n.label=1;case 1:return e=0?(e=qs(e,t),[4,t[e]]):[3,3];case 2:return n.sent(),e--,[3,1];case 3:return[2]}}))}function js(t,e){return $n(this,(function(n){switch(n.label){case 0:return[5,Jn(e(t))];case 1:return n.sent(),[3,0];case 2:return[2]}}))}function qs(t,e){return Vo(t,0,e.length-1)}function Is(t,e){var n;return $n(this,(function(o){switch(o.label){case 0:n=e?0:t.length-1,o.label=1;case 1:return n=qs(n,t),[4,t[n]];case 2:return o.sent(),e?++n>=t.length-1&&(e=!1):--n<=0&&(e=!0),[3,1];case 3:return[2]}}))}function Vs(t){var e,n;return $n(this,(function(o){switch(o.label){case 0:e=0,n=0,o.label=1;case 1:return e=0?(e=qs(e,t),[4,t[e]]):[3,3];case 2:return o.sent(),n++,e+=n%2?-2:1,[3,1];case 3:return[2]}}))}function Ns(t){var e;return $n(this,(function(n){switch(n.label){case 0:return e=Math.floor(Math.random()*t.length),[4,t[e]];case 1:return n.sent(),[3,0];case 2:return[2]}}))}function Ls(t){var e,n,o,i;return $n(this,(function(r){switch(r.label){case 0:for(e=[],n=0;n0?(o=e.splice(Math.floor(e.length*Math.random()),1),i=qs(o[0],t),[4,t[i]]):[3,3];case 2:return r.sent(),[3,1];case 3:return[2]}}))}function zs(t,e,n){return void 0===e&&(e="up"),void 0===n&&(n=0),$n(this,(function(n){switch(n.label){case 0:switch(eo(t.length>0,"The array must have more than one value in it"),e){case"up":return[3,1];case"down":return[3,3];case"upDown":return[3,5];case"downUp":return[3,7];case"alternateUp":return[3,9];case"alternateDown":return[3,11];case"random":return[3,13];case"randomOnce":return[3,15]}return[3,17];case 1:return[5,Jn(js(t,Ps))];case 2:n.sent(),n.label=3;case 3:return[5,Jn(js(t,Rs))];case 4:n.sent(),n.label=5;case 5:return[5,Jn(Is(t,!0))];case 6:n.sent(),n.label=7;case 7:return[5,Jn(Is(t,!1))];case 8:n.sent(),n.label=9;case 9:return[5,Jn(js(t,Vs))];case 10:n.sent(),n.label=11;case 11:return[5,Jn(js(t,Fs))];case 12:n.sent(),n.label=13;case 13:return[5,Jn(Ns(t))];case 14:n.sent(),n.label=15;case 15:return[5,Jn(js(t,Ls))];case 16:n.sent(),n.label=17;case 17:return[2]}}))}var Bs=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["callback","values","pattern"]))||this;n.name="Pattern";var o=Ao(e.getDefaults(),arguments,["callback","values","pattern"]);return n.callback=o.callback,n._values=o.values,n._pattern=zs(o.values,o.pattern),n._type=o.pattern,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Es.getDefaults(),{pattern:"up",values:[],callback:Qo})},e.prototype._tick=function(t){var e=this._pattern.next();this._value=e.value,this.callback(t,this._value)},Object.defineProperty(e.prototype,"values",{get:function(){return this._values},set:function(t){this._values=t,this.pattern=this._type},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pattern",{get:function(){return this._type},set:function(t){this._type=t,this._pattern=zs(this._values,this._type)},enumerable:!0,configurable:!0}),e}(Es),Us=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["callback","events","subdivision"]))||this;n.name="Sequence",n._part=new Ms({callback:n._seqCallback.bind(n),context:n.context}),n._events=[],n._eventsArray=[];var o=Ao(e.getDefaults(),arguments,["callback","events","subdivision"]);return n._subdivision=n.toTicks(o.subdivision),n.events=o.events,n.loop=o.loop,n.loopStart=o.loopStart,n.loopEnd=o.loopEnd,n.playbackRate=o.playbackRate,n.probability=o.probability,n.humanize=o.humanize,n.mute=o.mute,n.playbackRate=o.playbackRate,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Eo(Ds.getDefaults(),["value"]),{events:[],loop:!0,loopEnd:0,loopStart:0,subdivision:"8n"})},e.prototype._seqCallback=function(t,e){null!==e&&this.callback(t,e)},Object.defineProperty(e.prototype,"events",{get:function(){return this._events},set:function(t){this.clear(),this._eventsArray=t,this._events=this._createSequence(this._eventsArray),this._eventsUpdated()},enumerable:!0,configurable:!0}),e.prototype.start=function(t,e){return this._part.start(t,e?this._indexTime(e):e),this},e.prototype.stop=function(t){return this._part.stop(t),this},Object.defineProperty(e.prototype,"subdivision",{get:function(){return new ji(this.context,this._subdivision).toSeconds()},enumerable:!0,configurable:!0}),e.prototype._createSequence=function(t){var e=this;return new Proxy(t,{get:function(t,e){return t[e]},set:function(t,n,o){return yo(n)&&isFinite(parseInt(n,10))&&mo(o)?t[n]=e._createSequence(o):t[n]=o,e._eventsUpdated(),!0}})},e.prototype._eventsUpdated=function(){this._part.clear(),this._rescheduleSequence(this._eventsArray,this._subdivision,this.startOffset),this.loopEnd=this.loopEnd},e.prototype._rescheduleSequence=function(t,e,n){var o=this;t.forEach((function(t,i){var r=i*e+n;if(mo(t))o._rescheduleSequence(t,e/t.length,r);else{var s=new ji(o.context,r,"i").toSeconds();o._part.add(s,t)}}))},e.prototype._indexTime=function(t){return new ji(this.context,t*this._subdivision+this.startOffset).toSeconds()},e.prototype.clear=function(){return this._part.clear(),this},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._part.dispose(),this},Object.defineProperty(e.prototype,"loop",{get:function(){return this._part.loop},set:function(t){this._part.loop=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loopStart",{get:function(){return this._loopStart},set:function(t){this._loopStart=t,this._part.loopStart=this._indexTime(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loopEnd",{get:function(){return this._loopEnd},set:function(t){this._loopEnd=t,this._part.loopEnd=0===t?this._indexTime(this._eventsArray.length):this._indexTime(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"startOffset",{get:function(){return this._part.startOffset},set:function(t){this._part.startOffset=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"playbackRate",{get:function(){return this._part.playbackRate},set:function(t){this._part.playbackRate=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"probability",{get:function(){return this._part.probability},set:function(t){this._part.probability=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"humanize",{get:function(){return this._part.humanize},set:function(t){this._part.humanize=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._part.length},enumerable:!0,configurable:!0}),e}(Ds),Ws=function(t){function e(e){var n=t.call(this,e)||this;return n.name="Effect",n._dryWet=new gr({context:n.context}),n.wet=n._dryWet.fade,n.effectSend=new Oi({context:n.context}),n.effectReturn=new Oi({context:n.context}),n.input=new Oi({context:n.context}),n.output=n._dryWet,n.input.fan(n._dryWet.a,n.effectSend),n.effectReturn.connect(n._dryWet.b),n.wet.setValueAtTime(e.wet,0),n._internalChannels=[n.effectReturn,n.effectSend],Xo(n,"wet"),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(bi.getDefaults(),{wet:1})},e.prototype.connectEffect=function(t){return this._internalChannels.push(t),this.effectSend.chain(t,this.effectReturn),this},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this},e}(bi),Gs=function(t){function e(e){var n=t.call(this,e)||this;return n.name="LFOEffect",n._lfo=new us({context:n.context,frequency:e.frequency,amplitude:e.depth}),n.depth=n._lfo.amplitude,n.frequency=n._lfo.frequency,n.type=e.type,Xo(n,["frequency","depth"]),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Ws.getDefaults(),{frequency:1,type:"sine",depth:1})},e.prototype.start=function(t){return this._lfo.start(t),this},e.prototype.stop=function(t){return this._lfo.stop(t),this},e.prototype.sync=function(){return this._lfo.sync(),this},e.prototype.unsync=function(){return this._lfo.unsync(),this},Object.defineProperty(e.prototype,"type",{get:function(){return this._lfo.type},set:function(t){this._lfo.type=t},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this},e}(Ws),Hs=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["frequency","baseFrequency","octaves"]))||this;n.name="AutoFilter";var o=Ao(e.getDefaults(),arguments,["frequency","baseFrequency","octaves"]);return n.filter=new kr(Object.assign(o.filter,{context:n.context})),n.connectEffect(n.filter),n._lfo.connect(n.filter.frequency),n.octaves=o.octaves,n.baseFrequency=o.baseFrequency,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Gs.getDefaults(),{baseFrequency:200,octaves:2.6,filter:{type:"lowpass",rolloff:-12,Q:1}})},Object.defineProperty(e.prototype,"baseFrequency",{get:function(){return this._lfo.min},set:function(t){this._lfo.min=this.toFrequency(t),this.octaves=this._octaves},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"octaves",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._lfo.max=this._lfo.min*Math.pow(2,t)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.filter.dispose(),this},e}(Gs),Xs=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["frequency"]))||this;return n.name="AutoPanner",n._panner=new dr({context:n.context}),n.connectEffect(n._panner),n._lfo.connect(n._panner.pan),n._lfo.min=-1,n._lfo.max=1,n}return Yn(e,t),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._panner.dispose(),this},e}(Gs),Ys=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["baseFrequency","octaves","sensitivity"]))||this;n.name="AutoWah";var o=Ao(e.getDefaults(),arguments,["baseFrequency","octaves","sensitivity"]);return n._follower=new pr({context:n.context,smoothing:o.follower}),n._sweepRange=new ps({context:n.context,min:0,max:1,exponent:.5}),n._baseFrequency=n.toFrequency(o.baseFrequency),n._octaves=o.octaves,n._inputBoost=new Oi({context:n.context}),n._bandpass=new kr({context:n.context,rolloff:-48,frequency:0,Q:o.Q}),n._peaking=new kr({context:n.context,type:"peaking"}),n._peaking.gain.value=o.gain,n.gain=n._peaking.gain,n.Q=n._bandpass.Q,n.effectSend.chain(n._inputBoost,n._follower,n._sweepRange),n._sweepRange.connect(n._bandpass.frequency),n._sweepRange.connect(n._peaking.frequency),n.effectSend.chain(n._bandpass,n._peaking,n.effectReturn),n._setSweepRange(),n.sensitivity=o.sensitivity,Xo(n,["gain","Q"]),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Ws.getDefaults(),{baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,follower:.2})},Object.defineProperty(e.prototype,"octaves",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._setSweepRange()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"follower",{get:function(){return this._follower.smoothing},set:function(t){this._follower.smoothing=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"baseFrequency",{get:function(){return this._baseFrequency},set:function(t){this._baseFrequency=this.toFrequency(t),this._setSweepRange()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sensitivity",{get:function(){return ii(1/this._inputBoost.gain.value)},set:function(t){this._inputBoost.gain.value=1/oi(t)},enumerable:!0,configurable:!0}),e.prototype._setSweepRange=function(){this._sweepRange.min=this._baseFrequency,this._sweepRange.max=Math.min(this._baseFrequency*Math.pow(2,this._octaves),this.context.sampleRate/2)},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._follower.dispose(),this._sweepRange.dispose(),this._bandpass.dispose(),this._peaking.dispose(),this._inputBoost.dispose(),this},e}(Ws),Qs=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["bits"]))||this;n.name="BitCrusher";var o=Ao(e.getDefaults(),arguments,["bits"]);return n._bitCrusherWorklet=new Zs({context:n.context,bits:o.bits}),n.connectEffect(n._bitCrusherWorklet),n.bits=n._bitCrusherWorklet.bits,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Ws.getDefaults(),{bits:4,frequencyReduction:.5})},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._bitCrusherWorklet.dispose(),this},e}(Ws),Zs=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments))||this;n.name="BitCrusherWorklet",n.workletOptions={numberOfInputs:1,numberOfOutputs:1};var o=Ao(e.getDefaults(),arguments);n.input=new Oi({context:n.context}),n.output=new Oi({context:n.context});var i=n.context.createGain();return n.bits=new vi({context:n.context,value:o.bits,units:"positive",minValue:1,maxValue:16,param:i.gain,swappable:!0}),n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Gr.getDefaults(),{bits:12})},e.prototype._audioWorkletName=function(){return"bit-crusher"},e.prototype._audioWorklet=function(){return' \n\t\tregisterProcessor("'+this._audioWorkletName()+"\", class extends AudioWorkletProcessor {\n\t\t\tstatic get parameterDescriptors () {\n\t\t\t\treturn [{\n\t\t\t\t\tname: 'bits',\n\t\t\t\t\tdefaultValue: 12,\n\t\t\t\t\tminValue: 1,\n\t\t\t\t\tmaxValue: 16\n\t\t\t\t}];\n\t\t\t}\n\t\t\t\n\t\t\tprocess (inputs, outputs, parameters) {\n\t\t\t\tconst input = inputs[0];\n\t\t\t\tconst output = outputs[0];\n\t\t\t\tif (input && output && input.length === output.length) {\n\t\t\t\t\tconst bits = parameters.bits;\n\t\t\t\t\tfor (let channelNum = 0; channelNum < input.length; channelNum++) {\n\t\t\t\t\t\tconst inputChannel = input[channelNum];\n\t\t\t\t\t\tfor (let index = 0; index < inputChannel.length; index++) {\n\t\t\t\t\t\t\tconst value = inputChannel[index];\n\t\t\t\t\t\t\tconst step = bits.length > 1 ? Math.pow(0.5, bits[index]) : Math.pow(0.5, bits[0]);\n\t\t\t\t\t\t\tconst val = step * Math.floor(value / step + 0.5);\n\t\t\t\t\t\t\toutput[channelNum][index] = val;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t});\n\t\t"},e.prototype.onReady=function(t){xi(this.input,t,this.output);var e=t.parameters.get("bits");this.bits.setParam(e)},e.prototype.dispose=function(){return t.prototype.dispose.call(this),this.input.dispose(),this.output.dispose(),this.bits.dispose(),this},e}(Gr),$s=function(t){function e(){var n=t.call(this,Ao(e.getDefaults(),arguments,["order"]))||this;n.name="Chebyshev";var o=Ao(e.getDefaults(),arguments,["order"]);return n._shaper=new lr({context:n.context,length:4096}),n._order=o.order,n.connectEffect(n._shaper),n.order=o.order,n.oversample=o.oversample,n}return Yn(e,t),e.getDefaults=function(){return Object.assign(Ws.getDefaults(),{order:1,oversample:"none"})},e.prototype._getCoefficient=function(t,e,n){return n.has(e)||(0===e?n.set(e,0):1===e?n.set(e,t):n.set(e,2*t*this._getCoefficient(t,e-1,n)-this._getCoefficient(t,e-2,n))),n.get(e)},Object.defineProperty(e.prototype,"order",{get:function(){return this._order},set:function(t){var e=this;this._order=t,this._shaper.setMap((function(n){return e._getCoefficient(n,t,new Map)}))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"oversample",{get:function(){return this._shaper.oversample},set:function(t){this._shaper.oversample=t},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){return t.prototype.dispose.call(this),this._shaper.dispose(),this},e}(Ws),Js=function(t){function e(e){var n=t.call(this,e)||this;return n.name="StereoEffect",n.input=new Oi({context:n.context}),n.input.channelCount=2,n.input.channelCountMode="explicit",n._dryWet=n.output=new gr({context:n.context,fade:e.wet}),n.wet=n._dryWet.fade,n._split=new er({context:n.context,channels:2}),n._merge=new vr({context:n.context,channels:2}),n.input.connect(n._split),n.input.connect(n._dryWet.a),n._merge.connect(n._dryWet.b),Xo(n,["wet"]),n}return Yn(e,t),e.prototype.connectEffectLeft=function(){for(var t=[],e=0;enew Tile)),this.width=t,this.height=e,this.renderer=new GridRenderer(t,e,n),this.currentInstrument=0,this.instruments=[],this.instruments.push(new SynthInstrument(t,e,{oscillator:{type:"sine"},envelope:{attack:.005,decay:.1,sustain:.3,release:1}},{frequency:1100,rolloff:-12})),this.instruments.push(new SynthInstrument(t,e,{oscillator:{type:"sawtooth"},envelope:{attack:.005,decay:.1,sustain:.3,release:2}},{frequency:1100,rolloff:-12}))}update(t,e){Util.assert(2===arguments.length),this.renderer.update(this,t,e)}getTileValue(t,e){return Util.assert(2===arguments.length),this.data[Util.coordToIndex(t,e,this.height)].hasNote(this.currentInstrument)}setTileValue(t,e,n){if(Util.assert(3===arguments.length),n){if(this.getTileValue(t,e))return;this.data[Util.coordToIndex(t,e,this.height)].addNote(this.currentInstrument,this.instruments[this.currentInstrument].scheduleNote(t,e))}else{if(!this.getTileValue(t,e))return;this.instruments[this.currentInstrument].unscheduleNote(this.data[Util.coordToIndex(t,e,this.height)].getNote(this.currentInstrument)),this.data[Util.coordToIndex(t,e,this.height)].removeNote(this.currentInstrument)}}toggleTileValue(t,e){Util.assert(2===arguments.length),this.setTileValue(t,e,!this.getTileValue(t,e))}clearAllTiles(){Util.assert(0===arguments.length),this.data.forEach((t=>t.removeAllNotes())),Tone.Transport.cancel()}setCurrentInstrument(t){t>=this.instruments.length?console.warn("tried to switch to nonexistent instrument"):this.currentInstrument=t}setMuted(t){Util.assert(1===arguments.length),Tone.Destination.mute=t}toBase64(){Util.assert(0===arguments.length);let t=!1;const e=new Uint8Array(this.data.length/8);for(let n=0;n0){const e=Util.pixelCoordsToTileCoords(o.x,o.y,this.gridWidth,this.gridHeight,this.canvas.width,this.canvas.height);e&&(t[Util.coordToIndex(e.x,e.y,this.gridHeight)]+=o.life)}}return t}}class ParticleSystem{constructor(t,e){Util.assert(2===arguments.length),this.PARTICLE_POOL_SIZE=2e3,this.PARTICLE_LIFETIME=40,this.width=t,this.height=e,this.oldestParticle=0,this.lastUpdate=0,this.particles=new Array(this.PARTICLE_POOL_SIZE);for(let t=0;t0){const t=n.vx*e,o=n.vy*e;n.x+=t,(n.x>this.width||n.x<0)&&(n.vx=-n.vx,n.x+=t),n.y+=o,(n.y>this.height||n.y<0)&&(n.vy=-n.vy,n.y+=o),n.life-=e}}this.lastUpdate=t}else this.lastUpdate=Date.now()}createParticle(t,e,n,o){Util.assert(4===arguments.length);const i=this.particles[this.oldestParticle];i.x=t,i.y=e,i.vx=n,i.vy=o,i.life=this.PARTICLE_LIFETIME,this.oldestParticle+=1,this.oldestParticle>=this.PARTICLE_POOL_SIZE&&(this.oldestParticle=0)}createParticleBurst(t,e,n,o){const i=2*Math.random()*Math.PI;for(let r=0;r<2*Math.PI;r+=2*Math.PI/o){const o=Math.cos(r+i)*n,s=Math.sin(r+i)*n;this.createParticle(t,e,o,s)}}}class SpriteSheet{constructor(t,e,n,o){Util.assert(4===arguments.length),this.spriteSheet=document.createElement("canvas");const i=this.spriteSheet.getContext("2d");this.tileWidth=n/t,this.tileHeight=o/e,this.spriteSheet.width=3*this.tileWidth,this.spriteSheet.height=this.tileHeight;const r=Util.getDevicePixelRatio();let s,a,u;const c=this.tileWidth,l=this.tileHeight;i.fillStyle="#fff",s=4*r,a=0,u=0,i.filter="none",Util.drawRoundedRectangle(i,a+s,u+s,c-2*s,l-2*s,2,!0,!1),s=3*r,a=c,u=0,i.filter=`blur(${r}px)`,Util.drawRoundedRectangle(i,a+s,u+s,c-2*s,l-2*s,2,!0,!1),s=2*r,a=2*c,u=0,i.filter=`blur(${2*r}px)`,Util.drawRoundedRectangle(i,a+s,u+s,c-2*s,l-2*s,2,!0,!1)}drawSprite(t,e,n,o){Util.assert(4===arguments.length),e.drawImage(this.spriteSheet,t*this.tileWidth,0,this.tileWidth,this.tileHeight,n,o,this.tileWidth,this.tileHeight)}}class SynthInstrument{constructor(t,e,n,o){Util.assert(4===arguments.length),this.gridWidth=t,this.gridHeight=e;const i=["B#","D","F","G","A"],r=Array(e);for(let t=0;t{const t=new Tone.Filter(o).toDestination(),e=new Tone.Synth(n).connect(t);this.scale.forEach(((t,n)=>{e.triggerAttackRelease(t,Tone.Time("1m")/this.gridWidth,n*s.noteOffset)}))}),this.noteOffset*this.scale.length).then((t=>{for(let e=0;e{const o=(this.gridHeight-this.polyphony[t])/this.gridHeight*10-20;try{this.players[this.currentPlayer].volume.setValueAtTime(o,n),this.players[this.currentPlayer].start(n,e*this.noteOffset,this.noteOffset),this.currentPlayer=(this.currentPlayer+1)%this.players.length}catch(t){Util.DEBUG&&console.warn("Note play failure:",t)}}),t*n);return this.notes[o]={x:t,y:e},this.polyphony[t]+=1,o}unscheduleNote(t){Util.assert(1===arguments.length);const{x:e}=this.notes[t];delete this.notes[t],this.polyphony[e]-=1,Util.assert(this.polyphony[e]>=0),Tone.Transport.clear(t)}getPlayheadX(){const t=Tone.Transport.seconds%(Tone.Transport.loopEnd-Tone.Transport.loopStart)/(Tone.Transport.loopEnd-Tone.Transport.loopStart);return Math.floor(t*this.gridWidth)}}class Tile{constructor(){this.notes=[],this.numberOfNotes=0}isEmpty(){return 0===this.numberOfNotes}getNote(t){return this.notes[t]}hasNote(t){return void 0!==this.notes[t]}addNote(t,e){this.notes[t]=e,this.numberOfNotes+=1}removeNote(t){delete this.notes[t],this.numberOfNotes-=1}removeAllNotes(){this.notes=[],this.numberOfNotes=0}}class ToneMatrix{constructor(t,e,n,o,i){Util.assert(5===arguments.length),this.c=document.createElement("canvas"),t.appendChild(this.c);const r=this.c.getBoundingClientRect();this.ctx=this.c.getContext("2d"),this.WIDTH=16,this.HEIGHT=16;const s=devicePixelRatio||1;this.c.height=r.height*s,this.c.width=r.height*(this.WIDTH/this.HEIGHT)*s,this.grid=new Grid(this.WIDTH,this.HEIGHT,this.c),this.mouseX=-1,this.mouseY=-1,this.clipboardInputEl=n||null,this.originalURL=[window.location.protocol,"//",window.location.host,window.location.pathname].join(""),e.addEventListener("click",(()=>{this.clear()})),new ClipboardJS(o),i.addEventListener("click",(()=>{i.classList.contains("muted")?(i.classList.remove("muted"),this.setMuted(!1)):(i.classList.add("muted"),this.setMuted(!0))}));let a=null;function u(t,e){Util.assert(2===arguments.length);const n=Util.pixelCoordsToTileCoords(t,e,this.WIDTH,this.HEIGHT,this.c.width,this.c.height);null===a&&(a=!this.grid.getTileValue(n.x,n.y)),this.grid.setTileValue(n.x,n.y,a);const o=this.grid.toBase64();o?this.setSharingURL(o):this.resetSharingURL(),Tone.context.resume()}this.c.addEventListener("mousemove",(t=>{this.updateCanvasMousePosition(t),1===t.buttons&&u.bind(this)(this.mouseX,this.mouseY)})),this.c.addEventListener("mouseleave",(()=>{this.resetCanvasMousePosition()})),this.c.addEventListener("mousedown",(t=>{this.updateCanvasMousePosition(t),a=null,u.bind(this)(this.mouseX,this.mouseY)})),this.c.addEventListener("touchstart",(t=>{t.preventDefault(),1===t.touches.length&&(a=null),Array.from(t.touches).forEach((t=>{this.updateCanvasMousePosition(t),u.bind(this)(this.mouseX,this.mouseY)}))})),this.c.addEventListener("touchend",(t=>{t.preventDefault(),this.resetCanvasMousePosition()})),this.c.addEventListener("touchmove",(t=>{t.preventDefault(),Array.from(t.touches).forEach((t=>{this.updateCanvasMousePosition(t),u.bind(this)(this.mouseX,this.mouseY)}))})),window.addEventListener("keydown",(t=>{t.isComposing||229===t.keyCode||(t.keyCode>=48&&t.keyCode<=57?this.grid.setCurrentInstrument(t.keyCode-48):t.keyCode>=96&&t.keyCode<=105&&this.grid.setCurrentInstrument(t.keyCode-96))})),Tone.Transport.loopEnd="1m",Tone.Transport.loop=!0,Tone.Transport.start(),window.addEventListener("DOMContentLoaded",(()=>{t.style.visibility="visible"})),"ontouchstart"in window||window.location.toString().indexOf("?")>=0?(t.addEventListener("click",(()=>{Tone.context.resume().then((()=>{document.body.classList.add("playing")}))})),Tone.context.resume().then((()=>{document.body.classList.add("playing")}))):document.body.classList.add("playing");const c=new URLSearchParams(window.location.search).get("d");c?(this.grid.fromBase64(c),this.setSharingURL(c),window.history.replaceState("",document.title,window.location.pathname)):this.resetSharingURL(),requestAnimationFrame(function t(){this.update(),requestAnimationFrame(t.bind(this))}.bind(this))}update(){Util.assert(0===arguments.length),this.grid.update(this.mouseX,this.mouseY)}updateCanvasMousePosition(t){Util.assert(1===arguments.length);const e=this.c.getBoundingClientRect(),n=this.c.width/e.width,o=this.c.height/e.height,i=(t.clientX-e.left)*n,r=(t.clientY-e.top)*o;this.mouseX=i,this.mouseY=r}resetCanvasMousePosition(){Util.assert(0===arguments.length),this.mouseX=-1,this.mouseY=-1}clear(){Util.assert(0===arguments.length),this.grid.clearAllTiles(),this.resetSharingURL()}setMuted(t){Util.assert(1===arguments.length),this.grid.setMuted(t)}setSharingURL(t){Util.assert(1===arguments.length),Util.assert(t);const e=new URLSearchParams({v:"1",d:t});this.clipboardInputEl.value=`${this.originalURL}?${e}`}resetSharingURL(){this.clipboardInputEl.value=this.originalURL}}class Util{static pixelCoordsToTileCoords(t,e,n,o,i,r){Util.assert(6===arguments.length);const s=i/n,a=r/o,u=Math.floor(t/s),c=Math.floor(e/a);return!(u>=n||c>=n||u<0||c<0)&&{x:u,y:c}}static coordToIndex(t,e,n){return Util.assert(3===arguments.length),t*n+e}static indexToCoord(t,e){return Util.assert(2===arguments.length),{x:Math.floor(t/e),y:t%e}}static drawRoundedRectangle(t,e,n,o,i,r=5,s=!1,a=!0){Util.assert(arguments.length>=5&&arguments.length<=8),t.beginPath(),t.moveTo(e+r,n),t.lineTo(e+o-r,n),t.quadraticCurveTo(e+o,n,e+o,n+r),t.lineTo(e+o,n+i-r),t.quadraticCurveTo(e+o,n+i,e+o-r,n+i),t.lineTo(e+r,n+i),t.quadraticCurveTo(e,n+i,e,n+i-r),t.lineTo(e,n+r),t.quadraticCurveTo(e,n,e+r,n),t.closePath(),s&&t.fill(),a&&t.stroke()}static getDevicePixelRatio(){return Util.devicePixelRatio}static assert(t){t||console.error("assertion failed")}}Util.devicePixelRatio=1,function(){const t=`(resolution: ${window.devicePixelRatio}dppx)`,e=()=>{Util.devicePixelRatio=window.devicePixelRatio||1};e(),matchMedia(t).addEventListener("change",e)}(),Util.DEBUG=!1; \ No newline at end of file diff --git a/android-chrome-192x192.png b/android-chrome-192x192.png new file mode 100644 index 0000000..51a8ed3 Binary files /dev/null and b/android-chrome-192x192.png differ diff --git a/android-chrome-512x512.png b/android-chrome-512x512.png new file mode 100644 index 0000000..d4b3324 Binary files /dev/null and b/android-chrome-512x512.png differ diff --git a/apple-touch-icon.png b/apple-touch-icon.png new file mode 100644 index 0000000..78ff936 Binary files /dev/null and b/apple-touch-icon.png differ diff --git a/browserconfig.xml b/browserconfig.xml new file mode 100644 index 0000000..d21c447 --- /dev/null +++ b/browserconfig.xml @@ -0,0 +1,9 @@ + + + + + + #000000 + + + diff --git a/clippy.svg b/clippy.svg new file mode 100644 index 0000000..d827e82 --- /dev/null +++ b/clippy.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/favicon-16x16.png b/favicon-16x16.png new file mode 100644 index 0000000..00a5af9 Binary files /dev/null and b/favicon-16x16.png differ diff --git a/favicon-32x32.png b/favicon-32x32.png new file mode 100644 index 0000000..31f8e79 Binary files /dev/null and b/favicon-32x32.png differ diff --git a/favicon-alt.png b/favicon-alt.png new file mode 100644 index 0000000..1faf457 Binary files /dev/null and b/favicon-alt.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..05e1a50 --- /dev/null +++ b/index.html @@ -0,0 +1,67 @@ + + + + + + ToneMatrix Redux Sequencer - No Flash Required + + + + + + + + + + + + + + + + + + + + +

ToneMatrix Redux

+

A pentatonic step sequencer. Click tiles and make music.

+ +
+
+ +
+

Clear Notes Based on ToneMatrix - By Max L - GitHub

+ + + + diff --git a/montserrat-thin-webfont.woff2 b/montserrat-thin-webfont.woff2 new file mode 100644 index 0000000..7af1285 Binary files /dev/null and b/montserrat-thin-webfont.woff2 differ diff --git a/mstile-150x150.png b/mstile-150x150.png new file mode 100644 index 0000000..beff56e Binary files /dev/null and b/mstile-150x150.png differ diff --git a/safari-pinned-tab.svg b/safari-pinned-tab.svg new file mode 100644 index 0000000..111604b --- /dev/null +++ b/safari-pinned-tab.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site.webmanifest b/site.webmanifest new file mode 100644 index 0000000..a491b27 --- /dev/null +++ b/site.webmanifest @@ -0,0 +1,20 @@ +{ + "name": "ToneMatrix Redux", + "short_name": "ToneMatrix", + "icons": [ + { + "src": "android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "android-chrome-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "theme_color": "#000000", + "background_color": "#000000", + "display": "standalone", + "orientation": "portrait" +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..9f02799 --- /dev/null +++ b/style.css @@ -0,0 +1,190 @@ +* { + user-select: none; +} + +html { + height: 100%; +} + +html, +body { + background: #000000; + font-family: Arial, sans-serif; + margin: 0; + min-height: 100%; + width: 100%; +} + +body { + align-items: center; + display: flex; + flex-direction: column; + justify-content: center; + overscroll-behavior-y: contain; +} + +body, +a { + color: #777; +} + +h1 { + color: #ddd; + font-family: "Montserrat", sans-serif; + font-weight: 100; + margin-bottom: 0; +} + +#clearnotes { + margin-right: 10px; + padding: 7px; +} + +canvas { + margin: -4px 0; + cursor: pointer; +} + +.canvaswrap { + position: relative; + visibility: hidden; +} + +canvas, +.canvaswrap { + height: 500px; + width: auto; +} + +#clipboard-input { + background-color: #222; + border: solid #444 1px; + border-radius: 3px 0 0 3px; + color: #999; + font-size: 0.7em; + height: 24px; + padding: 0 5px; + width: 300px; +} + +.clipboard { + border-radius: 0 3px 3px 0; + color: #aaa; + height: 26px; +} + +#muteButton { + display: inline-block; + vertical-align: middle; + margin-right: 15px; + width: 40px; + height: 40px; + background-image: url("volume-up.svg"); + background-size: contain; + background-position: center; + background-repeat: no-repeat; + filter: invert(1); + opacity: 0.6; + cursor: pointer; +} + +#muteButton.muted { + background-image: url("volume-mute.svg"); +} + +button, +.button { + background: #333; + border: solid #808080 1px; + border-radius: 4px; + color: #ddd; + display: inline-block; + font-weight: bold; + text-decoration: none; +} +button :hover, +.button :hover { + background: #555; + cursor: pointer; +} + +.icon { + filter: invert(1); + height: 1em; + vertical-align: middle; +} + +.share-wrap { + font-size: 0.8em; +} + +.share-wrap > * { + vertical-align: middle; +} + +body:not(.playing) canvas { + filter: blur(5px); + opacity: 0.3; + overflow: hidden; + pointer-events: none; +} +body:not(.playing) .canvaswrap { + border: solid #444 1px; +} +body:not(.playing) .play-btn { + background: radial-gradient(rgba(255, 0, 128, 0.8) 60%, rgb(255, 255, 255) 62%); + border-radius: 50%; + box-shadow: 0 0 25px 3px rgba(255, 0, 128, 0.8); + display: block; + height: 50px; + left: 50%; + position: absolute; + top: 50%; + transform: translate(-50%, -50%); + width: 50px; +} +body:not(.playing) .play-btn::after { + border-bottom: 9px solid transparent; + border-left: 13px solid #fff; + border-top: 9px solid transparent; + content: ""; + height: 0; + left: 50%; + position: absolute; + top: 50%; + transform: translateX(-40%) translateY(-50%); + transform-origin: center center; + transition: all 400ms cubic-bezier(0.55, 0.055, 0.675, 0.19); + width: 0; + z-index: 100; +} +body:not(.playing) .play-btn::before { + animation: pulsate1 2s; + animation-delay: 0s; + animation-direction: forwards; + animation-iteration-count: infinite; + animation-timing-function: steps; + background: rgba(198, 16, 0, 0); + border: 5px solid rgba(255, 255, 255, 0.75); + border-radius: 50%; + content: ""; + height: 150%; + left: -35%; + opacity: 1; + position: absolute; + top: -35%; + width: 150%; +} + +@keyframes pulsate1 { + 0% { + box-shadow: inset 0 0 25px 3px rgba(255, 255, 255, 0.75), 0 0 25px 10px rgba(255, 255, 255, 0.75); + opacity: 1; + transform: scale(0.6); + } + 100% { + box-shadow: none; + opacity: 0; + transform: scale(1); + } +} \ No newline at end of file diff --git a/volume-mute.svg b/volume-mute.svg new file mode 100644 index 0000000..b78aad6 --- /dev/null +++ b/volume-mute.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/volume-up.svg b/volume-up.svg new file mode 100644 index 0000000..c85f3e8 --- /dev/null +++ b/volume-up.svg @@ -0,0 +1 @@ + \ No newline at end of file