chiark / gitweb /
Import upstream version 5.3.
[mup] / mup / mup / defines.h
1 /* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2  * 2006 by Arkkra Enterprises */
3 /* All rights reserved */
4 /*
5  *      defines.h
6  *
7  *      This file defines the constants needed for the music publication
8  *      program.
9  */
10
11 #include <math.h>
12 #ifndef _DEFINES
13 #define _DEFINES
14 #include "muschar.h"
15
16 /*
17  * Define the environment =============================================
18  */
19
20 /* for all forms of DOS we've tried, make sure __DOS__ is defined */
21 #if defined(__TURBOC__) || defined(__WATCOMC__) || defined(__MINGW32__)
22 #ifndef __DOS__
23 #define __DOS__
24 #endif
25 #endif
26
27 /* if you are short on memory or know you'll never use the extended character
28  * set (with accented characters, etc) you can undefine EXTCHAR
29  */
30 #ifndef __TURBOC__
31 #define EXTCHAR
32 #endif
33 #include "extchar.h"
34
35 /* the following is needed for the DOS port of the GNU C compiler */
36 #ifdef __DJGPP__
37 #define __DOS__
38 #undef unix
39 #endif
40
41 /*
42  * Based on system type, #define or don't #define various symbols, as follows:
43  *
44  * UNIX_LIKE_FILES      If defined, files can be simultaneously read from and
45  *                      written to and invisibly unlinked.
46  * UNIX_LIKE_PATH_RULES If defined, use these rules for MUPPATH.
47  * DOS_LIKE_PATH_RULES  If defined, use these rules for MUPPATH.
48  * CORE_MESSAGE         If defined, then a creating core error message will be
49  *                      printed in debug mode.
50  * NEED_GETOPT          If defined, the getopt suite is not available,
51  *                      therefore use the limited one in main.c.
52  * MAGIC_FILE_HOME      If defined, check for magic file in $HOME.
53  * MAGIC_FILE_NAME      Name of magic file.
54  * OPTION_MARKER        The char which preceeds command line options.
55  */
56 #ifdef unix
57 #define UNIX_LIKE_FILES
58 #define UNIX_LIKE_PATH_RULES
59 #define CORE_MESSAGE
60 #define MAGIC_FILE_HOME
61 #define MAGIC_FILE_NAME ".mup"
62 #define OPTION_MARKER   '-'
63 #endif
64
65 #ifdef VMS
66 #define MAGIC_FILE_HOME
67 #define MAGIC_FILE_NAME ".mup"
68 #define OPTION_MARKER   '-'
69 #endif
70
71 #ifdef AMIGA
72 #undef  UNIX_LIKE_FILES
73 #define NEED_GETOPT
74 #define MAGIC_FILE_HOME
75 #define MAGIC_FILE_NAME ".mup"
76 #define OPTION_MARKER   '-'
77 #endif
78
79 #ifdef __DOS__
80 #define DOS_LIKE_PATH_RULES
81 #define NEED_GETOPT
82 #define MAGIC_FILE_NAME "mup.ok"
83 #define OPTION_MARKER   '/'
84 #endif
85
86 #ifdef Mac_BBEdit
87 #undef  UNIX_LIKE_FILES
88 #define NEED_GETOPT
89 /* skip length byte of Pascal string literal */
90 #define MAGIC_FILE_NAME (char *)(MupRegFileName + 1);
91 #define OPTION_MARKER   '-'
92 #endif
93
94 #ifdef __EMX__
95 #undef  UNIX_LIKE_FILES
96 #define DOS_LIKE_PATH_RULES
97 #define MAGIC_FILE_HOME
98 #define MAGIC_FILE_NAME ".mup"
99 #define OPTION_MARKER   '-'
100 #endif
101
102 #ifndef OPTION_MARKER
103 /* use - as default if nothing has been defined for it */
104 #define OPTION_MARKER '-'
105 #endif
106
107 /*
108  * Define ranges for variables =============================================
109  */
110
111 /*
112  * Define maximum value for exit code from Mup. Must be less than 128
113  * to be able to distinguish from WAIT_ABANDONED value on Windows.
114  */
115 #define MAX_ERRORS      (127)
116
117 /* text point sizes */
118 #define MINSIZE (1)
119 #define MAXSIZE (100)
120
121 /* key signatures */
122 #define MINSHARPS       (-7)
123 #define MAXSHARPS       (7)
124 #define DEFSHARPS       (0)
125
126 /* octave */
127 #define MINOCTAVE       (0)
128 #define MAXOCTAVE       (9)
129 #define DEFOCTAVE       (4)
130
131 /* staves */
132 #define MINSTAFFS       (1)
133 #define MAXSTAFFS       (40)
134 #define DEFSTAFFS       (1)
135
136 /* voices */
137 #define MINVOICES       (1)
138 #define NORMVOICES      (2)
139 #define MAXVOICES       (3)
140
141 /* number of lines in a tablature staff */
142 #define MINTABLINES     (1)
143 #define DEFTABLINES     (6)     /* see Guitar[] in globals.c */
144 #define MAXTABLINES     (9)
145
146 /* number of ticks on a string designation for tablature */
147 #define MINTICKS        (0)
148 #define MAXTICKS        (MAXTABLINES - 1)
149
150 #define TABDEFOCT       (4)
151
152 /* tablature fret numbers, including pseudo fret numbers */
153 #define MINFRET         (0)
154 #define MAXFRET         (99)
155 #define DEFFRET         (0)
156 #define NOFRET          (MAXFRET + 1)
157 #define IN_UPWARD       (MAXFRET + 2)   /* slur from nowhere, going up */
158 #define IN_DOWNWARD     (MAXFRET + 3)   /* slur from nowhere, going down */
159 #define OUT_UPWARD      (MAXFRET + 4)   /* slur to nowhere, going up */
160 #define OUT_DOWNWARD    (MAXFRET + 5)   /* slur to nowhere, going down */
161 #define IS_NOWHERE(fret) ((fret) >= IN_UPWARD && (fret) <= OUT_DOWNWARD)
162
163 /* range of frets that can be printed by a chord grid */
164 #define MINGRIDFRET     (2)
165 #define MAXGRIDFRET     (MAXFRET)
166 #define DEFGRIDFRET     (4)
167 #define NOGRIDFRET      (-1)    /* must be negative so user can't enter it */
168
169 /* USE_DFLT_OCTAVE has to be number that is not a valid octave, nor a */
170 /* valid fret number.  But it has to be positive and small enough to be */
171 /* able to add MAX_OCTAVE to it */
172 #define USE_DFLT_OCTAVE (MAXFRET + 6)
173
174 /* min and max numbers for bend integers, numerators, and denominators */
175 #define BENDINTBITS     (4)
176 #define MINBENDINT      (0)
177 #define MAXBENDINT      ((1 << BENDINTBITS) - 1)
178 #define BENDNUMBITS     (6)
179 #define MINBENDNUM      (0)
180 #define MAXBENDNUM      ((1 << BENDNUMBITS) - 1)
181 #define BENDDENBITS     (6)
182 #define MINBENDDEN      (1)
183 #define MAXBENDDEN      ((1 << BENDDENBITS) - 1)
184
185 /* time unit */
186 /* -1 means quadruple whole and 0 means double whole.  Actually, less than -1 */
187 /* is allowed, and it's minus the number of measures in a multirest */
188 #define MINBASICTIME    (-1)
189 #define MAXBASICTIME    (256)
190
191 /* the biggest number that is allowed on a multirest */
192 #define MAXMULTINUM     (1000)
193
194 /* limits for scaling the output */
195 #define MINSCALE        (0.1)
196 #define MAXSCALE        (10.0)
197 #define DEFSCALE        (1.0)
198
199 /* limits for scaling a staff relative to the output as a whole */
200 #define MINSTFSCALE     (0.1)
201 #define MAXSTFSCALE     (10.0)
202 #define DEFSTFSCALE     (1.0)
203
204 #define MINGRIDSCALE    (0.1)
205 #define MAXGRIDSCALE    (10.0)
206 #define DEFGRIDSCALE    (1.0)
207
208 /* limits on min distance required between a chord and its staff (stepsizes) */
209 #define MINCHORDDIST    (0)
210 #define MAXCHORDDIST    (50)
211 #define DEFCHORDDIST    (3)
212
213 /* limits on min dist required between other stuff and its staff (stepsizes) */
214 #define MINDIST         (0)
215 #define MAXDIST         (50)
216 #define DEFDIST         (2)
217
218 /* limits on min distance required between a cresc and its staff (stepsizes) */
219 #define MINDYNDIST      (0)
220 #define MAXDYNDIST      (50)
221 #define DEFDYNDIST      (0)
222
223 /* vertical space between staffs and scores, in units of stepsize */
224 #define MINMINSTSEP     (6)     /* min user-specified min between staffs */
225 #define DEFMINSTSEP     (10)    /* default min between staffs */
226 #define MINMINSCSEP     (6)     /* min user-specified min between scores */
227 #define DEFMINSCSEP     (12)    /* default min between scores */
228 #define MINMAXSCSEP     MINMINSCSEP /* min user-specified max between scores */
229 #define DEFMAXSCSEP     (20)    /* default max between scores */
230 #define MAXSEPVAL       ((int)(PGHEIGHT / STEPSIZE)) /* max for either one */
231 #define MINSTPAD        (-MAXSEPVAL) /* min user-spec. white between staffs */
232 #define MAXSTPAD        (MAXSEPVAL) /* max user white between staffs */
233 #define DEFSTPAD        (0)     /* default white between staffs */
234 #define MINMINSCPAD     (-MAXSEPVAL) /* min user-spec. white between scores */
235 #define DEFMINSCPAD     (2)     /* default white between scores */
236 #define MINMAXSCPAD     (-MAXSEPVAL) /* min user-spec. white between scores */
237 #define DEFMAXSCPAD     (2)     /* default white between scores */
238 #define MAXPADVAL       (MAXSEPVAL) /* max user white between scores */
239
240 /* distance from center line a rest should be forced to be */
241 #define MINRESTDIST     (-50)
242 #define MAXRESTDIST     (50)
243 #define NORESTDIST      (11111) /* this means it is not set */
244
245 /* number of mr needed to combine into a multirest (like -c option) */
246 #define MINRESTCOMBINE  (2)
247 #define MAXRESTCOMBINE  (1000)
248 #define NORESTCOMBINE   (-1)    /* must be negative so user can't enter it */
249
250 /* page number to be put on the first page (like -p option) */
251 #define MINFIRSTPAGE    (1)
252 #define MAXFIRSTPAGE    (5000)
253 #define NOFIRSTPAGE     (0)     /* this means it is not set */
254
255 /* number to multiply linear regression slope by to get beam's slope */
256 #define MINBEAMFACT     (0.0)
257 #define MAXBEAMFACT     (1.0)
258 #define DEFBEAMFACT     (1.0)
259
260 /* maximum beam angle allowed, in degrees */
261 #define MINBEAMMAX      (0.0)
262 #define MAXBEAMMAX      (45.0)
263 #define DEFBEAMMAX      (20.0)
264
265 /* angle of beam specified by the "slope" interchord attribute */
266 #define MINBEAMANGLE    (-MAXBEAMMAX)
267 #define MAXBEAMANGLE    (MAXBEAMMAX)
268 #define NOBEAMANGLE     (2 * MAXBEAMANGLE)      /* something out of range */
269
270 /* padding to be applied on the left of every group (and the right of the */
271 /* last group in the measure), in stepsizes */
272 #define MINPAD          (-5.0)
273 #define MAXPAD          (50.0)
274 #define DEFPAD          (0.0)
275
276 /* for setting and testing unknown stem length */
277 #define STEMLEN_UNKNOWN         (-1.0)
278 #define IS_STEMLEN_KNOWN(x)     ((x) >= 0.0)    /* avoid using "==" on floats */
279 #define IS_STEMLEN_UNKNOWN(x)   ((x) < 0.0)     /* avoid using "==" on floats */
280
281 /* other stem length definitions */
282 #define MINSTEMLEN      (0.0)
283 #define DEFSTEMLEN      (7.0)
284 #define MAXSTEMLEN      (100.0)
285 #define SM_STEMFACTOR   (5.0 / 7.0)     /* grace/cue factor */
286
287 /* number of stepsizes by which a beamed stem can be shortened */
288 #define MINSTEMSHORTEN  (0.0)
289 #define MAXSTEMSHORTEN  (2.0)
290 #define DEFSTEMSHORTEN  (1.0)
291
292 /* what fraction of each lyrics syllable goes left of the center of chord */
293 #define MINLYRICSALIGN  (0.0)
294 #define MAXLYRICSALIGN  (1.0)
295 #define DEFLYRICSALIGN  (0.25)
296
297 /* size of the paper */
298 #define MINPAGEHEIGHT   (2.0)
299 #define MAXPAGEHEIGHT   (24.0)
300 #define DEFPAGEHEIGHT   (11.0)
301 #define MINPAGEWIDTH    (2.0)
302 #define MAXPAGEWIDTH    (24.0)
303 #define DEFPAGEWIDTH    (8.5)
304
305 /* top and bottom margins */
306 #define MINVMARGIN      (0.0)
307 #define MAXVMARGIN      (3.0)
308 #define DEFVMARGIN      (0.5)
309
310 /* left and right margins */
311 #define MINHMARGIN      (0.0)
312 #define MAXHMARGIN      (3.0)
313 #define DEFHMARGIN      (0.5)
314
315 /* panels per page */
316 #define MINPANELSPERPAGE        (1)
317 #define MAXPANELSPERPAGE        (2)
318 #define DEFPANELSPERPAGE        (1)
319
320 /* how tightly to pack the stuff horizontally (default value) */
321 #define MINPACKFACT     (0.0)
322 #define DFLTPACKFACT    (1.0)
323 #define MAXPACKFACT     (10.0)
324
325 /* how much to expand long notes relative to short ones */
326 #define MINPACKEXP      (0.0)
327 #define DFLTPACKEXP     (0.8)
328 #define MAXPACKEXP      (1.0)
329
330 /* time signature */
331 #define MINNUMERATOR    (1)
332 #define MAXNUMERATOR    (99)
333
334 #define MINDENOMINATOR  (1)
335 #define MAXDENOMINATOR  (64)
336
337 #define MINDIVISION     (1)
338 #define DEFDIVISION     (192)
339 #define MAXDIVISION     (3 * 512)
340
341 /* define values for the "release" parameter, in milliseconds */
342 #define MINRELEASE      (0)
343 #define DEFRELEASE      (20)
344 #define MAXRELEASE      (500)
345
346 /* define values for the "sylposition" parameter, in points */
347 #define MINSYLPOSITION  (-100)
348 #define MAXSYLPOSITION  (100)
349 #define DEFSYLPOSITION  (-5)
350 #define NOSYLPOSITION   (11111) /* this means it is not set */
351
352
353 /*
354  * Define sets of symbols which probably should have been done as enums,
355  * but in ANSI C enums aren't much good anyhow.  =============================
356  * Also define some macros for testing these enums.
357  */
358
359 /*
360  * To limit the number of terminal symbols so that yacc won't blow up,
361  * several tokens map to the same terminal symbol, and we set a variable
362  * (yylval) to say which particular one was actually seen.
363  */
364 #define F_STAFFS        (1)
365 #define F_OCTAVE        (2)
366 #define F_LYRSIZE       (3)
367 #define F_VERTSPACE     (4)
368 #define F_SIZE          (5)
369
370 #define F_TOPMARGIN     (6)
371 #define F_BOTMARGIN     (7)
372 #define F_LEFTMARGIN    (8)
373 #define F_RIGHTMARGIN   (9)
374
375 #define F_TIMEUNIT      (10)
376 #define F_VSCHEME       (11)
377
378 #define F_BRACKET       (12)
379 #define F_BRACE         (13)
380 #define F_BARSTYLE      (14)
381
382 #define F_LABEL         (15)
383 #define F_LABEL2        (16)
384
385 #define F_FONT          (17)
386 #define F_LYRFONT       (18)
387
388 #define F_VISIBLE       (19)
389 #define F_VERSES        (20)
390
391 /*
392  * Define all the types of context in the input.  Make each one a bit, so that
393  * we can also define a couple groupings of them.
394  */
395 #define C_HEADER        (0x1)   /* first page header */
396 #define C_FOOTER        (0x2)   /* first page footer */
397 #define C_HEAD2         (0x4)   /* later page header */
398 #define C_FOOT2         (0x8)   /* later page footer */
399 #define C_TOP           (0x10)  /* initial block at top */
400 #define C_BOT           (0x20)  /* initial block at bottom */
401 #define C_TOP2          (0x40)  /* later block at top */
402 #define C_BOT2          (0x80)  /* later block at bottom */
403 #define C_BLOCK         (0x100) /* other block */
404 #define C_SCORE         (0x200) /* the whole score */
405 #define C_STAFF         (0x400) /* a staff */
406 #define C_VOICE         (0x800) /* a voice */
407 #define C_MUSIC         (0x1000) /* notes, etc. */
408 #define C_GRIDS         (0x2000) /* chord grids */
409 #define C_HEADSHAPES    (0x4000) /* head shapes for notehead characters */
410
411 /* context classes--combining things that mostly have the same rules */
412 #define C_BLOCKHEAD     (C_HEADER | C_FOOTER | C_HEAD2 | C_FOOT2 | \
413                         C_TOP | C_BOT | C_TOP2 | C_BOT2 | C_BLOCK)
414 #define C_SSV           (C_SCORE | C_STAFF | C_VOICE)
415
416 /* define whether things are measured in inches or centimeters */
417 #define INCHES          (0)
418 #define CM              (1)
419
420 /*
421  * Define the voice schemes.  V_1 means just one voice is on the staff;
422  * the program will decide the stem direction of each group.  V_2OPSTEM
423  * means there are two voices with opposing stems:  the first voice always
424  * points up, and the second one always points down.  V_2FREESTEM means there
425  * are two voices.  If, at any time, one has a space, the other one's stems
426  * can point either way (as with one voice).  Otherwise, the first voice
427  * points up and the second one down.
428  * V_3OPSTEM and V_3FREESTEM are just like the "2" ones, except that a third
429  * voice is allowed to exist.  Its stem direction is determined elsewhere.
430  */
431 #define V_1             (0)
432 #define V_2OPSTEM       (1)
433 #define V_2FREESTEM     (2)
434 #define V_3OPSTEM       (3)
435 #define V_3FREESTEM     (4)
436
437 /*
438  * Define the modes of the voicecombine parameter.
439  */
440 /* bottom note of high voice must be higher than top note of low voice */
441 #define VC_NOOVERLAP    (0)
442 /* bottom note of high voice must be no lower than top note of low voice */
443 #define VC_SHAREONE     (1)
444 /* no restrictions */
445 #define VC_OVERLAP      (2)
446
447 /*
448  * Define the staff style vis-a-vis printing of clefs, accidentals (in key
449  * signatures and otherwise), and tranposing.  WARNING:  SS_NOTHING must be
450  * defined to be 0 so that calloc inits the field to this.
451  */
452 #define SS_NOTHING      (0)     /* no transpose; print no clef, no accidentals*/
453 #define SS_NORMAL       (1)     /* normal printing */
454 #define SS_DRUM         (2)     /* like SS_NOTHING, but print a "drum clef" */
455
456 /*
457  * Define the time signature types.  NUMERIC is the usual two-number
458  * signature.  INVISNUM is the same, except that it will not be printed.
459  * Common and cut time are noted here separately.  But for all other
460  * purposes they are treated as 4/4 and 2/2 respectively.
461  */
462 #define TS_NUMERIC      (0)
463 #define TS_INVISNUM     (1)
464 #define TS_COMMON       (2)
465 #define TS_CUT          (3)
466
467 /*
468  * Special bytes used inside time signature representation.
469  * These values need to be outside the range of time signature numerators
470  * and denominators, but small enough to fit in a byte.
471  * Probably safer to keep them under 128 as well, to avoid any possible
472  * issues with negative chars.
473  *
474  * Here's how the encoding works:
475  * cut and common get stored as TSR_CUT and TSR_COMMON respectively.
476  * If a + is used between a denominator of one fraction
477  * and numerator of another, it is encoded as TSR_ADD.
478  * When a + is used inside a numerator, nothing is stored at all,
479  * since it is clear all numbers up to the slash
480  * must be components of the numerator.
481  * White space rather than + after a denominator
482  * means alternating time signatures, marked internally by TSR_ALTERNATING.
483  * Numbers are stored as their binary values.
484  * A TSR_END is placed at the end of everything to mark the end.
485  * A null is used for that, so one could use things like strlen or strcpy
486  * on a representation.
487  */
488 #define TSR_CUT         (MAXNUMERATOR + 1)
489 #define TSR_COMMON      (MAXNUMERATOR + 2)
490 #define TSR_SLASH       (MAXNUMERATOR + 3)
491 #define TSR_ADD         (MAXNUMERATOR + 4)
492 #define TSR_ALTERNATING (MAXNUMERATOR + 5)
493 #define TSR_END         (0)
494
495 /*
496  * This is the maximum length of an internal time signature representation.
497  * Note that the internal form is more compact than the input form,
498  * so even something so ridiculously complicated that it's doubtful any
499  * human could keep it straight, like
500  *   3+1+4/16 + cut + 7+11+41/2  9+2/64 + 5+7+31+29/1 + com
501  * would only take 28 bytes, so 40 should be plenty!
502  * The maximum number of numerator components 40 bytes could accomodate
503  * would be 37, so maximum theoretical effective time signature
504  * would be thirty-seven 99's or 3663 counts.
505  */
506 #define MAXTSLEN        40
507
508 /*
509  * Define when time signatures should be printed.  "Once" means when it
510  * changes.  "Always" makes sense only when there is an alternating time sig,
511  * and it means print it at each measure.
512  */
513 #define PTS_NEVER       (0)     /* user input "n" */
514 #define PTS_ONCE        (1)     /* user input nothing */
515 #define PTS_ALWAYS      (2)     /* user input "y" */
516
517 /*
518  * Define the clefs that are allowed.  The values are important, so that
519  * the program can conveniently figure note positions without having a
520  * separate case for each value.
521  */
522 #define TREBLE_8A       (-7)
523 #define FRENCHVIOLIN    (-2)
524 #define TREBLE          (0)
525 #define SOPRANO         (2)
526 #define MEZZOSOPRANO    (4)
527 #define ALTO            (6)
528 #define TREBLE_8        (7)
529 #define TENOR           (8)
530 #define BARITONE        (10)
531 #define BASS            (12)
532 #define TABCLEF         (-1)    /* tablature "clef" */
533 #define NOCLEF          (-99)   /* no clef is present */
534
535 /*
536  * Define what a GRPSYL structure can represent.
537  */
538 #define GS_GROUP        (0)
539 #define GS_SYLLABLE     (1)
540
541 /*
542  * Define the different contents a group can have.
543  */
544 #define GC_NOTES        (0)
545 #define GC_REST         (1)
546 #define GC_SPACE        (2)
547
548 /*
549  * Define the time values a group can have.  Only note groups can be other than
550  * normal (grace notes).  There are no grace rests or spaces.
551  */
552 #define GV_NORMAL       (0)
553 #define GV_ZERO         (1)
554
555 /*
556  * Define the unknown value for headshapes.  The other values aren't defined
557  * here because they are established as headshapes are loaded at run time.
558  * There is a built-in set of these that are loaded, and then the user can use
559  * the "headshapes" context to load more.  Each headshape number corresponds to
560  * a headshape name, such as "norm", "xnote", "rect", etc., and stands for the
561  * set of music characters used to print note heads of the various basictimes.
562  */
563 #define HS_UNKNOWN      (0)
564
565 /*
566  * Define the size of a group.  Spaces are always normal, but notes and rests
567  * can have different sizes.  For note groups, this can vary on a per-note
568  * basis.
569  */
570 #define GS_NORMAL       (0)
571 #define GS_SMALL        (1)
572
573 /*
574  * Define position that you can be in relative to a list of objects.
575  */
576 #define NOITEM          (0)     /* not within a list */
577 #define STARTITEM       (1)     /* first item in a list */
578 #define INITEM          (2)     /* interior item in a list */
579 #define ENDITEM         (3)     /* last item in a list */
580 #define LONEITEM        (4)     /* only item in a list */
581
582
583 /*
584  * Define the directions for various items.
585  */
586 #define UNKNOWN (0)
587 #define UP      (1)
588 #define DOWN    (2)
589
590
591 /*
592  * Define values for controlling printing of tuplet numbers and brackets.
593  * For PT_DEFAULT, the bracket will be printed unless all the notes of the
594  * tuplet (and no other notes) form a beamed set.
595  */
596 #define PT_NEITHER      (0)     /* never print number or bracket */
597 #define PT_DEFAULT      (1)     /* always print number; maybe print bracket */
598 #define PT_BOTH         (2)     /* always print number and bracket */
599 #define PT_NUMBER       (3)     /* always print just the number */
600
601
602 /*
603  * Coordinate types that can have location variables associated with them.
604  */
605 #define CT_BUILTIN      (1)
606 #define CT_GRPSYL       (2)
607 #define CT_BAR          (4)
608 #define CT_NOTE         (8)
609 #define CT_INVISIBLE    (128)
610
611
612 /*
613  * Define the types of STUFF structure.  "Stuff" is things that are to be
614  * printed other than the actual music and lyrics.
615  */
616 #define ST_ROM          (0)
617 #define ST_BOLD         (1)
618 #define ST_ITAL         (2)
619 #define ST_BOLDITAL     (3)
620 #define ST_CRESC        (4)
621 #define ST_DECRESC      (5)
622 #define ST_MUSSYM       (6)
623 #define ST_PEDAL        (7)
624 #define ST_TIESLUR      (8)
625 #define ST_TABSLUR      (9)
626 #define ST_BEND         (10)
627 #define ST_PHRASE       (11)
628 #define ST_OCTAVE       (12)
629 #define ST_MIDI         (13)
630
631 #define IS_TEXT(stype)  ((stype) == ST_ROM || (stype) == ST_ITAL ||     \
632                         (stype) == ST_BOLD || (stype) == ST_BOLDITAL)
633
634 /*
635  * Define the places where the stuff can be printed, relative to staff(s).
636  */
637 #define PL_ABOVE        (0)
638 #define PL_BELOW        (1)
639 #define PL_BETWEEN      (2)
640 #define PL_UNKNOWN      (3)
641 #define NUM_PLACE       (3)     /* number of "good" places (exclude unknown) */
642
643 /*
644  * Define the ways a user can specify the horizonal offset of a group from the
645  * chord's X coordinate.
646  */
647 #define HO_NONE         (0)     /* not specified */
648 #define HO_LEFT         (1)     /* "-" (next to other group(s), on the left) */
649 #define HO_RIGHT        (2)     /* "+" (next to other group(s), on the right) */
650 #define HO_VALUE        (3)     /* "+/-N" (offset given by GRPSYL.ho_value) */
651
652 /*
653  * Define text modifiers:  different flavors of rom, bold, ital, and
654  * boldital.  TM_DYN also applies automatically to the hairpin stuffs, < and >.
655  */
656 #define TM_NONE         (0)
657 #define TM_CHORD        (1)
658 #define TM_ANALYSIS     (2)
659 #define TM_FIGBASS      (3)
660 #define TM_DYN          (4)
661
662 #define IS_CHORDLIKE(x) ((x) == TM_CHORD || (x) == TM_ANALYSIS ||       \
663                         (x) == TM_FIGBASS)
664
665 /*
666  * Define values for dist_usage in STUFF.
667  */
668 #define SD_NONE         (0)     /* user did not specify */
669 #define SD_MIN          (1)     /* user specified minimum distance */
670 #define SD_FORCE        (2)     /* user is forcing this distance */
671
672 /*
673  * Define all the types of marks that the user can request to be stacked in
674  * different orders.  This list is in increasing order of the default priority
675  * of stacking, except that by default MK_DYN, MK_OTHERTEXT, and MK_CHORD are
676  * of equal priority.  If this list changes, make sure that Defmarkorder[]
677  * is updated too.  For each place (above, below, between), the user can
678  * specify a different ordering of priority to be used.  There is a restriction
679  * that the last ones (MK_LYRICS, MK_ENDING, MK_REHEARSAL, MK_PEDAL) must
680  * have a different priority from each other and any of the other ones.  Also,
681  * MK_PEDAL is allowed only below; MK_ENDING and MK_REHEARSAL are allowed only
682  * above; and those three and MK_OCTAVE are not allowed between.
683  */
684 #define MK_MUSSYM       (0)     /* ST_MUSSYM */
685 #define MK_OCTAVE       (1)     /* ST_OCTAVE */
686 #define MK_DYN          (2)     /* ST_CRESC or ST_DECRESC; or ST_ROM, */
687                                 /* ST_ITAL, ST_BOLD, ST_BOLDITAL with "dyn" */
688                                 /* (TM_DYN is set for these and only these) */
689 #define MK_OTHERTEXT    (3)     /* ST_ROM, ST_ITAL, ST_BOLD, ST_BOLDITAL */
690                                 /* without chord/analysis/figbass or dyn */
691 #define MK_CHORD        (4)     /* ST_ROM, ST_ITAL, ST_BOLD, ST_BOLDITAL */
692                                 /* with chord, analysis, or figbass */
693                                 /* (TM_CHORD is set for these and only these) */
694 #define MK_LYRICS       (5)     /* lyrics */
695 #define MK_ENDING       (6)     /* ending mark */
696 #define MK_REHEARSAL    (7)     /* rehearsal mark */
697 #define MK_PEDAL        (8)     /* ST_PEDAL */
698 #define NUM_MARK        (9)     /* this must follow the last MK */
699
700 /*
701  * While parsing, we need to temporarily store some things as pseudo-pitches.
702  * When the user does not specify any pitch for the first group of a measure,
703  * we temporarily use PP_NO_PITCH, since not specifying a pitch is legal iff it
704  * is for one or more 1-line staffs, but it's not easy to check on that until
705  * later.  We also need to save rest, space, and rpt as pseudo notes until we
706  * later map them to groups.
707  */
708 #define PP_NO_PITCH     'h'
709 #define PP_REST         'r'
710 #define PP_SPACE        's'
711 #define PP_RPT          'p'
712
713 /*
714  * Define the other staff that a given staff's groups are beamed or stemmed to.
715  */
716 #define CS_SAME         (0)
717 #define CS_ABOVE        (1)
718 #define CS_BELOW        (2)
719
720 /*
721  * Define symbols for indexing coordinate arrays.  The first 12 are X, Y,
722  * north, south, east, and west, both relative and absolute.  Not all things
723  * that have coordinates bother to set all 12 of these.  There should be
724  * comments in structs.h saying which things get set for what.
725  *
726  * In GRPSYL, during the time that positions of phrase marks are being
727  * figured out, AN and AS are used in a strange way.  But later, they get
728  * set to their intended values.
729  *
730  * The 13th is a special number used by nongrace notes and GRPSYLs, and BARs
731  * only.  For notes and GRPSYLs, it has the following meaning.  It indicates
732  * how many inches of horizontal space would be allocated to this object
733  * if it were a whole note instead of whatever it actually is, but were
734  * allocated space proportionally.  That is, fulltime times this number
735  * is the amount of space between the X coordinates of this GRPSYL and
736  * the next one in the measure (or the bar line if this is the last GRPSYL
737  * in the measure).  Notice that even for notes, it's the X coordinate of
738  * the note's GRPSYL that count, even if the note head is on the "wrong"
739  * side of the stem.  For BARs, this 13th number has a similiar use.  If
740  * you pretend that a bar line is count 0 of the following measure, and
741  * the first GRPSYL of the measure is at count 1 (whichever type of note
742  * constitutes a "count"), this number is how many inches would be allocated
743  * to a whole note instead of the one count of space that is there.
744  */
745 #define RX      (0)
746 #define RY      (1)
747 #define RN      (2)
748 #define RS      (3)
749 #define RE      (4)
750 #define RW      (5)
751 #define AX      (6)
752 #define AY      (7)
753 #define AN      (8)
754 #define AS      (9)
755 #define AE      (10)
756 #define AW      (11)
757 #define INCHPERWHOLE    (12)
758 #define NUMCTYPE        (13)
759
760
761 /*
762  * AN and AS of group coordinates are used temporarily to store the distance
763  * from the group to any phrase marks, to be used to make sure nesting phrases
764  * don't impinge on that space. But if a group has a phrase ending on it and
765  * another beginning on it, those won't collide.  So use bitmap to keep track
766  * of whether the AN and AS values apply to east side, west side, or both.
767  * (phraseside in GRPSYL is a bit map.)
768  */
769 #define EAST_SIDE       (1 << 0)
770 #define WEST_SIDE       (1 << 1)
771
772
773 /*
774  * Define the types of bar line.
775  */
776 #define INVISBAR        (0)
777 #define SINGLEBAR       (1)
778 #define DOUBLEBAR       (2)
779 #define REPEATSTART     (3)
780 #define REPEATEND       (4)
781 #define REPEATBOTH      (5)
782 #define ENDBAR          (6)
783 #define RESTART         (7)
784
785 /*
786  * Define the types of font, leaving 0 unused to avoid ending up having
787  * null characters appear in strings where this number is stored,
788  * and to have something convenient to use to flag an unknown font.
789  * WARNING:  the getfontinfo.c program depends on all the font names
790  * beginning with "FONT_", and on MAXFONTS being at the end of the list.
791  */
792 #define FONT_UNKNOWN    (0)
793 #define FAMILY_DFLT     (-1)
794
795 #define BASE_TIMES      (0)
796 #define FONT_TR         (1)
797 #define FONT_TI         (2)
798 #define FONT_TB         (3)
799 #define FONT_TX         (4)
800
801 #define BASE_AVANTGARDE (FONT_TX)
802 #define FONT_AR         (BASE_AVANTGARDE + FONT_TR)
803 #define FONT_AI         (BASE_AVANTGARDE + FONT_TI)
804 #define FONT_AB         (BASE_AVANTGARDE + FONT_TB)
805 #define FONT_AX         (BASE_AVANTGARDE + FONT_TX)
806
807 #define BASE_COURIER    (FONT_AX)
808 #define FONT_CR         (BASE_COURIER + FONT_TR)
809 #define FONT_CI         (BASE_COURIER + FONT_TI)
810 #define FONT_CB         (BASE_COURIER + FONT_TB)
811 #define FONT_CX         (BASE_COURIER + FONT_TX)
812
813 #define BASE_HELVETICA  (FONT_CX)
814 #define FONT_HR         (BASE_HELVETICA + FONT_TR)
815 #define FONT_HI         (BASE_HELVETICA + FONT_TI)
816 #define FONT_HB         (BASE_HELVETICA + FONT_TB)
817 #define FONT_HX         (BASE_HELVETICA + FONT_TX)
818
819 #define BASE_BOOKMAN    (FONT_HX)
820 #define FONT_BR         (BASE_BOOKMAN + FONT_TR)
821 #define FONT_BI         (BASE_BOOKMAN + FONT_TI)
822 #define FONT_BB         (BASE_BOOKMAN + FONT_TB)
823 #define FONT_BX         (BASE_BOOKMAN + FONT_TX)
824
825 #define BASE_NEWCENTURY (FONT_BX)
826 #define FONT_NR         (BASE_NEWCENTURY + FONT_TR)
827 #define FONT_NI         (BASE_NEWCENTURY + FONT_TI)
828 #define FONT_NB         (BASE_NEWCENTURY + FONT_TB)
829 #define FONT_NX         (BASE_NEWCENTURY + FONT_TX)
830
831 #define BASE_PALATINO   (FONT_NX)
832 #define FONT_PR         (BASE_PALATINO + FONT_TR)
833 #define FONT_PI         (BASE_PALATINO + FONT_TI)
834 #define FONT_PB         (BASE_PALATINO + FONT_TB)
835 #define FONT_PX         (BASE_PALATINO + FONT_TX)
836
837 #ifdef EXTCHAR
838 /* extra fonts that contain the extended character set start here.
839  * They go in the same order as their corresponding standard ASCII fonts */
840 #define EXT_FONT_OFFSET (FONT_PX - BASE_TIMES)
841
842 #define FONT_XTR        (FONT_TR + EXT_FONT_OFFSET)
843 #define FONT_XTI        (FONT_TI + EXT_FONT_OFFSET)
844 #define FONT_XTB        (FONT_TB + EXT_FONT_OFFSET)
845 #define FONT_XTX        (FONT_TX + EXT_FONT_OFFSET)
846
847 #define FONT_XAR        (FONT_AR + EXT_FONT_OFFSET)
848 #define FONT_XAI        (FONT_AI + EXT_FONT_OFFSET)
849 #define FONT_XAB        (FONT_AB + EXT_FONT_OFFSET)
850 #define FONT_XAX        (FONT_AX + EXT_FONT_OFFSET)
851
852 #define FONT_XCR        (FONT_CR + EXT_FONT_OFFSET)
853 #define FONT_XCI        (FONT_CI + EXT_FONT_OFFSET)
854 #define FONT_XCB        (FONT_CB + EXT_FONT_OFFSET)
855 #define FONT_XCX        (FONT_CX + EXT_FONT_OFFSET)
856
857 #define FONT_XHR        (FONT_HR + EXT_FONT_OFFSET)
858 #define FONT_XHI        (FONT_HI + EXT_FONT_OFFSET)
859 #define FONT_XHB        (FONT_HB + EXT_FONT_OFFSET)
860 #define FONT_XHX        (FONT_HX + EXT_FONT_OFFSET)
861
862 #define FONT_XBR        (FONT_BR + EXT_FONT_OFFSET)
863 #define FONT_XBI        (FONT_BI + EXT_FONT_OFFSET)
864 #define FONT_XBB        (FONT_BB + EXT_FONT_OFFSET)
865 #define FONT_XBX        (FONT_BX + EXT_FONT_OFFSET)
866
867 #define FONT_XNR        (FONT_NR + EXT_FONT_OFFSET)
868 #define FONT_XNI        (FONT_NI + EXT_FONT_OFFSET)
869 #define FONT_XNB        (FONT_NB + EXT_FONT_OFFSET)
870 #define FONT_XNX        (FONT_NX + EXT_FONT_OFFSET)
871
872 #define FONT_XPR        (FONT_PR + EXT_FONT_OFFSET)
873 #define FONT_XPI        (FONT_PI + EXT_FONT_OFFSET)
874 #define FONT_XPB        (FONT_PB + EXT_FONT_OFFSET)
875 #define FONT_XPX        (FONT_PX + EXT_FONT_OFFSET)
876
877 #define BASE_MISC       (FONT_XPX)
878 #else
879 #define BASE_MISC       (FONT_PX)
880 #endif
881 #define FONT_ZD         (BASE_MISC + 1)
882 #define FONT_ZI         (BASE_MISC + 2)
883 #define FONT_MUSIC      (BASE_MISC + 3)
884 #define FONT_MUSIC2     (BASE_MISC + 4)
885 #define MAXFONTS        (BASE_MISC + 5)
886
887 /* number of music fonts */
888 #define NUM_MFONTS      (2)
889
890 /* first printable character in a font */
891 #define FIRST_CHAR      (32)
892
893 /*
894  * The following value plus FIRST_CHAR needs to be at least as large as
895  * one more than the largest value in either muschar.h or extchar.h
896  */
897 #define CHARS_IN_FONT   (96)
898
899 /*
900  * Find array offset into height, width, and ascent tables.  This is character
901  * code -FIRST_CHAR, to skip ASCII control characters.
902  */
903 #define CHAR_INDEX(c)   ((c) - FIRST_CHAR)
904
905 /*
906  * Test if a font is a "music" font.
907  */
908 #define IS_MUSIC_FONT(f)        ((f) == FONT_MUSIC || (f) == FONT_MUSIC2)
909
910 /*
911  * Special commands to use inside internal format of strings.
912  * All use high-bit==1 to indicate a command.
913  * Note that the low order bits of STR_MUS_CHAR* specify which music font it is.
914  */
915 #define STR_MUS_CHAR            0x80    /* followed by 1-byte size and 1-byte \
916                                          * music character code */
917 #define STR_MUS_CHAR2           0x81    /* same rules as above */
918 #define STR_FONT                0xe0    /* followed by 1-byte font number */
919 #define STR_SIZE                0xe1    /* followed by 1-byte size */
920 #define STR_PAGENUM             0xe2    /* followed by '%' */
921 #define STR_NUMPAGES            0xe3    /* followed by '#' */
922 #define STR_PRE                 0xe4    /* pre-syl <--->, ignored in spacing */
923 #define STR_U_PRE               0xe5    /* pre-syl <...>, used in spacing */
924 #define STR_PRE_END             0xe6    /* end of pre-syllable <...> */
925 #define STR_PST                 0xe7    /* post-syl <...>, ignored in spacing */
926 #define STR_U_PST               0xe8    /* post-syl <...>, used in spacing */
927 #define STR_PST_END             0xe9    /* end of post-syllable <...> */
928 /*
929  * Backspace is a bit strange.  The amount to back up varies because of
930  * proportionally spaced fonts.  So we save the distance in terms of the width
931  * in 250ths of an inch in the default size.  The actual distance to back up is
932  * then that number times the ratio of the current actual size to the default
933  * size divided by 250.  250 was chosen because that means a range of 1-127
934  * (to make sure it is non-zero and with high-bit of zero)
935  * will give a range of .004 to 0.508 inches, which should cover all
936  * characters we have today (the widest of which is currently just over 1/4").
937  * This is done in floating point, so no reason to use a power of 2 like 256.
938  */
939 #define STR_BACKSPACE           0xea    /* followed by how much to back up */
940
941 #define BACKSP_FACTOR           (250.0)
942
943 /* string commands for boxed text */
944 #define STR_BOX                 0xeb
945 #define STR_BOX_END             0xec
946 #define IS_BOXED(string)   (((string[2] & 0xff) == (STR_BOX & 0xff)) ? YES : NO)
947
948 #define STR_VERTICAL            0xed    /* vert move followed by 1-byte dist */
949 #define STR_L_ALIGN             0xee    /* align at left edge of next char */
950 #define STR_C_ALIGN             0xef    /* align at center of next char */
951 #define STR_PILE                0xf0    /* toggle for piling, \: */
952 #define STR_SLASH               0xf1    /* slash used by figbass, \/ */
953
954 /* string commands for circled text */
955 #define STR_CIR                 0xf2
956 #define STR_CIR_END             0xf3
957 #define IS_CIRCLED(string) (((string[2] & 0xff) == (STR_CIR & 0xff)) ? YES : NO)
958
959 /*
960  * Define macros relating to vertical movement within a string.  It is stored
961  * in points, offset by a bias so that the number will always be positive when
962  * stored in the byte after the STR_VERTICAL in a string.
963  */
964 #define MINVERTICAL     (-50)
965 #define MAXVERTICAL     (50)
966 #define VERT_BIAS       (1 - MINVERTICAL)
967 #define ENCODE_VERT(x)  (x + VERT_BIAS)
968 #define DECODE_VERT(x)  (x - VERT_BIAS)
969
970 /*
971  * Macro to determine if a character in an internal-format string is a
972  * command character.
973  */
974 #define IS_STR_COMMAND(c)       ((c) & 0x80)
975
976
977 #define DFLT_SIZE       (12)
978 #define SMALLSIZE       ((int)(DFLT_SIZE * SM_FACTOR))
979
980 /*
981  * Define the default font size of a measure number.
982  */
983 #define MNUM_SIZE       (11)
984
985 /*
986  * Define types of lines and curves.
987  */
988 #define L_NORMAL        (0)
989 #define L_MEDIUM        (1)
990 #define L_WIDE          (2)
991 #define L_WAVY          (3)
992 #define L_DOTTED        (4)
993 #define L_DASHED        (5)
994
995 /*
996  * Define the kinds of justification.
997  */
998 #define J_LEFT          (1)
999 #define J_RIGHT         (2)
1000 #define J_CENTER        (3)
1001 #define J_NONE          (4)
1002 #define J_RAGPARA       (5)     /* ragged-right paragraph */
1003 #define J_JUSTPARA      (6)     /* justified paragraph */
1004
1005 /*
1006  * Define the ending styles (which staffs 1st, 2nd, etc. endings are to
1007  * be drawn on).
1008  */
1009 #define ENDING_TOP      (0)     /* only above top visible staff */
1010 #define ENDING_BARRED   (1)     /* above each group of staffs barred together*/
1011 #define ENDING_GROUPED  (2)     /* above each group of staffs grouped */
1012                                 /*  together by braces or brackets */
1013
1014 /*
1015  * Define types of rehearsal letters/numbers.
1016  */
1017 #define REH_NONE        (0)     /* none at all */
1018 #define REH_STRING      (1)     /* user-supplied string */
1019 #define REH_NUM         (2)     /* consecutive numbers 1, 2, 3, . . . */
1020 #define REH_LET         (3)     /* consecutive letters A, B, C, . . . */
1021 #define REH_MNUM        (4)     /* use current measure number */
1022
1023 /*
1024  * Define the style of (ways of drawing) rehearsal letters/numbers.
1025  */
1026 #define RS_PLAIN        (0)     /* just the letter/number */
1027 #define RS_BOXED        (1)     /* enclosed in a box */
1028 #define RS_CIRCLED      (2)     /* enclosed in a circle */
1029
1030 /*
1031  * Define the ways to print pedal markings.
1032  */
1033 #define P_LINE          (0)     /* draw a line under where the pedal is down */
1034 #define P_PEDSTAR       (1)     /* print "Ped." and the start and "*" at end */
1035 #define P_ALTPEDSTAR    (2)     /* like P_PEDSTAR but only "Ped." when bounce*/
1036
1037 /*
1038  * Define the side of a stem that a partial beam can be on.  There is code in
1039  * prntdata.c that depends on these values, -1 and 1.
1040  */
1041 #define PB_LEFT         (-1)
1042 #define PB_RIGHT        (1)
1043
1044 /*
1045  * Define types of intervals.  There is code that depends on these being in
1046  * this order, starting from 0, counting up (like in trnspose.c).
1047  */
1048 #define DIMINISHED      (0)
1049 #define MINOR           (1)
1050 #define PERFECT         (2)
1051 #define MAJOR           (3)
1052 #define AUGMENTED       (4)
1053
1054 /*
1055  * Define the input style.
1056  */
1057 #define IS_VOICE_INPUT  (0)     /* voice-at-a-time (must be zero) */
1058 #define IS_CHORD_INPUT  (1)     /* chord-at-a-time */
1059
1060 /*
1061  * Define the valid page sizes. The values must match the indexes of
1062  * pagesztbl in gram.y.
1063  */
1064 #define PS_LETTER       (0)
1065 #define PS_LEGAL        (1)
1066 #define PS_FLSA         (2)
1067 #define PS_HALFLETTER   (3)
1068 #define PS_A4           (4)
1069 #define PS_A5           (5)
1070 #define PS_A6           (6)
1071
1072 /* Define page orientations */
1073 #define O_PORTRAIT      (0)
1074 #define O_LANDSCAPE     (1)
1075
1076 /*
1077  * Define various constants =============================================
1078  */
1079
1080 /* the number of PostScript points in one inch */
1081 #define PPI             (72.0)
1082
1083 /* the size of a point in inches */
1084 #define POINT           (1.0 / PPI)
1085
1086 /* the distance between a note and the next higher note */
1087 #define STEPSIZE        (3.0 * POINT)
1088
1089 /* size of white space for surrounding things that should be padded thus */
1090 #define STDPAD          (STEPSIZE / 3.0)
1091
1092 /* (distance between tab staff lines) / (distance between normal staff lines)*/
1093 #define TABRATIO        (1.735)
1094
1095 /* scaling factor giving size of "sm" (small) music chars relative to normal */
1096 #define SM_FACTOR       (0.65)
1097
1098 /* scaling factor giving size of a grace fret number relative to normal */
1099 #define SMFRETSIZE      ((int)(0.80 * DFLT_SIZE))
1100
1101 /* font character size information is stored in FONTFACTORs of an inch */
1102 #define FONTFACTOR      (1000.0)
1103
1104 /* widths of various types of lines, in points */
1105 #define W_NORMAL        (0.7)
1106 #define W_MEDIUM        (1.5)
1107 #define W_WIDE          (3.0)
1108
1109 /* vertical distance between two flags or two beams */
1110 #define FLAGSEP         (1.6 * STEPSIZE)        /* for normal notes */
1111 #define SMFLAGSEP       (FLAGSEP * SM_FACTOR)   /* for cue or grace notes */
1112
1113 /* minimum width to be given to a multirest */
1114 #define MINMULTIWIDTH   (0.7)
1115
1116 /* temporary width for a measure rest, serves as a marker */
1117 #define TEMPMRPTWIDTH   (0.02)
1118
1119 /* half the width of a restart bar */
1120 #define HALF_RESTART_WIDTH      (12 * POINT)
1121
1122 /* padding provided to force more room between groups for various reasons */
1123 #define TIESLURPAD      (0.12)  /* ties and slurs */
1124 #define SLASHPAD        (0.06)  /* slashes through stems */
1125 #define ALTPAD          (0.12)  /* alternation beams between groups */
1126 #define ROLLPADDING     (12 * STDPAD)   /* a roll to the left of a group */
1127
1128 /* padding to be put after a clef */
1129 #define CLEFPAD         (2.0 * STDPAD)
1130
1131 /* how high certain things are */
1132 #define TUPHEIGHT       (10.0/3.0 * STEPSIZE)   /* tuplet bracket */
1133 #define OCTHEIGHT       (10.0/3.0 * STEPSIZE)   /* octave bracket */
1134 #define ENDINGHEIGHT    (13.0/3.0 * STEPSIZE)   /* ending bracket */
1135 #define MULTIHEIGHT     (12.0/3.0 * STEPSIZE)   /* multirest number */
1136 #define MINWITHHEIGHT   (2.2 * STEPSIZE)        /* minimum "with" list item */
1137
1138 /* horizontal extent of a slash, in stepsizes */
1139 #define SLASHHORZ       (5.0 / 3.0)
1140
1141 /*
1142  * The maximum number of notes there could ever be in a "hand" (the notes of a
1143  * chord that occur on a given staff) is the number of unique notes that can
1144  * exist, C0 through B9.
1145  */
1146 #define MAXHAND         ((MAXOCTAVE - MINOCTAVE + 1) * 7)
1147
1148 /* the length in the X direction of a tabslur to or from nowhere */
1149 #define SLIDEXLEN       (3.0 * STEPSIZE)
1150
1151 /* define the default distance, in stepsizes, between the lines of a grid */
1152 #define WHEREUSED_GS    (1.6)   /* when printed by the music */
1153 #define ATEND_GS        (2.0)   /* when printed at the end of the song */
1154
1155 #define NO              (0)
1156 #define YES             (1)
1157
1158 /* the "used" field in input SSVs uses the following in addition to YES/NO */
1159 #define UNSET           (2)
1160
1161 #ifndef PI
1162 #define PI      (3.141592653589793)
1163 #endif
1164
1165 #define CMPERINCH       (2.54)          /* centimeters per inch */
1166
1167 /*
1168  * Define miscellaneous macros =============================================
1169  */
1170
1171 /* number of elements in an array */
1172 #define NUMELEM(a)      (sizeof(a) / sizeof((a)[0]))
1173
1174 /*
1175  * Define macros for allocating structures.
1176  */
1177 #define MALLOC(structtype, new_p, numelem) {                            \
1178         if ((new_p = (struct structtype *)malloc((unsigned)             \
1179                         (((numelem) == 0 ? 1 : (numelem)) *             \
1180                         sizeof(struct structtype)))) == 0)              \
1181                 l_no_mem(__FILE__, __LINE__);                           \
1182 }
1183 #define CALLOC(structtype, new_p, numelem) {                            \
1184         if ((new_p = (struct structtype *)calloc(                       \
1185                         (numelem) == 0 ? 1 : (numelem),                 \
1186                         (unsigned)sizeof(struct structtype)))  == 0)    \
1187                 l_no_mem(__FILE__, __LINE__);                           \
1188 }
1189 #ifndef __STDC__
1190 #define REALLOC(structtype, new_p, numelem) {                           \
1191         if ((new_p = (struct structtype *)realloc((char *)(new_p),      \
1192                         (unsigned)(((numelem) == 0 ? 1 : (numelem)) *   \
1193                         sizeof(struct structtype)))) == 0)              \
1194                 l_no_mem(__FILE__, __LINE__);                           \
1195 }
1196 #else
1197 #define REALLOC(structtype, new_p, numelem) {                           \
1198         if ((new_p = (struct structtype *)realloc((void *)(new_p),      \
1199                         (unsigned)(((numelem) == 0 ? 1 : (numelem)) *   \
1200                         sizeof(struct structtype)))) == 0)              \
1201                 l_no_mem(__FILE__, __LINE__);                           \
1202 }
1203 #endif
1204
1205 /*
1206  * Define macros for allocating other arrays.
1207  */
1208 #define MALLOCA(type, new_p, numelem) {                                 \
1209         if ((new_p = (type *)malloc((unsigned)                          \
1210                         (((numelem) == 0 ? 1 : (numelem)) *             \
1211                         sizeof(type)))) == 0)                           \
1212                 l_no_mem(__FILE__, __LINE__);                           \
1213 }
1214 #define CALLOCA(type, new_p, numelem) {                                 \
1215         if ((new_p = (type *)calloc((numelem) == 0 ? 1 : (numelem),     \
1216                         (unsigned)sizeof(type)))  == 0)                 \
1217                 l_no_mem(__FILE__, __LINE__);                           \
1218 }
1219 #ifndef __STDC__
1220 #define REALLOCA(type, new_p, numelem) {                                \
1221         if ((new_p = (type *)realloc((char *)(new_p),                   \
1222                         (unsigned)(((numelem) == 0 ? 1 : (numelem)) *   \
1223                         sizeof(type)))) == 0)                           \
1224                 l_no_mem(__FILE__, __LINE__);                           \
1225 }
1226 #else
1227 #define REALLOCA(type, new_p, numelem) {                                \
1228         if ((new_p = (type *)realloc((void *)(new_p),                   \
1229                         (unsigned)(((numelem) == 0 ? 1 : (numelem)) *   \
1230                         sizeof(type)))) == 0)                           \
1231                 l_no_mem(__FILE__, __LINE__);                           \
1232 }
1233 #endif
1234
1235 /* define macro for freeing memory */
1236 #ifdef __STDC__
1237 #define FREE(mem_p)     free((void *)mem_p)
1238 #else
1239 #define FREE(mem_p)     free((char *)mem_p)
1240 #endif
1241
1242 /* convert a RATIONAL to a float */
1243 #define RAT2FLOAT(rat)  ( (float)(rat).n / (float)(rat).d )
1244
1245 /* the usual minimum and maximum macros */
1246 #define MAX(a, b)       ( (a) > (b) ? (a) : (b) )
1247 #define MIN(a, b)       ( (a) < (b) ? (a) : (b) )
1248
1249 /* absolute value of the difference of a and b */
1250 #define ABSDIFF(a, b)   ( (a) > (b) ? (a) - (b) : (b) - (a) )
1251
1252 /* even and odd numbers (positive, zero, or negative; works on any compiler) */
1253 #define EVEN(a)         (abs(a) % 2 == 0)
1254 #define ODD(a)          (abs(a) % 2 == 1)
1255
1256 #define SQUARED(x)      ((x) * (x))
1257 #define NEARESTQUARTER(x) ( (int)((x) * 4.0 + 0.5) / 4.0 )
1258
1259 /* half the height of a staff in stepsizes; use 1 for 1-line staffs */
1260 #define HALFSTAFF(s)    ((svpath(s, STAFFLINES)->stafflines == 5) ? 4 : 1)
1261
1262 /* given ptr to a group, return the NOTE struct for note nearest to the beam */
1263 #define BNOTE(gs_p)     \
1264         (gs_p)->notelist[ (gs_p)->stemdir == UP ? 0 : (gs_p)->nnotes - 1 ]
1265
1266 /*
1267  * Define indices into GRPSYL.notelist for the first (FNNI) and last (LNNI)
1268  * non-cross-staff-stemmed notes.  Also define indices for the first (FCNI)
1269  * and last (LCNI) cross-staff-stemmed notes.
1270  *
1271  * For FNNI and LNNI to work, there must be non-CSS notes, although even if
1272  * not, it's still okay to have loops like 
1273  *      for (n = FNNI(gs_p); n <= LNNI(gs_p); n++)
1274  * and the NNN macro, which uses them, always works.
1275  *
1276  * LCNI and FCNI only work if there are CSS notes.
1277  */
1278 #define FNNI(gs_p)      ((gs_p)->stemto == CS_ABOVE ?   \
1279                         (gs_p)->stemto_idx + 1 : 0)
1280 #define LNNI(gs_p)      ((gs_p)->stemto == CS_BELOW ?   \
1281                         (gs_p)->stemto_idx - 1 : (gs_p)->nnotes - 1)
1282 #define FCNI(gs_p)      ((gs_p)->stemto == CS_ABOVE ?   \
1283                         0 : (gs_p)->stemto_idx)
1284 #define LCNI(gs_p)      ((gs_p)->stemto == CS_BELOW ?   \
1285                         (gs_p)->nnotes - 1 : (gs_p)->stemto_idx)
1286
1287 /* define the Number of Normal Notes (non-CSS notes) in a group */
1288 #define NNN(gs_p)       (LNNI(gs_p) - FNNI(gs_p) + 1)
1289
1290 /* test whether the note given via the index is CSS */
1291 #define IS_CSS_NOTE(gs_p, idx)  (                                       \
1292         (((gs_p)->stemto == CS_ABOVE && idx <= (gs_p)->stemto_idx) ||   \
1293          ((gs_p)->stemto == CS_BELOW && idx >= (gs_p)->stemto_idx))     \
1294 )
1295
1296 /* test whether any CSS notes that exist would be on stem side of the group */
1297 #define STEMSIDE_CSS(gs_p)                                      \
1298         ((gs_p)->stemto == CS_ABOVE && (gs_p)->stemdir == UP || \
1299          (gs_p)->stemto == CS_BELOW && (gs_p)->stemdir == DOWN)
1300
1301 /*
1302  * Define CSS_STEPS to be an offset to be applied to "stepsup" when the note is
1303  * on the other staff.  It needs to be at twice as big as the interval between
1304  * the highest and lowest notes so that stepsup plus or minus half of it  will
1305  * become a value that it could never be for a normal note (see doacc()), and
1306  * it has to be an even number, because, for example, that matters for vertical
1307  * dot placement.
1308  */
1309 #define CSS_STEPS       (MAXHAND * 2)
1310
1311 /* is this FEED followed by a CLEFSIG (music), not a block? */
1312 #define IS_CLEFSIG_FEED(mll_p) ((mll_p)->str == S_FEED && \
1313                 (mll_p)->next != 0 && (mll_p)->next->str == S_CLEFSIG)
1314
1315 /*
1316  * This macro is to be used as in this example:
1317  *      extern int func P((int parm1, float parm2));
1318  * The ANSI version will result in a function prototype.  The other version
1319  * will result in a function declaration (no parameters).
1320  */
1321 #ifdef __STDC__
1322 #define P(parms)        parms
1323 #else
1324 #define P(parms)        ()
1325 #endif
1326
1327 #endif