Changeset 3e48568
 Timestamp:
 Jul 30, 2017, 10:53:43 PM (3 years ago)
 Branches:
 feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
 Children:
 2a4ce6d
 Parents:
 34ce715
 Location:
 src/pitch
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

src/pitch/pitchyin.c
r34ce715 r3e48568 37 37 fvec_t *yin; 38 38 smpl_t tol; 39 smpl_t confidence;39 uint_t peak_pos; 40 40 }; 41 41 … … 68 68 o>yin = new_fvec (bufsize / 2); 69 69 o>tol = 0.15; 70 o>peak_pos = 0; 70 71 return o; 71 72 } … … 157 158 if (tau > 4 && (yin_data[period] < tol) && 158 159 (yin_data[period] < yin_data[period + 1])) { 159 out>data[0] = fvec_quadratic_peak_pos (yin, period); 160 goto beach; 160 o>peak_pos = (uint_t)period; 161 out>data[0] = fvec_quadratic_peak_pos (yin, o>peak_pos); 162 return; 161 163 } 162 164 } 163 out>data[0] = fvec_quadratic_peak_pos (yin, fvec_min_elem (yin)); 164 beach: 165 return; 165 o>peak_pos = (uint_t)fvec_min_elem (yin); 166 out>data[0] = fvec_quadratic_peak_pos (yin, o>peak_pos); 166 167 } 167 168 168 169 smpl_t 169 170 aubio_pitchyin_get_confidence (aubio_pitchyin_t * o) { 170 o>confidence = 1.  fvec_min (o>yin); 171 return o>confidence; 171 return 1.  o>yin>data[o>peak_pos]; 172 172 } 173 173 
src/pitch/pitchyinfast.c
r34ce715 r3e48568 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[W1: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 
src/pitch/pitchyinfft.c
r34ce715 r3e48568 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 }; … … 68 68 p>yinfft = new_fvec (bufsize / 2 + 1); 69 69 p>tol = 0.85; 70 p>peak_pos = 0; 70 71 p>win = new_aubio_window ("hanningz", bufsize); 71 72 p>weight = new_fvec (bufsize / 2 + 1); … … 162 163 halfperiod = FLOOR (tau / 2 + .5); 163 164 if (yin>data[halfperiod] < p>tol) 164 output>data[0] = fvec_quadratic_peak_pos (yin, halfperiod);165 p>peak_pos = halfperiod; 165 166 else 166 output>data[0] = fvec_quadratic_peak_pos (yin, tau); 167 p>peak_pos = tau; 168 output>data[0] = fvec_quadratic_peak_pos (yin, p>peak_pos); 167 169 } 168 170 } else { 171 p>peak_pos = 0; 169 172 output>data[0] = 0.; 170 173 } … … 186 189 smpl_t 187 190 aubio_pitchyinfft_get_confidence (aubio_pitchyinfft_t * o) { 188 o>confidence = 1.  fvec_min (o>yinfft); 189 return o>confidence; 191 return 1.  o>yinfft>data[o>peak_pos]; 190 192 } 191 193
Note: See TracChangeset
for help on using the changeset viewer.