Changes in / [b31a91c:b39a676]
- Files:
-
- 3 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/aubioonset.c
rb31a91c rb39a676 44 44 aubio_wavetable_stop ( wavetable ); 45 45 } 46 if (mix_input) {46 if (mix_input) 47 47 aubio_wavetable_do (wavetable, ibuf, obuf); 48 } else {48 else 49 49 aubio_wavetable_do (wavetable, obuf, obuf); 50 }51 50 } 52 51 … … 63 62 examples_common_init(argc,argv); 64 63 64 verbmsg ("using source: %s at %dHz\n", source_uri, samplerate); 65 verbmsg ("onset method: %s, ", onset_method); 66 verbmsg ("buffer_size: %d, ", buffer_size); 67 verbmsg ("hop_size: %d, ", hop_size); 68 verbmsg ("silence: %f, ", silence_threshold); 69 verbmsg ("threshold: %f\n", onset_threshold); 70 65 71 o = new_aubio_onset (onset_method, buffer_size, hop_size, samplerate); 66 72 if (o == NULL) { ret = 1; goto beach; } … … 71 77 if (onset_minioi != 0.) 72 78 aubio_onset_set_minioi_s (o, onset_minioi); 73 74 verbmsg ("using source: %s at %dHz\n", source_uri, samplerate);75 verbmsg ("onset method: %s, ", onset_method);76 verbmsg ("buffer_size: %d, ", buffer_size);77 verbmsg ("hop_size: %d, ", hop_size);78 verbmsg ("silence: %f, ", aubio_onset_get_silence(o));79 verbmsg ("threshold: %f, ", aubio_onset_get_threshold(o));80 verbmsg ("awhitening: %f, ", aubio_onset_get_awhitening(o));81 verbmsg ("compression: %f\n", aubio_onset_get_compression(o));82 79 83 80 onset = new_fvec (1); -
examples/aubiotrack.c
rb31a91c rb39a676 47 47 aubio_wavetable_stop ( wavetable ); 48 48 } 49 if (mix_input) {49 if (mix_input) 50 50 aubio_wavetable_do (wavetable, ibuf, obuf); 51 } else {51 else 52 52 aubio_wavetable_do (wavetable, obuf, obuf); 53 }54 53 } 55 54 -
python/lib/gen_code.py
rb31a91c rb39a676 184 184 def gen_code(self): 185 185 out = "" 186 try: 187 out += self.gen_struct() 188 out += self.gen_doc() 189 out += self.gen_new() 190 out += self.gen_init() 191 out += self.gen_del() 192 out += self.gen_do() 193 out += self.gen_memberdef() 194 out += self.gen_set() 195 out += self.gen_get() 196 out += self.gen_methodef() 197 out += self.gen_typeobject() 198 except Exception as e: 199 print ("Failed generating code for", self.shortname) 200 raise 186 out += self.gen_struct() 187 out += self.gen_doc() 188 out += self.gen_new() 189 out += self.gen_init() 190 out += self.gen_del() 191 out += self.gen_do() 192 out += self.gen_memberdef() 193 out += self.gen_set() 194 out += self.gen_get() 195 out += self.gen_methodef() 196 out += self.gen_typeobject() 201 197 return out 202 198 -
python/lib/gen_external.py
rb31a91c rb39a676 40 40 #'sampler', 41 41 'audio_unit', 42 'spectral_whitening',43 42 ] 44 43 -
src/aubio.h
rb31a91c rb39a676 188 188 #include "spectral/mfcc.h" 189 189 #include "spectral/specdesc.h" 190 #include "spectral/awhitening.h"191 190 #include "spectral/tss.h" 192 191 #include "pitch/pitch.h" -
src/cvec.c
rb31a91c rb39a676 140 140 cvec_phas_zeros(s); 141 141 } 142 143 void cvec_logmag(cvec_t *s, smpl_t lambda) {144 uint_t j;145 for (j=0; j< s->length; j++) {146 s->norm[j] = LOG(lambda * s->norm[j] + 1);147 }148 } -
src/cvec.h
rb31a91c rb39a676 231 231 void cvec_zeros(cvec_t *s); 232 232 233 /** take logarithmic magnitude234 235 \param s input cvec to compress236 \param lambda value to use for normalisation237 238 \f$ S_k = log( \lambda * S_k + 1 ) \f$239 240 */241 void cvec_logmag(cvec_t *s, smpl_t lambda);242 243 233 #ifdef __cplusplus 244 234 } -
src/mathutils.c
rb31a91c rb39a676 290 290 } 291 291 292 void fvec_push(fvec_t *in, smpl_t new_elem) {293 uint_t i;294 for (i = 0; i < in->length - 1; i++) {295 in->data[i] = in->data[i + 1];296 }297 in->data[in->length - 1] = new_elem;298 }299 300 void fvec_clamp(fvec_t *in, smpl_t absmax) {301 uint_t i;302 for (i = 0; i < in->length; i++) {303 if (in->data[i] > 0 && in->data[i] > ABS(absmax)) {304 in->data[i] = absmax;305 } else if (in->data[i] < 0 && in->data[i] < -ABS(absmax)) {306 in->data[i] = -absmax;307 }308 }309 }310 311 292 smpl_t 312 293 aubio_level_lin (const fvec_t * f) -
src/mathutils.h
rb31a91c rb39a676 117 117 */ 118 118 void fvec_ishift (fvec_t * v); 119 120 /** push a new element to the end of a vector, erasing the first element and121 * sliding all others122 123 \param in vector to push to124 \param new_elem new_element to add at the end of the vector125 126 In numpy words, this is equivalent to: in = np.concatenate([in, [new_elem]])[1:]127 128 */129 void fvec_push(fvec_t *in, smpl_t new_elem);130 119 131 120 /** compute the sum of all elements of a vector -
src/musicutils.h
rb31a91c rb39a676 157 157 smpl_t aubio_level_detection (const fvec_t * v, smpl_t threshold); 158 158 159 /** clamp the values of a vector within the range [-abs(max), abs(max)]160 161 \param in vector to clamp162 \param absmax maximum value over which input vector elements should be clamped163 164 */165 void fvec_clamp(fvec_t *in, smpl_t absmax);166 167 159 #ifdef __cplusplus 168 160 } -
src/onset/onset.c
rb31a91c rb39a676 24 24 #include "spectral/specdesc.h" 25 25 #include "spectral/phasevoc.h" 26 #include "spectral/awhitening.h"27 26 #include "onset/peakpicker.h" 28 27 #include "mathutils.h" 29 28 #include "onset/onset.h" 30 31 void aubio_onset_default_parameters (aubio_onset_t *o, const char_t * method);32 29 33 30 /** structure to store object state */ … … 46 43 uint_t total_frames; /**< total number of frames processed since the beginning */ 47 44 uint_t last_onset; /**< last detected onset location, in frames */ 48 49 uint_t apply_compression;50 smpl_t lambda_compression;51 uint_t apply_awhitening; /**< apply adaptive spectral whitening */52 aubio_spectral_whitening_t *spectral_whitening;53 45 }; 54 46 … … 58 50 smpl_t isonset = 0; 59 51 aubio_pvoc_do (o->pv,input, o->fftgrain); 60 /*61 if (apply_filtering) {62 }63 */64 if (o->apply_awhitening) {65 aubio_spectral_whitening_do(o->spectral_whitening, o->fftgrain);66 }67 if (o->apply_compression) {68 cvec_logmag(o->fftgrain, o->lambda_compression);69 }70 52 aubio_specdesc_do (o->od, o->fftgrain, o->desc); 71 53 aubio_peakpicker_do(o->pp, o->desc, onset); … … 118 100 } 119 101 120 uint_t aubio_onset_set_awhitening (aubio_onset_t *o, uint_t enable)121 {122 o->apply_awhitening = enable == 1 ? 1 : 0;123 return AUBIO_OK;124 }125 126 smpl_t aubio_onset_get_awhitening (aubio_onset_t *o)127 {128 return o->apply_awhitening;129 }130 131 uint_t aubio_onset_set_compression (aubio_onset_t *o, smpl_t lambda)132 {133 if (lambda < 0.) {134 return AUBIO_FAIL;135 }136 o->lambda_compression = lambda;137 o->apply_compression = (o->lambda_compression > 0.) ? 1 : 0;138 return AUBIO_OK;139 }140 141 smpl_t aubio_onset_get_compression (aubio_onset_t *o)142 {143 return o->apply_compression ? o->lambda_compression : 0;144 }145 146 102 uint_t aubio_onset_set_silence(aubio_onset_t * o, smpl_t silence) { 147 103 o->silence = silence; … … 253 209 o->fftgrain = new_cvec(buf_size); 254 210 o->desc = new_fvec(1); 255 o->spectral_whitening = new_aubio_spectral_whitening(buf_size, hop_size, samplerate); 211 212 /* set some default parameter */ 213 aubio_onset_set_threshold (o, 0.3); 214 aubio_onset_set_delay(o, 4.3 * hop_size); 215 aubio_onset_set_minioi_ms(o, 20.); 216 aubio_onset_set_silence(o, -70.); 256 217 257 218 /* initialize internal variables */ 258 aubio_onset_set_default_parameters (o, onset_mode); 259 260 aubio_onset_reset(o); 219 o->last_onset = 0; 220 o->total_frames = 0; 261 221 return o; 262 222 … … 269 229 } 270 230 271 void aubio_onset_reset (aubio_onset_t *o) {272 o->last_onset = 0;273 o->total_frames = 0;274 }275 276 uint_t aubio_onset_set_default_parameters (aubio_onset_t * o, const char_t * onset_mode)277 {278 uint_t ret = AUBIO_OK;279 /* set some default parameter */280 aubio_onset_set_threshold (o, 0.3);281 aubio_onset_set_delay (o, 4.3 * o->hop_size);282 aubio_onset_set_minioi_ms (o, 50.);283 aubio_onset_set_silence (o, -70.);284 // disable spectral whitening285 aubio_onset_set_awhitening (o, 0);286 // disable logarithmic magnitude287 aubio_onset_set_compression (o, 0.);288 289 /* method specific optimisations */290 if (strcmp (onset_mode, "energy") == 0) {291 } else if (strcmp (onset_mode, "hfc") == 0 || strcmp (onset_mode, "default") == 0) {292 aubio_onset_set_threshold (o, 0.058);293 aubio_onset_set_compression (o, 1.);294 } else if (strcmp (onset_mode, "complexdomain") == 0295 || strcmp (onset_mode, "complex") == 0) {296 aubio_onset_set_delay (o, 4.6 * o->hop_size);297 aubio_onset_set_threshold (o, 0.15);298 aubio_onset_set_awhitening(o, 1);299 aubio_onset_set_compression (o, 1.);300 } else if (strcmp (onset_mode, "phase") == 0) {301 o->apply_compression = 0;302 aubio_onset_set_awhitening (o, 0);303 } else if (strcmp (onset_mode, "mkl") == 0) {304 aubio_onset_set_threshold (o, 0.05);305 aubio_onset_set_awhitening(o, 1);306 aubio_onset_set_compression (o, 0.02);307 } else if (strcmp (onset_mode, "kl") == 0) {308 aubio_onset_set_threshold (o, 0.35);309 aubio_onset_set_awhitening(o, 1);310 aubio_onset_set_compression (o, 0.02);311 } else if (strcmp (onset_mode, "specflux") == 0) {312 aubio_onset_set_threshold (o, 0.25);313 aubio_onset_set_awhitening(o, 1);314 aubio_onset_set_compression (o, 20.);315 } else if (strcmp (onset_mode, "specdiff") == 0) {316 } else {317 AUBIO_WRN("onset: unknown spectral descriptor type %s, "318 "using default parameters.\n", onset_mode);319 ret = AUBIO_FAIL;320 }321 return ret;322 }323 324 231 void del_aubio_onset (aubio_onset_t *o) 325 232 { 326 del_aubio_spectral_whitening(o->spectral_whitening);327 233 del_aubio_specdesc(o->od); 328 234 del_aubio_peakpicker(o->pp); -
src/onset/onset.h
rb31a91c rb39a676 118 118 smpl_t aubio_onset_get_last_ms (const aubio_onset_t *o); 119 119 120 /** set onset detection adaptive whitening121 122 \param o onset detection object as returned by new_aubio_onset()123 \param enable 1 to enable, 0 to disable124 125 \return 0 if successful, 1 otherwise126 127 */128 uint_t aubio_onset_set_awhitening(aubio_onset_t * o, uint_t enable);129 130 /** get onset detection adaptive whitening131 132 \param o onset detection object as returned by new_aubio_onset()133 134 \return 1 if enabled, 0 otherwise135 136 */137 smpl_t aubio_onset_get_awhitening(aubio_onset_t * o);138 139 /** set or disable log compression140 141 \param o onset detection object as returned by new_aubio_onset()142 \param lambda logarithmic compression factor, 0 to disable143 144 \return 0 if successful, 1 otherwise145 146 */147 uint_t aubio_onset_set_compression(aubio_onset_t *o, smpl_t lambda);148 149 /** get onset detection log compression150 151 \param o onset detection object as returned by new_aubio_onset()152 153 \returns 0 if disabled, compression factor otherwise154 155 */156 smpl_t aubio_onset_get_compression(aubio_onset_t *o);157 158 120 /** set onset detection silence threshold 159 121 … … 312 274 */ 313 275 smpl_t aubio_onset_get_threshold(const aubio_onset_t * o); 314 315 /** set default parameters316 317 \param o onset detection object as returned by new_aubio_onset()318 \param onset_mode detection mode to adjust319 320 This function is called at the end of new_aubio_onset().321 322 */323 uint_t aubio_onset_set_default_parameters (aubio_onset_t * o, const char_t * onset_mode);324 325 /** reset onset detection326 327 \param o onset detection object as returned by new_aubio_onset()328 329 Reset current time and last onset to 0.330 331 This function is called at the end of new_aubio_onset().332 333 */334 void aubio_onset_reset(aubio_onset_t * o);335 276 336 277 /** delete onset detection object -
src/onset/peakpicker.c
rb31a91c rb39a676 93 93 fvec_t *scratch = p->scratch; 94 94 smpl_t mean = 0., median = 0.; 95 uint_t length = p->win_post + p->win_pre + 1; 95 96 uint_t j = 0; 96 97 97 /* push new novelty to the end */ 98 fvec_push(onset_keep, onset->data[0]); 99 /* store a copy */ 100 fvec_copy(onset_keep, onset_proc); 101 102 /* filter this copy */ 98 /* store onset in onset_keep */ 99 /* shift all elements but last, then write last */ 100 for (j = 0; j < length - 1; j++) { 101 onset_keep->data[j] = onset_keep->data[j + 1]; 102 onset_proc->data[j] = onset_keep->data[j]; 103 } 104 onset_keep->data[length - 1] = onset->data[0]; 105 onset_proc->data[length - 1] = onset->data[0]; 106 107 /* filter onset_proc */ 108 /** \bug filtfilt calculated post+pre times, should be only once !? */ 103 109 aubio_filter_do_filtfilt (p->biquad, onset_proc, scratch); 104 110 105 111 /* calculate mean and median for onset_proc */ 106 112 mean = fvec_mean (onset_proc); 107 108 /* copy to scratch and compute its median */109 fvec_copy(onset_proc, scratch);113 /* copy to scratch */ 114 for (j = 0; j < length; j++) 115 scratch->data[j] = onset_proc->data[j]; 110 116 median = p->thresholdfn (scratch); 111 117 -
src/spectral/specdesc.c
rb31a91c rb39a676 31 31 void aubio_specdesc_complex(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset); 32 32 void aubio_specdesc_phase(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset); 33 void aubio_specdesc_wphase(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);34 33 void aubio_specdesc_specdiff(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset); 35 34 void aubio_specdesc_kl(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset); … … 59 58 aubio_onset_complex, /**< complex domain */ 60 59 aubio_onset_phase, /**< phase fast */ 61 aubio_onset_wphase, /**< weighted phase */62 60 aubio_onset_kl, /**< Kullback Liebler */ 63 61 aubio_onset_mkl, /**< modified Kullback Liebler */ … … 160 158 onset->data[0] = aubio_hist_mean(o->histog); 161 159 //onset->data[0] = fvec_mean(o->dev1); 162 }163 164 /* weighted phase */165 void166 aubio_specdesc_wphase(aubio_specdesc_t *o,167 const cvec_t *fftgrain, fvec_t *onset) {168 uint_t i;169 aubio_specdesc_phase(o, fftgrain, onset);170 for (i = 0; i < fftgrain->length; i++) {171 o->dev1->data[i] *= fftgrain->norm[i];172 }173 /* apply o->histogram */174 aubio_hist_dyn_notnull(o->histog,o->dev1);175 /* weight it */176 aubio_hist_weight(o->histog);177 /* its mean is the result */178 onset->data[0] = aubio_hist_mean(o->histog);179 160 } 180 161 … … 270 251 else if (strcmp (onset_mode, "phase") == 0) 271 252 onset_type = aubio_onset_phase; 272 else if (strcmp (onset_mode, "wphase") == 0)273 onset_type = aubio_onset_wphase;274 253 else if (strcmp (onset_mode, "mkl") == 0) 275 254 onset_type = aubio_onset_mkl; … … 313 292 break; 314 293 case aubio_onset_phase: 315 case aubio_onset_wphase:316 294 o->dev1 = new_fvec(rsize); 317 295 o->theta1 = new_fvec(rsize); … … 348 326 o->funcpointer = aubio_specdesc_phase; 349 327 break; 350 case aubio_onset_wphase:351 o->funcpointer = aubio_specdesc_wphase;352 break;353 328 case aubio_onset_specdiff: 354 329 o->funcpointer = aubio_specdesc_specdiff; … … 404 379 break; 405 380 case aubio_onset_phase: 406 case aubio_onset_wphase:407 381 del_fvec(o->dev1); 408 382 del_fvec(o->theta1); -
src/spectral/specdesc.h
rb31a91c rb39a676 59 59 Conference on Acoustics Speech and Signal Processing, pages 441444, 60 60 Hong-Kong, 2003. 61 62 \b \p wphase : Weighted Phase Deviation onset detection function63 64 S. Dixon. Onset detection revisited. In Proceedings of the 9th International65 Conference on Digital Audio Ef- fects (DAFx) , pages 133–137, 2006.66 67 http://www.eecs.qmul.ac.uk/~simond/pub/2006/dafx.pdf68 61 69 62 \b \p specdiff : Spectral difference method onset detection function … … 182 175 The parameter \p method is a string that can be any of: 183 176 184 - onset novelty functions: `complex`, `energy`, `hfc`, `kl`, `mkl`, 185 `phase`, `specdiff`, `specflux`, `wphase`, 186 187 - spectral descriptors: `centroid`, `decrease`, `kurtosis`, `rolloff`, 188 `skewness`, `slope`, `spread`. 177 - `energy`, `hfc`, `complex`, `phase`, `specdiff`, `kl`, `mkl`, `specflux` 178 - `centroid`, `spread`, `skewness`, `kurtosis`, `slope`, `decrease`, `rolloff` 189 179 190 180 */ -
src/synth/wavetable.c
rb31a91c rb39a676 104 104 output->data[i] += input->data[i]; 105 105 } 106 fvec_clamp(output, 1.);107 106 } 108 107 }
Note: See TracChangeset
for help on using the changeset viewer.