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>
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"
19 class Timing_engraver
: public Timing_translator
, public Engraver
22 /* Needed to know whether we're advancing in grace notes, or not. */
25 virtual void start_translation_timestep ();
26 virtual void stop_translation_timestep ();
29 TRANSLATOR_DECLARATIONS (Timing_engraver
);
33 Timing_engraver::Timing_engraver ()
35 last_moment_
.main_part_
= Rational (-1);
41 Timing_engraver::start_translation_timestep ()
43 Timing_translator::start_translation_timestep ();
45 SCM nonauto
= get_property ("barNonAuto");
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
))
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_
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 (nonauto
))
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
);
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 "
98 /* reads */ "timeSignatureFraction barNonAuto whichBar barAlways defaultBarType skipBars timing oneBeat measureLength measurePosition currentBarNumber",