annotate dsp/onsets/DetectionFunction.h @ 298:255e431ae3d4

* 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 Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 05 Jun 2009 15:12:39 +0000
parents 9c403afdd9e9
children e5907ae6de17
rev   line source
c@225 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@225 2
c@225 3 /*
c@225 4 QM DSP Library
c@225 5
c@225 6 Centre for Digital Music, Queen Mary, University of London.
c@225 7 This file copyright 2005-2006 Christian Landone.
c@225 8 All rights reserved.
c@225 9 */
c@225 10
c@225 11 #ifndef DETECTIONFUNCTION_H
c@225 12 #define DETECTIONFUNCTION_H
c@225 13
c@241 14 #include "maths/MathUtilities.h"
c@241 15 #include "maths/MathAliases.h"
c@225 16 #include "dsp/phasevocoder/PhaseVocoder.h"
c@225 17 #include "base/Window.h"
c@225 18
c@225 19 #define DF_HFC (1)
c@225 20 #define DF_SPECDIFF (2)
c@225 21 #define DF_PHASEDEV (3)
c@225 22 #define DF_COMPLEXSD (4)
c@237 23 #define DF_BROADBAND (5)
c@225 24
c@225 25 struct DFConfig{
c@225 26 unsigned int stepSize; // DF step in samples
c@225 27 unsigned int frameLength; // DF analysis window - usually 2*step
c@225 28 int DFType; // type of detection function ( see defines )
c@237 29 double dbRise; // only used for broadband df (and required for it)
c@239 30 bool adaptiveWhitening; // perform adaptive whitening
c@239 31 double whiteningRelaxCoeff; // if < 0, a sensible default will be used
c@239 32 double whiteningFloor; // if < 0, a sensible default will be used
c@225 33 };
c@225 34
c@225 35 class DetectionFunction
c@225 36 {
c@225 37 public:
c@225 38 double* getSpectrumMagnitude();
c@225 39 DetectionFunction( DFConfig Config );
c@225 40 virtual ~DetectionFunction();
c@280 41 double process( const double* TDomain );
c@280 42 double process( const double* magnitudes, const double* phases );
c@225 43
c@225 44 private:
c@239 45 void whiten();
c@227 46 double runDF();
c@227 47
c@225 48 double HFC( unsigned int length, double* src);
c@225 49 double specDiff( unsigned int length, double* src);
c@239 50 double phaseDev(unsigned int length, double *srcPhase);
c@225 51 double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase);
c@239 52 double broadband(unsigned int length, double *srcMagnitude);
c@225 53
c@225 54 private:
c@225 55 void initialise( DFConfig Config );
c@225 56 void deInitialise();
c@225 57
c@225 58 int m_DFType;
c@225 59 unsigned int m_dataLength;
c@225 60 unsigned int m_halfLength;
c@238 61 unsigned int m_stepSize;
c@237 62 double m_dbRise;
c@239 63 bool m_whiten;
c@239 64 double m_whitenRelaxCoeff;
c@239 65 double m_whitenFloor;
c@225 66
c@227 67 double* m_magHistory;
c@227 68 double* m_phaseHistory;
c@227 69 double* m_phaseHistoryOld;
c@239 70 double* m_magPeaks;
c@225 71
c@225 72 double* m_DFWindowedFrame; // Array for windowed analysis frame
c@225 73 double* m_magnitude; // Magnitude of analysis frame ( frequency domain )
c@225 74 double* m_thetaAngle;// Phase of analysis frame ( frequency domain )
c@225 75
c@225 76 Window<double> *m_window;
c@227 77 PhaseVocoder* m_phaseVoc; // Phase Vocoder
c@225 78 };
c@225 79
c@225 80 #endif