diff CepstrumPitchTracker.cpp @ 14:98256077e2a2 track

Reap expired/rejected hypotheses from list; report an estimate as accepted only if the accepting hypothesis has been satisfied already (otherwise a different provisional hypothesis might become satisfied first)
author Chris Cannam
date Sun, 01 Jul 2012 11:33:37 +0100
parents 6f73de098d35
children bd7fb10646fc
line wrap: on
line diff
--- a/CepstrumPitchTracker.cpp	Sat Jun 30 10:12:08 2012 +0100
+++ b/CepstrumPitchTracker.cpp	Sun Jul 01 11:33:37 2012 +0100
@@ -51,7 +51,7 @@
     Estimate last = m_pending[m_pending.size()-1];
     double r = s.freq / last.freq;
     int cents = lrint(1200.0 * (log(r) / log(2.0)));
-    return (cents > -200 && cents < 200);
+    return (cents > -100 && cents < 100);
 }
 
 bool 
@@ -109,7 +109,7 @@
         }
     }
 
-    return accept;
+    return accept && (m_state == Satisfied);
 }        
 
 CepstrumPitchTracker::Hypothesis::State
@@ -522,12 +522,22 @@
             }
         }
 
+        // reap rejected/expired hypotheses from possible list
+        Hypotheses toReap = m_possible;
+        m_possible.clear();
+        for (int i = 0; i < toReap.size(); ++i) {
+            Hypothesis h = toReap[i];
+            if (h.getState() != Hypothesis::Rejected && 
+                h.getState() != Hypothesis::Expired) {
+                m_possible.push_back(h);
+            }
+        }
+    }  
+
         std::cerr << "accepted length = " << m_accepted.getPendingLength()
                   << ", state = " << m_accepted.getState()
                   << ", hypothesis count = " << m_possible.size() << std::endl;
 
-        //!!! and also need to reap rejected/expired hypotheses from the list
-    }  
             
 
 /*