]> 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 02:45:52 +0000 (02:45 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 11 Jul 2004 02:45:52 +0000 (02:45 +0000)
computations.

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

index b408a8653ed22a45ef2fa4eaa5eba0273436e1af..de408d431799f93a0ee1644475d93a1429e5f388 100644 (file)
@@ -12,5 +12,7 @@
     <c g>_( f <g b>)
     <g b>_( g  <b d>)
     <g b>_( \stemDown g \stemBoth  <b d>)
-    
+    c,^( c'' c) 
+    c,,^( c'')
+    c,,^( c')
 }
index 37f2412433e6a6c5e27614e0f33c05ab6f10a107..111fd1b463d54401440863b71394ab2cc3de97cf 100644 (file)
@@ -10,6 +10,9 @@
 
 #include <math.h>
 
+#include "font-interface.hh"
+#include "text-item.hh"
+
 #include "directional-element-interface.hh"
 #include "group-interface.hh"
 #include "group-interface.hh"
@@ -141,7 +144,14 @@ New_slur::get_encompass_info (Grob *me,
   else
     ei.x_ = col->extent (common[X_AXIS], X_AXIS).center ();
 
-  ei.head_ = Stem::extremal_heads (stem)[Direction (stem_dir * dir)]->extent (common[Y_AXIS], Y_AXIS)[dir];
+  Grob * h = Stem::extremal_heads (stem)[Direction (dir)];
+  if (!h)
+    {
+      ei.head_ = ei.stem_ = col->relative_coordinate (common[Y_AXIS], Y_AXIS);
+      return ei;  
+    }
+  
+  ei.head_ = h->extent (common[Y_AXIS], Y_AXIS)[dir];
   
   if ((stem_dir == dir)
       && !stem->extent (stem, Y_AXIS).is_empty ())
@@ -224,7 +234,11 @@ New_slur::set_end_points (Grob *me)
   Link_array<Grob> columns =
     Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns");
   
-
+  if (columns.is_empty ())
+    {
+      me->suicide ();
+      return ; 
+    }
   Real staff_space = Staff_symbol_referencer::staff_space ((Grob*)me);
   Drul_array<Grob *> extremes (columns[0], columns.top ());
   Direction dir = get_grob_direction (me);
@@ -245,8 +259,7 @@ New_slur::set_end_points (Grob *me)
   
   do {
     Grob *stem = Note_column::get_stem (extremes[d]);
-    Direction stemdir = get_grob_direction (stem);
-    Grob * h = Stem::extremal_heads (stem)[Direction (dir * stemdir)];
+    Grob * h = Stem::extremal_heads (stem)[Direction (dir)];
     staves[d] = Staff_symbol_referencer::get_staff_symbol (h);
 
     common[Y_AXIS] = common[Y_AXIS]->common_refpoint (staves[d], Y_AXIS);
@@ -256,8 +269,7 @@ New_slur::set_end_points (Grob *me)
     {
       // c&p
       Grob *stem = Note_column::get_stem (extremes[d]);
-      Direction stemdir = get_grob_direction (stem);
-      Grob * h = Stem::extremal_heads (stem)[Direction (dir * stemdir)];
+      Grob * h = Stem::extremal_heads (stem)[dir];
      
       Real y = h->extent (common[Y_AXIS], Y_AXIS)[dir];
 
@@ -351,11 +363,11 @@ New_slur::set_end_points (Grob *me)
   me->set_property ("control-points", controls);
 
 #if DEBUG_SLUR_QUANTING
     qscores[opt_idx].score_card_ += to_string ("i%d", best_idx);
scores[opt_idx].score_card_ += to_string ("i%d", opt_idx);
       
     // debug quanting
     me->set_property ("quant-score",
-                       scm_makfrom0str (scores[opt_idx].score_card_.to_str0 ()));
+ // debug quanting
+ me->set_property ("quant-score",
+                  scm_makfrom0str (scores[opt_idx].score_card_.to_str0 ()));
 #endif
   
 }
@@ -404,8 +416,8 @@ New_slur::score_encompass (Grob * me,  Grob *common[], Drul_array<Offset> base_a
              demerit += - CLOSENESS_FACTOR * (dir * (y - (ext[dir] + dir * HEAD_FREE_SPACE)) <? 0) ;
            }
        }
-
-      demerit /= infos.size ();
+      if (infos.size())
+       demerit /= infos.size ();
       Direction d = LEFT;
       do {
        demerit +=
@@ -414,7 +426,7 @@ New_slur::score_encompass (Grob * me,  Grob *common[], Drul_array<Offset> base_a
       } while (flip (&d) != LEFT);
 
 #if DEBUG_SLUR_QUANTING
-      (*qscores)[i].score_card_ += to_string ("E%.2f",d);
+      (*scores)[i].score_card_ += to_string ("E%.2f", demerit);
 #endif
       
       (*scores)[i].score_ += demerit;
@@ -437,8 +449,7 @@ New_slur::score_slopes (Grob * me,  Grob *common[], Drul_array<Offset> base_atta
   Direction d = LEFT;
   do {
     Grob *stem = Note_column::get_stem (extremes [d]);
-    Direction sd = get_grob_direction (stem);
-    ys[d] = Stem::extremal_heads (stem)[Direction (dir * sd)]
+    ys[d] = Stem::extremal_heads (stem)[Direction (dir)]
       ->relative_coordinate (common[Y_AXIS], Y_AXIS);
   } while (flip (&d) != LEFT);
 
@@ -464,7 +475,7 @@ New_slur::score_slopes (Grob * me,  Grob *common[], Drul_array<Offset> base_atta
        demerit += SAME_SLOPE_PENALTY;
       
 #if DEBUG_SLUR_QUANTING
-      (*qscores)[i].score_card_ += to_string ("E%.2f",d);
+      (*scores)[i].score_card_ += to_string ("S%.2f",d);
 #endif
       (*scores)[i].score_ += demerit;
     }
@@ -551,8 +562,6 @@ New_slur::print (SCM smob)
       String str;
       SCM properties = Font_interface::text_font_alist_chain (me);
 
-      Direction stem_dir = stems.size() ? to_dir (stems[0]->get_property ("direction")) : UP;
-    
       Stencil tm = *unsmob_stencil (Text_item::interpret_markup
         (me->get_paper ()->self_scm (), properties, quant_score));
       a.add_at_edge (Y_AXIS, get_grob_direction (me), tm, 1.0, 0);
index c7914a054066355738a3f893f094af8523678841..1d723e72b2ee58348099f66e76141eebbbe99e3c 100644 (file)
@@ -154,7 +154,11 @@ Stem::last_head (Grob *me)
   return 0;  
 }
 
-/* START is part where stem reaches `last' head.  */
+/* START is part where stem reaches `last' head.
+
+This function returns a drul with (bottom-head, top-head). 
+
+*/
 Drul_array<Grob*>
 Stem::extremal_heads (Grob *me)
 {
index a4c431b8febef9e250dbd9820b27d4b01a36e394..edbb682aa2a08f81ed866b273a70506a06b07a56 100644 (file)
 
     (Slur
      . (
-       (print-function . ,Slur::print)
+       (print-function . ,New_slur::print)
        (thickness . 1.2)               
        (spacing-procedure . ,Spanner::set_spacing_rods)                
        (minimum-length . 1.5)
-       (after-line-breaking-callback . ,Slur::after_line_breaking)
+       (after-line-breaking-callback . ,New_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 . ,Slur::height)
+       (Y-extent-callback . ,#f) ; Slur::height
        (height-limit . 2.0)
        (ratio . 0.333)
        (beautiful . 0.5)