Next: , Previous: Music expressions explained, Up: Multiple notes at once


2.3.2 Multiple staves

As we saw in Music expressions explained, LilyPond input files are constructed out of music expressions. If the score begins with simultaneous music expressions, LilyPond creates multiples staves. However, it is easier to see what happens if we create each staff explicitly.

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 elements are then combined in parallel with << and >>:

     
     \relative c'' {
       <<
         \new Staff { \clef treble 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 automatically. For more complex pieces, it is best to mark contexts explicitly.

There are several types of contexts. Score, Staff, and Voice handle melodic notation, while Lyrics sets lyric texts and ChordNames prints 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.

Time signatures entered in one staff affects all other staves, but the key signature of one staff does not affect other staves1.

     
     \relative c'' {
       <<
         \new Staff { \clef treble \time 3/4 c }
         \new Staff { \clef bass \key d \major c,, }
       >>
     }

[image of music]


Footnotes

[1] This behavior may be changed if desired; see Changing defaults for details.


Next: , Previous: Music expressions explained, Up: Multiple notes at once

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

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

Other languages: French.