X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftie-performer.cc;h=9f6ae786696234f72e85bd004ded06c1bfbfe8d4;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=a44bf7df7e14eee837dcf0ad7eba353476dbe973;hpb=a501f5946426488804ca2b03ab986f9c2b94ab99;p=lilypond.git diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index a44bf7df7e..9f6ae78669 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -1,84 +1,80 @@ -/* - new-tie-engraver.cc -- implement Tie_performer - +/* + tie-performer.cc -- implement Tie_performer + source file of the GNU LilyPond music typesetter - - (c) 1998--2004 Han-Wen Nienhuys - - */ -#include "context.hh" -#include "audio-item.hh" -#include "event.hh" -#include "pqueue.hh" + (c) 1998--2008 Han-Wen Nienhuys +*/ + #include "performer.hh" +#include "audio-item.hh" +#include "context.hh" +#include "stream-event.hh" +#include "translator.icc" + class Tie_performer : public Performer { - Music *event_; - Music *last_event_; - Array now_heads_; - Array heads_to_tie_; + Stream_event *event_; + vector now_heads_; + vector now_tied_heads_; + vector heads_to_tie_; bool ties_created_; - + protected: - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); + void stop_translation_timestep (); + void start_translation_timestep (); virtual void acknowledge_audio_element (Audio_element_info); - virtual bool try_music (Music*); - virtual void process_music (); + void process_music (); + DECLARE_TRANSLATOR_LISTENER (tie); public: TRANSLATOR_DECLARATIONS (Tie_performer); }; - - 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 Tie_performer::process_music () { if (event_) - get_parent_context ()->set_property ("tieMelismaBusy", SCM_BOOL_T); + context ()->set_property ("tieMelismaBusy", SCM_BOOL_T); } void Tie_performer::acknowledge_audio_element (Audio_element_info inf) { - if (Audio_note * an = dynamic_cast (inf.elem_)) + if (Audio_note *an = dynamic_cast (inf.elem_)) { - now_heads_.push (inf); - for (int i = heads_to_tie_.size (); i--;) + 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_; - - Audio_note *th = dynamic_cast (heads_to_tie_[i].elem_); - Music * left_mus = heads_to_tie_[i].event_; + Stream_event *right_mus = inf.event_; + + Audio_note *th = dynamic_cast (heads_to_tie_[i].elem_); + Stream_event *left_mus = heads_to_tie_[i].event_; if (right_mus && left_mus - && is_equal (right_mus->get_property ("pitch"), - left_mus->get_property ("pitch"))) + && ly_is_equal (right_mus->get_property ("pitch"), + left_mus->get_property ("pitch"))) { an->tie_to (th); - ties_created_ = true; + ties_created_ = true; } } } @@ -87,9 +83,8 @@ Tie_performer::acknowledge_audio_element (Audio_element_info inf) void Tie_performer::start_translation_timestep () { - get_parent_context ()->set_property ("tieMelismaBusy", - ly_bool2scm (heads_to_tie_.size ())); - + context ()->set_property ("tieMelismaBusy", + ly_bool2scm (heads_to_tie_.size ())); } void @@ -98,22 +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 (); } -ENTER_DESCRIPTION (Tie_performer, -/* descr */ "Generate ties between noteheads of equal pitch.", -/* creats*/ "", -/* accepts */ "tie-event", -/* acks */ "", -/* reads */ "tieMelismaBusy", -/* write */ ""); +ADD_TRANSLATOR (Tie_performer, + /* doc */ + "Generate ties between note heads of equal pitch.", + + /* create */ + "", + + /* read */ + "tieMelismaBusy", + + /* write */ + "" + );