Index: python.old/aubio/__init__.py
===================================================================
--- python.old/aubio/__init__.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/__init__.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,28 @@
+"""Copyright (C) 2004 Paul Brossier <piem@altern.org>
+print aubio.__LICENSE__ for the terms of use
+"""
+
+__LICENSE__ = """\
+  Copyright (C) 2004-2009 Paul Brossier <piem@aubio.org>
+
+  This file is part of aubio.
+
+  aubio is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  aubio is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
+"""            
+
+#from aubioclass import *
+#from onsetcompare import *
+#from median import *
+#from noteroc import *
+#from txtfile import *
Index: python.old/aubio/aubioclass.py
===================================================================
--- python.old/aubio/aubioclass.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/aubioclass.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,160 @@
+from aubiowrapper import *
+
+class fvec:
+    def __init__(self,size):
+        self.vec = new_fvec(size)
+    def __call__(self):
+        return self.vec
+    def __del__(self):
+        del_fvec(self())
+    def get(self,pos):
+        return fvec_read_sample(self(),pos)
+    def set(self,value,pos):
+        return fvec_write_sample(self(),value,pos)
+    def data(self):
+        return fvec_get_data(self())
+
+class cvec:
+    def __init__(self,size):
+        self.vec = new_cvec(size)
+    def __call__(self):
+        return self.vec
+    def __del__(self):
+        del_cvec(self())
+    def get(self,pos):
+        return self.get_norm(pos)
+    def set(self,val,pos):
+        self.set_norm(val,pos)
+    def get_norm(self,pos):
+        return cvec_read_norm(self(),pos)
+    def set_norm(self,val,pos):
+        cvec_write_norm(self(),val,pos)
+    def get_phas(self,pos):
+        return cvec_read_phas(self(),pos)
+    def set_phas(self,val,pos):
+        cvec_write_phas(self(),val,pos)
+
+class sndfile:
+    def __init__(self,filename,model=None):
+        if (model!=None):
+            self.file = new_aubio_sndfile_wo(model.file,filename)
+        else:
+            self.file = new_aubio_sndfile_ro(filename)
+        if self.file == None:
+            raise IOError, "failed opening file %s" % filename
+    def __del__(self):
+        if self.file != None: del_aubio_sndfile(self.file)
+    def info(self):
+        aubio_sndfile_info(self.file)
+    def samplerate(self):
+        return aubio_sndfile_samplerate(self.file)
+    def channels(self):
+        return aubio_sndfile_channels(self.file)
+    def read(self,nfram,vecread):
+        return aubio_sndfile_read_mono(self.file,nfram,vecread())
+    def write(self,nfram,vecwrite):
+        return aubio_sndfile_write(self.file,nfram,vecwrite())
+
+class pvoc:
+    def __init__(self,buf,hop):
+        self.pv = new_aubio_pvoc(buf,hop)
+    def __del__(self):
+        del_aubio_pvoc(self.pv)
+    def do(self,tf,tc):
+        aubio_pvoc_do(self.pv,tf(),tc())
+    def rdo(self,tc,tf):
+        aubio_pvoc_rdo(self.pv,tc(),tf())
+
+class onsetdetection:
+    """ class for aubio_specdesc """
+    def __init__(self,mode,buf):
+        self.od = new_aubio_specdesc(mode,buf)
+    def do(self,tc,tf):
+        aubio_specdesc_do(self.od,tc(),tf())
+    def __del__(self):
+        del_aubio_specdesc(self.od)
+
+class peakpick:
+    """ class for aubio_peakpicker """
+    def __init__(self,threshold=0.1):
+        self.pp = new_aubio_peakpicker()
+        self.out = new_fvec(1)
+        aubio_peakpicker_set_threshold (self.pp, threshold)
+    def do(self,fv):
+        aubio_peakpicker_do(self.pp, fv(), self.out)
+        return fvec_read_sample(self.out, 0)
+    def getval(self):
+        return aubio_peakpicker_get_adaptive_threshold(self.pp)
+    def __del__(self):
+        del_aubio_peakpicker(self.pp)
+
+class onsetpick:
+    """ superclass for aubio_pvoc + aubio_specdesc + aubio_peakpicker """
+    def __init__(self,bufsize,hopsize,myvec,threshold,mode='dual',derivate=False,dcthreshold=0):
+        self.myfft    = cvec(bufsize)
+        self.pv       = pvoc(bufsize,hopsize)
+        if mode in ['dual'] :
+                self.myod     = onsetdetection("hfc",bufsize)
+                self.myod2    = onsetdetection("mkl",bufsize)
+                self.myonset  = fvec(1)
+                self.myonset2 = fvec(1)
+        else: 
+                self.myod     = onsetdetection(mode,bufsize)
+                self.myonset  = fvec(1)
+        self.mode     = mode
+        self.pp       = peakpick(float(threshold))
+        self.derivate = derivate
+        self.dcthreshold = dcthreshold 
+        self.oldval   = 0.
+
+    def do(self,myvec): 
+        self.pv.do(myvec,self.myfft)
+        self.myod.do(self.myfft,self.myonset)
+        if self.mode == 'dual':
+           self.myod2.do(self.myfft,self.myonset2)
+           self.myonset.set(self.myonset.get(0)*self.myonset2.get(0),0)
+        if self.derivate:
+           val         = self.myonset.get(0)
+           dval        = val - self.oldval
+           self.oldval = val
+           if dval > 0: self.myonset.set(dval,0)
+           else:  self.myonset.set(0.,0,0)
+        isonset, dval = self.pp.do(self.myonset),self.myonset.get(0)
+        if self.dcthreshold:
+           if dval < self.dcthreshold: isonset = 0 
+        return isonset, dval
+
+class pitch:
+    def __init__(self,mode="mcomb",bufsize=2048,hopsize=1024,
+        samplerate=44100.,omode="freq",tolerance=0.1):
+        self.pitchp = new_aubio_pitch(mode,bufsize,hopsize,
+            samplerate)
+        self.mypitch = fvec(1)
+        aubio_pitch_set_unit(self.pitchp,omode)
+        aubio_pitch_set_tolerance(self.pitchp,tolerance)
+        #self.filt     = filter(srate,"adsgn")
+    def __del__(self):
+        del_aubio_pitch(self.pitchp)
+    def __call__(self,myvec): 
+        aubio_pitch_do(self.pitchp,myvec(), self.mypitch())
+        return self.mypitch.get(0)
+
+class filter:
+    def __init__(self,srate,type=None):
+        if (type=="adsgn"):
+            self.filter = new_aubio_adsgn_filter(srate)
+    def __del__(self):
+        #del_aubio_filter(self.filter)
+        pass
+    def __call__(self,myvec):
+        aubio_filter_do(self.filter,myvec())
+
+class beattracking:
+    """ class for aubio_beattracking """
+    def __init__(self,winlen,channels):
+        self.p = new_aubio_beattracking(winlen,channels)
+    def do(self,dfframe,out):
+        return aubio_beattracking_do(self.p,dfframe(),out())
+    def __del__(self):
+        del_aubio_beattracking(self.p)
+
Index: python.old/aubio/bench/broadcast.py
===================================================================
--- python.old/aubio/bench/broadcast.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/bench/broadcast.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,25 @@
+from config import *
+
+class run_broadcast:
+        def __init__(self,command,*args):
+                for host in REMOTEHOSTS:
+                        command(host,args[0],args[1:])
+
+def remote_sync(host,path='',options=''):
+        optstring = ''
+        for i in options:
+                optstring = "%s %s" % (optstring,i)
+        print RSYNC_CMD,optstring,RSYNC_OPT,' --delete', 
+        print '%s%s%s%s%s' % (path,'/ ',host,':',path)
+
+
+def fetch_results(host,path='',options=''):
+        optstring = ''
+        for i in options:
+                optstring = "%s %s" % (optstring,i)
+        print RSYNC_CMD,optstring,RSYNC_OPT,' --update', 
+        print '%s%s%s%s%s' % (host,':',path,'/ ',path)
+
+def remote_queue(host,command,options=''):
+        print 'oarsub -p "hostname = \'',host,'\'',command
+        
Index: python.old/aubio/bench/config.py
===================================================================
--- python.old/aubio/bench/config.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/bench/config.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,22 @@
+
+filefound = 0
+try:
+        filename = "/etc/aubio-bench.conf"
+        execfile(filename)
+        filefound = 1
+except IOError:
+        print "no system wide configuration file found in", filename
+
+try:
+        import os
+        filename = "%s%s%s" % (os.getenv('HOME'),os.sep,".aubio-bench.conf")
+        execfile(filename)
+        filefound = 1
+except IOError:
+        #print "no user configuration file found in", filename
+	pass
+
+if filefound == 0:
+        import sys
+        print "error: no configuration file found at all"
+        sys.exit(1)
Index: python.old/aubio/bench/node.py
===================================================================
--- python.old/aubio/bench/node.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/bench/node.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,224 @@
+from config import *
+import commands,sys
+import re
+
+def runcommand(cmd,debug=0):
+        if VERBOSE >= VERBOSE_CMD or debug: print cmd
+        if debug: return 
+        status, output = commands.getstatusoutput(cmd)
+        if status == 0 or VERBOSE >= VERBOSE_OUT:
+                output = output.split('\n')
+        if VERBOSE >= VERBOSE_OUT: 
+                for i in output: 
+                        if i: print i
+        if not status == 0: 
+                print 'error:',status,output
+                print 'command returning error was',cmd
+                #sys.exit(1)
+	if output == '' or output == ['']: return
+        return output 
+
+def list_files(datapath,filter='f', maxdepth = -1):
+	if not os.path.exists(datapath):
+		print
+		print "ERR: no directory %s were found" % datapath
+		sys.exit(1)
+	if maxdepth >= 0: maxstring = " -maxdepth %d " % maxdepth	
+	else: maxstring = ""
+        cmd = '%s' * 6 % ('find ',datapath,maxstring,' -type ',filter, "| sort -n")
+        return runcommand(cmd)
+
+def list_wav_files(datapath,maxdepth = -1):
+	return list_files(datapath, filter="f -name '*.wav'",maxdepth = maxdepth)
+
+sndfile_filter = "f -name '*.wav' -o -name '*.aif' -o -name '*.aiff'"
+
+def list_snd_files(datapath,maxdepth = -1):
+	return list_files(datapath, filter=sndfile_filter, 
+		maxdepth = maxdepth)
+
+def list_res_files(datapath,maxdepth = -1):
+	return list_files(datapath, filter="f -name '*.txt'", maxdepth = maxdepth)
+
+def list_dirs(datapath):
+	return list_files(datapath, filter="d")
+
+def mkdir(path):
+        cmd = '%s%s' % ('mkdir -p ',path)
+        return runcommand(cmd)
+
+def act_on_data (action,datapath,respath=None,suffix='.txt',filter='f',sub='\.wav$',**keywords):
+        """ execute action(datafile,resfile) on all files in datapath """
+        dirlist = list_files(datapath,filter=filter)
+        if dirlist == ['']: dirlist = []
+        if respath:
+		respath_in_datapath = re.split(datapath, respath,maxsplit=1)[1:]
+        	if(respath_in_datapath and suffix == ''): 
+                	print 'error: respath in datapath and no suffix used'
+        for i in dirlist:
+                j = re.split(datapath, i,maxsplit=1)[1]
+                j = re.sub(sub,'',j)
+                #j = "%s%s%s"%(respath,j,suffix)
+		if respath:
+			j = "%s%s"%(respath,j)
+			if sub != '':
+				j = re.sub(sub,suffix,j)
+			else:
+				j = "%s%s" % (j,suffix)
+                action(i,j,**keywords)
+
+def act_on_results (action,datapath,respath,filter='d'):
+        """ execute action(respath) an all subdirectories in respath """
+        dirlist = list_files(datapath,filter='d')
+        respath_in_datapath = re.split(datapath, respath,maxsplit=1)[1:]
+        if(respath_in_datapath and not filter == 'd' and suffix == ''): 
+                print 'warning: respath is in datapath'
+        for i in dirlist:
+                s = re.split(datapath, i ,maxsplit=1)[1]
+                action("%s%s%s"%(respath,'/',s))
+
+def act_on_files (action,listfiles,listres=None,suffix='.txt',filter='f',sub='\.wav$',**keywords):
+        """ execute action(respath) an all subdirectories in respath """
+        if listres and len(listfiles) <= len(listres): 
+		for i in range(len(listfiles)):
+			action(listfiles[i],listres[i],**keywords)
+        else:
+		for i in listfiles:
+                	action(i,None,**keywords)
+
+class bench:
+	""" class to run benchmarks on directories """
+	def __init__(self,datadir,resdir=None,checkres=False,checkanno=False,params=[]):
+		from aubio.task.params import taskparams
+		self.datadir = datadir
+		# path to write results path to
+		self.resdir = resdir
+		# list of annotation files
+		self.reslist = []
+		# list used to gather results
+		self.results = []
+		if not params: self.params = taskparams()
+		else:          self.params = params
+		print "Checking data directory", self.datadir
+		self.checkdata()
+		if checkanno: self.checkanno()
+		if checkres: self.checkres()
+	
+	def checkdata(self):
+		if os.path.isfile(self.datadir):
+			self.dirlist = os.path.dirname(self.datadir)
+		elif os.path.isdir(self.datadir):
+			self.dirlist = list_dirs(self.datadir)
+		# allow dir* matching through find commands?
+		else:
+			print "ERR: path not understood"
+			sys.exit(1)
+		print "Listing directories in data directory",
+		if self.dirlist:
+			print " (%d elements)" % len(self.dirlist)
+		else:
+			print " (0 elements)"
+			print "ERR: no directory %s were found" % self.datadir
+			sys.exit(1)
+		print "Listing sound files in data directory",
+		self.sndlist = list_snd_files(self.datadir)
+		if self.sndlist:
+			print " (%d elements)" % len(self.sndlist)
+		else:
+			print " (0 elements)"
+			print "ERR: no sound files were found in", self.datadir
+			sys.exit(1)
+	
+	def checkanno(self):
+		print "Listing annotations in data directory",
+		self.reslist = list_res_files(self.datadir)
+		print " (%d elements)" % len(self.reslist)
+		#for each in self.reslist: print each
+		if not self.reslist or len(self.reslist) < len (self.sndlist):
+			print "ERR: not enough annotations"
+			return -1
+		else:
+			print "Found enough annotations"
+	
+	def checkres(self):
+		print "Creating results directory"
+		act_on_results(mkdir,self.datadir,self.resdir,filter='d')
+
+	def pretty_print(self,sep='|'):
+		for i in self.printnames:
+			print self.formats[i] % self.v[i], sep,
+		print
+
+	def pretty_titles(self,sep='|'):
+		for i in self.printnames:
+			print self.formats[i] % i, sep,
+		print
+
+	def dir_exec(self):
+		""" run file_exec on every input file """
+		self.l , self.labs = [], [] 
+		self.v = {}
+		for i in self.valuenames:
+			self.v[i] = [] 
+		for i in self.valuelists:
+			self.v[i] = [] 
+		act_on_files(self.file_exec,self.sndlist,self.reslist, \
+			suffix='',filter=sndfile_filter)
+
+	def dir_eval(self):
+		pass
+
+	def file_gettruth(self,input):
+		""" get ground truth filenames """
+		from os.path import isfile
+		ftrulist = []
+		# search for match as filetask.input,".txt" 
+		ftru = '.'.join(input.split('.')[:-1])
+		ftru = '.'.join((ftru,'txt'))
+		if isfile(ftru):
+			ftrulist.append(ftru)
+		else:
+			# search for matches for filetask.input in the list of results
+			for i in range(len(self.reslist)):
+				check = '.'.join(self.reslist[i].split('.')[:-1])
+				check = '_'.join(check.split('_')[:-1])
+				if check == '.'.join(input.split('.')[:-1]):
+					ftrulist.append(self.reslist[i])
+		return ftrulist
+
+	def file_exec(self,input,output):
+		""" create filetask, extract data, evaluate """
+		filetask = self.task(input,params=self.params)
+		computed_data = filetask.compute_all()
+		ftrulist = self.file_gettruth(filetask.input)
+		for i in ftrulist:
+			filetask.eval(computed_data,i,mode='rocloc',vmode='')
+			""" append filetask.v to self.v """
+			for i in self.valuenames:
+				self.v[i].append(filetask.v[i])
+			for j in self.valuelists:
+				if filetask.v[j]:
+					for i in range(len(filetask.v[j])):
+						self.v[j].append(filetask.v[j][i])
+	
+	def file_eval(self):
+		pass
+	
+	def file_plot(self):
+		pass
+
+	def dir_plot(self):
+		pass
+	
+	def run_bench(self):
+		for mode in self.modes:
+			self.params.mode = mode
+			self.dir_exec()
+			self.dir_eval()
+			self.dir_plot()
+
+	def dir_eval_print(self):
+		self.dir_exec()
+		self.dir_eval()
+		self.pretty_print()
+
Index: python.old/aubio/bench/onset.py
===================================================================
--- python.old/aubio/bench/onset.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/bench/onset.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,303 @@
+
+from aubio.bench.node import *
+from os.path import dirname,basename
+
+def mmean(l):
+	return sum(l)/max(float(len(l)),1)
+
+def stdev(l):
+	smean = 0
+	if not len(l): return smean
+	lmean = mmean(l)
+	for i in l:
+		smean += (i-lmean)**2
+	smean *= 1. / len(l)
+	return smean**.5
+
+class benchonset(bench):
+
+	""" list of values to store per file """
+	valuenames = ['orig','missed','Tm','expc','bad','Td']
+	""" list of lists to store per file """
+	valuelists = ['l','labs']
+	""" list of values to print per dir """
+	printnames = [ 'mode', 'thres', 'dist', 'prec', 'recl',
+		'GD', 'FP', 
+		'Torig', 'Ttrue', 'Tfp',  'Tfn',  'TTm',   'TTd',
+		'aTtrue', 'aTfp', 'aTfn', 'aTm',  'aTd',  
+		'mean', 'smean',  'amean', 'samean']
+
+	""" per dir """
+	formats = {'mode': "%12s" , 'thres': "%5.4s", 
+		'dist':  "%5.4s", 'prec': "%5.4s", 'recl':  "%5.4s",
+		'Torig': "%5.4s", 'Ttrue': "%5.4s", 'Tfp':   "%5.4s", 'Tfn':   "%5.4s", 
+		'TTm':    "%5.4s", 'TTd':    "%5.4s",
+		'aTtrue':"%5.4s", 'aTfp':  "%5.4s", 'aTfn':  "%5.4s", 
+		'aTm':   "%5.4s", 'aTd':   "%5.4s",
+		'mean':  "%5.6s", 'smean': "%5.6s", 
+		'amean':  "%5.6s", 'samean': "%5.6s", 
+		"GD":     "%5.4s", "FP":     "%5.4s",
+		"GDm":     "%5.4s", "FPd":     "%5.4s",
+		"bufsize": "%5.4s", "hopsize": "%5.4s",
+		"time":   "%5.4s"}
+
+	def dir_eval(self):
+		""" evaluate statistical data over the directory """
+		v = self.v
+
+		v['mode']      = self.params.onsetmode
+		v['thres']     = self.params.threshold 
+		v['bufsize']   = self.params.bufsize
+		v['hopsize']   = self.params.hopsize
+		v['silence']   = self.params.silence
+		v['mintol']   = self.params.mintol
+
+		v['Torig']     = sum(v['orig'])
+		v['TTm']       = sum(v['Tm'])
+		v['TTd']       = sum(v['Td'])
+		v['Texpc']     = sum(v['expc'])
+		v['Tbad']      = sum(v['bad'])
+		v['Tmissed']   = sum(v['missed'])
+		v['aTm']       = mmean(v['Tm'])
+		v['aTd']       = mmean(v['Td'])
+
+		v['mean']      = mmean(v['l'])
+		v['smean']     = stdev(v['l'])
+
+		v['amean']     = mmean(v['labs'])
+		v['samean']    = stdev(v['labs'])
+		
+		# old type calculations
+		# good detection rate 
+		v['GD']  = 100.*(v['Torig']-v['Tmissed']-v['TTm'])/v['Torig']
+		# false positive rate
+		v['FP']  = 100.*(v['Tbad']+v['TTd'])/v['Torig']
+		# good detection counting merged detections as good
+		v['GDm'] = 100.*(v['Torig']-v['Tmissed'])/v['Torig'] 
+		# false positives counting doubled as good
+		v['FPd'] = 100.*v['Tbad']/v['Torig']                
+		
+		# mirex type annotations
+		totaltrue = v['Texpc']-v['Tbad']-v['TTd']
+		totalfp = v['Tbad']+v['TTd']
+		totalfn = v['Tmissed']+v['TTm']
+		self.v['Ttrue']     = totaltrue
+		self.v['Tfp']       = totalfp
+		self.v['Tfn']       = totalfn
+		# average over the number of annotation files
+		N = float(len(self.reslist))
+		self.v['aTtrue']    = totaltrue/N
+		self.v['aTfp']      = totalfp/N
+		self.v['aTfn']      = totalfn/N
+
+		# F-measure
+		self.P = 100.*float(totaltrue)/max(totaltrue + totalfp,1)
+		self.R = 100.*float(totaltrue)/max(totaltrue + totalfn,1)
+		#if self.R < 0: self.R = 0
+		self.F = 2.* self.P*self.R / max(float(self.P+self.R),1)
+		self.v['dist']      = self.F
+		self.v['prec']      = self.P
+		self.v['recl']      = self.R
+
+
+	"""
+	Plot functions 
+	"""
+
+	def plotroc(self,d,plottitle=""):
+		import Gnuplot, Gnuplot.funcutils
+		gd = []
+		fp = []
+		for i in self.vlist:
+			gd.append(i['GD']) 
+			fp.append(i['FP']) 
+		d.append(Gnuplot.Data(fp, gd, with_='linespoints', 
+			title="%s %s" % (plottitle,i['mode']) ))
+
+	def plotplotroc(self,d,outplot=0,extension='ps'):
+		import Gnuplot, Gnuplot.funcutils
+		from sys import exit
+		g = Gnuplot.Gnuplot(debug=0, persist=1)
+		if outplot:
+			if   extension == 'ps':  ext, extension = '.ps' , 'postscript'
+			elif extension == 'png': ext, extension = '.png', 'png'
+			elif extension == 'svg': ext, extension = '.svg', 'svg'
+			else: exit("ERR: unknown plot extension")
+			g('set terminal %s' % extension)
+			g('set output \'roc-%s%s\'' % (outplot,ext))
+		xmax = 30 #max(fp)
+		ymin = 50 
+		g('set xrange [0:%f]' % xmax)
+		g('set yrange [%f:100]' % ymin)
+		# grid set
+		g('set grid')
+		g('set xtics 0,5,%f' % xmax)
+		g('set ytics %f,5,100' % ymin)
+		g('set key 27,65')
+		#g('set format \"%g\"')
+		g.title(basename(self.datadir))
+		g.xlabel('false positives (%)')
+		g.ylabel('correct detections (%)')
+		g.plot(*d)
+
+	def plotpr(self,d,plottitle=""):
+		import Gnuplot, Gnuplot.funcutils
+		x = []
+		y = []
+		for i in self.vlist:
+			x.append(i['prec']) 
+			y.append(i['recl']) 
+		d.append(Gnuplot.Data(x, y, with_='linespoints', 
+			title="%s %s" % (plottitle,i['mode']) ))
+
+	def plotplotpr(self,d,outplot=0,extension='ps'):
+		import Gnuplot, Gnuplot.funcutils
+		from sys import exit
+		g = Gnuplot.Gnuplot(debug=0, persist=1)
+		if outplot:
+			if   extension == 'ps':  ext, extension = '.ps' , 'postscript'
+			elif extension == 'png': ext, extension = '.png', 'png'
+			elif extension == 'svg': ext, extension = '.svg', 'svg'
+			else: exit("ERR: unknown plot extension")
+			g('set terminal %s' % extension)
+			g('set output \'pr-%s%s\'' % (outplot,ext))
+		g.title(basename(self.datadir))
+		g.xlabel('Recall (%)')
+		g.ylabel('Precision (%)')
+		g.plot(*d)
+
+	def plotfmeas(self,d,plottitle=""):
+		import Gnuplot, Gnuplot.funcutils
+		x,y = [],[]
+		for i in self.vlist:
+			x.append(i['thres']) 
+			y.append(i['dist']) 
+		d.append(Gnuplot.Data(x, y, with_='linespoints', 
+			title="%s %s" % (plottitle,i['mode']) ))
+
+	def plotplotfmeas(self,d,outplot="",extension='ps', title="F-measure"):
+		import Gnuplot, Gnuplot.funcutils
+		from sys import exit
+		g = Gnuplot.Gnuplot(debug=0, persist=1)
+		if outplot:
+			if   extension == 'ps':  terminal = 'postscript'
+			elif extension == 'png': terminal = 'png'
+			elif extension == 'svg': terminal = 'svg'
+			else: exit("ERR: unknown plot extension")
+			g('set terminal %s' % terminal)
+			g('set output \'fmeas-%s.%s\'' % (outplot,extension))
+		g.xlabel('threshold \\delta')
+		g.ylabel('F-measure (%)')
+		g('set xrange [0:1.2]')
+		g('set yrange [0:100]')
+		g.title(basename(self.datadir))
+		# grid set
+		#g('set grid')
+		#g('set xtics 0,5,%f' % xmax)
+		#g('set ytics %f,5,100' % ymin)
+		#g('set key 27,65')
+		#g('set format \"%g\"')
+		g.plot(*d)
+
+	def plotfmeasvar(self,d,var,plottitle=""):
+		import Gnuplot, Gnuplot.funcutils
+		x,y = [],[]
+		for i in self.vlist:
+			x.append(i[var]) 
+			y.append(i['dist']) 
+		d.append(Gnuplot.Data(x, y, with_='linespoints', 
+			title="%s %s" % (plottitle,i['mode']) ))
+	
+	def plotplotfmeasvar(self,d,var,outplot="",extension='ps', title="F-measure"):
+		import Gnuplot, Gnuplot.funcutils
+		from sys import exit
+		g = Gnuplot.Gnuplot(debug=0, persist=1)
+		if outplot:
+			if   extension == 'ps':  terminal = 'postscript'
+			elif extension == 'png': terminal = 'png'
+			elif extension == 'svg': terminal = 'svg'
+			else: exit("ERR: unknown plot extension")
+			g('set terminal %s' % terminal)
+			g('set output \'fmeas-%s.%s\'' % (outplot,extension))
+		g.xlabel(var)
+		g.ylabel('F-measure (%)')
+		#g('set xrange [0:1.2]')
+		g('set yrange [0:100]')
+		g.title(basename(self.datadir))
+		g.plot(*d)
+
+	def plotdiffs(self,d,plottitle=""):
+		import Gnuplot, Gnuplot.funcutils
+		v = self.v
+		l = v['l']
+		mean   = v['mean']
+		smean  = v['smean']
+		amean  = v['amean']
+		samean = v['samean']
+		val = []
+		per = [0] * 100
+		for i in range(0,100):
+			val.append(i*.001-.05)
+			for j in l: 
+				if abs(j-val[i]) <= 0.001:
+					per[i] += 1
+		total = v['Torig']
+		for i in range(len(per)): per[i] /= total/100.
+
+		d.append(Gnuplot.Data(val, per, with_='fsteps', 
+			title="%s %s" % (plottitle,v['mode']) ))
+		#d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (mean,smean))
+		#d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (amean,samean))
+
+
+	def plotplotdiffs(self,d,outplot=0,extension='ps'):
+		import Gnuplot, Gnuplot.funcutils
+		from sys import exit
+		g = Gnuplot.Gnuplot(debug=0, persist=1)
+		if outplot:
+			if   extension == 'ps':  ext, extension = '.ps' , 'postscript'
+			elif extension == 'png': ext, extension = '.png', 'png'
+			elif extension == 'svg': ext, extension = '.svg', 'svg'
+			else: exit("ERR: unknown plot extension")
+			g('set terminal %s' % extension)
+			g('set output \'diffhist-%s%s\'' % (outplot,ext))
+		g('eps(x) = 1./(sigma*(2.*3.14159)**.5) * exp ( - ( x - mean ) ** 2. / ( 2. * sigma ** 2. ))')
+		g.title(basename(self.datadir))
+		g.xlabel('delay to hand-labelled onset (s)')
+		g.ylabel('% number of correct detections / ms ')
+		g('set xrange [-0.05:0.05]')
+		g('set yrange [0:20]')
+		g.plot(*d)
+
+
+	def plothistcat(self,d,plottitle=""):
+		import Gnuplot, Gnuplot.funcutils
+		total = v['Torig']
+		for i in range(len(per)): per[i] /= total/100.
+
+		d.append(Gnuplot.Data(val, per, with_='fsteps', 
+			title="%s %s" % (plottitle,v['mode']) ))
+		#d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (mean,smean))
+		#d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (amean,samean))
+
+
+	def plotplothistcat(self,d,outplot=0,extension='ps'):
+		import Gnuplot, Gnuplot.funcutils
+		from sys import exit
+		g = Gnuplot.Gnuplot(debug=0, persist=1)
+		if outplot:
+			if   extension == 'ps':  ext, extension = '.ps' , 'postscript'
+			elif extension == 'png': ext, extension = '.png', 'png'
+			elif extension == 'svg': ext, extension = '.svg', 'svg'
+			else: exit("ERR: unknown plot extension")
+			g('set terminal %s' % extension)
+			g('set output \'diffhist-%s%s\'' % (outplot,ext))
+		g('eps(x) = 1./(sigma*(2.*3.14159)**.5) * exp ( - ( x - mean ) ** 2. / ( 2. * sigma ** 2. ))')
+		g.title(basename(self.datadir))
+		g.xlabel('delay to hand-labelled onset (s)')
+		g.ylabel('% number of correct detections / ms ')
+		g('set xrange [-0.05:0.05]')
+		g('set yrange [0:20]')
+		g.plot(*d)
+
+
Index: python.old/aubio/gnuplot.py
===================================================================
--- python.old/aubio/gnuplot.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/gnuplot.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,222 @@
+"""Copyright (C) 2004 Paul Brossier <piem@altern.org>
+print aubio.__LICENSE__ for the terms of use
+"""
+
+__LICENSE__ = """\
+  Copyright (C) 2004-2009 Paul Brossier <piem@aubio.org>
+
+  This file is part of aubio.
+
+  aubio is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  aubio is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
+"""
+
+
+def audio_to_array(filename):
+	import aubio.aubioclass
+	from numpy import arange
+	hopsize  = 2048
+	filei    = aubio.aubioclass.sndfile(filename)
+	framestep = 1/(filei.samplerate()+0.)
+	channels = filei.channels()
+	myvec    = aubio.aubioclass.fvec(hopsize,channels)
+	data = []
+	readsize = hopsize
+	while (readsize==hopsize):
+		readsize = filei.read(hopsize,myvec)
+		#for i in range(channels):
+		i = 0
+		curpos = 0
+		while (curpos < readsize):
+			data.append(myvec.get(curpos,i))
+			curpos+=1
+	time = arange(len(data))*framestep
+	return time,data
+
+def plot_audio(filenames, g, options):
+	todraw = len(filenames)
+	xorig = 0.
+	xratio = 1./todraw
+	g('set multiplot;')
+	while (len(filenames)):
+		time,data = audio_to_array(filenames.pop(0))
+		if todraw==1:
+			if max(time) < 1.:
+				time = [t*1000. for t in time]
+				g.xlabel('Time (ms)')
+			else:
+				g.xlabel('Time (s)')
+			g.ylabel('Amplitude')
+		curplot = make_audio_plot(time,data)
+		g('set size %f,%f;' % (options.xsize*xratio,options.ysize) )
+		g('set origin %f,0.;' % (xorig) )
+		g('set style data lines; \
+			set yrange [-1.:1.]; \
+			set xrange [0:%f]' % time[-1]) 
+		g.plot(curplot)
+		xorig += options.xsize*xratio 
+	g('unset multiplot;')
+
+def audio_to_spec(filename,minf = 0, maxf = 0, lowthres = -20., 
+		bufsize= 8192, hopsize = 1024):
+	from aubioclass import fvec,cvec,pvoc,sndfile
+	from math import log10
+	filei     = sndfile(filename)
+	srate     = float(filei.samplerate())
+	framestep = hopsize/srate
+	freqstep  = srate/bufsize
+	channels  = filei.channels()
+	myvec = fvec(hopsize,channels)
+	myfft = cvec(bufsize,channels)
+	pv    = pvoc(bufsize,hopsize,channels)
+	data,time,freq = [],[],[]
+
+	if maxf == 0.: maxf = bufsize/2
+	else: maxf = int(maxf/freqstep)
+	if minf: minf = int(minf/freqstep)
+	else: minf = 0 
+
+	for f in range(minf,maxf):
+		freq.append(f*freqstep)
+	readsize = hopsize
+	frameread = 0
+	while (readsize==hopsize):
+		readsize = filei.read(hopsize,myvec)
+		pv.do(myvec,myfft)
+		frame = []
+		i = 0 #for i in range(channels):
+		curpos = minf 
+		while (curpos < maxf):
+			frame.append(max(lowthres,20.*log10(myfft.get(curpos,i)**2+0.00001)))
+			curpos+=1
+		time.append(frameread*framestep)
+		data.append(frame)
+		frameread += 1
+	# crop data if unfinished frames
+	if len(data[-1]) != len(data[0]):
+		data = data[0:-2]
+		time = time[0:-2]
+	# verify size consistency
+	assert len(data) == len(time)
+	assert len(data[0]) == len(freq)
+	return data,time,freq
+
+def plot_spec(filename, g, options):
+	import Gnuplot
+	data,time,freq = audio_to_spec(filename,
+    minf=options.minf,maxf=options.maxf,
+    bufsize=options.bufsize,hopsize=options.hopsize)
+	xorig = 0.
+	if max(time) < 1.:
+		time = [t*1000. for t in time]
+		g.xlabel('Time (ms)')
+	else:
+		g.xlabel('Time (s)')
+	if options.xsize < 0.5 and not options.log and max(time) > 1.:
+		freq = [f/1000. for f in freq]
+		options.minf /= 1000.
+		options.maxf /= 1000.
+		g.ylabel('Frequency (kHz)')
+	else:
+		g.ylabel('Frequency (Hz)')
+	g('set pm3d map')
+	g('set palette rgbformulae -25,-24,-32')
+	g('set cbtics 20')
+	#g('set colorbox horizontal')
+	g('set xrange [0.:%f]' % time[-1]) 
+	if options.log:
+		g('set log y')
+		g('set yrange [%f:%f]' % (max(10,options.minf),options.maxf))
+	else:
+		g('set yrange [%f:%f]' % (options.minf,options.maxf))
+	g.splot(Gnuplot.GridData(data,time,freq, binary=1))
+	#xorig += 1./todraw
+
+def downsample_audio(time,data,maxpoints=10000):
+  """ resample audio data to last only maxpoints """
+  from numpy import array, resize
+  length = len(time)
+  downsample = length/maxpoints
+  if downsample == 0: downsample = 1
+  x = resize(array(time),length)[0:-1:downsample]
+  y = resize(array(data),length)[0:-1:downsample]
+  return x,y
+
+def make_audio_plot(time,data,maxpoints=10000):
+  """ create gnuplot plot from an audio file """
+  import Gnuplot, Gnuplot.funcutils
+  x,y = downsample_audio(time,data,maxpoints=maxpoints)
+  return Gnuplot.Data(x,y,with_='lines')
+
+def make_audio_envelope(time,data,maxpoints=10000):
+  """ create gnuplot plot from an audio file """
+  from numpy import array
+  import Gnuplot, Gnuplot.funcutils
+  bufsize = 500
+  x = [i.mean() for i in resize(array(time), (len(time)/bufsize,bufsize))] 
+  y = [i.mean() for i in resize(array(data), (len(time)/bufsize,bufsize))] 
+  x,y = downsample_audio(x,y,maxpoints=maxpoints)
+  return Gnuplot.Data(x,y,with_='lines')
+
+def gnuplot_addargs(parser):
+  """ add common gnuplot argument to OptParser object """
+  parser.add_option("-x","--xsize",
+          action="store", dest="xsize", default=1., 
+          type='float',help="define xsize for plot")
+  parser.add_option("-y","--ysize",
+          action="store", dest="ysize", default=1., 
+          type='float',help="define ysize for plot")
+  parser.add_option("--debug",
+          action="store_true", dest="debug", default=False, 
+          help="use gnuplot debug mode")
+  parser.add_option("--persist",
+          action="store_false", dest="persist", default=True, 
+          help="do not use gnuplot persistant mode")
+  parser.add_option("--lmargin",
+          action="store", dest="lmargin", default=None, 
+          type='int',help="define left margin for plot")
+  parser.add_option("--rmargin",
+          action="store", dest="rmargin", default=None, 
+          type='int',help="define right margin for plot")
+  parser.add_option("--bmargin",
+          action="store", dest="bmargin", default=None, 
+          type='int',help="define bottom margin for plot")
+  parser.add_option("--tmargin",
+          action="store", dest="tmargin", default=None, 
+          type='int',help="define top margin for plot")
+  parser.add_option("-O","--outplot",
+          action="store", dest="outplot", default=None, 
+          help="save plot to output.{ps,png}")
+
+def gnuplot_create(outplot='',extension='', options=None):
+  import Gnuplot
+  if options:
+    g = Gnuplot.Gnuplot(debug=options.debug, persist=options.persist)
+  else:
+    g = Gnuplot.Gnuplot(persist=1)
+  if not extension or not outplot: return g
+  if   extension == 'ps':  ext, extension = '.ps' , 'postscript'
+  elif extension == 'eps': ext, extension = '.eps' , 'postscript enhanced'
+  elif extension == 'epsc': ext, extension = '.eps' , 'postscript enhanced color'
+  elif extension == 'png': ext, extension = '.png', 'png'
+  elif extension == 'svg': ext, extension = '.svg', 'svg'
+  else: exit("ERR: unknown plot extension")
+  g('set terminal %s' % extension)
+  if options and options.lmargin: g('set lmargin %i' % options.lmargin)
+  if options and options.rmargin: g('set rmargin %i' % options.rmargin)
+  if options and options.bmargin: g('set bmargin %i' % options.bmargin)
+  if options and options.tmargin: g('set tmargin %i' % options.tmargin)
+  if outplot != "stdout":
+    g('set output \'%s%s\'' % (outplot,ext))
+  if options: g('set size %f,%f' % (options.xsize, options.ysize))
+  return g
Index: python.old/aubio/median.py
===================================================================
--- python.old/aubio/median.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/median.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,69 @@
+"""Copyright (C) 2004 Paul Brossier <piem@altern.org>
+print aubio.__LICENSE__ for the terms of use
+"""
+
+__LICENSE__ = """\
+  Copyright (C) 2004-2009 Paul Brossier <piem@aubio.org>
+
+  This file is part of aubio.
+
+  aubio is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  aubio is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
+"""            
+
+""" 
+original author Tim Peters
+modified by Paul Brossier <piem@altern.org>
+inspired from http://www.ics.uci.edu/~eppstein/161/python/peters-selection.py
+"""
+
+def short_find(a, rank):
+    """ find the rank-th value in sorted a """
+    # copy to b before sorting
+    b = a[:]
+    b.sort()
+    return b[rank - 1]
+
+def percental(a, rank):
+    """ Find the rank'th-smallest value in a, in worst-case linear time. """
+    n = len(a)
+    assert 1 <= rank <= n
+    if n <= 7:
+        return short_find(a, rank)
+
+    ## Find median of median-of-7's.
+    ##medians = [short_find(a[i : i+7], 4) for i in xrange(0, n-6, 7)]
+    #median = find(medians, (len(medians) + 1) // 2)
+    
+    # modified to Find median
+    median = short_find([a[0], a[-1], a[n//2]], 2)
+
+    # Partition around the median.
+    # a[:i]   <= median
+    # a[j+1:] >= median
+    i, j = 0, n-1
+    while i <= j:
+        while a[i] < median:
+            i += 1
+        while a[j] > median:
+            j -= 1
+        if i <= j:
+            a[i], a[j] = a[j], a[i]
+            i += 1
+            j -= 1
+
+    if rank <= i:
+        return percental(a[:i], rank)
+    else:
+        return percental(a[i:], rank - i)
+
Index: python.old/aubio/onsetcompare.py
===================================================================
--- python.old/aubio/onsetcompare.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/onsetcompare.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,143 @@
+"""Copyright (C) 2004 Paul Brossier <piem@altern.org>
+print aubio.__LICENSE__ for the terms of use
+"""
+
+__LICENSE__ = """\
+  Copyright (C) 2004-2009 Paul Brossier <piem@aubio.org>
+
+  This file is part of aubio.
+
+  aubio is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  aubio is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
+"""            
+
+""" this file contains routines to compare two lists of onsets or notes.
+it somewhat implements the Receiver Operating Statistic (ROC).
+see http://en.wikipedia.org/wiki/Receiver_operating_characteristic
+"""
+
+def onset_roc(ltru, lexp, eps):
+    """ compute differences between two lists 
+          orig = hits + missed + merged 
+          expc = hits + bad + doubled
+        returns orig, missed, merged, expc, bad, doubled 
+    """
+    orig, expc = len(ltru), len(lexp)
+    # if lexp is empty
+    if expc == 0 : return orig,orig,0,0,0,0
+    missed, bad, doubled, merged = 0, 0, 0, 0
+    # find missed and doubled ones first
+    for x in ltru:
+        correspond = 0
+        for y in lexp:
+            if abs(x-y) <= eps:    correspond += 1
+        if correspond == 0:        missed += 1
+        elif correspond > 1:       doubled += correspond - 1 
+    # then look for bad and merged ones
+    for y in lexp:
+        correspond = 0
+        for x in ltru:
+            if abs(x-y) <= eps:    correspond += 1
+        if correspond == 0:        bad += 1
+        elif correspond > 1:       merged += correspond - 1
+    # check consistancy of the results
+    assert ( orig - missed - merged == expc - bad - doubled)
+    return orig, missed, merged, expc, bad, doubled 
+
+def onset_diffs(ltru, lexp, eps):
+    """ compute differences between two lists 
+          orig = hits + missed + merged 
+          expc = hits + bad + doubled
+        returns orig, missed, merged, expc, bad, doubled 
+    """
+    orig, expc = len(ltru), len(lexp)
+    # if lexp is empty
+    l = []
+    if expc == 0 : return l 
+    # find missed and doubled ones first
+    for x in ltru:
+        correspond = 0
+        for y in lexp:
+            if abs(x-y) <= eps:    l.append(y-x) 
+    # return list of diffs
+    return l 
+
+def onset_rocloc(ltru, lexp, eps):
+    """ compute differences between two lists 
+          orig = hits + missed + merged 
+          expc = hits + bad + doubled
+        returns orig, missed, merged, expc, bad, doubled 
+    """
+    orig, expc = len(ltru), len(lexp)
+    l = []
+    labs = []
+    mean = 0
+    # if lexp is empty
+    if expc == 0 : return orig,orig,0,0,0,0,l,mean
+    missed, bad, doubled, merged = 0, 0, 0, 0
+    # find missed and doubled ones first
+    for x in ltru:
+        correspond = 0
+        for y in lexp:
+            if abs(x-y) <= eps:    correspond += 1
+        if correspond == 0:        missed += 1
+        elif correspond > 1:       doubled += correspond - 1 
+    # then look for bad and merged ones
+    for y in lexp:
+        correspond = 0
+        for x in ltru:
+            if abs(x-y) <= eps:    
+	    	correspond += 1
+            	l.append(y-x) 
+            	labs.append(abs(y-x))
+        if correspond == 0:        bad += 1
+        elif correspond > 1:       merged += correspond - 1
+    # check consistancy of the results
+    assert ( orig - missed - merged == expc - bad - doubled)
+    return orig, missed, merged, expc, bad, doubled, l, labs
+
+def notes_roc (la, lb, eps):
+    from numpy import transpose, add, resize 
+    """ creates a matrix of size len(la)*len(lb) then look for hit and miss
+    in it within eps tolerance windows """
+    gdn,fpw,fpg,fpa,fdo,fdp = 0,0,0,0,0,0
+    m = len(la)
+    n = len(lb)
+    x =           resize(la[:][0],(n,m))
+    y = transpose(resize(lb[:][0],(m,n)))
+    teps =  (abs(x-y) <= eps[0]) 
+    x =           resize(la[:][1],(n,m))
+    y = transpose(resize(lb[:][1],(m,n)))
+    tpitc = (abs(x-y) <= eps[1]) 
+    res = teps * tpitc
+    res = add.reduce(res,axis=0)
+    for i in range(len(res)) :
+        if res[i] > 1:
+            gdn+=1
+            fdo+=res[i]-1
+        elif res [i] == 1:
+            gdn+=1
+    fpa = n - gdn - fpa
+    return gdn,fpw,fpg,fpa,fdo,fdp
+
+def load_onsets(filename) :
+    """ load onsets targets / candidates files in arrays """
+    l = [];
+    
+    f = open(filename,'ro')
+    while 1:
+        line = f.readline().split()
+        if not line : break
+        l.append(float(line[0]))
+    
+    return l
Index: python.old/aubio/plot/keyboard.py
===================================================================
--- python.old/aubio/plot/keyboard.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/plot/keyboard.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,46 @@
+
+def draw_keyboard(firstnote = 21, lastnote = 108, y0 = 0, y1 = 1):
+  import Gnuplot
+  octaves = 10
+
+  # build template of white notes
+  scalew  = 12/7.
+  xw_temp = [i*scalew for i in range(0,7)]
+  # build template of black notes
+  scaleb  = 6/7.
+  xb_temp = [i*scaleb for i in [1,3,7,9,11]]
+
+  xb,xw = [],[]
+  for octave in range(octaves-1): 
+    for i in xb_temp:
+      curnote = i+12*octave
+      if  curnote > firstnote-1 and curnote < lastnote+1:
+        xb = xb + [curnote] 
+  for octave in range(octaves-1): 
+    for i in xw_temp:
+      curnote = i+12*octave
+      if  curnote > firstnote-1 and curnote < lastnote+1:
+        xw = xw + [curnote]
+
+  xwdelta = [1/2. * scalew for i in range(len(xw))]
+  yw      = [y0+(y1-y0)*1/2. for i in range(len(xw))]
+  ywdelta = [(y1-y0)*1/2. for i in range(len(xw))]
+
+  xbdelta = [2/3. * scaleb for i in range(len(xb))]
+  yb      = [y0+(y1-y0)*2/3. for i in range(len(xb))]
+  ybdelta = [(y1-y0)*1/3. for i in range(len(xb))]
+
+  whites  = Gnuplot.Data(xw,yw,xwdelta,ywdelta,with_ = 'boxxyerrorbars')
+  blacks  = Gnuplot.Data(xb,yb,xbdelta,ybdelta,with_ = 'boxxyerrorbars fill solid')
+
+  return blacks,whites
+
+if __name__ == '__main__':
+  from aubio.gnuplot import gnuplot_create
+  blacks,whites = draw_keyboard(firstnote = 21, lastnote = 108)
+  g = gnuplot_create('','')
+  #g('set style fill solid .5')
+  #g('set xrange [60-.5:72+.5]')
+  #g('set yrange [-0.1:1.1]')
+
+  g.plot(whites,blacks)
Index: python.old/aubio/plot/notes.py
===================================================================
--- python.old/aubio/plot/notes.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/plot/notes.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,90 @@
+__LICENSE__ = """\
+  Copyright (C) 2004-2009 Paul Brossier <piem@aubio.org>
+
+  This file is part of aubio.
+
+  aubio is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  aubio is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
+"""
+
+def plotnote(la,title=None) :
+	if la[0,:].size() == 3:
+	        d = plotnote_withends(la, plot_title=title)
+	else: 
+	    # scale data if in freq (for REF.txt files)
+	    if max(la[:,1] > 128 ):
+	        print "scaling frequency data to midi range"
+	        la[:,1] /= 6.875
+	        la[:,1] = log(la[:,1])/0.6931
+	        la[:,1] *= 12
+	        la[:,1] -= 3
+	    d = plotnote_withoutends(la, plot_title=title)
+	return d
+
+def plotnote_multi(lalist,title=None,fileout=None) :
+	d=list()
+	for i in range(len(lalist)):
+	    d.append(plotnote(lalist[i], title=title))
+	return d
+       
+
+def plotnote_withends(la,plot_title=None) :
+	from numpy import array
+	import Gnuplot, Gnuplot.funcutils
+	d=[]
+	x_widths = array(la[:,1]-la[:,0])/2.
+	d.append(Gnuplot.Data(
+	        la[:,0]+x_widths,               # x centers
+	        la[:,2],                        # y centers
+	        x_widths,                       # x errors
+	        __notesheight*ones(len(la)),    # y errors
+	        title=plot_title,with_=('boxxyerrorbars fs 3')))
+	return d
+
+
+def plotnote_withoutends(la,plot_title=None) :
+        """ bug: fails drawing last note """
+	from numpy import array
+	import Gnuplot, Gnuplot.funcutils
+        d=[]
+        x_widths = array(la[1:,0]-la[:-1,0])/2;
+        d.append(Gnuplot.Data(
+                la[:-1,0]+x_widths,             # x centers
+                la[:-1,1],                      # y centers
+                x_widths,                       # x errors
+                __notesheight*ones(len(la)-1),  # y errors
+                title=plot_title,with_=('boxxyerrorbars fs 3')))
+        return d
+
+def plotnote_do(d,fileout=None):
+    import Gnuplot, Gnuplot.funcutils
+    g = Gnuplot.Gnuplot(debug=1, persist=1)
+    g.gnuplot('set style fill solid border 1; \
+    set size ratio 1/6; \
+    set boxwidth 0.9 relative; \
+    set mxtics 2.5; \
+    set mytics 2.5; \
+    set xtics 5; \
+    set ytics 1; \
+    set grid xtics ytics mxtics mytics')
+
+    g.xlabel('Time (s)')
+    g.ylabel('Midi pitch')
+    # do the plot
+    #g.gnuplot('set multiplot')
+    #for i in d:
+    g.plot(d[0])
+    #g.gnuplot('set nomultiplot') 
+    if fileout != None:
+        g.hardcopy(fileout, enhanced=1, color=0)
+
Index: python.old/aubio/task/__init__.py
===================================================================
--- python.old/aubio/task/__init__.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/task/__init__.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,9 @@
+from aubio.aubioclass import *
+from aubio.task.task import task
+from aubio.task.params import taskparams
+from aubio.task.silence import tasksilence
+from aubio.task.onset import taskonset
+from aubio.task.beat import taskbeat
+from aubio.task.cut import taskcut
+from aubio.task.pitch import taskpitch
+from aubio.task.notes import tasknotes
Index: python.old/aubio/task/beat.py
===================================================================
--- python.old/aubio/task/beat.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/task/beat.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,262 @@
+from aubio.aubioclass import *
+from onset import taskonset
+
+class taskbeat(taskonset):
+	def __init__(self,input,params=None,output=None):
+		""" open the input file and initialize arguments 
+		parameters should be set *before* calling this method.
+		"""
+		taskonset.__init__(self,input,output=None,params=params)
+		self.btwinlen  = 512**2/self.params.hopsize
+		self.btstep    = self.btwinlen/4
+		self.btoutput  = fvec(self.btstep,self.channels)
+		self.dfframe   = fvec(self.btwinlen,self.channels)
+		self.bt	       = beattracking(self.btwinlen,self.channels)
+		self.pos2      = 0
+		self.old       = -1000
+
+	def __call__(self):
+		taskonset.__call__(self)
+		#results = taskonset.__call__(self)
+		# write to current file
+		if self.pos2 == self.btstep - 1 : 
+			self.bt.do(self.dfframe,self.btoutput)
+			for i in range (self.btwinlen - self.btstep):
+				self.dfframe.set(self.dfframe.get(i+self.btstep,0),i,0) 
+			for i in range(self.btwinlen - self.btstep, self.btwinlen): 
+				self.dfframe.set(0,i,0)
+			self.pos2 = -1;
+		self.pos2 += 1
+		val = self.opick.pp.getval()
+		#if not results: val = 0
+		#else: val = results[1] 
+		self.dfframe.set(val,self.btwinlen - self.btstep + self.pos2,0)
+		i=0
+		for i in range(1,int( self.btoutput.get(0,0) ) ):
+			if self.pos2 == self.btoutput.get(i,0) and \
+				aubio_silence_detection(self.myvec(),
+					self.params.silence)!=1: 
+				now = self.frameread-0
+				period = (60 * self.params.samplerate) / ((now - self.old) * self.params.hopsize)
+				self.old = now
+				return now,period
+
+	def eval(self,results,tol=0.20,tolcontext=0.25):
+		obeats = self.gettruth()
+		etime = [result[0] for result in results]
+		otime = [obeat[0] for obeat in obeats]
+		CML_tot, CML_max, CML_start, CML_end = 0,0,0,0
+		AML_tot, AML_max, AML_start, AML_end = 0,0,0,0
+		AMLd_tot, AMLd_max, AMLd_start, AMLd_end = 0,0,0,0
+		AMLh_tot, AMLh_max, AMLh_start, AMLh_end = 0,0,0,0
+		AMLo_tot, AMLo_max, AMLo_start, AMLo_end = 0,0,0,0
+		# results iteration
+		j = 1
+		# for each annotation
+		for i in range(2,len(otime)-2):
+			if j+1 >= len(etime): break
+			count = 0
+			# look for next matching beat
+			while otime[i] > etime[j] - (otime[i] - otime[i+1])*tol:
+				if count > 0: 
+					#print "spurious etime"
+					if CML_end - CML_start > CML_max:
+						CML_max = CML_end - CML_start
+					CML_start, CML_end = j, j
+					if AMLh_end - AMLh_start > AMLh_max:
+						AMLh_max = AMLh_end - AMLh_start
+					AMLh_start, AMLh_end = j, j
+					if AMLd_end - AMLd_start > AMLd_max:
+						AMLd_max = AMLd_end - AMLd_start
+					AMLd_start, AMLd_end = j, j
+					if AMLo_end - AMLo_start > AMLo_max:
+						AMLo_max = AMLo_end - AMLo_start
+					AMLo_start, AMLo_end = j, j
+				j += 1
+				count += 1
+			if j+1 >= len(etime): break
+			#print otime[i-1],etime[j-1]," ",otime[i],etime[j]," ",otime[i+1],etime[j+1] 
+			prevtempo = (otime[i] - otime[i-1])
+			nexttempo = (otime[i+1] - otime[i])
+
+			current0  = (etime[j] > otime[i] - prevtempo*tol)
+			current1  = (etime[j] < otime[i] + prevtempo*tol)
+
+			# check correct tempo 
+			prev0 = (etime[j-1] > otime[i-1] - prevtempo*tolcontext)
+			prev1 = (etime[j-1] < otime[i-1] + prevtempo*tolcontext)
+			next0 = (etime[j+1] > otime[i+1] - nexttempo*tolcontext)
+			next1 = (etime[j+1] < otime[i+1] + nexttempo*tolcontext)
+
+			# check for off beat
+			prevoffb0 = (etime[j-1] > otime[i-1] - prevtempo/2 - prevtempo*tolcontext)
+			prevoffb1 = (etime[j-1] < otime[i-1] - prevtempo/2 + prevtempo*tolcontext)
+			nextoffb0 = (etime[j+1] > otime[i+1] - nexttempo/2 - nexttempo*tolcontext)
+			nextoffb1 = (etime[j+1] < otime[i+1] - nexttempo/2 + nexttempo*tolcontext)
+
+			# check half tempo 
+			prevhalf0 = (etime[j-1] > otime[i-1] + prevtempo - prevtempo/2*tolcontext)
+			prevhalf1 = (etime[j-1] < otime[i-1] + prevtempo + prevtempo/2*tolcontext)
+			nexthalf0 = (etime[j+1] > otime[i+1] - nexttempo - nexttempo/2*tolcontext)
+			nexthalf1 = (etime[j+1] < otime[i+1] - nexttempo + nexttempo/2*tolcontext)
+
+			# check double tempo
+			prevdoub0 = (etime[j-1] > otime[i-1] - prevtempo - prevtempo*2*tolcontext)
+			prevdoub1 = (etime[j-1] < otime[i-1] - prevtempo + prevtempo*2*tolcontext)
+			nextdoub0 = (etime[j+1] > otime[i+1] + nexttempo - nexttempo*2*tolcontext)
+			nextdoub1 = (etime[j+1] < otime[i+1] + nexttempo + nexttempo*2*tolcontext)
+
+			if current0 and current1 and prev0 and prev1 and next0 and next1: 
+				#print "YES!"
+				CML_end = j	
+				CML_tot += 1
+			else:
+				if CML_end - CML_start > CML_max:
+					CML_max = CML_end - CML_start
+				CML_start, CML_end = j, j
+			if current0 and current1 and prevhalf0 and prevhalf1 and nexthalf0 and nexthalf1: 
+				AMLh_end = j
+				AMLh_tot += 1
+			else:
+				if AMLh_end - AMLh_start > AMLh_max:
+					AMLh_max = AMLh_end - AMLh_start
+				AMLh_start, AMLh_end = j, j
+			if current0 and current1 and prevdoub0 and prevdoub1 and nextdoub0 and nextdoub1: 
+				AMLd_end = j
+				AMLd_tot += 1
+			else:
+				if AMLd_end - AMLd_start > AMLd_max:
+					AMLd_max = AMLd_end - AMLd_start
+				AMLd_start, AMLd_end = j, j
+			if current0 and current1 and prevoffb0 and prevoffb1 and nextoffb0 and nextoffb1: 
+				AMLo_end = j
+				AMLo_tot += 1
+			else:
+				if AMLo_end - AMLo_start > AMLo_max:
+					AMLo_max = AMLo_end - AMLo_start
+				AMLo_start, AMLo_end = j, j
+			# look for next matching beat
+			count = 0 
+			while otime[i] > etime[j] - (otime[i] - otime[i+1])*tolcontext:
+				j += 1
+				if count > 0: 
+					#print "spurious etime"
+					start = j
+				count += 1
+		total = float(len(otime))
+		CML_tot  /= total 
+		AMLh_tot /= total 
+		AMLd_tot /= total 
+		AMLo_tot /= total 
+		CML_cont  = CML_max/total
+		AMLh_cont = AMLh_max/total
+		AMLd_cont = AMLd_max/total
+		AMLo_cont = AMLo_max/total
+		return CML_cont, CML_tot, AMLh_cont, AMLh_tot, AMLd_cont, AMLd_tot, AMLo_cont, AMLo_tot
+
+#		for i in allfreq:
+#			freq.append(float(i) / 2. / N  * samplerate )
+#			while freq[i]>freqs[j]:
+#				j += 1
+#			a0 = weight[j-1]
+#			a1 = weight[j]
+#			f0 = freqs[j-1]
+#			f1 = freqs[j]
+#			if f0!=0:
+#				iweight.append((a1-a0)/(f1-f0)*freq[i] + (a0 - (a1 - a0)/(f1/f0 -1.)))
+#			else:
+#				iweight.append((a1-a0)/(f1-f0)*freq[i] + a0)
+#			while freq[i]>freqs[j]:
+#				j += 1
+			
+	def eval2(self,results,tol=0.2):
+		truth = self.gettruth()
+		obeats = [i[0] for i in truth] 
+		ebeats = [i[0]*self.params.step for i in results] 
+		NP = max(len(obeats), len(ebeats))
+		N  = int(round(max(max(obeats), max(ebeats))*100.)+100)
+		W  = int(round(tol*100.*60./median([i[1] for i in truth], len(truth)/2)))
+		ofunc = [0 for i in range(N+W)]
+		efunc = [0 for i in range(N+W)]
+		for i in obeats: ofunc[int(round(i*100.)+W)] = 1
+		for i in ebeats: efunc[int(round(i*100.)+W)] = 1
+		assert len(obeats) == sum(ofunc)
+		autocor = 0; m =0
+		for m in range (-W, W):
+			for i in range(W,N):
+				autocor += ofunc[i] * efunc[i-m] 
+		autocor /= float(NP)
+		return autocor
+	
+	def evaluation(self,results,tol=0.2,start=5.):
+
+		""" beat tracking evaluation function
+
+		computes P-score of experimental results (ebeats)
+		        against ground truth annotations (obeats) """
+
+		from aubio.median import short_find as median
+		truth = self.gettruth()
+		ebeats = [i[0]*self.params.step for i in results] 
+		obeats = [i[0] for i in truth] 
+
+		# trim anything found before start
+		while obeats[0] < start: obeats.pop(0)
+		while ebeats[0] < start: ebeats.pop(0)
+		# maximum number of beats found 
+		NP = max(len(obeats), len(ebeats))
+		# length of ofunc and efunc vector 
+		N  = int(round(max(max(obeats), max(ebeats))*100.)+100)
+		# compute W median of ground truth tempi 
+		tempi = []
+		for i in range(1,len(obeats)): tempi.append(obeats[i]-obeats[i-1])
+		W  = int(round(tol*100.*median(tempi,len(tempi)/2)))
+		# build ofunc and efunc functions, starting with W zeros  
+		ofunc = [0 for i in range(N+W)]
+		efunc = [0 for i in range(N+W)]
+		for i in obeats: ofunc[int(round(i*100.)+W)] = 1
+		for i in ebeats: efunc[int(round(i*100.)+W)] = 1
+		# optional: make sure we didn't miss any beats  
+		assert len(obeats) == sum(ofunc)
+		assert len(ebeats) == sum(efunc)
+		# compute auto correlation 
+		autocor = 0; m =0
+		for m in range (-W, W):
+		  for i in range(W,N):
+		    autocor += ofunc[i] * efunc[i-m] 
+		autocor /= float(NP)
+		return autocor
+
+	def gettruth(self):
+		import os.path
+		from aubio.txtfile import read_datafile
+		datafile = self.input.replace('.wav','.txt')
+		if not os.path.isfile(datafile):
+			print "no ground truth "
+			return False,False
+		else:
+			values = read_datafile(datafile,depth=0)
+			old = -1000
+			for i in range(len(values)):
+				now = values[i]
+				period = 60 / (now - old)
+				old = now
+				values[i] = [now,period]
+		return values
+	
+
+	def plot(self,oplots,results):
+		import Gnuplot
+		oplots.append(Gnuplot.Data(results,with_='linespoints',title="auto"))
+
+	def plotplot(self,wplot,oplots,outplot=None,extension=None,xsize=1.,ysize=1.,spectro=False):
+		import Gnuplot
+		from aubio.gnuplot import gnuplot_create, audio_to_array, make_audio_plot
+		import re
+		# audio data
+		#time,data = audio_to_array(self.input)
+		#f = make_audio_plot(time,data)
+
+		g = gnuplot_create(outplot=outplot, extension=extension)
+		oplots = [Gnuplot.Data(self.gettruth(),with_='linespoints',title="orig")] + oplots
+		g.plot(*oplots)
Index: python.old/aubio/task/cut.py
===================================================================
--- python.old/aubio/task/cut.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/task/cut.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,42 @@
+from task import task
+from aubio.aubioclass import *
+
+class taskcut(task):
+	def __init__(self,input,slicetimes,params=None,output=None):
+		""" open the input file and initialize arguments 
+		parameters should be set *before* calling this method.
+		"""
+		from os.path import basename,splitext
+		task.__init__(self,input,output=None,params=params)
+		self.soundoutbase, self.soundoutext = splitext(basename(self.input))
+		self.newname   = "%s%s%09.5f%s%s" % (self.soundoutbase,".",
+					self.frameread*self.params.step,".",self.soundoutext)
+		self.fileo	= sndfile(self.newname,model=self.filei)
+		self.myvec	= fvec(self.params.hopsize,self.channels)
+		self.mycopy	= fvec(self.params.hopsize,self.channels)
+		self.slicetimes = slicetimes 
+
+	def __call__(self):
+		task.__call__(self)
+		# write to current file
+		if len(self.slicetimes) and self.frameread >= self.slicetimes[0][0]:
+			self.slicetimes.pop(0)
+			# write up to 1st zero crossing
+			zerocross = 0
+			while ( abs( self.myvec.get(zerocross,0) ) > self.params.zerothres ):
+				zerocross += 1
+			writesize = self.fileo.write(zerocross,self.myvec)
+			fromcross = 0
+			while (zerocross < self.readsize):
+				for i in range(self.channels):
+					self.mycopy.set(self.myvec.get(zerocross,i),fromcross,i)
+					fromcross += 1
+					zerocross += 1
+			del self.fileo
+			self.fileo = sndfile("%s%s%09.5f%s%s" % (self.soundoutbase,".",
+				self.frameread*self.params.step,".",self.soundoutext),model=self.filei)
+			writesize = self.fileo.write(fromcross,self.mycopy)
+		else:
+			writesize = self.fileo.write(self.readsize,self.myvec)
+
+
Index: python.old/aubio/task/notes.py
===================================================================
--- python.old/aubio/task/notes.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/task/notes.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,159 @@
+
+from aubio.task import task
+from aubio.aubioclass import *
+
+class tasknotes(task):
+	def __init__(self,input,output=None,params=None):
+		task.__init__(self,input,params=params)
+		self.opick = onsetpick(self.params.bufsize,
+			self.params.hopsize,
+			self.channels,
+			self.myvec,
+			self.params.threshold,
+			mode=self.params.onsetmode,
+			dcthreshold=self.params.dcthreshold,
+			derivate=self.params.derivate)
+		self.pitchdet  = pitch(mode=self.params.pitchmode,
+			bufsize=self.params.pbufsize,
+			hopsize=self.params.phopsize,
+			channels=self.channels,
+			samplerate=self.srate,
+			omode=self.params.omode)
+		self.olist = [] 
+		self.ofunc = []
+		self.maxofunc = 0
+		self.last = -1000
+		self.oldifreq = 0
+		if self.params.localmin:
+			self.ovalist   = [0., 0., 0., 0., 0.]
+
+	def __call__(self):
+		from aubio.median import short_find
+		task.__call__(self)
+		isonset,val = self.opick.do(self.myvec)
+		if (aubio_silence_detection(self.myvec(),self.params.silence)):
+			isonset=0
+			freq = -1.
+		else:
+			freq = self.pitchdet(self.myvec)
+		minpitch = self.params.pitchmin
+		maxpitch = self.params.pitchmax
+		if maxpitch and freq > maxpitch : 
+			freq = -1.
+		elif minpitch and freq < minpitch :
+			freq = -1.
+		freq = aubio_freqtomidi(freq)
+		if self.params.pitchsmooth:
+			self.shortlist.append(freq)
+			self.shortlist.pop(0)
+			smoothfreq = short_find(self.shortlist,
+				len(self.shortlist)/2)
+			freq = smoothfreq
+		now = self.frameread
+		ifreq = int(round(freq))
+		if self.oldifreq == ifreq:
+			self.oldifreq = ifreq
+		else:
+			self.oldifreq = ifreq
+			ifreq = 0 
+		# take back delay
+		if self.params.delay != 0.: now -= self.params.delay
+		if now < 0 :
+			now = 0
+		if (isonset == 1):
+			if self.params.mintol:
+				# prune doubled 
+				if (now - self.last) > self.params.mintol:
+					self.last = now
+					return now, 1, freq, ifreq
+				else:
+					return now, 0, freq, ifreq
+			else:
+				return now, 1, freq, ifreq 
+		else:
+			return now, 0, freq, ifreq
+
+
+	def fprint(self,foo):
+		print self.params.step*foo[0], foo[1], foo[2], foo[3]
+
+	def compute_all(self):
+		""" Compute data """
+    		now, onset, freq, ifreq = [], [], [], []
+		while(self.readsize==self.params.hopsize):
+			n, o, f, i = self()
+			now.append(n*self.params.step)
+			onset.append(o)
+			freq.append(f)
+			ifreq.append(i)
+			if self.params.verbose:
+				self.fprint((n,o,f,i))
+    		return now, onset, freq, ifreq 
+
+	def plot(self,now,onset,freq,ifreq,oplots):
+		import Gnuplot
+
+		oplots.append(Gnuplot.Data(now,freq,with_='lines',
+			title=self.params.pitchmode))
+		oplots.append(Gnuplot.Data(now,ifreq,with_='lines',
+			title=self.params.pitchmode))
+
+		temponsets = []
+		for i in onset:
+			temponsets.append(i*1000)
+		oplots.append(Gnuplot.Data(now,temponsets,with_='impulses',
+			title=self.params.pitchmode))
+
+	def plotplot(self,wplot,oplots,outplot=None,multiplot = 0):
+		from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot
+		import re
+		import Gnuplot
+		# audio data
+		time,data = audio_to_array(self.input)
+		f = make_audio_plot(time,data)
+
+		# check if ground truth exists
+		#timet,pitcht = self.gettruth()
+		#if timet and pitcht:
+		#	oplots = [Gnuplot.Data(timet,pitcht,with_='lines',
+		#		title='ground truth')] + oplots
+
+		t = Gnuplot.Data(0,0,with_='impulses') 
+
+		g = gnuplot_init(outplot)
+		g('set title \'%s\'' % (re.sub('.*/','',self.input)))
+		g('set multiplot')
+		# hack to align left axis
+		g('set lmargin 15')
+		# plot waveform and onsets
+		g('set size 1,0.3')
+		g('set origin 0,0.7')
+		g('set xrange [0:%f]' % max(time)) 
+		g('set yrange [-1:1]') 
+		g.ylabel('amplitude')
+		g.plot(f)
+		g('unset title')
+		# plot onset detection function
+
+
+		g('set size 1,0.7')
+		g('set origin 0,0')
+		g('set xrange [0:%f]' % max(time))
+		g('set yrange [20:100]')
+		g('set key right top')
+		g('set noclip one') 
+		#g('set format x ""')
+		#g('set log y')
+		#g.xlabel('time (s)')
+		g.ylabel('f0 (Hz)')
+		if multiplot:
+			for i in range(len(oplots)):
+				# plot onset detection functions
+				g('set size 1,%f' % (0.7/(len(oplots))))
+				g('set origin 0,%f' % (float(i)*0.7/(len(oplots))))
+				g('set xrange [0:%f]' % max(time))
+				g.plot(oplots[i])
+		else:
+			g.plot(*oplots)
+		#g('unset multiplot')
+
Index: python.old/aubio/task/onset.py
===================================================================
--- python.old/aubio/task/onset.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/task/onset.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,220 @@
+from aubio.task.task import task
+from aubio.aubioclass import *
+
+class taskonset(task):
+	def __init__(self,input,output=None,params=None):
+		""" open the input file and initialize arguments 
+		parameters should be set *before* calling this method.
+		"""
+		task.__init__(self,input,params=params)
+		self.opick = onsetpick(self.params.bufsize,
+			self.params.hopsize,
+			self.myvec,
+			self.params.threshold,
+			mode=self.params.onsetmode,
+			dcthreshold=self.params.dcthreshold,
+			derivate=self.params.derivate)
+		self.olist = [] 
+		self.ofunc = []
+		self.maxofunc = 0
+		self.last = 0
+		if self.params.localmin:
+			self.ovalist   = [0., 0., 0., 0., 0.]
+
+	def __call__(self):
+		task.__call__(self)
+		isonset,val = self.opick.do(self.myvec)
+		if (aubio_silence_detection(self.myvec(),self.params.silence)):
+			isonset=0
+		if self.params.storefunc:
+			self.ofunc.append(val)
+		if self.params.localmin:
+			if val > 0: self.ovalist.append(val)
+			else: self.ovalist.append(0)
+			self.ovalist.pop(0)
+		if (isonset > 0.):
+			if self.params.localmin:
+				# find local minima before peak 
+				i=len(self.ovalist)-1
+				while self.ovalist[i-1] < self.ovalist[i] and i > 0:
+					i -= 1
+				now = (self.frameread+1-i)
+			else:
+				now = self.frameread
+			# take back delay
+			if self.params.delay != 0.: now -= self.params.delay
+			if now < 0 :
+				now = 0
+			if self.params.mintol:
+				# prune doubled 
+				if (now - self.last) > self.params.mintol:
+					self.last = now
+					return now, val
+			else:
+				return now, val 
+
+
+	def fprint(self,foo):
+		print self.params.step*foo[0]
+
+	def eval(self,inputdata,ftru,mode='roc',vmode=''):
+		from aubio.txtfile import read_datafile 
+		from aubio.onsetcompare import onset_roc, onset_diffs, onset_rocloc
+		ltru = read_datafile(ftru,depth=0)
+		lres = []
+		for i in range(len(inputdata)): lres.append(inputdata[i][0]*self.params.step)
+		if vmode=='verbose':
+			print "Running with mode %s" % self.params.onsetmode, 
+			print " and threshold %f" % self.params.threshold, 
+			print " on file", self.input
+		#print ltru; print lres
+		if mode == 'local':
+			l = onset_diffs(ltru,lres,self.params.tol)
+			mean = 0
+			for i in l: mean += i
+			if len(l): mean = "%.3f" % (mean/len(l))
+			else: mean = "?0"
+			return l, mean
+		elif mode == 'roc':
+			self.orig, self.missed, self.merged, \
+				self.expc, self.bad, self.doubled = \
+				onset_roc(ltru,lres,self.params.tol)
+		elif mode == 'rocloc':
+			self.v = {}
+			self.v['orig'], self.v['missed'], self.v['Tm'], \
+				self.v['expc'], self.v['bad'], self.v['Td'], \
+				self.v['l'], self.v['labs'] = \
+				onset_rocloc(ltru,lres,self.params.tol)
+
+	def plot(self,onsets,ofunc,wplot,oplots,nplot=False):
+		import Gnuplot, Gnuplot.funcutils
+		import aubio.txtfile
+		import os.path
+		from numpy import arange, array, ones
+		from aubio.onsetcompare import onset_roc
+
+		x1,y1,y1p = [],[],[]
+		oplot = []
+		if self.params.onsetmode in ('mkl','kl'): ofunc[0:10] = [0] * 10
+
+		self.lenofunc = len(ofunc) 
+		self.maxofunc = max(ofunc)
+		# onset detection function 
+		downtime = arange(len(ofunc))*self.params.step
+		oplot.append(Gnuplot.Data(downtime,ofunc,with_='lines',title=self.params.onsetmode))
+
+		# detected onsets
+		if not nplot:
+			for i in onsets:
+				x1.append(i[0]*self.params.step)
+				y1.append(self.maxofunc)
+				y1p.append(-self.maxofunc)
+			#x1 = array(onsets)*self.params.step
+			#y1 = self.maxofunc*ones(len(onsets))
+			if x1:
+				oplot.append(Gnuplot.Data(x1,y1,with_='impulses'))
+				wplot.append(Gnuplot.Data(x1,y1p,with_='impulses'))
+
+		oplots.append((oplot,self.params.onsetmode,self.maxofunc))
+
+		# check if ground truth datafile exists
+		datafile = self.input.replace('.wav','.txt')
+		if datafile == self.input: datafile = ""
+		if not os.path.isfile(datafile):
+			self.title = "" #"(no ground truth)"
+		else:
+			t_onsets = aubio.txtfile.read_datafile(datafile)
+			x2 = array(t_onsets).resize(len(t_onsets))
+			y2 = self.maxofunc*ones(len(t_onsets))
+			wplot.append(Gnuplot.Data(x2,y2,with_='impulses'))
+			
+			tol = 0.050 
+
+			orig, missed, merged, expc, bad, doubled = \
+				onset_roc(x2,x1,tol)
+			self.title = "GD %2.3f%% FP %2.3f%%" % \
+				((100*float(orig-missed-merged)/(orig)),
+				 (100*float(bad+doubled)/(orig)))
+
+
+	def plotplot(self,wplot,oplots,outplot=None,extension=None,xsize=1.,ysize=1.,spectro=False):
+		from aubio.gnuplot import gnuplot_create, audio_to_array, make_audio_plot, audio_to_spec
+		import re
+		# prepare the plot
+		g = gnuplot_create(outplot=outplot, extension=extension)
+		g('set title \'%s\'' % (re.sub('.*/','',self.input)))
+		if spectro:
+			g('set size %f,%f' % (xsize,1.3*ysize) )
+		else:
+			g('set size %f,%f' % (xsize,ysize) )
+		g('set multiplot')
+
+		# hack to align left axis
+		g('set lmargin 3')
+		g('set rmargin 6')
+
+		if spectro:
+			import Gnuplot
+			minf = 50
+			maxf = 500 
+			data,time,freq = audio_to_spec(self.input,minf=minf,maxf=maxf)
+			g('set size %f,%f' % (1.24*xsize , 0.34*ysize) )
+			g('set origin %f,%f' % (-0.12,0.65*ysize))
+			g('set xrange [0.:%f]' % time[-1]) 
+			g('set yrange [%f:%f]' % (minf,maxf))
+			g('set pm3d map')
+			g('unset colorbox')
+			g('set lmargin 0')
+			g('set rmargin 0')
+			g('set tmargin 0')
+			g('set palette rgbformulae -25,-24,-32')
+			g.xlabel('time (s)',offset=(0,1.))
+			g.ylabel('freq (Hz)')
+			g('set origin 0,%f' % (1.0*ysize) ) 
+			g('set format x "%1.1f"')
+			#if log:
+			#	g('set yrange [%f:%f]' % (max(10,minf),maxf))
+			#	g('set log y')
+			g.splot(Gnuplot.GridData(data,time,freq, binary=1, title=''))
+		else:
+			# plot waveform and onsets
+			time,data = audio_to_array(self.input)
+			wplot = [make_audio_plot(time,data)] + wplot
+			g('set origin 0,%f' % (0.7*ysize) )
+			g('set size %f,%f' % (xsize,0.3*ysize))
+			g('set format y "%1f"')
+			g('set xrange [0:%f]' % max(time)) 
+			g('set yrange [-1:1]') 
+			g('set noytics')
+			g('set y2tics -1,1')
+			g.xlabel('time (s)',offset=(0,0.7))
+			g.ylabel('amplitude')
+			g.plot(*wplot)
+
+		# default settings for next plots
+		g('unset title')
+		g('set format x ""')
+		g('set format y "%3e"')
+		g('set tmargin 0')
+		g.xlabel('')
+
+		N = len(oplots)
+		y = 0.7*ysize # the vertical proportion of the plot taken by onset functions
+		delta = 0.035 # the constant part of y taken by last plot label and data
+		for i in range(N):
+			# plot onset detection functions
+			g('set size %f,%f' % ( xsize, (y-delta)/N))
+			g('set origin 0,%f' % ((N-i-1)*(y-delta)/N + delta ))
+			g('set nokey')
+			g('set xrange [0:%f]' % (self.lenofunc*self.params.step))
+			g('set yrange [0:%f]' % (1.1*oplots[i][2]))
+			g('set y2tics ("0" 0, "%d" %d)' % (round(oplots[i][2]),round(oplots[i][2])))
+			g.ylabel(oplots[i][1])
+			if i == N-1:
+				g('set size %f,%f' % ( xsize, (y-delta)/N + delta ) )
+				g('set origin 0,0')
+				g.xlabel('time (s)', offset=(0,0.7))
+				g('set format x')
+			g.plot(*oplots[i][0])
+
+		g('unset multiplot')
Index: python.old/aubio/task/params.py
===================================================================
--- python.old/aubio/task/params.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/task/params.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,33 @@
+
+class taskparams(object):
+	""" default parameters for task classes """
+	def __init__(self,input=None,output=None):
+		self.silence = -90
+		self.derivate = False
+		self.localmin = False
+		self.delay = 4.
+		self.storefunc = False
+		self.bufsize = 512
+		self.hopsize = 256
+		self.pbufsize = 2048
+		self.phopsize =  512
+		self.samplerate = 44100
+		self.tol = 0.05
+		self.mintol = 0.0
+		self.step = float(self.hopsize)/float(self.samplerate)
+		self.threshold = 0.1
+		self.onsetmode = 'dual'
+		self.pitchmode = 'yin'
+		# best threshold for yin monophonic Mirex04 (depth of f0) 
+		self.yinthresh = 0.15 
+		# best thresh for yinfft monophonic Mirex04 (tradeoff sil/gd)
+		# also best param for yinfft polyphonic Mirex04
+		self.yinfftthresh = 0.85 
+		self.pitchsmooth = 0
+		self.pitchmin=20.
+		self.pitchmax=20000.
+		self.pitchdelay = -0.5
+		self.dcthreshold = -1.
+		self.omode = "freq"
+		self.verbose   = False
+
Index: python.old/aubio/task/pitch.py
===================================================================
--- python.old/aubio/task/pitch.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/task/pitch.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,234 @@
+from aubio.task.task import task
+from aubio.task.silence import tasksilence
+from aubio.aubioclass import *
+
+class taskpitch(task):
+	def __init__(self,input,params=None):
+		task.__init__(self,input,params=params)
+		self.shortlist = [0. for i in range(self.params.pitchsmooth)]
+		if self.params.pitchmode == 'yin':
+			tolerance = self.params.yinthresh
+		elif self.params.pitchmode == 'yinfft':
+			tolerance = self.params.yinfftthresh
+		else:
+			tolerance = 0.
+		self.pitchdet	= pitch(mode=self.params.pitchmode,
+			bufsize=self.params.bufsize,
+			hopsize=self.params.hopsize,
+			samplerate=self.srate,
+			omode=self.params.omode,
+			tolerance = tolerance)
+
+	def __call__(self):
+		from aubio.median import short_find
+		task.__call__(self)
+		if (aubio_silence_detection(self.myvec(),self.params.silence)==1):
+			freq = -1.
+		else:
+			freq = self.pitchdet(self.myvec)
+		minpitch = self.params.pitchmin
+		maxpitch = self.params.pitchmax
+		if maxpitch and freq > maxpitch : 
+			freq = -1.
+		elif minpitch and freq < minpitch :
+			freq = -1.
+		if self.params.pitchsmooth:
+			self.shortlist.append(freq)
+			self.shortlist.pop(0)
+			smoothfreq = short_find(self.shortlist,
+				len(self.shortlist)/2)
+			return smoothfreq
+		else:
+			return freq
+
+	def compute_all(self):
+		""" Compute data """
+    		mylist    = []
+		while(self.readsize==self.params.hopsize):
+			freq = self()
+			mylist.append(freq)
+			if self.params.verbose:
+				self.fprint("%s\t%s" % (self.frameread*self.params.step,freq))
+    		return mylist
+
+	def gettruth(self):
+		""" extract ground truth array in frequency """
+		import os.path
+		""" from wavfile.txt """
+		datafile = self.input.replace('.wav','.txt')
+		if datafile == self.input: datafile = ""
+		""" from file.<midinote>.wav """
+		# FIXME very weak check
+		floatpit = self.input.split('.')[-2]
+		if not os.path.isfile(datafile) and len(self.input.split('.')) < 3:
+			print "no ground truth "
+			return False,False
+		elif floatpit:
+			try:
+				self.truth = float(floatpit)
+				#print "ground truth found in filename:", self.truth
+				tasksil = tasksilence(self.input,params=self.params)
+				time,pitch =[],[]
+				while(tasksil.readsize==tasksil.params.hopsize):
+					tasksil()
+					time.append(tasksil.params.step*(tasksil.frameread))
+					if not tasksil.issilence:
+						pitch.append(self.truth)
+					else:
+						pitch.append(-1.)
+				return time,pitch
+			except ValueError:
+				# FIXME very weak check
+				if not os.path.isfile(datafile):
+					print "no ground truth found"
+					return 0,0
+				else:
+					from aubio.txtfile import read_datafile
+					values = read_datafile(datafile)
+					time, pitch = [], []
+					for i in range(len(values)):
+						time.append(values[i][0])
+						if values[i][1] == 0.0:
+							pitch.append(-1.)
+						else:
+							pitch.append(aubio_freqtomidi(values[i][1]))
+					return time,pitch
+
+	def oldeval(self,results):
+		def mmean(l):
+			return sum(l)/max(float(len(l)),1)
+
+		from aubio.median import percental 
+		timet,pitcht = self.gettruth()
+		res = []
+		for i in results:
+			#print i,self.truth
+			if i <= 0: pass
+			else: res.append(self.truth-i)
+		if not res or len(res) < 3: 
+			avg = self.truth; med = self.truth 
+		else:
+			avg = mmean(res) 
+			med = percental(res,len(res)/2) 
+		return self.truth, self.truth-med, self.truth-avg
+
+	def eval(self,pitch,tol=0.5):
+		timet,pitcht = self.gettruth()
+		pitch = [aubio_freqtomidi(i) for i in pitch]
+		for i in range(len(pitch)):
+			if pitch[i] == "nan" or pitch[i] == -1:
+				pitch[i] = -1
+		time = [ (i+self.params.pitchdelay)*self.params.step for i in range(len(pitch)) ]
+		#print len(timet),len(pitcht)
+		#print len(time),len(pitch)
+		if len(timet) != len(time):
+			time = time[1:len(timet)+1]
+			pitch = pitch[1:len(pitcht)+1]
+			#pitcht = [aubio_freqtomidi(i) for i in pitcht]
+			for i in range(len(pitcht)):
+				if pitcht[i] == "nan" or pitcht[i] == "-inf" or pitcht[i] == -1:
+					pitcht[i] = -1
+		assert len(timet) == len(time)
+		assert len(pitcht) == len(pitch)
+		osil, esil, opit, epit, echr = 0, 0, 0, 0, 0
+		for i in range(len(pitcht)):
+			if pitcht[i] == -1: # currently silent
+				osil += 1 # count a silence
+				if pitch[i] <= 0. or pitch[i] == "nan": 
+					esil += 1 # found a silence
+			else:
+				opit +=1
+				if abs(pitcht[i] - pitch[i]) < tol:
+					epit += 1
+					echr += 1
+				elif abs(pitcht[i] - pitch[i]) % 12. < tol:
+					echr += 1
+				#else:
+				#	print timet[i], pitcht[i], time[i], pitch[i]
+		#print "origsilence", "foundsilence", "origpitch", "foundpitch", "orig pitchroma", "found pitchchroma"
+		#print 100.*esil/float(osil), 100.*epit/float(opit), 100.*echr/float(opit)
+		return osil, esil, opit, epit, echr
+
+	def plot(self,pitch,wplot,oplots,titles,outplot=None):
+		import Gnuplot
+
+		time = [ (i+self.params.pitchdelay)*self.params.step for i in range(len(pitch)) ]
+		pitch = [aubio_freqtomidi(i) for i in pitch]
+		oplots.append(Gnuplot.Data(time,pitch,with_='lines',
+			title=self.params.pitchmode))
+		titles.append(self.params.pitchmode)
+
+			
+	def plotplot(self,wplot,oplots,titles,outplot=None,extension=None,xsize=1.,ysize=1.,multiplot = 1, midi = 1, truth = 1):
+		from aubio.gnuplot import gnuplot_create , audio_to_array, make_audio_plot
+		import re
+		import Gnuplot
+
+		# check if ground truth exists
+		if truth:
+			timet,pitcht = self.gettruth()
+			if timet and pitcht:
+				oplots = [Gnuplot.Data(timet,pitcht,with_='lines',
+					title='ground truth')] + oplots
+
+		g = gnuplot_create(outplot=outplot, extension=extension)
+		g('set title \'%s\'' % (re.sub('.*/','',self.input)))
+		g('set size %f,%f' % (xsize,ysize) )
+		g('set multiplot')
+		# hack to align left axis
+		g('set lmargin 4')
+		g('set rmargin 4')
+    # plot waveform
+		time,data = audio_to_array(self.input)
+		wplot = [make_audio_plot(time,data)]
+		g('set origin 0,%f' % (0.7*ysize) )
+		g('set size %f,%f' % (xsize,0.3*ysize))
+		#g('set format y "%1f"')
+		g('set xrange [0:%f]' % max(time)) 
+		g('set yrange [-1:1]') 
+		g('set noytics')
+		g('set y2tics -1,1')
+		g.xlabel('time (s)',offset=(0,0.7))
+		g.ylabel('amplitude')
+		g.plot(*wplot)
+
+		# default settings for next plots
+		g('unset title')
+		g('set format x ""')
+		g('set format y "%3e"')
+		g('set tmargin 0')
+		g.xlabel('')
+		g('set noclip one') 
+
+		if not midi:
+			g('set log y')
+			#g.xlabel('time (s)')
+			g.ylabel('f0 (Hz)')
+			g('set yrange [100:%f]' % self.params.pitchmax) 
+		else: 
+			g.ylabel('midi')
+			g('set yrange [%f:%f]' % (aubio_freqtomidi(self.params.pitchmin), aubio_freqtomidi(self.params.pitchmax)))
+			g('set y2tics %f,%f' % (round(aubio_freqtomidi(self.params.pitchmin)+.5),12))
+		
+		if multiplot:
+			N = len(oplots)
+			y = 0.7*ysize # the vertical proportion of the plot taken by onset functions
+			delta = 0.035 # the constant part of y taken by last plot label and data
+			for i in range(N):
+				# plot pitch detection functions
+				g('set size %f,%f' % ( xsize, (y-delta)/N))
+				g('set origin 0,%f' % ((N-i-1)*(y-delta)/N + delta ))
+				g('set nokey')
+				g('set xrange [0:%f]' % max(time))
+				g.ylabel(titles[i])
+				if i == N-1:
+					g('set size %f,%f' % (xsize, (y-delta)/N + delta ) )
+					g('set origin 0,0')
+					g.xlabel('time (s)', offset=(0,0.7))
+					g('set format x')
+				g.plot(oplots[i])
+		else:
+			g('set key right top')
+			g.plot(*oplots)
+		g('unset multiplot')
+
Index: python.old/aubio/task/silence.py
===================================================================
--- python.old/aubio/task/silence.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/task/silence.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,28 @@
+from aubio.task.task import task
+from aubio.aubioclass import *
+
+class tasksilence(task):
+	wassilence = 1
+	issilence  = 1
+	def __call__(self):
+		task.__call__(self)
+		if (aubio_silence_detection(self.myvec(),self.params.silence)==1):
+			if self.wassilence == 1: self.issilence = 1
+			else: self.issilence = 2
+			self.wassilence = 1
+		else: 
+			if self.wassilence <= 0: self.issilence = 0
+			else: self.issilence = -1 
+			self.wassilence = 0
+		if self.issilence == -1:
+			return max(self.frameread-self.params.delay,0.), -1
+		elif self.issilence == 2:
+			return max(self.frameread+self.params.delay,0.), 2 
+
+	def fprint(self,foo):
+		print self.params.step*foo[0],
+		if foo[1] == 2: print "OFF"
+		else: print "ON"
+
+
+
Index: python.old/aubio/task/task.py
===================================================================
--- python.old/aubio/task/task.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/task/task.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,53 @@
+from aubio.aubioclass import * 
+from params import taskparams
+
+class task(taskparams):
+	""" default template class to apply tasks on a stream """
+	def __init__(self,input,output=None,params=None):
+		""" open the input file and initialize default argument 
+		parameters should be set *before* calling this method.
+		"""
+		import time
+		self.tic = time.time()
+		if params == None: self.params = taskparams()
+		else: self.params = params
+		self.frameread = 0
+		self.readsize  = self.params.hopsize
+		self.input     = input
+		self.filei     = sndfile(self.input)
+		self.srate     = self.filei.samplerate()
+		self.params.step = float(self.params.hopsize)/float(self.srate)
+		self.myvec     = fvec(self.params.hopsize)
+		self.output    = output
+
+	def __call__(self):
+		self.readsize = self.filei.read(self.params.hopsize,self.myvec)
+		self.frameread += 1
+		
+	def compute_all(self):
+		""" Compute data """
+    		mylist    = []
+		while(self.readsize==self.params.hopsize):
+			tmp = self()
+			if tmp: 
+				mylist.append(tmp)
+				if self.params.verbose:
+					self.fprint(tmp)
+    		return mylist
+	
+	def fprint(self,foo):
+		print foo
+
+	def eval(self,results):
+		""" Eval data """
+		pass
+
+	def plot(self):
+		""" Plot data """
+		pass
+
+	def time(self):
+		import time
+		#print "CPU time is now %f seconds," % time.clock(),
+		#print "task execution took %f seconds" % (time.time() - self.tic)
+		return time.time() - self.tic
Index: python.old/aubio/txtfile.py
===================================================================
--- python.old/aubio/txtfile.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/txtfile.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,47 @@
+"""Copyright (C) 2004 Paul Brossier <piem@altern.org>
+print aubio.__LICENSE__ for the terms of use
+"""
+
+__LICENSE__ = """\
+  Copyright (C) 2004-2009 Paul Brossier <piem@aubio.org>
+
+  This file is part of aubio.
+
+  aubio is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  aubio is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
+"""            
+
+def read_datafile(filename,depth=-1):
+    """read list data from a text file (columns of float)"""
+    if filename == '--' or filename == '-':
+        import sys
+        fres = sys.stdin
+    else:
+        fres = open(filename,'ro')
+    l = []
+    while 1:
+        tmp = fres.readline()
+        if not tmp : break
+        else: tmp = tmp.split()
+        if depth > 0:
+            for i in range(min(depth,len(tmp))):
+                tmp[i] = float(tmp[i])
+            l.append(tmp)
+        elif depth == 0:
+            l.append(float(tmp[0]))
+        else:
+            for i in range(len(tmp)):
+                tmp[i] = float(tmp[i])
+            l.append(tmp)
+    return l
+
Index: python.old/aubio/web/browser.py
===================================================================
--- python.old/aubio/web/browser.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/web/browser.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,167 @@
+ #
+ # Copyright 2004 Apache Software Foundation 
+ # 
+ # Licensed under the Apache License, Version 2.0 (the "License"); you
+ # may not use this file except in compliance with the License.  You
+ # may obtain a copy of the License at
+ #
+ #      http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ # implied.  See the License for the specific language governing
+ # permissions and limitations under the License.
+ #
+ # Originally developed by Gregory Trubetskoy.
+ #
+ # $Id: publisher.py,v 1.36 2004/02/16 19:47:27 grisha Exp $
+
+"""
+  This handler is conceputally similar to Zope's ZPublisher, except
+  that it:
+
+  1. Is written specifically for mod_python and is therefore much faster
+  2. Does not require objects to have a documentation string
+  3. Passes all arguments as simply string
+  4. Does not try to match Python errors to HTTP errors
+  5. Does not give special meaning to '.' and '..'.
+
+  This is a modified version of mod_python.publisher.handler Only the first
+  directory argument is matched, the rest is left for path_info. A default
+  one must be provided.
+
+"""
+
+from mod_python import apache
+from mod_python import util
+from mod_python.publisher import resolve_object,process_auth,imp_suffixes
+
+import sys
+import os
+import re
+
+from types import *
+
+def configure_handler(req,default):
+
+    req.allow_methods(["GET", "POST"])
+    if req.method not in ["GET", "POST"]:
+        raise apache.SERVER_RETURN, apache.HTTP_METHOD_NOT_ALLOWED
+
+    func_path = ""
+    if req.path_info:
+        func_path = req.path_info[1:] # skip first /
+        #func_path = func_path.replace("/", ".")
+        #if func_path[-1:] == ".":
+        #    func_path = func_path[:-1] 
+        # changed: only keep the first directory
+        func_path = re.sub('/.*','',func_path)
+
+    # default to 'index' if no path_info was given
+    if not func_path:
+        func_path = "index"
+
+    # if any part of the path begins with "_", abort
+    if func_path[0] == '_' or func_path.count("._"):
+        raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND
+
+    ## import the script
+    path, module_name =  os.path.split(req.filename)
+    if not module_name:
+        module_name = "index"
+
+    # get rid of the suffix
+    #   explanation: Suffixes that will get stripped off
+    #   are those that were specified as an argument to the
+    #   AddHandler directive. Everything else will be considered
+    #   a package.module rather than module.suffix
+    exts = req.get_addhandler_exts()
+    if not exts:
+        # this is SetHandler, make an exception for Python suffixes
+        exts = imp_suffixes
+    if req.extension:  # this exists if we're running in a | .ext handler
+        exts += req.extension[1:] 
+    if exts:
+        suffixes = exts.strip().split()
+        exp = "\\." + "$|\\.".join(suffixes)
+        suff_matcher = re.compile(exp) # python caches these, so its fast
+        module_name = suff_matcher.sub("", module_name)
+
+    # import module (or reload if needed)
+    # the [path] argument tells import_module not to allow modules whose
+    # full path is not in [path] or below.
+    config = req.get_config()
+    autoreload=int(config.get("PythonAutoReload", 1))
+    log=int(config.get("PythonDebug", 0))
+    try:
+        module = apache.import_module(module_name,
+                                      autoreload=autoreload,
+                                      log=log,
+                                      path=[path])
+    except ImportError:
+        et, ev, etb = sys.exc_info()
+        # try again, using default module, perhaps this is a
+        # /directory/function (as opposed to /directory/module/function)
+        func_path = module_name
+        module_name = "index"
+        try:
+            module = apache.import_module(module_name,
+                                          autoreload=autoreload,
+                                          log=log,
+                                          path=[path])
+        except ImportError:
+            # raise the original exception
+            raise et, ev, etb
+        
+    # does it have an __auth__?
+    realm, user, passwd = process_auth(req, module)
+
+    # resolve the object ('traverse')
+    try:
+        object = resolve_object(req, module, func_path, realm, user, passwd)
+    except AttributeError:
+        # changed, return the default path instead
+        #raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND
+        object = default
+    # not callable, a class or an unbound method
+    if (not callable(object) or 
+        type(object) is ClassType or
+        (hasattr(object, 'im_self') and not object.im_self)):
+
+        result = str(object)
+        
+    else:
+        # callable, (but not a class or unbound method)
+        
+        # process input, if any
+        req.form = util.FieldStorage(req, keep_blank_values=1)
+        
+        result = util.apply_fs_data(object, req.form, req=req)
+
+    if result or req.bytes_sent > 0 or req.next:
+        
+        if result is None:
+            result = ""
+        else:
+            result = str(result)
+
+        # unless content_type was manually set, we will attempt
+        # to guess it
+        if not req._content_type_set:
+            # make an attempt to guess content-type
+            if result[:100].strip()[:6].lower() == '<html>' \
+               or result.find('</') > 0:
+                req.content_type = 'text/html'
+            else:
+                req.content_type = 'text/plain'
+
+        if req.method != "HEAD":
+            req.write(result)
+        else:
+            req.write("")
+        return apache.OK
+    else:
+        req.log_error("mod_python.publisher: %s returned nothing." % `object`)
+        return apache.HTTP_INTERNAL_SERVER_ERROR
+
Index: python.old/aubio/web/html.py
===================================================================
--- python.old/aubio/web/html.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/web/html.py	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,286 @@
+from aubio.bench.node import *
+
+def parse_args(req):
+    req.basehref = BASEHREF
+    req.datadir = DATADIR
+    if req.path_info: path_info = req.path_info
+    else: path_info = '/'
+    location = re.sub('^/show_[a-z0-9]*/','',path_info)
+    location = re.sub('^/play_[a-z0-9]*/','',location)
+    location = re.sub('^/index/','',location)
+    location = re.sub('^/','',location)
+    location = re.sub('/$','',location)
+    datapath = "%s/%s" % (DATADIR,location)
+    respath  = "%s/%s" % (DATADIR,location)
+    last     = re.sub('/$','',location)
+    last     = last.split('/')[-1]
+    first    = path_info.split('/')[1]
+    # store some of this in the mp_request
+    req.location, req.datapath, req.respath = location, datapath, respath
+    req.first, req.last = first, last
+
+    if location:
+        if not (os.path.isfile(datapath) or 
+		os.path.isdir(datapath) or 
+		location in ['feedback','email']):
+		# the path was not understood
+		from mod_python import apache
+		req.write("<html> path not found %s</html>" % (datapath))
+		raise apache.SERVER_RETURN, apache.OK
+		#from mod_python import apache
+		#raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND
+
+def navigation(req):
+    """ main html navigation header """
+    from mod_python import psp
+    req.content_type = "text/html"
+    parse_args(req)
+    datapath = req.datapath
+    location = req.location
+
+    # deal with session
+    if req.sess.is_new():
+	    msg = "<b>Welcome %s</b><br>" % req.sess['login']
+    else:
+	    msg = "<b>Welcome back %s</b><br>" % req.sess['login']
+
+    # start writing
+    tmpl = psp.PSP(req, filename='header.tmpl')
+    tmpl.run(vars = { 'title': "aubioweb / %s / %s" % (req.first,location),
+    		'basehref': '/~piem/',
+		'message': msg,
+    		'action': req.first})
+
+    req.write("<h2>Content of ")
+    print_link(req,"","/")
+    y = location.split('/')
+    for i in range(len(y)-1): 
+    	print_link(req,"/".join(y[:i+1]),y[i])
+	req.write(" / ")
+    req.write("%s</h2>\n" % y[-1])
+
+    a = {'show_info' : 'info',
+    	 'show_sound': 'waveform',
+    	 'show_onset': 'onset',
+    	 'index'     : 'index',
+	 'show_pitch': 'pitch',
+	 'play_m3u': 'stream (m3u/ogg)',
+	 'play_ogg': 'save (ogg)',
+	 'play_wav': 'save (wav)',
+	 }
+
+    # print task lists (only remaining tasks)
+    print_link(req,re.sub('%s.*'%req.last,'',location),"go up")
+    akeys = a.keys(); akeys.sort();
+    curkey = req.first
+    for akey in akeys: 
+        if akey != curkey:
+    		req.write(":: ")
+		print_link(req,"/".join((akey,location)),a[akey])
+	else:
+    		req.write(":: ")
+		req.write("<b>%s</b>" % a[akey])
+    req.write("<br>")
+
+    # list the content of the directories
+    listdir,listfiles = [],[]
+    if os.path.isdir(datapath):
+        listfiles = list_snd_files(datapath)
+    	listdir = list_dirs(datapath)
+	listdir.pop(0) # kick the current dir
+    elif os.path.isfile(datapath):
+        listfiles = [datapath]
+	listdir = [re.sub(req.last,'',location)]
+
+    link_list(req,listdir,title="Subdirectories")
+    link_list(req,listfiles,title="Files")
+
+def footer(req):
+    """ html navigation footer """
+    from mod_python import psp
+    tmpl = psp.PSP(req, filename='footer.tmpl')
+    tmpl.run(vars = { 'time': -req.mtime+req.request_time })
+
+def apply_on_data(req, func,**keywords):
+    # bug: hardcoded snd file filter
+    act_on_data(func,req.datapath,req.respath,
+    	filter="f  -maxdepth 1 -name '*.wav' -o -name '*.aif'",**keywords)
+
+def print_link(req,target,name,basehref=BASEHREF):
+    req.write("<a href='%s/%s'>%s</a>\n" % (basehref,target,name))
+
+def print_img(req,target,name='',basehref=BASEHREF):
+    if name == '': name = target
+    req.write("<img src='%s/%s' alt='%s' title='%s'>\n" % (basehref,target,name,name))
+
+def link_list(req,targetlist,basehref=BASEHREF,title=None):
+    if len(targetlist) > 1:
+        if title: req.write("<h3>%s</h3>"%title)
+        req.write('<ul>')
+        for i in targetlist:
+            s = re.split('%s/'%DATADIR,i,maxsplit=1)[1]
+            if s: 
+        	req.write('<li>')
+	    	print_link(req,s,s)
+        	req.write('</li>')
+        req.write('</ul>')
+
+def print_list(req,list):
+    req.write("<pre>\n")
+    for i in list: req.write("%s\n" % i)
+    req.write("</pre>\n")
+
+def print_command(req,command):
+    req.write("<h4>%s</h4>\n" % re.sub('%%','%',command))
+    def print_runcommand(input,output):
+        cmd = re.sub('(%)?%i','%s' % input, command)
+        cmd = re.sub('(%)?%o','%s' % output, cmd)
+        print_list(req,runcommand(cmd))
+    apply_on_data(req,print_runcommand)
+
+def datapath_to_location(input):
+    location = re.sub(DATADIR,'',input)
+    return re.sub('^/*','',location)
+
+## drawing hacks
+def draw_func(req,func):
+    import re
+    req.content_type = "image/png"
+    # build location (strip the func_path, add DATADIR)
+    location = re.sub('^/draw_[a-z]*/','%s/'%DATADIR,req.path_info)
+    location = re.sub('.png$','',location)
+    if not os.path.isfile(location):
+	from mod_python import apache
+	raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND
+    # replace location in func
+    cmd = re.sub('(%)?%i','%s' % location, func)
+    # add PYTHONPATH at the beginning, 
+    cmd = "%s%s 2> /dev/null" % (PYTHONPATH,cmd)
+    for each in runcommand(cmd):
+	req.write("%s\n"%each)
+
+def show_task(req,task):
+    def show_task_file(input,output,task):
+        location = datapath_to_location(input)
+        print_img(req,"draw_%s/%s" % (task,location))
+    navigation(req)
+    req.write("<h3>%s</h3>\n" % task)
+    apply_on_data(req,show_task_file,task=task)
+    footer(req)
+
+## waveform_foo
+def draw_sound(req):
+    draw_func(req,"aubioplot-audio %%i stdout 2> /dev/null")
+
+def show_sound(req):
+    show_task(req,"sound")
+
+## pitch foo
+def draw_pitch(req,threshold='0.3'):
+    draw_func(req,"aubiopitch -i %%i -p -m schmitt,yin,fcomb,mcomb -t %s -O stdout" % threshold)
+
+def show_pitch(req):
+    show_task(req,"pitch")
+
+## onset foo
+def draw_onset(req,threshold='0.3'):
+    draw_func(req,"aubiocut -i %%i -p -m complex -t %s -O stdout" % threshold)
+
+def show_onset(req,threshold='0.3',details=''):
+    def onset_file(input,output):
+        location = datapath_to_location(input)
+        print_img(req,"draw_onset/%s?threshold=%s"%(location,threshold))
+        print_link(req,"?threshold=%s" % (float(threshold)-0.1),"-")
+        req.write("%s\n" % threshold)
+        print_link(req,"?threshold=%s" % (float(threshold)+0.1),"+")
+	# bug: hardcoded sndfile extension 
+        anote = re.sub('\.wav$','.txt',input)
+	if anote == input: anote = ""
+        res = get_extract(input,threshold)
+        if os.path.isfile(anote):
+            tru = get_anote(anote)
+            print_list(req,get_results(tru,res,0.05))
+        else:
+            req.write("no ground truth found<br>\n")
+        if details:
+            req.write("<h4>Extraction</h4>\n")
+            print_list(req,res)
+        else:
+            req.write("<a href='%s/show_onset/%s?details=yes&amp;threshold=%s'>details</a><br>\n" %
+            	(req.basehref,location,threshold))
+        if details and os.path.isfile(anote):
+            req.write("<h4>Computed differences</h4>\n")
+            ldiffs = get_diffs(tru,res,0.05)
+            print_list(req,ldiffs)
+            req.write("<h4>Annotations</h4>\n")
+            print_list(req,tru)
+    navigation(req)
+    req.write("<h3>Onset</h3>\n")
+    apply_on_data(req,onset_file)
+    footer(req)
+
+def get_anote(anote):
+    import aubio.onsetcompare
+    # FIXME: should import with txtfile.read_datafile
+    return aubio.onsetcompare.load_onsets(anote)
+
+def get_diffs(anote,extract,tol):
+    import aubio.onsetcompare
+    return aubio.onsetcompare.onset_diffs(anote,extract,tol)
+
+def get_extract(datapath,threshold='0.3'):
+    cmd = "%saubiocut -v -m complex -t %s -i %s" % (PYTHONPATH,threshold,datapath)
+    lo = runcommand(cmd)
+    for i in range(len(lo)): lo[i] = float(lo[i])
+    return lo
+
+def get_results(anote,extract,tol):
+    import aubio.onsetcompare
+    orig, missed, merged, expc, bad, doubled = aubio.onsetcompare.onset_roc(anote,extract,tol)
+    s =("GD %2.8f\t"        % (100*float(orig-missed-merged)/(orig)),
+        "FP %2.8f\t"        % (100*float(bad+doubled)/(orig))       , 
+        "GD-merged %2.8f\t" % (100*float(orig-missed)/(orig))       , 
+        "FP-pruned %2.8f\t" % (100*float(bad)/(orig))		    )
+    return s
+
+# play m3u foo
+def play_m3u(req):
+    def show_task_file(input,output,task):
+        location = datapath_to_location(input)
+        req.write("http://%s%s/play_ogg/%s\n" % (HOSTNAME,BASEHREF,re.sub("play_m3u",task,location)))
+    req.content_type = "audio/mpegurl"
+    parse_args(req)
+    apply_on_data(req,show_task_file,task="play_ogg")
+
+# play wav foo
+def play_wav(req):
+    req.content_type = "audio/x-wav"
+    func = "cat %%i"
+    # build location (strip the func_path, add DATADIR)
+    location = re.sub('^/play_wav/','%s/'%DATADIR,req.path_info)
+    if not os.path.isfile(location):
+	from mod_python import apache
+	raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND
+    # replace location in func
+    cmd = re.sub('(%)?%i','%s' % location, func)
+    # add PYTHONPATH at the beginning, 
+    cmd = "%s 2> /dev/null" % cmd
+    for each in runcommand(cmd):
+	req.write("%s\n"%each)
+
+# play ogg foo
+def play_ogg(req):
+    req.content_type = "application/ogg"
+    func = "oggenc -o - %%i"
+    # build location (strip the func_path, add DATADIR)
+    location = re.sub('^/play_ogg/','%s/'%DATADIR,req.path_info)
+    location = re.sub('.ogg$','',location)
+    if not os.path.isfile(location):
+	from mod_python import apache
+	raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND
+    # replace location in func
+    cmd = re.sub('(%)?%i','%s' % location, func)
+    # add PYTHONPATH at the beginning, 
+    cmd = "%s 2> /dev/null" % cmd
+    for each in runcommand(cmd):
+	req.write("%s\n"%each)
Index: python.old/aubio/wscript_build
===================================================================
--- python.old/aubio/wscript_build	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
+++ python.old/aubio/wscript_build	(revision b554e41cfcf7d581dc3296f09dc846e5ffc65049)
@@ -0,0 +1,17 @@
+# vim:set syntax=python:
+
+pyaubio = ctx.new_task_gen(name = 'python-aubio',
+  features = 'c cshlib pyext',
+  source = '../../swig/aubio.i',
+  add_objects = 'sndfileio',
+  target = '_aubiowrapper',
+  use = ['aubio'],
+  uselib = ['SNDFILE'],
+  swig_flags = '-python -Wall',
+  includes = '. ../../src ../../examples')
+pyaubio.install_path = '${PYTHONDIR}/${PACKAGE}'
+
+# install python files 
+ctx.install_files('${PYTHONDIR}/${PACKAGE}/', ctx.path.ant_glob('**/*.py'))
+# install swig generated python file
+ctx.install_files('${PYTHONDIR}/${PACKAGE}/', '../../swig/aubiowrapper.py')
