3 # once upon a rainy monday afternoon.
18 global_voice_stuff = []
22 def dump_header (hdr):
25 print '%s = "%s";\n'% (k,hdr[k])
28 def set_default_length (s):
29 m = re.match ('1/(.*)$', s)
31 default_len = string.atoi ( m.group (1))
33 def parse_timesig (s):
34 m = re.match ('^M: *(.*)$', s)
36 print '\meter %s; ' % m.group (1)
39 m = re.match ('^K: *(.*)$', s)
41 print '\key %s; ' % m.group (1)
50 print 'can\'t open file: ' + f + '\n'
54 print 'gulped empty file: ' + f + '\n'
59 def try_parse_header_line (ln):
60 m = re.match ('^(.): *(.*)$', ln)
68 global_voice_stuff.append ('\\time %s;' % a)
70 global_voice_stuff.append ('\\key %s;' % a)
74 header ['crossRefNumber'] = a
79 header ['history'] = a
83 header ['subtitle'] = a
85 set_default_length (ln)
91 # WAT IS ABC EEN ONTZETTENDE PROGRAMMEERPOEP !
93 def try_parse_note (str):
113 if str[0] in "ABCDEFG":
114 str = string.lower (str[0]) + str[1:]
119 if str[0] in "abcdefg":
120 notename = ord(str[0]) - ord('a')
123 return str # failed; not a note!
128 while str[0] == '\'':
136 while str[0] in "1234567890":
137 durstr = durstr + str[0]
142 duration_mult = string.atoi (durstr)
153 def junk_space (str):
154 while str and str[0] in '\t\n ':
159 def try_parse_bar (str):
164 def try_parse_body_line (ln):
166 while ln and ln != prev_ln:
168 ln = try_parse_note (ln)
169 ln = try_parse_bar (ln)
181 if re.match ('^[\t ]*(%.*)?$', l):
185 m = try_parse_header_line (l)
190 m = try_parse_body_line (l)
194 print '%s %s' % (name, version)
198 This is a disfunctional ABC to mudela convertor. It only gulps input, and
199 says huh when confused. Does not do chords. Go ahead and fix me.
201 -h, --help this help.
205 (options, files) = getopt.getopt (sys.argv[1:], 'h', ['help'])
210 if o== '--help' or o == '-h':
223 print global_voice_stuff, 1