bug-lilypond
[Top][All Lists]
Advanced

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

Re: Odd interaction between ly:grob-property and hairpin


From: Jean Abou Samra
Subject: Re: Odd interaction between ly:grob-property and hairpin
Date: Thu, 10 Feb 2022 19:40:50 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0



Le 10/02/2022 à 03:29, Aaron Hill a écrit :
On 2022-02-09 5:15 pm, Simon Albrecht wrote:
Hello list,

if a grob callback queries a grob property on a hairpin as follows,
the hairpin gets printed infinitely short (with a corresponding
warning: crescendo too small):

A pure vs. unpure issue perhaps?  If you use ly:grob-pure-property to access it, it seems to work.

%%%%
\version "2.22.0"

off =
#(define-event-function
  (ev) (ly:music?)
  (define (offsetter-fn grob)
   (format #t "\nY-offset=~s"
    (ly:grob-pure-property grob 'Y-offset 0 0 0))
   (ly:grob-set-property! grob 'color red))
  #{ \tweak before-line-breaking #offsetter-fn $ev #})

{
  2\off \< 2\f
  2\tweak Y-offset #-0.5 \off \< 2\f
  2\offset Y-offset #0.5 \off \< 2\f
}
%%%%



Depending on the point of view, this may be regarded as a pure/unpure
issue, or just a logic issue.  Observe:

\version "2.22.1"

{
  c'''8\< 8 8 8 8 8 8 8
  c,,8 8 8 8 8 8 8 8\!
}

{
  c'''8\< 8 8 8 8 8 8 8
  \break
  c,,8 8 8 8 8 8 8 8\!
}


Hairpin.Y-offset depends which broken part of the hairpin you are
considering. It is only meaningful on one of the broken parts after
line breaking has been done and the Hairpin spanner has been broken in
parts. You are asking for it in before-line-breaking on an unbroken
spanner. LilyPond is being very kind and tries to compute the property
nevertheless, but this cannot work and doesn't make sense anyway.
Depending on the use case, you may want:

- A callback for a property that you are interested in setting. Often
  people use before-line-breaking or after-line-breaking for purposes
  different from what they're for. If your before-line-breaking
  function is just to do a ly:grob-set-property!, you can usually
  \override that property to a callback instead.

- after-line-breaking, which is called on the broken pieces at a point
  where the offset can be computed (and is meaningful),

- The 'pure' line-breaking-independent estimations (which are thus
  approximations) that LilyPond uses internally to figure out how to
  place line breaks. *That* is available on the unbroken spanner, but
  unless you are writing spacing code and in particular working with
  *horizontal* spacing, this is likely not what you want.

What are you trying to achieve in the first place?

Regards,
Jean




reply via email to

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