4 releases

0.2.0 Feb 2, 2024
0.1.3 Mar 12, 2023
0.1.2 Mar 4, 2023
0.1.1 Jul 23, 2022
0.1.0 Jul 23, 2022

#85 in Audio

Download history 376/week @ 2024-01-05 568/week @ 2024-01-12 479/week @ 2024-01-19 373/week @ 2024-01-26 519/week @ 2024-02-02 715/week @ 2024-02-09 1662/week @ 2024-02-16 1362/week @ 2024-02-23 629/week @ 2024-03-01 489/week @ 2024-03-08 614/week @ 2024-03-15 628/week @ 2024-03-22 594/week @ 2024-03-29 375/week @ 2024-04-05 377/week @ 2024-04-12 362/week @ 2024-04-19

1,770 downloads per month
Used in 4 crates (via czkawka_core)

MIT license

490KB
2K SLoC

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.

Dependencies

~3.5MB
~63K SLoC