File: abc2ps.h

package info (click to toggle)
abcm2ps 4.8.5-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 944 kB
  • ctags: 1,012
  • sloc: ansic: 15,723; sh: 2,697; makefile: 171
file content (462 lines) | stat: -rw-r--r-- 16,935 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
/* -- general macros -- */

#include "config.h"

#define OUTPUTFILE	"Out.ps"	/* standard output file */
#if defined(unix) || defined(__unix__)
#define DIRSEP '/'
#else
#define DIRSEP '\\'
#endif

/* basic page dimensions */
#ifdef A4_FORMAT
#define PAGEHEIGHT	(29.7 * CM)
#define PAGEWIDTH	(21.0 * CM)
#define MARGIN		(1.8 * CM)
#else
#define PAGEHEIGHT	(11.0 * IN)
#define PAGEWIDTH	(8.5 * IN)
#define MARGIN		(0.7 * IN)
#endif

/* -- macros controlling music typesetting -- */

#define STEM_YOFF	1.0	/* offset stem from note center */
#define STEM_XOFF	3.5
#define STEM		20	/* default stem height */
#define STEM_MIN	16	/* min stem height under beams */
#define STEM_MIN2	12	/* ... for notes with two beams */
#define STEM_MIN3	10	/* ... for notes with three beams */
#define STEM_MIN4	10	/* ... for notes with four beams */
#define STEM_CH_MIN	12	/* min stem height for chords under beams */
#define STEM_CH_MIN2	 8	/* ... for notes with two beams */
#define STEM_CH_MIN3	 7	/* ... for notes with three beams */
#define STEM_CH_MIN4	 7	/* ... for notes with four beams */
#define BEAM_DEPTH	3.2	/* width of a beam stroke (was 2.6) */
#define BEAM_OFFSET	0.25	/* pos of flat beam relative to staff line */
#define BEAM_SHIFT	5.0	/* shift of second and third beams (was 5.3) */
/*  To align the 4th beam as the 1st: shift=6-(depth-2*offset)/3  */
#define BEAM_FLATFAC	0.6	/* factor to decrease slope of long beams */
#define BEAM_THRESH	0.06	/* flat beam if slope below this threshold */
#define BEAM_SLOPE	0.5	/* max slope of a beam */
#define BEAM_STUB	6.0	/* length of stub for flag under beam */ 
#define SLUR_SLOPE	1.0	/* max slope of a slur */
#define DOTSHIFT	5	/* dot shift when up flag on note */
#define GSTEM		14	/* grace note stem length */
#define GSTEM_XOFF	1.6	/* x offset for grace note stem */
#define GSPACE0		12.0	/* space from grace note to big note */
#define GSPACE		8.0	/* space between grace notes */

#define BETA_C		0.1	/* max expansion for flag -c */
#define ALFA_X		1.0	/* max compression before complaining */
#define BETA_X		1.2	/* max expansion before complaining */

#define VOCPRE		0.4	/* portion of vocals word before note */
#define GCHPRE		0.4	/* portion of guitar chord before note */

/* -- Parameters for note spacing -- */
/* -- bnn determines how strongly the first note enters into the spacing.
      For bnn=1, the spacing is calculated using the first note.
      For bnn=0, the spacing is the average for the two notes.
   -- fnn multiplies the spacing under a beam, to compress the notes a bit
   -- gnn multiplies the spacing a second time within a tuplet
 */

#define bnnp 0.9
#define fnnp 0.9
#define gnnp 0.8

/* -- macros for program internals -- */

#define CM		28.35	/* factor to transform cm to pt */
#define PT		1.0	/* factor to transform pt to pt */
#define IN		72.0	/* factor to transform inch to pt */

#define STRL1		256	/* string length for file names */
#define MAXSTAFF	16	/* max staves */
#define BSIZE		512	/* buffer size for one input string */
#define BUFFSZ		64000	/* size of output buffer */
#define BUFFSZ1		5000	/* buffer reserved for one staff */

#define BREVE		(BASE_LEN * 2)	/* double note (square note) */
#define SEMIBREVE	BASE_LEN	/* whole note */
#define MINIM		(BASE_LEN / 2)	/* half note (white note) */
#define CROTCHET 	(BASE_LEN / 4)	/* quarter note (black note) */
#define QUAVER		(BASE_LEN / 8)	/* 1/8 note */
#define SEMIQUAVER	(BASE_LEN / 16)	/* 1/16 note */

#define MAXFONTS	30	/* max number of fonts */
#define MAXENC		6	/* max number of ISO-Latin encodings */
#define ENC_NATIVE	7	/* (see format.c) */

#define OBEYLINES	0
#define T_JUSTIFY	1
#define T_FILL		2
#define OBEYCENTER	3
#define SKIP		4

extern unsigned char deco_glob[256], deco_tune[256];

struct FONTSPEC {
	int fnum;		/* index to font tables in format.c */
	float size;
	float swfac;
};
extern char font_enc[MAXFONTS];	/* font encoding */

/* lyrics */
#define MAXLY	16	/* max number of lyrics */
struct lyl {
	struct FONTSPEC* f;	/* font */
	float w;		/* width */
	float s;		/* shift / note */
	unsigned char t[1];	/* word */
};
struct lyrics {
	struct lyl *lyl[MAXLY];	/* ptr to lyric lines */
};

/* music element */
struct SYMBOL { 		/* struct for a drawable symbol */
	struct abcsym as;	/* abc symbol !!must be the first field!! */
	struct SYMBOL *next, *prev;	/* voice linkage */
	unsigned char type;	/* symbol type */
#define NO_TYPE		0	/* invalid type */
#define NOTE		1	/* valid symbol types */
#define REST		2
#define BAR		3
#define CLEF		4
#define TIMESIG 	5
#define KEYSIG		6
#define TEMPO		7
#define STAVES		8
#define MREST		9
#define PART		10
#define MREP		11
#define GRACE		12
#define FMTCHG		13
#define TUPLET		14
	unsigned char seq;	/* sequence # - see parse.c */
	unsigned char voice;	/* voice (0..nvoice) */
	unsigned char staff;	/* staff (0..nstaff) */
	int len;		/* main note length */
	signed char pits[MAXHD]; /* pitches for notes */
	struct SYMBOL *ts_next, *ts_prev; /* time linkage */
	int time;		/* starting time */
	short sflags;		/* symbol flags */
#define S_EOLN		0x0001		/* end of line */
#define S_WORD_ST	0x0002		/* word starts here */
#define S_BEAM_BREAK	0x0004		/* 2nd beam must restart here */
#define S_NO_HEAD	0x0008		/* don't draw the highest/lowest note head */
#define S_OTHER_HEAD	0x0010		/* don't draw any note head */
#define S_IN_TUPLET	0x0020		/* in a tuplet */
#define S_RRBAR		0x0040		/* right repeat bar */
#define S_BEAM_ON	0x0080		/* continue beaming */
#define S_SL1		0x0100		/* some chord slur start */
#define S_SL2		0x0200		/* some chord slur end */
#define S_TI1		0x0400		/* some chord tie start */
#define S_DYNUP		0x0800		/* dynamic marks above the staff */
#define S_DYNDN		0x1000		/* dynamic marks below the staff */
	unsigned char nhd;	/* number of notes in chord - 1 */
	signed char stem;	/* 1 / -1 for stem up / down */
	signed char nflags;	/* number of note flags when > 0 */
	char dots;		/* number of dots */
	char head;		/* head type */
#define H_FULL		0
#define H_EMPTY 	1
#define H_OVAL		2
#define H_SQUARE	3
	signed char multi;	/* multi voice in the staff (+1, 0, -1) */
	signed char doty;	/* dot y pos when voices overlap */
	unsigned char gcf;	/* font for guitar chords */
	unsigned char anf;	/* font for annotations */
	short u;		/* auxillary information:
				 *	- CLEF: small clef
				 *	- KEYSIG: old key signature
				 *	- BAR: new bar number
				 *	- TUPLET: tuplet format
				 *	- FMTCHG (format change): subtype
				 *	  with value in xmx: */
#define STBRK 0				/* staff break */
#define PSSEQ 1				/* postscript sequence */
	float x;		/* position */
	short y;
	short ymn, ymx, yav;	/* min, max, avg note head height */
	float xmx;		/* max h-pos of a head rel to top */
	float dc_top;		/* max offset needed for decorations */
	float dc_bot;		/* min offset for decoration */
	float xs, ys;		/* position of stem end */
	float wl, wr;		/* left, right min width */
	float pl, pr;		/* left, right preferred width */
	float shrink, stretch;	/* glue before this symbol */
	float shhd[MAXHD];	/* horizontal shift for heads */
	float shac[MAXHD];	/* horizontal shift for accidentals */
	struct lyrics *ly;	/* lyrics */
	struct SYMBOL *grace;	/* grace notes */
};

/* bar types */
#define B_INVIS B_OBRA		/* invisible; for endings without bars */
#define B_SINGLE B_BAR		/* |	single bar */
#define B_DOUBLE 0x11		/* ||	thin double bar */
#define B_THIN_THICK 0x13	/* |]	thick at section end  */
#define B_THICK_THIN 0x21	/* [|	thick at section start */
#define B_LREP 0x14		/* |:	left repeat bar */
#define B_RREP 0x41		/* :|	right repeat bar */
#define B_DREP 0x44		/* ::	double repeat bar */
#define B_DASH 0x04		/* :	dashed bar */

struct FORMAT { 		/* struct for page layout */
	float pageheight, pagewidth;
	float topmargin, botmargin, leftmargin, rightmargin;
	float topspace, wordsspace, titlespace, subtitlespace, partsspace;
	float composerspace, musicspace, staffsep, vocalspace, textspace;
	float scale, maxshrink, lineskipfac, parskipfac, sysstaffsep;
	float indent, infospace, slurheight, notespacingfactor;
	float maxstaffsep, maxsysstaffsep, stemheight;
	int landscape, titleleft, continueall, writehistory;
	int stretchstaff, stretchlast, withxrefs, barsperstaff;
	int oneperpage, musiconly, titlecaps, graceslurs, straightflags;
	int splittune, encoding, partsbox, infoline, printtempo, autoclef;
	int measurenb, measurefirst, measurebox, flatbeams, squarebreve;
	int exprabove, exprbelow, breathlow, vocalabove, freegchord;
	int printparts, gchordbox, contbarnb, halfbeam, tuplets, bstemdown;
	int shifthnote, aligncomposer, pslevel, hyphencont, textoption;
	int dynalign;
	char *dateformat, *header, *footer;
	struct FONTSPEC titlefont, subtitlefont, vocalfont, textfont;
	struct FONTSPEC tempofont, composerfont, partsfont, gchordfont;
	struct FONTSPEC wordsfont, footerfont, headerfont, infofont;
	struct FONTSPEC repeatfont, measurefont, annotationfont;
	struct FONTSPEC voicefont;
#define DFONT_MIN 5		/* index of dynamic fonts */
#define DFONT_MAX 16		/* max number of dynamic fonts */
	struct FONTSPEC font_tb[DFONT_MAX];
	char ndfont;
	unsigned char gcf, anf, vof;	/* fonts for
				* guitar chords, annotations and lyrics */
};

extern struct FORMAT cfmt;	/* current format for output */

struct ISTRUCT {		/* information fields */
	struct SYMBOL *area;
	struct SYMBOL *book;
	struct SYMBOL *comp;
	struct SYMBOL *disco;
	struct SYMBOL *histo;
	struct SYMBOL *notes;
	struct SYMBOL *orig;
	struct SYMBOL *parts;
	struct SYMBOL *rhythm;
	struct SYMBOL *src;
	struct SYMBOL *tempo;
	struct SYMBOL *title;
	unsigned char *xref;
	struct SYMBOL *trans;
};

extern struct ISTRUCT info, default_info;

extern char *mbf;		/* where to PUTx() */
extern int nbuf;		/* number of bytes buffered */
extern int use_buffer;		/* 1 if lines are being accumulated */

extern struct FONTSPEC *font_init; /* font for page break */
extern int strcf;		/* current string font */
extern int tunenum;		/* number of current tune */
extern int pagenum;		/* current page number */
extern int nbar;		/* current measure number */
extern int nbar_rep;		/* last repeat bar number */

extern int in_page;
extern int defl;		/* decoration flags (see deco.c for values) */

		/* switches modified by flags: */
extern int pagenumbers; 	/* write page numbers ? */
extern int epsf;		/* for EPSF postscript output */
extern int break_continues;	/* ignore continuations ? */

extern char outf[STRL1];	/* output file name */
extern char *in_fname;		/* current input file name */
extern char *styd;		/* format search directory */
extern time_t mtime;		/* last modification time of the input file */

extern int file_initialized;	/* for output file */
extern FILE *fout;		/* output file */

#define MAXWHISTLE	4	/* max number of whistle tablature */
struct WHISTLE_S {
	short voice;		/* voice number */
	short pitch;		/* absolute key pitch */
};
extern struct WHISTLE_S whistle_tb[MAXWHISTLE];
extern int nwhistle;

extern int s_argc;		/* command line arguments */
extern char **s_argv;

struct STAFF {
	struct clef_s clef;	/* base clef */
	unsigned brace:1;	/* 1st staff of a brace */
	unsigned brace_end:1;	/* 2nd staff of a brace */
	unsigned bracket:1;	/* 1st staff of a bracket */
	unsigned bracket_end:1;	/* last staff of a bracket */
	unsigned forced_clef:1;	/* explicit clef */
	unsigned stop_bar:1;	/* stop drawing bar on this staff */
	float y;		/* y position */
	short nvocal;		/* number of vocals (0..n) */
};
extern struct STAFF staff_tb[MAXSTAFF];
extern int nstaff;		/* (0..MAXSTAFF-1) */

struct VOICE_S {
	struct SYMBOL *sym;	/* associated symbols */
	struct SYMBOL *last_symbol;	/* last symbol while scanning */
	struct SYMBOL *s_anc;	/* ancillary symbol pointer */
	struct VOICE_S *next, *prev;	/* staff links */
	char *name;		/* voice id */
	char *nm;		/* voice name */
	char *snm;		/* voice subname */
	struct clef_s clef;	/* current clef */
	struct key_s key;	/* current key signature */
	struct meter_s meter;	/* current time signature */
	float yvocal;		/* current vocal vertical offset */
	char *bar_text;		/* bar text at start of staff when bar_start */
	int time;		/* current time while parsing */
	struct SYMBOL *tie;	/* note with ties of previous line */
	struct SYMBOL *rtie;	/* note with ties before 1st repeat bar */
	unsigned hy_st;		/* lyrics hyphens at start of line (bit array) */
	unsigned forced_clef:1;	/* explicit clef */
	unsigned second:1;	/* secondary voice in a brace/parenthesis */
	unsigned floating:1;	/* floating voice in a brace */
	unsigned selected:1;	/* selected while sorting by time (music.c) */
	unsigned bar_repeat:1;	/* bar at start of staff is a repeat bar */
	unsigned norepbra:1;	/* display the repeat brackets */
	short wmeasure;		/* measure duration while parsing */
	signed char bar_start;	/* bar type at start of staff / -1 */
	unsigned char nvocal;	/* number of vocals (0..n) */
	signed char clone;	/* duplicate from this voice number */
	unsigned char staff;	/* staff (0..n-1) */
	unsigned char cstaff;	/* staff while parsing */
	signed char sfp;	/* key signature while parsing */
	signed char stem;	/* stem direction while parsing */
	signed char gstem;	/* grace stem direction while parsing */
	signed char dyn;	/* place of dynamic marks while parsing */
	unsigned char slur_st;	/* slurs at start of staff */
};
extern struct VOICE_S voice_tb[MAXVOICE]; /* voice table */
extern int current_voice;	/* current voice while parsing */
extern struct VOICE_S *first_voice; /* first_voice */

extern struct SYMBOL *tsnext;	/* next line when cut */
extern float realwidth;		/* real staff width while generating */

#define NFLAGS_SZ 10		/* size of note flags tables */
#define C_XFLAGS 5		/* index of crotchet in flags tables */
extern float space_tb[NFLAGS_SZ], dot_space; /* note spacing */

/* PUTn: add to buffer with n arguments */
#define PUT0(f) do {sprintf(mbf,f); a2b(); } while (0)
#define PUT1(f,a) do {sprintf(mbf,f,a); a2b(); } while (0)
#define PUT2(f,a,b) do {sprintf(mbf,f,a,b); a2b(); } while (0)
#define PUT3(f,a,b,c) do {sprintf(mbf,f,a,b,c); a2b(); } while (0)
#define PUT4(f,a,b,c,d) do {sprintf(mbf,f,a,b,c,d); a2b(); } while (0)
#define PUT5(f,a,b,c,d,e) do {sprintf(mbf,f,a,b,c,d,e); a2b(); } while (0)

/* -- external routines -- */
/* abc2ps.c */
void clrarena(int level);
void lvlarena(int level);
char *getarena(int len);
void ops_into_fmt(void);
void strext(char *fid, char *ext);
/* buffer.c */
void a2b(void);
void abskip(float h);
void buffer_eob(void);
void bskip(float h);
void check_buffer(void);
void clear_buffer(void);
void close_output_file(void);
void close_page(void);
float get_bposy(void);
void write_buffer(void);
void open_output_file(void);
void write_eps(void);
/* deco.c */
void deco_add(char *text);
void deco_cnv(struct deco *dc, struct SYMBOL *s);
unsigned char deco_intern(unsigned char deco);
void deco_update(struct SYMBOL *s, float dx);
float deco_width(struct SYMBOL *s);
void draw_all_deco(void);
int draw_deco_head(int deco, float x, float y);
void draw_all_deco_head(struct SYMBOL *s, float x, float y);
void draw_deco_near(void);
void draw_deco_note(void);
void draw_deco_staff(void);
float draw_partempo(float top,
		    int any_part,
		    int any_tempo,
		    int any_vocal);
void draw_measnb(void);
void reset_deco(int deco_old);
/* draw.c */
void draw_staff(int mline, float indent);
void draw_sym_near(void);
void draw_symbols(struct VOICE_S *p_voice);
void draw_whistle(void);
/* format.c */
int interpret_format_line(char *w, char *p);
void define_fonts(void);
int get_textopt(unsigned char *p);
void make_font_list(void);
void print_format(void);
int read_fmt_file(char *filename);
void set_format(void);
/* music.c */
void output_music(void);
void reset_gen(void);
/* parse.c */
extern float multicol_start;
struct SYMBOL *add_sym(struct VOICE_S *p_voice,
		       int type);
void voice_dup(void);
void do_tune(struct abctune *t,
	     int header_only);
void identify_note(struct SYMBOL *s,
		   int len,
		   int *p_head,
		   int *p_dots,
		   int *p_flags);
/* subs.c */
void bug(char *msg, int fatal);
void error(int sev, struct SYMBOL *s, char *fmt, ...);
void cap_str(unsigned char *c);
float scan_u(char *str);
void add_to_text_block(char *s, int job);
float cwid(unsigned char c);
void put_history(void);
void put_words(struct SYMBOL *words);
void set_font(struct FONTSPEC *font);
void str_font(struct FONTSPEC *font);
#define A_LEFT -1
#define A_CENTER 0
#define A_RIGHT 1
void str_out(unsigned char *p, int action);
void put_str(unsigned char *str, int action);
float tex_str(char *s);
extern unsigned char tex_buf[];	/* result of tex_str() */
#define TEX_BUF_SZ 512
void user_ps_add(char *s);
void user_ps_write(void);
void write_title(struct SYMBOL *s);
void write_heading(void);
void write_user_ps(void);
void write_text_block(int job, int abc_state);
/* syms.c */
void define_encoding(int enc, char *ename);
void define_font(char *name, int num, int enc);
void define_symbols(void);