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
20 #ifndef _MultiCumulativeDiffAlgo_h_
21 #define _MultiCumulativeDiffAlgo_h_
26 #include "Algorithm.h"
27 #include "CumulativeDiff.h"
31 //! Compute error for each possible freqs with correlation algorithm
32 class MultiCumulativeDiffAlgo : public Transform
34 double m_test_complexity;
36 vector<bool> m_is_fondamental;
40 virtual void AFreqChanged() {init();}
41 virtual void samplingRateChanged() {init();}
42 virtual void semitoneBoundsChanged() {init();}
45 //! correlation filters
46 vector< CumulativeDiff* > m_diffs;
48 bool is_minima(int ih);
51 double m_pitch_tolerance;
53 void setTestComplexity(double test_complexity) {m_test_complexity = test_complexity;}
54 double getTestComplexity() {return m_test_complexity;}
56 virtual int getSampleAlgoLatency() const {return int((getAlgoLatency()/1000.0)*GetSamplingRate());}
58 virtual double getAlgoLatency() const {return 1000.0*(2*m_diffs[0]->m_s)/GetSamplingRate();}
62 * \param latency_factor latency factor for statistical purpose [1;oo[
63 * \param test_complexity
65 MultiCumulativeDiffAlgo(int latency_factor, double test_complexity);
67 //! overwrited computing function
68 virtual void apply(const deque<double>& buff);
70 virtual double getFondamentalWaveLength() const;
72 virtual ~MultiCumulativeDiffAlgo();