diff plugins/OnsetDetect.cpp @ 153:38502a1595ff

Update for new DetectionFunction api
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 21 Oct 2013 12:02:51 +0100
parents dcf5800f0f00
children 855c91bfc912
line wrap: on
line diff
--- a/plugins/OnsetDetect.cpp	Thu Sep 05 13:21:26 2013 +0100
+++ b/plugins/OnsetDetect.cpp	Mon Oct 21 12:02:51 2013 +0100
@@ -351,7 +351,7 @@
 	return FeatureSet();
     }
 
-    size_t len = m_d->dfConfig.frameLength / 2;
+    size_t len = m_d->dfConfig.frameLength / 2 + 1;
 
 //    float mean = 0.f;
 //    for (size_t i = 0; i < len; ++i) {
@@ -365,23 +365,20 @@
 //              << "dftype " << m_dfType << ", sens " << m_sensitivity
 //              << ", len " << len << ", mean " << mean << std::endl;
 
-    double *magnitudes = new double[len];
-    double *phases = new double[len];
+    double *reals = new double[len];
+    double *imags = new double[len];
 
     // We only support a single input channel
 
     for (size_t i = 0; i < len; ++i) {
-
-        magnitudes[i] = sqrt(inputBuffers[0][i*2  ] * inputBuffers[0][i*2  ] +
-                             inputBuffers[0][i*2+1] * inputBuffers[0][i*2+1]);
-
-	phases[i] = atan2(-inputBuffers[0][i*2+1], inputBuffers[0][i*2]);
+        reals[i] = inputBuffers[0][i*2];
+        imags[i] = inputBuffers[0][i*2+1];
     }
 
-    double output = m_d->df->process(magnitudes, phases);
+    double output = m_d->df->processFrequencyDomain(reals, imags);
 
-    delete[] magnitudes;
-    delete[] phases;
+    delete[] reals;
+    delete[] imags;
 
     if (m_d->dfOutput.empty()) m_d->origin = timestamp;