Changeset b31f262


Ignore:
Timestamp:
Jun 14, 2005, 1:07:08 AM (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:
1397c6e
Parents:
0ce9acc3
Message:

add Kullback Liebler onset detection function and its modified version

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • python/aubio/aubioclass.py

    r0ce9acc3 rb31f262  
    7777        self.myfft    = cvec(bufsize,channels)
    7878        self.pv       = pvoc(bufsize,hopsize,channels)
    79         if mode in [complexdomain,hfc,phase,energy,specdiff]  :
    80                 self.myod     = onsetdetection(mode,bufsize,channels)
    81                 self.myonset  = fvec(1,channels)
    82         else:
     79        if mode in ['dual'] :
    8380                self.myod     = onsetdetection(hfc,bufsize,channels)
    8481                self.myod2    = onsetdetection(complexdomain,bufsize,channels)
    8582                self.myonset  = fvec(1,channels)
    8683                self.myonset2 = fvec(1,channels)
     84        else:
     85                self.myod     = onsetdetection(mode,bufsize,channels)
     86                self.myonset  = fvec(1,channels)
    8787        self.mode     = mode
    8888        self.pp       = peakpick(float(threshold))
  • python/aubio/gnuplot.py

    r0ce9acc3 rb31f262  
    151151        from aubio.onsetcompare import onset_roc
    152152
     153        if len(onsets) == 0: onsets = [0.];
     154
    153155        # onset detection function
    154156        downtime = (hopsize/samplerate)*numarray.arange(len(ofunc))
  • src/onsetdetection.c

    r0ce9acc3 rb31f262  
    6868
    6969/* Complex Domain Method onset detection function */
    70 /* moved to /2 032402 */
    7170void aubio_onsetdetection_complex (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset) {
    7271        uint_t i, j;
     
    128127
    129128/* Spectral difference method onset detection function */
    130 /* moved to /2 032402 */
    131129void aubio_onsetdetection_specdiff(aubio_onsetdetection_t *o,
    132130                cvec_t * fftgrain, fvec_t * onset){
     
    157155}
    158156
     157/* Kullback Liebler onset detection function
     158 * note we use ln(1+Xn/(Xn-1+0.0001)) to avoid
     159 * negative (1.+) and infinite values (+1.e-10) */
     160void aubio_onsetdetection_kl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset){
     161        uint_t i,j;
     162        for (i=0;i<fftgrain->channels;i++) {
     163                onset->data[i][0] = 0.;
     164                for (j=0;j<fftgrain->length;j++) {
     165                        onset->data[i][0] += fftgrain->norm[i][j]
     166                                *LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10));
     167                        o->oldmag->data[i][j] = fftgrain->norm[i][j];
     168                }
     169                if (isnan(onset->data[i][0])) onset->data[i][0] = 0.;
     170        }
     171}
     172
     173/* Modified Kullback Liebler onset detection function
     174 * note we use ln(1+Xn/(Xn-1+0.0001)) to avoid
     175 * negative (1.+) and infinite values (+1.e-10) */
     176void aubio_onsetdetection_mkl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset){
     177        uint_t i,j;
     178        for (i=0;i<fftgrain->channels;i++) {
     179                onset->data[i][0] = 0.;
     180                for (j=0;j<fftgrain->length;j++) {
     181                        onset->data[i][0] += LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10));
     182                        o->oldmag->data[i][j] = fftgrain->norm[i][j];
     183                }
     184                if (isnan(onset->data[i][0])) onset->data[i][0] = 0.;
     185        }
     186}
     187
    159188/* Generic function pointing to the choosen one */
    160189void
     
    205234                        o->threshold = 0.1;
    206235                        break;
     236                case kl:
     237                        o->oldmag = new_fvec(rsize,channels);
     238                        break;
     239                case mkl:
     240                        o->oldmag = new_fvec(rsize,channels);
     241                        break;
    207242                default:
    208243                        break;
     
    228263                case specdiff:
    229264                        o->funcpointer = aubio_onsetdetection_specdiff;
     265                        break;
     266                case kl:
     267                        o->funcpointer = aubio_onsetdetection_kl;
     268                        break;
     269                case mkl:
     270                        o->funcpointer = aubio_onsetdetection_mkl;
    230271                        break;
    231272                default:
  • src/onsetdetection.h

    r0ce9acc3 rb31f262  
    5454        hfc,            /**< high frequency content */
    5555        complexdomain,  /**< complex domain */       
    56         phase           /**< phase fast */           
     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) */
    5759} aubio_onsetdetection_type;
    5860
     
    99101 */
    100102void aubio_onsetdetection_specdiff(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
     103/** Kullback-Liebler onset detection function */
     104void aubio_onsetdetection_kl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
     105/** Modified Kullback-Liebler onset detection function */
     106void aubio_onsetdetection_mkl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
    101107/** Generic function pointing to the choosen one */
    102108void aubio_onsetdetection(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
Note: See TracChangeset for help on using the changeset viewer.