comparison dsp/onsets/DetectionFunction.h @ 505:930b5b0f707d

Merge branch 'codestyle-and-tidy'
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 05 Jun 2019 12:55:15 +0100
parents af5b7ef02aa7
children
comparison
equal deleted inserted replaced
471:e3335cb213da 505:930b5b0f707d
11 published by the Free Software Foundation; either version 2 of the 11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file 12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #ifndef DETECTIONFUNCTION_H 16 #ifndef QM_DSP_DETECTIONFUNCTION_H
17 #define DETECTIONFUNCTION_H 17 #define QM_DSP_DETECTIONFUNCTION_H
18 18
19 #include "maths/MathUtilities.h" 19 #include "maths/MathUtilities.h"
20 #include "maths/MathAliases.h" 20 #include "maths/MathAliases.h"
21 #include "dsp/phasevocoder/PhaseVocoder.h" 21 #include "dsp/phasevocoder/PhaseVocoder.h"
22 #include "base/Window.h" 22 #include "base/Window.h"
26 #define DF_PHASEDEV (3) 26 #define DF_PHASEDEV (3)
27 #define DF_COMPLEXSD (4) 27 #define DF_COMPLEXSD (4)
28 #define DF_BROADBAND (5) 28 #define DF_BROADBAND (5)
29 29
30 struct DFConfig{ 30 struct DFConfig{
31 unsigned int stepSize; // DF step in samples 31 int stepSize; // DF step in samples
32 unsigned int frameLength; // DF analysis window - usually 2*step. Must be even! 32 int frameLength; // DF analysis window - usually 2*step. Must be even!
33 int DFType; // type of detection function ( see defines ) 33 int DFType; // type of detection function ( see defines )
34 double dbRise; // only used for broadband df (and required for it) 34 double dbRise; // only used for broadband df (and required for it)
35 bool adaptiveWhitening; // perform adaptive whitening 35 bool adaptiveWhitening; // perform adaptive whitening
36 double whiteningRelaxCoeff; // if < 0, a sensible default will be used 36 double whiteningRelaxCoeff; // if < 0, a sensible default will be used
37 double whiteningFloor; // if < 0, a sensible default will be used 37 double whiteningFloor; // if < 0, a sensible default will be used
39 39
40 class DetectionFunction 40 class DetectionFunction
41 { 41 {
42 public: 42 public:
43 double* getSpectrumMagnitude(); 43 double* getSpectrumMagnitude();
44 DetectionFunction( DFConfig Config ); 44 DetectionFunction( DFConfig config );
45 virtual ~DetectionFunction(); 45 virtual ~DetectionFunction();
46 46
47 /** 47 /**
48 * Process a single time-domain frame of audio, provided as 48 * Process a single time-domain frame of audio, provided as
49 * frameLength samples. 49 * frameLength samples.
58 58
59 private: 59 private:
60 void whiten(); 60 void whiten();
61 double runDF(); 61 double runDF();
62 62
63 double HFC( unsigned int length, double* src); 63 double HFC(int length, double* src);
64 double specDiff( unsigned int length, double* src); 64 double specDiff(int length, double* src);
65 double phaseDev(unsigned int length, double *srcPhase); 65 double phaseDev(int length, double *srcPhase);
66 double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase); 66 double complexSD(int length, double *srcMagnitude, double *srcPhase);
67 double broadband(unsigned int length, double *srcMagnitude); 67 double broadband(int length, double *srcMagnitude);
68 68
69 private: 69 private:
70 void initialise( DFConfig Config ); 70 void initialise( DFConfig Config );
71 void deInitialise(); 71 void deInitialise();
72 72
73 int m_DFType; 73 int m_DFType;
74 unsigned int m_dataLength; 74 int m_dataLength;
75 unsigned int m_halfLength; 75 int m_halfLength;
76 unsigned int m_stepSize; 76 int m_stepSize;
77 double m_dbRise; 77 double m_dbRise;
78 bool m_whiten; 78 bool m_whiten;
79 double m_whitenRelaxCoeff; 79 double m_whitenRelaxCoeff;
80 double m_whitenFloor; 80 double m_whitenFloor;
81 81
88 double* m_magnitude; // Magnitude of analysis frame ( frequency domain ) 88 double* m_magnitude; // Magnitude of analysis frame ( frequency domain )
89 double* m_thetaAngle;// Phase of analysis frame ( frequency domain ) 89 double* m_thetaAngle;// Phase of analysis frame ( frequency domain )
90 double* m_unwrapped; // Unwrapped phase of analysis frame 90 double* m_unwrapped; // Unwrapped phase of analysis frame
91 91
92 Window<double> *m_window; 92 Window<double> *m_window;
93 PhaseVocoder* m_phaseVoc; // Phase Vocoder 93 PhaseVocoder* m_phaseVoc; // Phase Vocoder
94 }; 94 };
95 95
96 #endif 96 #endif