Changeset 633400d for src/pitch/pitchyinfft.c
- Timestamp:
- Dec 5, 2018, 10:34:39 PM (5 years ago)
- Branches:
- feature/cnn, feature/crepe, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
- Children:
- 283a619a
- Parents:
- 5b46bc3 (diff), f19db54 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/pitch/pitchyinfft.c
r5b46bc3 r633400d 37 37 fvec_t *yinfft; /**< Yin function */ 38 38 smpl_t tol; /**< Yin tolerance */ 39 smpl_t confidence; /**< confidence*/39 uint_t peak_pos; /**< currently selected peak pos*/ 40 40 uint_t short_period; /** shortest period under which to check for octave error */ 41 41 }; … … 45 45 160., 200., 250., 315., 400., 500., 630., 800., 1000., 1250., 46 46 1600., 2000., 2500., 3150., 4000., 5000., 6300., 8000., 9000., 10000., 47 12500., 15000., 20000., 25100 47 12500., 15000., 20000., 25100., -1. 48 48 }; 49 49 … … 63 63 p->winput = new_fvec (bufsize); 64 64 p->fft = new_aubio_fft (bufsize); 65 if (!p->fft) goto beach; 65 66 p->fftout = new_fvec (bufsize); 66 67 p->sqrmag = new_fvec (bufsize); 67 68 p->yinfft = new_fvec (bufsize / 2 + 1); 68 69 p->tol = 0.85; 70 p->peak_pos = 0; 69 71 p->win = new_aubio_window ("hanningz", bufsize); 70 72 p->weight = new_fvec (bufsize / 2 + 1); 71 73 for (i = 0; i < p->weight->length; i++) { 72 74 freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) samplerate; 73 while (freq > freqs[j]) { 75 while (freq > freqs[j] && freqs[j] > 0) { 76 //AUBIO_DBG("freq %3.5f > %3.5f \tsamplerate %d (Hz) \t" 77 // "(weight length %d, bufsize %d) %d %d\n", freq, freqs[j], 78 // samplerate, p->weight->length, bufsize, i, j); 74 79 j += 1; 75 80 } … … 96 101 p->short_period = (uint_t)ROUND(samplerate / 1300.); 97 102 return p; 103 104 beach: 105 if (p->winput) del_fvec(p->winput); 106 AUBIO_FREE(p); 107 return NULL; 98 108 } 99 109 … … 156 166 halfperiod = FLOOR (tau / 2 + .5); 157 167 if (yin->data[halfperiod] < p->tol) 158 output->data[0] = fvec_quadratic_peak_pos (yin, halfperiod);168 p->peak_pos = halfperiod; 159 169 else 160 output->data[0] = fvec_quadratic_peak_pos (yin, tau); 170 p->peak_pos = tau; 171 output->data[0] = fvec_quadratic_peak_pos (yin, p->peak_pos); 161 172 } 162 173 } else { 174 p->peak_pos = 0; 163 175 output->data[0] = 0.; 164 176 } … … 180 192 smpl_t 181 193 aubio_pitchyinfft_get_confidence (aubio_pitchyinfft_t * o) { 182 o->confidence = 1. - fvec_min (o->yinfft); 183 return o->confidence; 194 return 1. - o->yinfft->data[o->peak_pos]; 184 195 } 185 196
Note: See TracChangeset
for help on using the changeset viewer.