]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/timing-engraver.cc
* mf/feta-bolletjes.mf (overdone_heads): cleanup triangle
[lilypond.git] / lily / timing-engraver.cc
index 2bf0e5f6527184024817b542340b1d7e03aa22d2..73e4f5561f1f84b4c413481f1a198dd8d4083650 100644 (file)
@@ -5,8 +5,8 @@
 
   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
+
 #include "context.hh"
-#include "grob-info.hh"
 #include "multi-measure-rest.hh"
 #include "timing-translator.hh"
 #include "engraver.hh"
@@ -22,6 +22,8 @@ protected:
   Moment last_moment_;
   
   virtual void start_translation_timestep ();
+  virtual void initialize ();
+  virtual void process_music();
   virtual void stop_translation_timestep ();
 
 public:
@@ -35,6 +37,42 @@ Timing_engraver::Timing_engraver ()
 }
 
 
+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()
+{
+  Timing_translator::process_music ();
+
+  bool start_of_measure = (last_moment_.main_part_ != now_mom().main_part_
+                          && !measure_position ().main_part_);
+
+  /*
+    We can't do this in start_translation_timestep(), since time sig
+    changes won't have happened by then.
+   */
+  if (start_of_measure)
+    {
+      Moment mlen = Moment (measure_length ());
+      unsmob_grob (get_property ("currentCommandColumn"))
+       ->set_property ("measure-length", mlen.smobbed_copy ()); 
+    }
+}
+  
 
 void
 Timing_engraver::start_translation_timestep ()
@@ -46,23 +84,14 @@ Timing_engraver::start_translation_timestep ()
   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 ("|");
+  if (!scm_is_string (which))
+    which = SCM_EOL;
 
   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_property ("measure-length", mlen.smobbed_copy ()); 
-    }
-  
-  if (!gh_string_p (which) && to_boolean (automatic_bars))
+  if (!scm_is_string (which) && to_boolean (automatic_bars))
     {
       SCM always = get_property ("barAlways");
 
@@ -73,14 +102,14 @@ Timing_engraver::start_translation_timestep ()
        }
     }
 
-  daddy_context_->set_property ("whichBar", which);
+  context ()->set_property ("whichBar", which);
 }
 
 void
 Timing_engraver::stop_translation_timestep ()
 {
   Timing_translator::stop_translation_timestep ();
-  daddy_context_->set_property ("whichBar", SCM_EOL);
+  context ()->set_property ("whichBar", SCM_EOL);
   last_moment_ = now_mom ();
 }
 
@@ -96,5 +125,5 @@ ENTER_DESCRIPTION (Timing_engraver,
 /* creats*/       "",
 /* accepts */     "",
 /* acks  */      "",
-/* reads */       "timeSignatureFraction automaticBars whichBar barAlways defaultBarType skipBars timing measureLength measurePosition currentBarNumber",
+/* reads */       "automaticBars whichBar barAlways defaultBarType skipBars timing measureLength measurePosition currentBarNumber",
 /* write */       "");