Spectrum plugin shows magnitudes that are way too small
Submitted by r.f..@..nik.de
Created attachment 359057
Source code to reproduce the issue
The spectrum plugin shows extremely inaccurate values for the magnitudes of the audio.
I have created an example application (file attached) which is a modified copy of the spectrum example from https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good/html/gst-plugins-good-plugins-spectrum.html
The changes I've made:
- Exchange the fakesink for a filesink and export a wavefile
- Only show bands which have a magnitude > threshold / 2
- Set spectrum bands to 1024, audio frequency to 48000
- Globally defined threshold
The messages I receive look consistently like this:
New spectrum message, endtime 0:01:20.800000000
band 255 (freq 5988.28): magnitude -17.337473 dB phase 0.785320
band 256 (freq 6011.72): magnitude -13.766866 dB phase -2.356143
band 257 (freq 6035.16): magnitude -25.419439 dB phase 0.785200
One can see that the max. magnitude is -13.8 dB @ 6012 Hz.
Now importing the wave file into Audacity and using its spectrum visualizer, one can see that the magnitude of the wave file is actually about -0.6 dB @ 6033 Hz.
So the dominant frequency is fairly accurate, but the max. magnitude by far is not. Since the spectrum plugin does its job in real time and the Audacity feature does not, I don't expect the same result, but the difference is too large nonetheless.
Attachment 359057, "Source code to reproduce the issue":