add queen mary DSP library
[ardour2.git] / libs / qm-dsp / dsp / chromagram / ConstantQ.h
blobc06f60a9d010f07a498b9e1654b957a631e53e27
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
3 /*
4 QM DSP Library
6 Centre for Digital Music, Queen Mary, University of London.
7 This file 2005-2006 Christian Landone.
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
16 #ifndef CONSTANTQ_H
17 #define CONSTANTQ_H
19 #include <vector>
20 #include "maths/MathAliases.h"
21 #include "maths/MathUtilities.h"
23 struct CQConfig{
24 unsigned int FS; // samplerate
25 double min; // minimum frequency
26 double max; // maximum frequency
27 unsigned int BPO; // bins per octave
28 double CQThresh; // threshold
31 class ConstantQ {
33 //public functions incl. sparsekernel so can keep out of loop in main
34 public:
35 void process( const double* FFTRe, const double* FFTIm,
36 double* CQRe, double* CQIm );
38 ConstantQ( CQConfig Config );
39 ~ConstantQ();
41 double* process( const double* FFTData );
43 void sparsekernel();
45 double hamming(int len, int n) {
46 double out = 0.54 - 0.46*cos(2*PI*n/len);
47 return(out);
50 int getnumwin() { return m_numWin;}
51 double getQ() { return m_dQ;}
52 int getK() {return m_uK ;}
53 int getfftlength() { return m_FFTLength;}
54 int gethop() { return m_hop;}
56 private:
57 void initialise( CQConfig Config );
58 void deInitialise();
60 double* m_CQdata;
61 unsigned int m_FS;
62 double m_FMin;
63 double m_FMax;
64 double m_dQ;
65 double m_CQThresh;
66 unsigned int m_numWin;
67 unsigned int m_hop;
68 unsigned int m_BPO;
69 unsigned int m_FFTLength;
70 unsigned int m_uK;
72 struct SparseKernel {
73 std::vector<unsigned> is;
74 std::vector<unsigned> js;
75 std::vector<double> imag;
76 std::vector<double> real;
79 SparseKernel *m_sparseKernel;
83 #endif//CONSTANTQ_H