lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: angle of a tuplet bracket


From: Thomas Morley
Subject: Re: angle of a tuplet bracket
Date: Tue, 10 Jan 2012 22:51:18 +0100

Hi Paolo,

2012/1/9 Paolo Prete <address@hidden>:
> 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?
>
> --- Gio 5/1/12, Thomas Morley <address@hidden> ha scritto:
>
>> Da: Thomas Morley <address@hidden>
>> Oggetto: Re: angle of a tuplet bracket
>> A: "address@hidden" <address@hidden>
>> Cc: "Paolo Prete" <address@hidden>, "lilypond-user" <address@hidden>
>> Data: Giovedì 5 gennaio 2012, 16:20
>> Hi Paolo,
>>
>> 2012/1/5 address@hidden
>> <address@hidden>:
>> >
>> > On Jan 5, 2012, at 2:31 PM, Paolo Prete wrote:
>> >
>> > ... 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!
>> >
>>
>> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]