Changeset 54f2a70
- Timestamp:
- Aug 30, 2009, 5:11:05 PM (15 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:
- 32f5a01
- Parents:
- 9d7458d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tempo/beattracking.c
r9d7458d r54f2a70 25 25 uint_t fvec_gettimesig(smpl_t * acf, uint_t acflen, uint_t gp); 26 26 void aubio_beattracking_checkstate(aubio_beattracking_t * bt); 27 smpl_t fvec_getperiod(aubio_beattracking_t * bt);28 27 29 28 struct _aubio_beattracking_t { … … 38 37 uint_t timesig; /** time signature of input, set to zero until context dependent model activated */ 39 38 uint_t step; 40 fvec_t * locacf; /** vector to store harmonics of filterbank of acf */41 fvec_t * inds; /** vector for max index outputs for each harmonic */42 39 uint_t rayparam; /** Rayleigh parameter */ 43 40 uint_t lastbeat; … … 67 64 uint_t step = winlen/4; /* 1.5 seconds */ 68 65 69 uint_t maxnumelem = 4; /* max number of index output */70 66 p->lastbeat = 0; 71 67 p->counter = 0; … … 88 84 p->timesig = 0; 89 85 90 p->inds = new_fvec(maxnumelem,channels);91 p->locacf = new_fvec(winlen,channels);92 93 86 /* exponential weighting, dfwv = 0.5 when i = 43 */ 94 87 for (i=0;i<winlen;i++) { … … 115 108 del_fvec(p->phwv); 116 109 del_fvec(p->phout); 117 del_fvec(p->locacf);118 del_fvec(p->inds);119 110 AUBIO_FREE(p); 120 111 } … … 139 130 uint_t numelem = 4; 140 131 141 //smpl_t myperiod = 0.;142 //smpl_t * out = output->data[0];143 144 132 //parameters for making s.i.c.f.b. 145 133 uint_t a,b; … … 192 180 bt->rp = (maxindex==bt->acfout->length-1) ? bt->rayparam : maxindex; //rayparam 193 181 194 // get float period195 //myperiod = fvec_getperiod(bt);196 //AUBIO_DBG("\nrp = %d myperiod = %f\n",bt->rp,myperiod);197 //AUBIO_DBG("accurate tempo is %f bpm\n",5168./myperiod);198 199 182 /* activate biased filterbank */ 200 183 aubio_beattracking_checkstate(bt); … … 266 249 return (three_energy > four_energy) ? 3 : 4; 267 250 } 268 269 smpl_t fvec_getperiod(aubio_beattracking_t * bt){270 /*function to make a more accurate beat period measurement.*/271 272 smpl_t period = 0.;273 smpl_t maxval = 0.;274 uint_t numelem = 4;275 276 sint_t a,b;277 uint_t i,j;278 uint_t acfmi = bt->rp; //acfout max index279 uint_t maxind = 0;280 281 if(!bt->timesig)282 numelem = 4;283 else284 numelem = bt->timesig;285 286 for (i=0;i<numelem;i++) // initialize287 bt->inds->data[0][i] = 0.;288 289 for (i=0;i<bt->locacf->length;i++) // initialize290 bt->locacf->data[0][i] = 0.;291 292 // get appropriate acf elements from acf and store in locacf293 for (a=1;a<=4;a++){294 for(b=(1-a);b<a;b++){295 bt->locacf->data[0][a*(acfmi)+b-1] =296 bt->acf->data[0][a*(acfmi)+b-1];297 }298 }299 300 for(i=0;i<numelem;i++){301 302 maxind = 0;303 maxval = 0.0;304 305 for (j=0;j<(acfmi*(i+1)+(i)); j++){306 if(bt->locacf->data[0][j]>maxval){307 maxval = bt->locacf->data[0][j];308 maxind = j;309 }310 //bt->locacf->data[0][maxind] = 0.;311 bt->locacf->data[0][j] = 0.;312 }313 //AUBIO_DBG("\n maxind is %d\n",maxind);314 bt->inds->data[0][i] = maxind;315 316 }317 318 for (i=0;i<numelem;i++){319 period += bt->inds->data[0][i]/(i+1.);}320 321 period = period/numelem;322 323 return (period);324 }325 326 251 327 252 void aubio_beattracking_checkstate(aubio_beattracking_t * bt) {
Note: See TracChangeset
for help on using the changeset viewer.