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?
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).
This actually explains a lot, thank you! I didn’t realize Audacity did these conversions.
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!