+MAKE_SCHEME_CALLBACK (Stem_tremolo, calc_y_offset, 1);
+SCM
+Stem_tremolo::calc_y_offset (SCM smob)
+{
+ Grob *me = Grob::unsmob (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 = Grob::unsmob (smob);
+ return scm_from_double (y_offset (me, true));
+}
+
+MAKE_SCHEME_CALLBACK (Stem_tremolo, calc_direction, 1);
+SCM
+Stem_tremolo::calc_direction (SCM smob)
+{
+ Item *me = Item::unsmob (smob);
+
+ Item *stem = Item::unsmob (me->get_object ("stem"));
+ if (!stem)
+ return scm_from_int (CENTER);
+
+ Direction stemdir = get_grob_direction (stem);
+
+ vector<int> nhp = Stem::note_head_positions (stem);
+ /*
+ * We re-decide stem-dir if there may be collisions with other
+ * note heads in the staff.
+ */
+ Grob *maybe_nc = stem->get_parent (X_AXIS)->get_parent (X_AXIS);
+ bool whole_note = Stem::duration_log (stem) <= 0;
+ if (whole_note && Note_collision_interface::has_interface (maybe_nc))
+ {
+ Drul_array<bool> avoid_me (false, false);
+ vector<int> all_nhps = Note_collision_interface::note_head_positions (maybe_nc);
+ if (all_nhps[0] < nhp[0])
+ avoid_me[DOWN] = true;
+ if (all_nhps.back () > nhp.back ())
+ avoid_me[UP] = true;
+ if (avoid_me[stemdir])
+ {
+ stemdir = -stemdir;
+ if (avoid_me[stemdir])
+ {
+ me->warning ("Whole-note tremolo may collide with simultaneous notes.");
+ stemdir = -stemdir;
+ }
+ }
+ }
+ return scm_from_int (stemdir);
+}
+
+Real
+Stem_tremolo::y_offset (Grob *me, bool pure)
+{
+ Item *stem = Item::unsmob (me->get_object ("stem"));
+ if (!stem)
+ return 0.0;
+
+ Direction dir = get_grob_direction (me);
+
+ Spanner *beam = Stem::get_beam (stem);
+ Real beam_translation = get_beam_translation (me);