2 beam-engraver.cc -- implement Beam_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "beam-engraver.hh"
11 #include "musical-request.hh"
13 #include "rhythmic-grouping.hh"
16 #include "time-description.hh"
18 Beam_engraver::Beam_engraver ()
22 finished_grouping_p_ = 0;
24 reqs_drul_[LEFT] = reqs_drul_[RIGHT] =0;
29 Beam_engraver::do_try_music (Music *m)
31 if (Beam_req * c = dynamic_cast<Beam_req*>(m))
33 Direction d =c->spantype_;
35 if (d == STOP && !beam_p_)
37 m->warning (_ ("No Beam to end"));
48 Beam_engraver::do_process_requests ()
53 reqs_drul_[STOP]->warning (_("No beam to end"));
55 finished_beam_p_ = beam_p_;
56 finished_grouping_p_ = grouping_p_;
62 if (reqs_drul_[START])
66 reqs_drul_[START]->warning (_ ("Already have a Beam"));
70 prev_start_req_ = reqs_drul_[START];
72 grouping_p_ = new Rhythmic_grouping;
74 Scalar prop = get_property ("beamslopedamping", 0);
76 beam_p_->set_elt_property (damping_scm_sym, gh_int2scm( prop));
78 prop = get_property ("beamquantisation", 0);
80 beam_p_->quantisation_ = (Beam::Quantisation)(int)prop;
82 announce_element (Score_element_info (beam_p_, reqs_drul_[START]));
87 Beam_engraver::typeset_beam ()
91 Rhythmic_grouping const * rg_C = get_staff_info().rhythmic_C_;
92 rg_C->extend (finished_grouping_p_->interval());
93 finished_beam_p_->set_grouping (*rg_C, *finished_grouping_p_);
94 typeset_element (finished_beam_p_);
97 delete finished_grouping_p_;
98 finished_grouping_p_= 0;
100 reqs_drul_[STOP] = 0;
105 Beam_engraver::do_post_move_processing ()
107 reqs_drul_ [START] =0;
111 Beam_engraver::do_pre_move_processing ()
117 Beam_engraver::do_removal_processing ()
122 prev_start_req_->warning (_ ("Unfinished beam"));
123 finished_beam_p_ = beam_p_;
124 finished_grouping_p_ = grouping_p_;
130 Beam_engraver::acknowledge_element (Score_element_info info)
134 Stem* stem_l = dynamic_cast<Stem *> (info.elem_l_);
139 Rhythmic_req *rhythmic_req = dynamic_cast <Rhythmic_req *> (info.req_l_);
142 String s = _ ("Stem must have Rhythmic structure.");
144 info.req_l_->warning (s);
152 if (rhythmic_req->duration_.durlog_i_<= 2)
154 rhythmic_req->warning (_ ("stem doesn't fit in beam"));
155 prev_start_req_->warning (_ ("beam was started here"));
160 TODO: do something sensible if it doesn't fit in the beam.
162 Moment start = get_staff_info().time_C_->whole_in_measure_;
164 if (!grouping_p_->child_fit_b (start))
166 String s (_ ("please fix me") + ": "
167 + _f ("stem at %s doesn't fit in beam", now_mom ().str ()));
170 info.req_l_->warning(s);
176 grouping_p_->add_child (start, rhythmic_req->length_mom ());
177 stem_l->flag_i_ = rhythmic_req->duration_.durlog_i_;
178 beam_p_->add_stem (stem_l);
185 ADD_THIS_TRANSLATOR(Beam_engraver);