Changeset 0ce9acc3
- Timestamp:
- Jun 7, 2005, 6:56:39 PM (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:
- b31f262
- Parents:
- 97b8c3d
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/aubiotrack.c
r97b8c3d r0ce9acc3 27 27 aubio_beattracking_t * bt = NULL; 28 28 uint_t winlen = 512; 29 uint_t step = 128; 30 uint_t laglen = 128; 31 uint_t rayparam = 43; 29 uint_t step = 0; 32 30 uint_t istactus = 0; 33 31 … … 84 82 if (pos2 == btoutput[i]) { 85 83 //printf("pos2: %d\n", pos2); 84 //printf("tempo:\t%3.5f bpm \n", 85 //60.*44100./overlap_size/abs(btoutput[2]-btoutput[1])); 86 86 /* test for silence */ 87 87 if (aubio_silence_detection(ibuf, threshold2)==1) { … … 123 123 /* override default settings */ 124 124 examples_common_init(argc,argv); 125 winlen = SQR(512)/overlap_size; 125 126 126 127 dfframe = new_fvec(winlen,channels); 128 step = winlen/4; 127 129 out = new_fvec(step,channels); 130 128 131 /* test input : impulses starting from 15, at intervals of 50 samples */ 129 132 //for(i=0;i<16;i++){ … … 131 134 //} 132 135 133 bt = new_aubio_beattracking(winlen,step, laglen, 134 rayparam, channels); 136 bt = new_aubio_beattracking(winlen,channels); 135 137 136 138 examples_common_process(aubio_process,process_print); -
examples/utils.c
r97b8c3d r0ce9acc3 98 98 99 99 int parse_args (int argc, char **argv) { 100 const char *options = "hvjo:i:O:t:s: a";100 const char *options = "hvjo:i:O:t:s:H:a"; 101 101 int next_option; 102 102 struct option long_options[] = … … 111 111 {"silence" , 0, NULL, 's'}, 112 112 {"averaging", 0, NULL, 'a'}, 113 {"hopsize", 0, NULL, 'H'}, 113 114 {NULL , 0, NULL, 0} 114 115 }; … … 169 170 averaging = 1; 170 171 break; 172 case 'H': 173 overlap_size = atoi(optarg); 174 break; 171 175 case '?': /* unknown options */ 172 176 usage(stderr, 1); -
src/beattracking.c
r97b8c3d r0ce9acc3 23 23 #include "beattracking.h" 24 24 25 // 60*samplerate/winlen 26 25 27 /* maximum length for rp */ 26 static uint_t MAXRP = 512;27 28 static smpl_t constthresh = 3.901; //empirically derived! 28 static smpl_t stepthresh = 2.*3.901;29 29 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 smpl_t fvec_getperiod(aubio_beattracking_t * bt, uint_t timesig, uint_t rp); 33 33 34 34 /* could move to struct */ 35 uint_t gp =0, bp= 0, rp1 = 0, rp2 = 0, bp2 = 0;36 smpl_t g_mu =0.;37 smpl_t g_var = 3.901;38 uint_t flagconst = 0;39 uint_t flagstep = 0;35 uint_t gp = 0, bp = 0, rp1 = 0, rp2 = 0, bp2 = 0; 36 smpl_t g_mu = 0.; 37 smpl_t g_var = 3.901; 38 uint_t flagconst = 0; 39 uint_t flagstep = 0; 40 40 // needs to be a signed ? 41 sint_t counter = 0;42 uint_t maxindex = 0;43 uint_t timesig = 0;44 uint_t rp = 1;45 uint_t lastbeat = 0;41 sint_t counter = 0; 42 uint_t maxindex = 0; 43 uint_t timesig = 0; 44 uint_t rp = 1; 45 uint_t lastbeat = 0; 46 46 //number of harmonics in shift invariant comb filterbank 47 uint_t numelem = 4; 48 smpl_t myperiod = 0.; 49 50 51 // FIXME 47 uint_t numelem = 4; 48 smpl_t myperiod = 0.; 49 52 50 uint_t maxnumelem = 4; 53 uint_t len = 512;54 smpl_t inds[4]; //vector for max index outputs for each harmonic55 smpl_t local_acf[512]; //vector to store harmonics of filterbank of acf56 57 51 58 52 struct _aubio_beattracking_t { … … 67 61 //uint_t timesig; /* time signature of input, set to zero until context dependent model activated */ 68 62 uint_t step; 63 fvec_t * locacf; /* vector to store harmonics of filterbank of acf */ 64 fvec_t * inds; /* vector for max index outputs for each harmonic */ 65 uint_t rayparam; /* Rayleigh parameter */ 69 66 }; 70 67 71 68 aubio_beattracking_t * new_aubio_beattracking(uint_t winlen, 72 uint_t step,73 uint_t laglen,74 uint_t rayparam,75 69 uint_t channels) { 76 70 77 71 aubio_beattracking_t * p = AUBIO_NEW(aubio_beattracking_t); 78 79 72 uint_t i = 0; 73 smpl_t rayparam = 48./512. * winlen; 80 74 smpl_t dfwvnorm = EXP((LOG(2.0)/rayparam)*(winlen+2)); 81 75 uint_t laglen = winlen/4; 76 uint_t step = winlen/4; /* 1.5 seconds */ 77 78 p->rayparam = rayparam; 82 79 p->step = step; 83 80 p->rwv = new_fvec(laglen,channels); … … 88 85 p->acfout = new_fvec(laglen,channels); 89 86 p->phwv = new_fvec(2*laglen,channels); 90 p->phout = new_fvec(MAXRP,channels); 87 p->phout = new_fvec(winlen,channels); 88 91 89 //p->timesig = 0; 90 91 p->inds = new_fvec(maxnumelem,channels); 92 p->locacf = new_fvec(winlen,channels); 92 93 93 94 /* exponential weighting, dfwv = 0.5 when i = 43 */ … … 115 116 del_fvec(p->phwv); 116 117 del_fvec(p->phout); 118 del_fvec(p->locacf); 119 del_fvec(p->inds); 117 120 AUBIO_FREE(p); 118 121 } … … 158 161 /* get acfout - assume Rayleigh weightvector only */ 159 162 /* if timesig is unknown, use metrically unbiased version of filterbank */ 160 //if(!timesig)161 // AUBIO_DBG("using unbiased filterbank, timesig: %d\n", timesig);162 //else163 // AUBIO_DBG("using biased filterbank, timesig: %d\n", timesig);164 163 if(!timesig) 165 164 numelem = 4; 165 // AUBIO_DBG("using unbiased filterbank, timesig: %d\n", timesig); 166 166 else 167 167 numelem = timesig; 168 // AUBIO_DBG("using biased filterbank, timesig: %d\n", timesig); 168 169 169 170 /* first and last output values are left intentionally as zero */ … … 183 184 maxindex = vec_max_elem(bt->acfout); 184 185 rp = maxindex ? maxindex : 1; 185 rp = (maxindex==127) ? 43 : maxindex; //rayparam 186 //rp = (maxindex==127) ? 43 : maxindex; //rayparam 187 rp = (maxindex==bt->acfout->length-1) ? bt->rayparam : maxindex; //rayparam 186 188 187 189 // get float period 188 myperiod = fvec_getperiod( acf,timesig,rp);190 myperiod = fvec_getperiod(bt,timesig,rp); 189 191 //AUBIO_DBG("\nrp = %d myperiod = %f\n",rp,myperiod); 190 192 //AUBIO_DBG("accurate tempo is %f bpm\n",5168./myperiod); 191 192 193 193 194 /* activate biased filterbank */ … … 196 197 197 198 /* initialize output */ 198 for(i=0;i<MAXRP;i++) {phout[i] = 0.;} 199 200 /* deliberate integer operation */ 201 /* could be set to 3 max eventually */ 199 for(i=0;i<bt->phout->length;i++) {phout[i] = 0.;} 200 201 /* deliberate integer operation, could be set to 3 max eventually */ 202 202 kmax = winlen/bp; 203 203 … … 239 239 240 240 lastbeat = beat; 241 241 /* store the number of beat found in this frame as the first element */ 242 242 output->data[0][0] = i; 243 244 243 } 245 244 … … 262 261 } 263 262 264 smpl_t fvec_getperiod( smpl_t * acf, uint_t timesig, uint_t rp){263 smpl_t fvec_getperiod(aubio_beattracking_t * bt, uint_t timesig, uint_t rp){ 265 264 /*function to make a more accurate beat period measurement.*/ 266 265 … … 268 267 smpl_t maxval = 0.; 269 268 270 271 272 int a,b; 269 sint_t a,b; 273 270 uint_t i,j; 274 271 uint_t acfmi = rp; //acfout max index … … 281 278 282 279 for (i=0;i<numelem;i++) // initialize 283 inds[i] = 0.;284 285 for (i=0;i< len;i++) // initialize286 local_acf[i] = 0.;280 bt->inds->data[0][i] = 0.; 281 282 for (i=0;i<bt->locacf->length;i++) // initialize 283 bt->locacf->data[0][i] = 0.; 287 284 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 } 285 // get appropriate acf elements from acf and store in locacf 286 for (a=1;a<=4;a++){ 287 for(b=(1-a);b<a;b++){ 288 bt->locacf->data[0][a*(acfmi)+b-1] = 289 bt->acf->data[0][a*(acfmi)+b-1]; 290 } 291 } 294 292 295 293 for(i=0;i<numelem;i++){ … … 299 297 300 298 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.; 299 if(bt->locacf->data[0][j]>maxval){ 300 maxval = bt->locacf->data[0][j]; 301 maxind = j; 302 } 303 //bt->locacf->data[0][maxind] = 0.; 304 bt->locacf->data[0][j] = 0.; 306 305 } 307 //printf("\n\n");308 306 //AUBIO_DBG("\n maxind is %d\n",maxind); 309 inds[i] = maxind;307 bt->inds->data[0][i] = maxind; 310 308 311 309 } 312 310 313 311 for (i=0;i<numelem;i++){ 314 period += inds[i]/(i+1.);}312 period += bt->inds->data[0][i]/(i+1.);} 315 313 316 314 period = period/numelem; … … 357 355 358 356 //now look for step change - i.e. a difference between gp and rp that 359 // is greater than stepthresh - always true in first case, since gp = 0357 // is greater than 2*constthresh - always true in first case, since gp = 0 360 358 if(counter == 0){ 361 if(ABS(gp - rp) > stepthresh) {359 if(ABS(gp - rp) > 2.*constthresh) { 362 360 flagstep = 1; // have observed step change. 363 361 counter = 3; // setup 3 frame counter … … 421 419 /* if tempo is > 206 bpm, half it */ 422 420 while (bp < 25) { 423 AUBIO_DBG("warning, halving the tempo from %f\n", 5168./bp); 421 //while (bp < fact/206.) { 422 AUBIO_DBG("warning, doubling the beat period from %d\n", bp); 423 //AUBIO_DBG("warning, halving the tempo from %f\n", 60.*samplerate/hopsize/bp); 424 424 bp = bp*2; 425 425 } 426 426 427 AUBIO_DBG("tempo:\t%3.5f bpm | ", 5168./bp);427 //AUBIO_DBG("tempo:\t%3.5f bpm | ", 5168./bp); 428 428 429 429 /* smoothing */ … … 431 431 //AUBIO_DBG("tempo:\t%3.5f bpm smoothed | bp2 %d | bp %d | ", 5168./bp, bp2, bp); 432 432 //bp2 = bp; 433 AUBIO_DBG("time signature: %d \n", timesig);434 435 } 433 //AUBIO_DBG("time signature: %d \n", timesig); 434 435 } -
src/beattracking.h
r97b8c3d r0ce9acc3 37 37 * \param channel number (not functionnal) [1] */ 38 38 aubio_beattracking_t * new_aubio_beattracking(uint_t winlen, 39 uint_t step,40 uint_t laglen,41 uint_t rayparam,42 39 uint_t channels); 43 40 /**
Note: See TracChangeset
for help on using the changeset viewer.