]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #129.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 3 Jan 2007 12:10:49 +0000 (13:10 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 3 Jan 2007 12:10:49 +0000 (13:10 +0100)
Derive Time_scaled_music_iterator from
Music_wrapper_iterator. remember the Context_handle that was used for
the start event, and use that for the stop event.

input/regression/part-combine-tuplet.ly [new file with mode: 0644]
lily/time-scaled-music-iterator.cc
lily/tuplet-engraver.cc

diff --git a/input/regression/part-combine-tuplet.ly b/input/regression/part-combine-tuplet.ly
new file mode 100644 (file)
index 0000000..b6bf597
--- /dev/null
@@ -0,0 +1,19 @@
+\header {
+  
+  texidoc = "End tuplets events are sent to the starting context, so
+even after a switch, a tuplet ends correctly."
+  
+}
+
+\version "2.10.8"
+
+\new Staff <<
+  \partcombine
+  \relative c'' {
+    r2
+    \times 2/3 { g8[ g g] }
+    \times 2/3 { g[ g g] } g1
+  }
+  \relative c'' { R1 g1 }
+>>
+
index 9ab2673eeb86a23a7694700e886f5b0a13242086..973a1d8c5eb696d13f802ca1c590b268431fd578 100644 (file)
 #include "input.hh"
 #include "international.hh"
 #include "music.hh"
-#include "sequential-iterator.hh"
+#include "music-wrapper-iterator.hh"
 
 /*
   Iterates \times, by sending TupletSpanEvents at the start/end of each
   tuplet bracket. Extra stop/start events are sent at regular
   intervals if tupletSpannerDuration is set.
 */
-class Time_scaled_music_iterator : public Sequential_iterator
+class Time_scaled_music_iterator : public Music_wrapper_iterator
 {
 public:
   DECLARE_SCHEME_CALLBACK (constructor, ());
@@ -26,7 +26,6 @@ public:
   DECLARE_CLASSNAME(Time_scaled_music_iterator);
   Time_scaled_music_iterator ();
 protected:
-  virtual SCM get_music_list () const;
   virtual void process (Moment m);
   virtual void construct_children ();
   virtual void derived_mark () const;
@@ -42,18 +41,26 @@ private:
   /* Recycle start/stop events if tupletSpannerDuration is set. */
   Music *start_;
   Music *stop_;
+
+  bool done_first_;
+  
+  Context_handle tuplet_handler_;
 };
 
 Time_scaled_music_iterator::Time_scaled_music_iterator ()
 {
   spanner_duration_ = next_split_mom_ = 0;
+  done_first_ = 0;
 }
 
 
 Moment
 Time_scaled_music_iterator::pending_moment () const
 {
-  Moment next_mom = Sequential_iterator::pending_moment ();
+  if (!done_first_)
+    return Moment (0);
+  
+  Moment next_mom = Music_wrapper_iterator::pending_moment ();
 
   if (spanner_duration_.to_bool () &&
       next_mom.main_part_ > next_split_mom_)
@@ -68,10 +75,21 @@ Time_scaled_music_iterator::pending_moment () const
 void
 Time_scaled_music_iterator::process (Moment m)
 {
+  if (!done_first_)
+    {
+      done_first_ = true;
+      descend_to_bottom_context ();
+      report_event (start_);
+      tuplet_handler_.set_context (get_outlet());
+    }
+
   if (spanner_duration_.to_bool () &&
       m.main_part_ == next_split_mom_)
     {
-      report_event (stop_);
+      descend_to_bottom_context ();
+      stop_->send_to_context (tuplet_handler_.get_outlet ());
+      
+      tuplet_handler_.set_context (get_outlet ());
       report_event (start_);
       
       next_split_mom_ += spanner_duration_;
@@ -79,7 +97,16 @@ Time_scaled_music_iterator::process (Moment m)
       if (next_split_mom_ == get_music ()->get_length ().main_part_)
        next_split_mom_.set_infinite (1);
     }
-  Sequential_iterator::process(m);
+
+  Music_wrapper_iterator::process(m);
+  if (child_iter_ && child_iter_->ok ())
+    descend_to_child (child_iter_->get_outlet ());
+  
+  if (m.main_part_ == music_get_length ().main_part_)
+    {
+      stop_->send_to_context (tuplet_handler_.get_outlet ());
+      tuplet_handler_.set_context (0);
+    }
 }
 
 void
@@ -117,16 +144,10 @@ Time_scaled_music_iterator::construct_children ()
       next_split_mom_ = spanner_duration_;
     }
 
-  Sequential_iterator::construct_children ();
-}
-
-SCM
-Time_scaled_music_iterator::get_music_list () const
-{
-  Music *mus = get_music ();
-  SCM child = mus->get_property ("element");
+  Music_wrapper_iterator::construct_children ();
 
-  return scm_list_3 (start_->self_scm (), child, stop_->self_scm ());
+  if (child_iter_ && child_iter_->ok ())
+    descend_to_child (child_iter_->get_outlet ());
 }
 
 void
@@ -137,7 +158,7 @@ Time_scaled_music_iterator::derived_mark () const
   if (stop_)
     scm_gc_mark (stop_->self_scm ());
 
-  Sequential_iterator::derived_mark ();
+  Music_wrapper_iterator::derived_mark ();
 }
 
 IMPLEMENT_CTOR_CALLBACK (Time_scaled_music_iterator);
index 66930ce6bd892abff022f6ebfd1462b52c347e55..fd280e127e2978475315f8112afa848a9d798248 100644 (file)
@@ -81,7 +81,9 @@ Tuplet_engraver::process_music ()
 {
   for (vsize i = 0; i < stopped_tuplets_.size (); i++)
     {
-      if (stopped_tuplets_[i].bracket_)
+      Spanner *bracket = stopped_tuplets_[i].bracket_;
+      Spanner *number = stopped_tuplets_[i].number_;
+      if (bracket)
        {
          if (stopped_tuplets_[i].full_length_)
            {
@@ -90,20 +92,20 @@ Tuplet_engraver::process_music ()
                             ? get_property ("currentMusicalColumn")
                             : get_property ("currentCommandColumn"));
              
-             stopped_tuplets_[i].bracket_->set_bound (RIGHT, col);
-             stopped_tuplets_[i].number_->set_bound (RIGHT, col);
+             bracket->set_bound (RIGHT, col);
+             number->set_bound (RIGHT, col);
            }
-         else if (!stopped_tuplets_[i].bracket_->get_bound (RIGHT))
+         else if (!bracket->get_bound (RIGHT))
            {
-             stopped_tuplets_[i].bracket_->set_bound (RIGHT,
-                                                      stopped_tuplets_[i].bracket_->get_bound (LEFT));
-             stopped_tuplets_[i].number_->set_bound (RIGHT,
+             bracket->set_bound (RIGHT,
+                                 bracket->get_bound (LEFT));
+             number->set_bound (RIGHT,
                                                      stopped_tuplets_[i].bracket_->get_bound (LEFT));
            }
          // todo: scrap last_tuplets_, use stopped_tuplets_ only.
          // clear stopped_tuplets_ at start_translation_timestep
-         last_tuplets_.push_back (tuplets_[i].bracket_);
-         last_tuplets_.push_back (tuplets_[i].number_);
+         last_tuplets_.push_back (bracket);
+         last_tuplets_.push_back (number);
        }
     }
   stopped_tuplets_.clear ();