Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tempo/tempo.c

    r95748a6 rce6f652  
    6565  sint_t blockpos;               /** current position in dfframe */
    6666  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 */ 
    6969  uint_t hop_size;               /** get hop_size */
    7070  uint_t total_frames;           /** total frames since beginning */
    7171  uint_t last_beat;              /** time of latest detected beat, in samples */
    7272  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 */
    7573};
    7674
     
    9391    aubio_beattracking_do(o->bt,o->dfframe,o->out);
    9492    /* rotate dfframe */
    95     for (i = 0 ; i < winlen - step; i++ )
     93    for (i = 0 ; i < winlen - step; i++ ) 
    9694      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++ ) 
    9896      o->dfframe->data[i] = 0.;
    9997    o->blockpos = -1;
     
    106104  /* end of second level loop */
    107105  tempo->data[0] = 0; /* reset tactus */
    108   //i=0;
     106  i=0;
    109107  for (i = 1; i < o->out->data[0]; i++ ) {
    110108    /* if current frame is a predicted tactus */
     
    116114      }
    117115      o->last_beat = o->total_frames + (uint_t)ROUND(tempo->data[0] * o->hop_size);
    118       o->last_tatum = o->last_beat;
    119116    }
    120117  }
     
    218215    onset2 = new_fvec(1);
    219216  }*/
    220   o->last_tatum = 0;
    221   o->tatum_signature = 4;
    222217  return o;
    223218
     
    231226}
    232227
    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 
    243228smpl_t aubio_tempo_get_confidence(aubio_tempo_t *o) {
    244229  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   }
    278230}
    279231
Note: See TracChangeset for help on using the changeset viewer.