2 score.cc -- implement Score
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
15 #include "paperdef.hh"
18 #include "sourcefile.hh"
19 #include "scorewalker.hh"
24 *mlog
<< "\nSetting up music ..." << flush
;
25 if (last() == Moment(0)) {
26 warning("Need to have music in a score.", defined_ch_c_l_
);
29 pscore_p_
= new PScore(paper_p_
);
30 find_col(0, false)->set_breakable(); // ugh
31 find_col(last(), false)->set_breakable();
35 for (iter_top(staffs_
,i
); i
.ok(); i
++) {
36 i
->set_output(pscore_p_
);
43 Score::process_music()
45 *mlog
<< "Processing music ..." << flush
;
46 for (Score_walker
w(this); w
.ok(); w
++) {
57 // do this after processing, staffs first have to generate PCols.
69 Remove empty cols, preprocess other columns.
74 for (iter_top(staffs_
,i
); i
.ok(); i
++)
77 for (iter_top(cols_
,c
); c
.ok(); ) {
78 if (!c
->pcol_l_
->used()) {
88 Create columns at time #w#.
89 this sux. We should have Score_column create the appropriate PCol.
90 Unfortunately, PCols don't know about their position.
92 @return cursor pointing to the nonmusical (first) column
94 PCursor
<Score_column
*>
95 Score::create_cols(Moment w
)
97 Score_column
* c1
= new Score_column(w
);
98 Score_column
* c2
= new Score_column(w
);
100 c1
->musical_b_
= false;
101 c2
->musical_b_
= true;
105 for (; i
.ok(); i
++) {
106 assert(i
->when() != w
);
112 cols_
.bottom().add(c1
);
113 cols_
.bottom().add(c2
);
124 PCursor
<Score_column
*>
125 Score::find_col(Moment w
, bool mus
)
129 for (; i
.ok(); i
++) {
130 if (i
->when() == w
&& i
->musical_b_
== mus
)
145 for (; i
.ok(); i
++) {
146 pscore_p_
->add(i
->pcol_l_
);
148 clean_cols(); // can't move clean_cols() farther up.
155 for (iter_top(staffs_
,i
); i
.ok(); i
++) {
165 for (iter_top(staffs_
,i
); i
.ok(); i
++) {
167 assert(i
->score_l_
== this);
171 for (iter_top(cols_
,cc
); cc
.ok() && (cc
+1).ok(); cc
++) {
172 assert(cc
->when() <= (cc
+1)->when());
183 for (iter_top(staffs_
,i
); i
.ok(); i
++) {
186 for (iter_top(cols_
,i
); i
.ok(); i
++) {
196 Score::Score(Paperdef
*paper_p
)
211 Score::output(String s
)
214 if (paper_p_
->outfile
=="")
215 paper_p_
->outfile
= s
;
217 if ( errorlevel_i_
) {
218 *mlog
<< "lilypond: warning: no output to: " << paper_p_
->outfile
219 << " (errorlevel=" << errorlevel_i_
<< ")" << endl
;
223 *mlog
<< "output to " << paper_p_
->outfile
<< "...\n";
225 Tex_stream
the_output(paper_p_
->outfile
);
227 the_output
<< "% outputting Score, defined at: " <<
229 sourcefile_l (defined_ch_c_l_
)->file_line_no_str(defined_ch_c_l_
) << "\n";
230 pscore_p_
->output(the_output
);
239 staffs_
.bottom().add(s
);