]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Use s4 instead of s1*1/4
authorReinhold Kainhofer <reinhold@kainhofer.com>
Tue, 20 Nov 2007 22:12:50 +0000 (23:12 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Tue, 20 Nov 2007 22:12:50 +0000 (23:12 +0100)
Instead of always using s1 and adding the duration as factor,
I now convert the duration of the skip to real lilypond durations,
i.e. s4, s2., s1, etc.

input/regression/musicxml/00d-Backup.xml [new file with mode: 0644]
scripts/musicxml2ly.py

diff --git a/input/regression/musicxml/00d-Backup.xml b/input/regression/musicxml/00d-Backup.xml
new file mode 100644 (file)
index 0000000..8c2f7d9
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
+
+<score-partwise version="1.1">
+  <movement-title>Backup not to 0 in second voice</movement-title>
+  <part-list>
+    <score-part id="P1">
+      <part-name></part-name>
+      <part-abbreviation></part-abbreviation>
+    </score-part>
+  </part-list>
+  <part id="P1">
+    <measure number="1">
+      <attributes>
+        <divisions>2</divisions>
+        <key><fifths>0</fifths></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>C</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>2</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+      </note>
+      <note>
+        <pitch>
+          <step>C</step>
+          <octave>4</octave>
+        </pitch>
+        <duration>2</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+      </note>
+      <backup>
+        <duration>2</duration>
+      </backup>
+      <note>
+        <pitch>
+          <step>A</step>
+          <octave>3</octave>
+        </pitch>
+        <duration>2</duration>
+        <voice>2</voice>
+        <type>quarter</type>
+      </note>
+      <note>
+        <pitch>
+          <step>A</step>
+          <octave>3</octave>
+        </pitch>
+        <duration>2</duration>
+        <voice>2</voice>
+        <type>quarter</type>
+      </note>
+    </measure>
+  </part>
+</score-partwise>
+
index 01f02cfeac9a137f3779eb82775401acb8728b02..c5e07c2ece4a051c7e1311f659fc87eceeb7f829 100644 (file)
@@ -1187,8 +1187,21 @@ class LilyPondVoiceBuilder:
 
         if diff > Rational (0) and not (self.ignore_skips and moment == 0):
             skip = musicexp.SkipEvent()
-            skip.duration.duration_log = 0
-            skip.duration.factor = diff
+            duration_factor = 1
+            duration_log = {1: 0, 2: 1, 4:2, 8:3, 16:4, 32:5, 64:6, 128:7, 256:8, 512:9}.get (diff.denominator (), -1)
+            duration_dots = 0
+            if duration_log >= 0: # denominator is a power of 2...
+                if diff.numerator () == 3:
+                    duration_log -= 1
+                    duration_dots = 1
+                else:
+                    duration_factor = Rational (diff.numerator ())
+            else:
+                duration_log = 0
+                duration_factor = diff
+            skip.duration.duration_log = duration_log
+            skip.duration.factor = duration_factor
+            skip.duration.dots = duration_dots
 
             evc = musicexp.EventChord ()
             evc.elements.append (skip)