comparison dsp/onsets/DetectionFunction.h @ 0:d7116e3183f8

* Queen Mary C++ DSP library
author cannam
date Wed, 05 Apr 2006 17:35:59 +0000
parents
children c539af5259da
comparison
equal deleted inserted replaced
-1:000000000000 0:d7116e3183f8
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 QM DSP Library
5
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2005-2006 Christian Landone.
8 All rights reserved.
9 */
10
11 #ifndef DETECTIONFUNCTION_H
12 #define DETECTIONFUNCTION_H
13
14 #include "dsp/maths/MathUtilities.h"
15 #include "dsp/maths/MathAliases.h"
16 #include "dsp/phasevocoder/PhaseVocoder.h"
17 #include "base/Window.h"
18
19 #define DF_HFC (1)
20 #define DF_SPECDIFF (2)
21 #define DF_PHASEDEV (3)
22 #define DF_COMPLEXSD (4)
23
24 struct DFConfig{
25 double stepSecs; // DF step in seconds
26 unsigned int stepSize; // DF step in samples
27 unsigned int frameLength; // DF analysis window - usually 2*step
28 int DFType; // type of detection function ( see defines )
29 };
30
31 class DetectionFunction
32 {
33 public:
34 double* getSpectrumMagnitude();
35 DetectionFunction( DFConfig Config );
36 virtual ~DetectionFunction();
37 double process( double* TDomain );
38
39 private:
40 double HFC( unsigned int length, double* src);
41 double specDiff( unsigned int length, double* src);
42 double phaseDev(unsigned int length, double *srcMagnitude, double *srcPhase);
43 double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase);
44
45 private:
46 void initialise( DFConfig Config );
47 void deInitialise();
48
49 int m_DFType;
50 unsigned int m_dataLength;
51 unsigned int m_halfLength;
52
53 double* magHistory;
54 double* phaseHistory;
55 double* phaseHistoryOld;
56
57 double* m_DFWindowedFrame; // Array for windowed analysis frame
58 double* m_magnitude; // Magnitude of analysis frame ( frequency domain )
59 double* m_thetaAngle;// Phase of analysis frame ( frequency domain )
60
61
62 vector < ComplexData > meas ;
63
64 ComplexData j;
65
66 Window<double> *m_window;
67
68 PhaseVocoder* m_phaseVoc; // Phase Vocoder
69
70 };
71
72 #endif