2 /* Copyright (c) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 by Arkkra Enterprises */
3 /* All rights reserved */
7 /* routines for printing info for debugging purposes */
8 /* It would be nicer to write a program to read the header files and
9 * generate most of these routines from there to keep them up to date,
10 * but this will do for now. */
18 /* for number-to-English name translations, if we fall off the bottom of
19 * a switch without a match, need to return something, so use "unknown" */
20 static char Unknown[] = "unknown";
23 /* static functions */
24 static void print_ssv P((struct SSV *ssv_p));
25 static void print_markorder P((struct SSV *ssv_p, int place));
26 static void print_printdata P((struct PRINTDATA *printdata_p));
27 static void print_bar P((struct BAR *bar_p));
28 static void print_chhead P((struct CHORD *ch_p));
29 static void print_staff P((struct STAFF *staff_p));
30 static void print_grpsyl P((struct GRPSYL *g_p, char *gstype, int vno));
31 static void print_slurtolist P((struct NOTE *note_p));
32 static void pr_stuff P((struct STUFF *stuff_p));
33 static char *xlate_place P((int place));
34 static char *xlate_stufftype P((int stuff_type));
35 static char * xlate_linetype P((int ltype));
36 static char *xlate_gvalue P((int grpvalue));
37 static char *xlate_gsize P((int grpsize));
38 static char *xlate_gcont P((int gcont));
39 static char *xlate_item P((int item));
40 static char *xlate_dir P((int dir));
41 static void print_curve P((struct CURVE *curve_p));
42 static char *xlate_coordtype P((int coordtype));
45 /* tell what is in the main linked list. Walk down the list and print
46 * things of interest. */
52 struct MAINLL *mll_p; /* to walk through list */
53 register int i; /* count number of items in list */
54 int s; /* walk through staffs */
57 /* only do this stuff if debug level 128 is on */
58 if (debug_on(128) == 0) {
62 debug(128, "\n\t\t==== Contents of main linked list ====\n");
64 /* walk down the main linked list, printing things about each struct
66 for (i = 0, mll_p = Mainllhc_p; mll_p != (struct MAINLL *) 0;
67 mll_p = mll_p->next, i++) {
69 debug(128, "\nmainll %d: type %s", i, stype_name(mll_p->str));
70 if (mll_p->inputfile != (char *) 0 && mll_p->inputlineno > 0) {
71 debug(128, "from file %s inputlineno %d",
72 mll_p->inputfile, mll_p->inputlineno);
75 /* print info of interest based on struct type */
79 print_ssv(mll_p->u.ssv_p);
83 print_bar(mll_p->u.bar_p);
87 print_curve(mll_p->u.curve_p);
91 if (mll_p->u.line_p->linetype != L_NORMAL) {
93 xlate_linetype(mll_p->u.line_p->linetype));
98 print_printdata(mll_p->u.prhead_p->printdata_p);
102 debug(128, "\tfeed at (%f, %f) with%s pagefeed\n\tnorth %f, south %f, west %f, east %f",
103 mll_p->u.feed_p->c[AX], mll_p->u.feed_p->c[AY],
104 mll_p->u.feed_p->pagefeed ? "" : "out",
105 mll_p->u.feed_p->c[AN], mll_p->u.feed_p->c[AS],
106 mll_p->u.feed_p->c[AW], mll_p->u.feed_p->c[AE]);
107 debug(128, "\tleftmargin %f rightmargin %f",
108 mll_p->u.feed_p->leftmargin,
109 mll_p->u.feed_p->rightmargin);
110 if (mll_p->u.feed_p->top_p != 0) {
111 debug(128, "\ttop block: height %f",
112 mll_p->u.feed_p->top_p->height);
113 print_printdata(mll_p->u.feed_p->top_p->printdata_p);
115 if (mll_p->u.feed_p->bot_p != 0) {
116 debug(128, "\tbot block: height %f",
117 mll_p->u.feed_p->bot_p->height);
118 print_printdata(mll_p->u.feed_p->bot_p->printdata_p);
120 /* Note: after placment top2/bot2 are only meaningful
121 * on final FEED when doing gridsatend with more than
122 * one page worth of grids. */
123 if (mll_p->u.feed_p->top2_p != 0) {
124 debug(128, "\ttop2 block: height %f",
125 mll_p->u.feed_p->top2_p->height);
126 print_printdata(mll_p->u.feed_p->top2_p->printdata_p);
128 if (mll_p->u.feed_p->bot2_p != 0) {
129 debug(128, "\tbot2 block: height %f",
130 mll_p->u.feed_p->bot2_p->height);
131 print_printdata(mll_p->u.feed_p->bot2_p->printdata_p);
136 debug(128, "\twest at %f, prtimesig %d, hide %d",
137 mll_p->u.clefsig_p->wclefsiga,
138 mll_p->u.clefsig_p->prtimesig,
139 mll_p->u.clefsig_p->hide);
140 if (mll_p->u.clefsig_p->bar_p != (struct BAR *) 0) {
141 debug(128, " clefsig includes pseudo bar:");
142 print_bar(mll_p->u.clefsig_p->bar_p);
144 for (s = 1; s <= Score.staffs; s++) {
145 debug(128, " staff %d: prclef %d, %d sharps, %d naturals",
146 s, mll_p->u.clefsig_p->prclef[s],
147 mll_p->u.clefsig_p->sharps[s],
148 mll_p->u.clefsig_p->naturals[s]);
153 print_chhead(mll_p->u.chhead_p->ch_p);
157 print_staff(mll_p->u.staff_p);
161 debug(128, "height %f\n", mll_p->u.blockhead_p->height);
162 print_printdata(mll_p->u.blockhead_p->printdata_p);
171 /* translate S_* numbers used for the str field of MAINLL struct to names */
176 int stype; /* the S_* number to translate */
199 return("S_BLOCKHEAD");
206 /* print some useful info from SSV struct */
211 struct SSV *ssv_p; /* which struct to report on */
214 debug(128, "\tcontext = %s", contextname(ssv_p->context));
215 debug(128, "\tstaffno = %d", ssv_p->staffno);
216 debug(128, "\tvoiceno = %d", ssv_p->voiceno);
217 if (ssv_p->strinfo != (struct STRINGINFO *) 0) {
220 for (i = 0; i < ssv_p->stafflines; i++) {
221 debug(128, "\t\ttab string %d: %c%c nticks=%d, oct=%d",
222 i, ssv_p->strinfo[i].letter,
223 ssv_p->strinfo[i].accidental == '\0'
224 ? ' ' : ssv_p->strinfo[i].accidental,
225 ssv_p->strinfo[i].nticks,
226 ssv_p->strinfo[i].octave);
229 if (ssv_p->used[ABOVEORDER] == YES) {
230 print_markorder(ssv_p, PL_ABOVE);
232 if (ssv_p->used[BELOWORDER] == YES) {
233 print_markorder(ssv_p, PL_BELOW);
235 if (ssv_p->used[BETWEENORDER] == YES) {
236 print_markorder(ssv_p, PL_BETWEEN);
241 print_markorder(ssv_p, place)
249 debug(128, "\tmarkorder %s: ", xlate_place(place));
250 for (m = 0; m < NUM_MARK; m++) {
251 debug(128, "\t\t%d ", ssv_p->markorder[place][m]);
257 /* print useful info from STAFF struct */
262 struct STAFF *staff_p; /* which to report on */
265 register int i; /* index to walk down a list */
268 debug(128, "\tstaffno = %d, visible = %s", staff_p->staffno,
269 staff_p->visible == YES ? "y" : "n");
271 /* print each group */
272 for ( i = 0; i < MAXVOICES; i++) {
273 if (staff_p->groups_p[i] != (struct GRPSYL *) 0) {
274 print_grpsyl(staff_p->groups_p[i], "GROUP", i + 1);
278 /* print each lyrics syllable */
279 for (i = 0; i < staff_p->nsyllists; i++) {
280 debug(128, "\n\tsylplace = %s",
281 xlate_place(staff_p->sylplace[i]));
282 print_grpsyl(staff_p->syls_p[i], "SYLLABLE",
283 staff_p->syls_p[i]->vno);
286 pr_stuff(staff_p->stuff_p);
290 /* print info from a list of GRPSYL structs */
293 print_grpsyl(g_p, gstype, vno)
295 struct GRPSYL *g_p; /* which GRPSYL */
296 char *gstype; /* "GROUP" or "SYLLABLE" */
297 int vno; /* voice number or verse number */
300 register int i; /* index through list */
301 char *sylbuff; /* syllable with all ASCII characters */
304 if (debug_on(128) == 0) {
308 (void) fprintf(stderr, "\tgrpsyl = %s, vno = %d\n", gstype, vno);
310 /* print info about the stuff in GRPSYL structs */
311 for ( ; g_p != (struct GRPSYL *) 0; g_p = g_p->next) {
313 (void) fprintf(stderr, "\n\t\tbasictime = %d, dots = %d, fulltime = %ld/%ld\n",
314 g_p->basictime, g_p->dots,
315 g_p->fulltime.n, g_p->fulltime.d);
316 (void) fprintf(stderr, "\t\tc[AX] = %f, c[AY] = %f\n",
317 g_p->c[AX], g_p->c[AY]);
318 (void) fprintf(stderr, "\t\tc[AW] = %f, c[AE] = %f\n",
319 g_p->c[AW], g_p->c[AE]);
320 (void) fprintf(stderr, "\t\tc[AN] = %f, c[AS] = %f\n",
321 g_p->c[AN], g_p->c[AS]);
322 if (g_p->ho_usage != HO_NONE) {
323 (void) fprintf(stderr, "\t\tho_usage = %d", g_p->ho_usage);
324 if (g_p->ho_usage == HO_VALUE) {
325 (void) fprintf(stderr, ", ho_value = %f",
328 (void) fprintf(stderr, "\n");
331 /* if group, print info about it, including the list of
333 if (g_p->grpsyl == GS_GROUP) {
335 (void) fprintf(stderr, "\t\tclef = %d, xdotr = %f, stemx = %f\n",
336 g_p->clef, g_p->xdotr, g_p->stemx);
337 (void) fprintf(stderr, "\t\tgrpvalue = %s, grpsize = %s, headshape = %d,\n\t\tgrpcont = %s, beamloc = %s, beamslope=%f\n",
338 xlate_gvalue(g_p->grpvalue),
339 xlate_gsize(g_p->grpsize),
341 xlate_gcont(g_p->grpcont),
342 xlate_item(g_p->beamloc),
344 if (g_p->roll != NOITEM) {
345 (void) fprintf(stderr, "\t\troll = %s, rolldir = %s\n",
346 xlate_item(g_p->roll),
347 xlate_dir(g_p->rolldir));
350 if( g_p->padding != 0.0) {
351 (void) fprintf(stderr, "\t\tpadding=%f\n", g_p->padding);
353 (void) fprintf(stderr, "\t\tis_meas=%d, uncompressible=%d\n",
354 g_p->is_meas, g_p->uncompressible);
356 (void) fprintf(stderr, "\t\tstemlen=%f, stemdir=%s\n",
357 g_p->stemlen, xlate_dir(g_p->stemdir));
358 (void) fprintf(stderr, "\t\ttie=%d, slash_alt=%d\n",
359 g_p->tie, g_p->slash_alt);
361 /* if part of tuplet, print info about that */
362 if (g_p->tuploc != NOITEM) {
363 (void) fprintf(stderr, "\t\ttuploc=%s, tupcont=%d\n",
364 xlate_item(g_p->tuploc), g_p->tupcont);
365 (void) fprintf(stderr, "\t\tprinttup=%d, tupside=%s, tupextend=%f\n",
366 g_p->printtup, xlate_place(g_p->tupside),
370 /* print a bit about "with" lists */
373 (void) fprintf(stderr, "\t\t%d items in 'with' list (normwith=%d):\n",
374 g_p->nwith, g_p->normwith);
375 for (w = 0; w < g_p->nwith; w++) {
376 (void) fprintf(stderr, "\t\t\t\"%s\"\n",
377 ascii_str(g_p->withlist[w],
382 (void) fprintf(stderr, "\t\tnnotes = %d, beamto = %d, stemto = %d, stemto_idx = %d\n",
383 g_p->nnotes, g_p->beamto,
384 g_p->stemto, g_p->stemto_idx);
385 for (i = 0; i < g_p->nnotes; i++) {
386 if (is_tab_staff(g_p->staffno) == YES) {
387 (void) fprintf(stderr, "\t\t\tstring %d, fret %d, bend %d %d/%d, fret_paren %d\n",
388 g_p->notelist[i].STRINGNO,
389 g_p->notelist[i].FRETNO,
390 BENDINT(g_p->notelist[i]),
391 BENDNUM(g_p->notelist[i]),
392 BENDDEN(g_p->notelist[i]),
393 g_p->notelist[i].FRET_HAS_PAREN);
396 (void) fprintf(stderr, "\t\t\t%c %c %d steps %d",
397 g_p->notelist[i].letter,
398 g_p->notelist[i].accidental == '\0'
399 ? ' ' : g_p->notelist[i].accidental,
400 g_p->notelist[i].octave,
401 g_p->notelist[i].stepsup);
402 if (g_p->notelist[i].note_has_paren == YES) {
403 (void) fprintf(stderr, " note_paren (%f, %f)",
404 g_p->notelist[i].wlparen,
405 g_p->notelist[i].erparen);
407 if (g_p->notelist[i].acc_has_paren == YES) {
408 (void) fprintf(stderr, " acc_paren");
410 if (g_p->notelist[i].tie == YES) {
411 (void) fprintf(stderr, " tie(style %d)",
412 g_p->notelist[i].tiestyle);
415 (void) fprintf(stderr, " (headshape %d, headchar %d, headfont %d)",
416 g_p->notelist[i].headshape,
417 g_p->notelist[i].headchar,
418 g_p->notelist[i].headfont);
419 if (g_p->notelist[i].notesize != GS_NORMAL) {
420 (void) fprintf(stderr, " (size %s)",
421 xlate_gsize(g_p->notelist[i]
424 if (g_p->notelist[i].is_bend == YES) {
425 fprintf(stderr, " is_bend");
427 if (g_p->notelist[i].smallbend == YES) {
428 fprintf(stderr, " smallbend");
430 print_slurtolist( &(g_p->notelist[i]) );
431 (void) fprintf(stderr, "\n");
436 /* if syllable, print it */
437 if (g_p->syl != (char *) 0) {
438 sylbuff = ascii_str(g_p->syl, YES, NO, TM_NONE);
439 (void) fprintf(stderr, "\t\tsyllable = '%s', font %d, size %d\n",
440 sylbuff, g_p->syl[0], g_p->syl[1]);
446 /* print any slurtolist entries */
449 print_slurtolist(note_p)
456 if ( (note_p->nslurto == 0) || (debug_on(128) == 0) ) {
460 (void) fprintf(stderr, " slurred to:");
461 for (n = note_p->nslurto - 1; n >= 0; n--) {
462 switch (note_p->slurtolist[n].octave) {
464 (void) fprintf(stderr, " IN_UPWARD");
467 (void) fprintf(stderr, " IN_DOWNWARD");
470 (void) fprintf(stderr, " OUT_UPWARD");
473 (void) fprintf(stderr, " OUT_DOWNWARD");
476 (void) fprintf(stderr, " %c%d",
477 note_p->slurtolist[n].letter,
478 note_p->slurtolist[n].octave);
484 /* given a GV_* value, return its English name */
487 xlate_gvalue(grpvalue)
503 /* given a GS_* value, return its English name */
522 /* given a GC_* grpcont value, return its English name */
543 /* given an "ITEM" value, return its English name */
568 /* translate direction to name */
587 /* recursively print info from a list of PRINTDATA structs */
590 print_printdata(printdata_p)
592 struct PRINTDATA *printdata_p;
595 char *buff; /* for all-ASCII version. */
598 if (printdata_p == (struct PRINTDATA *) 0) {
599 /* we're at the end of the line... */
603 buff = ascii_str(printdata_p->string, YES, NO, TM_NONE);
604 debug(128, "\tprint (isPostScript %d, justify %d, width %.2f, font %d, size %d) '%s'",
605 printdata_p->isPostScript, printdata_p->justifytype,
606 printdata_p->width, (int) printdata_p->string[0],
607 (int) printdata_p->string[1], buff);
609 /* recurse down the list */
610 print_printdata(printdata_p->next);
614 /* print useful info from a bar struct */
623 struct TIMEDSSV *tssv_p; /* list of mid-meas param changes */
625 switch(bar_p->bartype) {
636 type = "REPEATSTART";
655 debug(128, "\tbartype = %d (%s), endingloc=%d", bar_p->bartype, type,
657 debug(128, "\tx = %f, y = %f, mnum = %d", bar_p->c[AX], bar_p->c[AY],
659 if (bar_p->reh_string != 0) {
660 debug(128, "\treh_string = '%s'",
661 ascii_str(bar_p->reh_string, YES, NO, TM_NONE));
664 for (tssv_p = bar_p->timedssv_p; tssv_p != 0; tssv_p = tssv_p->next) {
665 debug(128, "\tTimed SSV, time_off %d/%d\n", tssv_p->time_off.n,
667 print_ssv(&tssv_p->ssv);
672 /* recursively print coord info about chords in chord list */
680 struct GRPSYL * gs_p;
683 if (ch_p != (struct CHORD *) 0) {
684 debug(128, "\tchord at (%f, %f), width %f, fullwidth %f",
685 ch_p->c[AX], ch_p->c[AY], ch_p->width, ch_p->fullwidth);
686 debug(128, "\tc[RW] = %f, c[RE] = %f", ch_p->c[RW], ch_p->c[RE]);
687 debug(128, "\tstarttime %d/%d, duration %d/%d, pseudodur %f",
688 ch_p->starttime.n, ch_p->starttime.d,
689 ch_p->duration.n, ch_p->duration.d,
691 for (gs_p = ch_p->gs_p; gs_p != (struct GRPSYL *) 0;
693 debug(128, "\t\t%s, staff %d, vno %d",
694 gs_p->grpsyl == GS_GROUP ? "GROUP"
695 : "SYLLABLE", gs_p->staffno,
698 print_chhead(ch_p->ch_p);
703 /* print information about a STUFF list */
708 struct STUFF *stuff_p;
711 char *buff; /* for all-ASCII version */
714 for ( ; stuff_p != (struct STUFF *) 0; stuff_p = stuff_p->next) {
716 debug(128, "\nSTUFF: %s %s %s: start=%f (%d) [%f], end=%dm+%f, all=%d, x=%f, y=%f",
717 xlate_stufftype(stuff_p->stuff_type),
718 (stuff_p->stuff_type == ST_PHRASE
719 ? xlate_linetype(stuff_p->modifier)
720 : stuff_modifier(stuff_p->modifier)),
721 xlate_place(stuff_p->place), stuff_p->start.count,
722 stuff_p->gracebackup, stuff_p->start.steps,
723 stuff_p->end.bars, stuff_p->end.count, stuff_p->all,
724 stuff_p->c[AX], stuff_p->c[AY]);
726 if (stuff_p->string != (char *) 0) {
727 buff = ascii_str(stuff_p->string, YES, NO, stuff_p->modifier);
728 debug(128, "\tstring = \"%s\"", buff);
734 /* given a PL_* place value, return its English name */
752 return("invalid place");
757 /* given a ST_* stufftype, return its English name */
761 xlate_stufftype(stuff_type)
766 switch (stuff_type) {
796 return("unknown stuff_type");
801 /* Translate L_ line type to name */
804 xlate_linetype(ltype)
806 int ltype; /* L_* value */
831 struct CURVE *curve_p;
834 struct COORD_INFO *cinfo_p;
837 if (debug_on(128) == 0) {
841 for (n = 0; n < curve_p->ncoord; n++) {
842 if ((cinfo_p = find_coord(curve_p->coordlist[n].hor_p)) != 0) {
843 debug(128, "\thor_p = 0x%lx, page = %d, score = %d, pseudo_bar_p = %lx",
844 curve_p->coordlist[n].hor_p,
845 cinfo_p->page, cinfo_p->scorenum,
846 cinfo_p->pseudo_bar_p);
848 debug(128, "\thtype = %s, hsteps = %f, counts = %f",
849 xlate_coordtype(curve_p->coordlist[n].htype),
850 curve_p->coordlist[n].hsteps,
851 curve_p->coordlist[n].counts);
852 if ((cinfo_p = find_coord(curve_p->coordlist[n].vert_p)) != 0) {
853 debug(128, "\tvert_p = 0x%lx, page = %d, score = %d, pseudo_bar_p = %lx",
854 curve_p->coordlist[n].vert_p,
855 cinfo_p->page, cinfo_p->scorenum,
856 cinfo_p->pseudo_bar_p);
858 debug(128, "\tvtype = %s, vsteps = %f\n",
859 xlate_coordtype(curve_p->coordlist[n].vtype),
860 curve_p->coordlist[n].vsteps);
864 /* given an absolute coordinate type like AX, return its name */
867 *xlate_coordtype(coordtype)