+ /* In stems with several heads, use the one closest to the beam. */
+ Direction beamdir = get_grob_direction (beam);
+ Real shift = min (max ( (Stem::head_positions (left)[beamdir]
+ + Stem::head_positions (right)[beamdir]) / 2.0,
+ rest_max_pos[DOWN]),
+ rest_max_pos[UP]
+ ) * ss / 2.0
+ - previous;
+ /* Always move by a whole number of staff spaces */
+ shift = ceil (fabs (shift / ss)) * ss * sign (shift);
+
+ return scm_from_double (previous + shift);