Two goals in NIF's timing representation are 1) to describe the time values in a semantically useful way, and 2) to provide enough information for the reading program to produce a MIDI playback of the score.
Two kinds of playback are: 1) logically precise playback derived from the notation, and 2) nuanced rubato of a recorded performance.
For each playback event, there are two pieces of information to be described: 1) start time, when the event is to occur, and 2) duration, how long it lasts.
Durations in music notation are inherently rational numbers (fractions) which describe the relationship between a specific unit of time (the note value) and a standard unit of time (traditionally the whole note). A half note is 1/2 of a whole note; a quarter note is 1/4 of a whole note. Infinitely smaller note types can be invented by increasing the denominator to any power of 2.
More interestingly, the duration of each note in a tuplet sometimes can be precisely represented only by a fraction, such as half note triplets, where each note's duration can be accurately represented as 1/3. When three half notes occur in the time normally allotted for 2, each note takes up 2/3 the time of a normal half note (1/3 = 2/3 * 1/2). Similarly, when 3 quarter notes are stretched out to the time of 4 (notated as 3:4 over a bracket, in tuplet notation), this duration can also be represented as 1/3: each note takes up 4/3 of the time of a normal quarter note (1/3 = 4/3 * 1/4).
A fraction consisting of two integers (a numerator and a denominator) is therefore a natural way to describe durations.
The duration field in a Notehead chunk is the same whether or not the note is included in a tuplet. Additional information (a series of tuplet chunks) is to be stored in the file for each tuplet. The first tuplet chunk contains a transformation ratio to be applied to each note in the tuplet, and graphical information about the appearance of the tuplet such as the presence of numbers and/or brackets.
The tuplet transformation ratio is in the form of 4 integers: a, b, c, and d, where a b-type notes occur in the time of c d-type notes. In conventional usage of tuplets, b and d will be the same, but many musicians use tuplets in an "unconventional" way, and may choose to represent a tuplet as, for example, three half notes in the time of four quarter notes (a, b, c, d = 3, 2, 4, 4).
For example, in the case of half note triplets the transformation ratio in the tuplet chunk is 3:2. When applied to the half note duration on the note chunk (1/2), this would result in an effective duration of 1/3 (1/3= 2/3 * 1/2). The effective duration need not be stored in the file, since it can be calculated by the reading program from values in the note and tuplet chunks.
A tuplet is normally a multi-node symbol, represented by a series of Tuplet node chunks, each one associated with one Stem chunk. All notes on a tupletized stem must contain the same duration. See Chapter 2 for information about multi-node symbols.
Nested tuplets are represented by an additional tuplet associated with a subset of notes already included in a tuplet. The transformation ratios are applied cumulatively to each affected note.
More than one voice or part can be included in a tuplet. For example, when all horns shown on the same staff are playing in rhythmic unison, a whole collection of chords may be tupletized. However, within each voice (or part, if there is one voice per part), the sum of the durations of the notes must equal a b-type notes.
An explicit start time is required because simultaneous events are not always vertically aligned - for example, a chord with seconds. Ambiguity can result for a variety of other reasons as well.
The start time of a note or rest is stored on the event Time-slice chunk associated with (most recently preceding) the note or rest symbol. The start time is represented by a fraction which is the sum of the durations of all events that have occurred within the voice since the previous measure-start time-slice.
Here is an example, showing the start times and durations for 4 quarter notes in the first measure of a score in 4/4 time.
Time-slice, type=event, start-time=0/4 Stem Notehead, duration=1/4 Time-slice, type=event, start-time=1/4 Stem Notehead, duration=1/4 Time-slice, type=event, start-time=2/4 Stem Notehead, duration=1/4 Time-slice, type=event, start-time=3/4 Stem Notehead, duration=1/4
The start time of a measure is stored on a measure-start Time-slice chunk. It is given as the cumulative duration of all events since the start of the piece. The effective start time of each event in a measure is therefore the sum of the measure start time (from the measure-start Time-slice chunk) and the event start time (from the event Time-slice chunk). In the example above, the start time on the measure-start Time-slices of the first and second measures, respectively, would be 0/4 and 4/4.
The reference back to the start of the piece permits the correspondence between events in different parts to be determined even when the parts are in different meters.
Note concerning pickup bars: NIFF has no standard "correct" way to represent such (incomplete preliminary) bars. In particular, scanning programs may not have the intelligence to distinguish a genuinely incomplete bar from a pickup measure. Therefore the writing program has the choice of representing the pickup either as simply a "normal" incomplete bar, or else of representing it "correctly" (in musical terms) as the final portion of a preceding bar. As long as the barline time slice and the following measure time slice contain the same time, it should make little difference on which beats the two pickups are placed. Implementations should be prepared to deal with either of these possible representations of time in a pickup measure.
An additional reason start time is required is that voices are not always logically complete from start to finish. If a voice were logically complete, the start time of each event within the voice would always be the exact time that the previous event in that voice finished. Logical incompleteness (gaps) can occur, however, for various reasons: 1) Piano music often allows temporary voices to appear and disappear with no rests to fill the time gaps. 2) A non-metrical cadenza-like section can appear in one voice or part, leaving all other voices or parts with a logical gap during that time. 3) Scanning programs can easily miss one or more notes in the middle of a sequence. 4) Inactive parts might be hidden for large sections of a score.
Logical gaps can be filled in with invisible rests and placeholding measure-start time-slices. Or, logical gaps can be handled by adding extra value to the start time of the event following the gap to compensate for the missing time. Either technique ensures that the event following a logical gap in one voice will not occur until its proper time among the events in all other voices and parts.
For performance playback, both start time and duration are measured in MIDI ticks, which denote some fixed amount of time using an integer. MIDI ticks are well suited to performance information because of their high resolution. The relationship between the performance and logical values is described by the field MIDI ticks per quarter note, stored in the NIFF Information chunk in the Setup Section.
The performance start time and duration are given as offsets (+/-) from the logical start time and duration of the event.
Lengthy or complex MIDI information that cannot be represented with the simple MIDI Performance tag can be supplied with the MIDI Data Stream chunk (see below under MIDI Integration).
The Notehead and Stem chunks and associated chunks and tags contain graphical features such as notehead shape, number of dots and number of flags that in printed music describe a note's duration. However, the reading program need not concern itself with the timing implications of these details. The duration field stored on the Notehead chunk should be used for the timing value, regardless of the graphical features. For example, a note with duration of 3/16 could appear visually as a dotted eighth note with either a flag or a beam. In practice, any combination of a note's graphical features, or even an invisible note on a zero length stem, could be used to represent any time value.
The performance playback values may be affected by other chunks and tags associated with the Notehead or Stem chunks, however. For example, an Accidental chunk will affect the pitch, an Articulation chunk or Silent tag might affect the performance duration, and a Grace Note tag would likely affect the start time.
An event's start time and duration are always present (each composed of a numerator and denominator component); the performance start time and duration are optional values that can be supplied on the MIDI Performance tag. If not present, it is assumed that the performance values are equivalent to the logical values.
NIFF does not require logical adherence to time signatures.
A barline signals the end of a measure rather than the start of a measure. On the last measure of a system it is necessary to store the Barline chunk before the measure-start time-slice, which belongs in a new Staff list and a new System list. So, for consistency and logical rigor, the Barline graphical symbol chunk is to be stored between the last event in the measure and the measure-start time-slice of the next measure. A special event time-slice chunk should be stored for this purpose, to uniquely identify the sequential position of the barline. Its start time can be the same, in essence, as the start time of the next measure-start time-slice, except given in relation to the start of its measure rather than the start of the score. The only time non-unique time-slices are allowed within a Staff list are when an event time-slice duplicates a measure-start time-slice in this way.
Chunks representing changes in clef, key signature and time-signature, when present at a measure boundary, should be stored in the same way, following the Barline chunk. Horizontal placement can be supplied to identify the individual placement of each symbol within this special time-slice, though most reading programs would have spacing algorithms to handle them adequately without it. When changes in clef, key signature or time signature occur in the middle of a measure, they should be stored with the time-slice which represents the following event. The horizontal placement of a symbol chunk in this situation, if specified, should have a negative value.
Chunks representing the clefs, key signatures and time signatures that appear at the start of the staff do not need to be preceded by an event-time-slice. They are stored immediately after the new measure-start time-slice. In the case where the new system starts in the middle of a measure, these chunks should be stored with the time-slice which represents the following event. The horizontal placement of a symbol chunk in this situation, if specified, should have a negative value.
A grace note is a note whose time value is not counted in the general rhythm; its time value must be subtracted from that of the preceding or following normal note during performance. A grace note is always associated with the event time-slice of the normal note following it. It is indicated by the addition of a Grace Note tag to a Notehead or Stem chunk. The Grace Note tag gives the note's logical start time as an offset from thestart time of its time-slice (negative, zero or positive, depending on the chosen interpretation of grace notes and the note's position within a series of grace notes).
For small notes that break the meter but whose time is not subtracted from that of the preceding or following normal note, do not use the Grace Note tag.
The performance start time (in the note's MIDI Performance tag) is given as an offset in MIDI ticks from the grace note's logical start time. Other tags that might be found on a grace note's Notehead or Stem chunk include the Slash tag, Small Size tag, and the Absolute Placement tag (with a negative value) indicating a negative horizontal offset from the time-slice.
In the following example, the grace note's time value is subtracted from the preceding note during performance, as in Chopin or Liszt. However, the duration field on the preceding Notehead chunk is not modified to compensate for the grace note. The start time on the Grace Note tag gives a negative offset of 1/32 from its time slice, which can be used by the reading program during playback.
Time-slice, type=event,start-time=0/4 Stem Notehead, shape=filled, staff step=0, duration=1/4 Time-slice, type=event, start-time=1/4 Stem, Number of Flags=1, Slashed Stem, Small Size, Grace Note=-1/32 Notehead, shape=filled, staff step=2, duration=1/32 Stem Notehead, shape=filled, staff step=1, duration=1/4