History

moved out old python interface

Paul Brossier committed 13 years ago

Commit b554e411 parent a1da37f42 files · +0 −0Browse files

Showing the changes to python.old/aubiofilter-notes (1 of 42 files). Show all

Unified · Split

python.old/aubiofilter-notes+94−0
@@ -0,0 +1,94 @@
1+#!/usr/bin/python
2+
3+""" this file is used to get filter the (old) output format of aubionotes """
4+
5+# default parameters
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)
10+
11+import getopt
12+import sys
13+
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)
19+ assert len(args) > 1
20+ plot = __plot
21+ delay = __delay
22+ eps = __eps
23+ winlength = __winlength
24+ plot = __plot
25+ fileout = '/tmp/testprint.ps'
26+ args.sort()
27+ for i in range(len(args)): # a bad way
28+ if args[i][0] == '-i' or args[i][0] == '--input':
29+ fileorg = args[i][1]
30+ if args[i][0] == '-o' or args[i][0] == '--output':
31+ fileerr = args[i][1]
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':
41+ plot = 1
42+ fileout = args[i][1]
43+ return fileorg,fileerr,eps,winlength,plot,delay,fileout
44+
45+def usage():
46+ print __file__, "with at least some arguments"
47+
48+def main():
49+ try:
50+ opts,args = getopt.getopt(sys.argv[1:],
51+ "hvo:i:p:P",
52+ ["help", "output=", "verbose", "input=", "plot="])
53+ except getopt.GetoptError:
54+ usage()
55+ sys.exit(2)
56+
57+ input = None
58+ output = None
59+ verbose = False
60+ winlength = __winlength
61+ plot = __plot
62+ eps = __eps
63+
64+ for o, a in opts:
65+ if o in ("-v", "--verbose"):
66+ verbose = True
67+ if o in ("-h", "--help"):
68+ usage()
69+ sys.exit(2)
70+ if o in ("--output"):
71+ output = a
72+ if o in ("-i", "--input"):
73+ input = a
74+ if o in ("-P", "--plot"):
75+ plot = 1
76+
77+ assert input != None and input != "", "no input file"
78+
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))
83+ """ filter it out """
84+ notelist_filtered = notefilter.segraw_onsets4(notelist,winlength,eps)
85+ if verbose == 1 :
86+ for a,b in notelist_filtered:
87+ print a,b
88+ """ plot results """
89+ if plot == 1 :
90+ gnuplot.plotnote(notelist_filtered,title=input,fileout=output)
91+
92+if __name__ == "__main__":
93+ main()
94+

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t