I am trying to typeset some music in Lilypond, where there is a player doubling on an auxiliary instrument. I would like the 2nd flute player to change to 2nd piccolo. But I also want the staves to be displayed in the right order (i.e. Picc. 1, Picc. 2, Fl. 1, Fl. 2)
A minimal example code is provided below which almost works, however the old staff remains even though it is empty:
I don't want to use \RemoveEmptyStaves
, because there are staves (with rests) throughout the score that I do want displayed.
Is there some other way to "kill" the old staff?
Is there another way to write a doubling player's part on different staves?
Another approach that I have tried, is keeping a single staff for the doubling player (by removing/commenting-out the line marked with the asterisks ***
in the code below). This is much like the example on the parts-writing page of the documentation.
I can reset staff's shortInstrumentName
, but the alignBelowContext
does not seem to work, so the staff doesn't move into the right place:
(resetting the midiInstrument
doesn't work either)
Code
\version "2.21.0"
piccoloOne = {
\new Staff = "piccolo-one" {
\set Staff.instrumentName = "Piccolo 1"
\set Staff.shortInstrumentName = "Picc. 1"
\set Staff.midiInstrument = #"piccolo"
\transposition c''
% 1
fis''1~ | fis''1~ |
% 3
fis''1 |
}
}
fluteOne = {
\new Staff {
\set Staff.instrumentName = "Flute 1"
\set Staff.shortInstrumentName = "Fl. 1"
\set Staff.midiInstrument = #"flute"
\transposition c'
% 1
b'1~ | b'1~ |
% 3
b'1 |
}
}
fluteTwoDoublingPiccoloTwo = {
\new Staff {
\set Staff.instrumentName = "Flute 2"
\set Staff.shortInstrumentName = "Fl. 2"
\set Staff.midiInstrument = #"flute"
\transposition c'
% 1
d'1 | R1^\markup{"muta in Picc. 2"} | \break
% MUTA
} \new Staff { % ***
\set Staff.alignBelowContext = #"piccolo-one"
\set Staff.shortInstrumentName = "Picc. 2"
\set Staff.midiInstrument = #"piccolo"
\transposition c''
\once\override Staff.TimeSignature #'stencil = ##f
% 3
d''1~ |
}
}
\score {
\new StaffGroup
<<
\piccoloOne
\fluteOne
\fluteTwoDoublingPiccoloTwo
>>
\layout {
indent = 20
short-indent = 10
}
\midi { }
}
Update: Solution
Following the accepted answer below, the trick is:
- to use
VerticalAxisGroup.remove-layer
for each of the doubling part's staves, - and the
Keep_alive_together_engraver
for the staff group:
Updated Code
\version "2.21.0"
piccoloOne = {
\new Staff = "piccolo-one" {
\set Staff.instrumentName = "Piccolo 1"
\set Staff.shortInstrumentName = "Picc. 1"
\set Staff.midiInstrument = #"piccolo"
\transposition c''
% 1
fis''1~ | fis''1~ |
% 3
fis''1 |
}
}
fluteOne = {
\new Staff {
\set Staff.instrumentName = "Flute 1"
\set Staff.shortInstrumentName = "Fl. 1"
\set Staff.midiInstrument = #"flute"
\transposition c'
% 1
b'1~ | b'1~ |
% 3
b'1 |
}
}
fluteTwoDoublingPiccoloTwo = {
\new Staff
\with { \override VerticalAxisGroup.remove-layer = 2 } {
\set Staff.instrumentName = "Flute 2"
\set Staff.shortInstrumentName = "Fl. 2"
\set Staff.midiInstrument = #"flute"
\transposition c'
% 1
d'1 | R1^\markup{"muta in Picc. 2"} | \break
}
% MUTA
\new Staff
\with { \override VerticalAxisGroup.remove-layer = 1 } {
\set Staff.alignBelowContext = #"piccolo-one"
\set Staff.shortInstrumentName = "Picc. 2"
\set Staff.midiInstrument = #"piccolo"
\transposition c''
\once\override Staff.TimeSignature #'stencil = ##f
% 3
d''1~ |
}
}
\score {
\new StaffGroup
\with { \consists "Keep_alive_together_engraver" } {
<<
\piccoloOne
\fluteOne
\fluteTwoDoublingPiccoloTwo
>>
}
\layout {
indent = 20
short-indent = 10
}
\midi { }
}