Changeset 422a2a9
 Timestamp:
 Feb 2, 2017, 2:29:43 AM (4 years ago)
 Branches:
 yinfft+
 Children:
 5bdbb83
 Parents:
 09558b8
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/pitch/pitchyinfft.c
r09558b8 r422a2a9 115 115 fvec_t *yin = p>yinfft; 116 116 smpl_t tmp = 0., sum = 0.; 117 uint_t startbin = 0, endbin = 0, before = 0, after = 0; 117 // empirically derived peak width to look for 118 uint_t lookafter = yin>length / 128, endbin; 118 119 119 120 // window the input … … 159 160 } 160 161 161 // choose lowest confident candidate first, to avoid choosingharmonics162 // choose first confident candidate, to avoid choosing lower harmonics 162 163 tau = 0; 163 164 for (l = 1; l < yin>length; l++) { 164 165 // is this candidate "roughly" as good as the lowest one? 166 // the constant 0.1 is empirically derived 165 167 if (ABS (yin>data[l]  tmp) < 0.1) { 166 168 tau = l; … … 168 170 } 169 171 } 170 // find local min around current pick to sharpen the results 171 before = 2, after = 5; 172 // for low frequency, the peak may be large, we use a larger after 173 if (tau > yin>length/2) { before = 1; after = 20; } 174 startbin = tau > before ? tau  before : 0; 175 endbin = tau < yin>length  1  after ? tau + after : yin>length  1; 172 // find local min around current peak to sharpen the results 173 endbin = tau + lookafter < yin>length  1 ? tau + lookafter : yin>length  1; 176 174 tmp = yin>data[tau]; 177 for (l = startbin; l < endbin; l++) {175 for (l = tau; l < endbin; l++) { 178 176 if (yin>data[l] < tmp ) { 179 177 tmp = yin>data[l]; 180 178 tau = l; 179 } 180 // stop as soon as we start going up again 181 if (yin>data[l] > tmp && l > tau) { 182 break; 181 183 } 182 184 }
Note: See TracChangeset
for help on using the changeset viewer.