Dart FFI bindings for Chromaprint, the audio fingerprinting library used by AcoustID.
Generates compact fingerprints from raw PCM audio data that can be used to identify recordings via the AcoustID database.
| Platform | Status |
|---|---|
| Android | Yes |
| Linux | Yes |
| iOS | Planned |
| macOS | Planned |
| Windows | Planned |
import 'package:chromaprint/chromaprint.dart';
void main() {
final cp = Chromaprint();
cp.start(44100, 1); // 44.1 kHz, mono
// Feed raw PCM samples (16-bit signed integers, native byte order).
// For stereo, channels are interleaved (L, R, L, R, ...).
cp.feed(audioData);
cp.finish();
// Compressed fingerprint (base64, ready for AcoustID)
final fingerprint = cp.getFingerprint();
// 32-bit hash for quick comparison
final hash = cp.getFingerprintHash();
cp.dispose();
}// Get raw fingerprint data
final raw = cp.getRawFingerprint();
// Encode to a compressed base64 string
final encoded = encodeFingerprint(raw, ChromaprintAlgorithm.defaultAlgorithm);
// Decode back to raw data
final decoded = decodeFingerprint(encoded);
print(decoded.algorithm); // ChromaprintAlgorithm.test2
print(decoded.rawFingerprint); // List<int>
// Compute a 32-bit hash of raw fingerprint data
final hash = hashFingerprint(raw);final version = getVersion(); // e.g. "1.6.0"High-level wrapper around the Chromaprint C library.
| Method / Property | Description |
|---|---|
Chromaprint({algorithm}) |
Create a new fingerprinter instance. |
algorithm |
The algorithm used by this instance. |
sampleRate |
Configured sample rate (after start). |
numChannels |
Configured channel count (after start). |
setOption(name, value) |
Set an option (e.g. "silence_threshold"). Must be called before start. |
start(sampleRate, numChannels) |
Begin the fingerprinting process. |
feed(data) |
Feed 16-bit signed integer PCM samples. |
feedRaw(ptr, size) |
Feed samples from a native pointer. |
finish() |
Complete the fingerprinting process. |
getFingerprint() |
Get the compressed base64 fingerprint string. |
getRawFingerprint() |
Get the raw fingerprint as List<int>. |
getRawFingerprintSize() |
Number of elements in the raw fingerprint. |
getFingerprintHash() |
32-bit hash of the fingerprint. |
clearFingerprint() |
Clear fingerprint data to reuse the instance. |
dispose() |
Release native resources. |
| Function | Description |
|---|---|
getVersion() |
Returns the chromaprint library version string. |
encodeFingerprint(raw, algorithm, {base64}) |
Encode raw fingerprint data to compressed format. |
decodeFingerprint(encoded, {base64}) |
Decode a compressed fingerprint to raw data. |
hashFingerprint(raw) |
Compute a 32-bit hash of raw fingerprint data. |
| Value | Description |
|---|---|
test1 |
Algorithm test variant 1 |
test2 |
Default. Recommended for general use. |
test3 |
Algorithm test variant 3 |
test4 |
Algorithm test variant 4 |
test5 |
Algorithm test variant 5 |
- Flutter SDK >= 3.3.0
- Dart SDK >= 3.11.4
- CMake >= 3.10
- A C/C++ toolchain for your target platform
git clone --recurse-submodules <repo-url>If you already cloned without --recurse-submodules:
git submodule init
git submodule updatecd example
flutter runThe example app generates a fingerprint from a synthetic 440 Hz sine wave and displays the result.
The low-level bindings in lib/chromaprint_bindings_generated.dart are generated by package:ffigen. You need chromaprint.h installed on your system (e.g. libchromaprint-dev on Debian/Ubuntu, chromaprint on Arch Linux).
dart run ffigen --config ffigen.yamlThe native library is compiled directly from the Chromaprint source in the chromaprint/ git submodule. The build is configured in src/CMakeLists.txt and uses:
- KissFFT (bundled with Chromaprint) for FFT computation
- Internal avresample for audio resampling
- No external dependencies beyond the C/C++ standard library and
libm
The src/config.h header provides build configuration (version, FFT backend, etc.) that replaces the autoconf-generated header from the upstream Chromaprint build system.