Ignore:
Timestamp:
Mar 11, 2017, 4:57:49 AM (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:
42f1cd01
Parents:
90e25cc
Message:

src/spectral/specdesc.c: add weighted phase deviation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/specdesc.c

    r90e25cc rc23e591  
    3131void aubio_specdesc_complex(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
    3232void aubio_specdesc_phase(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
     33void aubio_specdesc_wphase(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
    3334void aubio_specdesc_specdiff(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
    3435void aubio_specdesc_kl(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
     
    5859        aubio_onset_complex,        /**< complex domain */       
    5960        aubio_onset_phase,          /**< phase fast */           
     61        aubio_onset_wphase,         /**< weighted phase */
    6062        aubio_onset_kl,             /**< Kullback Liebler */
    6163        aubio_onset_mkl,            /**< modified Kullback Liebler */
     
    158160  onset->data[0] = aubio_hist_mean(o->histog); 
    159161  //onset->data[0] = fvec_mean(o->dev1);
     162}
     163
     164/* weighted phase */
     165void
     166aubio_specdesc_wphase(aubio_specdesc_t *o,
     167    const cvec_t *fftgrain, fvec_t *onset) {
     168  uint_t i;
     169  aubio_specdesc_phase(o, fftgrain, onset);
     170  for (i = 0; i < fftgrain->length; i++) {
     171    o->dev1->data[i] *= fftgrain->norm[i];
     172  }
     173  /* apply o->histogram */
     174  aubio_hist_dyn_notnull(o->histog,o->dev1);
     175  /* weight it */
     176  aubio_hist_weight(o->histog);
     177  /* its mean is the result */
     178  onset->data[0] = aubio_hist_mean(o->histog);
    160179}
    161180
     
    251270  else if (strcmp (onset_mode, "phase") == 0)
    252271      onset_type = aubio_onset_phase;
     272  else if (strcmp (onset_mode, "wphase") == 0)
     273      onset_type = aubio_onset_wphase;
    253274  else if (strcmp (onset_mode, "mkl") == 0)
    254275      onset_type = aubio_onset_mkl;
     
    292313      break;
    293314    case aubio_onset_phase:
     315    case aubio_onset_wphase:
    294316      o->dev1   = new_fvec(rsize);
    295317      o->theta1 = new_fvec(rsize);
     
    326348      o->funcpointer = aubio_specdesc_phase;
    327349      break;
     350    case aubio_onset_wphase:
     351      o->funcpointer = aubio_specdesc_wphase;
     352      break;
    328353    case aubio_onset_specdiff:
    329354      o->funcpointer = aubio_specdesc_specdiff;
     
    379404      break;
    380405    case aubio_onset_phase:
     406    case aubio_onset_wphase:
    381407      del_fvec(o->dev1);
    382408      del_fvec(o->theta1);
Note: See TracChangeset for help on using the changeset viewer.