2 score.cc -- implement Score
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
10 #include "scorecolumn.hh"
14 #include "paperdef.hh"
17 #include "sourcefile.hh"
18 #include "scorewalker.hh"
19 #include "midioutput.hh"
22 extern String default_out_fn;
27 *mlog << "\nSetting up music ..." << flush;
28 if (last() == Moment(0)) {
30 error("Need to have music in a score.", defined_ch_c_l_);
33 for (iter_top(staffs_,i); i.ok(); i++) {
40 Score::process_music()
42 *mlog << "Processing music ..." << flush;
43 for (Score_walker w(this); w.ok(); w++) {
63 pscore_p_ = new PScore(paper_p_);
65 find_col(0, false)->set_breakable(); // ugh
66 find_col(last(), false)->set_breakable();
69 for (iter_top(staffs_,i); i.ok(); i++)
70 i->set_output(pscore_p_);
74 clean_cols(); // can't move clean_cols() farther up.
89 Remove empty cols, preprocess other columns.
94 for (iter_top(staffs_,i); i.ok(); i++)
97 for (iter_top(cols_,c); c.ok(); ) {
98 if (!c->pcol_l_->used_b()) {
108 Create columns at time #w#.
109 this sux. We should have Score_column create the appropriate PCol.
110 Unfortunately, PCols don't know about their position.
112 @return cursor pointing to the nonmusical (first) column
114 PCursor<Score_column*>
115 Score::create_cols(Moment w)
117 Score_column* c1 = new Score_column(w);
118 Score_column* c2 = new Score_column(w);
120 c1->musical_b_ = false;
121 c2->musical_b_ = true;
125 for (; i.ok(); i++) {
126 assert(i->when() != w);
132 cols_.bottom().add(c1);
133 cols_.bottom().add(c2);
144 PCursor<Score_column*>
145 Score::find_col(Moment w, bool mus)
149 for (; i.ok(); i++) {
150 if (i->when() == w && i->musical_b_ == mus)
165 for (; i.ok(); i++) {
166 pscore_p_->add(i->pcol_l_);
174 for (iter_top(staffs_,i); i.ok(); i++) {
181 Score::set(Paperdef *pap_p)
188 Score::set(Midi_def* midi_p)
198 for (iter_top(staffs_,i); i.ok(); i++) {
200 assert(i->score_l_ == this);
204 for (iter_top(cols_,cc); cc.ok() && (cc+1).ok(); cc++) {
205 assert(cc->when() <= (cc+1)->when());
216 for (iter_top(staffs_,i); i.ok(); i++) {
219 for (iter_top(cols_,i); i.ok(); i++) {
248 Score::paper_output()
251 if (paper_p_->outfile=="")
252 paper_p_->outfile = default_out_fn + ".out";
254 if ( errorlevel_i_ ) {
255 *mlog << "lilypond: warning: no output to: " << paper_p_->outfile
256 << " (errorlevel=" << errorlevel_i_ << ")" << endl;
260 *mlog << "TeX output to " << paper_p_->outfile << " ...\n";
262 Tex_stream the_output(paper_p_->outfile);
264 the_output << "% outputting Score, defined at: " <<
266 sourcefile_l (defined_ch_c_l_)->file_line_no_str(defined_ch_c_l_) << "\n";
267 pscore_p_->output(the_output);
276 if (midi_p_->outfile_str_ == "")
277 midi_p_->outfile_str_ = default_out_fn + ".midi";
279 *mlog << "midi output to " << midi_p_->outfile_str_ << " ...\n";
280 Midi_output(this, midi_p_);
287 staffs_.bottom().add(s);