comparison src/OnsetDetectionFunction.cpp @ 57:296af6af6c3d

Replaced switch statements in OnsetDetectionFunction with enums. Renamed lots of functions so that they have better names, in camel case. Added some unit tests for initialisation of BTrack.
author Adam Stark <adamstark@users.noreply.github.com>
date Thu, 23 Jan 2014 15:31:11 +0000
parents 338f5eb29e41
children a8e3e95d14e4
comparison
equal deleted inserted replaced
56:b6d440942ff6 57:296af6af6c3d
118 phase_old_2 = new double[framesize]; 118 phase_old_2 = new double[framesize];
119 119
120 120
121 // set the window to the specified type 121 // set the window to the specified type
122 switch (arg_win_type){ 122 switch (arg_win_type){
123 case 0: 123 case RectangularWindow:
124 set_win_rectangular(); // Rectangular window 124 set_win_rectangular(); // Rectangular window
125 break; 125 break;
126 case 1: 126 case HanningWindow:
127 set_win_hanning(); // Hanning Window 127 set_win_hanning(); // Hanning Window
128 break; 128 break;
129 case 2: 129 case HammingWindow:
130 set_win_hamming(); // Hamming Window 130 set_win_hamming(); // Hamming Window
131 break; 131 break;
132 case 3: 132 case BlackmanWindow:
133 set_win_blackman(); // Blackman Window 133 set_win_blackman(); // Blackman Window
134 break; 134 break;
135 case 4: 135 case TukeyWindow:
136 set_win_tukey(); // Tukey Window 136 set_win_tukey(); // Tukey Window
137 break; 137 break;
138 default: 138 default:
139 set_win_hanning(); // DEFAULT: Hanning Window 139 set_win_hanning(); // DEFAULT: Hanning Window
140 } 140 }
185 frame[i] = inputbuffer[j]; 185 frame[i] = inputbuffer[j];
186 j++; 186 j++;
187 } 187 }
188 188
189 switch (df_type){ 189 switch (df_type){
190 case 0: 190 case EnergyEnvelope:
191 df_sample = energy_envelope(); // calculate energy envelope detection function sample 191 {
192 break; 192 // calculate energy envelope detection function sample
193 case 1: 193 df_sample = energy_envelope();
194 df_sample = energy_difference(); // calculate half-wave rectified energy difference detection function sample 194 break;
195 break; 195 }
196 case 2: 196 case EnergyDifference:
197 df_sample = spectral_difference(); // calculate spectral difference detection function sample 197 {
198 break; 198 // calculate half-wave rectified energy difference detection function sample
199 case 3: 199 df_sample = energy_difference();
200 df_sample = spectral_difference_hwr(); // calculate spectral difference detection function sample (half wave rectified) 200 break;
201 break; 201 }
202 case 4: 202 case SpectralDifference:
203 df_sample = phase_deviation(); // calculate phase deviation detection function sample (half wave rectified) 203 {
204 break; 204 // calculate spectral difference detection function sample
205 case 5: 205 df_sample = spectral_difference();
206 df_sample = complex_spectral_difference(); // calcualte complex spectral difference detection function sample 206 break;
207 break; 207 }
208 case 6: 208 case SpectralDifferenceHWR:
209 df_sample = complex_spectral_difference_hwr(); // calcualte complex spectral difference detection function sample (half-wave rectified) 209 {
210 break; 210 // calculate spectral difference detection function sample (half wave rectified)
211 case 7: 211 df_sample = spectral_difference_hwr();
212 df_sample = high_frequency_content(); // calculate high frequency content detection function sample 212 break;
213 break; 213 }
214 case 8: 214 case PhaseDeviation:
215 df_sample = high_frequency_spectral_difference(); // calculate high frequency spectral difference detection function sample 215 {
216 break; 216 // calculate phase deviation detection function sample (half wave rectified)
217 case 9: 217 df_sample = phase_deviation();
218 df_sample = high_frequency_spectral_difference_hwr(); // calculate high frequency spectral difference detection function (half-wave rectified) 218 break;
219 break; 219 }
220 case ComplexSpectralDifference:
221 {
222 // calcualte complex spectral difference detection function sample
223 df_sample = complex_spectral_difference();
224 break;
225 }
226 case ComplexSpectralDifferenceHWR:
227 {
228 // calcualte complex spectral difference detection function sample (half-wave rectified)
229 df_sample = complex_spectral_difference_hwr();
230 break;
231 }
232 case HighFrequencyContent:
233 {
234 // calculate high frequency content detection function sample
235 df_sample = high_frequency_content();
236 break;
237 }
238 case HighFrequencySpectralDifference:
239 {
240 // calculate high frequency spectral difference detection function sample
241 df_sample = high_frequency_spectral_difference();
242 break;
243 }
244 case HighFrequencySpectralDifferenceHWR:
245 {
246 // calculate high frequency spectral difference detection function (half-wave rectified)
247 df_sample = high_frequency_spectral_difference_hwr();
248 break;
249 }
220 default: 250 default:
251 {
221 df_sample = 1.0; 252 df_sample = 1.0;
253 }
222 } 254 }
223 255
224 return df_sample; 256 return df_sample;
225 } 257 }
226 258