lilypond-user
[Top][All Lists]
Advanced

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

Re: Different default arpeggio positions


From: Jean Abou Samra
Subject: Re: Different default arpeggio positions
Date: Thu, 1 Dec 2022 09:46:59 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0



Le 01/12/2022 à 07:08, Abraham Lee a écrit :
Happy Holidays!

A number of versions ago, I created the following function to extend the top and bottom ends of the Arpeggio grob, which I find more aesthetically pleasing (generally), though I know it's not perfect:

\override Arpeggio.after-line-breaking =
 #(lambda (grob)
    (let* ((pos (ly:grob-property grob 'positions))
           (p1 (car pos))
           (p2 (cdr pos))
           (btm (- p1 1.0))
           (top (+ p2 0.5))
           )
      (ly:grob-set-property! grob 'positions (cons btm top))
    ))

It used to work perfectly (that I can remember), but now using either after-line-breaking or before-line-breaking, I can't get it to work correctly, especially when I need to use

\set PianoStaff.connectArpeggios = ##t.

Any thoughts as to why it no longer works and/or what I should be doing differently? Ideally, I'd like to use different values depending on if the associated note is in a space (like 1.0 space) or on a staff line (like 0.5 space), but I'd be happy with a single solution to start with like I have above.

Here's a small snippet showing the current default arpeggio in both single staff usage and cross-staff usage, another with my function used with before-line-breaking, and then finally the same function but with after-line-breaking. It almost works with before-line-breaking, but not the cross-staff one.




Hi Abraham,

This is a widespread but bad coding pattern that I regularly advise
against on this list :-)

It seems that when people notice they can set grob properties
in after-line-breaking, they start using after-line-breaking
for anything and everything, while that is not its purpose.

The problem here is that after-line-breaking is run *just* after
line breaking. It happens before LilyPond has done page spacing,
i.e., layout out systems and staves vertically. For a cross-staff
arpeggio, the positions depend on the distance between the
two staves, so you are requesting 'positions earlier than LilyPond
can provide it to you.

In general, cross-staff objects are treated specially. For
a normal arpeggio, LilyPond will request the arpeggio's
stencil, to build the staff's skylines, and stencil will
read positions. For a cross-staff arpeggio, which LilyPond
recognizes by its cross-staff property set to #t, LilyPond
refrains from reading the stencil before page layout is done,
knowing that it needs to depend on page layout.

The proper solution is to stop assuming that positions is
available at a specific point, and instead write a callback
that computes it as soon as it is asked for:

\version "2.23.82"

\score {
  <<
    \new PianoStaff <<
      \new Staff = "pianoRH" \pianoRH
      \new Staff = "pianoLH" \pianoLH
    >>
  >>
  \layout {
    #(use-modules (ice-9 match))
    \context {
      \Score
      \override Arpeggio.positions =
        #(grob-transformer
          'positions
          (lambda (grob original)
            (match original
              ((a . b) (cons (- a 0.5) (+ b 1.0)))
              (x x))))
    }
  }
}



Best,
Jean


Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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