Comparing sound files if not completely identical
Asked Answered
A

4

28

Is there any way to programatically compare two sound files to determine if they are identical, or nearly identical? These are not mp3 files and do not have any ID3 or other meta data, but plain wav files. Comparing the checksum values may not work as they may not be completely identical.

Alga answered 22/1, 2009 at 22:48 Comment(0)
P
14

The wikipedia article on acoustic fingerprinting mentions a number of products, including the opensource libfooid. Basically you're looking at going into the frequency domain, taking rough levels over a relatively small number of bands (say 32), to give you a string that represents something like 25ms of sound, doing that for the whole file, then doing a fuzzing comparison of those strings for different files. It's fairly complex, but needs doing - comparing the actual samples won't get you anywhere as something as simple as a volume shift by a few percent will throw out the whole match.

Pledget answered 22/1, 2009 at 23:1 Comment(1)
Good link. OQ seemed to suggest that the files could be identical or nearly so, which indicated that sample-by-sample comparison could work.Anaemic
M
10

The process for comparing a set of sounds for similarities is called Content Based Audio Indexing, Retrieval, and Fingerprinting in computer science research.

One method of doing this is to:

1) Run several bits of signal processing on each audio file to extract features, such as pitch over time, frequency spectrum, autocorrelation, dynamic range, transients, etc.

2) Put all the features for each audio file into a multi-dimensional array and dump each multi-dimensional array into a database

3) Use optimization techniques (such as gradient descent) to find the best match for a given audio file in your database of multi-dimensional data.

The trick to making this work well is which features

There are several projects that do stuff like this, including MusicBrainz, and EchoNest.

Echonest has one of the simplest APIs I've seen in this space. Very easy to get started.

P.S. No I do not work for Echonest, nor do I know anyone who works there.

Monoculture answered 23/1, 2009 at 13:13 Comment(0)
P
2

One thing that you could try that would give you a fairly decent fingerprint of the file is taking a Fourier transform and looking at the distribution of different frequencies present in the file. It's still very possible to make two very different sound files that have the same Fourier transform, but that's somewhat unlikely if your files are coming from a non-contrived source...

Plumbaginaceous answered 22/1, 2009 at 22:58 Comment(1)
So to compare files I find correlation between 2 ffts? (assuming that this will give me not so accurate results)Waverly
A
0

You could compare the two WAV files sample-by-sample, and calculate an average per-sample difference. To speed things up, you could use the same method but compare every 10th sample, or every 100th sample and come up with essentially the same value (two files that aren't the same or even close will have a huge per-sample average difference).

Anaemic answered 22/1, 2009 at 22:53 Comment(3)
this doesn't work if one file has 1 second of silence added to the front of it, but are otherwise identical.Plumbaginaceous
You need to do add pattern recognition then, and try to align them temporally before you check the samplesHeise
I agree with both points, but that takes this problem from the realm of the simple to the realm of the hideously complex.Anaemic

© 2022 - 2024 — McMap. All rights reserved.