]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Implement church modes; fix empty <mode/> tags for keys
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 15 Nov 2008 23:45:14 +0000 (00:45 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 15 Nov 2008 23:45:14 +0000 (00:45 +0100)
input/regression/musicxml/00o-Basics-Modes.xml [new file with mode: 0644]
python/musicxml.py
scripts/musicxml2ly.py

diff --git a/input/regression/musicxml/00o-Basics-Modes.xml b/input/regression/musicxml/00o-Basics-Modes.xml
new file mode 100644 (file)
index 0000000..63bac0b
--- /dev/null
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.0 Partwise//EN"
+                                "http://www.musicxml.org/dtds/partwise.dtd">
+<score-partwise>
+  <identification>
+    <miscellaneous>
+      <miscellaneous-field name="description">All different modes: major, 
+        minor, ionian, dorian, phrygian, lydian, mixolydian, aeolian, and 
+        locrian; All modes are given with 2 sharps.</miscellaneous-field>
+    </miscellaneous>
+  </identification>
+  <part-list>
+    <score-part id="P1">
+      <part-name>MusicXML Part</part-name>
+    </score-part>
+  </part-list>
+  <!--=========================================================-->
+  <part id="P1">
+    <measure number="1">
+      <attributes>
+        <divisions>1</divisions>
+        <key>
+          <fifths>2</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>
+      </attributes>
+      <note>
+        <pitch>
+          <step>G</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>1</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        <lyric number="1"><text>major</text></lyric>
+      </note>
+      <attributes>
+        <key>
+          <fifths>2</fifths>
+          <mode>minor</mode>
+        </key>
+      </attributes>
+      <note>
+        <pitch>
+          <step>G</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>1</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        <lyric number="1"><text>minor</text></lyric>
+      </note>
+      <attributes>
+        <key>
+          <fifths>2</fifths>
+          <mode>ionian</mode>
+        </key>
+      </attributes>
+      <note>
+        <pitch>
+          <step>G</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>1</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        <lyric number="1"><text>ionian</text></lyric>
+      </note>
+      <attributes>
+        <key>
+          <fifths>2</fifths>
+          <mode>dorian</mode>
+        </key>
+      </attributes>
+      <note>
+        <pitch>
+          <step>G</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>1</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        <lyric number="1"><text>dorian</text></lyric>
+      </note>
+    </measure>
+    <measure number="2">
+      <attributes>
+        <key>
+          <fifths>2</fifths>
+          <mode>phrygian</mode>
+        </key>
+      </attributes>
+      <note>
+        <pitch>
+          <step>G</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>1</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        <lyric number="1"><text>phrygian</text></lyric>
+      </note>
+      <attributes>
+        <key>
+          <fifths>2</fifths>
+          <mode>lydian</mode>
+        </key>
+      </attributes>
+      <note>
+        <pitch>
+          <step>G</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>1</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        <lyric number="1"><text>lydian</text></lyric>
+      </note>
+      <attributes>
+        <key>
+          <fifths>2</fifths>
+          <mode>mixolydian</mode>
+        </key>
+      </attributes>
+      <note>
+        <pitch>
+          <step>G</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>1</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        <lyric number="1"><text>mixolydian</text></lyric>
+      </note>
+      <attributes>
+        <key>
+          <fifths>2</fifths>
+          <mode>aeolian</mode>
+        </key>
+      </attributes>
+      <note>
+        <pitch>
+          <step>G</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>1</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        <lyric number="1"><text>aeolian</text></lyric>
+      </note>
+    </measure>
+    <measure number="3">
+      <attributes>
+        <key>
+          <fifths>2</fifths>
+          <mode>locrian</mode>
+        </key>
+      </attributes>
+      <note>
+        <pitch>
+          <step>G</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>1</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        <lyric number="1"><text>locrian</text></lyric>
+      </note>
+    </measure>
+  </part>
+</score-partwise>
+
index e9df0b30105d93ad61157de5ca11b71bdd63221a..e1a9446826bc18d7311110e992712bda8b62f0e9 100644 (file)
@@ -341,9 +341,11 @@ class Attributes (Measure_element):
 
         key = self.get_named_attribute ('key')
         mode_node = key.get_maybe_exist_named_child ('mode')
-        mode = 'major'
+        mode = None
         if mode_node:
             mode = mode_node.get_text ()
+        if not mode or mode == '':
+            mode = 'major'
 
         fifths = int (key.get_maybe_exist_named_child ('fifths').get_text ())
         return (fifths, mode)
index 91b28ae2c1f9398486e228e9d820e8ed7007bd59..8c8e336e31ca8c30a5610cb0fc0502c389862087 100644 (file)
@@ -650,8 +650,15 @@ def musicxml_key_to_lily (attributes):
     (fifths, mode) = attributes.get_key_signature () 
     try:
         (n,a) = {
-            'major' : (0,0),
-            'minor' : (5,0),
+            'major'     : (0,0),
+            'minor'     : (5,0),
+            'ionian'    : (0,0),
+            'dorian'    : (1,0),
+            'phrygian'  : (2,0),
+            'lydian'    : (3,0),
+            'mixolydian': (4,0),
+            'aeolian'   : (5,0),
+            'locrian'   : (6,0),
             }[mode]
         start_pitch.step = n
         start_pitch.alteration = a