/* 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; }
/* 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", hop_size, buf_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); if (o->od == NULL) goto beach_specdesc; o->fftgrain = new_cvec(buf_size); o->desc = new_fvec(1); o->spectral_whitening = new_aubio_spectral_whitening(buf_size, hop_size, samplerate); /* initialize internal variables */ aubio_onset_set_default_parameters (o, onset_mode); aubio_onset_reset(o); return o; beach_specdesc: del_aubio_peakpicker(o->pp); del_aubio_pvoc(o->pv); beach: AUBIO_FREE(o); return NULL; }
/* Allocate memory for an onset detection */ aubio_onset_t * new_aubio_onset (char_t * onset_mode, uint_t buf_size, uint_t hop_size, uint_t samplerate) { aubio_onset_t * o = AUBIO_NEW(aubio_onset_t); /** set some default parameter */ o->samplerate = samplerate; o->hop_size = hop_size; o->last_onset = 0; o->threshold = 0.3; o->delay = 4.3 * hop_size; o->minioi = 5 * hop_size; o->silence = -70; o->total_frames = 0; o->pv = new_aubio_pvoc(buf_size, o->hop_size); o->pp = new_aubio_peakpicker(); aubio_peakpicker_set_threshold (o->pp, o->threshold); o->od = new_aubio_specdesc(onset_mode,buf_size); o->fftgrain = new_cvec(buf_size); o->desc = new_fvec(1); return o; }
/* Allocate memory for an tempo detection */ aubio_tempo_t * new_aubio_tempo (char_t * tempo_mode, uint_t buf_size, uint_t hop_size, uint_t samplerate) { aubio_tempo_t * o = AUBIO_NEW(aubio_tempo_t); char_t specdesc_func[20]; o->samplerate = samplerate; /* length of observations, worth about 6 seconds */ o->winlen = aubio_next_power_of_two(5.8 * samplerate / hop_size); o->step = o->winlen/4; o->blockpos = 0; o->threshold = 0.3; o->silence = -90.; o->total_frames = 0; o->last_beat = 0; o->delay = 0; o->hop_size = hop_size; o->dfframe = new_fvec(o->winlen); o->fftgrain = new_cvec(buf_size); o->out = new_fvec(o->step); o->pv = new_aubio_pvoc(buf_size, hop_size); o->pp = new_aubio_peakpicker(); aubio_peakpicker_set_threshold (o->pp, o->threshold); if ( strcmp(tempo_mode, "default") == 0 ) { strcpy(specdesc_func, "specflux"); } else { strcpy(specdesc_func, tempo_mode); } o->od = new_aubio_specdesc(specdesc_func,buf_size); o->of = new_fvec(1); o->bt = new_aubio_beattracking(o->winlen, o->hop_size, o->samplerate); o->onset = new_fvec(1); /*if (usedoubled) { o2 = new_aubio_specdesc(type_onset2,buffer_size); onset2 = new_fvec(1); }*/ return o; }