]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/accidental-engraver.cc (process_acknowledged_grobs):
authorhanwen <hanwen>
Sun, 18 Jul 2004 21:15:24 +0000 (21:15 +0000)
committerhanwen <hanwen>
Sun, 18 Jul 2004 21:15:24 +0000 (21:15 +0000)
make accidental appear to come from note head engraver.

* lily/slur-quanting.cc: new file.
(score_extra_encompass): new function. Avoid scripts and
accidentals

ChangeLog
Documentation/topdocs/NEWS.texi
input/regression/new-slur.ly
lily/accidental-engraver.cc
lily/include/accidental-interface.hh
lily/new-slur.cc
lily/slur-engraver.cc
lily/slur-quanting.cc
scm/safe-lily.scm

index 75c32591081e7b40f102c0df9151f315b9536fb1..7b7efdb143429ab2a000e9fa2885e07c0e7a2934 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-07-18  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * lily/accidental-engraver.cc (process_acknowledged_grobs):
+       make accidental appear to come from note head engraver.
+
+       * lily/slur-quanting.cc: new file.
+       (score_extra_encompass): new function. Avoid scripts and
+       accidentals
+
 2004-07-18  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * lily/include/lily-guile.hh: Remove guile-1.4 compatibility.
index 032d8adb6fc5b9c00aa592fadfd5f903d5c83044..a32e0884de70478bbc3f51fe1830db8519a9e9fa 100644 (file)
@@ -8,6 +8,14 @@
 
 @itemize @bullet
 
+@item Slur formatting has been rewritten. The new slur code
+works similar to the Beam formatter: scores are assigned for all
+esthetic components of a slur. A large number of combinations for
+begin and end points is then tried out.  They will now also take into
+account collisions with staff lines, scripts (like staccato and
+accent) and accidentals.
+
+
 @item In the LilyPond  emacs mode, the @code{|} will now display the
   current beat within the measure. 
 
index bb9367eb9a6aba3cfc0d3f14a578fc536636838e..bb269d732bf6be72afa3d1ff046ba56de69930a6 100644 (file)
     c,^( c'' c) 
     c,,^( c'')
     c,,^( c')
+    \once \override Script #'padding = #1.2
+    b-.8( b-.
+    \once \override Script #'padding = #1.2
+
+    b-.)
+    b-.( b-.
+    b-.)
+    s4
     | b='2( a4) s4
     | b='4.( c8) s2
     | << c=''1_(
index 31e0998c9e00e1cb7611c6c9f9260caa7be46e93..d718c032083008c3de5ed02d2ca835093b25f7f0 100644 (file)
@@ -29,6 +29,7 @@ public:
   Music *melodic_;
   Grob *accidental_;
   Context *origin_;
+  Engraver *origin_trans_;
   Grob *head_;
   bool tied_;
 
@@ -317,7 +318,7 @@ Accidental_engraver::process_acknowledged_grobs ()
                Accidental from the respective Voice.
               */
              Grob *a
-               = make_item_from_properties (origin->implementation (),
+               = make_item_from_properties (accidentals_[i].origin_trans_,
                                             ly_symbol2scm ("Accidental"),
                                             note->self_scm ());
              a->set_parent (support, Y_AXIS);
@@ -455,6 +456,7 @@ Accidental_engraver::acknowledge_grob (Grob_info info)
          
          Accidental_entry entry ;
          entry.head_ = info.grob_;
+         entry.origin_trans_ = dynamic_cast<Engraver*> (info.origin_trans_);
          entry.origin_ = info.origin_trans_->context ();
          entry.melodic_ = note;
 
index b0cb49b5a5d6996d1d6c4061027eb2bebc9a3258..f3b2221fd181d0ce79f195b9edaf6d08c533a664 100644 (file)
@@ -10,7 +10,10 @@ source file of the GNU LilyPond music typesetter
 #ifndef ACCIDENTAL_INTERFACE_HH
 #define ACCIDENTAL_INTERFACE_HH
 
-#include "grob.hh"
+#include "box.hh"
+#include "lily-guile.hh"
+#include "lily-proto.hh"
+
 
 class Accidental_interface
 {
index 3ee7f8aec191f696912e5d5c500077fda6446bf0..53a004a16d5ae126d20948d2c96b9a5ec3e7edc1 100644 (file)
@@ -124,8 +124,6 @@ void
 New_slur::add_column (Grob*me, Grob*n)
 {
   Pointer_group_interface::add_grob (me, ly_symbol2scm ("note-columns"), n);
-  me->add_dependency (n);
-
   add_bound_item (dynamic_cast<Spanner*> (me), dynamic_cast<Item*> (n));
 }
 
@@ -134,12 +132,9 @@ void
 New_slur::add_extra_encompass (Grob*me, Grob*n)
 {
   Pointer_group_interface::add_grob (me, ly_symbol2scm ("encompass-objects"), n);
-  me->add_dependency (n);
-
-  add_bound_item (dynamic_cast<Spanner*> (me), dynamic_cast<Item*> (n));
 }
 
 
 ADD_INTERFACE (New_slur, "new-slur-interface",
               "A slur",
-              "extra-encompass control-points dashed details direction height-limit note-columns ratio thickness");
+              "encompass-objects control-points dashed details direction height-limit note-columns ratio thickness");
index 4164777ea2e39d1a770ab50ec586df6fb44d1435..7d7abf2440934e6206ea40f403e576c7cf09f0fd 100644 (file)
@@ -105,7 +105,7 @@ Slur_engraver::acknowledge_grob (Grob_info info)
   else
     {
       for (int i = 0; i < slur_stack_.size (); i++)
-       New_slur::add_extra_encompass (end_slurs_[i], e);
+       New_slur::add_extra_encompass (slur_stack_[i], e);
       for (int i = 0; i < end_slurs_.size (); i++)
        New_slur::add_extra_encompass (end_slurs_[i], e);
     }
@@ -185,9 +185,9 @@ Slur_engraver::stop_translation_timestep ()
 
 
 ENTER_DESCRIPTION (Slur_engraver,
-/* descr */       "Build slurs from Slur_evs",
+/* descr */       "Build slurs grobs from slur events",
 /* creats*/       "Slur",
 /* accepts */     "slur-event",
-/* acks  */      "note-column-interface accidental-interface script-interface",
+/* acks  */      "note-column-interface accidental-interface fingering-interface script-interface",
 /* reads */       "slurMelismaBusy",
 /* write */       "");
index 8748218a1f767d5004603c81b16e4007d4d21e5f..ba4c56b8e59710e319ce9dc91d3137e5e2b19e49 100644 (file)
@@ -10,6 +10,8 @@
 
 #include <math.h>
 
+#include "pitch.hh"
+#include "accidental-interface.hh"
 #include "directional-element-interface.hh"
 #include "group-interface.hh"
 #include "lily-guile.hh"
 #include "warn.hh"
 #include "beam.hh"
 
-
-
-#define DEBUG_SLUR_QUANTING 1
-
 struct Slur_score
 {
   Drul_array<Offset> attachment_;
@@ -45,7 +43,9 @@ struct Slur_score
 };
 
 /*
-  TODO: put in details property.
+  TODO: put in details property.,
+
+  use lowercase.
 */
 struct Slur_score_parameters
 {
@@ -60,6 +60,8 @@ struct Slur_score_parameters
   Real HEAD_STRICT_FREE_SPACE;
   Real MAX_SLOPE;
   Real MAX_SLOPE_FACTOR;
+  Real EXTRA_OBJECT_COLLISION;
+  Real ACCIDENTAL_COLLISION;
   Real FREE_HEAD_DISTANCE;
   Slur_score_parameters ();
 };
@@ -113,6 +115,13 @@ struct Bound_info
 
 
 
+
+static void
+score_extra_encompass (Grob *me, Grob *common[],
+                      Slur_score_parameters *score_param,
+                      Drul_array<Bound_info> ,
+                      Drul_array<Offset> ,
+                      Array<Slur_score> * scores);
 static void score_slopes (Grob *me, Grob *common[],
                          Slur_score_parameters *score_param,
                          Drul_array<Bound_info>,
@@ -172,6 +181,8 @@ init_score_param (Slur_score_parameters *score_param)
   score_param->MAX_SLOPE = 1.1;
   score_param->MAX_SLOPE_FACTOR = 10;
   score_param->FREE_HEAD_DISTANCE = 0.3;
+  score_param->EXTRA_OBJECT_COLLISION = 8;
+  score_param->ACCIDENTAL_COLLISION = 3;
 }
 
 Slur_score_parameters::Slur_score_parameters()
@@ -386,15 +397,23 @@ set_end_points (Grob *me)
     }
 
   SCM eltlist = me->get_property ("note-columns");
-  Grob *common[] = {common_refpoint_of_list (eltlist, me, X_AXIS),
-                   common_refpoint_of_list (eltlist, me, Y_AXIS)};
-
 
+  
+  SCM extra_list = me->get_property ("encompass-objects");
   Spanner *sp = dynamic_cast<Spanner*> (me);
-  common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (RIGHT),
-                                                   X_AXIS);
+
+  Grob *common[] = {0,0};
+  for (int i = X_AXIS; i < NO_AXES; i++)
+    {
+      Axis a = (Axis)i;
+      common[a] = common_refpoint_of_list (eltlist, me, a);
+      common[a] = common_refpoint_of_list (extra_list, common[a], a);
+    }
+  
+  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);
+  
   Drul_array<Bound_info> extremes = get_bound_info (sp, common);
   Drul_array<Offset> base_attachment
     = get_base_attachments (sp, common, extremes);
@@ -408,6 +427,7 @@ set_end_points (Grob *me)
   score_edges (me, common, &params,extremes, base_attachment, &scores);
   score_slopes (me, common, &params,extremes, base_attachment, &scores);
   score_encompass (me, common, &params,extremes, base_attachment, &scores);
+  score_extra_encompass (me, common, &params,extremes, base_attachment, &scores);
   
   Real opt = 1e6;
   int opt_idx = 0;
@@ -809,6 +829,98 @@ score_encompass (Grob *me, Grob *common[],
     }
 }
 
+
+
+void
+score_extra_encompass (Grob *me, Grob *common[],
+                Slur_score_parameters *score_param,
+                Drul_array<Bound_info> ,
+                Drul_array<Offset> ,
+                Array<Slur_score> * scores)
+{
+  Link_array<Grob> encompasses
+    = Pointer_group_interface__extract_grobs (me, (Grob *)0, "encompass-objects");
+  Direction dir = get_grob_direction (me);
+ Real lt =  me->get_paper ()->get_dimension (ly_symbol2scm ("linethickness"));
+  Real thick = robust_scm2double (me->get_property ("thickness"), 1.0) *  lt;
+
+
+  Array<Real> xs;
+  Array<Interval> yexts;
+  for (int i = 0; i < encompasses.size(); i++)
+    {
+      Grob *g = encompasses [i];
+      Interval xe = g->extent (common[X_AXIS], X_AXIS);
+      Interval ye = g->extent (common[Y_AXIS], Y_AXIS);
+
+      Real xp = 0.0;
+      
+      if (Accidental_interface::has_interface (g))
+       {
+         /*
+           C&P accidental.cc
+          */
+         bool parens = false;
+         if (to_boolean (g->get_property ("cautionary")))
+           {
+             SCM cstyle = g->get_property ("cautionary-style");
+             parens = ly_c_equal_p (cstyle, ly_symbol2scm ("parentheses"));
+
+           }
+         
+         SCM accs = g->get_property ("accidentals");
+         SCM scm_style = g->get_property ("style");
+         if (!ly_c_symbol_p (scm_style)
+             && !parens
+             && scm_ilength (accs) == 1)
+           {
+             switch (ly_scm2int (ly_car (accs))) {
+             case FLAT:
+             case DOUBLE_FLAT:
+               xp = LEFT;
+             case SHARP:
+               xp = 0.5* dir;
+             case NATURAL:
+               xp = -dir;
+             }
+           }
+                 
+       }
+      xs.push (xe.linear_combination (xp));
+      ye.widen (.5 * thick);
+      yexts.push (ye);
+    }
+  
+  for (int i = 0; i < scores->size (); i++)
+    {
+      Bezier const &bez (scores->elem (i).curve_);
+      Real demerit = 0.0;
+      for (int j = 0; j < xs.size(); j++)
+       {
+         Real x = xs[j];
+         if (!(x < scores->elem (i).attachment_[RIGHT][X_AXIS]
+               && x > scores->elem (i).attachment_[LEFT][X_AXIS]))
+           continue;
+       
+         Real y = bez.get_other_coordinate (X_AXIS, x);
+         
+         if (yexts[j].contains (y))
+           {
+             if (Accidental_interface::has_interface (encompasses[j]))
+               demerit += score_param->ACCIDENTAL_COLLISION;
+             else 
+               demerit += score_param->EXTRA_OBJECT_COLLISION;
+           }
+       }
+
+#if DEBUG_SLUR_QUANTING
+      (*scores)[i].score_card_ += to_string ("X%.2f", demerit);
+#endif
+      (*scores)[i].score_ += demerit;
+    }
+}
+
+
 void
 score_edges (Grob *me, Grob **,
             Slur_score_parameters * score_param,
@@ -846,7 +958,7 @@ void
 score_slopes (Grob *me, Grob *common[],
              Slur_score_parameters*score_param,
              Drul_array<Bound_info> extremes,
-             Drul_array<Offset> base_attach,
+             Drul_array<Offset> ,
              Array<Slur_score> * scores)
 {
   Drul_array<Real> ys;
index 5a9cbe0348fc04f36abca558aabe443041cd5389..590aefb465bd06ec302e8ea0a702d27351bc2db3 100644 (file)
      Separating_group_spanner::set_spacing_rods
      Side_position_interface::aligned_on_support_refpoints
      Side_position_interface::aligned_side
-     Slur::after_line_breaking
-     Slur::height
-     Slur::print
+     New_slur::after_line_breaking
+     New_slur::height
+     New_slur::print
      Spacing_spanner::set_springs
      Span_bar::before_line_breaking
      Span_bar::get_bar_size