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 if re.match('[1-9]', k):
178 m = alphabet[string.atoi(k)]
181 for i in range (len(slyrics[voice_idx_dict[k]])):
183 outf.write ("\nwords%sV%s = \\lyrics {" % (m, l))
184 outf.write ("\n" + slyrics [voice_idx_dict[k]][i])
187 def dump_voices (outf):
188 global doing_alternative, in_repeat
189 ks = voice_idx_dict.keys()
192 if re.match ('[1-9]', k):
193 m = alphabet[string.atoi(k)]
196 outf.write ("\nvoice%s = \\notes {" % m)
197 dump_default_bar(outf)
198 if repeat_state[voice_idx_dict[k]]:
199 outf.write("\n\\repeat volta 2 {")
200 outf.write ("\n" + voices [voice_idx_dict[k]])
202 if doing_alternative[voice_idx_dict[k]]:
204 if in_repeat[voice_idx_dict[k]]:
210 #assume that Q takes the form "Q:1/4=120"
211 #There are other possibilities, but they are deprecated
212 if string.count(a, '/') == 1:
213 array=string.split(a,'/')
216 sys.stderr.write("abc2ly: Warning, unable to translate a Q specification with a numerator of %s: %s\n" % (numerator, a))
217 array2=string.split(array[1],'=')
218 denominator=array2[0]
220 duration=str(string.atof(denominator)/string.atoi(numerator))
221 midi_specs=string.join(["\\tempo", duration, "=", perminute])
223 sys.stderr.write("abc2ly: Warning, unable to parse Q specification: %s\n" % a)
225 def dump_score (outf):
226 outf.write (r"""\score{
230 ks = voice_idx_dict.keys ();
233 if re.match('[1-9]', k):
234 m = alphabet[string.atoi(k)]
237 if k == 'default' and len (voice_idx_dict) > 1:
239 if len ( slyrics [voice_idx_dict[k]] ):
240 outf.write ("\n \\addlyrics")
241 outf.write ("\n\t\\context Staff=\"%s\"\n\t{\n" %k )
243 outf.write ("\t \\voicedefault\n")
244 outf.write ("\t \\voice%s " % m)
245 outf.write ("\n\t}\n")
246 if len ( slyrics [voice_idx_dict[k]] ):
247 outf.write ("\n\t\\context Lyrics=\"%s\" \n\t<\t" % k)
248 if re.match('[1-9]',k):
249 m = alphabet[string.atoi(k)]
252 for i in range (len(slyrics[voice_idx_dict[k]])):
254 outf.write("\n\t { \\words%sV%s }" % ( m, l) )
255 outf.write ( "\n\t>\n" )
257 outf.write ("\n\t\\paper {\n")
259 outf.write ("\t \\translator \n\t {\n")
260 outf.write ("\t\t\\StaffContext\n")
261 # outf.write ("\t\t\\consists Staff_margin_engraver\n")
262 outf.write ("\t }\n")
263 outf.write ("\t}\n\t\\midi {%s}\n}\n" % midi_specs)
267 def set_default_length (s):
268 global length_specified
269 m = re.search ('1/([0-9]+)', s)
271 __main__.default_len = string.atoi ( m.group (1))
274 def set_default_len_from_time_sig (s):
275 m = re.search ('([0-9]+)/([0-9]+)', s)
277 n = string.atoi (m.group (1))
278 d = string.atoi (m.group (2))
279 if (n * 1.0 )/(d * 1.0) < 0.75:
280 __main__.default_len = 16
282 __main__.default_len = 8
291 sys.stderr.write ("can't open file: `%s'\n" % f)
295 sys.stderr.write ("gulped empty file: `%s'\n" % f)
300 # pitch manipulation. Tuples are (name, alteration).
301 # 0 is (central) C. Alteration -1 is a flat, Alteration +1 is a sharp
302 # pitch in semitones.
303 def semitone_pitch (tup):
313 p = p + t* 2 + tup[1]
316 def fifth_above_pitch (tup):
317 (n, a) = (tup[0] + 4, tup[1])
319 difference = 7 - (semitone_pitch ((n,a)) - semitone_pitch (tup))
330 (t,a) = fifth_above_pitch (p)
331 if semitone_pitch((t,a)) % 12 == 0:
343 (t,a) = quart_above_pitch (p)
344 if semitone_pitch((t,a)) % 12 == 0:
350 def quart_above_pitch (tup):
351 (n, a) = (tup[0] + 3, tup[1])
353 difference = 5 - (semitone_pitch ((n,a)) - semitone_pitch (tup))
358 key_lookup = { # abc to lilypond key mode names
367 'mix' : 'mixolydian',
368 'mixolydian' : 'mixolydian',
378 if k and k[0] == '#':
381 elif k and k[0] == 'b':
385 return '%s \\major' % key
388 if key_lookup.has_key(type):
389 return("%s \\%s" % ( key, key_lookup[type]))
390 sys.stderr.write("Unknown key type `%s' ignored\n" % type)
393 def shift_key (note, acc , shift):
394 s = semitone_pitch((note, acc))
395 s = (s + shift + 12) % 12
407 key_shift = { # semitone shifts for key mode names
430 intkey = (ord (k[0]) - ord('a') + 5) % 7
434 if k and k[0] == 'b':
437 elif k and k[0] == '#':
441 if k and key_shift.has_key(k):
442 (intkey, intkeyacc) = shift_key(intkey, intkeyacc, key_shift[k])
443 keytup = (intkey, intkeyacc)
445 sharp_key_seq = sharp_keys ()
446 flat_key_seq = flat_keys ()
450 if keytup in sharp_key_seq:
452 key_count = sharp_key_seq.index (keytup)
453 accseq = map (lambda x: (4*x -1 ) % 7, range (1, key_count + 1))
455 elif keytup in flat_key_seq:
457 key_count = flat_key_seq.index (keytup)
458 accseq = map (lambda x: (3*x + 3 ) % 7, range (1, key_count + 1))
464 key_table[a] = key_table[a] + accsign
479 def try_parse_tuplet_begin (str, state):
480 if re.match ('\([2-9]', str):
483 state.parsing_tuplet = string.atoi (dig[0])
485 voices_append ("\\times %s {" % tup_lookup[dig])
488 def try_parse_group_end (str, state):
489 if str and str[0] in HSPACE:
493 def header_append (key, a):
495 if header.has_key (key):
496 s = header[key] + "\n"
500 linelen = len (v) - string.rfind(v, '\n')
501 if linelen + len (a) > 80:
505 def stuff_append (stuff, idx, a):
509 stuff [idx] = wordwrap(a, stuff[idx])
513 def voices_append(a):
514 if current_voice_idx < 0:
515 select_voice ('default', '')
516 stuff_append (voices, current_voice_idx, a)
518 def repeat_prepend():
520 if current_voice_idx < 0:
521 select_voice ('default', '')
523 repeat_state[current_voice_idx] = 't'
526 def lyrics_append(a):
527 a = re.sub ( '#', '\\#', a) # latex does not like naked #'s
528 a = re.sub ( '"', '\\"', a) # latex does not like naked "'s
529 a = '\t{ \\lyrics "' + a + '" }\n'
530 stuff_append (lyrics, current_lyric_idx, a)
532 # break lyrics to words and put "'s around words containing numbers and '"'s
536 m = re.match('[ \t]*([^ \t]*)[ \t]*(.*$)', str)
540 word = re.sub('"', '\\"', word) # escape "
541 if re.match('.*[0-9"\(]', word):
542 word = re.sub('_', ' ', word) # _ causes probs inside ""
543 ret = ret + '\"' + word + '\" '
545 ret = ret + word + ' '
550 def slyrics_append(a):
551 a = re.sub ( '_', ' _ ', a) # _ to ' _ '
552 a = re.sub ( '-', '- ', a) # split words with -
553 a = re.sub ( '\\\\- ', '-', a) # unless \-
554 a = re.sub ( '~', '_', a) # ~ to space('_')
555 a = re.sub ( '\*', '_ ', a) # * to to space
556 a = re.sub ( '#', '\\#', a) # latex does not like naked #'s
557 if re.match('.*[0-9"\(]', a): # put numbers and " and ( into quoted string
559 a = re.sub ( '$', ' ', a) # insure space between lines
560 __main__.lyric_idx = lyric_idx + 1
561 if len(slyrics[current_voice_idx]) <= lyric_idx:
562 slyrics[current_voice_idx].append(a)
564 v = slyrics[current_voice_idx][lyric_idx]
565 slyrics[current_voice_idx][lyric_idx] = wordwrap(a, slyrics[current_voice_idx][lyric_idx])
568 def try_parse_header_line (ln, state):
569 global length_specified
570 m = re.match ('^([A-Za-z]): *(.*)$', ln)
576 a = re.sub('[ \t]*$','', a) #strip trailing blanks
577 if header.has_key('title'):
579 header['title'] = header['title'] + '\\\\\\\\' + a
584 if not state.common_time:
585 state.common_time = 1
586 voices_append ("\\property Staff.TimeSignature \\override #\'style = #'C\n")
589 if not state.common_time:
590 state.common_time = 1
591 voices_append ("\\property Staff.TimeSignature \\override #\'style = #'C\n")
593 if not length_specified:
594 set_default_len_from_time_sig (a)
597 voices_append ('\\time %s' % a)
602 m = re.match ('^([^ \t]*) *(.*)$', a) # seperate clef info
604 # there may or may not be a space
605 # between the key letter and the mode
606 if key_lookup.has_key(m.group(2)[0:3]):
607 key_info = m.group(1) + m.group(2)[0:3]
608 clef_info = m.group(2)[4:]
610 key_info = m.group(1)
611 clef_info = m.group(2)
612 __main__.global_key = compute_key (key_info)# ugh.
613 voices_append ('\\key %s' % lily_key(key_info))
614 check_clef(clef_info)
616 __main__.global_key = compute_key (a)# ugh.
617 voices_append ('\\key %s \\major' % lily_key(a))
619 header ['footnotes'] = header['footnotes'] + '\\\\\\\\' + a
620 if g == 'O': # Origin
621 header ['origin'] = a
622 if g == 'X': # Reference Number
623 header ['crossRefNumber'] = a
626 if g == 'H': # History
627 header_append ('history', a)
630 if g == 'C': # Composer
631 if header.has_key('composer'):
633 header['composer'] = header['composer'] + '\\\\\\\\' + a
635 header['composer'] = a
637 header ['subtitle'] = a
638 if g == 'L': # Default note length
639 set_default_length (ln)
641 voice = re.sub (' .*$', '', a)
642 rest = re.sub ('^[^ \t]* *', '', a)
644 voices_append(state.next_bar)
646 select_voice (voice, rest)
649 if g == 'w': # vocals
656 # we use in this order specified accidental, active accidental for bar,
657 # active accidental for key
658 def pitch_to_lilypond_name (name, acc, bar_acc, key):
672 return(chr (name + ord('c')) + s)
675 def octave_to_lilypond_quotes (o):
688 while str and str[0] in DIGITS:
689 durstr = durstr + str[0]
694 n =string.atoi (durstr)
698 def duration_to_lilypond_duration (multiply_tup, defaultlen, dots):
700 # (num / den) / defaultlen < 1/base
701 while base * multiply_tup[0] < multiply_tup[1]:
704 if (multiply_tup[0] / multiply_tup[1]) == 2:
706 if (multiply_tup[0] / multiply_tup[1]) == 4:
708 return '%s%s' % ( base, '.'* dots)
713 self.next_articulation = ''
717 self.parsing_tuplet = 0
724 # return (str, num,den,dots)
725 def parse_duration (str, parser_state):
727 den = parser_state.next_den
728 parser_state.next_den = 1
730 (str, num) = parse_num (str)
736 while str[:1] == '/':
740 (str, d) =parse_num (str)
744 den = den * default_len
746 current_dots = parser_state.next_dots
747 parser_state.next_dots = 0
748 if re.match ('[ \t]*[<>]', str):
749 while str[0] in HSPACE:
753 current_dots = current_dots + 1
754 parser_state.next_den = parser_state.next_den * 2
759 parser_state.next_dots = parser_state.next_dots + 1
767 if num % multiplier == 0 and den % f == 0:
768 num = num / multiplier
770 current_dots = current_dots + d
772 return (str, num,den,current_dots)
775 def try_parse_rest (str, parser_state):
776 if not str or str[0] <> 'z' and str[0] <> 'x':
779 __main__.lyric_idx = -1
781 if parser_state.next_bar:
782 voices_append(parser_state.next_bar)
783 parser_state.next_bar = ''
791 (str, num,den,d) = parse_duration (str, parser_state)
792 voices_append ('%s%s' % (rest, duration_to_lilypond_duration ((num,den), default_len, d)))
793 if parser_state.next_articulation:
794 voices_append (parser_state.next_articulation)
795 parser_state.next_articulation = ''
808 'J' : '', # ignore slide
809 'R' : '', # ignore roll
813 def try_parse_articulation (str, state):
814 while str and artic_tbl.has_key(str[:1]):
815 state.next_articulation = state.next_articulation + artic_tbl[str[:1]]
816 if not artic_tbl[str[:1]]:
817 sys.stderr.write("Warning: ignoring `%s'\n" % str[:1] )
823 # s7m2 input doesnt care about spaces
824 if re.match('[ \t]*\(', str):
825 str = string.lstrip (str)
828 while str[:1] =='(' and str[1] not in DIGITS:
829 slur_begin = slur_begin + 1
830 state.next_articulation = state.next_articulation + '('
836 # remember accidental for rest of bar
838 def set_bar_acc(note, octave, acc, state):
841 n_oct = note + octave * 7
842 state.in_acc[n_oct] = acc
844 # get accidental set in this bar or UNDEF if not set
845 def get_bar_acc(note, octave, state):
846 n_oct = note + octave * 7
847 if state.in_acc.has_key(n_oct):
848 return(state.in_acc[n_oct])
852 def clear_bar_acc(state):
853 for k in state.in_acc.keys():
858 # WAT IS ABC EEN ONTZETTENDE PROGRAMMEERPOEP !
859 def try_parse_note (str, parser_state):
878 octave = parser_state.base_octave
879 if str[0] in "ABCDEFG":
880 str = string.lower (str[0]) + str[1:]
885 if str[0] in "abcdefg":
886 notename = (ord(str[0]) - ord('a') + 5)%7
889 return str # failed; not a note!
892 __main__.lyric_idx = -1
894 if parser_state.next_bar:
895 voices_append(parser_state.next_bar)
896 parser_state.next_bar = ''
901 while str[0] == '\'':
905 (str, num,den,current_dots) = parse_duration (str, parser_state)
908 if re.match('[ \t]*\)', str):
909 str = string.lstrip (str)
913 slur_end = slur_end + 1
918 voices_append ('%s' % ')' *slur_end )
920 bar_acc = get_bar_acc(notename, octave, parser_state)
921 pit = pitch_to_lilypond_name(notename, acc, bar_acc, global_key[notename])
922 oct = octave_to_lilypond_quotes (octave)
923 if acc != UNDEF and (acc == global_key[notename] or acc == bar_acc):
927 voices_append ("%s%s%s%s" %
929 duration_to_lilypond_duration ((num,den), default_len, current_dots)))
931 set_bar_acc(notename, octave, acc, parser_state)
932 if parser_state.next_articulation:
933 articulation = articulation + parser_state.next_articulation
934 parser_state.next_articulation = ''
936 voices_append (articulation)
938 if parser_state.parsing_tuplet:
939 parser_state.parsing_tuplet = parser_state.parsing_tuplet - 1
940 if not parser_state.parsing_tuplet:
943 voices_append ('%s' % '(' * slur_begin )
948 def junk_space (str):
949 while str and str[0] in '\t\n ':
955 def try_parse_guitar_chord (str, state):
959 if str[0] == '_' or (str[0] == '^'):
964 while str and str[0] != '"':
970 gc = re.sub('#', '\\#', gc) # escape '#'s
971 state.next_articulation = ("%c\"%s\"" % (position ,gc)) + state.next_articulation
974 def try_parse_escape (str):
975 if not str or str [0] != '\\':
980 key_table = compute_key ()
984 # |] thin-thick double bar line
985 # || thin-thin double bar line
986 # [| thick-thin double bar line
989 # :: left-right repeat
1005 '|]' : '\\bar "|."',
1006 '||' : '\\bar "||"',
1007 '[|' : '\\bar "||"',
1009 '|:' : '\\repeat volta 2 {',
1010 '::' : '} \\repeat volta 2 {',
1011 '|1' : '} \\alternative{{',
1018 warn_about = ['|:', '::', ':|', '|1', ':|2', '|2']
1019 alternative_opener = ['|1', '|2', ':|2']
1020 repeat_ender = ['::', ':|']
1021 repeat_opener = ['::', '|:']
1022 in_repeat = [''] * 8
1023 doing_alternative = [''] * 8
1026 def try_parse_bar (str,state):
1027 global in_repeat, doing_alternative, using_old
1030 if current_voice_idx < 0:
1031 select_voice ('default', '')
1032 # first try the longer one
1033 for trylen in [3,2,1]:
1034 if str[:trylen] and bar_dict.has_key (str[:trylen]):
1037 bs = "\\bar \"%s\"" % old_bar_dict[s]
1039 bs = "%s" % bar_dict[s]
1041 if s in alternative_opener:
1042 if not in_repeat[current_voice_idx]:
1044 bs = "\\bar \"%s\"" % old_bar_dict[s]
1046 doing_alternative[current_voice_idx] = 't'
1048 if s in repeat_ender:
1049 if not in_repeat[current_voice_idx]:
1050 sys.stderr.write("Warning: inserting repeat to beginning of notes.\n")
1052 in_repeat[current_voice_idx] = ''
1054 if doing_alternative[current_voice_idx]:
1057 bs = "\\bar \"%s\"" % old_bar_dict[s]
1060 doing_alternative[current_voice_idx] = ''
1061 in_repeat[current_voice_idx] = ''
1062 if s in repeat_opener:
1063 in_repeat[current_voice_idx] = 't'
1065 bs = "\\bar \"%s\"" % old_bar_dict[s]
1070 state.next_bar = '|\n'
1072 clear_bar_acc(state)
1074 if bs <> None or state.next_bar != '':
1075 if state.parsing_tuplet:
1076 state.parsing_tuplet =0
1077 voices_append ('} ')
1080 clear_bar_acc(state)
1083 voices_append("} }")
1087 def try_parse_tie (str):
1090 voices_append (' ~ ')
1093 def bracket_escape (str, state):
1094 m = re.match ( '^([^\]]*)] *(.*)$', str)
1098 try_parse_header_line (cmd, state)
1101 def try_parse_chord_delims (str, state):
1104 if re.match('[A-Z]:', str): # bracket escape
1105 return bracket_escape(str, state)
1107 voices_append(state.next_bar)
1113 if state.plus_chord:
1115 state.plus_chord = 0
1118 voices_append(state.next_bar)
1121 state.plus_chord = 1
1129 while str[:1] ==')':
1134 voices_append ("\\spanrequest \\stop \"slur\"" * end)
1138 def try_parse_grace_delims (str, state):
1141 voices_append(state.next_bar)
1144 voices_append ('\\grace { ')
1152 def try_parse_comment (str):
1155 if str[0:5] == '%MIDI':
1156 #the nobarlines option is necessary for an abc to lilypond translator for
1157 #exactly the same reason abc2midi needs it: abc requires the user to enter
1158 #the note that will be printed, and MIDI and lilypond expect entry of the
1159 #pitch that will be played.
1161 #In standard 19th century musical notation, the algorithm for translating
1162 #between printed note and pitch involves using the barlines to determine
1163 #the scope of the accidentals.
1165 #Since ABC is frequently used for music in styles that do not use this
1166 #convention, such as most music written before 1700, or ethnic music in
1167 #non-western scales, it is necessary to be able to tell a translator that
1168 #the barlines should not affect its interpretation of the pitch.
1169 if (string.find(str,'nobarlines') > 0):
1171 elif str[0:3] == '%LY':
1172 p = string.find(str, 'voices')
1174 voices_append(str[p+7:])
1176 p = string.find(str, 'slyrics')
1178 slyrics_append(str[p+8:])
1180 #write other kinds of appending if we ever need them.
1184 def parse_file (fn):
1188 select_voice('default', '')
1190 sys.stderr.write ("Line ... ")
1192 __main__.state = state_list[current_voice_idx]
1197 if not (lineno % happy_count):
1198 sys.stderr.write ('[%d]'% lineno)
1200 m = re.match ('^([^%]*)%(.*)$',ln) # add comments to current voice
1203 try_parse_comment(m.group(2))
1204 voices_append ('%% %s\n' % m.group(2))
1209 ln = try_parse_header_line (ln, state)
1211 # Try nibbling characters off until the line doesn't change.
1213 while ln != prev_ln:
1215 ln = try_parse_chord_delims (ln, state)
1216 ln = try_parse_rest (ln, state)
1217 ln = try_parse_articulation (ln,state)
1218 ln = try_parse_note (ln, state)
1219 ln = try_parse_bar (ln, state)
1220 ln = try_parse_tie (ln)
1221 ln = try_parse_escape (ln)
1222 ln = try_parse_guitar_chord (ln, state)
1223 ln = try_parse_tuplet_begin (ln, state)
1224 ln = try_parse_group_end (ln, state)
1225 ln = try_parse_grace_delims (ln, state)
1226 ln = junk_space (ln)
1229 msg = "%s: %d: Huh? Don't understand\n" % (fn, lineno)
1230 sys.stderr.write (msg)
1231 left = orig_ln[0:-len (ln)]
1232 sys.stderr.write (left + '\n')
1233 sys.stderr.write (' ' * len (left) + ln + '\n')
1237 sys.stderr.write ("%s from LilyPond %s\n" % (program_name, version))
1241 Convert ABC to lilypond.
1243 Usage: abc2ly [OPTIONS]... ABC-FILE
1246 -h, --help this help
1247 -o, --output=FILE set output filename to FILE
1248 -v, --version version information
1250 This program converts ABC music files (see
1251 http://www.gre.ac.uk/~c.walshaw/abc2mtex/abc.txt) To LilyPond input.
1254 def print_version ():
1255 print r"""abc2ly (GNU lilypond) %s""" % version
1259 (options, files) = getopt.getopt (sys.argv[1:], 'vo:h', ['help','version', 'output='])
1265 if o== '--help' or o == '-h':
1268 if o == '--version' or o == '-v':
1272 if o == '--output' or o == '-o':
1280 header['tagline'] = 'Lily was here %s -- automatically converted from ABC' % version
1285 sys.stderr.write ('Parsing `%s\'...\n' % f)
1288 if not out_filename:
1289 out_filename = os.path.basename (os.path.splitext (f)[0]) + ".ly"
1290 sys.stderr.write ('lilypond output to: `%s\'...' % out_filename)
1291 outf = open (out_filename, 'w')
1293 # dump_global (outf)
1294 dump_header (outf ,header)
1299 sys.stderr.write ('\n')