comparison src/btrack_plus/OnsetDetectionFunction.cpp @ 8:184a7c232049 tip

changed files since updating computer
author Venetian
date Thu, 14 Aug 2014 17:53:57 +0100
parents 3dcbd77efc94
children
comparison
equal deleted inserted replaced
7:b1c13e8bec26 8:184a7c232049
50 // destroy fft plan 50 // destroy fft plan
51 //fftw_destroy_plan(p); 51 //fftw_destroy_plan(p);
52 //fftw_free(in); 52 //fftw_free(in);
53 //fftw_free(out); 53 //fftw_free(out);
54 54
55 fft->~accFFT(); 55 // fft->~accFFT();
56
57 delete fft;
58 fft = NULL;
59
56 delete [] in; 60 delete [] in;
57 in = NULL; 61 in = NULL;
58 delete [] out; 62 delete [] out;
59 out = NULL; 63 out = NULL;
60 64
198 } 202 }
199 203
200 204
201 //-------------------------------------------------------------------------------------- 205 //--------------------------------------------------------------------------------------
202 // calculates a single detection function sample from a single audio frame. 206 // calculates a single detection function sample from a single audio frame.
207 double OnsetDetectionFunction :: getDFsample(float inputbuffer[])
208 {
209 double df_sample;
210
211 // shift audio samples back in frame by hop size
212 for (int i = 0; i < (framesize-hopsize);i++)
213 {
214 frame[i] = frame[i+hopsize];
215 }
216
217 // add new samples to frame from input buffer
218 int j = 0;
219 for (int i = (framesize-hopsize);i < framesize;i++)
220 {
221 frame[i] = inputbuffer[j];
222 j++;
223 }
224
225 switch (df_type){
226 case 0:
227 df_sample = energy_envelope(); // calculate energy envelope detection function sample
228 break;
229 case 1:
230 df_sample = energy_difference(); // calculate half-wave rectified energy difference detection function sample
231 break;
232 case 2:
233 df_sample = spectral_difference(); // calculate spectral difference detection function sample
234 break;
235 case 3:
236 df_sample = spectral_difference_hwr(); // calculate spectral difference detection function sample (half wave rectified)
237 break;
238 case 4:
239 df_sample = phase_deviation(); // calculate phase deviation detection function sample (half wave rectified)
240 break;
241 case 5:
242 df_sample = complex_spectral_difference(); // calcualte complex spectral difference detection function sample
243 break;
244 case 6:
245 df_sample = complex_spectral_difference_hwr(); // calcualte complex spectral difference detection function sample (half-wave rectified)
246 break;
247 case 7:
248 df_sample = high_frequency_content(); // calculate high frequency content detection function sample
249 break;
250 case 8:
251 df_sample = high_frequency_spectral_difference(); // calculate high frequency spectral difference detection function sample
252 break;
253 case 9:
254 df_sample = high_frequency_spectral_difference_hwr(); // calculate high frequency spectral difference detection function (half-wave rectified)
255 break;
256 default:
257 df_sample = 1.0;
258 }
259
260 return df_sample;
261 }
262
263
264
265
266 //--------------------------------------------------------------------------------------
267 // calculates a single detection function sample from a single audio frame.
203 double OnsetDetectionFunction :: getDFsample(double inputbuffer[]) 268 double OnsetDetectionFunction :: getDFsample(double inputbuffer[])
204 { 269 {
205 double df_sample; 270 double df_sample;
206 271
207 // shift audio samples back in frame by hop size 272 // shift audio samples back in frame by hop size