spectral centroid refactored