--- /dev/null
+<?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">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).</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>4</divisions>
+ <time>
+ <beats>1</beats>
+ <beat-type>8</beat-type>
+ </time>
+ </attributes>
+ <note>
+ <pitch>
+ <step>C</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>2</duration>
+ <voice>1</voice>
+ <type>eighth</type>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="2">
+ <attributes>
+ <measure-style>
+ <multiple-rest>1</multiple-rest>
+ </measure-style>
+ </attributes>
+ <note>
+ <rest/>
+ <duration>2</duration>
+ <voice>1</voice>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="3">
+ <attributes>
+ <time>
+ <beats>2</beats>
+ <beat-type>8</beat-type>
+ </time>
+ </attributes>
+ <note>
+ <pitch>
+ <step>C</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>4</duration>
+ <voice>1</voice>
+ <type>quarter</type>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="4">
+ <attributes>
+ <measure-style>
+ <multiple-rest>1</multiple-rest>
+ </measure-style>
+ </attributes>
+ <note>
+ <rest/>
+ <duration>4</duration>
+ <voice>1</voice>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="5">
+ <attributes>
+ <time>
+ <beats>3</beats>
+ <beat-type>4</beat-type>
+ </time>
+ </attributes>
+ <note>
+ <pitch>
+ <step>C</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>12</duration>
+ <voice>1</voice>
+ <type>half</type>
+ <dot/>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="6">
+ <attributes>
+ <measure-style>
+ <multiple-rest>1</multiple-rest>
+ </measure-style>
+ </attributes>
+ <note>
+ <rest/>
+ <duration>12</duration>
+ <voice>1</voice>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="7">
+ <attributes>
+ <time>
+ <beats>4</beats>
+ <beat-type>4</beat-type>
+ </time>
+ </attributes>
+ <note>
+ <pitch>
+ <step>C</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>16</duration>
+ <voice>1</voice>
+ <type>whole</type>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="8">
+ <attributes>
+ <measure-style>
+ <multiple-rest>1</multiple-rest>
+ </measure-style>
+ </attributes>
+ <note>
+ <rest/>
+ <duration>16</duration>
+ <voice>1</voice>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="9">
+ <attributes>
+ <time>
+ <beats>5</beats>
+ <beat-type>16</beat-type>
+ </time>
+ </attributes>
+ <note>
+ <pitch>
+ <step>C</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>4</duration>
+ <voice>1</voice>
+ <type>quarter</type>
+ </note>
+ <note>
+ <pitch>
+ <step>C</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>1</duration>
+ <voice>1</voice>
+ <type>16th</type>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="10">
+ <attributes>
+ <measure-style>
+ <multiple-rest>1</multiple-rest>
+ </measure-style>
+ </attributes>
+ <note>
+ <rest/>
+ <duration>5</duration>
+ <voice>1</voice>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="11">
+ <attributes>
+ <time>
+ <beats>7</beats>
+ <beat-type>8</beat-type>
+ </time>
+ </attributes>
+ <note>
+ <pitch>
+ <step>C</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>14</duration>
+ <voice>1</voice>
+ <type>half</type>
+ <dot/><dot/>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="12">
+ <attributes>
+ <measure-style>
+ <multiple-rest>1</multiple-rest>
+ </measure-style>
+ </attributes>
+ <note>
+ <rest/>
+ <duration>14</duration>
+ <voice>1</voice>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="13">
+ <attributes>
+ <time>
+ <beats>9</beats>
+ <beat-type>8</beat-type>
+ </time>
+ </attributes>
+ <note>
+ <pitch>
+ <step>C</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>16</duration>
+ <voice>1</voice>
+ <type>whole</type>
+ </note>
+ <note>
+ <pitch>
+ <step>C</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>2</duration>
+ <voice>1</voice>
+ <type>eighth</type>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="14">
+ <attributes>
+ <measure-style>
+ <multiple-rest>1</multiple-rest>
+ </measure-style>
+ </attributes>
+ <note>
+ <rest/>
+ <duration>18</duration>
+ <voice>1</voice>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="15">
+ <attributes>
+ <time>
+ <beats>31</beats>
+ <beat-type>8</beat-type>
+ </time>
+ </attributes>
+ <note>
+ <pitch>
+ <step>C</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>1</duration>
+ <voice>1</voice>
+ <type>16th</type>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="16">
+ <attributes>
+ <measure-style>
+ <multiple-rest>1</multiple-rest>
+ </measure-style>
+ </attributes>
+ <note>
+ <rest/>
+ <duration>62</duration>
+ <voice>1</voice>
+ </note>
+ </measure>
+ <!--=======================================================-->
+ <measure number="17">
+ <attributes>
+ <time>
+ <beats>2</beats>
+ <beat-type>2</beat-type>
+ </time>
+ </attributes>
+ <note>
+ <pitch>
+ <step>C</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>16</duration>
+ <voice>1</voice>
+ <type>whole</type>
+ </note>
+ </measure>
+ </part>
+</score-partwise>
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 ())