Changeset 155cc10 for src/onset


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

Location:
src/onset
Files:
4 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);
  • src/onset/onset.h

    r00d0275 r155cc10  
    4040
    4141
    42 #ifndef _AUBIO_ONSET_H
    43 #define _AUBIO_ONSET_H
     42#ifndef AUBIO_ONSET_H
     43#define AUBIO_ONSET_H
    4444
    4545#ifdef __cplusplus
     
    6060
    6161*/
    62 aubio_onset_t * new_aubio_onset (char_t * method,
     62aubio_onset_t * new_aubio_onset (const char_t * method,
    6363    uint_t buf_size, uint_t hop_size, uint_t samplerate);
    6464
     
    8989
    9090*/
    91 void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset);
     91void aubio_onset_do (aubio_onset_t *o, const fvec_t * input, fvec_t * onset);
    9292
    9393/** get the time of the latest onset detected, in samples
     
    9898
    9999*/
    100 uint_t aubio_onset_get_last (aubio_onset_t *o);
     100uint_t aubio_onset_get_last (const aubio_onset_t *o);
    101101
    102102/** get the time of the latest onset detected, in seconds
     
    107107
    108108*/
    109 smpl_t aubio_onset_get_last_s (aubio_onset_t *o);
     109smpl_t aubio_onset_get_last_s (const aubio_onset_t *o);
    110110
    111111/** get the time of the latest onset detected, in milliseconds
     
    116116
    117117*/
    118 smpl_t aubio_onset_get_last_ms (aubio_onset_t *o);
     118smpl_t aubio_onset_get_last_ms (const aubio_onset_t *o);
    119119
    120120/** set onset detection adaptive whitening
     
    150150
    151151*/
    152 smpl_t aubio_onset_get_silence(aubio_onset_t * o);
     152smpl_t aubio_onset_get_silence(const aubio_onset_t * o);
    153153
    154154/** get onset detection function
     
    158158
    159159*/
    160 smpl_t aubio_onset_get_descriptor ( aubio_onset_t *o);
     160smpl_t aubio_onset_get_descriptor (const aubio_onset_t *o);
    161161
    162162/** get thresholded onset detection function
     
    166166
    167167*/
    168 smpl_t aubio_onset_get_thresholded_descriptor ( aubio_onset_t *o);
     168smpl_t aubio_onset_get_thresholded_descriptor (const aubio_onset_t *o);
    169169
    170170/** set onset detection peak picking threshold
     
    237237
    238238*/
    239 uint_t aubio_onset_get_minioi(aubio_onset_t * o);
     239uint_t aubio_onset_get_minioi(const aubio_onset_t * o);
    240240
    241241/** get minimum inter onset interval in seconds
     
    246246
    247247*/
    248 smpl_t aubio_onset_get_minioi_s(aubio_onset_t * o);
     248smpl_t aubio_onset_get_minioi_s(const aubio_onset_t * o);
    249249
    250250/** get minimum inter onset interval in milliseconds
     
    255255
    256256*/
    257 smpl_t aubio_onset_get_minioi_ms(aubio_onset_t * o);
     257smpl_t aubio_onset_get_minioi_ms(const aubio_onset_t * o);
    258258
    259259/** get delay in samples
     
    264264
    265265*/
    266 uint_t aubio_onset_get_delay(aubio_onset_t * o);
     266uint_t aubio_onset_get_delay(const aubio_onset_t * o);
    267267
    268268/** get delay in seconds
     
    273273
    274274*/
    275 smpl_t aubio_onset_get_delay_s(aubio_onset_t * o);
     275smpl_t aubio_onset_get_delay_s(const aubio_onset_t * o);
    276276
    277277/** get delay in milliseconds
     
    282282
    283283*/
    284 smpl_t aubio_onset_get_delay_ms(aubio_onset_t * o);
     284smpl_t aubio_onset_get_delay_ms(const aubio_onset_t * o);
    285285
    286286/** get onset peak picking threshold
     
    290290
    291291*/
    292 smpl_t aubio_onset_get_threshold(aubio_onset_t * o);
     292smpl_t aubio_onset_get_threshold(const aubio_onset_t * o);
    293293
    294294/** delete onset detection object
     
    303303#endif
    304304
    305 #endif /* _AUBIO_ONSET_H */
     305#endif /* AUBIO_ONSET_H */
  • src/onset/peakpicker.c

    r00d0275 r155cc10  
    186186   */
    187187  t->biquad = new_aubio_filter_biquad (0.15998789, 0.31997577, 0.15998789,
    188       -0.59488894, 0.23484048);
     188      // FIXME: broken since c9e20ca, revert for now
     189      //-0.59488894, 0.23484048);
     190      0.23484048, 0);
    189191
    190192  return t;
  • src/onset/peakpicker.h

    r00d0275 r155cc10  
    2727*/
    2828
    29 #ifndef _AUBIO_PEAKPICK_H
    30 #define _AUBIO_PEAKPICK_H
     29#ifndef AUBIO_PEAKPICK_H
     30#define AUBIO_PEAKPICK_H
    3131
    3232#ifdef __cplusplus
     
    5555#endif
    5656
    57 #endif /* _AUBIO_PEAKPICK_H */
     57#endif /* AUBIO_PEAKPICK_H */
Note: See TracChangeset for help on using the changeset viewer.