my barline "split arrows" function needs improvement

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

my barline "split arrows" function needs improvement

Kieren MacMillan
Hello all,

In the snippet included below, I show how I use angled arrows to indicate a staff will split into multiple staves after the system break.
(Note: It doesn't actually happen here, since I wanted my WE to be reasonably M!)

The problem is, the function attaches the arrows to the carline, which fails in the case of cautionary signatures (see second system). I tried attaching the arrows to the StaffSymbol — that seems the most elegant solution — but my attempt didn't work.

Would love help on fixing this snippet so that it always Does The Right Thing™.

Thanks!
Kieren.

%%%%  SNIPPET BEGINS
\version "2.19.60"

#(define-markup-command (arrow-at-angle layout props angle-deg length fill)
   (number? number? boolean?)
   (let* (
           (PI-OVER-180 (/ (atan 1 1) 34))
           (degrees->radians (lambda (degrees) (* degrees PI-OVER-180)))
           (angle-rad (degrees->radians angle-deg))
           (target-x (* length (cos angle-rad)))
           (target-y (* length (sin angle-rad))))
     (interpret-markup layout props
       (markup
        #:translate (cons (/ target-x 2) (/ target-y 2))
        #:rotate angle-deg
        #:translate (cons (/ length -2) 0)
        #:concat (#:draw-line (cons length 0)
                   #:hspace -0.125
                   #:arrow-head X RIGHT fill)))))

splitStaffBarLineMarkup =
\markup
  \with-dimensions #'(0 . 0) #'(0 . 0)
  \override #'(thickness . 1.5) {
    \concat
    {
      \hspace #0.375
      \combine
        \raise #0.4 \arrow-at-angle #30 #(sqrt 4) ##t
        \lower #0.4 \arrow-at-angle #-30 #(sqrt 4) ##t
    }
  }

splitStaffBarLine = {
  \override Staff.BarLine.stencil =
    #(lambda (grob)
       (ly:stencil-combine-at-edge
        (ly:bar-line::print grob)
        X RIGHT
        (grob-interpret-markup grob splitStaffBarLineMarkup)
        0))
  \break
}

{
  \splitStaffBarLine
  c''1 \break
  c''1 \break
  \time 3/4 c''2.
}
%%%%  SNIPPET ENDS
________________________________

Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: [hidden email]


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: my barline "split arrows" function needs improvement

Kieren MacMillan
Hi all,

D'oh…

> I tried attaching the arrows to the StaffSymbol — that seems the most elegant solution — but my attempt didn't work.

User error. Works great. Sorry for the noise.

Thanks,
Kieren.
________________________________

Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: [hidden email]


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: my barline "split arrows" function needs improvement

Kieren MacMillan
Hi again,

D'oh again…

My "fix" appears to work as a global override, but not as a one-off tweak (see attached modified snippet).
I played around with \stopStaff & \startStaff, but couldn't find the magic incantation.

Help re-requested.  =)

Thanks,
Kieren.

%%%  SNIPPET BEGINS
\version "2.19.60"

#(define-markup-command (arrow-at-angle layout props angle-deg length fill)
   (number? number? boolean?)
   (let* (
           (PI-OVER-180 (/ (atan 1 1) 34))
           (degrees->radians (lambda (degrees) (* degrees PI-OVER-180)))
           (angle-rad (degrees->radians angle-deg))
           (target-x (* length (cos angle-rad)))
           (target-y (* length (sin angle-rad))))
     (interpret-markup layout props
       (markup
        #:translate (cons (/ target-x 2) (/ target-y 2))
        #:rotate angle-deg
        #:translate (cons (/ length -2) 0)
        #:concat (#:draw-line (cons length 0)
                   #:hspace -0.125
                   #:arrow-head X RIGHT fill)))))

splitStaffBarLineMarkup =
\markup
  \with-dimensions #'(0 . 0) #'(0 . 0)
  \override #'(thickness . 1.5) {
    \concat
    {
      \hspace #0.375
      \combine
        \raise #0.4 \arrow-at-angle #30 #(sqrt 4) ##t
        \lower #0.4 \arrow-at-angle #-30 #(sqrt 4) ##t
    }
  }

staffOverride = {
  \override Staff.StaffSymbol.stencil =
    #(lambda (grob)
       (ly:stencil-combine-at-edge
        (ly:staff-symbol::print grob)
        X RIGHT
        (grob-interpret-markup grob splitStaffBarLineMarkup)
        0))
}

splitStaffBarLine = {
  \once \staffOverride \break
}

\markup \bold "STAFF OVERRIDE:"
{
  \staffOverride
  c''1 \break
  c''1 \break
  \time 3/4 c''2.
}

\markup \bold "SPLIT TWEAKS:"
{
  c''1 \splitStaffBarLine
  c''1 \splitStaffBarLine
  \time 3/4 c''2.
}
%%%  SNIPPET ENDS
________________________________

Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: [hidden email]


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: my barline "split arrows" function needs improvement

Andrew Bernard
Hi Kieran,

I think you need an event function, not a tweak,

split-arrows =
#(define-event-function ()
   ()
   #{
     -\splitStaffBarLineMarkup
   #}
   )

I have not figured out how to incorporate \break in that. Others will know!

Andrew




_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Loading...