annotate src/btrack_plus/OnsetDetectionFunction.h @ 8:184a7c232049 tip

changed files since updating computer
author Venetian
date Thu, 14 Aug 2014 17:53:57 +0100
parents 93b9a9471011
children
rev   line source
andrew@0 1 /*
andrew@0 2 * OnsetDetectionFunction.h
andrew@0 3 *
andrew@0 4 *
andrew@0 5 * Created by Adam Stark on 22/03/2011.
andrew@0 6 * Copyright 2011 Queen Mary University of London. All rights reserved.
andrew@0 7 *
andrew@0 8 */
andrew@0 9
andrew@0 10 #ifndef __RTONSETDF_H
andrew@0 11 #define __RTONSETDF_H
andrew@0 12
andrew@0 13 //#include "fftw3.h"
andrew@0 14 #include "accFFT.h"
andrew@0 15
andrew@0 16 typedef double fft_complex[2];
andrew@0 17
andrew@0 18 class OnsetDetectionFunction
andrew@0 19 {
andrew@0 20 public:
andrew@0 21 OnsetDetectionFunction(); // Constructor
andrew@0 22 OnsetDetectionFunction(int arg_hsize,int arg_fsize,int arg_df_type,int arg_win_type); // Constructor (with arguments)
andrew@0 23 ~OnsetDetectionFunction(); // Destructor
andrew@0 24 void initialise(int arg_hsize,int arg_fsize,int arg_df_type,int arg_win_type); // Initialisation Function
Venetian@8 25
Venetian@8 26 double getDFsample(float inputbuffer[]);
andrew@0 27 double getDFsample(double inputbuffer[]); // process input buffer and calculate detection function sample
andrew@0 28 void set_df_type(int arg_df_type); // set the detection function type
andrew@0 29
andrew@4 30 int framesize; // audio framesize
andrew@4 31 int hopsize; // audio hopsize
andrew@0 32 private:
andrew@0 33
andrew@0 34 void perform_FFT(); // perform the FFT on the data in 'frame'
andrew@0 35
andrew@0 36 double energy_envelope(); // calculate energy envelope detection function sample
andrew@0 37 double energy_difference(); // calculate energy difference detection function sample
andrew@0 38 double spectral_difference(); // calculate spectral difference detection function sample
andrew@0 39 double spectral_difference_hwr(); // calculate spectral difference (half wave rectified) detection function sample
andrew@0 40 double phase_deviation(); // calculate phase deviation detection function sample
andrew@0 41 double complex_spectral_difference(); // calculate complex spectral difference detection function sample
andrew@0 42 double complex_spectral_difference_hwr(); // calculate complex spectral difference detection function sample (half-wave rectified)
andrew@0 43 double high_frequency_content(); // calculate high frequency content detection function sample
andrew@0 44 double high_frequency_spectral_difference(); // calculate high frequency spectral difference detection function sample
andrew@0 45 double high_frequency_spectral_difference_hwr(); // calculate high frequency spectral difference detection function sample (half-wave rectified)
andrew@0 46
andrew@0 47 void set_win_rectangular(); // calculate a Rectangular window
andrew@0 48 void set_win_hanning(); // calculate a Hanning window
andrew@0 49 void set_win_hamming(); // calculate a Hamming window
andrew@0 50 void set_win_blackman(); // calculate a Blackman window
andrew@0 51 void set_win_tukey(); // calculate a Tukey window
andrew@0 52
andrew@0 53
andrew@0 54 double princarg(double phaseval); // set phase values between [-pi, pi]
andrew@0 55
andrew@0 56
andrew@0 57 double pi; // pi, the constant
andrew@4 58
andrew@0 59 int df_type; // type of detection function
andrew@0 60
andrew@0 61 accFFT *fft;
andrew@0 62 fft_complex *out;
andrew@0 63 double *in;
andrew@0 64
andrew@0 65 //fftw_plan p; // create fft plan
andrew@0 66 //fftw_complex *in; // to hold complex fft values for input
andrew@0 67 //fftw_complex *out; // to hold complex fft values for output
andrew@0 68
andrew@0 69
andrew@0 70 int initialised; // flag indicating whether buffers and FFT plans have been initialised
andrew@0 71
andrew@0 72
andrew@0 73 double *frame; // audio frame
andrew@0 74 double *window; // window
andrew@0 75 double *wframe; // windowed frame
andrew@0 76
andrew@0 77 double energy_sum_old; // to hold the previous energy sum value
andrew@0 78
andrew@0 79 double *mag; // magnitude spectrum
andrew@0 80 double *mag_old; // previous magnitude spectrum
andrew@0 81
andrew@0 82 double *phase; // FFT phase values
andrew@0 83 double *phase_old; // previous phase values
andrew@0 84 double *phase_old_2; // second order previous phase values
andrew@0 85
andrew@0 86 };
andrew@0 87
andrew@0 88
andrew@0 89 #endif