changeset 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 979281679a39
children ec829e6a92a2
files plugins/AdaptiveSpectrogram.h plugins/BarBeatTrack.cpp plugins/BeatTrack.cpp plugins/OnsetDetect.cpp
diffstat 4 files changed, 18 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/AdaptiveSpectrogram.h	Thu Sep 05 13:21:26 2013 +0100
+++ b/plugins/AdaptiveSpectrogram.h	Mon Oct 21 12:02:51 2013 +0100
@@ -178,7 +178,7 @@
                     m_rin[j] = m_in[origin + i * m_w/2 + j];
                 }
                 m_window.cut(m_rin);
-                m_fft->process(false, m_rin, m_rout, m_iout);
+                m_fft->forward(m_rin, m_rout, m_iout);
                 for (int j = 0; j < m_w/2; ++j) {
                     int k = j+1; // include Nyquist but not DC
                     double mag = sqrt(m_rout[k] * m_rout[k] +
--- a/plugins/BarBeatTrack.cpp	Thu Sep 05 13:21:26 2013 +0100
+++ b/plugins/BarBeatTrack.cpp	Mon Oct 21 12:02:51 2013 +0100
@@ -348,7 +348,7 @@
 #endif
     for (int i = 0; i < fl; ++i) dfinput[i] = inputBuffers[0][i];
 
-    double output = m_d->df->process(dfinput);
+    double output = m_d->df->processTimeDomain(dfinput);
 
     if (m_d->dfOutput.empty()) m_d->origin = timestamp;
 
--- a/plugins/BeatTrack.cpp	Thu Sep 05 13:21:26 2013 +0100
+++ b/plugins/BeatTrack.cpp	Mon Oct 21 12:02:51 2013 +0100
@@ -367,25 +367,22 @@
     return FeatureSet();
     }
 
-    size_t len = m_d->dfConfig.frameLength / 2;
+    size_t len = m_d->dfConfig.frameLength / 2 + 1;
 
-    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;
 
--- 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;