shithub: aubio

ref: 1fe3ac2711adcbe1339a80ecaae5045082df3256
dir: /python.old/tests_demo_bench/onset/bench-window/

View raw version
#! /usr/bin/python

from aubio.bench.onset import benchonset
from aubio.task.onset import taskonset
from aubio.task.params import taskparams

class mybenchonset(benchonset):

	def run_bench(self,modes=['dual'],thresholds=[0.5]):
		from os.path import dirname,basename
		self.thresholds = thresholds
		self.pretty_titles()

		for mode in modes:

			self.params.onsetmode = mode
			self.params.localmin = True
			self.params.delay = 1. 
			self.params.threshold = thresholds[0]
			self.params.localmin = False 
			#
			for delay in (0., 4.):
				d = []
				self.params.delay = delay 
				for buf in (2048, 1024, 512):
					for hop in (buf/2, buf/4):
						self.params.bufsize = buf 
						self.params.hopsize = hop 
						self.params.step = float(self.params.hopsize)/float(self.params.samplerate)
						self.dir_eval_print()
						self.plotdiffs(d,plottitle="%s %s" % (buf,hop))
				#plotplotdiffs(d)
				outplot = "_-_".join(("window",mode,"delay-%s" % int(delay),
					basename(self.datadir) ))
				for ext in ("png","svg","ps"):
					self.plotplotdiffs(d,outplot=outplot,extension=ext)

if __name__ == "__main__":
	import sys
	if len(sys.argv) > 1: datapath = sys.argv[1]
	else: print "ERR: a path is required"; sys.exit(1)
	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]
	#modes = [ 'hfc' ]
	thresholds = [0.5]

	#datapath = "%s%s" % (DATADIR,'/onset/DB/*/')
	respath = '/var/tmp/DB-testings'

	benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True)
	benchonset.params = taskparams()
	benchonset.task = taskonset
	benchonset.valuesdict = {}

	try:
		#benchonset.auto_learn2(modes=modes)
		benchonset.run_bench(modes=modes,thresholds=thresholds)
	except KeyboardInterrupt:
		sys.exit(1)