qm-dsp  1.8
ConstantQ.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     QM DSP Library
00005 
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file 2005-2006 Christian Landone.
00008 
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef CONSTANTQ_H
00017 #define CONSTANTQ_H
00018 
00019 #include <vector>
00020 #include "maths/MathAliases.h"
00021 #include "maths/MathUtilities.h"
00022 
00023 struct CQConfig{
00024     unsigned int FS;   // samplerate
00025     double min;        // minimum frequency
00026     double max;        // maximum frequency
00027     unsigned int BPO;  // bins per octave
00028     double CQThresh;   // threshold
00029 };
00030 
00031 class ConstantQ {
00032         
00033 //public functions incl. sparsekernel so can keep out of loop in main
00034 public:
00035     void process( const double* FFTRe, const double* FFTIm,
00036                   double* CQRe, double* CQIm );
00037 
00038     ConstantQ( CQConfig Config );
00039     ~ConstantQ();
00040 
00041     double* process( const double* FFTData );
00042 
00043     void sparsekernel();
00044 
00045     double hamming(int len, int n) {
00046         double out = 0.54 - 0.46*cos(2*PI*n/len);
00047         return(out);
00048     }
00049         
00050     int getnumwin() { return m_numWin;}
00051     double getQ() { return m_dQ;}
00052     int getK() {return m_uK ;}
00053     int getfftlength() { return m_FFTLength;}
00054     int gethop() { return m_hop;}
00055 
00056 private:
00057     void initialise( CQConfig Config );
00058     void deInitialise();
00059         
00060     double* m_CQdata;
00061     unsigned int m_FS;
00062     double m_FMin;
00063     double m_FMax;
00064     double m_dQ;
00065     double m_CQThresh;
00066     unsigned int m_numWin;
00067     unsigned int m_hop;
00068     unsigned int m_BPO;
00069     unsigned int m_FFTLength;
00070     unsigned int m_uK;
00071 
00072     struct SparseKernel {
00073         std::vector<unsigned> is;
00074         std::vector<unsigned> js;
00075         std::vector<double> imag;
00076         std::vector<double> real;
00077     };
00078 
00079     SparseKernel *m_sparseKernel;
00080 };
00081 
00082 
00083 #endif//CONSTANTQ_H
00084