Revision 58:9f50a5876dd3

View differences:

CepstralPitchTracker.cpp
333 333
    if (nextPeakVal != 0.0) {
334 334
        confidence = (maxval - nextPeakVal) * 10.0;
335 335
        if (magmean < threshold) confidence = 0.0;
336
//        std::cerr << "magmean = " << magmean << ", confidence = " << confidence << std::endl;
337 336
    }
338 337

  
339 338
    delete[] data;
NoteHypothesis.cpp
64 64
NoteHypothesis::isOutOfDateFor(Estimate s) const
65 65
{
66 66
    if (m_pending.empty()) return false;
67

  
68 67
    return ((s.time - m_pending[m_pending.size()-1].time) > 
69 68
            RealTime::fromMilliseconds(40));
70 69
}
......
93 92
{
94 93
    bool accept = false;
95 94

  
95
    static double negligibleConfidence = 0.0001;
96

  
97
    if (s.confidence < negligibleConfidence) {
98
        // avoid piling up a lengthy sequence of estimates that are
99
        // all acceptable but are in total not enough to cause us to
100
        // be satisfied
101
        m_state = Rejected;
102
        return false;
103
    }
104

  
96 105
    switch (m_state) {
97 106

  
98 107
    case New:
NoteHypothesis.h
68 68
    ~NoteHypothesis();
69 69

  
70 70
    struct Estimate {
71
        Estimate() : freq(0), time(), confidence(0) { }
71
        Estimate() : freq(0), time(), confidence(1) { }
72 72
        Estimate(double _f, Vamp::RealTime _t, double _c) :
73 73
            freq(_f), time(_t), confidence(_c) { }
74 74
        bool operator==(const Estimate &e) const {
test/TestNoteHypothesis.cpp
53 53

  
54 54
BOOST_AUTO_TEST_CASE(emptyAccept)
55 55
{
56
    // An empty hypothesis should accept any estimate and enter
57
    // provisional state
56
    // An empty hypothesis should accept any estimate with a
57
    // non-negligible confidence, and enter provisional state
58 58
    NoteHypothesis h;
59
    NoteHypothesis::Estimate e;
59
    NoteHypothesis::Estimate e; // default estimate has confidence 1
60 60
    BOOST_CHECK_EQUAL(h.getState(), NoteHypothesis::New);
61 61
    BOOST_CHECK(h.accept(e));
62 62
    BOOST_CHECK_EQUAL(h.getState(), NoteHypothesis::Provisional);
63 63
}
64

  
65
BOOST_AUTO_TEST_CASE(noConfidence)
66
{
67
    // A hypothesis should reject any estimate that has a negligible
68
    // confidence
69
    NoteHypothesis h;
70
    NoteHypothesis::Estimate e;
71
    e.confidence = 0;
72
    BOOST_CHECK_EQUAL(h.getState(), NoteHypothesis::New);
73
    BOOST_CHECK(!h.accept(e));
74
    BOOST_CHECK_EQUAL(h.getState(), NoteHypothesis::Rejected);
75
}
64 76
		
65 77
BOOST_AUTO_TEST_CASE(tooSlow)
66 78
{

Also available in: Unified diff