]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.3.124.jcn2
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 24 Jan 2001 19:12:25 +0000 (20:12 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 24 Jan 2001 19:12:25 +0000 (20:12 +0100)
1.3.124.jcn2
============

* Cleanup automatic knees, junked calc_interstaff_dist.

* Automatic knees now on by default for vertical distances >= 7 staff-space.

14 files changed:
CHANGES
Documentation/user/features.itely
VERSION
input/test/auto-isknee.ly
input/test/auto-knee.ly
lily/beam.cc
lily/cross-staff.cc
lily/include/beam.hh
lily/include/cross-staff.hh
lily/stem.cc
scm/foo.scm
scm/generic-property.scm
scm/grob-description.scm
scm/grob-property-description.scm

diff --git a/CHANGES b/CHANGES
index 627d84f74d736f41ec5b4214adc8a6b438fd9527..90982aad40d1482f3615df70ff2fbcb5631011f4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,10 @@
+1.3.124.jcn2
+============
+
+* Cleanup automatic knees, junked calc_interstaff_dist.
+
+* Automatic knees now on by default for vertical distances >= 7 staff-space.
+
 1.3.124.jcn1
 ============
 
index cb60274f366989fa095d75e97ed8c592a7b54e0a..cdff41fb771c73bf7acfb77a5fc43fe0ffbd13c2 100644 (file)
@@ -1,3 +1,4 @@
+@c -*-texinfo-*-
 @ignore
 
 TODO
@@ -124,6 +125,9 @@ switches to another staff.  This is enabled if the property
 @cindex beam settings
 @cindex manual beams
 
+
+@c auto knees
+
 In some cases it may be necessary to override LilyPond's automatic
 beaming algorithm.  For example, the auto beamer will not beam over
 rests, so if you want that, specify the begin and end point manually
diff --git a/VERSION b/VERSION
index 27ca58f882069827c94ab716034b2d3b9943075b..73340fcd4b3e60806c0617deb68b6e9430bf0d00 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
 PATCH_LEVEL=124
-MY_PATCH_LEVEL=jcn1
+MY_PATCH_LEVEL=jcn2
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index 8402421493ca8a2412f27b8501c4b197850c9eec..fa3256b668abe71bb88b810da25595f38ed9bb6e 100644 (file)
@@ -16,9 +16,10 @@ texidoc="Two automatic knees";
   >
   \paper{
     linewidth = 40*\staffspace;
-    \translator{
-      \VoiceContext
-      Beam \override #'auto-interstaff-knee-gap = #4.0
-    }
+% Now by default
+%    \translator{
+%      \VoiceContext
+%      Beam \override #'auto-knee-gap = #7
+%    }
   }
 }
index 209bd3f0a165881eee4083d6dee827429b7636c4..b49954b60cadc8885b2ebb63f5ce2b4e890245f0 100644 (file)
@@ -8,9 +8,10 @@ texidoc="One automatic knee";
   }
   \paper{
     linewidth = 40*\staffspace;
-    \translator {
-      \VoiceContext
-      Beam \override #'auto-knee-gap = #13
-    }
+% Now by default
+%    \translator {
+%      \VoiceContext
+%      Beam \override #'auto-knee-gap = #7
+%    }
   }
 }
index 44e6da1dbdda491ea0bb74c83776da725314eb66..41a9a52323cb5f2a39c65b2249ed52bc21b19098 100644 (file)
@@ -31,7 +31,6 @@
 #include "lookup.hh"
 #include "group-interface.hh"
 #include "staff-symbol-referencer.hh"
-#include "cross-staff.hh"
 #include "item.hh"
 #include "spanner.hh"
 #include "warn.hh"
@@ -86,7 +85,7 @@ Beam::before_line_breaking (SCM smob)
   if (!Directional_element_interface::get (me))
     Directional_element_interface::set (me, get_default_dir (me));
 
-  auto_knees (me);
+  consider_auto_knees (me);
   set_stem_directions (me);
   set_stem_shorten (me);
 
@@ -158,69 +157,63 @@ Beam::set_stem_directions (Grob*me)
     }
 } 
 
-void
-Beam::auto_knees (Grob*me)
-{
-  if (!auto_knee (me,"auto-interstaff-knee-gap", true))
-    auto_knee (me, "auto-knee-gap", false);
-}
-
 /*
   Simplistic auto-knees; only consider vertical gap between two
   adjacent chords.
 
   `Forced' stem directions are ignored.  If you don't want auto-knees,
-  don't set, or unset autoKneeGap/autoInterstaffKneeGap.
+  don't set, or unset auto-knee-gap.
  */
-bool
-Beam::auto_knee (Grob*me, String gap_str, bool interstaff_b)
+void
+Beam::consider_auto_knees (Grob *me)
 {
-  bool knee_b = false;
-  int knee_y = 0;
-  SCM gap = me->get_grob_property (gap_str.ch_C());
+  SCM scm = me->get_grob_property ("auto-knee-gap");
 
-  Direction d = Directional_element_interface::get (me);
+  if (gh_number_p (scm))
+    {
+      bool knee_b = false;
+      Real knee_y = 0;
+      Real staff_space = Staff_symbol_referencer::staff_space (me);
+      Real gap = gh_scm2double (scm) / staff_space;
+
+      Direction d = Directional_element_interface::get (me);
       Link_array<Item> stems=
        Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
-  
-  if (gh_number_p (gap))
-    {
-      Spanner*sp = dynamic_cast<Spanner*> (me);
-      int auto_gap_i = gh_scm2int (gap);
+      
+      Grob *common = me->common_refpoint (stems[0], Y_AXIS);
+      for (int i=1; i < stems.size (); i++)
+       common = common->common_refpoint (stems[i], Y_AXIS);
+      
       for (int i=1; i < stems.size (); i++)
         {
-         bool is_b = (bool)(calc_interstaff_dist (stems[i], sp) 
-           - calc_interstaff_dist (stems[i-1], sp));
-         int l_y = (int)(Stem::head_positions(stems[i-1])[d]);
-         int l_i = (int)calc_interstaff_dist (stems[i-1], sp);
-         l_y -= l_i;
-         int r_y = (int)(Stem::head_positions(stems[i])[d]);
-         int r_i = (int)calc_interstaff_dist (stems[i], sp);
-         r_y -= r_i;
-         int gap_i = r_y - l_y;
-
-         if ((abs (gap_i) >= auto_gap_i) && (!interstaff_b || is_b))
+         Real left = Stem::extremal_heads (stems[i-1])[d]
+           ->relative_coordinate (common, Y_AXIS);
+         Real right = Stem::extremal_heads (stems[i])[d]
+           ->relative_coordinate (common, Y_AXIS);
+
+         Real dy = right - left;
+
+         if (abs (dy) >= gap)
            {
-             knee_y = (r_y + l_y) / 2;
+             knee_y = (right + left) / 2;
              knee_b = true;
              break;
            }
        }
-    }
-  if (knee_b)
-    {
-      for (int i=0; i < stems.size (); i++)
-        {
-         Item *s = stems[i];     
-         int y = (int)(Stem::head_positions(s)[d]);
-         int y_i = (int)calc_interstaff_dist (s, dynamic_cast<Spanner*> (me));
-         y -= y_i;
+      
+      if (knee_b)
+       {
+         for (int i=0; i < stems.size (); i++)
+           {
+             Item *s = stems[i];         
+             Real y = Stem::extremal_heads (stems[i])[d]
+               ->relative_coordinate (common, Y_AXIS);
 
-         Directional_element_interface::set (s,y < knee_y ? UP : DOWN);
-         s->set_grob_property ("dir-forced", SCM_BOOL_T);
+             Directional_element_interface::set (s, y < knee_y ? UP : DOWN);
+             s->set_grob_property ("dir-forced", SCM_BOOL_T);
+           }
        }
     }
-  return knee_b;
 }
 
 /*
@@ -523,6 +516,9 @@ Beam::set_stem_length (Grob*me,Real y, Real dy)
   Link_array<Item> stems=
     Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
 
+  Grob *common = me->common_refpoint (stems[0], Y_AXIS);
+  for (int i=1; i < stems.size (); i++)
+    common = common->common_refpoint (stems[i], Y_AXIS);
 
   for (int i=0; i < stems.size (); i++)
     {
@@ -533,7 +529,9 @@ Beam::set_stem_length (Grob*me,Real y, Real dy)
       Real stem_y = calc_stem_y_f (me, s, y, dy);
 
       /* caution: stem measures in staff-positions */
-      Stem::set_stemend (s,(stem_y + calc_interstaff_dist (s, dynamic_cast<Spanner*> (me))) / half_space);
+      Real id = me->relative_coordinate (common, Y_AXIS)
+       - stems[i]->relative_coordinate (common, Y_AXIS);
+      Stem::set_stemend (s, (stem_y + id) / half_space);
     }
 }
 
index 4bb5e0de00c461ee7f8e2506ff7d9a703dfd50a1..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,51 +0,0 @@
-#include "cross-staff.hh"
-#include "item.hh"
-#include "align-interface.hh"
-#include "spanner.hh"
-#include "warn.hh"
-#include "paper-def.hh"
-
-
-/*
-  JUNKME
- */
-Real
-calc_interstaff_dist (Item  *item, Spanner  *span)
-{
-  Real interstaff = 0.0; 
-  Grob *common = item->common_refpoint (span, Y_AXIS);
-
-
-  if (Align_interface::has_interface (common) && Align_interface::axis(common) == Y_AXIS)
-    {
-      SCM threshold = common->get_grob_property ("forced-distance");
-      interstaff = 1.0;
-      if (!gh_number_p (threshold))
-       warning (_ ("not a forced distance; cross-staff spanners may be broken"));
-      else
-       interstaff *= gh_scm2double (threshold);
-
-      Grob  * span_refpoint = span;
-      while (span_refpoint->parent_l  (Y_AXIS) != common)
-       span_refpoint = span_refpoint->parent_l (Y_AXIS);
-
-      Grob  * note_refpoint = item;
-      while (note_refpoint->parent_l (Y_AXIS) != common)
-       note_refpoint = note_refpoint->parent_l (Y_AXIS);
-
-      int span_prio =
-       Align_interface::get_count (common,(Grob*) dynamic_cast<Grob *> (span_refpoint));
-      int item_prio =
-       Align_interface::get_count (common,(Grob*) dynamic_cast<Grob   *> (note_refpoint));
-
-      /*
-       our staff is lower -> interstaff *= -1
-       */
-
-      if (span_prio < item_prio)
-       interstaff *= -1;
-      return interstaff;
-    }
-  else return 0.0;
-}
-
index 4f01a16982d348245a3b011ff5837460d2cf8573..18126770aff1a6523ef5a2e89317a1f42ffe0223 100644 (file)
@@ -16,8 +16,8 @@ class Beam
 {
 public:
   static int visible_stem_count (Grob*);
-  static  Item* first_visible_stem (Grob*);
-  static  Item* last_visible_stem (Grob*);
+  static Item* first_visible_stem (Grob*);
+  static Item* last_visible_stem (Grob*);
   static bool has_interface (Grob*);
   static void set_interface (Grob*);  
   DECLARE_SCHEME_CALLBACK(rest_collision_callback, (SCM element, SCM axis));
@@ -33,20 +33,19 @@ public:
 
 private:
   static Direction get_default_dir (Grob*);
-  static  void set_stem_directions (Grob*);
-  static  void auto_knees (Grob*);
-  static  bool auto_knee (Grob*,String gap_str, bool interstaff_b);
+  static void set_stem_directions (Grob*);
+  static void consider_auto_knees (Grob*);
   static void set_stem_shorten (Grob*);
-  static  void calc_default_position_and_height (Grob*,Real* y, Real* dy);
-  static  bool suspect_slope_b (Grob*, Real y, Real dy);
-  static  Real calc_slope_damping_f (Grob*, Real dy);
-  static  Real calc_stem_y_f (Grob*, Item* s, Real y, Real dy);
-  static  Real check_stem_length_f (Grob*, Real y, Real dy);
-  static  void set_stem_length (Grob*, Real y, Real dy);
-  static   Real quantise_dy_f (Grob*, Real dy);
-  static  Real quantise_y_f (Grob*, Real y, Real dy, int quant_dir);
+  static void calc_default_position_and_height (Grob*,Real* y, Real* dy);
+  static bool suspect_slope_b (Grob*, Real y, Real dy);
+  static Real calc_slope_damping_f (Grob*, Real dy);
+  static Real calc_stem_y_f (Grob*, Item* s, Real y, Real dy);
+  static Real check_stem_length_f (Grob*, Real y, Real dy);
+  static void set_stem_length (Grob*, Real y, Real dy);
+  static Real quantise_dy_f (Grob*, Real dy);
+  static Real quantise_y_f (Grob*, Real y, Real dy, int quant_dir);
   static int forced_stem_count (Grob*);
 };
 
-#endif // BEAM_HH
+#endif /* BEAM_HH */
 
index c5186008c206fa35a1ced808393fd393ae83c707..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,17 +0,0 @@
-/*   
-  cross-staff.hh -- declare cross staff calc funcs.
-  
-  source file of the GNU LilyPond music typesetter
-  
-  (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
- */
-
-#ifndef CROSS_STAFF_HH
-#define CROSS_STAFF_HH
-#include "lily-proto.hh"
-Real
-calc_interstaff_dist (Item  *item, Spanner  *span);
-
-#endif /* CROSS_STAFF_HH */
-
index 5824cc967ac4b17c76cd1e907660ffa096944cea..af597fd0a72a95d3062d3ea757849f2051e2e4d4 100644 (file)
@@ -24,7 +24,6 @@
 #include "beam.hh"
 #include "rest.hh"
 #include "group-interface.hh"
-#include "cross-staff.hh"
 #include "staff-symbol-referencer.hh"
 #include "spanner.hh"
 
@@ -639,8 +638,11 @@ Stem::calc_stem_info (Grob*me)
   if (gh_number_p (s))
     info.idealy_f_ -= gh_scm2double (s);
 
-  Real interstaff_f = -beam_dir* calc_interstaff_dist (dynamic_cast<Item*> (me), dynamic_cast<Spanner*> (beam));
-
+  Grob *common = me->common_refpoint (beam, Y_AXIS);
+  Real interstaff_f = beam_dir *
+    (me->relative_coordinate (common, Y_AXIS)
+     - beam->relative_coordinate (common, Y_AXIS));
+  
   info.idealy_f_ += interstaff_f;
   info.miny_f_ += interstaff_f;
   info.maxy_f_ += interstaff_f ;
index 8b137891791fe96927ad78e64b0aad7bded08bdc..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1 +0,0 @@
-
index f7256676a6346fc9930d7b6f8a9a17b9a0f4f5bf..3d7bb65af08650ed6fde5bbd633475a85d2afd97 100644 (file)
@@ -23,7 +23,6 @@
        (list
         (list 'beamSlopeDamping number? 'damping)
         (list 'autoKneeGap number? 'auto-knee-gap)
-        (list 'autoInterstaffKneeGap number? 'auto-interstaff-knee-gap)
         (list 'beamDirAlgorithm symbol? 'beam-dir-algorithm)
         (list 'beamHeight number? 'height-hs)
         (list 'beamVerticalPosition number? 'y-position-hs)
index 043f35673428ac90d8649c6db3e6b82b9e17a778..e83e91104192a0d8a6df5a489d0c02d5b4ecc0f5 100644 (file)
@@ -70,6 +70,7 @@
                 (flag-width-function . ,default-beam-flag-width-function)
                 (space-function . ,default-beam-space-function)
                 (damping . 1)
+                (auto-knee-gap . 7)
                 (meta . ,(grob-description "Beam" beam-interface))
                 ))
         
index 3a1993069ea83f17383e3830a0f93f3f34023236..eac251007c8bc6c3f0de6d7b59ca622f785c5feb 100644 (file)
@@ -41,8 +41,7 @@ This procedure is called (using dependency resolution) after line breaking. Retu
 '(LEFT-offset . RIGHT-offset).  This offset is added to the
 attachments to prevent ugly slurs.  [fixme: we need more documentation here].
 ")
-(grob-property-description 'auto-interstaff-knee-gap number? "")
-(grob-property-description 'auto-knee-gap number? "")
+(grob-property-description 'auto-knee-gap number? "The vertical distance of two adjacent beamed notes beyond which to make a knee.")
 
 (grob-property-description 'axes list? "list of axis numbers.