annotate dsp/keydetection/GetKeyMode.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 b4921bfd2aea
children 715f779d0b4f
rev   line source
cannam@7 1 /*
cannam@7 2 * Author: c.landone
cannam@7 3 * Description:
cannam@7 4 *
cannam@7 5 * Syntax: C++
cannam@7 6 *
cannam@7 7 * Copyright (c) 2005 Centre for Digital Music ( C4DM )
cannam@7 8 * Queen Mary Univesrity of London
cannam@7 9 *
cannam@7 10 *
cannam@7 11 * This program is not free software; you cannot redistribute it
cannam@7 12 * without the explicit authorization from the centre for digital music,
cannam@7 13 * queen mary university of london
cannam@7 14 *
cannam@7 15 */
cannam@7 16
cannam@40 17 #ifndef GETKEYMODE_H
cannam@7 18 #define GETKEYMODE_H
cannam@7 19
cannam@7 20
cannam@7 21 #include "dsp/rateconversion/Decimator.h"
cannam@7 22 #include "dsp/chromagram/Chromagram.h"
cannam@7 23
cannam@7 24
cannam@7 25 class GetKeyMode
cannam@7 26 {
cannam@7 27 public:
cannam@9 28 GetKeyMode( int sampleRate, float tuningFrequency,
cannam@9 29 double hpcpAverage, double medianAverage );
cannam@7 30
cannam@7 31 virtual ~GetKeyMode();
cannam@7 32
cannam@7 33 int process( double* PCMData );
cannam@7 34
cannam@7 35 double krumCorr( double* pData1, double* pData2, unsigned int length );
cannam@7 36
cannam@7 37 unsigned int getBlockSize() { return m_ChromaFrameSize*m_DecimationFactor; }
cannam@7 38 unsigned int getHopSize() { return m_ChromaHopSize*m_DecimationFactor; }
cannam@7 39
cannam@7 40 double* getChroma() { return m_ChrPointer; }
cannam@7 41 unsigned int getChromaSize() { return m_BPO; }
cannam@7 42
cannam@7 43 double* getMeanHPCP() { return m_MeanHPCP; }
cannam@7 44
cannam@40 45 double *getKeyStrengths() { return m_keyStrengths; }
cannam@40 46
cannam@43 47 bool isModeMinor( int key );
cannam@7 48
cannam@7 49 protected:
cannam@7 50
cannam@7 51 double m_hpcpAverage;
cannam@7 52 double m_medianAverage;
cannam@7 53 unsigned int m_DecimationFactor;
cannam@7 54
cannam@7 55 //Decimator (fixed)
cannam@7 56 Decimator* m_Decimator;
cannam@7 57
cannam@7 58 //chroma configuration
cannam@9 59 ChromaConfig m_ChromaConfig;
cannam@7 60
cannam@7 61 //Chromagram object
cannam@7 62 Chromagram* m_Chroma;
cannam@7 63
cannam@7 64 //Chromagram output pointer
cannam@7 65 double* m_ChrPointer;
cannam@7 66
cannam@7 67 //Framesize
cannam@7 68 unsigned int m_ChromaFrameSize;
cannam@7 69 //Hop
cannam@7 70 unsigned int m_ChromaHopSize;
cannam@7 71 //Bins per octave
cannam@7 72 unsigned int m_BPO;
cannam@7 73
cannam@7 74
cannam@7 75 unsigned int m_ChromaBuffersize;
cannam@7 76 unsigned int m_MedianWinsize;
cannam@7 77
cannam@7 78 unsigned int m_bufferindex;
cannam@7 79 unsigned int m_ChromaBufferFilling;
cannam@7 80 unsigned int m_MedianBufferFilling;
cannam@7 81
cannam@7 82
cannam@7 83 double* m_DecimatedBuffer;
cannam@7 84 double* m_ChromaBuffer;
cannam@7 85 double* m_MeanHPCP;
cannam@7 86
cannam@7 87 double* m_MajCorr;
cannam@7 88 double* m_MinCorr;
cannam@7 89 double* m_Keys;
cannam@7 90 int* m_MedianFilterBuffer;
cannam@7 91 int* m_SortedBuffer;
cannam@40 92
cannam@40 93 double *m_keyStrengths;
cannam@7 94 };
cannam@7 95
cannam@7 96 #endif // !defined GETKEYMODE_H