]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/beam.cc (least_squares): Fix asymmetry and scary float
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 13 Aug 2002 14:56:02 +0000 (14:56 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 13 Aug 2002 14:56:02 +0000 (14:56 +0000)
comparison.

* lily/stem.cc (calc_stem_info): Moved, documented, cleaned up and
fixed up-to-stem feature.

* scm/grob-description.scm (beamed-lengths): Subtract half a beam
thickness, to fix most ugly beams.  See input/test/stem.ly and
baerenreiter-sarabande.ly.

ChangeLog
cygwin/lilypond-doc.hint
lily/beam-quanting.cc
lily/beam.cc
lily/stem.cc
scm/grob-description.scm

index ed31b8b21e943fe41dfa6118eae0b2ca1d5189c7..2edaa77875258a4219715f882bac62da792eb304 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2002-08-13  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * lily/beam.cc (least_squares): Fix asymmetry and scary float
+       comparison.
+
+       * lily/stem.cc (calc_stem_info): Moved, documented, cleaned up and
+       fixed up-to-stem feature.
+
+       * scm/grob-description.scm (beamed-lengths): Subtract half a beam
+       thickness, to fix most ugly beams.  See input/test/stem.ly and
+       baerenreiter-sarabande.ly.
+
        * input/test/stem.ly:
        * input/mutopia/J.S.Bach/baerenreiter-sarabande.ly: Play with
        beamed-lengths.
index 3d84e60071f71e2b79d1de98d380c9b1a783d140..dbe40b211f63e3c7a9d40d1346aaa3c7c1a84f97 100644 (file)
@@ -1,5 +1,6 @@
 sdesc: "LilyPond documentation."
 category: Doc
-ldesc: "LilyPond Documentation in HTML, PS and DVI formats.
-This package contains the HTML, PostScript and DVI documentation for the
-LilyPond music typesetting software."
+ldesc: "LilyPond Documentation in HTML, PS, PDF and DVI formats.  This
+package contains the HTML, PostScript PDF and DVI documentation for
+the LilyPond music typesetting software.  Info and man pages are in
+the lilypond package."
index c589e5da37fc7f65c84b4ad1702dc7ff3b792bf9..e20393afd54d3ad475a2b96293299169dc6dcf9a 100644 (file)
@@ -32,9 +32,9 @@ const int IDEAL_SLOPE_FACTOR = 10;
 
 
 static Real
-shrink_extra_weight (Real x)
+shrink_extra_weight (Real x, Real fac)
 {
-  return fabs (x) * ((x < 0) ? 1.5 : 1.0);
+  return fabs (x) * ((x < 0) ? fac : 1.0);
 }
 
 
@@ -257,10 +257,10 @@ Beam::score_stem_lengths (Link_array<Grob>stems,
                          bool knee, 
                          Real yl, Real yr)
 {
-  Real pen = STEM_LENGTH_LIMIT_PENALTY;
-
+  Real limit_pen = STEM_LENGTH_LIMIT_PENALTY;
   Drul_array<Real> score (0, 0);
   Drul_array<int> count (0, 0);
+  
   for (int i=0; i < stems.size (); i++)
     {
       Grob* s = stems[i];
@@ -271,20 +271,23 @@ Beam::score_stem_lengths (Link_array<Grob>stems,
       Real dx = xr-xl;
       Real beam_y = yr *(x - xl)/dx + yl * ( xr - x)/dx;
       Real current_y = beam_y + base_stem_ys[i];
+      Real length_pen = STEM_LENGTH_LIMIT_PENALTY;
       
       Stem_info info = stem_infos[i];
       Direction d = info.dir_;
 
-      score[d] += pen * (0 >? (d * (info.shortest_y_ - current_y)));
-
-      Real ideal_score = shrink_extra_weight (d * (current_y - info.ideal_y_));
+      score[d] += limit_pen * (0 >? (d * (info.shortest_y_ - current_y)));
       
+      Real ideal_diff = d * (current_y - info.ideal_y_);
+      Real ideal_score = shrink_extra_weight (ideal_diff, 1.5);
+
       /* We introduce a power, to make the scoring strictly
          convex. Otherwise a symmetric knee beam (up/down/up/down)
          does not have an optimum in the middle. */
       if (knee)
        ideal_score = pow (ideal_score, 1.1);
-      score[d] += STEM_LENGTH_DEMERIT_FACTOR * ideal_score;
+      
+      score[d] += length_pen * ideal_score;
 
       count[d] ++;
     }
@@ -315,14 +318,14 @@ Beam::score_slopes_dy (Real yl, Real yr,
 
    Real slope_penalty = IDEAL_SLOPE_FACTOR;
 
-   /*
-     Xstaff beams tend to use extreme slopes to get short stems. We
-     put in a penalty here.
-   */
+   /* Xstaff beams tend to use extreme slopes to get short stems. We
+      put in a penalty here. */
    if (xstaff)
      slope_penalty *= 10;
 
-   dem += shrink_extra_weight (fabs (dy_damp) - fabs (dy))* slope_penalty;
+   /* Huh, why would a too steep beam be better than a too flat one ? */
+   dem += shrink_extra_weight (fabs (dy_damp) - fabs (dy), 1.5)
+     * slope_penalty;
    return dem;
 }
 
index 3e9c31f66cb407a4c840703e93a10f0d291f6f4d..63700ab1634cc9387e5aae9af70eeb8ef3a14706 100644 (file)
@@ -819,23 +819,17 @@ Beam::least_squares (SCM smob)
       Interval chord (Stem::chord_start_y (first_visible_stem (me)),
                      Stem::chord_start_y (last_visible_stem (me)));
 
+      /* Make simple beam on middle line have small tilt.
 
-      /*
-       TODO -- use scoring for this.
-
-       complicated, because we take stem-info.ideal for determining
-       beam slopes.
-       */
-      /* Make simple beam on middle line have small tilt */
-      if (!ideal[LEFT] && chord.delta () && count == 2)
+         Ideally, this should be handled by a scoring rule, but that's
+        complicated because we take stem-info.ideal for determining
+        beam slopes. */
+      if ((abs (ideal[LEFT]) < 0.5 || abs (ideal[RIGHT]) < 0.5)
+         && chord.delta () && count == 2)
        {
-
-         /*
-           FIXME. -> UP
-         */
+         /* FIXME. -> UP */
          Direction d = (Direction) (sign (chord.delta ()) * UP);
          pos[d] = gh_scm2double (me->get_grob_property ("thickness")) / 2;
-         //                * dir;
          pos[-d] = - pos[d];
        }
       else
index 493a7d0b774d4caa1d67b2c739b584582872e428..bbb7310fd4e2f74396913df05667adf01a508eeb 100644 (file)
@@ -276,14 +276,13 @@ Stem::get_default_dir (Grob*me)
 Real
 Stem::get_default_stem_end_position (Grob*me) 
 {
+  /* Tab notation feature: make stem end extend out of staff. */
   SCM up_to_staff = me->get_grob_property ("up-to-staff");
-  if (to_boolean(up_to_staff))
+  if (to_boolean (up_to_staff))
     {
       int line_count = Staff_symbol_referencer::line_count (me);
-    
       Direction dir = get_direction (me);
-    
-      return dir*  (line_count + 3.5);
+      return dir * (line_count + 3.5);
     }
   
   bool grace_b = to_boolean (me->get_grob_property ("grace"));
@@ -761,24 +760,6 @@ Stem::get_beam (Grob*me)
 Stem_info
 Stem::get_stem_info (Grob *me)
 {
-  /* DOCME!!! So, what's this all about? */
-  SCM up_to_staff = me->get_grob_property ("up-to-staff");
-  if (gh_scm2bool(up_to_staff))
-    {
-      /* Up-to-staff : the stem end out of the staff. */
-
-      /* FIXME: duplicate code. */
-      int line_count = Staff_symbol_referencer::line_count (me);
-      Stem_info si ;
-      Direction dir = get_direction (me);
-
-      si.ideal_y_ = dir*  (line_count + 1.5);
-      si.dir_ = dir;
-      si.shortest_y_ = si.ideal_y_; 
-      return si;
-    }
-
-
   /* Return cached info if available */
   SCM scm_info = me->get_grob_property ("stem-info");
   if (!gh_pair_p (scm_info))
@@ -797,6 +778,22 @@ Stem::get_stem_info (Grob *me)
 void
 Stem::calc_stem_info (Grob *me)
 {
+  /* Tab notation feature: make stem end extend out of staff. */
+  SCM up_to_staff = me->get_grob_property ("up-to-staff");
+  if (to_boolean (up_to_staff))
+    {
+      int line_count = Staff_symbol_referencer::line_count (me);
+      Direction dir = get_direction (me);
+      Real ideal_y = dir * (line_count + 1.5);
+      Real shortest_y = ideal_y;
+      
+      me->set_grob_property ("stem-info",
+                            scm_list_n (gh_double2scm (ideal_y),
+                                        gh_double2scm (shortest_y),
+                                        SCM_UNDEFINED));
+      return;
+    }
+
   Direction my_dir = Directional_element_interface::get (me);
   Real staff_space = Staff_symbol_referencer::staff_space (me);
   Grob *beam = get_beam (me);
index 4539a35e58125753f494283d4702c3a0924fcb67..ad6a813adfcccff410adf64239ce698790e90b6f 100644 (file)
        (neutral-direction . -1)
        
        ;; [Wanske]: standard length (but no shorter than minimum).
-       (beamed-lengths . (3.5))
+       ;; (beamed-lengths . (3.5))
+       
+       ;; FIXME.  3.5 yields too long beams (according to Ross and
+       ;; looking at Baerenreiter examples) for a number of common
+       ;; boundary cases.  Subtracting half a beam thickness fixes
+       ;; this, but the bug may well be somewhere else.
+       (beamed-lengths . (3.26))
 
        ;; [Wanske] lists three sets of minimum lengths.  One
        ;; set for the nomal case, and one set for beams with `der