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: Urs Liska
Subject: Re: Coordinates of the noteheads a tie/slur is attached to
Date: Wed, 25 Jan 2017 09:48:07 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0

Hi David,

thanks for your code


Am 24.01.2017 um 15:42 schrieb David Nalesnik:
> 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?
>>
>> ...
> Try:
>
> ...
>
> You can get the Y position by 'staff-position of the notes and
> calculate the Y from the staff-space, staff-width, etc.
>
> HTH,

Indeed. I think for the next step I have everything I need, I can
determine the horizontal distance of the note heads and the Y position,
and from there I'll be able to create a path. The following isn't the
path I'm after but it shows how (and that) it works.
What I'll have to deal with now is the direction and the proper handling
of chords (of course it's not a solution to simply pick the first
notehead). And of course I'll clean up the bindings.

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

\version "2.19.54"

#(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))
          (lb-noteheads (get-noteheads lb))
          (lb-x (ly:grob-relative-coordinate (first lb-noteheads) sys X))
          (lb-y (ly:grob-property (first lb-noteheads) 'staff-position))
          (lb-y-start (- (/ lb-y 2) 1.5))
          (rb (ly:spanner-bound grob RIGHT))
          (rb-noteheads (get-noteheads rb))
          (rb-x (ly:grob-relative-coordinate (first rb-noteheads) sys X))
          (rb-y (ly:grob-property (first rb-noteheads) 'staff-position))
          (rb-y-end (- (/ rb-y 2) 1.5))
          (grob-width (- rb-x lb-x))
          )
     (ly:make-stencil
      `(path
        0.5
        `(moveto 0 ,,lb-y-start
           lineto ,,grob-width ,,rb-y-end)))
     ))

\relative c' {
  \override Slur.stencil = #my-notehead-positions
  \override Tie.stencil = #my-notehead-positions
  c~ c <g' c>2( e)
}

\new PianoStaff <<
  \new Staff \relative c' {
    \override Slur.stencil = #my-notehead-positions
    \override Tie.stencil = #my-notehead-positions
    c~ c c( e)
  }
  \new Staff {
    R1*2
  }
>>

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


>
> David

-- 
address@hidden
https://openlilylib.org
http://lilypondblog.org




reply via email to

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