Spectral centroid for audio signals and auditory spectrograms

The spectral centroid is calculated as described in [1]:

$$\text{centroid}=\frac{{\displaystyle \sum _{k={b}_{1}}^{{b}_{2}}{f}_{k}{s}_{k}}}{{\displaystyle \sum _{k={b}_{1}}^{{b}_{2}}{s}_{k}}}$$

where

*f*is the frequency in Hz corresponding to bin_{k}*k*.*s*is the spectral value at bin_{k}*k*.*b*_{1}and*b*_{2}are the band edges, in bins, over which to calculate the spectral centroid.

[1] Peeters, G. "A Large Set of Audio Features for Sound Description (Similarity and Classification) in the CUIDADO Project." Technical Report; IRCAM: Paris, France, 2004.