예제 #1
0
/* execute onset detection function on iput buffer */
void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset)
{
  smpl_t isonset = 0;
  aubio_pvoc_do (o->pv,input, o->fftgrain);
  aubio_specdesc_do (o->od, o->fftgrain, o->desc);
  aubio_peakpicker_do(o->pp, o->desc, onset);
  isonset = onset->data[0];
  if (isonset > 0.) {
    if (aubio_silence_detection(input, o->silence)==1) {
      //AUBIO_DBG ("silent onset, not marking as onset\n");
      isonset  = 0;
    } else {
      uint_t new_onset = o->total_frames + (uint_t)ROUND(isonset * o->hop_size);
      if (o->last_onset + o->minioi < new_onset) {
        //AUBIO_DBG ("accepted detection, marking as onset\n");
        o->last_onset = new_onset;
      } else {
        //AUBIO_DBG ("doubled onset, not marking as onset\n");
        isonset  = 0;
      }
    }
  } else {
    // we are at the beginning of the file, and we don't find silence
    if (o->total_frames == 0 && aubio_silence_detection(input, o->silence) == 0) {
      //AUBIO_DBG ("beginning of file is not silent, marking as onset\n");
      isonset = o->delay / o->hop_size;
      o->last_onset = o->delay;
    }
  }
  onset->data[0] = isonset;
  o->total_frames += o->hop_size;
  return;
}
예제 #2
0
파일: onset.c 프로젝트: anthonylauzon/aubio
/* execute onset detection function on iput buffer */
void aubio_onset_do (aubio_onset_t *o, const fvec_t * input, fvec_t * onset)
{
  smpl_t isonset = 0;
  aubio_pvoc_do (o->pv,input, o->fftgrain);
  /*
  if (apply_filtering) {
  }
  */
  if (o->apply_awhitening) {
    aubio_spectral_whitening_do(o->spectral_whitening, o->fftgrain);
  }
  if (o->apply_compression) {
    cvec_logmag(o->fftgrain, o->lambda_compression);
  }
  aubio_specdesc_do (o->od, o->fftgrain, o->desc);
  aubio_peakpicker_do(o->pp, o->desc, onset);
  isonset = onset->data[0];
  if (isonset > 0.) {
    if (aubio_silence_detection(input, o->silence)==1) {
      //AUBIO_DBG ("silent onset, not marking as onset\n");
      isonset  = 0;
    } else {
      // we have an onset
      uint_t new_onset = o->total_frames + (uint_t)ROUND(isonset * o->hop_size);
      // check if last onset time was more than minioi ago
      if (o->last_onset + o->minioi < new_onset) {
        // start of file: make sure (new_onset - delay) >= 0
        if (o->last_onset > 0 && o->delay > new_onset) {
          isonset = 0;
        } else {
          //AUBIO_DBG ("accepted detection, marking as onset\n");
          o->last_onset = MAX(o->delay, new_onset);
        }
      } else {
        //AUBIO_DBG ("doubled onset, not marking as onset\n");
        isonset  = 0;
      }
    }
  } else {
    // we are at the beginning of the file
    if (o->total_frames <= o->delay) {
      // and we don't find silence
      if (aubio_silence_detection(input, o->silence) == 0) {
        uint_t new_onset = o->total_frames;
        if (o->total_frames == 0 || o->last_onset + o->minioi < new_onset) {
          isonset = o->delay / o->hop_size;
          o->last_onset = o->total_frames + o->delay;
        }
      }
    }
  }
  onset->data[0] = isonset;
  o->total_frames += o->hop_size;
  return;
}
예제 #3
0
파일: tempo.c 프로젝트: Objzilla/aubio
/* execute tempo detection function on iput buffer */
void aubio_tempo_do(aubio_tempo_t *o, fvec_t * input, fvec_t * tempo)
{
  uint_t i;
  uint_t winlen = o->winlen;
  uint_t step   = o->step;
  fvec_t * thresholded;
  aubio_pvoc_do (o->pv, input, o->fftgrain);
  aubio_specdesc_do (o->od, o->fftgrain, o->of);
  /*if (usedoubled) {
    aubio_specdesc_do(o2,fftgrain, onset2);
    onset->data[0] *= onset2->data[0];
  }*/
  /* execute every overlap_size*step */
  if (o->blockpos == (signed)step -1 ) {
    /* check dfframe */
    aubio_beattracking_do(o->bt,o->dfframe,o->out);
    /* rotate dfframe */
    for (i = 0 ; i < winlen - step; i++ ) 
      o->dfframe->data[i] = o->dfframe->data[i+step];
    for (i = winlen - step ; i < winlen; i++ ) 
      o->dfframe->data[i] = 0.;
    o->blockpos = -1;
  }
  o->blockpos++;
  aubio_peakpicker_do (o->pp, o->of, o->onset);
  tempo->data[1] = o->onset->data[0];
  thresholded = aubio_peakpicker_get_thresholded_input(o->pp);
  o->dfframe->data[winlen - step + o->blockpos] = thresholded->data[0];
  /* end of second level loop */
  tempo->data[0] = 0; /* reset tactus */
  i=0;
  for (i = 1; i < o->out->data[0]; i++ ) {
    /* if current frame is a predicted tactus */
    if (o->blockpos == FLOOR(o->out->data[i])) {
      tempo->data[0] = o->out->data[i] - FLOOR(o->out->data[i]); /* set tactus */
      /* test for silence */
      /*
      if (aubio_silence_detection(input, o->silence)==1) {
        tempo->data[0] = 0; // unset beat if silent
      }
      */
      o->last_beat = o->total_frames + (uint_t)ROUND(tempo->data[0] * o->hop_size);
    }
  }
  o->total_frames += o->hop_size;
  return;
}