2 timing-grav.cc -- implement Timing_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
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"
19 class Timing_engraver : public Timing_translator, public Engraver
23 Needed to know whether we're advancing in grace notes, or not.
27 virtual void start_translation_timestep ();
28 virtual void stop_translation_timestep ();
31 TRANSLATOR_DECLARATIONS(Timing_engraver);
35 Timing_engraver::Timing_engraver ()
37 last_moment_.main_part_ = Rational (-1);
43 Timing_engraver::start_translation_timestep ()
45 Timing_translator::start_translation_timestep ();
47 SCM nonauto = get_property ("barNonAuto");
48 Moment now = now_mom ();
49 SCM which = get_property ("whichBar");
52 Set the first bar of the score?
54 if (!gh_string_p (which))
56 = (now.main_part_ || now.main_part_ == last_moment_.main_part_)
57 ? SCM_EOL : ly_str02scm ("|");
59 Moment mp = measure_position ();
60 bool start_of_measure = (last_moment_.main_part_ != now.main_part_&& !mp.main_part_ );
64 Moment mlen = Moment(measure_length ());
65 unsmob_grob (get_property ("currentCommandColumn"))->set_grob_property ("measure-length", mlen.smobbed_copy());
68 if (!gh_string_p (which) && !to_boolean (nonauto))
70 SCM always = get_property ("barAlways");
72 if ( start_of_measure || (to_boolean (always)))
74 /* should this work, or be junked? See input/bugs/no-bars.ly */
75 which = get_property ("defaultBarType");
79 daddy_trans_l_->set_property ("whichBar", which);
83 Timing_engraver::stop_translation_timestep ()
85 Timing_translator::stop_translation_timestep ();
86 daddy_trans_l_->set_property ("whichBar", SCM_EOL);
87 last_moment_ = now_mom ();
92 ENTER_DESCRIPTION(Timing_engraver,
93 /* descr */ " Responsible for synchronizing timing information from staves.
94 Normally in @code{Score}. In order to create polyrhythmic music,
95 this engraver should be removed from @code{Score} and placed in
99 /* reads */ "timeSignatureFraction barCheckNoSynchronize barNonAuto whichBar barAlways defaultBarType skipBars timing oneBeat measureLength measurePosition currentBarNumber",