|
aubio 0.4.5
|
00001 /* 00002 Copyright (C) 2006-2013 Paul Brossier <piem@aubio.org> 00003 00004 This file is part of aubio. 00005 00006 aubio is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 aubio is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with aubio. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 /** \file 00022 00023 Onset detection object 00024 00025 The following routines compute the onset detection function and detect peaks 00026 in these functions. When onsets are found above a given silence threshold, 00027 and after a minimum inter-onset interval, the output vector returned by 00028 aubio_onset_do() is filled with `1`. Otherwise, the output vector remains 00029 `0`. 00030 00031 The peak-picking threshold, the silence threshold, and the minimum 00032 inter-onset interval can be adjusted during the execution of the 00033 aubio_onset_do routine using the corresponding functions. 00034 00035 \example onset/test-onset.c 00036 \example examples/aubioonset.c 00037 \example examples/aubionotes.c 00038 00039 */ 00040 00041 00042 #ifndef AUBIO_ONSET_H 00043 #define AUBIO_ONSET_H 00044 00045 #ifdef __cplusplus 00046 extern "C" { 00047 #endif 00048 00049 /** onset detection object */ 00050 typedef struct _aubio_onset_t aubio_onset_t; 00051 00052 /** create onset detection object 00053 00054 \param method onset detection type as specified in specdesc.h 00055 \param buf_size buffer size for phase vocoder 00056 \param hop_size hop size for phase vocoder 00057 \param samplerate sampling rate of the input signal 00058 00059 \return newly created ::aubio_onset_t 00060 00061 */ 00062 aubio_onset_t * new_aubio_onset (const char_t * method, 00063 uint_t buf_size, uint_t hop_size, uint_t samplerate); 00064 00065 /** execute onset detection 00066 00067 \param o onset detection object as returned by new_aubio_onset() 00068 \param input new audio vector of length hop_size 00069 \param onset output vector of length 1, containing 0 if no onset was found, 00070 and a value equal or greater than 1 otherwise 00071 00072 When no onset was detected, the first element of the output vector `onset` 00073 is set to 0. 00074 00075 When an onset is found, the first element of the output vector `onset` is set 00076 to `offset = 1 + a` where `a` is a number in the range`[0, 1]`. 00077 00078 The final onset detection time, in samples, can be obtained with 00079 aubio_onset_get_last(). It can also be derived from `offset` as 00080 follows: 00081 00082 \code 00083 t = total_frames + offset * hop_size - delay 00084 \endcode 00085 00086 where `total_frames` is the total number of frames processed so far, and 00087 `delay` is the current delay of the onset object, as returned by 00088 aubio_onset_get_delay(). 00089 00090 */ 00091 void aubio_onset_do (aubio_onset_t *o, const fvec_t * input, fvec_t * onset); 00092 00093 /** get the time of the latest onset detected, in samples 00094 00095 \param o onset detection object as returned by new_aubio_onset() 00096 00097 \return onset detection timestamps (in samples) 00098 00099 */ 00100 uint_t aubio_onset_get_last (const aubio_onset_t *o); 00101 00102 /** get the time of the latest onset detected, in seconds 00103 00104 \param o onset detection object as returned by new_aubio_onset() 00105 00106 \return onset detection timestamps (in seconds) 00107 00108 */ 00109 smpl_t aubio_onset_get_last_s (const aubio_onset_t *o); 00110 00111 /** get the time of the latest onset detected, in milliseconds 00112 00113 \param o onset detection object as returned by new_aubio_onset() 00114 00115 \return onset detection timestamps (in milliseconds) 00116 00117 */ 00118 smpl_t aubio_onset_get_last_ms (const aubio_onset_t *o); 00119 00120 /** set onset detection adaptive whitening 00121 00122 \param o onset detection object as returned by new_aubio_onset() 00123 \param enable 1 to enable, 0 to disable 00124 00125 \return 0 if successful, 1 otherwise 00126 00127 */ 00128 uint_t aubio_onset_set_awhitening(aubio_onset_t * o, uint_t enable); 00129 00130 /** get onset detection adaptive whitening 00131 00132 \param o onset detection object as returned by new_aubio_onset() 00133 00134 \return 1 if enabled, 0 otherwise 00135 00136 */ 00137 smpl_t aubio_onset_get_awhitening(aubio_onset_t * o); 00138 00139 /** set or disable log compression 00140 00141 \param o onset detection object as returned by new_aubio_onset() 00142 \param lambda logarithmic compression factor, 0 to disable 00143 00144 \return 0 if successful, 1 otherwise 00145 00146 */ 00147 uint_t aubio_onset_set_compression(aubio_onset_t *o, smpl_t lambda); 00148 00149 /** get onset detection log compression 00150 00151 \param o onset detection object as returned by new_aubio_onset() 00152 00153 \returns 0 if disabled, compression factor otherwise 00154 00155 */ 00156 smpl_t aubio_onset_get_compression(aubio_onset_t *o); 00157 00158 /** set onset detection silence threshold 00159 00160 \param o onset detection object as returned by new_aubio_onset() 00161 \param silence new silence detection threshold 00162 00163 */ 00164 uint_t aubio_onset_set_silence(aubio_onset_t * o, smpl_t silence); 00165 00166 /** get onset detection silence threshold 00167 00168 \param o onset detection object as returned by new_aubio_onset() 00169 00170 \return current silence threshold 00171 00172 */ 00173 smpl_t aubio_onset_get_silence(const aubio_onset_t * o); 00174 00175 /** get onset detection function 00176 00177 \param o onset detection object as returned by new_aubio_onset() 00178 \return the current value of the descriptor 00179 00180 */ 00181 smpl_t aubio_onset_get_descriptor (const aubio_onset_t *o); 00182 00183 /** get thresholded onset detection function 00184 00185 \param o onset detection object as returned by new_aubio_onset() 00186 \return the value of the thresholded descriptor 00187 00188 */ 00189 smpl_t aubio_onset_get_thresholded_descriptor (const aubio_onset_t *o); 00190 00191 /** set onset detection peak picking threshold 00192 00193 \param o onset detection object as returned by new_aubio_onset() 00194 \param threshold new peak-picking threshold 00195 00196 */ 00197 uint_t aubio_onset_set_threshold(aubio_onset_t * o, smpl_t threshold); 00198 00199 /** set minimum inter onset interval in samples 00200 00201 \param o onset detection object as returned by new_aubio_onset() 00202 \param minioi minimum interval between two consecutive onsets (in 00203 samples) 00204 00205 */ 00206 uint_t aubio_onset_set_minioi(aubio_onset_t * o, uint_t minioi); 00207 00208 /** set minimum inter onset interval in seconds 00209 00210 \param o onset detection object as returned by new_aubio_onset() 00211 \param minioi minimum interval between two consecutive onsets (in 00212 seconds) 00213 00214 */ 00215 uint_t aubio_onset_set_minioi_s(aubio_onset_t * o, smpl_t minioi); 00216 00217 /** set minimum inter onset interval in milliseconds 00218 00219 \param o onset detection object as returned by new_aubio_onset() 00220 \param minioi minimum interval between two consecutive onsets (in 00221 milliseconds) 00222 00223 */ 00224 uint_t aubio_onset_set_minioi_ms(aubio_onset_t * o, smpl_t minioi); 00225 00226 /** set delay in samples 00227 00228 \param o onset detection object as returned by new_aubio_onset() 00229 \param delay constant system delay to take back from detection time 00230 (in samples) 00231 00232 */ 00233 uint_t aubio_onset_set_delay(aubio_onset_t * o, uint_t delay); 00234 00235 /** set delay in seconds 00236 00237 \param o onset detection object as returned by new_aubio_onset() 00238 \param delay constant system delay to take back from detection time 00239 (in seconds) 00240 00241 */ 00242 uint_t aubio_onset_set_delay_s(aubio_onset_t * o, smpl_t delay); 00243 00244 /** set delay in milliseconds 00245 00246 \param o onset detection object as returned by new_aubio_onset() 00247 \param delay constant system delay to take back from detection time 00248 (in milliseconds) 00249 00250 */ 00251 uint_t aubio_onset_set_delay_ms(aubio_onset_t * o, smpl_t delay); 00252 00253 /** get minimum inter onset interval in samples 00254 00255 \param o onset detection object as returned by new_aubio_onset() 00256 \return minimum interval between two consecutive onsets (in 00257 samples) 00258 00259 */ 00260 uint_t aubio_onset_get_minioi(const aubio_onset_t * o); 00261 00262 /** get minimum inter onset interval in seconds 00263 00264 \param o onset detection object as returned by new_aubio_onset() 00265 \return minimum interval between two consecutive onsets (in 00266 seconds) 00267 00268 */ 00269 smpl_t aubio_onset_get_minioi_s(const aubio_onset_t * o); 00270 00271 /** get minimum inter onset interval in milliseconds 00272 00273 \param o onset detection object as returned by new_aubio_onset() 00274 \return minimum interval between two consecutive onsets (in 00275 milliseconds) 00276 00277 */ 00278 smpl_t aubio_onset_get_minioi_ms(const aubio_onset_t * o); 00279 00280 /** get delay in samples 00281 00282 \param o onset detection object as returned by new_aubio_onset() 00283 \return constant system delay to take back from detection time 00284 (in samples) 00285 00286 */ 00287 uint_t aubio_onset_get_delay(const aubio_onset_t * o); 00288 00289 /** get delay in seconds 00290 00291 \param o onset detection object as returned by new_aubio_onset() 00292 \return constant system delay to take back from detection time 00293 (in seconds) 00294 00295 */ 00296 smpl_t aubio_onset_get_delay_s(const aubio_onset_t * o); 00297 00298 /** get delay in milliseconds 00299 00300 \param o onset detection object as returned by new_aubio_onset() 00301 \return constant system delay to take back from detection time 00302 (in milliseconds) 00303 00304 */ 00305 smpl_t aubio_onset_get_delay_ms(const aubio_onset_t * o); 00306 00307 /** get onset peak picking threshold 00308 00309 \param o onset detection object as returned by new_aubio_onset() 00310 \return current onset detection threshold 00311 00312 */ 00313 smpl_t aubio_onset_get_threshold(const aubio_onset_t * o); 00314 00315 /** set default parameters 00316 00317 \param o onset detection object as returned by new_aubio_onset() 00318 \param onset_mode detection mode to adjust 00319 00320 This function is called at the end of new_aubio_onset(). 00321 00322 */ 00323 uint_t aubio_onset_set_default_parameters (aubio_onset_t * o, const char_t * onset_mode); 00324 00325 /** reset onset detection 00326 00327 \param o onset detection object as returned by new_aubio_onset() 00328 00329 Reset current time and last onset to 0. 00330 00331 This function is called at the end of new_aubio_onset(). 00332 00333 */ 00334 void aubio_onset_reset(aubio_onset_t * o); 00335 00336 /** delete onset detection object 00337 00338 \param o onset detection object to delete 00339 00340 */ 00341 void del_aubio_onset(aubio_onset_t * o); 00342 00343 #ifdef __cplusplus 00344 } 00345 #endif 00346 00347 #endif /* AUBIO_ONSET_H */
1.7.3