text: (function(){var i,u=[];function f(s){var t=this,o={},r=-1;this.parameters.forEach(function(p,c){var h=u[++r]||(u[r]=new Float32Array(t.bufferSize));h.fill(p.value),o[c]=h}),this.processor.realm.exec("self.sampleRate=sampleRate="+this.context.sampleRate+";self.currentTime=currentTime="+this.context.currentTime);var n=l(s.inputBuffer),a=l(s.outputBuffer);this.instance.process([n],[a],o)}function l(s){for(var t=[],o=0;o<s.numberOfChannels;o++)t[o]=s.getChannelData(o);return t}function e(s){return s.$$processors||(s.$$processors={})}typeof AudioWorkletNode!="function"&&(self.AudioWorkletNode=function(s,t,o){var r=e(s)[t],n=s.createScriptProcessor(void 0,2,o&&o.outputChannelCount?o.outputChannelCount[0]:2);if(n.parameters=new Map,r.properties)for(var a=0;a<r.properties.length;a++){var p=r.properties[a],c=s.createGain().gain;c.value=p.defaultValue,n.parameters.set(p.name,c)}var h=new MessageChannel;i=h.port2;var m=new r.Processor(o||{});return i=null,n.port=h.port1,n.processor=r,n.instance=m,n.onaudioprocess=f,n},Object.defineProperty((self.AudioContext||self.webkitAudioContext).prototype,"audioWorklet",{get:function(){return this.$$audioWorklet||(this.$$audioWorklet=new self.AudioWorklet(this))}}),self.AudioWorklet=function(){function s(t){this.$$context=t}return s.prototype.addModule=function(t,o){var r=this;return fetch(t).then(function(n){if(!n.ok)throw Error(n.status);return n.text()}).then(function(n){var a={sampleRate:0,currentTime:0,AudioWorkletProcessor:function(){this.port=i},registerProcessor:function(c,h){e(r.$$context)[c]={realm:p,context:a,Processor:h,properties:h.parameterDescriptors||[]}}};a.self=a;var p=new function(c,h){var m=document.createElement("iframe");m.style.cssText="position:absolute;left:0;top:-999px;width:1px;height:1px;",h.appendChild(m);var w=m.contentWindow,g=w.document,d="var window,$hook";for(var v in w)v in c||v==="eval"||(d+=",",d+=v);for(var x in c)d+=",",d+=x,d+="=self.",d+=x;var C=g.createElement("script");C.appendChild(g.createTextNode(`function $hook(self,console) {"use strict";
          `+d+";return function() {return eval(arguments[0])}}")),g.body.appendChild(C),this.exec=w.$hook(c,console)}(a,document.documentElement);return p.exec((o&&o.transpile||String)(n)),null})},s}())})();var y=URL.createObjectURL(new Blob([function(){registerProcessor("writer-worklet",class extends AudioWorkletProcessor{constructor(){super();this.q=[],this.end=!1,this.cur=null,this.port.onmessage=i=>i.data===null?this.end=!0:this.q.push(i.data)}process([i],[u]){let f=u.length,l=u[0].length;for(;l>0;){if(!this.cur)if(this.cur=this.q.shift())this.port.postMessage(this.cur[0].length);else{if(this.end)return this.port.postMessage(null),!1;this.port.postMessage(0);break}if(this.cur[0].length>l){for(let e=0;e<f;e++)u[e].set(this.cur[e].subarray(0,l),u[e].length-l),this.cur[e]=this.cur[e].subarray(l);l=0}else{for(let e=0;e<f;e++)u[e].set(this.cur[e],u[e].length-l);l-=this.cur[0].length,this.cur=null}}return!0}})}.toString().slice(11,-1)],{type:"text/javascript"}));function k(i){i||(i=new AudioContext().destination);let u=i.context,f,l=u.audioWorklet.addModule(y).then(()=>{l=null,e.node=new AudioWorkletNode(u,"writer-worklet",{outputChannelCount:[i.channelCount]}),f=[],e.node.port.onmessage=t=>{f.shift()(t),t.data===null&&(e.node.closed=!0)},e.node.connect(i),e.node.write=e});function e(t){return e.then&&(e.then=null),l?l.then(()=>s(t)):s(t)}e.then=t=>{e.then=null,l.then(()=>t(e))};function s(t){if(e.node.closed)throw Error("Writer is closed");let o=t;if(t){if(t.getChannelData){o=[];for(let r=0;r<i.channelCount;r++)o[r]=r<t.numberOfChannels?t.getChannelData(r):new Float32Array}else if(typeof t[0]=="number"){o=[];let r=Math.floor(t.length/i.channelCount);for(let n=0;n<i.channelCount;n++)o[n]=t.subarray?t.subarray(n*r,n*r+r):new Float32Array(t.slice(n*r,n*r+r))}}return new Promise(r=>{f.push(r),e.node.port.postMessage(o)})}return e}export{k as default};
  //# sourceMappingURL=web-audio-write.min.js.map
  