lilypond-user
[Top][All Lists]
Advanced

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

Re: building pairs in music functions


From: Kevin Barry
Subject: Re: building pairs in music functions
Date: Sun, 15 Mar 2015 00:33:48 +0000


On Fri, Mar 13, 2015 at 3:34 PM, Stephen MacNeil <address@hidden> wrote:

\version "2.18.2"


rotateBracket =

#(define-music-function (parser location input) (pair?)

#{

\once \override HorizontalBracket.bracket-flare = $input

#})


Actually I wanted to build the bracket flare from a single value, but I had stripped away most of the code for the purposes of the question. I do a lot of analytic music examples and for that I often angle the HorizontalBrackets, but each time I rotate one it requires using trigonometry (seriously) to calculate the right bracket-flare values, so I just wanted to do that automatically. I eventually got something that works. Here it is in case anyone is interested:

\version "2.18.2"

startAngledGroup =
#(define-event-function (parser location num)
   (integer?)
   (let* ((rot-angle (degrees->radians num))
          (left-flare (- (tan rot-angle)))
          (right-flare (tan rot-angle))
          (y-offset (- (/ num 10))))
     (define flare-callback
       (lambda (grob)
         (ly:grob-set-property! grob 'rotation (list num 0 0))
         (if (= UP (ly:grob-property grob 'direction))
              (ly:grob-set-property! grob 'bracket-flare (cons right-flare left-flare))
              (ly:grob-set-property! grob 'bracket-flare (cons left-flare right-flare)))))
     #{
       \single \override HorizontalBracket.before-line-breaking = #flare-callback
       \startGroup
     #}))

\relative {
  b\startAngledGroup #10 e\stopGroup
}

\layout {
  \context {
    \Voice
    \consists "Horizontal_bracket_engraver"
  }
}

reply via email to

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