+ def figures_replace (m):
+ s = m.group (1)
+ s = re.sub ('<', '@FIGOPEN@',s)
+ s = re.sub ('>', '@FIGCLOSE@',s)
+ return '\\figures { %s }' % s
+
+ str = re.sub (r'\\figures[ \t\n]*{([^}]+)}', figures_replace, str)
+ str = re.sub (r'\\<', '@STARTCRESC@', str)
+ str = re.sub (r'\\>', '@STARTDECRESC@', str)
+ str = re.sub (r'([-^_])>', r'\1@ACCENT@', str)
+ str = re.sub (r'<<', '@STARTCHORD@', str)
+ str = re.sub (r'>>', '@ENDCHORD@', str)
+ str = re.sub (r'>', '@ENDSIMUL@', str)
+ str = re.sub (r'<', '@STARTSIMUL@', str)
+ str = re.sub ('@STARTDECRESC@', '\\>', str)
+ str = re.sub ('@STARTCRESC@', '\\<', str)
+ str = re.sub ('@ACCENT@', '>', str)
+ str = re.sub ('@ENDCHORD@', '>', str)
+ str = re.sub ('@STARTCHORD@', '<', str)
+ str = re.sub ('@STARTSIMUL@', '<<', str)
+ str = re.sub ('@ENDSIMUL@', '>>', str)
+ str = re.sub ('@FIGOPEN@', '<', str)
+ str = re.sub ('@FIGCLOSE@', '>', str)
+
+ return str
+
+conversions.append (((1,9,4), conv, 'Swap < > and << >>'))
+
+
+def conv (str):
+ str = re.sub ('HaraKiriVerticalGroup', 'RemoveEmptyVerticalGroup', str)
+
+ return str
+
+conversions.append (((1,9,5), conv, 'HaraKiriVerticalGroup -> RemoveEmptyVerticalGroup'))
+
+def conv (str):
+ if re.search ("ly:get-font", str) :
+ sys.stderr.write (r"(ly:get-font foo ..) has been replaced by" + \
+ " (ly:paper-get-font (ly:grob-get-paper foo) .. ).\n" +\
+ "please update manually.")
+
+ raise FatalConversionError()
+
+ if re.search ("\\pitch *#", str) :
+ sys.stderr.write (r"\\pitch has been deprecated. " +\
+ " Use Scheme code to construct arbitrary note events.")
+
+ raise FatalConversionError()
+
+ return str
+
+
+conversions.append (((1,9,6), conv, 'ly:get-font deprecated.'))
+
+def conv (str):
+ def sub_alteration (m):
+ alt = m.group (3)
+ alt = {
+ '-1': 'FLAT',
+ '-2': 'DOUBLE-FLAT',
+ '0': 'NATURAL',
+ '1': 'SHARP',
+ '2': 'DOUBLE-SHARP',
+ }[alt]
+
+ return '(ly:make-pitch %s %s %s)' % (m.group(1), m.group (2),
+ alt)
+
+ str =re.sub ("\\(ly:make-pitch *([0-9-]+) *([0-9-]+) *([0-9-]+) *\\)",
+ sub_alteration, str)
+
+
+ str = re.sub ("ly:verbose", "ly:get-option 'verbose", str)
+
+ m= re.search ("\\\\outputproperty #([^#]+)[\t\n ]*#'([^ ]+)", str)
+ if m:
+ sys.stderr.write (\
+ r"""\outputproperty found,
+Please hand-edit, using
+
+ \applyoutput #(outputproperty-compatibility %s '%s <GROB PROPERTY VALUE>)
+
+as a substitution text.""" % (m.group (1), m.group (2)) )
+ raise FatalConversionError ()
+
+ if re.search ("ly:(make-pitch|pitch-alteration)", str) \
+ or re.search ("keySignature", str):
+ sys.stderr.write (
+"""The alteration field of Scheme pitches was multiplied by 2
+to support quarter tone accidentals. You have to edit the following constructs by hand:
+
+* calls of ly:make-pitch and ly:pitch-alteration
+* keySignature settings made with \property
+""")
+ raise FatalConversionError ()
+
+ return str
+conversions.append (((1,9,7), conv,
+ '''use symbolic constants for alterations,
+remove \\outputproperty, move ly:verbose into ly:get-option'''))
+
+
+def conv (str):
+ if re.search ("dash-length",str):
+ sys.stderr.write ("""dash-length has been removed. Use dash-fraction instead.""")
+ raise FatalConversionError()
+ return str
+
+conversions.append (((1,9,8), conv, """dash-length -> dash-fraction"""))
+
+
+def conv (str):
+ def func(match):
+ return "#'font-size = #%d" % (2*string.atoi (match.group (1)))
+
+ str =re.sub (r"#'font-relative-size\s*=\s*#([0-9-]+)", func, str)
+ str =re.sub (r"#'font-family\s*=\s*#'ancient",
+ r"#'font-family = #'music", str)
+
+ return str
+
+conversions.append (((2,1,1), conv, """font-relative-size -> font-size"""))
+
+def conv (str):
+ str =re.sub (r"ly:get-music-length", "ly:music-length", str)
+ return str
+
+conversions.append (((2,1,2), conv, """ly:get-music-length -> ly:music-length"""))
+
+def conv (str):
+ str =re.sub (r"\.\s+stz=", ". instr ", str)
+ return str
+
+conversions.append (((2,1,3), conv, """stanza -> instrument"""))
+
+def conv (str):
+ def func (match):
+ c = match.group (1)
+ b = match.group (2)
+
+ if b == 't':
+ if c == 'Score':
+ return ''
+ else:
+ return r" \property %s.melismaBusyProperties \unset" % c
+ elif b == 'f':
+ return r"\property %s.melismaBusyProperties = #'(melismaBusy)" % c
+
+ str =re.sub (r"\\property ([a-zA-Z]+)\s*\.\s*automaticMelismata\s*=\s*##([ft])", func, str)
+ return str
+
+conversions.append (((2,1,4), conv, """removal of automaticMelismata; use melismaBusyProperties instead."""))
+
+
+
+def conv (str):
+ str =re.sub (r"\\translator\s+([a-zA-Z]+)", r"\\change \1", str)
+ return str
+
+conversions.append (((2,1,7), conv, """\\translator Staff -> \\change Staff"""))
+
+def conv (str):
+ str =re.sub (r"\\newaddlyrics", r"\\lyricsto", str)
+ return str
+
+conversions.append (((2,1,10), conv, """\\newaddlyrics -> \\lyricsto"""))
+
+def conv (str):
+ str = re.sub (r'\\include\s*"paper([0-9]+)(-init)?.ly"',
+ r"#(set-staff-size \1)", str)
+
+ def sub_note (match):
+ dur = ''
+ log = string.atoi (match.group (1))
+ dots = string.atoi (match.group (2))
+
+ if log >= 0:
+ dur = '%d' % (1 << log)
+ else:
+ dur = { -1 : 'breve',
+ -2 : 'longa',
+ -3 : 'maxima'}[log]
+
+ dur += ('.' * dots)
+
+ return r'\note #"%s" #%s' % (dur, match.group (3))
+
+ str = re.sub (r'\\note\s+#([0-9-]+)\s+#([0-9]+)\s+#([0-9.-]+)',
+ sub_note, str)
+ return str
+
+conversions.append (((2,1,11), conv, """\\include "paper16.ly" -> #(set-staff-size 16)
+\note #3 #1 #1 -> \note #"8." #1
+"""))
+
+
+def conv (str):
+ str =re.sub (r"OttavaSpanner", r"OttavaBracket", str)
+ return str
+
+conversions.append (((2,1,12), conv, """OttavaSpanner -> OttavaBracket"""))
+
+
+def conv (str):
+ str =re.sub (r"\(set-staff-size ", r"(set-global-staff-size ", str)
+ return str
+
+conversions.append (((2,1,13), conv, """set-staff-size -> set-global-staff-size"""))
+
+def conv (str):
+ str =re.sub (r"#'style\s*=\s*#'dotted-line",
+ r"#'dash-fraction = #0.0 ", str)
+ return 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."""))
+
+def conv (str):
+ str = re.sub (r'nonevent-skip', 'skip-music', str)
+ return str
+
+conversions.append (((2,1,20), conv, """nonevent-skip -> skip-music""" ))
+
+def conv (str):
+ str = re.sub (r'molecule-callback', 'print-function', str)
+ str = re.sub (r'brew_molecule', 'print', str)
+ str = re.sub (r'brew-new-markup-molecule', 'Text_item::print', str)
+ str = re.sub (r'LyricsVoice', 'Lyrics', str)
+ str = re.sub (r'tupletInvisible',
+ r"TupletBracket \\set #'transparent", str)
+# str = re.sub (r'molecule', 'collage', str)
+#molecule -> collage
+ str = re.sub (r"\\property\s+[a-zA-Z]+\s*\.\s*[a-zA-Z]+\s*"
+ + r"\\set\s*#'X-extent-callback\s*=\s*#Grob::preset_extent",
+ "", str)
+
+ return str
+
+conversions.append (((2,1,21), conv, """molecule-callback -> print-function,
+brew_molecule -> print
+brew-new-markup-molecule -> Text_item::print
+LyricsVoice -> Lyrics
+tupletInvisible -> TupletBracket \set #'transparent
+Grob::preset_extent removed.
+""" ))
+
+
+def conv (str):
+ str = re.sub (r'\\property\s+([^.]+)\s*\.\s*([^\\=]+)\s*\\(set|override)',
+ r"\\overrid@ \1.\2 ", str)
+ str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*=',
+ r'\\s@t \1.\2 = ', str)
+ str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\unset',
+ r'\\uns@t \1.\2 ', str)
+ str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\revert'
+ + r"\s*#'([-a-z0-9_]+)",
+ r"\\rev@rt \1.\2 #'\3", str)
+ str = re.sub (r'Voice\.', '', str)
+ str = re.sub (r'Lyrics\.', '', str)
+ str = re.sub (r'ChordNames\.', '', str)
+
+ str = re.sub ('rev@rt', 'revert',str)
+ str = re.sub ('s@t', 'set',str)
+ str = re.sub ('overrid@', 'override',str)
+
+ str = re.sub ('molecule', 'stencil', str)
+ str = re.sub ('Molecule', 'Stencil', str)
+ return str
+
+conversions.append (((2,1,22), conv, """new syntax for property settings:
+ \set A.B = #C , \unset A.B
+ \override A.B #C = #D, \revert A.B #C
+
+"""))
+