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();
54 if (score_reg->extra_mom_pq_.size() &&
55 score_reg->extra_mom_pq_.front() <= w)
57 w = score_reg->extra_mom_pq_.get();
59 mtor << "processing moment " << w << "\n";
61 Score_column* c1 = new Score_column(w);
62 Score_column* c2 = new Score_column(w);
64 c1->musical_b_ = false;
65 c2->musical_b_ = true;
67 cols_.bottom().add(c1);
68 cols_.bottom().add(c2);
69 score_reg->set_cols(c1,c2);
71 score_reg->post_move_processing();
74 score_reg->process_requests();
75 score_reg->do_announces();
76 score_reg->pre_move_processing();
79 score_reg->do_removal_processing();
96 // should we? hampers debugging.
97 warning("Errors found, /*not processing score*/");
100 pscore_p_ = new PScore(paper_p_);
104 clean_cols(); // can't move clean_cols() farther up.
111 pscore_p_->process();
119 Remove empty cols, preprocess other columns.
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_);
169 Score::set(Paper_def *pap_p)
176 Score::set(Midi_def* midi_p)
187 for (iter_top(cols_,cc); cc.ok() && (cc+1).ok(); cc++) {
188 assert(cc->when() <= (cc+1)->when());
200 for (iter_top(cols_,i); i.ok(); i++) {
229 Score::paper_output()
231 if (paper_p_->outfile=="")
232 paper_p_->outfile = default_out_fn + ".out";
234 if ( errorlevel_i_ ) {
235 *mlog << "lilypond: warning: no output to: " << paper_p_->outfile
236 << " (errorlevel=" << errorlevel_i_ << ")" << endl;
240 *mlog << "TeX output to " << paper_p_->outfile << " ...\n";
242 Tex_stream the_output(paper_p_->outfile);
244 the_output << "% outputting Score, defined at: " <<
245 location_str() << "\n";
246 pscore_p_->output(the_output);
257 if (midi_p_->outfile_str_ == "")
258 midi_p_->outfile_str_ = default_out_fn + ".midi";
260 *mlog << "midi output to " << midi_p_->outfile_str_ << " ...\n";
261 Midi_output(this, midi_p_);