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@225
|
14 #include "dsp/maths/MathUtilities.h"
|
c@225
|
15 #include "dsp/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@225
|
31 };
|
c@225
|
32
|
c@225
|
33 class DetectionFunction
|
c@225
|
34 {
|
c@225
|
35 public:
|
c@225
|
36 double* getSpectrumMagnitude();
|
c@225
|
37 DetectionFunction( DFConfig Config );
|
c@225
|
38 virtual ~DetectionFunction();
|
c@225
|
39 double process( double* TDomain );
|
c@227
|
40 double process( double* magnitudes, double* phases );
|
c@225
|
41
|
c@225
|
42 private:
|
c@227
|
43 double runDF();
|
c@227
|
44
|
c@225
|
45 double HFC( unsigned int length, double* src);
|
c@225
|
46 double specDiff( unsigned int length, double* src);
|
c@225
|
47 double phaseDev(unsigned int length, double *srcMagnitude, double *srcPhase);
|
c@225
|
48 double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase);
|
c@237
|
49 double broadband(unsigned int length, double *srcMagnitude, double *srcPhase);
|
c@225
|
50
|
c@225
|
51 private:
|
c@225
|
52 void initialise( DFConfig Config );
|
c@225
|
53 void deInitialise();
|
c@225
|
54
|
c@225
|
55 int m_DFType;
|
c@225
|
56 unsigned int m_dataLength;
|
c@225
|
57 unsigned int m_halfLength;
|
c@237
|
58 double m_dbRise;
|
c@225
|
59
|
c@227
|
60 double* m_magHistory;
|
c@227
|
61 double* m_phaseHistory;
|
c@227
|
62 double* m_phaseHistoryOld;
|
c@225
|
63
|
c@225
|
64 double* m_DFWindowedFrame; // Array for windowed analysis frame
|
c@225
|
65 double* m_magnitude; // Magnitude of analysis frame ( frequency domain )
|
c@225
|
66 double* m_thetaAngle;// Phase of analysis frame ( frequency domain )
|
c@225
|
67
|
c@225
|
68 Window<double> *m_window;
|
c@227
|
69 PhaseVocoder* m_phaseVoc; // Phase Vocoder
|
c@225
|
70 };
|
c@225
|
71
|
c@225
|
72 #endif
|