Changeset 2cdae81
- Timestamp:
- May 23, 2005, 12:31:46 AM (20 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, pitchshift, sampler, timestretch, yinfft+
- Children:
- 71f98f1
- Parents:
- b78805a
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/aubiotrack.c
rb78805a r2cdae81 81 81 istactus = 0; 82 82 i=0; 83 for (i = 1; i < =btoutput[0]; i++ ) {84 if (pos2 == btoutput[i] && btoutput[i] != 0.) {83 for (i = 1; i < btoutput[0]; i++ ) { 84 if (pos2 == btoutput[i]) { 85 85 //printf("pos2: %d\n", pos2); 86 86 /* test for silence */ … … 113 113 if (output_filename == NULL) { 114 114 if (istactus) 115 outmsg("% d\t%f",pos2,(frames)*overlap_size/(float)samplerate);116 if (isonset )115 outmsg("%f\n",(frames)*overlap_size/(float)samplerate); 116 if (isonset && verbose) 117 117 outmsg(" \t \t%f\n",(frames)*overlap_size/(float)samplerate); 118 118 } -
src/beattracking.c
rb78805a r2cdae81 30 30 uint_t fvec_gettimesig(smpl_t * acf, uint_t acflen, uint_t gp); 31 31 void aubio_beattracking_checkstate(aubio_beattracking_t * bt); 32 smpl_t fvec_getperiod(smpl_t * acf, uint_t timesig, uint_t rp); 32 33 33 34 /* could move to struct */ 34 uint_t gp=0, bp = 0, rp1 = 0, rp2 = 0 ;35 uint_t gp=0, bp = 0, rp1 = 0, rp2 = 0, bp2 = 0; 35 36 smpl_t g_mu =0.; 36 37 smpl_t g_var = 3.901; … … 45 46 //number of harmonics in shift invariant comb filterbank 46 47 uint_t numelem = 4; 48 smpl_t myperiod = 0.; 49 50 51 // FIXME 52 uint_t maxnumelem = 4; 53 uint_t len = 512; 54 smpl_t inds[4]; //vector for max index outputs for each harmonic 55 smpl_t local_acf[512]; //vector to store harmonics of filterbank of acf 56 47 57 48 58 struct _aubio_beattracking_t { … … 160 170 for (i=0; i < bt->acfout->length; i++) 161 171 acfout[i] = 0.; 172 162 173 for(i=1;i<laglen-1;i++){ 163 for (a=1; a<=numelem;a++){164 for(b=(1-a); b<a;b++){174 for (a=1; a<=numelem; a++){ 175 for(b=(1-a); b<a; b++){ 165 176 acfout[i] += acf[a*(i+1)+b-1] 166 177 * 1./(2.*a-1.)*rwv[i]; … … 174 185 rp = (maxindex==127) ? 43 : maxindex; //rayparam 175 186 187 // get float period 188 myperiod = fvec_getperiod(acf,timesig,rp); 189 //AUBIO_DBG("\nrp = %d myperiod = %f\n",rp,myperiod); 190 //AUBIO_DBG("accurate tempo is %f bpm\n",5168./myperiod); 191 192 176 193 /* activate biased filterbank */ 177 194 aubio_beattracking_checkstate(bt); … … 192 209 } 193 210 194 195 211 /* find Rayleigh period */ 196 212 maxindex = vec_max_elem(bt->phout); … … 209 225 beat = bp - phase; 210 226 /* start counting the beats */ 211 if(beat )227 if(beat >= 0) 212 228 { 213 229 output->data[0][i] = (smpl_t)beat; … … 245 261 return (three_energy > four_energy) ? 3 : 4; 246 262 } 263 264 smpl_t fvec_getperiod(smpl_t * acf, uint_t timesig, uint_t rp){ 265 /*function to make a more accurate beat period measurement.*/ 266 267 smpl_t period = 0.; 268 smpl_t maxval = 0.; 269 270 271 272 int a,b; 273 uint_t i,j; 274 uint_t acfmi = rp; //acfout max index 275 uint_t maxind = 0; 276 277 if(!timesig) 278 numelem = 4; 279 else 280 numelem = timesig; 281 282 for (i=0;i<numelem;i++) // initialize 283 inds[i] = 0.; 284 285 for (i=0;i<len;i++) // initialize 286 local_acf[i] = 0.; 287 288 // get appropriate acf elements from acf and store in local_acf 289 for (a=1;a<=4;a++){ 290 for(b=(1-a);b<a;b++){ 291 local_acf[a*(acfmi)+b-1] = acf[a*(acfmi)+b-1]; 292 } 293 } 294 295 for(i=0;i<numelem;i++){ 296 297 maxindex = 0; 298 maxval = 0.0; 299 300 for (j=0;j<(acfmi*(i+1)+(i)); j++){ 301 if(local_acf[j]>maxval){ 302 maxval = local_acf[j]; 303 maxind = j; 304 } 305 local_acf[maxind] = 0.; 306 } 307 //printf("\n\n"); 308 //AUBIO_DBG("\n maxind is %d\n",maxind); 309 inds[i] = maxind; 310 311 } 312 313 for (i=0;i<numelem;i++){ 314 period += inds[i]/(i+1.);} 315 316 period = period/numelem; 317 318 return (period); 319 } 320 247 321 248 322 void aubio_beattracking_checkstate(aubio_beattracking_t * bt) { … … 273 347 } 274 348 gp = vec_max_elem(bt->acfout); 349 /* 350 while(gp<32) gp =gp*2; 351 while(gp>64) gp = gp/2; 352 */ 275 353 } else { 276 354 //still only using general model … … 339 417 } 340 418 341 342 419 /* do some further checks on the final bp value */ 420 343 421 /* if tempo is > 206 bpm, half it */ 344 422 while (bp < 25) { 423 AUBIO_DBG("warning, halving the tempo from %f\n", 5168./bp); 345 424 bp = bp*2; 346 AUBIO_DBG("warning, halving the tempo to %f\n", 5168./bp);347 425 } 348 426 349 AUBIO_DBG("tempo:\t%3.5f bpm | time signature: %d \n", 5168./bp, timesig); 350 351 } 427 AUBIO_DBG("tempo:\t%3.5f bpm | ", 5168./bp); 428 429 /* smoothing */ 430 //bp = (uint_t) (0.8 * (smpl_t)bp + 0.2 * (smpl_t)bp2); 431 //AUBIO_DBG("tempo:\t%3.5f bpm smoothed | bp2 %d | bp %d | ", 5168./bp, bp2, bp); 432 //bp2 = bp; 433 AUBIO_DBG("time signature: %d \n", timesig); 434 435 }
Note: See TracChangeset
for help on using the changeset viewer.