Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -206,6 +206,7 @@ class taskparams(object): · 205 unmodified lines | ||
| 206 | 206 | self.hopsize = 256 |
| 207 | 207 | self.samplerate = 44100 |
| 208 | 208 | self.tol = 0.05 |
| 209 | + self.mintol = 0.0 | |
| 209 | 210 | self.step = float(self.hopsize)/float(self.samplerate) |
| 210 | 211 | self.threshold = 0.1 |
| 211 | 212 | self.onsetmode = 'dual' |
| @@ -298,31 +299,28 @@ class taskpitch(task): · 86 unmodified lines | ||
| 298 | 299 | """ big hack to extract midi note from /path/to/file.<midinote>.wav """ |
| 299 | 300 | floatpit = self.input.split('.')[-2] |
| 300 | 301 | try: |
| 301 | − return float(floatpit) | |
| 302 | + return aubio_miditofreq(float(floatpit)) | |
| 302 | 303 | except ValueError: |
| 303 | 304 | print "ERR: no truth file found" |
| 304 | 305 | return 0 |
| 305 | 306 | |
| 306 | 307 | def eval(self,results): |
| 308 | + def mmean(l): | |
| 309 | + return sum(l)/max(float(len(l)),1) | |
| 310 | + | |
| 307 | 311 | from median import short_find |
| 308 | 312 | self.truth = self.gettruth() |
| 309 | − num = 0 | |
| 310 | − sum = 0 | |
| 311 | 313 | res = [] |
| 312 | 314 | for i in results: |
| 313 | 315 | if i == -1: pass |
| 314 | 316 | 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 | |
| 320 | 320 | 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 | |
| 326 | 324 | |
| 327 | 325 | def plot(self,pitch,outplot=None): |
| 328 | 326 | from aubio.gnuplot import plot_pitch |
| @@ -350,6 +348,7 @@ class taskonset(task): · 21 unmodified lines | ||
| 350 | 348 | self.ofunc = [] |
| 351 | 349 | self.d,self.d2 = [],[] |
| 352 | 350 | self.maxofunc = 0 |
| 351 | + self.last = 0 | |
| 353 | 352 | if self.params.localmin: |
| 354 | 353 | self.ovalist = [0., 0., 0., 0., 0.] |
| 355 | 354 | |
| @@ -376,7 +375,13 @@ class taskonset(task): · 20 unmodified lines | ||
| 376 | 375 | if self.params.delay != 0.: now -= self.params.delay |
| 377 | 376 | if now < 0 : |
| 378 | 377 | 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 | |
| 380 | 385 | |
| 381 | 386 | |
| 382 | 387 | def eval(self,inputdata,ftru,mode='roc',vmode=''): |