sidespread 0.5.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.
@@ -0,0 +1,567 @@
1
+ /* @ts-self-types="./sidespread_wasm.d.ts" */
2
+
3
+ export class ProcessResult {
4
+ static __wrap(ptr) {
5
+ const obj = Object.create(ProcessResult.prototype);
6
+ obj.__wbg_ptr = ptr;
7
+ ProcessResultFinalization.register(obj, obj.__wbg_ptr, obj);
8
+ return obj;
9
+ }
10
+ __destroy_into_raw() {
11
+ const ptr = this.__wbg_ptr;
12
+ this.__wbg_ptr = 0;
13
+ ProcessResultFinalization.unregister(this);
14
+ return ptr;
15
+ }
16
+ free() {
17
+ const ptr = this.__destroy_into_raw();
18
+ wasm.__wbg_processresult_free(ptr, 0);
19
+ }
20
+ /**
21
+ * @returns {Float32Array}
22
+ */
23
+ get audio() {
24
+ const ret = wasm.processresult_audio(this.__wbg_ptr);
25
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
26
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
27
+ return v1;
28
+ }
29
+ /**
30
+ * @returns {any}
31
+ */
32
+ get report() {
33
+ const ret = wasm.processresult_report(this.__wbg_ptr);
34
+ if (ret[2]) {
35
+ throw takeFromExternrefTable0(ret[1]);
36
+ }
37
+ return takeFromExternrefTable0(ret[0]);
38
+ }
39
+ /**
40
+ * @returns {Float32Array}
41
+ */
42
+ takeAudio() {
43
+ const ret = wasm.processresult_takeAudio(this.__wbg_ptr);
44
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
45
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
46
+ return v1;
47
+ }
48
+ }
49
+ if (Symbol.dispose) ProcessResult.prototype[Symbol.dispose] = ProcessResult.prototype.free;
50
+
51
+ /**
52
+ * @param {Float32Array} interleaved_stereo
53
+ * @param {number} sample_rate
54
+ * @param {any} options
55
+ * @returns {any}
56
+ */
57
+ export function analyze(interleaved_stereo, sample_rate, options) {
58
+ const ptr0 = passArrayF32ToWasm0(interleaved_stereo, wasm.__wbindgen_malloc);
59
+ const len0 = WASM_VECTOR_LEN;
60
+ const ret = wasm.analyze(ptr0, len0, sample_rate, options);
61
+ if (ret[2]) {
62
+ throw takeFromExternrefTable0(ret[1]);
63
+ }
64
+ return takeFromExternrefTable0(ret[0]);
65
+ }
66
+
67
+ /**
68
+ * @param {Float32Array} interleaved_stereo
69
+ * @param {number} sample_rate
70
+ * @param {any} options
71
+ * @param {Function | null} [on_progress]
72
+ * @returns {ProcessResult}
73
+ */
74
+ export function process(interleaved_stereo, sample_rate, options, on_progress) {
75
+ const ptr0 = passArrayF32ToWasm0(interleaved_stereo, wasm.__wbindgen_malloc);
76
+ const len0 = WASM_VECTOR_LEN;
77
+ const ret = wasm.process(ptr0, len0, sample_rate, options, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress));
78
+ if (ret[2]) {
79
+ throw takeFromExternrefTable0(ret[1]);
80
+ }
81
+ return ProcessResult.__wrap(ret[0]);
82
+ }
83
+
84
+ /**
85
+ * @returns {string}
86
+ */
87
+ export function version() {
88
+ let deferred1_0;
89
+ let deferred1_1;
90
+ try {
91
+ const ret = wasm.version();
92
+ deferred1_0 = ret[0];
93
+ deferred1_1 = ret[1];
94
+ return getStringFromWasm0(ret[0], ret[1]);
95
+ } finally {
96
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
97
+ }
98
+ }
99
+ function __wbg_get_imports() {
100
+ const import0 = {
101
+ __proto__: null,
102
+ __wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
103
+ const ret = Error(getStringFromWasm0(arg0, arg1));
104
+ return ret;
105
+ },
106
+ __wbg_Number_9a4e0ecb0fa16705: function(arg0) {
107
+ const ret = Number(arg0);
108
+ return ret;
109
+ },
110
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
111
+ const ret = String(arg1);
112
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
113
+ const len1 = WASM_VECTOR_LEN;
114
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
115
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
116
+ },
117
+ __wbg___wbindgen_bigint_get_as_i64_d968e41184ae354f: function(arg0, arg1) {
118
+ const v = arg1;
119
+ const ret = typeof(v) === 'bigint' ? v : undefined;
120
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
121
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
122
+ },
123
+ __wbg___wbindgen_boolean_get_fa956cfa2d1bd751: function(arg0) {
124
+ const v = arg0;
125
+ const ret = typeof(v) === 'boolean' ? v : undefined;
126
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
127
+ },
128
+ __wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) {
129
+ const ret = debugString(arg1);
130
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
131
+ const len1 = WASM_VECTOR_LEN;
132
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
133
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
134
+ },
135
+ __wbg___wbindgen_in_aca499c5de7ff5e5: function(arg0, arg1) {
136
+ const ret = arg0 in arg1;
137
+ return ret;
138
+ },
139
+ __wbg___wbindgen_is_bigint_2f76dc55065b4273: function(arg0) {
140
+ const ret = typeof(arg0) === 'bigint';
141
+ return ret;
142
+ },
143
+ __wbg___wbindgen_is_null_ea9085d691f535d3: function(arg0) {
144
+ const ret = arg0 === null;
145
+ return ret;
146
+ },
147
+ __wbg___wbindgen_is_object_a27215656b807791: function(arg0) {
148
+ const val = arg0;
149
+ const ret = typeof(val) === 'object' && val !== null;
150
+ return ret;
151
+ },
152
+ __wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
153
+ const ret = arg0 === undefined;
154
+ return ret;
155
+ },
156
+ __wbg___wbindgen_jsval_eq_e659fcf7b0e32763: function(arg0, arg1) {
157
+ const ret = arg0 === arg1;
158
+ return ret;
159
+ },
160
+ __wbg___wbindgen_jsval_loose_eq_db4c3b15f63fc170: function(arg0, arg1) {
161
+ const ret = arg0 == arg1;
162
+ return ret;
163
+ },
164
+ __wbg___wbindgen_number_get_394265ed1e1b84ee: function(arg0, arg1) {
165
+ const obj = arg1;
166
+ const ret = typeof(obj) === 'number' ? obj : undefined;
167
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
168
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
169
+ },
170
+ __wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
171
+ const obj = arg1;
172
+ const ret = typeof(obj) === 'string' ? obj : undefined;
173
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
174
+ var len1 = WASM_VECTOR_LEN;
175
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
176
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
177
+ },
178
+ __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
179
+ throw new Error(getStringFromWasm0(arg0, arg1));
180
+ },
181
+ __wbg_call_a6e5c5dce5018821: function() { return handleError(function (arg0, arg1, arg2) {
182
+ const ret = arg0.call(arg1, arg2);
183
+ return ret;
184
+ }, arguments); },
185
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
186
+ const ret = arg0[arg1];
187
+ return ret;
188
+ },
189
+ __wbg_instanceof_ArrayBuffer_4480b9e0068a8adb: function(arg0) {
190
+ let result;
191
+ try {
192
+ result = arg0 instanceof ArrayBuffer;
193
+ } catch (_) {
194
+ result = false;
195
+ }
196
+ const ret = result;
197
+ return ret;
198
+ },
199
+ __wbg_instanceof_Uint8Array_309b927aaf7a3fc7: function(arg0) {
200
+ let result;
201
+ try {
202
+ result = arg0 instanceof Uint8Array;
203
+ } catch (_) {
204
+ result = false;
205
+ }
206
+ const ret = result;
207
+ return ret;
208
+ },
209
+ __wbg_isSafeInteger_04f36e4056f1b851: function(arg0) {
210
+ const ret = Number.isSafeInteger(arg0);
211
+ return ret;
212
+ },
213
+ __wbg_length_1f0964f4a5e2c6d8: function(arg0) {
214
+ const ret = arg0.length;
215
+ return ret;
216
+ },
217
+ __wbg_new_32b398fb48b6d94a: function() {
218
+ const ret = new Array();
219
+ return ret;
220
+ },
221
+ __wbg_new_cd45aabdf6073e84: function(arg0) {
222
+ const ret = new Uint8Array(arg0);
223
+ return ret;
224
+ },
225
+ __wbg_new_da52cf8fe3429cb2: function() {
226
+ const ret = new Object();
227
+ return ret;
228
+ },
229
+ __wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
230
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
231
+ },
232
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
233
+ arg0[arg1] = arg2;
234
+ },
235
+ __wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
236
+ arg0[arg1 >>> 0] = arg2;
237
+ },
238
+ __wbindgen_cast_0000000000000001: function(arg0) {
239
+ // Cast intrinsic for `F64 -> Externref`.
240
+ const ret = arg0;
241
+ return ret;
242
+ },
243
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
244
+ // Cast intrinsic for `Ref(String) -> Externref`.
245
+ const ret = getStringFromWasm0(arg0, arg1);
246
+ return ret;
247
+ },
248
+ __wbindgen_cast_0000000000000003: function(arg0) {
249
+ // Cast intrinsic for `U64 -> Externref`.
250
+ const ret = BigInt.asUintN(64, arg0);
251
+ return ret;
252
+ },
253
+ __wbindgen_init_externref_table: function() {
254
+ const table = wasm.__wbindgen_externrefs;
255
+ const offset = table.grow(4);
256
+ table.set(0, undefined);
257
+ table.set(offset + 0, undefined);
258
+ table.set(offset + 1, null);
259
+ table.set(offset + 2, true);
260
+ table.set(offset + 3, false);
261
+ },
262
+ };
263
+ return {
264
+ __proto__: null,
265
+ "./sidespread_wasm_bg.js": import0,
266
+ };
267
+ }
268
+
269
+ const ProcessResultFinalization = (typeof FinalizationRegistry === 'undefined')
270
+ ? { register: () => {}, unregister: () => {} }
271
+ : new FinalizationRegistry(ptr => wasm.__wbg_processresult_free(ptr, 1));
272
+
273
+ function addToExternrefTable0(obj) {
274
+ const idx = wasm.__externref_table_alloc();
275
+ wasm.__wbindgen_externrefs.set(idx, obj);
276
+ return idx;
277
+ }
278
+
279
+ function debugString(val) {
280
+ // primitive types
281
+ const type = typeof val;
282
+ if (type == 'number' || type == 'boolean' || val == null) {
283
+ return `${val}`;
284
+ }
285
+ if (type == 'string') {
286
+ return `"${val}"`;
287
+ }
288
+ if (type == 'symbol') {
289
+ const description = val.description;
290
+ if (description == null) {
291
+ return 'Symbol';
292
+ } else {
293
+ return `Symbol(${description})`;
294
+ }
295
+ }
296
+ if (type == 'function') {
297
+ const name = val.name;
298
+ if (typeof name == 'string' && name.length > 0) {
299
+ return `Function(${name})`;
300
+ } else {
301
+ return 'Function';
302
+ }
303
+ }
304
+ // objects
305
+ if (Array.isArray(val)) {
306
+ const length = val.length;
307
+ let debug = '[';
308
+ if (length > 0) {
309
+ debug += debugString(val[0]);
310
+ }
311
+ for(let i = 1; i < length; i++) {
312
+ debug += ', ' + debugString(val[i]);
313
+ }
314
+ debug += ']';
315
+ return debug;
316
+ }
317
+ // Test for built-in
318
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
319
+ let className;
320
+ if (builtInMatches && builtInMatches.length > 1) {
321
+ className = builtInMatches[1];
322
+ } else {
323
+ // Failed to match the standard '[object ClassName]'
324
+ return toString.call(val);
325
+ }
326
+ if (className == 'Object') {
327
+ // we're a user defined class or Object
328
+ // JSON.stringify avoids problems with cycles, and is generally much
329
+ // easier than looping through ownProperties of `val`.
330
+ try {
331
+ return 'Object(' + JSON.stringify(val) + ')';
332
+ } catch (_) {
333
+ return 'Object';
334
+ }
335
+ }
336
+ // errors
337
+ if (val instanceof Error) {
338
+ return `${val.name}: ${val.message}\n${val.stack}`;
339
+ }
340
+ // TODO we could test for more things here, like `Set`s and `Map`s.
341
+ return className;
342
+ }
343
+
344
+ function getArrayF32FromWasm0(ptr, len) {
345
+ ptr = ptr >>> 0;
346
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
347
+ }
348
+
349
+ function getArrayU8FromWasm0(ptr, len) {
350
+ ptr = ptr >>> 0;
351
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
352
+ }
353
+
354
+ let cachedDataViewMemory0 = null;
355
+ function getDataViewMemory0() {
356
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
357
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
358
+ }
359
+ return cachedDataViewMemory0;
360
+ }
361
+
362
+ let cachedFloat32ArrayMemory0 = null;
363
+ function getFloat32ArrayMemory0() {
364
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
365
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
366
+ }
367
+ return cachedFloat32ArrayMemory0;
368
+ }
369
+
370
+ function getStringFromWasm0(ptr, len) {
371
+ return decodeText(ptr >>> 0, len);
372
+ }
373
+
374
+ let cachedUint8ArrayMemory0 = null;
375
+ function getUint8ArrayMemory0() {
376
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
377
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
378
+ }
379
+ return cachedUint8ArrayMemory0;
380
+ }
381
+
382
+ function handleError(f, args) {
383
+ try {
384
+ return f.apply(this, args);
385
+ } catch (e) {
386
+ const idx = addToExternrefTable0(e);
387
+ wasm.__wbindgen_exn_store(idx);
388
+ }
389
+ }
390
+
391
+ function isLikeNone(x) {
392
+ return x === undefined || x === null;
393
+ }
394
+
395
+ function passArrayF32ToWasm0(arg, malloc) {
396
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
397
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
398
+ WASM_VECTOR_LEN = arg.length;
399
+ return ptr;
400
+ }
401
+
402
+ function passStringToWasm0(arg, malloc, realloc) {
403
+ if (realloc === undefined) {
404
+ const buf = cachedTextEncoder.encode(arg);
405
+ const ptr = malloc(buf.length, 1) >>> 0;
406
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
407
+ WASM_VECTOR_LEN = buf.length;
408
+ return ptr;
409
+ }
410
+
411
+ let len = arg.length;
412
+ let ptr = malloc(len, 1) >>> 0;
413
+
414
+ const mem = getUint8ArrayMemory0();
415
+
416
+ let offset = 0;
417
+
418
+ for (; offset < len; offset++) {
419
+ const code = arg.charCodeAt(offset);
420
+ if (code > 0x7F) break;
421
+ mem[ptr + offset] = code;
422
+ }
423
+ if (offset !== len) {
424
+ if (offset !== 0) {
425
+ arg = arg.slice(offset);
426
+ }
427
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
428
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
429
+ const ret = cachedTextEncoder.encodeInto(arg, view);
430
+
431
+ offset += ret.written;
432
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
433
+ }
434
+
435
+ WASM_VECTOR_LEN = offset;
436
+ return ptr;
437
+ }
438
+
439
+ function takeFromExternrefTable0(idx) {
440
+ const value = wasm.__wbindgen_externrefs.get(idx);
441
+ wasm.__externref_table_dealloc(idx);
442
+ return value;
443
+ }
444
+
445
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
446
+ cachedTextDecoder.decode();
447
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
448
+ let numBytesDecoded = 0;
449
+ function decodeText(ptr, len) {
450
+ numBytesDecoded += len;
451
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
452
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
453
+ cachedTextDecoder.decode();
454
+ numBytesDecoded = len;
455
+ }
456
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
457
+ }
458
+
459
+ const cachedTextEncoder = new TextEncoder();
460
+
461
+ if (!('encodeInto' in cachedTextEncoder)) {
462
+ cachedTextEncoder.encodeInto = function (arg, view) {
463
+ const buf = cachedTextEncoder.encode(arg);
464
+ view.set(buf);
465
+ return {
466
+ read: arg.length,
467
+ written: buf.length
468
+ };
469
+ };
470
+ }
471
+
472
+ let WASM_VECTOR_LEN = 0;
473
+
474
+ let wasmModule, wasmInstance, wasm;
475
+ function __wbg_finalize_init(instance, module) {
476
+ wasmInstance = instance;
477
+ wasm = instance.exports;
478
+ wasmModule = module;
479
+ cachedDataViewMemory0 = null;
480
+ cachedFloat32ArrayMemory0 = null;
481
+ cachedUint8ArrayMemory0 = null;
482
+ wasm.__wbindgen_start();
483
+ return wasm;
484
+ }
485
+
486
+ async function __wbg_load(module, imports) {
487
+ if (typeof Response === 'function' && module instanceof Response) {
488
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
489
+ try {
490
+ return await WebAssembly.instantiateStreaming(module, imports);
491
+ } catch (e) {
492
+ const validResponse = module.ok && expectedResponseType(module.type);
493
+
494
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
495
+ 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", e);
496
+
497
+ } else { throw e; }
498
+ }
499
+ }
500
+
501
+ const bytes = await module.arrayBuffer();
502
+ return await WebAssembly.instantiate(bytes, imports);
503
+ } else {
504
+ const instance = await WebAssembly.instantiate(module, imports);
505
+
506
+ if (instance instanceof WebAssembly.Instance) {
507
+ return { instance, module };
508
+ } else {
509
+ return instance;
510
+ }
511
+ }
512
+
513
+ function expectedResponseType(type) {
514
+ switch (type) {
515
+ case 'basic': case 'cors': case 'default': return true;
516
+ }
517
+ return false;
518
+ }
519
+ }
520
+
521
+ function initSync(module) {
522
+ if (wasm !== undefined) return wasm;
523
+
524
+
525
+ if (module !== undefined) {
526
+ if (Object.getPrototypeOf(module) === Object.prototype) {
527
+ ({module} = module)
528
+ } else {
529
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
530
+ }
531
+ }
532
+
533
+ const imports = __wbg_get_imports();
534
+ if (!(module instanceof WebAssembly.Module)) {
535
+ module = new WebAssembly.Module(module);
536
+ }
537
+ const instance = new WebAssembly.Instance(module, imports);
538
+ return __wbg_finalize_init(instance, module);
539
+ }
540
+
541
+ async function __wbg_init(module_or_path) {
542
+ if (wasm !== undefined) return wasm;
543
+
544
+
545
+ if (module_or_path !== undefined) {
546
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
547
+ ({module_or_path} = module_or_path)
548
+ } else {
549
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
550
+ }
551
+ }
552
+
553
+ if (module_or_path === undefined) {
554
+ module_or_path = new URL('sidespread_wasm_bg.wasm', import.meta.url);
555
+ }
556
+ const imports = __wbg_get_imports();
557
+
558
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
559
+ module_or_path = fetch(module_or_path);
560
+ }
561
+
562
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
563
+
564
+ return __wbg_finalize_init(instance, module);
565
+ }
566
+
567
+ export { initSync, __wbg_init as default };
@@ -0,0 +1,18 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_processresult_free: (a: number, b: number) => void;
5
+ export const analyze: (a: number, b: number, c: number, d: any) => [number, number, number];
6
+ export const process: (a: number, b: number, c: number, d: any, e: number) => [number, number, number];
7
+ export const processresult_audio: (a: number) => [number, number];
8
+ export const processresult_report: (a: number) => [number, number, number];
9
+ export const processresult_takeAudio: (a: number) => [number, number];
10
+ export const version: () => [number, number];
11
+ export const __wbindgen_malloc: (a: number, b: number) => number;
12
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
13
+ export const __wbindgen_exn_store: (a: number) => void;
14
+ export const __externref_table_alloc: () => number;
15
+ export const __wbindgen_externrefs: WebAssembly.Table;
16
+ export const __externref_table_dealloc: (a: number) => void;
17
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
18
+ export const __wbindgen_start: () => void;
package/dist/web.js ADDED
@@ -0,0 +1,54 @@
1
+ import initWasm, {
2
+ analyze as wasmAnalyze,
3
+ process as wasmProcess,
4
+ version as wasmVersion,
5
+ } from "./wasm/web/sidespread_wasm.js";
6
+ import {
7
+ assertAudioInput,
8
+ assertOptions,
9
+ assertProgressCallback,
10
+ deinterleave,
11
+ interleave,
12
+ normalizeReport,
13
+ unwrapProcessResult,
14
+ } from "./shared.js";
15
+
16
+ let initPromise;
17
+ let initialized = false;
18
+
19
+ export function init(input) {
20
+ if (!initPromise) {
21
+ initPromise = initWasm(input).then(() => {
22
+ initialized = true;
23
+ });
24
+ }
25
+ return initPromise;
26
+ }
27
+
28
+ export function version() {
29
+ ensureInitialized();
30
+ return wasmVersion();
31
+ }
32
+
33
+ export function analyze(audio, sampleRate, options = {}) {
34
+ ensureInitialized();
35
+ assertAudioInput(audio, sampleRate);
36
+ assertOptions(options);
37
+ return normalizeReport(wasmAnalyze(audio, sampleRate, options));
38
+ }
39
+
40
+ export function process(audio, sampleRate, options = {}, onProgress) {
41
+ ensureInitialized();
42
+ assertAudioInput(audio, sampleRate);
43
+ assertOptions(options);
44
+ assertProgressCallback(onProgress);
45
+ return unwrapProcessResult(wasmProcess(audio, sampleRate, options, onProgress));
46
+ }
47
+
48
+ export { deinterleave, interleave };
49
+
50
+ function ensureInitialized() {
51
+ if (!initialized) {
52
+ throw new Error("Sidespread is not initialized; call and await init() first");
53
+ }
54
+ }
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "sidespread",
3
+ "version": "0.5.0",
4
+ "description": "Sidespread DSP audio repair for Web and Node.js, powered by WebAssembly",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "files": [
9
+ "dist",
10
+ "LICENSE",
11
+ "README.md"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "browser": "./dist/web.js",
17
+ "node": "./dist/node.js",
18
+ "default": "./dist/web.js"
19
+ }
20
+ },
21
+ "types": "./dist/index.d.ts",
22
+ "engines": {
23
+ "node": ">=18"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/backrunner/sidespread.git"
28
+ },
29
+ "homepage": "https://github.com/backrunner/sidespread#readme",
30
+ "bugs": "https://github.com/backrunner/sidespread/issues",
31
+ "scripts": {
32
+ "build": "node ./scripts/build.mjs",
33
+ "prepack": "npm run build",
34
+ "test": "npm run build && node --test ./tests/node.test.mjs"
35
+ },
36
+ "keywords": [
37
+ "audio",
38
+ "dsp",
39
+ "wasm",
40
+ "webassembly",
41
+ "music"
42
+ ]
43
+ }