Next: , Up: Multiple voices


Single-staff polyphony

The basic structure of code needed to achieve multiple, independent voices in a single staff is illustrated in the following example:

     
     \new Staff <<
       \new Voice = "first"
         { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
       \new Voice= "second"
         { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
     >>

[image of music]

Here, voices are instantiated explicitly and are given a name. The \voiceOne ... \voiceFour commands set up the voices so that first and third voices get stems up, second and fourth voices get stems down, third and fourth voice note heads are horizontally shifted, and rests in the respective voices are automatically moved to avoid collisions. Using the \oneVoice command, all the voice settings are put back to the neutral directions typical of a single-voice passage.

We can make a voice to be in the same Voice context before and after a temporary polyphonic passage. For example, the following construct keeps a voice alive throughout the polyphonic section. Said voice is the first one inside of the two-voice section, and the extra voice is the second one.

<< { \voiceOne ... } \new Voice { \voiceTwo ... } >> \oneVoice

Using the name given when created, this allows lyrics to be assigned to one consistent voice.

     
     <<
       \new Voice = "melody" {
         a4
         <<
           {
             \voiceOne
             g f
           }
           \new Voice {
             \voiceTwo
             e d
           }
         >>
         \oneVoice
         e
       }
       \new Lyrics \lyricsto "melody" {
       This is my song.
       }
     >>

[image of music]

Here, the \voiceOne and \voiceTwo commands help to make clear what settings does each voice receive.

The <<{...} \\ {...}>> construction, where the two (or more) voices are separated by double backslashes, can be used as a simplified method to print multiple voices in a single staff. Our first example could be typeset as follows:

     
     <<
       { r8 r16 g e8. f16 g8[ c,] f e16 d }
       \\
       { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
     >>

[image of music]

This syntax is simpler and can be used where it does not matter that temporary voices are created and then discarded. These implicitly created voices are given the settings equivalent to the effect of the \voiceOne ... \voiceFour commands, in the order in which they appear in the code. In the following example, the intermediate voice has stems up, therefore we enter it in the third place, so it becomes voice three which has the stems up as desired.

     
     <<
       { r8 g g  g g f16 es f8 d }
       \\
       { es,8 r es r d r d r }
       \\
       { d'8 s c s bes s a s }
     >>

[image of music]

Spacer rests are often used to avoid too many rests, as seen in the example above.

In all but simplest works it is advisable to create explicit Voice contexts using the \new and \context commands as it is explained in Contexts and engravers and Explicitly instantiating voices.

In the special case that we want to typeset parallel pieces of music that have the same rhythm, we can combine them into a single Voice context, thus forming chords. To achieve this, enclose them in a simple simultaneous music construction and make it to be an explicit voice:

     
     \new Voice <<
       { e4 f8 d e16 f g8 d4 }
       { c4 d8 b c16 d e8 b4 }
     >>

[image of music]

This method leads to strange beamings and warnings if the pieces of music do not have the same rhythm.

Predefined commands

\voiceOne, \voiceTwo, \voiceThree, \voiceFour, \oneVoice.

See also

Learning Manual: Voices contain music, Explicitly instantiating voices.

Notation Reference: Percussion staves, Invisible rests.

Snippets: Simultaneous notes.

Diese Seite ist für LilyPond-2.11.58 (Entwicklungszweig).

Fehler bitte an http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs melden.

Ihre Vorschläge für die Dokumentation sind willkommen.

Andere Sprachen: español.