lilypond-user
[Top][All Lists]
Advanced

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

Re: Coordinates of the noteheads a tie/slur is attached to


From: David Nalesnik
Subject: Re: Coordinates of the noteheads a tie/slur is attached to
Date: Tue, 24 Jan 2017 08:42:40 -0600

Hi Urs,

On Tue, Jan 24, 2017 at 7:19 AM, Urs Liska <address@hidden> wrote:
> Hi,
>
> how can I find the coordinates of the two note heads a tie or slur is
> attached to?
>
> I need to write a new stencil for these curves and want to hook that not
> to the staff origin but to the actual note heads.
>
> There is some code in
> https://github.com/openlilylib/snippets/blob/master/notation-snippets/shaping-bezier-curves/shapeII.ily
> that does this (esp. in get-extremal-head and in notehead-placement),
> but somehow I have the impression that code is more complicated than
> necessary. Apart from that IIRC this is exactly the part of \shapeII
> that seems to be problematic with current LilyPond.
>
> So, before I start to actually try understanding that code I'd like to
> ask for some pointers how I could better approach the question.
>

Try:

\version "2.19.53"

#(define (get-noteheads grob)
   (if (grob::has-interface grob 'note-column-interface)
       (ly:grob-array->list (ly:grob-object grob 'note-heads))
       (list grob)))

#(define (my-notehead-positions grob)
   (let* ((sys (ly:grob-system grob))
          (lb (ly:spanner-bound grob LEFT))
          (rb (ly:spanner-bound grob RIGHT))
          (lb-noteheads (get-noteheads lb))
          (rb-noteheads (get-noteheads rb)))
     (format #t "~a ~{~a ~}~%"
       grob
       (map (lambda (nh)
              (format #f "(~a, ~a)"
                (ly:grob-relative-coordinate nh sys X)
                (ly:grob-relative-coordinate nh sys Y)))
         (append lb-noteheads rb-noteheads)))))

{
  \override Slur.after-line-breaking = #my-notehead-positions
  \override Tie.after-line-breaking = #my-notehead-positions
  c~ c c( e)
}

%%%%%%%%%%%%%%%%%

The problem with the code above is that querying the Y-coordinate will
mess with vertical spacing.  This is clear with more than one staff:

\new PianoStaff <<
  \new Staff {
    \override Slur.after-line-breaking = #my-notehead-positions
    \override Tie.after-line-breaking = #my-notehead-positions
    c~ c c( e)
  }
  \new Staff {
    R1
  }
>>

%%%%%%%%%%%%%%%%

This, presumably is the problem with \shapeII.

You can get the Y position by 'staff-position of the notes and
calculate the Y from the staff-space, staff-width, etc.

HTH,

David



reply via email to

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