CLAM-Development  1.4.0
ConstantQTransform.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2006 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #ifndef ConstantQTransform_hxx
23 #define ConstantQTransform_hxx
24 
25 #include <vector>
26 #include <cmath>
27 
28 namespace Simac
29 {
30 
58 {
59 public:
60  typedef std::vector<double> ConstantQSpectrum;
61  typedef std::vector<double> Spectrum;
62 private:
63  ConstantQSpectrum cqdata;
64  unsigned FS;
65  double fmin;
66  double fmax;
67  double Q;
68  unsigned _binsPerOctave;
69  unsigned mSpectrumSize;
70  unsigned K;
71 
72  // Sparse complex numbers matrix represented by the i and j indexes
73  // for non null cells and the real and imaginary components of the cell
74  std::vector<unsigned> mSparseKernelIs;
75  std::vector<unsigned> mSparseKernelJs;
76  std::vector<double> mSparseKernelImagValues;
77  std::vector<double> mSparseKernelRealValues;
78 public:
79  void doIt(const std::vector<double> & fftData);
80 
81 //public functions incl. sparsekernel so can keep out of loop in main
82 public:
83  ConstantQTransform(unsigned FS, double fmin, double fmax, unsigned binsPerOctave);
84  void sparsekernel(double);
86  // Results
87  const ConstantQSpectrum & constantQSpectrum() const {return cqdata;}
88  double getQ() const {return Q;}
89  int getK() const {return K;}
90  int getfftlength() const {return mSpectrumSize;}
91 private:
92  double Hamming(int len, int n) {
93  double out = 0.54 - 0.46*std::cos(2*M_PI*n/len);
94  return(out);
95  }
96 };
97 
98 }
99 
100 #endif//ConstantQTransform_hxx
101