Next: , Previous: Changing staff manually, Up: Common notation for keyboards


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 autochanger 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]

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. For example, this is necessary to place a key signature in the lower staff:

     
     \new PianoStaff <<
       \new Staff = "up" {
         \new Voice = "melOne" {
           \key g \major
           \autochange \relative c' {
             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.

Internals Reference: AutoChangeMusic.

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.

This page is for LilyPond-2.11.58 (development-branch).

Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.

Your suggestions for the documentation are welcome.

Other languages: français, español, deutsch.