X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftiming-engraver.cc;h=a6153a90bfe925ba26a1a2ae35349b2c4c4036d6;hb=e58fce49b3113408254011774685370b8233df17;hp=e64182a3a8955d84e095558b4bf0f408f1471d4c;hpb=6b6a34e929bf1d5a8859fe77e66396c3c15ef37c;p=lilypond.git diff --git a/lily/timing-engraver.cc b/lily/timing-engraver.cc index e64182a3a8..a6153a90bf 100644 --- a/lily/timing-engraver.cc +++ b/lily/timing-engraver.cc @@ -3,80 +3,96 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2000 Han-Wen Nienhuys + (c) 1997--2003 Han-Wen Nienhuys */ +#include "translator-group.hh" -#include "score-engraver.hh" -#include "timing-engraver.hh" -#include "command-request.hh" -#include "score-element-info.hh" +#include "grob-info.hh" #include "multi-measure-rest.hh" +#include "timing-translator.hh" +#include "engraver.hh" +#include "grob.hh" -ADD_THIS_TRANSLATOR(Timing_engraver); - -void -Timing_engraver::do_post_move_processing( ) +/** + Do time bookkeeping + */ +class Timing_engraver : public Timing_translator, public Engraver { - bar_req_l_ = 0; - Timing_translator::do_post_move_processing (); +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 (); + +public: + TRANSLATOR_DECLARATIONS (Timing_engraver); +}; -bool -Timing_engraver::do_try_music (Music*m) + +Timing_engraver::Timing_engraver () { - if (Bar_req * b= dynamic_cast (m)) - { - if (bar_req_l_ && bar_req_l_->equal_b (b)) // huh? - return false; - - bar_req_l_ = b; - return true; - } - - return Timing_translator::do_try_music (m); + last_moment_.main_part_ = Rational (-1); } -#if 0 -String -Timing_engraver::do_process_music () -{ - if (gh_string_p (get_property ("barType"))) - ; - else if (!now_mom ()) - { - daddy_trans_l_->set_property ("barType", ly_str02scm ("|")); - } - else - { - } -} -#endif -String -Timing_engraver::which_bar () +void +Timing_engraver::start_translation_timestep () { - if (!bar_req_l_) + Timing_translator::start_translation_timestep (); + + SCM automatic_bars = get_property ("automaticBars"); + Moment now = now_mom (); + SCM which = get_property ("whichBar"); + + /* Set the first bar of the score? */ + if (!gh_string_p (which)) + which + = (now.main_part_ || now.main_part_ == last_moment_.main_part_) + ? SCM_EOL : scm_makfrom0str ("|"); + + Moment mp = measure_position (); + bool start_of_measure = (last_moment_.main_part_ != now.main_part_ + && !mp.main_part_); + + if (start_of_measure) { - if (!now_mom ()) - return "|"; + 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 (automatic_bars)) + { + SCM always = get_property ("barAlways"); - SCM nonauto = get_property ("barNonAuto"); - if (!to_boolean (nonauto)) + if ( start_of_measure || (to_boolean (always))) { - SCM always = get_property ("barAlways"); - if (!measure_position () - || (to_boolean (always))) - { - SCM def=get_property ("defaultBarType" ); - return (gh_string_p (def))? ly_scm2string (def) : ""; - } + /* should this work, or be junked? See input/bugs/no-bars.ly */ + which = get_property ("defaultBarType"); } - return ""; - } - else - { - return bar_req_l_->type_str_; } + + daddy_trans_->set_property ("whichBar", which); } + +void +Timing_engraver::stop_translation_timestep () +{ + Timing_translator::stop_translation_timestep (); + daddy_trans_->set_property ("whichBar", SCM_EOL); + last_moment_ = now_mom (); +} + + +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*/ "", +/* accepts */ "", +/* acks */ "", +/* reads */ "timeSignatureFraction automaticBars whichBar barAlways defaultBarType skipBars timing measureLength measurePosition currentBarNumber", +/* write */ "");