<!-- SS · part 150 -->
eturn super.dispose(),this.onstop=Ei,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}class Lo extends lo{constructor(){const t=ui(Lo.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,ro(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new no({context:this.context,param:this._source.playbackRate,units:"positive",value:t.playbackRate}),this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this._buffer=new Ri(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(lo.getDefaults(),{url:new Ri,loop:!1,loopEnd:0,loopStart:0,onload:Ei,onerror:Ei,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,s,n=1){Bn(this.buffer.loaded,"buffer is either not set or not loaded");const i=this.toSeconds(t);this._startGain(i,n),e=this.loop?pi(e,this.loopStart):pi(e,0);let o=Math.max(this.toSeconds(e),0);if(this.loop){const t=this.toSeconds(this.loopEnd)||this.buffer.duration,e=this.toSeconds(this.loopStart),s=t-e;gi(o,t)&&(o=(o-e)%s+e),yi(o,this.buffer.duration)&&(o=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,vi(o,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(i,o)),Fn(s)){let t=this.toSeconds(s);t=Math.max(t,0),this.stop(i+t)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}}class zo extends jo{constructor(){const t=ui(zo.getDefaults(),arguments,["type"]);super(t),this.name="Noise",this._source=null,this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(jo.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(Bn(t in Uo,"Noise: invalid type: "+t),this._type!==t&&(this._type=t,"started"===this.state)){const t=this.now();this._stop(t),this._start(t)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}_start(t){const e=Uo[this._type];this._source=new Lo({url:e,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(t),Math.random()*(e.duration-.001))}_stop(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(t){this._stop(t),this._start(t)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}}const Wo=220500,Bo={brown:null,pink:null,white:null},Uo={get brown(){if(!Bo.brown){const t=[];for(let e=0;e<2;e++){const s=new Float32Array(Wo);t[e]=s;let n=0;for(let t=0;t<Wo;t++){const e=2*Math.random()-1;s[t]=(n+.02*e)/1.02,n=s[t],s[t]*=3.5}}Bo.brown=(new Ri).fromArray(t)}return Bo.brown},get pink(){if(!Bo.pink){const t=[];for(let e=0;e<2;e++){const s=new Float32Array(Wo);let n,i,o,r,a,c,h;t[e]=s,n=i=o=r=a=c=h=0;for(let t=0;t<Wo;t++){const e=2*Math.random()-1;n=.99886*n+.0555179*e,i=.99332*i+.0750759*e,o=.969*o+.153852*e,r=.8665*r+.3104856*e,a=.55*a+.5329522*e,c=-.7616*c-.016898*e,s[t]=n+i+o+r+a+c+h+.5362*e,s[t]*=.11,h=.115926*e}}Bo.pink=(new Ri).fromArray(t)}return Bo.pink},get white(){if(!Bo.white){const t=[];for(let e=0;e<2;e++){const s=new Float32Array(Wo);t[e]=s;for(let t=0;t<Wo;t++)s[t]=2*Math.random()-1}Bo.white=(new Ri).fromArray(t)}return Bo.white}};class Go extends io{constructor(){const t=ui(Go.getDefaults(),arguments,["volume"]);super(t),this.name="UserMedia",this._volume=this.output=new xo({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Di(this,"volume"),this.mute=t.mute}static getDefaults(){return Object.assign(io.getDefaults(),{mute:!1,volume:0})}open(t){return ni(this,void 0,void 0,(function*(){Bn(Go.supported,"UserMe