-\version "2.14.0"
+\version "2.13.34"
\header {
- texidoc = "Seconds do not confuse the collision algorithm too much. The best
-way to format this would be to merge the two Ds, but we will be happy for now
-if the upstem D does not collide with the downstem C."
+ texidoc = "Seconds do not confuse the collision algorithm.
+The first pair of chords in each measure should merge, mesh,
+or come relatively close, but the second in each measure needs
+more space to make clear which notes belong to which voice."
}
-
-<< d' \\ <c' d'> >>
+\relative f << {
+ <a' b>2 <a b d e> <a e' f> <a e' f> <a b c> <f g a>
+ \bar "||" <f g c> <g a c> <f g c d> <f g c d>
+} \\ {
+ <g a> <a b> <g a e'> <g a c e> <f g a> <a b c>
+ <g a e'> <g a e'> <g c d> <g a b>
+} >>
Grob *head_up = Note_column::first_head (clash_up);
Grob *head_down = Note_column::first_head (clash_down);
- vector<int> ups = Stem::note_head_positions (Note_column::get_stem (clash_up));
- vector<int> dps = Stem::note_head_positions (Note_column::get_stem (clash_down));
+ /* Staff-positions of all noteheads on each stem */
+ vector<int> ups = Stem::note_head_positions (stems[UP]);
+ vector<int> dps = Stem::note_head_positions (stems[DOWN]);
/* Too far apart to collide. */
if (ups[0] > dps.back () + 1)
return;
+ /* If the chords just 'touch' their extreme noteheads,
+ then we can align their stems.
+ */
+ bool touch = false;
+ if (ups[0] >= dps.back ()
+ && (dps.size () < 2 || ups[0] >= dps[dps.size () - 2] + 2)
+ && (ups.size () < 2 || ups[1] >= dps.back () + 2))
+ touch = true;
+
+ /* Filter out the 'o's in this configuration, since they're no
+ * part in the collision.
+ *
+ * |
+ * x|o
+ * x|o
+ * x
+ *
+ */
+ ups = Stem::note_head_positions (stems[UP], true);
+ dps = Stem::note_head_positions (stems[DOWN], true);
+
/* Merge heads if the notes lie the same line, or if the "stem-up-note" is
above the "stem-down-note". */
bool merge_possible = (ups[0] >= dps[0]) && (ups.back () >= dps.back ());
*
*/
- /* TODO: filter out the 'o's in this configuration, since they're no
- * part in the collision.
- *
- * |
- * x|o
- * x|o
- * x
- *
- */
-
bool close_half_collide = false;
bool distant_half_collide = false;
bool full_collide = false;
full_collide = full_collide || (close_half_collide
&& distant_half_collide);
- /* If the only collision is in the extreme noteheads,
- then their stems can line up and the chords just 'touch'.
- A half collision with the next note along the chord prevents touching.
- */
- bool touch = false;
- if (ups[0] >= dps.back ()
- && (dps.size () < 2 || ups[0] >= dps[dps.size () - 2] + 2)
- && (ups.size () < 2 || ups[1] >= dps.back () + 2))
- touch = true;
-
/* Determine which chord goes on the left, and which goes right.
Up-stem usually goes on the right, but if chords just 'touch' we can put
both stems on a common vertical line. In the presense of collisions,
while ((flip (&d)) != UP);
/*
- do horizontal shifts of each direction
-
- |
- x||
- x||
- x|
+ * do horizontal shifts of each direction
+ *
+ * |
+ * x||
+ * x||
+ * x|
*/
do
return exthead;
}
-/* The positions, in ascending order. */
+/* The staff positions, in ascending order.
+ * If FILTER, include the main column of noteheads only */
vector<int>
-Stem::note_head_positions (Grob *me)
+Stem::note_head_positions (Grob *me, bool filter)
{
vector<int> ps;
extract_grob_set (me, "note-heads", heads);
+ Grob *xref = common_refpoint_of_array (heads, me, X_AXIS);
for (vsize i = heads.size (); i--;)
{
Grob *n = heads[i];
- int p = Staff_symbol_referencer::get_rounded_position (n);
+ if (filter
+ && n->relative_coordinate (xref, X_AXIS) != 0.0)
+ continue;
+ int p = Staff_symbol_referencer::get_rounded_position (n);
ps.push_back (p);
}