diff options
| author | Nevo Segal <Nevosegal@gmail.com> | 2015-01-07 11:44:08 +0000 |
|---|---|---|
| committer | Nevo Segal <Nevosegal@gmail.com> | 2015-01-07 11:44:08 +0000 |
| commit | b1ad9b676e00910021a3d9aeb0e2336f038d672a (patch) | |
| tree | 9832629236a865a45a762e313761b1fb19519552 | |
| parent | 911b5a35e925d5c270de405c4ac133d13e7e8e2a (diff) | |
Fixed spectral centroid
Slight error in the calculation of the numerator in spectral centroid.
| -rw-r--r-- | ofxMaxim/ofxMaxim/libs/maxiFFT.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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; |
