Search code examples
musicxml

How <divisions> specified in MusicXML


The MusicXML tutorial is not clear enough as to how the number in the <divisions> element is initialized in MusicXML. Is it related to MIDI files? Because I have cross checked with different samples having the same time signatures and the number keeps changing.


Solution

  • Divisions is an arbitrary number to allow you to specify the durations of notes independently from from the "type" of note.

    You specify the <divisions> as part of the measure attributes, where it means "number of divisions per quarter note".

    Then for each note within the measure you specify <duration> which determine the note's length as a fraction of one quarter note.

    So in the following example, within the attributes group we are stating that there are 4 divisions per quarter note. Then, in the first note, which is a quarter note, we are stating that the note lasts for 4 divisions. The next note is an eighth note so we state that it lasts for 2 divisions, and so on...

    <measure number="1">
       <attributes>
          <divisions>4</divisions>
          <time>
             <beats>2</beats>
             <beat-type>4</beat-type>
          </time>
       </attributes>
       <note>
          <pitch>
             <step>C</step>
             <alter>0</alter>
             <octave>4</octave>
          </pitch>
          <duration>4</duration>
          <type>quarter</type>
       </note>
       <note>
          <pitch>
             <step>C</step>
             <alter>0</alter>
             <octave>4</octave>
          </pitch>
          <duration>2</duration>
          <type>eighth</type>
       </note>
       <note>
          <pitch>
             <step>C</step>
             <alter>0</alter>
             <octave>4</octave>
          </pitch>
          <duration>1</duration>
          <type>16th</type>
       </note>
       <note>
          <pitch>
             <step>C</step>
             <alter>0</alter>
             <octave>4</octave>
          </pitch>
          <duration>1</duration>
          <type>16th</type>
       </note>
    </measure>