Sequence content

MNX uses the term sequence content to mean a series of musical events that are both presented and performed in a given order, each at a distinct time. For example, these musical events include notes, rests and directions.

Sequence content has three attributes:

  1. The content itself, which is encoded via the <sequence> element.
  2. A starting position, which is the metrical position of the content's first element within the containing measure.
  3. A time modification ratio, which is a rational number scale factor that implicitly applies to all positions and durations within the content.

Sequence content permits interspersed direction content whose directions are injected into the sequence either adjacent to events, or at explicitly given measure locations.

Sequencing the content

Within sequence content, each event is assigned a metrical position according to the following procedure, called sequencing the content:

  1. Let sequence cursor be the starting position of the sequence content.
  2. Let content be the list of XML elements comprising the sequence content.
  3. While content is not empty:
    1. Let next be the initial element of content, and remove it from the head of content.
    2. If next is an <event> element:
      1. If next has a measure value of yes,
        1. If sequence cursor is greater than zero, throw a processing error.
        2. Set sequence cursor to the end of the measure as defined by its time signature.
      2. Else,
        1. Set the metrical position of next to sequence cursor.
        2. If next has a duration attribute, assign it to event duration.
        3. Else, set event duration to next’s value attribute.
        4. Multiply event duration by the time modification ratio, and add the result to sequence cursor.
    3. If next is an <forward> element:
      1. Set the metrical position of next to sequence cursor.
      2. Add the duration of next, multiplied by the time modification ratio, to sequence cursor.
    4. Else, if next is an <tuplet> element:
      1. Sequence the content of next, using sequence cursor as the starting position, and multiplying the time modification ratio by the tuplet's outer / inner ratio for the processing of the tuplet.
      2. Add the total duration of next as given by outer, multiplied by the time modification ratio, to sequence cursor.
    5. Else, if next is an <grace> element:
      1. Process the contents of next, assigning them a non-metrical ordering relative to preceding or following elements as appropriate.
    6. If sequence cursor exceeds the specified duration for the enclosing element (time signature for a <measure>, inner attribute for a <tuplet>), throw a processing error.