Changeset b7eb9a5


Ignore:
Timestamp:
Dec 19, 2005, 8:48:44 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:
50e99cc
Parents:
0029638
Message:

factorise code for both peakpick versions
factorise code for both peakpick versions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/peakpick.c

    r0029638 rb7eb9a5  
    116116uint_t aubio_peakpick_pimrt_wt(fvec_t * onset,  aubio_pickpeak_t * p, smpl_t* peakval)
    117117{
    118         fvec_t * onset_keep = (fvec_t *)p->onset_keep;
    119         fvec_t * onset_proc = (fvec_t *)p->onset_proc;
    120         fvec_t * onset_peek = (fvec_t *)p->onset_peek;
    121         fvec_t * scratch    = (fvec_t *)p->scratch;
    122         smpl_t mean = 0., median = 0.;
    123         uint_t length = p->win_post + p->win_pre + 1;
    124         uint_t i = 0, j, isonset = 0;
    125 
    126         /* store onset in onset_keep */
    127         /* shift all elements but last, then write last */
    128         for (j=0;j<length-1;j++)
    129         {
    130                 onset_keep->data[i][j] = onset_keep->data[i][j+1];
    131                 onset_proc->data[i][j] = onset_keep->data[i][j];
    132         }
    133         onset_keep->data[i][length-1] = onset->data[i][0];
    134         onset_proc->data[i][length-1] = onset->data[i][0];
    135 
    136 
    137         /* filter onset_proc */
    138         /** \bug filtfilt calculated post+pre times should be only once !? */
    139 
    140         aubio_biquad_do_filtfilt(p->biquad,onset_proc,scratch);
    141                
    142         /* calculate mean and median for onset_proc */
    143 
    144         mean = vec_mean(onset_proc);
    145         /* copy to scratch */
    146         for (j = 0; j < length; j++)
    147                 scratch->data[i][j] = onset_proc->data[i][j];
    148         median = vec_median(scratch);
    149 
    150         /* shift peek array */
    151         for (j=0;j<3-1;j++)
    152                 onset_peek->data[i][j] = onset_peek->data[i][j+1];
    153         /* calculate new peek value */
    154        
    155         onset_peek->data[i][2] =
    156                 onset_proc->data[i][p->win_post] - median - mean * p->threshold;
    157        
    158         isonset = (p->pickerfn)(onset_peek,1);
     118        uint_t i = 0, isonset = 0;
     119        isonset = aubio_peakpick_pimrt(onset,p);
    159120
    160121        //if ( isonset && peakval != NULL )
    161122        if ( peakval != NULL )
    162                 *peakval = onset_peek->data[i][1];
     123                *peakval = p->onset_peek->data[i][1];
    163124
    164125        return isonset;
Note: See TracChangeset for help on using the changeset viewer.