]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tie-performer.cc
Run `make grand-replace'.
[lilypond.git] / lily / tie-performer.cc
index f122bcc86546c2c6fa1dd82207ffd12ae2eaa171..9f6ae786696234f72e85bd004ded06c1bfbfe8d4 100644 (file)
@@ -3,22 +3,22 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1998--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 1998--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "performer.hh"
 
-#include "music.hh"
-#include "context.hh"
 #include "audio-item.hh"
-#include "pqueue.hh"
+#include "context.hh"
+#include "stream-event.hh"
+#include "translator.icc"
 
 class Tie_performer : public Performer
 {
-  Music *event_;
-  Music *last_event_;
-  std::vector<Audio_element_info> now_heads_;
-  std::vector<Audio_element_info> heads_to_tie_;
+  Stream_event *event_;
+  vector<Audio_element_info> now_heads_;
+  vector<Audio_element_info> now_tied_heads_;
+  vector<Audio_element_info> heads_to_tie_;
 
   bool ties_created_;
 
@@ -26,8 +26,8 @@ protected:
   void stop_translation_timestep ();
   void start_translation_timestep ();
   virtual void acknowledge_audio_element (Audio_element_info);
-  virtual bool try_music (Music *);
   void process_music ();
+  DECLARE_TRANSLATOR_LISTENER (tie);
 public:
   TRANSLATOR_DECLARATIONS (Tie_performer);
 };
@@ -35,17 +35,14 @@ public:
 Tie_performer::Tie_performer ()
 {
   event_ = 0;
-  last_event_ = 0;
   ties_created_ = false;
 }
 
-bool
-Tie_performer::try_music (Music *mus)
+IMPLEMENT_TRANSLATOR_LISTENER (Tie_performer, tie);
+void
+Tie_performer::listen_tie (Stream_event *ev)
 {
-  if (mus->is_mus_type ("tie-event"))
-    event_ = mus;
-
-  return true;
+  event_ = ev;
 }
 
 void
@@ -60,13 +57,17 @@ Tie_performer::acknowledge_audio_element (Audio_element_info inf)
 {
   if (Audio_note *an = dynamic_cast<Audio_note *> (inf.elem_))
     {
-      now_heads_.push_back (inf);
+      if (an->tie_event_)
+        now_tied_heads_.push_back (inf);
+      else
+        now_heads_.push_back (inf);
+
       for (vsize i = heads_to_tie_.size (); i--;)
        {
-         Music *right_mus = inf.event_;
+         Stream_event *right_mus = inf.event_;
 
          Audio_note *th = dynamic_cast<Audio_note *> (heads_to_tie_[i].elem_);
-         Music *left_mus = heads_to_tie_[i].event_;
+         Stream_event *left_mus = heads_to_tie_[i].event_;
 
          if (right_mus && left_mus
              && ly_is_equal (right_mus->get_property ("pitch"),
@@ -92,24 +93,32 @@ Tie_performer::stop_translation_timestep ()
   if (ties_created_)
     {
       heads_to_tie_.clear ();
-      last_event_ = 0;
       ties_created_ = false;
     }
 
   if (event_)
     {
       heads_to_tie_ = now_heads_;
-      last_event_ = event_;
     }
+
+  for (vsize i = now_tied_heads_.size (); i--;)
+    heads_to_tie_.push_back (now_tied_heads_[i]);
+
   event_ = 0;
   now_heads_.clear ();
+  now_tied_heads_.clear ();
 }
 
-#include "translator.icc"
-
 ADD_TRANSLATOR (Tie_performer,
-               /* doc */ "Generate ties between noteheads of equal pitch.",
-               /* create */ "",
-               /* accept */ "tie-event",
-               /* read */ "tieMelismaBusy",
-               /* write */ "");
+               /* doc */
+               "Generate ties between note heads of equal pitch.",
+
+               /* create */
+               "",
+
+               /* read */
+               "tieMelismaBusy",
+
+               /* write */
+               ""
+               );