- Timestamp:
- Apr 21, 2016, 7:32:58 PM (9 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
- Location:
- src/pitch
- Files:
-
- 14 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.; -
src/pitch/pitch.h
reaee767 rce3ff2b 108 108 109 109 */ 110 void aubio_pitch_do (aubio_pitch_t * o, fvec_t * in, fvec_t * out);110 void aubio_pitch_do (aubio_pitch_t * o, const fvec_t * in, fvec_t * out); 111 111 112 112 /** change yin or yinfft tolerance threshold … … 135 135 136 136 */ 137 aubio_pitch_t *new_aubio_pitch (c har_t * method,137 aubio_pitch_t *new_aubio_pitch (const char_t * method, 138 138 uint_t buf_size, uint_t hop_size, uint_t samplerate); 139 139 … … 146 146 147 147 */ 148 uint_t aubio_pitch_set_unit (aubio_pitch_t * o, c har_t * mode);148 uint_t aubio_pitch_set_unit (aubio_pitch_t * o, const char_t * mode); 149 149 150 150 /** set the silence threshold of the pitch detection object -
src/pitch/pitchfcomb.c
reaee767 rce3ff2b 64 64 /* input must be stepsize long */ 65 65 void 66 aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input, fvec_t * output)66 aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, const fvec_t * input, fvec_t * output) 67 67 { 68 68 uint_t k, l, maxharm = 0; -
src/pitch/pitchfcomb.h
reaee767 rce3ff2b 52 52 53 53 */ 54 void aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input,54 void aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, const fvec_t * input, 55 55 fvec_t * output); 56 56 -
src/pitch/pitchmcomb.c
reaee767 rce3ff2b 32 32 uint_t length); 33 33 uint_t aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, 34 fvec_t * X);35 void aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, fvec_t * oldmag);36 void aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, fvec_t * newmag);34 const fvec_t * X); 35 void aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, const fvec_t * oldmag); 36 void aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, const fvec_t * newmag); 37 37 /* not used but useful : sort by amplitudes (or anything else) 38 38 * sort_pitchpeak(peaks, length); … … 43 43 void aubio_pitchmcomb_sort_peak (aubio_spectralpeak_t * peaks, uint_t nbins); 44 44 /** select the best candidates */ 45 uint_t aubio_pitch_cands (aubio_pitchmcomb_t * p, c vec_t * fftgrain,45 uint_t aubio_pitch_cands (aubio_pitchmcomb_t * p, const cvec_t * fftgrain, 46 46 smpl_t * cands); 47 47 … … 102 102 103 103 void 104 aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, c vec_t * fftgrain, fvec_t * output)104 aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, const cvec_t * fftgrain, fvec_t * output) 105 105 { 106 106 uint_t j; … … 135 135 136 136 uint_t 137 aubio_pitch_cands (aubio_pitchmcomb_t * p, c vec_t * fftgrain, smpl_t * cands)137 aubio_pitch_cands (aubio_pitchmcomb_t * p, const cvec_t * fftgrain, smpl_t * cands) 138 138 { 139 139 uint_t j; … … 166 166 167 167 void 168 aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, fvec_t * newmag)168 aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, const fvec_t * newmag) 169 169 { 170 170 fvec_t *mag = (fvec_t *) p->scratch; … … 198 198 199 199 void 200 aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, fvec_t * newmag)200 aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, const fvec_t * newmag) 201 201 { 202 202 aubio_spectralpeak_t *peaks = (aubio_spectralpeak_t *) p->peaks; … … 286 286 */ 287 287 uint_t 288 aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, fvec_t * X)288 aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, const fvec_t * X) 289 289 { 290 290 uint_t j, ispeak, count = 0; -
src/pitch/pitchmcomb.h
reaee767 rce3ff2b 53 53 54 54 */ 55 void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, c vec_t * in_fftgrain,55 void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, const cvec_t * in_fftgrain, 56 56 fvec_t * out_cands); 57 57 -
src/pitch/pitchschmitt.c
reaee767 rce3ff2b 48 48 49 49 void 50 aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, fvec_t * input,50 aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, const fvec_t * input, 51 51 fvec_t * output) 52 52 { -
src/pitch/pitchschmitt.h
reaee767 rce3ff2b 52 52 53 53 */ 54 void aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, fvec_t * samples_in,54 void aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, const fvec_t * samples_in, 55 55 fvec_t * cands_out); 56 56 -
src/pitch/pitchspecacf.c
reaee767 rce3ff2b 55 55 56 56 void 57 aubio_pitchspecacf_do (aubio_pitchspecacf_t * p, fvec_t * input, fvec_t * output)57 aubio_pitchspecacf_do (aubio_pitchspecacf_t * p, const fvec_t * input, fvec_t * output) 58 58 { 59 59 uint_t l, tau; … … 92 92 93 93 smpl_t 94 aubio_pitchspecacf_get_confidence ( aubio_pitchspecacf_t * o) {94 aubio_pitchspecacf_get_confidence (const aubio_pitchspecacf_t * o) { 95 95 // no confidence for now 96 96 return o->confidence; … … 105 105 106 106 smpl_t 107 aubio_pitchspecacf_get_tolerance ( aubio_pitchspecacf_t * p)107 aubio_pitchspecacf_get_tolerance (const aubio_pitchspecacf_t * p) 108 108 { 109 109 return p->tol; -
src/pitch/pitchspecacf.h
reaee767 rce3ff2b 56 56 57 57 */ 58 void aubio_pitchspecacf_do (aubio_pitchspecacf_t * o, fvec_t * samples_in, fvec_t * cands_out);58 void aubio_pitchspecacf_do (aubio_pitchspecacf_t * o, const fvec_t * samples_in, fvec_t * cands_out); 59 59 /** creation of the pitch detection object 60 60 … … 77 77 78 78 */ 79 smpl_t aubio_pitchspecacf_get_tolerance ( aubio_pitchspecacf_t * o);79 smpl_t aubio_pitchspecacf_get_tolerance (const aubio_pitchspecacf_t * o); 80 80 81 81 /** set tolerance parameter for `specacf` pitch detection object … … 95 95 96 96 */ 97 smpl_t aubio_pitchspecacf_get_confidence ( aubio_pitchspecacf_t * o);97 smpl_t aubio_pitchspecacf_get_confidence (const aubio_pitchspecacf_t * o); 98 98 99 99 #ifdef __cplusplus -
src/pitch/pitchyin.c
reaee767 rce3ff2b 41 41 42 42 /** compute difference function 43 44 \param input input signal 43 44 \param input input signal 45 45 \param yinbuf output buffer to store difference function (half shorter than input) 46 46 … … 48 48 void aubio_pitchyin_diff (fvec_t * input, fvec_t * yinbuf); 49 49 50 /** in place computation of the YIN cumulative normalised function 51 52 \param yinbuf input signal (a square difference function), also used to store function 50 /** in place computation of the YIN cumulative normalised function 51 52 \param yinbuf input signal (a square difference function), also used to store function 53 53 54 54 */ … … 56 56 57 57 /** detect pitch in a YIN function 58 58 59 59 \param yinbuf input buffer as computed by aubio_pitchyin_getcum 60 60 61 61 */ 62 uint_t aubio_pitchyin_getpitch ( fvec_t * yinbuf);62 uint_t aubio_pitchyin_getpitch (const fvec_t * yinbuf); 63 63 64 64 aubio_pitchyin_t * … … 112 112 113 113 uint_t 114 aubio_pitchyin_getpitch ( fvec_t * yin)114 aubio_pitchyin_getpitch (const fvec_t * yin) 115 115 { 116 116 uint_t tau = 1; … … 131 131 /* all the above in one */ 132 132 void 133 aubio_pitchyin_do (aubio_pitchyin_t * o, fvec_t * input, fvec_t * out)133 aubio_pitchyin_do (aubio_pitchyin_t * o, const fvec_t * input, fvec_t * out) 134 134 { 135 135 smpl_t tol = o->tol; -
src/pitch/pitchyin.h
reaee767 rce3ff2b 67 67 68 68 */ 69 void aubio_pitchyin_do (aubio_pitchyin_t * o, fvec_t * samples_in, fvec_t * cands_out);69 void aubio_pitchyin_do (aubio_pitchyin_t * o, const fvec_t * samples_in, fvec_t * cands_out); 70 70 71 71 -
src/pitch/pitchyinfft.c
reaee767 rce3ff2b 99 99 100 100 void 101 aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, fvec_t * output)101 aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, const fvec_t * input, fvec_t * output) 102 102 { 103 103 uint_t tau, l; -
src/pitch/pitchyinfft.h
reaee767 rce3ff2b 53 53 54 54 */ 55 void aubio_pitchyinfft_do (aubio_pitchyinfft_t * o, fvec_t * samples_in, fvec_t * cands_out);55 void aubio_pitchyinfft_do (aubio_pitchyinfft_t * o, const fvec_t * samples_in, fvec_t * cands_out); 56 56 /** creation of the pitch detection object 57 57
Note: See TracChangeset
for help on using the changeset viewer.