c@225: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@225: c@225: /* c@225: QM DSP Library c@225: c@225: Centre for Digital Music, Queen Mary, University of London. c@309: This file 2005-2006 Christian Landone. c@309: c@309: This program is free software; you can redistribute it and/or c@309: modify it under the terms of the GNU General Public License as c@309: published by the Free Software Foundation; either version 2 of the c@309: License, or (at your option) any later version. See the file c@309: COPYING included with this distribution for more information. c@225: */ c@225: c@225: #ifndef CHROMAGRAM_H c@225: #define CHROMAGRAM_H c@225: c@225: #include "dsp/transforms/FFT.h" c@257: #include "base/Window.h" c@225: #include "ConstantQ.h" c@225: cannam@465: struct ChromaConfig { cannam@465: double FS; c@225: double min; c@225: double max; c@414: int BPO; c@225: double CQThresh; c@259: MathUtilities::NormaliseType normalise; c@225: }; c@225: c@225: class Chromagram c@225: { c@225: c@225: public: c@225: Chromagram( ChromaConfig Config ); c@225: ~Chromagram(); cannam@467: cannam@467: /** cannam@467: * Process a time-domain input signal of length equal to cannam@467: * getFrameSize(). cannam@467: * cannam@467: * The returned buffer contains the chromagram values indexed by cannam@467: * bin, with the number of values corresponding to the BPO field cannam@467: * in the ChromaConfig supplied at construction. It is owned by cannam@467: * the Chromagram object and is reused from one process call to cannam@467: * the next. cannam@467: */ cannam@467: double *process(const double *data); cannam@467: cannam@467: /** cannam@467: * Process a frequency-domain input signal generated from a cannam@467: * time-domain signal of length equal to getFrameSize() that has cannam@467: * been windowed and "fftshifted" to place the zero index in the cannam@467: * centre of the frame. The real and imag buffers must each cannam@467: * contain the full getFrameSize() frequency bins. cannam@467: * cannam@467: * The returned buffer contains the chromagram values indexed by cannam@467: * bin, with the number of values corresponding to the BPO field cannam@467: * in the ChromaConfig supplied at construction. It is owned by cannam@467: * the Chromagram object and is reused from one process call to cannam@467: * the next. cannam@467: */ cannam@467: double *process(const double *real, const double *imag); cannam@467: cannam@467: void unityNormalise(double* src); c@225: c@225: // Complex arithmetic c@225: double kabs( double real, double imag ); c@225: c@225: // Results c@414: int getK() { return m_uK;} c@414: int getFrameSize() { return m_frameSize; } c@414: int getHopSize() { return m_hopSize; } c@414: c@225: private: c@225: int initialise( ChromaConfig Config ); c@225: int deInitialise(); c@257: c@257: Window *m_window; c@257: double *m_windowbuf; c@225: c@225: double* m_chromadata; c@225: double m_FMin; c@225: double m_FMax; c@414: int m_BPO; c@414: int m_uK; c@225: c@259: MathUtilities::NormaliseType m_normalise; c@225: c@414: int m_frameSize; c@414: int m_hopSize; c@225: c@289: FFTReal* m_FFT; c@225: ConstantQ* m_ConstantQ; c@225: c@225: double* m_FFTRe; c@225: double* m_FFTIm; c@225: double* m_CQRe; c@225: double* m_CQIm; c@225: c@276: bool m_skGenerated; c@225: }; c@225: c@225: #endif