Richard,
On Thu, Apr 14, 2016 at 1:53 AM, Richard Shann-2 [via Lilypond] <
ml-node+s1069038n189594...@n5.nabble.com> wrote:
> On Wed, 2016-04-13 at 23:28 +0200, Thomas Morley wrote:
> > 2016-04-13 15:06 GMT+02:00 Richard Shann <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=189594&i=0>>:
> > > Thanks Abraham, that's most informative.
> > > Thinking about it, I wonder if I've missed something: is there a way
> to
> > > say typeset the tuplet bracket like a slur, with the tuplet number
> > > inside?
> >
> > I once made the attached code.
> > Maybe you can adapt it to fit your needs.
>
> Hmm, quite a battle to get that I see! In fact your code does something
> extra-fancy compared with the commonplace examples I see in old prints,
> namely the tuplet number cuts into the slur. Typically the tuplet number
> is inside the slur, which happened by default in LilyPond once I set the
> direction. I was hoping it might be possible just to set the tuplet
> number direction to be the same as a slur would be - I don't mind adding
> the slur manually.
>
Here's a customized variant of Harm's function that does more of what you
want by moving the slur outside the TupletNumber without cutting it in
half. Like Simon eluded to, though, it would need some work to be robust
enough to be incorporated into LilyPond core. Anyway, here's the function
for your enjoyment:
%%%%%%%%%%%%%%%%
\version "2.18.2"
tupletBracketToSlur = {
% Use slur-stencil
\override TupletBracket.stencil = #ly:slur::print
%% Use 'thickness from Slur
\override TupletBracket.thickness = #1.2
%% 'control-points need to be set
\override TupletBracket.control-points =
#(lambda (grob)
(let* ((x-pos (ly:grob-property grob 'X-positions))
(pos (ly:grob-property grob 'positions))
(x-ln (interval-length x-pos))
(dir (ly:grob-property grob 'direction))
;; read out the height of the TupletBracket, maybe negative!
(height (- (cdr pos) (car pos)))
;; height-corr is introduced because sometimes the shape of the
;; slur needs to be adjusted.
;; It is used in the 2nd/3rd control-point.
;; The value of 0.3 is found by trial and error
(height-corr (* 0.3 dir height))
(edge-height (ly:grob-property grob 'edge-height '(0.7 . 0.7)))
(pad 1.0))
(list
;; first cp
(cons
(+ (car x-pos) 0.5)
(- (+ (* dir pad) (+ (car pos) (* -1 dir (car edge-height))))
(if (= dir -1)
(if (> height 3)
(/ dir 2.0)
0.0)
(if (< height -3)
(/ dir 2.0)
0.0))))
;; second cp
(cons
(+ (car x-pos) (* x-ln 1/4))
(+ (* dir pad) (+ (car pos) (* dir (+ 0.5 height-corr)))))
;; third cp
(cons
(+ (car x-pos) (* x-ln 3/4))
(+ (* dir pad) (+ (cdr pos) (* dir (- 0.5 height-corr)))))
;; fourth cp
(cons
(- (cdr x-pos) 0.5)
(+ (* dir pad) (+ (cdr pos) (* -1 dir (cdr edge-height)))))
)))
\override TupletBracket.staff-padding = #'()
}
%%%%%%%%%%%%%%%%%%% Example %%%%%%%%%%%%%%%%%%%%%
music = \relative c'' {
\tuplet 3/2 4 { a8 b c a b c' a, b c, a' b, c }
\tuplet 5/4 2 { a' b c d e a,, b c' d e }
\tuplet 5/4 2 { a b c, d e a b, c d, e }
\break
}
\layout {
indent = 0
\tupletBracketToSlur
\omit Staff.TimeSignature
\omit Score.BarNumber
}
\score {
{ \music }
\header { piece = "Default" }
}
\score {
{ \tupletUp \music }
\header { piece = "TupletBracket forced UP" }
}
\score {
{ \tupletDown \music }
\header { piece = "TupletBracket forced DOWN" }
}
\score {
{ \voiceOne \music }
\header { piece = "All forced UP (\voiceOne)" }
}
\score {
{ \voiceTwo \music }
\header { piece = "All forced DOWN (\voiceTwo)" }
}
%%%%%%%%%%%%%%%%
It does a pretty good job and follows the slope of the stems/beam, though
there are likely to be cases where the curve is not perfect (like one or
two in my example).
HTH,
Abraham
--
View this message in context:
http://lilypond.1069038.n5.nabble.com/Tuplet-number-direction-tp189552p189599.html
Sent from the User mailing list archive at Nabble.com.
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user