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"
16 class Tie_performer : public Performer
20 Array<Audio_element_info> now_heads_;
21 Array<Audio_element_info> heads_to_tie_;
26 void stop_translation_timestep ();
27 void start_translation_timestep ();
28 virtual void acknowledge_audio_element (Audio_element_info);
29 virtual bool try_music (Music *);
30 void process_music ();
32 TRANSLATOR_DECLARATIONS (Tie_performer);
35 Tie_performer::Tie_performer ()
39 ties_created_ = false;
43 Tie_performer::try_music (Music *mus)
45 if (mus->is_mus_type ("tie-event"))
52 Tie_performer::process_music ()
55 context ()->set_property ("tieMelismaBusy", SCM_BOOL_T);
59 Tie_performer::acknowledge_audio_element (Audio_element_info inf)
61 if (Audio_note *an = dynamic_cast<Audio_note *> (inf.elem_))
63 now_heads_.push (inf);
64 for (int i = heads_to_tie_.size (); i--;)
66 Music *right_mus = inf.event_;
68 Audio_note *th = dynamic_cast<Audio_note *> (heads_to_tie_[i].elem_);
69 Music *left_mus = heads_to_tie_[i].event_;
71 if (right_mus && left_mus
72 && ly_is_equal (right_mus->get_property ("pitch"),
73 left_mus->get_property ("pitch")))
83 Tie_performer::start_translation_timestep ()
85 context ()->set_property ("tieMelismaBusy",
86 ly_bool2scm (heads_to_tie_.size ()));
90 Tie_performer::stop_translation_timestep ()
94 heads_to_tie_.clear ();
96 ties_created_ = false;
101 heads_to_tie_ = now_heads_;
102 last_event_ = event_;
108 #include "translator.icc"
110 ADD_TRANSLATOR (Tie_performer,
111 /* doc */ "Generate ties between noteheads of equal pitch.",
113 /* accept */ "tie-event",
114 /* read */ "tieMelismaBusy",