rusty-chromaprint-wasm 0.1.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/README.md +30 -0
- package/package.json +16 -0
- package/rusty_chromaprint_wasm.d.ts +88 -0
- package/rusty_chromaprint_wasm.js +356 -0
- package/rusty_chromaprint_wasm_bg.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# chromaprint-wasm
|
|
2
|
+
|
|
3
|
+
WASM bindings for [rusty-chromaprint](https://github.com/darksv/rusty-chromaprint). Uses preset test2 (AcoustID/fpcalc compatible).
|
|
4
|
+
|
|
5
|
+
## Build
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install wasm-pack if needed: cargo install wasm-pack
|
|
9
|
+
wasm-pack build --target web
|
|
10
|
+
# Or for Node: wasm-pack build --target nodejs
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Output in `pkg/`: `.wasm`, `.js` glue, and (with wasm-pack) TypeScript definitions.
|
|
14
|
+
|
|
15
|
+
## API (from JS)
|
|
16
|
+
|
|
17
|
+
- **`new Fingerprinter()`** – create a fingerprinter
|
|
18
|
+
- **`.start(sampleRate, channels)`** – e.g. `44100`, `1` or `2`
|
|
19
|
+
- **`.consume(samples)`** – `samples` is an `Int16Array` (interleaved if stereo)
|
|
20
|
+
- **`.finish()`** – call when all samples have been fed
|
|
21
|
+
- **`.getFingerprint()`** – returns `Uint32Array` (raw)
|
|
22
|
+
- **`.getCompressedFingerprint()`** – returns base64 string (AcoustID format)
|
|
23
|
+
|
|
24
|
+
- **`fingerprintFromSamples(sampleRate, channels, samples)`** – one-shot; returns `{ raw: Uint32Array, compressed: string }`
|
|
25
|
+
|
|
26
|
+
- **`matchFingerprints(raw1, raw2)`** – both `Uint32Array`; returns array of `{ start1, end1, start2, end2, duration, score }` (times in seconds)
|
|
27
|
+
|
|
28
|
+
## Audio input
|
|
29
|
+
|
|
30
|
+
Decode in the browser (e.g. `decodeAudioData`), get channel data as Float32, convert to i16 (e.g. `samples[i] = Math.max(-32768, Math.min(32767, channelData[i] * 32768))`), then pass as `Int16Array` to `consume()` or `fingerprintFromSamples`.
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rusty-chromaprint-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "WASM bindings for rusty-chromaprint audio fingerprinting",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"files": [
|
|
7
|
+
"rusty_chromaprint_wasm_bg.wasm",
|
|
8
|
+
"rusty_chromaprint_wasm.js",
|
|
9
|
+
"rusty_chromaprint_wasm.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"main": "rusty_chromaprint_wasm.js",
|
|
12
|
+
"types": "rusty_chromaprint_wasm.d.ts",
|
|
13
|
+
"sideEffects": [
|
|
14
|
+
"./snippets/*"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create a new fingerprinter. Uses the default preset (compatible with AcoustID).
|
|
6
|
+
*/
|
|
7
|
+
export class Fingerprinter {
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
/**
|
|
11
|
+
* Feed interleaved i16 samples (e.g. from decodeAudioData → getChannelData → convert to i16).
|
|
12
|
+
* Pass an Int16Array from JS.
|
|
13
|
+
*/
|
|
14
|
+
consume(samples: Int16Array): void;
|
|
15
|
+
/**
|
|
16
|
+
* Call when all samples have been fed.
|
|
17
|
+
*/
|
|
18
|
+
finish(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Compressed fingerprint as base64 (AcoustID/fpcalc format). Only valid after finish().
|
|
21
|
+
*/
|
|
22
|
+
getCompressedFingerprint(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Raw fingerprint (u32 array). Only valid after finish().
|
|
25
|
+
*/
|
|
26
|
+
getFingerprint(): Uint32Array;
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Start fingerprinting. Call with your audio's sample rate (e.g. 44100) and channel count (1 or 2).
|
|
30
|
+
*/
|
|
31
|
+
start(sample_rate: number, channels: number): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* One-shot: compute fingerprint from interleaved i16 samples.
|
|
36
|
+
* Returns `{ raw: Uint32Array, compressed: string }`.
|
|
37
|
+
*/
|
|
38
|
+
export function fingerprintFromSamples(sample_rate: number, channels: number, samples: Int16Array): any;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Match two raw fingerprints (u32 arrays). Returns segments of similar audio.
|
|
42
|
+
* Each segment has start1, end1, start2, end2, duration (seconds) and score.
|
|
43
|
+
*/
|
|
44
|
+
export function matchFingerprints(raw1: Uint32Array, raw2: Uint32Array): any;
|
|
45
|
+
|
|
46
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
47
|
+
|
|
48
|
+
export interface InitOutput {
|
|
49
|
+
readonly memory: WebAssembly.Memory;
|
|
50
|
+
readonly __wbg_fingerprinter_free: (a: number, b: number) => void;
|
|
51
|
+
readonly fingerprintFromSamples: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
52
|
+
readonly fingerprinter_consume: (a: number, b: number, c: number) => void;
|
|
53
|
+
readonly fingerprinter_finish: (a: number) => void;
|
|
54
|
+
readonly fingerprinter_getCompressedFingerprint: (a: number) => [number, number];
|
|
55
|
+
readonly fingerprinter_getFingerprint: (a: number) => [number, number];
|
|
56
|
+
readonly fingerprinter_new: () => [number, number, number];
|
|
57
|
+
readonly fingerprinter_start: (a: number, b: number, c: number) => [number, number];
|
|
58
|
+
readonly matchFingerprints: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
59
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
60
|
+
readonly __externref_table_alloc: () => number;
|
|
61
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
62
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
63
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
64
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
65
|
+
readonly __wbindgen_start: () => void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
72
|
+
* a precompiled `WebAssembly.Module`.
|
|
73
|
+
*
|
|
74
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
75
|
+
*
|
|
76
|
+
* @returns {InitOutput}
|
|
77
|
+
*/
|
|
78
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
82
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
83
|
+
*
|
|
84
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
85
|
+
*
|
|
86
|
+
* @returns {Promise<InitOutput>}
|
|
87
|
+
*/
|
|
88
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
/* @ts-self-types="./rusty_chromaprint_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create a new fingerprinter. Uses the default preset (compatible with AcoustID).
|
|
5
|
+
*/
|
|
6
|
+
export class Fingerprinter {
|
|
7
|
+
__destroy_into_raw() {
|
|
8
|
+
const ptr = this.__wbg_ptr;
|
|
9
|
+
this.__wbg_ptr = 0;
|
|
10
|
+
FingerprinterFinalization.unregister(this);
|
|
11
|
+
return ptr;
|
|
12
|
+
}
|
|
13
|
+
free() {
|
|
14
|
+
const ptr = this.__destroy_into_raw();
|
|
15
|
+
wasm.__wbg_fingerprinter_free(ptr, 0);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Feed interleaved i16 samples (e.g. from decodeAudioData → getChannelData → convert to i16).
|
|
19
|
+
* Pass an Int16Array from JS.
|
|
20
|
+
* @param {Int16Array} samples
|
|
21
|
+
*/
|
|
22
|
+
consume(samples) {
|
|
23
|
+
const ptr0 = passArray16ToWasm0(samples, wasm.__wbindgen_malloc);
|
|
24
|
+
const len0 = WASM_VECTOR_LEN;
|
|
25
|
+
wasm.fingerprinter_consume(this.__wbg_ptr, ptr0, len0);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Call when all samples have been fed.
|
|
29
|
+
*/
|
|
30
|
+
finish() {
|
|
31
|
+
wasm.fingerprinter_finish(this.__wbg_ptr);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Compressed fingerprint as base64 (AcoustID/fpcalc format). Only valid after finish().
|
|
35
|
+
* @returns {string}
|
|
36
|
+
*/
|
|
37
|
+
getCompressedFingerprint() {
|
|
38
|
+
let deferred1_0;
|
|
39
|
+
let deferred1_1;
|
|
40
|
+
try {
|
|
41
|
+
const ret = wasm.fingerprinter_getCompressedFingerprint(this.__wbg_ptr);
|
|
42
|
+
deferred1_0 = ret[0];
|
|
43
|
+
deferred1_1 = ret[1];
|
|
44
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
45
|
+
} finally {
|
|
46
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Raw fingerprint (u32 array). Only valid after finish().
|
|
51
|
+
* @returns {Uint32Array}
|
|
52
|
+
*/
|
|
53
|
+
getFingerprint() {
|
|
54
|
+
const ret = wasm.fingerprinter_getFingerprint(this.__wbg_ptr);
|
|
55
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
56
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
57
|
+
return v1;
|
|
58
|
+
}
|
|
59
|
+
constructor() {
|
|
60
|
+
const ret = wasm.fingerprinter_new();
|
|
61
|
+
if (ret[2]) {
|
|
62
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
63
|
+
}
|
|
64
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
65
|
+
FingerprinterFinalization.register(this, this.__wbg_ptr, this);
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Start fingerprinting. Call with your audio's sample rate (e.g. 44100) and channel count (1 or 2).
|
|
70
|
+
* @param {number} sample_rate
|
|
71
|
+
* @param {number} channels
|
|
72
|
+
*/
|
|
73
|
+
start(sample_rate, channels) {
|
|
74
|
+
const ret = wasm.fingerprinter_start(this.__wbg_ptr, sample_rate, channels);
|
|
75
|
+
if (ret[1]) {
|
|
76
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (Symbol.dispose) Fingerprinter.prototype[Symbol.dispose] = Fingerprinter.prototype.free;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* One-shot: compute fingerprint from interleaved i16 samples.
|
|
84
|
+
* Returns `{ raw: Uint32Array, compressed: string }`.
|
|
85
|
+
* @param {number} sample_rate
|
|
86
|
+
* @param {number} channels
|
|
87
|
+
* @param {Int16Array} samples
|
|
88
|
+
* @returns {any}
|
|
89
|
+
*/
|
|
90
|
+
export function fingerprintFromSamples(sample_rate, channels, samples) {
|
|
91
|
+
const ptr0 = passArray16ToWasm0(samples, wasm.__wbindgen_malloc);
|
|
92
|
+
const len0 = WASM_VECTOR_LEN;
|
|
93
|
+
const ret = wasm.fingerprintFromSamples(sample_rate, channels, ptr0, len0);
|
|
94
|
+
if (ret[2]) {
|
|
95
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
96
|
+
}
|
|
97
|
+
return takeFromExternrefTable0(ret[0]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Match two raw fingerprints (u32 arrays). Returns segments of similar audio.
|
|
102
|
+
* Each segment has start1, end1, start2, end2, duration (seconds) and score.
|
|
103
|
+
* @param {Uint32Array} raw1
|
|
104
|
+
* @param {Uint32Array} raw2
|
|
105
|
+
* @returns {any}
|
|
106
|
+
*/
|
|
107
|
+
export function matchFingerprints(raw1, raw2) {
|
|
108
|
+
const ptr0 = passArray32ToWasm0(raw1, wasm.__wbindgen_malloc);
|
|
109
|
+
const len0 = WASM_VECTOR_LEN;
|
|
110
|
+
const ptr1 = passArray32ToWasm0(raw2, wasm.__wbindgen_malloc);
|
|
111
|
+
const len1 = WASM_VECTOR_LEN;
|
|
112
|
+
const ret = wasm.matchFingerprints(ptr0, len0, ptr1, len1);
|
|
113
|
+
if (ret[2]) {
|
|
114
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
115
|
+
}
|
|
116
|
+
return takeFromExternrefTable0(ret[0]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function __wbg_get_imports() {
|
|
120
|
+
const import0 = {
|
|
121
|
+
__proto__: null,
|
|
122
|
+
__wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
|
|
123
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
124
|
+
return ret;
|
|
125
|
+
},
|
|
126
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
127
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
128
|
+
},
|
|
129
|
+
__wbg_new_a70fbab9066b301f: function() {
|
|
130
|
+
const ret = new Array();
|
|
131
|
+
return ret;
|
|
132
|
+
},
|
|
133
|
+
__wbg_new_ab79df5bd7c26067: function() {
|
|
134
|
+
const ret = new Object();
|
|
135
|
+
return ret;
|
|
136
|
+
},
|
|
137
|
+
__wbg_new_from_slice_898ac63cbd46f332: function(arg0, arg1) {
|
|
138
|
+
const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
|
|
139
|
+
return ret;
|
|
140
|
+
},
|
|
141
|
+
__wbg_push_e87b0e732085a946: function(arg0, arg1) {
|
|
142
|
+
const ret = arg0.push(arg1);
|
|
143
|
+
return ret;
|
|
144
|
+
},
|
|
145
|
+
__wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
|
|
146
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
147
|
+
return ret;
|
|
148
|
+
}, arguments); },
|
|
149
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
150
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
151
|
+
const ret = arg0;
|
|
152
|
+
return ret;
|
|
153
|
+
},
|
|
154
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
155
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
156
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
157
|
+
return ret;
|
|
158
|
+
},
|
|
159
|
+
__wbindgen_init_externref_table: function() {
|
|
160
|
+
const table = wasm.__wbindgen_externrefs;
|
|
161
|
+
const offset = table.grow(4);
|
|
162
|
+
table.set(0, undefined);
|
|
163
|
+
table.set(offset + 0, undefined);
|
|
164
|
+
table.set(offset + 1, null);
|
|
165
|
+
table.set(offset + 2, true);
|
|
166
|
+
table.set(offset + 3, false);
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
return {
|
|
170
|
+
__proto__: null,
|
|
171
|
+
"./rusty_chromaprint_wasm_bg.js": import0,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const FingerprinterFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
176
|
+
? { register: () => {}, unregister: () => {} }
|
|
177
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_fingerprinter_free(ptr >>> 0, 1));
|
|
178
|
+
|
|
179
|
+
function addToExternrefTable0(obj) {
|
|
180
|
+
const idx = wasm.__externref_table_alloc();
|
|
181
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
182
|
+
return idx;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
186
|
+
ptr = ptr >>> 0;
|
|
187
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function getStringFromWasm0(ptr, len) {
|
|
191
|
+
ptr = ptr >>> 0;
|
|
192
|
+
return decodeText(ptr, len);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
let cachedUint16ArrayMemory0 = null;
|
|
196
|
+
function getUint16ArrayMemory0() {
|
|
197
|
+
if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
|
|
198
|
+
cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
|
|
199
|
+
}
|
|
200
|
+
return cachedUint16ArrayMemory0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
let cachedUint32ArrayMemory0 = null;
|
|
204
|
+
function getUint32ArrayMemory0() {
|
|
205
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
206
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
207
|
+
}
|
|
208
|
+
return cachedUint32ArrayMemory0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
let cachedUint8ArrayMemory0 = null;
|
|
212
|
+
function getUint8ArrayMemory0() {
|
|
213
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
214
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
215
|
+
}
|
|
216
|
+
return cachedUint8ArrayMemory0;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function handleError(f, args) {
|
|
220
|
+
try {
|
|
221
|
+
return f.apply(this, args);
|
|
222
|
+
} catch (e) {
|
|
223
|
+
const idx = addToExternrefTable0(e);
|
|
224
|
+
wasm.__wbindgen_exn_store(idx);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function passArray16ToWasm0(arg, malloc) {
|
|
229
|
+
const ptr = malloc(arg.length * 2, 2) >>> 0;
|
|
230
|
+
getUint16ArrayMemory0().set(arg, ptr / 2);
|
|
231
|
+
WASM_VECTOR_LEN = arg.length;
|
|
232
|
+
return ptr;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
236
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
237
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
238
|
+
WASM_VECTOR_LEN = arg.length;
|
|
239
|
+
return ptr;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function takeFromExternrefTable0(idx) {
|
|
243
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
244
|
+
wasm.__externref_table_dealloc(idx);
|
|
245
|
+
return value;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
249
|
+
cachedTextDecoder.decode();
|
|
250
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
251
|
+
let numBytesDecoded = 0;
|
|
252
|
+
function decodeText(ptr, len) {
|
|
253
|
+
numBytesDecoded += len;
|
|
254
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
255
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
256
|
+
cachedTextDecoder.decode();
|
|
257
|
+
numBytesDecoded = len;
|
|
258
|
+
}
|
|
259
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let WASM_VECTOR_LEN = 0;
|
|
263
|
+
|
|
264
|
+
let wasmModule, wasm;
|
|
265
|
+
function __wbg_finalize_init(instance, module) {
|
|
266
|
+
wasm = instance.exports;
|
|
267
|
+
wasmModule = module;
|
|
268
|
+
cachedUint16ArrayMemory0 = null;
|
|
269
|
+
cachedUint32ArrayMemory0 = null;
|
|
270
|
+
cachedUint8ArrayMemory0 = null;
|
|
271
|
+
wasm.__wbindgen_start();
|
|
272
|
+
return wasm;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async function __wbg_load(module, imports) {
|
|
276
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
277
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
278
|
+
try {
|
|
279
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
280
|
+
} catch (e) {
|
|
281
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
282
|
+
|
|
283
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
284
|
+
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);
|
|
285
|
+
|
|
286
|
+
} else { throw e; }
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const bytes = await module.arrayBuffer();
|
|
291
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
292
|
+
} else {
|
|
293
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
294
|
+
|
|
295
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
296
|
+
return { instance, module };
|
|
297
|
+
} else {
|
|
298
|
+
return instance;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function expectedResponseType(type) {
|
|
303
|
+
switch (type) {
|
|
304
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
305
|
+
}
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function initSync(module) {
|
|
311
|
+
if (wasm !== undefined) return wasm;
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
if (module !== undefined) {
|
|
315
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
316
|
+
({module} = module)
|
|
317
|
+
} else {
|
|
318
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const imports = __wbg_get_imports();
|
|
323
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
324
|
+
module = new WebAssembly.Module(module);
|
|
325
|
+
}
|
|
326
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
327
|
+
return __wbg_finalize_init(instance, module);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
async function __wbg_init(module_or_path) {
|
|
331
|
+
if (wasm !== undefined) return wasm;
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
if (module_or_path !== undefined) {
|
|
335
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
336
|
+
({module_or_path} = module_or_path)
|
|
337
|
+
} else {
|
|
338
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (module_or_path === undefined) {
|
|
343
|
+
module_or_path = new URL('rusty_chromaprint_wasm_bg.wasm', import.meta.url);
|
|
344
|
+
}
|
|
345
|
+
const imports = __wbg_get_imports();
|
|
346
|
+
|
|
347
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
348
|
+
module_or_path = fetch(module_or_path);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
352
|
+
|
|
353
|
+
return __wbg_finalize_init(instance, module);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|