From: Han-Wen Nienhuys Date: Sun, 18 Jul 2004 11:24:44 +0000 (+0000) Subject: * lily/new-slur.cc (score_encompass): variable head-distance penalty. X-Git-Tag: release/2.3.7~21 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0c15b464726842d9ca21fb7994b780d7d45a001a;p=lilypond.git * lily/new-slur.cc (score_encompass): variable head-distance penalty. * lily/stem.cc (height): call Beam::after_line_breaking(). * lily/rest-collision.cc (force_shift_callback): only call shift for columns containing rests. * lily/new-slur.cc (print): use debug-slur-quanting paper var. * input/regression/font-postscript.ly: invoke afm2tfm. --- diff --git a/ChangeLog b/ChangeLog index 98ec448363..3932c36842 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2004-07-18 Han-Wen Nienhuys + + * lily/new-slur.cc (score_encompass): variable head-distance penalty. + + * lily/stem.cc (height): call Beam::after_line_breaking(). + + * lily/rest-collision.cc (force_shift_callback): only call shift + for columns containing rests. + + * lily/new-slur.cc (print): use debug-slur-quanting paper var. + + * input/regression/font-postscript.ly: invoke afm2tfm. + 2004-07-18 Jan Nieuwenhuizen * mf/SConscript: Build map files. diff --git a/Documentation/user/changing-defaults.itely b/Documentation/user/changing-defaults.itely index 619f897ffc..5f6e72f11d 100644 --- a/Documentation/user/changing-defaults.itely +++ b/Documentation/user/changing-defaults.itely @@ -433,7 +433,7 @@ entered separately, @verbatim music = \notes { c4 c4 } -arts = \notes { s4-. s4-> } +arts = \notes { s4-. s4-> } @end verbatim They are combined by sending both to the same @context{Voice} context, @@ -444,7 +444,7 @@ They are combined by sending both to the same @context{Voice} context, >> @end verbatim @lilypond[raggedright] -music = \notes { c4 c4 } +music = \notes { c4 50 c4 } arts = \notes { s4-. s4-> } \score { \notes \relative c'' << \new Staff \context Voice = "A" \music diff --git a/input/regression/font-postscript.ly b/input/regression/font-postscript.ly index 795d360660..71110e782b 100644 --- a/input/regression/font-postscript.ly +++ b/input/regression/font-postscript.ly @@ -3,12 +3,10 @@ texidoc = "This file demonstrates how to load different (postscript) fonts. The file @file{font.scm} shows how to define the scheme-function called." - } \bookpaper { - #(define text-font-defaults '((font-encoding . latin1) (baseline-skip . 2) @@ -17,6 +15,11 @@ #(set! fonts (make-century-schoolbook-tree 1.0)) } +%ugh. +% do this here so we don't forget the connection with +% this file. +#(system "afm2tfm `kpsewhich uncb8a.afm` uncb8a.tfm") + \paper { linewidth = 160 \mm - 2.0 * 9.0 \mm diff --git a/input/regression/new-slur.ly b/input/regression/new-slur.ly index a840a56f0e..4547c9a5a6 100644 --- a/input/regression/new-slur.ly +++ b/input/regression/new-slur.ly @@ -22,12 +22,17 @@ } d8.[) c16] d8.[ \grace f16( e16)] - + + + << {c=''8.([ es16] bes4~bes )} + \\ + {r8 r r } + >> f'=''16( e) d( c) c'=''2(~c8 d16 c b8 a) - f='4 - 4 ( f ) + f='4 f + | 4 ( f ) f ^( f ) f diff --git a/lily/new-slur.cc b/lily/new-slur.cc index 42c8d95756..42cfa6c8af 100644 --- a/lily/new-slur.cc +++ b/lily/new-slur.cc @@ -36,8 +36,7 @@ - curve around flag/stem for x coordinate - better scoring. - */ - +*/ struct Encompass_info { Real x_; Real stem_; @@ -87,7 +86,7 @@ const Real NON_HORIZONTAL_PENALTY = 15; const Real HEAD_STRICT_FREE_SPACE = 0.2; const Real MAX_SLOPE = 1.1; const Real MAX_SLOPE_FACTOR = 10; - +const Real FREE_HEAD_DISTANCE = 0.5 ; #define DEBUG_SLUR_QUANTING 1 @@ -115,6 +114,10 @@ public: Drul_array base_attach, Array * scores); + static void score_edges (Grob * me, Grob *common[], + Drul_array extremes, + Drul_array base_attach, + Array * scores); static void score_encompass (Grob * me, Grob *common[], Drul_array, Drul_array, Array * scores); @@ -488,8 +491,9 @@ New_slur::set_end_points (Grob *me) } } - score_encompass (me, common, extremes, base_attachment, &scores); + score_edges (me, common, extremes, base_attachment, &scores); score_slopes (me, common, extremes, base_attachment, &scores); + score_encompass (me, common, extremes, base_attachment, &scores); Real opt = 1e6; int opt_idx = 0; @@ -502,6 +506,38 @@ New_slur::set_end_points (Grob *me) } } + +#if DEBUG_SLUR_QUANTING + SCM inspect_quants = me->get_property ("inspect-quants"); + if (to_boolean (me->get_paper ()->lookup_variable (ly_symbol2scm ("debug-slur-quanting"))) + && ly_c_pair_p (inspect_quants)) + { + Drul_array ins = ly_scm2interval (inspect_quants); + int i = 0; + + Real mindist = 1e6; + for (; i < scores.size (); i ++) + { + Real d =fabs (scores[i].attachment_[LEFT][Y_AXIS] - ins[LEFT]) + + fabs (scores[i].attachment_[RIGHT][Y_AXIS] - ins[RIGHT]); + if (d < mindist) + { + opt_idx = i; + mindist= d; + } + } + if (mindist > 1e5) + programming_error ("Could not find quant."); + } + + + scores[opt_idx].score_card_ += to_string ("i%d", opt_idx); + + // debug quanting + me->set_property ("quant-score", + scm_makfrom0str (scores[opt_idx].score_card_.to_str0 ())); +#endif + Bezier const &b = scores[opt_idx].curve_; SCM controls = SCM_EOL; @@ -516,14 +552,6 @@ New_slur::set_end_points (Grob *me) me->set_property ("control-points", controls); -#if DEBUG_SLUR_QUANTING - scores[opt_idx].score_card_ += to_string ("i%d", opt_idx); - - // debug quanting - me->set_property ("quant-score", - scm_makfrom0str (scores[opt_idx].score_card_.to_str0 ())); -#endif - } void @@ -550,13 +578,24 @@ New_slur::score_encompass (Grob * me, Grob *common[], Real x = infos[j].x_; if (!(x < scores->elem (i).attachment_[RIGHT][X_AXIS] - &&x > scores->elem (i).attachment_[LEFT][X_AXIS])) + && x > scores->elem (i).attachment_[LEFT][X_AXIS])) continue; Real y = bez.get_other_coordinate (X_AXIS, x); + Real head_dy = (y - infos[j].head_); + if (dir * head_dy < 0) + { + demerit += HEAD_ENCOMPASS_PENALTY; + } + else + { + Real hd = + (head_dy) ? (1/(fabs (head_dy) - 1/FREE_HEAD_DISTANCE)) + : HEAD_ENCOMPASS_PENALTY; + hd = (hd >? 0) extremes, + Drul_array base_attach, + Array * scores) +{ + Direction dir = get_grob_direction (me); + + for (int i =0 ; i < scores->size (); i++) + { + Direction d = LEFT; do { - Real attr = - EDGE_ATTRACTION_FACTOR - * fabs (scores->elem (i).attachment_[d][Y_AXIS] - base_attach[d][Y_AXIS]); - - if (extremes[d].stem_ - && extremes[d].stem_dir_ == dir - && !Stem::get_beaming (extremes[d].stem_, -d) - ) - attr /= 5; + Real y = scores->elem (i).attachment_[d][Y_AXIS]; + Real dy = fabs (y - base_attach[d][Y_AXIS]); - demerit += attr; - } while (flip (&d) != LEFT); + Real factor = EDGE_ATTRACTION_FACTOR; +#if 0 + if (extremes[d].stem_ && extremes[d].stem_dir_ == dir) + { + if (!extremes[d].stem_extent_[Y_AXIS].contains (y)) + { + dy = fabs (extremes[d].stem_extent_[Y_AXIS][dir] - y); + } + else + factor *= 0.3; + } + Real demerit = dy * factor; +#else + Real demerit = + EDGE_ATTRACTION_FACTOR + * fabs (scores->elem (i).attachment_[d][Y_AXIS] - base_attach[d][Y_AXIS]); + + if (extremes[d].stem_ + && extremes[d].stem_dir_ == dir + && !Stem::get_beaming (extremes[d].stem_, -d) + ) + demerit /= 5; + +#endif + + (*scores)[i].score_ += demerit; #if DEBUG_SLUR_QUANTING - (*scores)[i].score_card_ += to_string ("E%.2f", demerit); + (*scores)[i].score_card_ += to_string ("E%.2f", demerit); #endif - - (*scores)[i].score_ += demerit; + } while (flip (&d) != LEFT); } } - void New_slur::score_slopes (Grob * me, Grob *common[], Drul_array extremes, @@ -715,7 +789,7 @@ New_slur::print (SCM smob) #if DEBUG_SLUR_QUANTING SCM quant_score = me->get_property ("quant-score"); - if (debug_beam_quanting_flag && + if (to_boolean (me->get_paper ()->lookup_variable (ly_symbol2scm ("debug-slur-quanting"))) && ly_c_string_p (quant_score)) { String str; diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 83354c3a50..992b12b0e5 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -28,15 +28,16 @@ Rest_collision::force_shift_callback (SCM element_smob, SCM axis) Axis a = (Axis) ly_scm2int (axis); assert (a == Y_AXIS); - Grob * rc = unsmob_grob (them->get_property ("rest-collision")); + if (Note_column::has_rests (them)) + { + Grob * rc = unsmob_grob (them->get_property ("rest-collision")); - if (rc && !to_boolean (rc->get_property ("positioning-done"))) - { - rc->set_property ("positioning-done", SCM_BOOL_T); - - do_shift (rc); - } - + if (rc && !to_boolean (rc->get_property ("positioning-done"))) + { + rc->set_property ("positioning-done", SCM_BOOL_T); + do_shift (rc); + } + } return scm_make_real (0.0); } diff --git a/lily/stem.cc b/lily/stem.cc index 9ea8812c8d..64f8981b23 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -499,6 +499,16 @@ Stem::height (SCM smob, SCM ax) Grob *me = unsmob_grob (smob); assert (a == Y_AXIS); + /* + ugh. - this dependency should be automatic. + */ + Grob *beam= get_beam (me); + if (beam) + { + Beam::after_line_breaking (beam->self_scm ()); + } + + SCM mol = me->get_uncached_stencil (); Interval iv; if (mol != SCM_EOL)