Wav comparison, same file

I'm at a dead end right now . I searched and experimented with audio comparison. I found a lot of material and a ton of links to different libraries and methods for this.

At the moment, I took Audacity and exported a 3-minute wav file called "long.wav", and then split the first 30 seconds of this into a file called "short.wav". I decided that somewhere along the line I could visually log (log.txt) the data through java for each and should be able to see at least some visual similarity between the values ​​.... here is some code

The main method:

        int totalFramesRead = 0;
        File fileIn = new File(filePath);
        BufferedWriter writer = new BufferedWriter(new FileWriter(outPath));
        writer.flush();
        writer.write("");
        try {
            AudioInputStream audioInputStream = 
                    AudioSystem.getAudioInputStream(fileIn);
            int bytesPerFrame = 
                    audioInputStream.getFormat().getFrameSize();
            if (bytesPerFrame == AudioSystem.NOT_SPECIFIED) {
                // some audio formats may have unspecified frame size
                // in that case we may read any amount of bytes
                bytesPerFrame = 1;
            } 
            // Set an arbitrary buffer size of 1024 frames.
            int numBytes = 1024 * bytesPerFrame; 
            byte[] audioBytes = new byte[numBytes];
            try {
                int numBytesRead = 0;
                int numFramesRead = 0;
                // Try to read numBytes bytes from the file.
                while ((numBytesRead = 
                        audioInputStream.read(audioBytes)) != -1) {
                    // Calculate the number of frames actually read.
                    numFramesRead = numBytesRead / bytesPerFrame;
                    totalFramesRead += numFramesRead;
                    // Here, do something useful with the audio data that 
                    // now in the audioBytes array...

                    if(totalFramesRead <= 4096 * 100)
                    {                           

                    Complex[][] results = PerformFFT(audioBytes);
                    int[][] lines = GetKeyPoints(results);
                    DumpToFile(lines, writer);      

                    }   
                }
            } catch (Exception ex) { 
                // Handle the error...
            }
            audioInputStream.close();
        } catch (Exception e) {
            // Handle the error...
        }
        writer.close();

Then PerformFFT :

public static Complex[][] PerformFFT(byte[] data) throws IOException
    {
        final int totalSize = data.length;

        int amountPossible = totalSize/Harvester.CHUNK_SIZE;

        //When turning into frequency domain we'll need complex numbers:
        Complex[][] results = new Complex[amountPossible][];

        //For all the chunks:
        for(int times = 0;times < amountPossible; times++) {
            Complex[] complex = new Complex[Harvester.CHUNK_SIZE];
            for(int i = 0;i < Harvester.CHUNK_SIZE;i++) {
                //Put the time domain data into a complex number with imaginary part as 0:
                complex[i] = new Complex(data[(times*Harvester.CHUNK_SIZE)+i], 0);
            }
            //Perform FFT analysis on the chunk:
            results[times] = FFT.fft(complex);
        }
            return results;
}

: audioBytes , FFT.

: , , log.txt wav . . , small.wav large.wav( ), wav byte [], Complex [] [] fft... - ..

, .

, , ! , , !

+5
5

MARF? Java, .

( ), . , , FeatureExtraction, .

+2

16- 3e-05 . , (, ).

: , , Java, , , ( ).

+1

, matlab . Matlab .

"wavread" "stft", , . abs (), . imshow (abs (), []).

, 30- ( ?)

0

, , , - , (, TrackId MotoID), , (10-20 ), , , , , ( ) ( ), , , , , , , , .

0
source

I think you are looking at Acoustic Fingerprint. It's complicated, and there are libraries to do this. If you want to implement it yourself, this is a technical document on the Shazam algorithm.

0
source

All Articles