(process_acknowledged_grobs):
[lilypond.git] / lily / timing-engraver.cc
blobbe0fa1aef6cf0815e2a7ac7640a57f1bed9ff089
1 /*
2 timing-grav.cc -- implement Timing_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8 #include "translator-group.hh"
10 #include "grob-info.hh"
11 #include "multi-measure-rest.hh"
12 #include "timing-translator.hh"
13 #include "engraver.hh"
14 #include "grob.hh"
16 /**
17 Do time bookkeeping
19 class Timing_engraver : public Timing_translator, public Engraver
21 protected:
22 /* Needed to know whether we're advancing in grace notes, or not. */
23 Moment last_moment_;
25 virtual void start_translation_timestep ();
26 virtual void stop_translation_timestep ();
28 public:
29 TRANSLATOR_DECLARATIONS (Timing_engraver);
33 Timing_engraver::Timing_engraver ()
35 last_moment_.main_part_ = Rational (-1);
40 void
41 Timing_engraver::start_translation_timestep ()
43 Timing_translator::start_translation_timestep ();
45 SCM automatic_bars = get_property ("automaticBars");
46 Moment now = now_mom ();
47 SCM which = get_property ("whichBar");
49 /* Set the first bar of the score? */
50 if (!gh_string_p (which))
51 which
52 = (now.main_part_ || now.main_part_ == last_moment_.main_part_)
53 ? SCM_EOL : scm_makfrom0str ("|");
55 Moment mp = measure_position ();
56 bool start_of_measure = (last_moment_.main_part_ != now.main_part_
57 && !mp.main_part_);
59 if (start_of_measure)
61 Moment mlen = Moment (measure_length ());
62 unsmob_grob (get_property ("currentCommandColumn"))
63 ->set_grob_property ("measure-length", mlen.smobbed_copy ());
66 if (!gh_string_p (which) && to_boolean (automatic_bars))
68 SCM always = get_property ("barAlways");
70 if ( start_of_measure || (to_boolean (always)))
72 /* should this work, or be junked? See input/bugs/no-bars.ly */
73 which = get_property ("defaultBarType");
77 daddy_trans_->set_property ("whichBar", which);
80 void
81 Timing_engraver::stop_translation_timestep ()
83 Timing_translator::stop_translation_timestep ();
84 daddy_trans_->set_property ("whichBar", SCM_EOL);
85 last_moment_ = now_mom ();
90 ENTER_DESCRIPTION (Timing_engraver,
91 /* descr */ " Responsible for synchronizing timing information from staves. "
92 "Normally in @code{Score}. In order to create polyrhythmic music, "
93 "this engraver should be removed from @code{Score} and placed in "
94 "@code{Staff}.",
95 /* creats*/ "",
96 /* accepts */ "",
97 /* acks */ "",
98 /* reads */ "timeSignatureFraction automaticBars whichBar barAlways defaultBarType skipBars timing measureLength measurePosition currentBarNumber",
99 /* write */ "");