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 music ..." << 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 music ..." << 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 if (!i->command_column_l_->used_b()) {
118 i->command_column_l_ = 0;
120 if (!i->musical_column_l_->used_b())
121 i->musical_column_l_ = 0;
124 for (iter_top(cols_,c); c.ok(); ) {
125 if (!c->pcol_l_->used_b()) {
135 PCursor<Score_column*>
136 Score::find_col(Moment w, bool mus)
140 for (; i.ok(); i++) {
141 if (i->when() == w && i->musical_b_ == mus)
154 for (; i.ok(); i++) {
155 pscore_p_->add(i->pcol_l_);
163 for (iter_top(staffs_,i); i.ok(); i++) {
170 Score::set(Paper_def *pap_p)
177 Score::set(Midi_def* midi_p)
187 for (iter_top(staffs_,i); i.ok(); i++) {
189 assert(i->score_l_ == this);
193 for (iter_top(cols_,cc); cc.ok() && (cc+1).ok(); cc++) {
194 assert(cc->when() <= (cc+1)->when());
205 for (iter_top(staffs_,i); i.ok(); i++) {
208 for (iter_top(cols_,i); i.ok(); i++) {
236 Score::paper_output()
238 if (paper_p_->outfile=="")
239 paper_p_->outfile = default_out_fn + ".out";
241 if ( errorlevel_i_ ) {
242 *mlog << "lilypond: warning: no output to: " << paper_p_->outfile
243 << " (errorlevel=" << errorlevel_i_ << ")" << endl;
247 *mlog << "TeX output to " << paper_p_->outfile << " ...\n";
249 Tex_stream the_output(paper_p_->outfile);
251 the_output << "% outputting Score, defined at: " <<
252 input_.location_str() << "\n";
253 pscore_p_->output(the_output);
263 if (midi_p_->outfile_str_ == "")
264 midi_p_->outfile_str_ = default_out_fn + ".midi";
266 *mlog << "midi output to " << midi_p_->outfile_str_ << " ...\n";
267 Midi_output(this, midi_p_);
274 staffs_.bottom().add(s);