Previous: Automatic part combining, Up: Multiple voices
Music for multiple parts can be interleaved in input code. The
function \parallelMusic
accepts a list with the names of a
number of variables to be created, and a musical expression. The
content of alternate measures from the expression become the value
of the respective variables, so you can use them afterwards to
print the music.
Note: Bar checks | must be used, and the measures must
be of the same length.
|
\parallelMusic #'(voiceA voiceB voiceC) { % Bar 1 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' | r16 e'8.~ e'4 r16 e'8.~ e'4 | c'2 c'2 | % Bar 2 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' | r16 d'8.~ d'4 r16 d'8.~ d'4 | c'2 c'2 | } \new StaffGroup << \new Staff << \voiceA \\ \voiceB >> \new Staff { \clef bass \voiceC } >>
Relative mode may be used. Note that the \relative
command
is not used inside \parallelMusic
itself. The notes are
relative to the preceding note in the voice, not to the previous
note in the input – in other words, relative notes for
voiceA
ignore the notes in voiceB
.
\parallelMusic #'(voiceA voiceB voiceC) { % Bar 1 r8 g16 c e g, c e r8 g,16 c e g, c e | r16 e8.~ e4 r16 e8.~ e4 | c2 c | % Bar 2 r8 a,16 d f a, d f r8 a,16 d f a, d f | r16 d8.~ d4 r16 d8.~ d4 | c2 c | } \new StaffGroup << \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >> \new Staff \relative c' { \clef bass \voiceC } >>
This works quite well for piano music. This example maps four consecutive measures to four variables:
global = { \key g \major \time 2/4 } \parallelMusic #'(voiceA voiceB voiceC voiceD) { % Bar 1 a8 b c d | d4 e | c16 d e fis d e fis g | a4 a | % Bar 2 e8 fis g a | fis4 g | e16 fis g a fis g a b | a4 a | % Bar 3 ... } \score { \new PianoStaff << \new Staff { \global << \relative c'' \voiceA \\ \relative c' \voiceB >> } \new Staff { \global \clef bass << \relative c \voiceC \\ \relative c \voiceD >> } >> }
Learning Manual: Organizing pieces with variables.
Snippets: Simultaneous notes.
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.