From 28b105231795712cc7d38e9bc75af39996786578 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 5 Jan 1999 21:33:07 +0100 Subject: [PATCH] patch::: 1.1.18.jcn4: vixje pl 18.jcn4 - beam length adjustments - ugly beamtrend fix: input/test/beam-trend.ly --- NEWS | 4 + VERSION | 2 +- init/params.ly | 14 ++- input/test/beam-trend.ly | 9 ++ lily/beam.cc | 164 ++++++++++++++++++++------------ lily/include/beam.hh | 6 +- lily/stem-info.cc | 2 +- mutopia/J.S.Bach/wtk1-fugue2.ly | 26 +++-- 8 files changed, 152 insertions(+), 75 deletions(-) create mode 100644 input/test/beam-trend.ly diff --git a/NEWS b/NEWS index 733fbe3bd9..a87715db56 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +pl 18.jcn4 + - beam length adjustments + - ugly beamtrend fix: input/test/beam-trend.ly + pl 18.jcn3 - bf: (beamed) forced stem shorten - bf: broken slurs and ties; minimal slur/tie length setting ignored diff --git a/VERSION b/VERSION index c7fab2aa3f..d0c2078b63 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=1 PATCH_LEVEL=18 -MY_PATCH_LEVEL=jcn3 +MY_PATCH_LEVEL=jcn4 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/init/params.ly b/init/params.ly index cb4cf24aef..807a8a06fd 100644 --- a/init/params.ly +++ b/init/params.ly @@ -54,10 +54,16 @@ beam_dir_algorithm = \MAJORITY; % beam_*2 : multiplicity >= beam_multiple_break % beam_multiple_break = 3.0; -beam_minimum_stem1 = 1.5 * \interline; -beam_minimum_stem2 = 1.0 * \interline; -beam_ideal_stem1 = 2.0 * \interline; -beam_ideal_stem2 = 1.5 * \interline; +% beam_minimum_stem1 = 1.5 * \interline; +% beam_ideal_stem1 = 2.0 * \interline; +% beam_minimum_stem2 = 1.0 * \interline; +% beam_ideal_stem2 = 1.5 * \interline; + +% let's try these minor adjustments +beam_minimum_stem1 = 1.25 * \interline; +beam_ideal_stem1 = 1.75 * \interline; +beam_minimum_stem2 = 0.75 * \interline; +beam_ideal_stem2 = 1.25 * \interline; % beam_slope_damp_correct_factor = 2.0; beam_slope_damp_correct_factor = 0.0; diff --git a/input/test/beam-trend.ly b/input/test/beam-trend.ly new file mode 100644 index 0000000000..24b2e7bc56 --- /dev/null +++ b/input/test/beam-trend.ly @@ -0,0 +1,9 @@ +\score{ + \notes\relative c'{ + \stemup + [f8 a' g f] + } + \paper{ + linewidth=-1.; + } +} diff --git a/lily/beam.cc b/lily/beam.cc index f365889c4f..b82b7c498e 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -33,10 +33,6 @@ #include "paper-def.hh" #include "lookup.hh" #include "grouping.hh" -#include "stem-info.hh" - - - Beam::Beam () { @@ -117,7 +113,7 @@ Beam::do_post_processing () transparent_b_ = true; return ; } - solve_slope (); + calculate_slope (); set_stemlens (); } @@ -216,48 +212,29 @@ Beam::set_default_dir () /* See Documentation/tex/fonts.doc */ + void -Beam::solve_slope () +Beam::solve_slope (Array& sinfo) { /* should use minimum energy formulation (cf linespacing) */ - - assert (multiple_i_); - Array sinfo; + assert (sinfo.size () > 1); DOUT << "Beam::solve_slope: \n"; - for (int j=0; j mult_i_ = multiple_i_; - i->set_default_extents (); - if (i->invisible_b ()) - continue; + Real staffline_f = paper ()->rule_thickness (); + Real epsilon_f = staffline_f / 8; - Stem_info info (i); - sinfo.push (info); - } - if (! sinfo.size ()) - slope_f_ = left_y_ = 0; - else if (sinfo.size () == 1) + Real leftx = sinfo[0].x_; + Least_squares l; + for (int i=0; i < sinfo.size (); i++) { - slope_f_ = 0; - left_y_ = sinfo[0].idealy_f_; + sinfo[i].x_ -= leftx; + l.input.push (Offset (sinfo[i].x_, sinfo[i].idealy_f_)); } - else - { - Real leftx = sinfo[0].x_; - Least_squares l; - for (int i=0; i < sinfo.size (); i++) - { - sinfo[i].x_ -= leftx; - l.input.push (Offset (sinfo[i].x_, sinfo[i].idealy_f_)); - } - l.minimise (slope_f_, left_y_); - - } + l.input[0].y () += left_y_; + l.minimise (slope_f_, left_y_); solved_slope_f_ = dir_ * slope_f_; @@ -280,33 +257,32 @@ Beam::solve_slope () perhaps only if slope = 0 ? */ -// left_y_ = sinfo[0].minyf_; + if (abs (slope_f_) < epsilon_f) + left_y_ = (sinfo[0].idealy_f_ + sinfo.top ().idealy_f_) / 2; + else + /* + symmetrical, but results often in having stemlength = minimal + + left_y_ = sinfo[0].dir_ == dir_ ? sinfo[0].miny_f_ : sinfo[0].maxy_f_; - if (sinfo.size () >= 1) + what about + */ { - Real staffline_f = paper ()->rule_thickness (); - Real epsilon_f = staffline_f / 8; - if (abs (slope_f_) < epsilon_f) - left_y_ = (sinfo[0].idealy_f_ + sinfo.top ().idealy_f_) / 2; + Real dx = stems_.top ()->hpos_f () - stems_[0]->hpos_f (); + if (sinfo[0].dir_ == sinfo.top ().dir_) + left_y_ = sinfo[0].idealy_f_ >? sinfo.top ().idealy_f_ - slope_f_ * dx; + // knee else - /* - symmetrical, but results often in having stemlength = minimal - - left_y_ = sinfo[0].dir_ == dir_ ? sinfo[0].miny_f_ : sinfo[0].maxy_f_; - - what about - */ - { - Real dx = stems_.top ()->hpos_f () - stems_[0]->hpos_f (); - if (sinfo[0].dir_ == sinfo.top ().dir_) - left_y_ = sinfo[0].idealy_f_ >? sinfo.top ().idealy_f_ - slope_f_ * dx; - // knee - else - left_y_ = sinfo[0].idealy_f_; - } + left_y_ = sinfo[0].idealy_f_; } +} - // uh? +Real +Beam::check_stemlengths_f (Array& sinfo) +{ + /* + find shortest stem and adjust left_y accordingly + */ Real dy = 0.0; for (int i=0; i < sinfo.size (); i++) { @@ -316,7 +292,77 @@ Beam::solve_slope () if (my - y > dy) dy = my -y; } - left_y_ += dy; + return dy; +} + +void +Beam::calculate_slope () +{ + Real interline_f = paper ()->interline_f (); + Real staffline_f = paper ()->rule_thickness (); + Real epsilon_f = staffline_f / 8; + + assert (multiple_i_); + Array sinfo; + for (int i=0; i < stems_.size (); i++) + { + Stem *s = stems_[i]; + + s->mult_i_ = multiple_i_; + s->set_default_extents (); + if (s->invisible_b ()) + continue; + + Stem_info info (s); + sinfo.push (info); + } + + if (! sinfo.size ()) + slope_f_ = left_y_ = 0; + else if (sinfo.size () == 1) + { + slope_f_ = 0; + left_y_ = sinfo[0].idealy_f_; + } + else + { + Real y; + Real s; + for (int i = 0; i < 3; i++) + { + y = left_y_; + solve_slope (sinfo); + Real dy = check_stemlengths_f (sinfo); + left_y_ += dy; + + // only consider recalculation if long stem adjustments + if (!i && (left_y_ - sinfo[0].idealy_f_ < 0.5 * interline_f)) + break; + + if (!i) + s = slope_f_; + // never allow slope to tilt the other way + else if (sign (slope_f_) != sign (s)) + { + left_y_ = 0; + slope_f_ = 0; + Real dy = check_stemlengths_f (sinfo); + left_y_ += dy; + break; + } + // or become steeper + else if (abs (slope_f_) > abs (s)) + { + slope_f_ = s; + Real dy = check_stemlengths_f (sinfo); + left_y_ += dy; + break; + } + if (abs (dy) < epsilon_f) + break; + } + } + left_y_ *= dir_; slope_f_ *= dir_; diff --git a/lily/include/beam.hh b/lily/include/beam.hh index 29fa7049b4..5c42a6ba06 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -6,8 +6,10 @@ #ifndef BEAM_HH #define BEAM_HH + #include "lily-proto.hh" #include "directional-spanner.hh" +#include "stem-info.hh" #include "plist.hh" /** a beam connects multiple stems. @@ -59,7 +61,9 @@ protected: virtual void quantise_left_y (bool extend_b); virtual Molecule stem_beams (Stem *here, Stem *next, Stem *prev) const; - virtual void solve_slope (); + virtual void calculate_slope (); + virtual Real check_stemlengths_f (Array& sinfo); + virtual void solve_slope (Array& sinfo); virtual void quantise_dy (); virtual Molecule*do_brew_molecule_p () const; }; diff --git a/lily/stem-info.cc b/lily/stem-info.cc index ad09936111..20f16ea05c 100644 --- a/lily/stem-info.cc +++ b/lily/stem-info.cc @@ -93,7 +93,7 @@ Stem_info::Stem_info (Stem const *s) if (((int)s->chord_start_f ()) && (s->dir_ != s->get_default_dir ())) { idealy_f_ -= shorten_f; - miny_f_ = miny_f_ three pages - % hmm, too tight already, better more vsize! - arithmetic_multiplier = 4.8\pt; - % arithmetic_multiplier = 4.4\pt; + indent = 8.\mm; + textheight = 295.\mm; + + %hmm +% \translator { \BarNumberingScoreContext } + \translator { \BarNumberingStaffContext } % Breitkopf; unlike B\"arenreiter rule % really looks a lot better? % should have an array of min/ideal lengths (scheme) % and check B\"arenreiter rules again -- make testcase - beam_multiple_break = 2.0; - % beam_dir_algorithm = \MEDIAN; + % beam_multiple_break = 2.0; + % beam_minimum_stem1 = 1.5 * \interline; + % beam_ideal_stem1 = 2.0 * \interline; + % beam_minimum_stem2 = 1.25 * \interline; + % beam_ideal_stem2 = 1.75 * \interline; + } + \header{ + opus = "BWV 847"; } \midi { -- 2.39.5