- if (rhythmic_req->duration_.durlog_i_<= 2)
- {
- rhythmic_req->warning (_ ("stem doesn't fit in beam"));
- prev_start_req_->warning (_ ("beam was started here"));
- return;
- }
-
- /*
- TODO: do something sensible if it doesn't fit in the beam.
- */
- Moment start = get_staff_info().time_C_->whole_in_measure_;
-
- if (!grouping_p_->child_fit_b (start))
- {
- String s (_ ("please fix me") + ": "
- + _f ("stem at %s doesn't fit in beam", now_mom ().str ()));
-
- if (info.req_l_)
- info.req_l_->warning(s);
- else
- warning (s);
- }
- else
- {
- grouping_p_->add_child (start, rhythmic_req->length_mom ());
- stem_l->flag_i_ = rhythmic_req->duration_.durlog_i_;
- beam_p_->add_stem (stem_l);
- }
- }
+ Rhythmic_req *rhythmic_req = dynamic_cast <Rhythmic_req *> (info.music_cause ());
+ if (!rhythmic_req)
+ {
+ String s = _ ("stem must have Rhythmic structure");
+ if (info.music_cause ())
+ info.music_cause ()->origin ()->warning (s);
+ else
+ ::warning (s);
+
+ return;
+ }
+
+
+ last_stem_added_at_ = now;
+ int durlog = unsmob_duration (rhythmic_req->get_mus_property ("duration"))-> duration_log ();
+ if (durlog <= 2)
+ {
+ rhythmic_req->origin ()->warning (_ ("stem doesn't fit in beam"));
+ prev_start_req_->origin ()->warning (_ ("beam was started here"));
+ /*
+ don't return, since
+
+ [r4 c8] can just as well be modern notation.
+ */
+ }
+
+ stem_l->set_grob_property ("duration-log",
+ gh_int2scm (durlog));
+ Moment stem_location = now - beam_start_mom_ + beam_start_location_;
+ beam_info_p_->add_stem (stem_location,
+ (durlog- 2) >? 0);
+ Beam::add_stem (beam_p_, stem_l);
+ }
+ }
+}
+
+
+
+
+
+ENTER_DESCRIPTION(Beam_engraver,
+/* descr */ "Handles Beam_requests by engraving Beams. If omitted, then notes will be
+printed with flags instead of beams.",
+/* creats*/ "Beam",
+/* acks */ "stem-interface rest-interface",
+/* reads */ "beamMelismaBusy subdivideBeams",
+/* write */ "");
+
+
+class Grace_beam_engraver : public Beam_engraver
+{
+public:
+ TRANSLATOR_DECLARATIONS(Grace_beam_engraver);
+
+protected:
+ virtual bool valid_start_moment();
+ virtual bool valid_end_moment ();
+};
+
+Grace_beam_engraver::Grace_beam_engraver()
+{
+}
+
+bool
+Grace_beam_engraver::valid_start_moment()
+{
+ Moment n = now_mom ();
+
+ return n.grace_part_ != Rational (0);