Changeset b4f5967 for src/onset


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

Location:
src/onset
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.