Changeset 650e39b


Ignore:
Timestamp:
Mar 21, 2006, 11:59:17 PM (18 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:
4798fdf
Parents:
4994ebb
Message:

add yinfft method, make it default for pd plugin
add yinfft method, make it default for pd plugin

Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • plugins/puredata/aubiopitch~.c

    r4994ebb r650e39b  
    1313char aubiopitch_version[] = "aubiopitch~ version 0.1";
    1414
    15 aubio_pitchdetection_type type_pitch = aubio_pitch_mcomb;
     15aubio_pitchdetection_type type_pitch = aubio_pitch_yinfft;
    1616aubio_pitchdetection_mode mode_pitch = aubio_pitchm_freq;
    1717
     
    8181        x->o = new_aubio_pitchdetection(x->bufsize*4,
    8282                    x->hopsize, 1, 44100., type_pitch, mode_pitch);
     83        aubio_pitchdetection_set_yinthresh(x->o, 0.7);
    8384        x->vec = (fvec_t *)new_fvec(x->hopsize,1);
    8485
  • python/aubio/task/pitch.py

    r4994ebb r650e39b  
    88                task.__init__(self,input,params=params)
    99                self.shortlist = [0. for i in range(self.params.pitchsmooth)]
     10                if self.params.pitchmode == 'yinfft':
     11                        yinthresh = self.params.yinfftthresh
     12                elif self.params.pitchmode == 'yin':
     13                        yinthresh = self.params.yinthresh
     14                else:
     15                        yinthresh = 0.
    1016                self.pitchdet  = pitchdetection(mode=get_pitch_mode(self.params.pitchmode),
    1117                        bufsize=self.params.bufsize,
     
    1420                        samplerate=self.srate,
    1521                        omode=self.params.omode,
    16                         yinthresh=self.params.yinthresh)
     22                        yinthresh=yinthresh)
    1723
    1824        def __call__(self):
     
    6874                                while(tasksil.readsize==tasksil.params.hopsize):
    6975                                        tasksil()
    70                                         time.append(tasksil.params.step*tasksil.frameread)
     76                                        time.append(tasksil.params.step*(tasksil.frameread))
    7177                                        if not tasksil.issilence:
    7278                                                pitch.append(self.truth)
     
    156162
    157163                       
    158         def plotplot(self,wplot,oplots,outplot=None,multiplot = 1, midi = 1):
     164        def plotplot(self,wplot,oplots,outplot=None,multiplot = 0, midi = 1):
    159165                from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot
    160166                import re
     
    198204                else:
    199205                        g.ylabel('pitch (midi)')
    200                         g('set yrange [%f:%f]' % (40, aubio_freqtomidi(self.params.pitchmax)))
     206                        g('set yrange [%f:%f]' % (aubio_freqtomidi(self.params.pitchmin), aubio_freqtomidi(self.params.pitchmax)))
    201207                g('set key right top')
    202208                g('set noclip one')
  • python/aubio/task/utils.py

    r4994ebb r650e39b  
    3434        elif nvalue == 'schmitt':
    3535                 return aubio_pitch_schmitt
     36        elif nvalue == 'yinfft':
     37                 return aubio_pitch_yinfft
    3638        else:
    3739                 import sys
  • python/aubiopitch

    r4994ebb r650e39b  
    9090params.bufsize    = int(options.bufsize)
    9191params.step       = params.samplerate/float(params.hopsize)
    92 params.threshold  = float(options.threshold)
     92params.yinthresh  = float(options.threshold)
    9393params.silence    = float(options.silence)
    9494params.verbose    = options.verbose
     
    100100if options.note:
    101101        exit("not implemented yet")
    102 
    103102
    104103wplot,oplots = [],[]
  • src/Makefile.am

    r4994ebb r650e39b  
    1818        pitchschmitt.h \
    1919        pitchfcomb.h \
     20        pitchyinfft.h \
    2021        beattracking.h \
    2122        filter.h
     
    5758        pitchfcomb.c \
    5859        pitchfcomb.h \
     60        pitchyinfft.c \
     61        pitchyinfft.h \
    5962        beattracking.c \
    6063        beattracking.h \
  • src/pitchdetection.c

    r4994ebb r650e39b  
    2626#include "pitchfcomb.h"
    2727#include "pitchschmitt.h"
     28#include "pitchyinfft.h"
    2829#include "pitchdetection.h"
    2930
     
    4445        aubio_pitchfcomb_t * fcomb;
    4546        aubio_pitchschmitt_t * schmitt;
     47        aubio_pitchyinfft_t * yinfft;
    4648        aubio_filter_t * filter;
    4749        /* for yin */
     
    9294                        p->pv       = new_aubio_pvoc(bufsize, hopsize, channels);
    9395                        p->fftgrain = new_cvec(bufsize, channels);
    94                         p->mcomb    = new_aubio_pitchmcomb(bufsize,channels,samplerate);
     96                        p->mcomb    = new_aubio_pitchmcomb(bufsize,hopsize,channels,samplerate);
    9597                        p->filter   = new_aubio_cdsgn_filter(samplerate);
    9698                        p->callback = aubio_pitchdetection_mcomb;
     
    105107                        p->schmitt  = new_aubio_pitchschmitt(bufsize,samplerate);
    106108                        p->callback = aubio_pitchdetection_schmitt;
     109                        break;
     110                case aubio_pitch_yinfft:
     111                        p->buf      = new_fvec(bufsize,channels);
     112                        p->yinfft   = new_aubio_pitchyinfft(bufsize);
     113                        p->callback = aubio_pitchdetection_yinfft;
     114                        p->yinthres = 0.2;
    107115                        break;
    108116                default:
     
    147155                        del_fvec(p->buf);
    148156                        del_aubio_pitchfcomb(p->fcomb);
     157                        break;
     158                case aubio_pitch_yinfft:
     159                        del_fvec(p->buf);
     160                        del_aubio_pitchyinfft(p->yinfft);
    149161                        break;
    150162                default:
     
    206218
    207219
     220smpl_t aubio_pitchdetection_yinfft(aubio_pitchdetection_t *p, fvec_t *ibuf){
     221        smpl_t pitch = 0.;
     222        aubio_pitchdetection_slideblock(p,ibuf);
     223        pitch = aubio_pitchyinfft_detect(p->yinfft,p->buf,p->yinthres);
     224        if (pitch>0) {
     225                pitch = p->srate/(pitch+0.);
     226        } else {
     227                pitch = 0.;
     228        }
     229        return pitch;
     230}
     231
    208232smpl_t aubio_pitchdetection_fcomb(aubio_pitchdetection_t *p, fvec_t *ibuf){
    209233        aubio_pitchdetection_slideblock(p,ibuf);
  • src/pitchdetection.h

    r4994ebb r650e39b  
    2828        aubio_pitch_mcomb,
    2929        aubio_pitch_schmitt,
    30         aubio_pitch_fcomb
     30        aubio_pitch_fcomb,
     31        aubio_pitch_yinfft
    3132} aubio_pitchdetection_type;
    3233
     
    4546smpl_t aubio_pitchdetection_schmitt(aubio_pitchdetection_t *p, fvec_t *ibuf);
    4647smpl_t aubio_pitchdetection_fcomb(aubio_pitchdetection_t *p, fvec_t *ibuf);
     48smpl_t aubio_pitchdetection_yinfft(aubio_pitchdetection_t *p, fvec_t *ibuf);
    4749
    4850void aubio_pitchdetection_set_yinthresh(aubio_pitchdetection_t *p, smpl_t thres);
  • swig/aubio.i

    r4994ebb r650e39b  
    191191        aubio_pitch_mcomb,
    192192        aubio_pitch_schmitt,
    193         aubio_pitch_fcomb
     193        aubio_pitch_fcomb,
     194        aubio_pitch_yinfft
    194195} aubio_pitchdetection_type;
    195196
     
    218219
    219220/* pitch mcomb */
    220 aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t size, uint_t channels, uint_t samplerate);
     221aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate);
    221222smpl_t aubio_pitchmcomb_detect(aubio_pitchmcomb_t * p, cvec_t * fftgrain);
    222223uint_t aubio_pitch_cands(aubio_pitchmcomb_t * p, cvec_t * fftgrain, smpl_t * cands);
     
    227228void aubio_pitchyin_getcum(fvec_t *yin);
    228229uint_t aubio_pitchyin_getpitch(fvec_t *yin);
    229 uint_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t *yin, smpl_t tol);
     230smpl_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t *yin, smpl_t tol);
    230231
    231232/* pitch schmitt */
Note: See TracChangeset for help on using the changeset viewer.