]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4403: Part_combine_iterator: stop tracking the last-playing part
authorDan Eble <nine.fierce.ballads@gmail.com>
Mon, 18 May 2015 11:53:24 +0000 (07:53 -0400)
committerDan Eble <nine.fierce.ballads@gmail.com>
Mon, 25 May 2015 12:08:32 +0000 (08:08 -0400)
Rely on the Scheme-computed split state to choose which voice to use
for unisono and unisilence passages.

lily/part-combine-iterator.cc

index 08dc43bc520200160ce0fb2e859ad42eddb9a894..c1c03739341ee78fe0436c3ac3edcfc21859f719 100644 (file)
@@ -53,13 +53,6 @@ protected:
   virtual bool ok () const;
 
 private:
-  /* used by try_process */
-  void set_busy (SCM);
-  bool busy_;
-  bool notice_busy_;
-
-  bool try_process (Music_iterator *i, Moment m);
-
   Music_iterator *first_iter_;
   Music_iterator *second_iter_;
   Moment start_moment_;
@@ -82,8 +75,6 @@ private:
   // e.g. 1 for Solo I, 2 for Solo II.
   int chosen_part_;
 
-  int last_playing_;
-
   /*
     TODO: this is getting off hand...
   */
@@ -108,15 +99,6 @@ Part_combine_iterator::do_quit ()
     first_iter_->quit ();
   if (second_iter_)
     second_iter_->quit ();
-
-  // Add listeners to all contexts except Devnull.
-  for (int i = 0; i < NUM_OUTLETS; i++)
-    {
-      Context *c = handles_[i].get_context ();
-      if (c->is_alias (ly_symbol2scm ("Voice")))
-        c->event_source ()->remove_listener (GET_LISTENER (Part_combine_iterator, set_busy), ly_symbol2scm ("music-event"));
-      handles_[i].set_context (0);
-    }
 }
 
 Part_combine_iterator::Part_combine_iterator ()
@@ -128,10 +110,6 @@ Part_combine_iterator::Part_combine_iterator ()
   split_list_ = SCM_EOL;
   state_ = APART;
   chosen_part_ = 1;
-  last_playing_ = 0;
-
-  busy_ = false;
-  notice_busy_ = false;
 }
 
 void
@@ -297,8 +275,6 @@ Part_combine_iterator::construct_children ()
       /* find context below c: otherwise we may create new staff for each voice */
       c = c->find_create_context (type, outlet_names_[i], SCM_EOL);
       handles_[i].set_context (c);
-      if (c->is_alias (ly_symbol2scm ("Voice")))
-        c->event_source ()->add_listener (GET_LISTENER (Part_combine_iterator, set_busy), ly_symbol2scm ("music-event"));
     }
 
   SCM lst = get_music ()->get_property ("elements");
@@ -312,34 +288,6 @@ Part_combine_iterator::construct_children ()
   set_context (shared);
 }
 
-void
-Part_combine_iterator::set_busy (SCM se)
-{
-  if (!notice_busy_)
-    return;
-
-  Stream_event *e = unsmob<Stream_event> (se);
-
-  if (e->in_event_class ("note-event") || e->in_event_class ("cluster-note-event"))
-    busy_ = true;
-}
-
-/*
-  Processes a moment in an iterator, and returns whether any new music
-  was reported.
-*/
-bool
-Part_combine_iterator::try_process (Music_iterator *i, Moment m)
-{
-  busy_ = false;
-  notice_busy_ = true;
-
-  i->process (m);
-
-  notice_busy_ = false;
-  return busy_;
-}
-
 void
 Part_combine_iterator::process (Moment m)
 {
@@ -372,12 +320,12 @@ Part_combine_iterator::process (Moment m)
         {
           // Continue to use the most recently used part because we might have
           // killed mmrests in the other part.
-          unisono (false, (last_playing_ == 2) ? 2 : 1);
+          unisono (false, (chosen_part_ == 2) ? 2 : 1);
         }
       else if (scm_is_eq (tag, ly_symbol2scm ("unisilence")))
         {
           // as for unisono
-          unisono (true, (last_playing_ == 2) ? 2 : 1);
+          unisono (true, (chosen_part_ == 2) ? 2 : 1);
         }
       else if (scm_is_eq (tag, ly_symbol2scm ("silence1")))
         unisono (true, 1);
@@ -400,16 +348,10 @@ Part_combine_iterator::process (Moment m)
     }
 
   if (first_iter_->ok ())
-    {
-      if (try_process (first_iter_, m))
-        last_playing_ = 1;
-    }
+    first_iter_->process (m);
 
   if (second_iter_->ok ())
-    {
-      if (try_process (second_iter_, m))
-        last_playing_ = 2;
-    }
+    second_iter_->process (m);
 }
 
 IMPLEMENT_CTOR_CALLBACK (Part_combine_iterator);