]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.3.15.jcn3
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 21 Dec 1999 15:46:17 +0000 (16:46 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 21 Dec 1999 15:46:17 +0000 (16:46 +0100)
- moved poor man's stem arrays to scm

pl 15.jcn2

CHANGES
VERSION
lily/beam.cc
lily/include/lily-guile.hh
lily/include/lily-guile.icc
lily/lily-guile.cc
lily/stem.cc
ly/params.ly
scm/paper.scm

diff --git a/CHANGES b/CHANGES
index cfc164b2bb603044c3ce762474e42798378af5f3..cc642f8d83a74fb3a7c698782eb798e3ca52ca2d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+pl 15.jcn2
+       - moved poor man's stem arrays to scm
+       
 pl 15.jcn2
        - beam quanting using scm lists
 
diff --git a/VERSION b/VERSION
index 8644a073a413cbdd22f6511f8687e0c4db031746..4a05daddf6b3187a29147963b622d1232ad2cca0 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
 PATCH_LEVEL=15
-MY_PATCH_LEVEL=jcn2
+MY_PATCH_LEVEL=jcn3
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index 7305ff69c6f7baf79e11c63918c51fe81157855a..c77b84839ca72d75d9965b18c8663fc6ead8b6ef 100644 (file)
@@ -237,7 +237,9 @@ Beam::auto_knee (String gap_str, bool interstaff_b)
 
 /*
  Set stem's shorten property if unset.
- TODO: take some y-position (nearest?) into account
+ TODO:
+    take some y-position (chord/beam/nearest?) into account
+    scmify forced-fraction
  */
 void
 Beam::set_stem_shorten ()
@@ -250,12 +252,17 @@ Beam::set_stem_shorten ()
     return;
 
   int multiplicity = get_multiplicity ();
-  SCM shorten = scm_eval (gh_list (
-                                  ly_symbol2scm ("beamed-stem-shorten"),
-                                  gh_int2scm (multiplicity),
-                                  SCM_UNDEFINED));
-  Real shorten_f = gh_scm2double (shorten) 
-    * Staff_symbol_referencer_interface (this).staff_space ();
+  // grace stems?
+  SCM shorten = ly_eval_str ("beamed-stem-shorten");
+
+  Array<Real> a;
+  scm_to_array (shorten, &a);
+  if (!a.size ())
+    return;
+
+  Staff_symbol_referencer_interface st (this);
+  Real staff_space = st.staff_space ();
+  Real shorten_f = a[multiplicity <? (a.size () - 1)] * staff_space;
 
   /* cute, but who invented this -- how to customise ? */
   if (forced_fraction < 1)
@@ -270,6 +277,7 @@ Beam::set_stem_shorten ()
        s->set_elt_property ("shorten", gh_double2scm (shorten_f));
     }
 }
+
 /*
   Set elt properties height and y-position if not set.
   Adjust stem lengths to reach beam.
index f66caa760add1770797eed1a08c9168a0e6f986d..53dc8fdc03c5db9495fc882ae97941fadce6ba0f 100644 (file)
@@ -16,7 +16,7 @@
 #include "direction.hh"
 
 SCM ly_str02scm (char const*c);
-SCM ly_eval_str (char const*c);
+SCM ly_eval_str (String s);
 SCM ly_symbol2scm (char const *);
 String ly_symbol2string (SCM);
 SCM ly_set_x (String name , SCM val);
index 1152117f207397fbe943e8ddaed6d29e926e2f40..9fb611a64b017eaa066a7242fd6dbec6d448263e 100644 (file)
@@ -29,6 +29,7 @@ array_to_scm (Array<T> arr)
 template<class T>void
 scm_to_array (SCM s, Array<T>* arr)
 {
+  arr->clear ();
   for (; gh_pair_p (s); s= gh_cdr (s))
     {
       T t;
index be56d94587a97514513ab7c91f778eb9bdec48bb..73043deb0118616e41316030c955c42490576848 100644 (file)
@@ -28,10 +28,10 @@ ly_str02scm (char const*c)
 }
 
 SCM
-ly_eval_str (char const*c)
+ly_eval_str (String s)
 {
   // this all really sucks, guile should take char const* arguments!
-  return gh_eval_str ((char*)c);
+  return gh_eval_str ((char*)s.ch_C ());
 }
 
   
index 7c76a571f65b685ed457121e373f1dd93ec817d1..4ef5b7de2c41f36490227b2bf9c7d067d269c876 100644 (file)
@@ -23,6 +23,7 @@
 #include "group-interface.hh"
 #include "cross-staff.hh"
 #include "staff-symbol-referencer.hh"
+#include "lily-guile.icc"
 
 
 void
@@ -214,6 +215,11 @@ Stem::get_default_dir () const
 Real
 Stem::get_default_stemlen () const
 {
+  bool grace_b = get_elt_property ("grace") != SCM_UNDEFINED;
+  String type_str = grace_b ? "grace-" : "";
+  SCM s;
+  Array<Real> a;
+
   Real length_f = 0.;
   SCM scm_len = get_elt_property("length");
   if (gh_number_p (scm_len))
@@ -221,12 +227,19 @@ Stem::get_default_stemlen () const
       length_f = gh_scm2double (scm_len);
     }
   else
-    length_f = paper_l ()->get_var ("stem_length0");
+    {
+      s = ly_eval_str (type_str + "stem-length");
+      scm_to_array (s, &a);
+      // stem uses half-spaces
+      length_f = a[((flag_i () - 2) >? 0) <? (a.size () - 1)] * 2;
+    }
 
-  bool grace_b = get_elt_property ("grace") != SCM_UNDEFINED;
-  String type_str = grace_b ? "grace_" : "";
 
-  Real shorten_f = paper_l ()->get_var (type_str + "forced_stem_shorten0");
+  s = ly_eval_str (type_str + "stem-shorten");
+  scm_to_array (s, &a);
+
+  // stem uses half-spaces
+  Real shorten_f = a[((flag_i () - 2) >? 0) <? (a.size () - 1)] * 2;
 
   /* URGURGURG
      'set-default-stemlen' sets direction too
@@ -247,6 +260,7 @@ Stem::get_default_stemlen () const
       && (get_direction () != get_default_dir ()))
     length_f -= shorten_f;
 
+#if 0
   /*
     UGK.!
    */
@@ -254,18 +268,20 @@ Stem::get_default_stemlen () const
     length_f += 2.0;
   if (flag_i () >= 6)
     length_f += 1.0;
-
-
+#endif
   
-  Real st = head_positions()[-dir] + dir * length_f;
+  Real st_f = head_positions()[-dir] + dir * length_f;
 
   bool no_extend_b = get_elt_property ("no-stem-extend") != SCM_UNDEFINED;
-  if (!grace_b && !no_extend_b && dir * st < 0)
-    st = 0.0;
+  if (!grace_b && !no_extend_b && dir * st_f < 0)
+    st_f = 0.0;
 
-  return st;
+  return st_f;
 }
 
+/*
+  FIXME: wrong name
+ */
 int
 Stem::flag_i () const
 {
@@ -487,41 +503,46 @@ Stem::calc_stem_info () const
       beam_dir = UP;
     }
     
-  Stem_info info; 
-  Real internote_f
-     = staff_symbol_referencer_interface (this).staff_space ()/2;
+  Staff_symbol_referencer_interface st (this);
+  Real staff_space = st.staff_space ();
+  Real half_space = staff_space / 2;
   Real interbeam_f = paper_l ()->interbeam_f (beam_l ()->get_multiplicity ());
-  Real beam_f = gh_scm2double (beam_l ()->get_elt_property ("beam-thickness"));
-         
+  Real thick = gh_scm2double (beam_l ()->get_elt_property ("beam-thickness"));
+  int multiplicity = beam_l ()->get_multiplicity ();
+
+  Stem_info info; 
   info.idealy_f_ = chord_start_f ();
 
   // for simplicity, we calculate as if dir == UP
   info.idealy_f_ *= beam_dir;
   SCM grace_prop = get_elt_property ("grace");
+
   bool grace_b = gh_boolean_p (grace_prop) && gh_scm2bool (grace_prop);
-  SCM extend_prop = get_elt_property ("no-stem-extend");
-  bool no_extend_b = gh_boolean_p (extend_prop) && gh_scm2bool (extend_prop);
+  
+  Array<Real> a;
+  SCM s;
+  String type_str = grace_b ? "grace-" : "";
+  
+  s = ly_eval_str (type_str + "beamed-stem-minimum-length");
+  scm_to_array (s, &a);
+  Real minimum_length = a[multiplicity <? (a.size () - 1)] * staff_space;
 
-  int stem_max = (int)rint(paper_l ()->get_var ("stem_max"));
-  String type_str = grace_b ? "grace_" : "";
-  Real min_stem_f = paper_l ()->get_var (type_str + "minimum_stem_length"
-    + to_str (beam_l ()->get_multiplicity () <? stem_max)) * internote_f;
-  Real stem_f = paper_l ()->get_var (type_str + "stem_length"
-    + to_str (beam_l ()->get_multiplicity () <? stem_max)) * internote_f;
+  s = ly_eval_str (type_str + "beamed-stem-length");
+  scm_to_array (s, &a);
+  Real stem_length =  a[multiplicity <? (a.size () - 1)] * staff_space;
 
   if (!beam_dir || (beam_dir == get_direction ()))
     /* normal beamed stem */
     {
-      if (beam_l ()->get_multiplicity ())
+      if (multiplicity)
        {
-         info.idealy_f_ += beam_f
-           + (beam_l ()->get_multiplicity () - 1) * interbeam_f;
+         info.idealy_f_ += thick + (multiplicity - 1) * interbeam_f;
        }
       info.miny_f_ = info.idealy_f_;
       info.maxy_f_ = INT_MAX;
 
-      info.idealy_f_ += stem_f;
-      info.miny_f_ += min_stem_f;
+      info.idealy_f_ += stem_length;
+      info.miny_f_ += minimum_length;
 
       /*
        lowest beam of (UP) beam must never be lower than second staffline
@@ -533,33 +554,36 @@ Stem::calc_stem_info () const
        than middle staffline, just as normal stems.
        
       */
+      SCM extend_prop = get_elt_property ("no-stem-extend");
+      bool no_extend_b = gh_boolean_p (extend_prop)
+       && gh_scm2bool (extend_prop);
       if (!grace_b && !no_extend_b)
        {
-         /* highest beam of (UP) beam must never be lower than middle staffline
-            
+         /* highest beam of (UP) beam must never be lower than middle
+            staffline
             lowest beam of (UP) beam must never be lower than second staffline
           */
          info.miny_f_ =
            info.miny_f_ >? 0
-           >? (- 2 * internote_f - beam_f
-               + (beam_l ()->get_multiplicity () > 0) * beam_f
-               + interbeam_f * (beam_l ()->get_multiplicity () - 1));
+           >? (- 2 * half_space - thick
+               + (multiplicity > 0) * thick
+               + interbeam_f * (multiplicity - 1));
        }
     }
   else
     /* knee */
     {
-      info.idealy_f_ -= beam_f;
+      info.idealy_f_ -= thick;
       info.maxy_f_ = info.idealy_f_;
       info.miny_f_ = -INT_MAX;
 
-      info.idealy_f_ -= stem_f;
-      info.maxy_f_ -= min_stem_f;
+      info.idealy_f_ -= stem_length;
+      info.maxy_f_ -= minimum_length;
     }
   
   info.idealy_f_ = (info.maxy_f_ <? info.idealy_f_) >? info.miny_f_;
 
-  SCM s = beam_l ()->get_elt_property ("shorten");
+  s = beam_l ()->get_elt_property ("shorten");
   if (gh_number_p (s))
     info.idealy_f_ -= gh_double2scm (s);
 
index 07ec6cf89d872aa684a3809d6d15116c258fea31..4a9018966a1b4f572a587ec867839faefb28f6bc 100644 (file)
@@ -20,22 +20,6 @@ beam_thickness = 0.52 * (\interline - \stafflinethickness);
 interbeam = (2.0 * \interline + \stafflinethickness - \beam_thickness) / 2.0;
 interbeam4 = (3.0 * \interline - \beam_thickness) / 3.0;
 
-
-
-% stems and beams
-%
-% poor man's array size
-stem_max = 3.0;
-
-%{ Specify length of stems for notes in the staff
-that don't have beams. 
-   Measured in staff positions.
-%}
-stem_length0 = 7.;
-stem_length1 = 5.;
-stem_length2 = 4.;
-stem_length3 = 3.;
-
 %{
 The space taken by a note is determined by the formula 
 
@@ -50,45 +34,6 @@ to the width of a quarter note head.
 arithmetic_basicspace = 2.;
 arithmetic_multiplier = 0.9 * \quartwidth ;
 
-
-
-% urg.
-% if only these ugly arrays were scm,
-% we could override them in the Grace context
-grace_factor = 0.8;
-grace_stem_length0 = \stem_length0 * \grace_factor;
-grace_stem_length1 = \stem_length1 * \grace_factor;
-grace_stem_length2 = \stem_length2 * \grace_factor;
-grace_stem_length3 = \stem_length3 * \grace_factor;
-
-% only used for beams
-minimum_stem_length0 = 0.0 ; % not used
-minimum_stem_length1 = 3.;
-minimum_stem_length2 = 2.5;
-minimum_stem_length3 = 2.0;
-
-grace_minimum_stem_length0 = 0.0 ; % not used
-grace_minimum_stem_length1 = \minimum_stem_length1 * \grace_factor;
-grace_minimum_stem_length2 = \minimum_stem_length2 * \grace_factor;
-grace_minimum_stem_length3 = \minimum_stem_length3 * \grace_factor;
-
-%{
-  stems in unnatural (forced) direction should be shortened,
-  according to [Roush & Gourlay].  Their suggestion to knock off
-  a whole staffspace seems a bit drastical: we'll do half.
-%}
-
-forced_stem_shorten0 = 1.0;
-forced_stem_shorten1 = \forced_stem_shorten0;
-forced_stem_shorten2 = \forced_stem_shorten1;
-forced_stem_shorten3 = \forced_stem_shorten2;
-
-% don't shorten grace stems, always up
-grace_forced_stem_shorten0 = 0.;
-grace_forced_stem_shorten1 = \grace_forced_stem_shorten0;
-grace_forced_stem_shorten2 = \grace_forced_stem_shorten1;
-grace_forced_stem_shorten3 = \grace_forced_stem_shorten2;
-
 % there are several ways to calculate the direction of a beam
 % 
 % * MAJORITY : number count of up or down notes
index d4eb2d352093b73dae8e802b21fc6820b907ce3f..ce28ebf4bf42e751695cfdbe30c53c0538dae338 100644 (file)
@@ -6,12 +6,6 @@
 
 ;;; All dimensions are measured in staff-spaces
 
-;; TODO
-;;  - make easily customisable from mudela
-;;  - take #forced stems into account (now done in C++)
-;;  - take y-position of chord or beam into account
-(define (stem-shorten flags) 0.5)
-(define (beamed-stem-shorten multiplicity) 0.5)
 
 
 ;; Beams should be prevented to conflict with the stafflines, 
 (define beam-vertical-position-quants beam-normal-y-quants)
 
 
+;; array index flag-2 (what a name!!), last if index>size
+;; unbeamed stems
+(define stem-length '(3.5 3.5 3.5 4.5 5.0))
+(define grace-length-factor 0.8)
+(define grace-stem-length
+  (map (lambda (x) (* grace-length-factor x)) stem-length))
+
+;; array index multiplicity, last if index>size
+;; beamed stems
+(define beamed-stem-shorten '(0.5))
+(define beamed-stem-length '(0.0 2.5 2.0 1.5))
+(define beamed-stem-minimum-length '(0.0 3.0 2.5 2.0))
+(define grace-beamed-stem-minimum-length
+  (map (lambda (x) (* grace-length-factor x)) beamed-stem-minimum-length))
+
+;;  Stems in unnatural (forced) direction should be shortened,
+;;  according to [Roush & Gourlay].  Their suggestion to knock off
+;;  a whole staffspace seems a bit drastical: we'll do half.
+
+;; TODO
+;;  - take #forced stems into account (now done in C++)?
+;;  - take y-position of chord or beam into account
+
+(define stem-shorten '(0.5))
+(define grace-stem-shorten '(0.0))