annotate dsp/chromagram/ConstantQ.h @ 114:f6ccde089491 pvoc

Tidy real-to-complex FFT -- forward and inverse have different arguments, so make them separate functions; document
author Chris Cannam
date Wed, 02 Oct 2013 15:04:38 +0100
parents e5907ae6de17
children 50a97c8d52ed
rev   line source
cannam@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@0 2
cannam@0 3 /*
cannam@0 4 QM DSP Library
cannam@0 5
cannam@0 6 Centre for Digital Music, Queen Mary, University of London.
Chris@84 7 This file 2005-2006 Christian Landone.
Chris@84 8
Chris@84 9 This program is free software; you can redistribute it and/or
Chris@84 10 modify it under the terms of the GNU General Public License as
Chris@84 11 published by the Free Software Foundation; either version 2 of the
Chris@84 12 License, or (at your option) any later version. See the file
Chris@84 13 COPYING included with this distribution for more information.
cannam@0 14 */
cannam@0 15
cannam@0 16 #ifndef CONSTANTQ_H
cannam@0 17 #define CONSTANTQ_H
cannam@0 18
cannam@0 19 #include <vector>
cannam@16 20 #include "maths/MathAliases.h"
cannam@16 21 #include "maths/MathUtilities.h"
cannam@0 22
cannam@0 23 struct CQConfig{
cannam@20 24 unsigned int FS; // samplerate
cannam@20 25 double min; // minimum frequency
cannam@20 26 double max; // maximum frequency
cannam@20 27 unsigned int BPO; // bins per octave
cannam@20 28 double CQThresh; // threshold
cannam@0 29 };
cannam@0 30
cannam@0 31 class ConstantQ {
cannam@0 32
cannam@0 33 //public functions incl. sparsekernel so can keep out of loop in main
cannam@0 34 public:
cannam@32 35 void process( const double* FFTRe, const double* FFTIm,
cannam@32 36 double* CQRe, double* CQIm );
cannam@0 37
cannam@0 38 ConstantQ( CQConfig Config );
cannam@0 39 ~ConstantQ();
cannam@0 40
cannam@32 41 double* process( const double* FFTData );
cannam@0 42
cannam@0 43 void sparsekernel();
cannam@0 44
cannam@0 45 double hamming(int len, int n) {
cannam@0 46 double out = 0.54 - 0.46*cos(2*PI*n/len);
cannam@0 47 return(out);
cannam@0 48 }
cannam@0 49
cannam@0 50 int getnumwin() { return m_numWin;}
cannam@0 51 double getQ() { return m_dQ;}
cannam@0 52 int getK() {return m_uK ;}
cannam@0 53 int getfftlength() { return m_FFTLength;}
cannam@0 54 int gethop() { return m_hop;}
cannam@0 55
cannam@0 56 private:
cannam@0 57 void initialise( CQConfig Config );
cannam@0 58 void deInitialise();
cannam@0 59
cannam@0 60 double* m_CQdata;
cannam@0 61 unsigned int m_FS;
cannam@0 62 double m_FMin;
cannam@0 63 double m_FMax;
cannam@0 64 double m_dQ;
cannam@0 65 double m_CQThresh;
cannam@0 66 unsigned int m_numWin;
cannam@0 67 unsigned int m_hop;
cannam@0 68 unsigned int m_BPO;
cannam@0 69 unsigned int m_FFTLength;
cannam@0 70 unsigned int m_uK;
cannam@51 71
cannam@51 72 struct SparseKernel {
cannam@51 73 std::vector<unsigned> is;
cannam@51 74 std::vector<unsigned> js;
cannam@51 75 std::vector<double> imag;
cannam@51 76 std::vector<double> real;
cannam@51 77 };
cannam@51 78
cannam@51 79 SparseKernel *m_sparseKernel;
cannam@0 80 };
cannam@0 81
cannam@0 82
cannam@0 83 #endif//CONSTANTQ_H
cannam@0 84