lilypond-user
[Top][All Lists]
Advanced

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

Re: Cross-staff stems


From: Thomas Morley
Subject: Re: Cross-staff stems
Date: Wed, 28 Mar 2018 16:08:48 +0200

2018-03-28 15:43 GMT+02:00 Andrew Bernard <address@hidden>:
> Hi All,
>
> This is surprisingly tricky, because the b flats don't line up with the
> bass. I think the OP is asking how to achieve that, not the mechanism of
> cross staff stemming.
>
> I cant figure it out either!
>
> Andrew



Hi Bernhard.

as Andrew pointed out it is tricky.

One reason is the typesetting in the image you provided is bad
concerning the order in which the last two notes in the RH are set,
imho
LilyPond does it the other way round by default. So you need to move
one note, if you want to mimic the image.
Additionally the AccidentalPlacement at second 8th is different by
default, not sure whether LilyPond does it correct. (This is not
tweaked below)

Another reason are the not aligning notes which should have the
cross-staff-stem. For this purpose I wrote `pushNC' some time ago.
Using it will result in uneven spacing so moving another NoteColumn
via X-offset is applied.

So here you are:

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
  }
}

\new PianoStaff
<<
  \new Staff <<
    \new Voice {
      \voiceOne
      d'8 c'? \once \override Score.NoteColumn.X-offset = 2 b a
    }
    \new Voice {
      \voiceTwo
      s \crossStaff bes s
      \once \override NoteColumn.force-hshift = 1.5
      \crossStaff bes
    }
  >>
  \new Staff {
    \clef F
    \voiceTwo
    fis, \pushNC cis fis, \pushNC cis
  }
>>

HTH,
  Harm



reply via email to

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