Ejemplo n.º 1
0
uint_t aubio_onset_set_default_parameters (aubio_onset_t * o, const char_t * onset_mode)
{
  uint_t ret = AUBIO_OK;
  /* set some default parameter */
  aubio_onset_set_threshold (o, 0.3);
  aubio_onset_set_delay (o, 4.3 * o->hop_size);
  aubio_onset_set_minioi_ms (o, 50.);
  aubio_onset_set_silence (o, -70.);
  // disable spectral whitening
  aubio_onset_set_awhitening (o, 0);
  // disable logarithmic magnitude
  aubio_onset_set_compression (o, 0.);

  /* method specific optimisations */
  if (strcmp (onset_mode, "energy") == 0) {
  } else if (strcmp (onset_mode, "hfc") == 0 || strcmp (onset_mode, "default") == 0) {
    aubio_onset_set_threshold (o, 0.058);
    aubio_onset_set_compression (o, 1.);
  } else if (strcmp (onset_mode, "complexdomain") == 0
             || strcmp (onset_mode, "complex") == 0) {
    aubio_onset_set_delay (o, 4.6 * o->hop_size);
    aubio_onset_set_threshold (o, 0.15);
    aubio_onset_set_awhitening(o, 1);
    aubio_onset_set_compression (o, 1.);
  } else if (strcmp (onset_mode, "phase") == 0) {
    o->apply_compression = 0;
    aubio_onset_set_awhitening (o, 0);
  } else if (strcmp (onset_mode, "wphase") == 0) {
    // use defaults for now
  } else if (strcmp (onset_mode, "mkl") == 0) {
    aubio_onset_set_threshold (o, 0.05);
    aubio_onset_set_awhitening(o, 1);
    aubio_onset_set_compression (o, 0.02);
  } else if (strcmp (onset_mode, "kl") == 0) {
    aubio_onset_set_threshold (o, 0.35);
    aubio_onset_set_awhitening(o, 1);
    aubio_onset_set_compression (o, 0.02);
  } else if (strcmp (onset_mode, "specflux") == 0) {
    aubio_onset_set_threshold (o, 0.18);
    aubio_onset_set_awhitening(o, 1);
    aubio_spectral_whitening_set_relax_time(o->spectral_whitening, 100);
    aubio_spectral_whitening_set_floor(o->spectral_whitening, 1.);
    aubio_onset_set_compression (o, 10.);
  } else if (strcmp (onset_mode, "specdiff") == 0) {
  } else if (strcmp (onset_mode, "old_default") == 0) {
    // used to reproduce results obtained with the previous version
    aubio_onset_set_threshold (o, 0.3);
    aubio_onset_set_minioi_ms (o, 20.);
    aubio_onset_set_compression (o, 0.);
  } else {
    AUBIO_WRN("onset: unknown spectral descriptor type %s, "
               "using default parameters.\n", onset_mode);
    ret = AUBIO_FAIL;
  }
  return ret;
}
Ejemplo n.º 2
0
/* Allocate memory for an onset detection */
aubio_onset_t * new_aubio_onset (const char_t * onset_mode,
                                 uint_t buf_size, uint_t hop_size, uint_t samplerate)
{
    aubio_onset_t * o = AUBIO_NEW(aubio_onset_t);

    /* check parameters are valid */
    if ((sint_t)hop_size < 1) {
        AUBIO_ERR("onset: got hop_size %d, but can not be < 1\n", hop_size);
        goto beach;
    } else if ((sint_t)buf_size < 2) {
        AUBIO_ERR("onset: got buffer_size %d, but can not be < 2\n", buf_size);
        goto beach;
    } else if (buf_size < hop_size) {
        AUBIO_ERR("onset: hop size (%d) is larger than win size (%d)\n", buf_size, hop_size);
        goto beach;
    } else if ((sint_t)samplerate < 1) {
        AUBIO_ERR("onset: samplerate (%d) can not be < 1\n", samplerate);
        goto beach;
    }

    /* store creation parameters */
    o->samplerate = samplerate;
    o->hop_size = hop_size;

    /* allocate memory */
    o->pv = new_aubio_pvoc(buf_size, o->hop_size);
    o->pp = new_aubio_peakpicker();
    o->od = new_aubio_specdesc(onset_mode,buf_size);
    o->fftgrain = new_cvec(buf_size);
    o->desc = new_fvec(1);

    /* set some default parameter */
    aubio_onset_set_threshold (o, 0.3);
    aubio_onset_set_delay(o, 4.3 * hop_size);
    aubio_onset_set_minioi_ms(o, 20.);
    aubio_onset_set_silence(o, -70.);

    /* initialize internal variables */
    o->last_onset = 0;
    o->total_frames = 0;
    return o;

beach:
    AUBIO_FREE(o);
    return NULL;
}
Ejemplo n.º 3
0
uint_t aubio_onset_set_delay_s(aubio_onset_t * o, smpl_t delay) {
  return aubio_onset_set_delay (o, delay * o->samplerate);
}