Changeset ce3ff2b for src/pitch/pitch.c
- Timestamp:
- Apr 21, 2016, 7:32:58 PM (8 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- feb694b
- Parents:
- eaee767
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/pitch/pitch.c
reaee767 rce3ff2b 62 62 63 63 /** callback to get pitch candidate, defined below */ 64 typedef void (*aubio_pitch_detect_t) (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);64 typedef void (*aubio_pitch_detect_t) (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 65 65 66 66 /** callback to convert pitch from one unit to another, defined below */ … … 79 79 void *p_object; /**< pointer to pitch object */ 80 80 aubio_filter_t *filter; /**< filter */ 81 fvec_t *filtered; /**< filtered input */ 81 82 aubio_pvoc_t *pv; /**< phase vocoder for mcomb */ 82 83 cvec_t *fftgrain; /**< spectral frame for mcomb */ … … 89 90 90 91 /* callback functions for pitch detection */ 91 static void aubio_pitch_do_mcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);92 static void aubio_pitch_do_yin (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);93 static void aubio_pitch_do_schmitt (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);94 static void aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);95 static void aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);96 static void aubio_pitch_do_specacf (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);92 static void aubio_pitch_do_mcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 93 static void aubio_pitch_do_yin (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 94 static void aubio_pitch_do_schmitt (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 95 static void aubio_pitch_do_fcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 96 static void aubio_pitch_do_yinfft (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 97 static void aubio_pitch_do_specacf (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 97 98 98 99 /* conversion functions for frequency conversions */ … … 102 103 103 104 /* adapter to stack ibuf new samples at the end of buf, and trim `buf` to `bufsize` */ 104 void aubio_pitch_slideblock (aubio_pitch_t * p, fvec_t * ibuf);105 void aubio_pitch_slideblock (aubio_pitch_t * p, const fvec_t * ibuf); 105 106 106 107 107 108 aubio_pitch_t * 108 new_aubio_pitch (c har_t * pitch_mode,109 new_aubio_pitch (const char_t * pitch_mode, 109 110 uint_t bufsize, uint_t hopsize, uint_t samplerate) 110 111 { … … 161 162 break; 162 163 case aubio_pitcht_mcomb: 164 p->filtered = new_fvec (hopsize); 163 165 p->pv = new_aubio_pvoc (bufsize, hopsize); 164 166 p->fftgrain = new_cvec (bufsize); … … 210 212 break; 211 213 case aubio_pitcht_mcomb: 214 del_fvec (p->filtered); 212 215 del_aubio_pvoc (p->pv); 213 216 del_cvec (p->fftgrain); … … 238 241 239 242 void 240 aubio_pitch_slideblock (aubio_pitch_t * p, fvec_t * ibuf)243 aubio_pitch_slideblock (aubio_pitch_t * p, const fvec_t * ibuf) 241 244 { 242 245 uint_t overlap_size = p->buf->length - ibuf->length; … … 258 261 259 262 uint_t 260 aubio_pitch_set_unit (aubio_pitch_t * p, c har_t * pitch_unit)263 aubio_pitch_set_unit (aubio_pitch_t * p, const char_t * pitch_unit) 261 264 { 262 265 uint_t err = AUBIO_OK; … … 343 346 /* do method, calling the detection callback, then the conversion callback */ 344 347 void 345 aubio_pitch_do (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)348 aubio_pitch_do (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) 346 349 { 347 350 p->detect_cb (p, ibuf, obuf); … … 354 357 /* do method for each algorithm */ 355 358 void 356 aubio_pitch_do_mcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)357 { 358 aubio_filter_do (p->filter, ibuf);359 aubio_pitch_do_mcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) 360 { 361 aubio_filter_do_outplace (p->filter, ibuf, p->filtered); 359 362 aubio_pvoc_do (p->pv, ibuf, p->fftgrain); 360 363 aubio_pitchmcomb_do (p->p_object, p->fftgrain, obuf); … … 363 366 364 367 void 365 aubio_pitch_do_yin (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)368 aubio_pitch_do_yin (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) 366 369 { 367 370 smpl_t pitch = 0.; … … 379 382 380 383 void 381 aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)384 aubio_pitch_do_yinfft (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) 382 385 { 383 386 smpl_t pitch = 0.; … … 394 397 395 398 void 396 aubio_pitch_do_specacf (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out)399 aubio_pitch_do_specacf (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out) 397 400 { 398 401 smpl_t pitch = 0., period; … … 410 413 411 414 void 412 aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out)415 aubio_pitch_do_fcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out) 413 416 { 414 417 aubio_pitch_slideblock (p, ibuf); … … 418 421 419 422 void 420 aubio_pitch_do_schmitt (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out)423 aubio_pitch_do_schmitt (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out) 421 424 { 422 425 smpl_t period, pitch = 0.;
Note: See TracChangeset
for help on using the changeset viewer.