[4cc9fe5] | 1 | #! /usr/bin/python |
---|
| 2 | |
---|
| 3 | from aubio.bench.node import * |
---|
[0029638] | 4 | from aubio.tasks import * |
---|
| 5 | |
---|
| 6 | class benchpitch(bench): |
---|
| 7 | |
---|
[4f4a8a4] | 8 | def file_exec(self,input,output): |
---|
[0029638] | 9 | filetask = self.task(input,params=self.params) |
---|
| 10 | computed_data = filetask.compute_all() |
---|
| 11 | results = filetask.eval(computed_data) |
---|
| 12 | self.results.append(results) |
---|
| 13 | truth = filetask.gettruth() |
---|
| 14 | #print input, results, results - float(input.split('.')[-2]) |
---|
[4f4a8a4] | 15 | self.pretty_print((self.params.pitchmode, truth, |
---|
[0029638] | 16 | truth - results[0], results[0], |
---|
| 17 | truth - results[1], results[1])) |
---|
| 18 | |
---|
[4f4a8a4] | 19 | def run_bench(self,modes=['schmitt']): |
---|
[0029638] | 20 | self.modes = modes |
---|
| 21 | self.pretty_print(self.titles) |
---|
| 22 | for mode in self.modes: |
---|
[4f4a8a4] | 23 | self.params.pitchmode = mode |
---|
| 24 | self.dir_exec() |
---|
| 25 | self.dir_eval() |
---|
| 26 | self.dir_plot() |
---|
[0029638] | 27 | |
---|
| 28 | if __name__ == "__main__": |
---|
| 29 | import sys |
---|
| 30 | if len(sys.argv) > 1: datapath = sys.argv[1] |
---|
| 31 | else: print "error: a path is required"; sys.exit(1) |
---|
[4f4a8a4] | 32 | if len(sys.argv) > 2: |
---|
| 33 | for each in sys.argv[3:-1]: print each |
---|
| 34 | modes = ['yin', 'schmitt', 'mcomb', 'fcomb'] |
---|
[0029638] | 35 | |
---|
| 36 | benchpitch = benchpitch(datapath) |
---|
| 37 | benchpitch.params = taskparams() |
---|
| 38 | benchpitch.task = taskpitch |
---|
| 39 | |
---|
[4f4a8a4] | 40 | |
---|
[0029638] | 41 | benchpitch.titles = [ 'mode', 'thres', 'avg', 'avgdist' ] |
---|
| 42 | benchpitch.formats = ["%12s" , "| %6s", "| %6s", "| %6s", "| %6s", "| %6s" ] |
---|
| 43 | try: |
---|
| 44 | benchpitch.run_bench(modes=modes) |
---|
| 45 | except KeyboardInterrupt: |
---|
| 46 | print "Interrupted by user" |
---|
| 47 | sys.exit(1) |
---|
| 48 | |
---|
| 49 | sys.exit(0) |
---|