Mercurial > hg > btrack
comparison src/OnsetDetectionFunction.h @ 15:2b94d3d2fb9d develop
Reformatted comments, removed the OnsetDetectionFunction constructor with no arguments, removed a number of unused variables and made changes to the python module to fix some casting problems and removed some unused variables there also. Still getting the same results, so no overall changes to the algorithm.
author | Adam <adamstark.uk@gmail.com> |
---|---|
date | Wed, 22 Jan 2014 01:13:45 +0000 |
parents | bd2c405d4a06 |
children | 73c64ca0ed23 |
comparison
equal
deleted
inserted
replaced
14:18fc3c248436 | 15:2b94d3d2fb9d |
---|---|
25 #include "fftw3.h" | 25 #include "fftw3.h" |
26 | 26 |
27 class OnsetDetectionFunction | 27 class OnsetDetectionFunction |
28 { | 28 { |
29 public: | 29 public: |
30 OnsetDetectionFunction(); // Constructor | 30 |
31 OnsetDetectionFunction(int arg_hsize,int arg_fsize,int arg_df_type,int arg_win_type); // Constructor (with arguments) | 31 /** Constructor */ |
32 ~OnsetDetectionFunction(); // Destructor | 32 OnsetDetectionFunction(int arg_hsize,int arg_fsize,int arg_df_type,int arg_win_type); |
33 void initialise(int arg_hsize,int arg_fsize,int arg_df_type,int arg_win_type); // Initialisation Function | 33 |
34 /** Destructor */ | |
35 ~OnsetDetectionFunction(); | |
36 | |
37 /** Initialisation Function */ | |
38 void initialise(int arg_hsize,int arg_fsize,int arg_df_type,int arg_win_type); | |
34 | 39 |
35 double getDFsample(double inputbuffer[]); // process input buffer and calculate detection function sample | 40 /** process input buffer and calculate detection function sample */ |
36 void set_df_type(int arg_df_type); // set the detection function type | 41 double getDFsample(double inputbuffer[]); |
42 | |
43 /** set the detection function type */ | |
44 void set_df_type(int arg_df_type); | |
37 | 45 |
38 private: | 46 private: |
39 | 47 |
40 void perform_FFT(); // perform the FFT on the data in 'frame' | 48 /** perform the FFT on the data in 'frame' */ |
49 void perform_FFT(); | |
41 | 50 |
42 double energy_envelope(); // calculate energy envelope detection function sample | 51 /** calculate energy envelope detection function sample */ |
43 double energy_difference(); // calculate energy difference detection function sample | 52 double energy_envelope(); |
44 double spectral_difference(); // calculate spectral difference detection function sample | 53 |
45 double spectral_difference_hwr(); // calculate spectral difference (half wave rectified) detection function sample | 54 /** calculate energy difference detection function sample */ |
46 double phase_deviation(); // calculate phase deviation detection function sample | 55 double energy_difference(); |
47 double complex_spectral_difference(); // calculate complex spectral difference detection function sample | 56 |
48 double complex_spectral_difference_hwr(); // calculate complex spectral difference detection function sample (half-wave rectified) | 57 /** calculate spectral difference detection function sample */ |
49 double high_frequency_content(); // calculate high frequency content detection function sample | 58 double spectral_difference(); |
50 double high_frequency_spectral_difference(); // calculate high frequency spectral difference detection function sample | 59 |
51 double high_frequency_spectral_difference_hwr(); // calculate high frequency spectral difference detection function sample (half-wave rectified) | 60 /** calculate spectral difference (half wave rectified) detection function sample */ |
61 double spectral_difference_hwr(); | |
62 | |
63 /** calculate phase deviation detection function sample */ | |
64 double phase_deviation(); | |
65 | |
66 /** calculate complex spectral difference detection function sample */ | |
67 double complex_spectral_difference(); | |
68 | |
69 /** calculate complex spectral difference detection function sample (half-wave rectified) */ | |
70 double complex_spectral_difference_hwr(); | |
71 | |
72 /** calculate high frequency content detection function sample */ | |
73 double high_frequency_content(); | |
74 | |
75 /** calculate high frequency spectral difference detection function sample */ | |
76 double high_frequency_spectral_difference(); | |
77 | |
78 /** calculate high frequency spectral difference detection function sample (half-wave rectified) */ | |
79 double high_frequency_spectral_difference_hwr(); | |
52 | 80 |
53 void set_win_rectangular(); // calculate a Rectangular window | 81 /** calculate a Rectangular window */ |
54 void set_win_hanning(); // calculate a Hanning window | 82 void set_win_rectangular(); |
55 void set_win_hamming(); // calculate a Hamming window | 83 |
56 void set_win_blackman(); // calculate a Blackman window | 84 /** calculate a Hanning window */ |
57 void set_win_tukey(); // calculate a Tukey window | 85 void set_win_hanning(); |
86 | |
87 /** calculate a Hamming window */ | |
88 void set_win_hamming(); | |
89 | |
90 /** calculate a Blackman window */ | |
91 void set_win_blackman(); | |
92 | |
93 /** calculate a Tukey window */ | |
94 void set_win_tukey(); | |
58 | 95 |
59 | 96 /** set phase values between [-pi, pi] */ |
60 double princarg(double phaseval); // set phase values between [-pi, pi] | 97 double princarg(double phaseval); |
61 | 98 |
62 | 99 |
63 double pi; // pi, the constant | 100 double pi; /**< pi, the constant */ |
64 | 101 |
65 int framesize; // audio framesize | 102 int framesize; /**< audio framesize */ |
66 int hopsize; // audio hopsize | 103 int hopsize; /**< audio hopsize */ |
67 int df_type; // type of detection function | 104 int df_type; /**< type of detection function */ |
68 | 105 |
69 fftw_plan p; // create fft plan | 106 fftw_plan p; /**< create fft plan */ |
70 fftw_complex *in; // to hold complex fft values for input | 107 fftw_complex *in; /**< to hold complex fft values for input */ |
71 fftw_complex *out; // to hold complex fft values for output | 108 fftw_complex *out; /**< to hold complex fft values for output */ |
72 | 109 |
73 int initialised; // flag indicating whether buffers and FFT plans have been initialised | 110 int initialised; /**< flag indicating whether buffers and FFT plans are initialised */ |
111 | |
112 double *frame; /**< audio frame */ | |
113 double *window; /**< window */ | |
114 double *wframe; /**< windowed frame */ | |
74 | 115 |
75 | 116 double energy_sum_old; /**< to hold the previous energy sum value */ |
76 double *frame; // audio frame | |
77 double *window; // window | |
78 double *wframe; // windowed frame | |
79 | 117 |
80 double energy_sum_old; // to hold the previous energy sum value | 118 double *mag; /**< magnitude spectrum */ |
119 double *mag_old; /**< previous magnitude spectrum */ | |
81 | 120 |
82 double *mag; // magnitude spectrum | 121 double *phase; /**< FFT phase values */ |
83 double *mag_old; // previous magnitude spectrum | 122 double *phase_old; /**< previous phase values */ |
84 | 123 double *phase_old_2; /**< second order previous phase values */ |
85 double *phase; // FFT phase values | |
86 double *phase_old; // previous phase values | |
87 double *phase_old_2; // second order previous phase values | |
88 | 124 |
89 }; | 125 }; |
90 | 126 |
91 | 127 |
92 #endif | 128 #endif |