Changeset 633400d for src/pitch/pitchyin.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/pitchyin.c
r5b46bc3 r633400d 37 37 fvec_t *yin; 38 38 smpl_t tol; 39 smpl_t confidence;39 uint_t peak_pos; 40 40 }; 41 41 42 #if 0 42 43 /** compute difference function 43 44 … … 61 62 */ 62 63 uint_t aubio_pitchyin_getpitch (const fvec_t * yinbuf); 64 #endif 63 65 64 66 aubio_pitchyin_t * … … 68 70 o->yin = new_fvec (bufsize / 2); 69 71 o->tol = 0.15; 72 o->peak_pos = 0; 70 73 return o; 71 74 } … … 78 81 } 79 82 83 #if 0 80 84 /* outputs the difference function */ 81 85 void … … 127 131 return 0; 128 132 } 129 133 #endif 130 134 131 135 /* all the above in one */ … … 133 137 aubio_pitchyin_do (aubio_pitchyin_t * o, const fvec_t * input, fvec_t * out) 134 138 { 135 smpl_t tol = o->tol; 136 fvec_t *yin = o->yin; 137 uint_t j, tau = 0; 139 const smpl_t tol = o->tol; 140 fvec_t* yin = o->yin; 141 const smpl_t *input_data = input->data; 142 const uint_t length = yin->length; 143 smpl_t *yin_data = yin->data; 144 uint_t j, tau; 138 145 sint_t period; 139 smpl_t tmp = 0., tmp2 = 0.; 140 yin->data[0] = 1.; 141 for (tau = 1; tau < yin->length; tau++) { 142 yin->data[tau] = 0.; 143 for (j = 0; j < yin->length; j++) { 144 tmp = input->data[j] - input->data[j + tau]; 145 yin->data[tau] += SQR (tmp); 146 smpl_t tmp, tmp2 = 0.; 147 148 yin_data[0] = 1.; 149 for (tau = 1; tau < length; tau++) { 150 yin_data[tau] = 0.; 151 for (j = 0; j < length; j++) { 152 tmp = input_data[j] - input_data[j + tau]; 153 yin_data[tau] += SQR (tmp); 146 154 } 147 tmp2 += yin ->data[tau];155 tmp2 += yin_data[tau]; 148 156 if (tmp2 != 0) { 149 157 yin->data[tau] *= tau / tmp2; … … 152 160 } 153 161 period = tau - 3; 154 if (tau > 4 && (yin->data[period] < tol) && 155 (yin->data[period] < yin->data[period + 1])) { 156 out->data[0] = fvec_quadratic_peak_pos (yin, period); 157 goto beach; 162 if (tau > 4 && (yin_data[period] < tol) && 163 (yin_data[period] < yin_data[period + 1])) { 164 o->peak_pos = (uint_t)period; 165 out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos); 166 return; 158 167 } 159 168 } 160 out->data[0] = fvec_quadratic_peak_pos (yin, fvec_min_elem (yin)); 161 beach: 162 return; 169 o->peak_pos = (uint_t)fvec_min_elem (yin); 170 out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos); 163 171 } 164 172 165 173 smpl_t 166 174 aubio_pitchyin_get_confidence (aubio_pitchyin_t * o) { 167 o->confidence = 1. - fvec_min (o->yin); 168 return o->confidence; 175 return 1. - o->yin->data[o->peak_pos]; 169 176 } 170 177
Note: See TracChangeset
for help on using the changeset viewer.