lilypond-devel
[Top][All Lists]
Advanced

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

Need real cross-staff chords


From: Pavel Roskin
Subject: Need real cross-staff chords
Date: Fri, 6 Jan 2012 23:18:20 -0500

Hello!

I just wanted to update one song (Schubert's "Die Forelle") on Mutopia
from Lilypond 2.4 to 2.14.2.

Most stuff could be updated easily.  It's great that some overrides
could even be removed. However, there is one "regression" when I cannot
do something with the new Lilypond.

In some places, there are cross-staff chords, i.e. chords with
noteheads placed on both piano staves.

Lilypond documentation suggests making the stems on the lower
staff longer so they meet the stems on the upper staff:

http://lilypond.org/doc/v2.15/Documentation/notation/common-notation-for-keyboards#cross_002dstaff-stems

There is also a snippet that suggest lowering the stems:

http://lsr.dsi.unimi.it/LSR/Snippet?id=770

The problem is that both approaches depend on the ability to fix the
distance between staves, which existed in Lilypond 2.4 both doesn't
seem to exist now.  The original file used:

\context {
   \PianoStaff
   \accepts Dynamics
   \override VerticalAlignment #'forced-distance = #7
}

There is no "forced-distance" now.  I can use "minimal-distance", but
there is no guarantee that Lilypond won't increase the distance between
staves.  And Lilypond may do it because of something in another measure.

I can typeset the score, but I'll make it more fragile.  I'm guilty of
omitting some niceties from other scores, but in this case I'm going to
update the existing score, so I don't want any regressions, even
potential ones.

This file illustrates the problem:

\version "2.14.2"
\score {
  <<
    \new PianoStaff
    <<
      \new Staff = right {
        b4 b4 b4 b4 \break |
        c,4 b4 b4 b4 |
      }
      \new Staff = left {
        \override Stem #'length = #16
        \override Stem #'cross-staff = ##t
        \clef bass c4 c4 c4 c4 |
        r4 c4 c4 c4 |
      }
    >>
  >>
  \layout { }
}

A low note breaks the stems apart.  I used extra length for the stems
to have some overlap, but it created another problem.  It can be seen
that the stems below F on the upper staff are slightly thicker than
above.  It's seen in the PDF viewer only with some zoom settings.  I
believe the stem is drawn twice, so if any antialiasing is used to
display it, the antialiased pixels get darker where they overlap.

The overlap problem can be solved by lowering the stems as in the LSR
snippet.  However, the snippet uses some calculations that are based on
staff-staff distance, so stems would get detached from the lower notes
if that distance increases.

I believe it would be nice to have support for cross-staff chords.
Perhaps it could be done as another snippet.  I'm a beginner in Scheme
and Lilypond, so it takes me quite a lot of effort.  I'll appreciate
some help.

I envision having a Scheme function that would apply to some notes in
the chord:

<g c g,\crossStaff>

The crossStaff function would thus get the note grob as the argument.
One approach would be to "reparent" the notehead to another staff
context.  I have no idea if that's possible.  I would need to find the
PianoStaff (or GrandStaff) context from the grob, find the other Staff
and tell Lilypond that the notehead should sit there.  Hopefully, no
voices on the other staff would need to be used.

Another approach would be to do more manual work, namely hide the
notehead, draw it on the other staff (considering the middle C
position) and extend the beam downwards.  I'll need a way to find
the actual distance between staves in the given point.  I've been
struggling to get that number, but I only managed to get the default
numbers and obscure functions (probably not to be called by my
snippet).  I believe I need to find the grob for the staff, but I don't
see any way to do it starting from the grob for the note.

I'll appreciate any suggestions.

-- 
Regards,
Pavel Roskin



reply via email to

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