2 score.cc -- implement Score
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
8 #include "tex-stream.hh"
10 #include "score-column.hh"
14 #include "paper-def.hh"
17 #include "source-file.hh"
18 #include "score-walker.hh"
19 #include "midi-output.hh"
20 #include "midi-def.hh"
21 #include "pulk-voices.hh"
22 #include "request-column.hh"
25 extern String default_out_fn;
30 *mlog << "\nSetting up requests..." << flush;
32 Pulk_voices pulk(staffs_);
34 Moment l_mom = pulk.last_;
35 if (l_mom == Moment(0)) {
37 input_.error("Need to have music in a score.");
40 Moment previous_mom = -1;
43 Moment w= pulk.next_mom();
44 assert(w > previous_mom);
45 Request_column* rcol_p = new Request_column( staffs_ );
47 Score_column* c1 = new Score_column(w);
48 Score_column* c2 = new Score_column(w);
49 if (w == Moment(0) || w == l_mom) {
53 c1->musical_b_ = false;
54 c2->musical_b_ = true;
56 cols_.bottom().add(c1);
57 cols_.bottom().add(c2);
58 rcol_p->set_score_cols(c1, c2);
59 rcols_.bottom().add(rcol_p);
60 pulk.get_aligned_request( rcol_p );
64 errorlevel_i_ |= pulk.time_checks_failed_b();
68 Score::process_music()
70 *mlog << "Processing requests ..." << flush;
71 for (Score_walker w(this); w.ok(); w++) {
91 // should we? hampers debugging.
92 warning("Errors found, /*not processing score*/");
95 pscore_p_ = new PScore(paper_p_);
98 for (iter_top(staffs_,i); i.ok(); i++)
99 i->set_output(pscore_p_);
103 clean_cols(); // can't move clean_cols() farther up.
110 pscore_p_->process();
118 Remove empty cols, preprocess other columns.
124 for (iter_top(staffs_,i); i.ok(); i++)
127 for (iter_top(rcols_,i); i.ok(); i++) {
128 i->when(); // update cache, ugh
129 if (!i->command_column_l_->used_b()) {
130 i->command_column_l_ = 0;
132 if (!i->musical_column_l_->used_b())
133 i->musical_column_l_ = 0;
136 for (iter_top(cols_,c); c.ok(); ) {
137 if (!c->pcol_l_->used_b()) {
147 PCursor<Score_column*>
148 Score::find_col(Moment w, bool mus)
152 for (; i.ok(); i++) {
153 if (i->when() == w && i->musical_b_ == mus)
166 for (; i.ok(); i++) {
167 pscore_p_->add(i->pcol_l_);
175 for (iter_top(staffs_,i); i.ok(); i++) {
182 Score::set(Paper_def *pap_p)
189 Score::set(Midi_def* midi_p)
199 for (iter_top(staffs_,i); i.ok(); i++) {
201 assert(i->score_l_ == this);
205 for (iter_top(cols_,cc); cc.ok() && (cc+1).ok(); cc++) {
206 assert(cc->when() <= (cc+1)->when());
217 for (iter_top(staffs_,i); i.ok(); i++) {
220 for (iter_top(cols_,i); i.ok(); i++) {
248 Score::paper_output()
250 if (paper_p_->outfile=="")
251 paper_p_->outfile = default_out_fn + ".out";
253 if ( errorlevel_i_ ) {
254 *mlog << "lilypond: warning: no output to: " << paper_p_->outfile
255 << " (errorlevel=" << errorlevel_i_ << ")" << endl;
259 *mlog << "TeX output to " << paper_p_->outfile << " ...\n";
261 Tex_stream the_output(paper_p_->outfile);
263 the_output << "% outputting Score, defined at: " <<
264 input_.location_str() << "\n";
265 pscore_p_->output(the_output);
275 if (midi_p_->outfile_str_ == "")
276 midi_p_->outfile_str_ = default_out_fn + ".midi";
278 *mlog << "midi output to " << midi_p_->outfile_str_ << " ...\n";
279 Midi_output(this, midi_p_);
286 staffs_.bottom().add(s);