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"
13 #include "paper-def.hh"
16 #include "source-file.hh"
17 #include "midi-output.hh"
18 #include "midi-def.hh"
20 #include "score-reg.hh"
21 #include "music-iterator.hh"
23 #include "music-list.hh"
24 #include "input-register.hh"
26 extern String default_out_fn;
28 Score::Score(Score const &s)
31 music_p_ = s.music_p_->clone();
32 midi_p_ = new Midi_def(*s.midi_p_);
33 paper_p_ = new Paper_def(*s.paper_p_);
39 *mlog << "\nSetting up requests..." << flush;
41 Score_register * score_reg =
42 (Score_register*)lookup_reg("Score_register")->get_group_register_p();
44 score_reg->set_score (this);
45 Music_iterator * iter = Music_iterator::static_get_iterator_p(music_p_,
47 iter->construct_children();
49 while ( iter->ok() || score_reg->extra_mom_pq_.size() ) {
52 w = iter->next_moment();
55 if (score_reg->extra_mom_pq_.size() &&
56 score_reg->extra_mom_pq_.front() <= w)
58 w = score_reg->extra_mom_pq_.get();
60 mtor << "processing moment " << w << "\n";
62 Score_column* c1 = new Score_column(w);
63 Score_column* c2 = new Score_column(w);
65 c1->musical_b_ = false;
66 c2->musical_b_ = true;
68 cols_.bottom().add(c1);
69 cols_.bottom().add(c2);
70 score_reg->set_cols(c1,c2);
72 score_reg->post_move_processing();
75 score_reg->process_requests();
76 score_reg->do_announces();
77 score_reg->pre_move_processing();
78 score_reg->check_removal();
81 score_reg->check_removal();
82 score_reg->do_removal_processing();
99 // should we? hampers debugging.
100 warning("Errors found, /*not processing score*/");
103 pscore_p_ = new PScore(paper_p_);
107 clean_cols(); // can't move clean_cols() farther up.
114 pscore_p_->process();
122 Remove empty cols, preprocess other columns.
128 for (iter_top(cols_,c); c.ok(); ) {
129 if (!c->pcol_l_->used_b()) {
139 PCursor<Score_column*>
140 Score::find_col(Moment w, bool mus)
144 for (; i.ok(); i++) {
145 if (i->when() == w && i->musical_b_ == mus)
158 for (; i.ok(); i++) {
159 pscore_p_->add(i->pcol_l_);
172 Score::set(Paper_def *pap_p)
179 Score::set(Midi_def* midi_p)
190 for (iter_top(cols_,cc); cc.ok() && (cc+1).ok(); cc++) {
191 assert(cc->when() <= (cc+1)->when());
203 for (iter_top(cols_,i); i.ok(); i++) {
232 Score::paper_output()
234 if (paper_p_->outfile=="")
235 paper_p_->outfile = default_out_fn + ".out";
237 if ( errorlevel_i_ ) {
238 *mlog << "lilypond: warning: no output to: " << paper_p_->outfile
239 << " (errorlevel=" << errorlevel_i_ << ")" << endl;
243 *mlog << "TeX output to " << paper_p_->outfile << " ...\n";
245 Tex_stream the_output(paper_p_->outfile);
247 the_output << "% outputting Score, defined at: " <<
248 location_str() << "\n";
249 pscore_p_->output(the_output);
260 if (midi_p_->outfile_str_ == "")
261 midi_p_->outfile_str_ = default_out_fn + ".midi";
263 *mlog << "midi output to " << midi_p_->outfile_str_ << " ...\n";
264 Midi_output(this, midi_p_);