Mercurial > hg > btrack
comparison src/OnsetDetectionFunction.h @ 38:b7e3ed593fb0
flow: Created branch 'release/v0.9.0'.
author | Adam Stark <adamstark@users.noreply.github.com> |
---|---|
date | Tue, 21 Jan 2014 01:44:55 +0000 |
parents | |
children | 2b94d3d2fb9d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 38:b7e3ed593fb0 |
---|---|
1 //======================================================================= | |
2 /** @file OnsetDetectionFunction.h | |
3 * @brief A class for calculating onset detection functions | |
4 * @author Adam Stark | |
5 * @copyright Copyright (C) 2008-2014 Queen Mary University of London | |
6 * | |
7 * This program is free software: you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation, either version 3 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
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/>. | |
19 */ | |
20 //======================================================================= | |
21 | |
22 #ifndef __RTONSETDF_H | |
23 #define __RTONSETDF_H | |
24 | |
25 #include "fftw3.h" | |
26 | |
27 class OnsetDetectionFunction | |
28 { | |
29 public: | |
30 OnsetDetectionFunction(); // Constructor | |
31 OnsetDetectionFunction(int arg_hsize,int arg_fsize,int arg_df_type,int arg_win_type); // Constructor (with arguments) | |
32 ~OnsetDetectionFunction(); // Destructor | |
33 void initialise(int arg_hsize,int arg_fsize,int arg_df_type,int arg_win_type); // Initialisation Function | |
34 | |
35 double getDFsample(double inputbuffer[]); // process input buffer and calculate detection function sample | |
36 void set_df_type(int arg_df_type); // set the detection function type | |
37 | |
38 private: | |
39 | |
40 void perform_FFT(); // perform the FFT on the data in 'frame' | |
41 | |
42 double energy_envelope(); // calculate energy envelope detection function sample | |
43 double energy_difference(); // calculate energy difference detection function sample | |
44 double spectral_difference(); // calculate spectral difference detection function sample | |
45 double spectral_difference_hwr(); // calculate spectral difference (half wave rectified) detection function sample | |
46 double phase_deviation(); // calculate phase deviation detection function sample | |
47 double complex_spectral_difference(); // calculate complex spectral difference detection function sample | |
48 double complex_spectral_difference_hwr(); // calculate complex spectral difference detection function sample (half-wave rectified) | |
49 double high_frequency_content(); // calculate high frequency content detection function sample | |
50 double high_frequency_spectral_difference(); // calculate high frequency spectral difference detection function sample | |
51 double high_frequency_spectral_difference_hwr(); // calculate high frequency spectral difference detection function sample (half-wave rectified) | |
52 | |
53 void set_win_rectangular(); // calculate a Rectangular window | |
54 void set_win_hanning(); // calculate a Hanning window | |
55 void set_win_hamming(); // calculate a Hamming window | |
56 void set_win_blackman(); // calculate a Blackman window | |
57 void set_win_tukey(); // calculate a Tukey window | |
58 | |
59 | |
60 double princarg(double phaseval); // set phase values between [-pi, pi] | |
61 | |
62 | |
63 double pi; // pi, the constant | |
64 | |
65 int framesize; // audio framesize | |
66 int hopsize; // audio hopsize | |
67 int df_type; // type of detection function | |
68 | |
69 fftw_plan p; // create fft plan | |
70 fftw_complex *in; // to hold complex fft values for input | |
71 fftw_complex *out; // to hold complex fft values for output | |
72 | |
73 int initialised; // flag indicating whether buffers and FFT plans have been initialised | |
74 | |
75 | |
76 double *frame; // audio frame | |
77 double *window; // window | |
78 double *wframe; // windowed frame | |
79 | |
80 double energy_sum_old; // to hold the previous energy sum value | |
81 | |
82 double *mag; // magnitude spectrum | |
83 double *mag_old; // previous magnitude spectrum | |
84 | |
85 double *phase; // FFT phase values | |
86 double *phase_old; // previous phase values | |
87 double *phase_old_2; // second order previous phase values | |
88 | |
89 }; | |
90 | |
91 | |
92 #endif |