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 double stepSecs; // DF step in seconds
|
c@225
|
27 unsigned int stepSize; // DF step in samples
|
c@225
|
28 unsigned int frameLength; // DF analysis window - usually 2*step
|
c@225
|
29 int DFType; // type of detection function ( see defines )
|
c@237
|
30 double dbRise; // only used for broadband df (and required for it)
|
c@239
|
31 bool adaptiveWhitening; // perform adaptive whitening
|
c@239
|
32 double whiteningRelaxCoeff; // if < 0, a sensible default will be used
|
c@239
|
33 double whiteningFloor; // if < 0, a sensible default will be used
|
c@225
|
34 };
|
c@225
|
35
|
c@225
|
36 class DetectionFunction
|
c@225
|
37 {
|
c@225
|
38 public:
|
c@225
|
39 double* getSpectrumMagnitude();
|
c@225
|
40 DetectionFunction( DFConfig Config );
|
c@225
|
41 virtual ~DetectionFunction();
|
c@225
|
42 double process( double* TDomain );
|
c@227
|
43 double process( double* magnitudes, double* phases );
|
c@225
|
44
|
c@225
|
45 private:
|
c@239
|
46 void whiten();
|
c@227
|
47 double runDF();
|
c@227
|
48
|
c@225
|
49 double HFC( unsigned int length, double* src);
|
c@225
|
50 double specDiff( unsigned int length, double* src);
|
c@239
|
51 double phaseDev(unsigned int length, double *srcPhase);
|
c@225
|
52 double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase);
|
c@239
|
53 double broadband(unsigned int length, double *srcMagnitude);
|
c@225
|
54
|
c@225
|
55 private:
|
c@225
|
56 void initialise( DFConfig Config );
|
c@225
|
57 void deInitialise();
|
c@225
|
58
|
c@225
|
59 int m_DFType;
|
c@225
|
60 unsigned int m_dataLength;
|
c@225
|
61 unsigned int m_halfLength;
|
c@238
|
62 double m_stepSecs;
|
c@238
|
63 unsigned int m_stepSize;
|
c@237
|
64 double m_dbRise;
|
c@239
|
65 bool m_whiten;
|
c@239
|
66 double m_whitenRelaxCoeff;
|
c@239
|
67 double m_whitenFloor;
|
c@225
|
68
|
c@227
|
69 double* m_magHistory;
|
c@227
|
70 double* m_phaseHistory;
|
c@227
|
71 double* m_phaseHistoryOld;
|
c@239
|
72 double* m_magPeaks;
|
c@225
|
73
|
c@225
|
74 double* m_DFWindowedFrame; // Array for windowed analysis frame
|
c@225
|
75 double* m_magnitude; // Magnitude of analysis frame ( frequency domain )
|
c@225
|
76 double* m_thetaAngle;// Phase of analysis frame ( frequency domain )
|
c@225
|
77
|
c@225
|
78 Window<double> *m_window;
|
c@227
|
79 PhaseVocoder* m_phaseVoc; // Phase Vocoder
|
c@225
|
80 };
|
c@225
|
81
|
c@225
|
82 #endif
|