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.");
40 Moment w= pulk.next_mom();
41 Request_column* rcol_p = new Request_column( staffs_ );
43 Score_column* c1 = new Score_column(w);
44 Score_column* c2 = new Score_column(w);
45 if (w == Moment(0) || w == l_mom) {
49 c1->musical_b_ = false;
50 c2->musical_b_ = true;
52 cols_.bottom().add(c1);
53 cols_.bottom().add(c2);
54 rcol_p->set_score_cols(c1, c2);
55 rcols_.bottom().add(rcol_p);
56 pulk.get_aligned_request( rcol_p );
61 Score::process_music()
63 *mlog << "Processing requests ..." << flush;
64 for (Score_walker w(this); w.ok(); w++) {
84 pscore_p_ = new PScore(paper_p_);
87 for (iter_top(staffs_,i); i.ok(); i++)
88 i->set_output(pscore_p_);
92 clean_cols(); // can't move clean_cols() farther up.
107 Remove empty cols, preprocess other columns.
113 for (iter_top(staffs_,i); i.ok(); i++)
116 for (iter_top(rcols_,i); i.ok(); i++) {
117 i->when(); // update cache, ugh
118 if (!i->command_column_l_->used_b()) {
119 i->command_column_l_ = 0;
121 if (!i->musical_column_l_->used_b())
122 i->musical_column_l_ = 0;
125 for (iter_top(cols_,c); c.ok(); ) {
126 if (!c->pcol_l_->used_b()) {
136 PCursor<Score_column*>
137 Score::find_col(Moment w, bool mus)
141 for (; i.ok(); i++) {
142 if (i->when() == w && i->musical_b_ == mus)
155 for (; i.ok(); i++) {
156 pscore_p_->add(i->pcol_l_);
164 for (iter_top(staffs_,i); i.ok(); i++) {
171 Score::set(Paper_def *pap_p)
178 Score::set(Midi_def* midi_p)
188 for (iter_top(staffs_,i); i.ok(); i++) {
190 assert(i->score_l_ == this);
194 for (iter_top(cols_,cc); cc.ok() && (cc+1).ok(); cc++) {
195 assert(cc->when() <= (cc+1)->when());
206 for (iter_top(staffs_,i); i.ok(); i++) {
209 for (iter_top(cols_,i); i.ok(); i++) {
237 Score::paper_output()
239 if (paper_p_->outfile=="")
240 paper_p_->outfile = default_out_fn + ".out";
242 if ( errorlevel_i_ ) {
243 *mlog << "lilypond: warning: no output to: " << paper_p_->outfile
244 << " (errorlevel=" << errorlevel_i_ << ")" << endl;
248 *mlog << "TeX output to " << paper_p_->outfile << " ...\n";
250 Tex_stream the_output(paper_p_->outfile);
252 the_output << "% outputting Score, defined at: " <<
253 input_.location_str() << "\n";
254 pscore_p_->output(the_output);
264 if (midi_p_->outfile_str_ == "")
265 midi_p_->outfile_str_ = default_out_fn + ".midi";
267 *mlog << "midi output to " << midi_p_->outfile_str_ << " ...\n";
268 Midi_output(this, midi_p_);
275 staffs_.bottom().add(s);