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