diff plugins/BeatTrack.cpp @ 120:52d84f7f6ad3

* Add Ruohua's Transcription plugin
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 09 Jun 2009 15:07:19 +0000
parents 2416ef0e9319
children 0258a32639e6
line wrap: on
line diff
--- a/plugins/BeatTrack.cpp	Mon Jun 08 12:31:08 2009 +0000
+++ b/plugins/BeatTrack.cpp	Tue Jun 09 15:07:19 2009 +0000
@@ -438,7 +438,17 @@
     vector<double> beatPeriod;
     vector<double> tempi;
 
-    for (size_t i = 2; i < m_d->dfOutput.size(); ++i) { // discard first two elts
+    size_t nonZeroCount = m_d->dfOutput.size();
+    while (nonZeroCount > 0) {
+        if (m_d->dfOutput[nonZeroCount-1] > 0.0) {
+            break;
+        }
+        --nonZeroCount;
+    }
+
+    std::cerr << "Note: nonZeroCount was " << m_d->dfOutput.size() << ", is now " << nonZeroCount << std::endl;
+
+    for (size_t i = 2; i < nonZeroCount; ++i) { // discard first two elts
         df.push_back(m_d->dfOutput[i]);
         beatPeriod.push_back(0.0);
     }