From b1ad9b676e00910021a3d9aeb0e2336f038d672a Mon Sep 17 00:00:00 2001 From: Nevo Segal Date: Wed, 7 Jan 2015 11:44:08 +0000 Subject: Fixed spectral centroid Slight error in the calculation of the numerator in spectral centroid. --- ofxMaxim/ofxMaxim/libs/maxiFFT.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ofxMaxim') diff --git a/ofxMaxim/ofxMaxim/libs/maxiFFT.cpp b/ofxMaxim/ofxMaxim/libs/maxiFFT.cpp index 90a3137..c648992 100644 --- a/ofxMaxim/ofxMaxim/libs/maxiFFT.cpp +++ b/ofxMaxim/ofxMaxim/libs/maxiFFT.cpp @@ -110,7 +110,7 @@ float maxiFFT::spectralFlatness() { float maxiFFT::spectralCentroid() { float x=0, y=0; for(int i=0; i < bins; i++) { - x += fabs(magnitudes[i]) * (i+1); + x += fabs(magnitudes[i]) * i; y += fabs(magnitudes[i]); } return y != 0 ? x / y * ((float) maxiSettings::sampleRate / fftSize) : 0; -- cgit v1.3