rusty-chromaprint-wasm
v0.1.4
Published
WASM bindings for rusty-chromaprint audio fingerprinting
Maintainers
Readme
chromaprint-wasm
WASM bindings for rusty-chromaprint. Uses preset test2 (AcoustID/fpcalc compatible).
Build
# Install wasm-pack if needed: cargo install wasm-pack
wasm-pack build --target web
# Or for Node: wasm-pack build --target nodejsOutput in pkg/: .wasm, .js glue, and (with wasm-pack) TypeScript definitions.
API (from JS)
new Fingerprinter()– create a fingerprinter.start(sampleRate, channels)– e.g.44100,1or2.consume(samples)–samplesis anInt16Array(interleaved if stereo).finish()– call when all samples have been fed.getFingerprint()– returnsUint32Array(raw).getCompressedFingerprint()– returns base64 string (AcoustID format)fingerprintFromSamples(sampleRate, channels, samples)– one-shot; returns{ raw: Uint32Array, compressed: string }matchFingerprints(raw1, raw2)– bothUint32Array; returns array of{ start1, end1, start2, end2, duration, score }(times in seconds)
Audio input
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.
