Mercurial > hg > btrack
comparison src/OnsetDetectionFunction.h @ 59:ba3fc238ccad
Renamed many variables, functions and arguments so they have more sensible names. Also removed an apparently redundant variable in OnsetDetectionFunction called wframe
author | Adam Stark <adamstark@users.noreply.github.com> |
---|---|
date | Fri, 24 Jan 2014 21:45:55 +0000 |
parents | 296af6af6c3d |
children | 92ee4ace9d46 |
comparison
equal
deleted
inserted
replaced
58:f84ccd07e17f | 59:ba3fc238ccad |
---|---|
17 * You should have received a copy of the GNU General Public License | 17 * You should have received a copy of the GNU General Public License |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 */ | 19 */ |
20 //======================================================================= | 20 //======================================================================= |
21 | 21 |
22 #ifndef __RTONSETDF_H | 22 #ifndef __ONSETDETECTIONFUNCTION_H |
23 #define __RTONSETDF_H | 23 #define __ONSETDETECTIONFUNCTION_H |
24 | 24 |
25 #include "fftw3.h" | 25 #include "fftw3.h" |
26 | 26 |
27 //======================================================================= | 27 //======================================================================= |
28 enum OnsetDetectionFunctionType | 28 enum OnsetDetectionFunctionType |
52 class OnsetDetectionFunction | 52 class OnsetDetectionFunction |
53 { | 53 { |
54 public: | 54 public: |
55 | 55 |
56 /** Constructor */ | 56 /** Constructor */ |
57 OnsetDetectionFunction(int arg_hsize,int arg_fsize,int arg_df_type,int arg_win_type); | 57 OnsetDetectionFunction(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType); |
58 | 58 |
59 /** Destructor */ | 59 /** Destructor */ |
60 ~OnsetDetectionFunction(); | 60 ~OnsetDetectionFunction(); |
61 | 61 |
62 /** Initialisation Function */ | 62 /** Initialisation Function */ |
63 void initialise(int arg_hsize,int arg_fsize,int arg_df_type,int arg_win_type); | 63 void initialise(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType); |
64 | 64 |
65 /** process input buffer and calculate detection function sample */ | 65 /** process input frame and calculate detection function sample */ |
66 double getDFsample(double *inputbuffer); | 66 double calculateOnsetDetectionFunctionSample(double *buffer); |
67 | 67 |
68 /** set the detection function type */ | 68 /** set the detection function type */ |
69 void set_df_type(int arg_df_type); | 69 void setOnsetDetectionFunctionType(int onsetDetectionFunctionType_); |
70 | 70 |
71 private: | 71 private: |
72 | 72 |
73 /** perform the FFT on the data in 'frame' */ | 73 /** perform the FFT on the data in 'frame' */ |
74 void perform_FFT(); | 74 void performFFT(); |
75 | 75 |
76 //======================================================================= | |
76 /** calculate energy envelope detection function sample */ | 77 /** calculate energy envelope detection function sample */ |
77 double energy_envelope(); | 78 double energyEnvelope(); |
78 | 79 |
79 /** calculate energy difference detection function sample */ | 80 /** calculate energy difference detection function sample */ |
80 double energy_difference(); | 81 double energyDifference(); |
81 | 82 |
82 /** calculate spectral difference detection function sample */ | 83 /** calculate spectral difference detection function sample */ |
83 double spectral_difference(); | 84 double spectralDifference(); |
84 | 85 |
85 /** calculate spectral difference (half wave rectified) detection function sample */ | 86 /** calculate spectral difference (half wave rectified) detection function sample */ |
86 double spectral_difference_hwr(); | 87 double spectralDifferenceHWR(); |
87 | 88 |
88 /** calculate phase deviation detection function sample */ | 89 /** calculate phase deviation detection function sample */ |
89 double phase_deviation(); | 90 double phaseDeviation(); |
90 | 91 |
91 /** calculate complex spectral difference detection function sample */ | 92 /** calculate complex spectral difference detection function sample */ |
92 double complex_spectral_difference(); | 93 double complexSpectralDifference(); |
93 | 94 |
94 /** calculate complex spectral difference detection function sample (half-wave rectified) */ | 95 /** calculate complex spectral difference detection function sample (half-wave rectified) */ |
95 double complex_spectral_difference_hwr(); | 96 double complexSpectralDifferenceHWR(); |
96 | 97 |
97 /** calculate high frequency content detection function sample */ | 98 /** calculate high frequency content detection function sample */ |
98 double high_frequency_content(); | 99 double highFrequencyContent(); |
99 | 100 |
100 /** calculate high frequency spectral difference detection function sample */ | 101 /** calculate high frequency spectral difference detection function sample */ |
101 double high_frequency_spectral_difference(); | 102 double highFrequencySpectralDifference(); |
102 | 103 |
103 /** calculate high frequency spectral difference detection function sample (half-wave rectified) */ | 104 /** calculate high frequency spectral difference detection function sample (half-wave rectified) */ |
104 double high_frequency_spectral_difference_hwr(); | 105 double highFrequencySpectralDifferenceHWR(); |
105 | 106 |
107 //======================================================================= | |
106 /** calculate a Rectangular window */ | 108 /** calculate a Rectangular window */ |
107 void set_win_rectangular(); | 109 void calculateRectangularWindow(); |
108 | 110 |
109 /** calculate a Hanning window */ | 111 /** calculate a Hanning window */ |
110 void set_win_hanning(); | 112 void calculateHanningWindow(); |
111 | 113 |
112 /** calculate a Hamming window */ | 114 /** calculate a Hamming window */ |
113 void set_win_hamming(); | 115 void calclulateHammingWindow(); |
114 | 116 |
115 /** calculate a Blackman window */ | 117 /** calculate a Blackman window */ |
116 void set_win_blackman(); | 118 void calculateBlackmanWindow(); |
117 | 119 |
118 /** calculate a Tukey window */ | 120 /** calculate a Tukey window */ |
119 void set_win_tukey(); | 121 void calculateTukeyWindow(); |
120 | 122 |
123 //======================================================================= | |
121 /** set phase values between [-pi, pi] */ | 124 /** set phase values between [-pi, pi] */ |
122 double princarg(double phaseval); | 125 double princarg(double phaseVal); |
123 | 126 |
124 | 127 |
125 double pi; /**< pi, the constant */ | 128 double pi; /**< pi, the constant */ |
126 | 129 |
127 int framesize; /**< audio framesize */ | 130 int frameSize; /**< audio framesize */ |
128 int hopsize; /**< audio hopsize */ | 131 int hopSize; /**< audio hopsize */ |
129 int df_type; /**< type of detection function */ | 132 int onsetDetectionFunctionType; /**< type of detection function */ |
130 | 133 |
131 fftw_plan p; /**< create fft plan */ | 134 fftw_plan p; /**< fftw plan */ |
132 fftw_complex *in; /**< to hold complex fft values for input */ | 135 fftw_complex *complexIn; /**< to hold complex fft values for input */ |
133 fftw_complex *out; /**< to hold complex fft values for output */ | 136 fftw_complex *complexOut; /**< to hold complex fft values for output */ |
134 | 137 |
135 int initialised; /**< flag indicating whether buffers and FFT plans are initialised */ | 138 int initialised; /**< flag indicating whether buffers and FFT plans are initialised */ |
136 | 139 |
137 double *frame; /**< audio frame */ | 140 double *frame; /**< audio frame */ |
138 double *window; /**< window */ | 141 double *window; /**< window */ |
139 double *wframe; /**< windowed frame */ | |
140 | 142 |
141 double energy_sum_old; /**< to hold the previous energy sum value */ | 143 double prevEnergySum; /**< to hold the previous energy sum value */ |
142 | 144 |
143 double *mag; /**< magnitude spectrum */ | 145 double *magSpec; /**< magnitude spectrum */ |
144 double *mag_old; /**< previous magnitude spectrum */ | 146 double *prevMagSpec; /**< previous magnitude spectrum */ |
145 | 147 |
146 double *phase; /**< FFT phase values */ | 148 double *phase; /**< FFT phase values */ |
147 double *phase_old; /**< previous phase values */ | 149 double *prevPhase; /**< previous phase values */ |
148 double *phase_old_2; /**< second order previous phase values */ | 150 double *prevPhase2; /**< second order previous phase values */ |
149 | 151 |
150 }; | 152 }; |
151 | 153 |
152 | 154 |
153 #endif | 155 #endif |