annotate dsp/chromagram/Chromagram.h @ 73:dcb555b90924

* Key detector: when returning key strengths, use the peak value of the three underlying chromagram correlations (from 36-bin chromagram) corresponding to each key, instead of the mean. Rationale: This is the same method as used when returning the key value, and it's nice to have the same results in both returned value and plot. The peak performed better than the sum with a simple test set of triads, so it seems reasonable to change the plot to match the key output rather than the other way around. * FFT: kiss_fftr returns only the non-conjugate bins, synthesise the rest rather than leaving them (perhaps dangerously) undefined. Fixes an uninitialised data error in chromagram that could cause garbage results from key detector. * Constant Q: remove precalculated values again, I reckon they're not proving such a good tradeoff.
author cannam
date Fri, 05 Jun 2009 15:12:39 +0000
parents 6cb2b3cd5356
children e5907ae6de17
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.
cannam@0 7 This file copyright 2005-2006 Christian Landone.
cannam@0 8 All rights reserved.
cannam@0 9 */
cannam@0 10
cannam@0 11 #ifndef CHROMAGRAM_H
cannam@0 12 #define CHROMAGRAM_H
cannam@0 13
cannam@0 14 #include "dsp/transforms/FFT.h"
cannam@32 15 #include "base/Window.h"
cannam@0 16 #include "ConstantQ.h"
cannam@0 17
cannam@0 18 struct ChromaConfig{
cannam@0 19 unsigned int FS;
cannam@0 20 double min;
cannam@0 21 double max;
cannam@0 22 unsigned int BPO;
cannam@0 23 double CQThresh;
cannam@34 24 MathUtilities::NormaliseType normalise;
cannam@0 25 };
cannam@0 26
cannam@0 27 class Chromagram
cannam@0 28 {
cannam@0 29
cannam@0 30 public:
cannam@0 31 Chromagram( ChromaConfig Config );
cannam@0 32 ~Chromagram();
cannam@0 33
cannam@32 34 double* process( const double *data ); // time domain
cannam@32 35 double* process( const double *real, const double *imag ); // frequency domain
cannam@0 36 void unityNormalise( double* src );
cannam@0 37
cannam@0 38 // Complex arithmetic
cannam@0 39 double kabs( double real, double imag );
cannam@0 40
cannam@0 41 // Results
cannam@0 42 unsigned int getK() { return m_uK;}
cannam@0 43 unsigned int getFrameSize() { return m_frameSize; }
cannam@0 44 unsigned int getHopSize() { return m_hopSize; }
cannam@0 45
cannam@0 46 private:
cannam@0 47 int initialise( ChromaConfig Config );
cannam@0 48 int deInitialise();
cannam@32 49
cannam@32 50 Window<double> *m_window;
cannam@32 51 double *m_windowbuf;
cannam@0 52
cannam@0 53 double* m_chromadata;
cannam@0 54 double m_FMin;
cannam@0 55 double m_FMax;
cannam@0 56 unsigned int m_BPO;
cannam@0 57 unsigned int m_uK;
cannam@0 58
cannam@34 59 MathUtilities::NormaliseType m_normalise;
cannam@0 60
cannam@0 61 unsigned int m_frameSize;
cannam@0 62 unsigned int m_hopSize;
cannam@0 63
cannam@64 64 FFTReal* m_FFT;
cannam@0 65 ConstantQ* m_ConstantQ;
cannam@0 66
cannam@0 67 double* m_FFTRe;
cannam@0 68 double* m_FFTIm;
cannam@0 69 double* m_CQRe;
cannam@0 70 double* m_CQIm;
cannam@0 71
cannam@51 72 bool m_skGenerated;
cannam@0 73 };
cannam@0 74
cannam@0 75 #endif