2 piano-pedal-engraver.cc -- implement Piano_pedal_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "musical-request.hh"
11 #include "score-element.hh"
13 #include "lily-guile.hh"
14 #include "rhythmic-head.hh"
16 #include "side-position-interface.hh"
17 #include "staff-symbol-referencer.hh"
25 engrave Piano pedals symbols.
27 class Piano_pedal_engraver : public Engraver
30 VIRTUAL_COPY_CONS (Translator);
31 Piano_pedal_engraver ();
32 ~Piano_pedal_engraver ();
34 virtual void do_creation_processing ();
35 virtual bool do_try_music (Music*);
36 virtual void do_pre_move_processing ();
37 virtual void do_post_move_processing ();
38 virtual void acknowledge_element (Score_element_info);
39 virtual void process_acknowledged ();
45 Span_req* start_req_l_;
46 Drul_array<Span_req*> req_l_drul_;
51 Pedal_info *info_list_;
54 ADD_THIS_TRANSLATOR (Piano_pedal_engraver);
56 Piano_pedal_engraver::Piano_pedal_engraver ()
61 Piano_pedal_engraver::do_creation_processing()
63 info_list_ = new Pedal_info[4];
64 Pedal_info *p = info_list_;
67 char * names [] = { "Sostenuto", "Sustain", "UnaChorda", 0 };
73 p->req_l_drul_[START] = 0;
74 p->req_l_drul_[STOP] = 0;
82 Piano_pedal_engraver::~Piano_pedal_engraver()
92 Piano_pedal_engraver::acknowledge_element (Score_element_info info)
94 for (Pedal_info*p = info_list_; p && p->name_; p ++)
98 if (Rhythmic_head::has_interface (info.elem_l_))
100 Side_position::add_support (p->item_p_, info.elem_l_);
102 if (Side_position::get_axis(p->item_p_) == X_AXIS
103 && !p->item_p_->parent_l (Y_AXIS))
104 p->item_p_->set_parent (info.elem_l_, Y_AXIS);
106 if (Stem::has_interface (info.elem_l_))
108 Side_position::add_support (p->item_p_,info.elem_l_);
115 Piano_pedal_engraver::do_try_music (Music *m)
117 if (Span_req * s = dynamic_cast<Span_req*>(m))
119 for (Pedal_info*p = info_list_; p->name_; p ++)
121 if (scm_equal_p (s->get_mus_property ("span-type"),
122 ly_str02scm (p->name_))==SCM_BOOL_T)
124 p->req_l_drul_[s->get_span_dir()] = s;
133 Piano_pedal_engraver::process_acknowledged ()
135 for (Pedal_info*p = info_list_; p && p->name_; p ++)
140 if (p->req_l_drul_[STOP] && p->req_l_drul_[START])
142 if (!p->start_req_l_)
144 p->req_l_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: %s", p->name_ ));
148 s = get_property (("stopStart" + String (p->name_ )).ch_C());
150 p->start_req_l_ = p->req_l_drul_[START];
152 else if (p->req_l_drul_[STOP])
154 if (!p->start_req_l_)
156 p->req_l_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: %s", p->name_ ));
160 s = get_property (("stop" + String (p->name_ )).ch_C());
164 else if (p->req_l_drul_[START])
166 p->start_req_l_ = p->req_l_drul_[START];
167 s = get_property (("start" + String (p->name_ )).ch_C());
172 String propname = String (p->name_) + "Pedal";
173 p->item_p_ = new Item (get_property (propname.ch_C()));
174 p->item_p_->set_elt_property ("text", s);
176 announce_element (p->item_p_,
177 p->req_l_drul_[START]
178 ? p->req_l_drul_[START]
179 : p->req_l_drul_[STOP]);
181 p->req_l_drul_[START] = 0;
182 p->req_l_drul_[STOP] = 0;
187 Piano_pedal_engraver::do_pre_move_processing ()
190 for (Pedal_info*p = info_list_; p->name_; p ++)
192 if (p->name_ == String ("Sustain"))
193 sustain = p->item_p_;
196 for (Pedal_info*p = info_list_; p->name_; p ++)
200 Side_position::add_staff_support (p->item_p_);
204 if (p->name_ != String ("Sustain"))
208 Side_position::add_support (p->item_p_,sustain);
211 typeset_element (p->item_p_);
218 Piano_pedal_engraver::do_post_move_processing ()
220 for (Pedal_info*p = info_list_; p->name_; p ++)
222 p->req_l_drul_[STOP] = 0;
223 p->req_l_drul_[START] = 0;