I want to calculate the loudness of a given sound over time (like, in a graph) from its spectrogram. Can I do this from the spectrogram or is it better to do from the raw sound?


1 Answer 1


Yes, in fact it's not a bad idea at all to use some kind of spectrogram representation to calculate a loudness envelope. Depending on what exactly you need you can either just sum the spectral magnitude over all frequencies at a given time, or first apply some kind of perception based weighting functions to make your loudness measure more related to actual auditory perception.

So if you give some more detail about the application you have in mind you will likely receive a more accurate answer.

  • $\begingroup$ I try to compare results of aggression detection between spectrograms and cochleograms (link), loudness just being one of many features to test with. But I'm not really sure what I'm measuring when I sum the spectral magnitude (I get values far below 0, at least for cochleograms). I could also sum the peaks in the spectrum, or just use the value of the highest peak, or the value of the fundamental frequency. I really don't know how to choose. Just thinking out loud, maybe I shouldn't choose but just test what feature(s) work(s) best. $\endgroup$
    – Lewistrick
    Jun 25, 2014 at 20:43
  • 1
    $\begingroup$ If you get negative values you're summing up the logarithms of the magnitudes. Instead, just sum the magnitudes (which are non-negative) or the squared magnitudes and convert to dB after summing. $\endgroup$
    – Jazzmaniac
    Jun 25, 2014 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.