Changeset 09558b8


Ignore:
Timestamp:
Feb 2, 2017, 2:04:27 AM (4 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
yinfft+
Children:
422a2a9
Parents:
a7b14a6
Message:

src/pitch/pitchyinfft.c: simplify local peak lookup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitchyinfft.c

    ra7b14a6 r09558b8  
    112112  uint_t tau, l;
    113113  uint_t length = p->fftout->length;
    114   uint_t halfperiod;
    115114  fvec_t *fftout = p->fftout;
    116115  fvec_t *yin = p->yinfft;
    117116  smpl_t tmp = 0., sum = 0.;
     117  uint_t startbin = 0, endbin = 0, before = 0, after = 0;
    118118
    119119  // window the input
     
    154154  tmp = fvec_min(yin);
    155155  if (tmp > p->tol) {
    156     // give up - got no confident candidate at all 
     156    // give up - got no confident candidate at all
    157157    output->data[0] = 0.;
    158158    return;
     
    169169  }
    170170  // find local min around current pick to sharpen the results
    171   const uint_t LOCAL_NOTE_SEEK_RANGE = 1;
    172   const smpl_t note = aubio_bintomidi (tau, p->samplerate, p->fftout->length);
    173   const uint_t startbin = MAX (0, (uint_t)aubio_miditobin (note - LOCAL_NOTE_SEEK_RANGE,
    174     p->samplerate, p->fftout->length));
    175   const uint_t endbin = MIN (yin->length, (uint_t)(aubio_miditobin (note + LOCAL_NOTE_SEEK_RANGE,
    176     p->samplerate, p->fftout->length) + 0.5));
     171  before = 2, after = 5;
     172  // for low frequency, the peak may be large, we use a larger after
     173  if (tau > yin->length/2) { before = 1; after = 20; }
     174  startbin = tau > before ? tau - before : 0;
     175  endbin = tau < yin->length - 1 - after ? tau + after : yin->length - 1;
    177176  tmp = yin->data[tau];
    178177  for (l = startbin; l < endbin; l++) {
Note: See TracChangeset for help on using the changeset viewer.