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 Stream_event *last_event_;
21 vector<Audio_element_info> now_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 ()
40 ties_created_ = false;
43 IMPLEMENT_TRANSLATOR_LISTENER (Tie_performer, tie);
45 Tie_performer::listen_tie (Stream_event *ev)
51 Tie_performer::process_music ()
54 context ()->set_property ("tieMelismaBusy", SCM_BOOL_T);
58 Tie_performer::acknowledge_audio_element (Audio_element_info inf)
60 if (Audio_note *an = dynamic_cast<Audio_note *> (inf.elem_))
62 now_heads_.push_back (inf);
63 for (vsize i = heads_to_tie_.size (); i--;)
65 Stream_event *right_mus = inf.event_;
67 Audio_note *th = dynamic_cast<Audio_note *> (heads_to_tie_[i].elem_);
68 Stream_event *left_mus = heads_to_tie_[i].event_;
70 if (right_mus && left_mus
71 && ly_is_equal (right_mus->get_property ("pitch"),
72 left_mus->get_property ("pitch")))
82 Tie_performer::start_translation_timestep ()
84 context ()->set_property ("tieMelismaBusy",
85 ly_bool2scm (heads_to_tie_.size ()));
89 Tie_performer::stop_translation_timestep ()
93 heads_to_tie_.clear ();
95 ties_created_ = false;
100 heads_to_tie_ = now_heads_;
101 last_event_ = event_;
107 ADD_TRANSLATOR (Tie_performer,
108 /* doc */ "Generate ties between noteheads of equal pitch.",
110 /* accept */ "tie-event",
111 /* read */ "tieMelismaBusy",