[83c6734] | 1 | #! /usr/bin/python |
---|
| 2 | |
---|
| 3 | from aubio.tasks import * |
---|
| 4 | |
---|
| 5 | from benchonset import mmean, stdev, benchonset |
---|
| 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() |
---|
| 13 | |
---|
[6ae3a77] | 14 | for mode in modes: |
---|
| 15 | d = [] |
---|
[83c6734] | 16 | self.params.onsetmode = mode |
---|
[6ae3a77] | 17 | self.params.localmin = True |
---|
| 18 | self.params.delay = 1. |
---|
[83c6734] | 19 | self.params.threshold = thresholds[0] |
---|
[6ae3a77] | 20 | # |
---|
[83c6734] | 21 | self.params.localmin = False |
---|
| 22 | self.params.delay = 0. |
---|
[6ae3a77] | 23 | self.dir_eval_print() |
---|
[83c6734] | 24 | self.plotdiffs(d,plottitle="Causal") |
---|
[6ae3a77] | 25 | # |
---|
[83c6734] | 26 | self.params.localmin = True |
---|
| 27 | self.params.delay = 0. |
---|
[6ae3a77] | 28 | self.dir_eval_print() |
---|
[83c6734] | 29 | self.plotdiffs(d,plottitle="Local min") |
---|
| 30 | |
---|
| 31 | self.params.localmin = False |
---|
| 32 | self.params.delay = 6. |
---|
[6ae3a77] | 33 | self.dir_eval_print() |
---|
[83c6734] | 34 | self.plotdiffs(d,plottitle="Fixed delay") |
---|
| 35 | |
---|
[6ae3a77] | 36 | #self.plotplotdiffs(d) |
---|
| 37 | outplot = "_-_".join(("delay",mode,basename(self.datadir) )) |
---|
| 38 | for ext in ("png","svg","ps"): |
---|
| 39 | self.plotplotdiffs(d,outplot=outplot,extension=ext) |
---|
[83c6734] | 40 | |
---|
| 41 | if __name__ == "__main__": |
---|
| 42 | import sys |
---|
| 43 | if len(sys.argv) > 1: datapath = sys.argv[1] |
---|
| 44 | else: print "ERR: a path is required"; sys.exit(1) |
---|
[6ae3a77] | 45 | modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual'] |
---|
| 46 | #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 | #modes = [ 'hfc' ] |
---|
| 48 | thresholds = [0.5] |
---|
[83c6734] | 49 | |
---|
| 50 | #datapath = "%s%s" % (DATADIR,'/onset/DB/*/') |
---|
| 51 | respath = '/var/tmp/DB-testings' |
---|
| 52 | |
---|
| 53 | benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True) |
---|
| 54 | benchonset.params = taskparams() |
---|
| 55 | benchonset.task = taskonset |
---|
| 56 | benchonset.valuesdict = {} |
---|
| 57 | |
---|
| 58 | try: |
---|
| 59 | #benchonset.auto_learn2(modes=modes) |
---|
| 60 | benchonset.run_bench(modes=modes,thresholds=thresholds) |
---|
| 61 | except KeyboardInterrupt: |
---|
| 62 | sys.exit(1) |
---|