// Copyright 2004 "Gilles Degottex" // This file is part of "Music" // "Music" is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2.1 of the License, or // (at your option) any later version. // // "Music" is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "CumulativeDiffAlgo.h" #include #include #include #include #include using namespace std; #include using namespace Math; #include "Music.h" //#define MUSIC_DEBUG #ifdef MUSIC_DEBUG #define LOG(a) a #else #define LOG(a) #endif namespace Music { void CumulativeDiffAlgo::init() { setMinMaxLength(int(GetSamplingRate()/h2f(GetSemitoneMax())), int(GetSamplingRate()/h2f(GetSemitoneMin()))); } CumulativeDiffAlgo::CumulativeDiffAlgo(double noise_treshold) : m_noise_threshold(noise_treshold) , m_wave_length(0) { init(); } //! return the average differance on the sample delimited by [0,size] // - ne pas utiliser tout size // - sauter des données double diff(const deque& buff, size_t size, size_t s) { double r = 0.0; for(size_t i=0; i& buff) { if(buff.size()<2*m_max_length) { m_wave_length = 0; return; } double max_vol = 0.0; for(size_t i=0; i