@pexip/media-processor 16.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1047 -0
- package/LICENSE +188 -0
- package/README.md +193 -0
- package/dist/index.d.ts +1129 -0
- package/dist/index.mjs +2441 -0
- package/dist/worklets/denoise.worklet.js +2 -0
- package/dist/worklets/denoise.worklet.js.map +7 -0
- package/package.json +53 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";(()=>{var G=!0,g=String.fromCharCode,M={}.toString,H=M(),x=Uint8Array,A=x||Array,E=x?ArrayBuffer:A,q=E.isView||function(e){return e&&"length"in e},z=M.call(E.prototype);var N=T.prototype;var Z=/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,c=new(x?Uint16Array:A)(32);function D(){}D.prototype.decode=function(e){var t=e,s;if(!q(t)){if(s=M.call(t),s!==z&&s!==H)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");t=x?new A(t):t||[]}for(var o="",n="",a=0,r=t.length|0,i=r-32|0,d=0,w=0,f=0,u=0,l=0,m=0,p=0,b=-1;a<r;){for(d=a<=i?32:r-a|0;p<d;a=a+1|0,p=p+1|0){switch(f=t[a]&255,f>>4){case 15:if(m=t[a=a+1|0]&255,m>>6!==2||247<f){a=a-1|0;break}u=(f&7)<<6|m&63,l=5,f=256;case 14:m=t[a=a+1|0]&255,u<<=6,u|=(f&15)<<6|m&63,l=m>>6===2?l+4|0:24,f=f+256&768;case 13:case 12:m=t[a=a+1|0]&255,u<<=6,u|=(f&31)<<6|m&63,l=l+7|0,a<r&&m>>6===2&&u>>l&&u<1114112?(f=u,u=u-65536|0,0<=u?(b=(u>>10)+55296|0,f=(u&1023)+56320|0,p<31?(c[p]=b,p=p+1|0,b=-1):(m=b,b=f,f=m)):d=d+1|0):(f>>=8,a=a-f-1|0,f=65533),l=0,u=0,d=a<=i?32:r-a|0;default:c[p]=f;continue;case 11:case 10:case 9:case 8:}c[p]=65533}if(n+=g(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12],c[13],c[14],c[15],c[16],c[17],c[18],c[19],c[20],c[21],c[22],c[23],c[24],c[25],c[26],c[27],c[28],c[29],c[30],c[31]),p<32&&(n=n.slice(0,p-32|0)),a<r){if(c[0]=b,p=~b>>>31,b=-1,n.length<o.length)continue}else b!==-1&&(n+=g(b));o+=n,n=""}return o};function J(e){var t=e.charCodeAt(0)|0;if(55296<=t)if(t<=56319){var s=e.charCodeAt(1)|0;if(56320<=s&&s<=57343){if(t=(t<<10)+s-56613888|0,t>65535)return g(30<<3|t>>18,2<<6|t>>12&63,2<<6|t>>6&63,2<<6|t&63)}else t=65533}else t<=57343&&(t=65533);return t<=2047?g(6<<5|t>>6,2<<6|t&63):g(14<<4|t>>12,2<<6|t>>6&63,2<<6|t&63)}function T(){}N.encode=function(e){var t=e===void 0?"":""+e,s=t.length|0,o=new A((s<<1)+8|0),n,a=0,r=0,i=0,d=0,w=!x;for(a=0;a<s;a=a+1|0,r=r+1|0)if(i=t.charCodeAt(a)|0,i<=127)o[r]=i;else if(i<=2047)o[r]=6<<5|i>>6,o[r=r+1|0]=2<<6|i&63;else{e:{if(55296<=i)if(i<=56319){if(d=t.charCodeAt(a=a+1|0)|0,56320<=d&&d<=57343){if(i=(i<<10)+d-56613888|0,i>65535){o[r]=30<<3|i>>18,o[r=r+1|0]=2<<6|i>>12&63,o[r=r+1|0]=2<<6|i>>6&63,o[r=r+1|0]=2<<6|i&63;continue}break e}i=65533}else i<=57343&&(i=65533);!w&&a<<1<r&&a<<1<(r-7|0)&&(w=!0,n=new A(s*3),n.set(o),o=n)}o[r]=14<<4|i>>12,o[r=r+1|0]=2<<6|i>>6&63,o[r=r+1|0]=2<<6|i&63}return x?o.subarray(0,r):o.slice(0,r)};function K(e,t){var s=e===void 0?"":(""+e).replace(Z,J),o=s.length|0,n=0,a=0,r=0,i=t.length|0,d=e.length|0;i<o&&(o=i);e:for(;n<o;n=n+1|0){switch(a=s.charCodeAt(n)|0,a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:r=r+1|0;case 8:case 9:case 10:case 11:break;case 12:case 13:if((n+1|0)<i){r=r+1|0;break}case 14:if((n+2|0)<i){r=r+1|0;break}case 15:if((n+3|0)<i){r=r+1|0;break}default:break e}t[n]=a}return{written:n,read:d<r?d:r}}G&&(N.encodeInto=K);var re={},y,h=new Array(32).fill(void 0);h.push(void 0,null,!0,!1);function F(e){return h[e]}var _=h.length;function Q(e){e<36||(h[e]=_,_=e)}function X(e){let t=F(e);return Q(e),t}var W=new D("utf-8",{ignoreBOM:!0,fatal:!0});W.decode();var v=null;function S(){return(v===null||v.buffer!==y.memory.buffer)&&(v=new Uint8Array(y.memory.buffer)),v}function I(e,t){return W.decode(S().subarray(e,e+t))}function Y(e){_===h.length&&h.push(h.length+1);let t=_;return _=h[t],h[t]=e,t}var O=0,k=new T("utf-8"),$=typeof k.encodeInto=="function"?function(e,t){return k.encodeInto(e,t)}:function(e,t){let s=k.encode(e);return t.set(s),{read:e.length,written:s.length}};function ee(e,t,s){if(s===void 0){let i=k.encode(e),d=t(i.length);return S().subarray(d,d+i.length).set(i),O=i.length,d}let o=e.length,n=t(o),a=S(),r=0;for(;r<o;r++){let i=e.charCodeAt(r);if(i>127)break;a[n+r]=i}if(r!==o){r!==0&&(e=e.slice(r)),n=s(n,o,o=r+e.length*3);let i=S().subarray(n+r,n+o),d=$(e,i);r+=d.written}return O=r,n}var C=null;function R(){return(C===null||C.buffer!==y.memory.buffer)&&(C=new Int32Array(y.memory.buffer)),C}async function te(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(e.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let s=await e.arrayBuffer();return await WebAssembly.instantiate(s,t)}else{let s=await WebAssembly.instantiate(e,t);return s instanceof WebAssembly.Instance?{instance:s,module:e}:s}}async function B(e){typeof e>"u"&&(e=new URL("denoise_bg.wasm",re.url));let t={};t.wbg={},t.wbg.__wbg_new_693216e109162396=function(){var n=new Error;return Y(n)},t.wbg.__wbg_stack_0ddaca5d1abfb52f=function(n,a){var r=F(a).stack,i=ee(r,y.__wbindgen_malloc,y.__wbindgen_realloc),d=O;R()[n/4+1]=d,R()[n/4+0]=i},t.wbg.__wbg_error_09919627ac0992f5=function(n,a){try{console.error(I(n,a))}finally{y.__wbindgen_free(n,a)}},t.wbg.__wbindgen_object_drop_ref=function(n){X(n)},t.wbg.__wbindgen_throw=function(n,a){throw new Error(I(n,a))},(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:s,module:o}=await te(await e,t);return y=s.exports,B.__wbindgen_wasm_module=o,y}var L=B;var U=()=>typeof AudioWorkletProcessor<"u"&&typeof registerProcessor=="function";var P=(e,t)=>{e.forEach((s,o)=>s.forEach((n,a)=>{t(n,a,o)}))},V=(e,t)=>{P(t,(s,o,n)=>{let a=e[n]?.[o];a&&s.set(a)})},j=(e,t,s)=>{let o=e.denoise_new(s,t),n=!1,a=()=>new Float32Array(e.memory.buffer,e.denoise_input(o),s*t),r=()=>new Float32Array(e.memory.buffer,e.denoise_output(o),s*t);return{vad:i=>e.denoise_vad(o,i),free:()=>{let i=o;o=0,e.__wbg_denoise_free(i),n=!0},pipe:(i,d)=>{if(n)return;let w=a();P(i,(u,l)=>{w.set(u,l*u.length)}),e.denoise_process_frames(o);let f=r();P(d,(u,l)=>{u.set(f.slice(l*u.length,(l+1)*u.length))})}}};var ne=128;if(U()){class e extends AudioWorkletProcessor{constructor(o){super(o);this.processing=!0;this.shouldSendVAD=!1;this.enabled=!0;let n=o?.processorOptions;if(!n?.data)throw new Error("No WebAssembly data provided!");if(!n?.sampleRate)throw new Error("No Sample Rate provided!");this.shouldSendVAD=!!n?.shouldSendVAD;let a=o?.outputChannelCount?.[0]??1;L(n.data).then(r=>{this.denoise=j(r,a,ne)}),this.port.onmessage=r=>{switch(r.data.type){case"release":{this.denoise?.free(),this.processing=!1;break}case"enable":{this.enabled=r.data.value;break}default:break}}}process(o,n,a){return!this.denoise||!this.enabled||!this.processing?(V(o,n),this.processing):(this.denoise.pipe(o,n),this.shouldSendVAD&&this.port.postMessage(Array.from({length:o[0]?.length??2}).map((r,i)=>this.denoise?.vad(i))),this.processing)}}registerProcessor("denoise-processor",e)}})();
|
|
2
|
+
//# sourceMappingURL=denoise.worklet.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../denoise/EncoderDecoder.js", "../../../denoise/denoise.js", "../../src/utils.ts", "../../src/worklets/denoise.worklet.ts"],
|
|
4
|
+
"sourcesContent": ["/** @define {boolean} */\nvar ENCODEINTO_BUILD = true;\n\nvar fromCharCode = String.fromCharCode;\nvar Object_prototype_toString = {}.toString;\nvar undefinedObjectString = Object_prototype_toString();\nvar NativeUint8Array = Uint8Array;\nvar patchedU8Array = NativeUint8Array || Array;\nvar nativeArrayBuffer = NativeUint8Array ? ArrayBuffer : patchedU8Array;\nvar arrayBuffer_isView =\n nativeArrayBuffer.isView ||\n function (x) {\n return x && 'length' in x;\n };\nvar arrayBufferString = Object_prototype_toString.call(\n nativeArrayBuffer.prototype,\n);\nvar window_parseInt = parseInt;\nvar TextEncoderPrototype = TextEncoder['prototype'];\nvar decoderRegexp = /[\\xc0-\\xff][\\x80-\\xbf]+|[\\x80-\\xff]/g;\nvar encoderRegexp = /[\\x80-\\uD7ff\\uDC00-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g;\nvar tmpBufferU16 = new (NativeUint8Array ? Uint16Array : patchedU8Array)(32);\n\nfunction TextDecoder() {}\nTextDecoder['prototype']['decode'] = function (inputArrayOrBuffer) {\n var inputAs8 = inputArrayOrBuffer,\n asObjectString;\n if (!arrayBuffer_isView(inputAs8)) {\n asObjectString = Object_prototype_toString.call(inputAs8);\n if (\n asObjectString !== arrayBufferString &&\n asObjectString !== undefinedObjectString\n )\n throw TypeError(\n \"Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'\",\n );\n inputAs8 = NativeUint8Array\n ? new patchedU8Array(inputAs8)\n : inputAs8 || [];\n }\n\n var resultingString = '',\n tmpStr = '',\n index = 0,\n len = inputAs8.length | 0,\n lenMinus32 = (len - 32) | 0,\n nextEnd = 0,\n nextStop = 0,\n cp0 = 0,\n codePoint = 0,\n minBits = 0,\n cp1 = 0,\n pos = 0,\n tmp = -1;\n // Note that tmp represents the 2nd half of a surrogate pair incase a surrogate gets divided between blocks\n for (; index < len; ) {\n nextEnd = index <= lenMinus32 ? 32 : (len - index) | 0;\n for (; pos < nextEnd; index = (index + 1) | 0, pos = (pos + 1) | 0) {\n cp0 = inputAs8[index] & 0xff;\n switch (cp0 >> 4) {\n case 15:\n cp1 = inputAs8[(index = (index + 1) | 0)] & 0xff;\n if (cp1 >> 6 !== 0b10 || 0b11110111 < cp0) {\n index = (index - 1) | 0;\n break;\n }\n codePoint = ((cp0 & 0b111) << 6) | (cp1 & 0b00111111);\n minBits = 5; // 20 ensures it never passes -> all invalid replacements\n cp0 = 0x100; // keep track of th bit size\n case 14:\n cp1 = inputAs8[(index = (index + 1) | 0)] & 0xff;\n codePoint <<= 6;\n codePoint |= ((cp0 & 0b1111) << 6) | (cp1 & 0b00111111);\n minBits = cp1 >> 6 === 0b10 ? (minBits + 4) | 0 : 24; // 24 ensures it never passes -> all invalid replacements\n cp0 = (cp0 + 0x100) & 0x300; // keep track of th bit size\n case 13:\n case 12:\n cp1 = inputAs8[(index = (index + 1) | 0)] & 0xff;\n codePoint <<= 6;\n codePoint |= ((cp0 & 0b11111) << 6) | (cp1 & 0b00111111);\n minBits = (minBits + 7) | 0;\n\n // Now, process the code point\n if (\n index < len &&\n cp1 >> 6 === 0b10 &&\n codePoint >> minBits &&\n codePoint < 0x110000\n ) {\n cp0 = codePoint;\n codePoint = (codePoint - 0x10000) | 0;\n if (0 <= codePoint /*0xffff < codePoint*/) {\n // BMP code point\n //nextEnd = nextEnd - 1|0;\n\n tmp = ((codePoint >> 10) + 0xd800) | 0; // highSurrogate\n cp0 = ((codePoint & 0x3ff) + 0xdc00) | 0; // lowSurrogate (will be inserted later in the switch-statement)\n\n if (pos < 31) {\n // notice 31 instead of 32\n tmpBufferU16[pos] = tmp;\n pos = (pos + 1) | 0;\n tmp = -1;\n } else {\n // else, we are at the end of the inputAs8 and let tmp0 be filled in later on\n // NOTE that cp1 is being used as a temporary variable for the swapping of tmp with cp0\n cp1 = tmp;\n tmp = cp0;\n cp0 = cp1;\n }\n } else nextEnd = (nextEnd + 1) | 0; // because we are advancing i without advancing pos\n } else {\n // invalid code point means replacing the whole thing with null replacement characters\n cp0 >>= 8;\n index = (index - cp0 - 1) | 0; // reset index back to what it was before\n cp0 = 0xfffd;\n }\n\n // Finally, reset the variables for the next go-around\n minBits = 0;\n codePoint = 0;\n nextEnd = index <= lenMinus32 ? 32 : (len - index) | 0;\n /*case 11:\n\t\t\t\t\tcase 10:\n\t\t\t\t\tcase 9:\n\t\t\t\t\tcase 8:\n\t\t\t\t\t\tcodePoint ? codePoint = 0 : cp0 = 0xfffd; // fill with invalid replacement character\n\t\t\t\t\tcase 7:\n\t\t\t\t\tcase 6:\n\t\t\t\t\tcase 5:\n\t\t\t\t\tcase 4:\n\t\t\t\t\tcase 3:\n\t\t\t\t\tcase 2:\n\t\t\t\t\tcase 1:\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\ttmpBufferU16[pos] = cp0;\n\t\t\t\t\t\tcontinue;*/\n default:\n tmpBufferU16[pos] = cp0; // fill with invalid replacement character\n continue;\n case 11:\n case 10:\n case 9:\n case 8:\n }\n tmpBufferU16[pos] = 0xfffd; // fill with invalid replacement character\n }\n tmpStr += fromCharCode(\n tmpBufferU16[0],\n tmpBufferU16[1],\n tmpBufferU16[2],\n tmpBufferU16[3],\n tmpBufferU16[4],\n tmpBufferU16[5],\n tmpBufferU16[6],\n tmpBufferU16[7],\n tmpBufferU16[8],\n tmpBufferU16[9],\n tmpBufferU16[10],\n tmpBufferU16[11],\n tmpBufferU16[12],\n tmpBufferU16[13],\n tmpBufferU16[14],\n tmpBufferU16[15],\n tmpBufferU16[16],\n tmpBufferU16[17],\n tmpBufferU16[18],\n tmpBufferU16[19],\n tmpBufferU16[20],\n tmpBufferU16[21],\n tmpBufferU16[22],\n tmpBufferU16[23],\n tmpBufferU16[24],\n tmpBufferU16[25],\n tmpBufferU16[26],\n tmpBufferU16[27],\n tmpBufferU16[28],\n tmpBufferU16[29],\n tmpBufferU16[30],\n tmpBufferU16[31],\n );\n if (pos < 32) tmpStr = tmpStr.slice(0, (pos - 32) | 0); //-(32-pos));\n if (index < len) {\n //fromCharCode.apply(0, tmpBufferU16 : NativeUint8Array ? tmpBufferU16.subarray(0,pos) : tmpBufferU16.slice(0,pos));\n tmpBufferU16[0] = tmp;\n pos = ~tmp >>> 31; //tmp !== -1 ? 1 : 0;\n tmp = -1;\n\n if (tmpStr.length < resultingString.length) continue;\n } else if (tmp !== -1) {\n tmpStr += fromCharCode(tmp);\n }\n\n resultingString += tmpStr;\n tmpStr = '';\n }\n\n return resultingString;\n};\n//////////////////////////////////////////////////////////////////////////////////////\nfunction encoderReplacer(nonAsciiChars) {\n // make the UTF string into a binary UTF-8 encoded string\n var point = nonAsciiChars.charCodeAt(0) | 0;\n if (0xd800 <= point) {\n if (point <= 0xdbff) {\n var nextcode = nonAsciiChars.charCodeAt(1) | 0; // defaults to 0 when NaN, causing null replacement character\n\n if (0xdc00 <= nextcode && nextcode <= 0xdfff) {\n //point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;\n point = ((point << 10) + nextcode - 0x35fdc00) | 0;\n if (point > 0xffff)\n return fromCharCode(\n (0x1e /*0b11110*/ << 3) | (point >> 18),\n (0x2 /*0b10*/ << 6) |\n ((point >> 12) & 0x3f) /*0b00111111*/,\n (0x2 /*0b10*/ << 6) |\n ((point >> 6) & 0x3f) /*0b00111111*/,\n (0x2 /*0b10*/ << 6) | (point & 0x3f) /*0b00111111*/,\n );\n } else point = 65533 /*0b1111111111111101*/; //return '\\xEF\\xBF\\xBD';//fromCharCode(0xef, 0xbf, 0xbd);\n } else if (point <= 0xdfff) {\n point = 65533 /*0b1111111111111101*/; //return '\\xEF\\xBF\\xBD';//fromCharCode(0xef, 0xbf, 0xbd);\n }\n }\n /*if (point <= 0x007f) return nonAsciiChars;\n\t\telse */ if (point <= 0x07ff) {\n return fromCharCode(\n (0x6 << 5) | (point >> 6),\n (0x2 << 6) | (point & 0x3f),\n );\n } else\n return fromCharCode(\n (0xe /*0b1110*/ << 4) | (point >> 12),\n (0x2 /*0b10*/ << 6) | ((point >> 6) & 0x3f) /*0b00111111*/,\n (0x2 /*0b10*/ << 6) | (point & 0x3f) /*0b00111111*/,\n );\n}\nfunction TextEncoder() {}\nTextEncoderPrototype['encode'] = function (inputString) {\n // 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx\n // 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx\n var encodedString = inputString === void 0 ? '' : '' + inputString,\n len = encodedString.length | 0;\n var result = new patchedU8Array(((len << 1) + 8) | 0),\n tmpResult;\n var i = 0,\n pos = 0,\n point = 0,\n nextcode = 0;\n var upgradededArraySize = !NativeUint8Array; // normal arrays are auto-expanding\n for (i = 0; i < len; i = (i + 1) | 0, pos = (pos + 1) | 0) {\n point = encodedString.charCodeAt(i) | 0;\n if (point <= 0x007f) {\n result[pos] = point;\n } else if (point <= 0x07ff) {\n result[pos] = (0x6 << 5) | (point >> 6);\n result[(pos = (pos + 1) | 0)] = (0x2 << 6) | (point & 0x3f);\n } else {\n widenCheck: {\n if (0xd800 <= point) {\n if (point <= 0xdbff) {\n nextcode =\n encodedString.charCodeAt((i = (i + 1) | 0)) | 0; // defaults to 0 when NaN, causing null replacement character\n\n if (0xdc00 <= nextcode && nextcode <= 0xdfff) {\n //point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;\n point = ((point << 10) + nextcode - 0x35fdc00) | 0;\n if (point > 0xffff) {\n result[pos] =\n (0x1e /*0b11110*/ << 3) | (point >> 18);\n result[(pos = (pos + 1) | 0)] =\n (0x2 /*0b10*/ << 6) |\n ((point >> 12) & 0x3f) /*0b00111111*/;\n result[(pos = (pos + 1) | 0)] =\n (0x2 /*0b10*/ << 6) |\n ((point >> 6) & 0x3f) /*0b00111111*/;\n result[(pos = (pos + 1) | 0)] =\n (0x2 /*0b10*/ << 6) |\n (point & 0x3f) /*0b00111111*/;\n continue;\n }\n break widenCheck;\n }\n point = 65533 /*0b1111111111111101*/; //return '\\xEF\\xBF\\xBD';//fromCharCode(0xef, 0xbf, 0xbd);\n } else if (point <= 0xdfff) {\n point = 65533 /*0b1111111111111101*/; //return '\\xEF\\xBF\\xBD';//fromCharCode(0xef, 0xbf, 0xbd);\n }\n }\n if (\n !upgradededArraySize &&\n i << 1 < pos &&\n i << 1 < ((pos - 7) | 0)\n ) {\n upgradededArraySize = true;\n tmpResult = new patchedU8Array(len * 3);\n tmpResult.set(result);\n result = tmpResult;\n }\n }\n result[pos] = (0xe /*0b1110*/ << 4) | (point >> 12);\n result[(pos = (pos + 1) | 0)] =\n (0x2 /*0b10*/ << 6) | ((point >> 6) & 0x3f) /*0b00111111*/;\n result[(pos = (pos + 1) | 0)] =\n (0x2 /*0b10*/ << 6) | (point & 0x3f) /*0b00111111*/;\n }\n }\n return NativeUint8Array ? result.subarray(0, pos) : result.slice(0, pos);\n};\nfunction polyfill_encodeInto(inputString, u8Arr) {\n var encodedString =\n inputString === void 0\n ? ''\n : ('' + inputString).replace(encoderRegexp, encoderReplacer);\n var len = encodedString.length | 0,\n i = 0,\n char = 0,\n read = 0,\n u8ArrLen = u8Arr.length | 0,\n inputLength = inputString.length | 0;\n if (u8ArrLen < len) len = u8ArrLen;\n putChars: {\n for (; i < len; i = (i + 1) | 0) {\n char = encodedString.charCodeAt(i) | 0;\n switch (char >> 4) {\n case 0:\n case 1:\n case 2:\n case 3:\n case 4:\n case 5:\n case 6:\n case 7:\n read = (read + 1) | 0;\n // extension points:\n case 8:\n case 9:\n case 10:\n case 11:\n break;\n case 12:\n case 13:\n if (((i + 1) | 0) < u8ArrLen) {\n read = (read + 1) | 0;\n break;\n }\n case 14:\n if (((i + 2) | 0) < u8ArrLen) {\n //if (!(char === 0xEF && encodedString.substr(i+1|0,2) === \"\\xBF\\xBD\"))\n read = (read + 1) | 0;\n break;\n }\n case 15:\n if (((i + 3) | 0) < u8ArrLen) {\n read = (read + 1) | 0;\n break;\n }\n default:\n break putChars;\n }\n //read = read + ((char >> 6) !== 2) |0;\n u8Arr[i] = char;\n }\n }\n return {written: i, read: inputLength < read ? inputLength : read};\n}\nif (ENCODEINTO_BUILD) {\n TextEncoderPrototype['encodeInto'] = polyfill_encodeInto;\n}\n\nexport {TextEncoder, TextDecoder};\n", "import {TextDecoder, TextEncoder} from './EncoderDecoder';\n\nlet wasm;\n\nconst heap = new Array(32).fill(undefined);\n\nheap.push(undefined, null, true, false);\n\nfunction getObject(idx) {\n return heap[idx];\n}\n\nlet heap_next = heap.length;\n\nfunction dropObject(idx) {\n if (idx < 36) return;\n heap[idx] = heap_next;\n heap_next = idx;\n}\n\nfunction takeObject(idx) {\n const ret = getObject(idx);\n dropObject(idx);\n return ret;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', {\n ignoreBOM: true,\n fatal: true,\n});\n\ncachedTextDecoder.decode();\n\nlet cachegetUint8Memory0 = null;\nfunction getUint8Memory0() {\n if (\n cachegetUint8Memory0 === null ||\n cachegetUint8Memory0.buffer !== wasm.memory.buffer\n ) {\n cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachegetUint8Memory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));\n}\n\nfunction addHeapObject(obj) {\n if (heap_next === heap.length) heap.push(heap.length + 1);\n const idx = heap_next;\n heap_next = heap[idx];\n\n heap[idx] = obj;\n return idx;\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet cachedTextEncoder = new TextEncoder('utf-8');\n\nconst encodeString =\n typeof cachedTextEncoder.encodeInto === 'function'\n ? function (arg, view) {\n return cachedTextEncoder.encodeInto(arg, view);\n }\n : function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length,\n };\n };\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length);\n getUint8Memory0()\n .subarray(ptr, ptr + buf.length)\n .set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len);\n\n const mem = getUint8Memory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7f) break;\n mem[ptr + offset] = code;\n }\n\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, (len = offset + arg.length * 3));\n const view = getUint8Memory0().subarray(ptr + offset, ptr + len);\n const ret = encodeString(arg, view);\n\n offset += ret.written;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nlet cachegetInt32Memory0 = null;\nfunction getInt32Memory0() {\n if (\n cachegetInt32Memory0 === null ||\n cachegetInt32Memory0.buffer !== wasm.memory.buffer\n ) {\n cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);\n }\n return cachegetInt32Memory0;\n}\n/**\n */\nexport class Denoise {\n static __wrap(ptr) {\n const obj = Object.create(Denoise.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_denoise_free(ptr);\n }\n /**\n * @param {number} input_frame_size\n * @param {number} channel_size\n * @returns {Denoise}\n */\n static new(input_frame_size, channel_size) {\n var ret = wasm.denoise_new(input_frame_size, channel_size);\n return Denoise.__wrap(ret);\n }\n /**\n * @returns {number}\n */\n input() {\n var ret = wasm.denoise_input(this.ptr);\n return ret;\n }\n /**\n * @returns {number}\n */\n output() {\n var ret = wasm.denoise_output(this.ptr);\n return ret;\n }\n /**\n * @param {number} channel\n * @returns {number}\n */\n vad(channel) {\n var ret = wasm.denoise_vad(this.ptr, channel);\n return ret;\n }\n /**\n */\n process_frames() {\n wasm.denoise_process_frames(this.ptr);\n }\n}\n\nasync function load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n if (module.headers.get('Content-Type') != 'application/wasm') {\n console.warn(\n '`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n',\n e,\n );\n } else {\n throw e;\n }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return {instance, module};\n } else {\n return instance;\n }\n }\n}\n\nasync function init(input) {\n if (typeof input === 'undefined') {\n input = new URL('denoise_bg.wasm', import.meta.url);\n }\n const imports = {};\n imports.wbg = {};\n imports.wbg.__wbg_new_693216e109162396 = function () {\n var ret = new Error();\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_stack_0ddaca5d1abfb52f = function (arg0, arg1) {\n var ret = getObject(arg1).stack;\n var ptr0 = passStringToWasm0(\n ret,\n wasm.__wbindgen_malloc,\n wasm.__wbindgen_realloc,\n );\n var len0 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len0;\n getInt32Memory0()[arg0 / 4 + 0] = ptr0;\n };\n imports.wbg.__wbg_error_09919627ac0992f5 = function (arg0, arg1) {\n try {\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_free(arg0, arg1);\n }\n };\n imports.wbg.__wbindgen_object_drop_ref = function (arg0) {\n takeObject(arg0);\n };\n imports.wbg.__wbindgen_throw = function (arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n };\n\n if (\n typeof input === 'string' ||\n (typeof Request === 'function' && input instanceof Request) ||\n (typeof URL === 'function' && input instanceof URL)\n ) {\n input = fetch(input);\n }\n\n const {instance, module} = await load(await input, imports);\n\n wasm = instance.exports;\n init.__wbindgen_wasm_module = module;\n\n return wasm;\n}\n\nexport default init;\n", "import type {InitOutput} from '@pexip/denoise/denoise';\n\nimport type {Denoise, Clock, Callback} from './types';\n\nexport const hasAudioContext = () => typeof AudioContext !== 'undefined';\n\nexport const hasCreateGain = (context: BaseAudioContext) =>\n typeof context.createGain !== 'undefined';\n\nexport const hasAudioWorkletProcessor = () =>\n typeof AudioWorkletProcessor !== 'undefined' &&\n typeof registerProcessor === 'function';\n\nexport const hasAudioWorkletNode = () =>\n typeof AudioWorkletNode !== 'undefined';\n\nexport const hasAudioWorklet = () =>\n typeof AudioWorklet !== 'undefined' && hasAudioWorkletNode();\n\nconst stopTrack = (track: MediaStreamTrack) => track.stop();\n\nexport const stopStreamTracks = (stream?: MediaStream) =>\n stream?.getTracks().forEach(stopTrack);\n\n/**\n * The callback per iteration\n *\n * @param frame - The frame from the source buffer\n * @param channel - The channel number\n * @param input - The input number\n */\ntype FrameModifyFn = (\n frame: Float32Array,\n channel: number,\n input: number,\n) => void;\n\n/**\n * Iterating the provided frames and call the callback with the data and indices\n *\n * @param frames - The source frames to be iterated\n * @param modifierCallback - The callback function to be called per iteration\n */\nexport const getFrame = (\n frames: Float32Array[][],\n modifierCallback: FrameModifyFn,\n) => {\n frames.forEach((channels, i) =>\n channels.forEach((frame, c) => {\n modifierCallback(frame, c, i);\n }),\n );\n};\n\n/**\n * Connect the inputs and output without any changes\n */\nexport const connectInputsOutputs = (\n inputs: Float32Array[][],\n outputs: Float32Array[][],\n) => {\n getFrame(outputs, (output, channel_index, input_index) => {\n const input = inputs[input_index]?.[channel_index];\n if (input) {\n output.set(input);\n }\n });\n};\n\n/**\n * A wrapper for Denoise from the WASM module, extracted and refactored from the\n * generated denoise.js, which maps the WASM functions to js\n *\n * @param wasm - Wasm module exports with types from `wasm_bindgen` generated\n * @param channelCount - number of channels\n * @param frameSize - frame size\n */\nexport const createDenoise = (\n wasm: InitOutput,\n channelCount: number,\n frameSize: number,\n): Denoise => {\n let ptr = wasm.denoise_new(frameSize, channelCount);\n let freed = false;\n\n const getInputBufferDataView = () =>\n new Float32Array(\n wasm.memory.buffer,\n wasm.denoise_input(ptr),\n frameSize * channelCount,\n );\n\n const getOutputBufferDataView = () =>\n new Float32Array(\n wasm.memory.buffer,\n wasm.denoise_output(ptr),\n frameSize * channelCount,\n );\n\n return {\n vad: (channel: number) => {\n return wasm.denoise_vad(ptr, channel);\n },\n\n free: () => {\n const tmpPtr = ptr;\n ptr = 0;\n wasm.__wbg_denoise_free(tmpPtr);\n freed = true;\n },\n\n pipe: (inputs, outputs) => {\n if (freed) {\n return;\n }\n const inputBuffer = getInputBufferDataView();\n // Update inputBuffer accordingly from inputs\n getFrame(inputs, (input, channel) => {\n inputBuffer.set(input, channel * input.length);\n });\n\n wasm.denoise_process_frames(ptr);\n\n const outputBuffer = getOutputBufferDataView();\n // Update outputs from outputBuffer accordingly\n getFrame(outputs, (output, channel) => {\n output.set(\n outputBuffer.slice(\n channel * output.length,\n (channel + 1) * output.length,\n ),\n );\n });\n },\n };\n};\n\n/**\n * A function to create `MediaStreamAudioSourceNode` using constructor or factory\n * function depends on the browser supports\n *\n * @param context - @see {@link AudioContext}\n * @param options - @see {@link MediaStreamAudioSourceOptions}\n *\n * @internal\n */\nexport const createMediaStreamAudioSourceNode = (\n context: AudioContext,\n options: MediaStreamAudioSourceOptions,\n) => {\n try {\n const source = new MediaStreamAudioSourceNode(context, options);\n return source;\n } catch {\n return context.createMediaStreamSource(options.mediaStream);\n }\n};\n\n/**\n * A function to create `MediaStreamAudioSourceNode` using constructor or factory\n * function depends on the browser supports\n *\n * @param context - @see {@link AudioContext}\n * @param options - @see {@link MediaStreamAudioSourceOptions}\n *\n * @internal\n */\nexport const createMediaElementSourceNode = (\n context: AudioContext,\n options: MediaElementAudioSourceOptions,\n) => {\n try {\n const source = new MediaElementAudioSourceNode(context, options);\n return source;\n } catch {\n return context.createMediaElementSource(options.mediaElement);\n }\n};\n\n/**\n * A function to set AudioNodeOptions accordingly\n */\nconst setAudioNodeOptions = (node: AudioNode, options?: AudioNodeOptions) => {\n if (options?.channelCount) {\n node.channelCount = options.channelCount;\n }\n if (options?.channelCountMode) {\n node.channelCountMode = options.channelCountMode;\n }\n if (options?.channelInterpretation) {\n node.channelInterpretation = options.channelInterpretation;\n }\n};\n\n/**\n * A function to create `AnalyserNode` using constructor or factory\n * function depends on the browser supports\n *\n * @param audioContext - @see {@link AudioContext}\n * @param options - @see {@link AnalyserOptions}\n *\n * @internal\n */\nexport const createAnalyserNode = (\n audioContext: BaseAudioContext,\n options?: AnalyserOptions,\n) => {\n try {\n const analyser = new AnalyserNode(audioContext, options);\n return analyser;\n } catch {\n const analyser = audioContext.createAnalyser();\n options?.fftSize && (analyser.fftSize = options.fftSize);\n options?.maxDecibels && (analyser.maxDecibels = options.maxDecibels);\n options?.minDecibels && (analyser.minDecibels = options.minDecibels);\n options?.smoothingTimeConstant &&\n (analyser.smoothingTimeConstant = options.smoothingTimeConstant);\n setAudioNodeOptions(analyser, options);\n return analyser;\n }\n};\n\n/**\n * A function to create `GainNode` using constructor or factory\n * function depends on the browser supports\n *\n * @param context - @see {@link AudioContext}\n * @param options - @see {@link GainOptions}\n *\n * @internal\n */\nexport const createGainNode = (\n context: BaseAudioContext,\n options?: GainOptions,\n) => {\n try {\n const volume = new GainNode(context, options);\n return volume;\n } catch {\n const volume = hasCreateGain(context)\n ? context.createGain()\n : (context as webkitAudioContext).createGainNode();\n if (options?.gain) {\n volume.gain.setValueAtTime(options.gain, context.currentTime);\n }\n setAudioNodeOptions(volume, options);\n return volume;\n }\n};\n\n/**\n * A function to clone the Audio Track\n *\n * @param stream - Stream to be cloned\n *\n * @internal\n */\nexport const createMediaStreamAudioClone = (stream: MediaStream) => {\n try {\n const mediaStream = new MediaStream(\n stream.getAudioTracks().map(track => track.clone()),\n );\n return mediaStream;\n } catch {\n return stream.clone();\n }\n};\n\n/**\n * A function to create `MediaStreamAudioDestinationNode` using constructor or\n * factory function depends on the browser supports\n *\n * @param context - @see {@link AudioContext}\n * @param options - @see {@link AudioNodeOptions}\n *\n * @internal\n */\nexport const createMediaStreamAudioDestinationNode = (\n context: AudioContext,\n options?: AudioNodeOptions,\n) => {\n try {\n const destination = new MediaStreamAudioDestinationNode(\n context,\n options,\n );\n return destination;\n } catch {\n const destination = context.createMediaStreamDestination();\n setAudioNodeOptions(destination, options);\n return destination;\n }\n};\n\n/**\n * A function to create `DelayNode` using constructor or\n * factory function depends on the browser supports\n *\n * @param context - @see {@link AudioContext}\n * @param options - @see {@link DelayOptions}\n *\n * @internal\n */\nexport const createDelayNode = (\n context: AudioContext,\n options?: DelayOptions,\n): DelayNode => {\n try {\n const delay = new DelayNode(context, options);\n return delay;\n } catch {\n const delay = context.createDelay(options?.maxDelayTime);\n if (options?.delayTime !== undefined) {\n delay.delayTime.setValueAtTime(\n options?.delayTime,\n context.currentTime,\n );\n }\n setAudioNodeOptions(delay, options);\n return delay;\n }\n};\n\n/**\n * A function to create `ChannelSplitterNode` using constructor or\n * factory function depends on the browser supports\n *\n * @param context - @see {@link AudioContext}\n * @param options - @see {@link ChannelSplitterOptions}\n *\n * @internal\n */\nexport const createChannelSplitterNode = (\n context: AudioContext,\n options?: ChannelSplitterOptions,\n): ChannelSplitterNode => {\n try {\n const node = new ChannelSplitterNode(context, options);\n return node;\n } catch {\n const node = context.createChannelSplitter(options?.numberOfOutputs);\n setAudioNodeOptions(node, options);\n return node;\n }\n};\n\n/**\n * A function to create `ChannelMergerNode` using constructor or\n * factory function depends on the browser supports\n *\n * @param context - @see {@link AudioContext}\n * @param options - @see {@link ChannelSplitterOptions}\n *\n * @internal\n */\nexport const createChannelMergerNode = (\n context: AudioContext,\n options?: ChannelMergerOptions,\n): ChannelMergerNode => {\n try {\n const node = new ChannelMergerNode(context, options);\n return node;\n } catch {\n const node = context.createChannelMerger(options?.numberOfInputs);\n setAudioNodeOptions(node, options);\n return node;\n }\n};\n\n/**\n * Map mute value to gain value\n *\n * ```\n * `true` -> 0\n * `false` -> 1\n * ```\n */\nexport const muteToGain = (mute: boolean): number => (mute ? 0 : 1);\n\n/**\n * Calculate the timeout based on the provided data and returns a timeout in\n * milliseconds with compensation added\n *\n * @param targetTime - The target timeout after the compensation\n * @param startTime - The start time of the last execution\n * @param endTime - The end time of the last execution\n */\nexport const calculateNextTimeout = (\n targetTime: number,\n startTime: number,\n endTime: number,\n) => Math.max(targetTime - Math.max(endTime - startTime, 0), 0);\n\ntype Timeouts = Pick<WindowOrWorkerGlobalScope, 'setTimeout' | 'clearTimeout'>;\n\n/**\n * @param delayInMS - Delay in terms of milliseconds\n * @param params - The parameters to be passed to the provided callback\n */\ntype DelayCallback<P extends unknown[], R> = (\n delayInMS: number,\n ...params: P\n) => Promise<void | R>;\n/**\n * Cancel the delay created by the @see {@link createDelayedCallback}, when it\n * is invoked the ongoing delay will be resolved immediately\n */\ntype CancelDelay = () => void;\n\n/**\n * Convert a callback to an async callback with delay added\n *\n * @param callback - The callback to be delayed\n * @param options - The options to inject dependences\n *\n * @example\n *\n * ```typescript\n * const getRandom = () => Math.random();\n * const [delayGetRandom, cancelDelayGetRandom] = createDelayedCallback(getRandom);\n *\n * // Delay 500 ms to get the random number\n * const random = await delayGetRandom(500);\n * ```\n */\nexport const createDelayedCallback = <R, P extends unknown[]>(\n callback: Callback<R, P>,\n {\n setTimeout = window.setTimeout,\n clearTimeout = window.clearTimeout,\n }: Partial<Timeouts> = {},\n): [DelayCallback<P, R>, CancelDelay] => {\n const props: {\n timeoutID: number;\n cancel?: () => void;\n } = {\n timeoutID: 0,\n };\n\n const cancelTimeout = () => {\n if (props.timeoutID) {\n clearTimeout(props.timeoutID);\n props.timeoutID = 0;\n }\n };\n\n const delayedCallback = async (delayMs: number, ...params: P) => {\n const resolved = await new Promise<R | void>(resolve => {\n cancelTimeout();\n props.timeoutID = setTimeout(() => {\n const result = callback(...params);\n if (result instanceof Promise) {\n result\n .then(resolved => resolve(resolved))\n .catch(e => {\n throw e;\n });\n } else {\n resolve(result);\n }\n }, delayMs);\n props.cancel = resolve;\n });\n return resolved;\n };\n\n const cancel = () => {\n cancelTimeout();\n props.cancel?.();\n };\n\n return [delayedCallback, cancel];\n};\n\n/**\n * Convert the rate to milliseconds\n */\nconst rateToMs = (rate: number) => Math.ceil(1000 / rate);\n\ntype AsyncCallbackLoopOptions = Timeouts &\n Pick<Performance, 'now'> & {frameRate: number};\n\n/**\n * Create an async callback loop to be called recursively with delay based on\n * the `frameRate`\n *\n * @param callback - The callback to be invoked\n * @param frameRate - The rate to be expected to invoke the `callback`\n */\nexport const createAsyncCallbackLoop = <\n P extends unknown[],\n R extends Promise<unknown>,\n>(\n callback: Callback<R, P>,\n frameRate: number,\n {\n setTimeout = window.setTimeout,\n clearTimeout = window.clearTimeout,\n now = () => performance.now(),\n }: Partial<AsyncCallbackLoopOptions> = {},\n) => {\n const props = {\n frameRate,\n targetMs: rateToMs(frameRate),\n prevCalledMs: 0,\n timeoutID: 0,\n stopped: false,\n };\n const [delayedCallback, cancel] = createDelayedCallback(callback, {\n setTimeout,\n clearTimeout,\n });\n\n const fork = async (...params: P) => {\n if (props.stopped) {\n return;\n }\n const currentMs = now();\n const nextMs = calculateNextTimeout(\n props.targetMs,\n props.prevCalledMs,\n currentMs,\n );\n props.prevCalledMs = currentMs;\n await delayedCallback(nextMs, ...params);\n await fork(...params);\n };\n\n return {\n start: async (...params: P) => {\n props.prevCalledMs = now();\n props.stopped = false;\n\n await delayedCallback(0, ...params);\n\n void fork(...params);\n },\n stop: () => {\n props.stopped = true;\n cancel();\n },\n get frameRate() {\n return props.frameRate;\n },\n set frameRate(value: number) {\n props.frameRate = value;\n props.targetMs = rateToMs(value);\n },\n };\n};\n\nexport const DEFAULT_THROTTLE_MS = 3000;\n\n/**\n * A function to limit the provided callback being called too frequently, and\n * assuming the function is called repeatably, and NOT for general purpose.\n *\n * @param callback - the callback to be called under the specified time\n * @param throttleMs - the specified time for throttling\n * @param clock - how to get the current time\n */\nexport const throttleProcess = <P extends unknown[]>(\n callback: Callback<void, P>,\n throttleMs = DEFAULT_THROTTLE_MS,\n clock: Clock = performance,\n) => {\n let lastCall = 0;\n return (...params: P) => {\n const now = clock.now();\n if (now - lastCall >= throttleMs) {\n callback(...params);\n lastCall = now;\n }\n };\n};\n\ntype Unsubscribe = () => void;\n\n/**\n * Subscribe visibilitychange event\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilitychange_event}\n *\n * @param callback - A callback to be called with `document.hidden` when the event is trigger\n */\nexport const subscribeVisibilityChangeEvent = (\n callback: (hidden: boolean) => Promise<void>,\n): Unsubscribe => {\n const handleEvent = () => {\n callback(document.hidden).catch(error => {\n throw error;\n });\n };\n document.addEventListener('visibilitychange', handleEvent);\n return () => {\n document.removeEventListener('visibilitychange', handleEvent);\n };\n};\n", "import init from '@pexip/denoise/denoise';\n\nimport type {\n WasmWorkletNodeOptions,\n Denoise,\n AudioProcessorMessageEvent,\n} from '../types';\nimport {\n createDenoise,\n hasAudioWorkletProcessor,\n connectInputsOutputs,\n} from '../utils';\n\n// Ref. https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletProcessor/process\nconst FRAME_SIZE = 128;\n\nif (hasAudioWorkletProcessor()) {\n // wasm-bindgen\n class DenoiseProcessor extends AudioWorkletProcessor {\n private denoise?: Denoise;\n private processing = true;\n private shouldSendVAD = false;\n private enabled = true;\n\n constructor(options?: WasmWorkletNodeOptions) {\n super(options);\n const wasmOptions = options?.processorOptions;\n if (!wasmOptions?.data) {\n throw new Error('No WebAssembly data provided!');\n }\n if (!wasmOptions?.sampleRate) {\n throw new Error('No Sample Rate provided!');\n }\n this.shouldSendVAD = !!wasmOptions?.shouldSendVAD;\n\n // Ref. https://webaudio.github.io/web-audio-api/#configuring-channels-with-audioworkletnodeoptions\n const channelCount = options?.outputChannelCount?.[0] ?? 1;\n\n void init(wasmOptions.data).then(wasm => {\n this.denoise = createDenoise(wasm, channelCount, FRAME_SIZE);\n });\n\n this.port.onmessage = (event: AudioProcessorMessageEvent) => {\n switch (event.data.type) {\n case 'release': {\n this.denoise?.free();\n this.processing = false;\n break;\n }\n case 'enable': {\n this.enabled = event.data.value;\n break;\n }\n default:\n break;\n }\n };\n }\n\n process(\n inputs: Float32Array[][],\n outputs: Float32Array[][],\n _parameters: Record<string, Float32Array>,\n ) {\n if (!this.denoise || !this.enabled || !this.processing) {\n // Do nothing but wire the inputs and outputs\n connectInputsOutputs(inputs, outputs);\n return this.processing;\n }\n\n this.denoise.pipe(inputs, outputs);\n\n this.shouldSendVAD &&\n this.port.postMessage(\n Array.from({length: inputs[0]?.length ?? 2}).map(\n (_, channel) => this.denoise?.vad(channel),\n ),\n );\n\n return this.processing;\n }\n }\n registerProcessor('denoise-processor', DenoiseProcessor);\n}\n"],
|
|
5
|
+
"mappings": "mBACA,IAAIA,EAAmB,GAEnBC,EAAe,OAAO,aACtBC,EAA4B,CAAC,EAAE,SAC/BC,EAAwBD,EAA0B,EAClDE,EAAmB,WACnBC,EAAiBD,GAAoB,MAC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ype_toString", "undefinedObjectString", "NativeUint8Array", "patchedU8Array", "nativeArrayBuffer", "arrayBuffer_isView", "x", "arrayBufferString", "TextEncoderPrototype", "TextEncoder", "encoderRegexp", "tmpBufferU16", "NativeUint8Array", "patchedU8Array", "TextDecoder", "inputArrayOrBuffer", "inputAs8", "asObjectString", "arrayBuffer_isView", "Object_prototype_toString", "arrayBufferString", "undefinedObjectString", "resultingString", "tmpStr", "index", "len", "lenMinus32", "nextEnd", "nextStop", "cp0", "codePoint", "minBits", "cp1", "pos", "tmp", "fromCharCode", "encoderReplacer", "nonAsciiChars", "point", "nextcode", "TextEncoder", "TextEncoderPrototype", "inputString", "encodedString", "result", "tmpResult", "i", "upgradededArraySize", "widenCheck", "polyfill_encodeInto", "u8Arr", "char", "read", "u8ArrLen", "inputLength", "putChars", "ENCODEINTO_BUILD", "import_meta", "wasm", "heap", "getObject", "idx", "heap_next", "dropObject", "takeObject", "ret", "cachedTextDecoder", "TextDecoder", "cachegetUint8Memory0", "getUint8Memory0", "getStringFromWasm0", "ptr", "len", "addHeapObject", "obj", "WASM_VECTOR_LEN", "cachedTextEncoder", "TextEncoder", "encodeString", "arg", "view", "buf", "passStringToWasm0", "malloc", "realloc", "mem", "offset", "code", "cachegetInt32Memory0", "getInt32Memory0", "load", "module", "imports", "e", "bytes", "instance", "init", "input", "import_meta", "ret", "addHeapObject", "arg0", "arg1", "getObject", "ptr0", "passStringToWasm0", "wasm", "len0", "WASM_VECTOR_LEN", "getInt32Memory0", "getStringFromWasm0", "takeObject", "denoise_default", "hasAudioWorkletProcessor", "getFrame", "frames", "modifierCallback", "channels", "i", "frame", "c", "connectInputsOutputs", "inputs", "outputs", "output", "channel_index", "input_index", "input", "createDenoise", "wasm", "channelCount", "frameSize", "ptr", "freed", "getInputBufferDataView", "getOutputBufferDataView", "channel", "tmpPtr", "inputBuffer", "outputBuffer", "FRAME_SIZE", "hasAudioWorkletProcessor", "DenoiseProcessor", "options", "wasmOptions", "channelCount", "denoise_default", "wasm", "createDenoise", "event", "inputs", "outputs", "_parameters", "connectInputsOutputs", "_", "channel"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pexip/media-processor",
|
|
3
|
+
"version": "16.7.0",
|
|
4
|
+
"description": "Media processor for video and audio",
|
|
5
|
+
"homepage": "https://gitlab.com/pexip/zoo",
|
|
6
|
+
"bugs": "https://gitlab.com/pexip/zoo/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://gitlab.com/pexip/zoo.git",
|
|
10
|
+
"directory": "src/aquila/packages/media-processor"
|
|
11
|
+
},
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"module": "dist/index.mjs",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"directories": {
|
|
16
|
+
"lib": "dist",
|
|
17
|
+
"test": "__tests__"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "pexip-bundler build && yarn build:worklets",
|
|
24
|
+
"build:denoise": "cd denoise && wasm-pack build -t web && printf '%s\n%s\n' \"import {TextDecoder, TextEncoder} from './EncoderDecoder';\" \"$(cat ./pkg/denoise.js)\" >./pkg/denoise.js && prettier --write pkg && cp pkg/denoise* ../../denoise/",
|
|
25
|
+
"build:worklets": "pexip-bundler build --bundler=esbuild -o dist/worklets -b src/worklets/*.ts",
|
|
26
|
+
"clean": "rm -fr dist",
|
|
27
|
+
"prepack": "yarn build",
|
|
28
|
+
"test": "pexip-bundler test",
|
|
29
|
+
"tsc": "tsc --noEmit",
|
|
30
|
+
"check-format": "prettier --ignore-path=../../.prettierignore --check .",
|
|
31
|
+
"format": "prettier --ignore-path=../../.prettierignore --write .",
|
|
32
|
+
"lint": "yarn run -T eslint --ext .js,.ts,.tsx --report-unused-disable-directives .",
|
|
33
|
+
"typecheck": "yarn tsc --noEmit -p ."
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@pexip/bg-blur": "16.4.0",
|
|
37
|
+
"@pexip/denoise": "16.3.0",
|
|
38
|
+
"@pexip/utils": "16.5.0",
|
|
39
|
+
"@tensorflow/tfjs-backend-webgl": "^4.0.0",
|
|
40
|
+
"@tensorflow/tfjs-core": "^4.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@pexip/bundler": "16.3.0",
|
|
44
|
+
"@types/dom-webcodecs": "^0.1.4",
|
|
45
|
+
"@types/offscreencanvas": "^2019.7.0",
|
|
46
|
+
"@types/trusted-types": "^2.0.2",
|
|
47
|
+
"typescript": "~5.0.0"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public",
|
|
51
|
+
"registry": "https://registry.npmjs.org"
|
|
52
|
+
}
|
|
53
|
+
}
|