MCPcopy Index your code
hub / github.com/darksv/rusty-chromaprint

github.com/darksv/rusty-chromaprint @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
220 symbols 474 edges 22 files 35 documented · 16%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

rusty-chromaprint

This is an in-progress port of chromaprint:

Chromaprint is an audio fingerprint library developed for the AcoustID project. It's designed to identify near-identical audio and the fingerprints it generates are as compact as possible to achieve that. It's not a general purpose audio fingerprinting solution. It trades precision and robustness for search performance. The target use cases are full audio file identification, duplicate audio file detection and long audio stream monitoring.

Usage

To calculate a fingerprint for an audio stream simply create a new Fingerprinter and give it all the audio samples:

use rusty_chromaprint::{Configuration, Fingerprinter};

fn main() {
    // Use a preset configuration. This must be always the same for the audio fingerprints 
    // that are going to be compared against each other.
    let mut printer = Fingerprinter::new(&Configuration::preset_test2());

    // Sampling rate is set to 44100 and stream has 2 audio channels. It is expected that samples 
    // are interleaved: in this case left channel samples are placed at even indices 
    // and right channel - at odd ones.
    printer.start(44100, 2).unwrap();

    // Process a few samples...
    printer.consume(&[-100, -100, -50, -50, 1000, 1000]);
    // ... and add some more...
    printer.consume(&more_samples);

    // Make sure that all the sample are processed.
    printer.finish();

    // Get the fingerprint.
    let fingerprint = printer.fingerprint();

    println!("fingerprint = {:08x?}", &fingerprint);
}

For a complete example check out compare from this repository which is using Symphonia to decode various audio formats. It compares two files and prints out their common segments

cargo run --release --bin compare -- audio1.mp3 audio2.wav
  #  |          File 1          |          File 2          |  Duration  |  Score  
-----+--------------------------+--------------------------+------------+---------
   1 | 0:00:04.83 -- 0:00:19.44 | 0:00:00.00 -- 0:00:14.61 | 0:00:14.61 |   0.69

For more details on comparing audio fingerprints reach out to the documentation.

Extension points exported contracts — how you extend this code

Stage (Interface)
(no doc) [12 implementers]
chromaprint/src/stages.rs
DurationExt (Interface)
(no doc) [1 implementers]
compare/src/utils.rs
FeatureVectorConsumer (Interface)
(no doc) [8 implementers]
chromaprint/src/stages.rs
AudioConsumer (Interface)
(no doc) [4 implementers]
chromaprint/src/stages.rs
IntoBitIterator (Interface)
Turns an object (e.g. an `u32`) over an iterator of bits. [1 implementers]
chromaprint/src/compression.rs
Image (Interface)
(no doc) [1 implementers]
chromaprint/src/filter.rs

Core symbols most depended-on inside this repo

push
called by 23
chromaprint/src/gaussian.rs
area
called by 15
chromaprint/src/rolling_image.rs
move_forward
called by 11
chromaprint/src/gaussian.rs
consume
called by 10
chromaprint/src/chroma_filter.rs
add_row
called by 8
chromaprint/src/rolling_image.rs
filter0
called by 7
chromaprint/src/filter.rs
read_s16le
called by 7
chromaprint/src/utils.rs
box_filter
called by 7
chromaprint/src/gaussian.rs

Shape

Method 106
Function 79
Class 25
Interface 6
Enum 4

Languages

Rust100%

Modules by API surface

chromaprint/src/fingerprinter.rs25 symbols
chromaprint/src/filter.rs23 symbols
chromaprint/src/audio_processor.rs19 symbols
chromaprint/src/gaussian.rs17 symbols
chromaprint/src/chroma.rs16 symbols
fpcalc/src/main.rs15 symbols
chromaprint/src/compression.rs15 symbols
chromaprint/src/fingerprint_matcher.rs12 symbols
chromaprint/src/rolling_image.rs11 symbols
chromaprint/src/chroma_filter.rs11 symbols
chromaprint/src/fft.rs10 symbols
chromaprint/src/chroma_normalizer.rs9 symbols

For agents

$ claude mcp add rusty-chromaprint \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact