+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
============
+@c -*-texinfo-*-
@ignore
TODO
@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
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.
>
\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
+% }
}
}
}
\paper{
linewidth = 40*\staffspace;
- \translator {
- \VoiceContext
- Beam \override #'auto-knee-gap = #13
- }
+% Now by default
+% \translator {
+% \VoiceContext
+% Beam \override #'auto-knee-gap = #7
+% }
}
}
#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"
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);
}
}
-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<Item> stems=
Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
-
- if (gh_number_p (gap))
- {
- Spanner*sp = dynamic_cast<Spanner*> (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<Spanner*> (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;
}
/*
Link_array<Item> 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++)
{
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<Spanner*> (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);
}
}
-#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<Grob *> (span_refpoint));
- int item_prio =
- Align_interface::get_count (common,(Grob*) dynamic_cast<Grob *> (note_refpoint));
-
- /*
- our staff is lower -> interstaff *= -1
- */
-
- if (span_prio < item_prio)
- interstaff *= -1;
- return interstaff;
- }
- else return 0.0;
-}
-
{
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));
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 */
-/*
- cross-staff.hh -- declare cross staff calc funcs.
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef CROSS_STAFF_HH
-#define CROSS_STAFF_HH
-#include "lily-proto.hh"
-Real
-calc_interstaff_dist (Item *item, Spanner *span);
-
-#endif /* CROSS_STAFF_HH */
-
#include "beam.hh"
#include "rest.hh"
#include "group-interface.hh"
-#include "cross-staff.hh"
#include "staff-symbol-referencer.hh"
#include "spanner.hh"
if (gh_number_p (s))
info.idealy_f_ -= gh_scm2double (s);
- Real interstaff_f = -beam_dir* calc_interstaff_dist (dynamic_cast<Item*> (me), dynamic_cast<Spanner*> (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 ;
(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)
(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))
))
'(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.