From 61533ebc43e5b5b99702ff6a062ed4a1b9a5e2c0 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 23 May 2002 22:07:32 +0000 Subject: [PATCH] stem tremolo fix --- Documentation/user/invoking.itexi | 4 +- lily/beam.cc | 33 +++++++------ lily/chord-tremolo-engraver.cc | 4 +- lily/include/stem.hh | 3 +- lily/slur.cc | 2 +- lily/stem-tremolo.cc | 82 +++++++++++++++++++++---------- lily/stem.cc | 17 +++---- make/lilypond.redhat.spec.in | 2 + 8 files changed, 91 insertions(+), 56 deletions(-) diff --git a/Documentation/user/invoking.itexi b/Documentation/user/invoking.itexi index 36a219557f..754f8d4d4d 100644 --- a/Documentation/user/invoking.itexi +++ b/Documentation/user/invoking.itexi @@ -38,7 +38,9 @@ have appropriate environment variables set. For @TeX{}, you have to set @code{MFINPUTS} and @code{TEXINPUTS} to point to the directory containing LilyPond metafont and @file{.tex} files. For processing PostScript output with Ghostscript you have to set @code{GS_FONTPATH} -to point to the directory containing LilyPond PFA files. +to point to the directory containing LilyPond PFA files. When you +print direct PS output, remember to send the PFA files to the printer +as well. Scripts to do this are included in @file{buildscripts/out/lilypond-profile} (for sh shells) and diff --git a/lily/beam.cc b/lily/beam.cc index ac715ee9f2..b75537e2a8 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -735,8 +735,8 @@ Beam::least_squares (SCM smob) if (!ideal.delta ()) { - Interval chord (Stem::chord_start_f (first_visible_stem (me)), - Stem::chord_start_f (last_visible_stem (me))); + Interval chord (Stem::chord_start_y (first_visible_stem (me)), + Stem::chord_start_y (last_visible_stem (me))); /* @@ -831,16 +831,16 @@ Beam::check_concave (SCM smob) == Stem::get_direction(stems[0])) { Real r1 = gh_scm2double (gap); - Real dy = Stem::chord_start_f (stems.top ()) - - Stem::chord_start_f (stems[0]); + Real dy = Stem::chord_start_y (stems.top ()) + - Stem::chord_start_y (stems[0]); Real slope = dy / (stems.size () - 1); - Real y0 = Stem::chord_start_f (stems[0]); + Real y0 = Stem::chord_start_y (stems[0]); for (int i = 1; i < stems.size () - 1; i++) { - Real c = (Stem::chord_start_f (stems[i]) - y0) - i * slope; + Real c = (Stem::chord_start_y (stems[i]) - y0) - i * slope; if (c > r1) { concaveness1 = true; @@ -862,8 +862,8 @@ Beam::check_concave (SCM smob) Direction dir = Directional_element_interface::get (me); Real concave = 0; - Interval iv (Stem::chord_start_f (stems[0]), - Stem::chord_start_f (stems.top ())); + Interval iv (Stem::chord_start_y (stems[0]), + Stem::chord_start_y (stems.top ())); if (iv[MAX] < iv[MIN]) iv.swap (); @@ -871,7 +871,7 @@ Beam::check_concave (SCM smob) for (int i = 1; i < stems.size () - 1; i++) { Real c = 0; - Real f = Stem::chord_start_f (stems[i]); + Real f = Stem::chord_start_y (stems[i]); if ((c = f - iv[MAX]) > 0) concave += c; else if ((c = f - iv[MIN]) < 0) @@ -1080,13 +1080,14 @@ Beam::stem_beams (Grob *me, Item *here, Item *next, Item *prev, Real dydx) Real nw_f; if (!Stem::first_head (here)) nw_f = 0; - else { - int t = Stem::type_i (here); + else + { + int t = Stem::duration_log (here); - SCM proc = me->get_grob_property ("flag-width-function"); - SCM result = gh_call1 (proc, gh_int2scm (t)); - nw_f = gh_scm2double (result); - } + SCM proc = me->get_grob_property ("flag-width-function"); + SCM result = gh_call1 (proc, gh_int2scm (t)); + nw_f = gh_scm2double (result); + } Direction dir = Directional_element_interface::get (me); @@ -1293,7 +1294,7 @@ Beam::forced_stem_count (Grob *me) if (Stem::invisible_b (s)) continue; - if (((int)Stem::chord_start_f (s)) + if (((int)Stem::chord_start_y (s)) && (Stem::get_direction (s) != Stem::get_default_dir (s))) f++; } diff --git a/lily/chord-tremolo-engraver.cc b/lily/chord-tremolo-engraver.cc index 3c46bb5ad0..43e66eb4a3 100644 --- a/lily/chord-tremolo-engraver.cc +++ b/lily/chord-tremolo-engraver.cc @@ -169,9 +169,9 @@ Chord_tremolo_engraver::acknowledge_grob (Grob_info info) Stem::set_beaming (s, f, RIGHT); SCM d = s->get_grob_property ("direction"); - if (Stem::type_i (s) != 1) + if (Stem::duration_log (s) != 1) { - int gap_i =Stem::duration_log (s) - ((Stem::type_i (s) >? 2) - 2); + int gap_i =Stem::duration_log (s) - ((Stem::duration_log (s) >? 2) - 2); beam_p_->set_grob_property ("gap", gh_int2scm (gap_i)); } s->set_grob_property ("direction", d); diff --git a/lily/include/stem.hh b/lily/include/stem.hh index 1c3b90883c..c48bade0cc 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -27,9 +27,8 @@ public: static Grob * support_head (Grob*) ; static void add_head (Grob*me, Grob*n); static Stem_info calc_stem_info (Grob *) ; - static Real chord_start_f (Grob *) ; + static Real chord_start_y (Grob *) ; static Direction get_direction (Grob*) ; - static int type_i (Grob *) ; static void set_stemend (Grob *,Real); static Direction get_default_dir (Grob *) ; diff --git a/lily/slur.cc b/lily/slur.cc index 716bcff34b..8a05cc744e 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -329,7 +329,7 @@ Slur::get_attachment (Grob *me, Direction dir, } else if (str == "alongside-stem") { - o = Offset (0, Stem::chord_start_f (stem)); + o = Offset (0, Stem::chord_start_y (stem)); /* Default position is on stem X, on outer side of head Y */ diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index 4e10df1676..5af470bae5 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -21,8 +21,6 @@ TODO: lengthen stem if necessary */ - - MAKE_SCHEME_CALLBACK (Stem_tremolo,dim_callback,2); /* @@ -49,7 +47,11 @@ Stem_tremolo::height (SCM smob, SCM ax) assert (a == Y_AXIS); SCM mol = me->get_uncached_molecule (); - return ly_interval2scm (unsmob_molecule (mol)->extent (a)); + + if (Molecule *m = unsmob_molecule (mol)) + return ly_interval2scm (m->extent (a)); + else + return ly_interval2scm (Interval()); } @@ -87,14 +89,24 @@ Stem_tremolo::brew_molecule (SCM smob) Molecule a (Lookup::beam (dydx, width, thick)); a.translate (Offset (-width/2, width / 2 * dydx)); - int tremolo_flags; + int tremolo_flags = 0; SCM s = me->get_grob_property ("flag-count"); if (gh_number_p (s)) tremolo_flags = gh_scm2int (s); - else - // huh? - tremolo_flags = 1; + if (!tremolo_flags) + { + programming_error ("No tremolo flags?"); + + me->suicide(); + return SCM_EOL; + } + + /* + Who the fuck is 0.81 ? + + --hwn. + */ Real interbeam = beam ? Beam::get_interbeam (beam) : 0.81; Molecule mol; @@ -104,27 +116,47 @@ Stem_tremolo::brew_molecule (SCM smob) b.translate_axis (interbeam * i, Y_AXIS); mol.add_molecule (b); } - if (tremolo_flags) - mol.translate_axis (-mol.extent (Y_AXIS).center (), Y_AXIS); - if (beam) + Direction stemdir = Stem::get_direction (stem); + Interval mol_ext = mol.extent (Y_AXIS); + + // ugh, rather calc from Stem_tremolo_req + int beams_i = (beam) + ? (Stem::beam_count (stem, RIGHT) >? Stem::beam_count (stem, LEFT)) + : 0; + + Real beamthickness = 0.0; + SCM sbt = (beam) ? beam->get_grob_property ("thickness") : SCM_EOL ; + if (gh_number_p (sbt)) + { + beamthickness = gh_scm2double (sbt) * ss; + } + + Real end_y + = Stem::stem_end_position (stem) *ss/2 + - stemdir * (beams_i * beamthickness + + ((beams_i -1) >? 0) * interbeam); + + /* + the 0.33 ss is to compensate for the size of the note head + */ + Real chord_start_y = Stem::chord_start_y (stem) + + 0.33 * ss * stemdir; + + Real padding = interbeam; + + /* + if there is not enough space, center on remaining space, + else one beamspace away from stem end. + */ + if (stemdir * (end_y - chord_start_y) - 2*padding - mol_ext.length () < 0.0) { - // ugh, rather calc from Stem_tremolo_req - int beams_i = Stem::beam_count (stem, RIGHT) - >? Stem::beam_count (stem, LEFT); - mol.translate (Offset (0, - Stem::stem_end_position (stem) * ss / 2 - - Directional_element_interface::get (beam) - * beams_i * interbeam)); + mol.translate_axis ((end_y + chord_start_y) /2.0 - mol_ext.center (),Y_AXIS); } else - { - /* - Beams should intersect one beamthickness below stem end - */ - Real dy = Stem::stem_end_position (stem) * ss / 2; - dy -= mol.extent (Y_AXIS).length () / 2 * Stem::get_direction (stem); - - mol.translate (Offset (0, dy)); + { + mol.translate_axis (end_y - stemdir * interbeam + -mol_ext [stemdir] + , Y_AXIS); } return mol.smobbed_copy (); diff --git a/lily/stem.cc b/lily/stem.cc index 2b1ad6440a..d0efe954f8 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -7,6 +7,10 @@ Jan Nieuwenhuizen TODO: This is way too hairy + + TODO: fix naming. + + Stem-end, chord-start, etc. is all confusing naming. */ #include // rint @@ -70,7 +74,7 @@ Stem::head_positions (Grob*me) Real -Stem::chord_start_f (Grob*me) +Stem::chord_start_y (Grob*me) { return head_positions (me)[get_direction (me)] * Staff_symbol_referencer::staff_space (me)/2.0; @@ -119,11 +123,6 @@ Stem::set_stemend (Grob*me, Real se) me->set_grob_property ("stem-end-position", gh_double2scm (se)); } -int -Stem::type_i (Grob*me) -{ - return first_head (me) ? Note_head::balltype_i (first_head (me)) : 2; -} /* Note head that determines hshift for upstems @@ -296,7 +295,7 @@ Stem::get_default_stem_end_position (Grob*me) Real shorten_f = a[ ((duration_log (me) - 2) >? 0) get_grob_property ("thickness")); Stem_info info; - info.ideal_y = chord_start_f (me); + info.ideal_y = chord_start_y (me); // for simplicity, we calculate as if dir == UP diff --git a/make/lilypond.redhat.spec.in b/make/lilypond.redhat.spec.in index abd9e1479e..e06ac2b59d 100644 --- a/make/lilypond.redhat.spec.in +++ b/make/lilypond.redhat.spec.in @@ -143,3 +143,5 @@ chkfontpath --remove=/usr/share/lilypond/pfa/ %files documentation %doc web/ +%doc input/ +%doc mutopia/ -- 2.39.2