Changeset 2a4ce6d for src/pitch/pitchyinfast.c
- Timestamp:
- Oct 1, 2017, 11:44:42 AM (7 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
- Children:
- 16c12a1
- Parents:
- 5b194f0 (diff), 3e48568 (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/pitchyinfast.c
r5b194f0 r2a4ce6d 39 39 fvec_t *yin; 40 40 smpl_t tol; 41 smpl_t confidence;41 uint_t peak_pos; 42 42 fvec_t *tmpdata; 43 43 fvec_t *sqdiff; … … 60 60 o->fft = new_aubio_fft (bufsize); 61 61 o->tol = 0.15; 62 o->peak_pos = 0; 62 63 return o; 63 64 } … … 86 87 uint_t W = o->yin->length; // B / 2 87 88 fvec_t tmp_slice, kernel_ptr; 88 smpl_t *yin_data = yin->data;89 89 uint_t tau; 90 90 sint_t period; … … 143 143 // compute square difference r_t(tau) = sqdiff - 2 * r_t_tau[W-1:-1] 144 144 for (tau = 0; tau < W; tau++) { 145 yin _data[tau] = o->sqdiff->data[tau] - 2. * rt_of_tau->data[tau+W];145 yin->data[tau] = o->sqdiff->data[tau] - 2. * rt_of_tau->data[tau+W]; 146 146 } 147 147 } 148 148 149 149 // now build yin and look for first minimum 150 fvec_ set_all(out, 0.);151 yin _data[0] = 1.;150 fvec_zeros(out); 151 yin->data[0] = 1.; 152 152 for (tau = 1; tau < length; tau++) { 153 tmp2 += yin _data[tau];153 tmp2 += yin->data[tau]; 154 154 if (tmp2 != 0) { 155 155 yin->data[tau] *= tau / tmp2; … … 158 158 } 159 159 period = tau - 3; 160 if (tau > 4 && (yin_data[period] < tol) && 161 (yin_data[period] < yin_data[period + 1])) { 162 out->data[0] = fvec_quadratic_peak_pos (yin, period); 163 goto beach; 160 if (tau > 4 && (yin->data[period] < tol) && 161 (yin->data[period] < yin->data[period + 1])) { 162 o->peak_pos = (uint_t)period; 163 out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos); 164 return; 164 165 } 165 166 } 166 out->data[0] = fvec_quadratic_peak_pos (yin, fvec_min_elem (yin) );167 beach: 168 return;167 // use global minimum 168 o->peak_pos = (uint_t)fvec_min_elem (yin); 169 out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos); 169 170 } 170 171 171 172 smpl_t 172 173 aubio_pitchyinfast_get_confidence (aubio_pitchyinfast_t * o) { 173 o->confidence = 1. - fvec_min (o->yin); 174 return o->confidence; 174 return 1. - o->yin->data[o->peak_pos]; 175 175 } 176 176
Note: See TracChangeset
for help on using the changeset viewer.