Sequence content | MNX specification

# 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 and rests.

Sequence content has three attributes:

1. The content itself, which is encoded via the sequence object.
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.

## 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 MNX objects comprising the sequence content.
3. For each object obj within content:
   1. If obj has a `"type"` value of `"event"` or is missing a `"type"` attribute:
      1. Set the metrical position of obj to sequence cursor.
      2. Assign the event's `"duration"` to event duration.
      3. Multiply event duration by the time modification ratio, and add the result to sequence cursor.
   2. Else, if obj has a `"type"` value of `"space"`:
      1. Set the metrical position of obj to sequence cursor.
      2. Add the `"duration"` of obj, multiplied by the time modification ratio, to sequence cursor.
   3. Else, if obj has a `"type"` value of `"tuplet"`:
      1. Sequence the content of obj, 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 obj as given by `outer`, multiplied by the time modification ratio, to sequence cursor.
   4. Else, if obj has a `"type"` value of `"grace"`:
      1. Process the contents of obj, assigning them a non-metrical ordering relative to preceding or following elements as appropriate.
   5. Else, if obj has a `"type"` value of `"tremolo"`:
      1. Sequence the content of obj, using sequence cursor as the starting position. Note each event within this multi-note tremolo should be assigned an event duration equal to obj's `outer.duration` (i.e., ignoring obj's `outer.multiple`).
      2. Add the total duration of obj as given by `outer`, multiplied by the time modification ratio, to sequence cursor.
   6. If sequence cursor exceeds the specified duration for the enclosing element (time signature for a measure, `"inner"` value for a tuplet), throw a processing error.