c@225
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
c@225
|
2
|
c@225
|
3 /*
|
c@225
|
4 QM DSP Library
|
c@225
|
5
|
c@225
|
6 Centre for Digital Music, Queen Mary, University of London.
|
c@225
|
7 This file copyright 2005-2006 Christian Landone.
|
c@225
|
8 All rights reserved.
|
c@225
|
9 */
|
c@225
|
10
|
c@225
|
11 #ifndef CONSTANTQ_H
|
c@225
|
12 #define CONSTANTQ_H
|
c@225
|
13
|
c@225
|
14 #include <vector>
|
c@241
|
15 #include "maths/MathAliases.h"
|
c@241
|
16 #include "maths/MathUtilities.h"
|
c@225
|
17
|
c@225
|
18 struct CQConfig{
|
c@245
|
19 unsigned int FS; // samplerate
|
c@245
|
20 double min; // minimum frequency
|
c@245
|
21 double max; // maximum frequency
|
c@245
|
22 unsigned int BPO; // bins per octave
|
c@245
|
23 double CQThresh; // threshold
|
c@225
|
24 };
|
c@225
|
25
|
c@225
|
26 class ConstantQ {
|
c@225
|
27
|
c@225
|
28 //public functions incl. sparsekernel so can keep out of loop in main
|
c@225
|
29 public:
|
c@257
|
30 void process( const double* FFTRe, const double* FFTIm,
|
c@257
|
31 double* CQRe, double* CQIm );
|
c@225
|
32
|
c@225
|
33 ConstantQ( CQConfig Config );
|
c@225
|
34 ~ConstantQ();
|
c@225
|
35
|
c@257
|
36 double* process( const double* FFTData );
|
c@225
|
37
|
c@225
|
38 void sparsekernel();
|
c@225
|
39
|
c@225
|
40 double hamming(int len, int n) {
|
c@225
|
41 double out = 0.54 - 0.46*cos(2*PI*n/len);
|
c@225
|
42 return(out);
|
c@225
|
43 }
|
c@225
|
44
|
c@225
|
45 int getnumwin() { return m_numWin;}
|
c@225
|
46 double getQ() { return m_dQ;}
|
c@225
|
47 int getK() {return m_uK ;}
|
c@225
|
48 int getfftlength() { return m_FFTLength;}
|
c@225
|
49 int gethop() { return m_hop;}
|
c@225
|
50
|
c@225
|
51 private:
|
c@225
|
52 void initialise( CQConfig Config );
|
c@225
|
53 void deInitialise();
|
c@225
|
54
|
c@225
|
55 double* m_CQdata;
|
c@225
|
56 unsigned int m_FS;
|
c@225
|
57 double m_FMin;
|
c@225
|
58 double m_FMax;
|
c@225
|
59 double m_dQ;
|
c@225
|
60 double m_CQThresh;
|
c@225
|
61 unsigned int m_numWin;
|
c@225
|
62 unsigned int m_hop;
|
c@225
|
63 unsigned int m_BPO;
|
c@225
|
64 unsigned int m_FFTLength;
|
c@225
|
65 unsigned int m_uK;
|
c@225
|
66 std::vector<unsigned> m_sparseKernelIs;
|
c@225
|
67 std::vector<unsigned> m_sparseKernelJs;
|
c@225
|
68 std::vector<double> m_sparseKernelImagValues;
|
c@225
|
69 std::vector<double> m_sparseKernelRealValues;
|
c@225
|
70 };
|
c@225
|
71
|
c@225
|
72
|
c@225
|
73 #endif//CONSTANTQ_H
|
c@225
|
74
|