2 score.cc -- implement Score
4 source file of the 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"
24 extern String default_out_fn;
29 *mlog << "\nSetting up requests..." << flush;
31 Pulk_voices pulk(staffs_);
33 Moment l_mom = pulk.last_;
34 if (l_mom == Moment(0)) {
36 input_.error("Need to have music in a score.");
39 Moment previous_mom = -1;
42 Moment w= pulk.next_mom();
43 assert(w > previous_mom);
44 Request_column* rcol_p = new Request_column( staffs_ );
46 Score_column* c1 = new Score_column(w);
47 Score_column* c2 = new Score_column(w);
48 if (w == Moment(0) || w == l_mom) {
52 c1->musical_b_ = false;
53 c2->musical_b_ = true;
55 cols_.bottom().add(c1);
56 cols_.bottom().add(c2);
57 rcol_p->set_score_cols(c1, c2);
58 rcols_.bottom().add(rcol_p);
59 pulk.get_aligned_request( rcol_p );
63 errorlevel_i_ |= pulk.time_checks_failed_b();
67 Score::process_music()
69 *mlog << "Processing requests ..." << flush;
70 for (Score_walker w(this); w.ok(); w++) {
90 // should we? hampers debugging.
91 warning("Errors found, /*not processing score*/");
94 pscore_p_ = new PScore(paper_p_);
97 for (iter_top(staffs_,i); i.ok(); i++)
98 i->set_output(pscore_p_);
102 clean_cols(); // can't move clean_cols() farther up.
109 pscore_p_->process();
117 Remove empty cols, preprocess other columns.
123 for (iter_top(staffs_,i); i.ok(); i++)
126 for (iter_top(rcols_,i); i.ok(); i++) {
127 i->when(); // update cache, ugh
128 if (!i->command_column_l_->used_b()) {
129 i->command_column_l_ = 0;
131 if (!i->musical_column_l_->used_b())
132 i->musical_column_l_ = 0;
135 for (iter_top(cols_,c); c.ok(); ) {
136 if (!c->pcol_l_->used_b()) {
146 PCursor<Score_column*>
147 Score::find_col(Moment w, bool mus)
151 for (; i.ok(); i++) {
152 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(Paper_def *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++) {
247 Score::paper_output()
249 if (paper_p_->outfile=="")
250 paper_p_->outfile = default_out_fn + ".out";
252 if ( errorlevel_i_ ) {
253 *mlog << "lilypond: warning: no output to: " << paper_p_->outfile
254 << " (errorlevel=" << errorlevel_i_ << ")" << endl;
258 *mlog << "TeX output to " << paper_p_->outfile << " ...\n";
260 Tex_stream the_output(paper_p_->outfile);
262 the_output << "% outputting Score, defined at: " <<
263 input_.location_str() << "\n";
264 pscore_p_->output(the_output);
274 if (midi_p_->outfile_str_ == "")
275 midi_p_->outfile_str_ = default_out_fn + ".midi";
277 *mlog << "midi output to " << midi_p_->outfile_str_ << " ...\n";
278 Midi_output(this, midi_p_);
285 staffs_.bottom().add(s);