2 score.cc -- implement Score
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "ly-smobs.icc"
13 #include "music-output-def.hh"
14 #include "music-output.hh"
15 #include "music-iterator.hh"
17 #include "global-translator.hh"
18 #include "scm-hash.hh"
19 #include "cpu-timer.hh"
21 #include "paper-def.hh"
39 store point & click locations.
40 Global to save some time. (Sue us!)
42 bool store_locations_global_b;
44 Score::Score (Score const &s)
51 Music * m =unsmob_music (s.music_);
52 music_ = m?m->clone ()->self_scm () : SCM_EOL;
53 scm_gc_unprotect_object (music_);
55 for (int i=0; i < s.def_p_arr_.size (); i++)
56 def_p_arr_.push (s.def_p_arr_[i]->clone ());
57 errorlevel_i_ = s.errorlevel_i_;
60 header_p_ = (s.header_p_) ? new Scheme_hash_table (*s.header_p_): 0;
62 scm_gc_unprotect_object (header_p_->self_scm ());
72 Score::run_translator (Music_output_def *odef_l)
75 We want to know if we want to store locations, since they take a
79 store_locations_global_b = (gh_eval_str ("point-and-click") != SCM_BOOL_F);
85 Global_translator * trans_p = odef_l->get_global_translator_p ();
88 programming_error ("no toplevel translator");
91 progress_indication (_ ("Interpreting music..."));
92 Music * music = unsmob_music (music_);
94 trans_p->final_mom_ = music->length_mom ();
97 Music_iterator * iter = Music_iterator::static_get_iterator_p (music);
98 iter->init_translator (music, trans_p);
100 iter->construct_children ();
105 warning (_ ("Need music in a score"));
111 trans_p->run_iterator_on_me (iter);
117 // should we? hampers debugging.
118 warning (_ ("Errors found/*, not processing score*/"));
121 Music_output * output = trans_p->get_output_p ();
122 scm_gc_unprotect_object (trans_p->self_scm ());
124 if (verbose_global_b)
125 progress_indication (_f ("elapsed time: %.2f seconds", timer.read ()));
128 header_p_ = new Scheme_hash_table; // ugh
130 output->header_l_ = header_p_;
131 output->origin_str_ = location_str ();
133 progress_indication ("\n");
138 force GC. At this point, GUILE may give back mallocated area to
148 if (!unsmob_music (music_))
152 for (int i=0; i < def_p_arr_.size (); i++)
154 if (no_paper_global_b
155 && dynamic_cast<Paper_def*> (def_p_arr_[i]))
157 run_translator (def_p_arr_[i]);
165 Score::add_output (Music_output_def *pap_p)
167 def_p_arr_.push (pap_p);
170 IMPLEMENT_SMOBS (Score);
171 IMPLEMENT_DEFAULT_EQUAL_P (Score);
175 Score::mark_smob (SCM s)
177 Score * sc = (Score*) SCM_CELL_WORD_1 (s);
179 scm_gc_mark (sc->header_p_->self_scm ());
180 for (int i = sc->def_p_arr_.size (); i--;)
181 scm_gc_mark (sc->def_p_arr_[i]->self_scm ());
187 Score::print_smob (SCM , SCM p, scm_print_state*)
189 scm_puts ("#<Score>", p);