Next: , Up: Different editions from one source


Using variables

If sections of the music are defined in variables they can be reused in different parts of the score, see pieces with variables Organizing pieces with variables. For example, an a cappella vocal score frequently includes a piano reduction of the parts for rehearsal purposes which is identical to the vocal music, so the music need be entered only once. Music from two variables may be combined on one staff, see Automatic part combining. Here is an example:

     
     sopranoMusic = \relative c'' { a4 b c b8( a)}
     altoMusic = \relative g' { e4 e e f }
     tenorMusic = \relative c' { c4 b e d8( c) }
     bassMusic = \relative c' { a4 gis a d, }
     allLyrics = \lyricmode {King of glo -- ry }
     <<
       \new Staff = "Soprano" \sopranoMusic
       \new Lyrics \allLyrics
       \new Staff = "Alto" \altoMusic
       \new Lyrics \allLyrics
       \new Staff = "Tenor" {
         \clef "treble_8"
         \tenorMusic
       }
       \new Lyrics \allLyrics
       \new Staff = "Bass" {
         \clef "bass"
         \bassMusic
       }
       \new Lyrics \allLyrics
       \new PianoStaff <<
         \new Staff = "RH" {
           \set Staff.printPartCombineTexts = ##f
           \partcombine
           \sopranoMusic
           \altoMusic
         }
         \new Staff = "LH" {
           \set Staff.printPartCombineTexts = ##f
           \clef "bass"
           \partcombine
           \tenorMusic
           \bassMusic
         }
       >>
     >>

[image of music]

Separate scores showing just the vocal parts or just the piano part can be produced by changing just the structural statements, leaving the musical notation unchanged.

For lengthy scores, the variable definitions may be placed in separate files which are then included, see Including LilyPond files.

Esta página corresponde a LilyPond-2.11.58 (rama de desarrollo).

Informe de los fallos a través de la lista en español lilypond-es, o en inglés a través de http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.

Se agradecen las sugerencias para la documentación.