+ Direction stemdir = Stem::get_direction (stem);
+ Interval mol_ext = mol.extent (Y_AXIS);
+
+ // ugh, rather calc from Stem_tremolo_req
+ int beams_i = (beam)
+ ? (Stem::beam_count (stem, RIGHT) >? Stem::beam_count (stem, LEFT))
+ : 0;
+
+ Real beamthickness = 0.0;
+ SCM sbt = (beam) ? beam->get_grob_property ("thickness") : SCM_EOL ;
+ if (gh_number_p (sbt))
+ {
+ beamthickness = gh_scm2double (sbt) * ss;
+ }
+
+ Real end_y
+ = Stem::stem_end_position (stem) *ss/2
+ - stemdir * (beams_i * beamthickness
+ + ((beams_i -1) >? 0) * interbeam);
+
+ /*
+ the 0.33 ss is to compensate for the size of the note head
+ */
+ Real chord_start_y = Stem::chord_start_y (stem) +
+ 0.33 * ss * stemdir;
+
+ Real padding = interbeam;
+
+ /*
+ if there is not enough space, center on remaining space,
+ else one beamspace away from stem end.
+ */
+ if (stemdir * (end_y - chord_start_y) - 2*padding - mol_ext.length () < 0.0)