MML: General module

  1. Comment
  2. Commentary
  3. Repetition
    1. Notation method
      1. Syntax of MML repetition
      2. Nested repetition
      3. Range
      4. Exception
    2. Identifier method
      1. Declare attribute
      2. Repeat attribute
    3. Note on calculations for repetitions

The General Module covers markup such as Comments and Commentrary. It also covers a possible approach to the repetitive nature of music. XML parsers will only be able to render MML markup textually. To render MML data in graphic music notation, or to output to other modules such as MIDI, additional software programs will need to be called. Repetition will need to be handled by such additional programs. Although an XML parser will not be able to render the abbreviated forms of repetition, markup of repetitions should nevertheless be well-formed and valid, which means XML parsers will be handled the markup as is.

1 Comment

A comment consists of text that is not rendereed by a user agent. Markup authors generally use this for notes and remarks. The MML comment follows the SGML/XML structure:

<!-- this is a comment -->


2 Commentary

commentary element

A commentary is a string of text (typed or spoken) that in some cases need to be synchronized with the music. Commentary can take at least the following characteristics:

Synchronization will not be handled by an XML parser, but by additional software.

Commentary rendering

Commentary Could be rendered either visually as text, or audibly by a speech synthesizer.

This could be handled with functions contained in the SMIL specification.


3 Repetition

Music often consists of repetition on various structural levels. It would be very uneconomical to expect explicit markup for elements that are repeated endlessly. For this reason MML introduces a convention for marking repetitions, which could obviously not be handled by an XML parser, but by additional software. However, even markup for repetitions should nevertheless conform to well-formedness and validity, which would indeed be parsed properly by an XML parser. Such a parser will just not fill in the gaps.

Repetition can be declared with a notation method, or by declaring an identifier name for a section of music.


1 Notation method

1 Syntax of MML repetition

Repetition is indicated with the round brackets usually used for parenthesis:

( and )

The number of times the element should be repeated must be written after the close parenthesis symbol.

Example: long form

Here is the comprehensive markup for a division that includes five bars (the division declaration is optional):


  <bar barid="1">...</bar>
  <bar barid="2">...</bar>
  <bar barid="3">...</bar>
  <bar barid="4">...</bar>
  <bar barid="5">...</bar>


bar | div | bars

Example: short form

Here is the short form of the above example:

<div bars="5">

This is read as:
In this division, repeat the bar element and its content five times.

2 Nested repetition

A repeated element may contain another element that is repeated as its content.


In this example the same note is repeated in several bars, and the bars are contained in a division.

<div bars="5">

Here is another example. The content (ie 4 repeates of 2D:4) of the division is repeated in bars x and y, but not in bar z, which contains 3C:4.

  <bar barid="x"></bar>
  <bar barid="y">3C:4 </bar>
  <bar barid="z"></bar>

bar | div | note

This is translated into English as:
There are five bars in the division. Each bar consists of four notes with the value "D quarter note in the second octave".

3 Range

The above examples do not specify the position where the repetition occurs. MML allows for specifying a range, with the range attribute. Two numbers are stated in the range: where the range begins and where it ends. What the range refers to depends on its element.


In this example the range applies to bars. The first value of the range indicates the bar number where the range begins (Bar 6), the second number after the colon indicates the bar number where it ends (Bar 10). This syntax is a short form for nested elements.

<div range="6:10">

bar | div | range

This is translated as:
Within the division there are five repeated bars beginning with bar 6, ending with bar 10 (see the Note on calculations).

A range may also apply to other elements such as beat.

4 Exception

Repeated music phrases may contain almost exactly the same content, perhaps with a deviation somewhere along its progression. The repeated phrase can be declared with the repeat attribute, while exceptions within the repeated sequence are declared with the exclude attribute. Exclusion can be declared in the same manner as a range, ie beginning with the excluded element number and ending where the exclusion ends.

<div range="6:10" exclude="7">


This is translated as:
In this range of 5 bars (in the division) beginning with bar 6, ending with bar 10 the 7th bar is excluded.

Example: excluding a range
<div range="16:30" exclude="20:22">

This is translated as:
In this range of 15 bars (in the division) beginning with bar 16, ending with bar 30, 3 bars (from 20 to 22) are excluded.

2 Identifier method

With the identifier method the section of music that needs to be copied at other instances is marked with the span or div elements, or with that of the parent element of the phrase. Using these elements' declare attribute, a unique identifier name is declared. This identifier name is later used with the repeat attribute. The exact music sequence will then be repeated.

1 Declare attribute

declare attribute

In this example a declare ID is declared with the name "one".

  <bar barid="2">D:2 B:4

  <bar barid="3" declare="one">5(B C D An B A Gs A C Gb)

2 Repeat attribute

repeat attribute

At a later instance, in this case Bar 11, the exact sequence of notes (as declared earlier) can be called upon as follows:

  <bar barid="10">D:2</bar>
  <bar barid="11" repeat id="one">  </bar>


3 Note on calculations for repetitions

When calculating a number of elements remember that when you add or subtract you apply the calculation to a spanned series. In other words, 10-5 does NOT equal 5, but 6, as the starting point (number) should be added as well.

In ordinary maths 10-5=5.

However, consider the following bars

bar 1 bar 2 bar 3 bar 4 bar 5 bar 6 bar 7 bar 8 bar 9 bar 10

Begin at bar 10 and count five bars to the left. You will end at bar 6 and not bar 5. This is because you are counting spans. Remember to keep this in mind otherwise you will end up with included bars you actually wanted to exclude.


1999, 2000 Author: Jacques Steyn