1 // Copyright 2004 "Gilles Degottex"
3 // This file is part of "Music"
5 // "Music" is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 2.1 of the License, or
8 // (at your option) any later version.
10 // "Music" is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <CppAddons/CAMath.h>
31 #include "Algorithm.h"
35 /*! Combed FT for one voice
36 * Hypothesis: the highest energy peak takes part of the instrument sound
39 class CombedFT : public Transform
47 bool m_use_audibility_treshold;
49 double m_window_factor;
52 virtual void AFreqChanged() {init();}
53 virtual void samplingRateChanged() {init();}
54 virtual void semitoneBoundsChanged() {init();}
61 void setZeroPaddingFactor(double zp);
62 double getZeroPaddingFactor() const {return m_zp_factor;}
64 void setWindowFactor(double wf);
65 double getWindowFactor() const {return m_window_factor;}
67 /*! set audibility ratio of low harmonics against higher ones
68 * decrease influences of low harmonics in the evaluation of the fundamental.
69 * (avoid many too-low evaluation in high frequencies)
70 * Sometimes in high pitch notes (eg. G3 with bari-sax) a "disturbing" component appears
71 * at frequency f=G2 and so the fundamental is badly evaluated.
72 * By "disturbing" I mean: present in the spectral representation, but not audible or weak to much to change the impression of the pitch.
73 * Actually, that's a physiological setting, there is no "true" choice for a such situation.
74 * in [0, inf], 0 mean no correction, a good value seems to be 0.1
76 void useAudibilityRatio(bool use) {m_use_audibility_treshold=use;}
77 void setAudibilityRatio(double audib_ratio=0.1) {m_audib_ratio=audib_ratio;}
78 double getAudibilityRatio() {return m_audib_ratio;}
80 virtual int getSampleAlgoLatency() const;
81 virtual double getFondamentalFreq() const;
82 virtual bool hasNoteRecognized() const {return m_f0>0.0;}
83 virtual int getMinSize() const;
84 virtual void apply(const deque<double>& buff);