2
timing-grav.cc -- implement Timing_engraver
4
source file of the GNU LilyPond music typesetter
6
(c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9
#include "grob-info.hh"
10
#include "multi-measure-rest.hh"
11
#include "timing-translator.hh"
12
#include "engraver.hh"
18
class Timing_engraver : public Timing_translator, public Engraver
21
/* Needed to know whether we're advancing in grace notes, or not. */
24
virtual void start_translation_timestep ();
25
virtual void initialize ();
26
virtual void stop_translation_timestep ();
29
TRANSLATOR_DECLARATIONS (Timing_engraver);
33
Timing_engraver::Timing_engraver ()
35
last_moment_.main_part_ = Rational (-1);
40
Timing_engraver::initialize ()
42
Timing_translator::initialize ();
44
SCM which = get_property ("whichBar");
45
Moment now = now_mom ();
47
/* Set the first bar of the score? */
48
if (!gh_string_p (which))
49
which = (now.main_part_ || now.main_part_ == last_moment_.main_part_)
50
? SCM_EOL : scm_makfrom0str ("|");
52
daddy_context_->set_property ("whichBar", which);
57
Timing_engraver::start_translation_timestep ()
59
Timing_translator::start_translation_timestep ();
61
SCM automatic_bars = get_property ("automaticBars");
62
Moment now = now_mom ();
63
SCM which = get_property ("whichBar");
65
/* Set the first bar of the score? */
66
if (!gh_string_p (which))
69
Moment mp = measure_position ();
70
bool start_of_measure = (last_moment_.main_part_ != now.main_part_
75
Moment mlen = Moment (measure_length ());
76
unsmob_grob (get_property ("currentCommandColumn"))
77
->set_property ("measure-length", mlen.smobbed_copy ());
80
if (!gh_string_p (which) && to_boolean (automatic_bars))
82
SCM always = get_property ("barAlways");
84
if ( start_of_measure || (to_boolean (always)))
86
/* should this work, or be junked? See input/bugs/no-bars.ly */
87
which = get_property ("defaultBarType");
91
daddy_context_->set_property ("whichBar", which);
95
Timing_engraver::stop_translation_timestep ()
97
Timing_translator::stop_translation_timestep ();
98
daddy_context_->set_property ("whichBar", SCM_EOL);
99
last_moment_ = now_mom ();
103
ENTER_DESCRIPTION (Timing_engraver,
104
/* descr */ " Responsible for synchronizing timing information from staves. "
105
"Normally in @code{Score}. In order to create polyrhythmic music, "
106
"this engraver should be removed from @code{Score} and placed in "
108
"\n\nThis engraver adds the alias @code{Timing} to its containing context."
114
/* reads */ "timeSignatureFraction automaticBars whichBar barAlways defaultBarType skipBars timing measureLength measurePosition currentBarNumber",