- Timestamp:
- Sep 12, 2009, 1:22:20 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:
- ae4d5de
- Parents:
- 54a5d56
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tempo/beattracking.c
r54a5d56 r4e19e5b 38 38 uint_t step; 39 39 uint_t rayparam; /** Rayleigh parameter */ 40 uint_t lastbeat;40 smpl_t lastbeat; 41 41 sint_t counter; 42 42 uint_t flagstep; 43 43 smpl_t g_var; 44 uint_t gp;45 uint_t bp;46 uint_t rp;47 uint_t rp1;48 uint_t rp2;44 smpl_t gp; 45 smpl_t bp; 46 smpl_t rp; 47 smpl_t rp1; 48 smpl_t rp2; 49 49 }; 50 50 … … 115 115 116 116 uint_t i,k; 117 /* current beat period value found using gaussian weighting (from context dependent model) */118 117 uint_t step = bt->step; 119 118 uint_t laglen = bt->rwv->length; … … 130 129 uint_t numelem = 4; 131 130 132 //parameters for making s.i.c.f.b. 133 uint_t a,b; 134 //beat alignment 135 uint_t phase; 136 uint_t kmax; 137 sint_t beat; 138 uint_t bp; 131 smpl_t phase; // beat alignment (step - lastbeat) 132 smpl_t beat; // beat position 133 smpl_t bp; // beat period 134 uint_t a,b; // used to build shift invariant comb filterbank 135 uint_t kmax; // number of elements used to find beat phase 139 136 140 137 for (i = 0; i < winlen; i++){ … … 145 142 /* find autocorrelation function */ 146 143 aubio_autocorr(dfframe,bt->acf); 147 /* 148 for (i = 0; i < winlen; i++){ 149 AUBIO_DBG("%f,",acf[i]); 150 } 151 AUBIO_DBG("\n"); 152 */ 153 154 /* get acfout - assume Rayleigh weightvector only */ 144 155 145 /* if timesig is unknown, use metrically unbiased version of filterbank */ 156 if(!bt->timesig) 146 if(!bt->timesig) { 157 147 numelem = 4; 158 // AUBIO_DBG("using unbiased filterbank, timesig: %d\n", timesig); 159 else 148 } else { 160 149 numelem = bt->timesig; 161 // AUBIO_DBG("using biased filterbank, timesig: %d\n", timesig);150 } 162 151 163 152 /* first and last output values are left intentionally as zero */ … … 165 154 acfout[i] = 0.; 166 155 156 /* get acfout - assume Rayleigh weightvector only */ 167 157 for(i=1;i<laglen-1;i++){ 168 158 for (a=1; a<=numelem; a++){ … … 176 166 /* find non-zero Rayleigh period */ 177 167 maxindex = vec_max_elem(bt->acfout); 178 bt->rp = maxindex ? maxindex: 1;168 bt->rp = maxindex ? vec_quadint(bt->acfout, maxindex, 1) : 1; 179 169 //rp = (maxindex==127) ? 43 : maxindex; //rayparam 180 170 bt->rp = (maxindex==bt->acfout->length-1) ? bt->rayparam : maxindex; //rayparam … … 182 172 /* activate biased filterbank */ 183 173 aubio_beattracking_checkstate(bt); 174 #if 0 // debug metronome mode 175 bt->bp = 36.9142; 176 #endif 184 177 bp = bt->bp; 185 178 /* end of biased filterbank */ … … 189 182 190 183 /* deliberate integer operation, could be set to 3 max eventually */ 191 kmax = winlen/bp;184 kmax = FLOOR(winlen/bp); 192 185 193 186 for(i=0;i<bp;i++){ 194 187 phout[i] = 0.; 195 188 for(k=0;k<kmax;k++){ 196 phout[i] += dfrev[i+ bp*k] * phwv[i];189 phout[i] += dfrev[i+(uint_t)ROUND(bp*k)] * phwv[i]; 197 190 } 198 191 } … … 200 193 /* find Rayleigh period */ 201 194 maxindex = vec_max_elem(bt->phout); 202 if (maxindex == winlen-1) maxindex = 0; 203 phase = 1 + maxindex; 204 205 /* debug */ 206 //AUBIO_DBG("beat period = %d, rp1 = %d, rp2 = %d\n", bp, rp1, rp2); 207 //AUBIO_DBG("rp = %d, gp = %d, phase = %d\n", bt->rp, bt->gp, phase); 195 if (maxindex == winlen) maxindex = 0; 196 phase = 1. + vec_quadint(bt->phout, maxindex, 1); 197 #if 0 // debug metronome mode 198 phase = step - bt->lastbeat; 199 #endif 208 200 209 201 /* reset output */ … … 212 204 213 205 i = 1; 214 beat = 206 beat = bp - phase; 215 207 /* start counting the beats */ 216 208 if(beat >= 0) 217 209 { 218 output->data[0][i] = (smpl_t)beat;210 output->data[0][i] = beat; 219 211 i++; 220 212 } 221 213 222 while( beat +bp < step)214 while( beat + bp <= step) 223 215 { 224 216 beat += bp; 225 output->data[0][i] = (smpl_t)beat;217 output->data[0][i] = beat; 226 218 i++; 227 219 } … … 255 247 sint_t counter = bt->counter; 256 248 uint_t flagstep = bt->flagstep; 257 uint_t gp = bt->gp;258 uint_t bp = bt->bp;259 uint_t rp = bt->rp;260 uint_t rp1 = bt->rp1;261 uint_t rp2 = bt->rp2;249 smpl_t gp = bt->gp; 250 smpl_t bp = bt->bp; 251 smpl_t rp = bt->rp; 252 smpl_t rp1 = bt->rp1; 253 smpl_t rp2 = bt->rp2; 262 254 uint_t laglen = bt->rwv->length; 263 255 uint_t acflen = bt->acf->length; … … 284 276 } 285 277 } 286 gp = vec_ max_elem(bt->acfout);278 gp = vec_quadint(bt->acfout, vec_max_elem(bt->acfout), 1); 287 279 /* 288 280 while(gp<32) gp =gp*2; … … 381 373 smpl_t aubio_beattracking_get_bpm(aubio_beattracking_t * bt) { 382 374 if (bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) { 383 return 5168. / (smpl_t)bt->gp;375 return 5168. / vec_quadint(bt->acfout, bt->bp, 1); 384 376 } else { 385 377 return 0.;
Note: See TracChangeset
for help on using the changeset viewer.