2 tie-performer.cc -- implement Tie_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "performer.hh"
11 #include "audio-item.hh"
14 #include "stream-event.hh"
15 #include "translator.icc"
17 class Tie_performer : public Performer
20 vector<Audio_element_info> now_heads_;
21 vector<Audio_element_info> now_tied_heads_;
22 vector<Audio_element_info> heads_to_tie_;
27 void stop_translation_timestep ();
28 void start_translation_timestep ();
29 virtual void acknowledge_audio_element (Audio_element_info);
30 void process_music ();
31 DECLARE_TRANSLATOR_LISTENER (tie);
33 TRANSLATOR_DECLARATIONS (Tie_performer);
36 Tie_performer::Tie_performer ()
39 ties_created_ = false;
42 IMPLEMENT_TRANSLATOR_LISTENER (Tie_performer, tie);
44 Tie_performer::listen_tie (Stream_event *ev)
50 Tie_performer::process_music ()
53 context ()->set_property ("tieMelismaBusy", SCM_BOOL_T);
57 Tie_performer::acknowledge_audio_element (Audio_element_info inf)
59 if (Audio_note *an = dynamic_cast<Audio_note *> (inf.elem_))
62 now_tied_heads_.push_back (inf);
64 now_heads_.push_back (inf);
66 for (vsize i = heads_to_tie_.size (); i--;)
68 Stream_event *right_mus = inf.event_;
70 Audio_note *th = dynamic_cast<Audio_note *> (heads_to_tie_[i].elem_);
71 Stream_event *left_mus = heads_to_tie_[i].event_;
73 if (right_mus && left_mus
74 && ly_is_equal (right_mus->get_property ("pitch"),
75 left_mus->get_property ("pitch")))
85 Tie_performer::start_translation_timestep ()
87 context ()->set_property ("tieMelismaBusy",
88 ly_bool2scm (heads_to_tie_.size ()));
92 Tie_performer::stop_translation_timestep ()
96 heads_to_tie_.clear ();
97 ties_created_ = false;
102 heads_to_tie_ = now_heads_;
105 for (vsize i = now_tied_heads_.size(); i--;)
106 heads_to_tie_.push_back (now_tied_heads_[i]);
110 now_tied_heads_.clear ();
113 ADD_TRANSLATOR (Tie_performer,
114 /* doc */ "Generate ties between noteheads of equal pitch.",
116 /* read */ "tieMelismaBusy",