[83c6734] | 1 | #! /usr/bin/python |
---|
| 2 | |
---|
| 3 | from aubio.tasks import * |
---|
| 4 | |
---|
[6ae3a77] | 5 | from benchonset import mmean, stdev, benchonset |
---|
[83c6734] | 6 | |
---|
| 7 | class mybenchonset(benchonset): |
---|
| 8 | |
---|
| 9 | def run_bench(self,modes=['dual'],thresholds=[0.5]): |
---|
| 10 | from os.path import dirname,basename |
---|
| 11 | self.thresholds = thresholds |
---|
| 12 | self.pretty_titles() |
---|
[6ae3a77] | 13 | |
---|
[83c6734] | 14 | for mode in modes: |
---|
| 15 | |
---|
| 16 | self.params.onsetmode = mode |
---|
[6ae3a77] | 17 | self.params.localmin = True |
---|
| 18 | self.params.delay = 1. |
---|
[83c6734] | 19 | self.params.threshold = thresholds[0] |
---|
| 20 | self.params.localmin = False |
---|
[6ae3a77] | 21 | # |
---|
[83c6734] | 22 | for delay in (0., 4.): |
---|
| 23 | d = [] |
---|
| 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) |
---|
[6ae3a77] | 30 | self.dir_eval_print() |
---|
| 31 | self.plotdiffs(d,plottitle="%s %s" % (buf,hop)) |
---|
| 32 | #plotplotdiffs(d) |
---|
| 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) |
---|
[83c6734] | 37 | |
---|
| 38 | if __name__ == "__main__": |
---|
| 39 | import sys |
---|
| 40 | if len(sys.argv) > 1: datapath = sys.argv[1] |
---|
| 41 | else: print "ERR: a path is required"; sys.exit(1) |
---|
[6ae3a77] | 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] |
---|
| 44 | #modes = [ 'hfc' ] |
---|
| 45 | thresholds = [0.5] |
---|
[83c6734] | 46 | |
---|
| 47 | #datapath = "%s%s" % (DATADIR,'/onset/DB/*/') |
---|
| 48 | respath = '/var/tmp/DB-testings' |
---|
| 49 | |
---|
| 50 | benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True) |
---|
| 51 | benchonset.params = taskparams() |
---|
| 52 | benchonset.task = taskonset |
---|
| 53 | benchonset.valuesdict = {} |
---|
| 54 | |
---|
| 55 | try: |
---|
| 56 | #benchonset.auto_learn2(modes=modes) |
---|
| 57 | benchonset.run_bench(modes=modes,thresholds=thresholds) |
---|
| 58 | except KeyboardInterrupt: |
---|
| 59 | sys.exit(1) |
---|