@mimium/mimium-webaudio 2.0.0 → 4.0.0-alpha.4

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.
@@ -1,2 +1,741 @@
1
- (function(t){function e(){}e.prototype.encode=function(r){for(var o=[],i=r.length,s=0;s<i;){var c=r.codePointAt(s),a=0,l=0;for(c<=127?(a=0,l=0):c<=2047?(a=6,l=192):c<=65535?(a=12,l=224):c<=2097151&&(a=18,l=240),o.push(l|c>>a),a-=6;a>=0;)o.push(128|c>>a&63),a-=6;s+=c>=65536?2:1}return o},globalThis.TextEncoder=e,t.TextEncoder||(t.TextEncoder=e);function n(){}n.prototype.decode=function(r){if(!r)return"";for(var o="",i=0;i<r.length;){var s=r[i],c=0,a=0;if(s<=127?(c=0,a=s&255):s<=223?(c=1,a=s&31):s<=239?(c=2,a=s&15):s<=244&&(c=3,a=s&7),r.length-i-c>0)for(var l=0;l<c;)s=r[i+l+1],a=a<<6|s&63,l+=1;else a=65533,c=r.length-i;o+=String.fromCodePoint(a),i+=c+1}return o},globalThis.TextDecoder=n,t.TextDecoder||(t.TextDecoder=n)})(typeof globalThis>"u"?typeof global>"u"?typeof self>"u"?void 0:self:global:globalThis);function W(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){var o=!1;try{o=this instanceof r}catch{}return o?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return t[r]}})}),n}var v={};const k={},L=Object.freeze(Object.defineProperty({__proto__:null,default:k},Symbol.toStringTag,{value:"Module"})),$=W(L);var E;function R(){if(E)return v;E=1;const t=$;function e(r){return t.readFileSync(r,{encoding:"utf8"})}v.read_file=e;function n(r){return process.env[r]}return v.get_env=n,v}var B=R();let _;function p(t){const e=_.__externref_table_alloc();return _.__wbindgen_export_2.set(e,t),e}function I(t,e){try{return t.apply(this,e)}catch(n){const r=p(n);_.__wbindgen_exn_store(r)}}let h=null;function d(){return(h===null||h.byteLength===0)&&(h=new Uint8Array(_.memory.buffer)),h}let u=0;function N(t,e){const n=e(t.length*1,1)>>>0;return d().set(t,n/1),u=t.length,n}let b=null;function g(){return(b===null||b.buffer.detached===!0||b.buffer.detached===void 0&&b.buffer!==_.memory.buffer)&&(b=new DataView(_.memory.buffer)),b}const M=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&M.decode();function O(t,e){return t=t>>>0,M.decode(d().subarray(t,t+e))}const A=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},U=typeof A.encodeInto=="function"?function(t,e){return A.encodeInto(t,e)}:function(t,e){const n=A.encode(t);return e.set(n),{read:t.length,written:n.length}};function w(t,e,n){if(n===void 0){const c=A.encode(t),a=e(c.length,1)>>>0;return d().subarray(a,a+c.length).set(c),u=c.length,a}let r=t.length,o=e(r,1)>>>0;const i=d();let s=0;for(;s<r;s++){const c=t.charCodeAt(s);if(c>127)break;i[o+s]=c}if(s!==r){s!==0&&(t=t.slice(s)),o=n(o,r,r=s+t.length*3,1)>>>0;const c=d().subarray(o+s,o+r),a=U(t,c);s+=a.written,o=n(o,r,s,1)>>>0}return u=s,o}function y(t){return t==null}const j=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>{_.__wbindgen_export_6.get(t.dtor)(t.a,t.b)});function F(t,e,n,r){const o={a:t,b:e,cnt:1,dtor:n},i=(...s)=>{o.cnt++;const c=o.a;o.a=0;try{return r(c,o.b,...s)}finally{--o.cnt===0?(_.__wbindgen_export_6.get(o.dtor)(c,o.b),j.unregister(o)):o.a=c}};return i.original=o,j.register(i,o,o),i}function q(t,e){return t=t>>>0,d().subarray(t/1,t/1+e)}function T(t){const e=typeof t;if(e=="number"||e=="boolean"||t==null)return`${t}`;if(e=="string")return`"${t}"`;if(e=="symbol"){const o=t.description;return o==null?"Symbol":`Symbol(${o})`}if(e=="function"){const o=t.name;return typeof o=="string"&&o.length>0?`Function(${o})`:"Function"}if(Array.isArray(t)){const o=t.length;let i="[";o>0&&(i+=T(t[0]));for(let s=1;s<o;s++)i+=", "+T(t[s]);return i+="]",i}const n=/\[object ([^\]]+)\]/.exec(toString.call(t));let r;if(n&&n.length>1)r=n[1];else return toString.call(t);if(r=="Object")try{return"Object("+JSON.stringify(t)+")"}catch{return"Object"}return t instanceof Error?`${t.name}: ${t.message}
2
- ${t.stack}`:r}function C(t,e){if(!(t instanceof e))throw new Error(`expected instance of ${e.name}`)}let m=null;function G(){return(m===null||m.byteLength===0)&&(m=new Float32Array(_.memory.buffer)),m}function D(t,e){const n=e(t.length*4,4)>>>0;return G().set(t,n/4),u=t.length,n}function H(t,e,n){_.closure60_externref_shim(t,e,n)}function J(t,e,n){_.closure73_externref_shim(t,e,n)}function V(t,e,n,r){_.closure89_externref_shim(t,e,n,r)}const S=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>_.__wbg_config_free(t>>>0,1));class x{static __wrap(e){e=e>>>0;const n=Object.create(x.prototype);return n.__wbg_ptr=e,S.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,S.unregister(this),e}free(){const e=this.__destroy_into_raw();_.__wbg_config_free(e,0)}get sample_rate(){return _.__wbg_get_config_sample_rate(this.__wbg_ptr)}set sample_rate(e){_.__wbg_set_config_sample_rate(this.__wbg_ptr,e)}get input_channels(){return _.__wbg_get_config_input_channels(this.__wbg_ptr)>>>0}set input_channels(e){_.__wbg_set_config_input_channels(this.__wbg_ptr,e)}get output_channels(){return _.__wbg_get_config_output_channels(this.__wbg_ptr)>>>0}set output_channels(e){_.__wbg_set_config_output_channels(this.__wbg_ptr,e)}get buffer_size(){return _.__wbg_get_config_buffer_size(this.__wbg_ptr)>>>0}set buffer_size(e){_.__wbg_set_config_buffer_size(this.__wbg_ptr,e)}static new(){const e=_.config_new();return x.__wrap(e)}}const z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>_.__wbg_context_free(t>>>0,1));class K{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,z.unregister(this),e}free(){const e=this.__destroy_into_raw();_.__wbg_context_free(e,0)}constructor(e){C(e,x);var n=e.__destroy_into_raw();const r=_.context_new(n);return this.__wbg_ptr=r>>>0,z.register(this,this.__wbg_ptr,this),this}compile(e){const n=w(e,_.__wbindgen_malloc,_.__wbindgen_realloc),r=u;_.context_compile(this.__wbg_ptr,n,r)}recompile(e){const n=w(e,_.__wbindgen_malloc,_.__wbindgen_realloc),r=u;_.context_recompile(this.__wbg_ptr,n,r)}get_input_channels(){return _.context_get_input_channels(this.__wbg_ptr)>>>0}get_output_channels(){return _.context_get_output_channels(this.__wbg_ptr)>>>0}process(e,n){const r=D(e,_.__wbindgen_malloc),o=u;var i=D(n,_.__wbindgen_malloc),s=u;const c=_.context_process(this.__wbg_ptr,r,o,i,s,n);return BigInt.asUintN(64,c)}}function Q(){const t={};return t.wbg={},t.wbg.__wbg_call_b0d8e36992d9900d=function(){return I(function(e,n){return e.call(n)},arguments)},t.wbg.__wbg_data_d2ef8a36fe06fc0a=function(){return I(function(e,n){const r=n.data,o=N(r,_.__wbindgen_malloc),i=u;g().setInt32(e+4,i,!0),g().setInt32(e+0,o,!0)},arguments)},t.wbg.__wbg_error_7534b8e9a36f1ab4=function(e,n){let r,o;try{r=e,o=n,console.error(O(e,n))}finally{_.__wbindgen_free(r,o,1)}},t.wbg.__wbg_forEach_960fd897546c2cc7=function(e,n,r){try{var o={a:n,b:r},i=(s,c)=>{const a=o.a;o.a=0;try{return V(a,o.b,s,c)}finally{o.a=a}};e.forEach(i)}finally{o.a=o.b=0}},t.wbg.__wbg_id_342672fabcb69265=function(e,n){const r=n.id,o=w(r,_.__wbindgen_malloc,_.__wbindgen_realloc),i=u;g().setInt32(e+4,i,!0),g().setInt32(e+0,o,!0)},t.wbg.__wbg_inputs_b38a2701063a9f19=function(e){return e.inputs},t.wbg.__wbg_instanceof_MidiAccess_0a300b3304ef3202=function(e){let n;try{n=e instanceof MIDIAccess}catch{n=!1}return n},t.wbg.__wbg_instanceof_MidiInput_8847af17a1bd9e0a=function(e){let n;try{n=e instanceof MIDIInput}catch{n=!1}return n},t.wbg.__wbg_instanceof_Window_d2514c6a7ee7ba60=function(e){let n;try{n=e instanceof Window}catch{n=!1}return n},t.wbg.__wbg_name_476a3f59d488a92a=function(e,n){const r=n.name;var o=y(r)?0:w(r,_.__wbindgen_malloc,_.__wbindgen_realloc),i=u;g().setInt32(e+4,i,!0),g().setInt32(e+0,o,!0)},t.wbg.__wbg_navigator_0fe968937104eaa7=function(e){return e.navigator},t.wbg.__wbg_new_688846f374351c92=function(){return new Object},t.wbg.__wbg_new_8a6f238a6ece86ea=function(){return new Error},t.wbg.__wbg_newnoargs_fd9e4bf8be2bc16d=function(e,n){return new Function(O(e,n))},t.wbg.__wbg_open_bad7415c7076f4d4=function(e){return e.open()},t.wbg.__wbg_readfile_4315899bb6081982=function(){return I(function(e,n,r){const o=B.read_file(O(n,r)),i=w(o,_.__wbindgen_malloc,_.__wbindgen_realloc),s=u;g().setInt32(e+4,s,!0),g().setInt32(e+0,i,!0)},arguments)},t.wbg.__wbg_requestMIDIAccess_e5de2909f77fdf72=function(){return I(function(e,n){return e.requestMIDIAccess(n)},arguments)},t.wbg.__wbg_setonmidimessage_cc963fd52d629fb2=function(e,n){e.onmidimessage=n},t.wbg.__wbg_setsysex_634999d73a9f19a9=function(e,n){e.sysex=n!==0},t.wbg.__wbg_stack_0ed75d68575b0f3c=function(e,n){const r=n.stack,o=w(r,_.__wbindgen_malloc,_.__wbindgen_realloc),i=u;g().setInt32(e+4,i,!0),g().setInt32(e+0,o,!0)},t.wbg.__wbg_static_accessor_GLOBAL_0be7472e492ad3e3=function(){const e=typeof global>"u"?null:global;return y(e)?0:p(e)},t.wbg.__wbg_static_accessor_GLOBAL_THIS_1a6eb482d12c9bfb=function(){const e=typeof globalThis>"u"?null:globalThis;return y(e)?0:p(e)},t.wbg.__wbg_static_accessor_SELF_1dc398a895c82351=function(){const e=typeof self>"u"?null:self;return y(e)?0:p(e)},t.wbg.__wbg_static_accessor_WINDOW_ae1c80c7eea8d64a=function(){const e=typeof window>"u"?null:window;return y(e)?0:p(e)},t.wbg.__wbg_then_0ffafeddf0e182a4=function(e,n,r){return e.then(n,r)},t.wbg.__wbg_timeStamp_0aab179f39f96348=function(e){return e.timeStamp},t.wbg.__wbindgen_cb_drop=function(e){const n=e.original;return n.cnt--==1?(n.a=0,!0):!1},t.wbg.__wbindgen_closure_wrapper190=function(e,n,r){return F(e,n,61,H)},t.wbg.__wbindgen_closure_wrapper215=function(e,n,r){return F(e,n,74,J)},t.wbg.__wbindgen_copy_to_typed_array=function(e,n,r){new Uint8Array(r.buffer,r.byteOffset,r.byteLength).set(q(e,n))},t.wbg.__wbindgen_debug_string=function(e,n){const r=T(n),o=w(r,_.__wbindgen_malloc,_.__wbindgen_realloc),i=u;g().setInt32(e+4,i,!0),g().setInt32(e+0,o,!0)},t.wbg.__wbindgen_init_externref_table=function(){const e=_.__wbindgen_export_2,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,!0),e.set(n+3,!1)},t.wbg.__wbindgen_is_undefined=function(e){return e===void 0},t.wbg.__wbindgen_throw=function(e,n){throw new Error(O(e,n))},t}function X(t,e){return _=t.exports,b=null,m=null,h=null,_.__wbindgen_start(),_}function Y(t){if(_!==void 0)return _;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=Q();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));const n=new WebAssembly.Instance(t,e);return X(n)}class P extends AudioWorkletProcessor{context;interleaved_input=new Float32Array;interleaved_output=new Float32Array;constructor(){super(),this.context=null,this.port.onmessage=e=>{this.onmessage(e.data)}}onmessage(e){switch(console.log("onmessage ",e),e.type){case"send-wasm-module":{console.log("start_loading");const n=e.data;WebAssembly.compile(n).then(r=>{Y({module:r}),console.log("wasm module loaded,sending message"),this.port.postMessage({type:"wasm-module-loaded"})}).catch(r=>{console.error("wasm module load error, ",r),this.port.postMessage({type:"error_wasm_load",data:r})});break}case"compile":this.compile(e.data.samplerate,e.data.buffersize,e.data.src);case"recompile":this.recompile(e.data.src);break}}compile(e,n,r){let o=x.new();o.sample_rate=e,o.buffer_size=n,this.context=new K(o),this.context.compile(r),this.interleaved_input=new Float32Array(n*this.context.get_input_channels()),this.interleaved_output=new Float32Array(n*this.context.get_output_channels()),this.port.postMessage({type:"compile_finished",data:{output_channels:this.context.get_output_channels()||0}})}recompile(e){if(this.context)this.context.recompile(e),this.port.postMessage({type:"re-compiled",data:{output_channels:this.context.get_output_channels()||0}});else return this.compile}process(e,n,r){if(this.context){const o=this.context.get_input_channels(),i=this.context.get_output_channels(),s=e[0],c=n[0];s.forEach((a,l)=>{for(let f=0;f<a.length;f++)this.interleaved_input[o*f+l]=a[f]}),this.interleaved_output.fill(0),this.context.process(this.interleaved_input,this.interleaved_output),c.forEach((a,l)=>{for(let f=0;f<a.length;f++)a[f]=this.interleaved_output[i*f+l]})}return!0}}registerProcessor("MimiumProcessor",P);export{P as MimiumProcessor};
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ (function(n) {
5
+ function e() {
6
+ }
7
+ e.prototype.encode = function(r) {
8
+ for (var o = [], c = r.length, i = 0; i < c; ) {
9
+ var s = r.codePointAt(i), a = 0, l = 0;
10
+ for (s <= 127 ? (a = 0, l = 0) : s <= 2047 ? (a = 6, l = 192) : s <= 65535 ? (a = 12, l = 224) : s <= 2097151 && (a = 18, l = 240), o.push(l | s >> a), a -= 6; a >= 0; )
11
+ o.push(128 | s >> a & 63), a -= 6;
12
+ i += s >= 65536 ? 2 : 1;
13
+ }
14
+ return o;
15
+ }, globalThis.TextEncoder = e, n.TextEncoder || (n.TextEncoder = e);
16
+ function t() {
17
+ }
18
+ t.prototype.decode = function(r) {
19
+ if (!r) return "";
20
+ for (var o = "", c = 0; c < r.length; ) {
21
+ var i = r[c], s = 0, a = 0;
22
+ if (i <= 127 ? (s = 0, a = i & 255) : i <= 223 ? (s = 1, a = i & 31) : i <= 239 ? (s = 2, a = i & 15) : i <= 244 && (s = 3, a = i & 7), r.length - c - s > 0)
23
+ for (var l = 0; l < s; )
24
+ i = r[c + l + 1], a = a << 6 | i & 63, l += 1;
25
+ else
26
+ a = 65533, s = r.length - c;
27
+ o += String.fromCodePoint(a), c += s + 1;
28
+ }
29
+ return o;
30
+ }, globalThis.TextDecoder = t, n.TextDecoder || (n.TextDecoder = t);
31
+ })(
32
+ typeof globalThis > "u" ? typeof global > "u" ? typeof self > "u" ? void 0 : self : global : globalThis
33
+ );
34
+ let x = null;
35
+ const D = typeof process < "u" && !!(process.versions && process.versions.node);
36
+ if (D && (typeof process.getBuiltinModule == "function" && (x = process.getBuiltinModule("node:fs") ?? process.getBuiltinModule("fs")), !x))
37
+ try {
38
+ const n = Function(
39
+ 'return typeof require !== "undefined" ? require : null;'
40
+ )();
41
+ n && (x = n("node:fs"));
42
+ } catch {
43
+ x = null;
44
+ }
45
+ const V = "https://raw.githubusercontent.com/mimium-org/mimium-rs/", I = "dev", N = [
46
+ "core.mmm",
47
+ "delay.mmm",
48
+ "env.mmm",
49
+ "filter.mmm",
50
+ "math.mmm",
51
+ "noise.mmm",
52
+ "osc.mmm",
53
+ "reactive.mmm",
54
+ "reverb.mmm"
55
+ ], f = /* @__PURE__ */ new Map();
56
+ function U(n) {
57
+ return typeof n != "string" ? "" : n.replace(/\\/g, "/").trim().replace(/^\/+/, "").replace(/^\.\//, "").replace(/^lib\//, "").split("/").filter((o) => o.length > 0 && o !== ".").join("/");
58
+ }
59
+ function C(n) {
60
+ if (!n || n.length === 0)
61
+ return "";
62
+ let e = n;
63
+ typeof location < "u" && (e = new URL(n, location.href).toString());
64
+ try {
65
+ const t = new URL(e);
66
+ if (t.hostname !== "github.com")
67
+ return e;
68
+ const r = t.pathname.split("/").filter((G) => G.length > 0), [o, c, i, s, ...a] = r;
69
+ if (!o || !c || !i || !s || i !== "tree" && i !== "blob")
70
+ return e;
71
+ const l = a.join("/");
72
+ return `https://raw.githubusercontent.com${l.length > 0 ? `/${o}/${c}/${s}/${l}` : `/${o}/${c}/${s}`}`;
73
+ } catch {
74
+ return e;
75
+ }
76
+ }
77
+ function A(n, e) {
78
+ const t = U(n);
79
+ t && (f.set(t, e), f.set(`./${t}`, e), f.set(`lib/${t}`, e), f.set(`/lib/${t}`, e));
80
+ }
81
+ function P(n) {
82
+ if (D)
83
+ return x.readFileSync(n, { encoding: "utf8" });
84
+ const e = U(n), t = f.get(n) ?? f.get(e) ?? f.get(`./${e}`) ?? f.get(`lib/${e}`) ?? f.get(`/lib/${e}`);
85
+ if (t !== void 0)
86
+ return t;
87
+ throw new Error(
88
+ `Include target not found in browser cache: ${n}. Call preload_mimium_lib_cache() before compile().`
89
+ );
90
+ }
91
+ async function q() {
92
+ const n = J();
93
+ return !globalThis.navigator || !navigator.storage || !navigator.storage.getDirectory ? null : (await navigator.storage.getDirectory()).getDirectoryHandle(n, { create: true });
94
+ }
95
+ function Z(n) {
96
+ const e = (n || "").replace(/\/+$/, ""), t = "raw.githubusercontent.com/mimium-org/mimium-rs/", r = e.indexOf(t);
97
+ return r < 0 ? I : e.slice(r + t.length).split("/")[0] || I;
98
+ }
99
+ function J() {
100
+ return `mimium-lib-${Z(globalThis.__mimium_lib_base_url || "")}`;
101
+ }
102
+ async function X(n) {
103
+ const e = await q();
104
+ if (!e)
105
+ return null;
106
+ try {
107
+ return await (await (await e.getFileHandle(n, { create: false })).getFile()).text();
108
+ } catch {
109
+ return null;
110
+ }
111
+ }
112
+ async function Y(n, e) {
113
+ const t = await q();
114
+ if (!t)
115
+ return;
116
+ const o = await (await t.getFileHandle(n, { create: true })).createWritable();
117
+ await o.write(e), await o.close();
118
+ }
119
+ async function K(n, e) {
120
+ const t = `${n}${e}`, r = await fetch(t, { cache: "no-cache" });
121
+ if (!r.ok)
122
+ throw new Error(`Failed to fetch ${t}: ${r.status} ${r.statusText}`);
123
+ return r.text();
124
+ }
125
+ function z(n) {
126
+ const e = [...n.matchAll(/^\s*mod\s+([A-Za-z_][A-Za-z0-9_]*)\s*$/gm)].map(
127
+ (r) => `${r[1]}.mmm`
128
+ ), t = [...n.matchAll(/^\s*include\(\s*"([^"]+)"\s*\)\s*$/gm)].map(
129
+ (r) => r[1]
130
+ );
131
+ return [.../* @__PURE__ */ new Set([...e, ...t])];
132
+ }
133
+ function H(n) {
134
+ const e = n && n.length > 0 ? n : globalThis.__mimium_module_base_url || (typeof location < "u" ? new URL(".", location.href).toString() : "");
135
+ if (!e)
136
+ return "";
137
+ const t = C(e);
138
+ return t.endsWith("/") ? t : `${t}/`;
139
+ }
140
+ async function Q(n, e) {
141
+ const t = new URL(e, n).toString(), r = await fetch(t, { cache: "no-cache" });
142
+ if (!r.ok)
143
+ throw new Error(`Failed to fetch ${t}: ${r.status} ${r.statusText}`);
144
+ return r.text();
145
+ }
146
+ async function ee(n, e) {
147
+ if (D)
148
+ return;
149
+ const t = H(e);
150
+ if (!t)
151
+ return;
152
+ globalThis.__mimium_module_base_url = t;
153
+ const r = z(n), o = /* @__PURE__ */ new Set();
154
+ for (; r.length > 0; ) {
155
+ const c = r.pop(), i = U(c || "");
156
+ if (!i || o.has(i))
157
+ continue;
158
+ o.add(i);
159
+ const s = f.get(c) ?? f.get(i) ?? f.get(`./${i}`) ?? f.get(`lib/${i}`) ?? f.get(`/lib/${i}`);
160
+ if (s !== void 0) {
161
+ z(s).forEach((l) => r.push(l));
162
+ continue;
163
+ }
164
+ const a = await Q(t, c);
165
+ A(c, a), z(a).forEach((l) => r.push(l));
166
+ }
167
+ }
168
+ async function te(n) {
169
+ const e = n && n.length > 0 ? n : `${V}${I}/lib/`, t = C(e), r = t.endsWith("/") ? t : `${t}/`;
170
+ if (globalThis.__mimium_lib_base_url = r, !D)
171
+ for (const o of N) {
172
+ const c = f.get(o);
173
+ if (c !== void 0) {
174
+ A(o, c);
175
+ continue;
176
+ }
177
+ const i = await X(o);
178
+ if (i !== null) {
179
+ A(o, i);
180
+ continue;
181
+ }
182
+ const s = await K(r, o);
183
+ A(o, s), await Y(o, s);
184
+ }
185
+ }
186
+ function ne(n, e) {
187
+ A(n, e);
188
+ }
189
+ function re() {
190
+ f.clear(), delete globalThis.__mimium_lib_base_url, delete globalThis.__mimium_module_base_url;
191
+ }
192
+ function oe(n) {
193
+ const e = H(n);
194
+ if (!e) {
195
+ delete globalThis.__mimium_module_base_url;
196
+ return;
197
+ }
198
+ globalThis.__mimium_module_base_url = e;
199
+ }
200
+ class w {
201
+ static __wrap(e) {
202
+ e = e >>> 0;
203
+ const t = Object.create(w.prototype);
204
+ return t.__wbg_ptr = e, k.register(t, t.__wbg_ptr, t), t;
205
+ }
206
+ __destroy_into_raw() {
207
+ const e = this.__wbg_ptr;
208
+ return this.__wbg_ptr = 0, k.unregister(this), e;
209
+ }
210
+ free() {
211
+ const e = this.__destroy_into_raw();
212
+ _.__wbg_config_free(e, 0);
213
+ }
214
+ /**
215
+ * @returns {Config}
216
+ */
217
+ static new() {
218
+ const e = _.config_new();
219
+ return w.__wrap(e);
220
+ }
221
+ /**
222
+ * @returns {number}
223
+ */
224
+ get buffer_size() {
225
+ return _.__wbg_get_config_buffer_size(this.__wbg_ptr) >>> 0;
226
+ }
227
+ /**
228
+ * @returns {number}
229
+ */
230
+ get input_channels() {
231
+ return _.__wbg_get_config_input_channels(this.__wbg_ptr) >>> 0;
232
+ }
233
+ /**
234
+ * @returns {number}
235
+ */
236
+ get output_channels() {
237
+ return _.__wbg_get_config_output_channels(this.__wbg_ptr) >>> 0;
238
+ }
239
+ /**
240
+ * @returns {number}
241
+ */
242
+ get sample_rate() {
243
+ return _.__wbg_get_config_sample_rate(this.__wbg_ptr);
244
+ }
245
+ /**
246
+ * @param {number} arg0
247
+ */
248
+ set buffer_size(e) {
249
+ _.__wbg_set_config_buffer_size(this.__wbg_ptr, e);
250
+ }
251
+ /**
252
+ * @param {number} arg0
253
+ */
254
+ set input_channels(e) {
255
+ _.__wbg_set_config_input_channels(this.__wbg_ptr, e);
256
+ }
257
+ /**
258
+ * @param {number} arg0
259
+ */
260
+ set output_channels(e) {
261
+ _.__wbg_set_config_output_channels(this.__wbg_ptr, e);
262
+ }
263
+ /**
264
+ * @param {number} arg0
265
+ */
266
+ set sample_rate(e) {
267
+ _.__wbg_set_config_sample_rate(this.__wbg_ptr, e);
268
+ }
269
+ }
270
+ Symbol.dispose && (w.prototype[Symbol.dispose] = w.prototype.free);
271
+ class L {
272
+ __destroy_into_raw() {
273
+ const e = this.__wbg_ptr;
274
+ return this.__wbg_ptr = 0, W.unregister(this), e;
275
+ }
276
+ free() {
277
+ const e = this.__destroy_into_raw();
278
+ _.__wbg_context_free(e, 0);
279
+ }
280
+ clear_virtual_file_cache() {
281
+ const e = _.context_clear_virtual_file_cache(this.__wbg_ptr);
282
+ if (e[1])
283
+ throw y(e[0]);
284
+ }
285
+ /**
286
+ * @param {string} src
287
+ * @returns {Promise<void>}
288
+ */
289
+ compile(e) {
290
+ const t = g(e, _.__wbindgen_malloc, _.__wbindgen_realloc), r = u;
291
+ return _.context_compile(this.__wbg_ptr, t, r);
292
+ }
293
+ /**
294
+ * @param {string} src
295
+ */
296
+ compile_direct(e) {
297
+ const t = g(e, _.__wbindgen_malloc, _.__wbindgen_realloc), r = u, o = _.context_compile_direct(this.__wbg_ptr, t, r);
298
+ if (o[1])
299
+ throw y(o[0]);
300
+ }
301
+ /**
302
+ * @returns {number}
303
+ */
304
+ get_input_channels() {
305
+ return _.context_get_input_channels(this.__wbg_ptr) >>> 0;
306
+ }
307
+ /**
308
+ * @returns {number}
309
+ */
310
+ get_output_channels() {
311
+ return _.context_get_output_channels(this.__wbg_ptr) >>> 0;
312
+ }
313
+ /**
314
+ * @returns {Promise<void>}
315
+ */
316
+ init_github_lib_cache() {
317
+ return _.context_init_github_lib_cache(this.__wbg_ptr);
318
+ }
319
+ /**
320
+ * @param {string} base_url
321
+ * @returns {Promise<void>}
322
+ */
323
+ init_lib_cache_with_base_url(e) {
324
+ const t = g(e, _.__wbindgen_malloc, _.__wbindgen_realloc), r = u;
325
+ return _.context_init_lib_cache_with_base_url(this.__wbg_ptr, t, r);
326
+ }
327
+ /**
328
+ * @param {Config} config
329
+ */
330
+ constructor(e) {
331
+ ce(e, w);
332
+ var t = e.__destroy_into_raw();
333
+ const r = _.context_new(t);
334
+ return this.__wbg_ptr = r >>> 0, W.register(this, this.__wbg_ptr, this), this;
335
+ }
336
+ /**
337
+ * .
338
+ *
339
+ * # Safety
340
+ * Array size of input and output must be equal to `input_channels * buffer_size` and `output_channels * buffer_size` respectively.
341
+ * .
342
+ * @param {Float32Array} input
343
+ * @param {Float32Array} output
344
+ * @returns {bigint}
345
+ */
346
+ process(e, t) {
347
+ const r = j(e, _.__wbindgen_malloc), o = u;
348
+ var c = j(t, _.__wbindgen_malloc), i = u;
349
+ const s = _.context_process(this.__wbg_ptr, r, o, c, i, t);
350
+ return BigInt.asUintN(64, s);
351
+ }
352
+ /**
353
+ * @param {string} path
354
+ * @param {string} content
355
+ */
356
+ put_virtual_file_cache(e, t) {
357
+ const r = g(e, _.__wbindgen_malloc, _.__wbindgen_realloc), o = u, c = g(t, _.__wbindgen_malloc, _.__wbindgen_realloc), i = u, s = _.context_put_virtual_file_cache(this.__wbg_ptr, r, o, c, i);
358
+ if (s[1])
359
+ throw y(s[0]);
360
+ }
361
+ /**
362
+ * @param {string} src
363
+ * @returns {Promise<void>}
364
+ */
365
+ recompile(e) {
366
+ const t = g(e, _.__wbindgen_malloc, _.__wbindgen_realloc), r = u;
367
+ return _.context_recompile(this.__wbg_ptr, t, r);
368
+ }
369
+ /**
370
+ * @param {string} src
371
+ */
372
+ recompile_direct(e) {
373
+ const t = g(e, _.__wbindgen_malloc, _.__wbindgen_realloc), r = u, o = _.context_recompile_direct(this.__wbg_ptr, t, r);
374
+ if (o[1])
375
+ throw y(o[0]);
376
+ }
377
+ /**
378
+ * @param {string} base_url
379
+ */
380
+ set_module_base_url(e) {
381
+ const t = g(e, _.__wbindgen_malloc, _.__wbindgen_realloc), r = u, o = _.context_set_module_base_url(this.__wbg_ptr, t, r);
382
+ if (o[1])
383
+ throw y(o[0]);
384
+ }
385
+ }
386
+ Symbol.dispose && (L.prototype[Symbol.dispose] = L.prototype.free);
387
+ function _e() {
388
+ return {
389
+ __proto__: null,
390
+ "./mimium_web_bg.js": {
391
+ __proto__: null,
392
+ __wbg___mimium_test_clear_cache_15bc783b03d49d3f: function() {
393
+ return m(function() {
394
+ re();
395
+ }, arguments);
396
+ },
397
+ __wbg___mimium_test_put_cache_6e930cf841a82463: function() {
398
+ return m(function(e, t, r, o) {
399
+ ne(d(e, t), d(r, o));
400
+ }, arguments);
401
+ },
402
+ __wbg___wbindgen_copy_to_typed_array_d2f20acdab8e0740: function(e, t, r) {
403
+ new Uint8Array(r.buffer, r.byteOffset, r.byteLength).set(ae(e, t));
404
+ },
405
+ __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(e, t) {
406
+ const r = B(t), o = g(r, _.__wbindgen_malloc, _.__wbindgen_realloc), c = u;
407
+ p().setInt32(e + 4, c, true), p().setInt32(e + 0, o, true);
408
+ },
409
+ __wbg___wbindgen_is_function_3c846841762788c1: function(e) {
410
+ return typeof e == "function";
411
+ },
412
+ __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(e) {
413
+ return e === void 0;
414
+ },
415
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(e, t) {
416
+ throw new Error(d(e, t));
417
+ },
418
+ __wbg__wbg_cb_unref_6b5b6b8576d35cb1: function(e) {
419
+ e._wbg_cb_unref();
420
+ },
421
+ __wbg_call_2d781c1f4d5c0ef8: function() {
422
+ return m(function(e, t, r) {
423
+ return e.call(t, r);
424
+ }, arguments);
425
+ },
426
+ __wbg_error_a6fa202b58aa1cd3: function(e, t) {
427
+ let r, o;
428
+ try {
429
+ r = e, o = t, console.error(d(e, t));
430
+ } finally {
431
+ _.__wbindgen_free(r, o, 1);
432
+ }
433
+ },
434
+ __wbg_new_227d7c05414eb861: function() {
435
+ return new Error();
436
+ },
437
+ __wbg_new_typed_aaaeaf29cf802876: function(e, t) {
438
+ try {
439
+ var r = { a: e, b: t }, o = (i, s) => {
440
+ const a = r.a;
441
+ r.a = 0;
442
+ try {
443
+ return se(a, r.b, i, s);
444
+ } finally {
445
+ r.a = a;
446
+ }
447
+ };
448
+ return new Promise(o);
449
+ } finally {
450
+ r.a = r.b = 0;
451
+ }
452
+ },
453
+ __wbg_preload_mimium_lib_cache_0a73db4b652312b0: function() {
454
+ return m(function(e, t) {
455
+ return te(d(e, t));
456
+ }, arguments);
457
+ },
458
+ __wbg_preload_user_module_cache_385c142315bc1d3f: function() {
459
+ return m(function(e, t, r, o) {
460
+ return ee(d(e, t), d(r, o));
461
+ }, arguments);
462
+ },
463
+ __wbg_queueMicrotask_0c399741342fb10f: function(e) {
464
+ return e.queueMicrotask;
465
+ },
466
+ __wbg_queueMicrotask_a082d78ce798393e: function(e) {
467
+ queueMicrotask(e);
468
+ },
469
+ __wbg_read_file_265a82e26644b785: function() {
470
+ return m(function(e, t, r) {
471
+ const o = P(d(t, r)), c = g(o, _.__wbindgen_malloc, _.__wbindgen_realloc), i = u;
472
+ p().setInt32(e + 4, i, true), p().setInt32(e + 0, c, true);
473
+ }, arguments);
474
+ },
475
+ __wbg_resolve_ae8d83246e5bcc12: function(e) {
476
+ return Promise.resolve(e);
477
+ },
478
+ __wbg_set_module_base_url_32604e1e603e53b4: function() {
479
+ return m(function(e, t) {
480
+ oe(d(e, t));
481
+ }, arguments);
482
+ },
483
+ __wbg_stack_3b0d974bbf31e44f: function(e, t) {
484
+ const r = t.stack, o = g(r, _.__wbindgen_malloc, _.__wbindgen_realloc), c = u;
485
+ p().setInt32(e + 4, c, true), p().setInt32(e + 0, o, true);
486
+ },
487
+ __wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
488
+ const e = typeof global > "u" ? null : global;
489
+ return S(e) ? 0 : T(e);
490
+ },
491
+ __wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function() {
492
+ const e = typeof globalThis > "u" ? null : globalThis;
493
+ return S(e) ? 0 : T(e);
494
+ },
495
+ __wbg_static_accessor_SELF_f207c857566db248: function() {
496
+ const e = typeof self > "u" ? null : self;
497
+ return S(e) ? 0 : T(e);
498
+ },
499
+ __wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function() {
500
+ const e = typeof window > "u" ? null : window;
501
+ return S(e) ? 0 : T(e);
502
+ },
503
+ __wbg_then_098abe61755d12f6: function(e, t) {
504
+ return e.then(t);
505
+ },
506
+ __wbg_then_9e335f6dd892bc11: function(e, t, r) {
507
+ return e.then(t, r);
508
+ },
509
+ __wbindgen_cast_0000000000000001: function(e, t) {
510
+ return ue(e, t, _.wasm_bindgen__closure__destroy__hab95d7be7d8a5a60, ie);
511
+ },
512
+ __wbindgen_cast_0000000000000002: function(e, t) {
513
+ return d(e, t);
514
+ },
515
+ __wbindgen_init_externref_table: function() {
516
+ const e = _.__wbindgen_externrefs, t = e.grow(4);
517
+ e.set(0, void 0), e.set(t + 0, void 0), e.set(t + 1, null), e.set(t + 2, true), e.set(t + 3, false);
518
+ }
519
+ }
520
+ };
521
+ }
522
+ function ie(n, e, t) {
523
+ const r = _.wasm_bindgen__convert__closures_____invoke__ha0f31ef339bf6681(n, e, t);
524
+ if (r[1])
525
+ throw y(r[0]);
526
+ }
527
+ function se(n, e, t, r) {
528
+ _.wasm_bindgen__convert__closures_____invoke__h0d15b73cb2272b2b(n, e, t, r);
529
+ }
530
+ const k = typeof FinalizationRegistry > "u" ? { register: () => {
531
+ }, unregister: () => {
532
+ } } : new FinalizationRegistry((n) => _.__wbg_config_free(n >>> 0, 1)), W = typeof FinalizationRegistry > "u" ? { register: () => {
533
+ }, unregister: () => {
534
+ } } : new FinalizationRegistry((n) => _.__wbg_context_free(n >>> 0, 1));
535
+ function T(n) {
536
+ const e = _.__externref_table_alloc();
537
+ return _.__wbindgen_externrefs.set(e, n), e;
538
+ }
539
+ function ce(n, e) {
540
+ if (!(n instanceof e))
541
+ throw new Error(`expected instance of ${e.name}`);
542
+ }
543
+ const R = typeof FinalizationRegistry > "u" ? { register: () => {
544
+ }, unregister: () => {
545
+ } } : new FinalizationRegistry((n) => n.dtor(n.a, n.b));
546
+ function B(n) {
547
+ const e = typeof n;
548
+ if (e == "number" || e == "boolean" || n == null)
549
+ return `${n}`;
550
+ if (e == "string")
551
+ return `"${n}"`;
552
+ if (e == "symbol") {
553
+ const o = n.description;
554
+ return o == null ? "Symbol" : `Symbol(${o})`;
555
+ }
556
+ if (e == "function") {
557
+ const o = n.name;
558
+ return typeof o == "string" && o.length > 0 ? `Function(${o})` : "Function";
559
+ }
560
+ if (Array.isArray(n)) {
561
+ const o = n.length;
562
+ let c = "[";
563
+ o > 0 && (c += B(n[0]));
564
+ for (let i = 1; i < o; i++)
565
+ c += ", " + B(n[i]);
566
+ return c += "]", c;
567
+ }
568
+ const t = /\[object ([^\]]+)\]/.exec(toString.call(n));
569
+ let r;
570
+ if (t && t.length > 1)
571
+ r = t[1];
572
+ else
573
+ return toString.call(n);
574
+ if (r == "Object")
575
+ try {
576
+ return "Object(" + JSON.stringify(n) + ")";
577
+ } catch {
578
+ return "Object";
579
+ }
580
+ return n instanceof Error ? `${n.name}: ${n.message}
581
+ ${n.stack}` : r;
582
+ }
583
+ function ae(n, e) {
584
+ return n = n >>> 0, v().subarray(n / 1, n / 1 + e);
585
+ }
586
+ let h = null;
587
+ function p() {
588
+ return (h === null || h.buffer.detached === true || h.buffer.detached === void 0 && h.buffer !== _.memory.buffer) && (h = new DataView(_.memory.buffer)), h;
589
+ }
590
+ let $ = null;
591
+ function le() {
592
+ return ($ === null || $.byteLength === 0) && ($ = new Float32Array(_.memory.buffer)), $;
593
+ }
594
+ function d(n, e) {
595
+ return n = n >>> 0, ge(n, e);
596
+ }
597
+ let F = null;
598
+ function v() {
599
+ return (F === null || F.byteLength === 0) && (F = new Uint8Array(_.memory.buffer)), F;
600
+ }
601
+ function m(n, e) {
602
+ try {
603
+ return n.apply(this, e);
604
+ } catch (t) {
605
+ const r = T(t);
606
+ _.__wbindgen_exn_store(r);
607
+ }
608
+ }
609
+ function S(n) {
610
+ return n == null;
611
+ }
612
+ function ue(n, e, t, r) {
613
+ const o = { a: n, b: e, cnt: 1, dtor: t }, c = (...i) => {
614
+ o.cnt++;
615
+ const s = o.a;
616
+ o.a = 0;
617
+ try {
618
+ return r(s, o.b, ...i);
619
+ } finally {
620
+ o.a = s, c._wbg_cb_unref();
621
+ }
622
+ };
623
+ return c._wbg_cb_unref = () => {
624
+ --o.cnt === 0 && (o.dtor(o.a, o.b), o.a = 0, R.unregister(o));
625
+ }, R.register(c, o, o), c;
626
+ }
627
+ function j(n, e) {
628
+ const t = e(n.length * 4, 4) >>> 0;
629
+ return le().set(n, t / 4), u = n.length, t;
630
+ }
631
+ function g(n, e, t) {
632
+ if (t === void 0) {
633
+ const s = E.encode(n), a = e(s.length, 1) >>> 0;
634
+ return v().subarray(a, a + s.length).set(s), u = s.length, a;
635
+ }
636
+ let r = n.length, o = e(r, 1) >>> 0;
637
+ const c = v();
638
+ let i = 0;
639
+ for (; i < r; i++) {
640
+ const s = n.charCodeAt(i);
641
+ if (s > 127) break;
642
+ c[o + i] = s;
643
+ }
644
+ if (i !== r) {
645
+ i !== 0 && (n = n.slice(i)), o = t(o, r, r = i + n.length * 3, 1) >>> 0;
646
+ const s = v().subarray(o + i, o + r), a = E.encodeInto(n, s);
647
+ i += a.written, o = t(o, r, i, 1) >>> 0;
648
+ }
649
+ return u = i, o;
650
+ }
651
+ function y(n) {
652
+ const e = _.__wbindgen_externrefs.get(n);
653
+ return _.__externref_table_dealloc(n), e;
654
+ }
655
+ let M = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
656
+ M.decode();
657
+ const fe = 2146435072;
658
+ let O = 0;
659
+ function ge(n, e) {
660
+ return O += e, O >= fe && (M = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }), M.decode(), O = e), M.decode(v().subarray(n, n + e));
661
+ }
662
+ const E = new TextEncoder();
663
+ "encodeInto" in E || (E.encodeInto = function(n, e) {
664
+ const t = E.encode(n);
665
+ return e.set(t), {
666
+ read: n.length,
667
+ written: t.length
668
+ };
669
+ });
670
+ let u = 0, _;
671
+ function be(n, e) {
672
+ return _ = n.exports, h = null, $ = null, F = null, _.__wbindgen_start(), _;
673
+ }
674
+ function de(n) {
675
+ if (_ !== void 0) return _;
676
+ n !== void 0 && (Object.getPrototypeOf(n) === Object.prototype ? { module: n } = n : console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));
677
+ const e = _e();
678
+ n instanceof WebAssembly.Module || (n = new WebAssembly.Module(n));
679
+ const t = new WebAssembly.Instance(n, e);
680
+ return be(t);
681
+ }
682
+ class me extends AudioWorkletProcessor {
683
+ constructor() {
684
+ super();
685
+ __publicField(this, "context");
686
+ __publicField(this, "interleaved_input", new Float32Array());
687
+ __publicField(this, "interleaved_output", new Float32Array());
688
+ this.context = null, this.port.onmessage = (e) => {
689
+ this.onmessage(e.data);
690
+ };
691
+ }
692
+ onmessage(e) {
693
+ switch (console.log("onmessage ", e), e.type) {
694
+ case "send-wasm-module": {
695
+ console.log("start_loading");
696
+ const t = e.data;
697
+ WebAssembly.compile(t).then((r) => {
698
+ de({ module: r }), console.log("wasm module loaded,sending message"), this.port.postMessage({ type: "wasm-module-loaded" });
699
+ }).catch((r) => {
700
+ console.error("wasm module load error, ", r), this.port.postMessage({ type: "error_wasm_load", data: r });
701
+ });
702
+ break;
703
+ }
704
+ case "compile":
705
+ this.compile(
706
+ e.data.samplerate,
707
+ e.data.buffersize,
708
+ e.data.src
709
+ );
710
+ break;
711
+ }
712
+ }
713
+ compile(e, t, r) {
714
+ let o = w.new();
715
+ o.sample_rate = e, o.buffer_size = t, this.context = new L(o), this.context.compile(r), this.interleaved_input = new Float32Array(
716
+ t * this.context.get_input_channels()
717
+ ), this.interleaved_output = new Float32Array(
718
+ t * this.context.get_output_channels()
719
+ ), this.port.postMessage({
720
+ type: "compile_finished",
721
+ data: { output_channels: this.context.get_output_channels() || 0 }
722
+ });
723
+ }
724
+ process(e, t, r) {
725
+ if (this.context) {
726
+ const o = this.context.get_input_channels(), c = this.context.get_output_channels(), i = e[0], s = t[0];
727
+ i.forEach((a, l) => {
728
+ for (let b = 0; b < a.length; b++)
729
+ this.interleaved_input[o * b + l] = a[b];
730
+ }), this.interleaved_output.fill(0), this.context.process(this.interleaved_input, this.interleaved_output), s.forEach((a, l) => {
731
+ for (let b = 0; b < a.length; b++)
732
+ a[b] = this.interleaved_output[c * b + l];
733
+ });
734
+ }
735
+ return true;
736
+ }
737
+ }
738
+ registerProcessor("MimiumProcessor", me);
739
+ export {
740
+ me as MimiumProcessor
741
+ };