Discussion:
angle of a tuplet bracket
Paolo Prete
2012-01-05 13:31:55 UTC
Permalink
... is there a way to specify the angle of a tuplet bracket?

In addition, how can I force the bracket of the following tuplet:

\times 2/3 {c' c'' c'''}

so to be horizontal? (0 °)


thanks!
Thomas Morley
2012-01-05 13:40:18 UTC
Permalink
Hi Paolo,
Post by Paolo Prete
... is there a way to specify the angle of a tuplet bracket?
\times 2/3 {c' c'' c'''}
so to be horizontal? (0 °)
how about:

{
\once\override TupletBracket #'positions = #'(-5 . -5)
\times 2/3 {c' c'' c'''}
}

HTH,
Harm
m***@apollinemike.com
2012-01-05 13:40:58 UTC
Permalink
Post by Paolo Prete
... is there a way to specify the angle of a tuplet bracket?
\times 2/3 {c' c'' c'''}
so to be horizontal? (0 °)
thanks!
Hey Paolo,

You can set the positions property.

http://lilypond.org/doc/v2.15/Documentation/internals/tupletbracket

To force it to be horizontal, just use the same two numbers.

Cheers,
MS
Thomas Morley
2012-01-05 15:20:30 UTC
Permalink
Hi Paolo,
Post by Paolo Prete
... is there a way to specify the angle of a tuplet bracket?
\times 2/3 {c' c'' c'''}
so to be horizontal? (0 °)
thanks!
Hey Paolo,
You can set the positions property.
http://lilypond.org/doc/v2.15/Documentation/internals/tupletbracket
To force it to be horizontal, just use the same two numbers.
Cheers,
MS
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
Paolo Prete
2012-01-09 19:43:20 UTC
Permalink
Oggetto: Re: angle of a tuplet bracket
Data: Giovedì 5 gennaio 2012, 14:40
Hi Paolo,
Post by Paolo Prete
... is there a way to specify the angle of a tuplet
bracket?
Post by Paolo Prete
In addition, how can I force the bracket of the
\times 2/3 {c' c'' c'''}
so to be horizontal? (0 °)
{
        \once\override
TupletBracket  #'positions = #'(-5 . -5)
        \times 2/3 {c' c'' c'''}
}
HTH,
  Harm
thanks for your help but I would avoid to specify the vertical offset of the tuplet bracket.

I would like to set horizontal (0 °) \tupletUp brackets for ALL the score... is there a way to obtain that?

thanks
Paolo Prete
2012-01-09 19:45:17 UTC
Permalink
Hi 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 Prete
In addition, how can I force the bracket of the
\times 2/3 {c' c'' c'''}
so to be horizontal? (0 °)
thanks!
Hey Paolo,
You can set the positions property.
http://lilypond.org/doc/v2.15/Documentation/internals/tupletbracket
To force it to be horizontal, just use the same two
numbers.
Post by Paolo Prete
Cheers,
MS
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
Thomas Morley
2012-01-10 21:51:18 UTC
Permalink
Hi Paolo,
Post by Paolo Prete
Hi 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 Prete
In 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

Loading...