1 // Copyright 2007 "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
24 #include <CppAddons/CAMath.h>
28 std::vector<double> hann(int n);
29 std::vector<double> hamming(int n);
31 inline double win_sinc(double x, double f)
33 if(x==0.5) return 1.0;
34 double s = Math::sinc((x-0.5)*f);
42 Win_Sinc(double f) : m_f(f) {}
44 double operator()(double x) {return win_sinc(x, m_f);}
47 //! usefull gauss fonction
49 * \param x \f$\approx\in [0,1]\f$
50 * \param f width factor
52 inline double win_gauss(double x, double f)
54 return Math::gauss((x-0.5)*f);
57 //! object fonction of \ref win_gauss
62 Win_Gauss(double g) : m_g(g) {}
64 double operator()(double x) {return win_gauss(x, m_g);}
67 //! compute integrale of fn \f$\in [0,1]\f$
68 /*! with a Simpson algorithm
71 inline double Usefull(Fn fn, double simpsonStep=0.001)
73 return Math::Simpson(0.0, 1.0, fn, simpsonStep);
77 #endif // _SPWindow_h_