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 _CumulativeDiffAlgo_h_
21 #define _CumulativeDiffAlgo_h_
27 #include "Algorithm.h"
28 #include "CumulativeDiff.h"
32 //! Compute period with a "classical" auto-correlation algorithm
33 class CumulativeDiffAlgo : public Algorithm
36 double m_noise_threshold;
44 virtual void AFreqChanged() {init();}
45 virtual void samplingRateChanged() {init();}
46 virtual void semitoneBoundsChanged() {init();}
49 CumulativeDiffAlgo(double noise_treshold);
51 virtual int getSampleAlgoLatency() const {return 2*m_max_length;}
53 double getNoiseThreshold() const {return m_noise_threshold;}
54 void setNoiseThreshold(double noise_threshold) {m_noise_threshold=noise_threshold;}
55 void setMinMaxLength(size_t min_length, size_t max_length)
56 {m_min_length=min_length; m_max_length=max_length;}
58 void apply(const deque<double>& buff);
60 virtual bool hasNoteRecognized() const {return m_wave_length>0;}
61 virtual double getFondamentalWaveLength() const {return m_wave_length;}
63 virtual ~CumulativeDiffAlgo(){}