annotate Yin.h @ 164:a7d9c6142f8f tip

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