rusty-chromaprint-wasm 0.1.3 → 0.1.5
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.
|
@@ -42,6 +42,31 @@ export class Fingerprinter {
|
|
|
42
42
|
start(sample_rate: number, channels: number): void;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Result of matching two fingerprints.
|
|
47
|
+
*/
|
|
48
|
+
export class MatchFingerprintsResult {
|
|
49
|
+
private constructor();
|
|
50
|
+
free(): void;
|
|
51
|
+
[Symbol.dispose](): void;
|
|
52
|
+
segments: MatchSegment[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A matched segment between two fingerprints.
|
|
57
|
+
*/
|
|
58
|
+
export class MatchSegment {
|
|
59
|
+
private constructor();
|
|
60
|
+
free(): void;
|
|
61
|
+
[Symbol.dispose](): void;
|
|
62
|
+
readonly duration: number;
|
|
63
|
+
readonly end1: number;
|
|
64
|
+
readonly end2: number;
|
|
65
|
+
readonly score: number;
|
|
66
|
+
readonly start1: number;
|
|
67
|
+
readonly start2: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
45
70
|
/**
|
|
46
71
|
* One-shot: compute fingerprint from interleaved i16 samples.
|
|
47
72
|
*/
|
|
@@ -49,6 +74,5 @@ export function fingerprintFromSamples(sample_rate: number, channels: number, sa
|
|
|
49
74
|
|
|
50
75
|
/**
|
|
51
76
|
* Match two raw fingerprints (u32 arrays). Returns segments of similar audio.
|
|
52
|
-
* Each segment has start1, end1, start2, end2, duration (seconds) and score.
|
|
53
77
|
*/
|
|
54
|
-
export function matchFingerprints(raw1: Uint32Array, raw2: Uint32Array):
|
|
78
|
+
export function matchFingerprints(raw1: Uint32Array, raw2: Uint32Array): MatchFingerprintsResult;
|
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./rusty_chromaprint_wasm_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
FingerprintFromSamplesResult, Fingerprinter, fingerprintFromSamples, matchFingerprints
|
|
8
|
+
FingerprintFromSamplesResult, Fingerprinter, MatchFingerprintsResult, MatchSegment, fingerprintFromSamples, matchFingerprints
|
|
9
9
|
} from "./rusty_chromaprint_wasm_bg.js";
|
|
@@ -141,6 +141,119 @@ export class Fingerprinter {
|
|
|
141
141
|
}
|
|
142
142
|
if (Symbol.dispose) Fingerprinter.prototype[Symbol.dispose] = Fingerprinter.prototype.free;
|
|
143
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Result of matching two fingerprints.
|
|
146
|
+
*/
|
|
147
|
+
export class MatchFingerprintsResult {
|
|
148
|
+
static __wrap(ptr) {
|
|
149
|
+
ptr = ptr >>> 0;
|
|
150
|
+
const obj = Object.create(MatchFingerprintsResult.prototype);
|
|
151
|
+
obj.__wbg_ptr = ptr;
|
|
152
|
+
MatchFingerprintsResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
153
|
+
return obj;
|
|
154
|
+
}
|
|
155
|
+
__destroy_into_raw() {
|
|
156
|
+
const ptr = this.__wbg_ptr;
|
|
157
|
+
this.__wbg_ptr = 0;
|
|
158
|
+
MatchFingerprintsResultFinalization.unregister(this);
|
|
159
|
+
return ptr;
|
|
160
|
+
}
|
|
161
|
+
free() {
|
|
162
|
+
const ptr = this.__destroy_into_raw();
|
|
163
|
+
wasm.__wbg_matchfingerprintsresult_free(ptr, 0);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* @returns {MatchSegment[]}
|
|
167
|
+
*/
|
|
168
|
+
get segments() {
|
|
169
|
+
const ret = wasm.__wbg_get_matchfingerprintsresult_segments(this.__wbg_ptr);
|
|
170
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
171
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
172
|
+
return v1;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* @param {MatchSegment[]} arg0
|
|
176
|
+
*/
|
|
177
|
+
set segments(arg0) {
|
|
178
|
+
const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
179
|
+
const len0 = WASM_VECTOR_LEN;
|
|
180
|
+
wasm.__wbg_set_matchfingerprintsresult_segments(this.__wbg_ptr, ptr0, len0);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (Symbol.dispose) MatchFingerprintsResult.prototype[Symbol.dispose] = MatchFingerprintsResult.prototype.free;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* A matched segment between two fingerprints.
|
|
187
|
+
*/
|
|
188
|
+
export class MatchSegment {
|
|
189
|
+
static __wrap(ptr) {
|
|
190
|
+
ptr = ptr >>> 0;
|
|
191
|
+
const obj = Object.create(MatchSegment.prototype);
|
|
192
|
+
obj.__wbg_ptr = ptr;
|
|
193
|
+
MatchSegmentFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
194
|
+
return obj;
|
|
195
|
+
}
|
|
196
|
+
static __unwrap(jsValue) {
|
|
197
|
+
if (!(jsValue instanceof MatchSegment)) {
|
|
198
|
+
return 0;
|
|
199
|
+
}
|
|
200
|
+
return jsValue.__destroy_into_raw();
|
|
201
|
+
}
|
|
202
|
+
__destroy_into_raw() {
|
|
203
|
+
const ptr = this.__wbg_ptr;
|
|
204
|
+
this.__wbg_ptr = 0;
|
|
205
|
+
MatchSegmentFinalization.unregister(this);
|
|
206
|
+
return ptr;
|
|
207
|
+
}
|
|
208
|
+
free() {
|
|
209
|
+
const ptr = this.__destroy_into_raw();
|
|
210
|
+
wasm.__wbg_matchsegment_free(ptr, 0);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* @returns {number}
|
|
214
|
+
*/
|
|
215
|
+
get duration() {
|
|
216
|
+
const ret = wasm.matchsegment_duration(this.__wbg_ptr);
|
|
217
|
+
return ret;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* @returns {number}
|
|
221
|
+
*/
|
|
222
|
+
get end1() {
|
|
223
|
+
const ret = wasm.matchsegment_end1(this.__wbg_ptr);
|
|
224
|
+
return ret;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* @returns {number}
|
|
228
|
+
*/
|
|
229
|
+
get end2() {
|
|
230
|
+
const ret = wasm.matchsegment_end2(this.__wbg_ptr);
|
|
231
|
+
return ret;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* @returns {number}
|
|
235
|
+
*/
|
|
236
|
+
get score() {
|
|
237
|
+
const ret = wasm.matchsegment_score(this.__wbg_ptr);
|
|
238
|
+
return ret;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* @returns {number}
|
|
242
|
+
*/
|
|
243
|
+
get start1() {
|
|
244
|
+
const ret = wasm.matchsegment_start1(this.__wbg_ptr);
|
|
245
|
+
return ret;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* @returns {number}
|
|
249
|
+
*/
|
|
250
|
+
get start2() {
|
|
251
|
+
const ret = wasm.matchsegment_start2(this.__wbg_ptr);
|
|
252
|
+
return ret;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (Symbol.dispose) MatchSegment.prototype[Symbol.dispose] = MatchSegment.prototype.free;
|
|
256
|
+
|
|
144
257
|
/**
|
|
145
258
|
* One-shot: compute fingerprint from interleaved i16 samples.
|
|
146
259
|
* @param {number} sample_rate
|
|
@@ -160,10 +273,9 @@ export function fingerprintFromSamples(sample_rate, channels, samples) {
|
|
|
160
273
|
|
|
161
274
|
/**
|
|
162
275
|
* Match two raw fingerprints (u32 arrays). Returns segments of similar audio.
|
|
163
|
-
* Each segment has start1, end1, start2, end2, duration (seconds) and score.
|
|
164
276
|
* @param {Uint32Array} raw1
|
|
165
277
|
* @param {Uint32Array} raw2
|
|
166
|
-
* @returns {
|
|
278
|
+
* @returns {MatchFingerprintsResult}
|
|
167
279
|
*/
|
|
168
280
|
export function matchFingerprints(raw1, raw2) {
|
|
169
281
|
const ptr0 = passArray32ToWasm0(raw1, wasm.__wbindgen_malloc);
|
|
@@ -174,7 +286,7 @@ export function matchFingerprints(raw1, raw2) {
|
|
|
174
286
|
if (ret[2]) {
|
|
175
287
|
throw takeFromExternrefTable0(ret[1]);
|
|
176
288
|
}
|
|
177
|
-
return
|
|
289
|
+
return MatchFingerprintsResult.__wrap(ret[0]);
|
|
178
290
|
}
|
|
179
291
|
export function __wbg_Error_83742b46f01ce22d(arg0, arg1) {
|
|
180
292
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
@@ -183,30 +295,12 @@ export function __wbg_Error_83742b46f01ce22d(arg0, arg1) {
|
|
|
183
295
|
export function __wbg___wbindgen_throw_6ddd609b62940d55(arg0, arg1) {
|
|
184
296
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
185
297
|
}
|
|
186
|
-
export function
|
|
187
|
-
const ret =
|
|
188
|
-
return ret;
|
|
189
|
-
}
|
|
190
|
-
export function __wbg_new_ab79df5bd7c26067() {
|
|
191
|
-
const ret = new Object();
|
|
298
|
+
export function __wbg_matchsegment_new(arg0) {
|
|
299
|
+
const ret = MatchSegment.__wrap(arg0);
|
|
192
300
|
return ret;
|
|
193
301
|
}
|
|
194
|
-
export function
|
|
195
|
-
const ret =
|
|
196
|
-
return ret;
|
|
197
|
-
}
|
|
198
|
-
export function __wbg_set_7eaa4f96924fd6b3() { return handleError(function (arg0, arg1, arg2) {
|
|
199
|
-
const ret = Reflect.set(arg0, arg1, arg2);
|
|
200
|
-
return ret;
|
|
201
|
-
}, arguments); }
|
|
202
|
-
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
203
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
204
|
-
const ret = arg0;
|
|
205
|
-
return ret;
|
|
206
|
-
}
|
|
207
|
-
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
208
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
209
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
302
|
+
export function __wbg_matchsegment_unwrap(arg0) {
|
|
303
|
+
const ret = MatchSegment.__unwrap(arg0);
|
|
210
304
|
return ret;
|
|
211
305
|
}
|
|
212
306
|
export function __wbindgen_init_externref_table() {
|
|
@@ -221,6 +315,12 @@ export function __wbindgen_init_externref_table() {
|
|
|
221
315
|
const FingerprintFromSamplesResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
222
316
|
? { register: () => {}, unregister: () => {} }
|
|
223
317
|
: new FinalizationRegistry(ptr => wasm.__wbg_fingerprintfromsamplesresult_free(ptr >>> 0, 1));
|
|
318
|
+
const MatchFingerprintsResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
319
|
+
? { register: () => {}, unregister: () => {} }
|
|
320
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_matchfingerprintsresult_free(ptr >>> 0, 1));
|
|
321
|
+
const MatchSegmentFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
322
|
+
? { register: () => {}, unregister: () => {} }
|
|
323
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_matchsegment_free(ptr >>> 0, 1));
|
|
224
324
|
const FingerprinterFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
225
325
|
? { register: () => {}, unregister: () => {} }
|
|
226
326
|
: new FinalizationRegistry(ptr => wasm.__wbg_fingerprinter_free(ptr >>> 0, 1));
|
|
@@ -231,11 +331,30 @@ function addToExternrefTable0(obj) {
|
|
|
231
331
|
return idx;
|
|
232
332
|
}
|
|
233
333
|
|
|
334
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
335
|
+
ptr = ptr >>> 0;
|
|
336
|
+
const mem = getDataViewMemory0();
|
|
337
|
+
const result = [];
|
|
338
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
339
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
340
|
+
}
|
|
341
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
342
|
+
return result;
|
|
343
|
+
}
|
|
344
|
+
|
|
234
345
|
function getArrayU32FromWasm0(ptr, len) {
|
|
235
346
|
ptr = ptr >>> 0;
|
|
236
347
|
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
237
348
|
}
|
|
238
349
|
|
|
350
|
+
let cachedDataViewMemory0 = null;
|
|
351
|
+
function getDataViewMemory0() {
|
|
352
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
353
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
354
|
+
}
|
|
355
|
+
return cachedDataViewMemory0;
|
|
356
|
+
}
|
|
357
|
+
|
|
239
358
|
function getStringFromWasm0(ptr, len) {
|
|
240
359
|
ptr = ptr >>> 0;
|
|
241
360
|
return decodeText(ptr, len);
|
|
@@ -265,15 +384,6 @@ function getUint8ArrayMemory0() {
|
|
|
265
384
|
return cachedUint8ArrayMemory0;
|
|
266
385
|
}
|
|
267
386
|
|
|
268
|
-
function handleError(f, args) {
|
|
269
|
-
try {
|
|
270
|
-
return f.apply(this, args);
|
|
271
|
-
} catch (e) {
|
|
272
|
-
const idx = addToExternrefTable0(e);
|
|
273
|
-
wasm.__wbindgen_exn_store(idx);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
387
|
function passArray16ToWasm0(arg, malloc) {
|
|
278
388
|
const ptr = malloc(arg.length * 2, 2) >>> 0;
|
|
279
389
|
getUint16ArrayMemory0().set(arg, ptr / 2);
|
|
@@ -288,6 +398,16 @@ function passArray32ToWasm0(arg, malloc) {
|
|
|
288
398
|
return ptr;
|
|
289
399
|
}
|
|
290
400
|
|
|
401
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
402
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
403
|
+
for (let i = 0; i < array.length; i++) {
|
|
404
|
+
const add = addToExternrefTable0(array[i]);
|
|
405
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
406
|
+
}
|
|
407
|
+
WASM_VECTOR_LEN = array.length;
|
|
408
|
+
return ptr;
|
|
409
|
+
}
|
|
410
|
+
|
|
291
411
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
292
412
|
if (realloc === undefined) {
|
|
293
413
|
const buf = cachedTextEncoder.encode(arg);
|
|
Binary file
|
|
@@ -5,8 +5,12 @@ export const __wbg_fingerprinter_free: (a: number, b: number) => void;
|
|
|
5
5
|
export const __wbg_fingerprintfromsamplesresult_free: (a: number, b: number) => void;
|
|
6
6
|
export const __wbg_get_fingerprintfromsamplesresult_compressed: (a: number) => [number, number];
|
|
7
7
|
export const __wbg_get_fingerprintfromsamplesresult_raw: (a: number) => [number, number];
|
|
8
|
+
export const __wbg_get_matchfingerprintsresult_segments: (a: number) => [number, number];
|
|
9
|
+
export const __wbg_matchfingerprintsresult_free: (a: number, b: number) => void;
|
|
10
|
+
export const __wbg_matchsegment_free: (a: number, b: number) => void;
|
|
8
11
|
export const __wbg_set_fingerprintfromsamplesresult_compressed: (a: number, b: number, c: number) => void;
|
|
9
12
|
export const __wbg_set_fingerprintfromsamplesresult_raw: (a: number, b: number, c: number) => void;
|
|
13
|
+
export const __wbg_set_matchfingerprintsresult_segments: (a: number, b: number, c: number) => void;
|
|
10
14
|
export const fingerprintFromSamples: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
11
15
|
export const fingerprinter_consume: (a: number, b: number, c: number) => void;
|
|
12
16
|
export const fingerprinter_finish: (a: number) => void;
|
|
@@ -15,11 +19,17 @@ export const fingerprinter_getFingerprint: (a: number) => [number, number];
|
|
|
15
19
|
export const fingerprinter_new: () => [number, number, number];
|
|
16
20
|
export const fingerprinter_start: (a: number, b: number, c: number) => [number, number];
|
|
17
21
|
export const matchFingerprints: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
18
|
-
export const
|
|
19
|
-
export const
|
|
22
|
+
export const matchsegment_duration: (a: number) => number;
|
|
23
|
+
export const matchsegment_end1: (a: number) => number;
|
|
24
|
+
export const matchsegment_end2: (a: number) => number;
|
|
25
|
+
export const matchsegment_score: (a: number) => number;
|
|
26
|
+
export const matchsegment_start1: (a: number) => number;
|
|
27
|
+
export const matchsegment_start2: (a: number) => number;
|
|
20
28
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
21
29
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
22
30
|
export const __externref_table_dealloc: (a: number) => void;
|
|
23
31
|
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
32
|
+
export const __externref_drop_slice: (a: number, b: number) => void;
|
|
24
33
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
34
|
+
export const __externref_table_alloc: () => number;
|
|
25
35
|
export const __wbindgen_start: () => void;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rusty-chromaprint-wasm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "WASM bindings for rusty-chromaprint audio fingerprinting",
|
|
7
7
|
"author": "Janis Jansen <oss@janis.me>",
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"homepage": "https://
|
|
9
|
+
"homepage": "https://rusty-chromaprint-wasm.janis.me",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/janis-me/rusty-chromaprint-wasm.git"
|
|
@@ -21,7 +21,19 @@
|
|
|
21
21
|
"musicbrainz"
|
|
22
22
|
],
|
|
23
23
|
"main": "dist/rusty_chromaprint_wasm.js",
|
|
24
|
+
"module": "dist/rusty_chromaprint_wasm.js",
|
|
24
25
|
"types": "dist/rusty_chromaprint_wasm.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": "./dist/rusty_chromaprint_wasm.js",
|
|
29
|
+
"types": "./dist/rusty_chromaprint_wasm.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./dist/rusty_chromaprint_wasm_bg.js": {
|
|
32
|
+
"import": "./dist/rusty_chromaprint_wasm_bg.js",
|
|
33
|
+
"types": "./dist/rusty_chromaprint_wasm_bg.wasm.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./dist/rusty_chromaprint_wasm_bg.wasm": "./dist/rusty_chromaprint_wasm_bg.wasm"
|
|
36
|
+
},
|
|
25
37
|
"files": [
|
|
26
38
|
"dist/rusty_chromaprint_wasm_bg.js",
|
|
27
39
|
"dist/rusty_chromaprint_wasm_bg.wasm",
|