Nitpick: ly:spanner-bound grob name slur -> spanner.
[lilypond.git] / lily / tie-performer.cc
blob58bc879ec13bb3619ee7007fdf89f697e376c817
1 /*
2 tie-performer.cc -- implement Tie_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "performer.hh"
11 #include "audio-item.hh"
12 #include "context.hh"
13 #include "stream-event.hh"
14 #include "translator.icc"
16 class Tie_performer : public Performer
18 Stream_event *event_;
19 vector<Audio_element_info> now_heads_;
20 vector<Audio_element_info> now_tied_heads_;
21 vector<Audio_element_info> heads_to_tie_;
23 bool ties_created_;
25 protected:
26 void stop_translation_timestep ();
27 void start_translation_timestep ();
28 virtual void acknowledge_audio_element (Audio_element_info);
29 void process_music ();
30 DECLARE_TRANSLATOR_LISTENER (tie);
31 public:
32 TRANSLATOR_DECLARATIONS (Tie_performer);
35 Tie_performer::Tie_performer ()
37 event_ = 0;
38 ties_created_ = false;
41 IMPLEMENT_TRANSLATOR_LISTENER (Tie_performer, tie);
42 void
43 Tie_performer::listen_tie (Stream_event *ev)
45 event_ = ev;
48 void
49 Tie_performer::process_music ()
51 if (event_)
52 context ()->set_property ("tieMelismaBusy", SCM_BOOL_T);
55 void
56 Tie_performer::acknowledge_audio_element (Audio_element_info inf)
58 if (Audio_note *an = dynamic_cast<Audio_note *> (inf.elem_))
60 if (an->tie_event_)
61 now_tied_heads_.push_back (inf);
62 else
63 now_heads_.push_back (inf);
65 for (vsize i = heads_to_tie_.size (); i--;)
67 Stream_event *right_mus = inf.event_;
69 Audio_note *th = dynamic_cast<Audio_note *> (heads_to_tie_[i].elem_);
70 Stream_event *left_mus = heads_to_tie_[i].event_;
72 if (right_mus && left_mus
73 && ly_is_equal (right_mus->get_property ("pitch"),
74 left_mus->get_property ("pitch")))
76 an->tie_to (th);
77 ties_created_ = true;
83 void
84 Tie_performer::start_translation_timestep ()
86 context ()->set_property ("tieMelismaBusy",
87 ly_bool2scm (heads_to_tie_.size ()));
90 void
91 Tie_performer::stop_translation_timestep ()
93 if (ties_created_)
95 heads_to_tie_.clear ();
96 ties_created_ = false;
99 if (event_)
101 heads_to_tie_ = now_heads_;
104 for (vsize i = now_tied_heads_.size (); i--;)
105 heads_to_tie_.push_back (now_tied_heads_[i]);
107 event_ = 0;
108 now_heads_.clear ();
109 now_tied_heads_.clear ();
112 ADD_TRANSLATOR (Tie_performer,
113 /* doc */
114 "Generate ties between note heads of equal pitch.",
116 /* create */
119 /* read */
120 "tieMelismaBusy",
122 /* write */