- if (Stem* s = dynamic_cast<Stem *> (i.elem_l_))
- {
- int type_i = prev_start_req_->type_i_;
- s->flag_i_ = intlog2 (type_i) - 2;
-
- s->beams_i_drul_[LEFT] = s->flag_i_;
- s->beams_i_drul_[RIGHT] = s->flag_i_;
-
- abeam_p_->multiple_i_ = s->flag_i_;
- /*
- abbrev gaps on all but half note
- */
-#if 0
- if (s->type_i () != 1)
- {
- int gap_i =s->flag_i_ - ((s->type_i () >? 2) - 2);
- s->set_elt_property ("beam-gap", gh_int2scm(gap_i));
- }
-#else
- if (s->type_i () != 1)
- {
- int gap_i =s->flag_i_ - ((s->type_i () >? 2) - 2);
- abeam_p_->set_elt_property ("beam-gap", gh_int2scm(gap_i));
- }
-#endif
-
- abeam_p_->add_stem (s);
- }
+ int tremolo_type = robust_scm2int (repeat_->get_property ("tremolo-type"), 1);
+ int flags = max (0, intlog2 (tremolo_type) - 2);
+ int repeat_count = robust_scm2int (repeat_->get_property ("repeat-count"), 1);
+ int gap_count = min (flags, intlog2 (repeat_count) + 1);
+
+ Grob *s = info.grob ();
+ if (previous_stem_)
+ {
+ // FIXME: We know that the beam has ended only in listen_tremolo_span
+ // but then it is too late for Spanner_break_forbid_engraver
+ // to allow a line break... So, as a nasty hack, announce the
+ // spanner's end after each note except the first. The only
+ // "drawback" is that for multi-note tremolos a break would
+ // theoretically be allowed after the second note (but since
+ // that note is typically not at a barline, I don't think
+ // anyone will ever notice!)
+ announce_end_grob (beam_, previous_stem_->self_scm ());
+ // Create the whole beam between previous and current note
+ Stem::set_beaming (previous_stem_, flags, RIGHT);
+ Stem::set_beaming (s, flags, LEFT);
+ }
+
+ if (Stem::duration_log (s) != 1)
+ beam_->set_property ("gap-count", scm_from_int (gap_count));
+
+ if (info.ultimate_event_cause ()->in_event_class ("rhythmic-event"))
+ Beam::add_stem (beam_, s);
+ else
+ {
+ string s = _ ("stem must have Rhythmic structure");
+ if (info.event_cause ())
+ info.event_cause ()->origin ()->warning (s);
+ else
+ ::warning (s);
+ }
+ // Store current grob, so we can possibly end the spanner here (and
+ // reset the beam direction to RIGHT)
+ previous_stem_ = s;