INTERMEDIATE FILES FOR MUSIC PRINTING

                       November 28, 1990
                       (revised 5-28-93)
                       (revised 11-11-93)
                       (revised 9-15-94)
                       (revised 9-27-94)
                       (revised 8-09-95)


I. File Structure

   Variable length ASCII records
   Fields separated by blanks

II. Types of I-files

     The first step is to generate an I-file for each individual
part.  These "source" I-files are non-page-specific; i.e. the clef,
key and time signatures occur only at the beginning of the file,
and there are no line breaks or page breaks.  The reason for this
type of representation is that we may want to generate a printed
part, or we may want to generate a score.

     The generation of a single part will lead to a page-specific
I-file for this part.  The generation of a full score will lead to
a page-specific I-file for the score.  There will be some slight
variation in representation for these page-specific files:

     1. Lines will be broken and located on the page.

     2. Clef, key and time signatures will be placed
          at the begining of every line.
     3. The hyphens betwen syllables of text underlay
          locations.
     4. Ties, slurs and extended hyphens will be
          continued across line and page boundaries.

III. Record Types

      Source Files                   Page Specific (additional)
      ------------                   --------------------------
       Music Lines                    Systems
       Objects                        Music Lines (page specific)
       Sub-objects                    End of Music Line
       Text (form of sub-object)      System Bar
       Words (form of sub-object)     Page Text
       Attribute (form for sub-object)
       Super-objects

IV. Record Formats

  A. Music Lines

     Field 1: Identifier = L
     Field 2: 0 = single staff; # = vertical offset of second staff
     Field 3: vertical displacement of text line
     Field 4: part name (ASCII string)
_NP

  B. Objects

     Field 1: Identifier = J

     Field 2: type of object    B = bar line
                                C = clef
                                K = key signature
                                T = time signature
                                D = directive (e.g. time word, etc)
                                S = other symbol
                                N = note
                                R = rest
                                G = grace note
                                Q = cue note
                                F = figures
                                I = isolated directive or symbol (not
                                      associated with a note, rest, or figure)
                                M = mark (mostly for superobjects)
     Field 3: object code

           Bar line:   x = measure number if there be one, else zero

           Clef:       x = clef code
           Key:        x = key code
           Time sig:   x = time code (100 * tnum + tden)
           Directive:  0 = print always (parts and score)
                       bit 0 set = print in parts
                       bit 1 set = print in score
                       bit 2 set = print if top part in score
                       bit 3 set = print if bottom part in score
                          (bit 1 over-rides bits 2 and 3)

           Symbol:     0 = not identified
                       4 = extended rest
                       6 = whole measure rest

                       From the standpoint of typesetting for a score
                       the major difference between a directive and a
                       symbol is that a symbol will always be printed
                       whether or not the part stands alone or is part
                       of a score (e.g., letter dynamics), whereas a
                       directive can be "made invisible" in parts that
                       are not at the top or the bottom of a score
                       (e.g., the segno sign).

           Notes:      x = note type
           Rests:      x = rest type
           Grace note: x = note type
           Cue note:   x = note type
           Figure:     0
           Isolated:   same as for Directives
           Mark:       0

     Field 4: horizontal displacement measured in 32-bit precision
                from beginning of piece

           For objects which are groups of notes (chords),
           the x co-ordinate is the position of the notes
           which fall on the proper side of the stem.  For
           stem up, the object's position is that of the
           note heads to the left of the stem; for stem down,
           the object's position is that of the note heads
           to the right of the stem.
_NP

     Field 5: vertical displacement from top staff line

           For objects which are groups of notes (chords), the
           y co-ordinate is the position of the note which is
           farthest from the note-end of the stem (and hence
           closest to a beam, if there be one).  This is impor-
           tant for the proper setting of beams at print time.

           For objects to be placed on the second (or greater)
           staff of the grand staff, 1000 (2000) will be added
           to the displacement.  This means that the print
           program must check the range of the displacement before
           placing the object.

           For Bar type objects, which always have a
           y co-ordinate of 0, this field contains instead
           the bar line code:
                                 1 = single light bar
                                 2 = single heave bar
                                 3 = dotted bar
                                 5 = double light bar
                                 6 = light-heavy double bar
                                 9 = heavy-light double bar
                                10 = heavy-heavy double bar

           In case the bar object extends to more than one staff
           an amount equal to 1000 times (n-1) where n is the
           number of staves is added to the bar line code


     Field 6: print code (or if < 32, number of sub-objects)

     Field 7: space node number

           1. Multiple rests -- number = measures of rest

           2. Everything else -- number = division number

              This number will indicate the division within the
            measure to which the object belongs.  The measure
            is divided into 6912 (27 x 256) parts.  Divisions
            run from 1 to 6912.  It is possible for several
            objects to have the same space node number.  These
            objects will have separate numbers in the page-
            specific format.

     Field 8: distance increment flag.  This flag describes the
              distance from the preceding object, as well as an
              attribute of the node:

                 0 = preceding distance should remain fixed
                      at print time

                 # = preceding distance may vary at print time;
                      parameter is the duration of the preceding
                      node, measured in units such that
                      576 = quarter note.

             10000 = object will be centered between bar lines
                      (used only with whole measure rests)

     Field 9: number of super-objects associated with this object

     Fields 9a,b...,: super-object numbers
_NP

  C. Sub-objects (these must follow directly after their associated
                    objects)

     Field 1: Identifier = K
     Field 2: horiz. displacement, relative to object co-ordinate
     Field 3: vertical displacement, relative to object co-ordinate
     Field 4: print code of sub-object

  D. Text (a form of sub-object attached to note or rest)

     Field 1: Identifier = T
     Field 2: horizontal displacement of text, relative to object
     Field 3: vertical code (text line number) or offset from staff line
                If field 3 is between 1 and 10, it is interpreted as text
                line number; if greater than 10, it is interpreted as
                an offset + 1000.  Normally this field will contain the text
                line number; this allows all texts to be moved by simply
                changing paramter 3 in the Line (L) record.  When the
                vertical position of a word of text is specifically
                specified, this has the effect of "uncoupling" the word
                from the rest of the text.
     Field 4: ASCII string
     Field 5: indication of forward hyphen or underline character

                - = forward hyphen
                _ = forward underline character
                . =     "         "       "     followed by  .
                , =     "         "       "        "     "   ,
                : =     "         "       "        "     "   :
                ; =     "         "       "        "     "   ;
                ! =     "         "       "        "     "   !
                ? =     "         "       "        "     "   ?
                * = nothing

     Field 6: space taken up by ASCII string

  E. Words (a form of sub-object attached to symbol)

     Field 1: Identifier = W
     Field 2: horizontal displacement of word(s), relative to
                 directive or symbol object
     Field 3: vertical displacement
     Field 4: font number
     Field 5: ASCII string (includine font designations)
_NP

  F. Attributes (a form of sub-object attached to notes/rests)

     The purpose of attributes is to communication information about
     an object that is not represented precisely by purely graphical
     information.  An example is the duration of tuplets.  The tuplet
     super-object (H . X) references only the end points of a tuplet;
     there is no precise way to determine the remaining objects whose
     duration might be effected by the tuplet.  When converting page
     specific i-files to SCORE pmx files, we need to know the precise
     duration of all notes.  The only foolproof way to convey this
     information is in an attribute.  Attributes are typically ignored
     in the printing process.

     Field 1: Identifier = A
     Field 2: type of attribute

     1. D = duration

        Field 3: numerator of duration
        Field 4: denominator of duration

            Duration is represented as a proper fraction.
              1/4 = quarter note
              1/2 = half note
              etc.
            In terms of divisions (from stage2 source representation)
            the numerator is the number of divisions, and the denominator
            is four times the divisions per quarter.


  G. Super-objects (these are things whose shapes depend on the
           locations of more than one object.  They generally follow
           after all of their associated objects have been described

     Field 1: Identifier = H
     Field 2: super-object number
     Field 3: type of super-object

                B = beam
                T = tie
                S = slur (dotted slur)
                X = tuple/bracket
                W = wedge
                D = word plus dashes
                E = ending
                R = long trills
                V = octave transposition
                F = figure extension
                N = null super-object (no action)

     Fields 4--: depend on the super-object type

     1. Beams    (type = B)

        Fields 4 and 5:

          Case I: location undetermined

            Field 4:  0 = beam above first object
                      1 = beam below first object

            Field 5:  0 or 1 = stem directions are all the same
                    > 1 = binary representation of stem direction.
                          If field 4 = 0, then bit set = stem up;
                          if field 4 = 1, then bit set = stem down;
                          Example: if field 4 = 1, then 101001010 =
                          down, up, down, up, up, down, up, down, up

          Case II: location determined

            Field 4:  length of first stem (positive = stem up)

            Field 5:  slope of beam

        Field 6: font number
        Field 7: number of associated objects
        Fields 7a, b,...   beam codes

            beam code = up to 6 digit number

               0 = no beam
               1 = continue beam
               2 = begin beam
               3 = end beam
               4 = forward hook
               5 = backward hook
               6 = begin repeated beam
               7 = end repeated beam

                    1's digit = eight level beams
                   10's digit = 16th level beams
                  100's digit = 32nd level beams
                 1000's digit = 64th level beams
                10000's digit = 128th level beams
               100000's digit = 256th level beams
_NP

     2. Ties    (type = T)

        Fields 4--6:  locations of note heads to be tied

          Field 4: vertical position of tied notes (position
                     measured in dots (300/inch) from top staff
                     line)

              For ties on the virtual staff, 1000 will be added to
              this value.


          Field 5: horizontal displacement of first note head from
                     associated object (non-zero only with chords)
          Field 6: horizontal displacement of second note head from
                     associated object (non-zero only with hords)

        Fields 7--9:  parameters for tie shape and placement
                         (calculated at print time)

          Field 7: horizontal displacement from note head one
          Field 8: vertical displacement from note head one
          Field 9: font number

        Field 10: situation flag

           interference     tips down       tips up
           stem   staff   space   line    space   line
           -----  -----   -----   ----    -----   ----
            no     yes      1       5        9     13
            no     no       2       6       10     14
            yes    yes      3       7       11     15
            yes    no       4       8       12     16

        Field 11: reset parameter flag (used in cases where
              post-editing has specified non-standard parameters)

            value    action
            -----    ------
              0      recompute position and font (normal setting)
              1      do not recompute position
              2      do not recompute font
              3      do not recompute position or font


_NP

     3. Slurs (dotted slurs)    (type = S)

        Field 4: situation flag

                       bit clear            bit set
                     --------------       -------------
            bit 0:   full slur            dotted slur
            bit 1:   stock slur           custom slur
            bit 2:   first tip down       first tip up
       (*)  bit 3:   second tip down      second tip up
       (+)  bit 4:   compute stock slur   hold stock slur

            (*) used on custom slurs only
            (+) used on stock slurs only

        Field 5--8:  position fields:

            For stock slurs, these are displacements added to
               the note positions before the slur number is
               calculated.  Displacements are measured in dots
               (300/inch).  Horizontal positive is forward to
               the right; vertical positive is down.

            For custom slurs, these displacements are the actual
               starting point and ending points of the slur
               relative to the first and second objects.

            Field 5: (extra) horizontal displacement from
                        associated object one
            Field 6: (extra) vertical displacement from
                        associated object one
            Field 7: (extra) horizontal displacement from
                        associated object two
            Field 8: (extra) vertical displacement from
                        associated object two

        Field 9--10:  parameter fields:

            Stock slurs:  Field 9:   post adjustment to curvature
                          Field 10:  beam flag  1 = set slur above beam
                                                2 = set slur below beam

            Custom slurs:  Field 9:   vertical height parameter
                           Field 10:  length of flat portion as a
                                      percent of span between end
                                      points

        Field 11--12:  more parameters

            Stock slurs:  Field 11:  post adjustment to x-position
                                     negative = left; positive = right
                          Field 12:  post adjustment to y-position
                                     negative = up; positive = down

_NP

     4. Tuplets/brackets    (type = X)

        Field 4: situation flag

                       bit clear           bit set
                     --------------      -------------
            bit 0:   no tuplet           tuplet
            bit 1:   no bracket          bracket
            bit 2:   tips down           tips up
            bit 3:       0               tuplet aligns with beam
            bit 4:   tuple near notes    tuple near beam
                     (bit 4 has meaning only if bit 3 is set)

        Field 5:  tuplet number

        Fields 6--10: parameters

          Case I: bit 3 of sitflag = 0 (tuple not aligned with beam)
               or bit 3 of sitflag = 1 and bit 4 of sitflag = 0 (tuple aligned with notes of beam)

            Field 6:  horizontal displacement from
                            associated object one
            Field 7:  vertical displacement from
                            associated object one
            Field 8:  horizontal displacement from
                            associated object two
            Field 9:  vertical displacement from
                            associated object two
            Field 10: not used

          Case II: bit 3 of sitflag = 1 (tuple aligned with beam)

            Field 6:  horizontal post adjustment to tuple
 
            Field 7:  vertical post adjustment to tuple
 
            Field 8:  horizontal post adjustment to tuple

            Field 9:  vertical post adjustment to tuple
 
            Field 10: beam super-object number with which tuplet
                            aligns

     5. Wedges    (type = W)

        Field 4: wedge size at left end

        Field 5: wedge size at right end

        Field 6: horizontal displacement from
                        associated object one
        Field 7: vertical displacement from
                        top of staff
        Field 8: horizontal displacement from
                        associated object two
        Field 9: vertical displacement from
                        top of staff

     6. Word(s) plus dashes    (type = D)

        Field 4: horizontal displacement from
                        associated object one
        Field 5: horizontal displacement from
                        associated object two
        Field 6: vertical displacement from staff lines

        Field 7: spacing parameter

        Field 8: font designator
_NP

     7. Endings    (type = E)

        Field 4: situation flag

                  0 = ending with no number
                  1 = first ending
                  2 = second ending
                  3 = third ending
                  4 = fourth ending
                 11 = transposed 8av down
                 12 = transposed 8av up

        Field 5: horizontal displacement from
                        associated object one
        Field 6: horizontal displacement from
                        associated object two
        Field 7: vertical displacement from staff lines

        Field 8: length of left vertical hook

        Field 9: length of right vertical hook


     8. Long trills    (type = R)

        Field 4: situation    1 = no trill, 2 = trill

        Field 5: horizontal displacement from
                        associated object one
        Field 6: horizontal displacement from
                        associated object two
        Field 7: vertical displacement from
                        associated object one


     9. Octave transposition     (type = V)

        Field 4: situation    0 = 8ve up, 1 = 8ve down
                              2 = 15 up,  3 = 15 down

        Field 5: horizontal displacement from
                        associated object one
        Field 6: horizontal displacement from
                        associated object two
        Field 7: vertical displacement from
                        associated object one
        Field 8: length of vertical hooks
_NP

    10. Figure extension    (type = F)

        Field 4: level   1,2,3 or 4

        Field 5: horizontal displacement from
                        associated object one
        Field 6: horizontal displacement from
                        associated object two


_NP
V. Record Formats for Page Specific Record Types

  A. Systems

     Field 1: Identifier = S
     Field 2: 0
     Field 3: x co-ordinate of system on page
     Field 4: y co-ordinate of system on page
     Field 5: horizontal length of system
     Field 6: vertical length of system
     Field 7: number of lines in system
     Field 8: control string in double quotes (null string allowed)

  B. Music Lines (page specific)

     Field 1: Identifier = L
     Field 2: y off-set in system
     Field 3: text off-set from line
     Fields 4--7:  parameters carried over from previous line

       Field 4: dyoff
       Field 5: uxstart
       Field 6: backloc
       Field 7: xbyte

     Field 8: y off-set to virtual staff line (0 = none)

  C. End of Music Line

     Field 1: Identifier = E
     Field 2: xbyte at end of line

  D. System Bar

     Field 1: Identifier = B
     Field 2: bar type     Single bars   Double Bars
                           -----------   -----------
                           1 = simple    5 = double light
                           2 = heavy     6 = light-heavy
                           3 = dotted    9 = heavy-light
                                        10 = heavy-heavy
                                        25 = heavy-light with
                          99 = no bar            repeat dots

     Field 3: x off-set from beginning of line
     Field 4: number of breaks in line (to avoid interference with
                  text and other designations)
       Fields 5--: parameter pairs, beginning and ending of breaks

  E. Page Text

     Field 1: Identifier = X
     Field 2: font number
     Field 3: x co-ordinate of beginning of text
     Field 4: y co-ordinate of text line
     Field 5: ASCII text

VI. Header Information (required for all MPG page specific files)

     Field 1: Identifier = Z
     Field 2: information type
                                          Example 1
                                     ──────────────────────────────
              1 = Composer:           Ludvig van Beethoven
              2 = Work:               Symphony No. 5 in C minor
              3 = Sub-division:       Movement 1
              4 = Representation:     Full Score
              5 = Resolution:         300 dots/inch
              6 = Notesize:           14 dots per staff line
              7 = Page:               1

                                          Example 2
                                     ──────────────────────────────
              1 = Composer:           Ludvig van Beethoven
              2 = Work:               Symphony No. 5 in C minor
              3 = Sub-division:       Violin I
              4 = Representation:     Complete Parts
              5 = Resolution:         300 dots/inch
              6 = Notesize:           14 dots per staff line
              7 = Page:               1

                                          Example 3
                                     ──────────────────────────────
              1 = Composer:           Ludvig van Beethoven
              2 = Work:               Symphony No. 5 in C minor
              3 = Sub-division:       Movement 1
              4 = Representation:     Violin I
              5 = Resolution:         300 dots/inch
              6 = Notesize:           14 dots per staff line
              7 = Page:               1

     Field 3: actual data