Revision 11:c938c60de2de

View differences:

CepstrumPitchTracker.cpp
38 38
    m_age = 0;
39 39
}
40 40

  
41
CepstrumPitchTracker::Hypothesis::~Hypothesis()
42
{
43
}
44

  
41 45
bool
42 46
CepstrumPitchTracker::Hypothesis::isWithinTolerance(Estimate s)
43 47
{
......
124 128
    }
125 129
}
126 130

  
131
void
132
CepstrumPitchTracker::Hypothesis::addFeatures(FeatureList &fl)
133
{
134
    for (int i = 0; i < m_pending.size(); ++i) {
135
	Feature f;
136
	f.hasTimestamp = true;
137
	f.timestamp = m_pending[i].time;
138
	f.values.push_back(m_pending[i].freq);
139
	fl.push_back(f);
140
    }
141
}
127 142

  
128 143
CepstrumPitchTracker::CepstrumPitchTracker(float inputSampleRate) :
129 144
    Plugin(inputSampleRate),
......
462 477
    e.time = timestamp;
463 478

  
464 479
    m_accepted.advanceTime();
480

  
465 481
    for (int i = 0; i < m_possible.size(); ++i) {
466 482
        m_possible[i].advanceTime();
467 483
    }
468 484

  
469
    if (m_accepted.test(e)) {
470
        return fs;
471
    }
485
    if (!m_accepted.test(e)) {
486
        int candidate = -1;
487
        for (int i = 0; i < m_possible.size(); ++i) {
488
            if (m_possible[i].test(e)) {
489
                if (m_possible[i].getState() == Hypothesis::Satisfied) {
490
                    candidate = i;
491
                }
492
                break;
493
            }
494
        }
495
        if (m_accepted.getState() == Hypothesis::Expired) {
496
            m_accepted.addFeatures(fs[0]);
497
            if (candidate >= 0) {
498
                m_accepted = m_possible[candidate];
499
            } else {
500
                m_accepted = Hypothesis();
501
            }
502
        }
472 503

  
473
    //...
504
        //!!! and also need to reap rejected/expired hypotheses from the list
505
    }  
506
            
474 507

  
475 508
/*
476 509
    bool accepted = false;
......
510 543
//    std::cerr << "bins = " << m_bins << std::endl;
511 544

  
512 545
//    if (peakProportion >= (0.00006 * m_bins)) {
546
/*
513 547
    if (accepted) {
514 548
	Feature f;
515 549
	f.hasTimestamp = true;
......
517 551
	f.values.push_back(m_inputSampleRate / (maxbin + m_binFrom));
518 552
	fs[0].push_back(f);
519 553
    }
520

  
554
*/
521 555
    delete[] data;
522 556
    return fs;
523 557
}
......
526 560
CepstrumPitchTracker::getRemainingFeatures()
527 561
{
528 562
    FeatureSet fs;
563
    if (m_accepted.getState() != Hypothesis::New) {
564
        m_accepted.addFeatures(fs[0]);
565
    }
529 566
    return fs;
530 567
}
531 568

  
CepstrumPitchTracker.h
103 103

  
104 104
        Estimates getAcceptedEstimates();
105 105

  
106
        void addFeatures(FeatureList &fl);
107

  
106 108
    private:
107 109
        bool isWithinTolerance(Estimate);
108 110
        bool isSatisfied();

Also available in: Unified diff