From b459e941f3a1044ca6275ae4c3225abf784e2401 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Wed, 24 Jan 2001 20:12:25 +0100 Subject: [PATCH] patch::: 1.3.124.jcn2 1.3.124.jcn2 ============ * Cleanup automatic knees, junked calc_interstaff_dist. * Automatic knees now on by default for vertical distances >= 7 staff-space. --- CHANGES | 7 +++ Documentation/user/features.itely | 4 ++ VERSION | 2 +- input/test/auto-isknee.ly | 9 ++-- input/test/auto-knee.ly | 9 ++-- lily/beam.cc | 90 +++++++++++++++---------------- lily/cross-staff.cc | 51 ------------------ lily/include/beam.hh | 27 +++++----- lily/include/cross-staff.hh | 17 ------ lily/stem.cc | 8 +-- scm/foo.scm | 1 - scm/generic-property.scm | 1 - scm/grob-description.scm | 1 + scm/grob-property-description.scm | 3 +- 14 files changed, 86 insertions(+), 144 deletions(-) diff --git a/CHANGES b/CHANGES index 627d84f74d..90982aad40 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +1.3.124.jcn2 +============ + +* Cleanup automatic knees, junked calc_interstaff_dist. + +* Automatic knees now on by default for vertical distances >= 7 staff-space. + 1.3.124.jcn1 ============ diff --git a/Documentation/user/features.itely b/Documentation/user/features.itely index cb60274f36..cdff41fb77 100644 --- a/Documentation/user/features.itely +++ b/Documentation/user/features.itely @@ -1,3 +1,4 @@ +@c -*-texinfo-*- @ignore TODO @@ -124,6 +125,9 @@ switches to another staff. This is enabled if the property @cindex beam settings @cindex manual beams + +@c auto knees + In some cases it may be necessary to override LilyPond's automatic beaming algorithm. For example, the auto beamer will not beam over rests, so if you want that, specify the begin and end point manually diff --git a/VERSION b/VERSION index 27ca58f882..73340fcd4b 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=124 -MY_PATCH_LEVEL=jcn1 +MY_PATCH_LEVEL=jcn2 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/input/test/auto-isknee.ly b/input/test/auto-isknee.ly index 8402421493..fa3256b668 100644 --- a/input/test/auto-isknee.ly +++ b/input/test/auto-isknee.ly @@ -16,9 +16,10 @@ texidoc="Two automatic knees"; > \paper{ linewidth = 40*\staffspace; - \translator{ - \VoiceContext - Beam \override #'auto-interstaff-knee-gap = #4.0 - } +% Now by default +% \translator{ +% \VoiceContext +% Beam \override #'auto-knee-gap = #7 +% } } } diff --git a/input/test/auto-knee.ly b/input/test/auto-knee.ly index 209bd3f0a1..b49954b60c 100644 --- a/input/test/auto-knee.ly +++ b/input/test/auto-knee.ly @@ -8,9 +8,10 @@ texidoc="One automatic knee"; } \paper{ linewidth = 40*\staffspace; - \translator { - \VoiceContext - Beam \override #'auto-knee-gap = #13 - } +% Now by default +% \translator { +% \VoiceContext +% Beam \override #'auto-knee-gap = #7 +% } } } diff --git a/lily/beam.cc b/lily/beam.cc index 44e6da1dbd..41a9a52323 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -31,7 +31,6 @@ #include "lookup.hh" #include "group-interface.hh" #include "staff-symbol-referencer.hh" -#include "cross-staff.hh" #include "item.hh" #include "spanner.hh" #include "warn.hh" @@ -86,7 +85,7 @@ Beam::before_line_breaking (SCM smob) if (!Directional_element_interface::get (me)) Directional_element_interface::set (me, get_default_dir (me)); - auto_knees (me); + consider_auto_knees (me); set_stem_directions (me); set_stem_shorten (me); @@ -158,69 +157,63 @@ Beam::set_stem_directions (Grob*me) } } -void -Beam::auto_knees (Grob*me) -{ - if (!auto_knee (me,"auto-interstaff-knee-gap", true)) - auto_knee (me, "auto-knee-gap", false); -} - /* Simplistic auto-knees; only consider vertical gap between two adjacent chords. `Forced' stem directions are ignored. If you don't want auto-knees, - don't set, or unset autoKneeGap/autoInterstaffKneeGap. + don't set, or unset auto-knee-gap. */ -bool -Beam::auto_knee (Grob*me, String gap_str, bool interstaff_b) +void +Beam::consider_auto_knees (Grob *me) { - bool knee_b = false; - int knee_y = 0; - SCM gap = me->get_grob_property (gap_str.ch_C()); + SCM scm = me->get_grob_property ("auto-knee-gap"); - Direction d = Directional_element_interface::get (me); + if (gh_number_p (scm)) + { + bool knee_b = false; + Real knee_y = 0; + Real staff_space = Staff_symbol_referencer::staff_space (me); + Real gap = gh_scm2double (scm) / staff_space; + + Direction d = Directional_element_interface::get (me); Link_array stems= Pointer_group_interface__extract_elements (me, (Item*)0, "stems"); - - if (gh_number_p (gap)) - { - Spanner*sp = dynamic_cast (me); - int auto_gap_i = gh_scm2int (gap); + + Grob *common = me->common_refpoint (stems[0], Y_AXIS); + for (int i=1; i < stems.size (); i++) + common = common->common_refpoint (stems[i], Y_AXIS); + for (int i=1; i < stems.size (); i++) { - bool is_b = (bool)(calc_interstaff_dist (stems[i], sp) - - calc_interstaff_dist (stems[i-1], sp)); - int l_y = (int)(Stem::head_positions(stems[i-1])[d]); - int l_i = (int)calc_interstaff_dist (stems[i-1], sp); - l_y -= l_i; - int r_y = (int)(Stem::head_positions(stems[i])[d]); - int r_i = (int)calc_interstaff_dist (stems[i], sp); - r_y -= r_i; - int gap_i = r_y - l_y; - - if ((abs (gap_i) >= auto_gap_i) && (!interstaff_b || is_b)) + Real left = Stem::extremal_heads (stems[i-1])[d] + ->relative_coordinate (common, Y_AXIS); + Real right = Stem::extremal_heads (stems[i])[d] + ->relative_coordinate (common, Y_AXIS); + + Real dy = right - left; + + if (abs (dy) >= gap) { - knee_y = (r_y + l_y) / 2; + knee_y = (right + left) / 2; knee_b = true; break; } } - } - if (knee_b) - { - for (int i=0; i < stems.size (); i++) - { - Item *s = stems[i]; - int y = (int)(Stem::head_positions(s)[d]); - int y_i = (int)calc_interstaff_dist (s, dynamic_cast (me)); - y -= y_i; + + if (knee_b) + { + for (int i=0; i < stems.size (); i++) + { + Item *s = stems[i]; + Real y = Stem::extremal_heads (stems[i])[d] + ->relative_coordinate (common, Y_AXIS); - Directional_element_interface::set (s,y < knee_y ? UP : DOWN); - s->set_grob_property ("dir-forced", SCM_BOOL_T); + Directional_element_interface::set (s, y < knee_y ? UP : DOWN); + s->set_grob_property ("dir-forced", SCM_BOOL_T); + } } } - return knee_b; } /* @@ -523,6 +516,9 @@ Beam::set_stem_length (Grob*me,Real y, Real dy) Link_array stems= Pointer_group_interface__extract_elements (me, (Item*)0, "stems"); + Grob *common = me->common_refpoint (stems[0], Y_AXIS); + for (int i=1; i < stems.size (); i++) + common = common->common_refpoint (stems[i], Y_AXIS); for (int i=0; i < stems.size (); i++) { @@ -533,7 +529,9 @@ Beam::set_stem_length (Grob*me,Real y, Real dy) Real stem_y = calc_stem_y_f (me, s, y, dy); /* caution: stem measures in staff-positions */ - Stem::set_stemend (s,(stem_y + calc_interstaff_dist (s, dynamic_cast (me))) / half_space); + Real id = me->relative_coordinate (common, Y_AXIS) + - stems[i]->relative_coordinate (common, Y_AXIS); + Stem::set_stemend (s, (stem_y + id) / half_space); } } diff --git a/lily/cross-staff.cc b/lily/cross-staff.cc index 4bb5e0de00..e69de29bb2 100644 --- a/lily/cross-staff.cc +++ b/lily/cross-staff.cc @@ -1,51 +0,0 @@ -#include "cross-staff.hh" -#include "item.hh" -#include "align-interface.hh" -#include "spanner.hh" -#include "warn.hh" -#include "paper-def.hh" - - -/* - JUNKME - */ -Real -calc_interstaff_dist (Item *item, Spanner *span) -{ - Real interstaff = 0.0; - Grob *common = item->common_refpoint (span, Y_AXIS); - - - if (Align_interface::has_interface (common) && Align_interface::axis(common) == Y_AXIS) - { - SCM threshold = common->get_grob_property ("forced-distance"); - interstaff = 1.0; - if (!gh_number_p (threshold)) - warning (_ ("not a forced distance; cross-staff spanners may be broken")); - else - interstaff *= gh_scm2double (threshold); - - Grob * span_refpoint = span; - while (span_refpoint->parent_l (Y_AXIS) != common) - span_refpoint = span_refpoint->parent_l (Y_AXIS); - - Grob * note_refpoint = item; - while (note_refpoint->parent_l (Y_AXIS) != common) - note_refpoint = note_refpoint->parent_l (Y_AXIS); - - int span_prio = - Align_interface::get_count (common,(Grob*) dynamic_cast (span_refpoint)); - int item_prio = - Align_interface::get_count (common,(Grob*) dynamic_cast (note_refpoint)); - - /* - our staff is lower -> interstaff *= -1 - */ - - if (span_prio < item_prio) - interstaff *= -1; - return interstaff; - } - else return 0.0; -} - diff --git a/lily/include/beam.hh b/lily/include/beam.hh index 4f01a16982..18126770af 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -16,8 +16,8 @@ class Beam { public: static int visible_stem_count (Grob*); - static Item* first_visible_stem (Grob*); - static Item* last_visible_stem (Grob*); + static Item* first_visible_stem (Grob*); + static Item* last_visible_stem (Grob*); static bool has_interface (Grob*); static void set_interface (Grob*); DECLARE_SCHEME_CALLBACK(rest_collision_callback, (SCM element, SCM axis)); @@ -33,20 +33,19 @@ public: private: static Direction get_default_dir (Grob*); - static void set_stem_directions (Grob*); - static void auto_knees (Grob*); - static bool auto_knee (Grob*,String gap_str, bool interstaff_b); + static void set_stem_directions (Grob*); + static void consider_auto_knees (Grob*); static void set_stem_shorten (Grob*); - static void calc_default_position_and_height (Grob*,Real* y, Real* dy); - static bool suspect_slope_b (Grob*, Real y, Real dy); - static Real calc_slope_damping_f (Grob*, Real dy); - static Real calc_stem_y_f (Grob*, Item* s, Real y, Real dy); - static Real check_stem_length_f (Grob*, Real y, Real dy); - static void set_stem_length (Grob*, Real y, Real dy); - static Real quantise_dy_f (Grob*, Real dy); - static Real quantise_y_f (Grob*, Real y, Real dy, int quant_dir); + static void calc_default_position_and_height (Grob*,Real* y, Real* dy); + static bool suspect_slope_b (Grob*, Real y, Real dy); + static Real calc_slope_damping_f (Grob*, Real dy); + static Real calc_stem_y_f (Grob*, Item* s, Real y, Real dy); + static Real check_stem_length_f (Grob*, Real y, Real dy); + static void set_stem_length (Grob*, Real y, Real dy); + static Real quantise_dy_f (Grob*, Real dy); + static Real quantise_y_f (Grob*, Real y, Real dy, int quant_dir); static int forced_stem_count (Grob*); }; -#endif // BEAM_HH +#endif /* BEAM_HH */ diff --git a/lily/include/cross-staff.hh b/lily/include/cross-staff.hh index c5186008c2..e69de29bb2 100644 --- a/lily/include/cross-staff.hh +++ b/lily/include/cross-staff.hh @@ -1,17 +0,0 @@ -/* - cross-staff.hh -- declare cross staff calc funcs. - - source file of the GNU LilyPond music typesetter - - (c) 1999--2000 Han-Wen Nienhuys - - */ - -#ifndef CROSS_STAFF_HH -#define CROSS_STAFF_HH -#include "lily-proto.hh" -Real -calc_interstaff_dist (Item *item, Spanner *span); - -#endif /* CROSS_STAFF_HH */ - diff --git a/lily/stem.cc b/lily/stem.cc index 5824cc967a..af597fd0a7 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -24,7 +24,6 @@ #include "beam.hh" #include "rest.hh" #include "group-interface.hh" -#include "cross-staff.hh" #include "staff-symbol-referencer.hh" #include "spanner.hh" @@ -639,8 +638,11 @@ Stem::calc_stem_info (Grob*me) if (gh_number_p (s)) info.idealy_f_ -= gh_scm2double (s); - Real interstaff_f = -beam_dir* calc_interstaff_dist (dynamic_cast (me), dynamic_cast (beam)); - + Grob *common = me->common_refpoint (beam, Y_AXIS); + Real interstaff_f = beam_dir * + (me->relative_coordinate (common, Y_AXIS) + - beam->relative_coordinate (common, Y_AXIS)); + info.idealy_f_ += interstaff_f; info.miny_f_ += interstaff_f; info.maxy_f_ += interstaff_f ; diff --git a/scm/foo.scm b/scm/foo.scm index 8b13789179..e69de29bb2 100644 --- a/scm/foo.scm +++ b/scm/foo.scm @@ -1 +0,0 @@ - diff --git a/scm/generic-property.scm b/scm/generic-property.scm index f7256676a6..3d7bb65af0 100644 --- a/scm/generic-property.scm +++ b/scm/generic-property.scm @@ -23,7 +23,6 @@ (list (list 'beamSlopeDamping number? 'damping) (list 'autoKneeGap number? 'auto-knee-gap) - (list 'autoInterstaffKneeGap number? 'auto-interstaff-knee-gap) (list 'beamDirAlgorithm symbol? 'beam-dir-algorithm) (list 'beamHeight number? 'height-hs) (list 'beamVerticalPosition number? 'y-position-hs) diff --git a/scm/grob-description.scm b/scm/grob-description.scm index 043f356734..e83e911041 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -70,6 +70,7 @@ (flag-width-function . ,default-beam-flag-width-function) (space-function . ,default-beam-space-function) (damping . 1) + (auto-knee-gap . 7) (meta . ,(grob-description "Beam" beam-interface)) )) diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index 3a1993069e..eac251007c 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -41,8 +41,7 @@ This procedure is called (using dependency resolution) after line breaking. Retu '(LEFT-offset . RIGHT-offset). This offset is added to the attachments to prevent ugly slurs. [fixme: we need more documentation here]. ") -(grob-property-description 'auto-interstaff-knee-gap number? "") -(grob-property-description 'auto-knee-gap number? "") +(grob-property-description 'auto-knee-gap number? "The vertical distance of two adjacent beamed notes beyond which to make a knee.") (grob-property-description 'axes list? "list of axis numbers. -- 2.39.5