History

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

Paul Brossier committed 20 years ago

Commit 37f03521 parent 0baafcf1 file · +19 −14Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/aubio/tasks.py+19−14
@@ -206,6 +206,7 @@ class taskparams(object): · 205 unmodified lines
206 self.hopsize = 256206 self.hopsize = 256
207 self.samplerate = 44100207 self.samplerate = 44100
208 self.tol = 0.05208 self.tol = 0.05
209 self.mintol = 0.0
209 self.step = float(self.hopsize)/float(self.samplerate)210 self.step = float(self.hopsize)/float(self.samplerate)
210 self.threshold = 0.1211 self.threshold = 0.1
211 self.onsetmode = 'dual'212 self.onsetmode = 'dual'
@@ -298,31 +299,28 @@ class taskpitch(task): · 86 unmodified lines
298 """ big hack to extract midi note from /path/to/file.<midinote>.wav """299 """ big hack to extract midi note from /path/to/file.<midinote>.wav """
299 floatpit = self.input.split('.')[-2]300 floatpit = self.input.split('.')[-2]
300 try:301 try:
301 return float(floatpit)302 return aubio_miditofreq(float(floatpit))
302 except ValueError:303 except ValueError:
303 print "ERR: no truth file found"304 print "ERR: no truth file found"
304 return 0305 return 0
305 306
306 def eval(self,results):307 def eval(self,results):
308 def mmean(l):
309 return sum(l)/max(float(len(l)),1)
310
307 from median import short_find 311 from median import short_find
308 self.truth = self.gettruth()312 self.truth = self.gettruth()
309 num = 0
310 sum = 0
311 res = []313 res = []
312 for i in results:314 for i in results:
313 if i == -1: pass315 if i == -1: pass
314 else: 316 else:
315 res.append(i)317 res.append(self.truth-i)
316 sum += i318 if not res:
317 num += 1319 avg = self.truth; med = self.truth
318 if num == 0:
319 avg = 0; med = 0
320 else:320 else:
321 avg = aubio_freqtomidi(sum / float(num))321 avg = mmean(res)
322 med = aubio_freqtomidi(short_find(res,len(res)/2))322 med = short_find(res,len(res)/2)
323 avgdist = self.truth - avg323 return self.truth, self.truth-med, self.truth-avg
324 meddist = self.truth - med
325 return avgdist, meddist
326 324
327 def plot(self,pitch,outplot=None):325 def plot(self,pitch,outplot=None):
328 from aubio.gnuplot import plot_pitch326 from aubio.gnuplot import plot_pitch
@@ -350,6 +348,7 @@ class taskonset(task): · 21 unmodified lines
350 self.ofunc = []348 self.ofunc = []
351 self.d,self.d2 = [],[]349 self.d,self.d2 = [],[]
352 self.maxofunc = 0350 self.maxofunc = 0
351 self.last = 0
353 if self.params.localmin:352 if self.params.localmin:
354 self.ovalist = [0., 0., 0., 0., 0.]353 self.ovalist = [0., 0., 0., 0., 0.]
355 354
@@ -376,7 +375,13 @@ class taskonset(task): · 20 unmodified lines
376 if self.params.delay != 0.: now -= self.params.delay375 if self.params.delay != 0.: now -= self.params.delay
377 if now < 0 :376 if now < 0 :
378 now = 0377 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 def eval(self,inputdata,ftru,mode='roc',vmode=''):387 def eval(self,inputdata,ftru,mode='roc',vmode=''):

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t