Changeset b4f5967


Ignore:
Timestamp:
Oct 15, 2009, 5:09:34 PM (15 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, pitchshift, sampler, timestretch, yinfft+
Children:
cd77c15
Parents:
27fa522
Message:

src/onset: use a string to set onset mode, keeping onset types enum private, update everywhere onsets are used

Files:
16 edited

Legend:

Unmodified
Added
Removed
  • examples/aubiotrack.c

    r27fa522 rb4f5967  
    8181
    8282  out = new_fvec(2,channels);
    83   bt  = new_aubio_tempo(type_onset,buffer_size,overlap_size,channels);
     83  bt  = new_aubio_tempo(onset_mode,buffer_size,overlap_size,channels);
    8484
    8585  examples_common_process(aubio_process,process_print);
  • examples/utils.c

    r27fa522 rb4f5967  
    4646
    4747/* energy,specdiff,hfc,complexdomain,phase */
    48 aubio_onsetdetection_type type_onset = aubio_onset_kl;
    49 aubio_onsetdetection_type type_onset2 = aubio_onset_complex;
     48char_t * onset_mode = "default";
    5049smpl_t threshold = 0.3;
    5150smpl_t silence = -90.;
     
    9291
    9392/* badly redeclare some things */
    94 aubio_onsetdetection_type type_onset;
    9593smpl_t threshold;
    9694smpl_t averaging;
     
    164162        break;
    165163      case 'O':                /*onset type */
    166         if (strcmp (optarg, "energy") == 0)
    167           type_onset = aubio_onset_energy;
    168         else if (strcmp (optarg, "specdiff") == 0)
    169           type_onset = aubio_onset_specdiff;
    170         else if (strcmp (optarg, "hfc") == 0)
    171           type_onset = aubio_onset_hfc;
    172         else if (strcmp (optarg, "complexdomain") == 0)
    173           type_onset = aubio_onset_complex;
    174         else if (strcmp (optarg, "complex") == 0)
    175           type_onset = aubio_onset_complex;
    176         else if (strcmp (optarg, "phase") == 0)
    177           type_onset = aubio_onset_phase;
    178         else if (strcmp (optarg, "mkl") == 0)
    179           type_onset = aubio_onset_mkl;
    180         else if (strcmp (optarg, "kl") == 0)
    181           type_onset = aubio_onset_kl;
    182         else if (strcmp (optarg, "specflux") == 0)
    183           type_onset = aubio_onset_specflux;
    184         else {
    185           errmsg ("unknown onset type.\n");
    186           abort ();
    187         }
    188         usedoubled = 0;
     164        onset_mode = optarg;
    189165        break;
    190166      case 's':                /* threshold value for onset */
     
    332308  /* onsets */
    333309  parms = new_aubio_peakpicker (threshold);
    334   o = new_aubio_onsetdetection (type_onset, buffer_size, channels);
     310  o = new_aubio_onsetdetection (onset_mode, buffer_size, channels);
    335311  onset = new_fvec (1, channels);
    336   if (usedoubled) {
    337     o2 = new_aubio_onsetdetection (type_onset2, buffer_size, channels);
    338     onset2 = new_fvec (1, channels);
    339   }
    340312
    341313}
  • examples/utils.h

    r27fa522 rb4f5967  
    7979
    8080/* energy,specdiff,hfc,complexdomain,phase */
    81 extern aubio_onsetdetection_type type_onset;
    82 extern aubio_onsetdetection_type type_onset2;
     81extern char_t * onset_mode;
    8382extern smpl_t threshold;
    8483extern smpl_t silence;
  • plugins/puredata/aubioonset~.c

    r27fa522 rb4f5967  
    8888        x->hopsize   = x->bufsize / 2;
    8989
    90         x->o = new_aubio_onsetdetection(aubio_onset_complex, x->bufsize, 1);
     90        x->o = new_aubio_onsetdetection("complex", x->bufsize, 1);
    9191        x->vec = (fvec_t *)new_fvec(x->hopsize,1);
    9292        x->pv = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize, 1);
  • plugins/puredata/aubiotempo~.c

    r27fa522 rb4f5967  
    8383  x->hopsize   = x->bufsize / 2;
    8484
    85   x->t = new_aubio_tempo (aubio_onset_complex, x->bufsize, x->hopsize, 1);
     85  x->t = new_aubio_tempo ("complex", x->bufsize, x->hopsize, 1);
    8686  aubio_tempo_set_silence(x->t,x->silence);
    8787  aubio_tempo_set_threshold(x->t,x->threshold);
  • python/aubio/aubioclass.py

    r27fa522 rb4f5967  
    7070class onsetdetection:
    7171    """ class for aubio_onsetdetection """
    72     def __init__(self,type,buf,chan):
    73         self.od = new_aubio_onsetdetection(type,buf,chan)
     72    def __init__(self,mode,buf,chan):
     73        self.od = new_aubio_onsetdetection(mode,buf,chan)
    7474    def do(self,tc,tf):
    7575        aubio_onsetdetection_do(self.od,tc(),tf())
     
    9494        self.pv       = pvoc(bufsize,hopsize,channels)
    9595        if mode in ['dual'] :
    96                 self.myod     = onsetdetection(aubio_onset_hfc,bufsize,channels)
    97                 self.myod2    = onsetdetection(aubio_onset_mkl,bufsize,channels)
     96                self.myod     = onsetdetection("hfc",bufsize,channels)
     97                self.myod2    = onsetdetection("mkl",bufsize,channels)
    9898                self.myonset  = fvec(1,channels)
    9999                self.myonset2 = fvec(1,channels)
  • src/onset/onset.c

    r27fa522 rb4f5967  
    8989
    9090/* Allocate memory for an onset detection */
    91 aubio_onset_t * new_aubio_onset (aubio_onsetdetection_type type_onset,
     91aubio_onset_t * new_aubio_onset (char_t * onset_mode,
    9292    uint_t buf_size, uint_t hop_size, uint_t channels)
    9393{
     
    100100  o->pv = new_aubio_pvoc(buf_size, hop_size, channels);
    101101  o->pp = new_aubio_peakpicker(o->threshold);
    102   o->od = new_aubio_onsetdetection(type_onset,buf_size,channels);
     102  o->od = new_aubio_onsetdetection(onset_mode,buf_size,channels);
    103103  o->fftgrain = new_cvec(buf_size,channels);
    104104  o->of = new_fvec(1, channels);
    105105  /*if (usedoubled)    {
    106     o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels);
     106    o2 = new_aubio_onsetdetection(onset_type2,buffer_size,channels);
    107107    onset2 = new_fvec(1 , channels);
    108108  }*/
  • src/onset/onset.h

    r27fa522 rb4f5967  
    5252
    5353*/
    54 aubio_onset_t * new_aubio_onset (aubio_onsetdetection_type type_onset,
     54aubio_onset_t * new_aubio_onset (char_t * onset_mode,
    5555    uint_t buf_size, uint_t hop_size, uint_t channels);
    5656
  • src/onset/onsetdetection.c

    r27fa522 rb4f5967  
    124124void aubio_onsetdetection_specflux(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
    125125
     126/** onsetdetection types */
     127typedef enum {
     128        aubio_onset_energy,         /**< energy based */         
     129        aubio_onset_specdiff,       /**< spectral diff */         
     130        aubio_onset_hfc,            /**< high frequency content */
     131        aubio_onset_complex,        /**< complex domain */       
     132        aubio_onset_phase,          /**< phase fast */           
     133        aubio_onset_kl,             /**< Kullback Liebler */
     134        aubio_onset_mkl,            /**< modified Kullback Liebler */
     135        aubio_onset_specflux,       /**< spectral flux */
     136} aubio_onsetdetection_type;
     137
    126138/** structure to store object state */
    127139struct _aubio_onsetdetection_t {
    128   aubio_onsetdetection_type type; /**< onset detection type */
     140  aubio_onsetdetection_type onset_type; /**< onset detection type */
    129141  /** Pointer to aubio_onsetdetection_<type> function */
    130142  void (*funcpointer)(aubio_onsetdetection_t *o,
     
    305317 */
    306318aubio_onsetdetection_t *
    307 new_aubio_onsetdetection (aubio_onsetdetection_type type,
     319new_aubio_onsetdetection (char_t * onset_mode,
    308320    uint_t size, uint_t channels){
    309321  aubio_onsetdetection_t * o = AUBIO_NEW(aubio_onsetdetection_t);
    310322  uint_t rsize = size/2+1;
    311   switch(type) {
     323  aubio_onsetdetection_type onset_type;
     324  if (strcmp (onset_mode, "energy") == 0)
     325      onset_type = aubio_onset_energy;
     326  else if (strcmp (onset_mode, "specdiff") == 0)
     327      onset_type = aubio_onset_specdiff;
     328  else if (strcmp (onset_mode, "hfc") == 0)
     329      onset_type = aubio_onset_hfc;
     330  else if (strcmp (onset_mode, "complexdomain") == 0)
     331      onset_type = aubio_onset_complex;
     332  else if (strcmp (onset_mode, "complex") == 0)
     333      onset_type = aubio_onset_complex;
     334  else if (strcmp (onset_mode, "phase") == 0)
     335      onset_type = aubio_onset_phase;
     336  else if (strcmp (onset_mode, "mkl") == 0)
     337      onset_type = aubio_onset_mkl;
     338  else if (strcmp (onset_mode, "kl") == 0)
     339      onset_type = aubio_onset_kl;
     340  else if (strcmp (onset_mode, "specflux") == 0)
     341      onset_type = aubio_onset_specflux;
     342  else {
     343      AUBIO_ERR("unknown onset type.\n");
     344      return NULL;
     345  }
     346  switch(onset_type) {
    312347    /* for both energy and hfc, only fftgrain->norm is required */
    313348    case aubio_onset_energy:
     
    348383   * above and always allocate all the structure */
    349384
    350   switch(type) {
     385  switch(onset_type) {
    351386    case aubio_onset_energy:
    352387      o->funcpointer = aubio_onsetdetection_energy;
     
    376411      break;
    377412  }
    378   o->type = type;
     413  o->onset_type = onset_type;
    379414  return o;
    380415}
    381416
    382417void del_aubio_onsetdetection (aubio_onsetdetection_t *o){
    383   switch(o->type) {
     418  switch(o->onset_type) {
    384419    /* for both energy and hfc, only fftgrain->norm is required */
    385420    case aubio_onset_energy:
  • src/onset/onsetdetection.h

    r27fa522 rb4f5967  
    3939#endif
    4040
    41 /** onsetdetection types */
    42 typedef enum {
    43         aubio_onset_energy,         /**< energy based */         
    44         aubio_onset_specdiff,       /**< spectral diff */         
    45         aubio_onset_hfc,            /**< high frequency content */
    46         aubio_onset_complex,        /**< complex domain */       
    47         aubio_onset_phase,          /**< phase fast */           
    48         aubio_onset_kl,             /**< Kullback Liebler */
    49         aubio_onset_mkl,            /**< modified Kullback Liebler */
    50         aubio_onset_specflux,       /**< spectral flux */
    51 } aubio_onsetdetection_type;
    52 
    5341/** onsetdetection structure */
    5442typedef struct _aubio_onsetdetection_t aubio_onsetdetection_t;
     
    7058
    7159*/
    72 aubio_onsetdetection_t * new_aubio_onsetdetection(aubio_onsetdetection_type type, uint_t size, uint_t channels);
     60aubio_onsetdetection_t * new_aubio_onsetdetection(char_t * onset_mode, uint_t buf_size, uint_t channels);
    7361/** deletion of an onset detection object
    7462
  • src/tempo/tempo.c

    r27fa522 rb4f5967  
    9999
    100100/* Allocate memory for an tempo detection */
    101 aubio_tempo_t * new_aubio_tempo (aubio_onsetdetection_type type_onset,
     101aubio_tempo_t * new_aubio_tempo (char_t * onset_mode,
    102102    uint_t buf_size, uint_t hop_size, uint_t channels)
    103103{
     
    114114  o->pv       = new_aubio_pvoc(buf_size, hop_size, channels);
    115115  o->pp       = new_aubio_peakpicker(o->threshold);
    116   o->od       = new_aubio_onsetdetection(type_onset,buf_size,channels);
     116  o->od       = new_aubio_onsetdetection(onset_mode,buf_size,channels);
    117117  o->of       = new_fvec(1, channels);
    118118  o->bt       = new_aubio_beattracking(o->winlen,channels);
  • src/tempo/tempo.h

    r27fa522 rb4f5967  
    3838
    3939/** create tempo detection object */
    40 aubio_tempo_t * new_aubio_tempo (aubio_onsetdetection_type type_onset,
     40aubio_tempo_t * new_aubio_tempo (char_t * mode,
    4141    uint_t buf_size, uint_t hop_size, uint_t channels);
    4242
  • swig/aubio.i

    r27fa522 rb4f5967  
    188188
    189189/* onset detection */
    190 typedef enum {
    191         aubio_onset_energy,
    192         aubio_onset_specdiff,
    193         aubio_onset_hfc,
    194         aubio_onset_complex,
    195         aubio_onset_phase,
    196         aubio_onset_kl,
    197         aubio_onset_mkl,
    198         aubio_onset_specflux,
    199 } aubio_onsetdetection_type;
    200 aubio_onsetdetection_t * new_aubio_onsetdetection(aubio_onsetdetection_type type, uint_t size, uint_t channels);
     190aubio_onsetdetection_t * new_aubio_onsetdetection(char * onset_mode, uint_t size, uint_t channels);
    201191void aubio_onsetdetection_do (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
    202192void del_aubio_onsetdetection(aubio_onsetdetection_t *o);
  • tests/src/test-onset.c

    r27fa522 rb4f5967  
    77        fvec_t * in       = new_fvec (win_s/4, channels); /* input buffer */
    88        fvec_t * out      = new_fvec (2, channels);     /* input buffer */
    9         aubio_onset_t * onset  = new_aubio_onset(aubio_onset_complex, win_s, win_s/4, channels);
     9        aubio_onset_t * onset  = new_aubio_onset("complex", win_s, win_s/4, channels);
    1010        uint_t i = 0;
    1111
  • tests/src/test-onsetdetection.c

    r27fa522 rb4f5967  
    1212  aubio_onsetdetection_t *o;
    1313 
    14   o = new_aubio_onsetdetection (aubio_onset_energy, win_s, channels);
     14  o = new_aubio_onsetdetection ("energy", win_s, channels);
    1515  aubio_onsetdetection_do (o, in, out);
    1616  del_aubio_onsetdetection (o);
    1717
    18   o = new_aubio_onsetdetection (aubio_onset_specdiff, win_s, channels);
     18  o = new_aubio_onsetdetection ("energy", win_s, channels);
    1919  aubio_onsetdetection_do (o, in, out);
    2020  del_aubio_onsetdetection (o);
    2121
    22   o = new_aubio_onsetdetection (aubio_onset_hfc, win_s, channels);
     22  o = new_aubio_onsetdetection ("hfc", win_s, channels);
    2323  aubio_onsetdetection_do (o, in, out);
    2424  del_aubio_onsetdetection (o);
    2525
    26   o = new_aubio_onsetdetection (aubio_onset_complex, win_s, channels);
     26  o = new_aubio_onsetdetection ("complex", win_s, channels);
    2727  aubio_onsetdetection_do (o, in, out);
    2828  del_aubio_onsetdetection (o);
    2929
    30   o = new_aubio_onsetdetection (aubio_onset_phase, win_s, channels);
     30  o = new_aubio_onsetdetection ("phase", win_s, channels);
    3131  aubio_onsetdetection_do (o, in, out);
    3232  del_aubio_onsetdetection (o);
    3333
    34   o = new_aubio_onsetdetection (aubio_onset_kl, win_s, channels);
     34  o = new_aubio_onsetdetection ("kl", win_s, channels);
    3535  aubio_onsetdetection_do (o, in, out);
    3636  del_aubio_onsetdetection (o);
    3737
    38   o = new_aubio_onsetdetection (aubio_onset_mkl, win_s, channels);
     38  o = new_aubio_onsetdetection ("mkl", win_s, channels);
    3939  aubio_onsetdetection_do (o, in, out);
    4040  del_aubio_onsetdetection (o);
  • tests/src/test-tempo.c

    r27fa522 rb4f5967  
    88        fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
    99        fvec_t * out      = new_fvec (2, channels);     /* input buffer */
    10         aubio_tempo_t * o  = new_aubio_tempo(aubio_onset_complex, win_s, win_s/4, channels);
     10        aubio_tempo_t * o  = new_aubio_tempo("complex", win_s, win_s/4, channels);
    1111        uint_t i = 0;
    1212
Note: See TracChangeset for help on using the changeset viewer.