Revision 35:2f5b169e4a3b CepstralPitchTracker.h

View differences:

CepstralPitchTracker.h
22 22
    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 23
*/
24 24

  
25
#ifndef _CEPSTRUM_PITCH_H_
26
#define _CEPSTRUM_PITCH_H_
25
#ifndef _CEPSTRAL_PITCH_H_
26
#define _CEPSTRAL_PITCH_H_
27 27

  
28 28
#include <vamp-sdk/Plugin.h>
29 29

  
30
#include "NoteHypothesis.h"
31

  
30 32
class CepstralPitchTracker : public Vamp::Plugin
31 33
{
32 34
public:
......
76 78
    int m_binTo;
77 79
    int m_bins; // count of "interesting" bins, those returned in m_cepOutput
78 80

  
79
    class Hypothesis {
81
    typedef std::vector<NoteHypothesis> Hypotheses;
82
    Hypotheses m_possible;
83
    NoteHypothesis m_good;
80 84

  
81
    public:
82
        struct Estimate {
83
            double freq;
84
            Vamp::RealTime time;
85
            double confidence;
86
        };
87
        typedef std::vector<Estimate> Estimates;
88

  
89
        struct Note {
90
            double freq;
91
            Vamp::RealTime time;
92
            Vamp::RealTime duration;
93
        };
94
        
95
        Hypothesis();
96
        ~Hypothesis();
97

  
98
        enum State {
99
            New,
100
            Provisional,
101
            Satisfied,
102
            Rejected,
103
            Expired
104
        };
105

  
106
        bool accept(Estimate);
107

  
108
        State getState() const;
109
        Estimates getAcceptedEstimates() const;
110
        Note getAveragedNote() const;
111

  
112
    private:
113
        bool isWithinTolerance(Estimate) const;
114
        bool isOutOfDateFor(Estimate) const;
115
        bool isSatisfied() const;
116
        double getMeanFrequency() const;
117

  
118
        State m_state;
119
        Estimates m_pending;
120
    };
121

  
122
    typedef std::vector<Hypothesis> Hypotheses;
123
    Hypotheses m_possible;
124
    Hypothesis m_good;
125

  
126
    void addFeaturesFrom(Hypothesis h, FeatureSet &fs);
85
    void addFeaturesFrom(NoteHypothesis h, FeatureSet &fs);
127 86

  
128 87
    void filter(const double *in, double *out);
129 88
    double cubicInterpolate(const double[4], double);

Also available in: Unified diff