+ /* 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;
+
+ // So that ceil below kicks in for rests that would otherwise brush
+ // up against a beam quanted to a ledger line, add a bit of space
+ // between the beam and the rest.
+ shift += (0.01 * beamdir);
+
+ /* Always move by a whole number of staff spaces */
+ shift = ceil (fabs (shift / ss)) * ss * sign (shift);
+
+ return scm_from_double (previous + shift);