X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Fconvert-ly.py;h=fd8aa4e5c4f895d68c29a5c1b154470d99f0a2cb;hb=7e72a1e50e94a7f9738d62599de79fe7745f600c;hp=9d69d660f58453723e3f7da142eff0bdc847beba;hpb=dac5763830f70241f92cdd0def9af9ef2f32269c;p=lilypond.git diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index 9d69d660f5..fd8aa4e5c4 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -4,7 +4,7 @@ # # source file of the GNU LilyPond music typesetter # -# (c) 1998--2003 Han-Wen Nienhuys +# (c) 1998--2004 Han-Wen Nienhuys # Jan Nieuwenhuizen @@ -1712,6 +1712,109 @@ def conv (str): conversions.append (((2,1,14), conv, """style = dotted -> dash-fraction = 0""")) +def conv (str): + str =re.sub (r'LyricsVoice\s*\.\s*instrument\s*=\s*("[^"]*")', + r'LyricsVoice . vocalName = \1', str) + + str =re.sub (r'LyricsVoice\s*\.\s*instr\s*=\s*("[^"]*")', + r'LyricsVoice . vocNam = \1', str) + return str + +conversions.append (((2,1,15), conv, """LyricsVoice . instr(ument) -> vocalName""")) + +def conv (str): + def sub_acc (m): + d = { + '4': 'doublesharp', + '3': 'threeqsharp', + '2': 'sharp', + '1': 'semisharp', + '0': 'natural', + '-1': 'semiflat', + '-2': 'flat', + '-3': 'threeqflat', + '-4': 'doubleflat'} + return '\\%s' % d[m.group (1)] + + str = re.sub (r'\\musicglyph\s*#"accidentals-([0-9-]+)"', + sub_acc, str) + return str + +conversions.append (((2,1,16), conv, """\\musicglyph #"accidentals-NUM" -> \\sharp/flat/etc.""")) + + +def conv (str): + + if re.search (r'\\partcombine', str): + sys.stderr.write ('Warning: \\partcombine has been changed. ' + +'Check conversion manually!') + + raise FatalConversionError() + + # this rule doesn't really work, + # too lazy to figure out why. + str = re.sub (r'\\context\s+Voice\s*=\s*one\s*\\partcombine\s+Voice\s*\\context\s+Thread\s*=\s*one(.*)\s*' + + r'\\context\s+Thread\s*=\s*two', + '\\\\newpartcombine\n\\1\n', str) + + + return str + +conversions.append (((2,1,17), conv, """\\partcombine syntax change to \\newpartcombine""")) + + +def conv (str): + str = re.sub (r'\\newpartcombine', r'\\partcombine', str) + str = re.sub (r'\\autochange\s+Staff', r'\\autochange ', str) + return str + +conversions.append (((2,1,18), conv, """\\newpartcombine -> \\partcombine, +\\autochange Staff -> \\autochange +""")) + + + + +def conv (str): + str = re.sub (r'\\include "drumpitch-init.ly"','', str) + str = re.sub (r'\\pitchnames ','pitchnames = ', str) + str = re.sub (r'\\chordmodifiers ','chordmodifiers = ', str) + str = re.sub (r'\bdrums\b\s*=','drumContents = ', str) + str = re.sub (r'\\drums\b','\\drumContents ', str) + + + if re.search ('drums->paper', str): + sys.stderr.write ("\nDrum notation found. Check file manually!") + + str = re.sub (r"""\\apply\s+#\(drums->paper\s+'([a-z]+)\)""", + r"""\property DrumStaff.drumStyleTable = #\1-style""", + str) + + if re.search ('Thread', str): + sys.stderr.write ("\nThread found. Check file manually!\n"); + + str = re.sub (r"""(\\once\s*)?\\property\s+Thread\s*\.\s*NoteHead\s*""" + + r"""\\(set|override)\s*#'style\s*=\s*#'harmonic""" + + r"""\s+([a-z]+[,'=]*)([0-9]*\.*)""" + ,r"""<\3\\harmonic>\4""", str) + + str = re.sub (r"""\\new Thread""", """\context Voice""", str) + str = re.sub (r"""Thread""", """Voice""", str) + + if re.search ('\bLyrics\b', str): + sys.stderr.write ("\nLyrics found. Check file manually!\n"); + + str = re.sub (r"""LyricsVoice""", r"""L@ricsVoice""", str) + str = re.sub (r"""\bLyrics\b""", r"""LyricsVoice""", str) + str = re.sub (r"""LyricsContext""", r"""LyricsVoiceContext""", str) + str = re.sub (r"""L@ricsVoice""", r"""LyricsVoice""",str) + + + return str + +conversions.append (((2,1,19), conv, """Drum notation changes, Removing \chordmodifiers, \notenames. +Harmonic notes. Thread context removed. Lyrics context removed.""")) + ################################ # END OF CONVERSIONS ################################