HydrogenAudio

Hydrogenaudio Forum => General Audio => Topic started by: garfield85 on 2011-10-18 11:41:41

Title: Help needed for comparison of two waveforms of audio files
Post by: garfield85 on 2011-10-18 11:41:41
Hi,
I need help in comparing two audio files. Lets say I have two wave files and one of it is created using the other with some modifications like lowering the loudness etc.

Now, I have to compare these files and see if the modified one is almost copy of the original one, means, while creating the modified one, my application has unknowingly not distorted the file.

A percentage value would be better to signify how much different these files are. I have tried taking FFT of both files and then computing the difference in dB (like, 10 * log10 (ft1/ft2)) and averaging out the result. I get a resultant number but I am not sure what that number signifies.

Actual thing I need to do is:
Lets say I have a wave file and use it as an input to a "software" which decreases ,say volume, and gives output wave file. Now I want to compare these files to confirm that my "software" has not shifted the waveform or distorted it too much. I guess the shape of waveform must be identical, only amplitude would have been affected.
I need to check this only. Please help me out.

Thanks in advance for any kind of help.
Title: Help needed for comparison of two waveforms of audio files
Post by: DVDdoug on 2011-10-18 20:33:38
If you are going to use FFT, you'll have to compare more than one number (i.e. the frequency bands or "bins") and you are going to have to normalize or otherwise compensate for the change in level. i.e. If you reduce the volume by 6dB, all of the frequency components should be reduced by 6dB. If the spectrum distribution is different, you've done more than alter the volume...

I assume there are distortion analyzer algorithms that work with pure test tones. Testing music for distortion... I dunno...

If you are simply reducing (or boosting) the volume, you can re-boost (or reduce) the signal and subtract from the original to get the difference. (If there's a phase/timing shift, it will show-up big-time when you subtract.)

If you are just reducing the volume (multiplying each sample by the same fractional number), I wouldn't worry about distortion.  If you are boosting the volume, there is the potential for clipping (if you are using an integer format), but it's fairly easy to check the numbers before boosting or before converting to integer. As long as you're doing it right and checking for clipping there's nothing to worry about.

Volume change is a simple algorithm, probably the simplest thing you can do.  If something goes wrong, chances it will go very-wrong and you won't need any fancy analysis to notice it!

Now, there are rounding errors when you reduce volume, and the signal-to-noise ratio is reduced if you reduce the signal. But as long as you don't re-boost the volume, the actual/absolute level of noise & distortion is not increased.  (Essentially the same thing happens when you reduce the signal with an analog volume control.)


Quote
I want to compare these files to confirm that my "software" has not shifted the waveform...

Time/phase shifting is a bit more difficult. But again, there is no reason to time-shift when you adjust the volume. (If you are filtering, most filters do introduce phase shift.)