ref: b4fd9d678481bb0b9d83690fc743827a930f6404
parent: 44755a05e0b7e7d2940ea2ea9d5d74b1ba51350e
author: Paul Brossier <piem@piem.org>
date: Sat Jul 4 08:42:48 EDT 2015
python.old: removed old code
--- a/python.old/README
+++ /dev/null
@@ -1,30 +1,0 @@
-# Here you will find some examples of python scripts and some evaluation
-# routines. The python interface for libaubio is generated using Swig.
-
-# To have it working before installation, you will need to set LD_LIBRARY_PATH.
-# for instance, to run the python script from within aubio/python/, you can use
-# '. README'
-
-export LD_LIBRARY_PATH=../src/.libs:../ext/.libs
-export PYTHONPATH=aubio/.libs
-
-echo """
-
-the aubio/ directory should be organised as follow:
-
- aubiowrapper.py,_aubiowrapper.so, aubio_wrap.c, aubio_wrap.o
- swig generated aubio interface
- aubioclass.py
- human usable interface
- plot/
- everything required to plot
- web/
- tools to use aubioweb.py
- bench/
- tools to explore a database of sound file and run benchmarks on it
- eval/
- tools to evaluate the performance of aubio extractors
- aubioweb.py
- a hack to pipe aubio in mod_python
-
-"""
--- a/python.old/aubio/__init__.py
+++ /dev/null
@@ -1,28 +1,0 @@
-"""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 *
--- a/python.old/aubio/aubioclass.py
+++ /dev/null
@@ -1,160 +1,0 @@
-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)
-
--- a/python.old/aubio/bench/broadcast.py
+++ /dev/null
@@ -1,25 +1,0 @@
-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
-
--- a/python.old/aubio/bench/config.py
+++ /dev/null
@@ -1,22 +1,0 @@
-
-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)
--- a/python.old/aubio/bench/node.py
+++ /dev/null
@@ -1,224 +1,0 @@
-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 "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,
-
- def pretty_titles(self,sep='|'):
- for i in self.printnames:
- print self.formats[i] % i, sep,
-
- 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()
-
--- a/python.old/aubio/bench/onset.py
+++ /dev/null
@@ -1,303 +1,0 @@
-
-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)
-
-
--- a/python.old/aubio/gnuplot.py
+++ /dev/null
@@ -1,222 +1,0 @@
-"""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
--- a/python.old/aubio/median.py
+++ /dev/null
@@ -1,69 +1,0 @@
-"""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)
-
--- a/python.old/aubio/onsetcompare.py
+++ /dev/null
@@ -1,143 +1,0 @@
-"""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
--- a/python.old/aubio/plot/notes.py
+++ /dev/null
@@ -1,90 +1,0 @@
-__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)
-
--- a/python.old/aubio/task/__init__.py
+++ /dev/null
@@ -1,9 +1,0 @@
-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
--- a/python.old/aubio/task/beat.py
+++ /dev/null
@@ -1,262 +1,0 @@
-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)
--- a/python.old/aubio/task/cut.py
+++ /dev/null
@@ -1,42 +1,0 @@
-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)
-
-
--- a/python.old/aubio/task/notes.py
+++ /dev/null
@@ -1,159 +1,0 @@
-
-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')
-
--- a/python.old/aubio/task/onset.py
+++ /dev/null
@@ -1,220 +1,0 @@
-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')
--- a/python.old/aubio/task/params.py
+++ /dev/null
@@ -1,33 +1,0 @@
-
-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
-
--- a/python.old/aubio/task/pitch.py
+++ /dev/null
@@ -1,234 +1,0 @@
-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')
-
--- a/python.old/aubio/task/silence.py
+++ /dev/null
@@ -1,28 +1,0 @@
-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"
-
-
-
--- a/python.old/aubio/task/task.py
+++ /dev/null
@@ -1,53 +1,0 @@
-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
--- a/python.old/aubio/txtfile.py
+++ /dev/null
@@ -1,47 +1,0 @@
-"""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
-
--- a/python.old/aubio/web/browser.py
+++ /dev/null
@@ -1,167 +1,0 @@
- #
- # 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
-
--- a/python.old/aubio/web/html.py
+++ /dev/null
@@ -1,286 +1,0 @@
-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&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)
--- a/python.old/aubio/wscript_build
+++ /dev/null
@@ -1,17 +1,0 @@
-# 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')
--- a/python.old/aubiocompare-onset
+++ /dev/null
@@ -1,114 +1,0 @@
-#! /usr/bin/python
-
-"""Copyright (C) 2004 Paul Brossier <piem@altern.org>
-
-print aubio.__LICENSE__ for the terms of use
-
-or see LICENSE.txt in the aubio installation directory.
-"""
-__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/>.
-"""
-
-
-__HELP__ = """\
-# required arguments
- -c targetfilename
- -o detectfilename
-(both must be text files with 1 time a line expressed in seconds)
-
-# optional arguments
- -D <delay> delay in seconds
- -v verbose mode
- -d debug mode
-
-# output
-results:number of correct detections
- number of incorrect detections
- number of doubled detections
- number of total detections
- number of total targets
-
-# example:
-$ aubioonset-comp -c checked-onsets.txt -o handlab-onsets.txt -v
-( gd fp dd ) tot / real
-( 5 4 0 ) 9 / 9
-55.5555555556 %GD 44.4444444444 %FP 0.0 %OD
-
-# bugs
-does not scale to very long lists
-"""
-
-import sys
-from aubio.onsetcompare import onset_roc, onset_diffs
-from aubio.txtfile import read_datafile
-
-# default values
-fileo=None;filec=None;vmode=None;dmode=None;delay=0.
-# default tolerance is 50 ms
-#tol = 0.050
-tol = 0.048
-# default mode is onset
-mode = 'onset'
-
-while len(sys.argv) >=2:
- option = sys.argv[1]; del sys.argv[1]
- if option == '-h': print __HELP__; sys.exit()
- if option == '-o': fileo = sys.argv[1]; del sys.argv[1]
- if option == '-c': filec = sys.argv[1]; del sys.argv[1]
- if option == '-v': vmode = 'verbose'
- if option == '-d': dmode = 'debug'
- if option == '-D': delay = float(sys.argv[1]); del sys.argv[1]
- if option == '-tol': tol = float(sys.argv[1]); del sys.argv[1]
- if option == '-l': mode = 'localisation'
-
-# arguments required
-if (not fileo) or (not filec):
- print 'wrong set of arguments. use \'-h\' for help'
- sys.exit('error: needs at least \'-c targets.txt -o detected.txt\'')
-
-# load files
-ltru, lres = read_datafile(fileo,depth=0),read_datafile(filec,depth=0)
-
-# delay onsets as required with -D
-if delay:
- for i in range(len(lres)):
- lres[i] = lres[i] + delay
-# compute errors types
-if mode == 'localisation':
- l = onset_diffs(ltru,lres,tol)
- for i in l: print "%.3f" % i
-else:
- orig, missed, merged, expc, bad, doubled = onset_roc(ltru,lres,tol)
-
- # print results
- #print "orig, missed, merged, expc, bad, doubled:"
- if vmode=='verbose':
- print "orig", orig
- print "expc", expc
- print "missed",missed
- print "merged", merged
- print "bad", bad
- print "doubled", doubled
- print "correct", orig-missed-merged
- print "GD %2.8f\t" % (100*float(orig-missed-merged)/(orig)),
- print "FP %2.8f\t" % (100*float(bad+doubled)/(orig)) ,
- print "GD-merged %2.8f\t" % (100*float(orig-missed)/(orig)) ,
- print "FP-pruned %2.8f\t" % (100*float(bad)/(orig))
- else:
- print orig, missed, merged, expc, bad, doubled
--- a/python.old/aubiodiffs-onset
+++ /dev/null
@@ -1,86 +1,0 @@
-#! /usr/bin/python
-
-__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/>.
-"""
-
-__HELP__ = """\
-# required arguments
- -c targetfilename
- -o detectfilename
-(both must be text files with 1 time a line expressed in seconds)
-
-# optional arguments
- -D <delay> delay in seconds
- -v verbose mode
- -d debug mode
-
-# output
-results:number of correct detections
- number of incorrect detections
- number of doubled detections
- number of total detections
- number of total targets
-
-# example:
-$ aubioonset-comp -c checked-onsets.txt -o handlab-onsets.txt -v
-( gd fp dd ) tot / real
-( 5 4 0 ) 9 / 9
-55.5555555556 %GD 44.4444444444 %FP 0.0 %OD
-
-# bugs
-does not scale to very long lists
-"""
-
-import sys
-from aubio.onsetcompare import onset_diffs
-from aubio.txtfile import read_datafile
-
-# default values
-fileo=None;filec=None;vmode=None;dmode=None;delay=0.
-# default tolerance is 50 ms
-#tol = 0.050
-tol = 0.048
-
-while len(sys.argv) >=2:
- option = sys.argv[1]; del sys.argv[1]
- if option == '-h': print __HELP__; sys.exit()
- if option == '-o': fileo = sys.argv[1]; del sys.argv[1]
- if option == '-c': filec = sys.argv[1]; del sys.argv[1]
- if option == '-v': vmode = 'verbose'
- if option == '-d': dmode = 'debug'
- if option == '-D': delay = float(sys.argv[1]); del sys.argv[1]
- if option == '-tol': tol = float(sys.argv[1]); del sys.argv[1]
-
-# arguments required
-if (not fileo) or (not filec):
- print 'wrong set of arguments. use \'-h\' for help'
- sys.exit('error: needs at least \'-c targets.txt -o detected.txt\'')
-
-# load files
-ltru, lres = read_datafile(fileo,depth=0),read_datafile(filec,depth=0)
-
-# delay onsets as required with -D
-if delay:
- for i in range(len(lres)):
- lres[i] = lres[i] + delay
-# compute errors types
-l = onset_diffs(ltru,lres,tol)
-# print with 1ms precision
-for i in l: print "%.3f" % float(i)
-
--- a/python.old/aubiofilter-notes
+++ /dev/null
@@ -1,94 +1,0 @@
-#!/usr/bin/python
-
-""" this file is used to get filter the (old) output format of aubionotes """
-
-# default parameters
-__eps = [0.250,0.50] # minimum length, pitch tolerance (ms,midipitch)
-__plot = 0 # -P (command line switch)
-__delay = 0.0 # -D <value> (fixed delay for score alignement)
-__winlength = 10 # -w <value> (window length for pitch estimation in frames)
-
-import getopt
-import sys
-
-def parse_args (sysargs):
- from getopt import gnu_getopt
- shortopts ='i:o:t:p:w:D:P:'
- longopts =('input=','output=','tolpitch=','toltime=','winlength=','delay','plot=')
- args,tmp = gnu_getopt(sysargs,shortopts,longopts)
- assert len(args) > 1
- plot = __plot
- delay = __delay
- eps = __eps
- winlength = __winlength
- plot = __plot
- fileout = '/tmp/testprint.ps'
- args.sort()
- for i in range(len(args)): # a bad way
- if args[i][0] == '-i' or args[i][0] == '--input':
- fileorg = args[i][1]
- if args[i][0] == '-o' or args[i][0] == '--output':
- fileerr = args[i][1]
- if args[i][0] == '-t' or args[i][0] == '--toltime':
- eps[0] = float(args[i][1])
- if args[i][0] == '-p' or args[i][0] == '--tolpitch':
- eps[1] = float(args[i][1])
- if args[i][0] == '-D' or args[i][0] == '--delay':
- delay = float(args[i][1])
- if args[i][0] == '-w' or args[i][0] == '--winlength':
- winlength = int(args[i][1])
- if args[i][0] == '-P' or args[i][0] == '--plot':
- plot = 1
- fileout = args[i][1]
- return fileorg,fileerr,eps,winlength,plot,delay,fileout
-
-def usage():
- print __file__, "with at least some arguments"
-
-def main():
- try:
- opts,args = getopt.getopt(sys.argv[1:],
- "hvo:i:p:P",
- ["help", "output=", "verbose", "input=", "plot="])
- except getopt.GetoptError:
- usage()
- sys.exit(2)
-
- input = None
- output = None
- verbose = False
- winlength = __winlength
- plot = __plot
- eps = __eps
-
- for o, a in opts:
- if o in ("-v", "--verbose"):
- verbose = True
- if o in ("-h", "--help"):
- usage()
- sys.exit(2)
- if o in ("--output"):
- output = a
- if o in ("-i", "--input"):
- input = a
- if o in ("-P", "--plot"):
- plot = 1
-
- assert input != None and input != "", "no input file"
-
- from aubio import notefilter,txtfile,gnuplot
- """ load midi and raw data """
- from numpy import array
- notelist = array(txtfile.read_datafile(input))
- """ filter it out """
- notelist_filtered = notefilter.segraw_onsets4(notelist,winlength,eps)
- if verbose == 1 :
- for a,b in notelist_filtered:
- print a,b
- """ plot results """
- if plot == 1 :
- gnuplot.plotnote(notelist_filtered,title=input,fileout=output)
-
-if __name__ == "__main__":
- main()
-
--- a/python.old/aubioinput.py
+++ /dev/null
@@ -1,141 +1,0 @@
-#! /usr/bin/python
-
-import pygst
-pygst.require('0.10')
-import gst
-import gobject
-gobject.threads_init ()
-
-def gst_buffer_to_numpy_array(buffer, chan):
- import numpy
- samples = numpy.frombuffer(buffer.data, dtype=numpy.float32)
- if chan == 1:
- return samples.T
- else:
- samples.resize([len(samples)/chan, chan])
- return samples.T
-
-class AubioSink(gst.BaseSink):
- _caps = gst.caps_from_string('audio/x-raw-float, \
- rate=[ 1, 2147483647 ], \
- channels=[ 1, 2147483647 ], \
- endianness={ 1234, 4321 }, \
- width=32')
-
- __gsttemplates__ = (
- gst.PadTemplate ("sink",
- gst.PAD_SINK,
- gst.PAD_ALWAYS,
- _caps),
- )
-
- def __init__(self, name, process):
- self.__gobject_init__()
- self.set_name(name)
- self.process = process
- self.adapter = gst.Adapter()
- self.set_property('sync', False)
- self.pos = 0
-
- def set_property(self, name, value):
- if name == 'hopsize':
- # blocksize is in byte, convert from hopsize
- from struct import calcsize
- self.set_property('blocksize', value * calcsize('f'))
- else:
- super(gst.BaseSink, self).set_property(name, value)
-
- def do_render(self, buffer):
- blocksize = self.get_property('blocksize')
- caps = buffer.get_caps()
- chan = caps[0]['channels']
- self.adapter.push(buffer)
- while self.adapter.available() >= blocksize:
- block = self.adapter.take_buffer(blocksize)
- v = gst_buffer_to_numpy_array(block, chan)
- if self.process:
- self.process(v, self.pos)
- self.pos += 1
- remaining = self.adapter.available()
- if remaining < blocksize and remaining > 0:
- block = self.adapter.take_buffer(remaining)
- v = gst_buffer_to_numpy_array(block, chan)
- if self.process:
- self.process(v, self.pos)
- self.pos += 1
- return gst.FLOW_OK
-
-gobject.type_register(AubioSink)
-
-class aubioinput(gst.Bin):
-
- ret = 0
-
- def __init__(self, uri, process = None, hopsize = 512,
- caps = None):
- if uri.startswith('/'):
- from urllib import quote
- uri = 'file://'+quote(uri)
- src = gst.element_factory_make('uridecodebin')
- src.set_property('uri', uri)
- src.connect('pad-added', self.source_pad_added_cb)
- conv = gst.element_factory_make('audioconvert')
- self.conv = conv
- rsmpl = gst.element_factory_make('audioresample')
- capsfilter = gst.element_factory_make('capsfilter')
- if caps:
- capsfilter.set_property('caps', gst.caps_from_string(caps))
- sink = AubioSink("AubioSink", process = process)
- sink.set_property('hopsize', hopsize) # * calcsize('f'))
-
- self.pipeline = gst.Pipeline()
-
- self.bus = self.pipeline.get_bus()
- self.bus.add_signal_watch()
- self.bus.connect('message', self.on_eos)
-
- self.apad = conv.get_pad('sink')
-
- self.pipeline.add(src, conv, rsmpl, capsfilter, sink)
-
- gst.element_link_many(conv, rsmpl, capsfilter, sink)
-
- self.mainloop = gobject.MainLoop()
- self.pipeline.set_state(gst.STATE_PLAYING)
-
- def run(self):
- self.mainloop.run()
- return self.ret
-
- def source_pad_added_cb(self, src, pad):
- name = pad.get_caps()[0].get_name()
- if name == 'audio/x-raw-float' or name == 'audio/x-raw-int':
- pad.link(self.conv.get_pad("sink"))
-
- def source_pad_removed_cb(self, src, pad):
- pad.unlink(self.conv.get_pad("sink"))
-
- def on_eos(self, bus, msg):
- if msg.type == gst.MESSAGE_EOS:
- self.bus.remove_signal_watch()
- self.pipeline.set_state(gst.STATE_PAUSED)
- self.mainloop.quit()
- elif msg.type == gst.MESSAGE_ERROR:
- print "ERROR", msg.parse_error()
- self.bus.remove_signal_watch()
- self.pipeline.set_state(gst.STATE_PAUSED)
- self.mainloop.quit()
- self.ret = 1 # set return value to 1 in case of error
-
-if __name__ == '__main__':
- import sys
- if len(sys.argv) < 2:
- print "Usage: %s <filename>" % sys.argv[0]
- sys.exit(1)
- for filename in sys.argv[1:]:
- peak = [0.] # use a mutable
- def process(buf, hop):
- peak[0] = max( peak[0], abs(buf.max()) )
- a = aubioinput(filename, process = process, hopsize = 512)
- if a.run() == 0: # only display the results if no
- print "Finished reading %s, peak value is %f" % (filename, max(peak))
--- a/python.old/aubionotes
+++ /dev/null
@@ -1,79 +1,0 @@
-#!/usr/bin/python
-
-def do(filein,threshold):
-
- import aubio.aubioclass
- import aubio.median
- from math import floor
- hopsize = 512
- bufsize = 4096
- channels = 1
- frameread = 0
- silthres = -80.
- filei = aubio.aubioclass.sndfile(filein)
- srate = filei.samplerate()
- myvec = aubio.aubioclass.fvec(hopsize,channels)
- readsize = filei.read(hopsize,myvec)
- ppick = aubio.aubioclass.pitchpick(bufsize,hopsize,channels,myvec,srate)
- opick = aubio.aubioclass.onsetpick(bufsize,hopsize,channels,myvec,threshold)
- mylist = list()
-
- wassilence = 0
- lastpitch = 0
- starttime = 0
- while(readsize==hopsize):
- readsize = filei.read(hopsize,myvec)
- val = ppick.do(myvec)
- midival = aubio.aubioclass.bintomidi(val,srate,bufsize)
- isonset,onset = opick.do(myvec)
- now = (frameread)*hopsize/(srate+0.)
- issilence = aubio.aubioclass.aubio_silence_detection(myvec.vec,silthres)
-
- estmidival = 0
- if (issilence == 1):
- if (wassilence == 0):
- #outputnow
- endtime = (frameread-3)*hopsize/(srate+0.)
- if len(mylist) > 5 :
- estmidival = aubio.median.percental(mylist,len(mylist)/2)
- print "sil", starttime, endtime, estmidival
- #resetnow
- mylist = list()
- else:
- wassilence = 1
- else:
- if isonset == 1:
- if (wassilence == 0):
- #outputnow
- endtime = (frameread-3)*hopsize/(srate+0.)
- #estmidival = aubio.median.percental(around(array(mylist)),len(mylist)//2)
- if len(mylist) > 5 :
- estmidival = aubio.median.percental(mylist,len(mylist)/2)
- print starttime, endtime, estmidival
- #resetnow
- mylist = list()
- #store start time
- starttime = (frameread-3)*hopsize/(srate+0.)
- else:
- """
- if(listfull):
- #outputnow
- endtime = (frameread-3)*hopsize/(srate+0.)
- print starttime, endtime, estimmidival
- else:
- """
- #bufferize
- if midival > 50 and midival < 75:
- mylist.append(floor(midival))
- wassilence = 0
-
-
- #elif( midival > 45 ):
- # mylist.append(( now , midival+12 ))
- #mylist.append(toappend)
- frameread += 1
-
-
-if __name__ == "__main__":
- import sys
- do(sys.argv[1],sys.argv[2])
--- a/python.old/aubiopitch
+++ /dev/null
@@ -1,131 +1,0 @@
-#!/usr/bin/python
-
-""" this file was written by Paul Brossier
- it is released under the GNU/GPL license.
-"""
-
-import sys
-from aubio.task import *
-
-usage = "usage: %s [options] -i soundfile" % sys.argv[0]
-
-
-def parse_args():
- from optparse import OptionParser
- parser = OptionParser(usage=usage)
- parser.add_option("-i","--input",
- action="store", dest="filename",
- help="input sound file")
- parser.add_option("-m","--mode",
- action="store", dest="mode", default='yinfft',
- help="pitch detection mode [default=mcomb] \
- mcomb|yin|fcomb|schmitt")
- parser.add_option("-u","--units",
- action="store", dest="omode", default="freq",
- help="output pitch in units [default=Hz] \
- freq|midi|cent|bin")
- parser.add_option("-B","--bufsize",
- action="store", dest="bufsize", default=None,
- help="buffer size [default=2048]")
- parser.add_option("-H","--hopsize",
- action="store", dest="hopsize", default=None,
- help="overlap size [default=512]")
- parser.add_option("-t","--threshold",
- action="store", dest="threshold", default=0.1,
- help="pitch threshold (for yin) [default=0.1]")
- parser.add_option("-s","--silence",
- action="store", dest="silence", default=-70,
- help="silence threshold [default=-70]")
- parser.add_option("-D","--delay",
- action="store", dest="delay",
- help="number of seconds frames to take back [default=0]")
- parser.add_option("-S","--smoothing",
- action="store", dest="smoothing", default=False,
- help="use a median filter of N frames [default=0]")
- parser.add_option("-M","--maximum",
- action="store", dest="pitchmax", default=False,
- help="maximum pitch value to look for (Hz) [default=20000]")
- parser.add_option("-l","--minimum",
- action="store", dest="pitchmin", default=False,
- help="minimum pitch value to look for (Hz) [default=20]")
- # to be implemented
- parser.add_option("-n","--note",
- action="store_true", dest="note", default=False,
- help="NOT IMPLEMENTED output notes")
- # plotting functions
- parser.add_option("-T","--plottruth",
- action="store_true", dest="plottruth", default=False,
- help="draw plot of the ground truth pitch track")
- parser.add_option("-p","--plot",
- action="store_true", dest="plot", default=False,
- help="draw plot of the pitch track")
- 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("-O","--outplot",
- action="store", dest="outplot", default=None,
- help="save the plot to output.{ps,png,svg} instead of displaying it")
- parser.add_option("-v","--verbose",
- action="store_true", dest="verbose", default=True,
- help="make lots of noise")
- parser.add_option("-q","--quiet",
- action="store_false", dest="verbose", default=True,
- help="be quiet")
- (options, args) = parser.parse_args()
- if not options.bufsize:
- if options.mode == "yin": options.bufsize = 1024
- if options.mode == "schmitt": options.bufsize = 2048
- if options.mode == "mcomb": options.bufsize = 4096
- if options.mode == "fcomb": options.bufsize = 4096
- else: options.bufsize = 2048
- if not options.hopsize:
- options.hopsize = float(options.bufsize) / 2
- if not options.filename:
- print "no file name given\n", usage
- sys.exit(1)
- return options, args
-
-options, args = parse_args()
-
-#print options.bufsize, options.hopsize
-
-filename = options.filename
-params = taskparams()
-params.samplerate = float(sndfile(filename).samplerate())
-params.hopsize = int(options.hopsize)
-params.bufsize = int(options.bufsize)
-params.step = params.samplerate/float(params.hopsize)
-params.yinthresh = float(options.threshold)
-params.silence = float(options.silence)
-params.verbose = options.verbose
-if options.smoothing: params.pitchsmooth = int(options.smoothing)
-if options.pitchmax: params.pitchmax = int(options.pitchmax)
-if options.pitchmin: params.pitchmin = int(options.pitchmin)
-#mintol = float(options.mintol)*step
-# default take back system delay
-if options.delay: params.pitchdelay = float(options.delay)
-
-if options.note:
- exit("not implemented yet")
-
-wplot,oplots,titles = [],[],[]
-modes = options.mode.split(',')
-for i in range(len(modes)):
- pitch = []
- params.pitchmode = modes[i]
- filetask = taskpitch(filename,params=params)
- pitch = filetask.compute_all()
- #print filetask.eval(pitch[i])
- if options.plot: filetask.plot(pitch,wplot,oplots,titles)
-
-if options.outplot:
- extension = options.outplot.split('.')[-1]
- outplot = '.'.join(options.outplot.split('.')[:-1])
-else:
- extension,outplot = None,None
-if options.plot:
- filetask.plotplot(wplot,oplots,titles,outplot=outplot,extension=extension,
- xsize=options.xsize,ysize=options.ysize,truth=options.plottruth)
--- a/python.old/aubioplot-audio
+++ /dev/null
@@ -1,31 +1,0 @@
-#!/usr/bin/python
-
-import sys
-from aubio.gnuplot import gnuplot_create,gnuplot_addargs,plot_audio
-
-usage = "usage: %s [options] -i soundfile" % sys.argv[0]
-
-def parse_args():
- from optparse import OptionParser
- parser = OptionParser(usage=usage)
- parser.add_option("-i","--input",
- action="store", dest="filename",
- help="input sound file")
- gnuplot_addargs(parser)
- (options, args) = parser.parse_args()
- if not options.filename:
- print "no file name given\n", usage
- sys.exit(1)
- return options, args
-
-options, args = parse_args()
-
-if options.outplot:
- extension = options.outplot.split('.')[-1]
- outplot = '.'.join(options.outplot.split('.')[:-1])
-else:
- extension = ''
- outplot = None
-
-g = gnuplot_create(outplot,extension,options)
-plot_audio(options.filename.split(','), g, options)
--- a/python.old/aubioplot-notes
+++ /dev/null
@@ -1,31 +1,0 @@
-#!/usr/bin/python
-
-def parse_args (sysargs):
- from getopt import gnu_getopt
- shortopts ='i:o:'
- longopts =('input=','output=')
- args,tmp = gnu_getopt(sysargs,shortopts,longopts)
- args.sort()
- filein,fileout= None,None
- for i in range(len(args)): # a bad way
- if args[i][0] == '-i' or args[i][0] == '--input':
- filein = args[i][1]
- if args[i][0] == '-o' or args[i][0] == '--output':
- fileout = args[i][1]
- assert filein != None, 'precise filein'
- return filein,fileout
-
-def main (sysargs) :
- from aubio.txtfile import read_datafile
- from aubio.gnuplot import plotnote,plotnote_do
- from numpy import array
- filein,fileout = parse_args(sysargs)
- #print 'checking', fileerr, 'against', fileorg
- """ load midi and raw data """
- d = plotnote(array(read_datafile(filein)),title=filein)
- plotnote_do(d,fileout=fileout)
-
-if __name__ == "__main__":
- import sys
- main(sys.argv[1:])
-
--- a/python.old/aubioplot-spec
+++ /dev/null
@@ -1,51 +1,0 @@
-#! /usr/bin/python
-
-""" this file was written by Paul Brossier
- it is released under the GNU/GPL license.
-"""
-
-import sys
-from aubio.gnuplot import gnuplot_create,gnuplot_addargs,plot_spec
-
-usage = "usage: %s [options] -i soundfile" % sys.argv[0]
-
-def parse_args():
- from optparse import OptionParser
- parser = OptionParser(usage=usage)
- parser.add_option("-i","--input",
- action="store", dest="filename",
- help="input sound file")
- parser.add_option("-M","--maxf",
- action="store", dest="maxf", default=10000.,
- type='float',help="higher frequency limit")
- parser.add_option("-L","--minf",
- action="store", dest="minf", default=0.,
- type='float',help="lower frequency limit")
- parser.add_option("-l","--log",
- action="store_true", dest="log", default=False,
- help="plot on a logarithmic scale")
- parser.add_option("-B","--bufsize", type='int',
- action="store", dest="bufsize", default=8192,
- help="buffer size [default=8192]")
- parser.add_option("-H","--hopsize", type='int',
- action="store", dest="hopsize", default=1024,
- help="overlap size [default=1024]")
- gnuplot_addargs(parser)
- (options, args) = parser.parse_args()
- if not options.filename:
- print "no file name given\n", usage
- sys.exit(1)
- return options, args
-
-options, args = parse_args()
-filename = options.filename
-
-if options.outplot:
- extension = options.outplot.split('.')[-1]
- outplot = '.'.join(options.outplot.split('.')[:-1])
-else:
- extension = ''
- outplot = None
-
-g = gnuplot_create(outplot,extension,options)
-plot_spec(filename, g, options)
--- a/python.old/aubioplot-yinfft
+++ /dev/null
@@ -1,135 +1,0 @@
-#! /usr/bin/python
-
-""" this file was written by Paul Brossier
- it is released under the GNU/GPL license.
-"""
-
-import sys,time
-from aubio.task import task,taskparams
-from aubio.aubioclass import fvec
-from aubio.gnuplot import gnuplot_create
-from aubio.aubiowrapper import *
-
-usage = "usage: %s [options] -i soundfile" % sys.argv[0]
-
-def parse_args():
- from optparse import OptionParser
- parser = OptionParser(usage=usage)
- parser.add_option("-i","--input",
- action="store", dest="filename",
- help="input sound file")
- parser.add_option("-n","--printframe",
- action="store", dest="printframe", default=-1,
- help="make a plot of the n_th frame")
- parser.add_option("-x","--xsize",
- action="store", dest="xsize", default=1.,
- help="define xsize for plot")
- parser.add_option("-y","--ysize",
- action="store", dest="ysize", default=1.,
- help="define ysize for plot")
- parser.add_option("-O","--outplot",
- action="store", dest="outplot", default=None,
- help="save plot to output.{ps,png}")
- (options, args) = parser.parse_args()
- if not options.filename:
- print "no file name given\n", usage
- sys.exit(1)
- return options, args
-
-def plotdata(x,y,plottitle="",**keyw):
- import Gnuplot
- return Gnuplot.Data(x, y, title="%s" % plottitle,**keyw)
-
-options, args = parse_args()
-filename = options.filename
-xsize = float(options.xsize)
-ysize = float(options.ysize)*2
-
-printframe = int(options.printframe)
-if printframe == -1:
- print "Will wait for ^D to skip to next plot"
- print "Press enter before to print to file"
-
-
-g = gnuplot_create()
-params = taskparams()
-params.hopsize = 2048 # 512
-params.bufsize = params.hopsize #2048
-taskfile = task(filename,params=params)
-
-yin = fvec(params.bufsize/2,1)
-
-t = [i for i in range(params.bufsize)]
-a = [0 for i in range(params.bufsize)]
-
-while (taskfile.readsize == params.hopsize):
- taskfile()
-
- n = [i for i in range(params.bufsize/2)]
- a = [taskfile.myvec.get(i,0) for i in range(params.hopsize/2)]
- aubio_pitchyin_diff(taskfile.myvec(),yin()) # compute d[t]
- c = [yin.get(i,0) for i in range(params.bufsize/2)]
- aubio_pitchyin_getcum(yin()) # compute d'[t]
- y = [yin.get(i,0) for i in range(params.bufsize/2)]
- thresh = [0.1 for i in range(params.bufsize/2)]
- #t.append((i/float(params.hopsize)+taskfile.frameread)*params.step),t.pop(0)
- d = [plotdata(n,a,plottitle="signal", with_='lines'),
- plotdata(n,c,plottitle="d[t]",axes='x1y2', with_='lines lt 1'),
- plotdata(n,y,plottitle="d'[t]",axes='x1y1', with_='lines lt 2'),
- plotdata(n,thresh,plottitle="threshold",axes='x1y1', with_='lines lt 3')]
- #g('set xrange [%f:%f]' % (t[0],t[-1]))
- #time.sleep(.2)
- g.reset()
- g('set yrange [-1:3]')
- g('set xrange [0:%d]' % (params.bufsize/2))
- g('set title \"%s\"' % "Example of period detection using YIN")
- if printframe == -1:
- g.replot(*d)
- a = sys.stdin.read()
- if a == "\n" or printframe == taskfile.frameread:
- from os.path import basename
- outplot = "_".join([basename(sys.argv[0]),'_'.join(basename(filename).split('.')),"%d" % taskfile.frameread])
- print outplot
- f = gnuplot_create(outplot=outplot,extension='ps')
- f('set size %f,%f;' % (xsize,ysize) )
- f('set lmargin %f' % (15*xsize))
- f('set rmargin %f' % (10*xsize))
- #f('set title \"%s\"' % "Example of period detection using YIN")
- f('set multiplot')
- f.ylabel('amplitude',offset=(+.5,0))
- f.xlabel('time (samples)')
- f('set size %f,%f;' % (xsize,ysize*0.4) )
- f('set orig %f,%f;' % (0,ysize*0.6) )
- sigmax = max(abs(min(a)),abs(max(a)))
- f('set yrange [%f:%f]' % (-1.3*sigmax,1.3*sigmax))
- f('set xrange [0:%d]' % (params.bufsize/2))
- f.plot(d[0])
-
- f.ylabel('')
- f.xlabel('lag (samples)')
- f('set bmargin %f' % (4*ysize))
- f('set size %f,%f;' % (xsize,ysize*0.6) )
- f('set orig %f,%f;' % (0,0) )
- f('set autoscale')
- f('set xrange [0:%d]' % (params.bufsize/2))
- f('set notitle')
- f('set y2tics')
- f('set ytics nomirror')
- f('set noytics')
- f('set key right')
- f.plot(d[1])
-
- f.ylabel('amplitude')
- f.xlabel('')
- f('set y2tics nomirror')
- f('set ytics nomirror')
- f('set noy2tics')
- f('set noxtics')
- f('set ytics')
- f('set key left')
- f.plot(d[2],d[3])
- #f('set yrange [-1:3]')
- #f.plot(*d)
- print "saved plot", outplot, 'ps'
- elif printframe < taskfile.frameread:
- break
--- a/python.old/aubioweb.py
+++ /dev/null
@@ -1,113 +1,0 @@
-#!/usr/bin/python
-
-doc = """
-This script works with mod_python to browse a collection of annotated wav files
-and results.
-
-you will need to have at least the following packages need to be installed (the
-name of the command line tool is precised in parenthesis):
-
-libapache-mod-python (apache2 prefered)
-sndfile-programs (sndfile-info)
-vorbis-tools (oggenc)
-python-gnuplot
-python-numpy
-
-Try the command line tools in aubio/python to test your installation.
-
-NOTE: this script is probably horribly insecure.
-
-example configuration for apache to put in your preferred virtual host.
-
-<Directory /home/piem/public_html/aubioweb>
- # Minimal config
- AddHandler mod_python .py
- # Disable these in production
- PythonDebug On
- PythonAutoReload on
- # Default handler in url
- PythonHandler aubioweb
- ## Authentication stuff (optional)
- #PythonAuthenHandler aubioweb
- #AuthType Basic
- #AuthName "Restricted Area"
- #require valid-user
- # make default listing
- DirectoryIndex aubioweb/
-</Directory>
-
-"""
-
-from aubio.web.html import *
-
-def handler(req):
- from aubio.web.browser import *
- from mod_python import Session
- req.sess = Session.Session(req)
- req.sess['login']='new aubio user'
- req.sess.save()
- return configure_handler(req,index)
-
-def index(req,threshold='0.3'):
- navigation(req)
- print_command(req,"sfinfo %%i")
- return footer(req)
-
-def show_info(req,verbose=''):
- navigation(req)
- print_command(req,"sndfile-info %%i")
- return footer(req)
-
-def feedback(req):
- navigation(req)
- req.write("""
- Please provide feedback below:
- <p>
- <form action="/~piem/aubioweb/email" method="POST">
- Name: <input type="text" name="name"><br>
- Email: <input type="text" name="email"><br>
- Comment: <textarea name="comment" rows=4 cols=20></textarea><br>
- <input type="submit">
- </form>
- """)
-
-WEBMASTER='piem@calabaza'
-SMTP_SERVER='localhost'
-
-def email(req,name,email,comment):
- import smtplib
- # make sure the user provided all the parameters
- if not (name and email and comment):
- return "A required parameter is missing, \
- please go back and correct the error"
- # create the message text
- msg = """\
-From: %s
-Subject: feedback
-To: %s
-
-I have the following comment:
-
-%s
-
-Thank You,
-
-%s
-
-""" % (email, WEBMASTER, comment, name)
- # send it out
- conn = smtplib.SMTP(SMTP_SERVER)
- try:
- conn.sendmail(email, [WEBMASTER], msg)
- except smtplib.SMTPSenderRefused:
- return """<html>please provide a valid email</html>"""
-
- conn.quit()
- # provide feedback to the user
- s = """\
-<html>
-Dear %s,<br>
-Thank You for your kind comments, we
-will get back to you shortly.
-</html>""" % name
- return s
--- a/python.old/bench-cluster-test
+++ /dev/null
@@ -1,9 +1,0 @@
-#! /usr/bin/python
-
-from aubio.bench.broadcast import *
-
-run_broadcast(remote_sync,'/home/testing')
-run_broadcast(remote_sync,'/home/testing','-n')
-run_broadcast(fetch_results,'/home/testing','-n')
-
-run_broadcast(remote_queue,'echo coucou')
--- a/python.old/bench-test
+++ /dev/null
@@ -1,13 +1,0 @@
-#! /usr/bin/python
-
-from aubio.bench.node import *
-
-datapath = '/var/www'
-respath = '/var/tmp'
-
-def my_print(input,output):
- cmd = "%s %s %s" % ("time sleep 0.3; echo",input,output)
- return runcommand(cmd,debug=0)
-
-act_on_results(mkdir,datapath,respath,filter='d')
-act_on_data(my_print,datapath,respath,suffix='.txt')
--- a/python.old/tests_demo_bench/onset/bench-delay
+++ /dev/null
@@ -1,62 +1,0 @@
-#! /usr/bin/python
-
-from aubio.bench.onset import benchonset
-from aubio.task.onset import taskonset
-from aubio.task.params import taskparams
-
-class mybenchonset(benchonset):
-
- def run_bench(self,modes=['dual'],thresholds=[0.5]):
- from os.path import dirname,basename
- self.thresholds = thresholds
- self.pretty_titles()
-
- for mode in modes:
- d = []
- self.params.onsetmode = mode
- self.params.localmin = True
- self.params.delay = 1.
- self.params.threshold = thresholds[0]
- #
- self.params.localmin = False
- self.params.delay = 0.
- self.dir_eval_print()
- self.plotdiffs(d,plottitle="Causal")
- #
- self.params.localmin = True
- self.params.delay = 0.
- self.dir_eval_print()
- self.plotdiffs(d,plottitle="Local min")
-
- self.params.localmin = False
- self.params.delay = 6.
- self.dir_eval_print()
- self.plotdiffs(d,plottitle="Fixed delay")
-
- #self.plotplotdiffs(d)
- outplot = "_-_".join(("delay",mode,basename(self.datadir) ))
- for ext in ("png","svg","ps"):
- self.plotplotdiffs(d,outplot=outplot,extension=ext)
-
-if __name__ == "__main__":
- import sys
- if len(sys.argv) > 1: datapath = sys.argv[1]
- else: print "ERR: a path is required"; sys.exit(1)
- modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual']
- #thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2]
- #modes = [ 'hfc' ]
- thresholds = [0.5]
-
- #datapath = "%s%s" % (DATADIR,'/onset/DB/*/')
- respath = '/var/tmp/DB-testings'
-
- benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True)
- benchonset.params = taskparams()
- benchonset.task = taskonset
- benchonset.valuesdict = {}
-
- try:
- #benchonset.auto_learn2(modes=modes)
- benchonset.run_bench(modes=modes,thresholds=thresholds)
- except KeyboardInterrupt:
- sys.exit(1)
--- a/python.old/tests_demo_bench/onset/bench-onset
+++ /dev/null
@@ -1,68 +1,0 @@
-#! /usr/bin/python
-
-from aubio.task import *
-
-from aubio.bench.onset import mmean, stdev, benchonset
-
-class mybenchonset(benchonset):
-
- def run_bench(self,modes=['dual'],thresholds=[0.5]):
- from os.path import dirname,basename
- self.thresholds = thresholds
- self.pretty_titles()
- d,e,f,g = [],[],[],[]
- for mode in modes:
- self.vlist = []
- self.params.onsetmode = mode
- #self.params.localmin = True
-
- for threshold in self.thresholds:
- self.params.threshold = threshold
- self.dir_eval_print()
- self.vlist.append(self.v)
- self.plotroc(d)
- self.plotfmeas(e)
- self.plotpr(f)
- #self.plothistcat(g)
-
-
-
- #self.plotplotroc(d)
- #self.plotplotfmeas(e)
- #self.plotplotpr(f)
- outplot = basename(self.datadir)
- for ext in ("png","svg","ps"):
- self.plotplotroc(d,outplot=outplot,extension=ext)
- self.plotplotfmeas(e,outplot=outplot,extension=ext)
- self.plotplotpr(f,outplot=outplot,extension=ext)
- #self.plotplothistcat(g,outplot=outplot,extension=ext)
-
-if __name__ == "__main__":
- import sys
- if len(sys.argv) > 1: datapath = sys.argv[1]
- else: print "ERR: a path is required"; sys.exit(1)
- modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual']
- thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2]
- #modes = [ 'hfc' ]
- #thresholds = [0.5]
-
- #datapath = "%s%s" % (DATADIR,'/onset/DB/*/')
- respath = '/var/tmp/DB-testings'
-
- benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True)
- benchonset.params = taskparams()
- benchonset.params.dcthreshold = -1.
- benchonset.params.silence = -100.
- benchonset.params.delay = 5.
- benchonset.params.bufsize = 1024
- benchonset.params.hopsize = 256
- benchonset.params.step = float(benchonset.params.hopsize)/float(benchonset.params.samplerate)
- benchonset.params.mintol = 4.1
- benchonset.task = taskonset
- benchonset.valuesdict = {}
-
- try:
- #benchonset.auto_learn2(modes=modes)
- benchonset.run_bench(modes=modes,thresholds=thresholds)
- except KeyboardInterrupt:
- sys.exit(1)
--- a/python.old/tests_demo_bench/onset/bench-window
+++ /dev/null
@@ -1,59 +1,0 @@
-#! /usr/bin/python
-
-from aubio.bench.onset import benchonset
-from aubio.task.onset import taskonset
-from aubio.task.params import taskparams
-
-class mybenchonset(benchonset):
-
- def run_bench(self,modes=['dual'],thresholds=[0.5]):
- from os.path import dirname,basename
- self.thresholds = thresholds
- self.pretty_titles()
-
- for mode in modes:
-
- self.params.onsetmode = mode
- self.params.localmin = True
- self.params.delay = 1.
- self.params.threshold = thresholds[0]
- self.params.localmin = False
- #
- for delay in (0., 4.):
- d = []
- self.params.delay = delay
- for buf in (2048, 1024, 512):
- for hop in (buf/2, buf/4):
- self.params.bufsize = buf
- self.params.hopsize = hop
- self.params.step = float(self.params.hopsize)/float(self.params.samplerate)
- self.dir_eval_print()
- self.plotdiffs(d,plottitle="%s %s" % (buf,hop))
- #plotplotdiffs(d)
- outplot = "_-_".join(("window",mode,"delay-%s" % int(delay),
- basename(self.datadir) ))
- for ext in ("png","svg","ps"):
- self.plotplotdiffs(d,outplot=outplot,extension=ext)
-
-if __name__ == "__main__":
- import sys
- if len(sys.argv) > 1: datapath = sys.argv[1]
- else: print "ERR: a path is required"; sys.exit(1)
- modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual']
- #thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2]
- #modes = [ 'hfc' ]
- thresholds = [0.5]
-
- #datapath = "%s%s" % (DATADIR,'/onset/DB/*/')
- respath = '/var/tmp/DB-testings'
-
- benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True)
- benchonset.params = taskparams()
- benchonset.task = taskonset
- benchonset.valuesdict = {}
-
- try:
- #benchonset.auto_learn2(modes=modes)
- benchonset.run_bench(modes=modes,thresholds=thresholds)
- except KeyboardInterrupt:
- sys.exit(1)
--- a/python.old/tests_demo_bench/pitch/bench-pitch-isolated
+++ /dev/null
@@ -1,198 +1,0 @@
-#! /usr/bin/python
-
-from aubio.bench.node import *
-from aubio.task import *
-
-class benchpitch(bench):
-
- """ list of values to store per file """
- valuenames = ['mode']
- """ list of lists to store per file """
- valuelists = ['truth', 'osil', 'esil', 'opit', 'epit', 'echr',
- 'Msil', 'Mpit', 'Mchr',
- 'TotalPit', 'TotalPit', 'TotalChr' ]
- """ list of values to print per dir """
- printnames_total = [ 'mode', 'MinPit', 'MaxPit', 'TotalSil', 'TotalPit', 'TotalChr']
- printnames_notes = [ 'mode', 'Note', 'Sil', 'Pit', 'Chr']
- printnames = printnames_notes
-
- """ per dir """
- formats = {'mode': "%12s" ,
- 'truth': "%s",
- 'osil': "%s", 'esil': "%s",
- 'opit': "%s", 'epit': "%s", 'echr': "%s",
- 'Note': "%s", 'Sil': "%s", 'Chr': "%s", 'Pit': "%s",
- 'TotalPit': "%s", 'TotalSil': "%s", 'TotalChr': "%s",
- 'MinPit': "%s", 'MaxPit': "%s",
- 'Msil': "%s", 'Mpit': "%s", 'Mchr': "%s"}
-
- def dir_eval(self):
- """ evaluate statistical data over the directory """
- v = self.v
- v['mode'] = self.params.pitchmode
-
- def file_exec(self,input,output):
- filetask = self.task(input,params=self.params)
- computed_data = filetask.compute_all()
- osil, esil, opit, epit, echr = filetask.eval(computed_data,tol=0.5)
- self.v['truth'].append(int(filetask.truth))
- assert opit > 0
-
- self.v['osil'].append(osil)
- self.v['esil'].append(esil)
- self.v['opit'].append(opit)
- self.v['epit'].append(epit)
- self.v['echr'].append(echr)
-
- self.v['Msil'].append(esil/float(osil)*100.)
- self.v['Mpit'].append(epit/float(opit)*100.)
- self.v['Mchr'].append(echr/float(opit)*100.)
- #print results#, computed_data
- #print input, results, results - float(input.split('.')[-2])
-
- def run_bench(self,modes=['schmitt'],multiplot=0):
- from os.path import basename
- self.modes = modes
- self.pretty_titles()
- d = []
- for mode in self.modes:
- self.params.pitchmode = mode
- self.dir_exec()
- self.dir_eval()
- truth = [i for i in range(min(self.v['truth']),max(self.v['truth'])+1)]
- allOsil = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)]
- allEsil = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)]
- allOpit = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)]
- allEpit = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)]
- allEchr = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)]
- allMsil = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)]
- allMpit = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)]
- allMchr = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)]
- for i in range(len(self.v['truth'])):
- allOsil[self.v['truth'][i]-min(self.v['truth'])] += self.v['osil'][i]
- allEsil[self.v['truth'][i]-min(self.v['truth'])] += self.v['esil'][i]
- allOpit[self.v['truth'][i]-min(self.v['truth'])] += self.v['opit'][i]
- allEpit[self.v['truth'][i]-min(self.v['truth'])] += self.v['epit'][i]
- allEchr[self.v['truth'][i]-min(self.v['truth'])] += self.v['echr'][i]
- for i in range(len(truth)):
- allOsil[i] = max(1,allOsil[i])
- allOpit[i] = max(1,allOpit[i])
- allMsil[i] = allEsil[i]/float(allOsil[i])*100.
- allMpit[i] = allEpit[i]/float(allOpit[i])*100.
- allMchr[i] = allEchr[i]/float(allOpit[i])*100.
- self.v['Sil'], self.v['Pit'], self.v['Chr'] = allMsil[i], allMpit[i], allMchr[i]
- self.v['Note'] = truth[i]
- #self.printnames = self.printnames_notes
- self.pretty_print()
- self.v['TotalSil'] = sum(allMsil)/len(truth)
- self.v['TotalPit'] = sum(allMpit)/len(truth)
- self.v['TotalChr'] = sum(allMchr)/len(truth)
- self.v['MinPit'] = min(truth)
- self.v['MaxPit'] = max(truth)
- #self.printnames = self.printnames_total
- #self.pretty_print()
-
- plot = []
- self.plotpitchtessiture(plot,
- truth,
- allMpit,
- plottitle="%s %s" % (self.v['mode'],self.params.bufsize),
- plotmode='lines')
- """
- self.plotpitchtessiture(plot,
- truth,
- allMchr,
- plottitle="%s %s" % (self.v['mode'],"%12"),
- plotmode='lines')
- self.plotpitchtessiture(plot,
- truth,
- allMsil,
- plottitle="%s %s" % (self.v['mode'],"sil"),
- plotmode='lines')
- """
- title = basename(self.datadir)
- if multiplot:
- d.append(plot)
- else:
- d += plot
- outplot = "_-_".join(('pitchtessiture',title))
- self.xmin = min(self.v['truth']) #20.
- self.xmax = max(self.v['truth'])
- for ext in ('ps','png','svg'): #,''):
- self.plotplotpitchtessiture(d,
- plottitle="".join(['Performance against MIDI Note number (',
- title,
- ", %s" % len(self.sndlist), " samples)"]),
- outplot=outplot,
- extension=ext,multiplot=multiplot)
- #d.append('beta = .25,orig(x) title \"-2 octave\"')
- #d.append('beta = .50,orig(x) title \"-1 octave\"')
- #d.append('beta = 1.0,orig(x) title \"original\"')
- #d.append('beta = 2.0,orig(x) title \"+1 octave\"')
-
- """
- Plot functions
- """
-
- def plotpitchtessiture(self,d,lx,ly,plottitle="",plotmode='linespoints'):
- import Gnuplot, Gnuplot.funcutils
- d.append(Gnuplot.Data(lx, ly, with=plotmode, title="%s" % (plottitle) ))
-
- def plotplotpitchtessiture(self,d,plottitle='',outplot=0,extension='',multiplot=1):
- from aubio.gnuplot import gnuplot_create
- g = gnuplot_create(outplot=outplot,extension=extension)
- #g.title(plottitle)
- #g('orig(x) = beta*x')
- g.title(plottitle)
- g('set yrange [50:100]')
- # erase axis
- g('set xrange [%f:%f]' % (self.xmin,self.xmax)) #(self.xmax - (self.xmax-self.xmin)*5./4.,self.xmax))
- #g.plot(*d)
- g('set border 3')
- g('set xtics nomirror')
- g('set ytics nomirror')
- g('set key bottom')
- if multiplot:
- g('set multiplot')
- for i in range(len(d)):
- # plot onset detection functions
- g('set size 1,%f' % ( 1.0/float(len(d)) ) )
- g('set origin 0,%f' % ( 1.0*float(len(d)-i-1)/float(len(d)) ) )
- #g.ylabel('%Correct detections')
- g('set xrange [%f:%f]' % (self.xmin,self.xmax)) #(self.xmax - (self.xmax-self.xmin)*5./4.,self.xmax))
- g.plot(*d[i])
- g('unset title')
- g('unset multiplot')
- else:
- g.plot(*d)
-
-
-if __name__ == "__main__":
- import sys
- if len(sys.argv) > 1: datapath = sys.argv[1]
- else: print "error: a path is required"; sys.exit(1)
- if len(sys.argv) > 2:
- for each in sys.argv[3:-1]: print each
- modes = ['schmitt', 'yin', 'yinfft', 'mcomb', 'fcomb']
- #modes = ['mcomb']
-
- params = taskparams()
- params.bufsize = 2048 # 4096
- params.hopsize = 256
- params.silence = -60.
- params.pitchsmooth = 0
- params.pitchmax = 20000
- params.pitchmin = 20
- params.pitchyinfft = 0.95
- benchpitch = benchpitch(datapath,params=params)
- benchpitch.task = taskpitch
-
- #benchpitch.titles = [ 'mode', 'thres', 'avg', 'avgdist' ]
- #benchpitch.formats = ["%12s" , "| %6s", "| %6s", "| %6s", "| %6s", "| %6s" ]
- try:
- benchpitch.run_bench(modes=modes)
- except KeyboardInterrupt:
- print "Interrupted by user"
- sys.exit(1)
-
- sys.exit(0)
--- a/python.old/tests_demo_bench/pitch/bench-pitch-plot-isolated
+++ /dev/null
@@ -1,63 +1,0 @@
-#! /usr/bin/python
-
-if __name__ == '__main__':
- import sys, Gnuplot
- from aubio.gnuplot import gnuplot_create
- from aubio.txtfile import read_datafile
- from aubio.plot.keyboard import draw_keyboard
- lines = []
- titles = []
- for file in range(len(sys.argv)-1):
- l = read_datafile(sys.argv[file+1])
- notes, score = [],[]
- for i in range(len(l)):
- notes.append(l[i][0])
- score.append(l[i][2])
- lines.append(Gnuplot.Data(notes,score,
- with='linespoints',
- title=sys.argv[file+1].split('.')[-1]))
- titles.append(sys.argv[file+1].split('.')[-1])
- blacks,whites = draw_keyboard(firstnote = notes[0], lastnote = notes[-1],
- y0= 40, y1 = 50)
-
- g = gnuplot_create(sys.argv[file+1].split('.')[-3],'ps')
- #g = gnuplot_create('','')
- #g = gnuplot_create('/tmp/test','eps')
- g('set yrange [40:100]')
- #g('set xrange [%f:%f]' % (notes[0],notes[-1]+60))
- g('set size 0.5')
- g('set key outside')
-
- g('set border 3')
- g('set xtics nomirror')
- g('set ytics nomirror')
- multiplot = 1
- oplots = lines
- g('set size 1,2')
- if multiplot:
- height = 2.
- g('set lmargin 10')
- #g('set rmargin 15')
- g('set multiplot')
- g('set yrange [50:100]')
- g('set xrange [%f:%f]' % (notes[0],notes[-1]))
- g('set xtics %f,12' % notes[0])
- g('set nokey')
- for i in range(len(oplots)):
- g.ylabel(titles[i])
- g('set size %f,%f' % (1.,height*.85/float(len(oplots))))
- g('set origin 0,%f' % (height*(.15+.85*float(len(oplots)-i-1)/float(len(oplots)))))
- g.plot(oplots[i])
- g('set title "Raw pitch accuracy (%) against midi note numbers"')
- g('set noxtics')
- g('set noytics')
- g('set size %f,%f' % (1.,.15*height))
- g('set origin 0,%f' % 0)
- g('set yrange [40:50]')
- g('set xrange [%f:%f]' % (notes[0],notes[-1]))
- g.xlabel('')
- g.ylabel('')
- g.plot(whites,blacks)
- g('unset multiplot')
- else:
- g.plot(whites,blacks,*lines)
--- a/python.old/tests_demo_bench/tempo/demo-tempo
+++ /dev/null
@@ -1,313 +1,0 @@
-#! /usr/bin/python
-
-""" this file was written by Paul Brossier
- it is released under the GNU/GPL license.
-"""
-
-import sys,time
-from aubio.task import taskbeat,taskparams
-from aubio.aubioclass import fvec, aubio_autocorr
-from aubio.gnuplot import gnuplot_create, gnuplot_addargs
-from aubio.aubiowrapper import *
-from math import exp,log
-
-usage = "usage: %s [options] -i soundfile" % sys.argv[0]
-
-def parse_args():
- from optparse import OptionParser
- parser = OptionParser(usage=usage)
- parser.add_option("-i","--input",
- action="store", dest="filename",
- help="input sound file")
- parser.add_option("-n","--printframe",
- action="store", dest="printframe", default=-1,
- help="make a plot of the n_th frame")
- gnuplot_addargs(parser)
- (options, args) = parser.parse_args()
- if not options.filename:
- print "no file name given\n", usage
- sys.exit(1)
- return options, args
-
-def plotdata(x,y,plottitle="",**keyw):
- import Gnuplot
- return Gnuplot.Data(x, y, title="%s" % plottitle,**keyw)
-
-options, args = parse_args()
-filename = options.filename
-xsize = float(options.xsize)
-ysize = float(options.ysize)
-
-printframe = int(options.printframe)
-
-if options.outplot and printframe > 0:
- extension = options.outplot.split('.')[-1]
- outplot = '.'.join(options.outplot.split('.')[:-1])
-else:
- extension = ''
- outplot = None
-f = gnuplot_create(outplot=outplot,extension=extension,options=options)
-
-params = taskparams()
-params.onsetmode = 'specdiff'
-task = taskbeat(filename,params=params)
-
-hopsize = params.hopsize
-bufsize = params.bufsize
-btstep = task.btstep
-winlen = task.btwinlen
-laglen = winlen/4
-step = winlen/4
-
-timesig = 0
-maxnumelem = 4
-gp = 0
-counter = 0
-flagconst = 0
-constthresh = 3.901
-g_var = 3.901
-rp = 0
-rp1 = 0
-rp2 = 0
-g_mu = 0
-
-rayparam = 48/512.*winlen
-
-#t = [i for i in range(hopsize)]
-#tlong = [i for i in range(hopsize*(btstep-1))]
-#tall = [i for i in range(hopsize*btstep)]
-#a = [0 for i in range(hopsize*btstep)]
-dfx = [i for i in range(winlen)]
-dfframe = [0 for i in range(winlen)]
-dfrev = [0 for i in range(winlen)]
-acframe = [0 for i in range(winlen)]
-
-localacf = [0 for i in range(winlen)]
-inds = [0 for i in range(maxnumelem)]
-
-acx = [i for i in range(laglen)]
-acfout = [0 for i in range(laglen)]
-
-phwv = [0 for i in range(2*laglen)]
-phwvx = [i for i in range(2*laglen)]
-
-dfwvnorm = exp(log(2.0)*(winlen+2.)/rayparam);
-dfwv = [exp(log(2.)*(i+1.)/rayparam)/dfwvnorm for i in range(winlen)]
-
-gwv = [exp(-.5*(j+1.-g_mu)**2/g_var**2) for j in range(laglen)]
-rwv = [(i+1.)/rayparam**2 * exp(-(i+1.)**2 / (2.*rayparam)**2)
- for i in range(0,laglen)]
-acf = fvec(winlen,1)
-
-nrframe = 0
-while (task.readsize == params.hopsize):
- task()
- #print task.pos2
- #a[:-hopsize] = [i for i in a[-(btstep-1)*hopsize:]]
- #a[-hopsize:] = [task.myvec.get(i,0) for i in t]
-
- #g('set xrange [%f:%f]' % (t[0],t[-1]))
- #time.sleep(.2)
- if task.pos2==btstep-1:
- nrframe += 1
- dfframe = [task.dfframe.get(i,0) for i in range(winlen)]
- if printframe == nrframe or printframe == -1:
- d = [[plotdata(range(-winlen,0),dfframe,plottitle="onset detection", with='lines')]]
- # start beattracking_do
- for i in range(winlen):
- dfrev[winlen-1-i] = 0.
- dfrev[winlen-1-i] = dfframe[i]*dfwv[i]
- aubio_autocorr(task.dfframe(),acf());
- acframe = [acf.get(i,0) for i in range(winlen)]
- if not timesig:
- numelem = 4
- else:
- numelem = timesig
-
- old = 0
- acfout = [0 for i in range(winlen/4)]
- for i in range(1,laglen-1):
- for a in range(1,numelem+1):
- for b in range (1-a,a):
- acfout[i] += acframe[a*(i+1)+b-1] * 1./(2.*a-1.)*rwv[i]
- if old < acfout[i]:
- old = acfout[i]
- maxi = i
- rp = max(maxi,1);
-
- if printframe == nrframe or printframe == -1:
- rwvs = [rwv[i]*max(acframe) for i in range(len(rwv))]
- d += [[plotdata(acx,acfout,plottitle="comb filterbank", with='lines', axes='x1y1'),
- plotdata([rp,rp],[1.2*old,min(acfout)],plottitle="period", with='impulses', axes='x1y1'),
- plotdata(acx,rwvs,plottitle="L_w", with='lines', axes='x1y1')]]
-
- # getperiod
- inds = [0 for i in range(maxnumelem)]
- localacf = [0 for i in range(winlen)]
- period = 0
- for a in range(1,4+1):
- for b in range(1-a,a):
- localacf[a*rp+b-1] = acframe[a*rp+b-1]
- for i in range(numelem):
- maxindex = 0
- maxval = 0.0
- for j in range(rp*(i+1)+i):
- if localacf[j] > maxval:
- maxval = localacf[j]
- maxind = j
- localacf[j] = 0
- inds[i] = maxind
- for i in range(numelem):
- period += inds[i]/(i+1.)
- period = period/numelem
- #print "period", period
-
- # checkstate
- if gp:
- # context dependant model
- acfout = [0 for i in range(winlen/4)]
- old = 0
- for i in range(laglen-1):
- for a in range(timesig):
- for b in range(1-a,a):
- acfout[i] += acframe[a*(i+1)+b-1] * gwv[i]
- if old < acfout[i]:
- old = acfout[i]
- maxi = i
- gp = maxi
- else:
- # general model
- gp = 0
- #print "gp", gp
- if printframe == nrframe or printframe == -1:
- gwvs = [gwv[i]*max(acfout) for i in range(len(gwv))]
- d += [[plotdata(acx,acfout,plottitle="comb filterbank", with='lines', axes='x1y1'),
- plotdata(gp,old,plottitle="period", with='impulses', axes='x1y1'),
- plotdata(acx,gwvs,plottitle="L_{gw}", with='lines', axes='x1y1')]]
-
- if counter == 0:
- # initial step
- if abs(gp-rp) > 2.*constthresh:
- flagstep = 1
- counter = 3
- else:
- flagstep = 0
- #print "flagstep", flagstep
- #print "rp2,rp1,rp", rp2,rp1,rp
- acfw = [dfframe[i]*dfwv[i] for i in range(winlen)]
-
- if counter == 1 and flagstep == 1:
- # "3rd frame after flagstep set"
- if abs(2.*rp-rp1- rp2) < constthresh:
- flagconst = 1
- counter = 0
- else:
- flagconst = 0
- counter = 2
- elif counter > 0:
- counter -= 1
-
- rp2 = rp1; rp1 = rp
-
- if flagconst:
- # "first run of new hypothesis"
- gp = rp
- g_mu = gp
- timesig = 4 #FIXME
- gwv = [exp(-.5*(j+1.-g_mu)**2/g_var**2) for j in range(laglen)]
- flagconst = 0
- bp = gp
- phwv = [1 for i in range(2*laglen)]
- elif timesig:
- # "contex dependant"
- bp = gp
- if step > lastbeat:
- phwv = [exp(-.5*(1.+j-step+lastbeat)**2/(bp/8.)) for j in range(2*laglen)]
- else:
- print "NOT using phase weighting"
- phwv = [1 for i in range(2*laglen)]
- else:
- # "initial state"
- bp = rp
- phwv = [1 for i in range(2*laglen)]
-
- while bp < 25:
- print "WARNING, doubling the beat period"
- bp *= 2
-
- #
- phout = [0. for i in range(winlen)]
-
- kmax = int(winlen/float(bp));
-
- old = 0
- for i in range(bp):
- phout[i] = 0.
- for k in range(kmax):
- phout[i] += dfrev[i+bp*k] * phwv[i]
- if phout[i] > old:
- old = phout[i]
- maxi = i
- maxindex = maxi
- if (maxindex == winlen - 1): maxindex = 0
- phase = 1 + maxindex
- i = 1
- beat = bp - phase
- beats= []
- if beat >= 0: beats.append(beat)
- while beat+bp < step:
- beat += bp
- beats.append(beat)
- lastbeat = beat
- #print beats,
- #print "the lastbeat is", lastbeat
-
- # plot all this
- if printframe == nrframe or printframe == -1:
- phwvs = [phwv[i]*max(phout) for i in range(len(phwv))]
- d += [[plotdata(range(-laglen,0),phwvs[laglen:0:-1],plottitle="A_{gw}", with='lines',axes='x1y1'),
- plotdata(range(-laglen,0),phout[laglen:0:-1],plottitle="df", with='lines'),
- plotdata(-phase,old,plottitle="phase", with='impulses', axes='x1y1'),
- plotdata([i for i in beats],[old for i in beats],plottitle="predicted", with='impulses')
- ]]
- #d += [[plotdata(dfx,dfwv,plottitle="phase weighting", with='lines', axes='x1y2'),
- # plotdata(dfx,dfrev,plottitle="df reverse", with='lines', axes='x1y1')]]
- #d += [[plotdata(dfx,phout,plottitle="phase", with='lines', axes='x1y2')]]
- #d += [[plotdata(dfx,dfwv,plottitle="phase weighting", with='lines', axes='x1y2'),
- # plotdata(dfx,dfrev,plottitle="df reverse", with='lines', axes='x1y1')]]
- #d += [[plotdata(dfx,phout,plottitle="phase", with='lines', axes='x1y2')]]
-
- f('set lmargin 4')
- f('set rmargin 4')
- f('set size %f,%f' % (1.0*xsize,1.0*ysize) )
- f('set key spacing 1.3')
- f('set multiplot')
-
- f('set size %f,%f' % (1.0*xsize,0.33*ysize) )
- f('set orig %f,%f' % (0.0*xsize,0.66*ysize) )
- f('set xrange [%f:%f]' % (-winlen,0) )
- f.title('Onset detection function')
- f.xlabel('time (df samples)')
- f.plot(*d[0])
- f('set size %f,%f' % (0.5*xsize,0.33*ysize) )
- f('set orig %f,%f' % (0.0*xsize,0.33*ysize) )
- f('set xrange [%f:%f]' % (0,laglen) )
- f.title('Period detection: Rayleygh weighting')
- f.xlabel('lag (df samples)')
- f.plot(*d[1])
- f('set size %f,%f' % (0.5*xsize,0.33*ysize) )
- f('set orig %f,%f' % (0.5*xsize,0.33*ysize) )
- f('set xrange [%f:%f]' % (0,laglen) )
- f.title('Period detection: Gaussian weighting')
- f.xlabel('lag (df samples)')
- f.plot(*d[2])
- f('set size %f,%f' % (1.0*xsize,0.33*ysize) )
- f('set orig %f,%f' % (0.0*xsize,0.00*ysize) )
- f('set xrange [%f:%f]' % (-laglen,laglen) )
- f.title('Phase detection and predicted beats')
- f.xlabel('time (df samples)')
- f.plot(*d[3])
- f('set nomultiplot')
- if printframe == -1: a = sys.stdin.read()
- elif 0 < printframe and printframe < nrframe:
- break
--- a/python.old/tests_demo_bench/tempo/demo-tempo-acf
+++ /dev/null
@@ -1,157 +1,0 @@
-#! /usr/bin/python
-
-""" this file was written by Paul Brossier
- it is released under the GNU/GPL license.
-"""
-
-import sys,time
-from aubio.task import taskbeat,taskparams
-from aubio.aubioclass import fvec, aubio_autocorr
-from aubio.gnuplot import gnuplot_create, gnuplot_addargs
-from aubio.aubiowrapper import *
-from math import exp,log
-
-usage = "usage: %s [options] -i soundfile" % sys.argv[0]
-
-def parse_args():
- from optparse import OptionParser
- parser = OptionParser(usage=usage)
- parser.add_option("-i","--input",
- action="store", dest="filename",
- help="input sound file")
- parser.add_option("-n","--printframe",
- action="store", dest="printframe", default=-1,
- help="make a plot of the n_th frame")
- gnuplot_addargs(parser)
- (options, args) = parser.parse_args()
- if not options.filename:
- print "no file name given\n", usage
- sys.exit(1)
- return options, args
-
-def plotdata(x,y,plottitle="",**keyw):
- import Gnuplot
- return Gnuplot.Data(x, y, title="%s" % plottitle,**keyw)
-
-options, args = parse_args()
-filename = options.filename
-xsize = float(options.xsize)
-ysize = float(options.ysize)
-
-printframe = int(options.printframe)
-
-if options.outplot and printframe > 0:
- extension = options.outplot.split('.')[-1]
- outplot = '.'.join(options.outplot.split('.')[:-1])
-else:
- extension = ''
- outplot = None
-f = gnuplot_create(outplot,extension,options)
-
-params = taskparams()
-params.onsetmode = 'specdiff'
-task = taskbeat(filename,params=params)
-
-hopsize = params.hopsize
-bufsize = params.bufsize
-btstep = task.btstep
-winlen = task.btwinlen
-laglen = winlen/4
-step = winlen/4
-
-timesig = 0
-maxnumelem = 4
-gp = 0
-counter = 0
-flagconst = 0
-constthresh = 3.901
-g_var = 3.901
-rp = 0
-rp1 = 0
-rp2 = 0
-g_mu = 0
-
-rayparam = 48/512.*winlen
-
-t = [i for i in range(hopsize)]
-#tlong = [i for i in range(hopsize*(btstep-1))]
-#tall = [i for i in range(hopsize*btstep)]
-sig = [0 for i in range(hopsize*btstep*4)]
-dfx = [i for i in range(winlen)]
-dfframe = [0 for i in range(winlen)]
-dfrev = [0 for i in range(winlen)]
-acframe = [0 for i in range(winlen/2)]
-
-localacf = [0 for i in range(winlen)]
-inds = [0 for i in range(maxnumelem)]
-
-acx = [i for i in range(laglen)]
-acfout = [0 for i in range(laglen)]
-
-phwv = [0 for i in range(2*laglen)]
-phwvx = [i for i in range(2*laglen)]
-
-dfwvnorm = exp(log(2.0)*(winlen+2.)/rayparam);
-dfwv = [exp(log(2.)*(i+1.)/rayparam)/dfwvnorm for i in range(winlen)]
-
-gwv = [exp(-.5*(j+1.-g_mu)**2/g_var**2) for j in range(laglen)]
-rwv = [(i+1.)/rayparam**2 * exp(-(i+1.)**2 / (2.*rayparam)**2)
- for i in range(0,laglen)]
-acf = fvec(winlen,1)
-
-nrframe = 0
-while (task.readsize == params.hopsize):
- task()
- #print task.pos2
- sig[:-hopsize] = [i for i in sig[-(btstep*4-1)*hopsize:]]
- sig[-hopsize:] = [task.myvec.get(i,0) for i in t]
-
- #g('set xrange [%f:%f]' % (t[0],t[-1]))
- #time.sleep(.2)
- if task.pos2==btstep-1:
- nrframe += 1
- dfframe = [task.dfframe.get(i,0) for i in range(winlen)]
- # start beattracking_do
- for i in range(winlen):
- dfrev[winlen-1-i] = 0.
- dfrev[winlen-1-i] = dfframe[i]*dfwv[i]
- aubio_autocorr(task.dfframe(),acf());
- acframe = [acf.get(i,0) for i in range(winlen/2)]
- if printframe == nrframe or printframe == -1:
- d = [[plotdata(range(0,btstep*hopsize*4,4),sig[0:-1:4],plottitle="input signal", with='lines')]]
- d += [[plotdata(range(-winlen,0),dfframe,plottitle="onset detection", with='lines')]]
- d += [[plotdata(range(winlen/2),acframe,plottitle="autocorrelation", with='lines')]]
-
- # plot all this
- if printframe == nrframe or printframe == -1:
-
- f('set lmargin 4')
- f('set rmargin 4')
- f('set size %f,%f' % (1.0*xsize,1.0*ysize) )
- f('set key spacing 1.3')
- f('set multiplot')
-
- f('set size %f,%f' % (1.0*xsize,0.33*ysize) )
- f('set orig %f,%f' % (0.0*xsize,0.66*ysize) )
- f('set xrange [%f:%f]' % (0,btstep*hopsize*4) )
- f('set yrange [%f:%f]' % (-1.2*max(sig),1.2*max(sig)) )
- f.title('Input signal')
- f.xlabel('time (samples)')
- f.plot(*d[0])
- f('set size %f,%f' % (1.0*xsize,0.33*ysize) )
- f('set orig %f,%f' % (0.0*xsize,0.33*ysize) )
- f('set xrange [%f:%f]' % (-winlen,0) )
- f('set autoscale y')
- f.title('Onset detection function')
- f.xlabel('time (df samples)')
- f.plot(*d[1])
- f('set size %f,%f' % (1.0*xsize,0.33*ysize) )
- f('set orig %f,%f' % (0.0*xsize,0.00*ysize) )
- f('set xrange [%f:%f]' % (0,winlen/2) )
- f.title('Autocorrelation')
- f.xlabel('lag (df samples)')
- f.plot(*d[2])
- f('set nomultiplot')
- if printframe == -1: a = sys.stdin.read()
- elif 0 < printframe and printframe < nrframe:
- break
--- a/python.old/tests_examples/aubioonset.py
+++ /dev/null
@@ -1,41 +1,0 @@
-from template import program_test_case
-
-class aubioonset_unit(program_test_case):
-
- import os.path
- filename = os.path.join('..','..','sounds','woodblock.aiff')
- progname = os.path.join('..','..','examples','aubioonset')
-
- def test_aubioonset_with_inf_silence(self):
- """ test aubioonset with -s 0 """
- self.command += " -s 0"
- self.getOutput()
- assert len(self.output) == 0, self.output
-
-class aubioonset_unit_finds_onset(aubioonset_unit):
-
- def test_aubioonset(self):
- """ test aubioonset with default parameters """
- self.getOutput()
- assert len(str(self.output)) != 0, "no output produced with command:\n" \
- + self.command
-
- def test_aubioonset_with_no_silence(self):
- """ test aubioonset with -s -100 """
- self.command += " -s -100 "
- self.getOutput()
- # only one onset in woodblock.aiff
- self.assertNotEqual(0, len(str(self.output)), \
- "no output produced with command:\n" + self.command)
- self.assertEqual(1, len(self.output.split('\n')) )
- # onset should be at 0.00000
- self.assertEqual(0, float(self.output.strip()))
-
-list_of_onset_modes = ["energy", "specdiff", "hfc", "complex", "phase", \
- "kl", "mkl", "specflux"]
-
-for name in list_of_onset_modes:
- exec("class aubioonset_"+name+"_unit(aubioonset_unit):\n\
- options = \" -O "+name+" \"")
-
-if __name__ == '__main__': unittest.main()
--- a/python.old/tests_examples/aubiopitch.py
+++ /dev/null
@@ -1,69 +1,0 @@
-from template import *
-
-import os.path
-
-class aubiopitch_test_case(program_test_case):
-
- import os.path
- filename = os.path.join('..','..','sounds','woodblock.aiff')
- progname = "PYTHONPATH=../../python:../../python/aubio/.libs " + \
- os.path.join('..','..','python','aubiopitch')
-
- def test_aubiopitch(self):
- """ test aubiopitch with default parameters """
- self.getOutput()
- # FIXME: useless check
- self.assertEqual(len(self.output.split('\n')), 1)
- #self.assertEqual(float(self.output.strip()), 0.)
-
- def test_aubiopitch_verbose(self):
- """ test aubiopitch with -v parameter """
- self.command += " -v "
- self.getOutput()
- # FIXME: loose checking: make sure at least 8 lines are printed
- assert len(self.output) >= 8
-
- def test_aubiopitch_devnull(self):
- """ test aubiopitch on /dev/null """
- self.filename = "/dev/null"
- # exit status should not be 0
- self.getOutput(expected_status = 256)
- # and there should be an error message
- assert len(self.output) > 0
- # that looks like this
- output_lines = self.output.split('\n')
- #assert output_lines[0] == "Unable to open input file /dev/null."
- #assert output_lines[1] == "Supported file format but file is malformed."
- #assert output_lines[2] == "Could not open input file /dev/null."
-
-mode_names = ["yinfft", "yin", "fcomb", "mcomb", "schmitt"]
-for name in mode_names:
- exec("class aubiopitch_test_case_" + name + "(aubiopitch_test_case):\n\
- options = \" -m " + name + " \"")
-
-class aubiopitch_test_yinfft(program_test_case):
-
- filename = os.path.join('..','..','sounds','16568__acclivity__TwoCows.wav')
- url = "http://www.freesound.org/samplesViewSingle.php?id=16568"
- progname = "PYTHONPATH=../../python:../../python/aubio/.libs " + \
- os.path.join('..','..','python','aubiopitch')
- options = " -m yinfft -t 0.75 "
-
- def test_aubiopitch(self):
- """ test aubiopitch with default parameters """
- if not os.path.isfile(self.filename):
- print "Warning: file 16568_acclivity_TwoCows.wav was not found in %s" % os.path.dirname(self.filename)
- print "download it from %s to actually run test" % url
- return
- self.getOutput()
- expected_output = open(os.path.join('examples','aubiopitch','yinfft'+'.'+os.path.basename(self.filename)+'.txt')).read()
- lines = 0
- for line_out, line_exp in zip(self.output.split('\n'), expected_output.split('\n')):
- try:
- assert line_exp == line_out, line_exp + " vs. " + line_out + " at line " + str(lines)
- except:
- open(os.path.join('examples','aubiopitch','yinfft'+'.'+os.path.basename(self.filename)+'.txt.out'),'w').write(self.output)
- raise
- lines += 1
-
-if __name__ == '__main__': unittest.main()
--- a/python.old/tests_examples/aubiopitch/yinfft.16568__acclivity__TwoCows.wav.txt
+++ /dev/null
@@ -1,566 +1,0 @@
-0.0232199546485 -1.0
-0.0464399092971 -1.0
-0.0696598639456 -1.0
-0.0928798185941 -1.0
-0.116099773243 -1.0
-0.139319727891 -1.0
-0.16253968254 -1.0
-0.185759637188 -1.0
-0.208979591837 -1.0
-0.232199546485 -1.0
-0.255419501134 -1.0
-0.278639455782 -1.0
-0.301859410431 -1.0
-0.325079365079 -1.0
-0.348299319728 -1.0
-0.371519274376 -1.0
-0.394739229025 -1.0
-0.417959183673 -1.0
-0.441179138322 -1.0
-0.464399092971 -1.0
-0.487619047619 -1.0
-0.510839002268 -1.0
-0.534058956916 -1.0
-0.557278911565 -1.0
-0.580498866213 -1.0
-0.603718820862 -1.0
-0.62693877551 -1.0
-0.650158730159 -1.0
-0.673378684807 -1.0
-0.696598639456 -1.0
-0.719818594104 -1.0
-0.743038548753 -1.0
-0.766258503401 -1.0
-0.78947845805 -1.0
-0.812698412698 -1.0
-0.835918367347 -1.0
-0.859138321995 -1.0
-0.882358276644 -1.0
-0.905578231293 -1.0
-0.928798185941 -1.0
-0.95201814059 -1.0
-0.975238095238 -1.0
-0.998458049887 -1.0
-1.02167800454 -1.0
-1.04489795918 -1.0
-1.06811791383 392.768096924
-1.09133786848 115.522140503
-1.11455782313 116.574150085
-1.13777777778 117.720863342
-1.16099773243 120.00163269
-1.18421768707 123.633300781
-1.20743764172 426.787963867
-1.23065759637 141.312179565
-1.25387755102 144.336975098
-1.27709750567 148.604934692
-1.30031746032 150.864654541
-1.32353741497 154.889007568
-1.34675736961 156.505081177
-1.36997732426 158.878829956
-1.39319727891 160.931289673
-1.41641723356 163.155059814
-1.43963718821 324.814025879
-1.46285714286 167.016983032
-1.48607709751 168.871704102
-1.50929705215 170.665634155
-1.5325170068 172.353149414
-1.55573696145 174.764205933
-1.5789569161 176.318893433
-1.60217687075 178.282669067
-1.6253968254 179.82383728
-1.64861678005 181.488952637
-1.67183673469 183.1927948
-1.69505668934 184.449371338
-1.71827664399 185.715484619
-1.74149659864 186.702224731
-1.76471655329 187.907455444
-1.78793650794 188.703475952
-1.81115646259 189.502182007
-1.83437641723 190.250213623
-1.85759637188 190.834747314
-1.88081632653 190.98348999
-1.90403628118 190.847137451
-1.92725623583 190.805847168
-1.95047619048 191.00831604
-1.97369614512 191.377182007
-1.99691609977 191.935241699
-2.02013605442 192.395782471
-2.04335600907 192.534378052
-2.06657596372 192.404174805
-2.08979591837 192.085708618
-2.11301587302 191.410400391
-2.13623582766 191.070388794
-2.15945578231 190.677963257
-2.18267573696 190.020675659
-2.20589569161 189.669265747
-2.22911564626 189.298828125
-2.25233560091 188.546142578
-2.27555555556 186.856491089
-2.2987755102 184.917297363
-2.32199546485 183.044509888
-2.3452154195 181.399368286
-2.36843537415 179.126312256
-2.3916553288 175.22946167
-2.41487528345 171.139190674
-2.4380952381 338.55368042
-2.46131519274 162.799713135
-2.48453514739 320.075500488
-2.50775510204 148.602432251
-2.53097505669 139.503982544
-2.55419501134 340.922271729
-2.57741496599 326.436950684
-2.60063492063 333.484558105
-2.62385487528 -1.0
-2.64707482993 -1.0
-2.67029478458 -1.0
-2.69351473923 -1.0
-2.71673469388 -1.0
-2.73995464853 -1.0
-2.76317460317 -1.0
-2.78639455782 -1.0
-2.80961451247 -1.0
-2.83283446712 -1.0
-2.85605442177 -1.0
-2.87927437642 -1.0
-2.90249433107 -1.0
-2.92571428571 -1.0
-2.94893424036 -1.0
-2.97215419501 -1.0
-2.99537414966 -1.0
-3.01859410431 -1.0
-3.04181405896 -1.0
-3.06503401361 -1.0
-3.08825396825 -1.0
-3.1114739229 -1.0
-3.13469387755 -1.0
-3.1579138322 -1.0
-3.18113378685 -1.0
-3.2043537415 -1.0
-3.22757369615 -1.0
-3.25079365079 -1.0
-3.27401360544 -1.0
-3.29723356009 -1.0
-3.32045351474 -1.0
-3.34367346939 -1.0
-3.36689342404 -1.0
-3.39011337868 -1.0
-3.41333333333 -1.0
-3.43655328798 -1.0
-3.45977324263 -1.0
-3.48299319728 -1.0
-3.50621315193 -1.0
-3.52943310658 -1.0
-3.55265306122 -1.0
-3.57587301587 -1.0
-3.59909297052 -1.0
-3.62231292517 -1.0
-3.64553287982 -1.0
-3.66875283447 -1.0
-3.69197278912 -1.0
-3.71519274376 -1.0
-3.73841269841 -1.0
-3.76163265306 -1.0
-3.78485260771 -1.0
-3.80807256236 -1.0
-3.83129251701 -1.0
-3.85451247166 -1.0
-3.8777324263 -1.0
-3.90095238095 -1.0
-3.9241723356 -1.0
-3.94739229025 -1.0
-3.9706122449 -1.0
-3.99383219955 -1.0
-4.0170521542 -1.0
-4.04027210884 -1.0
-4.06349206349 -1.0
-4.08671201814 -1.0
-4.10993197279 -1.0
-4.13315192744 -1.0
-4.15637188209 -1.0
-4.17959183673 -1.0
-4.20281179138 -1.0
-4.22603174603 -1.0
-4.24925170068 -1.0
-4.27247165533 -1.0
-4.29569160998 -1.0
-4.31891156463 -1.0
-4.34213151927 -1.0
-4.36535147392 -1.0
-4.38857142857 -1.0
-4.41179138322 -1.0
-4.43501133787 -1.0
-4.45823129252 -1.0
-4.48145124717 -1.0
-4.50467120181 -1.0
-4.52789115646 -1.0
-4.55111111111 -1.0
-4.57433106576 -1.0
-4.59755102041 -1.0
-4.62077097506 -1.0
-4.64399092971 -1.0
-4.66721088435 -1.0
-4.690430839 -1.0
-4.71365079365 -1.0
-4.7368707483 -1.0
-4.76009070295 -1.0
-4.7833106576 -1.0
-4.80653061224 -1.0
-4.82975056689 -1.0
-4.85297052154 -1.0
-4.87619047619 -1.0
-4.89941043084 -1.0
-4.92263038549 -1.0
-4.94585034014 -1.0
-4.96907029478 -1.0
-4.99229024943 -1.0
-5.01551020408 -1.0
-5.03873015873 -1.0
-5.06195011338 -1.0
-5.08517006803 -1.0
-5.10839002268 -1.0
-5.13160997732 -1.0
-5.15482993197 -1.0
-5.17804988662 -1.0
-5.20126984127 -1.0
-5.22448979592 -1.0
-5.24770975057 -1.0
-5.27092970522 -1.0
-5.29414965986 -1.0
-5.31736961451 -1.0
-5.34058956916 -1.0
-5.36380952381 -1.0
-5.38702947846 -1.0
-5.41024943311 -1.0
-5.43346938776 -1.0
-5.4566893424 -1.0
-5.47990929705 -1.0
-5.5031292517 -1.0
-5.52634920635 -1.0
-5.549569161 -1.0
-5.57278911565 -1.0
-5.59600907029 -1.0
-5.61922902494 -1.0
-5.64244897959 -1.0
-5.66566893424 -1.0
-5.68888888889 -1.0
-5.71210884354 -1.0
-5.73532879819 -1.0
-5.75854875283 -1.0
-5.78176870748 -1.0
-5.80498866213 -1.0
-5.82820861678 -1.0
-5.85142857143 -1.0
-5.87464852608 -1.0
-5.89786848073 -1.0
-5.92108843537 -1.0
-5.94430839002 -1.0
-5.96752834467 -1.0
-5.99074829932 -1.0
-6.01396825397 -1.0
-6.03718820862 -1.0
-6.06040816327 -1.0
-6.08362811791 -1.0
-6.10684807256 -1.0
-6.13006802721 -1.0
-6.15328798186 -1.0
-6.17650793651 -1.0
-6.19972789116 -1.0
-6.2229478458 -1.0
-6.24616780045 -1.0
-6.2693877551 -1.0
-6.29260770975 -1.0
-6.3158276644 -1.0
-6.33904761905 -1.0
-6.3622675737 -1.0
-6.38548752834 -1.0
-6.40870748299 -1.0
-6.43192743764 -1.0
-6.45514739229 -1.0
-6.47836734694 -1.0
-6.50158730159 187.887435913
-6.52480725624 143.988250732
-6.54802721088 147.904678345
-6.57124716553 151.674087524
-6.59446712018 3221.32983398
-6.61768707483 3159.02587891
-6.64090702948 160.395706177
-6.66412698413 162.535690308
-6.68734693878 164.282516479
-6.71056689342 166.054779053
-6.73378684807 167.578659058
-6.75700680272 169.234619141
-6.78022675737 171.029663086
-6.80344671202 173.257110596
-6.82666666667 174.64654541
-6.84988662132 175.149429321
-6.87310657596 175.456039429
-6.89632653061 176.283660889
-6.91954648526 177.318511963
-6.94276643991 178.066696167
-6.96598639456 178.517211914
-6.98920634921 179.053573608
-7.01242630385 179.549285889
-7.0356462585 180.029403687
-7.05886621315 180.64515686
-7.0820861678 180.8934021
-7.10530612245 180.952774048
-7.1285260771 181.48147583
-7.15174603175 182.092208862
-7.17496598639 183.082504272
-7.19818594104 183.907089233
-7.22140589569 184.607666016
-7.24462585034 185.0181427
-7.26784580499 185.282440186
-7.29106575964 185.946502686
-7.31428571429 186.74571228
-7.33750566893 187.205505371
-7.36072562358 187.595703125
-7.38394557823 187.939483643
-7.40716553288 188.01159668
-7.43038548753 187.807418823
-7.45360544218 187.751464844
-7.47682539683 187.811416626
-7.50004535147 187.951507568
-7.52326530612 188.168029785
-7.54648526077 188.630828857
-7.56970521542 188.946014404
-7.59292517007 189.095901489
-7.61614512472 189.302886963
-7.63936507937 189.673339844
-7.66258503401 189.881591797
-7.68580498866 189.865234375
-7.70902494331 189.865234375
-7.73224489796 189.595870972
-7.75546485261 188.954116821
-7.77868480726 188.192108154
-7.8019047619 187.352645874
-7.82512471655 186.524551392
-7.8483446712 184.967712402
-7.87156462585 183.589355469
-7.8947845805 182.828231812
-7.91800453515 181.968215942
-7.9412244898 180.796981812
-7.96444444444 180.0
-7.98766439909 179.184524536
-8.01088435374 178.799484253
-8.03410430839 178.29347229
-8.05732426304 178.088272095
-8.08054421769 177.894317627
-8.10376417234 177.693618774
-8.12698412698 177.905075073
-8.15020408163 178.041549683
-8.17342403628 178.045135498
-8.19664399093 177.650650024
-8.21986394558 177.32208252
-8.24308390023 176.611938477
-8.26630385488 175.525878906
-8.28952380952 172.121078491
-8.31274376417 584.997009277
-8.33596371882 575.042358398
-8.35918367347 465.681121826
-8.38240362812 447.307037354
-8.40562358277 -1.0
-8.42884353741 -1.0
-8.45206349206 -1.0
-8.47528344671 -1.0
-8.49850340136 -1.0
-8.52172335601 -1.0
-8.54494331066 -1.0
-8.56816326531 -1.0
-8.59138321995 -1.0
-8.6146031746 -1.0
-8.63782312925 -1.0
-8.6610430839 -1.0
-8.68426303855 -1.0
-8.7074829932 -1.0
-8.73070294785 -1.0
-8.75392290249 -1.0
-8.77714285714 -1.0
-8.80036281179 -1.0
-8.82358276644 -1.0
-8.84680272109 -1.0
-8.87002267574 -1.0
-8.89324263039 -1.0
-8.91646258503 -1.0
-8.93968253968 -1.0
-8.96290249433 -1.0
-8.98612244898 -1.0
-9.00934240363 -1.0
-9.03256235828 -1.0
-9.05578231293 -1.0
-9.07900226757 -1.0
-9.10222222222 -1.0
-9.12544217687 -1.0
-9.14866213152 -1.0
-9.17188208617 -1.0
-9.19510204082 -1.0
-9.21832199546 -1.0
-9.24154195011 -1.0
-9.26476190476 -1.0
-9.28798185941 -1.0
-9.31120181406 -1.0
-9.33442176871 -1.0
-9.35764172336 -1.0
-9.380861678 -1.0
-9.40408163265 -1.0
-9.4273015873 -1.0
-9.45052154195 -1.0
-9.4737414966 -1.0
-9.49696145125 -1.0
-9.5201814059 -1.0
-9.54340136054 -1.0
-9.56662131519 -1.0
-9.58984126984 -1.0
-9.61306122449 -1.0
-9.63628117914 -1.0
-9.65950113379 -1.0
-9.68272108844 -1.0
-9.70594104308 -1.0
-9.72916099773 -1.0
-9.75238095238 -1.0
-9.77560090703 -1.0
-9.79882086168 -1.0
-9.82204081633 -1.0
-9.84526077098 -1.0
-9.86848072562 -1.0
-9.89170068027 -1.0
-9.91492063492 -1.0
-9.93814058957 -1.0
-9.96136054422 -1.0
-9.98458049887 -1.0
-10.0078004535 -1.0
-10.0310204082 -1.0
-10.0542403628 -1.0
-10.0774603175 -1.0
-10.1006802721 -1.0
-10.1239002268 -1.0
-10.1471201814 -1.0
-10.1703401361 -1.0
-10.1935600907 -1.0
-10.2167800454 -1.0
-10.24 -1.0
-10.2632199546 -1.0
-10.2864399093 100.193115234
-10.3096598639 -1.0
-10.3328798186 326.038757324
-10.3560997732 104.222053528
-10.3793197279 105.370048523
-10.4025396825 106.595123291
-10.4257596372 107.893875122
-10.4489795918 108.992500305
-10.4721995465 109.93119812
-10.4954195011 110.819335938
-10.5186394558 112.031303406
-10.5418594104 113.389472961
-10.5650793651 114.239830017
-10.5882993197 116.827377319
-10.6115192744 119.250427246
-10.634739229 122.184356689
-10.6579591837 148.222839355
-10.6811791383 150.104660034
-10.704399093 153.361968994
-10.7276190476 155.115112305
-10.7508390023 158.433624268
-10.7740589569 161.372955322
-10.7972789116 163.421096802
-10.8204988662 167.165771484
-10.8437188209 170.329452515
-10.8669387755 173.311584473
-10.8901587302 175.445571899
-10.9133786848 177.304244995
-10.9365986395 179.024490356
-10.9598185941 180.073501587
-10.9830385488 180.826629639
-11.0062585034 181.559936523
-11.029478458 182.487792969
-11.0526984127 183.303192139
-11.0759183673 183.976135254
-11.099138322 184.650161743
-11.1223582766 185.613876343
-11.1455782313 186.123062134
-11.1687981859 186.852523804
-11.1920181406 187.531890869
-11.2152380952 188.232284546
-11.2384580499 189.20135498
-11.2616780045 189.485900879
-11.2848979592 190.094390869
-11.3081179138 190.636749268
-11.3313378685 191.252670288
-11.3545578231 191.647476196
-11.3777777778 192.673187256
-11.4009977324 193.018920898
-11.4242176871 193.641860962
-11.4474376417 194.307373047
-11.4706575964 194.234619141
-11.493877551 194.290252686
-11.5170975057 194.641845703
-11.5403174603 194.663314819
-11.563537415 194.719177246
-11.5867573696 194.149108887
-11.6099773243 194.166213989
-11.6331972789 194.136291504
-11.6564172336 193.786529541
-11.6796371882 192.605865479
-11.7028571429 190.785202026
-11.7260770975 188.578399658
-11.7492970522 182.544433594
-11.7725170068 173.676742554
-11.7957369615 415.019744873
-11.8189569161 417.989685059
-11.8421768707 333.699066162
-11.8653968254 415.058837891
-11.88861678 352.025543213
-11.9118367347 -1.0
-11.9350566893 -1.0
-11.958276644 -1.0
-11.9814965986 -1.0
-12.0047165533 -1.0
-12.0279365079 -1.0
-12.0511564626 -1.0
-12.0743764172 -1.0
-12.0975963719 -1.0
-12.1208163265 -1.0
-12.1440362812 -1.0
-12.1672562358 -1.0
-12.1904761905 -1.0
-12.2136961451 -1.0
-12.2369160998 -1.0
-12.2601360544 -1.0
-12.2833560091 -1.0
-12.3065759637 -1.0
-12.3297959184 -1.0
-12.353015873 -1.0
-12.3762358277 -1.0
-12.3994557823 -1.0
-12.422675737 -1.0
-12.4458956916 -1.0
-12.4691156463 -1.0
-12.4923356009 -1.0
-12.5155555556 -1.0
-12.5387755102 -1.0
-12.5619954649 -1.0
-12.5852154195 -1.0
-12.6084353741 -1.0
-12.6316553288 -1.0
-12.6548752834 -1.0
-12.6780952381 -1.0
-12.7013151927 -1.0
-12.7245351474 -1.0
-12.747755102 -1.0
-12.7709750567 -1.0
-12.7941950113 -1.0
-12.817414966 -1.0
-12.8406349206 -1.0
-12.8638548753 -1.0
-12.8870748299 -1.0
-12.9102947846 -1.0
-12.9335147392 -1.0
-12.9567346939 -1.0
-12.9799546485 -1.0
-13.0031746032 -1.0
-13.0263945578 -1.0
-13.0496145125 -1.0
-13.0728344671 -1.0
-13.0960544218 -1.0
-13.1192743764 -1.0
-13.1424943311 -1.0
--- a/python.old/wscript_build
+++ /dev/null
@@ -1,6 +1,0 @@
-# vim:set syntax=python:
-
-ctx.add_subdirs('aubio')
-# install headers
-for file in ['aubiocut', 'aubiopitch']:
- ctx.install_as('${PREFIX}/bin/' + file, file, chmod = 0755)