0

I have a program as such

package com.mycompany.audiofile;
import com.musicg.fingerprint.FingerprintManager;
import com.musicg.fingerprint.FingerprintSimilarity;
import com.musicg.fingerprint.FingerprintSimilarityComputer;
import com.musicg.wave.Wave;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import javazoom.jl.converter.Converter;
import javazoom.jl.decoder.JavaLayerException;
public class AudioFile {
    public static void main(String[] args) throws JavaLayerException, FileNotFoundException, IOException {
        new Converter().convert("Kanye West - Hell Of A Life.mp3", "Kanye West - Hell Of A Life.wav");
        byte[] newFingerPrint = new FingerprintManager().extractFingerprint(new Wave ("Kanye West - Hell Of A Life.wav"));
        int chunk = 10000; 
        byte [] firstFingerPrint = Arrays.copyOfRange(newFingerPrint, 0, Math.min(newFingerPrint.length,0 + chunk));
        new FingerprintManager().saveFingerprintAsFile(newFingerPrint, "0.txt");
        for(int i = 0; i < newFingerPrint.length; i +=chunk){
            byte [] secondFingerPrint = (Arrays.copyOfRange(newFingerPrint, i, Math.min(newFingerPrint.length,i + chunk)));
            FingerprintSimilarity fingerprintSimilarity = new FingerprintSimilarityComputer(firstFingerPrint, secondFingerPrint).getFingerprintsSimilarity();
            if(fingerprintSimilarity.getScore() < 0.1) {
                new FingerprintManager().saveFingerprintAsFile(newFingerPrint, String.valueOf(i) + ".txt");
            }
        }                   
    }
}

Basically my idea was to compare chunks of an audio file and if one chunk had a low score compared to the first chunk, it would save that finger print. The reason is because I wanted snippets to compare to as it's quicker, but sometimes songs have multiple parts. Originally, I was going to constantly trim the audio file but musicg was incorrectly giving me a negative length. So instead I'm splitting the fingerprint byte. Now let's say when I find a part that's different, can I convert it back to a WAV file instead of turning the bytes into a text file? I want to hear what part it finds different.

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 15 '22 at 03:55

0 Answers0