]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/timing-engraver.cc
* make/lilypond.fedora.spec.in (Requires): scrap kpathsea/tex
[lilypond.git] / lily / timing-engraver.cc
index d366a7a088804def188c72fd9a36fabc35179710..97db20c1bb6eb739e2b7f721fde765eb3ab3cfb7 100644 (file)
@@ -3,10 +3,10 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2005 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"
@@ -23,6 +23,7 @@ protected:
   
   virtual void start_translation_timestep ();
   virtual void initialize ();
+  virtual void process_music();
   virtual void stop_translation_timestep ();
 
 public:
@@ -45,13 +46,33 @@ Timing_engraver::initialize ()
   Moment now = now_mom ();
   
   /* Set the first bar of the score? */
-  if (!is_string (which))
+  if (!scm_is_string (which))
     which = (now.main_part_ || now.main_part_ == last_moment_.main_part_)
       ? SCM_EOL : scm_makfrom0str ("|");
 
-  daddy_context_->set_property ("whichBar", which);
+  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 ()
@@ -63,21 +84,14 @@ Timing_engraver::start_translation_timestep ()
   SCM which = get_property ("whichBar");
 
   /* Set the first bar of the score? */
-  if (!is_string (which))
+  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 (!is_string (which) && to_boolean (automatic_bars))
+  if (!scm_is_string (which) && to_boolean (automatic_bars))
     {
       SCM always = get_property ("barAlways");
 
@@ -88,19 +102,19 @@ 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 ();
 }
 
 
-ENTER_DESCRIPTION (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 "
@@ -111,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 */       "");