# Comparing two spectrograms

I'm a total beginner at comparing spectrograms, is there any way to compare differences between two spectrograms or two mp3 files? I've seen people subtract two spectrograms to show only the difference and tried using photoshop. Any help or tips would be useful thanks!

• What information are you hoping to glean from your comparison? Visually, they look like the same track with different levels of compression. – Tetsujin Aug 8 '17 at 9:40
• Wonder what happened at 12kHz... – Linuxios Aug 8 '17 at 15:51
• @Tetsujin I was wondering if this compression you speak of impacts audio quality, It seems to me that the second spectrogram just seems louder – Vordan Aug 9 '17 at 5:12
• In very very broad terms, more compressed == louder, yes. – Tetsujin Aug 9 '17 at 19:10
• @Vordan A quick explanation of compression : for every decibel of volume (power, whatever) that passes the threshold ( commonly something you set), the device only allows a ratio (also set) through. As an example, if you have a threshold of -12dB and a ratio of 8 to 1, then for every 8 decibels above -12dB, it will only allow 1 decibel through (attenuate 7 decibels). You would usually then raise the volume (makeup gain) of the whole thing. There's a lot more to it, but that should help you conceptualize it. Hope that helps! – user22688 Aug 14 '17 at 18:02

I've been looking at this for a couple of days and it just came to me. You could subtract the two waveforms and get the spectrogram of the difference. In theory it should be the same as what you asked for.

To do this you need to invert one of the tracks and mix(add) them in equal volume. If you did that with a single waveform and its inverse you should get silence at the out because as one wave rises, the other falls at the same rate and they cancel each other out. If the two tracks as slightly different, most parts will cancel out and only their difference will remain. So if you calculate the spectrogram of the result, you should get the result you're after. After all, the spectrogram and the waveform are two different interpretations of the same information and this allows you to do the subtraction at one form and convert to the other.

• I'm not what happened by after aligning, normalizing, inverting one of the tracks and mixing, the result spectrogram doesn't seem to be the expected result. imgur.com/a/DVKeC – Vordan Aug 14 '17 at 6:02
• I was was expecting a somewhat different result myself. You similar are the two tracks to the ear? Would you mind trying this with a known test signal? Say, 1 second of square wave @ 1k. Inverted and added, you should get silence and a black spectrogram. With some eq on only one track, you should just see/hear the effect of the eq. If the 2 tracks are very different, then the result will have a lot more content. I suspect that this is what's happened to your example. The peaks at the top could be the mp3 aliasing but I can't tell without any idea of what the content is. – Schizomorph Aug 14 '17 at 7:13

The easiest way (for beginners) to gauge differences is not look at sonograms of the whole file but at momentary curves. these are more easy to read for comparison, and usually you get them with a logarithmic frequency scale (which helps)

if you want to calculate the difference from the full sonograms you CAN do that with an image editor, but it gets much easier if you use a monochrome color scheme for your sonogram.

Sonograms Are very helpful though, e.g. to spot antialiasing or that 12k Notchfilter. But their main benefit to me seems to be the way you can see time-varying audio features instantly (e.g. trajectories of filters). Always look out for your domain scalings as well (i.e. log freq vs lin freq, log level vs lin level). Have a look at some of the available meters.. there is a whole variety out there.

If you want to actually do analysis in the frequency domain, there are special software bundles out there, e.g. Matlab or SciPy/NumPy.