Changeset 5cf415f


Ignore:
Timestamp:
Aug 9, 2005, 8:35:14 PM (19 years ago)
Author:
Paul Brossier <piem@altern.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:
b1f723d
Parents:
a29ad46
Message:

protected onset enumerators, factorise python check_modes

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • examples/utils.c

    ra29ad46 r5cf415f  
    3030
    3131/* energy,specdiff,hfc,complexdomain,phase */
    32 aubio_onsetdetection_type type_onset  = kl;
    33 aubio_onsetdetection_type type_onset2 = complexdomain;
     32aubio_onsetdetection_type type_onset  = aubio_onset_kl;
     33aubio_onsetdetection_type type_onset2 = aubio_onset_complex;
    3434smpl_t threshold                      = 0.3;
    3535smpl_t threshold2                     = -90.;
     
    140140                        case 'O':   /*onset type*/
    141141                                if (strcmp(optarg,"energy") == 0)
    142                                         type_onset = energy;
     142                                        type_onset = aubio_onset_energy;
    143143                                else if (strcmp(optarg,"specdiff") == 0)
    144                                         type_onset = specdiff;
     144                                        type_onset = aubio_onset_specdiff;
    145145                                else if (strcmp(optarg,"hfc") == 0)
    146                                         type_onset = hfc;
     146                                        type_onset = aubio_onset_hfc;
    147147                                else if (strcmp(optarg,"complexdomain") == 0)
    148                                         type_onset = complexdomain;
     148                                        type_onset = aubio_onset_complex;
     149                                else if (strcmp(optarg,"complex") == 0)
     150                                        type_onset = aubio_onset_complex;
    149151                                else if (strcmp(optarg,"phase") == 0)
    150                                         type_onset = phase;
     152                                        type_onset = aubio_onset_phase;
     153                                else if (strcmp(optarg,"mkl") == 0)
     154                                        type_onset = aubio_onset_mkl;
     155                                else if (strcmp(optarg,"kl") == 0)
     156                                        type_onset = aubio_onset_kl;
    151157                                else {
    152158                                        debug("could not get onset type.\n");
  • plugins/puredata/aubioonset~.c

    ra29ad46 r5cf415f  
    7171        x->hopsize   = x->bufsize / 2;
    7272
    73         x->o = new_aubio_onsetdetection(complexdomain, x->bufsize, 1);
     73        x->o = new_aubio_onsetdetection(aubio_onset_complex, x->bufsize, 1);
    7474        x->vec = (fvec_t *)new_fvec(x->hopsize,1);
    7575        x->pv = new_aubio_pvoc(x->bufsize, x->hopsize, 1);
  • python/aubio/aubioclass.py

    ra29ad46 r5cf415f  
    8080        self.pv       = pvoc(bufsize,hopsize,channels)
    8181        if mode in ['dual'] :
    82                 self.myod     = onsetdetection(hfc,bufsize,channels)
    83                 self.myod2    = onsetdetection(complexdomain,bufsize,channels)
     82                self.myod     = onsetdetection(aubio_onset_hfc,bufsize,channels)
     83                self.myod2    = onsetdetection(aubio_onset_complex,bufsize,channels)
    8484                self.myonset  = fvec(1,channels)
    8585                self.myonset2 = fvec(1,channels)
     
    105105                else:  self.myonset.set(0.,0,0)
    106106        return self.pp.do(self.myonset),self.myonset.get(0,0)
     107
     108def check_onset_mode(option, opt, value, parser):
     109        nvalue = parser.rargs[0]
     110        if   nvalue == 'complexdomain' or nvalue == 'complex' :
     111                 setattr(parser.values, option.dest, aubio_onset_complex)
     112        elif nvalue == 'hfc'           :
     113                 setattr(parser.values, option.dest, aubio_onset_hfc)
     114        elif nvalue == 'phase'         :
     115                 setattr(parser.values, option.dest, aubio_onset_phase)
     116        elif nvalue == 'specdiff'      :
     117                 setattr(parser.values, option.dest, aubio_onset_specdiff)
     118        elif nvalue == 'energy'        :
     119                 setattr(parser.values, option.dest, aubio_onset_energy)
     120        elif nvalue == 'kl'            :
     121                 setattr(parser.values, option.dest, aubio_onset_kl)
     122        elif nvalue == 'mkl'           :
     123                 setattr(parser.values, option.dest, aubio_onset_mkl)
     124        elif nvalue == 'dual'          :
     125                 setattr(parser.values, option.dest, 'dual')
     126        else:
     127                 print "unknown detection function selected\n", usage
     128                 sys.exit(1)
     129
     130def check_pitch_mode(option, opt, value, parser):
     131        nvalue = parser.rargs[0]
     132        if   nvalue == 'mcomb' :
     133                 setattr(parser.values, option.dest, aubio_pitch_mcomb)
     134        elif nvalue == 'yin'           :
     135                 setattr(parser.values, option.dest, aubio_pitch_yin)
     136        elif nvalue == 'fcomb'         :
     137                 setattr(parser.values, option.dest, aubio_pitch_fcomb)
     138        elif nvalue == 'schmitt'      :
     139                 setattr(parser.values, option.dest, aubio_pitch_schmitt)
     140        else:
     141                 print "unknown detection function selected\n", usage
     142                 sys.exit(1)
     143
    107144
    108145def getonsets(filein,threshold=0.2,silence=-70.,bufsize=1024,hopsize=512,
  • python/aubiocut

    ra29ad46 r5cf415f  
    1010usage = "usage: %s [options] -i soundfile" % sys.argv[0]
    1111
    12 def check_mode(option, opt, value, parser):
    13         nvalue = parser.rargs[0]
    14         if   nvalue == 'complexdomain' :
    15                  setattr(parser.values, option.dest, complexdomain)
    16         elif nvalue == 'hfc'           :
    17                  setattr(parser.values, option.dest, hfc)
    18         elif nvalue == 'phase'         :
    19                  setattr(parser.values, option.dest, phase)
    20         elif nvalue == 'specdiff'      :
    21                  setattr(parser.values, option.dest, specdiff)
    22         elif nvalue == 'energy'        :
    23                  setattr(parser.values, option.dest, energy)
    24         elif nvalue == 'kl'            :
    25                  setattr(parser.values, option.dest, kl)
    26         elif nvalue == 'mkl'           :
    27                  setattr(parser.values, option.dest, mkl)
    28         elif nvalue == 'dual'          :
    29                  setattr(parser.values, option.dest, 'dual')
    30         else:
    31                  print "unknown detection function selected\n", usage
    32                  sys.exit(1)
    33 
    3412def parse_args():
    3513        from optparse import OptionParser
     
    3917                          help="input sound file")
    4018        parser.add_option("-m","--mode", action="callback",
    41                           callback=check_mode, dest="mode", default='dual',
     19                          callback=check_onset_mode, dest="mode", default='dual',
    4220                          help="onset detection mode [default=dual] \
    4321                          complexdomain|hfc|phase|specdiff|energy|kl|mkl|dual")
  • python/aubiopitch

    ra29ad46 r5cf415f  
    1111usage = "usage: %s [options] -i soundfile" % sys.argv[0]
    1212
    13 def check_mode(option, opt, value, parser):
    14         nvalue = parser.rargs[0]
    15         if   nvalue == 'mcomb' :
    16                  setattr(parser.values, option.dest, aubio_pitch_mcomb)
    17         elif nvalue == 'yin'           :
    18                  setattr(parser.values, option.dest, aubio_pitch_yin)
    19         elif nvalue == 'fcomb'         :
    20                  setattr(parser.values, option.dest, aubio_pitch_fcomb)
    21         elif nvalue == 'schmitt'      :
    22                  setattr(parser.values, option.dest, aubio_pitch_schmitt)
    23 
    2413
    2514def parse_args():
     
    3019                          help="input sound file")
    3120        parser.add_option("-m","--mode", action="callback",
    32                           callback=check_mode, dest="mode", default=aubio_pitch_mcomb,
     21                          callback=check_pitch_mode, dest="mode",
     22                          default=aubio_pitch_mcomb,
    3323                          help="pitch detection mode [default=mcomb] \
    3424                          mcomb|yin|fcomb|schmitt")
  • src/onsetdetection.c

    ra29ad46 r5cf415f  
    208208        switch(type) {
    209209                /* for both energy and hfc, only fftgrain->norm is required */
    210                 case energy:
    211                         break;
    212                 case hfc:
     210                case aubio_onset_energy:
     211                        break;
     212                case aubio_onset_hfc:
    213213                        break;
    214214                /* the other approaches will need some more memory spaces */
    215                 case complexdomain:
     215                case aubio_onset_complex:
    216216                        o->oldmag = new_fvec(rsize,channels);
    217217                        /** bug: must be complex array */
     
    221221                        o->theta2 = new_fvec(rsize,channels);
    222222                        break;
    223                 case phase:
     223                case aubio_onset_phase:
    224224                        o->dev1  = new_fvec(rsize,channels);
    225225                        o->theta1 = new_fvec(rsize,channels);
     
    228228                        o->threshold = 0.1;
    229229                        break;
    230                 case specdiff:
     230                case aubio_onset_specdiff:
    231231                        o->oldmag = new_fvec(rsize,channels);
    232232                        o->dev1   = new_fvec(rsize,channels);
     
    234234                        o->threshold = 0.1;
    235235                        break;
    236                 case kl:
     236                case aubio_onset_kl:
    237237                        o->oldmag = new_fvec(rsize,channels);
    238238                        break;
    239                 case mkl:
     239                case aubio_onset_mkl:
    240240                        o->oldmag = new_fvec(rsize,channels);
    241241                        break;
     
    249249
    250250        switch(type) {
    251                 case energy:
     251                case aubio_onset_energy:
    252252                        o->funcpointer = aubio_onsetdetection_energy;
    253253                        break;
    254                 case hfc:
     254                case aubio_onset_hfc:
    255255                        o->funcpointer = aubio_onsetdetection_hfc;
    256256                        break;
    257                 case complexdomain:
     257                case aubio_onset_complex:
    258258                        o->funcpointer = aubio_onsetdetection_complex;
    259259                        break;
    260                 case phase:
     260                case aubio_onset_phase:
    261261                        o->funcpointer = aubio_onsetdetection_phase;
    262262                        break;
    263                 case specdiff:
     263                case aubio_onset_specdiff:
    264264                        o->funcpointer = aubio_onsetdetection_specdiff;
    265265                        break;
    266                 case kl:
     266                case aubio_onset_kl:
    267267                        o->funcpointer = aubio_onsetdetection_kl;
    268268                        break;
    269                 case mkl:
     269                case aubio_onset_mkl:
    270270                        o->funcpointer = aubio_onsetdetection_mkl;
    271271                        break;
     
    281281        switch(o->type) {
    282282                /* for both energy and hfc, only fftgrain->norm is required */
    283                 case energy:
    284                         break;
    285                 case hfc:
     283                case aubio_onset_energy:
     284                        break;
     285                case aubio_onset_hfc:
    286286                        break;
    287287                /* the other approaches will need some more memory spaces */
    288                 case complexdomain:
     288                case aubio_onset_complex:
    289289                        AUBIO_FREE(o->meas);
    290290                        del_fvec(o->oldmag);
     
    293293                        del_fvec(o->theta2);
    294294                        break;
    295                 case phase:
     295                case aubio_onset_phase:
    296296                        del_fvec(o->dev1);
    297297                        del_fvec(o->theta1);
     
    299299                        del_aubio_hist(o->histog);
    300300                        break;
    301                 case specdiff:
     301                case aubio_onset_specdiff:
    302302                        del_fvec(o->oldmag);
    303303                        del_fvec(o->dev1);
  • src/onsetdetection.h

    ra29ad46 r5cf415f  
    5050/** onsetdetection types */
    5151typedef enum {
    52         energy,         /**< energy based */         
    53         specdiff,       /**< spectral diff */         
    54         hfc,            /**< high frequency content */
    55         complexdomain,  /**< complex domain */       
    56         phase,          /**< phase fast */           
    57         kl,             /**< Kullback Liebler (Hainsworth et al.,  Onset detection in musical audio signals) */
    58         mkl             /**< modified Kullback Liebler (Hainsworth et al.,  Onset detection in musical audio signals) */
     52        aubio_onset_energy,         /**< energy based */         
     53        aubio_onset_specdiff,       /**< spectral diff */         
     54        aubio_onset_hfc,            /**< high frequency content */
     55        aubio_onset_complex,        /**< complex domain */       
     56        aubio_onset_phase,          /**< phase fast */           
     57        aubio_onset_kl,             /**< Kullback Liebler (Hainsworth et al.,  Onset detection in musical audio signals) */
     58        aubio_onset_mkl             /**< modified Kullback Liebler (Hainsworth et al.,  Onset detection in musical audio signals) */
    5959} aubio_onsetdetection_type;
    6060
  • swig/aubio.i

    ra29ad46 r5cf415f  
    139139
    140140/* onset detection */
    141 typedef enum { energy, specdiff, hfc, complexdomain, phase, kl, mkl } aubio_onsetdetection_type;
     141typedef enum {
     142        aubio_onset_energy,
     143        aubio_onset_specdiff,
     144        aubio_onset_hfc,
     145        aubio_onset_complex,
     146        aubio_onset_phase,
     147        aubio_onset_kl,
     148        aubio_onset_mkl
     149} aubio_onsetdetection_type;
    142150aubio_onsetdetection_t * new_aubio_onsetdetection(aubio_onsetdetection_type type, uint_t size, uint_t channels);
    143151void aubio_onsetdetection(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
     
    146154/* should these still be exposed ? */
    147155void aubio_onsetdetection_energy  (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
    148 void aubio_onsetdetection_hfc   (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
     156void aubio_onsetdetection_hfc     (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
    149157void aubio_onsetdetection_complex (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
    150158void aubio_onsetdetection_phase   (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
    151159void aubio_onsetdetection_specdiff(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
     160void aubio_onsetdetection_kl      (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
     161void aubio_onsetdetection_mkl     (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
    152162
    153163/* pvoc */
Note: See TracChangeset for help on using the changeset viewer.