]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Implement changing the (short)instrumentName via the print element
authorReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 22 Feb 2010 12:53:31 +0000 (13:53 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 22 Feb 2010 13:09:08 +0000 (14:09 +0100)
input/regression/musicxml/72c-TransposingInstruments-Change.xml [new file with mode: 0644]
python/musicexp.py
scripts/musicxml2ly.py

diff --git a/input/regression/musicxml/72c-TransposingInstruments-Change.xml b/input/regression/musicxml/72c-TransposingInstruments-Change.xml
new file mode 100644 (file)
index 0000000..05ef9f9
--- /dev/null
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.1 Partwise//EN"
+                                "http://www.musicxml.org/dtds/partwise.dtd">
+<score-partwise version="1.1">
+  <identification>
+    <miscellaneous>
+      <miscellaneous-field name="description">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.
+      </miscellaneous-field>
+    </miscellaneous>
+  </identification>
+  <part-list>
+    <score-part id="P1">
+      <part-name>Clarinet in Eb</part-name>
+      <part-abbreviation>Eb Cl.</part-abbreviation>
+    </score-part>
+  </part-list>
+  <!--=========================================================-->
+  <part id="P1">
+    <measure number="1">
+      <attributes>
+        <divisions>1</divisions>
+        <key>
+          <fifths>1</fifths>
+          <mode>major</mode>
+        </key>
+        <time symbol="common">
+          <beats>4</beats>
+          <beat-type>4</beat-type>
+        </time>
+        <clef>
+          <sign>G</sign>
+          <line>2</line>
+        </clef>
+        <transpose>
+          <diatonic>2</diatonic>
+          <chromatic>3</chromatic>
+        </transpose>
+      </attributes>
+      <note>
+        <pitch>
+          <step>C</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>4</duration>
+        <voice>1</voice>
+        <type>whole</type>
+      </note>
+    </measure>
+    <measure number="2">
+      <attributes>
+        <key>
+          <fifths>0</fifths>
+          <mode>major</mode>
+        </key>
+        <transpose>
+          <diatonic>-1</diatonic>
+          <chromatic>-2</chromatic>
+        </transpose>
+      </attributes>
+      <print>
+        <part-name-display><display-text>Clarinet in Bb</display-text></part-name-display>
+        <part-abbreviation-display><display-text>Bb Cl.</display-text></part-abbreviation-display>
+      </print>
+      <note>
+        <pitch>
+          <step>C</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>4</duration>
+        <voice>1</voice>
+        <type>whole</type>
+      </note>
+    </measure>
+    <measure number="3">
+      <print new-system="yes" />
+      <note>
+        <pitch>
+          <step>C</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>4</duration>
+        <voice>1</voice>
+        <type>whole</type>
+      </note>
+      <barline location="right">
+        <bar-style>light-heavy</bar-style>
+      </barline>
+    </measure>
+  </part>
+  <!--=========================================================-->
+</score-partwise>
index 1303af2655145bd3ee7714288d1baeabf1bf7280..b49ee658af6bb2aedf34894e7bb81214a6c6f9e0 100644 (file)
@@ -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):
index e89c94811e9c9a8a36d5c2c001c49fdc7522d804..b0f8284d864cb511d3903c637051666261a01d42 100644 (file)
@@ -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