Next: After the tutorial, Previous: Absolute note names, Up: Final touches
When all of the elements discussed earlier are combined to produce larger files, the music expressions get a lot bigger. In polyphonic music with many staves, the input files can become very confusing. We can reduce this confusion by using identifiers.
With identifiers (also known as variables or macros), we can break up complex music expressions. An identifier is assigned as follows
namedMusic = { ... }
The contents of the music expression namedMusic
can be used
later by placing a backslash in front of the name
(\namedMusic
, just like a normal LilyPond command). Identifiers
must be defined before the main music expression.
violin = \new Staff { \relative c'' { a4 b c b }} cello = \new Staff { \relative c { \clef bass e2 d }} { << \violin \cello >> }
The name of an identifier must have alphabetic characters only: no numbers, underscores, or dashes.
It is possible to use variables for many other types of objects in the input. For example,
width = 4.5\cm name = "Wendy" aFivePaper = \paper { paperheight = 21.0 \cm }
Depending on its contents, the identifier can be used in different places. The following example uses the above variables:
\paper { \aFivePaper line-width = \width } { c4^\name }
Next: After the tutorial, Previous: Absolute note names, Up: Final touches
This page is for LilyPond-2.10.33 (stable-branch).
Other languages: French.