Use conf.fatal for fatal configuration errors
[ardour.git] / libs / vamp-pyin / YinUtil.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 _YINUTIL_H_
15 #define _YINUTIL_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
28 class YinUtil
29 {
30 public:
31     static double sumSquare(const double *in, const size_t startInd, const size_t endInd);
32     static void difference(const double *in, double *yinBuffer, const size_t yinBufferSize);
33     static void fastDifference(const double *in, double *yinBuffer, const size_t yinBufferSize);
34     static void slowDifference(const double *in, double *yinBuffer, const size_t yinBufferSize);
35     static void cumulativeDifference(double *yinBuffer, const size_t yinBufferSize);
36     static int absoluteThreshold(const double *yinBuffer, const size_t yinBufferSize, const double thresh);
37     static vector<double> yinProb(const double *yinBuffer, const size_t prior, const size_t yinBufferSize, size_t minTau = 0, size_t maxTau = 0);
38     static double parabolicInterpolation(const double *yinBuffer, const size_t tau,
39                                          const size_t yinBufferSize);
40 };
41
42 #endif