Changes in src/tempo/tempo.c [95748a6:ce6f652]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tempo/tempo.c
r95748a6 rce6f652 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 */75 73 }; 76 74 … … 93 91 aubio_beattracking_do(o->bt,o->dfframe,o->out); 94 92 /* rotate dfframe */ 95 for (i = 0 ; i < winlen - step; i++ ) 93 for (i = 0 ; i < winlen - step; i++ ) 96 94 o->dfframe->data[i] = o->dfframe->data[i+step]; 97 for (i = winlen - step ; i < winlen; i++ ) 95 for (i = winlen - step ; i < winlen; i++ ) 98 96 o->dfframe->data[i] = 0.; 99 97 o->blockpos = -1; … … 106 104 /* end of second level loop */ 107 105 tempo->data[0] = 0; /* reset tactus */ 108 //i=0;106 i=0; 109 107 for (i = 1; i < o->out->data[0]; i++ ) { 110 108 /* if current frame is a predicted tactus */ … … 116 114 } 117 115 o->last_beat = o->total_frames + (uint_t)ROUND(tempo->data[0] * o->hop_size); 118 o->last_tatum = o->last_beat;119 116 } 120 117 } … … 218 215 onset2 = new_fvec(1); 219 216 }*/ 220 o->last_tatum = 0;221 o->tatum_signature = 4;222 217 return o; 223 218 … … 231 226 } 232 227 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 243 228 smpl_t aubio_tempo_get_confidence(aubio_tempo_t *o) { 244 229 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, pass259 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 }278 230 } 279 231
Note: See TracChangeset
for help on using the changeset viewer.