Changeset 155cc10 for src/onset/onset.c


Ignore:
Timestamp:
Mar 10, 2017, 2:26:32 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, sampler
Children:
ee8a57c
Parents:
00d0275 (diff), 67b6618 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into awhitening

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/onset/onset.c

    r00d0275 r155cc10  
    5252
    5353/* execute onset detection function on iput buffer */
    54 void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset)
     54void aubio_onset_do (aubio_onset_t *o, const fvec_t * input, fvec_t * onset)
    5555{
    5656  smpl_t isonset = 0;
     
    100100}
    101101
    102 uint_t aubio_onset_get_last (aubio_onset_t *o)
     102uint_t aubio_onset_get_last (const aubio_onset_t *o)
    103103{
    104104  return o->last_onset - o->delay;
    105105}
    106106
    107 smpl_t aubio_onset_get_last_s (aubio_onset_t *o)
     107smpl_t aubio_onset_get_last_s (const aubio_onset_t *o)
    108108{
    109109  return aubio_onset_get_last (o) / (smpl_t) (o->samplerate);
    110110}
    111111
    112 smpl_t aubio_onset_get_last_ms (aubio_onset_t *o)
     112smpl_t aubio_onset_get_last_ms (const aubio_onset_t *o)
    113113{
    114114  return aubio_onset_get_last_s (o) * 1000.;
     
    131131}
    132132
    133 smpl_t aubio_onset_get_silence(aubio_onset_t * o) {
     133smpl_t aubio_onset_get_silence(const aubio_onset_t * o) {
    134134  return o->silence;
    135135}
     
    140140}
    141141
    142 smpl_t aubio_onset_get_threshold(aubio_onset_t * o) {
     142smpl_t aubio_onset_get_threshold(const aubio_onset_t * o) {
    143143  return aubio_peakpicker_get_threshold(o->pp);
    144144}
     
    149149}
    150150
    151 uint_t aubio_onset_get_minioi(aubio_onset_t * o) {
     151uint_t aubio_onset_get_minioi(const aubio_onset_t * o) {
    152152  return o->minioi;
    153153}
    154154
    155155uint_t aubio_onset_set_minioi_s(aubio_onset_t * o, smpl_t minioi) {
    156   return aubio_onset_set_minioi (o, minioi * o->samplerate);
    157 }
    158 
    159 smpl_t aubio_onset_get_minioi_s(aubio_onset_t * o) {
     156  return aubio_onset_set_minioi (o, (uint_t)ROUND(minioi * o->samplerate));
     157}
     158
     159smpl_t aubio_onset_get_minioi_s(const aubio_onset_t * o) {
    160160  return aubio_onset_get_minioi (o) / (smpl_t) o->samplerate;
    161161}
     
    165165}
    166166
    167 smpl_t aubio_onset_get_minioi_ms(aubio_onset_t * o) {
     167smpl_t aubio_onset_get_minioi_ms(const aubio_onset_t * o) {
    168168  return aubio_onset_get_minioi_s (o) * 1000.;
    169169}
     
    174174}
    175175
    176 uint_t aubio_onset_get_delay(aubio_onset_t * o) {
     176uint_t aubio_onset_get_delay(const aubio_onset_t * o) {
    177177  return o->delay;
    178178}
     
    182182}
    183183
    184 smpl_t aubio_onset_get_delay_s(aubio_onset_t * o) {
     184smpl_t aubio_onset_get_delay_s(const aubio_onset_t * o) {
    185185  return aubio_onset_get_delay (o) / (smpl_t) o->samplerate;
    186186}
     
    190190}
    191191
    192 smpl_t aubio_onset_get_delay_ms(aubio_onset_t * o) {
     192smpl_t aubio_onset_get_delay_ms(const aubio_onset_t * o) {
    193193  return aubio_onset_get_delay_s (o) * 1000.;
    194194}
    195195
    196 smpl_t aubio_onset_get_descriptor(aubio_onset_t * o) {
     196smpl_t aubio_onset_get_descriptor(const aubio_onset_t * o) {
    197197  return o->desc->data[0];
    198198}
    199199
    200 smpl_t aubio_onset_get_thresholded_descriptor(aubio_onset_t * o) {
     200smpl_t aubio_onset_get_thresholded_descriptor(const aubio_onset_t * o) {
    201201  fvec_t * thresholded = aubio_peakpicker_get_thresholded_input(o->pp);
    202202  return thresholded->data[0];
     
    204204
    205205/* Allocate memory for an onset detection */
    206 aubio_onset_t * new_aubio_onset (char_t * onset_mode,
     206aubio_onset_t * new_aubio_onset (const char_t * onset_mode,
    207207    uint_t buf_size, uint_t hop_size, uint_t samplerate)
    208208{
     
    213213    AUBIO_ERR("onset: got hop_size %d, but can not be < 1\n", hop_size);
    214214    goto beach;
    215   } else if ((sint_t)buf_size < 1) {
    216     AUBIO_ERR("onset: got buffer_size %d, but can not be < 1\n", buf_size);
     215  } else if ((sint_t)buf_size < 2) {
     216    AUBIO_ERR("onset: got buffer_size %d, but can not be < 2\n", buf_size);
    217217    goto beach;
    218218  } else if (buf_size < hop_size) {
    219     AUBIO_ERR("onset: hop size (%d) is larger than win size (%d)\n", buf_size, hop_size);
     219    AUBIO_ERR("onset: hop size (%d) is larger than win size (%d)\n", hop_size, buf_size);
    220220    goto beach;
    221221  } else if ((sint_t)samplerate < 1) {
     
    232232  o->pp = new_aubio_peakpicker();
    233233  o->od = new_aubio_specdesc(onset_mode,buf_size);
     234  if (o->od == NULL) goto beach_specdesc;
    234235  o->fftgrain = new_cvec(buf_size);
    235236  o->desc = new_fvec(1);
     
    244245  return o;
    245246
     247beach_specdesc:
     248  del_aubio_peakpicker(o->pp);
     249  del_aubio_pvoc(o->pv);
    246250beach:
    247251  AUBIO_FREE(o);
Note: See TracChangeset for help on using the changeset viewer.