Expand description
In-memory fingerprint matching and identification.
This module provides a Matcher trait and one algorithm per
fingerprinter. All matching is purely in memory — there is no
persistence, no serialisation format, no database adapter, and no
on-disk index. Everything operates on in-memory fingerprints and
returns an in-memory MatchResult.
§Architecture
| Matcher | Fingerprint | Strategy |
|---|---|---|
WangMatcher | WangFingerprint | Offset-histogram voter (Shazam-style) |
PanakoMatcher | PanakoFingerprint | 2-D Hough + optional RANSAC (tempo-invariant) |
HaitsmaMatcher | HaitsmaFingerprint | BER sliding + sub-fingerprint LUT |
NeuralMatcher | NeuralFingerprint | Cosine similarity (requires the neural feature) |
§Quick example
extern crate alloc;
use audiofp::classical::{Wang, WangFingerprint};
use audiofp::matching::{WangMatcher, WangMatchConfig, Matcher, MatchResult};
use audiofp::{Fingerprinter, SampleRate};
let samples: alloc::vec::Vec<f32> = alloc::vec![0.0_f32; 8_000 * 4];
let mut wang = Wang::default();
let q = wang.extract(&samples, SampleRate::HZ_8000).unwrap();
let r = q.clone();
let matcher = WangMatcher::new(WangMatchConfig::default());
let m = matcher.match_one(&q, &r);
if m.is_match {
println!("same recording (score {:.2}, offset {} ms)", m.score, m.offset.ms);
}Structs§
- Haitsma
Index - An in-memory inverted index over several Haitsma fingerprints.
- Haitsma
Match Config - Configuration for
HaitsmaMatcher. - Haitsma
Matcher - Offline 1:1 Haitsma matcher (BER minimisation).
- Match
Result - Outcome of matching a query fingerprint against one reference.
- Neural
Match Config - Configuration for
NeuralMatcher. - Neural
Matcher - Offline 1:1 neural matcher (cosine similarity).
- Panako
Index - An in-memory inverted index over several Panako fingerprints.
- Panako
Match Config - Configuration for
PanakoMatcher. - Panako
Matcher - Offline 1:1 Panako matcher (2-D Hough + optional RANSAC).
- Panako
RefIndex - Prebuilt reference index for
PanakoMatcher::match_one_prebuilt. - Time
Offset - Signed time offset of the query relative to the reference.
- Wang
Index - An in-memory inverted index over several Wang fingerprints.
- Wang
Match Config - Configuration for
WangMatcher. - Wang
Matcher - Offline 1:1 Wang matcher (Shazam-style offset-histogram voter).
- Wang
RefIndex - Prebuilt single-reference index for
WangMatcher.
Enums§
- Aggregation
- Aggregation strategy for comparing two embedding sequences.
Constants§
- HAITSMA_
V1_ MID - Haitsma v1 calibration: score (
1 − BER) gap (0.573, 0.888) → mid 0.73, slope 29 maps the edges to ≈0.010/0.990. - HAITSMA_
V1_ SLOPE - See
HAITSMA_V1_MID. - NEURAL_
SLOPE - Neural calibration slope: deliberately conservative (k=20) — there is
no corpus coverage for embeddings, and cosine scales vary by model.
The midpoint is NOT fixed here: it anchors at the matcher’s own
min_cosine, so the decision boundary always maps to exactly 0.5. Refit per deployment; see the recalibration recipe inROBUSTNESS.md. - PANAKO_
V1_ MID - Panako v1 calibration: score gap (0.003, 0.480) at fit time →
mid 0.24, slope 19 maps the edges to ≈0.011/0.989. The corpus
expansion added a weaker positive (acidjazz ogg, 0.394 → ≈0.949);
the map is unchanged — see
ROBUSTNESS.md“Calibrated confidence”. - PANAKO_
V1_ SLOPE - See
PANAKO_V1_MID. - WANG_
V1_ MID - Wang v1 calibration: score gap (0.001, 0.405) on the corpus → mid 0.20, slope 22 maps the edges to ≈0.011/0.989.
- WANG_
V1_ SLOPE - See
WANG_V1_MID.
Traits§
- Matcher
- One matcher per fingerprinting algorithm.
Functions§
- calibrated_
haitsma - Estimated P(same recording | Haitsma evidence): logistic map of the
1 − BERscore. Versionedhaitsma-v1; see module docs. - calibrated_
neural - Estimated P(same recording | neural evidence): logistic map of the
cosine score anchored at
min_cosine(the matcher’s own decision boundary → exactly 0.5). Provisional slope (NEURAL_SLOPE): no corpus coverage, model-dependent — refit per deployment. - calibrated_
panako - Estimated P(same recording | Panako evidence): logistic map of the
RANSAC-inlier-ratio score. Versioned
panako-v1; see module docs. - calibrated_
wang - Estimated P(same recording | Wang evidence): logistic map of the
contrib-ratio score. Versioned
wang-v1; see module docs. - clamp_
score - Clamp a score into
[0.0, 1.0]. - compute_
prominence - Compute prominence:
peak / (mean_of_rest + 1.0). - match_
best - Find the single best-matching reference.
- match_
ranked - Score every reference and return all results sorted by descending score (ties broken by descending prominence).
- match_
result_ compare_ desc - Compare two
MatchResults in descending order of quality. - par_
match_ best - Rayon-parallel
match_best(requires therayonfeature, audit C5). - par_
match_ ranked - Rayon-parallel
match_ranked(requires therayonfeature, audit C5). - score_
compare - Compare two
f32scores safely (NaN-proof).