Changeset 37f0352


Ignore:
Timestamp:
Feb 23, 2006, 3:14:30 AM (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:
2d975cf
Parents:
0baafcf
Message:

add mintol to taskonset, fix taskpitch.eval
add mintol to taskonset, fix taskpitch.eval

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/aubio/tasks.py

    r0baafcf r37f0352  
    207207                self.samplerate = 44100
    208208                self.tol = 0.05
     209                self.mintol = 0.0
    209210                self.step = float(self.hopsize)/float(self.samplerate)
    210211                self.threshold = 0.1
     
    299300                floatpit = self.input.split('.')[-2]
    300301                try:
    301                         return float(floatpit)
     302                        return aubio_miditofreq(float(floatpit))
    302303                except ValueError:
    303304                        print "ERR: no truth file found"
     
    305306
    306307        def eval(self,results):
     308                def mmean(l):
     309                        return sum(l)/max(float(len(l)),1)
     310
    307311                from median import short_find
    308312                self.truth = self.gettruth()
    309                 num = 0
    310                 sum = 0
    311313                res = []
    312314                for i in results:
    313315                        if i == -1: pass
    314316                        else:
    315                                 res.append(i)
    316                                 sum += i
    317                                 num += 1
    318                 if num == 0:
    319                         avg = 0; med = 0
     317                                res.append(self.truth-i)
     318                if not res:
     319                        avg = self.truth; med = self.truth
    320320                else:
    321                         avg = aubio_freqtomidi(sum / float(num))
    322                         med = aubio_freqtomidi(short_find(res,len(res)/2))
    323                 avgdist = self.truth - avg
    324                 meddist = self.truth - med
    325                 return avgdist, meddist
     321                        avg = mmean(res)
     322                        med = short_find(res,len(res)/2)
     323                return self.truth, self.truth-med, self.truth-avg
    326324
    327325        def plot(self,pitch,outplot=None):
     
    351349                self.d,self.d2 = [],[]
    352350                self.maxofunc = 0
     351                self.last = 0
    353352                if self.params.localmin:
    354353                        self.ovalist   = [0., 0., 0., 0., 0.]
     
    377376                        if now < 0 :
    378377                                now = 0
    379                         return now, val
     378                        if self.params.mintol:
     379                                #print now - self.last, self.params.mintol
     380                                if (now - self.last) > self.params.mintol:
     381                                        self.last = now
     382                                        return now, val
     383                        else:
     384                                return now, val
    380385
    381386
Note: See TracChangeset for help on using the changeset viewer.