Suppose I want to use eighth notes which differ widely in pitch, so that half of the eighth notes fall in a bass clef and half of them are best represented in a treble clef. Is there a way to use one beam to connect these notes on two different staves in Lilypond?
2 Answers
A Voice
can change Staff
(the respective Staff
has to exist at that point of time, if necessary by using \skip
as appropriate).
Try
\new PianoStaff <<
\new Staff = "treble" {
\new Voice {
\repeat unfold 8 { \change Staff = "treble" c''16
\change Staff = "bass" c,16
}
}
}
\new Staff = "bass" \with { \clef "bass" } { \skip 1 }
>>
Yes, this is possible, but there are some quirks you may encounter:
upper = \relative c' {
g''8 \change Staff = "LH" g,,,
\change Staff = "RH" a''' \change Staff = "LH" fis,,,
\change Staff = "RH" b''' \change Staff = "LH" e,,,,
\change Staff = "RH" c'''' \change Staff = "LH" d,,,,
}
lower = \relative c {
\clef bass
s2
}
\score {
\new PianoStaff <<
\new Staff = "RH" \upper
\new Staff = "LH" \lower
>>
}
Hm, a warning:
warning: cannot find context to switch to
\change Staff = "RH" b'''
\change Staff = "LH" e,,,,
This means that the Staff
named "LH"
did not "exist" where another Staff
was trying to reference it. So we need to keep both staves "alive." A spacer rest does nicely:
upper = \relative c' {
g''8 \change Staff = "LH" g,,,
\change Staff = "RH" a''' \change Staff = "LH" fis,,,
\change Staff = "RH" b''' \change Staff = "LH" e,,,,
\change Staff = "RH" c'''' \change Staff = "LH" d,,,,
}
lower = \relative c {
\clef bass
s2 s2 % (or s1)
}
\score {
\new PianoStaff <<
\new Staff = "RH" \upper
\new Staff = "LH" \lower
>>
}
You can control the when and where of beaming, as well. For when, see 1.2.4 Automatic beams > Selected Snippets > Changing beam knee gap: \override Beam.auto-knee-gap = #6
; for where, you can specifically move the beams:
upper = \relative c' {
g''8 \change Staff = "LH" g,,,
\change Staff = "RH" a''' \change Staff = "LH" fis,,,
\override Beam.positions = #'( -4.5 . -4.5 )
\change Staff = "RH" b''' \change Staff = "LH" e,,,,
\change Staff = "RH" c'''' \change Staff = "LH" d,,,,
}
lower = \relative c {
\clef bass
s2 s2 % (or s1)
}
\score {
\new PianoStaff <<
\new Staff = "RH" \upper
\new Staff = "LH" \lower
>>
}