ref: 27f2c08efb7176c7f9417c1be3d17a8d3fe3fd6f
dir: /python/bench-pitch/
#! /usr/bin/python from aubio.bench.node import * from aubio.tasks import * class benchpitch(bench): def file_exec(self,input,output): filetask = self.task(input,params=self.params) computed_data = filetask.compute_all() results = filetask.eval(computed_data) self.results.append(results) truth = filetask.gettruth() #print input, results, results - float(input.split('.')[-2]) self.pretty_print((self.params.pitchmode, truth, truth - results[0], results[0], truth - results[1], results[1])) def run_bench(self,modes=['schmitt']): self.modes = modes self.pretty_print(self.titles) for mode in self.modes: self.params.pitchmode = mode self.dir_exec() self.dir_eval() self.dir_plot() if __name__ == "__main__": import sys if len(sys.argv) > 1: datapath = sys.argv[1] else: print "error: a path is required"; sys.exit(1) if len(sys.argv) > 2: for each in sys.argv[3:-1]: print each modes = ['yin', 'schmitt', 'mcomb', 'fcomb'] benchpitch = benchpitch(datapath) benchpitch.params = taskparams() benchpitch.task = taskpitch benchpitch.titles = [ 'mode', 'thres', 'avg', 'avgdist' ] benchpitch.formats = ["%12s" , "| %6s", "| %6s", "| %6s", "| %6s", "| %6s" ] try: benchpitch.run_bench(modes=modes) except KeyboardInterrupt: print "Interrupted by user" sys.exit(1) sys.exit(0)