From 5fbfb36fc0c68b5d17879f2dcb388772b19fedc9 Mon Sep 17 00:00:00 2001 From: hanwen Date: Sat, 27 Apr 2002 23:02:01 +0000 Subject: [PATCH] '' --- ChangeLog | 4 ++ Documentation/user/refman.itely | 16 +++++--- Documentation/user/tutorial.itely | 4 +- VERSION | 2 +- lily/beam.cc | 61 ++++++++++++++++++++----------- lily/box.cc | 7 ++++ lily/font-size-engraver.cc | 4 ++ lily/include/box.hh | 2 + lily/include/group-interface.hh | 16 ++++++++ lily/include/slur-bezier-bow.hh | 6 +-- lily/slur.cc | 20 +++++----- 11 files changed, 101 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index eefb7c539b..2c9979a6c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-04-27 Han-Wen + + * lily/beam.cc: move scoring constants out of code + 2002-04-25 Han-Wen * mf/feta-nummer.mf: scalability fixes. diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index 01b9b8b1e9..139209c90d 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -3597,19 +3597,25 @@ You may enter these dimension using units (@code{cm}, @code{in}, @c . {Font size} @node Font Size @subsection Font size -@cindex font size +@cindex font size, setting +@cindex staff size, setting +@cindex @code{paper} file The Feta font provides musical symbols at six different sizes. These -fonts are 11 point, 13 point, 16 point, 20 point, -23 point, and 26 point. The point size of a font is the -height of the five lines in a staff when displayed in the font. +fonts are 11 point, 13 point, 16 point, 20 point, 23 point, and 26 +point. The point size of a font is the height of the five lines in a +staff when displayed in the font. Definitions for these sizes are the files @file{paperSZ.ly}, where @code{SZ} is one of 11, 13, 16, 20, 23 and 26. If you include any of these files, the identifiers @code{paperEleven}, @code{paperThirteen}, @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and @code{paperTwentysix} are defined respectively. The default -@code{\paper} block is also set. +@code{\paper} block is also set. These files should be imported at toplevel, i.e. +@example + \include "paper26.ly" + \score @{ ... @} +@end example The font definitions are generated using a Scheme function. For more details, see the file @file{scm/font.scm}. diff --git a/Documentation/user/tutorial.itely b/Documentation/user/tutorial.itely index 41c7d7f7a5..62cb86775f 100644 --- a/Documentation/user/tutorial.itely +++ b/Documentation/user/tutorial.itely @@ -925,7 +925,9 @@ can also make longer comments by enclosing text in @code{%@{} and @end example @cindex @code{\include} @cindex point, printer's -@cindex staff size setting +@cindex staff size, setting +@cindex font size, setting + By default, LilyPond will typeset the music in a size such that each staff is 20 point (0.7 cm, or 0.27 inch) high. We want smaller output (16 point staff height), so we must import the settings for that size, diff --git a/VERSION b/VERSION index 7b73fcc3e1..fb964200e0 100644 --- a/VERSION +++ b/VERSION @@ -1,7 +1,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=5 -PATCH_LEVEL=53 +PATCH_LEVEL=54 MY_PATCH_LEVEL=uu1 # use the above to send patches: MY_PATCH_LEVEL is always empty for a diff --git a/lily/beam.cc b/lily/beam.cc index 8c360baede..57ff7ff3f8 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -25,6 +25,8 @@ */ + + #include // tanh. #include "molecule.hh" @@ -47,6 +49,14 @@ #define DEBUG_QUANTING 0 +const int INTER_QUANT_PENALTY = 1000; +const int SECONDARY_BEAM_DEMERIT = 15; +const int STEM_LENGTH_DEMERIT_FACTOR = 5; +const int STEM_LENGTH_LIMIT_PENALTY = 500; +const int DAMPING_DIRECTIION_PENALTY = 800; +const int MUSICAL_DIRECTION_FACTOR = 400; +const int IDEAL_SLOPE_FACTOR = 10; + static Real shrink_extra_weight (Real x) @@ -551,10 +561,10 @@ Beam::score_stem_lengths (Link_arraystems, Stem_info info = stem_infos[i]; Direction d = Direction (directions[i]); - demerit_score += 500 * ( 0 >? (info.min_y - d * current_y)); - demerit_score += 500 * ( 0 >? (d * current_y - info.max_y)); + demerit_score += STEM_LENGTH_LIMIT_PENALTY * ( 0 >? (info.min_y - d * current_y)); + demerit_score += STEM_LENGTH_LIMIT_PENALTY * ( 0 >? (d * current_y - info.max_y)); - demerit_score += 5 * shrink_extra_weight (d * current_y - info.ideal_y); + demerit_score += STEM_LENGTH_DEMERIT_FACTOR * shrink_extra_weight (d * current_y - info.ideal_y); } demerit_score *= 2.0 / stems.size (); @@ -571,13 +581,13 @@ Beam::score_slopes_dy (Grob *me, Real yl, Real yr, Real dem = 0.0; if (sign (dy_damp) != sign (dy)) { - dem += 800; + dem += DAMPING_DIRECTIION_PENALTY; } - - dem += 400* (0 >? (fabs (dy) - fabs (dy_mus))); + + dem += MUSICAL_DIRECTION_FACTOR * (0 >? (fabs (dy) - fabs (dy_mus))); - dem += shrink_extra_weight (fabs (dy_damp) - fabs (dy))* 10; + dem += shrink_extra_weight (fabs (dy_damp) - fabs (dy))* IDEAL_SLOPE_FACTOR; return dem; } @@ -599,9 +609,9 @@ Beam::score_forbidden_quants (Grob*me, Real dem = 0.0; if (fabs (yl) < rad && fabs ( my_modf (yl) - 0.5) < 1e-3) - dem += 1000; + dem += INTER_QUANT_PENALTY; if (fabs (yr) < rad && fabs ( my_modf (yr) - 0.5) < 1e-3) - dem += 1000; + dem += INTER_QUANT_PENALTY; // todo: use multiplicity of outer stems. if (multiplicity >= 2) @@ -615,10 +625,10 @@ Beam::score_forbidden_quants (Grob*me, Direction dir = Directional_element_interface::get (me); if (fabs (yl - dir * interbeam) < rad && fabs (my_modf (yl) - inter) < 1e-3) - dem += 15; + dem += SECONDARY_BEAM_DEMERIT; if (fabs (yr - dir * interbeam) < rad && fabs (my_modf (yr) - inter) < 1e-3) - dem += 15; + dem += SECONDARY_BEAM_DEMERIT; Real eps = 1e-3; @@ -630,28 +640,29 @@ Beam::score_forbidden_quants (Grob*me, --hwn */ - + + // hmm, without Interval/Drul_array, you get ~ 4x same code... if (fabs (yl - dir * interbeam) < rad + inter) { if (dir == UP && dy <= eps && fabs (my_modf (yl) - sit) < eps) - dem += 15; + dem += SECONDARY_BEAM_DEMERIT; if (dir == DOWN && dy >= eps && fabs (my_modf (yl) - hang) < eps) - dem += 15; + dem += SECONDARY_BEAM_DEMERIT; } if (fabs (yr - dir * interbeam) < rad + inter) { if (dir == UP && dy >= eps && fabs (my_modf (yr) - sit) < eps) - dem += 15; + dem += SECONDARY_BEAM_DEMERIT; if (dir == DOWN && dy <= eps && fabs (my_modf (yr) - hang) < eps) - dem += 15; + dem += SECONDARY_BEAM_DEMERIT; } if (multiplicity >= 3) @@ -660,22 +671,22 @@ Beam::score_forbidden_quants (Grob*me, { if (dir == UP && dy <= eps && fabs (my_modf (yl) - straddle) < eps) - dem += 15; + dem += SECONDARY_BEAM_DEMERIT; if (dir == DOWN && dy >= eps && fabs (my_modf (yl) - straddle) < eps) - dem += 15; + dem += SECONDARY_BEAM_DEMERIT; } if (fabs (yr - 2 * dir * interbeam) < rad + inter) { if (dir == UP && dy >= eps && fabs (my_modf (yr) - straddle) < eps) - dem += 15; + dem += SECONDARY_BEAM_DEMERIT; if (dir == DOWN && dy <= eps && fabs (my_modf (yr) - straddle) < eps) - dem += 15; + dem += SECONDARY_BEAM_DEMERIT; } } } @@ -1176,7 +1187,15 @@ Beam::brew_molecule (SCM smob) dx = stems.top ()->relative_coordinate (0, X_AXIS) - x0; } - Interval pos = ly_scm2interval (me->get_grob_property ("positions")); + SCM posns = me->get_grob_property ("positions"); + Interval pos; + if (!ly_number_pair_p (posns)) + { + programming_error ("No beam posns"); + pos = Interval (0,0); + } + else + pos= ly_scm2interval (posns); Real dy = pos.delta (); Real dydx = dy && dx ? dy/dx : 0; diff --git a/lily/box.cc b/lily/box.cc index a74a6a7ad0..efed2217b5 100644 --- a/lily/box.cc +++ b/lily/box.cc @@ -68,3 +68,10 @@ Box::add_point (Offset o) interval_a_[X_AXIS].add_point (o[X_AXIS]); interval_a_[Y_AXIS].add_point (o[Y_AXIS]); } + +Offset +Box::center () const +{ + return Offset (interval_a_[X_AXIS].center(), + interval_a_[Y_AXIS].center()); +} diff --git a/lily/font-size-engraver.cc b/lily/font-size-engraver.cc index 863bc6bf11..41874eeae3 100644 --- a/lily/font-size-engraver.cc +++ b/lily/font-size-engraver.cc @@ -25,6 +25,10 @@ Font_size_engraver::Font_size_engraver () } +/* + TODO: use fontSize = NUMBER as a scaling constant: find the closest + integer design size, and use magnification to do the fractional bit. +*/ void Font_size_engraver::acknowledge_grob (Grob_info gi) { diff --git a/lily/include/box.hh b/lily/include/box.hh index 8e7b57417b..cbdfc2da7a 100644 --- a/lily/include/box.hh +++ b/lily/include/box.hh @@ -22,6 +22,8 @@ struct Box Interval y () const{return interval_a_[Y_AXIS]; } Interval operator[] (Axis a) const; Interval &operator[] (Axis a); + + Offset center () const; void translate (Offset o); /// smallest box enclosing #b# diff --git a/lily/include/group-interface.hh b/lily/include/group-interface.hh index 64476d0a0a..5ee3a085e5 100644 --- a/lily/include/group-interface.hh +++ b/lily/include/group-interface.hh @@ -38,6 +38,22 @@ public: /** Put all score elements of ELT's property called NAME into an array, and return it. */ + +inline Link_array +list_to_grob_array (SCM l) +{ + Link_array arr; + + for (SCM s = l; gh_pair_p (s); s = gh_cdr (s)) + { + SCM e = gh_car (s); + arr.push (unsmob_grob (e)); + } + + arr.reverse (); + return arr; +} + template Link_array Pointer_group_interface__extract_grobs (Grob const *elt, T *, const char* name) diff --git a/lily/include/slur-bezier-bow.hh b/lily/include/slur-bezier-bow.hh index 14e14eba71..f690b202fe 100644 --- a/lily/include/slur-bezier-bow.hh +++ b/lily/include/slur-bezier-bow.hh @@ -13,23 +13,21 @@ class Slur_bezier_bow { - -protected: Array encompass_; -private: void to_canonical_form (); Direction dir_; Real alpha_; Offset origin_; Real h_inf_, r_0_; + public: + /** The canonical bezier. */ Bezier curve_; - Slur_bezier_bow (Array encompass, Direction dir, Real hinf, Real r0); Bezier get_bezier () const; diff --git a/lily/slur.cc b/lily/slur.cc index b4439de631..4cc43ecf18 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -93,6 +93,8 @@ Slur::de_uglyfy (Grob*me, Slur_bezier_bow* bb, Real default_height) bb->curve_.assert_sanity (); } + + Direction Slur::get_default_dir (Grob*me) { @@ -131,6 +133,7 @@ Slur::after_line_breaking (SCM smob) void Slur::check_slope (Grob *me) { + /* Avoid too steep slurs. */ @@ -169,6 +172,7 @@ Slur::check_slope (Grob *me) ly_offset2scm (o[RIGHT]))); } } + } /* @@ -278,6 +282,11 @@ Slur::broken_trend_offset (Grob *me, Direction dir) return o; } +/* + COMMON is size-2 array with common refpoints. + +UGH: this routine delivers offsets which are *not* relative to COMMON. +*/ Offset Slur::get_attachment (Grob *me, Direction dir, Grob **common) @@ -455,15 +464,7 @@ Slur::get_encompass_offset_arr (Grob *me) common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (RIGHT), X_AXIS); common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (LEFT), X_AXIS); - Link_array encompass_arr; - while (gh_pair_p (eltlist)) - { - encompass_arr.push (unsmob_grob (ly_car (eltlist))); - eltlist =ly_cdr (eltlist); - } - encompass_arr.reverse (); - - + Link_array encompass_arr = list_to_grob_array (eltlist); Array offset_arr; Offset origin (me->relative_coordinate (common[X_AXIS], X_AXIS), @@ -578,6 +579,7 @@ Slur::set_control_points (Grob*me) Directional_element_interface::get (me), h_inf, r_0); + if (bb.fit_factor () > 1.0) { Real length = bb.curve_.control_[3][X_AXIS]; -- 2.39.5