Mercurial > hg > precise-onset-detection
diff 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 |
line wrap: on
line diff
--- a/src/btrack_plus/OnsetDetectionFunction.cpp Thu Aug 14 16:27:52 2014 +0100 +++ b/src/btrack_plus/OnsetDetectionFunction.cpp Thu Aug 14 17:53:57 2014 +0100 @@ -52,7 +52,11 @@ //fftw_free(in); //fftw_free(out); - fft->~accFFT(); +// fft->~accFFT(); + + delete fft; + fft = NULL; + delete [] in; in = NULL; delete [] out; @@ -200,6 +204,67 @@ //-------------------------------------------------------------------------------------- // calculates a single detection function sample from a single audio frame. +double OnsetDetectionFunction :: getDFsample(float inputbuffer[]) +{ + double df_sample; + + // shift audio samples back in frame by hop size + for (int i = 0; i < (framesize-hopsize);i++) + { + frame[i] = frame[i+hopsize]; + } + + // add new samples to frame from input buffer + int j = 0; + for (int i = (framesize-hopsize);i < framesize;i++) + { + frame[i] = inputbuffer[j]; + j++; + } + + switch (df_type){ + case 0: + df_sample = energy_envelope(); // calculate energy envelope detection function sample + break; + case 1: + df_sample = energy_difference(); // calculate half-wave rectified energy difference detection function sample + break; + case 2: + df_sample = spectral_difference(); // calculate spectral difference detection function sample + break; + case 3: + df_sample = spectral_difference_hwr(); // calculate spectral difference detection function sample (half wave rectified) + break; + case 4: + df_sample = phase_deviation(); // calculate phase deviation detection function sample (half wave rectified) + break; + case 5: + df_sample = complex_spectral_difference(); // calcualte complex spectral difference detection function sample + break; + case 6: + df_sample = complex_spectral_difference_hwr(); // calcualte complex spectral difference detection function sample (half-wave rectified) + break; + case 7: + df_sample = high_frequency_content(); // calculate high frequency content detection function sample + break; + case 8: + df_sample = high_frequency_spectral_difference(); // calculate high frequency spectral difference detection function sample + break; + case 9: + df_sample = high_frequency_spectral_difference_hwr(); // calculate high frequency spectral difference detection function (half-wave rectified) + break; + default: + df_sample = 1.0; + } + + return df_sample; +} + + + + +//-------------------------------------------------------------------------------------- +// calculates a single detection function sample from a single audio frame. double OnsetDetectionFunction :: getDFsample(double inputbuffer[]) { double df_sample;