python/aubio: update to latest pitch prototypes
authorPaul Brossier <piem@piem.org>
Thu, 8 Oct 2009 18:59:23 +0000 (20:59 +0200)
committerPaul Brossier <piem@piem.org>
Thu, 8 Oct 2009 18:59:23 +0000 (20:59 +0200)
python/aubio/aubioclass.py
python/aubio/task/pitch.py

index 0a5f702dda5c49067a3a33490ff8b4aeaaabc0a2..18f6ce16d2d9bb17f4f5b3d25a015108cbe355c5 100644 (file)
@@ -125,16 +125,17 @@ class onsetpick:
 
 class pitchdetection:
     def __init__(self,mode=aubio_pitch_mcomb,bufsize=2048,hopsize=1024,
-        channels=1,samplerate=44100.,omode=aubio_pitchm_freq,yinthresh=0.1):
+        channels=1,samplerate=44100.,omode=aubio_pitchm_freq,tolerance=0.1):
         self.pitchp = new_aubio_pitchdetection(bufsize,hopsize,channels,
                 samplerate,mode,omode)
-        aubio_pitchdetection_set_yinthresh(self.pitchp,yinthresh)
+        self.mypitch = fvec(1, channels)
+        aubio_pitchdetection_set_tolerance(self.pitchp,tolerance)
         #self.filt     = filter(srate,"adsgn")
     def __del__(self):
         del_aubio_pitchdetection(self.pitchp)
     def __call__(self,myvec): 
-        #self.filt(myvec)
-        return aubio_pitchdetection_do(self.pitchp,myvec())
+        aubio_pitchdetection_do(self.pitchp,myvec(), self.mypitch())
+        return self.mypitch.get(0,0)
 
 class filter:
     def __init__(self,srate,type=None):
index a531a62bacb63911c47d1ef9986167f7e70e92a0..1db00b3b74fb10b77f0dfd5e843be63bb8ca6955 100644 (file)
@@ -7,19 +7,19 @@ class taskpitch(task):
        def __init__(self,input,params=None):
                task.__init__(self,input,params=params)
                self.shortlist = [0. for i in range(self.params.pitchsmooth)]
-               if self.params.pitchmode == 'yinfft':
-                       yinthresh = self.params.yinfftthresh
-               elif self.params.pitchmode == 'yin':
-                       yinthresh = self.params.yinthresh
+               if self.params.pitchmode == 'yin':
+                       tolerance = self.params.yinthresh
+               elif self.params.pitchmode == 'yinfft':
+                       tolerance = self.params.yinfftthresh
                else:
-                       yinthresh = 0.
-               self.pitchdet  = pitchdetection(mode=get_pitch_mode(self.params.pitchmode),
+                       tolerance = 0.
+               self.pitchdet   = pitchdetection(mode=get_pitch_mode(self.params.pitchmode),
                        bufsize=self.params.bufsize,
                        hopsize=self.params.hopsize,
                        channels=self.channels,
                        samplerate=self.srate,
                        omode=self.params.omode,
-                       yinthresh=yinthresh)
+                       tolerance = tolerance)
 
        def __call__(self):
                from aubio.median import short_find