Next: , Previous: Music expressions explained, Up: Tutorial



2.8 More staves

To print more than one staff, each piece of music that makes up a staff is marked by adding \new Staff before it. These Staff's are then combined parallel with << and >>, as demonstrated here

     <<
       \new Staff { \clef violin c'' }
       \new Staff { \clef bass c }
     >>

[image of music]

The command \new introduces a “notation context.” A notation context is an environment in which musical events (like notes or \clef commands) are interpreted. For simple pieces, such notation contexts are created implicitly. For more complex pieces, it is best to mark contexts explicitly. This ensures that each fragment gets its own stave.

There are several types of contexts: Staff, Voice and Score handle normal music notation. Other staves are also Lyrics (for setting lyric texts) and ChordNames (for printing chord names).

In terms of syntax, prepending \new to a music expression creates a bigger music expression. In this way it resembles the minus sign in mathematics. The formula (4+5) is an expression, so -(4+5) is a bigger expression.

We can now typeset a melody with two staves

     \score {
       \notes <<
         \new Staff {
           \time 3/4
           \clef violin
           \relative c'' {
             e2 d4 c2 b4 a8[ a]
             b[ b] g[ g] a2. }
         }
         \new Staff {
            \clef bass
            c2 e4  g2.
            f4 e d c2.
         }
       >>
     }

[image of music]

For more information on context see the description in Interpretation contexts.

Read comments on this page, or add one.

This page is for LilyPond-2.2.6 (stable-branch).

Report errors to <bug-lilypond@gnu.org>.