1 | /* |
---|
2 | Copyright (C) 2003 Paul Brossier |
---|
3 | |
---|
4 | This program is free software; you can redistribute it and/or modify |
---|
5 | it under the terms of the GNU General Public License as published by |
---|
6 | the Free Software Foundation; either version 2 of the License, or |
---|
7 | (at your option) any later version. |
---|
8 | |
---|
9 | This program is distributed in the hope that it will be useful, |
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | GNU General Public License for more details. |
---|
13 | |
---|
14 | You should have received a copy of the GNU General Public License |
---|
15 | along with this program; if not, write to the Free Software |
---|
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
17 | |
---|
18 | */ |
---|
19 | |
---|
20 | /** @file |
---|
21 | * |
---|
22 | * Onset detection functions |
---|
23 | * |
---|
24 | * These functions are adapted from Juan Pablo Bello matlab code. |
---|
25 | * |
---|
26 | * - all of the following onset detection function take as arguments the fft of |
---|
27 | * a windowed signal ( be created with an aubio_pvoc). |
---|
28 | * |
---|
29 | * |
---|
30 | * (the phasevocoder implementation does implement an fftshift like) |
---|
31 | * |
---|
32 | * - they output one smpl_t per frame and per channel (stored in a fvec_t * of |
---|
33 | * size [channels][1]) |
---|
34 | * |
---|
35 | * Some of the functions should be improved by - downsampling the input of the |
---|
36 | * phasevocoder - oversampling the ouput |
---|
37 | * |
---|
38 | * \todo write a generic driver (with a phase vocoder and the appropriate |
---|
39 | * resampling) |
---|
40 | */ |
---|
41 | |
---|
42 | |
---|
43 | #ifndef ONSETDETECTION_H |
---|
44 | #define ONSETDETECTION_H |
---|
45 | |
---|
46 | #ifdef __cplusplus |
---|
47 | extern "C" { |
---|
48 | #endif |
---|
49 | |
---|
50 | /** onsetdetection types */ |
---|
51 | typedef enum { |
---|
52 | energy, /**< energy based */ |
---|
53 | specdiff, /**< spectral diff */ |
---|
54 | hfc, /**< high frequency content */ |
---|
55 | complexdomain, /**< complex domain */ |
---|
56 | phase /**< phase fast */ |
---|
57 | } aubio_onsetdetection_type; |
---|
58 | |
---|
59 | /** onsetdetection structure */ |
---|
60 | typedef struct _aubio_onsetdetection_t aubio_onsetdetection_t; |
---|
61 | /** Energy based onset detection function |
---|
62 | * |
---|
63 | * calculates the local energy profile |
---|
64 | * |
---|
65 | * - buffer 1024 |
---|
66 | * - overlap 512 |
---|
67 | */ |
---|
68 | void aubio_onsetdetection_energy(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); |
---|
69 | /** High Frequency Content onset detection function |
---|
70 | * |
---|
71 | * - buffer 1024 |
---|
72 | * - overlap 512 |
---|
73 | */ |
---|
74 | void aubio_onsetdetection_hfc(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); |
---|
75 | /** Complex Domain Method onset detection function |
---|
76 | * |
---|
77 | * From C. Duxbury & J. Pablo Bello |
---|
78 | * |
---|
79 | * - buffer 512 |
---|
80 | * - overlap 128 |
---|
81 | * - dowfact 8 |
---|
82 | * - interpfact 2 |
---|
83 | */ |
---|
84 | void aubio_onsetdetection_complex(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); |
---|
85 | /** Phase Based Method onset detection function |
---|
86 | * |
---|
87 | * - buffer 512 |
---|
88 | * - overlap 128 |
---|
89 | * - dowfact 8 |
---|
90 | * - interpfact 2 |
---|
91 | */ |
---|
92 | void aubio_onsetdetection_phase(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); |
---|
93 | /** Spectral difference method onset detection function |
---|
94 | * |
---|
95 | * - buffer 512 |
---|
96 | * - overlap 128 |
---|
97 | * - dowfact 8 |
---|
98 | * - interpfact 2 |
---|
99 | */ |
---|
100 | void aubio_onsetdetection_specdiff(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); |
---|
101 | /** Generic function pointing to the choosen one */ |
---|
102 | void aubio_onsetdetection(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); |
---|
103 | /** Allocate memory for an onset detection */ |
---|
104 | aubio_onsetdetection_t * new_aubio_onsetdetection(aubio_onsetdetection_type type, uint_t size, uint_t channels); |
---|
105 | /** Free memory for an onset detection */ |
---|
106 | void aubio_onsetdetection_free(aubio_onsetdetection_t *o); |
---|
107 | |
---|
108 | #ifdef __cplusplus |
---|
109 | } |
---|
110 | #endif |
---|
111 | |
---|
112 | #endif /* ONSETDETECTION_H */ |
---|