lilypond-user
[Top][All Lists]
Advanced

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

Re: Getting grob Y position (spacing error)


From: Gregory Evans
Subject: Re: Getting grob Y position (spacing error)
Date: Mon, 26 Dec 2022 13:18:53 -0500

Hi Jean,
I apologize for my delayed reply.

I do not think I can use the VoiceFollower grob because I am not using staff changes. Attached is a pdf of what I am trying to do. It works successfully if I input the y-position by hand but ideally it would be calculated automatically. You see, they are completely unrelated voices. Also see this image of hocket indications in Ben Johnston's 3rd string quartet which I think would not be done with VoiceFollower:
Screen Shot 2022-12-26 at 1.02.08 PM.png
 I have also included the lilypond file for my interruptive polyphony example if that is of any use to you even though it is quite large. While it's true that certain aspects of the process could be simplified (such as removing the use of 'meta as you suggest), there is little reason to revise it if the callback cannot be delayed until after the skyline calculation. Is there no way to simply trigger callback at a later time? Or, since I am overriding the note head grob, is there a cross-staff grob I could override instead? I understand this is an unusual problem! I thought there must be a grob which is aware of the final positions of everything on the page.

Thank you for your help even if there is no solution.

best,
greg

p.s. Just as a reminder to anyone reading this email the interruptive polyphony engraver originates with Piaras Hoban who I haven't been able to contact.

On Sat, Nov 19, 2022 at 3:08 AM Jean Abou Samra <jean@abou-samra.fr> wrote:

Le 19 nov. 2022 à 02:37, Gregory Evans <gregoryrowlandevans@gmail.com> a écrit :



Hello Jean,
thank you for the information about after-line-breaking and the timing of skyline computing. Is there an equivalent property to trigger callback after the skylines are calculated?



I’m afraid not. There are lower-level techniques you can use for that though, but see below for why you won’t need them.


I am trying to use (ly:stencil-add ...) to add to the stencil of a notehead by drawing a line from one notehead in one staff to a notehead in another staff.


Have you seen the VoiceFollower grob? Try using that instead.

By reading things in 'left-bound-info and 'right-bound-info, you can also spare yourself quite some code.

The notehead grob does not appear to have a cross-staff property to delay stencil callback.


NoteHead is a very fundamental grob at the heart of a lot of code (note collision handling, beams, note spacing, etc.). That code makes reasonable assumptions about the note heads and doesn’t expect cross-staff note heads.

\language "english"
\version "2.23.14"

#(set-global-staff-size 12)

\score {
    <<
        \new Staff {
            \override NoteHead.cross-staff = ##t
            \once \override NoteHead.after-line-breaking = #(lambda (grob)
                    (let*
                        (
                           (sys (ly:grob-system grob))
                           (x-extent (ly:grob-extent grob sys X))
                           (y-extent (ly:grob-extent grob sys Y))
                        )
                        (display (list x-extent ))
                    )
                )
            c'1
            c'1
            c'1
            c'1
        }
        \new Staff {
            c'1
            c'1
            c'1
            c'1
        }
    >>
}

A larger example of the function (without a great deal of context) looks like this:

interrupt = #(define-music-function (value) (number?)
  #{
      \once \override Staff.NoteHead.after-line-breaking = #(lambda (grob)
              (let* (
                (stem (ly:grob-object grob 'stem))
                (stem-dir (ly:grob-property stem 'direction))
                (stem-thickness (ly:grob-property stem 'thickness))
                (thickness (/ stem-thickness 10))
                (notecol (ly:grob-parent grob X))
                (meta  (assoc 'other-grob (ly:grob-property notecol 'meta)))

Have you seen ly:grob-object and ly:grob-set-object! ?

That would be way cleaner than abusing 'meta for this purpose. There is also 'details you can use instead of 'meta.

                (other (if meta
                              (cdr meta)
                              grob
                      ))
                (notehead-width (cdr (ly:grob-property grob 'X-extent)))
                (sys (ly:grob-system grob))
                (now-pos (ly:grob-extent grob sys X))
                (next-pos (ly:grob-extent other sys X))

                ;;the offending lines
                (now-pos-y (ly:grob-extent grob common Y))
                (next-pos-y (ly:grob-extent other common Y))

                (x-distance
                    (if (= stem-dir -1)
                      (+ (- (get-distance now-pos next-pos) notehead-width ) (/ thickness 2))
                      (- (get-distance now-pos next-pos) (/ thickness 2))
                    ))
                (y-distance
                    (if (= stem-dir -1)
                      (+ (- (get-distance now-pos-y next-pos-y) notehead-width ) (/ thickness 2))
                      (- (get-distance now-pos-y next-pos-y) (/ thickness 2))
                    ))

                ;; alternative which takes input number
                ;(ps-bracket
                ;    (if (= stem-dir -1)
                ;      (draw-ps-bracket x-distance notehead-width (- value 0.5) thickness)
                ;      (draw-ps-bracket x-distance notehead-width value thickness)
                ;    ))
                (ps-bracket


Does 'ps' stand for PostScript?

Best,
Jean



--
gregory rowland evans

Attachment: terrain.pdf
Description: Adobe PDF document

Attachment: terrain.ly
Description: Binary data


reply via email to

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