#include "pre_mus.h"
#include <stdio.h>

barprint (bar) {
    struct bars *barp = barv + bar;
    int     i;
    fprintf (stderr, "Bar %2d: ", bar );
    if ( barp->b_stt_type ) fprintf( stderr, "stt %d; ", barp -> b_stt_type);
    if ( barp->b_end_type ) fprintf( stderr, "end %d; ", barp -> b_end_type);
    for (i = 0; i < n_parts; i++)
	fprintf (stderr, "Pt %d n [%2d,%2d-1] ",
		i, bar_first_note[bar][i], bar_last_note[bar][i]);
    for ( i=0; i<n_staffs; i++ ) {
	if ( barp->b_clef[i] )
	    fprintf( stderr, " \\c %d %d;", i, barp->b_clef[i] );
	if ( barp->b_tover[i] )
	    fprintf( stderr, " o\"%s\"", barp->b_tover[i] );
	if ( barp->b_tunder[i] )
	    fprintf( stderr, " u\"%s\"", barp->b_tunder[i] );
    }
    if ( barp->b_key )
	fprintf( stderr, " \\k %d;", barp->b_key );
    if ( barp->b_n_tsig )
	fprintf( stderr, " \\t %d %d;", barp->b_n_tsig, barp->b_d_tsig );
    if ( barp->b_bps )
	fprintf( stderr, " \\n %d;", barp->b_bps );
    fprintf (stderr, "\n");
    return;
}

noteprint (beat) {
    struct notes   *notep = notev + beat;
    fprintf (stderr, "Note %2d(pt %d) ",
	    beat, notep->n_part+1 );
    if ( notep->n_pitch == RESTSYM )
	fprintf( stderr, "rest  " );
    else
	fprintf( stderr, "%c%c o%d ",
	    scale[notep -> n_pitch - 'a' + root_now - 8
	       /* + staffv[0][notep -> n_staff].s_key_offset */][0],
	    scale[notep -> n_pitch - 'a' + root_now - 8][1],
	    notep -> n_octv - '0' );
    fprintf( stderr, "l %2d ",
	    notep -> n_length );
    if (notep -> n_tnote)
	fprintf (stderr, "%s ", notep -> n_tnote);
    if (notep -> n_accid != ' ' && notep -> n_accid)
	fprintf (stderr, "[%c] ", notep -> n_accid);
    if (notep -> n_beam > 0)
	fprintf (stderr, "\"%c\"", BEAMSTART);
    if (notep -> n_tie_start > 0)
	fprintf (stderr, "\"%c\"", TIESTART);
    if (notep -> n_beam < 0)
	fprintf (stderr, " \"%c\"", BEAMEND);
    if (notep -> n_tie_end > 0)
	fprintf (stderr, " \"%c\"", TIEEND);
    if (notep -> n_group)
	fprintf (stderr, " gp %d", notep -> n_group);
    fprintf (stderr, "\n" );
}

#ifdef junk
stavepr (stave) {
    fprintf (stderr,
	    "stave %d, bars [%d,%d], y %d, y range [%d,%d], s_x_right %d\n",
	    stave,
	    stavev[stave].s_first_bar,
	    stavev[stave].s_last_bar - 1,
	    stavev[stave].s_y_wrt_page,
	    stavev[stave].sv_miny, stavev[stave].sv_maxy,
	    stavev[stave].s_x_right);
}

staffpr (stave, staff) {
    fprintf (stderr,
	    "staff %d, y %d, y range [%d,%d]\n",
	    staff,
	    stavev[stave].s_y_wrt_page + staffv[stave][staff].s_y_wrt_stave,
	    staffv[stave][staff].sf_miny, staffv[stave][staff].sf_maxy);
}
#endif
