- Timestamp:
- Dec 4, 2009, 1:40:48 AM (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:
- 8e5c051
- Parents:
- 741bdda
- Location:
- src/tempo
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tempo/beattracking.c
r741bdda rd207300 55 55 56 56 aubio_beattracking_t * 57 new_aubio_beattracking (uint_t winlen , uint_t channels)57 new_aubio_beattracking (uint_t winlen) 58 58 { 59 59 … … 79 79 p->rayparam = rayparam; 80 80 p->step = step; 81 p->rwv = new_fvec (laglen , 1);82 p->gwv = new_fvec (laglen , 1);83 p->dfwv = new_fvec (winlen , 1);84 p->dfrev = new_fvec (winlen , channels);85 p->acf = new_fvec (winlen , channels);86 p->acfout = new_fvec (laglen , channels);87 p->phwv = new_fvec (2 * laglen , 1);88 p->phout = new_fvec (winlen , channels);81 p->rwv = new_fvec (laglen); 82 p->gwv = new_fvec (laglen); 83 p->dfwv = new_fvec (winlen); 84 p->dfrev = new_fvec (winlen); 85 p->acf = new_fvec (winlen); 86 p->acfout = new_fvec (laglen); 87 p->phwv = new_fvec (2 * laglen); 88 p->phout = new_fvec (winlen); 89 89 90 90 p->timesig = 0; … … 92 92 /* exponential weighting, dfwv = 0.5 when i = 43 */ 93 93 for (i = 0; i < winlen; i++) { 94 p->dfwv->data[ 0][i] = (EXP ((LOG (2.0) / rayparam) * (i + 1)))94 p->dfwv->data[i] = (EXP ((LOG (2.0) / rayparam) * (i + 1))) 95 95 / dfwvnorm; 96 96 } 97 97 98 98 for (i = 0; i < (laglen); i++) { 99 p->rwv->data[ 0][i] = ((smpl_t) (i + 1.) / SQR ((smpl_t) rayparam)) *99 p->rwv->data[i] = ((smpl_t) (i + 1.) / SQR ((smpl_t) rayparam)) * 100 100 EXP ((-SQR ((smpl_t) (i + 1.)) / (2. * SQR ((smpl_t) rayparam)))); 101 101 } … … 161 161 for (a = 1; a <= numelem; a++) { 162 162 for (b = (1 - a); b < a; b++) { 163 bt->acfout->data[ 0][i] += bt->acf->data[0][a * (i + 1) + b - 1]163 bt->acfout->data[i] += bt->acf->data[a * (i + 1) + b - 1] 164 164 * 1. / (2. * a - 1.); 165 165 } … … 171 171 /* find non-zero Rayleigh period */ 172 172 maxindex = fvec_max_elem (bt->acfout); 173 bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex , 0) : 1;173 bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex) : 1; 174 174 //rp = (maxindex==127) ? 43 : maxindex; //rayparam 175 175 bt->rp = (maxindex == bt->acfout->length - 1) ? bt->rayparam : maxindex; //rayparam … … 191 191 for (i = 0; i < bp; i++) { 192 192 for (k = 0; k < kmax; k++) { 193 bt->phout->data[ 0][i] += bt->dfrev->data[0][i + (uint_t) ROUND (bp * k)];193 bt->phout->data[i] += bt->dfrev->data[i + (uint_t) ROUND (bp * k)]; 194 194 } 195 195 } … … 204 204 phase = step - bt->lastbeat; 205 205 } else { 206 phase = fvec_quadint (bt->phout, maxindex , 0);206 phase = fvec_quadint (bt->phout, maxindex); 207 207 } 208 208 /* take back one frame delay */ … … 237 237 if (beat >= 0) { 238 238 //AUBIO_DBG ("beat: %d, %f, %f\n", i, bp, beat); 239 output->data[ 0][i] = beat;239 output->data[i] = beat; 240 240 i++; 241 241 } … … 244 244 beat += bp; 245 245 //AUBIO_DBG ("beat: %d, %f, %f\n", i, bp, beat); 246 output->data[ 0][i] = beat;246 output->data[i] = beat; 247 247 i++; 248 248 } … … 250 250 bt->lastbeat = beat; 251 251 /* store the number of beats in this frame as the first element */ 252 output->data[0] [0]= i;252 output->data[0] = i; 253 253 } 254 254 … … 260 260 if (acflen > 6 * gp + 2) { 261 261 for (k = -2; k < 2; k++) { 262 three_energy += acf->data[ 0][3 * gp + k];263 four_energy += acf->data[ 0][4 * gp + k];262 three_energy += acf->data[3 * gp + k]; 263 four_energy += acf->data[4 * gp + k]; 264 264 } 265 265 } else { 266 266 /*Expanded to be more accurate in time sig estimation */ 267 267 for (k = -2; k < 2; k++) { 268 three_energy += acf->data[ 0][3 * gp + k] + acf->data[0][6 * gp + k];269 four_energy += acf->data[ 0][4 * gp + k] + acf->data[0][2 * gp + k];268 three_energy += acf->data[3 * gp + k] + acf->data[6 * gp + k]; 269 four_energy += acf->data[4 * gp + k] + acf->data[2 * gp + k]; 270 270 } 271 271 } … … 301 301 for (a = 1; a <= bt->timesig; a++) { 302 302 for (b = (1 - a); b < a; b++) { 303 acfout->data[ 0][i] += acf->data[0][a * (i + 1) + b - 1];303 acfout->data[i] += acf->data[a * (i + 1) + b - 1]; 304 304 } 305 305 } 306 306 } 307 307 fvec_weight (acfout, bt->gwv); 308 gp = fvec_quadint (acfout, fvec_max_elem (acfout) , 0);308 gp = fvec_quadint (acfout, fvec_max_elem (acfout)); 309 309 /* 310 310 while(gp<32) gp =gp*2; … … 351 351 bt->timesig = fvec_gettimesig (acf, acflen, gp); 352 352 for (j = 0; j < laglen; j++) 353 bt->gwv->data[ 0][j] =353 bt->gwv->data[j] = 354 354 EXP (-.5 * SQR ((smpl_t) (j + 1. - gp)) / SQR (bt->g_var)); 355 355 flagconst = 0; … … 363 363 if (step > bt->lastbeat) { 364 364 for (j = 0; j < 2 * laglen; j++) { 365 bt->phwv->data[ 0][j] =365 bt->phwv->data[j] = 366 366 EXP (-.5 * SQR ((smpl_t) (1. + j - step + 367 367 bt->lastbeat)) / (bp / 8.)); … … 410 410 { 411 411 if (bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) { 412 return 5168. / fvec_quadint (bt->acfout, bt->bp , 0);412 return 5168. / fvec_quadint (bt->acfout, bt->bp); 413 413 } else { 414 414 return 0.; -
src/tempo/beattracking.h
r741bdda rd207300 48 48 49 49 \param hop_size number of onset detection samples [512] 50 \param channels number (not functionnal) [1]51 50 52 51 */ 53 aubio_beattracking_t * new_aubio_beattracking(uint_t hop_size , uint_t channels);52 aubio_beattracking_t * new_aubio_beattracking(uint_t hop_size); 54 53 55 54 /** track the beat -
src/tempo/tempo.c
r741bdda rd207300 59 59 /*if (usedoubled) { 60 60 aubio_specdesc_do(o2,fftgrain, onset2); 61 onset->data[0] [0] *= onset2->data[0][0];61 onset->data[0] *= onset2->data[0]; 62 62 }*/ 63 63 /* execute every overlap_size*step */ … … 67 67 /* rotate dfframe */ 68 68 for (i = 0 ; i < winlen - step; i++ ) 69 o->dfframe->data[ 0][i] = o->dfframe->data[0][i+step];69 o->dfframe->data[i] = o->dfframe->data[i+step]; 70 70 for (i = winlen - step ; i < winlen; i++ ) 71 o->dfframe->data[ 0][i] = 0.;71 o->dfframe->data[i] = 0.; 72 72 o->blockpos = -1; 73 73 } 74 74 o->blockpos++; 75 75 aubio_peakpicker_do (o->pp, o->of, o->onset); 76 tempo->data[ 0][1] = o->onset->data[0][0];76 tempo->data[1] = o->onset->data[0]; 77 77 thresholded = aubio_peakpicker_get_thresholded_input(o->pp); 78 o->dfframe->data[ 0][winlen - step + o->blockpos] = thresholded->data[0][0];78 o->dfframe->data[winlen - step + o->blockpos] = thresholded->data[0]; 79 79 /* end of second level loop */ 80 tempo->data[0] [0]= 0; /* reset tactus */80 tempo->data[0] = 0; /* reset tactus */ 81 81 i=0; 82 for (i = 1; i < o->out->data[0] [0]; i++ ) {82 for (i = 1; i < o->out->data[0]; i++ ) { 83 83 /* if current frame is a predicted tactus */ 84 if (o->blockpos == FLOOR(o->out->data[ 0][i])) {85 tempo->data[0] [0] = o->out->data[0][i] - FLOOR(o->out->data[0][i]); /* set tactus */84 if (o->blockpos == FLOOR(o->out->data[i])) { 85 tempo->data[0] = o->out->data[i] - FLOOR(o->out->data[i]); /* set tactus */ 86 86 /* test for silence */ 87 87 if (aubio_silence_detection(input, o->silence)==1) { 88 tempo->data[ 0][1] = 0; /* unset onset */88 tempo->data[1] = 0; /* unset onset */ 89 89 } 90 90 } … … 105 105 /* Allocate memory for an tempo detection */ 106 106 aubio_tempo_t * new_aubio_tempo (char_t * onset_mode, 107 uint_t buf_size, uint_t hop_size, uint_t channels, uint_tsamplerate)107 uint_t buf_size, uint_t hop_size, uint_t samplerate) 108 108 { 109 109 aubio_tempo_t * o = AUBIO_NEW(aubio_tempo_t); … … 115 115 o->silence = -90.; 116 116 o->blockpos = 0; 117 o->dfframe = new_fvec(o->winlen ,channels);118 o->fftgrain = new_cvec(buf_size , channels);119 o->out = new_fvec(o->step ,channels);120 o->pv = new_aubio_pvoc(buf_size, hop_size , channels);121 o->pp = new_aubio_peakpicker( channels);117 o->dfframe = new_fvec(o->winlen); 118 o->fftgrain = new_cvec(buf_size); 119 o->out = new_fvec(o->step); 120 o->pv = new_aubio_pvoc(buf_size, hop_size); 121 o->pp = new_aubio_peakpicker(); 122 122 aubio_peakpicker_set_threshold (o->pp, o->threshold); 123 o->od = new_aubio_specdesc(onset_mode,buf_size ,channels);124 o->of = new_fvec(1 , channels);125 o->bt = new_aubio_beattracking(o->winlen ,channels);126 o->onset = new_fvec(1 , channels);123 o->od = new_aubio_specdesc(onset_mode,buf_size); 124 o->of = new_fvec(1); 125 o->bt = new_aubio_beattracking(o->winlen); 126 o->onset = new_fvec(1); 127 127 /*if (usedoubled) { 128 o2 = new_aubio_specdesc(type_onset2,buffer_size ,channels);129 onset2 = new_fvec(1 , channels);128 o2 = new_aubio_specdesc(type_onset2,buffer_size); 129 onset2 = new_fvec(1); 130 130 }*/ 131 131 return o; -
src/tempo/tempo.h
r741bdda rd207300 40 40 /** create tempo detection object */ 41 41 aubio_tempo_t * new_aubio_tempo (char_t * method, 42 uint_t buf_size, uint_t hop_size, uint_t channels, uint_tsamplerate);42 uint_t buf_size, uint_t hop_size, uint_t samplerate); 43 43 44 44 /** execute tempo detection */
Note: See TracChangeset
for help on using the changeset viewer.