1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! `audiofp` — audio fingerprinting SDK for Rust.
//!
//! `audiofp` extracts compact, codec-tolerant perceptual hashes from audio
//! so you can identify the same recording across re-encoding, modest
//! noise, and (for some algorithms) tempo or pitch changes — the
//! fundamental primitive behind systems like Shazam or AcoustID.
//!
//! The crate compiles **`no_std + alloc`** by default (when the `std`
//! feature is disabled), so the DSP primitives and classical
//! fingerprinters can target embedded systems such as
//! `thumbv7em-none-eabihf`. The file decoder ([`io`]) and watermark
//! detector ([`watermark`]) live behind feature flags and require `std`.
//!
//! # Quick tour
//!
//! - **Errors** — [`AfpError`] (`#[non_exhaustive]`) plus the
//! [`Result`] alias.
//! - **Value types** — [`SampleRate`] (newtype around `NonZeroU32` with
//! `HZ_*` constants), [`AudioBuffer`] (borrowed mono PCM view), and
//! [`TimestampMs`] (ordered millisecond timestamp).
//! - **Traits** — [`Fingerprinter`] for whole-buffer extraction,
//! [`StreamingFingerprinter`] for incremental extraction. Every
//! algorithm in the crate implements both.
//! - **Classical fingerprinters** — [`classical::Wang`] (Shazam-style
//! landmark pairs), [`classical::Panako`] (tempo-invariant triplets),
//! [`classical::Haitsma`] (Philips robust hash bands), each with a
//! streaming sibling.
//! - **DSP primitives** — [`dsp`] exposes STFT, mel filterbank, peak
//! picker, resampler, and tapered windows for users building their
//! own pipelines on top of `audiofp`.
//!
//! # Example
//!
//! Identify a song by counting Wang hash collisions between two files:
//!
//! ```no_run
//! use audiofp::classical::Wang;
//! use audiofp::io::decode_to_mono_at;
//! use audiofp::{AudioBuffer, Fingerprinter, SampleRate};
//! use std::collections::HashSet;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let samples = decode_to_mono_at("song.flac", 8_000)?;
//! let mut wang = Wang::default();
//! let buf = AudioBuffer { samples: &samples, rate: SampleRate::HZ_8000 };
//! let fp = wang.extract(buf)?;
//!
//! let unique: HashSet<u32> = fp.hashes.into_iter().map(|h| h.hash).collect();
//! println!("{} unique landmark hashes", unique.len());
//! # Ok(()) }
//! ```
//!
//! # Cargo features
//!
//! | Feature | Default | Description |
//! | ------------ | :-----: | ----------------------------------------------------------------- |
//! | `std` | ✅ | Pulls in [`symphonia`](https://docs.rs/symphonia) → [`io`]. |
//! | `watermark` | | Pulls in [`tract-onnx`](https://docs.rs/tract-onnx) → [`watermark`]. |
//! | `neural` | | Reserved for the upcoming neural fingerprinter. |
//! | `mimalloc` | | Installs `mimalloc::MiMalloc` as the process-wide allocator. |
//!
//! See [`USAGE.md`](https://github.com/themankindproject/audiofp/blob/main/USAGE.md)
//! for the complete API guide.
extern crate alloc;
static GLOBAL: MiMalloc = MiMalloc;
pub use ;
pub use ;
pub use ;
/// Crate version string, sourced from `Cargo.toml`.
///
/// Useful when persisting fingerprints alongside the producer version,
/// or when emitting diagnostics that need to identify the SDK build.
///
/// # Example
///
/// ```
/// assert!(!audiofp::VERSION.is_empty());
/// ```
pub const VERSION: &str = env!;