- Timestamp:
- Oct 31, 2018, 10:26:52 PM (6 years ago)
- Branches:
- feature/constantq
- Children:
- c03d191
- Parents:
- 45c2c5c (diff), 7a54b37 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/aubio_priv.h
r45c2c5c r088760e 71 71 #endif 72 72 73 #if def HAVE_ACCELERATE73 #if defined(HAVE_ACCELERATE) 74 74 #define HAVE_ATLAS 1 75 #define HAVE_BLAS 1 75 76 #include <Accelerate/Accelerate.h> 76 77 #elif defined(HAVE_ATLAS_CBLAS_H) 78 #elif defined(HAVE_BLAS) 79 #if defined(HAVE_ATLAS_CBLAS_H) 77 80 #define HAVE_ATLAS 1 78 81 #include <atlas/cblas.h> 79 #else 80 #undef HAVE_ATLAS 82 #elif defined(HAVE_OPENBLAS_CBLAS_H) 83 #include <openblas/cblas.h> 84 #elif defined(HAVE_CBLAS_H) 85 #include <cblas.h> 86 #endif 81 87 #endif 82 88 … … 114 120 #endif /* HAVE_ACCELERATE */ 115 121 122 #if defined(HAVE_BLAS) 123 #ifndef HAVE_AUBIO_DOUBLE 116 124 #ifdef HAVE_ATLAS 117 #ifndef HAVE_AUBIO_DOUBLE118 125 #define aubio_catlas_set catlas_sset 126 #endif /* HAVE_ATLAS */ 119 127 #define aubio_cblas_copy cblas_scopy 120 128 #define aubio_cblas_swap cblas_sswap 121 129 #define aubio_cblas_dot cblas_sdot 122 130 #else /* HAVE_AUBIO_DOUBLE */ 131 #ifdef HAVE_ATLAS 123 132 #define aubio_catlas_set catlas_dset 133 #endif /* HAVE_ATLAS */ 124 134 #define aubio_cblas_copy cblas_dcopy 125 135 #define aubio_cblas_swap cblas_dswap 126 136 #define aubio_cblas_dot cblas_ddot 127 137 #endif /* HAVE_AUBIO_DOUBLE */ 128 #endif /* HAVE_ ATLAS */138 #endif /* HAVE_BLAS */ 129 139 130 140 #if defined HAVE_INTEL_IPP … … 161 171 #if !defined(HAVE_MEMCPY_HACKS) && !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS) && !defined(HAVE_INTEL_IPP) 162 172 #define HAVE_NOOPT 1 163 #else164 #undef HAVE_NOOPT165 173 #endif 166 174 -
src/fmat.c
r45c2c5c r088760e 161 161 assert(s->length == scale->length); 162 162 #endif 163 #if !defined(HAVE_ACCELERATE) && !defined(HAVE_ ATLAS)163 #if !defined(HAVE_ACCELERATE) && !defined(HAVE_BLAS) 164 164 uint_t j; 165 165 fvec_zeros(output); … … 170 170 } 171 171 } 172 #elif defined(HAVE_ ATLAS)172 #elif defined(HAVE_BLAS) 173 173 for (k = 0; k < s->height; k++) { 174 174 output->data[k] = aubio_cblas_dot( s->length, scale->data, 1, s->data[k], 1); -
src/fvec.c
r45c2c5c r088760e 135 135 #if defined(HAVE_INTEL_IPP) 136 136 aubio_ippsCopy(s->data, t->data, (int)s->length); 137 #elif defined(HAVE_ ATLAS)137 #elif defined(HAVE_BLAS) 138 138 aubio_cblas_copy(s->length, s->data, 1, t->data, 1); 139 139 #elif defined(HAVE_ACCELERATE) -
src/io/source_avcodec.c
r45c2c5c r088760e 35 35 // determine whether we use libavformat from ffmpeg or from libav 36 36 #define FFMPEG_LIBAVFORMAT (LIBAVFORMAT_VERSION_MICRO > 99 ) 37 // max_analyze_duration2 was used from ffmpeg libavformat 55.43.100 through57.2.10037 // max_analyze_duration2 was used from ffmpeg libavformat 55.43.100 -> 57.2.100 38 38 #define FFMPEG_LIBAVFORMAT_MAX_DUR2 FFMPEG_LIBAVFORMAT && ( \ 39 39 (LIBAVFORMAT_VERSION_MAJOR == 55 && LIBAVFORMAT_VERSION_MINOR >= 43) \ … … 93 93 }; 94 94 95 // hack to create or re-create the context the first time _do or _do_multi is called 96 void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi); 97 void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples); 95 // create or re-create the context when _do or _do_multi is called 96 void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, 97 uint_t multi); 98 // actually read a frame 99 void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, 100 uint_t * read_samples); 98 101 99 102 uint_t aubio_source_avcodec_has_network_url(aubio_source_avcodec_t *s); … … 112 115 113 116 114 aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path, uint_t samplerate, uint_t hop_size) { 117 aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path, 118 uint_t samplerate, uint_t hop_size) { 115 119 aubio_source_avcodec_t * s = AUBIO_NEW(aubio_source_avcodec_t); 116 120 AVFormatContext *avFormatCtx = s->avFormatCtx; … … 129 133 } 130 134 if ((sint_t)samplerate < 0) { 131 AUBIO_ERR("source_avcodec: Can not open %s with samplerate %d\n", path, samplerate); 135 AUBIO_ERR("source_avcodec: Can not open %s with samplerate %d\n", 136 path, samplerate); 132 137 goto beach; 133 138 } 134 139 if ((sint_t)hop_size <= 0) { 135 AUBIO_ERR("source_avcodec: Can not open %s with hop_size %d\n", path, hop_size); 140 AUBIO_ERR("source_avcodec: Can not open %s with hop_size %d\n", 141 path, hop_size); 136 142 goto beach; 137 143 } … … 173 179 char errorstr[256]; 174 180 av_strerror (err, errorstr, sizeof(errorstr)); 175 AUBIO_ERR("source_avcodec: Could not find stream information " "for %s (%s)\n", s->path,176 errorstr);181 AUBIO_ERR("source_avcodec: Could not find stream information " 182 "for %s (%s)\n", s->path, errorstr); 177 183 goto beach; 178 184 } … … 214 220 avCodecCtx = avcodec_alloc_context3(codec); 215 221 if (!avCodecCtx) { 216 AUBIO_ERR("source_avcodec: Failed to allocate the %s codec context for path %s\n", 217 av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path); 222 AUBIO_ERR("source_avcodec: Failed to allocate the %s codec context " 223 "for path %s\n", av_get_media_type_string(AVMEDIA_TYPE_AUDIO), 224 s->path); 218 225 goto beach; 219 226 } … … 230 237 /* Copy codec parameters from input stream to output codec context */ 231 238 if ((err = avcodec_parameters_to_context(avCodecCtx, codecpar)) < 0) { 232 AUBIO_ERR("source_avcodec: Failed to copy %s codec parameters to decoder context for %s\n", 233 av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path); 239 AUBIO_ERR("source_avcodec: Failed to copy %s codec parameters to " 240 "decoder context for %s\n", 241 av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path); 234 242 goto beach; 235 243 } … … 239 247 char errorstr[256]; 240 248 av_strerror (err, errorstr, sizeof(errorstr)); 241 AUBIO_ERR("source_avcodec: Could not load codec for %s (%s)\n", s->path, errorstr); 249 AUBIO_ERR("source_avcodec: Could not load codec for %s (%s)\n", s->path, 250 errorstr); 242 251 goto beach; 243 252 } … … 266 275 267 276 /* allocate output for avr */ 268 s->output = (smpl_t *)av_malloc(AUBIO_AVCODEC_MAX_BUFFER_SIZE * sizeof(smpl_t)); 277 s->output = (smpl_t *)av_malloc(AUBIO_AVCODEC_MAX_BUFFER_SIZE 278 * sizeof(smpl_t)); 269 279 270 280 s->read_samples = 0; … … 294 304 } 295 305 296 void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi) { 306 void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, 307 uint_t multi) 308 { 297 309 // create or reset resampler to/from mono/multi-channel 298 310 if ( (multi != s->multi) || (s->avr == NULL) ) { … … 309 321 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 310 322 311 av_opt_set_int(avr, "in_channel_layout", input_layout, 0);312 av_opt_set_int(avr, "out_channel_layout", output_layout, 0);313 av_opt_set_int(avr, "in_sample_rate", s->input_samplerate, 0);314 av_opt_set_int(avr, "out_sample_rate", s->samplerate, 0);323 av_opt_set_int(avr, "in_channel_layout", input_layout, 0); 324 av_opt_set_int(avr, "out_channel_layout", output_layout, 0); 325 av_opt_set_int(avr, "in_sample_rate", s->input_samplerate, 0); 326 av_opt_set_int(avr, "out_sample_rate", s->samplerate, 0); 315 327 av_opt_set_int(avr, "in_sample_fmt", s->avCodecCtx->sample_fmt, 0); 316 328 #if HAVE_AUBIO_DOUBLE 317 av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_DBL, 0);318 #else 319 av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_FLT, 0);329 av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_DBL, 0); 330 #else 331 av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_FLT, 0); 320 332 #endif 321 333 // TODO: use planar? … … 329 341 char errorstr[256]; 330 342 av_strerror (err, errorstr, sizeof(errorstr)); 331 AUBIO_ERR("source_avcodec: Could not open resampling context for %s (%s)\n",332 s->path, errorstr);343 AUBIO_ERR("source_avcodec: Could not open resampling context" 344 " for %s (%s)\n", s->path, errorstr); 333 345 return; 334 346 } … … 347 359 } 348 360 349 void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples) { 361 void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, 362 uint_t * read_samples) 363 { 350 364 AVFormatContext *avFormatCtx = s->avFormatCtx; 351 365 AVCodecContext *avCodecCtx = s->avCodecCtx; … … 388 402 char errorstr[256]; 389 403 av_strerror (err, errorstr, sizeof(errorstr)); 390 AUBIO_ERR("source_avcodec: could not read frame in %s (%s)\n", s->path, errorstr); 404 AUBIO_ERR("source_avcodec: could not read frame in %s (%s)\n", 405 s->path, errorstr); 391 406 s->eof = 1; 392 407 goto beach; … … 406 421 if (ret < 0) { 407 422 if (ret == AVERROR(EAGAIN)) { 408 //AUBIO_WRN("source_avcodec: output is not available right now - user must try to send new input\n"); 423 //AUBIO_WRN("source_avcodec: output is not available right now - " 424 // "user must try to send new input\n"); 409 425 goto beach; 410 426 } else if (ret == AVERROR_EOF) { 411 AUBIO_WRN("source_avcodec: the decoder has been fully flushed, and there will be no more output frames\n"); 427 AUBIO_WRN("source_avcodec: the decoder has been fully flushed, " 428 "and there will be no more output frames\n"); 412 429 } else { 413 430 AUBIO_ERR("source_avcodec: decoding errors on %s\n", s->path); … … 424 441 #endif 425 442 if (got_frame == 0) { 426 AUBIO_WRN("source_avcodec: did not get a frame when reading %s\n", s->path); 443 AUBIO_WRN("source_avcodec: did not get a frame when reading %s\n", 444 s->path); 427 445 goto beach; 428 446 } … … 431 449 if (avFrame->channels != (sint_t)s->input_channels) { 432 450 AUBIO_WRN ("source_avcodec: trying to read from %d channel(s)," 433 "but configured for %d; is '%s' corrupt?\n", avFrame->channels, 434 s->input_channels, s->path); 435 goto beach; 436 } 451 "but configured for %d; is '%s' corrupt?\n", 452 avFrame->channels, s->input_channels, s->path); 453 goto beach; 454 } 455 #else 456 #warning "avutil < 53 is deprecated, crashes might occur on corrupt files" 437 457 #endif 438 458 … … 455 475 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 456 476 if (out_samples <= 0) { 457 AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n", s->path); 477 AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n", 478 s->path); 458 479 goto beach; 459 480 } … … 473 494 } 474 495 475 void aubio_source_avcodec_do(aubio_source_avcodec_t * s, fvec_t * read_data, uint_t * read){ 496 void aubio_source_avcodec_do(aubio_source_avcodec_t * s, fvec_t * read_data, 497 uint_t * read) { 476 498 uint_t i; 477 499 uint_t end = 0; … … 505 527 } 506 528 507 void aubio_source_avcodec_do_multi(aubio_source_avcodec_t * s, fmat_t * read_data, uint_t * read){ 529 void aubio_source_avcodec_do_multi(aubio_source_avcodec_t * s, 530 fmat_t * read_data, uint_t * read) { 508 531 uint_t i,j; 509 532 uint_t end = 0; … … 551 574 552 575 uint_t aubio_source_avcodec_seek (aubio_source_avcodec_t * s, uint_t pos) { 553 int64_t resampled_pos = (uint_t)ROUND(pos * (s->input_samplerate * 1. / s->samplerate)); 576 int64_t resampled_pos = 577 (uint_t)ROUND(pos * (s->input_samplerate * 1. / s->samplerate)); 554 578 int64_t min_ts = MAX(resampled_pos - 2000, 0); 555 579 int64_t max_ts = MIN(resampled_pos + 2000, INT64_MAX); … … 559 583 ret = AUBIO_OK; 560 584 } else { 561 AUBIO_ERR("source_avcodec: failed seeking in %s (file not opened?)", s->path); 585 AUBIO_ERR("source_avcodec: failed seeking in %s (file not opened?)", 586 s->path); 562 587 return ret; 563 588 } … … 570 595 min_ts, resampled_pos, max_ts, seek_flags); 571 596 if (ret < 0) { 572 AUBIO_ERR("source_avcodec: failed seeking to %d in file %s", pos, s->path); 597 AUBIO_ERR("source_avcodec: failed seeking to %d in file %s", 598 pos, s->path); 573 599 } 574 600 // reset read status -
src/mathutils.c
r45c2c5c r088760e 272 272 // if length is odd, middle element is moved to the end 273 273 if (2 * half < s->length) start ++; 274 #ifndef HAVE_ ATLAS274 #ifndef HAVE_BLAS 275 275 for (j = 0; j < half; j++) { 276 276 ELEM_SWAP (s->data[j], s->data[j + start]); … … 292 292 // if length is odd, middle element is moved to the beginning 293 293 if (2 * half < s->length) start ++; 294 #ifndef HAVE_ ATLAS294 #ifndef HAVE_BLAS 295 295 for (j = 0; j < half; j++) { 296 296 ELEM_SWAP (s->data[j], s->data[j + start]); … … 329 329 { 330 330 smpl_t energy = 0.; 331 #ifndef HAVE_ ATLAS331 #ifndef HAVE_BLAS 332 332 uint_t j; 333 333 for (j = 0; j < f->length; j++) { … … 523 523 /* log(freq/A-2)/log(2) */ 524 524 midi = freq / 6.875; 525 midi = LOG (midi) / 0.6931471805599 5;525 midi = LOG (midi) / 0.6931471805599453; 526 526 midi *= 12; 527 527 midi -= 3; … … 535 535 if (midi > 140.) return 0.; // avoid infs 536 536 freq = (midi + 3.) / 12.; 537 freq = EXP (freq * 0.6931471805599 5);537 freq = EXP (freq * 0.6931471805599453); 538 538 freq *= 6.875; 539 539 return freq; -
src/notes/notes.c
r45c2c5c r088760e 1 1 /* 2 Copyright (C) 2014 Paul Brossier <piem@aubio.org>2 Copyright (C) 2014-2018 Paul Brossier <piem@aubio.org> 3 3 4 4 This file is part of aubio. … … 26 26 27 27 #define AUBIO_DEFAULT_NOTES_SILENCE -70. 28 #define AUBIO_DEFAULT_NOTES_RELEASE_DROP 10. 28 29 // increase to 10. for .1 cent precision 29 30 // or to 100. for .01 cent precision … … 57 58 58 59 uint_t isready; 60 61 smpl_t last_onset_level; 62 smpl_t release_drop_level; 59 63 }; 60 64 … … 102 106 aubio_notes_set_minioi_ms (o, AUBIO_DEFAULT_NOTES_MINIOI_MS); 103 107 108 o->last_onset_level = AUBIO_DEFAULT_NOTES_SILENCE; 109 o->release_drop_level = AUBIO_DEFAULT_NOTES_RELEASE_DROP; 110 104 111 return o; 105 112 … … 139 146 { 140 147 return aubio_onset_get_minioi_ms(o->onset); 148 } 149 150 uint_t aubio_notes_set_release_drop(aubio_notes_t *o, smpl_t release_drop_level) 151 { 152 uint_t err = AUBIO_OK; 153 if (release_drop_level <= 0.) { 154 AUBIO_ERR("notes: release_drop should be >= 0, got %f\n", release_drop_level); 155 err = AUBIO_FAIL; 156 } else { 157 o->release_drop_level = release_drop_level; 158 } 159 return err; 160 } 161 162 smpl_t aubio_notes_get_release_drop(const aubio_notes_t *o) 163 { 164 return o->release_drop_level; 141 165 } 142 166 … … 185 209 //notes->data[0] = o->curnote; 186 210 //notes->data[1] = 0.; 211 //AUBIO_WRN("notes: sending note-off at onset, not enough level\n"); 187 212 notes->data[2] = o->curnote; 188 213 } else { … … 192 217 /* kill old note */ 193 218 //send_noteon(o->curnote,0, o->samplerate); 219 //AUBIO_WRN("notes: sending note-off at onset, new onset detected\n"); 194 220 notes->data[2] = o->curnote; 195 221 /* get and send new one */ … … 199 225 o->curnote = new_pitch; 200 226 } 227 o->last_onset_level = curlevel; 201 228 } 202 229 } else { 203 if (o->median) { 230 if (curlevel < o->last_onset_level - o->release_drop_level) 231 { 232 // send note off 233 //AUBIO_WRN("notes: sending note-off, release detected\n"); 234 notes->data[0] = 0; 235 notes->data[1] = 0; 236 notes->data[2] = o->curnote; 237 // reset last_onset_level to silence_threshold 238 o->last_onset_level = o->silence_threshold; 239 o->curnote = 0; 240 } 241 else if (o->median) 242 { 204 243 if (o->isready > 0) 205 244 o->isready++; … … 208 247 /* kill old note */ 209 248 //send_noteon(curnote,0); 210 notes->data[2] = o->curnote; 249 if (o->curnote != 0) 250 { 251 //AUBIO_WRN("notes: sending note-off, new note detected\n"); 252 notes->data[2] = o->curnote; 253 } 211 254 o->newnote = aubio_notes_get_latest_note(o); 212 255 o->curnote = o->newnote; -
src/notes/notes.h
r45c2c5c r088760e 107 107 uint_t aubio_notes_set_minioi_ms (aubio_notes_t *o, smpl_t minioi_ms); 108 108 109 /** get notes object release drop level, in dB 110 111 \param o notes detection object as returned by new_aubio_notes() 112 113 \return current release drop level, in dB 114 115 */ 116 smpl_t aubio_notes_get_release_drop (const aubio_notes_t *o); 117 118 /** set note release drop level, in dB 119 120 This function sets the release_drop_level parameter, in dB. When a new note 121 is found, the current level in dB is measured. If the measured level drops 122 under that initial level - release_drop_level, then a note-off will be 123 emitted. 124 125 Defaults to `10`, in dB. 126 127 \note This parameter was added in version `0.4.8`. Results obtained with 128 earlier versions can be reproduced by setting this value to `100`, so that 129 note-off will not be played until the next note. 130 131 \param o notes detection object as returned by new_aubio_notes() 132 \param release_drop new release drop level, in dB 133 134 \return 0 on success, non-zero otherwise 135 136 */ 137 uint_t aubio_notes_set_release_drop (aubio_notes_t *o, smpl_t release_drop); 138 109 139 #ifdef __cplusplus 110 140 } -
src/spectral/filterbank_mel.h
r45c2c5c r088760e 59 59 60 60 The filter coefficients are built according to Malcolm Slaney's Auditory 61 Toolbox, available at http://engineering.purdue.edu/~malcolm/interval/1998-010/ 62 (see file mfcc.m). 61 Toolbox, available online at the following address (see file mfcc.m): 62 63 https://engineering.purdue.edu/~malcolm/interval/1998-010/ 63 64 64 65 */ -
src/spectral/mfcc.c
r45c2c5c r088760e 32 32 #include "spectral/mfcc.h" 33 33 34 #undef HAVE_SLOW_DCT 34 #ifdef HAVE_NOOPT 35 #define HAVE_SLOW_DCT 1 36 #endif 35 37 36 38 /** Internal structure for mfcc object */ -
src/spectral/mfcc.h
r45c2c5c r088760e 27 27 28 28 The implementation follows the specifications established by Malcolm Slaney 29 in its Auditory Toolbox, available online (see file mfcc.m). 29 in its Auditory Toolbox, available online at the following address (see 30 file mfcc.m): 30 31 31 http ://engineering.ecn.purdue.edu/~malcolm/interval/1998-010/32 https://engineering.purdue.edu/~malcolm/interval/1998-010/ 32 33 33 34 \example spectral/test-mfcc.c -
src/spectral/phasevoc.c
r45c2c5c r088760e 213 213 synthold[i] += synth[i + pv->hop_s] * pv->scale; 214 214 } 215 216 uint_t aubio_pvoc_get_win(aubio_pvoc_t* pv) 217 { 218 return pv->win_s; 219 } 220 221 uint_t aubio_pvoc_get_hop(aubio_pvoc_t* pv) 222 { 223 return pv->hop_s; 224 } -
src/spectral/phasevoc.h
r45c2c5c r088760e 89 89 */ 90 90 uint_t aubio_pvoc_get_win(aubio_pvoc_t* pv); 91 91 92 /** get hop size 92 93 -
src/synth/wavetable.c
r45c2c5c r088760e 165 165 aubio_wavetable_set_amp (s, 0.); 166 166 //s->last_pos = 0; 167 return aubio_wavetable_set_playing (s, 1);167 return aubio_wavetable_set_playing (s, 0); 168 168 } 169 169 -
src/synth/wavetable.h
r45c2c5c r088760e 51 51 */ 52 52 aubio_wavetable_t * new_aubio_wavetable(uint_t samplerate, uint_t hop_size); 53 54 /** load source in wavetable55 56 \param o wavetable, created by new_aubio_wavetable()57 \param uri the uri of the source to load58 59 \return 0 if successful, non-zero otherwise60 61 */62 uint_t aubio_wavetable_load( aubio_wavetable_t * o, const char_t * uri );63 53 64 54 /** process wavetable function
Note: See TracChangeset
for help on using the changeset viewer.