]> git.donarmstrong.com Git - lilypond.git/commitdiff
knee kludge
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 17 May 2002 22:13:15 +0000 (22:13 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 17 May 2002 22:13:15 +0000 (22:13 +0000)
ChangeLog
VERSION
lily/beam.cc
lily/include/beam.hh
lily/stem.cc

index f99147987eed390f791b9a9ec0e23150f64033a5..2c935ac275591d240b04f9287ba17697d0a1e4ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2002-05-18  Han-Wen  <hanwen@cs.uu.nl>
+
+       * lily/stem.cc (calc_stem_info): bugfix for less ugly knees.
+
 2002-05-17  Han-Wen  <hanwen@cs.uu.nl>
 
        * scripts/lilypond-book.py (re_dict): fix regexps; don't combine ?
diff --git a/VERSION b/VERSION
index 5f243dd0675a1c079b87215615437620718caf39..b8a48f6f7dcf481c9e8c6cd1cfe1b18e99d91fa2 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=5
 PATCH_LEVEL=56
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=hwn1
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index da17fd4d0b4f575087c188153036cfa5d3e0c159..ac715ee9f2feb3a032fb9b81c09bd9e54a89b63b 100644 (file)
@@ -428,7 +428,7 @@ Beam::quanting (SCM smob)
 
   */
 
-  const int REGION_SIZE = 3;
+  const int REGION_SIZE = 2;
   for (int i  = -REGION_SIZE ; i < REGION_SIZE; i++)
     for (int j = 0; j < num_quants; j++)
       {
@@ -492,6 +492,9 @@ Beam::quanting (SCM smob)
   Array<Real> rbase_lengths;  
 
   Array<int> directions;
+  
+  Drul_array<bool> dirs_found(0,0);
+
   for (int i= 0; i < stems.size(); i++)
     {
       Grob*s = stems[i];
@@ -502,16 +505,20 @@ Beam::quanting (SCM smob)
 
       b = calc_stem_y (me, s, Interval (0,1));
       rbase_lengths.push (b);
-      directions.push( Directional_element_interface::get( s));
+
+      Direction d = Directional_element_interface::get( s);
+      directions.push( d);
+      dirs_found [d] = true;
     }
 
+  bool knee_b = dirs_found[LEFT] && dirs_found[RIGHT];
   for (int i = qscores.size (); i--;)
     if (qscores[i].demerits < 100)
       {
        qscores[i].demerits
          += score_stem_lengths (stems, stem_infos,
                                 lbase_lengths, rbase_lengths,
-                                directions,
+                                directions, knee_b,
                                 me, qscores[i].yl, qscores[i].yr);
       }
 
@@ -550,6 +557,7 @@ Beam::score_stem_lengths (Link_array<Grob>stems,
                          Array<Real> left_factor,
                          Array<Real> right_factor,
                          Array<int> directions,
+                         bool knee, 
                          Grob*me, Real yl, Real yr)
 {
   Real demerit_score = 0.0 ;
@@ -565,9 +573,13 @@ Beam::score_stem_lengths (Link_array<Grob>stems,
 
       Stem_info info = stem_infos[i];
       Direction d = Direction (directions[i]);
+
+      Real pen = STEM_LENGTH_LIMIT_PENALTY;
+      if (knee)
+       pen = sqrt(pen);
       
-      demerit_score += STEM_LENGTH_LIMIT_PENALTY * ( 0 >? (info.min_y - d * current_y));
-      demerit_score += STEM_LENGTH_LIMIT_PENALTY * ( 0 >? (d * current_y  - info.max_y));
+      demerit_score += pen * ( 0 >? (info.min_y - d * current_y));
+      demerit_score += pen * ( 0 >? (d * current_y  - info.max_y));
 
       demerit_score += STEM_LENGTH_DEMERIT_FACTOR * shrink_extra_weight (d * current_y  - info.ideal_y);
     }
index e8ace6dcceda6215657006974d305289a4eb8476..bbbfbda3252765eb3fbc96c656f7d11abf158b2f 100644 (file)
@@ -40,7 +40,7 @@ public:
   static Real score_stem_lengths (Link_array<Grob>,
                                  Array<Stem_info>,
                                  Array<Real>, Array<Real>, Array<int>,
-                                 Grob*,Real , Real);
+                                 bool,Grob*,Real , Real);
   static Real score_forbidden_quants (Grob*, Real, Real,
                                      Real, Real, Real, Real,
                                      int);
index 600092f8b41a80d72293ce794dda6b4fcee1ff75..7b8db24062a4917260c107045fb029fd571139f5 100644 (file)
@@ -9,7 +9,7 @@
   TODO: This is way too hairy
 */
 
-#include <math.h>              // m_pi
+#include <math.h>              // rint
 
 #include "lookup.hh"
 #include "directional-element-interface.hh"
@@ -753,6 +753,10 @@ Stem::calc_stem_info (Grob*me)
   info.ideal_y = chord_start_f (me);
 
   // for simplicity, we calculate as if dir == UP
+
+  /*
+    UGH. This confuses issues more. fixme. --hwn
+   */
   info.ideal_y *= beam_dir;
   SCM grace_prop = me->get_grob_property ("grace");
 
@@ -776,6 +780,10 @@ Stem::calc_stem_info (Grob*me)
 
   Real stem_length =  a[multiplicity <? (a.size () - 1)] * staff_space;
 
+
+  /*
+    This sucks -- On a kneed beam, *all* stems are kneed, not half of them.
+   */
   if (!beam_dir || (beam_dir == Directional_element_interface::get (me)))
     /* normal beamed stem */
     {
@@ -816,12 +824,13 @@ Stem::calc_stem_info (Grob*me)
   else
     /* knee */
     {
-      info.ideal_y -= thick;
-      info.max_y = info.ideal_y;
-      info.min_y = - 1000 ; // INT_MAX;
+      info.ideal_y -= thick + stem_length;
+      info.max_y = info.ideal_y - minimum_length;
 
-      info.ideal_y -= stem_length;
-      info.max_y -= minimum_length;
+      /*
+       We shouldn't invert the stems, so we set minimum at 0. 
+       */
+      info.min_y = 0.5;
     }
   
   info.ideal_y = (info.max_y <? info.ideal_y) >? info.min_y;