- Timestamp:
- Oct 8, 2009, 8:49:10 PM (15 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:
- 7a6cbbe
- Parents:
- 2ba3440
- Location:
- src/pitch
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/pitch/pitchyinfft.c
r2ba3440 r22d33e2 34 34 aubio_fft_t * fft; /**< fft object to compute square difference function */ 35 35 fvec_t * yinfft; /**< Yin function */ 36 smpl_t tol; /**< Yin tolerance */ 36 37 }; 37 38 … … 55 56 p->res = new_cvec(bufsize,1); 56 57 p->yinfft = new_fvec(bufsize/2+1,1); 58 p->tol = 0.85; 57 59 p->win = new_aubio_window(bufsize, aubio_win_hanningz); 58 60 p->weight = new_fvec(bufsize/2+1,1); … … 88 90 } 89 91 90 smpl_t aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, smpl_t tol) {91 uint_t tau, l = 0;92 void aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, fvec_t * output) { 93 uint_t i, tau, l; 92 94 uint_t halfperiod; 93 smpl_t tmp = 0, sum = 0;95 smpl_t tmp, sum; 94 96 cvec_t * res = (cvec_t *)p->res; 95 97 fvec_t * yin = (fvec_t *)p->yinfft; 98 for (i=0; i < input->channels; i++){ 99 l = 0; tmp = 0.; sum = 0.; 96 100 for (l=0; l < input->length; l++){ 97 p->winput->data[0][l] = p->win->data[0][l] * input->data[ 0][l];101 p->winput->data[0][l] = p->win->data[0][l] * input->data[i][l]; 98 102 } 99 103 aubio_fft_do(p->fft,p->winput,p->fftout); … … 121 125 } 122 126 tau = fvec_min_elem(yin); 123 if (yin->data[0][tau] < tol) {127 if (yin->data[0][tau] < p->tol) { 124 128 /* no interpolation */ 125 129 //return tau; … … 128 132 /* additional check for (unlikely) octave doubling in higher frequencies */ 129 133 if (tau>35) { 130 returnfvec_quadint(yin,tau,1);134 output->data[i][0] = fvec_quadint(yin,tau,1); 131 135 } else { 132 136 /* should compare the minimum value of each interpolated peaks */ 133 137 halfperiod = FLOOR(tau/2+.5); 134 if (yin->data[0][halfperiod] < tol)135 returnfvec_quadint(yin,halfperiod,1);138 if (yin->data[0][halfperiod] < p->tol) 139 output->data[i][0] = fvec_quadint(yin,halfperiod,1); 136 140 else 137 returnfvec_quadint(yin,tau,1);141 output->data[i][0] = fvec_quadint(yin,tau,1); 138 142 } 139 } else 140 return 0.; 143 } else { 144 output->data[i][0] = 0.; 145 } 146 } 141 147 } 142 148 … … 152 158 AUBIO_FREE(p); 153 159 } 160 161 uint_t aubio_pitchyinfft_set_tolerance (aubio_pitchyinfft_t * p, smpl_t tol) { 162 p->tol = tol; 163 return 0; 164 } 165 166 smpl_t aubio_pitchyinfft_get_tolerance (aubio_pitchyinfft_t * p) { 167 return p->tol; 168 } -
src/pitch/pitchyinfft.h
r2ba3440 r22d33e2 46 46 \param p pitch detection object as returned by new_aubio_pitchyinfft 47 47 \param input input signal window (length as specified at creation time) 48 \param tol tolerance parameter for minima selection [default 0.85]48 \param output pitch period candidates, in samples 49 49 50 50 */ 51 smpl_t aubio_pitchyinfft_do (aubio_pitchyinfft_t *p, fvec_t * input, smpl_t tol);51 void aubio_pitchyinfft_do (aubio_pitchyinfft_t *p, fvec_t * input, fvec_t * output); 52 52 /** creation of the pitch detection object 53 53 … … 63 63 void del_aubio_pitchyinfft (aubio_pitchyinfft_t *p); 64 64 65 /** get tolerance parameter for YIN algorithm 66 67 \param o YIN pitch detection object 68 69 \return tolerance parameter for minima selection [default 0.15] 70 71 */ 72 smpl_t aubio_pitchyinfft_get_tolerance (aubio_pitchyinfft_t * p); 73 74 /** set tolerance parameter for YIN algorithm 75 76 \param o YIN pitch detection object 77 \param tol tolerance parameter for minima selection [default 0.15] 78 79 */ 80 uint_t aubio_pitchyinfft_set_tolerance (aubio_pitchyinfft_t * p, smpl_t tol); 81 65 82 #ifdef __cplusplus 66 83 }
Note: See TracChangeset
for help on using the changeset viewer.