]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/define-grobs.scm: switch on new-slur by default.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 17 Jul 2004 01:05:51 +0000 (01:05 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 17 Jul 2004 01:05:51 +0000 (01:05 +0000)
* lily/scm-option.cc: symbol != string.

* lily/new-slur.cc (set_end_points): handle broken slurs. Doesn't
really work yet.
(set_end_points): make X coord of attachment dependent on  Y.
(score_encompass): add edges too.

ChangeLog
input/mutopia/W.A.Mozart/mozart-hrn3-allegro.ily
input/regression/new-slur.ly [new file with mode: 0644]
input/regression/slur-broken-trend.ly
input/test/new-slur.ly [deleted file]
lily/include/main.hh
lily/include/stem.hh
lily/new-slur.cc
lily/scm-option.cc
lily/stem.cc
scm/define-grobs.scm

index 0db1579b0e437d9196999315b24b93ccd5520628..259875c5eb0e71064d3e63dca86154656742dd17 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
+2004-07-17  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * scm/define-grobs.scm: switch on new-slur by default.
+
+       * lily/scm-option.cc: symbol != string.
+
+       * lily/new-slur.cc (set_end_points): handle broken slurs. Doesn't
+       really work yet.
+       (set_end_points): make X coord of attachment dependent on  Y.
+       (score_encompass): add edges too.
+
 2004-07-16  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * lily/stem.cc (get_beaming): new function.
+
        * scripts/lilypond-book.py (compose_ly): make fragment mandatory
        for fragment snippets. This fixes inclusion of toplevel-music
        examples (such as new-slur.ly)
index d6c47d5b7a4b9a4db56e185471eb1e22e83ba948..b51ac1f0bb9068ab42792c35df9436f29d7e176b 100644 (file)
@@ -175,7 +175,7 @@ allegro =
        g4 \times 2/3 {  r8  c8[( g)] } \times 2/3 {  e[ ( g) e-. ] } \times 2/3 {  c[ ( e) c-.] }|
        g4 r8 g'\f  a[ b c d]|
 
-       << d1(\trill
+       << d1_(\trill
          { s2 \grace {
   \override Stem   #'stroke-style = #"grace"
     c16[ d] 
diff --git a/input/regression/new-slur.ly b/input/regression/new-slur.ly
new file mode 100644 (file)
index 0000000..b822ba3
--- /dev/null
@@ -0,0 +1,39 @@
+
+\header {
+    texidoc = "Scoring based slur formatting."
+}
+
+\paper {
+    raggedright = ##t
+}
+
+% #(ly:set-option 'debug-beam #t)
+
+\relative {
+    \override Slur #'after-line-breaking-callback = #New_slur::after_line_breaking
+    \override Slur #'print-function = #New_slur::print     
+    \override Slur #'height = ##f
+
+    \grace {
+       e=''16( 
+    }
+    d8.[) c16]
+    d8.[ \grace f16( e16)]
+    
+    
+    f'=''16( e)    d( c)
+    c'=''2(~c8 d16 c b8 a)
+    f='4
+    <c g>4 ( f <g b>)
+     f
+    <c g>^( f <g b>)
+    f
+    <c g>_( f <g b>)
+    <g b>_( g  <b d>)
+    <g b>_( \stemDown g \stemBoth  <b d>)
+    c,^( c'' c) 
+    c,,^( c'')
+    c,,^( c')
+    }
+
+% #(ly:set-option 'debug-beam #f)
index 4c435c60cc77cb1273299c32906f13b2a0c6df61..aec1dce7991f005adc4f48676c035af23059ca39 100644 (file)
@@ -9,17 +9,28 @@ staff.  A slur should follow the same vertical direction it would have
 in unbroken state.
 "
 }
-\score{
-        \relative c''{
-               e1( \break a,)
-               \time 2/4
-               e'2( \break a,)(\break
-               a2\break
-                e'2)
-       }
-       \paper {
-               linewidth=40.\mm
-               indent=0.
-       }
+\paper {
+    linewidth=40.\mm
+    indent=0.
+}
+
+\relative c''{
+    \override Slur #'after-line-breaking-callback = #New_slur::after_line_breaking
+    \override Slur #'print-function = #New_slur::print     
+    \override Slur #'height = ##f
+    
+    e1( \break a,)
+    \time 2/4
+    e'2( \break a,)(\break
+    a2\break
+    e'2)
+    \time 4/4
+    << d1_(\trill
+       { s2 \grace {
+          c16[ d] 
+       } }
+     >>
+    \break 
+    c4)
 }
 
diff --git a/input/test/new-slur.ly b/input/test/new-slur.ly
deleted file mode 100644 (file)
index e312340..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-
-% breaks web
-\paper {
-    raggedright = ##t
-}
-
-
-\relative {
-
-
-    \override Slur #'after-line-breaking-callback = #New_slur::after_line_breaking
-    \override Slur #'print-function = #New_slur::print     
-    \override Slur #'height = ##f
-    f'=''16( e)    d( c)
-    c'=''2(~c8 d16 c b8 a)
-    f='4
-    <c g>4 ( f <g b>)
-     f
-    <c g>^( f <g b>)
-    f
-    <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 a26d7f372c3af0f5583d7f3b62501f594998756e..62aeb4fbea2dde242078d8bb4930ed4b63438d79 100644 (file)
@@ -35,6 +35,7 @@ extern bool safe_global_b;
 extern bool verbose_global_b;
 extern bool store_locations_global_b;
 extern bool internal_type_checking_global_b;
+extern bool debug_beam_quanting_flag;
 
 
 /* misc */
index d1060f432bf8f31217098074d14bb64107f482b6..e3078a13d6fa4b9eaef470e0a631ba95a12c5c70 100644 (file)
@@ -18,6 +18,7 @@ public:
   static Array<int> note_head_positions (Grob *);
   static int duration_log (Grob *);
   static void set_beaming (Grob *, int, Direction d);
+  static int get_beaming (Grob *, Direction d);
   static Grob *get_beam (Grob *);
   static Grob *first_head (Grob *);
   static Grob *last_head (Grob *);
index fdef450f4f9bf620221e4851493ecf8024197da1..fe20bcfde844a1630ba9ae24ed33b3557fe09f40 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <math.h>
 
+#include "main.hh"
 #include "font-interface.hh"
 #include "text-item.hh"
 #include "directional-element-interface.hh"
@@ -49,6 +50,28 @@ struct Encompass_info {
   }
 };
 
+struct Bound_info {
+
+  Box stem_extent_;
+  Direction stem_dir_;
+  Grob *bound_;
+  Grob *note_column_;
+  Grob *slur_head_;
+  Grob *staff_;
+  Grob *stem_;
+  Interval slur_head_extent_;
+  Real neighbor_y_;
+
+  Bound_info () {
+    stem_ = 0;
+    neighbor_y_ = 0;
+    staff_ = 0;
+    slur_head_ = 0;
+    stem_dir_ = CENTER;
+    note_column_ = 0;
+  }
+};
+
 /*
   TODO: put in details list.
   */
@@ -62,7 +85,7 @@ const Real SAME_SLOPE_PENALTY = 20;
 const Real STEEPER_SLOPE_FACTOR = 50;
 const Real NON_HORIZONTAL_PENALTY = 15;
 const Real HEAD_STRICT_FREE_SPACE = 0.2;
-const Real MAX_SLOPE = 1.4;
+const Real MAX_SLOPE = 1.1;
 const Real MAX_SLOPE_FACTOR = 10;
 
 
@@ -87,10 +110,13 @@ class New_slur
 public:
   static void add_column (Grob *me, Grob *col);
   DECLARE_SCHEME_CALLBACK (print, (SCM));
-  static void score_slopes (Grob * me,  Grob *common[], Drul_array<Offset> base_attach,
+  static void score_slopes (Grob * me,  Grob *common[],
+                           Drul_array<Bound_info>,
+                           Drul_array<Offset> base_attach,
                            Array<Slur_score> * scores);
   
   static  void score_encompass (Grob * me,  Grob *common[],
+                               Drul_array<Bound_info>,
                                Drul_array<Offset>, Array<Slur_score> * scores);
   static void set_interface (Grob*);
   static bool  has_interface (Grob*);
@@ -103,7 +129,7 @@ public:
 private:
   static void set_end_points (Grob*);
   static Real get_boundary_notecolumn_y (Grob *me, Direction dir);
-  static Offset broken_trend_offset (Grob *me, Direction dir);
+  static Real broken_trend_y (Grob *me, Grob**, Direction dir);
   static Offset get_attachment (Grob *me,Direction dir, Grob **common);
   static void de_uglyfy (Grob *me,Slur_bezier_bow* bb, Real default_height);
   static SCM set_extremities (Grob *me);
@@ -112,6 +138,59 @@ private:
   static Encompass_info get_encompass_info (Grob *me, Grob *col, Grob **common);
 };
 
+Real
+New_slur::broken_trend_y (Grob *me, Grob**common, Direction hdir)
+{
+  /*
+    A broken slur should maintain the same vertical trend
+    the unbroken slur would have had.
+  */
+  Real by = 0.0;
+  if (Spanner *mother =  dynamic_cast<Spanner*> (me->original_))
+    {
+      int k = broken_spanner_index (dynamic_cast<Spanner*> (me));
+      int j = k + hdir;
+      if (j < 0 || j >= mother->broken_intos_.size ())
+       return by;
+      
+      Grob *neighbor = mother->broken_intos_[j];      
+      if (hdir == RIGHT)
+       neighbor->set_property ("direction",
+                                me->get_property ("direction"));
+
+      Spanner * common_mother = dynamic_cast<Spanner*> (common[Y_AXIS]->original_);
+      int common_k = broken_spanner_index (dynamic_cast<Spanner*> (common[Y_AXIS]));
+      int common_j = common_k + hdir;
+
+      if (common_j < 0 || common_j >= common_mother->broken_intos_.size())
+       return by;
+      
+
+      Grob *common_next_system = common_mother->broken_intos_[common_j];
+      Link_array<Grob> neighbor_cols = 
+       Pointer_group_interface__extract_grobs (neighbor, (Grob*)0, "note-columns");
+
+      Grob * neighbor_col = (hdir == RIGHT) ? neighbor_cols[0] : neighbor_cols.top ();
+      Grob * neighbor_common = common_next_system->common_refpoint (neighbor_col, Y_AXIS);
+
+      Direction vdir = get_grob_direction (me);
+      Real neighbor_y =
+       neighbor_col->extent (neighbor_common, Y_AXIS)
+       .linear_combination (int(neighbor_cols.size()==1 ? CENTER : vdir))
+       - common_next_system->relative_coordinate (neighbor_common, Y_AXIS);
+
+      Link_array<Grob> my_cols = 
+       Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns");
+      
+      Grob *extreme_col = (hdir == RIGHT) ? my_cols.top() : my_cols[0];
+      Real y = extreme_col->extent (common[Y_AXIS], Y_AXIS).linear_combination (vdir);
+      
+      by = (y*neighbor_cols.size() + neighbor_y*my_cols.size()) /
+       (my_cols.size() + neighbor_cols.size());
+    }
+  return by;
+}
+
 void
 New_slur::set_interface (Grob*me)
 {
@@ -144,7 +223,7 @@ New_slur::get_encompass_info (Grob *me,
     {
       programming_error ("No stem for note column?");
       ei.x_ = col->relative_coordinate (common[X_AXIS], X_AXIS);
-      ei.head_ = ei.stem_ = col->relative_coordinate (common[Y_AXIS], Y_AXIS);
+      ei.head_ = ei.stem_ = col->extent (common[Y_AXIS], Y_AXIS)[get_grob_direction (me)];
       return ei;  
     }
   Direction stem_dir = get_grob_direction (stem);
@@ -157,7 +236,7 @@ New_slur::get_encompass_info (Grob *me,
   Grob * h = Stem::extremal_heads (stem)[Direction (dir)];
   if (!h)
     {
-      ei.head_ = ei.stem_ = col->relative_coordinate (common[Y_AXIS], Y_AXIS);
+      ei.head_ = ei.stem_ = col->extent (common[Y_AXIS], Y_AXIS)[dir];
       return ei;  
     }
   
@@ -208,10 +287,6 @@ New_slur::after_line_breaking (SCM smob)
     set_grob_direction (me, get_default_dir (me));
 
   
-  if (!Note_column::has_interface (me->get_bound (LEFT))
-      || !Note_column::has_interface (me->get_bound (RIGHT)))
-    me->suicide ();            // fixme.
-  
   set_end_points (me);
 
   return SCM_UNSPECIFIED;
@@ -244,8 +319,8 @@ New_slur::set_end_points (Grob *me)
       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);
+  Real minimum_length = staff_space * robust_scm2double (me->get_property ("minimum-length"),
+                                                        2.0);
   
   Drul_array<Offset> base_attachment;
 
@@ -258,72 +333,95 @@ New_slur::set_end_points (Grob *me)
   common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
   common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (LEFT), X_AXIS);
 
-  Direction d = LEFT;
-  Drul_array<Grob*> staves;
+
+  Drul_array<Bound_info> extremes;
+  Direction dir = get_grob_direction (me);
   
+  
+  Direction d = LEFT;
   do {
-    Grob *stem = Note_column::get_stem (extremes[d]);
-    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);
+    extremes[d].bound_ = dynamic_cast<Spanner*> (me)->get_bound (d);
+      
+    if (Note_column::has_interface (extremes[d].bound_))
+      {
+       extremes[d].note_column_ = extremes[d].bound_;
+       extremes[d].stem_ = Note_column::get_stem (extremes[d].note_column_);
+       extremes[d].stem_dir_ = get_grob_direction (extremes[d].stem_);
+       extremes[d].stem_extent_[X_AXIS] = extremes[d].stem_->extent (common[X_AXIS], X_AXIS);
+       extremes[d].stem_extent_[Y_AXIS] = extremes[d].stem_->extent (common[Y_AXIS], Y_AXIS);
+       extremes[d].slur_head_ = Stem::extremal_heads (extremes[d].stem_)[dir];
+       extremes[d].slur_head_extent_ = extremes[d].slur_head_->extent (common[X_AXIS], X_AXIS);
+       extremes[d].staff_ = Staff_symbol_referencer::get_staff_symbol (extremes[d].slur_head_);
+      }
+    else
+      {
+       extremes[d].neighbor_y_ = broken_trend_y (me, common, d);
+      }
   } while (flip (&d) != LEFT);
   
   do
     {
-      // c&p
-      Grob *stem = Note_column::get_stem (extremes[d]);
-      Grob * h = Stem::extremal_heads (stem)[dir];
-      Real y;
-      if (stem
-       && get_grob_direction (stem) == dir
-       && Stem::get_beam (stem))
+      Grob *stem = extremes[d].stem_;
+      Grob *head = extremes[d].slur_head_;
+      
+      Real x,y;
+      if (!extremes[d].note_column_)
        {
-         y = stem->extent (common[Y_AXIS], Y_AXIS)[dir];
+         y = extremes[d].neighbor_y_;
+         if (d== RIGHT)
+           x = extremes[d].bound_->extent (common[X_AXIS], X_AXIS)[d];
+         else
+           x = sp->get_broken_left_end_align ();
        }
       else
        {
-         y = h->extent (common[Y_AXIS], Y_AXIS)[dir];
-       }
-
-      y += dir * 0.5 * staff_space;
-
-      Grob * staff = Staff_symbol_referencer::get_staff_symbol (h);
-      Real pos = 2.0 * (y - staff->relative_coordinate (common[Y_AXIS], Y_AXIS))
-       / Staff_symbol::staff_space (staff);
-
-      
-      /*
-       start off staffline.
-      */
-      if (fabs (pos - round (pos)) < 0.2
-         && Staff_symbol_referencer::on_staffline (h, (int) rint (pos))
-         && Staff_symbol_referencer::line_count (h) -1 >= rint (pos)
-         )
+         if (stem
+             && extremes[d].stem_dir_ == dir
+             && Stem::get_beaming (stem, -d)
+             && columns.size () > 2
+             )
+           {
+             y = extremes[d].stem_extent_[Y_AXIS][dir];
+           }
+         else if (head) 
+           {
+             y = head->extent (common[Y_AXIS], Y_AXIS)[dir];
+           }
+         y += dir * 0.5 * staff_space;
+
+         Real pos = 2.0 * (y - extremes[d].staff_->relative_coordinate (common[Y_AXIS], Y_AXIS))
+           / Staff_symbol::staff_space (extremes[d].staff_);
+
+         /*
+           start off staffline.
+         */
+         if (fabs (pos - round (pos)) < 0.2
+             && Staff_symbol_referencer::on_staffline (head, (int) rint (pos))
+             && Staff_symbol_referencer::line_count (head) -1 >= rint (pos)
+             )
            y += staff_space * dir / 10 ;         
-
-      
       
-      Grob * fh = Note_column::first_head (extremes[d]);
-      Real x = fh->extent (common[X_AXIS],  X_AXIS).linear_combination (CENTER);
-
-      if (get_grob_direction (stem) == dir
-         && dir == -d)
-       {
-         x -=  d * fh->extent(fh, X_AXIS).length ();
+         Grob * fh = Note_column::first_head (extremes[d].note_column_);
+         x = fh->extent (common[X_AXIS],  X_AXIS).linear_combination (CENTER);
        }
-    
       base_attachment[d] = Offset (x, y);
 
     } 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])));
+    if (extremes[d].note_column_)
+      {
+       end_ys[d] =  dir * ((dir * (base_attachment[d][Y_AXIS] + 4.0 *dir))
+                           >? (dir * (dir + extremes[d].note_column_->extent(common[Y_AXIS],Y_AXIS)[dir]))
+                           >? (dir * base_attachment[-d][Y_AXIS])
+                           );
+      }
+    else
+      {
+       end_ys[d] = extremes[d].neighbor_y_ + 4.0 * dir ;
+      }
   } while (flip (&d) != LEFT);
   
   Array<Slur_score> scores;
@@ -333,30 +431,51 @@ New_slur::set_end_points (Grob *me)
   /*ugh.   */
   os[LEFT] = base_attachment[LEFT];
     
-  for (int i = 0; dir * os[LEFT][Y_AXIS] < dir * end_ys[LEFT]; i++)
+  for (int i = 0; dir * os[LEFT][Y_AXIS] <= dir * end_ys[LEFT]; i++)
     {
       os[RIGHT] = base_attachment[RIGHT];
-      for (int j = 0; dir *os[RIGHT][Y_AXIS] < dir * end_ys[RIGHT]; j++)
+      for (int j = 0; dir *os[RIGHT][Y_AXIS] <= dir * end_ys[RIGHT]; j++)
        {
          Slur_score s;
-         s.attachment_ = os;
+         Direction d = LEFT;
 
+         
+         do {  
+           os[d][X_AXIS] = base_attachment[d][X_AXIS];
+           if (extremes[d].stem_
+               && !Stem::is_invisible (extremes[d].stem_)
+               && extremes[d].stem_dir_ == dir
+               && dir == -d)
+             {
+               if (extremes[d].stem_extent_[Y_AXIS].contains (os[d][Y_AXIS]))
+                 {
+                   os[d][X_AXIS] -=  d * extremes[d].slur_head_extent_.length ();
+                 }
+               else if (dir *extremes[d].stem_extent_[Y_AXIS][dir] < dir * os[d][Y_AXIS])
+                 {
+                   os[d][X_AXIS] = extremes[d].stem_extent_[X_AXIS].center();
+                 }
+             }
+         } while (flip (&d) != LEFT);
+
+         Offset dz = os[RIGHT] - os[LEFT];
+         if (dz[X_AXIS] < minimum_length
+             || fabs (dz[Y_AXIS] / dz[X_AXIS])  > MAX_SLOPE
+             )
+           {
+             do {
+               if (extremes[d].slur_head_)
+                 os[d][X_AXIS] = extremes[d].slur_head_extent_.center ();
+             } while (flip (&d) != LEFT);
+           }
+         
+         s.attachment_ = os;
          scores.push (s);
-
-         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] += incr;      
+         
+         os[RIGHT][Y_AXIS] += 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] += incr;          
+      os[LEFT][Y_AXIS] += dir * staff_space /2 ;
     }
   
   {
@@ -369,8 +488,8 @@ New_slur::set_end_points (Grob *me)
       }
   }
   
-  score_encompass (me, common, base_attachment, &scores);
-  score_slopes (me, common, base_attachment, &scores);
+  score_encompass (me, common, extremes, base_attachment, &scores);
+  score_slopes (me, common, extremes, base_attachment, &scores);
 
   Real opt = 1e6;
   int opt_idx = 0;
@@ -408,7 +527,9 @@ New_slur::set_end_points (Grob *me)
 }
 
 void
-New_slur::score_encompass (Grob * me,  Grob *common[], Drul_array<Offset> base_attach,
+New_slur::score_encompass (Grob * me,  Grob *common[],
+                          Drul_array<Bound_info> extremes,
+                          Drul_array<Offset> base_attach,
                           Array<Slur_score> * scores)
 {
   Link_array<Grob> encompasses =
@@ -416,23 +537,10 @@ New_slur::score_encompass (Grob * me,  Grob *common[], Drul_array<Offset> base_a
   Direction dir = get_grob_direction (me);
  
   Array<Encompass_info> infos;
-  Drul_array<Grob *> extremes (encompasses[0], encompasses.top ());
-
-  int first = 1;
-  int last = encompasses.size () - 2;
 
-  for (int i = first; i <= last; i++)
+  for (int i = 0; i < encompasses.size(); i++)
     infos.push (get_encompass_info (me, encompasses[i], common));
 
-  Drul_array<Grob*> stems;
-  Direction d = LEFT;
-  do {
-    Grob *stem = Note_column::get_stem (extremes [d]);
-    stems[d] = stem;
-  } while (flip (&d) != LEFT);
-
-
   for (int i =0 ; i < scores->size (); i++)
     {
       Bezier const &bez (scores->elem (i).curve_);
@@ -452,7 +560,7 @@ New_slur::score_encompass (Grob * me,  Grob *common[], Drul_array<Offset> base_a
          
          if (dir * (y - infos[j].stem_) < 0)
            demerit += STEM_ENCOMPASS_PENALTY;
-         else
+         else if (j && j < encompasses.size () - 1)  
            {
              Interval ext;
              ext.add_point (infos[j].stem_);
@@ -465,11 +573,10 @@ New_slur::score_encompass (Grob * me,  Grob *common[], Drul_array<Offset> base_a
 
       Direction d = LEFT;
       do {
-
        Real attr =
          EDGE_ATTRACTION_FACTOR
          * fabs (scores->elem (i).attachment_[d][Y_AXIS] - base_attach[d][Y_AXIS]);
-       if (get_grob_direction (stems[d]) == dir)
+       if (extremes[d].stem_ && extremes[d].stem_dir_ == dir)
          attr /= 5;
        
        demerit += attr;
@@ -485,57 +592,52 @@ New_slur::score_encompass (Grob * me,  Grob *common[], Drul_array<Offset> base_a
 
 
 void
-New_slur::score_slopes (Grob * me,  Grob *common[], Drul_array<Offset> base_attach,
+New_slur::score_slopes (Grob * me,  Grob *common[],
+                       Drul_array<Bound_info> extremes,
+                       Drul_array<Offset> base_attach,
                        Array<Slur_score> * scores)
 {
- Link_array<Grob> columns =
-    Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns");
-
-  Drul_array<Grob *> extremes (columns[0], columns.top ());
   Direction dir = get_grob_direction (me);
   Drul_array<Real> ys;
 
   Direction d = LEFT;
-  Drul_array<Direction> stem_dirs;
-  Drul_array<bool> beams;
   do {
-    Grob *stem = Note_column::get_stem (extremes [d]);
-    ys[d] = Stem::extremal_heads (stem)[Direction (dir)]
-      ->relative_coordinate (common[Y_AXIS], Y_AXIS);
 
-    stem_dirs[d] = get_grob_direction (stem);
-    beams[d] = Stem::get_beam (stem);
+    if (extremes[d].slur_head_)
+      ys[d] = extremes[d].slur_head_ ->relative_coordinate (common[Y_AXIS], Y_AXIS);
+    else
+      ys[d] = extremes[d].neighbor_y_;
   } while (flip (&d) != LEFT);
 
-  Real dx = extremes[RIGHT]->relative_coordinate (common[X_AXIS],X_AXIS)
-    - extremes[LEFT]->relative_coordinate (common[X_AXIS],X_AXIS);
+  bool has_beams =
+    (extremes[LEFT].stem_ && Stem::get_beam (extremes[LEFT].stem_))
+    || (extremes[RIGHT].stem_ && Stem::get_beam (extremes[RIGHT].stem_));
 
   Real dy = ys[RIGHT] - ys[LEFT];
   for (int i =0 ; i < scores->size (); i++)
     {
-      Real slur_dy = (*scores)[i].attachment_[RIGHT][Y_AXIS]
-       -  (*scores)[i].attachment_[LEFT][Y_AXIS];
+      Offset slur_dz = (*scores)[i].attachment_[RIGHT]
+       -  (*scores)[i].attachment_[LEFT];
 
-      Real demerit = 0.0;
+      Real slur_dy = slur_dz[Y_AXIS]; 
 
 
-      if(! (beams[LEFT] || beams[RIGHT]))
+      Real demerit = 0.0;
+
+      if (!has_beams)
        demerit += STEEPER_SLOPE_FACTOR *  (dir * (fabs (slur_dy) - fabs (dy)) >? 0);
 
-      demerit += ((fabs (slur_dy/dx) - MAX_SLOPE)>?0)  * MAX_SLOPE_FACTOR;
+      demerit += ((fabs (slur_dy/slur_dz[X_AXIS]) - MAX_SLOPE)>?0)  * MAX_SLOPE_FACTOR;
       
       if (sign (dy) == 0 &&
          sign (slur_dy) != 0)
        demerit += NON_HORIZONTAL_PENALTY;
 
-       
-
       if (sign (dy)
          && sign (slur_dy)
          && sign (slur_dy) != sign (dy))
        demerit +=
-         (beams[LEFT] || beams[RIGHT])
-         ? SAME_SLOPE_PENALTY/10 : SAME_SLOPE_PENALTY;
+         has_beams ? SAME_SLOPE_PENALTY/10 : SAME_SLOPE_PENALTY;
       
 #if DEBUG_SLUR_QUANTING
       (*scores)[i].score_card_ += to_string ("S%.2f",d);
@@ -559,13 +661,6 @@ New_slur::get_curve (Grob*me)
 }
 
 
-
-
-
-
-/*
-  ugh ?
- */
 MAKE_SCHEME_CALLBACK (New_slur, height, 2);
 SCM
 New_slur::height (SCM smob, SCM ax)
@@ -619,7 +714,8 @@ New_slur::print (SCM smob)
 
 #if DEBUG_SLUR_QUANTING
   SCM quant_score = me->get_property ("quant-score");
-  if (// debug_beam_quanting_flag      &&
+  
+  if (debug_beam_quanting_flag      &&
       ly_c_string_p (quant_score))
     {
       String str;
index 5a7c6cee19b8a8ce0b69802c552b3a1586119e4e..f89e27698aa588e2c8b44fa754c7cdc718c8c1a6 100644 (file)
@@ -126,12 +126,15 @@ LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val),
     lily_1_8_relative = false;
   else if (var == ly_symbol2scm ("debug-beam"))
     {
-      extern bool debug_beam_quanting_flag;
       debug_beam_quanting_flag = true;
     }
   else
-    warning (_f ("No such internal option: %s", ly_scm2string (var)));
-
+    {
+      if (ly_c_symbol_p (var))
+       var = scm_symbol_to_string (var);
+      
+      warning (_f ("No such internal option: %s", ly_scm2string (var)));
+    }
   return SCM_UNSPECIFIED;
 }
 
index 1d723e72b2ee58348099f66e76141eebbbe99e3c..9ea8812c8d1cc55b603295861a15f955e1d0a67e 100644 (file)
@@ -52,6 +52,18 @@ Stem::set_beaming (Grob *me, int beam_count, Direction d)
   index_set_cell (pair, d, lst);
 }
 
+int
+Stem::get_beaming (Grob *me, Direction d)
+{
+  SCM pair = me->get_property ("beaming");
+  if (!ly_c_pair_p (pair))
+    return 0;
+
+  SCM lst = index_get_cell (pair, d);
+  return scm_ilength (lst);
+}
+
+
 Interval
 Stem::head_positions (Grob *me)
 {
index 57d5c0b92ffc5ef7dc0ac460dfed8b8a3b164cca..4a1b44c656b219979a97e706c45af82de17f0595 100644 (file)
 
     (Slur
      . (
-       (print-function . ,New_slur::print)
-                       ,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)
-                                     ,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)
-                          ;; must be of type procedure
-                          ,Slur::height)
+                          ,New_slur::height)
+                                       ; Slur::height)
        (height-limit . 2.0)
        (ratio . 0.333)
        (beautiful . 0.5)