From: Reinhold Kainhofer Date: Tue, 20 Nov 2007 22:12:50 +0000 (+0100) Subject: MusicXML: Use s4 instead of s1*1/4 X-Git-Tag: release/2.11.36-1~119 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9ea4b70df3418ae31ee1bcfd6526d7a040e1f6ce;p=lilypond.git MusicXML: Use s4 instead of s1*1/4 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. --- diff --git a/input/regression/musicxml/00d-Backup.xml b/input/regression/musicxml/00d-Backup.xml new file mode 100644 index 0000000000..8c2f7d92f4 --- /dev/null +++ b/input/regression/musicxml/00d-Backup.xml @@ -0,0 +1,68 @@ + + + + + Backup not to 0 in second voice + + + + + + + + + + 2 + 0 + + + G + 2 + + + + + C + 4 + + 2 + 1 + quarter + + + + C + 4 + + 2 + 1 + quarter + + + 2 + + + + A + 3 + + 2 + 2 + quarter + + + + A + 3 + + 2 + 2 + quarter + + + + + diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index 01f02cfeac..c5e07c2ece 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -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)