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)
54 program_name = 'abc2ly'
55 version = '@TOPLEVEL_VERSION@'
56 if version == '@' + 'TOPLEVEL_VERSION' + '@':
57 version = '(unknown version)' # uGUHGUHGHGUGH
71 header['footnotes'] = ''
76 repeat_state = [0] * 8
77 current_voice_idx = -1
78 current_lyric_idx = -1
84 global_key = [0] * 7 # UGH
85 names = ["One", "Two", "Three"]
93 if re.match('-8va', s) or re.match('treble8', s):
94 # treble8 is used by abctab2ps; -8va is used by barfly,
95 # and by my patch to abc2ps. If there's ever a standard
96 # about this we'll support that.
98 state.base_octave = -1
99 voices_append("\\clef \"G_8\";\n")
100 elif re.match('^treble', s):
102 if re.match ('^-8', s):
104 state.base_octave = -2
105 voices_append("\\clef \"G_8\";\n")
107 state.base_octave = 0
108 voices_append("\\clef treble;\n")
109 elif re.match('^alto', s):
111 state.base_octave = -1
112 voices_append ("\\clef alto;\n" )
113 elif re.match('^bass',s ):
115 state.base_octave = -2
116 voices_append ("\\clef bass;\n" )
119 def select_voice (name, rol):
120 if not voice_idx_dict.has_key (name):
121 state_list.append(Parser_state())
124 voice_idx_dict[name] = len (voices) -1
125 __main__.current_voice_idx = voice_idx_dict[name]
126 __main__.state = state_list[current_voice_idx]
128 m = re.match ('^([^ \t=]*)=(.*)$', rol) # find keywork
132 a = re.match ('^("[^"]*"|[^ \t]*) *(.*)$', rol)
136 if keyword == 'clef':
138 elif keyword == "name":
139 value = re.sub ('\\\\','\\\\\\\\', value)
140 voices_append ("\\property Staff.instrument = %s\n" % value )
141 __main__.part_names = 1
142 elif keyword == "sname" or keyword == "snm":
143 voices_append ("\\property Staff.instr = %s\n" % value )
151 def dump_header (outf,hdr):
152 outf.write ('\\header {\n')
156 outf.write ('\t%s = "%s";\n'% (k,hdr[k]))
159 def dump_lyrics (outf):
161 outf.write("\n\\score\n{\n \\context Lyrics\n <\n")
162 for i in range (len (lyrics)):
163 outf.write ( lyrics [i])
165 outf.write(" >\n \\paper{}\n}\n")
167 def dump_default_bar (outf):
168 outf.write ("\n\\property Score.defaultBarType=\"empty\"\n")
171 def dump_slyrics (outf):
172 ks = voice_idx_dict.keys()
175 for i in range (len(slyrics[voice_idx_dict[k]])):
176 outf.write ("\nwords%sV%d = \\lyrics {" % (k, i))
177 outf.write ("\n" + slyrics [voice_idx_dict[k]][i])
180 def dump_voices (outf):
181 global doing_alternative, in_repeat
182 ks = voice_idx_dict.keys()
185 outf.write ("\nvoice%s = \\notes {" % k)
186 dump_default_bar(outf)
187 if repeat_state[voice_idx_dict[k]]:
188 outf.write("\n\\repeat volta 2 {")
189 outf.write ("\n" + voices [voice_idx_dict[k]])
191 if doing_alternative[voice_idx_dict[k]]:
193 if in_repeat[voice_idx_dict[k]]:
197 def dump_score (outf):
198 outf.write (r"""\score{
202 ks = voice_idx_dict.keys ();
205 if k == 'default' and len (voice_idx_dict) > 1:
207 if len ( slyrics [voice_idx_dict[k]] ):
208 outf.write ("\n \\addlyrics")
209 outf.write ("\n\t\\context Staff=\"%s\"\n\t{\n" %k )
211 outf.write ("\t \\$voicedefault\n")
212 outf.write ("\t \\$voice%s " % k)
213 outf.write ("\n\t}\n")
214 if len ( slyrics [voice_idx_dict[k]] ):
215 outf.write ("\n\t\\context Lyrics=\"%s\" \n\t<\t" % k)
216 for i in range (len(slyrics[voice_idx_dict[k]])):
217 outf.write("\n\t { \\$words%sV%d }" % ( k, i) )
218 outf.write ( "\n\t>\n" )
220 outf.write ("\n\t\\paper {\n")
222 outf.write ("\t \\translator \n\t {\n")
223 outf.write ("\t\t\\StaffContext\n")
224 outf.write ("\t\t\\consists Staff_margin_engraver;\n")
225 outf.write ("\t }\n")
226 outf.write ("\t}\n\t\\midi {}\n}\n")
230 def set_default_length (s):
231 global length_specified
232 m = re.search ('1/([0-9]+)', s)
234 __main__.default_len = string.atoi ( m.group (1))
237 def set_default_len_from_time_sig (s):
238 m = re.search ('([0-9]+)/([0-9]+)', s)
240 n = string.atoi (m.group (1))
241 d = string.atoi (m.group (2))
242 if (n * 1.0 )/(d * 1.0) < 0.75:
243 __main__.default_len = 16
245 __main__.default_len = 8
254 sys.stderr.write ("can't open file: %s\n" % f)
258 sys.stderr.write ("gulped empty file: %s\n" % f)
263 # pitch manipulation. Tuples are (name, alteration).
264 # 0 is (central) C. Alteration -1 is a flat, Alteration +1 is a sharp
265 # pitch in semitones.
266 def semitone_pitch (tup):
276 p = p + t* 2 + tup[1]
279 def fifth_above_pitch (tup):
280 (n, a) = (tup[0] + 4, tup[1])
282 difference = 7 - (semitone_pitch ((n,a)) - semitone_pitch (tup))
293 (t,a) = fifth_above_pitch (p)
294 if semitone_pitch((t,a)) % 12 == 0:
306 (t,a) = quart_above_pitch (p)
307 if semitone_pitch((t,a)) % 12 == 0:
313 def quart_above_pitch (tup):
314 (n, a) = (tup[0] + 3, tup[1])
316 difference = 5 - (semitone_pitch ((n,a)) - semitone_pitch (tup))
321 key_lookup = { # abc to lilypond key mode names
330 'mix' : 'mixolydian',
331 'mixolydian' : 'mixolydian',
341 if k and k[0] == '#':
344 elif k and k[0] == 'b':
348 return '%s \\major' % key
351 if key_lookup.has_key(type):
352 return("%s \\%s" % ( key, key_lookup[type]))
353 sys.stderr.write("Unknown key type %s ignored\n" % type)
356 def shift_key (note, acc , shift):
357 s = semitone_pitch((note, acc))
358 s = (s + shift + 12) % 12
370 key_shift = { # semitone shifts for key mode names
384 intkey = (ord (k[0]) - ord('a') + 5) % 7
388 if k and k[0] == 'b':
391 elif k and k[0] == '#':
395 if k and key_shift.has_key(k):
396 (intkey, intkeyacc) = shift_key(intkey, intkeyacc, key_shift[k])
397 keytup = (intkey, intkeyacc)
399 sharp_key_seq = sharp_keys ()
400 flat_key_seq = flat_keys ()
404 if keytup in sharp_key_seq:
406 key_count = sharp_key_seq.index (keytup)
407 accseq = map (lambda x: (4*x -1 ) % 7, range (1, key_count + 1))
409 elif keytup in flat_key_seq:
411 key_count = flat_key_seq.index (keytup)
412 accseq = map (lambda x: (3*x + 3 ) % 7, range (1, key_count + 1))
418 key_table[a] = key_table[a] + accsign
433 def try_parse_tuplet_begin (str, state):
434 if re.match ('\([2-9]', str):
437 state.parsing_tuplet = string.atoi (dig[0])
439 voices_append ("\\times %s {" % tup_lookup[dig])
442 def try_parse_group_end (str, state):
443 if str and str[0] in HSPACE:
447 def header_append (key, a):
449 if header.has_key (key):
450 s = header[key] + "\n"
454 linelen = len (v) - string.rfind(v, '\n')
455 if linelen + len (a) > 80:
459 def stuff_append (stuff, idx, a):
463 stuff [idx] = wordwrap(a, stuff[idx])
467 def voices_append(a):
468 if current_voice_idx < 0:
469 select_voice ('default', '')
470 stuff_append (voices, current_voice_idx, a)
472 def repeat_prepend():
474 if current_voice_idx < 0:
475 select_voice ('default', '')
477 repeat_state[current_voice_idx] = 't'
480 def lyrics_append(a):
481 a = re.sub ( '#', '\\#', a) # latex does not like naked #'s
482 a = re.sub ( '"', '\\"', a) # latex does not like naked "'s
483 a = '\t{ \\lyrics "' + a + '" }\n'
484 stuff_append (lyrics, current_lyric_idx, a)
486 # break lyrics to words and put "'s around words containing numbers and '"'s
490 m = re.match('[ \t]*([^ \t]*)[ \t]*(.*$)', str)
494 word = re.sub('"', '\\"', word) # escape "
495 if re.match('.*[0-9"\(]', word):
496 word = re.sub('_', ' ', word) # _ causes probs inside ""
497 ret = ret + '\"' + word + '\" '
499 ret = ret + word + ' '
504 def slyrics_append(a):
505 a = re.sub ( '_', ' _ ', a) # _ to ' _ '
506 a = re.sub ( '-', '- ', a) # split words with -
507 a = re.sub ( '\\\\- ', '-', a) # unless \-
508 a = re.sub ( '~', '_', a) # ~ to space('_')
509 a = re.sub ( '\*', '_ ', a) # * to to space
510 a = re.sub ( '#', '\\#', a) # latex does not like naked #'s
511 if re.match('.*[0-9"\(]', a): # put numbers and " and ( into quoted string
513 a = re.sub ( '$', ' ', a) # insure space between lines
514 __main__.lyric_idx = lyric_idx + 1
515 if len(slyrics[current_voice_idx]) <= lyric_idx:
516 slyrics[current_voice_idx].append(a)
518 v = slyrics[current_voice_idx][lyric_idx]
519 slyrics[current_voice_idx][lyric_idx] = wordwrap(a, slyrics[current_voice_idx][lyric_idx])
522 def try_parse_header_line (ln, state):
523 global length_specified
524 m = re.match ('^([A-Za-z]): *(.*)$', ln)
530 a = re.sub('[ \t]*$','', a) #strip trailing blanks
531 if header.has_key('title'):
533 header['title'] = header['title'] + '\\\\\\\\' + a
538 if not state.common_time:
539 state.common_time = 1
540 voices_append ("\\property Staff.TimeSignature \\override #\'style = #'C\n")
543 if not state.common_time:
544 state.common_time = 1
545 voices_append ("\\property Staff.TimeSignature \\override #\'style = #'C\n")
547 if not length_specified:
548 set_default_len_from_time_sig (a)
551 voices_append ('\\time %s;' % a)
556 m = re.match ('^([^ \t]*) *(.*)$', a) # seperate clef info
558 # there may or may not be a space
559 # between the key letter and the mode
560 if key_lookup.has_key(m.group(2)[0:3]):
561 key_info = m.group(1) + m.group(2)[0:3]
562 clef_info = m.group(2)[4:]
564 key_info = m.group(1)
565 clef_info = m.group(2)
566 __main__.global_key = compute_key (key_info)# ugh.
567 voices_append ('\\key %s;' % lily_key(key_info))
568 check_clef(clef_info)
570 __main__.global_key = compute_key (a)# ugh.
571 voices_append ('\\key %s \\major;' % lily_key(a))
573 header ['footnotes'] = header['footnotes'] + '\\\\\\\\' + a
574 if g == 'O': # Origin
575 header ['origin'] = a
576 if g == 'X': # Reference Number
577 header ['crossRefNumber'] = a
580 if g == 'H': # History
581 header_append ('history', a)
584 if g == 'C': # Composer
585 if header.has_key('composer'):
587 header['composer'] = header['composer'] + '\\\\\\\\' + a
589 header['composer'] = a
591 header ['subtitle'] = a
592 if g == 'L': # Default note length
593 set_default_length (ln)
595 voice = re.sub (' .*$', '', a)
596 rest = re.sub ('^[^ \t]* *', '', a)
598 voices_append(state.next_bar)
600 select_voice (voice, rest)
603 if g == 'w': # vocals
609 # we use in this order specified accidental, active accidental for bar,
610 # active accidental for key
611 def pitch_to_lilypond_name (name, acc, bar_acc, key):
625 return(chr (name + ord('c')) + s)
628 def octave_to_lilypond_quotes (o):
641 while str and str[0] in DIGITS:
642 durstr = durstr + str[0]
647 n =string.atoi (durstr)
651 def duration_to_lilypond_duration (multiply_tup, defaultlen, dots):
653 # (num / den) / defaultlen < 1/base
654 while base * multiply_tup[0] < multiply_tup[1]:
657 if (multiply_tup[0] / multiply_tup[1]) == 2:
659 if (multiply_tup[0] / multiply_tup[1]) == 4:
661 return '%s%s' % ( base, '.'* dots)
666 self.next_articulation = ''
670 self.parsing_tuplet = 0
677 # return (str, num,den,dots)
678 def parse_duration (str, parser_state):
680 den = parser_state.next_den
681 parser_state.next_den = 1
683 (str, num) = parse_num (str)
688 while str[:1] == '/':
692 (str, d) =parse_num (str)
696 den = den * default_len
698 current_dots = parser_state.next_dots
699 parser_state.next_dots = 0
700 if re.match ('[ \t]*[<>]', str):
701 while str[0] in HSPACE:
705 current_dots = current_dots + 1;
706 parser_state.next_den = parser_state.next_den * 2
711 parser_state.next_dots = parser_state.next_dots + 1
719 if num % multiplier == 0 and den % f == 0:
720 num = num / multiplier
722 current_dots = current_dots + d
724 return (str, num,den,current_dots)
727 def try_parse_rest (str, parser_state):
728 if not str or str[0] <> 'z' and str[0] <> 'x':
731 __main__.lyric_idx = -1
733 if parser_state.next_bar:
734 voices_append(parser_state.next_bar)
735 parser_state.next_bar = ''
743 (str, num,den,d) = parse_duration (str, parser_state)
744 voices_append ('%s%s' % (rest, duration_to_lilypond_duration ((num,den), default_len, d)))
745 if parser_state.next_articulation:
746 voices_append (parser_state.next_articulation)
747 parser_state.next_articulation = ''
760 'J' : '', # ignore slide
761 'R' : '', # ignore roll
765 def try_parse_articulation (str, state):
766 while str and artic_tbl.has_key(str[:1]):
767 state.next_articulation = state.next_articulation + artic_tbl[str[:1]]
768 if not artic_tbl[str[:1]]:
769 sys.stderr.write("Warning: ignoring %s\n" % str[:1] )
775 # s7m2 input doesnt care about spaces
776 if re.match('[ \t]*\(', str):
777 str = string.lstrip (str)
780 while str[:1] =='(' and str[1] not in DIGITS:
781 slur_begin = slur_begin + 1
782 state.next_articulation = state.next_articulation + '('
788 # remember accidental for rest of bar
790 def set_bar_acc(note, octave, acc, state):
793 n_oct = note + octave * 7
794 state.in_acc[n_oct] = acc
796 # get accidental set in this bar or UNDEF if not set
797 def get_bar_acc(note, octave, state):
798 n_oct = note + octave * 7
799 if state.in_acc.has_key(n_oct):
800 return(state.in_acc[n_oct])
804 def clear_bar_acc(state):
805 for k in state.in_acc.keys():
810 # WAT IS ABC EEN ONTZETTENDE PROGRAMMEERPOEP !
811 def try_parse_note (str, parser_state):
830 octave = parser_state.base_octave
831 if str[0] in "ABCDEFG":
832 str = string.lower (str[0]) + str[1:]
837 if str[0] in "abcdefg":
838 notename = (ord(str[0]) - ord('a') + 5)%7
841 return str # failed; not a note!
844 __main__.lyric_idx = -1
846 if parser_state.next_bar:
847 voices_append(parser_state.next_bar)
848 parser_state.next_bar = ''
853 while str[0] == '\'':
857 (str, num,den,current_dots) = parse_duration (str, parser_state)
860 if re.match('[ \t]*\)', str):
861 str = string.lstrip (str)
865 slur_end = slur_end + 1
870 voices_append ('%s' % ')' *slur_end )
872 bar_acc = get_bar_acc(notename, octave, parser_state)
873 pit = pitch_to_lilypond_name(notename, acc, bar_acc, global_key[notename])
874 oct = octave_to_lilypond_quotes (octave)
875 if acc != UNDEF and (acc == global_key[notename] or acc == bar_acc):
879 voices_append ("%s%s%s%s" %
881 duration_to_lilypond_duration ((num,den), default_len, current_dots)))
883 set_bar_acc(notename, octave, acc, parser_state)
884 if parser_state.next_articulation:
885 articulation = articulation + parser_state.next_articulation
886 parser_state.next_articulation = ''
888 voices_append (articulation)
890 if parser_state.parsing_tuplet:
891 parser_state.parsing_tuplet = parser_state.parsing_tuplet - 1
892 if not parser_state.parsing_tuplet:
895 voices_append ('%s' % '(' * slur_begin )
900 def junk_space (str):
901 while str and str[0] in '\t\n ':
907 def try_parse_guitar_chord (str, state):
911 if str[0] == '_' or (str[0] == '^'):
916 while str and str[0] != '"':
922 gc = re.sub('#', '\\#', gc) # escape '#'s
923 state.next_articulation = ("%c\"%s\"" % (position ,gc)) + state.next_articulation
926 def try_parse_escape (str):
927 if not str or str [0] != '\\':
932 key_table = compute_key ()
936 # |] thin-thick double bar line
937 # || thin-thin double bar line
938 # [| thick-thin double bar line
941 # :: left-right repeat
957 '|]' : '\\bar "|.";',
958 '||' : '\\bar "||";',
959 '[|' : '\\bar "||";',
961 '|:' : '\\repeat volta 2 {',
962 '::' : '} \\repeat volta 2 {',
963 '|1' : '} \\alternative{{',
970 warn_about = ['|:', '::', ':|', '|1', ':|2', '|2']
971 alternative_opener = ['|1', '|2', ':|2']
972 repeat_ender = ['::', ':|']
973 repeat_opener = ['::', '|:']
975 doing_alternative = [''] * 8
978 def try_parse_bar (str,state):
979 global in_repeat, doing_alternative, using_old
982 if current_voice_idx < 0:
983 select_voice ('default', '')
984 # first try the longer one
985 for trylen in [3,2,1]:
986 if str[:trylen] and bar_dict.has_key (str[:trylen]):
989 bs = "\\bar \"%s\";" % old_bar_dict[s]
991 bs = "%s" % bar_dict[s]
993 if s in alternative_opener:
994 if not in_repeat[current_voice_idx]:
996 bs = "\\bar \"%s\";" % old_bar_dict[s]
998 doing_alternative[current_voice_idx] = 't'
1000 if s in repeat_ender:
1001 if not in_repeat[current_voice_idx]:
1002 sys.stderr.write("Warning: inserting repeat to beginning of notes.\n")
1004 in_repeat[current_voice_idx] = ''
1006 if doing_alternative[current_voice_idx]:
1009 bs = "\\bar \"%s\";" % old_bar_dict[s]
1012 doing_alternative[current_voice_idx] = ''
1013 in_repeat[current_voice_idx] = ''
1014 if s in repeat_opener:
1015 in_repeat[current_voice_idx] = 't'
1017 bs = "\\bar \"%s\";" % old_bar_dict[s]
1022 state.next_bar = '|\n'
1024 clear_bar_acc(state)
1026 if bs <> None or state.next_bar != '':
1027 if state.parsing_tuplet:
1028 state.parsing_tuplet =0
1029 voices_append ('} ')
1032 clear_bar_acc(state)
1035 voices_append("} }")
1039 def try_parse_tie (str):
1042 voices_append (' ~ ')
1045 def bracket_escape (str, state):
1046 m = re.match ( '^([^\]]*)] *(.*)$', str)
1050 try_parse_header_line (cmd, state)
1053 def try_parse_chord_delims (str, state):
1056 if re.match('[A-Z]:', str): # bracket escape
1057 return bracket_escape(str, state)
1059 voices_append(state.next_bar)
1065 if state.plus_chord:
1067 state.plus_chord = 0
1070 voices_append(state.next_bar)
1073 state.plus_chord = 1
1081 while str[:1] ==')':
1086 voices_append ("\\spanrequest \\stop \"slur\"" * end);
1090 def try_parse_grace_delims (str, state):
1093 voices_append(state.next_bar)
1096 voices_append ('\\grace { ')
1104 def try_parse_comment (str):
1107 if str[0:5] == '%MIDI':
1108 #the nobarlines option is necessary for an abc to lilypond translator for
1109 #exactly the same reason abc2midi needs it: abc requires the user to enter
1110 #the note that will be printed, and MIDI and lilypond expect entry of the
1111 #pitch that will be played.
1113 #In standard 19th century musical notation, the algorithm for translating
1114 #between printed note and pitch involves using the barlines to determine
1115 #the scope of the accidentals.
1117 #Since ABC is frequently used for music in styles that do not use this
1118 #convention, such as most music written before 1700, or ethnic music in
1119 #non-western scales, it is necessary to be able to tell a translator that
1120 #the barlines should not affect its interpretation of the pitch.
1121 if (string.find(str,'nobarlines') > 0):
1123 elif str[0:3] == '%LY':
1124 p = string.find(str, 'voices')
1126 voices_append(str[p+7:])
1128 p = string.find(str, 'slyrics')
1130 slyrics_append(str[p+8:])
1132 #write other kinds of appending if we ever need them.
1136 def parse_file (fn):
1140 select_voice('default', '')
1142 sys.stderr.write ("Line ... ")
1144 __main__.state = state_list[current_voice_idx]
1149 if not (lineno % happy_count):
1150 sys.stderr.write ('[%d]'% lineno)
1152 m = re.match ('^([^%]*)%(.*)$',ln) # add comments to current voice
1155 try_parse_comment(m.group(2))
1156 voices_append ('%% %s\n' % m.group(2))
1161 ln = try_parse_header_line (ln, state)
1163 # Try nibbling characters off until the line doesn't change.
1165 while ln != prev_ln:
1167 ln = try_parse_chord_delims (ln, state)
1168 ln = try_parse_rest (ln, state)
1169 ln = try_parse_articulation (ln,state)
1170 ln = try_parse_note (ln, state)
1171 ln = try_parse_bar (ln, state)
1172 ln = try_parse_tie (ln)
1173 ln = try_parse_escape (ln)
1174 ln = try_parse_guitar_chord (ln, state)
1175 ln = try_parse_tuplet_begin (ln, state)
1176 ln = try_parse_group_end (ln, state)
1177 ln = try_parse_grace_delims (ln, state)
1178 ln = junk_space (ln)
1181 msg = "%s: %d: Huh? Don't understand\n" % (fn, lineno)
1182 sys.stderr.write (msg)
1183 left = orig_ln[0:-len (ln)]
1184 sys.stderr.write (left + '\n')
1185 sys.stderr.write (' ' * len (left) + ln + '\n')
1189 sys.stderr.write ("%s from LilyPond %s\n" % (program_name, version))
1193 Convert ABC to lilypond.
1195 Usage: abc2ly [OPTIONS]... ABC-FILE
1198 -h, --help this help
1199 -o, --output=FILE set output filename to FILE
1200 -v, --version version information
1202 This program converts ABC music files (see
1203 http://www.gre.ac.uk/~c.walshaw/abc2mtex/abc.txt) To LilyPond input.
1206 def print_version ():
1207 print r"""abc2ly (GNU lilypond) %s""" % version
1211 (options, files) = getopt.getopt (sys.argv[1:], 'vo:h', ['help','version', 'output='])
1217 if o== '--help' or o == '-h':
1220 if o == '--version' or o == '-v':
1224 if o == '--output' or o == '-o':
1232 header['tagline'] = 'Lily was here %s -- automatically converted from ABC' % version
1237 sys.stderr.write ('Parsing... [%s]\n' % f)
1240 if not out_filename:
1241 out_filename = os.path.basename (os.path.splitext (f)[0]) + ".ly"
1242 sys.stderr.write ('Ly output to: %s...' % out_filename)
1243 outf = open (out_filename, 'w')
1245 # dump_global (outf)
1246 dump_header (outf ,header)
1251 sys.stderr.write ('\n')