lilypond-user
[Top][All Lists]
Advanced

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

Re: Text spanner associated start and end notes


From: Thomas Morley
Subject: Re: Text spanner associated start and end notes
Date: Wed, 9 Mar 2016 11:26:03 +0100

2016-03-09 10:59 GMT+01:00 Andrew Bernard <address@hidden>:
> Greetings All,
>
> This is a Scheme question. We are trying to make a callback function for a
> customised text spanner that centres the left and right markup text exactly
> over the centre of the first and last notes the spanner covers. I am doing
> this in Scheme, and all is working, but so far I am unable to determine the
> actual grob for the note that the \startTexSpan is associated with. It
> appears that the left bound of the spanner is a paper column object, not a
> note. I do not know how to go from that to find the note. Why do I want to
> find the note? So that I can find its half width and use that as the offset
> for the text, the point being that different note values have different
> widths – long white notes are wider, for example.
>
> I would very much like to post code here, but it is difficult to post code
> to ask for assistance in this case where I simply have idea no how to
> proceed. I apologise for this. Somewhat problematical. I am looking for
> conceptual guidance on this matter, rather than code assistance.
>
> I have searched LSR a dozen times with many keywords. I have read and reread
> the Scheme function list. I have googled as deeply as I know how. I have
> written many pages of exploratory code in Scheme. I am unable to believe
> that we are the first and only people to want to do this, as I am unable to
> find any examples similar. What am I not understanding or missing? Any help
> would be most appreciated.
>
> Andrew


Hi Andrew,

thinking of suspended NoteHeads you may be better off to rely on the
NoteColumn-extent for aligning.

Nevertheless the below may be of some help:

\version "2.19.36"

foo =
\override TextSpanner.after-line-breaking =
#(lambda (grob)
  (let* ((left-pc
           (ly:grob-array-ref  (ly:grob-object grob 'note-columns) 0))
         (note-heads
           (ly:grob-array->list (ly:grob-object left-pc 'note-heads))))
    (for-each
      (lambda (nh)
        (ly:grob-set-property! nh 'color red))
      note-heads)))


\relative c'' {
    \foo
    <c d>1\startTextSpan
    d
    e\stopTextSpan
}


HTH,
  Harm



reply via email to

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