annotate src/OnsetDetectionFunction.h @ 52:45231107c9d6

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