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>
11 #include "ly-smobs.icc"
15 #include "music-output-def.hh"
16 #include "music-output.hh"
17 #include "music-iterator.hh"
19 #include "global-translator.hh"
20 #include "scm-hash.hh"
21 #include "cpu-timer.hh"
23 #include "paper-def.hh"
24 #include "ly-modules.hh"
43 store point & click locations.
44 Global to save some time. (Sue us!)
46 bool store_locations_global_b;
48 Score::Score (Score const &s)
55 Music * m =unsmob_music (s.music_);
56 music_ = m?m->clone ()->self_scm () : SCM_EOL;
57 scm_gc_unprotect_object (music_);
59 for (int i=0; i < s.defs_.size (); i++)
60 defs_.push (s.defs_[i]->clone ());
61 errorlevel_ = s.errorlevel_;
63 header_ = ly_make_anonymous_module ();
64 if (ly_module_p (s.header_))
65 ly_copy_module_variables (header_, s.header_);
76 Score::run_translator (Music_output_def *odef)
79 We want to know if we want to store locations, since they take a
82 store_locations_global_b = (gh_eval_str ("point-and-click") != SCM_BOOL_F);
85 Global_translator * trans = odef->get_global_translator ();
88 programming_error ("no toplevel translator");
91 progress_indication (_ ("Interpreting music..."));
92 Music * music = unsmob_music (music_);
94 trans->final_mom_ = music->get_length ();
95 SCM protected_iter = Music_iterator::get_static_get_iterator (music);
96 Music_iterator * iter = unsmob_iterator (protected_iter);
97 iter->init_translator (music, trans);
99 iter->construct_children ();
103 warning (_ ("Need music in a score"));
109 trans->run_iterator_on_me (iter);
111 scm_remember_upto_here_1 (protected_iter);
116 // should we? hampers debugging.
117 warning (_ ("Errors found/*, not processing score*/"));
120 Music_output * output = trans->get_output ();
121 scm_gc_unprotect_object (trans->self_scm ());
123 if (verbose_global_b)
124 progress_indication (_f ("elapsed time: %.2f seconds", timer.read ()));
127 header_ = ly_make_anonymous_module(); // ug.h
129 output->header_ = header_;
130 output->origin_string_ = location_string ();
132 progress_indication ("\n");
141 if (!unsmob_music (music_))
144 for (int i=0; i < defs_.size (); i++)
146 if (no_paper_global_b
147 && dynamic_cast<Paper_def*> (defs_[i]))
149 run_translator (defs_[i]);
155 Score::add_output (Music_output_def *pap)
160 IMPLEMENT_SMOBS (Score);
161 IMPLEMENT_DEFAULT_EQUAL_P (Score);
165 Score::mark_smob (SCM s)
167 Score * sc = (Score*) SCM_CELL_WORD_1 (s);
169 scm_gc_mark (sc->header_);
170 for (int i = sc->defs_.size (); i--;)
171 scm_gc_mark (sc->defs_[i]->self_scm ());
177 Score::print_smob (SCM , SCM p, scm_print_state*)
179 scm_puts ("#<Score>", p);