Changes in src/tempo/tempo.c [ce6f652:95748a6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tempo/tempo.c
rce6f652 r95748a6 65 65 sint_t blockpos; /** current position in dfframe */ 66 66 uint_t winlen; /** dfframe bufsize */ 67 uint_t step; /** dfframe hopsize */ 68 uint_t samplerate; /** sampling rate of the signal */ 67 uint_t step; /** dfframe hopsize */ 68 uint_t samplerate; /** sampling rate of the signal */ 69 69 uint_t hop_size; /** get hop_size */ 70 70 uint_t total_frames; /** total frames since beginning */ 71 71 uint_t last_beat; /** time of latest detected beat, in samples */ 72 72 uint_t delay; /** delay to remove to last beat, in samples */ 73 uint_t last_tatum; /** time of latest detected tatum, in samples */ 74 uint_t tatum_signature; /** number of tatum between each beats */ 73 75 }; 74 76 … … 91 93 aubio_beattracking_do(o->bt,o->dfframe,o->out); 92 94 /* rotate dfframe */ 93 for (i = 0 ; i < winlen - step; i++ ) 95 for (i = 0 ; i < winlen - step; i++ ) 94 96 o->dfframe->data[i] = o->dfframe->data[i+step]; 95 for (i = winlen - step ; i < winlen; i++ ) 97 for (i = winlen - step ; i < winlen; i++ ) 96 98 o->dfframe->data[i] = 0.; 97 99 o->blockpos = -1; … … 104 106 /* end of second level loop */ 105 107 tempo->data[0] = 0; /* reset tactus */ 106 i=0;108 //i=0; 107 109 for (i = 1; i < o->out->data[0]; i++ ) { 108 110 /* if current frame is a predicted tactus */ … … 114 116 } 115 117 o->last_beat = o->total_frames + (uint_t)ROUND(tempo->data[0] * o->hop_size); 118 o->last_tatum = o->last_beat; 116 119 } 117 120 } … … 215 218 onset2 = new_fvec(1); 216 219 }*/ 220 o->last_tatum = 0; 221 o->tatum_signature = 4; 217 222 return o; 218 223 … … 226 231 } 227 232 233 smpl_t aubio_tempo_get_period (aubio_tempo_t *o) 234 { 235 return aubio_beattracking_get_period (o->bt); 236 } 237 238 smpl_t aubio_tempo_get_period_s (aubio_tempo_t *o) 239 { 240 return aubio_beattracking_get_period_s (o->bt); 241 } 242 228 243 smpl_t aubio_tempo_get_confidence(aubio_tempo_t *o) { 229 244 return aubio_beattracking_get_confidence(o->bt); 245 } 246 247 uint_t aubio_tempo_was_tatum (aubio_tempo_t *o) 248 { 249 uint_t last_tatum_distance = o->total_frames - o->last_tatum; 250 smpl_t beat_period = aubio_tempo_get_period(o); 251 smpl_t tatum_period = beat_period / o->tatum_signature; 252 if (last_tatum_distance < o->hop_size) { 253 o->last_tatum = o->last_beat; 254 return 2; 255 } 256 else if (last_tatum_distance > tatum_period) { 257 if ( last_tatum_distance + o->hop_size > beat_period ) { 258 // next beat is too close, pass 259 return 0; 260 } 261 o->last_tatum = o->total_frames; 262 return 1; 263 } 264 return 0; 265 } 266 267 smpl_t aubio_tempo_get_last_tatum (aubio_tempo_t *o) { 268 return (smpl_t)o->last_tatum - o->delay; 269 } 270 271 uint_t aubio_tempo_set_tatum_signature (aubio_tempo_t *o, uint_t signature) { 272 if (signature < 1 || signature > 64) { 273 return AUBIO_FAIL; 274 } else { 275 o->tatum_signature = signature; 276 return AUBIO_OK; 277 } 230 278 } 231 279
Note: See TracChangeset
for help on using the changeset viewer.