]> git.donarmstrong.com Git - lilypond.git/commitdiff
* Documentation/user/refman.itely (Font selection): font size doco
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 21 Jul 2002 12:28:45 +0000 (12:28 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 21 Jul 2002 12:28:45 +0000 (12:28 +0000)
* lily/stem.cc: rewrite of scoring to give sane results on knee
beams.

* lily/beam.cc (set_stem_lengths): extend stems for gapped tremolo
beams.
(connect_beams): chop off beaming outside the beam. Fixes problem
with tremolo beams.

ChangeLog
Documentation/user/preface.itely
Documentation/user/refman.itely
lily/beam-quanting.cc
lily/beam.cc
lily/include/beam.hh
lily/stem.cc

index 60b417c03c3e9da0243c4bb947f615667a94d92a..7bf607b5b07a55f07543ce02bf2775f8da5ed16c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2002-07-21  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * input/test/cue-notes.ly: better example
+
+       * Documentation/user/refman.itely (Font selection): font size doco
+
+       * input/mutopia/F.Schubert/standchen.ly: note bugfix
+
+       * lily/stem.cc: rewrite of scoring to give sane results on knee
+       beams.
+
        * lily/beam.cc (set_stem_lengths): extend stems for gapped tremolo
        beams.
        (connect_beams): chop off beaming outside the beam. Fixes problem
index e7778c4faa1c0f17f8caf56f288cd7de905689fc..8d947eb6ca80aab95d7ef6e20698944c142fcd43 100644 (file)
@@ -1,6 +1,7 @@
+@comment @c -*-texinfo-*-
 
 @node Preface
-@chapter Preface
+@unnumbered Preface
 
 
 It must have been during a rehearsal of the EJE (Eindhoven Youth
index 93ddd5c369488ffefb4f2176406b49febfbd2aa8..ba3d6aa03532e82e0e912bca821e322fc526a0d3 100644 (file)
@@ -3888,7 +3888,7 @@ slightly different design. Smaller design sizes are relatively wider,
 which enhances readability.
 @end table
 
-For any of these properties, the value @code{*} (i.e. the @em{symbol},
+For any of these properties, the value @code{*} (i.e. the @emph{symbol},
 @code{*}, entered as @code{#'*}), acts as a wildcard. This can be used
 to override default setting, which are always present. For example:
 @example
index efe670738a40e2986bfd61e9de616f3050f6fd3f..dc5afce3643e5594539c3d65c4d2fb987b9c2a24 100644 (file)
@@ -270,10 +270,20 @@ Beam::score_stem_lengths (Link_array<Grob>stems,
       Direction d = info.dir_;
 
       score[d] += pen
-       * (0 >? (info.dir_ * (info.shortest_y_ - current_y)));
+       * (0 >? (d * (info.shortest_y_ - current_y)));
+
+      Real ideal_score = shrink_extra_weight (d * current_y  - d * info.ideal_y_);
       
-      score[d] += STEM_LENGTH_DEMERIT_FACTOR
-       * shrink_extra_weight (d * current_y  - info.dir_ * info.ideal_y_);
+      /*
+
+      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;
 
       count[d] ++;
     }
index 23f38c40794d3a53f968aaf1890299e3ee16f34d..dda0cf2c8062f2f55ae594de4f6fe9a48a78e662 100644 (file)
@@ -560,17 +560,20 @@ Beam::consider_auto_knees (Grob *me, Direction d)
  TODO:
    take some y-position (chord/beam/nearest?) into account
    scmify forced-fraction
-
-   TODO:
-   
-   why is shorten stored in beam, and not directly in stem?
+  This is done in beam because the shorten has to be uniform over the
+  entire beam.
 
 */
 void
-Beam::set_stem_shorten (Grob *m)
+Beam::set_stem_shorten (Grob *me)
 {
-  Spanner*me = dynamic_cast<Spanner*> (m);
-
+  /*
+    shortening looks silly for x staff beams
+   */
+  if (knee_b(me))
+    return ;
+  
   Real forced_fraction = forced_stem_count (me) / visible_stem_count (me);
 
   int beam_count = get_beam_count (me);
@@ -1268,7 +1271,32 @@ Beam::rest_collision_callback (SCM element_smob, SCM axis)
   return gh_double2scm (-d *  discrete_dist);
 }
 
+bool
+Beam::knee_b (Grob*me)
+{
+  SCM k=   me->get_grob_property ("knee");
+  if (gh_boolean_p(k))
+    return gh_scm2bool (k);
 
+  Link_array<Grob> stems=
+    Pointer_group_interface__extract_grobs (me, (Grob*)0, "stems");
+
+  Drul_array<bool> dirs_found(0,0);
+  
+  for (int i= 0; i < stems.size(); i++)
+    {
+      Grob*s = stems[i];
+      dirs_found[Directional_element_interface::get(s)] = true;
+
+      if (dirs_found[LEFT]&&dirs_found[RIGHT])
+       break;
+    }
+
+  bool knee = dirs_found[LEFT]&&dirs_found[RIGHT];
+  me->set_grob_property ("knee", gh_bool2scm (knee));
+
+  return knee;
+}
 
 
 ADD_INTERFACE (Beam, "beam-interface",
index 528348538a7cb73b859cd66cff2555391efd2ebc..a582c62555c53c0cf916d14811ae314c9d07b918 100644 (file)
@@ -22,6 +22,7 @@ public:
   DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM axis));
   Beam (SCM);
   static void add_stem (Grob*,Grob*);
+  static bool knee_b (Grob*);
   static void set_beaming (Grob*,Beaming_info_list *);
   static void set_stemlens (Grob*);
   static int get_beam_count (Grob*me);
index ffd07ffcfde0d052d8d729c9e22e6a7c61494c01..8589fc0295f02595fcda8ed9d7e986984609c0aa 100644 (file)
@@ -818,15 +818,14 @@ Stem::calc_stem_info (Grob*me)
 
   Grob * beam = beam_l (me);
   int beam_count = beam_multiplicity(me).length()+1;
-  Real beam_translation_f = Beam::get_beam_translation (beam);
+  Real beam_translation= Beam::get_beam_translation (beam);
   Real thick = gh_scm2double (beam->get_grob_property ("thickness"));
-  Real ideal_y = chord_start_y (me);
+  Real note_start = chord_start_y (me);
   
   /* from here on, calculate as if dir == UP */
-  ideal_y *= mydir;
+  note_start *= mydir;
   
   SCM grace_prop = me->get_grob_property ("grace");
-
   
   bool grace_b = to_boolean (grace_prop);
   SCM bml = robust_list_ref ( beam_count ,
@@ -837,17 +836,16 @@ Stem::calc_stem_info (Grob*me)
                              me->get_grob_property ("beamed-lengths"));
   Real stem_length =  gh_scm2double(bl) * staff_space;
 
-  ideal_y += thick + (beam_count - 1) * beam_translation_f;
 
-   
-  Real shortest_y = ideal_y + minimum_length
-    + (beam_count > 0) ? thick : 0
-    + beam_translation_f * (beam_count - 1);
-    
+  /*
+    stem goes to center of beam, hence 0.5
+   */
+  Real beam_lengthen = beam_translation* (beam_count - 1)
+    + ((beam_count > 0) ? thick : 0) - 0.5 * thick;
 
-  ideal_y += stem_length;
+  Real shortest_y = note_start + minimum_length + beam_lengthen;
+  Real ideal_y = stem_length + note_start + beam_lengthen;
 
-  
   /*
     lowest beam of (UP) beam must never be lower than second staffline
 
@@ -865,21 +863,9 @@ Stem::calc_stem_info (Grob*me)
         staffline
         lowest beam of (UP) beam must never be lower than second staffline
       */
-#if 0
-      shortest_y =
-       shortest_y >? 0
-       >? (- 2 * half_space - thick
-           + (beam_count > 0) * thick
-           + beam_translation_f * (beam_count - 1));
-
-#else
       ideal_y =
        ideal_y >? 0
-       >? (- 2 * half_space - thick
-           + (beam_count > 0) * thick
-           + beam_translation_f * (beam_count - 1));
-#endif
-      
+       >? (- 2 * half_space - thick + beam_lengthen);
     }