On Sat, Feb 11, 2017 at 1:47 PM, David Nalesnik <david.nales...@gmail.com> wrote: > On Sat, Feb 11, 2017 at 1:43 PM, David Nalesnik > <david.nales...@gmail.com> wrote: >> On Sat, Feb 11, 2017 at 11:11 AM, Werner LEMBERG <w...@gnu.org> wrote: >>> >>>>> For voices with lyrics it is common to put triplet indications >>>>> always above the staff, using the following rules. >>>>> >>>>> . stems up or down, no beam: as usual (i.e., a number and a >>>>> bracket at the top, as if using \tupletUp) >>>>> >>>>> . stems up, with beam: as usual (i.e., a number over the beam) >>>>> >>>>> The last case, however, is unusual: >>>>> >>>>> . stem down, with beam: a number and a *slur* at the top. >>> >>> BTW, these rules can be found in the vocal score of `Arabella' (by >>> Richard Strauss), for example. >>> >>>> It strikes me that I've seen code somewhere that uses slurs instead of >>>> brackets. I find this: >>>> http://www.lilypondforum.de/index.php?topic=1658.0 >>> >>> Yes, I can remember that also – very nice! >>> >>>> The results look great, but of course, the slur is broken. It might >>>> not be hard to modify that routine to do what you want.. >>> >>> Oh, I actually don't really care whether the slur is broken or not. >>> I'm rather interested in having a lilypond option to make it behave >>> (i.e., differentiate between tuplet slur and tuplet brackets) as >>> outlined above. >> >> I've attached a patch which permits tuplets with slurs instead of >> brackets. Sorry that you have to build LilyPond to use it. >> >> It's pretty rough. For one thing, the slur shapes for inclined slurs >> are probably not ideal. >> >> To get the bowed-tuplets, you set TupletBracket.tuplet-slur to #t. >> >> You can move the slur closer/further from the number by setting >> TupletNumber.padding to the value you'd like (default: 0.3). Don't >> know what other >> consequences there might be when setting TupletNumber.padding, but I >> don't want to add more properties unless it's really necessary. >> >> To get the behavior you want, check the example file. There is a >> Scheme function which >> should put your rules into effect. >>
The attached is better structured and it supports 'shorten-pair for the slurs. (Note that you can also set dash-definition) David
From c583d664d2aed5f62cb603dfbb01235ecd2cbd23 Mon Sep 17 00:00:00 2001 From: David Nalesnik <david.nales...@gmail.com> Date: Sat, 11 Feb 2017 13:19:16 -0600 Subject: [PATCH] Allow slurs instead of brackets with tuplets Older editions often use slurs with tuplets. This patch creates a new property ('tuplet-slur'), which toggles this notation style. Note that 'bracket-visibility must be set to #t for the slurs to appear with beamed notes. (In the future, 'bracket-visibility might automatically be set to #t.) Support shorten-pair --- lily/tuplet-bracket.cc | 95 +++++++++++++++++++++++++++++++++++------- scm/define-grob-properties.scm | 2 + scm/define-grobs.scm | 1 + 3 files changed, 83 insertions(+), 15 deletions(-) diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index 340b017..2600d7a 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -58,6 +58,7 @@ #include "lookup.hh" #include "paper-column.hh" #include "moment.hh" +#include "bezier.hh" static Item * get_x_bound_item (Grob *me_grob, Direction hdir, Direction my_dir) @@ -245,6 +246,54 @@ Tuplet_bracket::calc_x_positions (SCM smob) return ly_interval2scm (x_span - me->get_bound (LEFT)->relative_coordinate (commonx, X_AXIS)); } +Bezier +tuplet_slur_shape (Offset l, Offset r, Real h_limit, Real ratio, Direction d) +{ + Real indent; + Real height; + + Real width = (r[X_AXIS] - l[X_AXIS]); + + get_slur_indent_height (&indent, &height, width, h_limit, ratio); + + Bezier curve; + + curve.control_[0] = l; + curve.control_[1] = Offset (l[X_AXIS] + indent, l[Y_AXIS] + height * d); + curve.control_[2] = Offset (r[X_AXIS] - indent, r[Y_AXIS] + height * d); + curve.control_[3] = r; + + return curve; +} + +Stencil +make_tuplet_slur (Grob *me, Offset l, Offset r, Drul_array<Real> shorten) +{ + SCM dash_definition = me->get_property ("dash-definition"); + Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); + + Real height_limit = 1.5; + Real ratio = .33; + + Direction dir = get_grob_direction (me); + + Offset dz = r - l; + Real length = dz.length (); + + l += shorten[LEFT] / length * dz; + r -= shorten[RIGHT] / length * dz; + + Bezier curve = tuplet_slur_shape (l, r, height_limit, ratio, dir); + + Stencil mol (Lookup::slur (curve, lt, lt, dash_definition)); + + Grob *tn = unsmob<Grob> (me->get_object ("tuplet-number")); + Real padding = robust_scm2double (tn->get_property ("padding"), 0.3); + + mol.translate_axis (padding * dir, Y_AXIS); + return mol; +} + /* TODO: @@ -258,6 +307,8 @@ Tuplet_bracket::print (SCM smob) Spanner *me = unsmob<Spanner> (smob); Stencil mol; + bool tuplet_slur = ly_scm2bool (me->get_property ("tuplet-slur")); + extract_grob_set (me, "note-columns", columns); bool equally_long = false; Grob *par_beam = parallel_beam (me, columns, &equally_long); @@ -325,20 +376,32 @@ Tuplet_bracket::print (SCM smob) if (bracket_visibility) { Drul_array<Real> zero (0, 0); + + Drul_array<Real> shorten + = robust_scm2drul (me->get_property ("shorten-pair"), zero); + Real ss = Staff_symbol_referencer::staff_space (me); + scale_drul (&shorten, ss); + + Stencil brack; + + if (tuplet_slur) { + brack = make_tuplet_slur (me, points[LEFT], points[RIGHT], shorten); + mol.add_stencil (brack); + } + else + { + Drul_array<Stencil> edge_stencils; + Drul_array<Real> height = robust_scm2drul (me->get_property ("edge-height"), zero); Drul_array<Real> flare = robust_scm2drul (me->get_property ("bracket-flare"), zero); - Drul_array<Real> shorten - = robust_scm2drul (me->get_property ("shorten-pair"), zero); - Drul_array<Stencil> edge_stencils; Direction dir = get_grob_direction (me); scale_drul (&height, -ss * dir); scale_drul (&flare, ss); - scale_drul (&shorten, ss); Drul_array<bool> connect_to_other = robust_scm2booldrul (me->get_property ("connect-to-neighbor"), @@ -373,15 +436,15 @@ Tuplet_bracket::print (SCM smob) } } - Stencil brack = make_bracket (me, Y_AXIS, - points[RIGHT] - points[LEFT], - height, - /* - 0.1 = more space at right due to italics - TODO: use italic correction of font. - */ - Interval (-0.5, 0.5) * gap + 0.1, - flare, shorten); + brack = make_bracket (me, Y_AXIS, + points[RIGHT] - points[LEFT], + height, + /* + 0.1 = more space at right due to italics + TODO: use italic correction of font. + */ + Interval (-0.5, 0.5) * gap + 0.1, + flare, shorten); for (LEFT_and_RIGHT (d)) { @@ -390,12 +453,13 @@ Tuplet_bracket::print (SCM smob) } mol.add_stencil (brack); + mol.translate (points[LEFT]); } - - mol.translate (points[LEFT]); + } return mol.smobbed_copy (); } + /* should move to lookup? @@ -842,6 +906,7 @@ ADD_INTERFACE (Tuplet_bracket, "note-columns " "padding " "tuplet-number " + "tuplet-slur " "scripts " "shorten-pair " "staff-padding " diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 34450a9..d34a416 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -1135,6 +1135,8 @@ direction and it is associated with a @code{ScriptColumn} object. @code{0.0} means centered on the note head (the default position of most scripts); @code{1.0} means centered on the stem. Interpolated values are possible.") + (tuplet-slur ,boolean? "Draw a slur instead of a bracket for +tuplets.") (transparent ,boolean? "This makes the grob invisible.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index a04e070..fceb313 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -2611,6 +2611,7 @@ (staff-padding . 0.25) (stencil . ,ly:tuplet-bracket::print) (thickness . 1.6) + (tuplet-slur . #f) (vertical-skylines . ,grob::unpure-vertical-skylines-from-stencil) (X-positions . ,ly:tuplet-bracket::calc-x-positions) -- 2.1.4
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user