- if (Stem::has_interface (info.elem_l_))
- {
- Score_element * s = info.elem_l_;
- int f = Stem::flag_i (s);
- f = (f > 2) ? f - 2 : 1;
- Stem::set_beaming (s, f, LEFT);
- Stem::set_beaming (s, f, RIGHT);
-
- /*
- URG: this sets the direction of the Stem s.
- It's amazing Mike:
-
- Stem:: type_i () ->first_head ()->get_direction () ->
- Directional_element_interface::set (me, d);
-
-
- don't understand this comment.
- --hwn.
- */
- SCM d = s->get_elt_property ("direction");
- if (Stem::type_i (s ) != 1)
- {
- int gap_i =Stem::flag_i (s ) - ((Stem::type_i (s ) >? 2) - 2);
- beam_p_->set_elt_property ("beam-gap", gh_int2scm(gap_i));
- }
- s->set_elt_property ("direction", d);
-
- if (dynamic_cast <Rhythmic_req *> (info.req_l_))
- {
- Beam::add_stem (beam_p_, s);
- }
- else
- {
- String s = _ ("stem must have Rhythmic structure");
- if (info.req_l_)
- info.req_l_->origin ()->warning (s);
- else
- ::warning (s);
- }
- }
- if (Note_head::has_interface (info.elem_l_))
- {
- info.elem_l_->set_elt_property ("duration-log", gh_int2scm (intlog2 (note_head_i_)));
- }
+ 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;