]> git.donarmstrong.com Git - lilypond.git/commitdiff
(class New_slur): new file. Score based slur
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 11 Jul 2004 11:28:23 +0000 (11:28 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 11 Jul 2004 11:28:23 +0000 (11:28 +0000)
computations.

input/test/new-slur.ly
lily/new-slur.cc
scm/define-grobs.scm

index de408d431799f93a0ee1644475d93a1429e5f388..876698ef6c5bf9fccfc4e50ce3d3e8c3bb0661d0 100644 (file)
@@ -1,11 +1,18 @@
-
+\paper {
+    raggedright = ##t
+}
 
 \relative {
 
     \override Slur #'after-line-breaking-callback = #New_slur::after_line_breaking
-   \override Slur #'print-function = #New_slur::print     
+    \override Slur #'print-function = #New_slur::print     
     \override Slur #'height = ##f
-    <c g> ( f <g b>)
+
+    f'=''16( e)
+%    d( c)
+%    c'=''2(~c8 d16 c b8 a)
+    
+%{    <c g> ( f <g b>)
      f
     <c g>^( f <g b>)
     f
@@ -14,5 +21,6 @@
     <g b>_( \stemDown g \stemBoth  <b d>)
     c,^( c'' c) 
     c,,^( c'')
-    c,,^( c')
+    c,,^( c') 
+%}
 }
index 111fd1b463d54401440863b71394ab2cc3de97cf..f496640f57ec5df76eba1f11a7a5daf15b2749b8 100644 (file)
@@ -274,8 +274,9 @@ New_slur::set_end_points (Grob *me)
       Real y = h->extent (common[Y_AXIS], Y_AXIS)[dir];
 
       y += dir * 0.5 * staff_space;
-      if (Staff_symbol_referencer::on_staffline (h))
-       y += .5 * staff_space * dir ; 
+      int p = Staff_symbol_referencer::get_position (h) + 2*dir;
+      if (Staff_symbol_referencer::on_staffline (h, p))
+       y += 0.5 * staff_space * dir ; 
 
       Grob * fh = Note_column::first_head (extremes[d]);
       Real x = fh->extent (common[X_AXIS],  X_AXIS).linear_combination (CENTER);
@@ -291,8 +292,12 @@ New_slur::set_end_points (Grob *me)
     } while (flip (&d) != LEFT);
 
   Drul_array<Real> staff_offsets;
+  Interval end_ys;
+
   do {
     staff_offsets[d] = staves[d]->relative_coordinate (common[Y_AXIS], Y_AXIS);
+    end_ys[d] =  dir * (dir * base_attachment[d][Y_AXIS] + 4.0 *dir >?
+                       dir * (dir + extremes[d]->extent(common[Y_AXIS],Y_AXIS)[dir]));
   } while (flip (&d) != LEFT);
   
   Array<Slur_score> scores;
@@ -300,37 +305,32 @@ New_slur::set_end_points (Grob *me)
   Drul_array<Offset> os;
 
   /*ugh.   */
-  os[LEFT] = base_attachment[LEFT]; 
-  for (int i = 0; i < SLUR_REGION_SIZE; i++)
+  os[LEFT] = base_attachment[LEFT];
+    
+  for (int i = 0; dir * os[LEFT][Y_AXIS] < dir * end_ys[LEFT]; i++)
     {
       os[RIGHT] = base_attachment[RIGHT];
-      for (int j = 0; j < SLUR_REGION_SIZE; j++)
+      for (int j = 0; dir *os[RIGHT][Y_AXIS] < dir * end_ys[RIGHT]; j++)
        {
          Slur_score s;
          s.attachment_ = os;
 
          scores.push (s);
 
-         Real y  = os[RIGHT][Y_AXIS]; 
-         
-         if (Staff_symbol_referencer::staff_radius (staves[RIGHT])
-             > fabs ((y - staff_offsets[RIGHT]) / staff_space))
-           y += dir *staff_space;
-         else
-           y += dir * staff_space / 2;
+         Real incr = dir * staff_space;
+         if  (Staff_symbol_referencer::staff_radius (staves[RIGHT])
+             < fabs ((os[RIGHT][Y_AXIS] - staff_offsets[RIGHT]) / staff_space))
+           incr /= 2;
 
-         os[RIGHT][Y_AXIS] = y;          
+         os[RIGHT][Y_AXIS] += incr;      
        }
 
-      Real y  = os[LEFT][Y_AXIS]; 
-
-      if (Staff_symbol_referencer::staff_radius (staves[LEFT])
-         > fabs ((y - staff_offsets[LEFT]) / staff_space))
-       y += dir *staff_space;
-      else
-       y += dir *staff_space / 2;
+      Real incr = dir * staff_space;
+      if  (Staff_symbol_referencer::staff_radius (staves[LEFT])
+          < fabs ((os[LEFT][Y_AXIS] - staff_offsets[LEFT]) / staff_space))
+       incr /= 2;
 
-      os[LEFT][Y_AXIS] = y;      
+      os[LEFT][Y_AXIS] += incr;          
     }
   
 
@@ -413,11 +413,11 @@ New_slur::score_encompass (Grob * me,  Grob *common[], Drul_array<Offset> base_a
              ext.add_point (infos[j].stem_);
              ext.add_point (infos[j].head_);
 
-             demerit += - CLOSENESS_FACTOR * (dir * (y - (ext[dir] + dir * HEAD_FREE_SPACE)) <? 0) ;
+             demerit += - CLOSENESS_FACTOR * (dir * (y - (ext[dir] + dir * HEAD_FREE_SPACE)) <? 0) /
+               infos.size ();
            }
        }
-      if (infos.size())
-       demerit /= infos.size ();
+
       Direction d = LEFT;
       do {
        demerit +=
index edbb682aa2a08f81ed866b273a70506a06b07a56..588ff691d8cf1730f0cce051bef773622343a168 100644 (file)
 
     (Slur
      . (
-       (print-function . ,New_slur::print)
+       (print-function . ; ,New_slur::print)
+                       ,Slur::print)
        (thickness . 1.2)               
        (spacing-procedure . ,Spanner::set_spacing_rods)                
        (minimum-length . 1.5)
-       (after-line-breaking-callback . ,New_slur::after_line_breaking)
+       (after-line-breaking-callback . ; ,New_slur::after_line_breaking)
+                                     ,Slur::after_line_breaking)
        (extremity-function . ,calc-slur-extremity)
        (extremity-offset-alist . ,default-slur-extremity-offset-alist)
        (de-uglify-parameters . (1.5  0.8  -2.0))
-       (Y-extent-callback . ,#f) ; Slur::height
+       (Y-extent-callback .
+                          ; ,#f) 
+                          Slur::height)
        (height-limit . 2.0)
        (ratio . 0.333)
        (beautiful . 0.5)