It seems this issue doesn't bother anyone else? In any case, now that 2.8 is 
out there, I thought I'd start pushing this point again. I attach a patch 
that gives the behaviour that I think is correct. I also attach 2 examples of 
the differences between the existing and the proposed behaviours.

Joe

On Mon, 27 Feb 2006 16:01, Joe Neeman wrote:
> I've finally put my finger on what was bothering me about lilypond
> tremolos -- they are too close to the noteheads.
>
> I think that the tremolo marks shouldn't depend on where the notehead
> is, but rather on the position of the end of the stem. Also, the stem
> should be made longer to accomodate the tremolo. For example, if I have
> doubled eighth notes, the stems should be as long as if they were 16th
> notes and the tremolo markings should go where the second beams would be
> if they were 16th notes.
>
> I attach 2 scanned examples, a Schirmer edition of Franck's sonata for
> violin and piano and a B&H edition of Bartok's solo violin sonata. I
> also attach lilypond versions of the snippets, just for comparison.
>
> I also have an example (no scan of this) where lilypond makes the stems
> so short that the tremolo and the notehead overlap. (Sorry for all the
> images. I've tried to keep them small.)
>
> Joe

<<attachment: franck_after.jpeg>>

<<attachment: tchaik_after.jpeg>>

<<attachment: franck_before.jpeg>>

<<attachment: tchaik_before.jpeg>>

Index: lily/stem.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/stem.cc,v
retrieving revision 1.304
diff -u -r1.304 stem.cc
--- lily/stem.cc	2 Mar 2006 10:50:40 -0000	1.304
+++ lily/stem.cc	26 Mar 2006 06:37:34 -0000
@@ -798,7 +798,6 @@
   return si;
 }
 
-/* TODO: add extra space for tremolos!  */
 MAKE_SCHEME_CALLBACK(Stem, calc_stem_info, 1);
 SCM
 Stem::calc_stem_info (SCM smob)
@@ -847,6 +846,13 @@
     * staff_space
     * length_fraction;
 
+  Real height_of_my_trem = 0.0;
+  Grob *trem = unsmob_grob (me->get_object ("tremolo-flag"));
+  if (trem)
+      height_of_my_trem = ly_scm2interval (trem->get_property ("Y-extent")).length ()
+        /* hack a bit of space around the trem. */
+        + beam_translation - beam_thickness;
+
   /* UGH
      It seems that also for ideal minimum length, we must use
      the maximum beam count (for this direction):
@@ -859,6 +865,7 @@
 
   Real ideal_minimum_length = ideal_minimum_free
     + height_of_my_beams
+    + height_of_my_trem
     /* stem only extends to center of beam */
     - 0.5 * beam_thickness;
 
@@ -908,18 +915,11 @@
     * staff_space
     * length_fraction;
 
-  Real minimum_length = minimum_free
+  Real minimum_length = max (minimum_free, height_of_my_trem)
     + height_of_my_beams
     /* stem only extends to center of beam */
     - 0.5 * beam_thickness;
 
-  if (Grob *tremolo = unsmob_grob (me->get_object ("tremolo-flag")))
-    {
-      Interval y_ext = tremolo->extent (tremolo, Y_AXIS);
-      y_ext.widen (0.5);	// FIXME. Should be tunable? 
-      minimum_length = max (minimum_length, y_ext.length ());
-    }
-
   ideal_y *= my_dir;
   Real minimum_y = note_start + minimum_length;
   Real shortest_y = minimum_y * my_dir;
Index: lily/stem-tremolo.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/stem-tremolo.cc,v
retrieving revision 1.99
diff -u -r1.99 stem-tremolo.cc
--- lily/stem-tremolo.cc	10 Feb 2006 01:05:05 -0000	1.99
+++ lily/stem-tremolo.cc	26 Mar 2006 06:37:34 -0000
@@ -82,7 +82,8 @@
   thick *= ss;
 
   Stencil a (Lookup::beam (slope, width, thick, blot));
-  a.translate (Offset (-width * 0.5, width * 0.5 * slope));
+  Interval a_ext = a.extent (Y_AXIS);
+  a.translate (Offset (-width * 0.5, a_ext.length () / 2 - a_ext[UP]));
 
   int tremolo_flags = robust_scm2int (me->get_property ("flag-count"), 0);
   if (!tremolo_flags)
@@ -147,6 +148,7 @@
 
   Stencil mol = raw_stencil (me, robust_scm2double (me->get_property ("slope"),
 						    0.25));
+
   Interval mol_ext = mol.extent (Y_AXIS);
   Real ss = Staff_symbol_referencer::staff_space (me);
 
@@ -160,29 +162,18 @@
 
   Real end_y
     = Stem::stem_end_position (stem) * ss / 2
-    - stemdir * (beam_count * beamthickness
-		 + (max (beam_count -1, 0) * beam_translation));
-
-  /* FIXME: 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 = beam_translation;
+    - stemdir * max (beam_count, 1) * beam_translation;
 
-  /* if there is a flag, just above/below the notehead.
-     if there is not enough space, center on remaining space,
-     else one beamspace away from stem end.  */
-  if (!beam && Stem::duration_log (stem) >= 3)
+  /* the bottom flag is now centred on the middle of the staff. Centre the
+     closest flag to the beam instead. (Move this to raw_stencil?)*/
+  if (stemdir == UP)
     {
-      mol.align_to (Y_AXIS, -stemdir);
-      mol.translate_axis (chord_start_y + 0.5 * stemdir, Y_AXIS);
+      Real down_off = mol_ext.length () / 2 + mol_ext[DOWN];
+      mol.translate_axis (-down_off * 2, Y_AXIS);
     }
-  else if (stemdir * (end_y - chord_start_y) - 2 * padding - mol_ext.length ()
-	   < 0.0)
-    mol.translate_axis (0.5 * (end_y + chord_start_y) - mol_ext.center (),
-			Y_AXIS);
-  else
-    mol.translate_axis (end_y - stemdir * beam_translation -mol_ext [stemdir],
-			Y_AXIS);
+  if (!beam && Stem::duration_log (stem) >= 3)
+    end_y -= (stemdir * (Stem::duration_log (stem) - 2)) * beam_translation;
+  mol.translate_axis (end_y, Y_AXIS);
 
   return mol.smobbed_copy ();
 }
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to