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
206206 self.hopsize = 256
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
211212 self.onsetmode = 'dual'
@@ -298,31 +299,28 @@ class taskpitch(task): · 86 unmodified lines
298299 """ big hack to extract midi note from /path/to/file.<midinote>.wav """
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"
304305 return 0
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):
328326 from aubio.gnuplot import plot_pitch
@@ -350,6 +348,7 @@ class taskonset(task): · 21 unmodified lines
350348 self.ofunc = []
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.]
355354
@@ -376,7 +375,13 @@ class taskonset(task): · 20 unmodified lines
376375 if self.params.delay != 0.: now -= self.params.delay
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
382387 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