diff examples/SpectralCentroid.cpp @ 243:3cf5bd155e5b

* Some build improvements * Make parameterisable values in tempo estimator into parameters
author cannam
date Mon, 10 Nov 2008 22:04:40 +0000
parents 6b30e064cab7
children 88ef5ffdbe8d
line wrap: on
line diff
--- a/examples/SpectralCentroid.cpp	Mon Nov 10 17:34:14 2008 +0000
+++ b/examples/SpectralCentroid.cpp	Mon Nov 10 22:04:40 2008 +0000
@@ -157,10 +157,10 @@
 	double freq = (double(i) * m_inputSampleRate) / m_blockSize;
 	double real = inputBuffers[0][i*2];
 	double imag = inputBuffers[0][i*2 + 1];
-	double power = sqrt(real * real + imag * imag) / (m_blockSize/2);
-	numLin += freq * power;
-        numLog += log10f(freq) * power;
-	denom += power;
+	double scalemag = sqrt(real * real + imag * imag) / (m_blockSize/2);
+	numLin += freq * scalemag;
+        numLog += log10f(freq) * scalemag;
+	denom += scalemag;
     }
 
 //    std::cerr << denom << std::endl;
@@ -173,15 +173,16 @@
 
 	Feature feature;
 	feature.hasTimestamp = false;
-    if (!isnan(centroidLog) && !isinf(centroidLog)) {
-        feature.values.push_back(centroidLog);
-    }
+
+        if (!isnan(centroidLog) && !isinf(centroidLog)) {
+            feature.values.push_back(centroidLog);
+        }
 	returnFeatures[0].push_back(feature);
 
-    feature.values.clear();
-    if (!isnan(centroidLin) && !isinf(centroidLin)) {
-        feature.values.push_back(centroidLin);
-    }
+        feature.values.clear();
+        if (!isnan(centroidLin) && !isinf(centroidLin)) {
+            feature.values.push_back(centroidLin);
+        }
 	returnFeatures[1].push_back(feature);
     }