comparison dsp/onsets/DetectionFunction.h @ 14:68801ecbab6a

* add adaptive whitening and simple power metric
author cannam
date Thu, 09 Aug 2007 16:30:26 +0000
parents f2b5c4251bf3
children 2e3f5d2d62c1
comparison
equal deleted inserted replaced
13:f2b5c4251bf3 14:68801ecbab6a
19 #define DF_HFC (1) 19 #define DF_HFC (1)
20 #define DF_SPECDIFF (2) 20 #define DF_SPECDIFF (2)
21 #define DF_PHASEDEV (3) 21 #define DF_PHASEDEV (3)
22 #define DF_COMPLEXSD (4) 22 #define DF_COMPLEXSD (4)
23 #define DF_BROADBAND (5) 23 #define DF_BROADBAND (5)
24 #define DF_POWER (6)
24 25
25 struct DFConfig{ 26 struct DFConfig{
26 double stepSecs; // DF step in seconds 27 double stepSecs; // DF step in seconds
27 unsigned int stepSize; // DF step in samples 28 unsigned int stepSize; // DF step in samples
28 unsigned int frameLength; // DF analysis window - usually 2*step 29 unsigned int frameLength; // DF analysis window - usually 2*step
29 int DFType; // type of detection function ( see defines ) 30 int DFType; // type of detection function ( see defines )
30 double dbRise; // only used for broadband df (and required for it) 31 double dbRise; // only used for broadband df (and required for it)
32 bool adaptiveWhitening; // perform adaptive whitening
33 double whiteningRelaxCoeff; // if < 0, a sensible default will be used
34 double whiteningFloor; // if < 0, a sensible default will be used
31 }; 35 };
32 36
33 class DetectionFunction 37 class DetectionFunction
34 { 38 {
35 public: 39 public:
38 virtual ~DetectionFunction(); 42 virtual ~DetectionFunction();
39 double process( double* TDomain ); 43 double process( double* TDomain );
40 double process( double* magnitudes, double* phases ); 44 double process( double* magnitudes, double* phases );
41 45
42 private: 46 private:
47 void whiten();
43 double runDF(); 48 double runDF();
44 49
45 double HFC( unsigned int length, double* src); 50 double HFC( unsigned int length, double* src);
46 double specDiff( unsigned int length, double* src); 51 double specDiff( unsigned int length, double* src);
47 double phaseDev(unsigned int length, double *srcMagnitude, double *srcPhase); 52 double phaseDev(unsigned int length, double *srcPhase);
48 double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase); 53 double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase);
49 double broadband(unsigned int length, double *srcMagnitude, double *srcPhase); 54 double broadband(unsigned int length, double *srcMagnitude);
55 double power(unsigned int length, double *src);
50 56
51 private: 57 private:
52 void initialise( DFConfig Config ); 58 void initialise( DFConfig Config );
53 void deInitialise(); 59 void deInitialise();
54 60
56 unsigned int m_dataLength; 62 unsigned int m_dataLength;
57 unsigned int m_halfLength; 63 unsigned int m_halfLength;
58 double m_stepSecs; 64 double m_stepSecs;
59 unsigned int m_stepSize; 65 unsigned int m_stepSize;
60 double m_dbRise; 66 double m_dbRise;
67 bool m_whiten;
68 double m_whitenRelaxCoeff;
69 double m_whitenFloor;
61 70
62 double* m_magHistory; 71 double* m_magHistory;
63 double* m_phaseHistory; 72 double* m_phaseHistory;
64 double* m_phaseHistoryOld; 73 double* m_phaseHistoryOld;
74 double* m_magPeaks;
65 75
66 double* m_DFWindowedFrame; // Array for windowed analysis frame 76 double* m_DFWindowedFrame; // Array for windowed analysis frame
67 double* m_magnitude; // Magnitude of analysis frame ( frequency domain ) 77 double* m_magnitude; // Magnitude of analysis frame ( frequency domain )
68 double* m_thetaAngle;// Phase of analysis frame ( frequency domain ) 78 double* m_thetaAngle;// Phase of analysis frame ( frequency domain )
69 79