2 tie-performer.cc -- implement Tie_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "performer.hh"
13 #include "audio-item.hh"
17 class Tie_performer : public Performer
21 Array<Audio_element_info> now_heads_;
22 Array<Audio_element_info> heads_to_tie_;
27 PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
28 PRECOMPUTED_VIRTUAL void start_translation_timestep ();
29 virtual void acknowledge_audio_element (Audio_element_info);
30 virtual bool try_music (Music *);
31 PRECOMPUTED_VIRTUAL void process_music ();
33 TRANSLATOR_DECLARATIONS (Tie_performer);
36 Tie_performer::Tie_performer ()
40 ties_created_ = false;
44 Tie_performer::try_music (Music *mus)
46 if (mus->is_mus_type ("tie-event"))
55 Tie_performer::process_music ()
58 context ()->set_property ("tieMelismaBusy", SCM_BOOL_T);
62 Tie_performer::acknowledge_audio_element (Audio_element_info inf)
64 if (Audio_note *an = dynamic_cast<Audio_note *> (inf.elem_))
66 now_heads_.push (inf);
67 for (int i = heads_to_tie_.size (); i--;)
69 Music *right_mus = inf.event_;
71 Audio_note *th = dynamic_cast<Audio_note *> (heads_to_tie_[i].elem_);
72 Music *left_mus = heads_to_tie_[i].event_;
74 if (right_mus && left_mus
75 && ly_is_equal (right_mus->get_property ("pitch"),
76 left_mus->get_property ("pitch")))
86 Tie_performer::start_translation_timestep ()
88 context ()->set_property ("tieMelismaBusy",
89 ly_bool2scm (heads_to_tie_.size ()));
93 Tie_performer::stop_translation_timestep ()
97 heads_to_tie_.clear ();
99 ties_created_ = false;
104 heads_to_tie_ = now_heads_;
105 last_event_ = event_;
111 #include "translator.icc"
113 ADD_TRANSLATOR (Tie_performer,
114 /* descr */ "Generate ties between noteheads of equal pitch.",
116 /* accepts */ "tie-event",
118 /* reads */ "tieMelismaBusy",