]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.5.41.jcn1
authorJan Nieuwenhuizen <janneke@gnu.org>
Sat, 16 Mar 2002 15:04:22 +0000 (16:04 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sat, 16 Mar 2002 15:04:22 +0000 (16:04 +0100)
2002-03-16  Jan Nieuwenhuizen  <janneke@gnu.org>

* lily/beam.cc (least_squares): Remember least-squares-dy for
later use.
(quantise_interval): Don't quant to dy steeper that
least-squares-dy.  Return empty interval if no sane quants found.
(quantise_position): Try quantise_interval until we have
acceptable solution.

2002-03-15  Jan Nieuwenhuizen  <janneke@gnu.org>

* scm/interface-description.scm (beam-interface): Update.

---
Generated by janneke@gnu.org,
From = lilypond-1.5.41, To = lilypond-1.5.41.jcn1

usage

    cd lilypond-source-dir; patch -E -p1 < lilypond-1.5.41.jcn1.diff

Patches do not contain automatically generated files
or (urg) empty directories,
i.e., you should rerun autoconf, configure

ChangeLog
VERSION
lily/beam.cc
scm/beam.scm
scm/grob-description.scm
scm/interface-description.scm

index 65cb32d32288b10b361be2dcf2afee0a6e98ba18..46d1ad78bc9afb27818075a56f76732b6273ed90 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,22 @@
-2002-03-15  Mats Bengtsson  <mats.bengtsson@s3.kth.se>
+--- ../lilypond-1.5.41/ChangeLog       Fri Mar 15 15:44:50 2002
+++ b/ChangeLog Sat Mar 16 16:04:22 2002
+@@ -1,3 +1,16 @@
+2002-03-16  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * lily/beam.cc (least_squares): Remember least-squares-dy for
+       later use.
+       (quantise_interval): Don't quant to dy steeper that
+       least-squares-dy.  Return empty interval if no sane quants found.
+       (quantise_position): Try quantise_interval until we have
+       acceptable solution.
+
+2002-03-15  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * scm/interface-description.scm (beam-interface): Update.
+
+ 2002-03-15  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+       * VERSION: 1.5.41 released2002-03-15  Mats Bengtsson  <mats.bengtsson@s3.kth.se>
 
        * buildscripts/lilypond-profile.sh: 
 
diff --git a/VERSION b/VERSION
index 8aa52a92e871f98d5495cb3fcef1e33bfcb0da97..a8b541224c54108fb962dc93c84700d6cb178fb5 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=5
 PATCH_LEVEL=41
-MY_PATCH_LEVEL=mb1
+MY_PATCH_LEVEL=jcn1
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index 9f15cdc24e67c5462845080eb7c0107762bb3e14..67d9b664ce3f0fce0dc1022535d2283d2c8af30d 100644 (file)
@@ -368,6 +368,8 @@ Beam::least_squares (SCM smob)
 
       Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0;
       Real dy = dydx * dx;
+      me->set_grob_property ("least-squares-dy", gh_double2scm (dy * dir));
+
       pos = Interval (y*dir, (y+dy) * dir);
     }
 
@@ -428,6 +430,7 @@ Beam::check_concave (SCM smob)
       Interval pos = ly_scm2interval (me->get_grob_property ("positions"));
       Real r = pos.linear_combination (0);
       me->set_grob_property ("positions", ly_interval2scm (Interval (r, r)));
+      me->remove_grob_property ("least-squares-dy");
     }
 
   return SCM_UNSPECIFIED;
@@ -477,36 +480,38 @@ Beam::quantise_interval (Grob *me, Interval pos, Direction quant_dir)
 
   Real staff_space = Staff_symbol_referencer::staff_space (me);
   Real thick = me->paper_l ()->get_var ("stafflinethickness");
-
-  /* TODO:
-
-     - left and right should be different, depending on direction and
-     multiplicity
-
-     -use different left-position-quant-function,
-     right-position-quant-function for handier slope quanting? */
-  SCM proc = me->get_grob_property ("vertical-position-quant-function");
-  SCM quants = scm_apply (proc,
-                         me->self_scm (),
-                         scm_list_n (gh_int2scm (multiplicity),
-                                     gh_double2scm (1), /* junkme */
-                                     gh_double2scm (thick / staff_space),
-                                     /* HUH? */
-                                     SCM_EOL,
-                                     SCM_UNDEFINED));
-  
-  Array<Real> a;
-  for (SCM i = quants; gh_pair_p (i); i = ly_cdr (i))
-    a.push (gh_scm2double (ly_car (i)));
-  
-  if (a.size () <= 1)
-    return pos;
-
   Direction dir = Directional_element_interface::get (me);
-  Interval left = quantise_iv (a, pos[LEFT]*dir/staff_space) * staff_space;
-  Interval right = quantise_iv (a, pos[RIGHT]*dir/staff_space) * staff_space;
-  
   Real dy = pos.delta ();
+
+  Drul_array<Interval> bounds;
+  Direction d = LEFT;
+  do
+    {
+      SCM proc = d == LEFT
+       ? me->get_grob_property ("left-position-quant-function")
+       : me->get_grob_property ("right-position-quant-function");
+      
+      SCM quants = scm_apply (proc,
+                             me->self_scm (),
+                             scm_list_n (gh_int2scm (multiplicity),
+                                         gh_double2scm (dir),
+                                         gh_double2scm (dy),
+                                         gh_double2scm (thick / staff_space),
+                                         /* HUH? */
+                                         SCM_EOL,
+                                         SCM_UNDEFINED));
+      
+      Array<Real> a;
+      for (SCM i = quants; gh_pair_p (i); i = ly_cdr (i))
+       a.push (gh_scm2double (ly_car (i)));
+      
+      if (a.size () <= 1)
+       return pos;
+      
+      bounds[d] = quantise_iv (a, pos[d]*dir/staff_space) * staff_space;
+    }
+  while (flip (&d) != LEFT);
+  
   Real ady = abs (dy);
 
   // quant direction hints disabled for now
@@ -518,18 +523,28 @@ Beam::quantise_interval (Grob *me, Interval pos, Direction quant_dir)
      (save that value?)
      Slope should never be reduced to zero.
    */
-  Interval qpos (0, 20.0 *sign (dy));
+  SCM s = me->get_grob_property ("least-squares-dy");
+  Real lsdy = gh_number_p (s) ? gh_scm2double (s) : 0;
+    
+  //  Interval qpos (0, 1000 * sign (dy));
+  Interval qpos;
+  Real epsilon = staff_space / 10;
   Direction ldir = LEFT;
   do
     {
       Direction rdir = LEFT;
       do
        {
-         Interval i (left[ldir]*dir, right[rdir]*dir);
-         if ((abs (abs (i.delta ()) - ady) <= abs (abs (qpos.delta ()) - ady)
-       && sign (i.delta ()) == sign (pos.delta ())
-       && (!q
-          || (i[LEFT]*q >= pos[LEFT]*q && i[RIGHT]*q >= pos[RIGHT]*q))))
+         Interval i (bounds[LEFT][ldir]*dir, bounds[RIGHT][rdir]*dir);
+         if ((!lsdy
+              || (abs (i.delta ()) <= abs (lsdy) + epsilon
+                  && sign (i.delta ()) == sign (lsdy)))
+             && (abs (abs (i.delta ()) - ady)
+                 <= abs (abs (qpos.delta ()) - ady))
+             && sign (i.delta ()) == sign (pos.delta ())
+             && (!q
+                 || (i[LEFT]*q >= pos[LEFT]*q && i[RIGHT]*q
+                     >= pos[RIGHT]*q)))
            qpos = i;
        }
       while (flip (&rdir) != LEFT);
@@ -551,11 +566,30 @@ Beam::quantise_position (SCM smob)
   Interval pos = ly_scm2interval (me->get_grob_property ("positions"));
   Real y_shift = check_stem_length_f (me, pos);
   pos += y_shift;
-  pos = quantise_interval (me, pos, CENTER);
+  Real staff_space = Staff_symbol_referencer::staff_space (me);
+
+  Direction dir = Directional_element_interface::get (me);
+  for (int i = 0; i < 10; i++)
+    {
+      Interval qpos = quantise_interval (me, pos, CENTER);
+      // how to check for uninitised interval,  (inf, -inf)?
+      if (qpos[LEFT] < 1000)
+       {
+         y_shift = check_stem_length_f (me, qpos);
+         if (y_shift * dir < staff_space / 2)
+           {
+             pos = qpos;
+             break;
+           }
+       }
+      pos += ((i + 1) * ((i % 2) * -2 + 1)) *  dir * staff_space / 4;
+    }
+      
   
   me->set_grob_property ("positions", ly_interval2scm (pos));
   set_stem_lengths (me);
 
+#if 0  
   pos = ly_scm2interval (me->get_grob_property ("positions"));
   
   y_shift = check_stem_length_f (me, pos);
@@ -575,7 +609,8 @@ Beam::quantise_position (SCM smob)
     }
   
   me->set_grob_property ("positions", ly_interval2scm (pos));
-
+#endif
+  
   return SCM_UNSPECIFIED;
 }
 
@@ -668,13 +703,23 @@ Beam::check_stem_length_f (Grob *me, Interval pos)
 
       if (info.idealy_f_ - stem_y > 0)
        {
+#if 0    
          ideal_lengthen += info.idealy_f_ - stem_y;
          ideal_lengthen_count++;
+#else
+         ideal_lengthen = ideal_lengthen >? info.idealy_f_ - stem_y;
+         ideal_lengthen_count = 1;
+#endif   
        }
       else if (info.idealy_f_ - stem_y < 0)
        {
+#if 0    
          ideal_shorten += info.idealy_f_ - stem_y;
          ideal_shorten_count++;
+#else
+         ideal_shorten = ideal_shorten <? info.idealy_f_ - stem_y;
+         ideal_shorten_count = 1;
+#endif   
        }
     }
   
index efcc28835eafde51a5fd3543f14590bc9e55e91b..92da1b0b96d33abd0c84a476e90a45e4ac66dfd3 100644 (file)
     ;; period: 1 (staff-space)
     (append quants (list (+ 1 (car quants))))))
 
+(define (default-left-beam-pos-quants beam multiplicity dir dy staff-line)
+  (default-beam-pos-quants beam multiplicity 1 staff-line))
+    
+(define (foo beam multiplicity dir dy staff-line)
+  (let* ((beam-straddle 0)
+        (thick (ly-get-grob-property beam 'thickness))
+        (beam-sit (/ (- thick staff-line) 2))
+        (beam-hang (- 1 (/ (- thick staff-line) 2)))
+        (quants '())
+        )
+
+    (if (or (<= multiplicity 1)
+           (and (not (equal? dir 1))
+                (not (< dy 0))))
+       (set! quants (cons beam-sit quants)))
+    (if (or (<= multiplicity 1)
+           (and (not (equal? dir -1))
+                (not (> dy 0))))
+       (set! quants (cons beam-hang quants)))
+    (if (or (<= multiplicity 2) (>= (abs dy) (/ staff-line 2)))
+       (set! quants (cons beam-straddle quants)))
+    ;; period: 1 (staff-space)
+    (append quants (list (+ 1 (car quants))))))
+
+(define (default-right-beam-pos-quants beam multiplicity dir dy staff-line)
+  (default-beam-pos-quants beam multiplicity 1 staff-line))
+
+(define (foo beam multiplicity dir dy staff-line)
+  (let* ((beam-straddle 0)
+        (thick (ly-get-grob-property beam 'thickness))
+        (beam-sit (/ (- thick staff-line) 2))
+        (beam-hang (- 1 (/ (- thick staff-line) 2)))
+        (quants '())
+        )
+
+    
+    (if (or (<= multiplicity 1)
+           (and (not (equal? dir 1))
+                (not (> dy 0))))
+       (set! quants (cons beam-sit quants)))
+    (if (or (<= multiplicity 1)
+           (and (not (equal? dir -1))
+                (not (< dy 0))))
+       (set! quants (cons beam-hang quants)))
+    (if (or (<= multiplicity 2) (>= (abs dy) (/ staff-line 2)))
+       (set! quants (cons beam-straddle quants)))
+    ;; period: 1 (staff-space)
+    (append quants (list (+ 1 (car quants))))))
+
 (define (beam-traditional-pos-quants beam multiplicity dy staff-line)
   (let* ((beam-straddle 0)
        (thick (ly-get-grob-property beam 'thickness))
index fcb3f3b90f4b91207151a4366afc50f8ba4a45f5..c583c4c7cf0e8597778ed96ea0b0105bd0f23812 100644 (file)
                                         ,Beam::end_after_line_breaking))
        (neutral-direction . -1)
        (dir-function . ,beam-dir-majority)
-       (vertical-position-quant-function . ,default-beam-pos-quants)
+       (left-position-quant-function . ,default-left-beam-pos-quants)
+       (right-position-quant-function . ,default-right-beam-pos-quants)
        (beamed-stem-shorten . (1.0 0.5))
        (outer-stem-length-limit . 0.2)
        (slope-limit . 0.2)
      . (
        (molecule-callback . ,Staff_symbol::brew_molecule)
        (staff-space . 1.0)
-       (line-count . 5)
+       (line-count . 15)
        (layer . 0)
        (meta . ,(grob-description staff-symbol-interface ))
        ))
index dd05c80db01e02f0df3ca9ea91474e7840e40f8b..38499a65b4cab1f0481e418f7de893d2eb1b3136 100644 (file)
 #'thickness= weight of beams, in staffspace
   "
  '(auto-knee-gap
-   staff-position
-   height
-   flag-width-function 
-   damping 
-   neutral-direction 
-   thickness 
-   space-function 
    beamed-stem-shorten 
-   height-quants 
-   vertical-position-quant-function 
    damping 
+   flag-width-function 
+   neutral-direction 
    outer-stem-length-limit 
+   positions
    slope-limit 
-   auto-knee-gap
+   space-function 
+   thickness 
+   vertical-position-quant-function 
    )
  )