chiark / gitweb /
Import upstream version 5.3.
[mup] / mup / mup / structs.h
CommitLineData
69695f33
MW
1/* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2 * 2005, 2006 by Arkkra Enterprises */
3/* All rights reserved */
4/*
5 * structs.h
6 *
7 * This file defines the structures needed for the Mup program.
8 */
9
10#ifndef _STRUCTS
11#define _STRUCTS
12
13#include <stdio.h>
14#include "defines.h"
15#include "rational.h"
16
17/*
18 * Define a structure for holding coordinates as input. These are always
19 * relative to something, either a real object, _page (the whole sheet of
20 * paper), _win (this context's window: header, footer, or center region),
21 * or _cur (the current position).
22 *
23 * Both the horizonal and vertical elements have a pointer to some
24 * object's coordinates, and a type, which tells what part of the object is
25 * to be used. The type is RX (relative X), AE (absolute east), etc. For
26 * horizontal this would be one of [RA][XEW]. For y this would be one
27 * of [RA][YNS]. Both hor and vert also have a fixed offset that is to be
28 * added in (could be 0), measured in step sizes. Finally, hor also has a
29 * counts value, which translates to a width, based on the 13th coordinate
30 * (INCHPERWHOLE) of the thing this structure is attached to. This field is
31 * not allowed in headers and footers.
32 */
33struct INPCOORD {
34 float *hor_p;
35 short htype;
36 float hsteps;
37 float counts;
38
39 float *vert_p;
40 short vtype;
41 float vsteps;
42};
43
44/*
45 * We save a linked list of the addresses of tag references, so that if a tag
46 * is moved, we can update its references.
47 */
48struct COORD_REF {
49 float **ref_p_p; /* address of tag reference */
50 struct COORD_REF *next; /* for linked list */
51};
52
53/*
54 * For each coodinate that is pointed to by some location variable, we
55 * need a bunch of information about it, such as whether it's from a NOTE,
56 * BAR, builtin variable, or GRPSYL. If not a builtin varaible, we'll need
57 * to know what page, score, and (if GRPSYL) staff, it is associated with
58 * in order to figure out how to split things that end up on different
59 * scores and/or pages.
60 */
61struct COORD_INFO {
62 float *coordlist_p; /* address of the coordinate */
63 short flags; /* if CT_NOTE, CT_BAR, etc */
64 short page; /* which page it's on */
65 short scorenum; /* which score on the page */
66 short staffno; /* which staff (CT_GRPSYL only) */
67 struct MAINLL *mll_feed_p; /* the feed info about the score it's on */
68 struct BAR *pseudo_bar_p; /* if this is a CT_BAR that happens
69 * to fall at the end of a score,
70 * this field will contain a pointer
71 * to the pseudo bar at the beginning
72 * of the following score */
73 struct COORD_REF *ref_list_p; /* list of references to this coord */
74 struct COORD_INFO *next; /* linked list off hash table */
75};
76
77/*
78 * Define a structure to be used to hold two staff numbers, and pointers
79 * to strings to be malloc'ed to hold labels, if desired. This is to
80 * be used for brace and bracket info.
81 */
82struct STAFFSET {
83 short topstaff; /* first staff joined by brace or bracket */
84 short botstaff; /* last staff joined by brace or bracket */
85 char *label; /* label to be used on first score */
86 char *label2; /* label to be used on later scores */
87};
88
89/*
90 * Define a structure to be used to hold top and bottom of a range of staffs
91 */
92struct TOP_BOT {
93 short top;
94 short bottom;
95};
96
97/*
98 * Define headcell structure pointing off at linked list of structures
99 * holding information about an instance of one of the contexts of the
100 * C_BLOCKHEAD class.
101 */
102struct BLOCKHEAD {
103 struct PRINTDATA *printdata_p; /* point at first item in list */
104 float c[NUMCTYPE]; /* for _win */
105 float height; /* of the context instance in inches */
106};
107
108/*
109 * Define a structure for the above linked list, holding information
110 * about printing. Can also be on a list off of a PRHEAD struct.
111 */
112struct PRINTDATA {
113 struct INPCOORD location; /* input coordinates */
114 float width; /* of string in inches */
115 short justifytype; /* J_LEFT, etc. */
116 char *string; /* malloc'ed string to print */
117 short isPostScript; /* is this for raw PostScript? */
118 char *inputfile; /* file this print command came from */
119 short inputlineno; /* line number in inputfile */
120 struct PRINTDATA *next; /* for linked list */
121};
122
123/*
124 * Information about the size of each character in FONTFACTORs of an inch.
125 * Note that we don't explicitly store descent; it is (height - ascent). Also
126 * info is only stored about the size of DFLT_SIZE characters; those in other
127 * sizes are assumed to be proportional.
128 */
129struct FONTINFO {
130 short ch_width[CHARS_IN_FONT];
131 short ch_height[CHARS_IN_FONT];
132 short ch_ascent[CHARS_IN_FONT];
133 char *ps_name; /* PostScript name of font */
134 FILE *fontfile; /* User's PostScript defn of font, if any */
135 short is_ital; /* is this an italic font? */
136};
137
138/* mapping of user names for non-ascii characters to internal code numbers */
139struct SPECCHAR {
140 char *charname; /* name user would use inside \( ) */
141 short code; /* internal code, like the ASCII code would
142 * be for a text font */
143};
144
145/*
146 * Store info about a string, for tablature. The parse phase fills in an array
147 * of these, one for each string, for each tablature staff.
148 */
149struct STRINGINFO {
150 char letter; /* 'a' to 'g' */
151 char accidental; /* '\0', '#', '&' */
152 short nticks; /* 0 or more */
153 short octave; /* MINOCTAVE to MAXOCTAVE */
154};
155
156/*
157 * Define structure holding information about these three contexts:
158 *
159 * score the whole score
160 * staff a staff
161 * voice a voice
162 *
163 * Every field used by voice is also used by staff and score. Every field
164 * used by staff is also used by score.
165 *
166 * Except for the selector and "used" fields, every field is numbered.
167 * Each item in the map "used" tells whether the corresponding field is
168 * currently being used in this instance of the structure. Fields that are
169 * always set at the same time may be numbered as a group.
170 *
171 * Instances of this structure are used in two ways.
172 *
173 * First, whenever the user's input contains a context of score, staff, or
174 * voice, a "struct MAINLL", which contains one of these structures, is
175 * allocated and put in the main linked list. For each item the user sets,
176 * the corresponding field is set in this structure and its "used" bit is
177 * set to YES. If the user sets a parameter during the course of the input for
178 * a voice, using the <<....>> construct, the SSV will be put in a TIMEDSSV
179 * structure and linked off the following BAR line.
180 *
181 * Second, a structure is allocated statically (global variable) for each
182 * possible score, staff, and voice. Each time the program scans through
183 * the main linked list, it starts off by populating the (one and only)
184 * score structure with default values for everything, and setting all its
185 * "used" bits to YES. It sets all the "used" bits for the staff and voice
186 * structures to NO. As it scans through the main linked list, whenever it
187 * finds one of these structures, it copies all the fields whose "used" bits
188 * are YES in that structure, to the appropriate fixed structure, and sets
189 * its "used" bit to YES there. The selector and linkage items are not used
190 * in these fixed structures.
191 *
192 * Whenever the program needs to know the current value of a field for a
193 * given voice, staff, and score, it uses a viewpath through the corresponding
194 * three fixed structures, in that order, using the "used" bits to see if
195 * the field is filled in. Note that the score structure is always fully
196 * populated, so the info will be found then, if not earlier.
197 */
198
199/* define the indices to the "used" field */
200#include "ssvused.h"
201
202struct SSV {
203 /* ======== SELECTOR ITEMS (ONLY SET FOR USER INPUT STRUCTS) ======= */
204 short context; /* which context is it for? (used by all) */
205 short staffno; /* staff no. (used by staff & voice); 1 to MAXSTAFFS */
206 short voiceno; /* voice no. (used by voice); 1 to MAXVOICES */
207
208 /* ======== USED FLAGS ======== */
209 char used[NUMFLDS]; /* map of which fields below are being used */
210
211 /* ======== ITEMS FOR SCORE CONTEXT ONLY ======== */
212 float scale_factor; /* scale the whole output by this amount */
213
214 float units; /* INCHES or CM */
215
216 float pageheight; /* size of the paper, in inches */
217 float pagewidth;
218
219 short panelsperpage; /* print how many panels on each page of paper*/
220
221 float topmargin; /* the four margins, in inches */
222 float botmargin;
223 float leftmargin;
224 float rightmargin;
225
226 short restcombine; /* min. no. of mr to combine, like -c option */
227 short firstpage; /* page number for first page, like -p option*/
228
229 short staffs; /* no. of staffs, 1 to MAXSTAFFS */
230
231 /*
232 * The following vertical distances are in units of stepsizes.
233 * They are as follows: minscsep is the smallest distance ever allowed
234 * between the bottom line of the bottom staff of one score, and the
235 * top of the top of the next. (The program distributes extra space
236 * on the page between scores.) maxscsep is the farthest distance
237 * allowed here, unless things sticking out force it farther.
238 * scorepad is the mininum distance allowed between the outermost
239 * things on neighboring scores.
240 */
241 short minscsep;
242 short maxscsep;
243 short minscpad;
244 short maxscpad;
245
246 /*
247 * A brace scheme is either "none" (nbrace == 0), or a list of pairs
248 * of staff numbers and optional labels. Braces are to be drawn
249 * joining each pair of staffs at the start of each score. The staffs
250 * in a pair may be the same; (3,3) means a brace is put on staff 3.
251 * If nbrace != 0, an array must be malloc'ed for bracelist to point
252 * at, so it can be treated as an array. If labels are to be printed
253 * for the group of staffs, a place must be malloc'ed for them, and
254 * the pointers in the "struct STAFFSET" must be set. Otherwise,
255 * those pointers must be set to null.
256 *
257 * A bracket scheme works exactly the same, using nbrack and bracklist.
258 *
259 * Barcon refers to which staffs are to be connected by bar lines.
260 * This also works the same way, except that if staff N does not
261 * fall within any of the ranges, it still will have bar lines, as
262 * if (N,N) had been listed explicity. Also, no labels are allowed.
263 */
264 short nbrace; /* brace ranges in list */
265 struct STAFFSET *bracelist; /* pointer to list */
266 short nbrack; /* bracket ranges in list */
267 struct STAFFSET *bracklist; /* pointer to list */
268 short nbarst; /* bar-connected ranges in list */
269 struct TOP_BOT *barstlist; /* pointer to list */
270
271 /*
272 * Common and cut time are noted as such in timetype, but in all other
273 * ways are treated as 4/4 and 2/2 respectively.
274 */
275 short timetype; /* time signature type */
276 short timenum; /* time sig numerator, 1 to 99 */
277 short timeden; /* time sig denominator, power of 2 */
278 /* from 1 to 64 */
279 char *timerep; /* representation of time signature */
280 short timevis; /* is time sig visible (YES or NO) */
281 RATIONAL time; /* time signature in lowest terms */
282
283 short division; /* clock ticks per 1/4 note (used by midi) */
284 short endingstyle; /* where ending brackets are to be drawn */
285 short gridsatend; /* print chord grids at end of song? */
286 short measnum; /* should measure numbers be printed? */
287 short measnumfamily; /* font family for measnum */
288 short measnumfont; /* font for measnum */
289 short measnumsize; /* point size for measnum */
290 float packfact; /* horizontal packing factor */
291 float packexp; /* horizontal packing expansion (exponent) */
292
293 short warn; /* should warnings be printed (YES/NO)? */
294
295 /* ======== ITEMS FOR SCORE AND STAFF CONTEXT ======== */
296 float staffscale; /* scale staff by this, relative to score */
297 short stafflines; /* number of lines in staff (normally 5) */
298 struct STRINGINFO *strinfo; /* iff tab staff, malloc'ed array */
299 short printclef; /* SS_* (shares staffline's "used" flag) */
300 short gridswhereused; /* print grids by chords where used? */
301 float gridscale; /* scale chord grids by this times staffscale*/
302 short gridfret; /* min fret to print next to chord grid */
303 short numbermrpt; /* should mrpt have number printed above? */
304 short printmultnum; /* should multirests have no. printed above? */
305 short restsymmult; /* draw multirests using rest chars? (YES/NO)*/
306 short vscheme; /* voice scheme */
307 short vcombine[MAXVOICES]; /* voices to be combined if possible, in the
308 * order to try the combining */
309 short vcombinequal; /* vcombine qualifer (see definition of VC_*) */
310 short sharps; /* no. of sharps, -7 to 7 */
311 short is_minor; /* minor key (YES/NO)? (used by MIDI) */
312 short cancelkey; /* should old key sig be canceled with nats? */
313 short inttype; /* transpose: interval type (MINOR, ...) */
314 short intnum; /* transpose: interval number, neg means down*/
315 short addinttype; /* same as inttype but for addtranspose */
316 short addintnum; /* same as intnum but for addtranspose */
317 short clef; /* which clef is it? */
318 short rehstyle; /* what should reh marks be enclosed in? */
319 short fontfamily; /* font family for text other than lyrics */
320 short font; /* font for text other than lyrics */
321 short size; /* point size for text other than lyrics */
322 short lyricsfamily; /* font family for lyrics */
323 short lyricsfont; /* font for lyrics */
324 short lyricssize; /* point size for lyrics */
325 float lyricsalign; /* fraction of syl to the left of chord center*/
326 short sylposition; /* points left of chord center to start syl
327 * (overrides lyricsalign if used) */
328
329 /*
330 * minstsep is the distance between bottom line of this staff and top
331 * line of the first visible staff below it, unless things sticking out
332 * force them to be farther apart.
333 */
334 short minstsep;
335
336 /*
337 * staffpad is the mininum distance allowed between the outermost
338 * things on neighboring staffs. It can be negative, to allow
339 * overlapping.
340 */
341 short staffpad;
342
343 /*
344 * markorder, for each "place", contains the stacking priority of each
345 * MK_* (mark type). Priority 1 get stack first, then 2, etc. This
346 * should really be "short" (a number, not a char), but it would waste
347 * too much space.
348 */
349 char markorder[NUM_PLACE][NUM_MARK];
350
351 short pedstyle; /* type of pedal marks to draw */
352 short chorddist; /* min dist between chord & staff, STEPSIZEs */
353 short dist; /* min dist between stuff & staff, STEPSIZEs */
354 short dyndist; /* min dist between dyn & staff, STEPSIZEs */
355
356 /* must malloc a place to store these strings, else set to null */
357 char *label; /* label on first score */
358 char *label2; /* label on later scores */
359
360 /* ======== ITEMS FOR SCORE, STAFF, AND VOICE CONTEXT ======== */
361 /*
362 * Although "visible" applies to score, staff, and voice, it is handled
363 * specially; see svpath() in ssv.c. The "visible" parameter sets both
364 * the "visible" and "hidesilent" fields, as follows:
365 * visible parameter visible field hidesilent field
366 * "n" NO NO
367 * "whereused" YES YES
368 * "y" YES NO
369 * The whereused value is not allowed for voice. As soon as the all
370 * the scorefeeds are known (after abshorz.c), new SSVs are inserted to
371 * make the appropriate staffs invisible "for real" (using "visible").
372 */
373 short visible; /* is the voice visible? */
374 short hidesilent; /* if normally visible, hide when not used? */
375 /*
376 * A beam scheme is either "none" (nbeam == 0), or a list of note
377 * durations adding up to a full measure. nbeam is how many durations
378 * in the list. If nbeam != 0, an array must be malloc'ed for
379 * beamstlist to point at, so it can be treated as an array.
380 * Some of these durations can be parenthesized sublists of durations.
381 * If not, then nsubbeam == nbeam and subbeamstlist is the same as
382 * beamstlist. But if so, the "sub" items count and list each
383 * individual duration, regardless of whether it's a stand-alone
384 * duration, or a member of a sublist; and nbeam and beamstlist give
385 * the combined version, where the durations of each sublist are added
386 * up and are regarded as a single duration.
387 * When nbeam != 0, beamrests tells whether the "r" flag was given;
388 * otherwise, beamrests is garbage.
389 * When nbeam != 0, beamspaces tells whether the "s" flag was given;
390 * otherwise, beamspaces is garbage.
391 */
392 short nbeam; /* durations in list */
393 RATIONAL *beamstlist; /* pointer to list */
394 short beamrests; /* YES or NO: beam across rests? */
395 short beamspaces; /* YES or NO: beam across spaces? */
396 short nsubbeam; /* durations in list */
397 RATIONAL *subbeamstlist; /* pointer to list */
398
399 /* these are controlled by BEAMSLOPE */
400 float beamfact; /* beam angle = this * regression angle */
401 float beammax; /* maximum beam angle allowed (degrees) */
402
403 float pad; /* apply on left of each group (stepsizes) */
404 /* internal value = external - 1/3 */
405 float stemlen; /* stem length in inches */
406 float stemshorten; /* how much beamed stems can be shortened */
407 /* (in stepsizes) */
408
409 short defoct; /* default octave number, 0 to 9 */
410 RATIONAL timeunit; /* note length to use when none specified */
411 struct TIMELIST *timelist_p; /* LL of additional times for timeunit*/
412 RATIONAL swingunit; /* duration within which notes are to "swing" */
413 short release; /* internote space for MIDI, in milliseconds */
414 short ontheline; /* put notes on the one-line staff line? */
415 short tabwhitebox; /* print white rectangle under fret numbers? */
416 short noteheads[7]; /* headshapes to be used for each scale degree*/
417};
418
419/*
420 * Define a structure for timed SSVs. These represent parameters that are set
421 * in the course of the input for a voice, using the <<....>> construct rather
422 * than being set the usual way in a score, staff, or voice context. They are
423 * put in a linked list hanging off the next BAR structure. They are stored in
424 * user input order, except that they are sorted by time_off.
425 */
426struct TIMEDSSV {
427 struct SSV ssv; /* all the normal contents of an SSV */
428 RATIONAL time_off; /* time offset into the measure where it is */
429 struct GRPSYL *grpsyl_p;/* the group before which the <<....>> was */
430 struct TIMEDSSV *next; /* link to the next one */
431};
432
433/*
434 * If the user enters times to be added together, like 2.+16, a linked list of
435 * these structs keeps track of the added times.
436 */
437struct TIMELIST {
438 int basictime;
439 RATIONAL fulltime; /* like fulltime in struct GRPSYL */
440 struct TIMELIST *next; /* for linked list */
441};
442
443/*
444 * Define structure pointing to the list of chords in a measure.
445 */
446struct CHHEAD {
447 struct CHORD *ch_p; /* point at a linked list of chords */
448};
449
450/*
451 * Define structure pointing a list of things to print. It is used for
452 * prints that occur in the "music" context.
453 */
454struct PRHEAD {
455 struct PRINTDATA *printdata_p; /* point at first item in list */
456};
457
458/*
459 * Define a structure containing a coordinate for an ending or rehearsal mark.
460 * The coordinate given is the south edge of the item's rectangle.
461 */
462struct MARKCOORD {
463 short staffno; /* which staff has the ending and/or rehear */
464 float ry; /* vertical coord rel to center line of staff */
465 struct MARKCOORD *next; /* for linked list */
466};
467
468/*
469 * Define structure holding info about a bar line.
470 */
471struct BAR {
472 short bartype; /* type of bar line */
473 short linetype; /* type of line (L_*) */
474
475 /*
476 * When a repeatstart occurs at the end of a line, it gets moved to the
477 * pseudobar on the next line. Where it used to be, a new bar line is
478 * supplied. The type of that new bar line is specified by precbartype.
479 * It defaults to singlebar.
480 */
481 short precbartype;
482
483 /*
484 * The bar line's coordinates have the following meanings.
485 * X is the middle of the bar line (even if it's a repeat sign, etc.).
486 * Y is the middle line of the top staff.
487 * W and E allow standard padding. (The leftmost "bar line" on a score
488 * is not considered to be a bar line at all, but is just drawn as
489 * part of the score.)
490 * N is the top line of the top staff; S is the bottom line of the
491 * bottom staff.
492 */
493 float c[NUMCTYPE]; /* coordinates */
494
495 float padding; /* extra space to allow */
496
497 /*
498 * Define whether the user used "hidechanges" on this bar, which
499 * prevents changes of clef, key, and time from printing out after this
500 * bar if it ends up being the last bar on a score.
501 */
502 short hidechanges; /* YES or NO */
503
504 /*
505 * Define position (*ITEM) relative to an ending, and what the label
506 * should say. The label is meaningful only for the first bar of
507 * the ending (STARTITEM). ENDITEM is used for the bar after the
508 * last measure of the ending.
509 */
510 short endingloc; /* position within (or not) an ending */
511 char *endinglabel; /* malloc'ed string to label the ending */
512
513 short reh_type; /* REH_* */
514 char *reh_string; /* string to print as rehearsal mark; should */
515 /* be null if reh_type != REH_STRING */
516 short dist; /* overrides SSV dist for the reh mark */
517 short dist_usage; /* was dist used, and was it forced? (SD_*) */
518
519 short mnum; /* measure number, 0 unless set by the user */
520
521 /*
522 * These start linked lists, one structure for each staff at this
523 * bar line that needs to have coordinates stored for an ending mark
524 * or a rehearsal mark above it. A coord is given for an ending
525 * mark only at the bar line where it begins.
526 */
527 struct MARKCOORD *ending_p; /* LL for ending marks */
528 struct MARKCOORD *reh_p; /* LL for rehearsal marks */
529
530 /*
531 * There is also a linked list holding SSVs for parameters that were
532 * set during the input for a voice rather than in their own context.
533 */
534 struct TIMEDSSV *timedssv_p;
535};
536
537/*
538 * Define structure for a line.
539 */
540struct LINE {
541 short linetype; /* type of line */
542 struct INPCOORD start, end; /* start and end points */
543 char *string; /* malloc; to be printed by the line */
544};
545
546/*
547 * Define structure for a curve. There are two input formats for a curve. The
548 * first type gives 3 or more coordinates, but no bulge distances. For that
549 * type ncoord tells how many coordinates, the coordinates are given by
550 * coordlist, nbulge is zero, and bulgelist is not allocated. For the other
551 * type of curve, 2 points (the endpoints) are given, and 1 or more bulge
552 * distances are given, in stepsize units.
553 */
554struct CURVE {
555 short curvetype; /* type of curve */
556 short ncoord; /* number of coords in the following */
557 struct INPCOORD *coordlist; /* array of coords to be malloc'ed */
558 short nbulge; /* number of bulge distances given */
559 float *bulgelist; /* array of them to be malloc'ed */
560};
561
562/*
563 * Define a structure for score and page feeds. The parser puts these in
564 * the main linked list when it sees the user's "newscore" and "newpage"
565 * directives, and the placement phase puts additional ones there as needed.
566 */
567struct FEED {
568 short pagefeed; /* YES=score & page feed, NO=scorefeed only */
569
570 /* the following are set to -1.0 when they aren't being used */
571 float leftmargin; /* override param on score after the feed */
572 float rightmargin; /* override param on score before the feed */
573
574 /*
575 * If this is a pagefeed, there may be blockhead contexts of some or
576 * all of these four types that we need to point at. When the user
577 * uses one of these contexts, it forces a pagefeed (whether they
578 * explicitly requested it or not), and the parse phase sets the
579 * pointer to a malloc'ed area. Later, in absvert.c, these pointer
580 * values are carried forward to subsequent pagefeeds.
581 */
582 struct BLOCKHEAD *top_p, *top2_p, *bot_p, *bot2_p;
583
584 short firstvis; /* first visible staff number in this score */
585 short lastvis; /* last visible staff number in this score */
586 float lastdist; /* distance from bottom line of last visible */
587 /* staff to the southernmost extent of score*/
588
589 /*
590 * The following are the coordinates of the score that follows.
591 * W and E are the margins, which it always extends out to when you
592 * consider labels and everything (no padding).
593 * N and S are just far enough out to include every rectangle,
594 * every staff, and every clef, with standard padding.
595 * X is the the X of the line left of the clefs.
596 * Y is the middle line of the top visible staff.
597 */
598 float c[NUMCTYPE]; /* coordinates of the score that follows */
599};
600
601
602/*
603 * Define structure telling whether to print clef, key signatures, or
604 * time signatures.
605 */
606struct CLEFSIG {
607 short prclef[MAXSTAFFS + 1]; /* print clef this staff? (YES/NO) */
608 short clefsize; /* print them DFLT_SIZE or SMALLSIZE */
609 /*
610 * sharps tells how many sharps to print in the key sig. If negative,
611 * it means flats. naturals means how many sharps are to be cancelled
612 * with natural signs. If negative, it means we are cancelling flats.
613 * Based on these numbers and on music theory, the print phase knows
614 * which ones to print. If both are zero, no key sig is to be printed.
615 */
616 short sharps[MAXSTAFFS + 1];
617 short naturals[MAXSTAFFS + 1];
618 short prtimesig; /* print time signature? (YES/NO) */
619 float wclefsiga; /* absolute west coord of clefsig */
620 float effwidth; /* width that can't overlap chords */
621 /* (used only by user clefsigs) */
622 float widestclef; /* width of widest clef to print */
623 /* (used only by user clefsigs) */
624 short hide; /* should be hidden (hidechanges)? */
625 short multinum; /* number of measures in the multirest
626 * that follows, 0 if no multirest */
627
628 /*
629 * The following is a pointer to a BAR that gets malloc'ed for
630 * CLEFSIGs that occur after FEEDs (at the start of a score). This
631 * represents the special, pseudo bar line at the start of a score.
632 * This pseudo bar comes immediately after the other clefsig items.
633 * It actually gets drawn only if it happens to be a REPEATSTART.
634 */
635 struct BAR *bar_p;
636};
637
638
639/*
640 * Define a structure describing a staff for one measure, which points off to
641 * linked lists of GRPSYLs and STUFFs.
642 */
643struct STAFF {
644 short staffno; /* staff number */
645 short visible; /* is this staff visible? */
646
647 /*
648 * Coordinates for the location of the staff. The relative horizontal
649 * ones are never set, but the absolute horizonal ones are set to meet
650 * the surrounding bar lines. The vertical ones are the same for
651 * all STAFFs for the same staff number for a given score. (For each
652 * staff number, the packing of rectangles is done across the whole
653 * score, and the same resulting vertical coords are stored in each
654 * measure's STAFF.) The relative vertical coords start out relative
655 * to the center line of the staff, so at that time RY is 0. Later,
656 * they are changed to be relative to the score.
657 */
658 float c[NUMCTYPE]; /* location of staff */
659
660 struct GRPSYL *groups_p[MAXVOICES]; /* linked list(s) of voices */
661
662 /*
663 * Following is syls_p, a malloc'ed array of headcells of linked lists
664 * of GRPSYLs for verses. There are "nsyllists" lists, which is
665 * "Maxverses" or less. The parallel array sylplace tells whether
666 * each list of syllables is above this staff, below it, or centered
667 * between this staff and the next staff number. The verse numbers do
668 * not have to equal the index into syls_p. Lists for the three
669 * places can be mixed together, alternating or whatever. But the
670 * verse numbers of each given place are in increasing order. Any
671 * verses may be missing, but then they won't have entries in syls_p.
672 */
673 short nsyllists;
674 short *sylplace;
675 struct GRPSYL **syls_p;
676
677 /*
678 * Following is the headcell for the linked list of other "stuff"
679 * associated with this staff; above, below, and between mixed together
680 * any which way. Actually, they are in user input order for below,
681 * and reversed for above and between, and that's the order in which
682 * their surrounding rectangles will be packed together. Thus, on the
683 * page things will end up placed in agreement with user input order.
684 */
685 struct STUFF *stuff_p;
686
687 /*
688 * Centered between this staff and the next we may have lyrics and/or
689 * "stuff". The rectangles for all this are packed together against
690 * a base line, and then the total height of all that is stored here.
691 */
692 float heightbetween;
693
694 /*
695 * In an mrpt measure, this holds the number that is to be printed
696 * above the measure (2 at the first mrpt, then increment). For other
697 * measures it is 0.
698 */
699 short mrptnum;
700};
701
702
703/*
704 * Define a structure that hold information about a chord grid.
705 */
706struct GRID {
707 char *name; /* internal chord name string (malloc) */
708
709 /*
710 * positions[0] is the fret for the first string, positions[1] is the
711 * second, etc. 0 means draw an "o" above this string, -1 means draw
712 * an "x". -2 means draw nothing.
713 */
714 short positions[MAXTABLINES]; /* slot for each string possible */
715 short numstr; /* number of strings used */
716
717 /*
718 * Numbers of the left and right strings to which the curved line
719 * extends. The first string is 1, not 0. 0 means no curved line.
720 */
721 short curvel, curver;
722
723 short used; /* was this grid used in this song? */
724};
725
726
727/*
728 * Define a structure that describes an item to be drawn other than music and
729 * lyrics. A linked list of these can hang off a STAFF structure.
730 */
731struct STUFF {
732#ifdef BIGMEM /* the way we'd define things, if we had plenty of memory */
733
734 short inputlineno; /* which input line this structure came from */
735 char *inputfile; /* which file this came from (malloc'ed) */
736 char *string; /* usual convention of 1st 2 bytes = font/size*/
737 short all; /* does this STUFF actually belong to "all" */
738 /* (the score), not a particular staff? YES/NO*/
739
740 /*
741 * Define start and end times for the stuff. "start" and "end.count"
742 * range from 0 to (numerator_of_time_sig + 1). They can be any float
743 * within that range; they don't have to line up with any group.
744 * However, if gracebackup is not 0, it means the stuff is to start at
745 * that many grace notes before the normal group that is closest to
746 * "start". Also, if the stuff is a phrase mark, both ends of it are
747 * set to the nearest group that is not rest or space, even if grace-
748 * backup is 0. (If it is nonzero, it then works the same way.)
749 * In any case, after the start position is determined as described
750 * above, the "steps" offset is applied to it, which can be positive,
751 * negative, or (usually) zero.
752 */
753 struct {
754 float count; /* counts into measure where the thing begins*/
755 float steps; /* offset in stepsizes */
756 } start;
757 struct {
758 int bars; /* how many bar lines it crosses */
759 float count; /* count (in whichever measure) where it ends */
760 } end; /* both are 0 if no "til" clause */
761 short gracebackup; /* how many graces before "start" to start at */
762
763 short stuff_type; /* ST_CRESC, etc. */
764 short modifier; /* if text, is it chord, etc. (TM_*)? */
765 /* if phrase, what type of line (L_*)? */
766 short place; /* PL_ABOVE, etc. */
767 short dist; /* overrides SSV dist/chorddist/dyndist */
768 short dist_usage; /* was dist used, and was it forced? (SD_*) */
769 short carryin; /* is this a continuation from last score? */
770 short carryout; /* does this continue onto the next score? */
771 struct STUFF *costuff_p;/* for tie/slur/bend carryin stuff, point at
772 * corresponding carryout stuff */
773
774 /*
775 * The following group of variables is used only for ST_PHRASE and/or
776 * ST_TIESLUR.
777 *
778 * Phrases use them as follows:
779 * A phrase must be assigned to apply to a particular voice on the
780 * staff. Unlike other STUFF, the endpoints of a phrase mark need to
781 * get associated with GRPSYLs. These pointers get set to point at
782 * them. If it crosses score feeds, carry ins and outs will have a
783 * pointer to the first and last GRPSYL of the score, respectively.
784 * The crvlist_p is the headcell of the linked list of points forming
785 * a phrase mark. begnote_p is not used.
786 *
787 * Ties and slurs use them as follows:
788 * A tie/slur is not input the same as other STUFF. The user's input
789 * sets its starting note. The STUFF structure is not allocated until
790 * stuff.c. At that point, vno, beggrp_p, and begnote_p are set, and
791 * crvlist_p is set up like for phrases. If it crosses a scorefeed,
792 * carry in and out are used, and the "beg" pointers for the second
793 * half of the tie/slur point at the end group and note. In any case,
794 * curveno tells which tie/slur this STUFF refers to, since a tie and
795 * multiple slurs can start at the same note. endgrp_p isn't used.
796 */
797 short vno; /* voice phrase applies to (1 or 2) */
798 struct GRPSYL *beggrp_p; /* beginning GRPSYL */
799 struct GRPSYL *endgrp_p; /* ending GRPSYL */
800 struct CRVLIST *crvlist_p; /* headcell of linked list of coords */
801 struct NOTE *begnote_p; /* beginning NOTE */
802 short curveno; /* idx into slurtolist; -1 for tie */
803
804 /*
805 * For above and below stuff, the relative vertical coords are
806 * relative to the staff's center line. For between stuff, they end
807 * up being relative to the center line of the above staff, but at
808 * first they are relative to the base line that the between stuff is
809 * piled on. (Not used for phrase marks.)
810 */
811 float c[NUMCTYPE]; /* where item is placed */
812
813 struct STUFF *next; /* for linked list */
814
815#else /* the same as above, optimized for space */
816
817 char *inputfile;
818 char *string;
819 struct GRPSYL *beggrp_p;
820 struct GRPSYL *endgrp_p;
821 struct CRVLIST *crvlist_p;
822 struct NOTE *begnote_p;
823 struct STUFF *next;
824 struct STUFF *costuff_p;
825 float c[NUMCTYPE];
826 struct {
827 float count;
828 float steps;
829 } start;
830 struct {
831 float count;
832 short bars;
833 } end;
834 short inputlineno;
835 short gracebackup;
836 short vno;
837 short curveno;
838 short dist;
839 unsigned dist_usage : 2;
840 unsigned all : 1;
841 unsigned stuff_type : 4;
842 unsigned modifier : 3;
843 unsigned place : 2;
844 unsigned carryin : 1;
845 unsigned carryout : 1;
846#endif
847};
848
849/*
850 * Define a structure for forming linked lists of coordinates making up the
851 * curve of a phrase mark. Each structure has the coordinates of one point.
852 */
853struct CRVLIST {
854 float x; /* absolute X */
855 float y; /* Y initially rel to staff, later absolute */
856 struct CRVLIST *next; /* doubly linked list */
857 struct CRVLIST *prev;
858};
859
860/*
861 * Define struct to save lists of staff number or vno (voice or verse) ranges.
862 */
863struct RANGELIST {
864 short begin; /* first number in range */
865 short end; /* last number in range. Must be >= begin */
866 short all; /* is this staff no. actually "all" (the */
867 /* score), not a particular staff? YES/NO */
868 short place; /* PL_* */
869 struct RANGELIST *next; /* for linked list */
870};
871
872/*
873 * Define a struct to save a list of pairs of staff and voice range lists.
874 */
875struct SVRANGELIST {
876 struct RANGELIST *stafflist_p;
877 struct RANGELIST *vnolist_p;
878 struct SVRANGELIST *next; /* linked list */
879};
880
881/*
882 * Define a structure for stating the note that a given note is slurred to.
883 */
884struct SLURTO {
885 char letter; /* a to g */
886 short octave; /* 0 to 9 */
887 short slurstyle; /* what type slur: L_[NORMAL|DOTTED|DASHED] */
888 short slurdir; /* should slur bulge UP or DOWN? */
889};
890
891/*
892 * Define the structure for holding information concerning a note. Much of
893 * the info you might expect to be here actually applies to the whole "group",
894 * and so is in the group/syllable structure below.
895 * NOTE: When adding fields to this structure, update function map1note().
896 */
897struct NOTE {
898 /*
899 * Define the coords x, y, north, south, east, west, both relative
900 * and absolute. The relative coords are relative to the group's
901 * (x, y). The NSEW coords define a rectangle surrounding the note
902 * head. XY are the center of the note head.
903 */
904 float *c; /* must malloc array; see comment in */
905 /* grpsyl.c, add_note() for why */
906
907 float waccr; /* relative coord: w(accidental)-x(group) */
908 float ydotr; /* relative coord: y(dot)-y(group) */
909
910 /* these next two are used when note_has_paren is YES */
911 float wlparen; /* relative coord: w(left paren)-x(group) */
912 float erparen; /* relative coord: e(right paren)-x(group) */
913
914 /*
915 * nslurto says how many notes of the following group this note is
916 * slurred to. If it is greater than 0, an array of that many SLURTO
917 * structures must be malloc'ed and slurtolist set to point at it.
918 */
919 struct SLURTO *slurtolist;
920 short nslurto;
921
922 char letter; /* a to g */
923 char accidental; /* '\0', 'x', '#', 'n', '&', 'B'(double flat)*/
924 short octave; /* 0 to 9 */
925 short stepsup; /* how many steps above middle line is note? */
926 char headfont; /* music char font of this note head */
927 char headchar; /* music char number of this note head */
928#ifdef BIGMEM /* the way we'd define things, if we had plenty of memory */
929 short headshape; /* shape type of this note head */
930 short notesize; /* size of the note head */
931 short tie; /* if YES, tie this note to the same note in
932 * the next note group */
933 short tiestyle; /* what type of tie: L_[NORMAL|DOTTED|DASHED] */
934 short tiedir; /* should tie bulge UP or DOWN? */
935 short acc_has_paren; /* does the accidental have () around it? */
936 short note_has_paren; /* does the entire note have () around it? */
937 short is_bend; /* does slurto list really contain a "bend"? */
938
939 /*
940 * On a tabnote staff, when there is a bend of <= 1/4 steps, the bent-
941 * to note isn't drawn. Instead, smallbend is set to YES, and a small,
942 * curved line gets drawn. In the input, the user specifies this by
943 * saying ^/ after the note.
944 */
945 short smallbend;
946
947#else /* the same as above, optimized for space */
948 unsigned notesize : 1;
949 unsigned tie : 1;
950 unsigned tiestyle : 3;
951 unsigned tiedir : 2;
952 unsigned acc_has_paren : 1;
953 unsigned note_has_paren : 1;
954 unsigned is_bend : 1;
955 unsigned smallbend : 1;
956 unsigned headshape : 5;
957#endif
958};
959/*
960 * For tablature, the items above are used differently from the usual meaning.
961 * Accidentals are never printed, so their coordinates are not used. letter
962 * is used to store the string number. accidental is used to store the fret
963 * number. Inside the octave field three bit fields are used to store the bend
964 * distance, as follows from high bits to low bits:
965 * integer part of bend; if no integer, store 0.
966 * numerator part of bend; if no fraction, store 0.
967 * denominator part of bend; if no fraction, store 0.
968 * If "full", store as if the integer 1 were given for bend (1-0-0).
969 * The following macros are used for accessing these fields. acc_has_paren is
970 * used to indicate parentheses around the fret number, so an alternate name is
971 * defined for it. stepsup is used, in the parse phase only, to store number
972 * of tick marks and fret values; see grpsyl.c for the details. In later
973 * phases it is set to its usual meaning, but note that middle of the staff
974 * will not be a line if there are an even number of lines.
975 */
976#define STRINGNO letter
977#define FRETNO accidental
978#define BEND octave
979#define BENDINT(note) (((note).BEND >> \
980 (BENDNUMBITS + BENDDENBITS)) & MAXBENDINT)
981#define BENDNUM(note) (((note).BEND >> BENDDENBITS) & MAXBENDNUM)
982#define BENDDEN(note) (((note).BEND >> 0) & MAXBENDDEN)
983#define TABOCT(inte, num, den) (((inte) << (BENDNUMBITS + BENDDENBITS)) | \
984 ((num) << BENDDENBITS) | ((den) << 0))
985#define HASBEND(note) ((note).BEND != 0)
986#define HASNULLBEND(note) ((note).BEND == 1)
987#define HASREALBEND(note) (HASBEND(note) && ! HASNULLBEND(note))
988#define FRET_HAS_PAREN acc_has_paren
989/*
990 * During parsing, we temporarily save nticks and fret in the stepsup field.
991 * Bits 0-8 hold the fret, bits 9-12 hold the nticks. Any changes to MAXFRET
992 * or MAXTICKS would have to be coordinated here. These things are stored
993 * temporarily in these fields since when we are doing parsing, we still need
994 * to remember the pitch and accidental information, so can't put them in their
995 * final place till a bit later.
996 */
997#define TMP_SAVE(note_p, nticks, fret) \
998 (note_p)->stepsup = (((nticks) & 0xf) << 8) | ((fret) & 0xff)
999#define TMP_NTICKS(note_p) (((note_p)->stepsup >> 8) & 0xf)
1000#define TMP_FRET(note_p) ((note_p)->stepsup & 0xff)
1001
1002/*
1003 * Define the structure for holding information concerning a "group", which
1004 * consists of either a space, a rest, or a list of notes stemmed together
1005 * (or which would be stemmed together if they were shorter than whole notes);
1006 * or a syllable of lyrics.
1007 * NOTE: When adding fields to this structure, update function map1note().
1008 */
1009struct GRPSYL {
1010#ifdef BIGMEM /* the way we'd define things, if we had plenty of memory */
1011
1012 /* ======== ITEMS FOR GROUPS AND SYLLABLES ======== */
1013 short inputlineno; /* which input line this structure came from */
1014 char *inputfile; /* which file this came from (malloc'ed) */
1015 short staffno; /* staff number */
1016 short vno; /* voice (1 to MAXVOICES) or verse number */
1017 short grpsyl; /* is it group or syllable? */
1018
1019 /*
1020 * Define the coords x, y, north, south, east, west, both relative
1021 * and absolute. The vertical relative coords are relative to the
1022 * center line of the staff. The horizontal relative coords are
1023 * relative to the chord's x. The NSEW coords define a rectangle
1024 * surrounding the group; for groups, X goes through the center of
1025 * the (normal) note heads; Y is the middle line of the staff.
1026 * For syllables, Y is the baseline and X is the place that should
1027 * line up with the chord, which is part way from the left edge toward
1028 * the right edge based on lyricsalign, not counting any characters in
1029 * <angle brackets> that precede or follow the real syllable.
1030 *
1031 * WARNING: for groups, during the time when positions of phrase
1032 * marks are being figured out, AN and AS are used in a strange way,
1033 * denoting the offset from RN or RS where the phrase is. But later
1034 * they get set to their normal values.
1035 */
1036 float c[NUMCTYPE]; /* coordinates */
1037
1038 /*
1039 * The basic time value is one of the following: -1, 0, power of 2 from
1040 * 1 to 256, or less than -1. For normal (is_meas==NO) groups, -1
1041 * means quadruple whole, 0 means double whole, 1 is whole, 2 is half,
1042 * etc. Less than -1 means a multirest of (-basictime) measures. For
1043 * is_meas==YES groups, basictime is the same as the preceding for
1044 * measure rests, where it just tells which rest to draw, but for ms
1045 * and mrpt it is arbitrarily set to -1.
1046 */
1047 short basictime;
1048
1049 /*
1050 * is_meas tells whether an "m" was used with the time in the input.
1051 * This is used for "measure" rests, spaces, or repeats (mr, ms, mrpt).
1052 * (Only mr can have a normal time value in addition to the "m"; it is
1053 * stored as the basictime (defaults to 1) and tells which rest to
1054 * draw.) Their fulltime is the time signature. mr and mrpt are
1055 * centered in the measure.
1056 */
1057 short is_meas;
1058
1059 short dots; /* number of dots applied to time value */
1060
1061 short tuploc; /* none, start, inner, end, lone (for tuplet) */
1062 short tupcont; /* number to print for the tuplet */
1063
1064 /*
1065 * Full time is basic time modified by dots, tuplets, etc. It's the
1066 * actual time duration, and thus for grace it's always 0.
1067 */
1068 RATIONAL fulltime;
1069
1070 float padding; /* extra space to allow */
1071
1072 /* ======== ITEMS FOR GROUPS ONLY ======== */
1073 short pvno; /* pseudo voice number: normally equals vno,
1074 * but when voice 3 is treated like voice 1 or
1075 * or 2, that number is stored here */
1076 /* also used as scratch area in mkchords.c */
1077 short grpcont; /* note(s), rest, or space; although normally
1078 * meaningful only for groups, gram.y uses it
1079 * as scratch while processing syllables */
1080 short grpvalue; /* normal time value; or zero for grace group
1081 * or for all-space chords in MIDI */
1082 short grpsize; /* size of items in group */
1083 short headshape; /* default shape of noteheads in group */
1084 short uncompressible; /* is this space a "us" (used for space only)*/
1085
1086 short beamloc; /* none, start, inner, end (only note groups)*/
1087 float beamslope; /* user specified angle of beam in degrees */
1088
1089 /*
1090 * Stem length applies to groups shorter than a whole note and groups
1091 * joined by "alternation" beams. It starts out based only on
1092 * basictime and grpsize, but due to a beam or override, it could be
1093 * changed. Direction is up or down, and applies to all groups, even
1094 * whole note groups (useful for figuring ties). stemx is the
1095 * horizontal position of the stem, relative to the X of the GRPSYL.
1096 * These fields are valid only for note groups.
1097 */
1098 float stemlen;
1099 short stemdir; /* up or down */
1100 float stemx;
1101
1102 /*
1103 * beamto is always CS_SAME, except when this group is a notes or
1104 * space group and is involved in cross staff beaming. It then tells
1105 * whether we are beamed with the staff above us or below us. It is
1106 * set for all the note and space groups on both staffs in the set.
1107 * So on the top staff it's set to CS_BELOW, and on the bottom staff
1108 * it's set to CS_ABOVE.
1109 */
1110 short beamto;
1111
1112 /*
1113 * stemto is always CS_SAME, except when this group is a notes group
1114 * and is involved in cross staff steming. It then tells whether we
1115 * are stemmed with the staff above us or below us. When stemto is not
1116 * CS_SAME, stemto_idx is an index into notelist[]. For CS_ABOVE,
1117 * it indexes to the last note that is on the above staff. For
1118 * CS_BELOW, it indexes to the first note that is on the below staff.
1119 */
1120 short stemto;
1121 short stemto_idx;
1122
1123 /* YES if the last group in a subbeam */
1124 short breakbeam;
1125
1126 /*
1127 * printtup tells whether the user wants a tuplet number and bracket to
1128 * be printed next to a note group. If PT_NEITHER, neither will be.
1129 * If PT_BOTH, both will be. If PF_DEFAULT, at least the number will
1130 * be. The bracket will be too, unless the tuplet contains only one
1131 * group, or if all the groups' beamlocs are equal to their tuplocs
1132 * (the groups are already beamed as a unit). If PT_NUMBER, the number
1133 * (and only the number) will be printed. In any case, printtup
1134 * is set for each group in the tuplet.
1135 *
1136 * tupextend is set only for the groups of a tuplet of notes that has
1137 * printtup == Y. It is the vertical offset of where the tuplet
1138 * bracket would be, from the AN or AS of the groups, as the case may
1139 * be. If the bracket would be above the groups, it is positive and
1140 * relative to AN; else it is negative and relative to AS. It is set
1141 * even for the case where the bracket is not going to be printed, so
1142 * that the tuplet number can still be placed as halfway between the
1143 * invisible bracket's endpoints.
1144 */
1145 short printtup;
1146 float tupextend;
1147 short tupside; /* should number & bracket be above or below?*/
1148
1149 short phraseside; /* relevant side(s) for phrase mark space */
1150
1151 /*
1152 * nnotes says how many notes there are in the group. An array of
1153 * that many note structures must be malloc'ed and notelist set to
1154 * point at it. The notes are stored in order of descending pitch,
1155 * regardless of the user's input ordering. These fields are valid
1156 * only for note groups.
1157 * But for measure repeats (mrpt), even though they are GC_NOTES,
1158 * nnotes is 0 and notelist is a null pointer.
1159 */
1160 short nnotes; /* no. of notes in group */
1161 struct NOTE *notelist; /* list of notes in group */
1162
1163 /*
1164 * If tie is set to YES, all notes in the group are to be tied to
1165 * corresponding notes in the following group. The "tie" flag will
1166 * also be set on each individual note in its NOTE struct, but it
1167 * turns out to be handy to have the whole group marked here too.
1168 * This field is valid only for note groups.
1169 */
1170 short tie;
1171
1172 /*
1173 * The slash_alt field is used for slashes on a group or between
1174 * pairs of groups (for tremolo, or just dividing the time value of
1175 * the group(s). 0 means normal group; >0 means draw that many
1176 * slashes through the stem of this group (or, if basictime < 2, where
1177 * the stem would have been); <0 means draw negative that many slashes
1178 * between this and the next group. This field is valid only for note
1179 * groups.
1180 */
1181 short slash_alt;
1182
1183 /*
1184 * On a tablature staff, when an entire group is tied to the following
1185 * group, the second group normally should not be printed. (Its
1186 * corresponding tabnote group will be, though.) This flag says not to
1187 * print this group. This is set by the parse phase when the preceding
1188 * tab group is tied. It is cleared by the placement phase after
1189 * scorefeeds.
1190 */
1191 short inhibitprint;
1192
1193 /*
1194 * This is used for rests only. If not used, it is NORESTDIST.
1195 * Otherwise, it is the vertical offset of the "center" of the rest
1196 * (the part that normally is on the center line) from the center line.
1197 * The rest is forced there.
1198 */
1199 short restdist;
1200
1201 /*
1202 * These are for the user-specified horizontal offset of the group from
1203 * the chord's X. The value is in stepsizes; negative to the left, and
1204 * positive to the right.
1205 */
1206 short ho_usage; /* HO_* */
1207 float ho_value; /* value to use when ho_usage is HO_VALUE */
1208
1209
1210 /* the X positions of dots are the same for every note in the group */
1211 float xdotr; /* relative coord of dots: x(dot)-x(group) */
1212 /*
1213 * When symbols are to be drawn "with" a group, they are stored
1214 * in the list below in order, starting from the group and moving
1215 * outwards. When nwith is 0, there is no list. Otherwise, a
1216 * list must be malloc'ed and the pointer must be set to point at
1217 * it. Each item in the list is a pointer to a string, which must
1218 * also be malloc'ed. Normally, the "with" items are on the note side
1219 * of the group, but if there are two voices, they might need to be
1220 * put on the stem side, so normwith says which side they go on.
1221 * These fields are valid only for note groups.
1222 */
1223 short nwith; /* no. of symbols with group */
1224 char **withlist; /* list of symbols with group */
1225 short normwith; /* does it go on the normal (note) end of grp?*/
1226
1227 short roll; /* where is this group in a roll, if at all? */
1228 short rolldir; /* is the roll's arrow UP, DOWN, or UNKNOWN? */
1229 /* (with UNKNOWN, roll is up, but no arrow) */
1230
1231 short clef; /* clef to be printed before this group */
1232
1233 /* ======== ITEMS FOR SYLLABLES ONLY ======== */
1234 char *syl; /* malloc a place for the syllable */
1235 short sylposition; /* points left of chord's X to start syl */
1236
1237 /* ======== LINKAGE ======== */
1238 struct GRPSYL *prev; /* point at previous group/syl in voice/verse*/
1239 struct GRPSYL *next; /* point at next group/syl in voice/verse */
1240 struct GRPSYL *gs_p; /* point at next group/syl in chord */
1241
1242#else /* the same as above, optimized for space */
1243
1244 RATIONAL fulltime;
1245 float c[NUMCTYPE];
1246 float padding;
1247 float stemlen;
1248 float stemx;
1249 float tupextend;
1250 float ho_value;
1251 float xdotr;
1252 float beamslope;
1253 char *inputfile;
1254 char **withlist;
1255 char *syl;
1256 struct GRPSYL *prev;
1257 struct GRPSYL *next;
1258 struct GRPSYL *gs_p;
1259 struct NOTE *notelist;
1260 short inputlineno;
1261 short staffno;
1262 short vno;
1263 short basictime;
1264 short dots;
1265 short tupcont;
1266 short pvno;
1267 short nnotes;
1268 short slash_alt;
1269 short nwith;
1270 short restdist;
1271 short sylposition;
1272 short clef;
1273 short headshape;
1274 short stemto_idx;
1275 unsigned ho_usage : 2;
1276 unsigned is_meas : 1;
1277 unsigned grpsyl : 1;
1278 unsigned tuploc : 3;
1279 unsigned grpcont : 2;
1280 unsigned grpvalue : 1;
1281 unsigned grpsize : 1;
1282 unsigned uncompressible : 1;
1283 unsigned beamloc : 3;
1284 unsigned stemdir : 2;
1285 unsigned tupside : 2;
1286 unsigned phraseside : 2;
1287 unsigned printtup : 2;
1288 unsigned tie : 1;
1289 unsigned normwith : 1;
1290 unsigned roll : 3;
1291 unsigned rolldir : 2;
1292 unsigned inhibitprint : 1;
1293 unsigned beamto : 2;
1294 unsigned stemto : 2;
1295 unsigned breakbeam : 1;
1296#endif
1297};
1298
1299/*
1300 * Define the structure for a chord.
1301 */
1302struct CHORD {
1303 /*
1304 * Define the coords of a CHORD. For vertical, only the absolute ones
1305 * are set. They are set the same as the FEED for this score, and they
1306 * are used only for drawing bounding boxes with MUP_BB. As for
1307 * horizontal, the relative coords are relative to the score's
1308 * (x, y). Basically, west and east are set out just far enough to
1309 * hold the biggest GRPSYL in the CHORD. However, for both groups and
1310 * syllables there is special code that allows parts of them to stick
1311 * out, when the overlap would be harmless even if the CHORDs end up
1312 * being packed tightly together.
1313 */
1314 float c[NUMCTYPE]; /* coordinates */
1315 float width; /* c[RE] - c[RW], which equals c[AE] - c[AW] */
1316 float fullwidth; /* dist from c[RX] of this chord to c[RX] of */
1317 /* next (or to bar line if last in measure) */
1318
1319 RATIONAL starttime; /* starting time of chord within its measure */
1320 RATIONAL duration; /* duration of the chord */
1321 float pseudodur; /* a function of duration; proportional to */
1322 /* width this chord will "deserve" */
1323
1324 struct CHORD *ch_p; /* point at next chord in list */
1325 struct GRPSYL *gs_p; /* point at first group or syllable in chord */
1326};
1327
1328/*
1329 * Define the structure that contains info concerning chord grids that are
1330 * going to be printed at the end of the song. Only one instance of this
1331 * structure exists.
1332 */
1333struct ATEND_INFO {
1334 /* number of different grids actually used in the song */
1335 int grids_used;
1336
1337 /*
1338 * Must grid dictionary be put on a separate page, following the last
1339 * page of music (because it doesn't fit with the music)? YES or NO.
1340 */
1341 int separate_page;
1342
1343 /*
1344 * This is a malloc'ed array of pointers to the grids to be printed.
1345 * Placement sets it up and sorts it.
1346 */
1347 struct GRID **grid_p;
1348
1349 int grids_per_row; /* no. of grids to print per row */
1350 int rows_per_page; /* no. of rows of grids allowed on one page */
1351 float firstgrid_x; /* X coord of grids in the first column */
1352 float firstgrid_y; /* Y coord of grids in the first row */
1353 float horz_sep; /* dist between X of neighboring grids */
1354 float vert_sep; /* dist between Y of neighboring grids */
1355};
1356
1357/*
1358 * Define a symbol for each structure type that can be inside a union, so
1359 * that we can record which member of the union is being used.
1360 */
1361#define S_SSV (0)
1362#define S_FEED (1)
1363#define S_CLEFSIG (2)
1364#define S_PRHEAD (3)
1365#define S_CHHEAD (4)
1366#define S_STAFF (5)
1367#define S_LINE (6)
1368#define S_CURVE (7)
1369#define S_BAR (8)
1370#define S_BLOCKHEAD (9)
1371
1372/*
1373 * The following contains a union of all the structures that can occur in the
1374 * main linked list, set up by yyparse().
1375 */
1376struct MAINLL {
1377 short str; /* which structure in the union is now being used? */
1378 short inputlineno; /* which input line this structure came from */
1379 char *inputfile; /* which file this came from (malloc'ed) */
1380 union { /* malloc'ed structures to be pointed at */
1381 struct SSV *ssv_p; /* score/staff/voice context info */
1382 struct FEED *feed_p; /* score and/or page feed */
1383 struct CLEFSIG *clefsig_p; /* print clef and/or sigs? */
1384 struct PRHEAD *prhead_p;/* head of list to print things */
1385 struct CHHEAD *chhead_p;/* head of chord list for a measure */
1386 struct STAFF *staff_p; /* staff info from data context */
1387 struct LINE *line_p; /* line info */
1388 struct CURVE *curve_p; /* curve info */
1389 struct BAR *bar_p; /* bar line info from data context */
1390 struct BLOCKHEAD *blockhead_p; /* info for a "block" context */
1391 } u;
1392 struct MAINLL *prev; /* previous structure in linked list */
1393 struct MAINLL *next; /* next structure in linked list */
1394};
1395/*
1396 * The structures in the main linked list must occur in the order as shown
1397 * below, by the end of the placement phase. There are optional initial SSVs,
1398 * then two alternative sets of structures that repeat, then some optional
1399 * final structures. The list shows [in brackets] which phase of Mup inserts
1400 * the structure: parse or placement. (The third phase, print, doesn't insert
1401 * any structures; nor does the midi phase, which can replace the print phase.)
1402 *
1403 * 0 or more SSVs [parse]
1404 * LOOP 1 or more times:
1405 * EITHER a measure:
1406 * 0 or 1 FEED; 1 is required in 1st measure & after block[parse or place]
1407 * 0 or 1 CLEFSIG (at start of a score); 1 iff a FEED precedes [place]
1408 * 1 CHHEAD [place]
1409 * 1 or more STAFFs. They are ordered by staff number. [parse]
1410 * 0 or more LINEs and/or CURVEs and/or PRHEADs, any order[parse or place]
1411 * 1 BAR [parse]
1412 * 0 or more SSVs [parse or place]
1413 * 0 or 1 CLEFSIG (after a bar line, not at start of a score) [place]
1414 * OR a block:
1415 * 1 FEED [parse]
1416 * 1 BLOCKHEAD [parse]
1417 * 0 or more SSVs [parse]
1418 * END_EITHER
1419 * END_LOOP
1420 * 0 or more LINEs and/or CURVEs and/or PRHEADs and 1 optional FEED; the FEED
1421 * is required if a block preceeds [parse]
1422 */
1423#endif