No more doxygen warnings for gtk2_arodur/*
[ardour.git] / libs / vamp-pyin / Yin.h
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2
3 /*
4     pYIN - A fundamental frequency estimator for monophonic audio
5     Centre for Digital Music, Queen Mary, University of London.
6
7     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License as
9     published by the Free Software Foundation; either version 2 of the
10     License, or (at your option) any later version.  See the file
11     COPYING included with this distribution for more information.
12 */
13
14 #ifndef _YIN_H_
15 #define _YIN_H_
16
17 #include "vamp-sdk/FFT.h"
18 #include "MeanFilter.h"
19
20 #include <cmath>
21
22 #include <iostream>
23 #include <vector>
24 #include <exception>
25
26 using std::vector;
27 using std::pair;
28
29
30 class Yin
31 {
32 public:
33     Yin(size_t frameSize, size_t inputSampleRate, double thresh = 0.2, bool fast = true);
34     virtual ~Yin();
35
36     struct YinOutput {
37         double f0;
38         double periodicity;
39         double rms;
40         vector<double> salience;
41         vector<pair<double, double> > freqProb;
42         YinOutput() :  f0(0), periodicity(0), rms(0),
43             salience(vector<double>(0)), freqProb(vector<pair<double, double> >(0)) { }
44         YinOutput(double _f, double _p, double _r) :
45             f0(_f), periodicity(_p), rms(_r),
46             salience(vector<double>(0)), freqProb(vector<pair<double, double> >(0)) { }
47         YinOutput(double _f, double _p, double _r, vector<double> _salience) :
48             f0(_f), periodicity(_p), rms(_r), salience(_salience),
49             freqProb(vector<pair<double, double> >(0)) { }
50     };
51
52     int setThreshold(double parameter);
53     int setThresholdDistr(float parameter);
54     int setFrameSize(size_t frameSize);
55     int setFast(bool fast);
56     // int setRemoveUnvoiced(bool frameSize);
57     YinOutput process(const double *in) const;
58     YinOutput processProbabilisticYin(const double *in) const;
59
60 private:
61     mutable size_t m_frameSize;
62     mutable size_t m_inputSampleRate;
63     mutable double m_thresh;
64     mutable size_t m_threshDistr;
65     mutable size_t m_yinBufferSize;
66     mutable bool   m_fast;
67     // mutable bool m_removeUnvoiced;
68 };
69
70 #endif