From 207042fccc88457457f20ed8ca9a29d2aca0e602 Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 27 Mar 2002 01:52:02 +0000 Subject: [PATCH] lilypond-1.5.9 --- Documentation/regression-test.tely | 2 + input/regression/collision-mesh.ly | 24 +++++ input/regression/hara-kiri-short.ly | 21 +++-- input/test/boxed-molecule.ly | 5 +- input/test/drums.ly | 2 +- lily/collision.cc | 140 +++++++++++++++++++++++++++- lily/global-translator.cc | 2 +- lily/include/stem.hh | 1 + lily/note-head.cc | 2 +- lily/span-bar.cc | 15 ++- lily/stem.cc | 97 ++++++++++++------- mf/feta-banier.mf | 10 +- 12 files changed, 264 insertions(+), 57 deletions(-) create mode 100644 input/regression/collision-mesh.ly diff --git a/Documentation/regression-test.tely b/Documentation/regression-test.tely index 03f562a563..bed908046a 100644 --- a/Documentation/regression-test.tely +++ b/Documentation/regression-test.tely @@ -199,6 +199,8 @@ Grace note do weird things with timing. Fragile. @lilypondfile[printfilename]{collision-dots.ly} +@lilypondfile[printfilename]{collision-mesh.ly} + @lilypondfile[printfilename]{number-staff-lines.ly} diff --git a/input/regression/collision-mesh.ly b/input/regression/collision-mesh.ly new file mode 100644 index 0000000000..25881933f7 --- /dev/null +++ b/input/regression/collision-mesh.ly @@ -0,0 +1,24 @@ +\header { +texidoc = "Oppositely stemmed chords, meshing into each other, +are resolved." +} + +\score { + \context Staff \notes \relative c' { + \time 3/4 + % Here's what I was trying to do: + < \context Voice = VI {\stemDown + r4 r4 } + \context Voice=VII {\stemUp d'2.} > + + % Or: + + <\context Voice = VI {\stemUp r r} + \context Voice= VII {\stemDown d'2.} > + } +} + + + + + diff --git a/input/regression/hara-kiri-short.ly b/input/regression/hara-kiri-short.ly index 313e0dd4f4..38aeac0877 100644 --- a/input/regression/hara-kiri-short.ly +++ b/input/regression/hara-kiri-short.ly @@ -8,27 +8,34 @@ therefore removed. Also, any staff brackets and braces are removed. } + + + zager = \context Staff = zager \notes \relative c'' { \clef treble - c1 + c1 c1 +} + +zeuger = \context Staff = zeuger \notes \relative c'' { + \clef treble + c1 c1 } zoger = \context Staff = zoger \notes \relative c'' { \clef treble - \skip 1* 1 + \skip 2* 1 } -zagers = \context GrandStaff < +zagers = \context StaffGroup < \zager \zoger + \zeuger > \score{ - < - \context StaffGroup = zagers < + < \context StaffGroup = zagers < \zagers - > - > + > > \paper{ linewidth = 80.0\mm diff --git a/input/test/boxed-molecule.ly b/input/test/boxed-molecule.ly index aef4112f2a..0aeb856200 100644 --- a/input/test/boxed-molecule.ly +++ b/input/test/boxed-molecule.ly @@ -5,9 +5,12 @@ texidoc = "overriding the molecule callback can also be used to draw a box around arbitrary grobs. TODO: check whether the corners are really correct. - + + TODO: circled molecules. + " } + #(define (box-molecule xext yext) (ly-make-molecule (list 'filledbox (- (car xext)) (cdr xext) diff --git a/input/test/drums.ly b/input/test/drums.ly index 4285d18bfb..93a0a9e700 100644 --- a/input/test/drums.ly +++ b/input/test/drums.ly @@ -2,7 +2,7 @@ % see ly/drumpitch.ly for list of instruments and paper-kits. % scm/midi.scm for list of midi-drumkits. -\include "drumpitch.ly" +\include "drumpitch-init.ly" \version "1.3.146" diff --git a/lily/collision.cc b/lily/collision.cc index 5b6b815aa6..39e906b6ab 100644 --- a/lily/collision.cc +++ b/lily/collision.cc @@ -13,7 +13,7 @@ #include "paper-def.hh" #include "axis-group-interface.hh" #include "item.hh" - +#include "stem.hh" MAKE_SCHEME_CALLBACK (Collision,force_shift_callback,2); @@ -37,6 +37,124 @@ Collision::force_shift_callback (SCM element_smob, SCM axis) return gh_double2scm (0.0); } + +void +check_meshing_chords (Grob*me, + Drul_array< Array < Real > > *offsets, + Drul_array< Array < Slice > > const &extents, + Drul_array > const &clash_groups) + +{ + if (!extents[UP].size () || ! extents[DOWN].size ()) + return ; + + + Grob *cu =clash_groups[UP][0]; + Grob *cd =clash_groups[DOWN][0]; + + Grob * nu_l= Note_column::first_head (cu); + Grob * nd_l = Note_column::first_head (cd); + + + + bool half_collide = false; + bool full_collide = false; + + /* + TODO: + + filter out the 'o's in this configuration, since they're no part + in the collision. + + | + x|o + x|o + x + + + */ + Array ups = Stem::note_head_positions (Note_column::stem_l (cu)); + Array dps = Stem::note_head_positions (Note_column::stem_l (cd)); + + /* + they're too far apart to collide. + + */ + + if (ups[0] > dps.top () + 1) + return ; + + bool touch = (ups[0] - dps.top () >= 0); + + bool merge_possible = (ups[0] >= dps[0]) && (ups.top () <= dps.top ()); + + merge_possible = merge_possible && + Rhythmic_head::balltype_i (nu_l) == Rhythmic_head::balltype_i (nd_l); + + if (!to_boolean (me->get_grob_property ("merge-differently-dotted"))) + merge_possible = merge_possible && Rhythmic_head::dot_count (nu_l) == Rhythmic_head::dot_count (nd_l); + + int i = 0, j=0; + while (i < ups.size () && j < dps.size ()) + { + if (abs (ups[i] - dps[j]) == 1) + { + merge_possible = false; + half_collide = true; + } + else if (ups[i]==dps[j]) + full_collide = true; + else if (ups[i] >dps[0] && ups[i] < dps.top ()) + merge_possible = false; + else if (dps[j] >ups[0] && dps[j] < ups.top ()) + merge_possible = false; + + if (ups[i] < dps[j]) + i++; + else if (ups[i] > dps[j]) + j++; + else + { + i++; + j++; + } + } + + Drul_array center_note_shifts; + center_note_shifts[LEFT] = 0.0; + center_note_shifts[RIGHT] = 0.0; + + + Real shift_amount = 1; + + if ( touch) + shift_amount *= -1; + else + /* + for full collisions, the right hand head may obscure dots, so + make sure the dotted heads go to the right. + */ + if ((Rhythmic_head::dot_count (nu_l) < Rhythmic_head::dot_count (nd_l) + && full_collide)) + shift_amount *= -1; + + if (merge_possible) + shift_amount *= 0.0; + else if (half_collide || full_collide) + shift_amount *= 0.5; + else + shift_amount *= 0.25; + + Direction d = UP; + do + { + for (int i=0; i < clash_groups[d].size (); i++) + (*offsets)[d][i] += d * shift_amount; + } + while ((flip (&d))!= UP); +} + + /* TODO: make callback of this. @@ -146,6 +264,15 @@ Collision::automatic_shift (Grob *me) } } while ((flip (&d))!= UP); + + /* + do horizontal shifts of each direction + + | + x|| + x|| + x| + */ do { @@ -161,6 +288,14 @@ Collision::automatic_shift (Grob *me) } while ((flip (&d))!= UP); + + /* + Check if chords are meshing + */ + + check_meshing_chords (me, &offsets, extents, clash_groups); + +#if 0 /* if the up and down version are close, and can not be merged, move all of them again. */ @@ -203,7 +338,8 @@ Collision::automatic_shift (Grob *me) } while ((flip (&d))!= UP); } - +#endif + do { for (int i=0; i < clash_groups[d].size (); i++) diff --git a/lily/global-translator.cc b/lily/global-translator.cc index d66b6f05e9..4e4208bd82 100644 --- a/lily/global-translator.cc +++ b/lily/global-translator.cc @@ -98,7 +98,7 @@ Global_translator::run_iterator_on_me (Music_iterator * iter) w = sneaky_insert_extra_moment (w); - cout << "Proccing " << w << endl; + // cout << "Proccing " << w << endl; if (first) diff --git a/lily/include/stem.hh b/lily/include/stem.hh index 40d26e6c13..6730e25fb1 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -17,6 +17,7 @@ class Stem public: DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM )); + static Array note_head_positions (Grob*); static int flag_i (Grob*) ; static int beam_count (Grob*,Direction) ; static void set_beaming (Grob*,int, Direction d); diff --git a/lily/note-head.cc b/lily/note-head.cc index 2a1c813a84..33ce000315 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -94,7 +94,7 @@ Note_head::brew_molecule (SCM smob) } /* - ugh: use gh_call () + ugh: use gh_call () / scm_apply (). UGH: use grob-property. */ diff --git a/lily/span-bar.cc b/lily/span-bar.cc index 015f6b2e25..61e1f097ea 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -76,22 +76,27 @@ Span_bar::brew_molecule (SCM smobbed_me) // compose span_bar_mol Molecule span_bar_mol; - Grob *prev_staff_bar = 0; + + Interval prev_extent; for (SCM elts = first_elt; gh_pair_p (elts); elts = gh_cdr (elts)) { SCM smobbed_staff_bar = gh_car (elts); Grob *staff_bar = unsmob_grob (smobbed_staff_bar); - if (prev_staff_bar) + Interval ext = staff_bar->extent (refp, Y_AXIS); + if (ext.empty_b ()) + continue; + + if (!prev_extent.empty_b ()) { - Interval l(prev_staff_bar->extent (refp, Y_AXIS)[UP], - staff_bar->extent (refp, Y_AXIS)[DOWN]); + Interval l(prev_extent [UP], + ext[DOWN]); Molecule interbar = Bar::compound_barline (staff_bar, glyph_str, l.length()); interbar.translate_axis (l.center (), Y_AXIS); span_bar_mol.add_molecule (interbar); } - prev_staff_bar = staff_bar; + prev_extent = ext; } span_bar_mol.translate_axis (- me->relative_coordinate (refp, Y_AXIS), Y_AXIS); diff --git a/lily/stem.cc b/lily/stem.cc index 03d2c07ef8..140e6876b6 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -196,6 +196,29 @@ Stem::extremal_heads (Grob*me) return exthead; } +static int +icmp (int const &a, int const &b) +{ + return a-b; +} + +Array +Stem::note_head_positions (Grob *me) +{ + Array ps ; + for (SCM s = me->get_grob_property ("heads"); gh_pair_p (s); s = gh_cdr (s)) + { + Grob * n = unsmob_grob (gh_car (s)); + int p = int (Staff_symbol_referencer::position_f (n)); + + ps.push (p); + } + + ps.sort (icmp); + return ps; +} + + void Stem::add_head (Grob*me, Grob *n) { @@ -337,6 +360,8 @@ Stem::get_default_stem_end_position (Grob*me) return st; } + + /* Number of hooks on the flag, ie. the log of the duration. */ @@ -461,10 +486,11 @@ Stem::set_spacing_hints (Grob*me) Molecule Stem::flag (Grob*me) { - // TODO: rename flag-style into something more appropriate, - // e.g. "stroke-style", maybe with values "" (i.e. no stroke), - // "single" and "double". Needs more discussion. - String style, fstyle, stafflineOffs; + /* TODO: rename flag-style into something more appropriate, + e.g. "stroke-style", maybe with values "" (i.e. no stroke), + "single" and "double". Needs more discussion. + */ + String style, fstyle, staffline_offs; SCM fst = me->get_grob_property ("flag-style"); if (gh_string_p (fst)) { @@ -481,43 +507,46 @@ Stem::flag (Grob*me) style = ""; } if (String::compare_i (style, "mensural") == 0) - // Mensural notation: For notes on staff lines, use different - // flags than for notes between staff lines. The idea is that - // flags are always vertically aligned with the staff lines, - // regardless if the note head is on a staff line or between two - // staff lines. In other words, the inner end of a flag always - // touches a staff line. + /* Mensural notation: For notes on staff lines, use different + flags than for notes between staff lines. The idea is that + flags are always vertically aligned with the staff lines, + regardless if the note head is on a staff line or between two + staff lines. In other words, the inner end of a flag always + touches a staff line. + */ { - // Urrgh! We have to detect wether this stem ends on a staff - // line or between two staff lines. But we can not call - // stem_end_position(me) or get_default_stem_end_position(me), - // since this encounters the flag and hence results in an - // infinite recursion. However, in pure mensural notation, - // there are no multiple note heads attached to a single stem, - // neither is there usually need for using the stem_shorten - // property (except for 32th and 64th notes, but that is not a - // problem since the stem length in this case is augmented by - // an integral multiple of staff_space). Hence, it should be - // sufficient to just take the first note head, assume it's - // the only one, look if it's on a staff line, and select the - // flag's shape accordingly. In the worst case, the shape - // looks slightly misplaced, but that will usually be the - // programmer's fault (e.g. when trying to attach multiple - // note heads to a single stem in mensural notation). - Grob *firstHead = first_head(me); + /* Urrgh! We have to detect wether this stem ends on a staff + line or between two staff lines. But we can not call + stem_end_position(me) or get_default_stem_end_position(me), + since this encounters the flag and hence results in an + infinite recursion. However, in pure mensural notation, + there are no multiple note heads attached to a single stem, + neither is there usually need for using the stem_shorten + property (except for 32th and 64th notes, but that is not a + problem since the stem length in this case is augmented by + an integral multiple of staff_space). Hence, it should be + sufficient to just take the first note head, assume it's + the only one, look if it's on a staff line, and select the + flag's shape accordingly. In the worst case, the shape + looks slightly misplaced, but that will usually be the + programmer's fault (e.g. when trying to attach multiple + note heads to a single stem in mensural notation). + + */ + Grob *first = first_head(me); int sz = Staff_symbol_referencer::line_count (me)-1; - int p = (int)rint (Staff_symbol_referencer::position_f (firstHead)); - stafflineOffs = (((p ^ sz) & 0x1) == 0) ? "1" : "0"; + int p = (int)rint (Staff_symbol_referencer::position_f (first)); + staffline_offs = (((p ^ sz) & 0x1) == 0) ? "1" : "0"; } else { - stafflineOffs = ""; + staffline_offs = ""; } char c = (get_direction (me) == UP) ? 'u' : 'd'; - Molecule m = - Font_interface::get_default_font (me)-> - find_by_name (String ("flags-") + style + to_str (c) + stafflineOffs + - to_str (flag_i (me))); + String index_str + = String ("flags-") + style + to_str (c) + staffline_offs + to_str (flag_i (me)); + Molecule m + = Font_interface::get_default_font (me)->find_by_name (index_str); if (!fstyle.empty_b ()) m.add_molecule (Font_interface::get_default_font (me)->find_by_name (String ("flags-") + to_str (c) + fstyle)); return m; diff --git a/mf/feta-banier.mf b/mf/feta-banier.mf index 2bb37f8d65..dfa347ef75 100644 --- a/mf/feta-banier.mf +++ b/mf/feta-banier.mf @@ -257,6 +257,11 @@ fet_beginchar("8th (down)", "d3", "deighthflag") (hip_width, foot_depth), hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness); + pickup pencircle scaled stemthickness; + draw (0, 0) .. (0,-2 staff_space); + y_mirror_char; +fet_endchar; + %%%%%%%% % % @@ -470,11 +475,6 @@ fet_beginchar("grace dash (up)", "ugrace", "gracedash") (w, h); fet_endchar; - pickup pencircle scaled stemthickness; - draw (0, 0) .. (0,-2 staff_space); - y_mirror_char; -fet_endchar; - fet_beginchar("16th (down)", "d4", "dsixteenthflag") save flare, hip_depth_ratio, hip_width, -- 2.39.5