annotate dsp/chromagram/ConstantQ.h @ 276:4c901426b9f3

* Do not calculate CQ sparse kernel when chromagram is constructed: only when it's actually used * Pre-calculate CQ sparse kernels in the sizes required for the default configurations of some of our transforms
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 04 Dec 2008 11:59:29 +0000
parents 9619d6995b73
children e5907ae6de17
rev   line source
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@276 66
c@276 67 struct SparseKernel {
c@276 68 std::vector<unsigned> is;
c@276 69 std::vector<unsigned> js;
c@276 70 std::vector<double> imag;
c@276 71 std::vector<double> real;
c@276 72 };
c@276 73
c@276 74 SparseKernel *m_sparseKernel;
c@225 75 };
c@225 76
c@225 77
c@225 78 #endif//CONSTANTQ_H
c@225 79