X-Git-Url: http://git.johnwright.org/?p=fmit.git;a=blobdiff_plain;f=libs%2FMusic%2FBubbleAlgo.cpp;fp=libs%2FMusic%2FBubbleAlgo.cpp;h=bf3c62848b966ba56c6c7a9a62cf94bf7ab8408a;hp=0000000000000000000000000000000000000000;hb=a8fb82288feb6b258f2c04312f0c36ba8d79b494;hpb=adfba0402927438a1869f1e716bcf0e25574ce1e diff --git a/libs/Music/BubbleAlgo.cpp b/libs/Music/BubbleAlgo.cpp new file mode 100644 index 0000000..bf3c628 --- /dev/null +++ b/libs/Music/BubbleAlgo.cpp @@ -0,0 +1,352 @@ +// 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 "BubbleAlgo.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 +{ + int gcd(int a, int b) + { + if (b == 0) return a; + + return gcd(b, a%b); + } + int gcd(vector v) + { + if(v.empty()) return -1; + + int s = v[0]; + for(size_t i=1; i(0.0, c*j)) * d * win_sinc(j/double(m_waves[s].size()), gauss_factor)/u; + + complex b(0.0,0.0); + for(int i=s-1; i>=0; i--) + { + for(size_t l=0; l& buff) + { + m_wave_length = 0; + + if(buff.size()=f) + if(gcds0) cerr<<"(pos:"<<100*err_drop_t/err_drop/n<<"%)"; + cerr<<",conv="<0) cerr<<"(pos:"<<100*score_drop_t/score_drop/n<<"%)"; + cerr<<",sgn="<0) cerr<<"(pos:"<<100*sgn_drop_t/sgn_drop/n<<"%)"; + cerr<<",mult="<0) cerr<<"(pos:"<<100*mult_drop_t/mult_drop/n<<"%)"; + cerr<<"]"<err_threshold +// || normm(m_bubbles[m_wave_length].conv)