]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Rework the way articulations are handled
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sun, 23 Sep 2007 18:57:18 +0000 (20:57 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Wed, 3 Oct 2007 16:40:48 +0000 (18:40 +0200)
Workover of the articulation translation. Use one dict instead
of two and condition on the dict value. Also implement accidental-mark.

Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
input/regression/musicxml/02f-Articulations-MusicXML.xml [new file with mode: 0644]
input/regression/musicxml/02g-ArticulationsNoAttributes-MusicXML.xml [new file with mode: 0644]
python/musicexp.py
scripts/musicxml2ly.py

diff --git a/input/regression/musicxml/02f-Articulations-MusicXML.xml b/input/regression/musicxml/02f-Articulations-MusicXML.xml
new file mode 100644 (file)
index 0000000..1ae5833
--- /dev/null
@@ -0,0 +1,761 @@
+<?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>
+  <movement-title>Articulations Test</movement-title>
+  <identification>
+    <creator type="composer">Reinhold Kainhofer</creator>
+    <rights>Public Domain</rights>
+    <encoding>
+      <software>Kate</software>
+    </encoding>
+  </identification>
+  <part-list>
+    <score-part id="P1">
+      <part-name>Test part</part-name>
+    </score-part>
+  </part-list>
+  <!--=========================================================-->
+  <part id="P1">
+    <measure number="1">
+      <attributes>
+        <divisions>1</divisions>
+        <key>
+          <fifths>0</fifths>
+          <mode>major</mode>
+        </key>
+        <time symbol="common">
+          <beats>12</beats>
+          <beat-type>4</beat-type>
+        </time>
+        <clef>
+          <sign>G</sign>
+          <line>2</line>
+        </clef>
+      </attributes>
+      <sound tempo="120"/>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <accent/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <ornaments>
+                  <turn/>
+                  <accidental-mark>sharp</accidental-mark>
+                  <accidental-mark>three-quarters-flat</accidental-mark>
+                  <accidental-mark>natural</accidental-mark>
+              </ornaments>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <technical>
+                  <bend><bend-alter>4</bend-alter></bend>
+              </technical>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <breath-mark/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <caesura/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <ornaments>
+                  <delayed-turn/>
+              </ornaments>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <detached-legato/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <doit/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <technical>
+                  <double-tongue/>
+              </technical>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <technical>
+                  <down-bow/>
+              </technical>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <falloff/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <technical>
+                  <fingering/>
+              </technical>
+          </notations>
+      </note>
+    </measure>
+    <!--=======================================================-->
+    <measure number="2">
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <fingernails/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <fret/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <hammer-on type="start"/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <hammer-on type="stop"/>
+                    <harmonic/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <heel/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <ornaments>
+                    <inverted-mordent/>
+                </ornaments>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <ornaments>
+                    <!--inverted-turn/-->
+                </ornaments>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <ornaments>
+                    <mordent/>
+                </ornaments>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <open-string/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <plop/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <pluck/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <!--portato/-->
+                </technical>
+            </notations>
+        </note>
+    </measure>
+    <!--=======================================================-->
+    <measure number="3">
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <pull-off type="start"/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <pull-off type="stop"/>
+                </technical>
+                <ornaments>
+                    <schleifer/>
+                </ornaments>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <scoop/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <ornaments>
+                    <shake/>
+                </ornaments>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <snap-pizzicato/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <spiccato/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <staccatissimo/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <staccato/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <stopped/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <!--stress/-->
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <string/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <strong-accent/>
+                </articulations>
+            </notations>
+        </note>
+    </measure>
+    <!--=======================================================-->
+    <measure number="4">
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <tap/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <tenuto/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <thumb-position/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <toe/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <ornaments>
+                    <turn/>
+                </ornaments>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <ornaments>
+                    <tremolo>3</tremolo>
+                </ornaments>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <ornaments>
+                    <trill-mark/>
+                </ornaments>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <triple-tongue/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <!--unstress/-->
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <technical>
+                    <up-bow/>
+                </technical>
+            </notations>
+        </note>
+        <note>
+            <rest/>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+        </note>
+        <note>
+            <rest/>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+        </note>
+    </measure>
+    <!--=======================================================-->
+  </part>
+  <!--=========================================================-->
+</score-partwise>
diff --git a/input/regression/musicxml/02g-ArticulationsNoAttributes-MusicXML.xml b/input/regression/musicxml/02g-ArticulationsNoAttributes-MusicXML.xml
new file mode 100644 (file)
index 0000000..0ff1989
--- /dev/null
@@ -0,0 +1,765 @@
+<?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>
+  <movement-title>Articulations Test</movement-title>
+  <identification>
+    <creator type="composer">Reinhold Kainhofer</creator>
+    <rights>Public Domain</rights>
+    <encoding>
+      <software>Kate</software>
+    </encoding>
+  </identification>
+  <part-list>
+    <score-part id="P1">
+      <part-name>Test part</part-name>
+    </score-part>
+  </part-list>
+  <!--=========================================================-->
+  <part id="P1">
+    <measure number="1">
+      <attributes>
+        <divisions>1</divisions>
+        <key>
+          <fifths>0</fifths>
+          <mode>major</mode>
+        </key>
+        <time symbol="common">
+          <beats>12</beats>
+          <beat-type>4</beat-type>
+        </time>
+        <clef>
+          <sign>G</sign>
+          <line>2</line>
+        </clef>
+      </attributes>
+      <sound tempo="120"/>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <accent/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <accidental-mark/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <bend/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <breath-mark/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <caesura/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <delayed-turn/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <detached-legato/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <doit/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <double-tongue/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <down-bow/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <falloff/>
+              </articulations>
+          </notations>
+      </note>
+      <note>
+          <pitch>
+              <step>C</step>
+              <octave>4</octave>
+          </pitch>
+          <duration>1</duration>
+          <voice>1</voice>
+          <type>quarter</type>
+          <stem>up</stem>
+          <notations>
+              <articulations>
+                  <fingering/>
+              </articulations>
+          </notations>
+      </note>
+    </measure>
+    <!--=======================================================-->
+    <measure number="2">
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <fingernails/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <fret/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <hammer-on/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <harmonic/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <heel/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <inverted-mordent/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <inverted-turn/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <mordent/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <open-string/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <plop/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <pluck/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <portato/>
+                </articulations>
+            </notations>
+        </note>
+    </measure>
+    <!--=======================================================-->
+    <measure number="3">
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <pull-off/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <schleifer/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <scoop/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <shake/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <snap-pizzicato/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <spiccato/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <staccatissimo/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <staccato/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <stopped/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <stress/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <string/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <strong-accent/>
+                </articulations>
+            </notations>
+        </note>
+    </measure>
+    <!--=======================================================-->
+    <measure number="4">
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <tap/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <tenuto/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <thumb-position/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <toe/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <turn/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <tremolo/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <trill-mark/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <triple-tongue/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <unstress/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <up-bow/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+            <notations>
+                <articulations>
+                    <wavy-line/>
+                </articulations>
+            </notations>
+        </note>
+        <note>
+            <pitch>
+                <step>C</step>
+                <octave>4</octave>
+            </pitch>
+            <duration>1</duration>
+            <voice>1</voice>
+            <type>quarter</type>
+            <stem>up</stem>
+        </note>
+    </measure>
+    <!--=======================================================-->
+  </part>
+  <!--=========================================================-->
+</score-partwise>
index 8649528abaa3f69413bf034d178cbcf98805096e..8ae3105cada6d35d1efeba95378124861b1dc5cb 100644 (file)
@@ -711,18 +711,30 @@ class ShortArticulationEvent (ArticulationEvent):
     def ly_expression (self):
         return '%s%s' % (self.direction_mod (), self.type)
 
-class TremoloEvent (Event):
+class NoDirectionArticulationEvent (ArticulationEvent):
+    def ly_expression (self):
+        return '\\%s' % self.type
+
+class MarkupEvent (ShortArticulationEvent):
+    def __init__ (self):
+        ArticulationEvent.__init__ (self)
+        self.contents = None
+    def ly_expression (self):
+        if self.contents:
+            return "%s\\markup { %s }" % (self.direction_mod (), self.contents)
+
+class TremoloEvent (ArticulationEvent):
     def __init__ (self):
         Event.__init__ (self)
         self.bars = 0
 
     def ly_expression (self):
         str=''
-        if self.bars > 0:
+        if self.bars and self.bars > 0:
             str += ':%s' % (2 ** (2 + string.atoi (self.bars)))
         return str
 
-class BendEvent (Event):
+class BendEvent (ArticulationEvent):
     def __init__ (self):
         Event.__init__ (self)
         self.alter = 0
index 48e090065819ffcf73e4e1856e8d548fc764f2ad..fd13721d9655121362f7dc2361b1c6d9dd84be3c 100644 (file)
@@ -316,72 +316,97 @@ def musicxml_fermata_to_lily_event (mxl_event):
     return ev
 
 def musicxml_tremolo_to_lily_event (mxl_event):
-    if mxl_event.get_name () != "tremolo": 
-        return
     ev = musicexp.TremoloEvent ()
     ev.bars = mxl_event.get_text ()
     return ev
 
 def musicxml_bend_to_lily_event (mxl_event):
-    if mxl_event.get_name () != "bend":
-        return
     ev = musicexp.BendEvent ()
     ev.alter = mxl_event.bend_alter ()
     return ev
 
 
-short_articulations_dict = {
-  "staccato": ".",
-  "tenuto": "-",
-  "stopped": "+",
-  "staccatissimo": "|",
-  "accent": ">",
-  "strong-accent": "^",
-  #"portato": "_", # does not exist in MusicXML
-    #"fingering": "", # fingering is special cased, as get_text() will be the event's name
-}
+def musicxml_fingering_event (mxl_event):
+    ev = musicexp.ShortArticulationEvent ()
+    ev.type = mxl_event.get_text ()
+    return ev
+
+def musicxml_accidental_mark (mxl_event):
+    ev = musicexp.MarkupEvent ()
+    contents = { "sharp": "\\sharp",
+      "natural": "\\natural",
+      "flat": "\\flat",
+      "double-sharp": "\\doublesharp",
+      "sharp-sharp": "\\sharp\\sharp",
+      "flat-flat": "\\flat\\flat",
+      "flat-flat": "\\doubleflat",
+      "natural-sharp": "\\natural\\sharp",
+      "natural-flat": "\\natural\\flat",
+      "quarter-flat": "\\semiflat",
+      "quarter-sharp": "\\semisharp",
+      "three-quarters-flat": "\\sesquiflat",
+      "three-quarters-sharp": "\\sesquisharp",
+    }.get (mxl_event.get_text ())
+    if contents:
+        ev.contents = contents
+        return ev
+    else:
+        return None
+
+# translate articulations, ornaments and other notations into ArticulationEvents
+# possible values:
+#   -) string  (ArticulationEvent with that name)
+#   -) function (function(mxl_event) needs to return a full ArticulationEvent-derived object
+#   -) (class, name)  (like string, only that a different class than ArticulationEvent is used)
 # TODO: Some translations are missing!
-articulations_dict = { 
-    ##### ORNAMENTS
-    "trill-mark": "trill", 
-    "turn": "turn", 
-    #"delayed-turn": "?", 
-    "inverted-turn": "reverseturn", 
-    #"shake": "?", 
-    #"wavy-line": "?", 
-    "mordent": "mordent",
-    "inverted-mordent": "prall",
-    #"schleifer": "?" 
-    ##### TECHNICALS
-    "up-bow": "upbow", 
-    "down-bow": "downbow", 
-    "harmonic": "flageolet", 
-    #"open-string": "", 
-    #"thumb-position": "", 
-    #"pluck": "", 
-    #"double-tongue": "", 
-    #"triple-tongue": "", 
-    #"snap-pizzicato": "", 
-    #"fret": "", 
-    #"string": "", 
-    #"hammer-on": "", 
-    #"pull-off": "", 
-    #"bend": "bendAfter #%s", # bend is special-cased, as we need to process the bend-alter subelement!
-    #"tap": "", 
-    #"heel": "", 
-    #"toe": "", 
-    #"fingernails": ""
-    ##### ARTICULATIONS
-    #"detached-legato": "", 
-    #"spiccato": "", 
-    #"scoop": "", 
-    #"plop": "", 
-    #"doit": "", 
+articulations_dict = {
+    "accent": (musicexp.ShortArticulationEvent, ">"),
+    "accidental-mark": musicxml_accidental_mark,
+    "bend": musicxml_bend_to_lily_event,
+    "breath-mark": (musicexp.NoDirectionArticulationEvent, "breathe"),
+    #"caesura": "caesura",
+    #"delayed-turn": "?",
+    #"detached-legato": "",
+    #"doit": "",
+    #"double-tongue": "",
+    "down-bow": "downbow",
     #"falloff": "",
-    "breath-mark": "breathe", 
-    #"caesura": "caesura", 
-    #"stress": "", 
+    "fingering": musicxml_fingering_event,
+    #"fingernails": "",
+    #"fret": "",
+    #"hammer-on": "",
+    "harmonic": "flageolet",
+    #"heel": "",
+    "inverted-mordent": "prall",
+    "inverted-turn": "reverseturn",
+    "mordent": "mordent",
+    #"open-string": "",
+    #"plop": "",
+    #"pluck": "",
+    #"portato": (musicexp.ShortArticulationEvent, "_"), # does not exist in MusicXML
+    #"pull-off": "",
+    #"schleifer": "?",
+    #"scoop": "",
+    #"shake": "?",
+    #"snap-pizzicato": "",
+    #"spiccato": "",
+    "staccatissimo": (musicexp.ShortArticulationEvent, "|"),
+    "staccato": (musicexp.ShortArticulationEvent, "."),
+    "stopped": (musicexp.ShortArticulationEvent, "+"),
+    #"stress": "",
+    #"string": "",
+    "strong-accent": (musicexp.ShortArticulationEvent, "^"),
+    #"tap": "",
+    "tenuto": (musicexp.ShortArticulationEvent, "-"),
+    #"thumb-position": "",
+    #"toe": "",
+    "turn": "turn",
+    "tremolo": musicxml_tremolo_to_lily_event,
+    "trill-mark": "trill",
+    #"triple-tongue": "",
     #"unstress": ""
+    "up-bow": "upbow",
+    #"wavy-line": "?",
 }
 articulation_spanners = [ "wavy-line" ]
 
@@ -390,26 +415,18 @@ def musicxml_articulation_to_lily_event (mxl_event):
     if mxl_event.get_name () in articulation_spanners:
         return musicxml_spanner_to_lily_event (mxl_event)
 
-    # special case, because of the bend-alter subelement
-    if mxl_event.get_name() == "bend":
-        return musicxml_bend_to_lily_event (mxl_event)
-
-    # If we can write a shorthand, use them!
-    if mxl_event.get_name() == "fingering":
-        ev = musicexp.ShortArticulationEvent ()
-        tp = mxl_event.get_text()
-    # In all other cases, use the dicts to translate the xml tag name to a proper lilypond command
-    elif short_articulations_dict.get (mxl_event.get_name ()):
-        ev = musicexp.ShortArticulationEvent ()
-        tp = short_articulations_dict.get (mxl_event.get_name ())
-    else:
-        ev = musicexp.ArticulationEvent ()
-        tp = articulations_dict.get (mxl_event.get_name ())
-
-    if not tp:
+    tmp_tp = articulations_dict.get (mxl_event.get_name ())
+    if not tmp_tp:
         return
-    
-    ev.type = tp
+
+    if isinstance (tmp_tp, str):
+        ev = musicexp.ArticulationEvent ()
+        ev.type = tmp_tp
+    elif isinstance (tmp_tp, tuple):
+        ev = tmp_tp[0] ()
+        ev.type = tmp_tp[1]
+    else:
+        ev = tmp_tp (mxl_event)
 
     # Some articulations use the type attribute, other the placement...
     dir = None
@@ -417,9 +434,6 @@ def musicxml_articulation_to_lily_event (mxl_event):
         dir = musicxml_direction_to_indicator (mxl_event.type)
     if hasattr (mxl_event, 'placement'):
         dir = musicxml_direction_to_indicator (mxl_event.placement)
-    # \breathe cannot have any direction modifier (^, _, -)!
-    if dir and tp != "breathe":
-        ev.force_direction = dir
     return ev