+ /* down stems with flags should have more sloped trems (helps avoid
+ flag/stem collisions without making the stem very long) */
+ return scm_from_double ((Stem::duration_log (stem) >= 3
+ && get_grob_direction (me) == DOWN && !beam)
+ ? 0.40 : 0.25);
+}
+
+MAKE_SCHEME_CALLBACK (Stem_tremolo, calc_width, 1)
+SCM
+Stem_tremolo::calc_width (SCM smob)
+{
+ Grob *me = unsmob<Grob> (smob);
+ Grob *stem = unsmob<Grob> (me->get_object ("stem"));
+ Direction dir = get_grob_direction (me);
+ bool beam = Stem::get_beam (stem);
+ bool flag = Stem::duration_log (stem) >= 3 && !beam;
+
+ /* beamed stems and up-stems with flags have shorter tremolos */
+ return scm_from_double (((dir == UP && flag) || beam) ? 1.0 : 1.5);
+}
+
+MAKE_SCHEME_CALLBACK (Stem_tremolo, calc_shape, 1)
+SCM
+Stem_tremolo::calc_shape (SCM smob)
+{
+ Grob *me = unsmob<Grob> (smob);
+ Grob *stem = unsmob<Grob> (me->get_object ("stem"));
+ Direction dir = get_grob_direction (me);
+ bool beam = Stem::get_beam (stem);
+ bool flag = Stem::duration_log (stem) >= 3 && !beam;
+ SCM style = me->get_property ("style");
+
+ return ly_symbol2scm (!scm_is_eq (style, ly_symbol2scm ("constant"))
+ && ((dir == UP && flag) || beam)
+ ? "rectangle" : "beam-like");