From 82a2d303599b4c46fabbeb0b3a393d2ed69fb213 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 23:24:43 +0000 Subject: [PATCH] lilypond-1.3.72 --- CHANGES | 18 ++ input/test/tie.ly | 5 +- lily/align-interface.cc | 2 +- lily/axis-group-interface.cc | 2 +- lily/bar.cc | 4 +- lily/beam.cc | 22 +- lily/bezier-bow.cc | 123 ++++------- lily/bezier.cc | 14 +- lily/break-align-item.cc | 8 +- lily/chord-name.cc | 8 +- lily/clef-item.cc | 4 +- lily/crescendo.cc | 2 +- lily/cross-staff.cc | 10 +- lily/dot-column.cc | 6 +- lily/grace-align-item.cc | 2 +- lily/include/bezier-bow.hh | 32 +-- lily/include/bezier.hh | 4 +- lily/include/cross-staff.hh | 2 +- lily/include/score-element.hh | 11 +- lily/include/slur-bezier-bow.hh | 30 ++- lily/include/staff-symbol-referencer.hh | 1 + lily/include/tie-column.hh | 2 +- lily/include/tie.hh | 23 +- lily/least-squares.cc | 15 +- lily/local-key-item.cc | 6 +- lily/lookup.cc | 1 + lily/multi-measure-rest.cc | 4 +- lily/my-lily-lexer.cc | 2 +- lily/note-head.cc | 4 +- lily/property-engraver.cc | 2 +- lily/rest-collision.cc | 8 +- lily/rest.cc | 2 +- lily/score-element.cc | 12 +- lily/script-column-engraver.cc | 2 +- lily/script-column.cc | 2 +- lily/script.cc | 2 +- lily/separating-group-spanner.cc | 2 +- lily/side-position-interface.cc | 7 +- lily/slur-bezier-bow.cc | 71 ++++++- lily/slur.cc | 33 +-- lily/spacing-spanner.cc | 2 +- lily/span-bar.cc | 2 +- lily/staff-symbol-referencer.cc | 9 + lily/stem.cc | 2 +- lily/system-start-delimiter.cc | 2 +- lily/tie-column.cc | 20 +- lily/tie-engraver.cc | 7 +- lily/tie.cc | 265 ++++++++++++------------ lily/translator-group.cc | 1 - lily/tuplet-spanner.cc | 24 ++- lily/volta-spanner.cc | 5 +- ly/engraver.ly | 9 +- ly/params.ly | 11 +- scm/paper.scm | 8 - 54 files changed, 456 insertions(+), 421 deletions(-) diff --git a/CHANGES b/CHANGES index 659d970b22..17afb3dfa8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,21 @@ +* Robustness fix for minimise_least_squares () + +* cleanups of Slur_bezier_bow, removed Bezier_bow. + +* cleanup of Tie. Changed Tie into interface. Made ties flatter by default. + +* changed SCM_UNDEFINED to SCM_UNSPECIFIED for return values that go +back into Scheme. + +* changed SCM_UNSPECIFIED to SCM_EOL for undefined element +properties. This makes initializing list properties redundant. + +* removed idiotic code for including tfm.[1-5] into search path. + +* fixed problem with tuplet placement for cross staff tuplets. + +1.3.71 +====== * Small cleanups to bring down compile time and binary ensmallment. * Made Lookup into a smob, and use guile alist iso. an STL map. diff --git a/input/test/tie.ly b/input/test/tie.ly index 36998a23f5..4a6d255da6 100644 --- a/input/test/tie.ly +++ b/input/test/tie.ly @@ -2,8 +2,9 @@ \notes\relative c''{ %b2~b4~b8~b16~b32~b64 r64\break %a2~a4~a8~a16~a32~a64 r64 - d2~d4~d8~d16~d32~d64 r64\break - a2~a4~a8~a16~a32~a64 r64 + \time 8/4; + d1 ~ d2~d4~d8~d16~d32~d64 r64\break + a1~ a2~a4~a8~a16~a32~a64 r64 %c2~c4~c8~c16~c32~c64 r64 } \paper{ diff --git a/lily/align-interface.cc b/lily/align-interface.cc index 200bd8d6c4..51ac50d509 100644 --- a/lily/align-interface.cc +++ b/lily/align-interface.cc @@ -21,7 +21,7 @@ Real Align_interface::alignment_callback (Score_element *sc, Axis ax) { Score_element * par = sc->parent_l (ax); - if (par && par->get_elt_property ("alignment-done") == SCM_UNDEFINED) + if (par && !to_boolean (par->get_elt_property ("alignment-done"))) { Align_interface::do_side_processing (par, ax); } diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 3b144f624f..83f391c976 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -73,7 +73,7 @@ Axis_group_interface::set_axes (Score_element*me,Axis a1, Axis a2) SCM prop = me->get_elt_property ("axes"); - if (prop == SCM_UNDEFINED + if (!gh_pair_p (prop) || scm_memq (sa1, prop) == SCM_BOOL_F || scm_memq (sa2, prop) == SCM_BOOL_F) { diff --git a/lily/bar.cc b/lily/bar.cc index 19716114dd..bb91147180 100644 --- a/lily/bar.cc +++ b/lily/bar.cc @@ -146,7 +146,7 @@ Bar::before_line_breaking (SCM smob) } else { - g = SCM_UNDEFINED; + g = SCM_EOL; } if (!gh_string_p (g)) @@ -159,7 +159,7 @@ Bar::before_line_breaking (SCM smob) me->set_elt_property ("glyph", g); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } void diff --git a/lily/beam.cc b/lily/beam.cc index 32bffce8dc..1356abe333 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -14,7 +14,7 @@ * less hairy code * move paper vars to scm - remove *-hs variables. + remove *-hs variables, and do all y-position stuff in staff-space. */ @@ -284,7 +284,7 @@ Beam::after_line_breaking (SCM smob) /* first, calculate y, dy */ Real y, dy; -calc_default_position_and_height (me, &y, &dy); + calc_default_position_and_height (me, &y, &dy); if (visible_stem_count (me)) { if (suspect_slope_b (me, y, dy)) @@ -305,6 +305,10 @@ calc_default_position_and_height (me, &y, &dy); Real half_space = Staff_symbol_referencer::staff_space (me) / 2; + /* weird: why do we do calc_position_and_height () ? regardless of + this setting? + + */ /* check for user-override of dy */ SCM s = me->remove_elt_property ("height-hs"); if (gh_number_p (s)) @@ -347,7 +351,7 @@ calc_default_position_and_height (me, &y, &dy); set_stem_length (me, y, dy); me->set_elt_property ("y-position", gh_double2scm (y)); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } /* @@ -370,6 +374,8 @@ Beam::calc_default_position_and_height (Score_element*me,Real* y, Real* dy) } Array ideals; + + // ugh -> use commonx Real x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS); Link_array stems= Pointer_group_interface__extract_elements (me, (Item*)0, "stems"); @@ -401,6 +407,7 @@ Beam::suspect_slope_b (Score_element*me, Real y, Real dy) Real lengthened = me->paper_l ()->get_var ("beam_lengthened"); Real steep = me->paper_l ()->get_var ("beam_steep_slope"); + // ugh -> use commonx Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS); Real dydx = dy && dx ? dy/dx : 0; @@ -425,6 +432,7 @@ Beam::calc_slope_damping_f (Score_element*me,Real dy) if (damping) { + // ugh -> use commonx Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS); Real dydx = dy && dx ? dy/dx : 0; @@ -444,6 +452,7 @@ Beam::calc_stem_y_f (Score_element*me,Item* s, Real y, Real dy) int stem_multiplicity = (Stem::flag_i (s) - 2) >? 0; Real interbeam_f = me->paper_l ()->interbeam_f (beam_multiplicity); + // ugh -> use commonx Real x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS); Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0; Real stem_y = (dy && dx ? (s->relative_coordinate (0, X_AXIS) - x0) / dx * dy : 0) + y; @@ -624,6 +633,7 @@ Beam::set_beaming (Score_element*me,Beaming_info_list *beaming) Molecule Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev) { + // ugh -> use commonx if ((next && !(next->relative_coordinate (0, X_AXIS) > here->relative_coordinate (0, X_AXIS))) || (prev && !(prev->relative_coordinate (0, X_AXIS) < here->relative_coordinate (0, X_AXIS)))) programming_error ("Beams are not left-to-right"); @@ -639,6 +649,7 @@ Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev) Real bdy = interbeam_f; Real stemdx = staffline_f; + // ugh -> use commonx Real dx = visible_stem_count (me) ? last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS) : 0.0; @@ -756,6 +767,7 @@ Beam::brew_molecule (SCM smob) Pointer_group_interface__extract_elements (me, (Item*) 0, "stems"); if (visible_stem_count (me)) { + // ugh -> use commonx x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS); dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0; } @@ -892,6 +904,7 @@ Beam::rest_collision_callback (Score_element *rest, Axis a ) if (gh_number_p (s)) beam_y = gh_scm2double (s); + // ugh -> use commonx Real x0 = first_visible_stem(beam)->relative_coordinate (0, X_AXIS); Real dx = last_visible_stem(beam)->relative_coordinate (0, X_AXIS) - x0; Real dydx = beam_dy && dx ? beam_dy/dx : 0; @@ -932,6 +945,9 @@ Beam::set_interface (Score_element*me) Pointer_group_interface g (me, "stems"); g.set_interface (); + /* + why the init? No way to tell difference between default and user + override. */ me->set_elt_property ("height", gh_int2scm (0)); // ugh. me->set_elt_property ("y-position" ,gh_int2scm (0)); me->set_interface (ly_symbol2scm("beam-interface")); diff --git a/lily/bezier-bow.cc b/lily/bezier-bow.cc index 8a92e9ddf4..6861f61fc4 100644 --- a/lily/bezier-bow.cc +++ b/lily/bezier-bow.cc @@ -7,107 +7,64 @@ */ #include + #include "bezier-bow.hh" #include "misc.hh" #include "bezier.hh" -#include "dimensions.hh" -#include "direction.hh" -#include "debug.hh" -#include "main.hh" -#include "lily-guile.hh" -#include "paper-def.hh" - -Bezier_bow::Bezier_bow (Array encompass, Direction dir) +static Real F0_1 (Real x) { - alpha_ = 0; - dir_ = dir; - encompass_ = encompass; - to_canonical_form (); + return M_PI /2 * atan(2 * x / M_PI); } -Bezier -Bezier_bow::get_bezier () const +Real +slur_height (Real width, Real h_inf, Real r_0) { - Bezier rv = curve_; - if (dir_ == DOWN) - { - rv.flip (Y_AXIS); - } - - rv.rotate (alpha_); - rv.translate (origin_); - - return rv; + return F0_1 (width * r_0 / h_inf) * h_inf; } -void -Bezier_bow::to_canonical_form () -{ - origin_ = encompass_[0]; - translate (&encompass_, -origin_); - - Offset delta = encompass_.top () - encompass_[0]; - alpha_ = delta.arg (); - - rotate (&encompass_, -alpha_); - if (dir_ == DOWN) - { - flip (&encompass_, Y_AXIS); - } - - while (encompass_.size () > 1 && encompass_[1][X_AXIS] <= 0.0) - { - programming_error ("Degenerate bow: infinite steepness reqd"); - encompass_.del (1); - } - - Real l = encompass_.top ()[X_AXIS]; - while (encompass_.size () > 1 && encompass_.top (1)[X_AXIS] >= l) - { - programming_error ("Degenerate bow: infinite steepness reqd"); - encompass_.del (encompass_.size ()-2); - } -} + /* + For small w, the height should be proportional to w, for w -> + infinity, the height should rise to a limit asymptotically. -void -Bezier_bow::set_default_bezier (Real h_inf, Real r_0) -{ - curve_ = get_default_bezier (h_inf, r_0); -} + Hence we take F(x) such that + F(0) = 0 , F'(0) = 1, and F(infty) = 1 + + and use + + h = h_infinity * F(x * r_0 / h_infinity) + + + Examples: + + * F(x) = pi/2 * atan (2x/pi) + + * F(x) 1/alpha * x^alpha / (1 + x^alpha) + + * (etc.) + + [with the 2nd recipe you can determine how quickly the conversion from + `small' slurs to `big' slurs occurs.] + + Although this might seem cand_idates to SCM-ify, it is not all clear + which parameters (ie. h_inf, r_0, F(.)) should be candidates for + this. At present h_inf and r_0 come from paper settings, but we did + no experiments for determining the best combinations of F, h_inf and + r_0. + + */ -/* - See Documentation/programmer/fonts.doc - */ Bezier -Bezier_bow::get_default_bezier (Real h_inf, Real r_0) const +slur_shape (Real width, Real h_inf, Real r_0) { - Offset delta (encompass_.top ()[X_AXIS] - encompass_[0][X_AXIS], 0); - Real b = delta.length (); - Real height = get_default_height (h_inf, r_0, b); - // urg: scmify this? + Bezier curve; + Real height = slur_height (width, h_inf, r_0); Real indent = height; - Bezier curve; curve.control_[0] = Offset (0, 0); curve.control_[1] = Offset (indent, height); - curve.control_[2] = Offset (b - indent, height); - curve.control_[3] = Offset (b, 0); + curve.control_[2] = Offset (width - indent, height); + curve.control_[3] = Offset (width, 0); return curve; } -/* - See Documentation/programmer/fonts.doc - */ -Real -Bezier_bow::get_default_height (Real h_inf, Real r_0, Real b) const -{ - - SCM h = scm_eval (scm_listify (ly_symbol2scm ("slur-default-height"), - gh_double2scm (h_inf), - gh_double2scm (r_0), - gh_double2scm (b), - SCM_UNDEFINED)); - return gh_scm2double (h); -} - diff --git a/lily/bezier.cc b/lily/bezier.cc index 02f2f055e3..faf5b899a2 100644 --- a/lily/bezier.cc +++ b/lily/bezier.cc @@ -29,10 +29,13 @@ binomial_coefficient (Real over , int under) } void -flip (Array* arr_p, Axis a) +scale (Array* arr_p, Real x , Real y) { for (int i = 0; i < arr_p->size (); i++) - (*arr_p)[i][a] = - (*arr_p)[i][a]; + { + (*arr_p)[i][X_AXIS] = x* (*arr_p)[i][X_AXIS]; + (*arr_p)[i][Y_AXIS] = y* (*arr_p)[i][Y_AXIS]; + } } void @@ -179,10 +182,13 @@ Bezier::extent (Axis a)const */ void -Bezier::flip (Axis a) +Bezier::scale (Real x, Real y) { for (int i = CONTROL_COUNT; i--;) - control_[i][a] = - control_[i][a]; + { + control_[i][X_AXIS] = x * control_[i][X_AXIS]; + control_[i][Y_AXIS] = y * control_[i][Y_AXIS]; + } } void diff --git a/lily/break-align-item.cc b/lily/break-align-item.cc index 53b6eaa232..2c9e705117 100644 --- a/lily/break-align-item.cc +++ b/lily/break-align-item.cc @@ -28,7 +28,7 @@ Break_align_item::before_line_breaking (SCM smob) { Score_element* me = unsmob_element (smob); do_alignment (me); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } Real @@ -97,9 +97,9 @@ Break_align_item::do_alignment (Score_element *me) { next_origin = next_elt->get_elt_property ("break-align-symbol"); next_origin = - (next_origin == SCM_UNDEFINED) - ? ly_symbol2scm ("none") - : next_origin; + gh_symbol_p (next_origin)? + next_origin : ly_symbol2scm ("none") +; } else next_origin = ly_symbol2scm ("begin-of-note"); diff --git a/lily/chord-name.cc b/lily/chord-name.cc index 4becdee60f..c05ebfc187 100644 --- a/lily/chord-name.cc +++ b/lily/chord-name.cc @@ -131,19 +131,19 @@ Chord_name::brew_molecule (SCM smob) { Score_element *sc = unsmob_element (smob); SCM style = sc->get_elt_property ("style"); - if (style == SCM_UNDEFINED) + + if (!gh_string_p (style)) style = ly_str02scm ("banter"); SCM inversion = sc-> get_elt_property ("inversion"); - if (inversion == SCM_UNDEFINED) + if (inversion != SCM_BOOL_T) inversion = SCM_BOOL_F; SCM bass = sc->get_elt_property ("bass"); - if (bass == SCM_UNDEFINED) + if (bass != SCM_BOOL_T) bass = SCM_BOOL_F; SCM pitches = sc->get_elt_property ("pitches"); - SCM text = scm_eval (gh_list (ly_symbol2scm ("chord::user-name"), style, ly_quote_scm (pitches), diff --git a/lily/clef-item.cc b/lily/clef-item.cc index 9c1179333d..1b3adc4d4c 100644 --- a/lily/clef-item.cc +++ b/lily/clef-item.cc @@ -46,10 +46,10 @@ Clef::before_line_breaking (SCM smob) else { s->suicide (); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } bool diff --git a/lily/crescendo.cc b/lily/crescendo.cc index 0c9fb96c69..c21897faca 100644 --- a/lily/crescendo.cc +++ b/lily/crescendo.cc @@ -18,7 +18,7 @@ void Crescendo::set_interface (Score_element*s) { - s->set_elt_property ("dynamic-drul", gh_cons (SCM_UNDEFINED, SCM_UNDEFINED)); + s->set_elt_property ("dynamic-drul", gh_cons (SCM_EOL, SCM_EOL)); } diff --git a/lily/cross-staff.cc b/lily/cross-staff.cc index ad0ba06109..68a18a9de4 100644 --- a/lily/cross-staff.cc +++ b/lily/cross-staff.cc @@ -8,7 +8,7 @@ JUNKME */ Real -calc_interstaff_dist (Item const *item, Spanner const *span) +calc_interstaff_dist (Item *item, Spanner *span) { Real interstaff = 0.0; Score_element *common = item->common_refpoint (span, Y_AXIS); @@ -25,18 +25,18 @@ calc_interstaff_dist (Item const *item, Spanner const *span) if (gh_pair_p (threshold)) interstaff = gh_scm2double (gh_car (threshold)); - Score_element const * span_refpoint = span; + Score_element * span_refpoint = span; while (span_refpoint->parent_l (Y_AXIS) != common) span_refpoint = span_refpoint->parent_l (Y_AXIS); - Score_element const * note_refpoint = item; + Score_element * note_refpoint = item; while (note_refpoint->parent_l (Y_AXIS) != common) note_refpoint = note_refpoint->parent_l (Y_AXIS); int span_prio = - Align_interface::get_count (common,(Score_element*) dynamic_cast (span_refpoint)); + Align_interface::get_count (common,(Score_element*) dynamic_cast (span_refpoint)); int item_prio = - Align_interface::get_count (common,(Score_element*) dynamic_cast (note_refpoint)); + Align_interface::get_count (common,(Score_element*) dynamic_cast (note_refpoint)); /* our staff is lower -> interstaff *= -1 diff --git a/lily/dot-column.cc b/lily/dot-column.cc index 556928f7da..5557790b33 100644 --- a/lily/dot-column.cc +++ b/lily/dot-column.cc @@ -86,7 +86,7 @@ Dot_column::do_shifts (SCM l) dots.sort (compare_position); if (dots.size () < 2) - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; Slice s; s.set_empty (); @@ -106,7 +106,7 @@ Dot_column::do_shifts (SCM l) } if (!conflicts) - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; int middle = s.center (); /* @@ -122,7 +122,7 @@ Dot_column::do_shifts (SCM l) Staff_symbol_referencer::set_position (d,pos); } - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } bool diff --git a/lily/grace-align-item.cc b/lily/grace-align-item.cc index a8150dac67..d37bdb4d77 100644 --- a/lily/grace-align-item.cc +++ b/lily/grace-align-item.cc @@ -29,7 +29,7 @@ Grace_align_item::before_line_breaking (SCM smob) gh_double2scm (infinity_f))); dynamic_cast(me)->column_l ()->set_elt_property ("contains-grace", SCM_BOOL_T); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } void diff --git a/lily/include/bezier-bow.hh b/lily/include/bezier-bow.hh index e9b361e8fa..43b09f0e75 100644 --- a/lily/include/bezier-bow.hh +++ b/lily/include/bezier-bow.hh @@ -14,33 +14,11 @@ #include "lily-proto.hh" #include "lily-guile.hh" -/** - Implement bow specific bezier curve. Calculate bezier curve for bow - from bow paratime_signatures. */ -class Bezier_bow -{ -public: - Bezier_bow (Array encompass, Direction dir); - - Bezier get_bezier () const; - Bezier get_default_bezier (Real h_inf, Real r_0) const; - Real get_default_height (Real h_inf, Real r_0, Real length) const; - void set_default_bezier (Real h_inf, Real r_0); - - /** - The canonical bezier. - */ - Bezier curve_; - -protected: - Array encompass_; - -private: - void to_canonical_form (); - Direction dir_; - Real alpha_; - Offset origin_; -}; + + +Bezier slur_shape (Real width, Real height_limit, + Real height_proportion); +Real slur_height (Real width, Real height_limit, Real height_proportion); #endif /* BEZIER_BOW_HH */ diff --git a/lily/include/bezier.hh b/lily/include/bezier.hh index 1f9bd2d252..ebdfdb3939 100644 --- a/lily/include/bezier.hh +++ b/lily/include/bezier.hh @@ -23,7 +23,7 @@ class Bezier { public: void assert_sanity () const; - void flip (Axis); + void scale (Real x,Real y); void reverse (); void rotate (Real); void translate (Offset); @@ -46,7 +46,7 @@ public: Offset control_[4]; }; -void flip (Array* arr_p, Axis a); +void scale (Array* arr_p, Real xscale, Real yscale); void rotate (Array* arr_p, Real phi); void translate (Array* arr_p, Offset o); diff --git a/lily/include/cross-staff.hh b/lily/include/cross-staff.hh index 673941a79d..c5186008c2 100644 --- a/lily/include/cross-staff.hh +++ b/lily/include/cross-staff.hh @@ -11,7 +11,7 @@ #define CROSS_STAFF_HH #include "lily-proto.hh" Real -calc_interstaff_dist (Item const *item, Spanner const *span); +calc_interstaff_dist (Item *item, Spanner *span); #endif /* CROSS_STAFF_HH */ diff --git a/lily/include/score-element.hh b/lily/include/score-element.hh index ebd656070d..eaf4e3cebd 100644 --- a/lily/include/score-element.hh +++ b/lily/include/score-element.hh @@ -60,18 +60,9 @@ class Score_element { */ Lookup * lookup_l_; - /** - properties specific for this element. Destructor will not call - scm_unprotect, so as to allow more flexible GC arrangements. The - real alist is in (cdr element_property_alist_), to reduce the - need for more scm_protect calls. - - */ -public: // ugh. +public: SCM immutable_property_alist_; SCM mutable_property_alist_; - -public: Score_element *original_l_; /** diff --git a/lily/include/slur-bezier-bow.hh b/lily/include/slur-bezier-bow.hh index 7fbbffd762..96b6cd0420 100644 --- a/lily/include/slur-bezier-bow.hh +++ b/lily/include/slur-bezier-bow.hh @@ -11,15 +11,35 @@ #include "bezier-bow.hh" -class Slur_bezier_bow : public Bezier_bow +class Slur_bezier_bow { + +protected: + Array encompass_; + +private: + void to_canonical_form (); + Direction dir_; + Real alpha_; + Offset origin_; + Real h_inf_, r_0_; public: - Slur_bezier_bow (Array encompass, Direction dir); - Array area_x_gradients_array (Real area); + /** + The canonical bezier. + */ + Bezier curve_; + + + Slur_bezier_bow (Array encompass, Direction dir, + Real hinf, Real r0); + Bezier get_bezier () const; + + void minimise_enclosed_area (Paper_def* paper_l); + Real fit_factor () const; void blow_fit (); Real enclosed_area_f () const; - Real fit_factor () const; - void minimise_enclosed_area (Paper_def* paper_l, Real default_height); +private: + Array area_x_gradients_array (Real area); }; #endif /* SLUR_BEZIER_BOW_HH */ diff --git a/lily/include/staff-symbol-referencer.hh b/lily/include/staff-symbol-referencer.hh index ea46d2d474..82c84cfc6a 100644 --- a/lily/include/staff-symbol-referencer.hh +++ b/lily/include/staff-symbol-referencer.hh @@ -35,6 +35,7 @@ public: static Score_element * staff_symbol_l (Score_element*); static int line_count (Score_element*); static Real position_f (Score_element*); + static Real staff_radius (Score_element*); }; int compare_position (Score_element *const&,Score_element *const&); diff --git a/lily/include/tie-column.hh b/lily/include/tie-column.hh index 8dfab669bd..2c8545a079 100644 --- a/lily/include/tie-column.hh +++ b/lily/include/tie-column.hh @@ -19,7 +19,7 @@ class Tie_column public: static void set_interface (Score_element*me); static bool has_interface (Score_element*); - static void add_tie (Score_element*me,Tie*); + static void add_tie (Score_element*me,Score_element*); static SCM after_line_breaking (SCM); static void set_directions (Score_element*me); }; diff --git a/lily/include/tie.hh b/lily/include/tie.hh index 422a9fa375..4ecd9e56d0 100644 --- a/lily/include/tie.hh +++ b/lily/include/tie.hh @@ -10,36 +10,21 @@ #ifndef TIE_HH #define TIE_HH -#include "spanner.hh" -#include "rod.hh" +#include "lily-guile.hh" +#include "lily-proto.hh" -/** - Connect two noteheads. - */ -class Tie : public Spanner +class Tie { public: - Tie (SCM); static void set_head (Score_element*,Direction, Item*head_l); static void set_interface (Score_element*); static bool has_interface (Score_element*); - VIRTUAL_COPY_CONS(Score_element); static Score_element * head (Score_element*,Direction) ; static Real position_f (Score_element*) ; static SCM brew_molecule (SCM); static Direction get_default_dir(Score_element*) ; - static SCM after_line_breaking (SCM); - - - /* - JUNKME - */ - Array get_encompass_offset_arr () const; - Bezier get_curve () const; - Drul_array dy_f_drul_; - Drul_array dx_f_drul_; + static SCM get_control_points (SCM); static SCM set_spacing_rods (SCM); - Array get_controls () const; }; #endif // TIE_HH diff --git a/lily/least-squares.cc b/lily/least-squares.cc index 737cbd6d58..4c63681fa5 100644 --- a/lily/least-squares.cc +++ b/lily/least-squares.cc @@ -36,8 +36,15 @@ minimise_least_squares (Real * coef, Real * offset, Real den = (N*sqx - sqr (sx)); if (!N || !den) - programming_error ("minimise_least_squares(): Nothing to minimise"); - - *coef = (N * sxy - sx*sy)/den; - *offset = (sy - (*coef) * sx)/N; + { + programming_error ("minimise_least_squares(): Nothing to minimise"); + *coef = 0.0; + *offset = N ? sy/N : 0.0; + } + else + { + *coef = (N * sxy - sx*sy)/den; + *offset = (sy - (*coef) * sx)/N; + } } + diff --git a/lily/local-key-item.cc b/lily/local-key-item.cc index 04445201ed..9cc338a48a 100644 --- a/lily/local-key-item.cc +++ b/lily/local-key-item.cc @@ -35,10 +35,8 @@ SCM Local_key_item::before_line_breaking (SCM smob) { Local_key_item* me = dynamic_cast(unsmob_element (smob)); - - me->accidental_arr_.sort (Local_key_cautionary_tuple::compare); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } Molecule @@ -79,7 +77,7 @@ Local_key_item::brew_molecule (SCM smob) bool oct_b = false; int lastoct = -100; - for (int i = 0; i < lki->accidental_arr_.size(); i++) + for (int i = 0; i < lki->accidental_arr_.size(); i++) { Musical_pitch p (lki->accidental_arr_[i].pitch_); // do one octave diff --git a/lily/lookup.cc b/lily/lookup.cc index 2b90ce5a79..4b7a9bdc53 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -111,6 +111,7 @@ Lookup::afm_find (String s, bool warn) const gh_int2scm (cm->code), SCM_UNDEFINED)); + at= fontify_atom (afm_l_,at); return Molecule ( afm_bbox_to_box (cm->charBBox), at); } diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc index ba2e2cbc24..bd177cea04 100644 --- a/lily/multi-measure-rest.cc +++ b/lily/multi-measure-rest.cc @@ -158,7 +158,7 @@ Multi_measure_rest::set_spacing_rods (SCM smob) if (!(sp->get_bound (LEFT) && sp->get_bound (RIGHT))) { programming_error ("Multi_measure_rest::get_rods (): I am not spanned!"); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } Item * l = sp->get_bound (LEFT)->column_l (); @@ -187,6 +187,6 @@ Multi_measure_rest::set_spacing_rods (SCM smob) rod.add_to_cols (); } - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index adfde15530..9020ae1659 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -100,7 +100,7 @@ My_lily_lexer::lookup_identifier (String s) for (int i = scope_l_arr_.size (); i--; ) if (scope_l_arr_[i]->elem_b (sym)) return scope_l_arr_[i]->scm_elem(sym); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } void diff --git a/lily/note-head.cc b/lily/note-head.cc index eb23429a89..505b75deb0 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -66,11 +66,13 @@ Note_head::brew_molecule (SCM smob) : (abs((int)p) - sz) /2; SCM style = me->get_elt_property ("style"); - if (style == SCM_UNDEFINED) + if (!gh_symbol_p (style)) { style = ly_symbol2scm("default"); } + + // ugh: use gh_call () Molecule out = me->lookup_l()->afm_find (String ("noteheads-") + ly_scm2string (scm_eval (gh_list (ly_symbol2scm("find-notehead-symbol"), me->get_elt_property ("duration-log"), diff --git a/lily/property-engraver.cc b/lily/property-engraver.cc index 3a6f547c91..35d19d162a 100644 --- a/lily/property-engraver.cc +++ b/lily/property-engraver.cc @@ -77,7 +77,7 @@ Property_engraver::apply_properties (SCM p, Score_element *e) SCM elt_prop_sym = gh_caddr (entry); SCM preset = e->get_elt_property (elt_prop_sym); // scm_assq(elt_prop_sym, e->property_alist_); - if (preset != SCM_UNDEFINED) + if (preset != SCM_EOL) continue; SCM val = get_property (prop_sym); diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 9d86cbb81b..5427a20c6d 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -96,11 +96,11 @@ Rest_collision::do_shift (Score_element *me, SCM elts) // no rests to collide if (!rests.size()) - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; // no partners to collide with if (rests.size() + notes.size () < 2) - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; // meisjes met meisjes if (!notes.size()) @@ -169,7 +169,7 @@ Rest_collision::do_shift (Score_element *me, SCM elts) Interval restdim = Note_column::rest_dim (rcol); if (restdim.empty_b ()) - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; // staff ref'd? Real staff_space = me->paper_l()->get_var ("interline"); @@ -210,7 +210,7 @@ Rest_collision::do_shift (Score_element *me, SCM elts) Note_column::translate_rests (rcol,dir * discrete_dist); } - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } void diff --git a/lily/rest.cc b/lily/rest.cc index 7f4e6cf4f7..e3a1de5043 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -34,7 +34,7 @@ Rest::after_line_breaking (SCM smob) gh_int2scm ((bt == 7) ? 4 : 3)); } - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } diff --git a/lily/score-element.cc b/lily/score-element.cc index 3c4af38059..f53cd8e9b2 100644 --- a/lily/score-element.cc +++ b/lily/score-element.cc @@ -102,7 +102,7 @@ Score_element::get_elt_property (SCM sym) const return gh_cdr (s); s = scm_sloppy_assq (sym, immutable_property_alist_); - return (s == SCM_BOOL_F) ? SCM_UNDEFINED : gh_cdr (s); + return (s == SCM_BOOL_F) ? SCM_EOL : gh_cdr (s); } /* @@ -114,8 +114,8 @@ SCM Score_element::remove_elt_property (const char* key) { SCM val = get_elt_property (key); - if (val != SCM_UNDEFINED) - set_elt_property (key, SCM_UNDEFINED); + if (val != SCM_EOL) + set_elt_property (key, SCM_EOL); return val; } @@ -762,7 +762,7 @@ ly_set_elt_property (SCM elt, SCM sym, SCM val) { error ("Not a symbol"); ly_display_scm (sym); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } if (sc) @@ -775,7 +775,7 @@ ly_set_elt_property (SCM elt, SCM sym, SCM val) ly_display_scm (elt); } - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } @@ -793,7 +793,7 @@ ly_get_elt_property (SCM elt, SCM sym) error ("Not a score element"); ly_display_scm (elt); } - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } diff --git a/lily/script-column-engraver.cc b/lily/script-column-engraver.cc index 02676f0145..73da380668 100644 --- a/lily/script-column-engraver.cc +++ b/lily/script-column-engraver.cc @@ -56,7 +56,7 @@ Script_column_engraver::do_post_move_processing () void Script_column_engraver::acknowledge_element( Score_element_info inf) { - if (Side_position::has_interface (inf.elem_l_)) + if (Side_position::has_interface (inf.elem_l_)) // ugh FIXME { Item *thing = dynamic_cast (inf.elem_l_); if (thing diff --git a/lily/script-column.cc b/lily/script-column.cc index 0da72b3d4b..15b2eb58e9 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -70,6 +70,6 @@ Script_column::before_line_breaking (SCM smob) } while (flip (&d) != DOWN); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } diff --git a/lily/script.cc b/lily/script.cc index 9cc53480a5..677dbd22d7 100644 --- a/lily/script.cc +++ b/lily/script.cc @@ -45,7 +45,7 @@ Script::after_line_breaking (SCM smob) Direction d = Side_position::get_direction (me); Side_position::set_direction (me,d); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } MAKE_SCHEME_CALLBACK(Script,brew_molecule); diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index cc6f70c219..e0082e84b0 100644 --- a/lily/separating-group-spanner.cc +++ b/lily/separating-group-spanner.cc @@ -92,7 +92,7 @@ Separating_group_spanner::set_spacing_rods (SCM smob) it->suicide (); } me->suicide (); - return SCM_UNDEFINED ; + return SCM_UNSPECIFIED ; } void diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index c6598c608d..de2d398b70 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -219,10 +219,11 @@ Side_position::add_staff_support (Score_element*me) void Side_position::set_axis (Score_element*me, Axis a) { + /* // prop transparent ? if (me->get_elt_property ("side-support-elements") == SCM_UNDEFINED) me->set_elt_property ("side-support-elements" ,SCM_EOL); - + */ if (!me->has_offset_callback_b (aligned_side, a)) me->add_offset_callback (aligned_side, a); } @@ -262,13 +263,13 @@ Side_position::set_padding (Score_element*me, Real p) bool Side_position::has_interface (Score_element*me) { - return me->get_elt_property ("side-support-elements") != SCM_UNDEFINED; + return me->get_elt_property ("side-support-elements") != SCM_EOL; } bool Side_position::supported_b (Score_element*me) { - SCM s =me->get_elt_property ("side-support-elements"); + SCM s = me->get_elt_property ("side-support-elements"); return s != SCM_UNDEFINED && s != SCM_EOL; } diff --git a/lily/slur-bezier-bow.cc b/lily/slur-bezier-bow.cc index 0dc7ba2418..e23f528a24 100644 --- a/lily/slur-bezier-bow.cc +++ b/lily/slur-bezier-bow.cc @@ -11,11 +11,66 @@ #include "slur-bezier-bow.hh" #include "main.hh" -Slur_bezier_bow::Slur_bezier_bow (Array encompass, Direction dir) - : Bezier_bow (encompass, dir) +Slur_bezier_bow::Slur_bezier_bow (Array encompass, Direction dir, + Real h_inf, Real r_0) { + h_inf_ = h_inf; + r_0_ = r_0; + alpha_ = 0; + dir_ = dir; + encompass_ = encompass; + to_canonical_form (); + + Real w = encompass_.top ()[X_AXIS] - encompass_[0][X_AXIS]; + curve_ = slur_shape (w, h_inf, r_0); } +Bezier +Slur_bezier_bow::get_bezier () const +{ + Bezier rv = curve_; + if (dir_ == DOWN) + { + rv.scale (1, -1); + } + + rv.rotate (alpha_); + rv.translate (origin_); + + return rv; +} + +void +Slur_bezier_bow::to_canonical_form () +{ + origin_ = encompass_[0]; + translate (&encompass_, -origin_); + + Offset delta = encompass_.top () - encompass_[0]; + alpha_ = delta.arg (); + + rotate (&encompass_, -alpha_); + if (dir_ == DOWN) + { + scale (&encompass_, 1, -1); + } + + while (encompass_.size () > 1 && encompass_[1][X_AXIS] <= 0.0) + { + programming_error ("Degenerate bow: infinite steepness reqd"); + encompass_.del (1); + } + + Real l = encompass_.top ()[X_AXIS]; + while (encompass_.size () > 1 && encompass_.top (1)[X_AXIS] >= l) + { + programming_error ("Degenerate bow: infinite steepness reqd"); + encompass_.del (encompass_.size ()-2); + } +} + + + void Slur_bezier_bow::blow_fit () { @@ -84,17 +139,21 @@ Slur_bezier_bow::area_x_gradients_array (Real area) return da; } +/* + ugh, should have another look, and use a regular optimization + algorithm, instead of this homebrew. +*/ void -Slur_bezier_bow::minimise_enclosed_area (Paper_def* paper_l, - Real default_height) +Slur_bezier_bow::minimise_enclosed_area (Paper_def* paper_l) { Real length = curve_.control_[3][X_AXIS]; + Real sb = paper_l->get_var ("slur_beautiful"); - Real beautiful = length * default_height * sb; + Real beautiful = sb * length * slur_height (length, h_inf_, r_0_); DEBUG_OUT << to_str ("Beautiful: %f\n", beautiful); DEBUG_OUT << to_str ("Length: %f\n", length); - DEBUG_OUT << to_str ("D-height: %f\n", default_height); + // DEBUG_OUT << to_str ("D-height: %f\n", default_height); DEBUG_OUT << to_str ("FitFac: %f\n", fit_factor ()); if (fit_factor () > 1.0) diff --git a/lily/slur.cc b/lily/slur.cc index f93069848d..19cabbc6c1 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -37,9 +37,7 @@ void Slur::set_interface (Score_element*me) { - me-> set_elt_property ("attachment", gh_cons (SCM_BOOL_F, SCM_BOOL_F)); - me->set_elt_property ("note-columns", SCM_EOL); - me->set_elt_property ("control-points", SCM_EOL); + me->set_elt_property ("attachment", gh_cons (SCM_BOOL_F, SCM_BOOL_F)); me->set_interface (ly_symbol2scm ("slur-interface")); } @@ -160,7 +158,7 @@ Slur::after_line_breaking (SCM smob) Score_element *me = unsmob_element (smob); set_extremities (me); set_control_points (me); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } void @@ -361,10 +359,12 @@ Slur::set_spacing_rods (SCM smob) Spanner*sp = dynamic_cast(me); r.item_l_drul_[LEFT] = sp->get_bound (LEFT); r.item_l_drul_[RIGHT] = sp->get_bound (RIGHT); - r.distance_f_ = me->paper_l ()->get_var ("slur_x_minimum"); + r.distance_f_ = + gh_scm2double (me->get_elt_property ("minimum-length")) + * me->paper_l ()->get_var ("staffspace"); r.add_to_cols (); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } @@ -376,7 +376,8 @@ SCM Slur::brew_molecule (SCM smob) { Score_element * me = unsmob_element (smob); - Real thick = me->paper_l ()->get_var ("slur_thickness"); + Real thick = me->paper_l ()->get_var ("stafflinethickness") * + gh_scm2double (me->get_elt_property ("thickness")); Bezier one = get_curve (me); Molecule a; @@ -392,20 +393,20 @@ Slur::brew_molecule (SCM smob) void Slur::set_control_points (Score_element*me) { - Slur_bezier_bow bb (get_encompass_offset_arr (me), - Directional_element_interface (me).get ()); - - Real staff_space = Staff_symbol_referencer::staff_space (me); - Real h_inf = me->paper_l ()->get_var ("slur_height_limit_factor") * staff_space; + Real staff_space = Staff_symbol_referencer::staff_space ((Score_element*)me); + Real h_inf = me->paper_l ()->get_var ("slur_height_limit_factor") * + staff_space; Real r_0 = me->paper_l ()->get_var ("slur_ratio"); - - bb.set_default_bezier (h_inf, r_0); + + Slur_bezier_bow bb (get_encompass_offset_arr (me), + Directional_element_interface (me).get (), + h_inf, r_0); if (bb.fit_factor () > 1.0) { Real length = bb.curve_.control_[3][X_AXIS]; - Real default_height = bb.get_default_height (h_inf, r_0, length); - bb.minimise_enclosed_area (me->paper_l(), default_height); + Real default_height = slur_height (length, h_inf, r_0); + bb.minimise_enclosed_area (me->paper_l()); Real bff = me->paper_l ()->get_var ("slur_force_blowfit"); bb.curve_.control_[1][Y_AXIS] *= bff; diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index 234be7314e..d032027005 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -327,7 +327,7 @@ Spacing_spanner::set_springs (SCM smob) farewell, cruel world */ me->suicide (); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } diff --git a/lily/span-bar.cc b/lily/span-bar.cc index eab329b9ea..e4e790da14 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -47,7 +47,7 @@ Span_bar::before_line_breaking (SCM smob) evaluate_empty (unsmob_element (smob)); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } Real diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc index b67c577954..85b52f5aab 100644 --- a/lily/staff-symbol-referencer.cc +++ b/lily/staff-symbol-referencer.cc @@ -142,6 +142,15 @@ Staff_symbol_referencer::set_position (Score_element*me,Real p) me->add_offset_callback (callback, Y_AXIS); } +/* + half of the height, in staff space. + */ +Real +Staff_symbol_referencer::staff_radius (Score_element*me) +{ + return (line_count (me) -1) / 2; +} + int compare_position (Score_element *const &a, Score_element * const &b) diff --git a/lily/stem.cc b/lily/stem.cc index a8583c450a..9a0f2b4688 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -378,7 +378,7 @@ Stem::before_line_breaking (SCM smob) } set_spacing_hints (me); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index 41b0dc3238..ae4be7d551 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -69,7 +69,7 @@ SCM System_start_delimiter::after_line_breaking (SCM smob) { try_collapse (unsmob_element (smob)); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } void diff --git a/lily/tie-column.cc b/lily/tie-column.cc index cd3badc526..346fa9992e 100644 --- a/lily/tie-column.cc +++ b/lily/tie-column.cc @@ -7,6 +7,7 @@ */ +#include "spanner.hh" #include "tie-column.hh" #include "group-interface.hh" #include "tie.hh" @@ -18,7 +19,6 @@ void Tie_column::set_interface (Score_element*me) { - me-> set_elt_property ("ties", SCM_EOL); me->set_interface (ly_symbol2scm ("tie-column")); me->set_extent_callback (0, X_AXIS); me->set_extent_callback (0, Y_AXIS); @@ -31,7 +31,7 @@ Tie_column::has_interface (Score_element*me) } void -Tie_column::add_tie (Score_element*me,Tie *s) +Tie_column::add_tie (Score_element*me,Score_element *s) { Pointer_group_interface g (me, "ties"); if (!g.count ()) @@ -46,8 +46,8 @@ Tie_column::add_tie (Score_element*me,Tie *s) int -tie_compare (Tie* const & s1, - Tie* const & s2) +tie_compare (Score_element* const & s1, + Score_element* const & s2) { return sign (Tie::position_f (s1) - Tie::position_f(s2)); } @@ -64,8 +64,8 @@ tie_compare (Tie* const & s1, void Tie_column::set_directions (Score_element*me) { - Link_array ties = - Pointer_group_interface__extract_elements (me, (Tie*)0, "ties"); + Link_array ties = + Pointer_group_interface__extract_elements (me, (Score_element*)0, "ties"); Direction d = Directional_element_interface (me).get (); @@ -74,7 +74,7 @@ Tie_column::set_directions (Score_element*me) { for (int i = ties.size (); i--;) { - Tie * t = ties[i]; + Score_element * t = ties[i]; Directional_element_interface (t).set (d); } return; @@ -82,7 +82,7 @@ Tie_column::set_directions (Score_element*me) if (ties.size () == 1) { - Tie * t = ties[0]; + Score_element * t = ties[0]; Directional_element_interface (t).set (Tie::get_default_dir (t)); return; } @@ -97,7 +97,7 @@ Tie_column::set_directions (Score_element*me) for (int i=ties.size(); i--; ) { - Tie * t = ties[i]; + Score_element * t = ties[i]; Real p = Tie::position_f (t); Direction d = (Direction) sign (p); if (!d) @@ -112,5 +112,5 @@ SCM Tie_column::after_line_breaking (SCM smob) { set_directions (unsmob_element (smob)); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index d3ac6c48cd..0f3f3b2300 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -13,6 +13,7 @@ #include "musical-request.hh" #include "tie.hh" #include "translator-group.hh" +#include "spanner.hh" #include "tie-column.hh" #include "pqueue.hh" #include "engraver.hh" @@ -50,7 +51,7 @@ class Tie_engraver : public Engraver Tie_req *req_l_; Array now_heads_; Array stopped_heads_; - Link_array tie_p_arr_; + Link_array tie_p_arr_; Spanner * tie_column_p_; @@ -178,7 +179,7 @@ Tie_engraver::process_acknowledged () SCM pair = gh_list_ref (head_list, gh_int2scm (i/2)); - Tie * p = new Tie (basic); + Spanner * p = new Spanner (basic); Tie::set_head (p,LEFT, dynamic_cast (unsmob_element (gh_car (pair)))); Tie::set_head (p,RIGHT, dynamic_cast (unsmob_element (gh_cdr (pair)))); @@ -187,7 +188,7 @@ Tie_engraver::process_acknowledged () } else for (SCM s = head_list; gh_pair_p (s); s = gh_cdr (s)) { - Tie * p = new Tie (basic); + Score_element * p = new Spanner (basic); Tie::set_interface (p); Tie::set_head (p, LEFT, dynamic_cast (unsmob_element (gh_caar (s)))); diff --git a/lily/tie.cc b/lily/tie.cc index 85332353a8..8e1cacf486 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -7,6 +7,7 @@ */ #include +#include "spanner.hh" #include "lookup.hh" #include "paper-def.hh" #include "tie.hh" @@ -20,6 +21,19 @@ #include "bezier-bow.hh" #include "stem.hh" +/* + tie: Connect two noteheads. + + What if we have + + c4 ~ \clef bass ; c4 or + + c4 \staffchange c4 + + do we have non-horizontal ties then? + */ + + void Tie::set_head (Score_element*me,Direction d, Item * head_l) { @@ -30,18 +44,13 @@ Tie::set_head (Score_element*me,Direction d, Item * head_l) me->add_dependency (head_l); } -Tie::Tie(SCM s) - : Spanner (s) -{ - dy_f_drul_[LEFT] = dy_f_drul_[RIGHT] = 0.0; - dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0; -} void Tie::set_interface (Score_element*me) { me->set_elt_property ("heads", gh_cons (SCM_EOL, SCM_EOL)); me->set_interface (ly_symbol2scm ("tie-interface")); } + bool Tie::has_interface (Score_element*me) { @@ -66,8 +75,9 @@ Tie::position_f (Score_element*me) /* - ugh: direction of the Tie is more complicated. See [Ross] p136 and further - */ + The direction of the Tie is more complicated (See [Ross] p136 and + further), the case of multiple ties is handled by Tie_column. +*/ Direction Tie::get_default_dir (Score_element*me) { @@ -82,93 +92,127 @@ Tie::get_default_dir (Score_element*me) } - -MAKE_SCHEME_CALLBACK(Tie,after_line_breaking); SCM -Tie::after_line_breaking (SCM smob) -{ - Tie*me = dynamic_cast (unsmob_element (smob)); - - if (!head (me,LEFT) && !head (me,RIGHT)) +Tie::get_control_points (SCM smob) +{ + Spanner*me = dynamic_cast (unsmob_element (smob)); + Direction headdir = CENTER; + if (head (me,LEFT)) + headdir = LEFT; + else if (head(me,RIGHT)) + headdir = RIGHT; + else { programming_error ("Tie without heads."); me->suicide (); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } - + if (!Directional_element_interface (me).get ()) Directional_element_interface (me).set (Tie::get_default_dir (me)); Real staff_space = Staff_symbol_referencer::staff_space (me); - Real half_space = staff_space / 2; - Real x_gap_f = me->paper_l ()->get_var ("tie_x_gap"); - Real y_gap_f = me->paper_l ()->get_var ("tie_y_gap"); - /* - Slur and tie placement [OSU] + Real x_gap_f = me->paper_l ()->get_var ("tie_x_gap"); - Ties: + Score_element* commonx = me->common_refpoint (me->get_bound (LEFT), X_AXIS); + commonx = me->common_refpoint (me->get_bound (RIGHT), X_AXIS); + + Score_element* l = me->get_bound (LEFT); + Score_element* r = me->get_bound (RIGHT); + Real width = r->relative_coordinate (commonx, X_AXIS) + + r->extent (X_AXIS)[LEFT] + - l->relative_coordinate (commonx, X_AXIS) + - l->extent (X_AXIS)[RIGHT] + -2* x_gap_f; + + Real left_x = l->extent (X_AXIS)[RIGHT] + x_gap_f; + + Direction dir = Directional_element_interface (me).get(); + + Real h_inf = me->paper_l ()->get_var ("tie_height_limit_factor") * staff_space; + Real r_0 = me->paper_l ()->get_var ("tie_ratio"); - * x = inner vertical tangent - d * gap - */ + Bezier b = slur_shape (width, h_inf, r_0); + + Offset leave_dir = b.control_[1] - b.control_[0]; + Real dx = (head (me, headdir)->extent (X_AXIS).length () + x_gap_f)/2.0; + Real max_gap = leave_dir[Y_AXIS] * dx / leave_dir[X_AXIS]; /* - OSU: not different for outer notes, so why all me code? - ie, can we drop me, or should it be made switchable. - */ - if (head (me,LEFT)) - me->dx_f_drul_[LEFT] = Tie::head (me,LEFT)->extent (X_AXIS).length (); - else - me->dx_f_drul_[LEFT] = dynamic_cast(me)->get_broken_left_end_align (); - me->dx_f_drul_[LEFT] += x_gap_f; - me->dx_f_drul_[RIGHT] -= x_gap_f; + for small ties (t small) we want to start in the Y-center (so dy = 0), for + large ties, the tie should appear to come from the center of the + head, so dy = max_gap - /* - Slur and tie placement [OSU] -- check me + maybe use a different formula? - Ties: + TODO: what if 2 heads have different size. - * y = dx < 5ss: horizontal tangent - y = dx >= 5ss: y next interline - d * 0.25 ss + TODO: for small ties, it is better to start over the heads + iso. next to the heads. + */ + Real t = (width / staff_space - 5.0); // ugh. + Real dy = t > 0 ? max_gap * sqr (t / (1 + t)) : 0.0; - which probably means that OSU assumes that + Real ypos = Tie::position_f (me) * staff_space/2 + dir * dy; - dy <= 5 dx + /* + todo: prevent ending / staffline collision. - for smal slurs + todo: tie / stem collision */ + b = slur_shape(width,h_inf, r_0); + b.scale (1, dir); + b.translate (Offset (left_x, ypos)); + - Real ypos = Tie::position_f (me); + /* + Avoid colliding of the horizontal part with stafflines. + + should do me for slurs as well. - Real y_f = half_space * ypos; - int ypos_i = int (ypos); - - Real dx_f = me->extent (X_AXIS).length () + me->dx_f_drul_[RIGHT] - me->dx_f_drul_[LEFT]; - Direction dir = Directional_element_interface (me).get(); - if (dx_f < me->paper_l ()->get_var ("tie_staffspace_length")) + */ + Array horizontal (b.solve_derivative (Offset (1,0))); + if (horizontal.size ()) { - if (abs (ypos_i) % 2) - y_f += dir * half_space; - y_f += dir * y_gap_f; + /* + ugh. Doesnt work for non-horizontal curves. + */ + Real y = b.curve_point (horizontal[0])[Y_AXIS]; + + Real ry = rint (y/staff_space) * staff_space; + Real diff = ry - y; + Real newy = y; + if (fabs (y) <= Staff_symbol_referencer::staff_radius (me) + && fabs (diff) < me->paper_l ()->get_var ("tie_staffline_clearance")) + { + newy = ry - 0.5 * staff_space * sign (diff) ; + } + + Real y0 = b.control_ [0][Y_AXIS]; + b.control_[2][Y_AXIS] = + b.control_[1][Y_AXIS] = + (b.control_[1][Y_AXIS] - y0) * ((newy - y0) / (y - y0)) + y0; } else - { - if (! (abs (ypos_i) % 2)) - y_f += dir * half_space; - y_f += dir * half_space; - y_f -= dir * y_gap_f; - } - - me->dy_f_drul_[LEFT] = me->dy_f_drul_[RIGHT] = y_f; + programming_error ("Tie is nowhere horizontal"); - return SCM_UNDEFINED; -} + SCM controls = SCM_EOL; + for (int i= 4; i--;) + controls = gh_cons ( ly_offset2scm (b.control_[i]), controls); + return controls; +} + MAKE_SCHEME_CALLBACK(Tie,set_spacing_rods); + +/* + TODO: set minimum distances for begin/end of line + */ SCM Tie::set_spacing_rods (SCM smob) { @@ -179,94 +223,41 @@ Tie::set_spacing_rods (SCM smob) r.item_l_drul_ [LEFT]=sp->get_bound (LEFT); r.item_l_drul_ [RIGHT]=sp->get_bound (RIGHT); - r.distance_f_ = me->paper_l ()->get_var ("tie_x_minimum"); + r.distance_f_ + = gh_scm2double (me->get_elt_property ("minimum-length")) + * me->paper_l ()->get_var ("staffspace"); r.add_to_cols (); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } - - - - - MAKE_SCHEME_CALLBACK(Tie,brew_molecule); SCM Tie::brew_molecule (SCM smob) { Score_element*me = unsmob_element (smob); - Real thick = me->paper_l ()->get_var ("tie_thickness"); - Bezier one = dynamic_cast (me)->get_curve (); - Molecule a; - SCM d = me->get_elt_property ("dashed"); - if (gh_number_p (d)) - a = me->lookup_l ()->dashed_slur (one, thick, gh_scm2int (d)); - else - a = me->lookup_l ()->slur (one, Directional_element_interface (me).get () * thick, thick); + SCM cp = me->get_elt_property ("control-points"); + if (cp == SCM_EOL) + { + cp = get_control_points (smob); + me->set_elt_property ("control-points", cp); + } - return a.create_scheme(); -} - - + Real thick = + gh_scm2double (me->get_elt_property ("thickness")) + * me->paper_l ()->get_var ("stafflinethickness"); -Bezier -Tie::get_curve () const -{ - Score_element*me = (Score_element*)this; - Direction d (Directional_element_interface (me).get ()); - Bezier_bow b (get_encompass_offset_arr (), d); - - Real staff_space = Staff_symbol_referencer::staff_space (me); - Real h_inf = paper_l ()->get_var ("tie_height_limit_factor") * staff_space; - Real r_0 = paper_l ()->get_var ("tie_ratio"); - - b.set_default_bezier (h_inf, r_0); - Bezier c = b.get_bezier (); - - /* - Avoid colliding of the horizontal part with stafflines. - - should do me for slurs as well. - - */ - Array horizontal (c.solve_derivative (Offset (1,0))); - - - if (horizontal.size ()) + Bezier b; + int i = 0; + for (SCM s= cp; s != SCM_EOL; s = gh_cdr (s)) { - /* - ugh. Doesnt work for non-horizontal curves. - */ - Real y = c.curve_point (horizontal[0])[Y_AXIS]; - - Real ry = rint (y/staff_space) * staff_space; - Real diff = ry - y; - Real newy = y; - if (fabs (y) <= 2.0 - && fabs (diff) < paper_l ()->get_var ("tie_staffline_clearance")) - { - newy = ry - 0.5 * staff_space * sign (diff) ; - } - - Real y0 = c.control_ [0][Y_AXIS]; - c.control_[2][Y_AXIS] = - c.control_[1][Y_AXIS] = - (c.control_[1][Y_AXIS] - y0) * ((newy - y0) / (y - y0)) + y0; + b.control_[i] = ly_scm2offset (gh_car (s)); + i++; } - else - programming_error ("Tie is nowhere horizontal"); - return c; -} - -Array -Tie::get_encompass_offset_arr () const -{ - Array offset_arr; - offset_arr.push (Offset (dx_f_drul_[LEFT], dy_f_drul_[LEFT])); - offset_arr.push (Offset (spanner_length () + dx_f_drul_[RIGHT], - dy_f_drul_[RIGHT])); - - return offset_arr; + + Molecule a = me->lookup_l ()->slur (b, Directional_element_interface (me).get () * thick, thick); + + return a.create_scheme (); } diff --git a/lily/translator-group.cc b/lily/translator-group.cc index 4e1bf9212a..62de8aa634 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -453,7 +453,6 @@ Translator_group::get_property (SCM sym) const if (daddy_trans_l_) return daddy_trans_l_->get_property (sym); - return SCM_UNDEFINED; } diff --git a/lily/tuplet-spanner.cc b/lily/tuplet-spanner.cc index 10ddf98876..a86a222c84 100644 --- a/lily/tuplet-spanner.cc +++ b/lily/tuplet-spanner.cc @@ -128,7 +128,8 @@ Tuplet_spanner::calc_position_and_height (Score_element*me,Real *offset, Real * Pointer_group_interface__extract_elements (me, (Score_element*)0, "columns"); - Score_element * common = me->common_refpoint (me->get_elt_property ("columns"), Y_AXIS); + Score_element * commony = me->common_refpoint (me->get_elt_property ("columns"), Y_AXIS); + Score_element * commonx = me->common_refpoint (me->get_elt_property ("columns"), X_AXIS); Direction d = Directional_element_interface (me).get (); @@ -145,8 +146,8 @@ Tuplet_spanner::calc_position_and_height (Score_element*me,Real *offset, Real * if (l < r) { - *dy = column_arr[r]->extent (Y_AXIS) [d] + column_arr[r]->relative_coordinate (common, Y_AXIS) - - column_arr[l]->extent (Y_AXIS) [d] - column_arr[l]->relative_coordinate (common, Y_AXIS); + *dy = column_arr[r]->extent (Y_AXIS) [d] + column_arr[r]->relative_coordinate (commony, Y_AXIS) + - column_arr[l]->extent (Y_AXIS) [d] - column_arr[l]->relative_coordinate (commony, Y_AXIS); } else * dy = 0; @@ -157,17 +158,18 @@ Tuplet_spanner::calc_position_and_height (Score_element*me,Real *offset, Real * if (!column_arr.size ()) return; - Real x0 = column_arr[0]->relative_coordinate (0, X_AXIS); - Real x1 = column_arr.top ()->relative_coordinate (0, X_AXIS); + Real x0 = column_arr[0]->relative_coordinate (commonx, X_AXIS); + Real x1 = column_arr.top ()->relative_coordinate (commonx, X_AXIS); Real factor = column_arr.size () > 1 ? 1/(x1 - x0) : 1.0; for (int i = 0; i < column_arr.size (); i++) { - Real notey = column_arr[i]->extent (Y_AXIS)[d] + - column_arr[i]->relative_coordinate (common, Y_AXIS) - ; - Real x = column_arr[i]->relative_coordinate (0, X_AXIS) - x0; + Real notey = column_arr[i]->extent (Y_AXIS)[d] + + column_arr[i]->relative_coordinate (commony, Y_AXIS) + - me->relative_coordinate (commony, Y_AXIS); + + Real x = column_arr[i]->relative_coordinate (commonx, X_AXIS) - x0; Real tuplety = *dy * x * factor; if (notey * d > (*offset + tuplety) * d) @@ -202,7 +204,7 @@ Tuplet_spanner::after_line_breaking (SCM smob) if (!column_arr.size ()) { me->suicide (); - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } Direction d = Directional_element_interface (me).get (); @@ -230,7 +232,7 @@ Tuplet_spanner::after_line_breaking (SCM smob) && sp->get_bound (RIGHT)->column_l () == beam_l->get_bound (RIGHT)->column_l ()) me->set_elt_property ("parallel-beam", SCM_BOOL_T); } - return SCM_UNDEFINED; + return SCM_UNSPECIFIED; } diff --git a/lily/volta-spanner.cc b/lily/volta-spanner.cc index 38052c5ba2..295e1665ae 100644 --- a/lily/volta-spanner.cc +++ b/lily/volta-spanner.cc @@ -29,7 +29,7 @@ Volta_spanner::set_interface (Score_element*me) /* - me is too complicated. Yet another version of side-positioning, + this is too complicated. Yet another version of side-positioning, badly implemented. -- @@ -71,6 +71,9 @@ Volta_spanner::brew_molecule (SCM smob) Real h = me->paper_l()->get_var ("volta_spanner_height"); Real t = me->paper_l ()->get_var ("volta_thick"); + /* + ugh: should build from line segments. + */ SCM at = (gh_list (ly_symbol2scm ("volta"), gh_double2scm (h), gh_double2scm (w), diff --git a/ly/engraver.ly b/ly/engraver.ly index da81fa71ef..f458dda6c0 100644 --- a/ly/engraver.ly +++ b/ly/engraver.ly @@ -598,7 +598,9 @@ ScoreContext = \translator { ) basicSlurProperties = #`( (molecule-callback . ,Slur::brew_molecule) - (spacing-procedure . ,Slur::set_spacing_rods) + (thickness . 1.2) + (spacing-procedure . ,Slur::set_spacing_rods) e + (minimum-length . 1.5) (after-line-breaking-callback . ,Slur::after_line_breaking) ) basicSpacingSpannerProperties =#`( @@ -662,8 +664,9 @@ ScoreContext = \translator { ) basicTieProperties = #`( (molecule-callback . ,Tie::brew_molecule) - (after-line-breaking-callback . ,Tie::after_line_breaking) - (spacing-procedure . ,Tie::set_spacing_rods) + (spacing-procedure . ,Tie::set_spacing_rods) + (thickness . 1.2) + (minimum-length . 2.5) (interfaces . (tie-interface)) ) basicTieColumnProperties = #`( diff --git a/ly/params.ly b/ly/params.ly index ba6494591d..e864388366 100644 --- a/ly/params.ly +++ b/ly/params.ly @@ -132,20 +132,13 @@ bezier_area_steps = 1.0; Tie parameters %} -tie_height_limit_factor = \slur_height_limit_factor; +tie_height_limit_factor = 1.0 ; tie_ratio = \slur_ratio; -tie_thickness = \slur_thickness; -tie_x_minimum = \staffspace + \slur_x_minimum; % OSU: tie gap == slur gap tie_x_gap = \slur_x_gap; -tie_y_gap = 0.25 * \staffspace; -% length of a tie that's a staffspace high -tie_staffspace_length = 4.0 * \staffspace; - -tie_staffline_clearance = 2.0 *\tie_thickness; - +tie_staffline_clearance = 2.0 *\slur_thickness; % ugh diff --git a/scm/paper.scm b/scm/paper.scm index a615f9564f..9e8146da48 100644 --- a/scm/paper.scm +++ b/scm/paper.scm @@ -129,11 +129,3 @@ (define stem-shorten '(0.5)) (define grace-stem-shorten '(0.0)) -;; urg -(define pi (* 2 (acos 0))) - -(define (slur-default-height h-inf r-0 b) - (let ((alpha (/ (* 2.0 h-inf) pi)) - (beta (/ (* pi r-0) (* 2.0 h-inf)))) - (* alpha (atan (* beta b))))) - -- 2.39.5