ref: ee7b9da61315625e941704bce48a035de4d63618
parent: 6ae3a77f49a78ea78a4dca71a42ac2da5768fa3d
author: Paul Brossier <piem@altern.org>
date: Wed Feb 22 21:28:35 EST 2006
new bench-pitch new bench-pitch
--- a/python/test/bench/pitch/bench-pitch
+++ b/python/test/bench/pitch/bench-pitch
@@ -5,26 +5,84 @@
class benchpitch(bench):
+ """ list of values to store per file """
+ valuenames = ['mode']
+ """ list of lists to store per file """
+ valuelists = ['orig', 'mean', 'med']
+ """ list of values to print per dir """
+ printnames = [ 'mode']
+
+ """ per dir """
+ formats = {'mode': "%12s" , 'thres': "%5.4s",
+ 'dist': "%5.4s", 'prec': "%5.4s", 'recl': "%5.4s",
+ 'Ttrue': "%5.4s", 'Tfp': "%5.4s", 'Tfn': "%5.4s",
+ 'Tm': "%5.4s", 'Td': "%5.4s",
+ 'aTtrue':"%5.4s", 'aTfp': "%5.4s", 'aTfn': "%5.4s",
+ 'aTm': "%5.4s", 'aTd': "%5.4s",
+ 'mean': "%5.40s", 'smean': "%5.40s",
+ 'amean': "%5.40s", 'samean': "%5.40s"}
+
+ def dir_eval(self):
+ """ evaluate statistical data over the directory """
+ v = self.v
+
+ v['mode'] = self.params.pitchmode
+
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()
+ orig,mean,med = filetask.eval(computed_data)
+
+ self.v['orig'].append(orig)
+ self.v['mean'].append(mean)
+ self.v['med'].append(med)
+ #print results#, computed_data
#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']):
+ from os.path import basename
+ d = []
self.modes = modes
- self.pretty_print(self.titles)
+ self.pretty_titles()
for mode in self.modes:
self.params.pitchmode = mode
- self.dir_exec()
- self.dir_eval()
- self.dir_plot()
+ self.dir_eval_print()
+ self.plotpitchtessiture(d,
+ self.v['orig'],
+ self.v['med'],
+ plottitle=self.v['mode'],
+ plotmode='points')
+ #d.append('beta = .25,orig(x) title \"-2 octave\"')
+ d.append('beta = .50,orig(x) title \"-1 octave\"')
+ d.append('beta = 1.0,orig(x) title \"original\"')
+ d.append('beta = 2.0,orig(x) title \"+1 octave\"')
+ title = basename(self.datadir)
+ outplot = "_-_".join(('pitchtessiture',title))
+ for ext in ('ps','png','svg',''):
+ self.plotplotpitchtessiture(d,
+ plottitle=title,
+ outplot=outplot,
+ extension=ext)
+ """
+ Plot functions
+ """
+
+ def plotpitchtessiture(self,d,lx,ly,plottitle="",plotmode='linespoints'):
+ import Gnuplot, Gnuplot.funcutils
+ d.append(Gnuplot.Data(lx, ly, with=plotmode, title="%s" % (plottitle) ))
+
+ def plotplotpitchtessiture(self,d,plottitle='',outplot=0,extension=''):
+ from aubio.gnuplot import gnuplot_create
+ g = gnuplot_create(outplot=outplot,extension=extension)
+ g.title(plottitle)
+ g('orig(x) = beta*x')
+ g.xlabel('original pitch (Hz)')
+ g.ylabel('detected pitch (Hz)')
+ g('set log xy')
+ g.plot(*d)
+
+
if __name__ == "__main__":
import sys
if len(sys.argv) > 1: datapath = sys.argv[1]
@@ -31,15 +89,17 @@
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']
+ modes = ['schmitt', 'yin', 'mcomb', 'fcomb']
+ #modes = ['fcomb']
- benchpitch = benchpitch(datapath)
- benchpitch.params = taskparams()
+ params = taskparams()
+ params.bufsize = 2048
+ params.hopsize = params.bufsize/2
+ benchpitch = benchpitch(datapath,params=params)
benchpitch.task = taskpitch
-
- benchpitch.titles = [ 'mode', 'thres', 'avg', 'avgdist' ]
- benchpitch.formats = ["%12s" , "| %6s", "| %6s", "| %6s", "| %6s", "| %6s" ]
+ #benchpitch.titles = [ 'mode', 'thres', 'avg', 'avgdist' ]
+ #benchpitch.formats = ["%12s" , "| %6s", "| %6s", "| %6s", "| %6s", "| %6s" ]
try:
benchpitch.run_bench(modes=modes)
except KeyboardInterrupt: