@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.
- package/dist/audioprocessor.d.mts +0 -1
- package/dist/audioprocessor.mjs +741 -2
- package/dist/audioprocessor.mjs.map +1 -1
- package/dist/index.mjs +72 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/audioprocessor.mjs
CHANGED
|
@@ -1,2 +1,741 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
};
|