1

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: new staff created in the right place but old staff remains

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) single staff doesn't get moved into the right place


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

solution

1

What you want is the VerticalAxisGroup.remove-layer property. You can find a code example exhibiting similar behavior to what you want at http://lilypond.org/doc/v2.23/Documentation/notation/modifying-single-staves#hiding-staves.

3
  • @Aaron - Since the questioner specified, “I don't want to use \RemoveEmptyStaves,” and the example that you posted uses \RemoveAllEmptyStaves (which I think identical to the former, except that it also affects the first system), is there any way to use VerticalAxisGroup.remove-layer apart from those commands? Or is it meant to be used only in conjunction with them?
    – Neal
    Oct 27 '21 at 14:54
  • @Neal I gathered that the reason OP didn't want \RemoveAllEmptyStaves was because it removed staves with only rests. The remove-layer property sidesteps that problem. But to the best of my knowledge, they operate together.
    – Aaron
    Oct 27 '21 at 14:57
  • 1
    On the first few readings of the page you link to, I was thinking that the example with violins wasn't the right way to go because it uses \RemoveAllEmptyStaves, and it's an example of "divisi" not "muta", so the parts are in parallel not sequential. Which I didn't think would work. However I was eventually able to just use VerticalAxisGroup.remove-layer for each staff, and Keep_alive_together_engraver for the staff group to achieve what I want, without changing to parallel structure or even needing the \RemoveAllEmptyStaves command at all. Oct 27 '21 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.