Next: Voice styles, Up: Multiple voices
Explicitly instantiating voices
The basic structure 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. } >>
Here, voices are instantiated explicitly and are given names. 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. The \oneVoice
command returns all the voice settings to the neutral default
directions.
Temporary polyphonic passages
A temporary polyphonic passage can be created with the following construct:
<< { \voiceOne ... } \new Voice { \voiceTwo ... } >> \oneVoice
Here, the first expression within a temporary polyphonic passage is
placed into the Voice
context which was in use immediately
before the polyphonic passage, and that same Voice
context
continues after the temporary section. Other expressions within
the angle brackets are assigned to distinct temporary voices.
This allows lyrics to be assigned to one continuing voice before,
during and after a polyphonic section:
<< \new Voice = "melody" { a4 << { \voiceOne g f } \new Voice { \voiceTwo d2 } >> \oneVoice e4 } \new Lyrics \lyricsto "melody" { This is my song. } >>
Here, the \voiceOne
and \voiceTwo
commands are
required to define the settings of each voice.
The double backslash construct
The << {...} \\ {...} >>
construct, where the two (or
more) expressions are separated by double backslashes, behaves
differently to the similar construct without the double backslashes:
all the expressions within this contruct are assigned
to new Voice
contexts. These new Voice
contexts
are created implicitly and are given the fixed names "1"
,
"2"
, etc.
The 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. } >>
This syntax 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. Spacer rests are used to avoid printing doubled rests.
<< { r8 g g g g f16 ees f8 d } \\ { ees,8 r ees r d r d r } \\ { d'8 s c s bes s a s } >>
In all but the simplest works it is advisable to create explicit
Voice
contexts as explained in Contexts and engravers and
Explicitly instantiating voices.
Identical rhythms
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 construct within an explicit voice:
\new Voice << { e4 f8 d e16 f g8 d4 } { c4 d8 b c16 d e8 b4 } >>
This method leads to strange beamings and warnings if the pieces of music do not have the same rhythm.
\voiceOne
,
\voiceTwo
,
\voiceThree
,
\voiceFour
,
\oneVoice
.
Learning Manual: Voices contain music, Explicitly instantiating voices.
Notation Reference: Percussion staves, Invisible rests.
Snippets: Simultaneous notes.