]> git.donarmstrong.com Git - lilypond.git/commitdiff
(score_edges): add exp(slope*dir*leftright)
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 14 Sep 2004 22:29:54 +0000 (22:29 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 14 Sep 2004 22:29:54 +0000 (22:29 +0000)
factor in edge attraction. This reflects that the left edge may
have a larger gap for an ascending up-slur.

ChangeLog
input/regression/new-slur.ly
input/regression/spacing-clef-first-note.ly
lily/slur-scoring.cc
scm/script.scm
scm/slur.scm

index e6bb67ec289873d5d6b4f43f2497ec75d59a4b97..4b464ba74c685c51f8f2c87d4d03a571e3cdbb52 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-09-15  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * lily/slur-scoring.cc (score_edges): add exp(slope*dir*leftright)
+       factor in edge attraction. This reflects that the left edge may
+       have a larger gap for an ascending up-slur.
+
 2004-09-14  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * buildscripts/guile-gnome.sh: Update with tarball [pre]releases.
@@ -12,6 +18,8 @@
 
 2004-09-13  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * lily/slur-scoring.cc (score_edges): don't be so picky for
+
        * ly/property-init.ly (hideStaffSwitch): remove turnOff.
 
        * scripts/convert-ly.py (conv): change Both to Neutral in property
index 2908984fcf933dc3ae1eb4daa76b43f47f527410..0127e66fdfcd6d3e264d8f4c2a91c4fc53415659 100644 (file)
     \clef bass a=8[ e16(f] g[ a bes d,)]  s4 | \break
     
     \clef treble
-    \relative c'' {
+    \new Voice \relative c'' {
        \slurDown f2( d4 f | g c a f | d c f2 | f1) |
     }
 
+%    \override Slur #'excentricity = #-2
+    c=''8 ( d[ b f d] a'[ c])
 }
 
index 71928b6184a5abb0d48113b60bb7fbc59cc0c489..fe19a6362f114b4b03455982bd70a4b9d2d94c34 100644 (file)
@@ -6,20 +6,23 @@ than clef changes halfway the line."
 
 }
 
-\score  {  {
-    << \new Staff {
-       c'2
-       \clef bass e16 f a
-       \clef treble b
+\score  {  
+    <<
+       \new Staff {
+           c'2
+           \clef bass e16 f a
+           \clef treble b
+       }
+       \new Staff  {
+           c'4 c'4 c'4 
+       }
+    >>
+    \paper {
+       raggedright = ##t
+       \context {
+           \Staff
+           \remove Time_signature_engraver
        }
-      \new Staff  {
-         c'4 c'4 c'4 
-      }>>
     }
-    \paper { raggedright = ##t
-\context { \Staff
-             TimeSignature = \turnOff
-        }
-
-     }}
+}
 
index 3cef50cb1a0fe596f0b92aea55c3fa415da7b85d..bb7904e9c3d7405789db2cf9034a82fb486f49f5 100644 (file)
@@ -83,7 +83,7 @@ struct Slur_score_parameters
   Real free_slur_distance_;
   Real free_head_distance_;
   Real extra_encompass_free_distance_;
-
+  Real edge_slope_exponent_;  
   Real head_slur_distance_max_ratio_;
   Real head_slur_distance_factor_;
 
@@ -125,7 +125,7 @@ struct Bound_info
   Interval slur_head_extent_;
   Real neighbor_y_;
   Real staff_space_;
-
+  
   Bound_info ()
   {
     stem_ = 0;
@@ -250,6 +250,8 @@ init_score_param (Grob *me,
     = get_detail (details, ly_symbol2scm ("head-slur-distance-max-ratio"));
   score_param->free_slur_distance_
     = get_detail (details, ly_symbol2scm ("free-slur-distance"));
+  score_param->edge_slope_exponent_
+    = get_detail (details, ly_symbol2scm ("edge-slope-exponent"));
 }
 
 
@@ -928,13 +930,18 @@ score_encompass (Grob *me, Grob *common[],
                                                configuration.attachment_[RIGHT][Y_AXIS],
                                                configuration.attachment_[LEFT][Y_AXIS]);
 
-             if (dir * (infos[j].get_point (dir) - line_y) > 0)
+             if ( 1 ) // dir * infos[j].get_point (dir) > dir *line_y )
                {
-                 Real d = fabs (infos[j].get_point (dir) - y);
+                 
+                 Real closest =
+                   dir * (dir * infos[j].get_point (dir)
+                          >? dir *line_y
+                          );
+                 Real d = fabs(closest - y);
+             
                  convex_head_distances.push (d);
-               }             
+               }
            }
-
          
        
 
@@ -981,11 +988,13 @@ score_encompass (Grob *me, Grob *common[],
          int n =  convex_head_distances.size();
          if (convex_head_distances.size() <= 2)
            {
+             //              Real min_edge_dist = 1e6;
              for (int j = 0; j < edge_distances.size(); j++)
                {
                  avg_distance += edge_distances[j];
                  n++;
                }
+
            }
 
          /*
@@ -1185,6 +1194,10 @@ score_extra_encompass (Grob *me, Grob *common[],
     }
 }
 
+/*
+  TODO: should make edge penalties dependent on the direction that the
+  slur-end is pointing.
+ */
 void
 score_edges (Grob *me, Grob *common[],
             Slur_score_parameters * score_param,
@@ -1198,9 +1211,12 @@ score_edges (Grob *me, Grob *common[],
   for (int i = 0; i < scores->size (); i++)
     {
       Direction d = LEFT;
+      Slur_score &config = scores->elem_ref (i);
+      Offset dz = config.attachment_[RIGHT] - config.attachment_[LEFT];
+      Real slope = dz[Y_AXIS] / dz[X_AXIS];
       do
        {
-         Real y = scores->elem (i).attachment_[d][Y_AXIS];
+         Real y = config.attachment_[d][Y_AXIS];
          Real dy = fabs (y - base_attach[d][Y_AXIS]);
        
          Real factor = score_param->edge_attraction_factor_;
@@ -1210,7 +1226,10 @@ score_edges (Grob *me, Grob *common[],
              && !Stem::get_beaming (extremes[d].stem_, -d)
              )
            demerit /= 5;
-       
+
+         demerit *= exp (dir * d * slope
+                         * score_param->edge_slope_exponent_ );
+         
          (*scores)[i].score_ += demerit;
 #if DEBUG_SLUR_QUANTING
          (*scores)[i].score_card_ += to_string ("E%.2f", demerit);
index d08c26a4e26c0deb604f184479711e9d5a89b461..0165f27c90ccaa57e4458b97c3a672928003b09d 100644 (file)
@@ -9,7 +9,7 @@
        '(("thumb" .
          ((script-stencil . (feta . ("thumb"  . "thumb")))
           (direction . 1)))
-        ("accent" .
+         ("accent" .
          ((inside-slur . #f)
           (follow-into-staff . #t)
           (script-stencil . (feta . ("sforzato" .  "sforzato")))
index 0213fdf738d96e593bf1ed81e8643e74a1a7933c..5b1e9c102806984a6bb871ee13f76129b6898c84 100644 (file)
@@ -25,4 +25,5 @@
     (extra-encompass-free-distance . 0.3)
     (head-slur-distance-max-ratio . 3)
     (head-slur-distance-factor . 10)
+    (edge-slope-exponent . 2)
     ))