lilypond-user
[Top][All Lists]
Advanced

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

Re: Cross-staffs where a note is already displaced


From: Thomas Morley
Subject: Re: Cross-staffs where a note is already displaced
Date: Thu, 15 Jun 2017 00:30:44 +0200

2017-06-14 18:58 GMT+02:00 David Wright <address@hidden>:
> On Mon 12 Jun 2017 at 09:17:31 (+0200), Thomas Morley wrote:
>> 2017-06-12 6:43 GMT+02:00 David Wright <address@hidden>:
>> > I can't figure out how to make crossStaff work when one component
>> > has been displaced by the interval of a second. I came up with a
>> > hack (a hidden note) in example 3, but it has the side effect of
>> > leaving the accidental (when there is one) rather far over.
>> > Is there a better way?
>>
>> See:
>> http://lists.gnu.org/archive/html/lilypond-user/2016-11/msg00230.html
>>
>> For your example:
>>
>> \version "2.19.59"
>>
>> \header { tagline = ##f }
>>
>> pushNC =
>> \once \override NoteColumn.X-offset =
> […]
>
> Thanks for this code. I searched back through the archives, but
> skated straight over this thread because I didn't recognise its
> relevance, perhaps because there wasn't an image of Andrew/LP's
> failing case. (Most of Andrew's scores are far too esoteric for
> me to understand.)
>
> Would I be right in thinking it searches through the grobs for
> this moment, finds out if any have been displaced, and returns
> the displacement?

Actually, all Stem-grobs are filtered from the current PaperColumn.
The value returned is the difference between the most left and the
most right Stem.
The NoteColumn where \pushNc (usually note the one on which
\crossStaff works) is applied to is moved by this amount.

As result the stems are aligned, so \crossStaff can join their stems.
One needs to full-fill the condition that the stems are _very_ close.

To get more detailed info whats coded, I always find displaying whats
done very helpful. Here:

pushNC =
\once \override NoteColumn.X-offset =
  #(lambda (grob)
    (let* ((p-c (ly:grob-parent grob X))
           (p-c-elts (ly:grob-object p-c 'elements))
           (stems
             (if (ly:grob-array? p-c-elts)
                 (filter
                   (lambda (elt)(grob::has-interface elt 'stem-interface))
                   (ly:grob-array->list p-c-elts))
                 #f))
           (stems-x-exts
             (if stems
                 (map
                   (lambda (stem)
                     (ly:grob-extent
                       stem
                       (ly:grob-common-refpoint grob stem X)
                       X))
                   stems)
                 '()))
           (sane-ext
             (filter interval-sane? stems-x-exts))
           (cars (map car sane-ext)))
(format #t "\np-c: ~a" p-c)
(format #t "\np-c-elts: ~y" (ly:grob-array->list p-c-elts))
(format #t "\nstems: ~a" stems)
(format #t "\nstems-x-exts: ~y" stems-x-exts)
(format #t "\nsane-ext: ~y" sane-ext)
(format #t "\ncars: ~a" cars)

(let ((amount-to-move
        (if (pair? cars)
            (abs (- (apply max cars)  (apply min cars)))
            0)))
  (format #t "\namount-to-move: ~a" amount-to-move)
  amount-to-move
  ;0
  )))

> Would it be worth having a snippet with a
> title that involves words like "determining the horizontal
> displacement of colliding simultaneous notes for eg crossstaffs"
> so that google (and others) might find it?

Well, I'm not sure it will always work or more precisely, that it will
always work as wished...
Needs more testing, I'd say.

> Despite having some scheme code that I don't understand
> bundled into an .ily file, it makes my LP code much simpler.
> Thanks again.
>
> Cheers,
> David.

Cheers,
  Harm



reply via email to

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