+pl 15.jcn2
+ - moved poor man's stem arrays to scm
+
pl 15.jcn2
- beam quanting using scm lists
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.
/*
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 ()
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)
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.
#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);
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;
}
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 ());
}
#include "group-interface.hh"
#include "cross-staff.hh"
#include "staff-symbol-referencer.hh"
+#include "lily-guile.icc"
void
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))
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
&& (get_direction () != get_default_dir ()))
length_f -= shorten_f;
+#if 0
/*
UGK.!
*/
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
{
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
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);
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
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
;;; 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))