Changeset 17b7d66


Ignore:
Timestamp:
Sep 28, 2009, 8:12:02 PM (15 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:
258195f
Parents:
3de10bb
Message:

src/tempo/beattracking.c: avoid large backward off-beat errors, add define for debugging

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tempo/beattracking.c

    r3de10bb r17b7d66  
    2222#include "mathutils.h"
    2323#include "tempo/beattracking.h"
     24
     25/** define to 1 to print out tracking difficulties */
     26#define AUBIO_BEAT_WARNINGS 1
    2427
    2528uint_t fvec_gettimesig (fvec_t * acf, uint_t acflen, uint_t gp);
     
    195198  maxindex = vec_max_elem (bt->phout);
    196199  if (maxindex >= winlen - 1) {
    197     // AUBIO_WRN ("damned, no idea what this groove is\n");
     200#if AUBIO_BEAT_WARNINGS
     201    AUBIO_WRN ("no idea what this groove's phase is\n");
     202#endif /* AUBIO_BEAT_WARNINGS */
    198203    phase = step - bt->lastbeat;
    199204  } else {
    200205    phase = vec_quadint (bt->phout, maxindex, 1);
    201206  }
     207  /* take back one frame delay */
     208  phase += 1.;
    202209#if 0                           // debug metronome mode
    203210  phase = step - bt->lastbeat;
     
    209216  i = 1;
    210217  beat = bp - phase;
    211   //AUBIO_DBG ("beat: %f, bp: %f, phase: %f, lastbeat: %f, step: %d, winlen: %d\n",
    212   //    beat, bp, phase, bt->lastbeat, step, winlen);
     218
     219  // AUBIO_DBG ("bp: %f, phase: %f, lastbeat: %f, step: %d, winlen: %d\n",
     220  //    bp, phase, bt->lastbeat, step, winlen);
     221
     222  /* the next beat will be earlier than 60% of the tempo period
     223    skip this one */
     224  if ( ( step - bt->lastbeat - phase ) < -0.40 * bp ) {
     225#if AUBIO_BEAT_WARNINGS
     226    AUBIO_WRN ("back off-beat error, skipping this beat\n");
     227#endif /* AUBIO_BEAT_WARNINGS */
     228    beat += bp;
     229  }
     230
    213231  /* start counting the beats */
    214232  while (beat + bp < 0) {
     
    230248
    231249  bt->lastbeat = beat;
    232   /* store the number of beat found in this frame as the first element */
     250  /* store the number of beats in this frame as the first element */
    233251  output->data[0][0] = i;
    234252}
     
    364382  /* if tempo is > 206 bpm, half it */
    365383  while (bp < 25) {
    366     //AUBIO_DBG("warning, doubling the beat period from %d\n", bp);
     384#if AUBIO_BEAT_WARNINGS
     385    AUBIO_WRN ("doubling from %f (%f bpm) to %f (%f bpm)\n",
     386        bp, 60.*44100./512./bp, bp/2., 60.*44100./512./bp/2. );
    367387    //AUBIO_DBG("warning, halving the tempo from %f\n", 60.*samplerate/hopsize/bp);
     388#endif /* AUBIO_BEAT_WARNINGS */
    368389    bp = bp * 2;
    369390  }
Note: See TracChangeset for help on using the changeset viewer.