Ignore:
Timestamp:
Aug 8, 2005, 10:08:21 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:
54bf847
Parents:
f841b81
Message:

fix schmitt and fcomb, factorise slideblock code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/pitchdetection.c

    rf841b81 r651b97e  
    3030typedef smpl_t (*aubio_pitchdetection_func_t)(aubio_pitchdetection_t *p,
    3131                fvec_t * ibuf);
     32void aubio_pitchdetection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf);
    3233
    3334struct _aubio_pitchdetection_t {
     
    7374                        break;
    7475                case aubio_fcomb:
     76                        p->buf      = new_fvec(bufsize,channels);
    7577                        p->fcomb    = new_aubio_pitchfcomb(bufsize,samplerate);
    7678                        p->callback = aubio_pitchdetection_fcomb;
    7779                        break;
    7880                case aubio_schmitt:
     81                        p->buf      = new_fvec(bufsize,channels);
    7982                        p->schmitt  = new_aubio_pitchschmitt(bufsize,samplerate);
    80                         p->callback = aubio_pitchdetection_mcomb;
     83                        p->callback = aubio_pitchdetection_schmitt;
    8184                        break;
    8285                default:
     
    98101                        break;
    99102                case aubio_schmitt:
     103                        del_fvec(p->buf);
    100104                        del_aubio_pitchschmitt(p->schmitt);
    101105                        break;
    102106                case aubio_fcomb:
     107                        del_fvec(p->buf);
    103108                        del_aubio_pitchfcomb(p->fcomb);
    104109                        break;
     
    107112        }
    108113        AUBIO_FREE(p);
     114}
     115
     116void aubio_pitchdetection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf){
     117        uint_t i,j = 0, overlap_size = 0;
     118        overlap_size = p->buf->length-ibuf->length;
     119        for (i=0;i<p->buf->channels;i++){
     120                for (j=0;j<overlap_size;j++){
     121                        p->buf->data[i][j] =
     122                                p->buf->data[i][j+ibuf->length];
     123                }
     124        }
     125        for (i=0;i<ibuf->channels;i++){
     126                for (j=0;j<ibuf->length;j++){
     127                        p->buf->data[i][j+overlap_size] =
     128                                ibuf->data[i][j];
     129                }
     130        }
    109131}
    110132
     
    128150smpl_t aubio_pitchdetection_yin(aubio_pitchdetection_t *p, fvec_t *ibuf) {
    129151        smpl_t pitch = 0.;
    130         uint_t i,j = 0, overlap_size = 0;
    131         overlap_size = p->buf->length-ibuf->length;
    132         /* do sliding window blocking */
    133         for (i=0;i<p->buf->channels;i++){
    134                 for (j=0;j<overlap_size;j++){
    135                         p->buf->data[i][j] =
    136                                 p->buf->data[i][j+ibuf->length];
    137                 }
    138         }
    139         for (i=0;i<ibuf->channels;i++){
    140                 for (j=0;j<ibuf->length;j++){
    141                         p->buf->data[i][j+overlap_size] =
    142                                 ibuf->data[i][j];
    143                 }
    144         }
     152        aubio_pitchdetection_slideblock(p,ibuf);
    145153        pitch = aubio_pitchyin_getpitchfast(p->buf,p->yin, 0.5);
    146154        if (pitch>0) {
     
    154162
    155163smpl_t aubio_pitchdetection_fcomb(aubio_pitchdetection_t *p, fvec_t *ibuf){
    156         return aubio_pitchfcomb_detect(p->fcomb,ibuf);
     164        aubio_pitchdetection_slideblock(p,ibuf);
     165        return aubio_pitchfcomb_detect(p->fcomb,p->buf);
    157166}
    158167
    159168smpl_t aubio_pitchdetection_schmitt(aubio_pitchdetection_t *p, fvec_t *ibuf){
    160         return aubio_pitchschmitt_detect(p->schmitt,ibuf);
     169        aubio_pitchdetection_slideblock(p,ibuf);
     170        return aubio_pitchschmitt_detect(p->schmitt,p->buf);
    161171}
Note: See TracChangeset for help on using the changeset viewer.