From 18ca67c0dec3675d197520fdd77978c9df04505c Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 17 Jul 2004 01:05:51 +0000 Subject: [PATCH] * scm/define-grobs.scm: switch on new-slur by default. * lily/scm-option.cc: symbol != string. * lily/new-slur.cc (set_end_points): handle broken slurs. Doesn't really work yet. (set_end_points): make X coord of attachment dependent on Y. (score_encompass): add edges too. --- ChangeLog | 13 + .../W.A.Mozart/mozart-hrn3-allegro.ily | 2 +- input/{test => regression}/new-slur.ly | 20 +- input/regression/slur-broken-trend.ly | 35 +- lily/include/main.hh | 1 + lily/include/stem.hh | 1 + lily/new-slur.cc | 346 +++++++++++------- lily/scm-option.cc | 9 +- lily/stem.cc | 12 + scm/define-grobs.scm | 14 +- 10 files changed, 300 insertions(+), 153 deletions(-) rename input/{test => regression}/new-slur.ly (70%) diff --git a/ChangeLog b/ChangeLog index 0db1579b0e..259875c5eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ +2004-07-17 Han-Wen Nienhuys + + * scm/define-grobs.scm: switch on new-slur by default. + + * lily/scm-option.cc: symbol != string. + + * lily/new-slur.cc (set_end_points): handle broken slurs. Doesn't + really work yet. + (set_end_points): make X coord of attachment dependent on Y. + (score_encompass): add edges too. + 2004-07-16 Han-Wen Nienhuys + * lily/stem.cc (get_beaming): new function. + * scripts/lilypond-book.py (compose_ly): make fragment mandatory for fragment snippets. This fixes inclusion of toplevel-music examples (such as new-slur.ly) diff --git a/input/mutopia/W.A.Mozart/mozart-hrn3-allegro.ily b/input/mutopia/W.A.Mozart/mozart-hrn3-allegro.ily index d6c47d5b7a..b51ac1f0bb 100644 --- a/input/mutopia/W.A.Mozart/mozart-hrn3-allegro.ily +++ b/input/mutopia/W.A.Mozart/mozart-hrn3-allegro.ily @@ -175,7 +175,7 @@ allegro = g4 \times 2/3 { r8 c8[( g)] } \times 2/3 { e[ ( g) e-. ] } \times 2/3 { c[ ( e) c-.] }| g4 r8 g'\f a[ b c d]| - << d1(\trill + << d1_(\trill { s2 \grace { \override Stem #'stroke-style = #"grace" c16[ d] diff --git a/input/test/new-slur.ly b/input/regression/new-slur.ly similarity index 70% rename from input/test/new-slur.ly rename to input/regression/new-slur.ly index e31234002a..b822ba30f4 100644 --- a/input/test/new-slur.ly +++ b/input/regression/new-slur.ly @@ -1,16 +1,26 @@ -% breaks web +\header { + texidoc = "Scoring based slur formatting." +} + \paper { raggedright = ##t } +% #(ly:set-option 'debug-beam #t) \relative { - - \override Slur #'after-line-breaking-callback = #New_slur::after_line_breaking \override Slur #'print-function = #New_slur::print \override Slur #'height = ##f + + \grace { + e=''16( + } + d8.[) c16] + d8.[ \grace f16( e16)] + + f'=''16( e) d( c) c'=''2(~c8 d16 c b8 a) f='4 @@ -24,6 +34,6 @@ c,^( c'' c) c,,^( c'') c,,^( c') - -} + } +% #(ly:set-option 'debug-beam #f) diff --git a/input/regression/slur-broken-trend.ly b/input/regression/slur-broken-trend.ly index 4c435c60cc..aec1dce799 100644 --- a/input/regression/slur-broken-trend.ly +++ b/input/regression/slur-broken-trend.ly @@ -9,17 +9,28 @@ staff. A slur should follow the same vertical direction it would have in unbroken state. " } -\score{ - \relative c''{ - e1( \break a,) - \time 2/4 - e'2( \break a,)(\break - a2\break - e'2) - } - \paper { - linewidth=40.\mm - indent=0. - } +\paper { + linewidth=40.\mm + indent=0. +} + +\relative c''{ + \override Slur #'after-line-breaking-callback = #New_slur::after_line_breaking + \override Slur #'print-function = #New_slur::print + \override Slur #'height = ##f + + e1( \break a,) + \time 2/4 + e'2( \break a,)(\break + a2\break + e'2) + \time 4/4 + << d1_(\trill + { s2 \grace { + c16[ d] + } } + >> + \break + c4) } diff --git a/lily/include/main.hh b/lily/include/main.hh index a26d7f372c..62aeb4fbea 100644 --- a/lily/include/main.hh +++ b/lily/include/main.hh @@ -35,6 +35,7 @@ extern bool safe_global_b; extern bool verbose_global_b; extern bool store_locations_global_b; extern bool internal_type_checking_global_b; +extern bool debug_beam_quanting_flag; /* misc */ diff --git a/lily/include/stem.hh b/lily/include/stem.hh index d1060f432b..e3078a13d6 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -18,6 +18,7 @@ public: static Array note_head_positions (Grob *); static int duration_log (Grob *); static void set_beaming (Grob *, int, Direction d); + static int get_beaming (Grob *, Direction d); static Grob *get_beam (Grob *); static Grob *first_head (Grob *); static Grob *last_head (Grob *); diff --git a/lily/new-slur.cc b/lily/new-slur.cc index fdef450f4f..fe20bcfde8 100644 --- a/lily/new-slur.cc +++ b/lily/new-slur.cc @@ -10,6 +10,7 @@ #include +#include "main.hh" #include "font-interface.hh" #include "text-item.hh" #include "directional-element-interface.hh" @@ -49,6 +50,28 @@ struct Encompass_info { } }; +struct Bound_info { + + Box stem_extent_; + Direction stem_dir_; + Grob *bound_; + Grob *note_column_; + Grob *slur_head_; + Grob *staff_; + Grob *stem_; + Interval slur_head_extent_; + Real neighbor_y_; + + Bound_info () { + stem_ = 0; + neighbor_y_ = 0; + staff_ = 0; + slur_head_ = 0; + stem_dir_ = CENTER; + note_column_ = 0; + } +}; + /* TODO: put in details list. */ @@ -62,7 +85,7 @@ const Real SAME_SLOPE_PENALTY = 20; const Real STEEPER_SLOPE_FACTOR = 50; const Real NON_HORIZONTAL_PENALTY = 15; const Real HEAD_STRICT_FREE_SPACE = 0.2; -const Real MAX_SLOPE = 1.4; +const Real MAX_SLOPE = 1.1; const Real MAX_SLOPE_FACTOR = 10; @@ -87,10 +110,13 @@ class New_slur public: static void add_column (Grob *me, Grob *col); DECLARE_SCHEME_CALLBACK (print, (SCM)); - static void score_slopes (Grob * me, Grob *common[], Drul_array base_attach, + static void score_slopes (Grob * me, Grob *common[], + Drul_array, + Drul_array base_attach, Array * scores); static void score_encompass (Grob * me, Grob *common[], + Drul_array, Drul_array, Array * scores); static void set_interface (Grob*); static bool has_interface (Grob*); @@ -103,7 +129,7 @@ public: private: static void set_end_points (Grob*); static Real get_boundary_notecolumn_y (Grob *me, Direction dir); - static Offset broken_trend_offset (Grob *me, Direction dir); + static Real broken_trend_y (Grob *me, Grob**, Direction dir); static Offset get_attachment (Grob *me,Direction dir, Grob **common); static void de_uglyfy (Grob *me,Slur_bezier_bow* bb, Real default_height); static SCM set_extremities (Grob *me); @@ -112,6 +138,59 @@ private: static Encompass_info get_encompass_info (Grob *me, Grob *col, Grob **common); }; +Real +New_slur::broken_trend_y (Grob *me, Grob**common, Direction hdir) +{ + /* + A broken slur should maintain the same vertical trend + the unbroken slur would have had. + */ + Real by = 0.0; + if (Spanner *mother = dynamic_cast (me->original_)) + { + int k = broken_spanner_index (dynamic_cast (me)); + int j = k + hdir; + if (j < 0 || j >= mother->broken_intos_.size ()) + return by; + + Grob *neighbor = mother->broken_intos_[j]; + if (hdir == RIGHT) + neighbor->set_property ("direction", + me->get_property ("direction")); + + Spanner * common_mother = dynamic_cast (common[Y_AXIS]->original_); + int common_k = broken_spanner_index (dynamic_cast (common[Y_AXIS])); + int common_j = common_k + hdir; + + if (common_j < 0 || common_j >= common_mother->broken_intos_.size()) + return by; + + + Grob *common_next_system = common_mother->broken_intos_[common_j]; + Link_array neighbor_cols = + Pointer_group_interface__extract_grobs (neighbor, (Grob*)0, "note-columns"); + + Grob * neighbor_col = (hdir == RIGHT) ? neighbor_cols[0] : neighbor_cols.top (); + Grob * neighbor_common = common_next_system->common_refpoint (neighbor_col, Y_AXIS); + + Direction vdir = get_grob_direction (me); + Real neighbor_y = + neighbor_col->extent (neighbor_common, Y_AXIS) + .linear_combination (int(neighbor_cols.size()==1 ? CENTER : vdir)) + - common_next_system->relative_coordinate (neighbor_common, Y_AXIS); + + Link_array my_cols = + Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns"); + + Grob *extreme_col = (hdir == RIGHT) ? my_cols.top() : my_cols[0]; + Real y = extreme_col->extent (common[Y_AXIS], Y_AXIS).linear_combination (vdir); + + by = (y*neighbor_cols.size() + neighbor_y*my_cols.size()) / + (my_cols.size() + neighbor_cols.size()); + } + return by; +} + void New_slur::set_interface (Grob*me) { @@ -144,7 +223,7 @@ New_slur::get_encompass_info (Grob *me, { programming_error ("No stem for note column?"); ei.x_ = col->relative_coordinate (common[X_AXIS], X_AXIS); - ei.head_ = ei.stem_ = col->relative_coordinate (common[Y_AXIS], Y_AXIS); + ei.head_ = ei.stem_ = col->extent (common[Y_AXIS], Y_AXIS)[get_grob_direction (me)]; return ei; } Direction stem_dir = get_grob_direction (stem); @@ -157,7 +236,7 @@ New_slur::get_encompass_info (Grob *me, Grob * h = Stem::extremal_heads (stem)[Direction (dir)]; if (!h) { - ei.head_ = ei.stem_ = col->relative_coordinate (common[Y_AXIS], Y_AXIS); + ei.head_ = ei.stem_ = col->extent (common[Y_AXIS], Y_AXIS)[dir]; return ei; } @@ -208,10 +287,6 @@ New_slur::after_line_breaking (SCM smob) set_grob_direction (me, get_default_dir (me)); - if (!Note_column::has_interface (me->get_bound (LEFT)) - || !Note_column::has_interface (me->get_bound (RIGHT))) - me->suicide (); // fixme. - set_end_points (me); return SCM_UNSPECIFIED; @@ -244,8 +319,8 @@ New_slur::set_end_points (Grob *me) return ; } Real staff_space = Staff_symbol_referencer::staff_space ((Grob*)me); - Drul_array extremes (columns[0], columns.top ()); - Direction dir = get_grob_direction (me); + Real minimum_length = staff_space * robust_scm2double (me->get_property ("minimum-length"), + 2.0); Drul_array base_attachment; @@ -258,72 +333,95 @@ New_slur::set_end_points (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); - Direction d = LEFT; - Drul_array staves; + + Drul_array extremes; + Direction dir = get_grob_direction (me); + + Direction d = LEFT; do { - Grob *stem = Note_column::get_stem (extremes[d]); - Grob * h = Stem::extremal_heads (stem)[Direction (dir)]; - staves[d] = Staff_symbol_referencer::get_staff_symbol (h); - - common[Y_AXIS] = common[Y_AXIS]->common_refpoint (staves[d], Y_AXIS); + extremes[d].bound_ = dynamic_cast (me)->get_bound (d); + + if (Note_column::has_interface (extremes[d].bound_)) + { + extremes[d].note_column_ = extremes[d].bound_; + extremes[d].stem_ = Note_column::get_stem (extremes[d].note_column_); + extremes[d].stem_dir_ = get_grob_direction (extremes[d].stem_); + extremes[d].stem_extent_[X_AXIS] = extremes[d].stem_->extent (common[X_AXIS], X_AXIS); + extremes[d].stem_extent_[Y_AXIS] = extremes[d].stem_->extent (common[Y_AXIS], Y_AXIS); + extremes[d].slur_head_ = Stem::extremal_heads (extremes[d].stem_)[dir]; + extremes[d].slur_head_extent_ = extremes[d].slur_head_->extent (common[X_AXIS], X_AXIS); + extremes[d].staff_ = Staff_symbol_referencer::get_staff_symbol (extremes[d].slur_head_); + } + else + { + extremes[d].neighbor_y_ = broken_trend_y (me, common, d); + } } while (flip (&d) != LEFT); do { - // c&p - Grob *stem = Note_column::get_stem (extremes[d]); - Grob * h = Stem::extremal_heads (stem)[dir]; - Real y; - if (stem - && get_grob_direction (stem) == dir - && Stem::get_beam (stem)) + Grob *stem = extremes[d].stem_; + Grob *head = extremes[d].slur_head_; + + Real x,y; + if (!extremes[d].note_column_) { - y = stem->extent (common[Y_AXIS], Y_AXIS)[dir]; + y = extremes[d].neighbor_y_; + if (d== RIGHT) + x = extremes[d].bound_->extent (common[X_AXIS], X_AXIS)[d]; + else + x = sp->get_broken_left_end_align (); } else { - y = h->extent (common[Y_AXIS], Y_AXIS)[dir]; - } - - y += dir * 0.5 * staff_space; - - Grob * staff = Staff_symbol_referencer::get_staff_symbol (h); - Real pos = 2.0 * (y - staff->relative_coordinate (common[Y_AXIS], Y_AXIS)) - / Staff_symbol::staff_space (staff); - - - /* - start off staffline. - */ - if (fabs (pos - round (pos)) < 0.2 - && Staff_symbol_referencer::on_staffline (h, (int) rint (pos)) - && Staff_symbol_referencer::line_count (h) -1 >= rint (pos) - ) + if (stem + && extremes[d].stem_dir_ == dir + && Stem::get_beaming (stem, -d) + && columns.size () > 2 + ) + { + y = extremes[d].stem_extent_[Y_AXIS][dir]; + } + else if (head) + { + y = head->extent (common[Y_AXIS], Y_AXIS)[dir]; + } + y += dir * 0.5 * staff_space; + + Real pos = 2.0 * (y - extremes[d].staff_->relative_coordinate (common[Y_AXIS], Y_AXIS)) + / Staff_symbol::staff_space (extremes[d].staff_); + + /* + start off staffline. + */ + if (fabs (pos - round (pos)) < 0.2 + && Staff_symbol_referencer::on_staffline (head, (int) rint (pos)) + && Staff_symbol_referencer::line_count (head) -1 >= rint (pos) + ) y += staff_space * dir / 10 ; - - - Grob * fh = Note_column::first_head (extremes[d]); - Real x = fh->extent (common[X_AXIS], X_AXIS).linear_combination (CENTER); - - if (get_grob_direction (stem) == dir - && dir == -d) - { - x -= d * fh->extent(fh, X_AXIS).length (); + Grob * fh = Note_column::first_head (extremes[d].note_column_); + x = fh->extent (common[X_AXIS], X_AXIS).linear_combination (CENTER); } - base_attachment[d] = Offset (x, y); } while (flip (&d) != LEFT); - Drul_array staff_offsets; + Interval end_ys; - do { - staff_offsets[d] = staves[d]->relative_coordinate (common[Y_AXIS], Y_AXIS); - end_ys[d] = dir * ((dir * (base_attachment[d][Y_AXIS] + 4.0 *dir)) >? - (dir * (dir + extremes[d]->extent(common[Y_AXIS],Y_AXIS)[dir]))); + if (extremes[d].note_column_) + { + end_ys[d] = dir * ((dir * (base_attachment[d][Y_AXIS] + 4.0 *dir)) + >? (dir * (dir + extremes[d].note_column_->extent(common[Y_AXIS],Y_AXIS)[dir])) + >? (dir * base_attachment[-d][Y_AXIS]) + ); + } + else + { + end_ys[d] = extremes[d].neighbor_y_ + 4.0 * dir ; + } } while (flip (&d) != LEFT); Array scores; @@ -333,30 +431,51 @@ New_slur::set_end_points (Grob *me) /*ugh. */ os[LEFT] = base_attachment[LEFT]; - for (int i = 0; dir * os[LEFT][Y_AXIS] < dir * end_ys[LEFT]; i++) + for (int i = 0; dir * os[LEFT][Y_AXIS] <= dir * end_ys[LEFT]; i++) { os[RIGHT] = base_attachment[RIGHT]; - for (int j = 0; dir *os[RIGHT][Y_AXIS] < dir * end_ys[RIGHT]; j++) + for (int j = 0; dir *os[RIGHT][Y_AXIS] <= dir * end_ys[RIGHT]; j++) { Slur_score s; - s.attachment_ = os; + Direction d = LEFT; + + do { + os[d][X_AXIS] = base_attachment[d][X_AXIS]; + if (extremes[d].stem_ + && !Stem::is_invisible (extremes[d].stem_) + && extremes[d].stem_dir_ == dir + && dir == -d) + { + if (extremes[d].stem_extent_[Y_AXIS].contains (os[d][Y_AXIS])) + { + os[d][X_AXIS] -= d * extremes[d].slur_head_extent_.length (); + } + else if (dir *extremes[d].stem_extent_[Y_AXIS][dir] < dir * os[d][Y_AXIS]) + { + os[d][X_AXIS] = extremes[d].stem_extent_[X_AXIS].center(); + } + } + } while (flip (&d) != LEFT); + + Offset dz = os[RIGHT] - os[LEFT]; + if (dz[X_AXIS] < minimum_length + || fabs (dz[Y_AXIS] / dz[X_AXIS]) > MAX_SLOPE + ) + { + do { + if (extremes[d].slur_head_) + os[d][X_AXIS] = extremes[d].slur_head_extent_.center (); + } while (flip (&d) != LEFT); + } + + s.attachment_ = os; scores.push (s); - - Real incr = dir * staff_space; - if (Staff_symbol_referencer::staff_radius (staves[RIGHT]) - < fabs ((os[RIGHT][Y_AXIS] - staff_offsets[RIGHT]) / staff_space)) - incr /= 2; - - os[RIGHT][Y_AXIS] += incr; + + os[RIGHT][Y_AXIS] += dir * staff_space / 2; } - Real incr = dir * staff_space; - if (Staff_symbol_referencer::staff_radius (staves[LEFT]) - < fabs ((os[LEFT][Y_AXIS] - staff_offsets[LEFT]) / staff_space)) - incr /= 2; - - os[LEFT][Y_AXIS] += incr; + os[LEFT][Y_AXIS] += dir * staff_space /2 ; } { @@ -369,8 +488,8 @@ New_slur::set_end_points (Grob *me) } } - score_encompass (me, common, base_attachment, &scores); - score_slopes (me, common, base_attachment, &scores); + score_encompass (me, common, extremes, base_attachment, &scores); + score_slopes (me, common, extremes, base_attachment, &scores); Real opt = 1e6; int opt_idx = 0; @@ -408,7 +527,9 @@ New_slur::set_end_points (Grob *me) } void -New_slur::score_encompass (Grob * me, Grob *common[], Drul_array base_attach, +New_slur::score_encompass (Grob * me, Grob *common[], + Drul_array extremes, + Drul_array base_attach, Array * scores) { Link_array encompasses = @@ -416,23 +537,10 @@ New_slur::score_encompass (Grob * me, Grob *common[], Drul_array base_a Direction dir = get_grob_direction (me); Array infos; - Drul_array extremes (encompasses[0], encompasses.top ()); - - int first = 1; - int last = encompasses.size () - 2; - for (int i = first; i <= last; i++) + for (int i = 0; i < encompasses.size(); i++) infos.push (get_encompass_info (me, encompasses[i], common)); - Drul_array stems; - Direction d = LEFT; - do { - Grob *stem = Note_column::get_stem (extremes [d]); - stems[d] = stem; - } while (flip (&d) != LEFT); - - - for (int i =0 ; i < scores->size (); i++) { Bezier const &bez (scores->elem (i).curve_); @@ -452,7 +560,7 @@ New_slur::score_encompass (Grob * me, Grob *common[], Drul_array base_a if (dir * (y - infos[j].stem_) < 0) demerit += STEM_ENCOMPASS_PENALTY; - else + else if (j && j < encompasses.size () - 1) { Interval ext; ext.add_point (infos[j].stem_); @@ -465,11 +573,10 @@ New_slur::score_encompass (Grob * me, Grob *common[], Drul_array base_a Direction d = LEFT; do { - Real attr = EDGE_ATTRACTION_FACTOR * fabs (scores->elem (i).attachment_[d][Y_AXIS] - base_attach[d][Y_AXIS]); - if (get_grob_direction (stems[d]) == dir) + if (extremes[d].stem_ && extremes[d].stem_dir_ == dir) attr /= 5; demerit += attr; @@ -485,57 +592,52 @@ New_slur::score_encompass (Grob * me, Grob *common[], Drul_array base_a void -New_slur::score_slopes (Grob * me, Grob *common[], Drul_array base_attach, +New_slur::score_slopes (Grob * me, Grob *common[], + Drul_array extremes, + Drul_array base_attach, Array * scores) { - Link_array columns = - Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns"); - - Drul_array extremes (columns[0], columns.top ()); Direction dir = get_grob_direction (me); Drul_array ys; Direction d = LEFT; - Drul_array stem_dirs; - Drul_array beams; do { - Grob *stem = Note_column::get_stem (extremes [d]); - ys[d] = Stem::extremal_heads (stem)[Direction (dir)] - ->relative_coordinate (common[Y_AXIS], Y_AXIS); - stem_dirs[d] = get_grob_direction (stem); - beams[d] = Stem::get_beam (stem); + if (extremes[d].slur_head_) + ys[d] = extremes[d].slur_head_ ->relative_coordinate (common[Y_AXIS], Y_AXIS); + else + ys[d] = extremes[d].neighbor_y_; } while (flip (&d) != LEFT); - Real dx = extremes[RIGHT]->relative_coordinate (common[X_AXIS],X_AXIS) - - extremes[LEFT]->relative_coordinate (common[X_AXIS],X_AXIS); + bool has_beams = + (extremes[LEFT].stem_ && Stem::get_beam (extremes[LEFT].stem_)) + || (extremes[RIGHT].stem_ && Stem::get_beam (extremes[RIGHT].stem_)); Real dy = ys[RIGHT] - ys[LEFT]; for (int i =0 ; i < scores->size (); i++) { - Real slur_dy = (*scores)[i].attachment_[RIGHT][Y_AXIS] - - (*scores)[i].attachment_[LEFT][Y_AXIS]; + Offset slur_dz = (*scores)[i].attachment_[RIGHT] + - (*scores)[i].attachment_[LEFT]; - Real demerit = 0.0; + Real slur_dy = slur_dz[Y_AXIS]; - if(! (beams[LEFT] || beams[RIGHT])) + Real demerit = 0.0; + + if (!has_beams) demerit += STEEPER_SLOPE_FACTOR * (dir * (fabs (slur_dy) - fabs (dy)) >? 0); - demerit += ((fabs (slur_dy/dx) - MAX_SLOPE)>?0) * MAX_SLOPE_FACTOR; + demerit += ((fabs (slur_dy/slur_dz[X_AXIS]) - MAX_SLOPE)>?0) * MAX_SLOPE_FACTOR; if (sign (dy) == 0 && sign (slur_dy) != 0) demerit += NON_HORIZONTAL_PENALTY; - - if (sign (dy) && sign (slur_dy) && sign (slur_dy) != sign (dy)) demerit += - (beams[LEFT] || beams[RIGHT]) - ? SAME_SLOPE_PENALTY/10 : SAME_SLOPE_PENALTY; + has_beams ? SAME_SLOPE_PENALTY/10 : SAME_SLOPE_PENALTY; #if DEBUG_SLUR_QUANTING (*scores)[i].score_card_ += to_string ("S%.2f",d); @@ -559,13 +661,6 @@ New_slur::get_curve (Grob*me) } - - - - -/* - ugh ? - */ MAKE_SCHEME_CALLBACK (New_slur, height, 2); SCM New_slur::height (SCM smob, SCM ax) @@ -619,7 +714,8 @@ New_slur::print (SCM smob) #if DEBUG_SLUR_QUANTING SCM quant_score = me->get_property ("quant-score"); - if (// debug_beam_quanting_flag && + + if (debug_beam_quanting_flag && ly_c_string_p (quant_score)) { String str; diff --git a/lily/scm-option.cc b/lily/scm-option.cc index 5a7c6cee19..f89e27698a 100644 --- a/lily/scm-option.cc +++ b/lily/scm-option.cc @@ -126,12 +126,15 @@ LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val), lily_1_8_relative = false; else if (var == ly_symbol2scm ("debug-beam")) { - extern bool debug_beam_quanting_flag; debug_beam_quanting_flag = true; } else - warning (_f ("No such internal option: %s", ly_scm2string (var))); - + { + if (ly_c_symbol_p (var)) + var = scm_symbol_to_string (var); + + warning (_f ("No such internal option: %s", ly_scm2string (var))); + } return SCM_UNSPECIFIED; } diff --git a/lily/stem.cc b/lily/stem.cc index 1d723e72b2..9ea8812c8d 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -52,6 +52,18 @@ Stem::set_beaming (Grob *me, int beam_count, Direction d) index_set_cell (pair, d, lst); } +int +Stem::get_beaming (Grob *me, Direction d) +{ + SCM pair = me->get_property ("beaming"); + if (!ly_c_pair_p (pair)) + return 0; + + SCM lst = index_get_cell (pair, d); + return scm_ilength (lst); +} + + Interval Stem::head_positions (Grob *me) { diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 57d5c0b92f..4a1b44c656 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -828,20 +828,20 @@ (Slur . ( - (print-function . ; ,New_slur::print) - ,Slur::print) + (print-function . ,New_slur::print) + ; ,Slur::print) (thickness . 1.2) (spacing-procedure . ,Spanner::set_spacing_rods) (minimum-length . 1.5) - (after-line-breaking-callback . ; ,New_slur::after_line_breaking) - ,Slur::after_line_breaking) + (after-line-breaking-callback . + ,New_slur::after_line_breaking) + ; ,Slur::after_line_breaking) (extremity-function . ,calc-slur-extremity) (extremity-offset-alist . ,default-slur-extremity-offset-alist) (de-uglify-parameters . (1.5 0.8 -2.0)) (Y-extent-callback . - ;; ,#f) - ;; must be of type procedure - ,Slur::height) + ,New_slur::height) + ; Slur::height) (height-limit . 2.0) (ratio . 0.333) (beautiful . 0.5) -- 2.39.2