From c95a9c879fdeaabad78c859ec0f2bfd4c160d4f3 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 21 Dec 1999 16:46:17 +0100 Subject: [PATCH] patch::: 1.3.15.jcn3 - moved poor man's stem arrays to scm pl 15.jcn2 --- CHANGES | 3 ++ VERSION | 2 +- lily/beam.cc | 22 ++++++--- lily/include/lily-guile.hh | 2 +- lily/include/lily-guile.icc | 1 + lily/lily-guile.cc | 4 +- lily/stem.cc | 98 +++++++++++++++++++++++-------------- ly/params.ly | 55 --------------------- scm/paper.scm | 31 +++++++++--- 9 files changed, 109 insertions(+), 109 deletions(-) diff --git a/CHANGES b/CHANGES index cfc164b2bb..cc642f8d83 100644 --- 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 8644a073a4..4a05daddf6 100644 --- 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. diff --git a/lily/beam.cc b/lily/beam.cc index 7305ff69c6..c77b84839c 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -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 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 set_elt_property ("shorten", gh_double2scm (shorten_f)); } } + /* Set elt properties height and y-position if not set. Adjust stem lengths to reach beam. diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index f66caa760a..53dc8fdc03 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -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); diff --git a/lily/include/lily-guile.icc b/lily/include/lily-guile.icc index 1152117f20..9fb611a64b 100644 --- a/lily/include/lily-guile.icc +++ b/lily/include/lily-guile.icc @@ -29,6 +29,7 @@ array_to_scm (Array arr) templatevoid scm_to_array (SCM s, Array* arr) { + arr->clear (); for (; gh_pair_p (s); s= gh_cdr (s)) { T t; diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index be56d94587..73043deb01 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -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 ()); } diff --git a/lily/stem.cc b/lily/stem.cc index 7c76a571f6..4ef5b7de2c 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -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 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) 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) = 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 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 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 () get_var (type_str + "stem_length" - + to_str (beam_l ()->get_multiplicity () 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.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); diff --git a/ly/params.ly b/ly/params.ly index 07ec6cf89d..4a9018966a 100644 --- a/ly/params.ly +++ b/ly/params.ly @@ -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 diff --git a/scm/paper.scm b/scm/paper.scm index d4eb2d3520..ce28ebf4bf 100644 --- a/scm/paper.scm +++ b/scm/paper.scm @@ -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, @@ -63,3 +57,28 @@ (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)) -- 2.39.2