Changeset 483b883 for src/tempo


Ignore:
Timestamp:
Apr 9, 2013, 7:54:52 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
9c9202f
Parents:
8b884ef
Message:

src/tempo/tempo.c: add get_last functions

Location:
src/tempo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/tempo/tempo.c

    r8b884ef r483b883  
    4646  uint_t step;                   /** dfframe hopsize */
    4747  uint_t samplerate;             /** sampling rate of the signal */
     48  uint_t hop_size;               /** get hop_size */
     49  uint_t total_frames;           /** total frames since beginning */
     50  uint_t last_beat;              /** time of latest detected beat, in samples */
     51  uint_t delay;                  /** delay to remove to last beat, in samples */
    4852};
    4953
     
    8690      /* test for silence */
    8791      if (aubio_silence_detection(input, o->silence)==1) {
    88         tempo->data[1] = 0; /* unset onset */
     92        //tempo->data[0] = 0; /* unset onset */
     93      } else {
     94        o->last_beat = o->total_frames + (uint_t)ROUND(tempo->data[0] * o->hop_size);
    8995      }
    9096    }
    9197  }
     98  o->total_frames += o->hop_size;
     99  return;
     100}
     101
     102uint_t aubio_tempo_get_last (aubio_tempo_t *o)
     103{
     104  return o->last_beat - o->delay;
     105}
     106
     107smpl_t aubio_tempo_get_last_s (aubio_tempo_t *o)
     108{
     109  return aubio_tempo_get_last (o) / (smpl_t) (o->samplerate);
     110}
     111
     112smpl_t aubio_tempo_get_last_ms (aubio_tempo_t *o)
     113{
     114  return aubio_tempo_get_last_s (o) / 1000.;
     115}
     116
     117uint_t aubio_tempo_set_delay(aubio_tempo_t * o, uint_t delay) {
     118  o->delay = delay;
     119  return AUBIO_OK;
     120}
     121
     122uint_t aubio_tempo_get_delay(aubio_tempo_t * o) {
     123  return o->delay;
    92124}
    93125
     
    115147  o->silence = -90.;
    116148  o->blockpos = 0;
     149  o->total_frames = 0;
     150  o->last_beat = 0;
     151  o->delay = 0;
     152  o->hop_size = hop_size;
    117153  o->dfframe  = new_fvec(o->winlen);
    118154  o->fftgrain = new_cvec(buf_size);
  • src/tempo/tempo.h

    r8b884ef r483b883  
    6161void aubio_tempo_do (aubio_tempo_t *o, fvec_t * input, fvec_t * tempo);
    6262
     63/** get the time of the latest beat detected, in samples
     64
     65  \param o tempo detection object as returned by ::new_aubio_tempo
     66
     67*/
     68uint_t aubio_tempo_get_last (aubio_tempo_t *o);
     69
     70/** get the time of the latest beat detected, in seconds
     71
     72  \param o tempo detection object as returned by ::new_aubio_tempo
     73
     74*/
     75smpl_t aubio_tempo_get_last_s (aubio_tempo_t *o);
     76
     77/** get the time of the latest beat detected, in milliseconds
     78
     79  \param o tempo detection object as returned by ::new_aubio_tempo
     80
     81*/
     82smpl_t aubio_tempo_get_last_ms (aubio_tempo_t *o);
     83
    6384/** set tempo detection silence threshold
    6485
Note: See TracChangeset for help on using the changeset viewer.