lilypond-user
[Top][All Lists]
Advanced

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

Re: Finding the objects at the start of the current measure


From: Urs Liska
Subject: Re: Finding the objects at the start of the current measure
Date: Tue, 26 Feb 2019 14:12:41 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

Hi Thomas,

thank you for the consideration!

Am 26.02.19 um 12:02 schrieb Thomas Morley:
Am Mo., 25. Feb. 2019 um 13:14 Uhr schrieb Urs Liska <address@hidden>:
...

\version "2.19.82"

\include "oll-core/package.ily"
Hi Urs,

because of my limited time I can't keep track what's going on oll.

Thus all your example code is limited to oll-users, I'd recommend to
break it doing to core-lilypond-functionality while asking here,
otherwise only those oll-users have a chance to compile your surely
nice code.


Well, I must admit I found this too complicated in this case, especially given that in the end I'll make it available somewhere in openLilyLib anyway.



That said, I probably can imagine what the not-core-functions do ;)

Why not going for bound-padding instead of minimum-length.


I wasn't aware that multimeasure rests are spanners and that I could use bound-padding.


Here a sketch:

foo =
     \override MultiMeasureRest.before-line-breaking =
     #(lambda (grob)
        (let* ((vag (ly:grob-parent grob Y)) ;; VerticalAxisGroup
               (vag-elts-array (ly:grob-object vag 'elements))
               (vag-elts-ls
                 (if (ly:grob-array? vag-elts-array)
                     (ly:grob-array->list vag-elts-array)
                     '()))
               (mm-grobs
                 (filter
                   (lambda (elt)
                     (and
                       (equal? (ly:grob-parent elt X) grob)
                       (grob::has-interface elt 'multi-measure-interface)))
                   vag-elts-ls)))

          (if (pair? mm-grobs)
              (let* ((mmr-stil-x-length
                       (interval-length
                         (ly:stencil-extent
                           (ly:multi-measure-rest::print grob) X)))
                     (mm-text-stil-x-lengths
                       (map
                         (lambda (mm)
                           (ly:stencil-extent
                             (grob-interpret-markup
                               mm
                               (ly:grob-property mm 'text))
                             X))
                         mm-grobs))
                     (max-text-x-length
                       (apply max (map cdr mm-text-stil-x-lengths)))
                     (half-x-diff
                       (/ (abs (- mmr-stil-x-length max-text-x-length)) 2)))
                (ly:grob-set-property! grob 'bound-padding half-x-diff)))))

{
     \foo
     R1
     \key bes \major
     R1

     \key b \major
     \time 16/16

     R1^"very very long"_"not short either"
     R^"very very very long"_"not really short either"
}


I must admit that this doesn't seem to properly work when applied to my code.

Do I understand correctly that bound-padding ensures padding to the right and left of the given (spanner) grob. So when the rest (or my in-place replacement with arbitrary markup) has a width of, say, 4 staff spaces, and bound-padding is set to, say, 10, then my measure is guaranteed to be (at least) 24 staff spaces wide?

I can successfully map your code to mine, determining a bound-padding value of half the difference between the wider markup and the stencil within the staff. However, without any additional padding I notice that the measures are usually *wider* than necessary, even forcing the music to run off the staff to the right.

The attached images show that the effective padding is very different in different measures. And when I subtract some manual offset I end up some measures still having generous padding while others already have the markup overlap the barlines.

So I have the impresstion that - while solving the original issue of measure-start elements - bound-padding is still not sufficiently reliable/manageable for my issue.

Urs

Attachment: 1756_034_1.png
Description: PNG image

Attachment: 1756_034_1.png
Description: PNG image


reply via email to

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