3 # once upon a rainy monday afternoon.
8 # ABC standard v1.6: http://www.gre.ac.uk/~c.walshaw/abc2mtex/abc.txt
10 # Enhancements (Roy R. Rankin)
12 # Header section moved to top of lilypond file
13 # handle treble, treble-8, alto, and bass clef
14 # Handle voices (V: headers) with clef and part names, multiple voices
15 # Handle w: lyrics with multiple verses
16 # Handle key mode names for minor, major, phrygian, ionian, locrian, aeolian,
17 # mixolydian, lydian, dorian
18 # Handle part names from V: header
19 # Tuplets handling fixed up
20 # Lines starting with |: not discarded as header lines
21 # Multiple T: and C: header entries handled
22 # Accidental maintained until next bar check
23 # Silent rests supported
24 # articulations fermata, upbow, downbow, ltoe, accent, tenuto supported
25 # Chord strings([-^]"string") can contain a '#'
26 # Header fields enclosed by [] in notes string processed
27 # W: words output after tune as abc2ps does it (they failed before)
29 # Enhancements (Laura Conrad)
31 # Barring now preserved between ABC and lilypond
32 # the default placement for text in abc is above the staff.
34 # \breve and \longa supported.
38 # Multiple tunes in single file not supported
39 # Blank T: header lines should write score and open a new score
40 # Not all header fields supported
41 # ABC line breaks are ignored
42 # Block comments generate error and are ignored
43 # Postscript commands are ignored
44 # lyrics not resynchronized by line breaks (lyrics must fully match notes)
45 # %%LY slyrics can't be directly before a w: line.
55 program_name = 'abc2ly'
56 version = '@TOPLEVEL_VERSION@'
57 if version == '@' + 'TOPLEVEL_VERSION' + '@':
58 version = '(unknown version)' # uGUHGUHGHGUGH
72 header['footnotes'] = ''
77 repeat_state = [0] * 8
78 current_voice_idx = -1
79 current_lyric_idx = -1
85 global_key = [0] * 7 # UGH
86 names = ["One", "Two", "Three"]
88 alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
95 if re.match('-8va', s) or re.match('treble8', s):
96 # treble8 is used by abctab2ps; -8va is used by barfly,
97 # and by my patch to abc2ps. If there's ever a standard
98 # about this we'll support that.
100 state.base_octave = -1
101 voices_append("\\clef \"G_8\"\n")
102 elif re.match('^treble', s):
104 if re.match ('^-8', s):
106 state.base_octave = -2
107 voices_append("\\clef \"G_8\"\n")
109 state.base_octave = 0
110 voices_append("\\clef treble\n")
111 elif re.match('^alto', s):
113 state.base_octave = -1
114 voices_append ("\\clef alto\n" )
115 elif re.match('^bass',s ):
117 state.base_octave = -2
118 voices_append ("\\clef bass\n" )
121 def select_voice (name, rol):
122 if not voice_idx_dict.has_key (name):
123 state_list.append(Parser_state())
126 voice_idx_dict[name] = len (voices) -1
127 __main__.current_voice_idx = voice_idx_dict[name]
128 __main__.state = state_list[current_voice_idx]
130 m = re.match ('^([^ \t=]*)=(.*)$', rol) # find keywork
134 a = re.match ('^("[^"]*"|[^ \t]*) *(.*)$', rol)
138 if keyword == 'clef':
140 elif keyword == "name":
141 value = re.sub ('\\\\','\\\\\\\\', value)
142 voices_append ("\\property Staff.instrument = %s\n" % value )
143 __main__.part_names = 1
144 elif keyword == "sname" or keyword == "snm":
145 voices_append ("\\property Staff.instr = %s\n" % value )
153 def dump_header (outf,hdr):
154 outf.write ('\\header {\n')
158 outf.write ('\t%s = "%s"\n'% (k,hdr[k]))
161 def dump_lyrics (outf):
163 outf.write("\n\\score\n{\n \\context Lyrics\n <\n")
164 for i in range (len (lyrics)):
165 outf.write ( lyrics [i])
167 outf.write(" >\n \\paper{}\n}\n")
169 def dump_default_bar (outf):
170 outf.write ("\n\\property Score.defaultBarType=\"empty\"\n")
173 def dump_slyrics (outf):
174 ks = voice_idx_dict.keys()
177 for i in range (len(slyrics[voice_idx_dict[k]])):
179 outf.write ("\nwords%sV%s = \\lyrics {" % (k, l))
180 outf.write ("\n" + slyrics [voice_idx_dict[k]][i])
183 def dump_voices (outf):
184 global doing_alternative, in_repeat
185 ks = voice_idx_dict.keys()
188 outf.write ("\nvoice%s = \\notes {" % k)
189 dump_default_bar(outf)
190 if repeat_state[voice_idx_dict[k]]:
191 outf.write("\n\\repeat volta 2 {")
192 outf.write ("\n" + voices [voice_idx_dict[k]])
194 if doing_alternative[voice_idx_dict[k]]:
196 if in_repeat[voice_idx_dict[k]]:
200 def dump_score (outf):
201 outf.write (r"""\score{
205 ks = voice_idx_dict.keys ();
208 if k == 'default' and len (voice_idx_dict) > 1:
210 if len ( slyrics [voice_idx_dict[k]] ):
211 outf.write ("\n \\addlyrics")
212 outf.write ("\n\t\\context Staff=\"%s\"\n\t{\n" %k )
214 outf.write ("\t \\voicedefault\n")
215 outf.write ("\t \\voice%s " % k)
216 outf.write ("\n\t}\n")
217 if len ( slyrics [voice_idx_dict[k]] ):
218 outf.write ("\n\t\\context Lyrics=\"%s\" \n\t<\t" % k)
219 for i in range (len(slyrics[voice_idx_dict[k]])):
221 outf.write("\n\t { \\words%sV%s }" % ( k, l) )
222 outf.write ( "\n\t>\n" )
224 outf.write ("\n\t\\paper {\n")
226 outf.write ("\t \\translator \n\t {\n")
227 outf.write ("\t\t\\StaffContext\n")
228 outf.write ("\t\t\\consists Staff_margin_engraver\n")
229 outf.write ("\t }\n")
230 outf.write ("\t}\n\t\\midi {}\n}\n")
234 def set_default_length (s):
235 global length_specified
236 m = re.search ('1/([0-9]+)', s)
238 __main__.default_len = string.atoi ( m.group (1))
241 def set_default_len_from_time_sig (s):
242 m = re.search ('([0-9]+)/([0-9]+)', s)
244 n = string.atoi (m.group (1))
245 d = string.atoi (m.group (2))
246 if (n * 1.0 )/(d * 1.0) < 0.75:
247 __main__.default_len = 16
249 __main__.default_len = 8
258 sys.stderr.write ("can't open file: `%s'\n" % f)
262 sys.stderr.write ("gulped empty file: `%s'\n" % f)
267 # pitch manipulation. Tuples are (name, alteration).
268 # 0 is (central) C. Alteration -1 is a flat, Alteration +1 is a sharp
269 # pitch in semitones.
270 def semitone_pitch (tup):
280 p = p + t* 2 + tup[1]
283 def fifth_above_pitch (tup):
284 (n, a) = (tup[0] + 4, tup[1])
286 difference = 7 - (semitone_pitch ((n,a)) - semitone_pitch (tup))
297 (t,a) = fifth_above_pitch (p)
298 if semitone_pitch((t,a)) % 12 == 0:
310 (t,a) = quart_above_pitch (p)
311 if semitone_pitch((t,a)) % 12 == 0:
317 def quart_above_pitch (tup):
318 (n, a) = (tup[0] + 3, tup[1])
320 difference = 5 - (semitone_pitch ((n,a)) - semitone_pitch (tup))
325 key_lookup = { # abc to lilypond key mode names
334 'mix' : 'mixolydian',
335 'mixolydian' : 'mixolydian',
345 if k and k[0] == '#':
348 elif k and k[0] == 'b':
352 return '%s \\major' % key
355 if key_lookup.has_key(type):
356 return("%s \\%s" % ( key, key_lookup[type]))
357 sys.stderr.write("Unknown key type `%s' ignored\n" % type)
360 def shift_key (note, acc , shift):
361 s = semitone_pitch((note, acc))
362 s = (s + shift + 12) % 12
374 key_shift = { # semitone shifts for key mode names
397 intkey = (ord (k[0]) - ord('a') + 5) % 7
401 if k and k[0] == 'b':
404 elif k and k[0] == '#':
408 if k and key_shift.has_key(k):
409 (intkey, intkeyacc) = shift_key(intkey, intkeyacc, key_shift[k])
410 keytup = (intkey, intkeyacc)
412 sharp_key_seq = sharp_keys ()
413 flat_key_seq = flat_keys ()
417 if keytup in sharp_key_seq:
419 key_count = sharp_key_seq.index (keytup)
420 accseq = map (lambda x: (4*x -1 ) % 7, range (1, key_count + 1))
422 elif keytup in flat_key_seq:
424 key_count = flat_key_seq.index (keytup)
425 accseq = map (lambda x: (3*x + 3 ) % 7, range (1, key_count + 1))
431 key_table[a] = key_table[a] + accsign
446 def try_parse_tuplet_begin (str, state):
447 if re.match ('\([2-9]', str):
450 state.parsing_tuplet = string.atoi (dig[0])
452 voices_append ("\\times %s {" % tup_lookup[dig])
455 def try_parse_group_end (str, state):
456 if str and str[0] in HSPACE:
460 def header_append (key, a):
462 if header.has_key (key):
463 s = header[key] + "\n"
467 linelen = len (v) - string.rfind(v, '\n')
468 if linelen + len (a) > 80:
472 def stuff_append (stuff, idx, a):
476 stuff [idx] = wordwrap(a, stuff[idx])
480 def voices_append(a):
481 if current_voice_idx < 0:
482 select_voice ('default', '')
483 stuff_append (voices, current_voice_idx, a)
485 def repeat_prepend():
487 if current_voice_idx < 0:
488 select_voice ('default', '')
490 repeat_state[current_voice_idx] = 't'
493 def lyrics_append(a):
494 a = re.sub ( '#', '\\#', a) # latex does not like naked #'s
495 a = re.sub ( '"', '\\"', a) # latex does not like naked "'s
496 a = '\t{ \\lyrics "' + a + '" }\n'
497 stuff_append (lyrics, current_lyric_idx, a)
499 # break lyrics to words and put "'s around words containing numbers and '"'s
503 m = re.match('[ \t]*([^ \t]*)[ \t]*(.*$)', str)
507 word = re.sub('"', '\\"', word) # escape "
508 if re.match('.*[0-9"\(]', word):
509 word = re.sub('_', ' ', word) # _ causes probs inside ""
510 ret = ret + '\"' + word + '\" '
512 ret = ret + word + ' '
517 def slyrics_append(a):
518 a = re.sub ( '_', ' _ ', a) # _ to ' _ '
519 a = re.sub ( '-', '- ', a) # split words with -
520 a = re.sub ( '\\\\- ', '-', a) # unless \-
521 a = re.sub ( '~', '_', a) # ~ to space('_')
522 a = re.sub ( '\*', '_ ', a) # * to to space
523 a = re.sub ( '#', '\\#', a) # latex does not like naked #'s
524 if re.match('.*[0-9"\(]', a): # put numbers and " and ( into quoted string
526 a = re.sub ( '$', ' ', a) # insure space between lines
527 __main__.lyric_idx = lyric_idx + 1
528 if len(slyrics[current_voice_idx]) <= lyric_idx:
529 slyrics[current_voice_idx].append(a)
531 v = slyrics[current_voice_idx][lyric_idx]
532 slyrics[current_voice_idx][lyric_idx] = wordwrap(a, slyrics[current_voice_idx][lyric_idx])
535 def try_parse_header_line (ln, state):
536 global length_specified
537 m = re.match ('^([A-Za-z]): *(.*)$', ln)
543 a = re.sub('[ \t]*$','', a) #strip trailing blanks
544 if header.has_key('title'):
546 header['title'] = header['title'] + '\\\\\\\\' + a
551 if not state.common_time:
552 state.common_time = 1
553 voices_append ("\\property Staff.TimeSignature \\override #\'style = #'C\n")
556 if not state.common_time:
557 state.common_time = 1
558 voices_append ("\\property Staff.TimeSignature \\override #\'style = #'C\n")
560 if not length_specified:
561 set_default_len_from_time_sig (a)
564 voices_append ('\\time %s' % a)
569 m = re.match ('^([^ \t]*) *(.*)$', a) # seperate clef info
571 # there may or may not be a space
572 # between the key letter and the mode
573 if key_lookup.has_key(m.group(2)[0:3]):
574 key_info = m.group(1) + m.group(2)[0:3]
575 clef_info = m.group(2)[4:]
577 key_info = m.group(1)
578 clef_info = m.group(2)
579 __main__.global_key = compute_key (key_info)# ugh.
580 voices_append ('\\key %s' % lily_key(key_info))
581 check_clef(clef_info)
583 __main__.global_key = compute_key (a)# ugh.
584 voices_append ('\\key %s \\major' % lily_key(a))
586 header ['footnotes'] = header['footnotes'] + '\\\\\\\\' + a
587 if g == 'O': # Origin
588 header ['origin'] = a
589 if g == 'X': # Reference Number
590 header ['crossRefNumber'] = a
593 if g == 'H': # History
594 header_append ('history', a)
597 if g == 'C': # Composer
598 if header.has_key('composer'):
600 header['composer'] = header['composer'] + '\\\\\\\\' + a
602 header['composer'] = a
604 header ['subtitle'] = a
605 if g == 'L': # Default note length
606 set_default_length (ln)
608 voice = re.sub (' .*$', '', a)
609 rest = re.sub ('^[^ \t]* *', '', a)
611 voices_append(state.next_bar)
613 select_voice (voice, rest)
616 if g == 'w': # vocals
622 # we use in this order specified accidental, active accidental for bar,
623 # active accidental for key
624 def pitch_to_lilypond_name (name, acc, bar_acc, key):
638 return(chr (name + ord('c')) + s)
641 def octave_to_lilypond_quotes (o):
654 while str and str[0] in DIGITS:
655 durstr = durstr + str[0]
660 n =string.atoi (durstr)
664 def duration_to_lilypond_duration (multiply_tup, defaultlen, dots):
666 # (num / den) / defaultlen < 1/base
667 while base * multiply_tup[0] < multiply_tup[1]:
670 if (multiply_tup[0] / multiply_tup[1]) == 2:
672 if (multiply_tup[0] / multiply_tup[1]) == 4:
674 return '%s%s' % ( base, '.'* dots)
679 self.next_articulation = ''
683 self.parsing_tuplet = 0
690 # return (str, num,den,dots)
691 def parse_duration (str, parser_state):
693 den = parser_state.next_den
694 parser_state.next_den = 1
696 (str, num) = parse_num (str)
702 while str[:1] == '/':
706 (str, d) =parse_num (str)
710 den = den * default_len
712 current_dots = parser_state.next_dots
713 parser_state.next_dots = 0
714 if re.match ('[ \t]*[<>]', str):
715 while str[0] in HSPACE:
719 current_dots = current_dots + 1
720 parser_state.next_den = parser_state.next_den * 2
725 parser_state.next_dots = parser_state.next_dots + 1
733 if num % multiplier == 0 and den % f == 0:
734 num = num / multiplier
736 current_dots = current_dots + d
738 return (str, num,den,current_dots)
741 def try_parse_rest (str, parser_state):
742 if not str or str[0] <> 'z' and str[0] <> 'x':
745 __main__.lyric_idx = -1
747 if parser_state.next_bar:
748 voices_append(parser_state.next_bar)
749 parser_state.next_bar = ''
757 (str, num,den,d) = parse_duration (str, parser_state)
758 voices_append ('%s%s' % (rest, duration_to_lilypond_duration ((num,den), default_len, d)))
759 if parser_state.next_articulation:
760 voices_append (parser_state.next_articulation)
761 parser_state.next_articulation = ''
774 'J' : '', # ignore slide
775 'R' : '', # ignore roll
779 def try_parse_articulation (str, state):
780 while str and artic_tbl.has_key(str[:1]):
781 state.next_articulation = state.next_articulation + artic_tbl[str[:1]]
782 if not artic_tbl[str[:1]]:
783 sys.stderr.write("Warning: ignoring `%s'\n" % str[:1] )
789 # s7m2 input doesnt care about spaces
790 if re.match('[ \t]*\(', str):
791 str = string.lstrip (str)
794 while str[:1] =='(' and str[1] not in DIGITS:
795 slur_begin = slur_begin + 1
796 state.next_articulation = state.next_articulation + '('
802 # remember accidental for rest of bar
804 def set_bar_acc(note, octave, acc, state):
807 n_oct = note + octave * 7
808 state.in_acc[n_oct] = acc
810 # get accidental set in this bar or UNDEF if not set
811 def get_bar_acc(note, octave, state):
812 n_oct = note + octave * 7
813 if state.in_acc.has_key(n_oct):
814 return(state.in_acc[n_oct])
818 def clear_bar_acc(state):
819 for k in state.in_acc.keys():
824 # WAT IS ABC EEN ONTZETTENDE PROGRAMMEERPOEP !
825 def try_parse_note (str, parser_state):
844 octave = parser_state.base_octave
845 if str[0] in "ABCDEFG":
846 str = string.lower (str[0]) + str[1:]
851 if str[0] in "abcdefg":
852 notename = (ord(str[0]) - ord('a') + 5)%7
855 return str # failed; not a note!
858 __main__.lyric_idx = -1
860 if parser_state.next_bar:
861 voices_append(parser_state.next_bar)
862 parser_state.next_bar = ''
867 while str[0] == '\'':
871 (str, num,den,current_dots) = parse_duration (str, parser_state)
874 if re.match('[ \t]*\)', str):
875 str = string.lstrip (str)
879 slur_end = slur_end + 1
884 voices_append ('%s' % ')' *slur_end )
886 bar_acc = get_bar_acc(notename, octave, parser_state)
887 pit = pitch_to_lilypond_name(notename, acc, bar_acc, global_key[notename])
888 oct = octave_to_lilypond_quotes (octave)
889 if acc != UNDEF and (acc == global_key[notename] or acc == bar_acc):
893 voices_append ("%s%s%s%s" %
895 duration_to_lilypond_duration ((num,den), default_len, current_dots)))
897 set_bar_acc(notename, octave, acc, parser_state)
898 if parser_state.next_articulation:
899 articulation = articulation + parser_state.next_articulation
900 parser_state.next_articulation = ''
902 voices_append (articulation)
904 if parser_state.parsing_tuplet:
905 parser_state.parsing_tuplet = parser_state.parsing_tuplet - 1
906 if not parser_state.parsing_tuplet:
909 voices_append ('%s' % '(' * slur_begin )
914 def junk_space (str):
915 while str and str[0] in '\t\n ':
921 def try_parse_guitar_chord (str, state):
925 if str[0] == '_' or (str[0] == '^'):
930 while str and str[0] != '"':
936 gc = re.sub('#', '\\#', gc) # escape '#'s
937 state.next_articulation = ("%c\"%s\"" % (position ,gc)) + state.next_articulation
940 def try_parse_escape (str):
941 if not str or str [0] != '\\':
946 key_table = compute_key ()
950 # |] thin-thick double bar line
951 # || thin-thin double bar line
952 # [| thick-thin double bar line
955 # :: left-right repeat
975 '|:' : '\\repeat volta 2 {',
976 '::' : '} \\repeat volta 2 {',
977 '|1' : '} \\alternative{{',
984 warn_about = ['|:', '::', ':|', '|1', ':|2', '|2']
985 alternative_opener = ['|1', '|2', ':|2']
986 repeat_ender = ['::', ':|']
987 repeat_opener = ['::', '|:']
989 doing_alternative = [''] * 8
992 def try_parse_bar (str,state):
993 global in_repeat, doing_alternative, using_old
996 if current_voice_idx < 0:
997 select_voice ('default', '')
998 # first try the longer one
999 for trylen in [3,2,1]:
1000 if str[:trylen] and bar_dict.has_key (str[:trylen]):
1003 bs = "\\bar \"%s\"" % old_bar_dict[s]
1005 bs = "%s" % bar_dict[s]
1007 if s in alternative_opener:
1008 if not in_repeat[current_voice_idx]:
1010 bs = "\\bar \"%s\"" % old_bar_dict[s]
1012 doing_alternative[current_voice_idx] = 't'
1014 if s in repeat_ender:
1015 if not in_repeat[current_voice_idx]:
1016 sys.stderr.write("Warning: inserting repeat to beginning of notes.\n")
1018 in_repeat[current_voice_idx] = ''
1020 if doing_alternative[current_voice_idx]:
1023 bs = "\\bar \"%s\"" % old_bar_dict[s]
1026 doing_alternative[current_voice_idx] = ''
1027 in_repeat[current_voice_idx] = ''
1028 if s in repeat_opener:
1029 in_repeat[current_voice_idx] = 't'
1031 bs = "\\bar \"%s\"" % old_bar_dict[s]
1036 state.next_bar = '|\n'
1038 clear_bar_acc(state)
1040 if bs <> None or state.next_bar != '':
1041 if state.parsing_tuplet:
1042 state.parsing_tuplet =0
1043 voices_append ('} ')
1046 clear_bar_acc(state)
1049 voices_append("} }")
1053 def try_parse_tie (str):
1056 voices_append (' ~ ')
1059 def bracket_escape (str, state):
1060 m = re.match ( '^([^\]]*)] *(.*)$', str)
1064 try_parse_header_line (cmd, state)
1067 def try_parse_chord_delims (str, state):
1070 if re.match('[A-Z]:', str): # bracket escape
1071 return bracket_escape(str, state)
1073 voices_append(state.next_bar)
1079 if state.plus_chord:
1081 state.plus_chord = 0
1084 voices_append(state.next_bar)
1087 state.plus_chord = 1
1095 while str[:1] ==')':
1100 voices_append ("\\spanrequest \\stop \"slur\"" * end)
1104 def try_parse_grace_delims (str, state):
1107 voices_append(state.next_bar)
1110 voices_append ('\\grace { ')
1118 def try_parse_comment (str):
1121 if str[0:5] == '%MIDI':
1122 #the nobarlines option is necessary for an abc to lilypond translator for
1123 #exactly the same reason abc2midi needs it: abc requires the user to enter
1124 #the note that will be printed, and MIDI and lilypond expect entry of the
1125 #pitch that will be played.
1127 #In standard 19th century musical notation, the algorithm for translating
1128 #between printed note and pitch involves using the barlines to determine
1129 #the scope of the accidentals.
1131 #Since ABC is frequently used for music in styles that do not use this
1132 #convention, such as most music written before 1700, or ethnic music in
1133 #non-western scales, it is necessary to be able to tell a translator that
1134 #the barlines should not affect its interpretation of the pitch.
1135 if (string.find(str,'nobarlines') > 0):
1137 elif str[0:3] == '%LY':
1138 p = string.find(str, 'voices')
1140 voices_append(str[p+7:])
1142 p = string.find(str, 'slyrics')
1144 slyrics_append(str[p+8:])
1146 #write other kinds of appending if we ever need them.
1150 def parse_file (fn):
1154 select_voice('default', '')
1156 sys.stderr.write ("Line ... ")
1158 __main__.state = state_list[current_voice_idx]
1163 if not (lineno % happy_count):
1164 sys.stderr.write ('[%d]'% lineno)
1166 m = re.match ('^([^%]*)%(.*)$',ln) # add comments to current voice
1169 try_parse_comment(m.group(2))
1170 voices_append ('%% %s\n' % m.group(2))
1175 ln = try_parse_header_line (ln, state)
1177 # Try nibbling characters off until the line doesn't change.
1179 while ln != prev_ln:
1181 ln = try_parse_chord_delims (ln, state)
1182 ln = try_parse_rest (ln, state)
1183 ln = try_parse_articulation (ln,state)
1184 ln = try_parse_note (ln, state)
1185 ln = try_parse_bar (ln, state)
1186 ln = try_parse_tie (ln)
1187 ln = try_parse_escape (ln)
1188 ln = try_parse_guitar_chord (ln, state)
1189 ln = try_parse_tuplet_begin (ln, state)
1190 ln = try_parse_group_end (ln, state)
1191 ln = try_parse_grace_delims (ln, state)
1192 ln = junk_space (ln)
1195 msg = "%s: %d: Huh? Don't understand\n" % (fn, lineno)
1196 sys.stderr.write (msg)
1197 left = orig_ln[0:-len (ln)]
1198 sys.stderr.write (left + '\n')
1199 sys.stderr.write (' ' * len (left) + ln + '\n')
1203 sys.stderr.write ("%s from LilyPond %s\n" % (program_name, version))
1207 Convert ABC to lilypond.
1209 Usage: abc2ly [OPTIONS]... ABC-FILE
1212 -h, --help this help
1213 -o, --output=FILE set output filename to FILE
1214 -v, --version version information
1216 This program converts ABC music files (see
1217 http://www.gre.ac.uk/~c.walshaw/abc2mtex/abc.txt) To LilyPond input.
1220 def print_version ():
1221 print r"""abc2ly (GNU lilypond) %s""" % version
1225 (options, files) = getopt.getopt (sys.argv[1:], 'vo:h', ['help','version', 'output='])
1231 if o== '--help' or o == '-h':
1234 if o == '--version' or o == '-v':
1238 if o == '--output' or o == '-o':
1246 header['tagline'] = 'Lily was here %s -- automatically converted from ABC' % version
1251 sys.stderr.write ('Parsing `%s\'...\n' % f)
1254 if not out_filename:
1255 out_filename = os.path.basename (os.path.splitext (f)[0]) + ".ly"
1256 sys.stderr.write ('lilypond output to: `%s\'...' % out_filename)
1257 outf = open (out_filename, 'w')
1259 # dump_global (outf)
1260 dump_header (outf ,header)
1265 sys.stderr.write ('\n')