Changing staff automatically

Voices can be made to switch automatically between the top and the bottom staff. The syntax for this is

\autoChange …music

This will create two staves inside the current staff group (usually a PianoStaff), called "up" and "down". The lower staff will be in the bass clef by default. The auto-changer switches on the basis of the pitch (middle C is the turning point), and it looks ahead skipping over rests to switch in advance.

\new PianoStaff {
  \autoChange {
    g4 a b c'
    d'4 r a g
  }
}

[image of music]

It is possible to specify other pitches for the turning point. If the staves are not instantiated explicitly, other clefs may be used.

music = {
  g8 b a c' b8 d' c'8 e'
  d'8 r f' g' a'2
}

\autoChange d' \music
\autoChange b \with { \clef soprano } \music
\autoChange d' \with { \clef alto } \with { \clef tenor } \music

[image of music]

A \relative section that is outside of \autoChange has no effect on the pitches of the music, so if necessary, put \relative inside \autoChange.

If additional control is needed over the individual staves, they can be created manually with the names "up" and "down". The \autoChange command will then switch its voice between the existing staves.

Note: If staves are created manually, they must be named "up" and "down".

For example, staves must be created manually in order to place a key signature in the lower staff:

\new PianoStaff <<
  \new Staff = "up" {
    \new Voice = "melOne" {
      \key g \major
      \autoChange \relative {
        g8 b a c b d c e
        d8 r fis, g a2
      }
    }
  }
  \new Staff = "down" {
    \key g \major
    \clef bass
  }
>>

[image of music]

See also

Notation Reference: Changing staff manually.

Snippets: Keyboards.

Known issues and warnings

The staff switches may not end up in optimal places. For high quality output, staff switches should be specified manually.

Chords will not be split across the staves; they will be assigned to a staff based on the first note named in the chord construct.


LilyPond Notation Reference v2.25.22 (development-branch).