From d136a9bc5cda8d0bd5d5675c37097c7a734163af Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Thu, 22 Oct 2009 16:14:58 +0200 Subject: [PATCH] MusicXML: Fix which durations can be expressed with dots and which can't --- .../03d-Rhythm-DottedDurations-Factors.xml | 306 ++++++++++++++++++ scripts/musicxml2ly.py | 7 +- 2 files changed, 310 insertions(+), 3 deletions(-) create mode 100644 input/regression/musicxml/03d-Rhythm-DottedDurations-Factors.xml diff --git a/input/regression/musicxml/03d-Rhythm-DottedDurations-Factors.xml b/input/regression/musicxml/03d-Rhythm-DottedDurations-Factors.xml new file mode 100644 index 0000000000..2a53d2c7f7 --- /dev/null +++ b/input/regression/musicxml/03d-Rhythm-DottedDurations-Factors.xml @@ -0,0 +1,306 @@ + + + + + + Several durations can be written + with dots. For multimeasure rests, we can also have durations that + cannot be expressed with dotted notes (like 5/8). + + + + + MusicXML Part + + + + + + + 4 + + + + + C + 5 + + 2 + 1 + eighth + + + + + + + 1 + + + + + 2 + 1 + + + + + + + + + + C + 5 + + 4 + 1 + quarter + + + + + + + 1 + + + + + 4 + 1 + + + + + + + + + + C + 5 + + 12 + 1 + half + + + + + + + + 1 + + + + + 12 + 1 + + + + + + + + + + C + 5 + + 16 + 1 + whole + + + + + + + 1 + + + + + 16 + 1 + + + + + + + + + + C + 5 + + 4 + 1 + quarter + + + + C + 5 + + 1 + 1 + 16th + + + + + + + 1 + + + + + 5 + 1 + + + + + + + + + + C + 5 + + 14 + 1 + half + + + + + + + + 1 + + + + + 14 + 1 + + + + + + + + + + C + 5 + + 16 + 1 + whole + + + + C + 5 + + 2 + 1 + eighth + + + + + + + 1 + + + + + 18 + 1 + + + + + + + + + + C + 5 + + 1 + 1 + 16th + + + + + + + 1 + + + + + 62 + 1 + + + + + + + + + + C + 5 + + 16 + 1 + whole + + + + diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index aa91e9fc68..a19c2fc880 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -580,10 +580,11 @@ def rational_to_lily_duration (rational_len): d_log = {1: 0, 2: 1, 4:2, 8:3, 16:4, 32:5, 64:6, 128:7, 256:8, 512:9}.get (rational_len.denominator (), -1) # Duration of the form 1/2^n or 3/2^n can be converted to a simple lilypond duration - if (d_log >= 0 and rational_len.numerator() in (1,3,5,7) ): + dots = {1: 0, 3: 1, 7: 2, 15: 3, 31: 4, 63: 5, 127: 6}.get (rational_len.numerator(), -1) + if ( d_log >= dots >= 0 ): # account for the dots! - d.dots = (rational_len.numerator()-1)/2 - d.duration_log = d_log - d.dots + d.duration_log = d_log - dots + d.dots = dots elif (d_log >= 0): d.duration_log = d_log d.factor = Rational (rational_len.numerator ()) -- 2.39.5