+
+ Direction stemdir = get_grob_direction (stem);
+ if (!stemdir)
+ stemdir = UP;
+
+ bool whole_note = Stem::duration_log (stem) <= 0;
+
+ /* for a whole note, we position relative to the notehead, so we want the
+ stencil aligned on the flag closest to the head */
+ Direction stencil_dir = whole_note ? -stemdir : stemdir;
+ return raw_stencil (me, slope, stencil_dir);
+}
+
+MAKE_SCHEME_CALLBACK (Stem_tremolo, calc_y_offset, 1);
+SCM
+Stem_tremolo::calc_y_offset (SCM smob)
+{
+ Grob *me = unsmob_grob (smob);
+ return scm_from_double (y_offset (me, false));
+}
+
+MAKE_SCHEME_CALLBACK (Stem_tremolo, pure_calc_y_offset, 3);
+SCM
+Stem_tremolo::pure_calc_y_offset (SCM smob,
+ SCM, /* start */
+ SCM /* end */)
+{
+ Grob *me = unsmob_grob (smob);
+ return scm_from_double (y_offset (me, true));
+}
+
+Real
+Stem_tremolo::y_offset (Grob *me, bool pure)
+{
+ Item *stem = unsmob_item (me->get_object ("stem"));
+ if (!stem)
+ return 0.0;
+
+ Direction stemdir = get_grob_direction (stem);
+ if (stemdir == 0)
+ stemdir = UP;
+
+ Spanner *beam = Stem::get_beam (stem);
+ Real beam_translation = get_beam_translation (me);
+
+ int beam_count = beam ? (Stem::beam_multiplicity (stem).length () + 1) : 0;
+
+ if (pure && beam)