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

2022-02-11 Thread Simon Albrecht

On 11/02/2022 00:50, Jean Abou Samra wrote:

When you get around to it, could you explain this? Maybe I'm
being dense, but it's not obvious to me. Do you expect it
to save enough vertical space that it will enable LilyPond
to cram more systems on a page?

Anyway, this might be a topic for the user list in the end. 



It is, which is why I’ll only give a brief example here. Have a look at 
the first few bars at this: 
https://imslp.org/wiki/File:SIBLEY1802.14023.d867-39087011616572score.pdf


It shows various strategies of placing dynamics and articulations 
overlapping with the staff (without there even being strict necessity 
for some of them). All of these are abundantly common in 19th century 
engraving and enable far more compact layout. The issue can more severe 
in choral music due to lyrics, but in orchestral music there are more 
ledger lines, articulations, slurs  exacerbating the need for 
flexibility with dynamic placement.


Modern aesthetics often favour exact alignment, no overlapping and very 
loose spacing at the expense of huge increases in page count. I rarely 
agree…


Best, Simon


___
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond


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

2022-02-10 Thread Jean Abou Samra

Le 11/02/2022 à 00:36, Simon Albrecht a écrit :
[...] I need to set multiple grob properties (of more than one grob) 
and since saving large amounts of vertical space is the whole point, 
it obviously needs to be before-line-breaking.



When you get around to it, could you explain this? Maybe I'm
being dense, but it's not obvious to me. Do you expect it
to save enough vertical space that it will enable LilyPond
to cram more systems on a page?

Anyway, this might be a topic for the user list in the end.


Jean


___
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond


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

2022-02-10 Thread Simon Albrecht

Hello Jean,

thanks for the information. I can’t respond to each point right now, too 
tired. But…


On 10/02/2022 19:40, Jean Abou Samra wrote:
What are you trying to achieve in the first place? 


I’m in another iteration of writing a macro for adjusting placement of 
dynamics (Hairpin, DynamicText and DynamicTextSpanner). It needs to 
allow intersection with staff lines, interact well with 
DynamicLineSpanner and have a concise, reliable, clear user interface 
suitable for frequent use. (What I’m after and have been using in most 
iterations is something like @code{ c1\off #'(-1 . 2) \f }). I have 
switched to using grob callbacks since I didn’t see another way of 
reacting to grob type, direction and previous offsets adequately. I need 
to set multiple grob properties (of more than one grob) and since saving 
large amounts of vertical space is the whole point, it obviously needs 
to be before-line-breaking.


However, I’m slowly realising that I don’t know well enough what exactly 
the functionality is supposed to be and how much of that is even feasible.


I’m hoping to get back to you tomorrow.

Best, Simon


___
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond


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

2022-02-10 Thread Jean Abou Samra



Le 10/02/2022 à 22:57, David Kastrup a écrit :

Jean Abou Samra  writes:


Le 10/02/2022 à 15:42, Simon Albrecht a écrit :

Hi Aaron,

thanks a lot for the help! I knew that these pure vs. impure issues
exist, but I’ve never been able to wrap my head around them and this
is the first time I ever needed to account for them in practice.

Looking at Extending Manual section 2.8, it seems that Y-offset is
likely to be affected, so that makes sense.

What I don’t quite get is the meaning of the ‘begin’ and ‘end’
parameters in ly:grob-pure-property, but as long as 0 0 works, I’m
good ;) (and it’s not a topic for the bug list)

Best, Simon



Sorry, I just received this message now so my previous reply didn't
account for it (yes, list messages are taking 5 hours to reach
recipients sometimes, this was discussed recently on lilypond-user).

So, to answer your question, start and end are column ranks.
The meaning of the question (ly:grob-pure-property grob start end)
is "What will this grob property approximately on the broken
piece if this spanner is broken between start and end?"

Not the way I understand things.  The question is "What will this grob
property be in a line that starts in column `start` and ends in column
`end`.  That spanners consist of broken pieces is a different
complication not specifically related to start/end.




What would be the difference exactly? I don't understand what
you mean.




(for items they should be ignored).

I don't see that.  Even items may have different properties depending on
start/end.  For example, accidental rules should be taking them into
account (but don't currently) since accidentals on notes tied over bars
get repeated after a line break (and then don't need another
repetition).




I was not talking the ideal design (which I happened to be exactly
working on while receiving this message). Rather I was talking about
the current design, which is that, to my knowledge, all pure functions
ignore start and end when passed an item, and item pure heights are
actively cached independently of start and end because they are
assumed not to depend on them and this saves calculations.

Interval
Item::pure_y_extent (Grob *g, vsize start, vsize end)
{
  if (cached_pure_height_valid_)
    return cached_pure_height_ + pure_relative_y_coordinate (g, start, 
end);

  /* Note: cached_pure_height_ does not notice if start changes, implicitly
 assuming that Items' pure_heights do not depend on 'start' or 'end'.
  */

  cache_pure_height (Grob::pure_y_extent (this, start, end));
  return cached_pure_height_ + pure_relative_y_coordinate (g, start, end);
}




They are used in VerticalAxisGroup pure calculations, to estimate how
tall a staff will be between two certain points in order to score page
breaking configurations.

Yes, that's more like it.




___
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond


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

2022-02-10 Thread David Kastrup
Jean Abou Samra  writes:

> Le 10/02/2022 à 15:42, Simon Albrecht a écrit :
>> Hi Aaron,
>>
>> thanks a lot for the help! I knew that these pure vs. impure issues
>> exist, but I’ve never been able to wrap my head around them and this
>> is the first time I ever needed to account for them in practice.
>>
>> Looking at Extending Manual section 2.8, it seems that Y-offset is
>> likely to be affected, so that makes sense.
>>
>> What I don’t quite get is the meaning of the ‘begin’ and ‘end’
>> parameters in ly:grob-pure-property, but as long as 0 0 works, I’m
>> good ;) (and it’s not a topic for the bug list)
>>
>> Best, Simon
>
>
>
> Sorry, I just received this message now so my previous reply didn't
> account for it (yes, list messages are taking 5 hours to reach
> recipients sometimes, this was discussed recently on lilypond-user).
>
> So, to answer your question, start and end are column ranks.
> The meaning of the question (ly:grob-pure-property grob start end)
> is "What will this grob property approximately on the broken
> piece if this spanner is broken between start and end?"

Not the way I understand things.  The question is "What will this grob
property be in a line that starts in column `start` and ends in column
`end`.  That spanners consist of broken pieces is a different
complication not specifically related to start/end.

> (for items they should be ignored).

I don't see that.  Even items may have different properties depending on
start/end.  For example, accidental rules should be taking them into
account (but don't currently) since accidentals on notes tied over bars
get repeated after a line break (and then don't need another
repetition).

> They are used in VerticalAxisGroup pure calculations, to estimate how
> tall a staff will be between two certain points in order to score page
> breaking configurations.

Yes, that's more like it.

-- 
David Kastrup

___
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond


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

2022-02-10 Thread Jean Abou Samra

Le 10/02/2022 à 15:42, Simon Albrecht a écrit :

Hi Aaron,

thanks a lot for the help! I knew that these pure vs. impure issues 
exist, but I’ve never been able to wrap my head around them and this 
is the first time I ever needed to account for them in practice.


Looking at Extending Manual section 2.8, it seems that Y-offset is 
likely to be affected, so that makes sense.


What I don’t quite get is the meaning of the ‘begin’ and ‘end’ 
parameters in ly:grob-pure-property, but as long as 0 0 works, I’m 
good ;) (and it’s not a topic for the bug list)


Best, Simon




Sorry, I just received this message now so my previous reply didn't
account for it (yes, list messages are taking 5 hours to reach
recipients sometimes, this was discussed recently on lilypond-user).

So, to answer your question, start and end are column ranks.
The meaning of the question (ly:grob-pure-property grob start end)
is "What will this grob property approximately on the broken
piece if this spanner is broken between start and end?" (for
items they should be ignored). They are used in VerticalAxisGroup
pure calculations, to estimate how tall a staff will be between
two certain points in order to score page breaking configurations.

Best,
Jean




___
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond


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

2022-02-10 Thread Simon Albrecht

Hi Aaron,

thanks a lot for the help! I knew that these pure vs. impure issues 
exist, but I’ve never been able to wrap my head around them and this is 
the first time I ever needed to account for them in practice.


Looking at Extending Manual section 2.8, it seems that Y-offset is 
likely to be affected, so that makes sense.


What I don’t quite get is the meaning of the ‘begin’ and ‘end’ 
parameters in ly:grob-pure-property, but as long as 0 0 works, I’m good 
;) (and it’s not a topic for the bug list)


Best, Simon

On 10/02/2022 03:29, Aaron Hill wrote:


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


___
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond


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

2022-02-10 Thread Jean Abou Samra



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


___
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond


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

2022-02-09 Thread Aaron Hill

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
}



-- Aaron Hill

___
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond


Odd interaction between ly:grob-property and hairpin

2022-02-09 Thread Simon Albrecht

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):


%%
% tested with version 2.22.0 as well -- same bug
\version "2.23.6"
% guile2 binary from
% 
https://gitlab.com/lilypond/lilypond/-/releases/release%252F2.23.6-1/downloads/lilypond-2.23.6-linux-x86_64.tar.gz

off =
#(define-event-function
  (ev)
  (ly:music?)
  (let ((offsetter-fn
 (lambda (grob)
   (let* (
   ; comment/uncomment the following to trigger bug:
   ; if the grob property is queried, the hairpin gets 
infinitely short

   (yoff-prev (ly:grob-property grob 'Y-offset 0))
   )
 (ly:grob-set-property! grob 'color red)
 
    #{
  - \tweak before-line-breaking $offsetter-fn
  - $ev
    #}))

{ 2\off \< 2\f }
%

Best, Simon


___
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond