comparison src/OnsetDetectionFunction.h @ 23:92ee4ace9d46 develop

Did more commenting. Added documentation.
author Adam <adamstark.uk@gmail.com>
date Sat, 25 Jan 2014 18:17:51 +0000
parents a8e3e95d14e4
children deb49a2590f3
comparison
equal deleted inserted replaced
22:a8e3e95d14e4 23:92ee4ace9d46
23 #define __ONSETDETECTIONFUNCTION_H 23 #define __ONSETDETECTIONFUNCTION_H
24 24
25 #include "fftw3.h" 25 #include "fftw3.h"
26 26
27 //======================================================================= 27 //=======================================================================
28 /** The type of onset detection function to calculate */
28 enum OnsetDetectionFunctionType 29 enum OnsetDetectionFunctionType
29 { 30 {
30 EnergyEnvelope, 31 EnergyEnvelope,
31 EnergyDifference, 32 EnergyDifference,
32 SpectralDifference, 33 SpectralDifference,
38 HighFrequencySpectralDifference, 39 HighFrequencySpectralDifference,
39 HighFrequencySpectralDifferenceHWR 40 HighFrequencySpectralDifferenceHWR
40 }; 41 };
41 42
42 //======================================================================= 43 //=======================================================================
44 /** The type of window to use when calculating onset detection function samples */
43 enum WindowType 45 enum WindowType
44 { 46 {
45 RectangularWindow, 47 RectangularWindow,
46 HanningWindow, 48 HanningWindow,
47 HammingWindow, 49 HammingWindow,
51 53
52 class OnsetDetectionFunction 54 class OnsetDetectionFunction
53 { 55 {
54 public: 56 public:
55 57
56 /** Constructor */ 58 /** Constructor
59 * @param hopSize_ the hop size in audio samples
60 * @param frameSize_ the frame size in audio samples
61 * @param onsetDetectionFunctionType_ the type of onset detection function to use - (see OnsetDetectionFunctionType)
62 * @param windowType the type of window to use (see WindowType)
63 */
57 OnsetDetectionFunction(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType); 64 OnsetDetectionFunction(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType);
58 65
59 /** Destructor */ 66 /** Destructor */
60 ~OnsetDetectionFunction(); 67 ~OnsetDetectionFunction();
61 68
62 /** Initialisation Function */ 69 /** Initialisation Function
70 * @param hopSize_ the hop size in audio samples
71 * @param frameSize_ the frame size in audio samples
72 * @param onsetDetectionFunctionType_ the type of onset detection function to use - (see OnsetDetectionFunctionType)
73 * @param windowType the type of window to use (see WindowType)
74 */
63 void initialise(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType); 75 void initialise(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType);
64 76
65 /** process input frame and calculate detection function sample */ 77 /** Process input frame and calculate detection function sample
78 * @param buffer a pointer to an array containing the audio samples to be processed
79 * @returns the onset detection function sample
80 */
66 double calculateOnsetDetectionFunctionSample(double *buffer); 81 double calculateOnsetDetectionFunctionSample(double *buffer);
67 82
68 /** set the detection function type */ 83 /** Set the detection function type
84 * @param onsetDetectionFunctionType_ the type of onset detection function to use - (see OnsetDetectionFunctionType)
85 */
69 void setOnsetDetectionFunctionType(int onsetDetectionFunctionType_); 86 void setOnsetDetectionFunctionType(int onsetDetectionFunctionType_);
70 87
71 private: 88 private:
72 89
73 /** perform the FFT on the data in 'frame' */ 90 /** Perform the FFT on the data in 'frame' */
74 void performFFT(); 91 void performFFT();
75 92
76 //======================================================================= 93 //=======================================================================
77 /** calculate energy envelope detection function sample */ 94 /** Calculate energy envelope detection function sample */
78 double energyEnvelope(); 95 double energyEnvelope();
79 96
80 /** calculate energy difference detection function sample */ 97 /** Calculate energy difference detection function sample */
81 double energyDifference(); 98 double energyDifference();
82 99
83 /** calculate spectral difference detection function sample */ 100 /** Calculate spectral difference detection function sample */
84 double spectralDifference(); 101 double spectralDifference();
85 102
86 /** calculate spectral difference (half wave rectified) detection function sample */ 103 /** Calculate spectral difference (half wave rectified) detection function sample */
87 double spectralDifferenceHWR(); 104 double spectralDifferenceHWR();
88 105
89 /** calculate phase deviation detection function sample */ 106 /** Calculate phase deviation detection function sample */
90 double phaseDeviation(); 107 double phaseDeviation();
91 108
92 /** calculate complex spectral difference detection function sample */ 109 /** Calculate complex spectral difference detection function sample */
93 double complexSpectralDifference(); 110 double complexSpectralDifference();
94 111
95 /** calculate complex spectral difference detection function sample (half-wave rectified) */ 112 /** Calculate complex spectral difference detection function sample (half-wave rectified) */
96 double complexSpectralDifferenceHWR(); 113 double complexSpectralDifferenceHWR();
97 114
98 /** calculate high frequency content detection function sample */ 115 /** Calculate high frequency content detection function sample */
99 double highFrequencyContent(); 116 double highFrequencyContent();
100 117
101 /** calculate high frequency spectral difference detection function sample */ 118 /** Calculate high frequency spectral difference detection function sample */
102 double highFrequencySpectralDifference(); 119 double highFrequencySpectralDifference();
103 120
104 /** calculate high frequency spectral difference detection function sample (half-wave rectified) */ 121 /** Calculate high frequency spectral difference detection function sample (half-wave rectified) */
105 double highFrequencySpectralDifferenceHWR(); 122 double highFrequencySpectralDifferenceHWR();
106 123
107 //======================================================================= 124 //=======================================================================
108 /** calculate a Rectangular window */ 125 /** Calculate a Rectangular window */
109 void calculateRectangularWindow(); 126 void calculateRectangularWindow();
110 127
111 /** calculate a Hanning window */ 128 /** Calculate a Hanning window */
112 void calculateHanningWindow(); 129 void calculateHanningWindow();
113 130
114 /** calculate a Hamming window */ 131 /** Calculate a Hamming window */
115 void calclulateHammingWindow(); 132 void calclulateHammingWindow();
116 133
117 /** calculate a Blackman window */ 134 /** Calculate a Blackman window */
118 void calculateBlackmanWindow(); 135 void calculateBlackmanWindow();
119 136
120 /** calculate a Tukey window */ 137 /** Calculate a Tukey window */
121 void calculateTukeyWindow(); 138 void calculateTukeyWindow();
122 139
123 //======================================================================= 140 //=======================================================================
124 /** set phase values between [-pi, pi] */ 141 /** Set phase values between [-pi, pi]
142 * @param phaseVal the phase value to process
143 * @returns the wrapped phase value
144 */
125 double princarg(double phaseVal); 145 double princarg(double phaseVal);
126 146
127 147
128 double pi; /**< pi, the constant */ 148 double pi; /**< pi, the constant */
129 149