From a03e6952321a29fd34fe9e6709a5fc443c9e56cd Mon Sep 17 00:00:00 2001 From: jan Date: Sun, 21 Jul 2002 12:28:45 +0000 Subject: [PATCH] * Documentation/user/refman.itely (Font selection): font size doco * lily/stem.cc: rewrite of scoring to give sane results on knee beams. * lily/beam.cc (set_stem_lengths): extend stems for gapped tremolo beams. (connect_beams): chop off beaming outside the beam. Fixes problem with tremolo beams. --- ChangeLog | 9 +++++++ Documentation/user/preface.itely | 3 ++- Documentation/user/refman.itely | 2 +- lily/beam-quanting.cc | 16 +++++++++--- lily/beam.cc | 42 ++++++++++++++++++++++++++------ lily/include/beam.hh | 1 + lily/stem.cc | 36 +++++++++------------------ 7 files changed, 72 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index 60b417c03c..7bf607b5b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2002-07-21 Jan Nieuwenhuizen + * input/test/cue-notes.ly: better example + + * Documentation/user/refman.itely (Font selection): font size doco + + * input/mutopia/F.Schubert/standchen.ly: note bugfix + + * lily/stem.cc: rewrite of scoring to give sane results on knee + beams. + * lily/beam.cc (set_stem_lengths): extend stems for gapped tremolo beams. (connect_beams): chop off beaming outside the beam. Fixes problem diff --git a/Documentation/user/preface.itely b/Documentation/user/preface.itely index e7778c4faa..8d947eb6ca 100644 --- a/Documentation/user/preface.itely +++ b/Documentation/user/preface.itely @@ -1,6 +1,7 @@ +@comment @c -*-texinfo-*- @node Preface -@chapter Preface +@unnumbered Preface It must have been during a rehearsal of the EJE (Eindhoven Youth diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index 93ddd5c369..ba3d6aa035 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -3888,7 +3888,7 @@ slightly different design. Smaller design sizes are relatively wider, which enhances readability. @end table -For any of these properties, the value @code{*} (i.e. the @em{symbol}, +For any of these properties, the value @code{*} (i.e. the @emph{symbol}, @code{*}, entered as @code{#'*}), acts as a wildcard. This can be used to override default setting, which are always present. For example: @example diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc index efe670738a..dc5afce364 100644 --- a/lily/beam-quanting.cc +++ b/lily/beam-quanting.cc @@ -270,10 +270,20 @@ Beam::score_stem_lengths (Link_arraystems, Direction d = info.dir_; score[d] += pen - * (0 >? (info.dir_ * (info.shortest_y_ - current_y))); + * (0 >? (d * (info.shortest_y_ - current_y))); + + Real ideal_score = shrink_extra_weight (d * current_y - d * info.ideal_y_); - score[d] += STEM_LENGTH_DEMERIT_FACTOR - * shrink_extra_weight (d * current_y - info.dir_ * info.ideal_y_); + /* + + we introduce a power, to make the scoring strictly + convex. Otherwise a symmetric knee beam (up/down/up/down) does + not have an optimum in the middle. + + */ + if (knee) + ideal_score = pow (ideal_score, 1.1); + score[d] += STEM_LENGTH_DEMERIT_FACTOR * ideal_score; count[d] ++; } diff --git a/lily/beam.cc b/lily/beam.cc index 23f38c4079..dda0cf2c80 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -560,17 +560,20 @@ Beam::consider_auto_knees (Grob *me, Direction d) TODO: take some y-position (chord/beam/nearest?) into account scmify forced-fraction - - TODO: - - why is shorten stored in beam, and not directly in stem? + + This is done in beam because the shorten has to be uniform over the + entire beam. */ void -Beam::set_stem_shorten (Grob *m) +Beam::set_stem_shorten (Grob *me) { - Spanner*me = dynamic_cast (m); - + /* + shortening looks silly for x staff beams + */ + if (knee_b(me)) + return ; + Real forced_fraction = forced_stem_count (me) / visible_stem_count (me); int beam_count = get_beam_count (me); @@ -1268,7 +1271,32 @@ Beam::rest_collision_callback (SCM element_smob, SCM axis) return gh_double2scm (-d * discrete_dist); } +bool +Beam::knee_b (Grob*me) +{ + SCM k= me->get_grob_property ("knee"); + if (gh_boolean_p(k)) + return gh_scm2bool (k); + Link_array stems= + Pointer_group_interface__extract_grobs (me, (Grob*)0, "stems"); + + Drul_array dirs_found(0,0); + + for (int i= 0; i < stems.size(); i++) + { + Grob*s = stems[i]; + dirs_found[Directional_element_interface::get(s)] = true; + + if (dirs_found[LEFT]&&dirs_found[RIGHT]) + break; + } + + bool knee = dirs_found[LEFT]&&dirs_found[RIGHT]; + me->set_grob_property ("knee", gh_bool2scm (knee)); + + return knee; +} ADD_INTERFACE (Beam, "beam-interface", diff --git a/lily/include/beam.hh b/lily/include/beam.hh index 528348538a..a582c62555 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -22,6 +22,7 @@ public: DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM axis)); Beam (SCM); static void add_stem (Grob*,Grob*); + static bool knee_b (Grob*); static void set_beaming (Grob*,Beaming_info_list *); static void set_stemlens (Grob*); static int get_beam_count (Grob*me); diff --git a/lily/stem.cc b/lily/stem.cc index ffd07ffcfd..8589fc0295 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -818,15 +818,14 @@ Stem::calc_stem_info (Grob*me) Grob * beam = beam_l (me); int beam_count = beam_multiplicity(me).length()+1; - Real beam_translation_f = Beam::get_beam_translation (beam); + Real beam_translation= Beam::get_beam_translation (beam); Real thick = gh_scm2double (beam->get_grob_property ("thickness")); - Real ideal_y = chord_start_y (me); + Real note_start = chord_start_y (me); /* from here on, calculate as if dir == UP */ - ideal_y *= mydir; + note_start *= mydir; SCM grace_prop = me->get_grob_property ("grace"); - bool grace_b = to_boolean (grace_prop); SCM bml = robust_list_ref ( beam_count , @@ -837,17 +836,16 @@ Stem::calc_stem_info (Grob*me) me->get_grob_property ("beamed-lengths")); Real stem_length = gh_scm2double(bl) * staff_space; - ideal_y += thick + (beam_count - 1) * beam_translation_f; - - Real shortest_y = ideal_y + minimum_length - + (beam_count > 0) ? thick : 0 - + beam_translation_f * (beam_count - 1); - + /* + stem goes to center of beam, hence 0.5 + */ + Real beam_lengthen = beam_translation* (beam_count - 1) + + ((beam_count > 0) ? thick : 0) - 0.5 * thick; - ideal_y += stem_length; + Real shortest_y = note_start + minimum_length + beam_lengthen; + Real ideal_y = stem_length + note_start + beam_lengthen; - /* lowest beam of (UP) beam must never be lower than second staffline @@ -865,21 +863,9 @@ Stem::calc_stem_info (Grob*me) staffline lowest beam of (UP) beam must never be lower than second staffline */ -#if 0 - shortest_y = - shortest_y >? 0 - >? (- 2 * half_space - thick - + (beam_count > 0) * thick - + beam_translation_f * (beam_count - 1)); - -#else ideal_y = ideal_y >? 0 - >? (- 2 * half_space - thick - + (beam_count > 0) * thick - + beam_translation_f * (beam_count - 1)); -#endif - + >? (- 2 * half_space - thick + beam_lengthen); } -- 2.39.5