]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/new-slur.cc (score_encompass): variable head-distance penalty.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 18 Jul 2004 11:24:44 +0000 (11:24 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 18 Jul 2004 11:24:44 +0000 (11:24 +0000)
* lily/stem.cc (height): call Beam::after_line_breaking().

* lily/rest-collision.cc (force_shift_callback): only call shift
for columns containing rests.

* lily/new-slur.cc (print): use debug-slur-quanting paper var.

* input/regression/font-postscript.ly: invoke afm2tfm.

ChangeLog
Documentation/user/changing-defaults.itely
input/regression/font-postscript.ly
input/regression/new-slur.ly
lily/new-slur.cc
lily/rest-collision.cc
lily/stem.cc

index 98ec448363a97d1ac295857792aaa3fbd567e2b2..3932c3684287857d52b9efba6464e518f3a374f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-07-18  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * lily/new-slur.cc (score_encompass): variable head-distance penalty.
+
+       * lily/stem.cc (height): call Beam::after_line_breaking().
+
+       * lily/rest-collision.cc (force_shift_callback): only call shift
+       for columns containing rests.
+
+       * lily/new-slur.cc (print): use debug-slur-quanting paper var.
+
+       * input/regression/font-postscript.ly: invoke afm2tfm. 
+
 2004-07-18  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * mf/SConscript: Build map files.
index 619f897ffc33d771a45c3e30f1101bc8c7b594d2..5f6e72f11d88c0aed1c4183e2b4a68bb2ddd6230 100644 (file)
@@ -433,7 +433,7 @@ entered separately,
 
 @verbatim
 music = \notes { c4 c4 }
-arts = \notes  { s4-. s4-> }
+arts = \notes { s4-. s4-> }
 @end verbatim
 
 They are combined by sending both to the same @context{Voice} context,
@@ -444,7 +444,7 @@ They are combined by sending both to the same @context{Voice} context,
   >>
 @end verbatim
 @lilypond[raggedright]
-music = \notes { c4 c4 }
+music = \notes { c4  50 c4 }
 arts = \notes  { s4-. s4-> }
 \score {
   \notes \relative c''  << \new Staff \context Voice = "A" \music
index 795d360660333ca1ff4b0df358d97d3c704d4f62..71110e782bdc716745e9fde23712ca376813a890 100644 (file)
@@ -3,12 +3,10 @@
     texidoc = "This file demonstrates how to load different
     (postscript) fonts. The file @file{font.scm} shows how to define
     the scheme-function called."
-
 }
 
 \bookpaper
 {
-
     #(define text-font-defaults
       '((font-encoding . latin1)
        (baseline-skip . 2)
     #(set! fonts (make-century-schoolbook-tree 1.0))
 }
 
+%ugh.
+% do this here so we don't forget the connection with
+% this file.
+#(system "afm2tfm `kpsewhich uncb8a.afm` uncb8a.tfm") 
+
 \paper {
     linewidth = 160 \mm - 2.0 * 9.0 \mm
 
index a840a56f0edcb1c8a28233a336047b76e56bffa3..4547c9a5a612435ff40995fcd4bdebfaa8df6a10 100644 (file)
     }
     d8.[) c16]
     d8.[ \grace f16( e16)]
-    
+
+
+    << {c=''8.([ es16] bes4~bes )}
+       \\
+       {r8  <as es> r <f des> r }
+   >>
     
     f'=''16( e)    d( c)
     c'=''2(~c8 d16 c b8 a)
-    f='4
-    <c g>4 ( f <g b>)
+    f='4 f
+    <c g>4 ( f <g b>)
      f
     <c g>^( f <g b>)
     f
index 42c8d957561c6c5cfcc1748cae919469e701b6fb..42cfa6c8afdeca64aa2022e2e5da36974e073104 100644 (file)
@@ -36,8 +36,7 @@
   - curve around flag/stem for x coordinate
   - better scoring.
   
- */
-
+*/
 struct Encompass_info {
   Real x_;
   Real stem_;
@@ -87,7 +86,7 @@ const Real NON_HORIZONTAL_PENALTY = 15;
 const Real HEAD_STRICT_FREE_SPACE = 0.2;
 const Real MAX_SLOPE = 1.1;
 const Real MAX_SLOPE_FACTOR = 10;
-
+const Real FREE_HEAD_DISTANCE = 0.5 ;
 
 #define DEBUG_SLUR_QUANTING 1
 
@@ -115,6 +114,10 @@ public:
                            Drul_array<Offset> base_attach,
                            Array<Slur_score> * scores);
   
+  static void score_edges (Grob * me,  Grob *common[],
+                 Drul_array<Bound_info> extremes,
+                 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);
@@ -488,8 +491,9 @@ New_slur::set_end_points (Grob *me)
       }
   }
   
-  score_encompass (me, common, extremes, base_attachment, &scores);
+  score_edges (me, common, extremes, base_attachment, &scores);
   score_slopes (me, common, extremes, base_attachment, &scores);
+  score_encompass (me, common, extremes, base_attachment, &scores);
 
   Real opt = 1e6;
   int opt_idx = 0;
@@ -502,6 +506,38 @@ New_slur::set_end_points (Grob *me)
        }
     }
   
+
+#if DEBUG_SLUR_QUANTING
+  SCM inspect_quants = me->get_property ("inspect-quants");
+  if (to_boolean (me->get_paper ()->lookup_variable (ly_symbol2scm ("debug-slur-quanting")))
+      && ly_c_pair_p (inspect_quants))
+    {
+      Drul_array<Real> ins = ly_scm2interval (inspect_quants);
+      int i = 0;
+
+      Real mindist = 1e6;
+      for (; i < scores.size (); i ++)
+       {
+         Real d =fabs (scores[i].attachment_[LEFT][Y_AXIS] - ins[LEFT])
+           + fabs (scores[i].attachment_[RIGHT][Y_AXIS] - ins[RIGHT]);
+         if (d < mindist)
+           {
+             opt_idx = i;
+             mindist= d;
+           }
+       }
+      if (mindist > 1e5)
+       programming_error ("Could not find quant.");
+    }
+  
+  
+ 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 ()));
+#endif
+  
   Bezier const &b =  scores[opt_idx].curve_;
   
   SCM controls = SCM_EOL;
@@ -516,14 +552,6 @@ New_slur::set_end_points (Grob *me)
 
   me->set_property ("control-points", controls);
 
-#if DEBUG_SLUR_QUANTING
- 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 ()));
-#endif
-  
 }
 
 void
@@ -550,13 +578,24 @@ New_slur::score_encompass (Grob * me,  Grob *common[],
          Real x = infos[j].x_;
 
          if (!(x < scores->elem (i).attachment_[RIGHT][X_AXIS]
-               &&x > scores->elem (i).attachment_[LEFT][X_AXIS]))
+               && x > scores->elem (i).attachment_[LEFT][X_AXIS]))
            continue;
          
          Real y = bez.get_other_coordinate (X_AXIS, x);
+         Real head_dy = (y - infos[j].head_);
+         if (dir * head_dy < 0)
+           {
+             demerit += HEAD_ENCOMPASS_PENALTY;
+           }
+         else 
+           {
+             Real hd =  
+               (head_dy) ? (1/(fabs (head_dy)  - 1/FREE_HEAD_DISTANCE))
+               : HEAD_ENCOMPASS_PENALTY;
+             hd = (hd >? 0)<? HEAD_ENCOMPASS_PENALTY; 
 
-         if (dir * (y - infos[j].head_) < 0)
-           demerit += HEAD_ENCOMPASS_PENALTY;
+             demerit += hd;      
+           }
          
          if (dir * (y - infos[j].stem_) < 0)
            demerit += STEM_ENCOMPASS_PENALTY;
@@ -571,30 +610,65 @@ New_slur::score_encompass (Grob * me,  Grob *common[],
            }
        }
 
+#if DEBUG_SLUR_QUANTING
+      (*scores)[i].score_card_ += to_string ("C%.2f", demerit);
+#endif
+      
+      (*scores)[i].score_ += demerit;
+    }
+}
+
+
+void
+New_slur::score_edges (Grob * me,  Grob *common[],
+                       Drul_array<Bound_info> extremes,
+                       Drul_array<Offset> base_attach,
+                       Array<Slur_score> * scores)
+{
+   Direction dir = get_grob_direction (me);
+  for (int i =0 ; i < scores->size (); i++)
+    {
+  
       Direction d = LEFT;
       do {
-       Real attr =
-         EDGE_ATTRACTION_FACTOR
-         * fabs (scores->elem (i).attachment_[d][Y_AXIS] - base_attach[d][Y_AXIS]);
-
-       if (extremes[d].stem_
-           && extremes[d].stem_dir_ == dir
-           && !Stem::get_beaming (extremes[d].stem_, -d)
-           )
-         attr /= 5;
+       Real y = scores->elem (i).attachment_[d][Y_AXIS];
+       Real dy = fabs (y - base_attach[d][Y_AXIS]);
        
-       demerit += attr;
-      } while (flip (&d) != LEFT);
+       Real factor = EDGE_ATTRACTION_FACTOR;
 
+#if 0
+       if (extremes[d].stem_ && extremes[d].stem_dir_ == dir)
+         {
+           if (!extremes[d].stem_extent_[Y_AXIS].contains (y))
+             {
+               dy = fabs (extremes[d].stem_extent_[Y_AXIS][dir] - y);
+             }
+           else
+             factor *= 0.3; 
+         }
+       Real demerit = dy * factor;
+#else
+       Real demerit =
+         EDGE_ATTRACTION_FACTOR
+         * fabs (scores->elem (i).attachment_[d][Y_AXIS] - base_attach[d][Y_AXIS]);
+       if (extremes[d].stem_
+           && extremes[d].stem_dir_ == dir
+           && !Stem::get_beaming (extremes[d].stem_, -d)
+           )
+         demerit /= 5;
+       
+#endif
+       
+       (*scores)[i].score_ += demerit;
 #if DEBUG_SLUR_QUANTING
-      (*scores)[i].score_card_ += to_string ("E%.2f", demerit);
+       (*scores)[i].score_card_ += to_string ("E%.2f", demerit);
 #endif
-      
-      (*scores)[i].score_ += demerit;
+      } while (flip (&d) != LEFT);
     }
 }
 
-
 void
 New_slur::score_slopes (Grob * me,  Grob *common[],
                        Drul_array<Bound_info> extremes,
@@ -715,7 +789,7 @@ New_slur::print (SCM smob)
 #if DEBUG_SLUR_QUANTING
   SCM quant_score = me->get_property ("quant-score");
   
-  if (debug_beam_quanting_flag      &&
+  if (to_boolean (me->get_paper ()->lookup_variable (ly_symbol2scm ("debug-slur-quanting"))) &&
       ly_c_string_p (quant_score))
     {
       String str;
index 83354c3a50541462b02e2145061699bbeef55e84..992b12b0e56dd4c59863099206cc5055dd6c1c59 100644 (file)
@@ -28,15 +28,16 @@ Rest_collision::force_shift_callback (SCM element_smob, SCM axis)
   Axis a = (Axis) ly_scm2int (axis);
   assert (a == Y_AXIS);
 
-  Grob * rc = unsmob_grob (them->get_property ("rest-collision"));
+  if (Note_column::has_rests (them))
+    {  
+      Grob * rc = unsmob_grob (them->get_property ("rest-collision"));
 
-  if (rc && !to_boolean (rc->get_property ("positioning-done")))
-    {
-      rc->set_property ("positioning-done", SCM_BOOL_T);
-
-      do_shift (rc);
-    }
-  
+      if (rc && !to_boolean (rc->get_property ("positioning-done")))
+       {
+         rc->set_property ("positioning-done", SCM_BOOL_T);
+         do_shift (rc);
+       }
+    }  
   return scm_make_real (0.0);
 }
 
index 9ea8812c8d1cc55b603295861a15f955e1d0a67e..64f8981b230e21fcf438f5713082c5f1e6840031 100644 (file)
@@ -499,6 +499,16 @@ Stem::height (SCM smob, SCM ax)
   Grob *me = unsmob_grob (smob);
   assert (a == Y_AXIS);
 
+  /*
+    ugh. - this dependency should be automatic.
+  */
+  Grob *beam= get_beam (me);
+  if (beam)
+    {
+      Beam::after_line_breaking (beam->self_scm ());
+    }
+  
+
   SCM mol = me->get_uncached_stencil ();
   Interval iv;
   if (mol != SCM_EOL)