Hi Paolo,
Post by Paolo PreteHi Thomas, thanks for your snippet that works greatly for a single staff but unfortunately it messes up the score when there are cross-staff notes... How can I fix that?
Oggetto: Re: angle of a tuplet bracket
Data: Giovedì 5 gennaio 2012, 16:20
Hi Paolo,
Post by Paolo Prete... is there a way to specify the angle of a tuplet
bracket?
Post by Paolo PreteIn addition, how can I force the bracket of the
\times 2/3 {c' c'' c'''}
so to be horizontal? (0 °)
thanks!
if you want to get explicit control about the angle of the
TupletBracket, you could try the function below. Sometimes
there's
need of an offset in Y-direction depending on the angle
you've chosen.
So I integrated the possibility to do so.
\version "2.15.20"
tupletAngles =
#(define-music-function (parser location y-off
angl)(number? number?)
"
angl is supposed to be the angle of the TupletBracket in
degrees,
y-off a (possible) offset in Y-direction
"
#{
\once\override TupletBracket #'after-line-breaking =
#(lambda (grob)
(let* ((pos (ly:grob-property grob 'positions))
(y-length
(interval-length pos))
(st
(ly:tuplet-bracket::print grob))
(st-x-ext
(ly:stencil-extent st X))
(st-x-length
(interval-length st-x-ext))
(alpha
(degrees->radians angl))
(new-start (+ (car
pos) y-off))
(new-y (*
st-x-length (tan alpha))))
(ly:grob-set-property! grob 'positions (cons
new-start (+ new-start new-y)))))
#})
%----- test
\relative c' {
\tupletAngles #-0.3 #15
\times 2/3 {c c' c'}
\tupletUp
\tupletAngles #0.9 #-30
\times 2/3 {c c, c,}
}
Cheers,
Harm
if you want to achieve horizontal Brackets for the entire score you
may try \horizontalTuplets as defined below. But there are some
situations I didn't manage to automize this. If the output is not
convincing you have to use the (revised) tupletAngles-function (see:
Example II) and to do it manually.
\version "2.15.20"
tupletAngles =
#(define-music-function (parser location y-off angl)(number? number?)
"
angl is supposed to be the angle of the TupletBracket in degrees,
y-off a (possible) offset in Y-direction
"
#{
\once\override TupletBracket #'stencil =
#(lambda (grob)
(let* ((pos (ly:grob-property grob 'positions))
(y-length (interval-length pos))
(st (ly:tuplet-bracket::print grob))
(st-x-ext (ly:stencil-extent st X))
(st-x-length (interval-length st-x-ext))
(alpha (degrees->radians angl))
(dir (ly:grob-property grob 'direction))
(new-start (+ (if (= dir 1)
(max (car pos)(cdr pos))
(min (car pos)(cdr pos)))
y-off))
(new-y (* st-x-length (tan alpha))))
(ly:grob-set-property! grob 'positions (cons new-start (+ new-start new-y)))
(ly:tuplet-bracket::print grob)))
#})
horizontalTuplets =
\override TupletBracket #'stencil =
#(lambda (grob)
(let* ((pos (ly:grob-property grob 'positions))
(dir (ly:grob-property grob 'direction))
(new-pos (if (= dir 1)
(max (car pos)(cdr pos))
(min (car pos)(cdr pos)))))
(ly:grob-set-property! grob 'positions (cons new-pos new-pos))
(ly:tuplet-bracket::print grob)))
%----- test
\markup "Example I"
\relative c' {
\horizontalTuplets
\times 2/3 {c' c'' c,}
\times 2/3 {c c, c,}
}
\markup "Example II"
top = \change Staff = "1"
bottom = \change Staff = "2"
music = \relative c {
\horizontalTuplets
\override Beam #'auto-knee-gap = #1
\tupletAngles #-3.2 #0
\times 2/3 {
\bottom c4 \top c' c' }
\times 2/3 {
c c, \bottom c,
}
}
\score {
\new PianoStaff <<
\new Staff = "1" {
s1
}
\new Staff = "2" {
\clef bass
\music
}
}
HTH,
Harm