1
$\begingroup$

I'm trying to convert musicg Spectrogram output to dBFS.

With 16-bit signed integer PCM audio, and an FFT length of 2048, I'm trying to analyze the spectrogram for an audio file to determine things like "Was a particular frequency notched out by equalization" or "Was the audio high-passed or low-passed" by looking for peaks in the spectrogram.

I'm taking a normalized musicg spectrogram, and converting the magnitude values to dBFS (max value: 0 dBFS) by doing:

dBFS = (20 * Math.log10( 2 * Math.abs(magnitude) / 2048)) - 100

I think this is giving me what I'm looking for, and it correlates closely to what I'm seeing in other tools. And if I decrease the gain on a file by 20db, and then analyze the decreased file, the dBFS data I get back is 20db less than the original.

However, I noticed that when I view the spectrogram in Audacity (using plot spectrum), the dB values in Audacity seem to range between 4db and 9db higher than what I'm getting from musicg and the above equation.

Is there something I'm doing particularly wrong in the way I'm trying to calculate dBFS from the musicg absolute spectrogram data? (or perhaps I'm mistaken and what I'm calculating, and what Audacity is displaying, are not quite the same thing)

$\endgroup$
  • $\begingroup$ Where does the -100 come from ? I expect it should be -96 (full scale for 16 bit audio) ? $\endgroup$ – Paul R Feb 4 '15 at 8:20
  • $\begingroup$ You know there is a HUGE difference between spectrogram and spectrum? $\endgroup$ – jojek Feb 4 '15 at 11:43
  • $\begingroup$ The -100 came from thinking that since the db scale max is 100, I should subtract 100 to put the values with 0 as the highest possible value. But since the full scale max for 16 bit audio is 96db, that makes sense to subtract 96, instead of 100. $\endgroup$ – mitch_moop Feb 4 '15 at 14:45
  • $\begingroup$ jojek, thanks for reminding me of the different between a spectrogram and a spectrum. I expected to find peaks in the spectrogram data equal to the peaks in the spectrum - I guess I did find that, +/- 5dBFS (using -96). $\endgroup$ – mitch_moop Feb 4 '15 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.