]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/timing-engraver.cc
* ChangeLog: Recode utf-8.
[lilypond.git] / lily / timing-engraver.cc
index 7660ba9a3e5166775b1456a1193ee6ee6b46d8ce..1c30fcd34f085bb5ba56a07d408e7d1f7648dd01 100644 (file)
@@ -6,23 +6,22 @@
   (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include "context.hh"
-#include "multi-measure-rest.hh"
 #include "timing-translator.hh"
 #include "engraver.hh"
+
+#include "context.hh"
+#include "multi-measure-rest.hh"
 #include "grob.hh"
+#include "warn.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. */
+  /* Need to know whether we're advancing in grace notes, or not. */
   Moment last_moment_;
 
   virtual void start_translation_timestep ();
-  virtual void initialize ();
   virtual void process_music ();
   virtual void stop_translation_timestep ();
 
@@ -30,27 +29,25 @@ public:
   TRANSLATOR_DECLARATIONS (Timing_engraver);
 };
 
+ADD_TRANSLATOR (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}. "
+               "\n\nThis engraver adds the alias @code{Timing} to its containing context.",
+               /* creats*/ "",
+               /* accepts */ "",
+               /* acks  */ "",
+               /* reads */ "automaticBars whichBar barAlways defaultBarType "
+               "skipBars timing measureLength measurePosition currentBarNumber",
+               /* write */ "");
+
+
 Timing_engraver::Timing_engraver ()
 {
   last_moment_.main_part_ = Rational (-1);
 }
 
-void
-Timing_engraver::initialize ()
-{
-  Timing_translator::initialize ();
-
-  SCM which = get_property ("whichBar");
-  Moment now = now_mom ();
-
-  /* Set the first bar of the score? */
-  if (!scm_is_string (which))
-    which = (now.main_part_ || now.main_part_ == last_moment_.main_part_)
-      ? SCM_EOL : scm_makfrom0str ("|");
-
-  context ()->set_property ("whichBar", which);
-}
-
 void
 Timing_engraver::process_music ()
 {
@@ -66,8 +63,11 @@ Timing_engraver::process_music ()
   if (start_of_measure)
     {
       Moment mlen = Moment (measure_length ());
-      unsmob_grob (get_property ("currentCommandColumn"))
-       ->set_property ("measure-length", mlen.smobbed_copy ());
+      Grob * column = unsmob_grob (get_property ("currentCommandColumn"));
+      if (column)
+       column->set_property ("measure-length", mlen.smobbed_copy ());
+      else
+       programming_error("No command column?");
     }
 }
 
@@ -92,7 +92,8 @@ Timing_engraver::start_translation_timestep ()
     {
       SCM always = get_property ("barAlways");
 
-      if (start_of_measure || (to_boolean (always)))
+      if ((start_of_measure && last_moment_.main_part_ >= Moment (0))
+         || to_boolean (always))
        {
          /* should this work, or be junked?  See input/bugs/no-bars.ly */
          which = get_property ("defaultBarType");
@@ -109,15 +110,3 @@ Timing_engraver::stop_translation_timestep ()
   context ()->set_property ("whichBar", SCM_EOL);
   last_moment_ = now_mom ();
 }
-
-ADD_TRANSLATOR (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}. "
-               "\n\nThis engraver adds the alias @code{Timing} to its containing context.",
-               /* creats*/ "",
-               /* accepts */ "",
-               /* acks  */ "",
-               /* reads */ "automaticBars whichBar barAlways defaultBarType skipBars timing measureLength measurePosition currentBarNumber",
-               /* write */ "");