Diffing audio - help me figure out what's going on?

Audio software developers forum.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
10098
Posts: 2
Joined: Sat Mar 14, 2015 7:22 pm
Operating System: Please select

Diffing audio - help me figure out what's going on?

Post by 10098 » Sat Mar 14, 2015 7:38 pm

I have one audio file, in "raw" signed 16-bit PCM format.

I also have a program that outputs raw signed 16-bit PCM data. I want to compare the output of the program to the content of the first file.

The files are different if we simply look at raw bytes (checked with Beyond Compare).

When I import the two tracks into Audacity, the waveforms appear the same. I can't hear any difference when playing them. I tried to use Audacity to compute the difference. To do that, I inverted one of the tracks and then mixed the two tracks together and rendered it into a separate track. It produced a flat line, which probably means that the inverted track and the other track cancel each other out, and therefore, the tracks are equivalent. However, when I exported the "silence" to a raw file and opened it in a hex editor I was surprised to see that it contained bytes with different values (I would expect all the bytes to have the same value, since the "diff" track appeared to be completely silent).

Can someone explain to me what's going on here? Why do two different PCM chunks produce results that are indistinguishable? Is comparing raw bytes even a valid approach for testing the "equivalence" of sound data? And what should I do if I want to compare two raw PCM streams programmatically, without Audacity?

kozikowski
Forum Staff
Posts: 41541
Joined: Thu Aug 02, 2007 5:57 pm
Operating System: OS X 10.9 Mavericks

Re: Diffing audio - help me figure out what's going on?

Post by kozikowski » Sun Mar 15, 2015 12:14 am

Audacity is not a scientific tool. It's a sound editor and manager. For one thing, Audacity doesn't edit 16-bit sound. It converts the show to 32-floating so to avoid accidental damage and distortion from filters and effects. After Audacity gets done, it has to convert back to 16-bit and when it does, it adds a tiny dithering signal to keep data conversion errors from becoming objectionable.

That pretty much kills scientists right there.

So that's where your bit-level accuracy went.

Unless you changed it, the blue waves only show activity down to about -30 dB or so. You can change the sound meters to measure accurately down to the limits of 16-bit audio, 96dB.

Audacity > Edit > Preferences > Interface > Meter.
Then make the meters bigger (attached).

Koz
Attachments
LiveRecordingLevels-650.jpg
LiveRecordingLevels-650.jpg (90.53 KiB) Viewed 1423 times

steve
Site Admin
Posts: 49022
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Diffing audio - help me figure out what's going on?

Post by steve » Sun Mar 15, 2015 12:27 am

10098 wrote:To do that, I inverted one of the tracks and then mixed the two tracks together and rendered it into a separate track. It produced a flat line, which probably means that the inverted track and the other track cancel each other out, and therefore, the tracks are equivalent.
If the result is "absolute" silence, the Amplify effect will show "New peak amplitude (dB): -infinity"
10098 wrote:when I exported the "silence" to a raw file and opened it in a hex editor I was surprised to see that it contained bytes with different values (I would expect all the bytes to have the same value, since the "diff" track appeared to be completely silent).
Two possibilities.
1) Although it appeared to be silent, did you check if it was "absolute" silence?
2) If you exported as 16 or 24 bit PCM, then the exported file will not be exactly identical to the 32 bit float data in Audacity. To export exactly the same data, export as 32 bit float PCM.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

10098
Posts: 2
Joined: Sat Mar 14, 2015 7:22 pm
Operating System: Please select

Re: Diffing audio - help me figure out what's going on?

Post by 10098 » Sun Mar 15, 2015 12:46 am

kozikowski wrote: It converts the show to 32-floating so to avoid accidental damage and distortion from filters and effects. After Audacity gets done, it has to convert back to 16-bit and when it does, it adds a tiny dithering signal to keep data conversion errors from becoming objectionable.
This actually explains a lot, thank you! I didn't realize Audacity did these conversions.
steve wrote: Although it appeared to be silent, did you check if it was "absolute" silence?
I just did what you suggested (attempted amplify on the "silent" track) and the new peak amplitude, in fact, was -21.2 dB. When I amplified it, it turned out to be just some noise, which explains the byte values in the "silent" file.

Thanks for the help, now I have a clear picture of what is actually happening!

Post Reply