Changeset d207300


Ignore:
Timestamp:
Dec 4, 2009, 1:40:48 AM (10 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:
8e5c051
Parents:
741bdda
Message:

src/tempo: switch to mono

Location:
src/tempo
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/tempo/beattracking.c

    r741bdda rd207300  
    5555
    5656aubio_beattracking_t *
    57 new_aubio_beattracking (uint_t winlen, uint_t channels)
     57new_aubio_beattracking (uint_t winlen)
    5858{
    5959
     
    7979  p->rayparam = rayparam;
    8080  p->step = step;
    81   p->rwv = new_fvec (laglen, 1);
    82   p->gwv = new_fvec (laglen, 1);
    83   p->dfwv = new_fvec (winlen, 1);
    84   p->dfrev = new_fvec (winlen, channels);
    85   p->acf = new_fvec (winlen, channels);
    86   p->acfout = new_fvec (laglen, channels);
    87   p->phwv = new_fvec (2 * laglen, 1);
    88   p->phout = new_fvec (winlen, channels);
     81  p->rwv = new_fvec (laglen);
     82  p->gwv = new_fvec (laglen);
     83  p->dfwv = new_fvec (winlen);
     84  p->dfrev = new_fvec (winlen);
     85  p->acf = new_fvec (winlen);
     86  p->acfout = new_fvec (laglen);
     87  p->phwv = new_fvec (2 * laglen);
     88  p->phout = new_fvec (winlen);
    8989
    9090  p->timesig = 0;
     
    9292  /* exponential weighting, dfwv = 0.5 when i =  43 */
    9393  for (i = 0; i < winlen; i++) {
    94     p->dfwv->data[0][i] = (EXP ((LOG (2.0) / rayparam) * (i + 1)))
     94    p->dfwv->data[i] = (EXP ((LOG (2.0) / rayparam) * (i + 1)))
    9595        / dfwvnorm;
    9696  }
    9797
    9898  for (i = 0; i < (laglen); i++) {
    99     p->rwv->data[0][i] = ((smpl_t) (i + 1.) / SQR ((smpl_t) rayparam)) *
     99    p->rwv->data[i] = ((smpl_t) (i + 1.) / SQR ((smpl_t) rayparam)) *
    100100        EXP ((-SQR ((smpl_t) (i + 1.)) / (2. * SQR ((smpl_t) rayparam))));
    101101  }
     
    161161    for (a = 1; a <= numelem; a++) {
    162162      for (b = (1 - a); b < a; b++) {
    163         bt->acfout->data[0][i] += bt->acf->data[0][a * (i + 1) + b - 1]
     163        bt->acfout->data[i] += bt->acf->data[a * (i + 1) + b - 1]
    164164            * 1. / (2. * a - 1.);
    165165      }
     
    171171  /* find non-zero Rayleigh period */
    172172  maxindex = fvec_max_elem (bt->acfout);
    173   bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex, 0) : 1;
     173  bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex) : 1;
    174174  //rp = (maxindex==127) ? 43 : maxindex; //rayparam
    175175  bt->rp = (maxindex == bt->acfout->length - 1) ? bt->rayparam : maxindex;      //rayparam
     
    191191  for (i = 0; i < bp; i++) {
    192192    for (k = 0; k < kmax; k++) {
    193       bt->phout->data[0][i] += bt->dfrev->data[0][i + (uint_t) ROUND (bp * k)];
     193      bt->phout->data[i] += bt->dfrev->data[i + (uint_t) ROUND (bp * k)];
    194194    }
    195195  }
     
    204204    phase = step - bt->lastbeat;
    205205  } else {
    206     phase = fvec_quadint (bt->phout, maxindex, 0);
     206    phase = fvec_quadint (bt->phout, maxindex);
    207207  }
    208208  /* take back one frame delay */
     
    237237  if (beat >= 0) {
    238238    //AUBIO_DBG ("beat: %d, %f, %f\n", i, bp, beat);
    239     output->data[0][i] = beat;
     239    output->data[i] = beat;
    240240    i++;
    241241  }
     
    244244    beat += bp;
    245245    //AUBIO_DBG ("beat: %d, %f, %f\n", i, bp, beat);
    246     output->data[0][i] = beat;
     246    output->data[i] = beat;
    247247    i++;
    248248  }
     
    250250  bt->lastbeat = beat;
    251251  /* store the number of beats in this frame as the first element */
    252   output->data[0][0] = i;
     252  output->data[0] = i;
    253253}
    254254
     
    260260  if (acflen > 6 * gp + 2) {
    261261    for (k = -2; k < 2; k++) {
    262       three_energy += acf->data[0][3 * gp + k];
    263       four_energy += acf->data[0][4 * gp + k];
     262      three_energy += acf->data[3 * gp + k];
     263      four_energy += acf->data[4 * gp + k];
    264264    }
    265265  } else {
    266266    /*Expanded to be more accurate in time sig estimation */
    267267    for (k = -2; k < 2; k++) {
    268       three_energy += acf->data[0][3 * gp + k] + acf->data[0][6 * gp + k];
    269       four_energy += acf->data[0][4 * gp + k] + acf->data[0][2 * gp + k];
     268      three_energy += acf->data[3 * gp + k] + acf->data[6 * gp + k];
     269      four_energy += acf->data[4 * gp + k] + acf->data[2 * gp + k];
    270270    }
    271271  }
     
    301301      for (a = 1; a <= bt->timesig; a++) {
    302302        for (b = (1 - a); b < a; b++) {
    303           acfout->data[0][i] += acf->data[0][a * (i + 1) + b - 1];
     303          acfout->data[i] += acf->data[a * (i + 1) + b - 1];
    304304        }
    305305      }
    306306    }
    307307    fvec_weight (acfout, bt->gwv);
    308     gp = fvec_quadint (acfout, fvec_max_elem (acfout), 0);
     308    gp = fvec_quadint (acfout, fvec_max_elem (acfout));
    309309    /*
    310310       while(gp<32) gp =gp*2;
     
    351351    bt->timesig = fvec_gettimesig (acf, acflen, gp);
    352352    for (j = 0; j < laglen; j++)
    353       bt->gwv->data[0][j] =
     353      bt->gwv->data[j] =
    354354          EXP (-.5 * SQR ((smpl_t) (j + 1. - gp)) / SQR (bt->g_var));
    355355    flagconst = 0;
     
    363363    if (step > bt->lastbeat) {
    364364      for (j = 0; j < 2 * laglen; j++) {
    365         bt->phwv->data[0][j] =
     365        bt->phwv->data[j] =
    366366            EXP (-.5 * SQR ((smpl_t) (1. + j - step +
    367367                    bt->lastbeat)) / (bp / 8.));
     
    410410{
    411411  if (bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) {
    412     return 5168. / fvec_quadint (bt->acfout, bt->bp, 0);
     412    return 5168. / fvec_quadint (bt->acfout, bt->bp);
    413413  } else {
    414414    return 0.;
  • src/tempo/beattracking.h

    r741bdda rd207300  
    4848
    4949  \param hop_size number of onset detection samples [512]
    50   \param channels number (not functionnal) [1]
    5150
    5251*/
    53 aubio_beattracking_t * new_aubio_beattracking(uint_t hop_size, uint_t channels);
     52aubio_beattracking_t * new_aubio_beattracking(uint_t hop_size);
    5453
    5554/** track the beat
  • src/tempo/tempo.c

    r741bdda rd207300  
    5959  /*if (usedoubled) {
    6060    aubio_specdesc_do(o2,fftgrain, onset2);
    61     onset->data[0][0] *= onset2->data[0][0];
     61    onset->data[0] *= onset2->data[0];
    6262  }*/
    6363  /* execute every overlap_size*step */
     
    6767    /* rotate dfframe */
    6868    for (i = 0 ; i < winlen - step; i++ )
    69       o->dfframe->data[0][i] = o->dfframe->data[0][i+step];
     69      o->dfframe->data[i] = o->dfframe->data[i+step];
    7070    for (i = winlen - step ; i < winlen; i++ )
    71       o->dfframe->data[0][i] = 0.;
     71      o->dfframe->data[i] = 0.;
    7272    o->blockpos = -1;
    7373  }
    7474  o->blockpos++;
    7575  aubio_peakpicker_do (o->pp, o->of, o->onset);
    76   tempo->data[0][1] = o->onset->data[0][0];
     76  tempo->data[1] = o->onset->data[0];
    7777  thresholded = aubio_peakpicker_get_thresholded_input(o->pp);
    78   o->dfframe->data[0][winlen - step + o->blockpos] = thresholded->data[0][0];
     78  o->dfframe->data[winlen - step + o->blockpos] = thresholded->data[0];
    7979  /* end of second level loop */
    80   tempo->data[0][0] = 0; /* reset tactus */
     80  tempo->data[0] = 0; /* reset tactus */
    8181  i=0;
    82   for (i = 1; i < o->out->data[0][0]; i++ ) {
     82  for (i = 1; i < o->out->data[0]; i++ ) {
    8383    /* if current frame is a predicted tactus */
    84     if (o->blockpos == FLOOR(o->out->data[0][i])) {
    85       tempo->data[0][0] = o->out->data[0][i] - FLOOR(o->out->data[0][i]); /* set tactus */
     84    if (o->blockpos == FLOOR(o->out->data[i])) {
     85      tempo->data[0] = o->out->data[i] - FLOOR(o->out->data[i]); /* set tactus */
    8686      /* test for silence */
    8787      if (aubio_silence_detection(input, o->silence)==1) {
    88         tempo->data[0][1] = 0; /* unset onset */
     88        tempo->data[1] = 0; /* unset onset */
    8989      }
    9090    }
     
    105105/* Allocate memory for an tempo detection */
    106106aubio_tempo_t * new_aubio_tempo (char_t * onset_mode,
    107     uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate)
     107    uint_t buf_size, uint_t hop_size, uint_t samplerate)
    108108{
    109109  aubio_tempo_t * o = AUBIO_NEW(aubio_tempo_t);
     
    115115  o->silence = -90.;
    116116  o->blockpos = 0;
    117   o->dfframe  = new_fvec(o->winlen,channels);
    118   o->fftgrain = new_cvec(buf_size, channels);
    119   o->out      = new_fvec(o->step,channels);
    120   o->pv       = new_aubio_pvoc(buf_size, hop_size, channels);
    121   o->pp       = new_aubio_peakpicker(channels);
     117  o->dfframe  = new_fvec(o->winlen);
     118  o->fftgrain = new_cvec(buf_size);
     119  o->out      = new_fvec(o->step);
     120  o->pv       = new_aubio_pvoc(buf_size, hop_size);
     121  o->pp       = new_aubio_peakpicker();
    122122  aubio_peakpicker_set_threshold (o->pp, o->threshold);
    123   o->od       = new_aubio_specdesc(onset_mode,buf_size,channels);
    124   o->of       = new_fvec(1, channels);
    125   o->bt       = new_aubio_beattracking(o->winlen,channels);
    126   o->onset    = new_fvec(1, channels);
     123  o->od       = new_aubio_specdesc(onset_mode,buf_size);
     124  o->of       = new_fvec(1);
     125  o->bt       = new_aubio_beattracking(o->winlen);
     126  o->onset    = new_fvec(1);
    127127  /*if (usedoubled)    {
    128     o2 = new_aubio_specdesc(type_onset2,buffer_size,channels);
    129     onset2 = new_fvec(1 , channels);
     128    o2 = new_aubio_specdesc(type_onset2,buffer_size);
     129    onset2 = new_fvec(1);
    130130  }*/
    131131  return o;
  • src/tempo/tempo.h

    r741bdda rd207300  
    4040/** create tempo detection object */
    4141aubio_tempo_t * new_aubio_tempo (char_t * method,
    42     uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate);
     42    uint_t buf_size, uint_t hop_size, uint_t samplerate);
    4343
    4444/** execute tempo detection */
Note: See TracChangeset for help on using the changeset viewer.