home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Extras / IFF / IFF_Forms / CMUS.proposal < prev    next >
Encoding:
Text File  |  1993-03-01  |  55.7 KB  |  1,322 lines

  1. Common MUsical Score
  2.  
  3. /* ========================================================================= *
  4.                          CMUS - Common Musical Score
  5.  
  6.                      An IFF File format for interchanging
  7.                    musical data using Common Music Notation
  8.  
  9.                             by Talin (David Joiner)
  10.  
  11.                                   Verion 0.4
  12.  * ========================================================================= */
  13.  
  14. #ifndef CMUS_H
  15. #define CMUS_H
  16.  
  17. /* ========================================================================= *
  18.     Note to Non-Amiga users of this document
  19.     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  20.         CMUS is an IFF (Interchange File Format) file. IFF is a "Meta-standard"
  21.     for making extensible, self-identifying file formats, and was developed
  22.     by Commodore and Electronic Arts. In order to understand CMUS you will
  23.     need to get the IFF Documentation. The quickest way to do this is to
  24.     get the "Amiga ROM Kernal Manual: Devices" volume and look in the Appendix.
  25.  * ========================================================================= *
  26.     Note on Timing:
  27.     ~~~~~~~~~~~~~~~
  28.         Common Music Notation is a symbolic, rather than a literal
  29.     representation. It is supposed to be interpreted by the player. A note
  30.     which is listed as "A quarter note", will seldom be played at the exact
  31.     time or duration as written. These deviations from mathematically perfect
  32.     time are important; they are part of what musicians call "feel" or
  33.     "liveliness".
  34.         Accordingly, FORM CMUS has two different kinds of timing information.
  35.     _Formal Time_ is represented in symbolic form: Each symbol has a field
  36.     which indicates it's duration (dotted quarter-note, etc) in symbolic units.
  37.     The formal start time of an event can be obtained by summing the durations
  38.     of all the previous times in the measure.
  39.         In addition, there is also _Casual Time_. Each event has a "start time"
  40.     which is the number of basic clock units from the start of the measure to
  41.     the start of that event. Some event types also have "duration" fields of
  42.     a similar nature.
  43.         In general, although there will probably be a strong correlation
  44.     between formal time and casual time, there is no guarantee of this.
  45.     Certainly this FORM does not enforce any relationship between the two.
  46.     This means that you cannot, in general, derive one from the other. You can
  47.     at most make an educated guess, and even that is a non-trivial problem
  48.     from an algorithmic point of view.
  49.  
  50.  * ========================================================================= *
  51.     Note on Layout Measurements:
  52.     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  53.         In general, I have tried to make all measurements as "device-
  54.     independent" as possible.
  55.  
  56.         Measurements of page dimensions and other page-related information
  57.     such as margins and indentations are represented in micrometers.
  58.         Converting from micrometers to inches and "big points" (the definition
  59.     of points used by Adobe and Apple) can be done with the following
  60.     formulas:
  61.  
  62.         inches = micrometers / 25400;
  63.  
  64.         points = micrometers * 72 / 25400;
  65.  
  66.         Vertical distances of musical items are all measured in "Levels".
  67.     A level is one half the distance between the lines of a staff. A note on
  68.     the centerline of the staff is at level zero. Placing the note just above
  69.     that line (between the 2nd and 3rd staff line) makes it level 1, while
  70.     placing it below the centerline makes it level -1. Note that up is positive
  71.     in this coordinate system.
  72.         Note positions are recorded as a fraction of the measure width.
  73.  
  74.  * ========================================================================= *
  75.     Rules for clipboard use:
  76.     ~~~~~~~~~~~~~~~~~~~~~~~~
  77.         A CMUS chunk may be copied to the clipboard. In such cases, it is
  78.     possible that only a subset of the data might be written. Specifically,
  79.     measures and signatures which occur before the first selection point,
  80.     or after the last selection point should not be included. Note that
  81.     the measure containing the first selection point should be written,
  82.     however, even if it is not in the selection range itself. (As to whether
  83.     measure-lines are selectable is up to the application). In addition,
  84.     an initial time signature item for that measure should be written as
  85.     well; key signature and clef items are optional in this case. The
  86.     application receiving the clip has the option of whether to use the
  87.     signature items in the clip, or to ignore them and use the existing
  88.     signatures in the score. The application can also decide to "insert"
  89.     the clip into the score (causing existing other events to be shifted
  90.     later in time), or "merging" the events with the existing items.
  91.     The application can also choose to respect measure lines in the clip
  92.     (each new measure line causes the notes to be pasted into the next
  93.     measure) or to "flow" the notes across measure boundaries.
  94.         Note that the notes in a clip may be non-contiguous. For example,
  95.     If the user were to select every second note and copy those to the
  96.     clipboard, there would be "gaps" in the clipped track. Unfortunately,
  97.     a reader program would not be able to detect those gaps (since formal
  98.     time does not have an explicit start time) and thus the formal time
  99.     and the casual time would get out of sync. To avoid this problem,
  100.     "filler" events can be inserted into the score to fill up the empty space.
  101.     Note that the duration of a filler event is formal, unlike all the
  102.     other events.
  103.         Notation programs which only support contiguous selection (i.e.
  104.     can't have a deselected note between two selected notes) can ignore
  105.     filler items.
  106.         A filler event at the end of the measure is not neccessary.
  107.     In fact, there is no requirement in CMUS that a measure be "filled".
  108.     In addition, certain music programs allow more notes in a measure than
  109.     would legally fit (only while editing, the extra notes are never played).
  110.     CMUS readers should handle this case robustly.
  111.  
  112.         This allows a reader to make intelligent use of the clip. The clip
  113.     can be pasted relative to an insertion point, and the relationship of
  114.     notes to measures can be (optionally) preserved, even if the selection
  115.     was non-contiguous.
  116.  * ========================================================================= *
  117.     Future Directions
  118.     ~~~~~~~~~~~~~~~~~
  119.         A number of musical features are currently mising from the CMUS spec,
  120.     such as the ability for a track to jump from one staff to another. In
  121.     addition, there are a number of features which would be desirable on the
  122.     "page" level, such as seperate margins for each page (currently, there is
  123.     no representation of individual pages in the spec).
  124.         All of these things can easily be added by defining new IFF chunks
  125.     or new event types. I have not done this because I feel that these
  126.     additional features would best be designed by the person who needs them,
  127.     in other words someone designing a music product that requires such
  128.     features and is familiar with the issues inolved. Otherwise, the format
  129.     might be defined wrongly, missing subtle advantages which
  130. */
  131.  
  132. /* ========================================================================= *
  133.                              General Definitions
  134.  * ========================================================================= */
  135.  
  136. typedef long            Micrometers;
  137.  
  138. #if CM_MICRO_CONVERSION
  139.  
  140.     /* (optional) conversion to / from inches */
  141.  
  142. #define InchesToMicros(inches)  ((inches) * 25400)
  143. #define MicrosToInches(micros)  (((micros) + 12700) / 25400)
  144.  
  145. #define HundredthsToMicros(inches)  ((inches) * 254)
  146. #define MicrosToHundredths(micros)  (((micros) + 127) / 254)
  147.  
  148. #define PointsToMicros(points)  (((points) * 25400 + 36) / 72)
  149. #define MicrosToPoints(micros)  (((micros) * 72 + 12700) / 25400)
  150.  
  151. #endif
  152.  
  153. /* ========================================================================= *
  154.                            Score Header Chunk (SCHD)
  155.  * ========================================================================= */
  156.  
  157. typedef struct {
  158.     WORD                scBarsPerLine;      /* preferred bars per line      */
  159.     WORD                scOverallVolume;    /* overall volume of score      */
  160.  
  161.     Micrometers         scPageWidth,        /* width of page                */
  162.                         scPageHeight,       /* height of page               */
  163.                         scTopMargin,        /* top margin of score on page 1*/
  164.                         scFirstLineIndent,  /* left margin indent on line 1 */
  165.                         scLineIndent;       /* left indent on other lines   */
  166. } CM_ScoreHeader;
  167.  
  168. /* ========================================================================= *
  169.                             Staff Table Chunk (STAF)
  170.  
  171.    This section describes the data structures which are used in the CMUS 'STAF'
  172.    Chunk. There is one STFF chunk per score, which contains an array of
  173.    StaffEntry structres (1 per staff in the document).
  174.  
  175.  * ========================================================================= */
  176.  
  177. typedef struct {
  178.     WORD                staffFlags;         /* various flags                */
  179.  
  180.         /*  This defines the vertical size of a measure. Both of the distances
  181.             are measured from the center line of the staff (in fact all staff-
  182.             relative distances are represented this way).
  183.         */
  184.  
  185.     Micrometers         staffSpaceAbove,    /* space above staff            */
  186.                         staffSpaceBelow;    /* space below staff            */
  187.  
  188.     Micrometers         staffLevelSize;     /* distance between staff lines */
  189.  
  190. } CM_StaffEntry;
  191.  
  192.     /* This flag indicates that a formfeed should be done before printing
  193.         this staff (used when a score has more staffs than will fit on a page.
  194.     */
  195.  
  196. #define STAFF_PAGEBREAK (1<<0)
  197.  
  198.     /*  This indicates that the measure lines for this staff should not be
  199.         connected to the measure lines for the staff below
  200.     */
  201.  
  202. #define STAFF_BAR_BROKEN (1<<1)
  203.  
  204.     /*  This flag indicates that a set of "curly braces" should connect this
  205.         staff with the staff below.
  206.     */
  207.  
  208. #define STAFF_BRACED    (1<<2)              /* Staff is "braced" with next  */
  209.  
  210.     /*  These flags indicate the start and end of a square bracket which can
  211.         span over several staffs. The brace should start at the staff
  212.         marked with the "START" bit and continue until a staff with the
  213.         "END" bit is encountered.
  214.     */
  215.  
  216. #define STAFF_BRACKET_START (1<<3)
  217. #define STAFF_BRACKET_END   (1<<4)
  218.  
  219. /* ========================================================================= *
  220.                                Track Chunk (TRCK)
  221.  
  222.    This section describes the data structures which are used in the CMUS 'TRCK'
  223.    Chunk.
  224.  
  225.    A track is a sequence of notes which reside on a staff. In the simplest
  226.    case, there is one TRCK chunk per melody line in the score. However, a
  227.    track can contain chords, rests, etc, as well.
  228.  
  229.    A more precise definition of a track is that a track is a sequence of
  230.    chords, where all the notes within each chord have the same start time
  231.    and the same duration (in formal time of course; in casual time anything
  232.    is possible). Note that ties can be used to create the illusion of
  233.    having broken this rule.
  234.  
  235.  * ========================================================================= */
  236.  
  237. /*  Track Header structure:
  238.  
  239.     Each track begins with a track header structure, followed by any number
  240.     of score items. (Use the chunk length to determine when to stop reading
  241.     score items).
  242. */
  243.  
  244. typedef struct {
  245.     UWORD               trkStaff,           /* staff number to place this on*/
  246.                         trkTrack,           /* track number within staff    */
  247.                         trkFlags;           /* flags for staff header       */
  248.  
  249.         /*  Sometimes notes on the staff are written transposed from how they
  250.             should actually be played. This is the number that should be added
  251.             to the pitch before it is actually played back.
  252.         */
  253.  
  254.     WORD                trkTransposition;   /* playback transposition       */
  255.  
  256. } CM_TrackHeader;
  257.  
  258. /* ========================================================================= *
  259.                                       Track Item
  260.  * ========================================================================= */
  261.  
  262. /*  Item Header:
  263.  
  264.     Score items are variable in length. The first byte of the item is the
  265.     length of the item in WORDS. This will allow new item types to be added
  266.     in the future. All score items are an integer number of WORDS long.
  267.  
  268.     Each score item has a standard header structure, followed by a variable
  269.     amount of item-specific data. The 'itemType' field is used to determine what
  270.     that data is.
  271.  
  272.     'itemLength' is the length of the item in WORDS. This allows items to be
  273.     from 2 to 512 bytes long. (The value '0' is reserved as a special case).
  274.  
  275.     'itemXPos' contains the X position of the item in fractions of the measure's
  276.     width. Note that the area containing the signatures, and the area just
  277.     before the ending measure line are not considered part of this range.
  278.     Think of it this way: The value 0 is the first possible note position.
  279.     The value 0x7fff if the last possible note position. Items placed at
  280.     these positions should not run into the graphics at either the beginning
  281.     or the end of the measure. In addition, negative numbers are also
  282.     allows, which is used for symbols which penetrate into the "signature"
  283.     area. In this case, 0 represents the first possible note position, and
  284.     -0x8000 represents the actual barline. This convention is normally only
  285.     used for lyrics, which can intrude into the signature area.
  286.  
  287.     'itemStart' is used to represent the real starting time of each event.
  288.     This is recorded as a delta-time, in other words itemStart contains
  289.     how many clock ticks have elapsed between the current item and the item
  290.     before it. Note that because of the fact that events can sometimes occur
  291.     out of order (for example, notes in a chord can be ordered by pitch rather
  292.     than by time, and they might not all start at exactly the same clock),
  293.     this value can be negative.
  294.         In addition, the clock is reset at each measure boundary. In other
  295.     words, the length of a measure is determined only by it's time signature,
  296.     and not by the delta between the last note and the next measure line.
  297.     In fact, the itemStart field for measure line items is ignored and should
  298.     always be set to zero.
  299.         An item's start time does NOT have to exactly match the event's
  300.     "formal" time. For example, an event at the beginning of a measure does
  301.     not have to start at exactly time zero, but can be offset somewhat.
  302.     This allows the subtle nuances of a live performance to be preserved, if
  303.     the notation software allows for that capability.
  304.  
  305.     The 'itemStart' field (and the noteDuration field defined later) use a
  306.     clock standard of 960 clock ticks per whole note. Thus, a quarter note
  307.     is one/quarter that, or 240. This number is divisible by 3, 5, and several
  308.     powers of two, making it convenient for representing triplets and
  309.     quintuplets as well as small note values.
  310. */
  311.  
  312. typedef struct {
  313.     UBYTE               itemLength,         /* length of item in WORDS      */
  314.                         itemType;           /* type of item                 */
  315.     WORD                itemXPos;           /* horizontal position of item  */
  316.     WORD                itemStart;          /* start time, in ticks         */
  317. } CM_ItemHeader;
  318.  
  319. #define WHOLE_NOTE_DURATION     960         /* duration of a whole note     */
  320.  
  321. #define MAX_ITEM_XPOS   0x7fff
  322. #define MMIN_ITEM_XPOS  -0x8000
  323.  
  324.     /* type codes for chunk item types */
  325.  
  326. enum notation_item_types {
  327.     MEASURE_ITEM = 0,                       /* measure line                 */
  328.     SIGNATURE_ITEM,                         /* time sig., key sig., or clef */
  329.     NOTE_ITEM,                              /* first note in a chord        */
  330.     CHORD_ITEM,                             /* additional notes in a chord  */
  331.     FILLER_ITEM,                            /* fills up empty gaps          */
  332.     DYNAMIC_ITEM,                           /* dynamic volume item (fff)    */
  333.     INSTRUMENT_ITEM,                        /* instrument change item       */
  334.     TEMPO_ITEM,                             /* tempo change item            */
  335.     REPEAT_ITEM,                            /* for jumping around in score  */
  336.     BEGIN_GROUP_ITEM,                       /* begin slur, crescendo, etc.  */
  337.     END_GROUP_ITEM,                         /* end slur, crecendo, etc.     */
  338.     TABLATURE_ITEM,                         /* guitar or other tablature    */
  339. };
  340.  
  341. /* ========================================================================= *
  342.                                   Measure Line Item
  343.  * ========================================================================= */
  344.  
  345. /*  This item represents the beginning of a new measure. As such, there should
  346.     be one of these at the beginning of the track, but not at the end.
  347. */
  348.  
  349. typedef struct {
  350.     CM_ItemHeader       measureItem;        /* item header                  */
  351.     Micrometers         measureWidth;       /* width of measure             */
  352.     UBYTE               measureFlags;       /* various flags, see below     */
  353.  
  354.         /*  measureEnding: If non-zero, it means that this measure is part
  355.             of an ending block. The value indicates which ending this measure
  356.             is part of. For example, if the value = 1, then this measure
  357.             is only played the first time through, if the value = 2 then
  358.             it is only played the second time through.
  359.  
  360.             Each "repeat" section in the score can have it's own set of
  361.             endings.
  362.  
  363.             "Endings" can be longer than one measure. Each measure that
  364.             is encountered that has the same value of measureEnding as the
  365.             previous measure is considered part of the same ending.
  366.         */
  367.  
  368.     UBYTE               measureEnding;      /* "ending" this measure is in  */
  369. } CM_Measure;
  370.  
  371. #define MEASURE_FULL_WIDTH 0x7fff           /* full width of score          */
  372.  
  373. enum measureFlags {
  374.  
  375.         /*  Draw a double bar at the end of this measure. The reason for
  376.             associating the double-bar flag with the next measure line is
  377.             because double bar can occur at the end of the score but not
  378.             at the beginning.
  379.         */
  380.     MEASUREF_DOUBLE_BAR = (1<<0),
  381.  
  382.         /*  This is a "line break", in other words it indicates that this
  383.             measure should start a new line.
  384.         */
  385.  
  386.     MEASUREF_NEW_LINE   = (1<<1),
  387.  
  388.         /*  If set, this flags means that the measure width was set by the
  389.             user. It not set, it means that measure width was calculated on
  390.             the fly, and can be re-adjusted feely if needed to line things
  391.             up. Note that this width includes signatures, but does not include
  392.             any indentation from the left margin of the document.
  393.         */
  394.  
  395.     MEASUREF_FIXED      = (1<<2),
  396.  
  397. };
  398.  
  399. /* ========================================================================= *
  400.                                Signature Items
  401.  * ========================================================================= */
  402.  
  403.     /*  Signature items are usually placed just after the measure line.
  404.  
  405.         Some notators have the ability to change clef in the middle of a
  406.         measure, but not all notators need support this. If it is not
  407.         supported, and a clef is encountered in the middle of a measure, it
  408.         is assumed to apply to the entire measure and therefore is associated
  409.         with the previous measure line.
  410.     */
  411.  
  412.     /*  Signature types: Each signature has a "sigSubType" field which
  413.         indicates the type of signature. In addition, the high bit of the
  414.         signature type field indicates that the signature should not be
  415.         shown visibly.
  416.     */
  417.  
  418. enum SignatureTypes {
  419.     SIGTYPE_TIMESIG=1,
  420.     SIGTYPE_CLEF,
  421.     SIGTYPE_MAJORKEY,
  422.     SIGTYPE_MINORKEY,
  423.  
  424.     SIGTYPE_HIDDEN=(1<<7)
  425. };
  426.  
  427.     /*  Stores a time signature. 'Beats' is the number above the line, and
  428.         'Notes' is the number below the line. For example, '3/4' time is
  429.         stored as beats = 3, notes = 4.
  430.  
  431.         "Common Time" (The "C" symbol) which is equivalent to 4/4 is stored
  432.         as 4/0 (beats = 4, notes = 0).
  433.  
  434.         "Cut Time" ("C" with a slash through it) which is equivalent to
  435.         2/4 is stored as 2/0 (beats = 2, notes = 0).
  436.  
  437.         In other words, the value "0" in "sigNotes" should always be treated
  438.         as the value "4" when calculating measure lengths. See the
  439.         MEASURE_LENGTH macro for an example of this.
  440.     */
  441.  
  442. typedef struct {
  443.     CM_ItemHeader       sigItem;            /* item header                  */
  444.     UBYTE               sigSubType,         /* (= SIGTYPE_TIMESIG)          */
  445.                         sigBeats,           /* beats per bar                */
  446.                         sigNotes,           /* size of each beat            */
  447.                         sigPad;
  448. } CM_TimeSignature;
  449.  
  450.     /* compute the measure length in clock ticks */
  451.  
  452. #define MEASURE_LENGTH(beats, notes) \
  453.     (WHOLE_NOTE_DURATION * beats / (notes ? notes : 4))
  454.  
  455.     /* stores a Clef */
  456.  
  457. typedef struct {
  458.     CM_ItemHeader       sigItem;            /* item header                  */
  459.     UBYTE               sigSubType;         /* (= SIGTYPE_CLEF)             */
  460.     UBYTE               sigClef;            /* new clef                     */
  461. } CM_Clef;
  462.  
  463.     /*  Definitions of clef types. Note clef modifier bits which are used as
  464.         part of this field as well.
  465.     */
  466.  
  467. enum ClefTypes {
  468.     TREBLE_CLEF = 0,                        /* G clef in normal position    */
  469.     BASS_CLEF,                              /* F clef in normal position    */
  470.     ALTO_CLEF,                              /* C clef centered on line 3    */
  471.     TENOR_CLEF,                             /* C clef centered on line 2    */
  472.  
  473.         /* optional clefs, some of which are obselete (in the U.S.) */
  474.  
  475.     SOPRANO_CLEF,                           /* C clef centered on line 5    */
  476.     MEZZO_SOPRANO_CLEF,                     /* C clef centered on line 4    */
  477.     BARITONE_CLEF,                          /* F clef one line lower        */
  478.     FRENCH_VIOLIN_CLEF,                     /* G clef one line lower        */
  479.  
  480.         /*  For drum scores. One of the things implied by a drum clef is that
  481.             there might not be a relationship between a note's vertical
  482.             position and it's MIDI note number, unlike other clef types.
  483.             (This could be especially handy for work with MIDI drum machines).
  484.         */
  485.  
  486.     DRUM_CLEF,                              /* vertical lines or box        */
  487.  
  488.         /* clef modifier bits: A clef can be raised or lowered by one or two
  489.             octaves. This is notated by placing a small "8" or "15" above or
  490.             below the clef.
  491.         */
  492.  
  493.     CLEF_DOWN_1_OCTAVE=(1<<4),              /* clef 1 oct lower (8 below)   */
  494.     CLEF_DOWN_2_OCTAVES=(1<<5),             /* clef 2 oct lower (15 below)  */
  495.     CLEF_UP_1_OCTAVE=(1<<6),                /* clef 1 oct higher (8 above)  */
  496.     CLEF_UP_2_OCTAVE=(1<<7),                /* clef 2 oct higher (15 above) */
  497. };
  498.  
  499.     /*  stores a Key Signature. (used for both major and minor)
  500.  
  501.         'sigKeySig' is a signed BYTE, where '0' is the key of C. Positive
  502.         numbers represent the number of sharps, so 1=G, 2=D, etc, around the
  503.         circle of fifths. Negative numbers represent the number of flats,
  504.         F=-1, B-Flat = -2, etc.
  505.  
  506.         For minor keys, 0 is the key of A-minor, which like C has no sharps
  507.         or flats.
  508.  
  509.         Other types of key signatures may be supported in the future, but
  510.         will probably be done as a different type of signature item.
  511.     */
  512.  
  513. typedef struct {
  514.     CM_ItemHeader       sigItem;            /* item header                  */
  515.     UBYTE               sigSubType;         /* (== SIGTYPE_KEYSIG)          */
  516.     BYTE                sigKeySig;          /* new key signature            */
  517. } CM_KeySignature;
  518.  
  519.     /* major key definitions */
  520.  
  521. #define KEY_OF_C_MAJOR           0
  522. #define KEY_OF_G_MAJOR           1
  523. #define KEY_OF_D_MAJOR           2
  524. #define KEY_OF_A_MAJOR           3
  525. #define KEY_OF_E_MAJOR           4
  526. #define KEY_OF_B_MAJOR           5
  527. #define KEY_OF_F_SHARP_MAJOR     6
  528. #define KEY_OF_C_SHARP_MAJOR     7
  529. #define KEY_OF_F_MAJOR          -1
  530. #define KEY_OF_B_FLAT_MAJOR     -2
  531. #define KEY_OF_E_FLAT_MAJOR     -3
  532. #define KEY_OF_A_FLAT_MAJOR     -4
  533. #define KEY_OF_D_FLAT_MAJOR     -5
  534. #define KEY_OF_G_FLAT_MAJOR     -6
  535. #define KEY_OF_C_FLAT_MAJOR     -7
  536.  
  537.     /* minor key definitions */
  538.  
  539. #define KEY_OF_A_MINOR           0
  540. #define KEY_OF_E_MINOR           1
  541. #define KEY_OF_B_MINOR           2
  542. #define KEY_OF_F_SHARP_MINOR     3
  543. #define KEY_OF_C_SHARP_MINOR     4
  544. #define KEY_OF_G_SHARP_MINOR     5
  545. #define KEY_OF_D_SHARP_MINOR     6
  546. #define KEY_OF_A_SHARP_MINOR     7
  547. #define KEY_OF_D_MINOR          -1
  548. #define KEY_OF_G_MINOR          -2
  549. #define KEY_OF_C_MINOR          -3
  550. #define KEY_OF_F_MINOR          -4
  551. #define KEY_OF_B_FLAT_MINOR     -5
  552. #define KEY_OF_E_FLAT_MINOR     -6
  553. #define KEY_OF_A_FLAT_MINOR     -7
  554.  
  555. /* ========================================================================= *
  556.                               Note or Chord item
  557.  * ========================================================================= */
  558.  
  559.     /*  Note Items.
  560.  
  561.         CHORDS: The first note of a chord is always of type "note".
  562.         Additional notes, or "intervals" are stored using the "chord"
  563.         type. The itemXPos, noteTuple, noteDots, noteDivision, noteStyle,
  564.         noteArpeggio, noteTrill and and noteBeamHeight fields are ignored
  565.         for chord items and are derived from the base note, however score
  566.         writers should set them to the same as the base note for consistency.
  567.  
  568.         RESTS: A rest is a note item with a notePitch of 255. Rests may not
  569.         be chorded.
  570.  
  571.         DRUM HEADS: If the NOTEF_DRUM flag is set, indicating that the
  572.         note has a "drum head" rather than an ordinary note head, then
  573.         all of the pitch-modifier fields should be ignored.
  574.  
  575.         OPTIONAL FIELDS: For less sophisticated programs, many of the fields
  576.         in the note structure can be ignored.
  577.             At a minimum, notation programs should look at noteLevel,
  578.         noteAccidental, noteDivision and noteDots. When writing, all other
  579.         fields can be set to zero, with the exception of noteDuration
  580.         which should be set to the formal duration of the note in clock
  581.         ticks.
  582.             Sequencer programs should look at notePitch and noteDuration
  583.         when loading CMUS scores. Writing is more difficult. It is suggested
  584.         that unless the program is very sophisticated, that a different
  585.         FORM, or perhaps a Standard MIDI File, be used for writing out
  586.         sequencer data, as most of the fields in CMUS have meaning only to
  587.         a notator-type program.
  588.  
  589.         Explanation of Fields:
  590.         ~~~~~~~~~~~~~~~~~~~~~~
  591.  
  592.         noteDuration -- The casual duration of the note.
  593.  
  594.         noteFlags -- various flags which affect either this note. Note that
  595.             the NOTEF_TIED and NOTEF_TIEDOWN can be different for each
  596.             note in a chord.
  597.  
  598.         noteDots: 0, 1 or 2 depending on the number of "dots" this note
  599.             has. A dotted note is 50% longer. A double-dotted note is
  600.             75% longer.
  601.  
  602.         noteDivision: Indicates the base duration of the note: whole note,
  603.             half note, quarter note, etc.
  604.  
  605.         notePitch: The MIDI pitch number for this note.
  606.  
  607.         noteArpeggio: Indicates an arpeggiated chord, one where the individual
  608.             notes are played sequentially (like a harp).
  609.  
  610.         noteTrill: Trills are a rapid alternation between two notes. There
  611.             are vaious kinds, see below.
  612.  
  613.         noteAccidental: This includes things like sharps and flats.
  614.  
  615.         noteLevel: This is the distance, in levels, from the center line of
  616.             the staff.
  617.  
  618.         noteBeamHeight: The height of a beamed group of notes isn't always
  619.             related to the height that the stem would be if the note were not
  620.             beamed. This field is the distance, in levels, from the center
  621.             line of the staff to the beam's position. This field is only
  622.             meaningful for the first and last note of a beam.
  623.  
  624.         noteStyle: This is a field of flags which indicate things like
  625.             Staccato, Legato, and other "performance style" modifiers.
  626.     */
  627.  
  628. /*  What the note structure looks like with bitfields:
  629.  
  630.     CM_ItemHeader       noteItem;           -- item header
  631.  
  632.     UWORD               noteDuration;       -- real duration, in ticks
  633.     UWORD               noteFlags;
  634.  
  635.     unsigned int        Pad1           : 2
  636.                         noteDots       : 2, -- dotted, double-dotted
  637.                         noteDivision   : 4, -- quarter note, etc.
  638.  
  639.     UBYTE               notePitch;          -- MIDI note number
  640.     unsigned int        noteArpeggio   : 2, -- arpeggiation
  641.                         noteTrill      : 3, -- various trill types
  642.                         noteAccidental : 3; -- sharp, flat, etc.
  643.  
  644.     BYTE                noteLevel;          -- dist from staff centerline
  645.     BYTE                noteBeamHeight;     -- Y position of beam
  646.     UBYTE               noteStyle;          -- Note Style type
  647. */
  648.  
  649. typedef struct {
  650.     CM_ItemHeader       noteItem;           /* item header                  */
  651.  
  652.     UWORD               noteDuration;       /* real duration, in ticks      */
  653.     UWORD               noteFlags;          /* various note flags           */
  654.  
  655.     UBYTE               noteDivision;       /* formal note length           */
  656.  
  657.     UBYTE               notePitch;          /* MIDI note number             */
  658.     UBYTE               notePitchMods;      /* modifications to pitch       */
  659.     BYTE                noteLevel;          /* vertical position            */
  660.  
  661.     BYTE                noteBeamHeight;     /* y position of beam           */
  662.     UBYTE               noteStyle;          /* Note Style type              */
  663. } CM_Note;
  664.  
  665.     /* macros to access the various bitfields */
  666.  
  667. #define CM_NoteDots(f)          (((f).noteDivision >> 4) & 0x03)
  668. #define CM_NoteDivision(f)      ((f).noteDivision & 0x0f)
  669.  
  670. #define CM_NoteAccidental(f)    ((f).notePitchMods & 7)
  671. #define CM_NoteTrill(f)         (((f).notePitchMods >> 3) & 7)
  672. #define CM_NoteArpeggiation(f)  (((f).notePitchMods >> 6) & 3)
  673.  
  674. #define CM_SetNoteDivision(note, division, dots) \
  675.         ((note).noteDivision = (dots << 4) | division)
  676.  
  677. #define CM_SetNotePitchMods(note, arp, trill, accidental) \
  678.         ((note).notePitchMods = (arp << 6) | ((trill << 3) & 7) | (accidental & 7))
  679.  
  680. #define CM_RestPitch    255
  681.  
  682. enum note_dots {
  683.     NO_DOT = 0,                             /* Note is normal duration      */
  684.     DOTTED_NOTE = 1,                        /* Note is 50% longer           */
  685.     DOUBLE_DOTTED = 2                       /* note is 75% longer           */
  686. };
  687.  
  688. enum note_divisions {
  689.     DOUBLE_WHOLE_NOTE = 0,
  690.     WHOLE_NOTE,
  691.     HALF_NOTE,
  692.     QUARTER_NOTE,
  693.     EIGHTH_NOTE,
  694.     SIXTEENTH_NOTE,
  695.     NOTE_32,
  696.     NOTE_64,
  697.     NOTE_128,
  698.     NOTE_256
  699. };
  700.  
  701. enum note_accidentals {
  702.     NOTE_ACC_NONE=0,
  703.     NOTE_ACC_DOUBLE_FLAT,
  704.     NOTE_ACC_FLAT,
  705.     NOTE_ACC_HALF_FLAT,
  706.     NOTE_ACC_NATURAL,
  707.     NOTE_ACC_HALF_SHARP,
  708.     NOTE_ACC_SHARP,
  709.     NOTE_ACC_DOUBLE_SHARP,
  710.  
  711.         /*  drum styles: used in place of accidental when NOTEF_DRUM is set.
  712.             Hollow symbols are used in place of "hollow" note heads, such
  713.             as half notes.
  714.  
  715.             Note that the assignment of drum parts to symbols is arbtrary,
  716.             however the X symbol in jazz notation means "brush", and the
  717.             triangle symbol is often assigned to the triangle instrument.
  718.             Note also that normal note heads are often used for many
  719.             drum instruments.
  720.         */
  721.  
  722.     NOTE_DRUM_X=0,                          /* An "x" instead of note head  */
  723.     NOTE_DRUM_DIAMOND,                      /* diamond shape                */
  724.     NOTE_DRUM_SQUARE,                       /* square box                   */
  725.     NOTE_DRUM_TRIANGLE,                     /* triangle                     */
  726.  
  727. };
  728.  
  729.     /*  trills and tremolos and other pitch modulations which can be attached
  730.         to a note. Note that these apply to the entire chord.
  731.     */
  732.  
  733. enum note_trills {
  734.     NOTE_PMOD_NONE=0,
  735.     NOTE_PMOD_TRILL,
  736.     NOTE_PMOD_MORDENT,
  737.     NOTE_PMOD_INV_MORDENT,
  738.     NOTE_PMOD_TURN,
  739. };
  740.  
  741.     /*  Arpeggiation, indicated as a vertical sqiggly line before the chord */
  742.  
  743. enum note_arp_mods {
  744.     NOTE_ARPEGGIO = 1,
  745.     NOTE_REV_ARPEGGIO = 2,
  746. };
  747.  
  748.     /* note style flags */
  749.  
  750. #define NSTYLEF_STACCATO        (1<<0)      /* Staccatto mark ('.')         */
  751. #define NSTYLEF_STACCATISSIMO   (1<<1)      /* Staccattissimo mark (wedge)  */
  752. #define NSTYLEF_LEGATO          (1<<2)      /* Legato ('-')                 */
  753. #define NSTYLEF_SFORZANDO       (1<<3)      /* Szorzando ('^')              */
  754. #define NSTYLEF_ACCENT          (1<<4)      /* Accent ('>')                 */
  755. #define NSTYLEF_TENUTO          (1<<5)      /* Tenuto (short '-')           */
  756.  
  757.     /* general note flags */
  758.  
  759. enum noteFlags {
  760.     NOTEF_STEMDOWN      = (1<<0),           /* Note's stem is down          */
  761.     NOTEF_BEAMED        = (1<<1),           /* Note is beamed with next note*/
  762.     NOTEF_TIED          = (1<<2),           /* Note is tied with next note  */
  763.     NOTEF_TIEDOWN       = (1<<3),           /* tie direction is DOWN        */
  764.     NOTEF_GRACE         = (1<<4),           /* display as grace note        */
  765.     NOTEF_CUE           = (1<<5),           /* display as cue note          */
  766.     NOTEF_DRUM          = (1<<6),           /* note has a drum head         */
  767.     NOTEF_STEMSET       = (1<<7),           /* Stem direction fixed by user */
  768.  
  769.     NOTEF_RES1          = (1<<12),          /* reserved by DMCS for play    */
  770.     NOTEF_RES2          = (1<<13),          /*      styles (sorry :-)       */
  771.     NOTEF_RES3          = (1<<14),
  772.     NOTEF_RES4          = (1<<15),
  773. };
  774.  
  775. /* ========================================================================= *
  776.                                  Filler item
  777.  * ========================================================================= */
  778.  
  779.     /*  This item is used for supporting sparse clips. The fillerDuration
  780.         field contains the total of the formal durations of the missing
  781.         items between the previous event and the next one.
  782.     */
  783.  
  784. typedef struct {
  785.     CM_ItemHeader       fillerItem;         /* item header                  */
  786.     UWORD               fillerDuration;     /* formal size of items left out*/
  787. } CM_Filler;
  788.  
  789. /* ========================================================================= *
  790.                                  Dynamic Item
  791.  * ========================================================================= */
  792.  
  793.     /*  This item specifies a MIDI volume. Note that the relationship between
  794.         Volume and dynamic markings (such as fff, pp, etc) is defined
  795.         elsewhere.
  796.     */
  797.  
  798. typedef struct {
  799.     CM_ItemHeader       dynItem;            /* item header                  */
  800.     BYTE                dynLevelPos;        /* vertical position in leveks  */
  801.     UBYTE               dynVolume;          /* midi pressure number (0..127)*/
  802.     BYTE                dynSymbol;          /* dynamic symbol, see below    */
  803.     UBYTE               dynPad;
  804. } CM_Dynamic;
  805.  
  806.     /*  Dynamic symbols:
  807.  
  808.         0 = symbol not specified, derive from MIDI volume.
  809.         +1 = mf         -1 = mp
  810.         +2 = f          -2 = p
  811.         +3 = ff         -3 = pp
  812.         +4 = fff        -4 = ppp
  813.                 (etc)
  814.     */
  815.  
  816. /* ========================================================================= *
  817.                                Instrument item
  818.  * ========================================================================= */
  819.  
  820.     /*  Rather than embedding the instrument names in the actual score, a
  821.         seperate "instrument table" chunk will be defined.
  822.     */
  823.  
  824. typedef struct {
  825.     CM_ItemHeader       instItem;           /* instrument item              */
  826.     UBYTE               instNumber;         /* instrument number from table */
  827.     UBYTE               instPad;
  828. } CM_Instrument;
  829.  
  830. /* ========================================================================= *
  831.                                   Tempo Item
  832.  * ========================================================================= */
  833.  
  834.     /*  For compatibility with Standard MIDI files, tempo is represented as
  835.         microseconds per quarter note, rather than the more commonly used
  836.         quarter notes per minute. To convert from one to the other, the
  837.         following formula works both ways:
  838.  
  839.                 T = 60,000,000 / t;
  840.  
  841.         For accuracy, you may want to round:
  842.  
  843.                 T = (60,000,000 + t/2) / t;
  844.  
  845.         Of course, the user interface of the program should not use units
  846.         like this.
  847.     */
  848.  
  849. typedef struct {
  850.     CM_ItemHeader       tempoItem;          /* item header                  */
  851.     ULONG               tempoValue;         /* new tempo value              */
  852. } CM_Tempo;
  853.  
  854. /* ========================================================================= *
  855.                                  Repeat Item
  856.  * ========================================================================= */
  857.  
  858.     /*  This is a general category of items for jumping around in the
  859.         score in a non-sequential fashion. It includes things like
  860.         begin/end repeat bars, repeat measure, Da Capo, etc.
  861.  
  862.         "repeatCount" is the number of times that the jump should occur,
  863.         not the total number of times a passage should be played. For example,
  864.         an begin/end repeat which is to play twice (once through, and then
  865.         prepeated once) should have a repeatCount of "1".
  866.  
  867.         In addition, repeatCount should be associated with the jump rather
  868.         than the label. This imples that the count should go with the
  869.         "end" of a begin/end block rather than the "begin".
  870.     */
  871.  
  872. typedef struct {
  873.     CM_ItemHeader       repeatItem;         /* item header                  */
  874.     UBYTE               repeatType;         /* subtype of group             */
  875.     UBYTE               repeatCount;        /* number of times to jump      */
  876. } CM_Repeat;
  877.  
  878. enum repeat_types {
  879.     REPEAT_BLOCK_BEGIN=0,                   /* defines a repeat block       */
  880.     REPEAT_BLOCK_END,
  881.  
  882.     REPEAT_LAST_MEASURE,                    /* jumps back 1 measure         */
  883.     REPEAT_LAST_TWO_MEASURES,               /* jumps back 2 measures        */
  884.  
  885.     REPEAT_MEASURE_REST,                    /* rest for N measures          */
  886.                                             /* (not really a jump)          */
  887.         /* labels to go to */
  888.  
  889.     REPEAT_LABEL_SEGNO,                     /* The "sign" D.S. refers to    */
  890.     REPEAT_LABEL_CODA,                      /* The Coda symbol              */
  891.  
  892.         /* goto operators */
  893.  
  894.     REPEAT_DC,                              /* D.C.                         */
  895.     REPEAT_DC_AL_FINE,                      /* D.C. al fine                 */
  896.     REPEAT_DS,                              /* D.S.                         */
  897.     REPEAT_DS_AL_FINE,                      /* D.S. al fine                 */
  898.     REPEAT_DS_AL_CODA,                      /* D.S. al coda                 */
  899. };
  900.  
  901. /* ========================================================================= *
  902.                                    Group Item
  903.  * ========================================================================= */
  904.  
  905.     /*  A "Group" Item is defined as a Slur, Crescendo, or Octave Raiser.
  906.         In general, groups can apply to any contiguous range of notes
  907.         on a track, and groups of the same type can note overlap.
  908.  
  909.         Note that in some cases, such as for example a crecendo, although
  910.         the modification is technically "attached" to a particular
  911.         track, it affects all the tracks on that staff.
  912.     */
  913.  
  914. typedef struct {
  915.     CM_ItemHeader       groupItem;          /* item header                  */
  916.     UBYTE               groupType;          /* subtype of group             */
  917.  
  918.         /*  To even out the structure, we'll add an extra byte which means
  919.             different things based on the group type. Right now it is
  920.             only defined in the case of a crescendo / decrescendo in which
  921.             case it means the final volume.
  922.  
  923.             For all others, it should be set to zero.
  924.         */
  925.  
  926.     UBYTE               groupVal;
  927. } CM_Group;
  928.  
  929.     /* Types of group items supported */
  930.  
  931. enum group_types {
  932.     GROUPTYPE_SLUR_UP=0,
  933.     GROUPTYPE_SLUR_DOWN,
  934.     GROUPTYPE_CRESCENDO,
  935.     GROUPTYPE_DECRESCENDO,
  936.     GROUPTYPE_OCTAVE_UP,                    /* "8va" symbol                 */
  937.     GROUPTYPE_OCTAVE_DOWN,                  /* "8vb" symbol                 */
  938.     GROUPTYPE_GLISSANDO_UP,
  939.     GROUPTYPE_GLISSANDO_DOWN,
  940.  
  941.     GROUPTYPE_TUPLET,                       /* see below                    */
  942.     GROUPTYPE_TRILL,                        /* the one with the wavy line   */
  943.     GROUPTYPE_TREMOLO,                      /* Slashes below a beam         */
  944. };
  945.  
  946.     /* Tuplets are a subtype of group items, and as such have an extended
  947.         structure. Unlike other group types, tuplet group items can be nested.
  948.  
  949.         Note that for ending a tuplet, the extra fields are not required
  950.         and a normal "Group" structure can be used. Each tuplet ending
  951.         item matches the nearest previous unmatched tuplet item.
  952.     */
  953.  
  954. typedef struct {
  955.     CM_ItemHeader       tupletItem;         /* item header                  */
  956.     UBYTE               tupletType;         /* subtype of group             */
  957.  
  958.         /*  tupletNumber indicates how many notes can fit in the space of
  959.             'tupletSpace'. For example, a triplet, i.e. "3 in the space of 2",
  960.             or 2/3 duration, can be represented as tupletNumber = 3,
  961.             tupletSpace = 2.
  962.         */
  963.  
  964.     UBYTE               tupletNumber,       /* How manu items               */
  965.                         tupletSpace;        /* in the space of how many     */
  966.  
  967.         /*  tupletDigits represents the binary number which should be
  968.             displayed above the tuplet; For example, for a triplet this
  969.             should be 3.
  970.         */
  971.  
  972.     UBYTE               tupletDigits;       /* number to display            */
  973.  
  974.         /*  tupletFlags is for later use when we want tuplets combined with
  975.             slurs / brackets. Currently there are no flags defined, so the
  976.             field should be all zeroes.
  977.         */
  978.  
  979.     UBYTE               tupletFlags,        /* various flags                */
  980.                         tupletPad;
  981. } CM_Tuplet;
  982.  
  983. /* ========================================================================= *
  984.                                     Tablature Item
  985.  * ========================================================================= */
  986.  
  987.     /*  The Tablature item is used for guitar, banjo or other fretted
  988.         instruments. It's a two-dimensional array of bits, which is drawn
  989.         as a grid indicating the exact placement of fingers.
  990.  
  991.         In addition, most tablatures have the name of the chord placed above
  992.         the grid. This can be quite complex, looking something like this:
  993.  
  994.                      7+6
  995.                 C min
  996.  
  997.         Which means: "C minor, with an added seventh and a raised sixth".
  998.     */
  999.  
  1000. typedef struct {
  1001.     CM_ItemHeader       tabItem;            /* item header                  */
  1002.  
  1003.         /*  tabRoot is used to indicate the name of the chord placed above
  1004.             the tablature. Note that the root can have superscripts, which
  1005.             are defined elsewhere.
  1006.  
  1007.             unsigned int    rootLetter      : 3,    -- A, B, C, etc.
  1008.                             rootAccidental  : 2,    -- accidental of root
  1009.                             rootType        : 3,    -- major, minor, etc.
  1010.         */
  1011.  
  1012.     UBYTE               tabRoot;            /* describes root of chord      */
  1013.  
  1014.         /*  tabDimensions is a field of two 4 bit values, representing the
  1015.             width and height of the tablature array. A dimension of (0,0)
  1016.             indicates that only the chord symbol should be used.
  1017.         */
  1018.  
  1019.     UBYTE               tabDimensions;      /* width/height of tab array    */
  1020.  
  1021.         /*  tabIntervals is an optional field -- if it's zero, it means that
  1022.             the writing program wasn't sophisticated enough to set it.
  1023.             (This is generally true for programs that are typographical
  1024.             rather than musical in orientation).
  1025.  
  1026.             The field used to exactly describe the intervals in the
  1027.             chord above the root. Each interval may be:
  1028.  
  1029.                 0 - missing ( no interval)
  1030.                 1 - lowered ( one half-step below major chord position )
  1031.                 2 - normal  ( in the normal position for a major chord )
  1032.                 3 - raised  ( one half-step above major chord position )
  1033.  
  1034.             unsigned int    chordThird      : 2,    -- (missing, -1, 0, +1)
  1035.                             chordFifth      : 2,    -- (missing, -1, 0, +1)
  1036.                             chordSeventh    : 2,    -- (missing, -1, 0, +1)
  1037.                             chordNinth      : 2,    -- (missing, -1, 0, +1)
  1038.                             chordEleventh   : 2,    -- (missing, -1, 0, +1)
  1039.                             chordThirteenth : 2,    -- (missing, -1, 0, +1)
  1040.                             chordFifteenth  : 2,    -- (missing, -1, 0, +1)
  1041.                             chordValid      : 1,    -- TRUE if field valid
  1042.                             chordPad        : 1;
  1043.         */
  1044.  
  1045.     UWORD               tabIntervals;       /* describes exact chord intervals*/
  1046.  
  1047.         /*  tabArray is a byte array of finger positions.
  1048.  
  1049.             Each byte represents a string. The value of the byte
  1050.             can be from 0 (representing an open string), or 1-16
  1051.             (representing a finger placed above the Nth fret). The high
  1052.             4 bits are reserved for now, but may be used later to indicate
  1053.             special placement of the fingers.
  1054.  
  1055.             Note that the tabArray can be longer or shorter than 6 bytes,
  1056.             up to a maximum of 16 strings. In such cases, the event length
  1057.             stored in the CM_ItemHeader would be adjusted accordingly.
  1058.         */
  1059.  
  1060.     UBYTE               tabArray[6];        /* tablature array              */
  1061.  
  1062.         /*  Following the tabArray field is an optional variable-length
  1063.             ASCII string which is the actual text of the superscript,
  1064.             such as "maj6+7".
  1065.  
  1066.             The length of the string can be computed comparing the end of
  1067.             the event with the end of the tab-array. Null termination is
  1068.             not required.
  1069.         */
  1070.  
  1071. };
  1072.  
  1073. enum chord_accidentals {
  1074.     CHORD_ACC_NONE=0,
  1075.     CHORD_ACC_FLAT,
  1076.     CHORD_ACC_NATURAL,
  1077.     CHORD_ACC_SHARP
  1078. };
  1079.  
  1080. enum chord_types {
  1081.     CHORD_TYPE_MAJOR,
  1082.     CHORD_TYPE_MINOR,
  1083.     CHORD_TYPE_DIMINISHED,
  1084.     CHORD_TYPE_AUGMENTED,
  1085.     CHORD_TYPE_SUSPENDED
  1086. };
  1087.  
  1088. enum chord_letters {
  1089.     CHORD_LETTER_A=0,
  1090.     CHORD_LETTER_B,
  1091.     CHORD_LETTER_C,
  1092.     CHORD_LETTER_D,
  1093.     CHORD_LETTER_E,
  1094.     CHORD_LETTER_F,
  1095.     CHORD_LETTER_G
  1096. };
  1097.  
  1098. /* ========================================================================= *
  1099.                            Lyric Font Chunk (LFON)
  1100.  
  1101.     This section describes the data structures which are used in the CMUS
  1102.     'LFON' Chunk.
  1103.  
  1104.     LFON chunks are used to store the font table for the document. Embedded
  1105.     within the Lyric, Annotation and title chunks are font specifiers which
  1106.     refer to a given font by number. That number is an index into this table.
  1107.  
  1108.     There is one LFON chunk per font. Each LFON chunk consists of the following
  1109.     header, and then the name of the font. The terminating NULL should be
  1110.     included in the font name.
  1111.  
  1112.  * ========================================================================= */
  1113.  
  1114. typedef struct {
  1115.     UWORD               fontNumber;             /* number assigned to font  */
  1116.     UWORD               fontHeight;             /* height of font in points */
  1117.  
  1118.     /* fontName follows */
  1119.  
  1120. } CM_FontEntry;
  1121.  
  1122. /* ========================================================================= *
  1123.                               Lyric Chunk (LYRC)
  1124.  
  1125.     This section describes the data structures which are used in the CMUS
  1126.     'LYRC' Chunk.
  1127.  
  1128.     Each lyric is associated with a particular track, and a particular measure
  1129.     within that track. The reason for this is because certain elements within
  1130.     the lyrics can be "attached" to notes within a track, so that syllables
  1131.     of the lyric can properly appear under the notes.
  1132.  
  1133.     Lyrics associated with a particular track are written immediately after
  1134.     that track. In other words, when reading a lyric, it should be associated
  1135.     with the previously read track.
  1136.  
  1137.  * ========================================================================= */
  1138.  
  1139.     /*  This is the header structure for a lyric. It is followed by the actual
  1140.         text of the lyric. No terminating NUL is used.
  1141.  
  1142.         Attaching syllables to notes: This is an optional feature which need
  1143.         not be supported by all readers. Basically, the TAB character is used
  1144.         to specify a block of text to align with the next note. Essentially,
  1145.         each chord on the track acts as a center-justified tab-stop. This is
  1146.         similar to the way tab stops work on medium- to high-end word
  1147.         processors: All the text between a tab, and the next tab (or the end
  1148.         of the line) is "centered" at the tab-stop position. Readers
  1149.         which don't wish to deal with this level of complexity can just
  1150.         treat the tab as a space.
  1151.     */
  1152.  
  1153. typedef struct {
  1154.     UWORD               lyricMeasure;       /* starting measure of lyric    */
  1155.  
  1156.         /*  Position of the upper-left coordinate of the lyric.
  1157.             This can be positive or negative, and is interpreted just like
  1158.             the 'itemXPos' field for track events.
  1159.         */
  1160.  
  1161.     WORD                lyricXPos;          /* position relative to measure */
  1162.  
  1163.         /*  lyricLevel is the position, in micrometers, of the upper-
  1164.             left corner of the lyric's extent box.
  1165.  
  1166.             lyricHeight is also in micrometers.
  1167.         */
  1168.  
  1169.     Micrometers         lyricLevel,         /* distance from center of staff*/
  1170.                         lyricHeight;        /* height of lyric extent       */
  1171.  
  1172.         /*  Width is in micrometers. */
  1173.  
  1174.     Micrometers         lyricWidth;
  1175.  
  1176.         /* lyric text string follows */
  1177.  
  1178. } CM_Lyric;
  1179.  
  1180.     /*  Codes for specification of fonts and text styles. The "newfont" code
  1181.         is followed by the font number. If no font is specified, font #0 is
  1182.         the default.
  1183.     */
  1184.  
  1185. enum {
  1186.     LSTYLE_BOLD_ON=0x80,
  1187.     LSTYLE_BOLD_OFF,
  1188.     LSTYLE_ITALIC_ON,
  1189.     LSTYLE_ITALIC_OFF,
  1190.     LSTYLE_UNDER_ON,
  1191.     LSTYLE_UNDER_OFF,
  1192.     LSTYLE_NEWFONT,                             /* font number follows      */
  1193. };
  1194.  
  1195. /* ========================================================================= *
  1196.                              Annotation chunks (ANOT)
  1197.  
  1198.     This section describes the data structures which are used in the CMUS
  1199.     'ANOT' Chunk. Note that there is a standard IFF chunk called 'ANNO'
  1200.     which can be added to any file to annotate the file. The 'ANOT' is
  1201.     used to specify annotations to the music, not to the file.
  1202.  
  1203.  * ========================================================================= */
  1204.  
  1205.     /*  Annotation chunks are specified exactly like Lyric chunks. The only
  1206.         reason for distinguishing between the two is that a "stripper" program
  1207.         might want to strip out one or the other.
  1208.     */
  1209.  
  1210. /* ========================================================================= *
  1211.                                Title Chunk (TITL)
  1212.  
  1213.     This section describes the data structures which are used in the CMUS 'TITL'
  1214.     Chunk. Unlike Lyrics, Titles are placed at fixed positions on the page
  1215.     (generally at the top) and are are not adjusted based on the positioning
  1216.     of any particular measure.
  1217.  
  1218.  * ========================================================================= */
  1219.  
  1220.     /*  Title chunks are specified exactly like Lyric chunks, except that the
  1221.         lyricMeasure field is ignored and should be set to 0.
  1222.  
  1223.         In particular, the lyricXPos field is no longer based on measure width,
  1224.         but is now a fractional width of the document. Similarly, the
  1225.         lyricLevel field is the number of levels from the top of the page.
  1226.         (Or should that be an absolute measure?)
  1227.     */
  1228.  
  1229. /* ========================================================================= *
  1230.                           CMUS Instrument Table (FORM INST)
  1231.  
  1232.         The instrument table fo the CMUS form is stored as an embedded FORM
  1233.     called 'INST'. Each instrument in the table is one INST form.
  1234.  
  1235.         Instruments can be configured for MIDI, internal audio, or both.
  1236.     When using internal sounds, samples can be sepcified using an embedded
  1237.     FORM 8SVX, or any other IFF sampled sound FORM that the program wishes
  1238.     to support. Sampled sounds can be embedded in the file, or external
  1239.     sample files can be referenced from within the file, by pathname.
  1240.  
  1241.         Here's a summary of the chunks which can be included in an INST
  1242.     form:
  1243.  
  1244.         'INHD': This is the instrument header. It contains the instrument
  1245.             number, and the various MIDI-related parameters. The chunk
  1246.             format is defined below.
  1247.  
  1248.         'FORM 8SVX': This is an embedded sampled sound file. The sampled
  1249.             sound is to be associated with the instrument.
  1250.  
  1251.         'SFIL': This is a reference to a sampled sound in a different file,
  1252.             and can be used instead of an embedded sample. The chunk format
  1253.             is simply the name of the file. If the file contains more than
  1254.             one sample, only the first is used. (A different chunk can be
  1255.             defined to select the Nth sample, if it turns out that this
  1256.             feature might be desired).
  1257.  
  1258.         'SHAR': This allows a instrument to share a sampled sound with
  1259.             another instrument. This would be used instead of either and
  1260.             embedded sample or an 'SFIL' chunk. The chunk format is simple
  1261.             a UWORD of the instrument number to share with; This
  1262.             instrument must have been previously loaded.
  1263.  
  1264.         'ATAK': Identical with the ATAK chunk in FORM 8SVX, this allows
  1265.             the instrument have a different envelope than the one in
  1266.             the sampled sound file.
  1267.  
  1268.         'RLSE': Identical with the RLSE chunk in FORM 8SVX, this allows the
  1269.             instrument have a different envelope than the one in the
  1270.             sampled sound file.
  1271.  
  1272.         'NAME': is a standard chunk which can be added to any IFF FORM.
  1273.             In this case, it is used to store the instrument name. Other
  1274.             standard chunks which can be added are "AUTH" (author name),
  1275.             "VERS" (version string), "ANNO" (Annotations) and "(C) "
  1276.             (copyright notice).
  1277.  
  1278.     Note: If there is no sampled sound specified, either through an
  1279.         embedded sample or SFIL or SHAR chunks, then this instrument is
  1280.         a MIDI-only instrument.
  1281.  
  1282.  * ========================================================================= */
  1283.  
  1284.     /* Instrument header chunk -- INHD */
  1285.  
  1286. typedef struct {
  1287.  
  1288.         /*  'instNumber' corresponds to the instrument number used
  1289.             in the "instrument event" in the TRCK chunk.
  1290.         */
  1291.  
  1292.     UBYTE               instNumber;
  1293.  
  1294.     UBYTE               instFlags;          /* various flags                */
  1295.     WORD                instTune;           /* tuning, in 1/100 semitones   */
  1296.     WORD                instVolume;         /* overall volume, 0-0xffff     */
  1297.  
  1298.         /*  "Pan" can be used by both MIDI and sampled sound instruments, and
  1299.             indicates a preferences for left or right. It ranges from 0 to
  1300.             127 (same as MIDI), with 0 being ?? and 127 being ??.
  1301.         */
  1302.  
  1303.     UBYTE               instPan;
  1304.  
  1305.         /*  MIDI-related variables */
  1306.  
  1307.     UBYTE               instMidiChannel;    /* MIDI channel to use          */
  1308.     UBYTE               instMidiPreset;     /* MIDI Preset for this channel */
  1309.     UBYTE               instMidiPort;       /* Hardware port #, if applies  */
  1310.  
  1311. } InstrumentHeader;
  1312.  
  1313. #define INST_MAXVOL     0x0ffff
  1314. #define INST_MAXPAN     127
  1315.  
  1316.     /* various flags for instFlags */
  1317.  
  1318. #define INSTF_MIDI      (1<<0)              /* MIDI is enabled              */
  1319. #define INSTF_MIDIVOL   (1<<1)              /* use MIDI volume, not velocity*/
  1320.  
  1321. #endif
  1322.