Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/tonal/ConstantQTransform.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2006 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef ConstantQTransform_hxx
00023 #define ConstantQTransform_hxx
00024 
00025 #include <vector>
00026 #include <cmath>
00027 
00028 #ifdef __WINDOWS__
00029 #define _USE_MATH_DEFINES
00030 #include <math.h>
00031 #endif
00032 
00033 namespace Simac
00034 {
00035 
00062 class ConstantQTransform
00063 {
00064 public:
00065         typedef std::vector<double> ConstantQSpectrum;
00066         typedef std::vector<double> Spectrum;
00067 private:
00068         ConstantQSpectrum cqdata;
00069         unsigned FS;
00070         double fmin;
00071         double fmax;
00072         double Q;
00073         unsigned _binsPerOctave;
00074         unsigned mSpectrumSize;
00075         unsigned K;
00076 
00077         // Sparse complex numbers matrix represented by the i and j indexes
00078         // for non null cells and the real and imaginary components of the cell
00079         std::vector<unsigned> mSparseKernelIs;
00080         std::vector<unsigned> mSparseKernelJs;
00081         std::vector<double> mSparseKernelImagValues;
00082         std::vector<double> mSparseKernelRealValues;
00083 public:
00084         void doIt(const std::vector<double> & fftData);
00085 
00086 //public functions incl. sparsekernel so can keep out of loop in main
00087 public:
00088         ConstantQTransform(unsigned FS, double fmin, double fmax, unsigned binsPerOctave);
00089         void sparsekernel(double);
00090         ~ConstantQTransform();
00091         // Results
00092         const ConstantQSpectrum & constantQSpectrum() const {return cqdata;}
00093         double getQ() const {return Q;}
00094         int getK() const {return K;}
00095         int getfftlength() const {return mSpectrumSize;}
00096 private:
00097         double Hamming(int len, int n) {
00098                 double out = 0.54 - 0.46*std::cos(2*M_PI*n/len);
00099                 return(out);
00100         }
00101 };
00102 
00103 }
00104 
00105 #endif//ConstantQTransform_hxx
00106 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines