CLAM-Development
1.1
|
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 namespace Simac 00029 { 00030 00057 class ConstantQTransform 00058 { 00059 public: 00060 typedef std::vector<double> ConstantQSpectrum; 00061 typedef std::vector<double> Spectrum; 00062 private: 00063 ConstantQSpectrum cqdata; 00064 unsigned FS; 00065 double fmin; 00066 double fmax; 00067 double Q; 00068 unsigned _binsPerOctave; 00069 unsigned mSpectrumSize; 00070 unsigned K; 00071 00072 // Sparse complex numbers matrix represented by the i and j indexes 00073 // for non null cells and the real and imaginary components of the cell 00074 std::vector<unsigned> mSparseKernelIs; 00075 std::vector<unsigned> mSparseKernelJs; 00076 std::vector<double> mSparseKernelImagValues; 00077 std::vector<double> mSparseKernelRealValues; 00078 public: 00079 void doIt(const std::vector<double> & fftData); 00080 00081 //public functions incl. sparsekernel so can keep out of loop in main 00082 public: 00083 ConstantQTransform(unsigned FS, double fmin, double fmax, unsigned binsPerOctave); 00084 void sparsekernel(double); 00085 ~ConstantQTransform(); 00086 // Results 00087 const ConstantQSpectrum & constantQSpectrum() const {return cqdata;} 00088 double getQ() const {return Q;} 00089 int getK() const {return K;} 00090 int getfftlength() const {return mSpectrumSize;} 00091 private: 00092 double Hamming(int len, int n) { 00093 double out = 0.54 - 0.46*std::cos(2*M_PI*n/len); 00094 return(out); 00095 } 00096 }; 00097 00098 } 00099 00100 #endif//ConstantQTransform_hxx 00101