2 score.cc -- implement Score
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "tex-stream.hh"
11 #include "score-column.hh"
14 #include "paper-def.hh"
17 #include "source-file.hh"
18 #include "midi-output.hh"
19 #include "midi-def.hh"
21 #include "music-iterator.hh"
23 #include "global-translator.hh"
25 extern String default_out_fn;
35 Score::Score(Score const &s)
38 music_p_ = s.music_p_->clone();
39 midi_p_ = new Midi_def(*s.midi_p_);
40 paper_p_ = new Paper_def(*s.paper_p_);
52 Score::run_translator(Global_translator * trans_l)
54 trans_l->set_score (this);
55 Music_iterator * iter = Music_iterator::static_get_iterator_p(music_p_,
57 iter->construct_children();
60 while ( iter->ok() || trans_l->moments_left_i() ) {
63 w = iter->next_moment();
66 trans_l->modify_next( w );
68 iter->process_and_next( w );
88 *mlog << "\nCreating elements ..." << flush;
90 Global_translator* score_trans= midi_p_->get_global_translator_p();
91 run_translator( score_trans );
95 // should we? hampers debugging.
96 warning( "Errors found, /*not processing score*/" );
109 *mlog << "\nCreating elements ..." << flush;
110 pscore_p_ = new PScore(paper_p_);
112 Global_translator * score_trans= paper_p_->get_global_translator_p();
113 run_translator( score_trans );
117 // should we? hampers debugging.
118 warning("Errors found, /*not processing score*/");
123 clean_cols(); // can't move clean_cols() farther up.
130 pscore_p_->process();
137 Remove empty cols, preprocess other columns.
142 for (iter_top(cols_,c); c.ok(); ) {
143 if (!c->pcol_l_->used_b()) {
152 PCursor<Score_column*>
153 Score::find_col(Moment w, bool mus)
157 for (; i.ok(); i++) {
158 if (i->when() == w && i->musical_b_ == mus)
171 for (; i.ok(); i++) {
172 pscore_p_->add(i->pcol_l_);
177 Score::set(Paper_def *pap_p)
184 Score::set(Midi_def* midi_p)
195 for (iter_top(cols_,cc); cc.ok() && (cc+1).ok(); cc++) {
196 assert(cc->when() <= (cc+1)->when());
208 for (iter_top(cols_,i); i.ok(); i++) {
221 Score::paper_output()
223 if (paper_p_->outfile_str_=="")
224 paper_p_->outfile_str_ = default_out_fn + ".out";
226 if ( errorlevel_i_ ) {
227 *mlog << "lilypond: warning: no output to: " << paper_p_->outfile_str_
228 << " (errorlevel=" << errorlevel_i_ << ")" << endl;
232 *mlog << "TeX output to " << paper_p_->outfile_str_ << " ...\n";
234 Tex_stream the_output(paper_p_->outfile_str_);
236 the_output << "% outputting Score, defined at: " <<
237 location_str() << "\n";
238 pscore_p_->output(the_output);
249 if (midi_p_->outfile_str_ == "")
250 midi_p_->outfile_str_ = default_out_fn + ".midi";
252 *mlog << "midi output to " << midi_p_->outfile_str_ << " ...\n";
253 Midi_output(this, midi_p_);