Changeset 95748a6


Ignore:
Timestamp:
Nov 2, 2015, 11:15:31 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
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:
8605361, f4cc4a8
Parents:
810b3b6
Message:

src/tempo/tempo.{c,h}: add tatum, a subdivision of the beat period, default to 4

Location:
src/tempo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/tempo/tempo.c

    r810b3b6 r95748a6  
    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 */
    7375};
    7476
     
    114116      }
    115117      o->last_beat = o->total_frames + (uint_t)ROUND(tempo->data[0] * o->hop_size);
     118      o->last_tatum = o->last_beat;
    116119    }
    117120  }
     
    215218    onset2 = new_fvec(1);
    216219  }*/
     220  o->last_tatum = 0;
     221  o->tatum_signature = 4;
    217222  return o;
    218223
     
    238243smpl_t aubio_tempo_get_confidence(aubio_tempo_t *o) {
    239244  return aubio_beattracking_get_confidence(o->bt);
     245}
     246
     247uint_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
     267smpl_t aubio_tempo_get_last_tatum (aubio_tempo_t *o) {
     268  return (smpl_t)o->last_tatum - o->delay;
     269}
     270
     271uint_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  }
    240278}
    241279
  • src/tempo/tempo.h

    r810b3b6 r95748a6  
    161161smpl_t aubio_tempo_get_confidence(aubio_tempo_t * o);
    162162
     163/* set number of tatum per beat
     164
     165   \param o beat tracking object
     166   \param signature number of tatum per beat (between 1 and 64)
     167
     168*/
     169uint_t aubio_tempo_set_tatum_signature(aubio_tempo_t *o, uint_t signature);
     170
     171/* check whether a tatum was detected in the current frame
     172
     173   \param o beat tracking object
     174
     175   \return 2 if a beat was detected, 1 if a tatum was detected, 0 otherwise
     176
     177*/
     178uint_t aubio_tempo_was_tatum(aubio_tempo_t *o);
     179
     180/* get position of last_tatum, in samples
     181
     182   \param o beat tracking object
     183
     184*/
     185smpl_t aubio_tempo_get_last_tatum(aubio_tempo_t *o);
     186
    163187/** delete tempo detection object
    164188
Note: See TracChangeset for help on using the changeset viewer.