3 from aubio.bench.onset import benchonset
4 from aubio.task.onset import taskonset
5 from aubio.task.params import taskparams
7 class mybenchonset(benchonset):
9 def run_bench(self,modes=['dual'],thresholds=[0.5]):
10 from os.path import dirname,basename
11 self.thresholds = thresholds
16 self.params.onsetmode = mode
17 self.params.localmin = True
18 self.params.delay = 1.
19 self.params.threshold = thresholds[0]
20 self.params.localmin = False
22 for delay in (0., 4.):
24 self.params.delay = delay
25 for buf in (2048, 1024, 512):
26 for hop in (buf/2, buf/4):
27 self.params.bufsize = buf
28 self.params.hopsize = hop
29 self.params.step = float(self.params.hopsize)/float(self.params.samplerate)
31 self.plotdiffs(d,plottitle="%s %s" % (buf,hop))
33 outplot = "_-_".join(("window",mode,"delay-%s" % int(delay),
34 basename(self.datadir) ))
35 for ext in ("png","svg","ps"):
36 self.plotplotdiffs(d,outplot=outplot,extension=ext)
38 if __name__ == "__main__":
40 if len(sys.argv) > 1: datapath = sys.argv[1]
41 else: print "ERR: a path is required"; sys.exit(1)
42 modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual']
43 #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]
47 #datapath = "%s%s" % (DATADIR,'/onset/DB/*/')
48 respath = '/var/tmp/DB-testings'
50 benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True)
51 benchonset.params = taskparams()
52 benchonset.task = taskonset
53 benchonset.valuesdict = {}
56 #benchonset.auto_learn2(modes=modes)
57 benchonset.run_bench(modes=modes,thresholds=thresholds)
58 except KeyboardInterrupt: