X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftiming-engraver.cc;h=e8d49a7771aab97134fb36d7d7c8cd78504281a7;hb=d799307965f096fccddf8885693f279b1575273b;hp=da097bc7d5499d2fa31bc0024cf5ce9a5df5868d;hpb=94189ec2b8da6d7e89dc619c646a927adead9b19;p=lilypond.git diff --git a/lily/timing-engraver.cc b/lily/timing-engraver.cc index da097bc7d5..e8d49a7771 100644 --- a/lily/timing-engraver.cc +++ b/lily/timing-engraver.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2001 Han-Wen Nienhuys + (c) 1997--2002 Han-Wen Nienhuys */ #include "translator-group.hh" #include "command-request.hh" @@ -11,42 +11,68 @@ #include "multi-measure-rest.hh" #include "timing-translator.hh" #include "engraver.hh" +#include "grob.hh" /** Do time bookkeeping */ class Timing_engraver : public Timing_translator, public Engraver -{ +{ protected: + /* + Needed to know whether we're advancing in grace notes, or not. + */ + Moment last_moment_; + virtual void start_translation_timestep (); virtual void stop_translation_timestep (); - virtual void process_music (); + public: - VIRTUAL_COPY_CONS(Translator); + TRANSLATOR_DECLARATIONS(Timing_engraver); }; -ADD_THIS_TRANSLATOR(Timing_engraver); + +Timing_engraver::Timing_engraver () +{ + last_moment_.main_part_ = Rational (-1); +} + + void -Timing_engraver::start_translation_timestep( ) +Timing_engraver::start_translation_timestep () { Timing_translator::start_translation_timestep (); SCM nonauto = get_property ("barNonAuto"); - + Moment now = now_mom (); SCM which = get_property ("whichBar"); + + /* + Set the first bar of the score? + */ if (!gh_string_p (which)) - which = now_mom () + which + = (now.main_part_ || now.main_part_ == last_moment_.main_part_) ? SCM_EOL : ly_str02scm ("|"); + + Moment mp = measure_position (); + bool start_of_measure = (last_moment_.main_part_ != now.main_part_&& !mp.main_part_ ); + + if (start_of_measure) + { + Moment mlen = Moment(measure_length ()); + unsmob_grob (get_property ("currentCommandColumn"))->set_grob_property ("measure-length", mlen.smobbed_copy()); + } if (!gh_string_p (which) && !to_boolean (nonauto)) { SCM always = get_property ("barAlways"); - if (!measure_position () - || (to_boolean (always))) + + if ( start_of_measure || (to_boolean (always))) { /* should this work, or be junked? See input/bugs/no-bars.ly */ - which=get_property ("defaultBarType" ); + which = get_property ("defaultBarType"); } } @@ -57,15 +83,18 @@ void Timing_engraver::stop_translation_timestep () { Timing_translator::stop_translation_timestep (); - daddy_trans_l_->set_property ("whichBar", SCM_EOL); + daddy_trans_l_->set_property ("whichBar", SCM_EOL); + last_moment_ = now_mom (); + } -/* - ugh. Translator doesn't do process_music (). - */ -void -Timing_engraver::process_music () -{ - Timing_translator::process_music (); -} +ENTER_DESCRIPTION(Timing_engraver, +/* descr */ " Responsible for synchronizing timing information from staves. +Normally in @code{Score}. In order to create polyrhythmic music, +this engraver should be removed from @code{Score} and placed in +@code{Staff}.", +/* creats*/ "", +/* acks */ "", +/* reads */ "timeSignatureFraction barNonAuto whichBar barAlways defaultBarType skipBars timing oneBeat measureLength measurePosition currentBarNumber", +/* write */ "");