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):
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