lilypond-1.5.10
[lilypond.git] / lily / timing-engraver.cc
blobfb021095830bcb4f58a7005fa4bfdc8014dec803
1 /*
2 timing-grav.cc -- implement Timing_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8 #include "translator-group.hh"
9 #include "command-request.hh"
10 #include "grob-info.hh"
11 #include "multi-measure-rest.hh"
12 #include "timing-translator.hh"
13 #include "engraver.hh"
15 /**
16 Do time bookkeeping
18 class Timing_engraver : public Timing_translator, public Engraver
20 protected:
22 Needed to know whether we're advancing in grace notes, or not.
24 Moment last_moment_;
26 virtual void start_translation_timestep ();
27 virtual void stop_translation_timestep ();
28 virtual void process_music ();
30 public:
31 Timing_engraver ();
32 VIRTUAL_COPY_CONS (Translator);
36 Timing_engraver::Timing_engraver ()
38 last_moment_.main_part_ = Rational (-1);
41 ADD_THIS_TRANSLATOR (Timing_engraver);
43 void
44 Timing_engraver::start_translation_timestep ()
46 Timing_translator::start_translation_timestep ();
48 SCM nonauto = get_property ("barNonAuto");
49 Moment now = now_mom ();
50 SCM which = get_property ("whichBar");
53 Set the first bar of the score?
55 if (!gh_string_p (which))
56 which
57 = (now.main_part_ || now.main_part_ == last_moment_.main_part_)
58 ? SCM_EOL : ly_str02scm ("|");
60 if (!gh_string_p (which) && !to_boolean (nonauto))
62 SCM always = get_property ("barAlways");
63 Moment mp = measure_position ();
64 if ( (last_moment_.main_part_ != now.main_part_
65 && !mp.main_part_)
66 || (to_boolean (always)))
68 /* should this work, or be junked? See input/bugs/no-bars.ly */
69 which = get_property ("defaultBarType");
73 daddy_trans_l_->set_property ("whichBar", which);
76 void
77 Timing_engraver::stop_translation_timestep ()
79 Timing_translator::stop_translation_timestep ();
80 daddy_trans_l_->set_property ("whichBar", SCM_EOL);
81 last_moment_ = now_mom ();
86 ugh. Translator doesn't do process_music ().
88 void
89 Timing_engraver::process_music ()
91 Timing_translator::process_music ();