BTrack - A Real-Time Beat Tracker
 All Classes Files Functions Enumerations
OnsetDetectionFunction.h
Go to the documentation of this file.
1 //=======================================================================
20 //=======================================================================
21 
22 #ifndef __ONSETDETECTIONFUNCTION_H
23 #define __ONSETDETECTIONFUNCTION_H
24 
25 #include "fftw3.h"
26 
27 //=======================================================================
30 {
31  EnergyEnvelope,
32  EnergyDifference,
33  SpectralDifference,
34  SpectralDifferenceHWR,
35  PhaseDeviation,
36  ComplexSpectralDifference,
37  ComplexSpectralDifferenceHWR,
38  HighFrequencyContent,
39  HighFrequencySpectralDifference,
40  HighFrequencySpectralDifferenceHWR
41 };
42 
43 //=======================================================================
46 {
47  RectangularWindow,
48  HanningWindow,
49  HammingWindow,
50  BlackmanWindow,
51  TukeyWindow
52 };
53 
55 {
56 public:
57 
64  OnsetDetectionFunction(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType);
65 
68 
70  void initialise(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType);
71 
73  double calculateOnsetDetectionFunctionSample(double *buffer);
74 
76  void setOnsetDetectionFunctionType(int onsetDetectionFunctionType_);
77 
78 private:
79 
81  void performFFT();
82 
83  //=======================================================================
85  double energyEnvelope();
86 
88  double energyDifference();
89 
91  double spectralDifference();
92 
94  double spectralDifferenceHWR();
95 
97  double phaseDeviation();
98 
100  double complexSpectralDifference();
101 
103  double complexSpectralDifferenceHWR();
104 
106  double highFrequencyContent();
107 
109  double highFrequencySpectralDifference();
110 
112  double highFrequencySpectralDifferenceHWR();
113 
114  //=======================================================================
116  void calculateRectangularWindow();
117 
119  void calculateHanningWindow();
120 
122  void calclulateHammingWindow();
123 
125  void calculateBlackmanWindow();
126 
128  void calculateTukeyWindow();
129 
130  //=======================================================================
132  double princarg(double phaseVal);
133 
134 
135  double pi;
137  int frameSize;
138  int hopSize;
139  int onsetDetectionFunctionType;
141  fftw_plan p;
142  fftw_complex *complexIn;
143  fftw_complex *complexOut;
145  int initialised;
147  double *frame;
148  double *window;
150  double prevEnergySum;
152  double *magSpec;
153  double *prevMagSpec;
155  double *phase;
156  double *prevPhase;
157  double *prevPhase2;
159 };
160 
161 
162 #endif