Index: python/test/bench/onset/bench-onset
===================================================================
--- python/test/bench/onset/bench-onset	(revision d998190e422036f80ffb1dac9c5ba1a16ed4bb51)
+++ python/test/bench/onset/bench-onset	(revision a7880d9a7d53610ea440ab70166ec0d40c27415a)
@@ -1,79 +1,17 @@
 #! /usr/bin/python
 
-from aubio.bench.node import *
 from aubio.tasks import *
 
+from benchonset import mmean, stdev, benchonset
 
-
-
-def mmean(l):
-	return sum(l)/float(len(l))
-
-def stdev(l):
-	smean = 0
-	lmean = mmean(l)
-	for i in l:
-		smean += (i-lmean)**2
-	smean *= 1. / len(l)
-	return smean**.5
-
-class benchonset(bench):
-
-	""" list of values to store per file """
-	valuenames = ['orig','missed','Tm','expc','bad','Td']
-	""" list of lists to store per file """
-	valuelists = ['l','labs']
-	""" list of values to print per dir """
-	printnames = [ 'mode', 'thres', 'dist', 'prec', 'recl', 
-		'Ttrue', 'Tfp',  'Tfn',  'Tm',   'Td',
-		'aTtrue', 'aTfp', 'aTfn', 'aTm',  'aTd',  
-		'mean', 'smean',  'amean', 'samean']
-
-	""" per dir """
-	formats = {'mode': "%12s" , 'thres': "%5.4s", 
-		'dist':  "%5.4s", 'prec': "%5.4s", 'recl':  "%5.4s",
-		'Ttrue': "%5.4s", 'Tfp':   "%5.4s", 'Tfn':   "%5.4s", 
-		'Tm':    "%5.4s", 'Td':    "%5.4s",
-		'aTtrue':"%5.4s", 'aTfp':  "%5.4s", 'aTfn':  "%5.4s", 
-		'aTm':   "%5.4s", 'aTd':   "%5.4s",
-		'mean':  "%5.40s", 'smean': "%5.40s", 
-		'amean':  "%5.40s", 'samean': "%5.40s"}
-
-	def dir_eval(self):
-		""" evaluate statistical data over the directory """
-		totaltrue = sum(self.v['expc'])-sum(self.v['bad'])-sum(self.v['Td'])
-		totalfp = sum(self.v['bad'])+sum(self.v['Td'])
-                totalfn = sum(self.v['missed'])+sum(self.v['Tm'])
-		self.P = 100*float(totaltrue)/max(totaltrue + totalfp,1)
-		self.R = 100*float(totaltrue)/max(totaltrue + totalfn,1)
-		if self.R < 0: self.R = 0
-		self.F = 2.* self.P*self.R / max(float(self.P+self.R),1)
-		N = float(len(self.reslist))
-		self.v['mode']      = self.params.onsetmode
-		self.v['thres']     = self.params.threshold 
-		self.v['thres']     = "%2.3f" % self.params.threshold
-		self.v['dist']      = "%2.3f" % self.F
-		self.v['prec']      = "%2.3f" % self.P
-		self.v['recl']      = "%2.3f" % self.R
-		self.v['Ttrue']     = totaltrue
-		self.v['Tfp']       = totalfp
-		self.v['Tfn']       = totalfn
-		self.v['aTtrue']    = totaltrue/N
-		self.v['aTfp']      = totalfp/N
-		self.v['aTfn']      = totalfn/N
-		self.v['aTm']       = sum(self.v['Tm'])/N
-		self.v['aTd']       = sum(self.v['Td'])/N
-		self.v['Tm']       = sum(self.v['Tm'])
-		self.v['Td']       = sum(self.v['Td'])
-		self.v['mean']      = mmean(self.v['l'])
-		self.v['smean']     = stdev(self.v['l'])
-		self.v['amean']     = mmean(self.v['labs'])
-		self.v['samean']    = stdev(self.v['labs'])
+class mybenchonset(benchonset):
 
 	def run_bench(self,modes=['dual'],thresholds=[0.5]):
-		self.modes = modes
+		from os.path import dirname,basename
 		self.thresholds = thresholds
 		self.pretty_titles()
-		for mode in self.modes:
+		d,e,f = [],[],[]
+		for mode in modes:
+			self.vlist = []
 			self.params.onsetmode = mode
 			for threshold in self.thresholds:
@@ -83,4 +21,18 @@
 				self.pretty_print()
 				#print self.v
+				self.vlist.append(self.v)
+			self.plotroc(d)
+			self.plotfmeas(e)
+			self.plotpr(f)
+			#print vlist
+		#self.plotplotroc(d)
+		#self.plotplotfmeas(e)
+		#self.plotplotpr(f)
+		outplot = basename(self.datadir)
+		for ext in ("png","svg","ps"):
+			self.plotplotroc(d,outplot=outplot,extension=ext)
+			self.plotplotfmeas(e,outplot=outplot,extension=ext)
+			self.plotplotpr(f,outplot=outplot,extension=ext)
+
 
 	def auto_learn(self,modes=['dual'],thresholds=[0.1,1.5]):
@@ -107,4 +59,8 @@
 
 			for i in range(steps):
+				self.params.localmin = True
+				self.params.delay = 1. 
+				self.dir_exec()
+				self.dir_eval()
 				self.params.threshold = ( lesst + topt ) * .5 
 				self.dir_exec()
@@ -170,13 +126,13 @@
 	if len(sys.argv) > 1: datapath = sys.argv[1]
 	else: print "ERR: a path is required"; sys.exit(1)
-	modes = ['complex', 'energy', 'phase', 'specdiff', 'kl', 'mkl', 'dual']
-	#modes = [ 'mkl' ]
+	modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual']
 	thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2]
-	#thresholds = [1.5]
+	#modes = [ 'hfc' ]
+	#thresholds = [0.1, 1.5]
 
 	#datapath = "%s%s" % (DATADIR,'/onset/DB/*/')
 	respath = '/var/tmp/DB-testings'
 
-	benchonset = benchonset(datapath,respath,checkres=True,checkanno=True)
+	benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True)
 	benchonset.params = taskparams()
 	benchonset.task = taskonset
