Skip to content

About

A pure-Rust 🦀 port of Chromaprint, the audio fingerprinting library used by AcoustID.

Topics

Resources

Stars

10 stars

Watchers

0 watching

Forks

Repository files navigation

chromaprint-next

A pure-Rust, drop-in replacement for Chromaprint, the audio fingerprinting library used by AcoustID.

Produces bit-identical fingerprints to the C reference implementation across all five algorithm variants, verified by running both implementations side-by-side on identical inputs and asserting equality of raw fingerprints, encoded strings, and hashes.

About 2x faster than C — chromaprint-next fingerprints 120 s of audio in 9.0 ms against the C reference library's (v1.6.2) 17.4 ms (589 vs 304 Melem/s), and short clips up to 4x faster, even though the C version uses Apple's hardware-optimised Accelerate/vDSP for FFT. This comes from SIMD kernels in the resampler, FFT post-processing and windowing, batched resampler outputs, shared filter banks, and register accumulation in chroma extraction, each verified bit-exact against the code it replaced. See benchmarks for details.

Audio length C reference chromaprint-next rusty-chromaprint
2 sec 1.34 ms 0.32 ms (4.1x faster) 1.33 ms
10 sec 2.23 ms 0.77 ms (2.9x faster) 3.25 ms
30 sec 4.90 ms 2.29 ms (2.1x faster) 9.75 ms
60 sec 9.24 ms 4.51 ms (2.0x faster) 19.85 ms
120 sec 17.38 ms 8.98 ms (1.9x faster) 38.68 ms

Test2 algorithm, 44.1 kHz mono, single thread, Apple M1 Max, C reference v1.6.2.

Repository structure

chromaprint/              C reference implementation (git submodule)
chromaprint-next/         Rust library crate
chromaprint-test-suite/   Cross-implementation comparison tests
chromaprint-benchmarks/   Criterion benchmarks comparing all three implementations
rusty-chromaprint/        Alternative Rust port by darksv (git submodule)

Why another Rust port?

rusty-chromaprint is an existing pure-Rust port that works well for the default algorithm. However, it uses a different resampler, doesn't reproduce certain C bugs needed for database compatibility, and has incomplete presets for 3 of the 5 algorithm variants. chromaprint-next aims for strict bit-identical output across all configurations. See the detailed comparison.

Getting started

git clone --recursive <repo-url>
cargo build -p chromaprint-next

Running tests

The test suite compares both Rust implementations (chromaprint-next and rusty-chromaprint) against the C reference library, which is built automatically via CMake. It feeds identical PCM audio through all three implementations and asserts equality of raw fingerprints, compressed encodings, and hashes.

cargo test -p chromaprint-test-suite

Some rusty-chromaprint tests are #[ignore]d due to known incompatibilities (resampler differences, incomplete presets). To run them:

cargo test -p chromaprint-test-suite -- --ignored

Benchmarks

The chromaprint-benchmarks crate compares throughput of all three implementations using the Test2 (default) algorithm at various audio durations, and benchmarks chromaprint-next's pipeline stages, per-stream setup and SIMD kernels.

cargo bench -p chromaprint-benchmarks

For a per-stage time breakdown of a real stream, enable the opt-in profiling feature:

cargo run --release -p chromaprint-next --features profiling --example profile_stages

See chromaprint-next/docs/benchmarks.md for results and analysis.

Documentation

License

Most of this project is licensed under the MIT License. The resampler module (chromaprint-next/src/audio/resample.rs) is a port of FFmpeg's av_resample and is licensed under LGPL-2.1-or-later.

The combined work is therefore licensed as MIT AND LGPL-2.1-or-later.

About

A pure-Rust 🦀 port of Chromaprint, the audio fingerprinting library used by AcoustID.

Topics

Resources

Stars

10 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages