4 program_name = 'musa.py'
5 version = '@TOPLEVEL_VERSION@'
6 if version == '@' + 'TOPLEVEL_VERSION' + '@':
7 version = '(unknown version)' # uGUHGUHGHGUGH
16 #names = ["One", "Two", "Three"]
19 def dump_score (outf):
20 outf.write (r"""\score{
24 def set_default_len_from_time_sig (s):
25 m = re.search ('([0-9]+)/([0-9]+)', s)
27 n = string.atoi (m.group (1))
28 d = string.atoi (m.group (2))
29 if (n * 1.0 )/(d * 1.0) < 0.75:
30 __main__.default_len = 16
32 __main__.default_len = 8
41 sys.stderr.write ("can't open file: %s\n" % f)
45 sys.stderr.write ("gulped emty file: %s\n" % f)
50 sys.stderr.write ("%s from LilyPond %s\n" % (program_name, version))
56 Usage: musa [OPTION]...
60 -o, --output=FILE set output filename to FILE
61 -v, --version version information
65 print r"""musa (GNU lilypond) %s""" % version
68 (options, files) = getopt.getopt (sys.argv[1:], 'vo:h', ['help','version', 'output='])
74 if o== '--help' or o == '-h':
77 if o == '--version' or o == '-v':
81 if o == '--output' or o == '-o':
89 #header['tagline'] = 'Lily was here %s -- automatically converted from ABC' % version
92 #out_filename = os.path.basename (os.path.splitext (f)[0]) + ".ly"
93 #sys.stderr.write ('Ly output to: %s...' % out_filename)
94 #outf = open (out_filename, 'w')
95 #sys.stderr.write ('\n')
112 def print_font (name):
115 for k in font.keys ():
117 print ("Character: %s" % k)
118 for i in range (len (c)):
121 def put_char (x, y, c):
123 height = len (line[0])
125 if x >= 0 and x < width - 2 and y >= 0 and y < height:
127 line[y] = line[y][:x] + c + line[y][x+1:]
129 print ("%d, %d: %c" % (x, y, c))
131 print ("%d, %d: %c" % (x, y, c))
133 def put_string (x, y, s):
135 height = len (line[0])
137 if x >= 0 and x < width and y >= 0 and y < height:
139 line[y] = line[y][:x] + s + line[y][x+len (s):]
141 print ("%d, %d: %s" % (x, y, s))
143 print ("%d, %d: %s" % (x, y, s))
145 def header (creator, generate):
146 print (creator, generate)
151 def load_font (name, mag):
153 font_str = gulp_file (name + ".af");
156 for c in string.split (font_str, '\f')[1:]:
160 for line in string.split (c, '\n')[:-1]:
163 #code = string.atoi (id[string.index (id,
164 # 'C')+2:string.index (id, ';')])
165 code = id[string.index (id,
166 'C')+2:string.index (id, ';')]
167 code = string.strip (code)
168 bbox = string.split (string.strip (id[string.rindex (id, 'B')+1: string.rindex (id, ';')]), ' ')
176 def start_line (height):
180 for i in range (height+2):
181 line.append (" " * width)
183 def move_to (new_x, new_y):
188 def move_relative (dx, dy):
195 for i in range (length):
196 put_char (x+i, y, '-')
199 def select_font (name):
204 global x, y, width, fonts, font
205 height = len (line[0])
207 #if x >= 0 and x < width and y >= 0 and y < height:
210 #print ("Bbox: %s " % `bbox`)
212 for i in range (len (c)):
213 put_string (x-string.atoi (bbox[1]), y-i+ string.atoi (bbox[3]), c[i])
221 for i in range (length):
222 put_char (x, y+i, '|')
226 for i in range (len (line)):