changeset 208:df55003e8968

* Slightly different angle on filtering... hmmm
author cannam
date Thu, 16 Oct 2008 14:17:07 +0000
parents fa8afbb7221b
children 0f6616ef0e18
files examples/FixedTempoEstimator.cpp
diffstat 1 files changed, 24 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/examples/FixedTempoEstimator.cpp	Wed Oct 15 13:09:08 2008 +0000
+++ b/examples/FixedTempoEstimator.cpp	Thu Oct 16 14:17:07 2008 +0000
@@ -381,13 +381,21 @@
         m_fr[i] = m_r[i] * (1 + weight / 3.f);
     }
 
-    float related[4] = { 2, 3, 4 };
+    int related[4] = { 2, 3, 4 };
+
+    int e = tempo2lag(60.f);
+    int universalDiv = (n/2 - 1) / e;
+    cerr << "universalDiv = " << universalDiv << endl;
 
     for (int i = 0; i < n/2; ++i) {
 
-        if (i == 0 || i == n/2 - 1 ||
+        if (i == 0 || i == n/2 - 1
+/*
+            ||
             !(m_fr[i] > m_fr[i-1] &&
-              m_fr[i] >= m_fr[i+1])) {
+              m_fr[i] >= m_fr[i+1])
+*/
+            ) {
             continue;
         }
 
@@ -415,6 +423,11 @@
                     }
                 }
 
+                if (related[j] <= universalDiv) {
+//                    m_fr[i] += m_fr[kmax]; //!!!
+                    m_fr[i] += m_r[kmax] / related[j];
+                }
+
                 if (m_r[kmax] > m_r[kmax-1] &&
                     m_r[kmax] > m_r[kmax+1] &&
                     kvmax > kvmin * 1.05) {
@@ -435,6 +448,7 @@
 //        }
     }
 
+/*
     int e = tempo2lag(60.f);
     int div = (n/2 - 1) / e;
 
@@ -446,7 +460,7 @@
             }
         }
     }
-
+*/
 //        cerr << "i = " << i << ", (n/2 - 1)/i = " << (n/2 - 1)/i << ", sum = " << m_fr[i] << ", div = " << div << ", val = " << m_fr[i] / div << ", t = " << lag2tempo(i) << endl;
 
 
@@ -474,16 +488,16 @@
     int n = m_n;
 
     for (int i = 0; i < n; ++i) {
-        feature.timestamp = RealTime::frame2RealTime(i * m_stepSize,
-                                                     m_inputSampleRate);
+        feature.timestamp = m_start +
+            RealTime::frame2RealTime(i * m_stepSize, m_inputSampleRate);
         feature.values[0] = m_df[i];
         feature.label = "";
         fs[DFOutput].push_back(feature);
     }
 
     for (int i = 1; i < n/2; ++i) {
-        feature.timestamp = RealTime::frame2RealTime(i * m_stepSize,
-                                                     m_inputSampleRate);
+        feature.timestamp = m_start +
+            RealTime::frame2RealTime(i * m_stepSize, m_inputSampleRate);
         feature.values[0] = m_r[i];
         sprintf(buffer, "%.1f bpm", lag2tempo(i));
         if (i == n/2-1) feature.label = "";
@@ -511,8 +525,8 @@
 
         candidates[m_fr[i]] = i;
 
-        feature.timestamp = RealTime::frame2RealTime(i * m_stepSize,
-                                                     m_inputSampleRate);
+        feature.timestamp = m_start +
+            RealTime::frame2RealTime(i * m_stepSize, m_inputSampleRate);
         feature.values[0] = m_fr[i];
         sprintf(buffer, "%.1f bpm", lag2tempo(i));
         if (i == p1 || i == n/2-2) feature.label = "";