Cross-staffs where a note is already displaced

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Cross-staffs where a note is already displaced

David Wright
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?

Also, in particular, why is the f4 displaced in example 2,
seeing as I have shifted the <d'' g'> well out of the way?

Cheers,
David.

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

crossstaff.ly (1K) Download Attachment
crossstaff.pdf (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Cross-staffs where a note is already displaced

Thomas Morley-2
2017-06-12 6:43 GMT+02:00 David Wright <[hidden email]>:
> 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 =
  #(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)))
    (if (pair? cars)
        (abs (- (apply max cars)  (apply min cars)))
        0)))

\layout {
  \context {
    \PianoStaff
    \consists #Span_stem_engraver
    \omit TimeSignature
  }
}

middle =  { \time 3/4 \voiceTwo \autoBeamOff \crossStaff { f'4 e'8 d' e'4 } }

\new PianoStaff <<
  \new Staff <<
    \new Voice { \voiceOne <d'' g'>4 g'8 f' g'4 }
    \new Voice { \middle }
  >>
  \new Staff <<
    \new Voice {
      \clef bass
      \voiceTwo
      %% the value 1.3 is not close/exact enough
      %% 1.304212 would have worked
      %\once \override NoteColumn.X-offset = #1.3
      %% better do:
      \pushNC
      cis'4 cis'8 cis' cis'4
    }
  >>
>>


HTH,
  Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Cross-staffs where a note is already displaced

David Wright
On Mon 12 Jun 2017 at 09:17:31 (+0200), Thomas Morley wrote:

> 2017-06-12 6:43 GMT+02:00 David Wright <[hidden email]>:
> > 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? 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?

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.

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Cross-staffs where a note is already displaced

Thomas Morley-2
2017-06-14 18:58 GMT+02:00 David Wright <[hidden email]>:

> On Mon 12 Jun 2017 at 09:17:31 (+0200), Thomas Morley wrote:
>> 2017-06-12 6:43 GMT+02:00 David Wright <[hidden email]>:
>> > 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

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Cross-staffs where a note is already displaced

David Wright
On Thu 15 Jun 2017 at 00:30:44 (+0200), Thomas Morley wrote:

> 2017-06-14 18:58 GMT+02:00 David Wright <[hidden email]>:
> >
> > 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:

Thanks for the explanation, which'll help me walk through the code,
and for the debug statements.

Cheers,
David.

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user