From: Reinhold Kainhofer Date: Mon, 22 Feb 2010 12:53:31 +0000 (+0100) Subject: MusicXML: Implement changing the (short)instrumentName via the print element X-Git-Tag: release/2.13.14-1~33 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=353baf37d6f4f82fcc9c45005f2d963cf4af56ba;p=lilypond.git MusicXML: Implement changing the (short)instrumentName via the print element --- diff --git a/input/regression/musicxml/72c-TransposingInstruments-Change.xml b/input/regression/musicxml/72c-TransposingInstruments-Change.xml new file mode 100644 index 0000000000..05ef9f9135 --- /dev/null +++ b/input/regression/musicxml/72c-TransposingInstruments-Change.xml @@ -0,0 +1,96 @@ + + + + + + An instrument change from one + transposition (Clarinet in Eb) to another transposing instrument + (Clarinet in Bb). The displayed instrument name should also be updated. + + The whole piece is in Bb major (sounding), so first the key signature + should be one flat, after the change it should have no accidentals. + + + + + + Clarinet in Eb + Eb Cl. + + + + + + + 1 + + 1 + major + + + + G + 2 + + + 2 + 3 + + + + + C + 4 + + 4 + 1 + whole + + + + + + 0 + major + + + -1 + -2 + + + + Clarinet in Bb + Bb Cl. + + + + C + 4 + + 4 + 1 + whole + + + + + + + C + 4 + + 4 + 1 + whole + + + light-heavy + + + + + diff --git a/python/musicexp.py b/python/musicexp.py index 1303af2655..b49ee658af 100644 --- a/python/musicexp.py +++ b/python/musicexp.py @@ -1587,6 +1587,16 @@ class StaffChange (Music): else: return '' +class SetEvent (Music): + def __init__ (self, contextprop, value): + Music.__init__ (self) + self.context_prop = contextprop + self.value = value + def ly_expression (self): + if self.value: + return "\\set %s = %s" % (self.context_prop, self.value) + else: + return '' class TempoMark (Music): def __init__ (self): diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index e89c94811e..b0f8284d86 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -973,6 +973,14 @@ def musicxml_print_to_lily (el): val = getattr (el, "new-page") if (val == "yes"): elts.append (musicexp.Break ("pageBreak")) + child = el.get_maybe_exist_named_child ("part-name-display") + if child: + elts.append (musicexp.SetEvent ("Staff.instrumentName", + "\"%s\"" % extract_display_text (child))) + child = el.get_maybe_exist_named_child ("part-abbreviation-display") + if child: + elts.append (musicexp.SetEvent ("Staff.shortInstrumentName", + "\"%s\"" % extract_display_text (child))) return elts