3 """ this file is used to get filter the (old) output format of aubionotes """
6 __eps = [0.250,0.50] # minimum length, pitch tolerance (ms,midipitch)
7 __plot = 0 # -P (command line switch)
8 __delay = 0.0 # -D <value> (fixed delay for score alignement)
9 __winlength = 10 # -w <value> (window length for pitch estimation in frames)
14 def parse_args (sysargs):
15 from getopt import gnu_getopt
16 shortopts ='i:o:t:p:w:D:P:'
17 longopts =('input=','output=','tolpitch=','toltime=','winlength=','delay','plot=')
18 args,tmp = gnu_getopt(sysargs,shortopts,longopts)
23 winlength = __winlength
25 fileout = '/tmp/testprint.ps'
27 for i in range(len(args)): # a bad way
28 if args[i][0] == '-i' or args[i][0] == '--input':
30 if args[i][0] == '-o' or args[i][0] == '--output':
32 if args[i][0] == '-t' or args[i][0] == '--toltime':
33 eps[0] = float(args[i][1])
34 if args[i][0] == '-p' or args[i][0] == '--tolpitch':
35 eps[1] = float(args[i][1])
36 if args[i][0] == '-D' or args[i][0] == '--delay':
37 delay = float(args[i][1])
38 if args[i][0] == '-w' or args[i][0] == '--winlength':
39 winlength = int(args[i][1])
40 if args[i][0] == '-P' or args[i][0] == '--plot':
43 return fileorg,fileerr,eps,winlength,plot,delay,fileout
46 print __file__, "with at least some arguments"
50 opts,args = getopt.getopt(sys.argv[1:],
52 ["help", "output=", "verbose", "input=", "plot="])
53 except getopt.GetoptError:
60 winlength = __winlength
65 if o in ("-v", "--verbose"):
67 if o in ("-h", "--help"):
72 if o in ("-i", "--input"):
74 if o in ("-P", "--plot"):
77 assert input != None and input != "", "no input file"
79 from aubio import notefilter,txtfile,gnuplot
80 """ load midi and raw data """
81 from numpy import array
82 notelist = array(txtfile.read_datafile(input))
84 notelist_filtered = notefilter.segraw_onsets4(notelist,winlength,eps)
86 for a,b in notelist_filtered:
90 gnuplot.plotnote(notelist_filtered,title=input,fileout=output)
92 if __name__ == "__main__":