In input files, music is represent by so-called music expression. We have already seen in the previous examples; a single note is a music expression
a4
Enclosing group of notes in braces creates a new music expression
{ a4 g4 }
Putting a bunch of music expressions (notes) in braces, means that they should be played in sequence. The result again is a music expression, which can be grouped with other expressions sequentially. Here, the expression from the previous example is combined with two notes
{ { a4 g } f g }
This technique is useful for non-monophonic music. To enter music
with more voices or more staves, we also combine expressions in
parallel. Two voices that should play at the same time, are entered
as a simultaneous combination of two sequences. A “simultaneous”
music expression is formed by enclosing expressions in <<
and
>>
. In the following example, three sequences (all containing
two notes) are combined simultaneously
<< { a4 g } { f e } { d b } >>
This mechanism is similar to mathematical formulas: a big formula is created by composing small formulas. Such formulas are called expressions, and their definition is recursive, so you can make arbitrarily complex and large expressions. For example,
1 1 + 2 (1 + 2) * 3 ((1 + 2) * 3) / (4 * 5)
This example shows a sequence of expressions, where each expression is contained in the next one. The simplest expressions are numbers and operators (like +, * and /). Parentheses are used to group expressions.
Like mathematical expressions, music expressions can be nested arbitrarily deep, e.g.
{ c <<c e>> << { e f } { c <<b d>> } >> }
When spreading expressions over multiple lines, it is customary to use an indent that indicates the nesting level. Formatting music like this eases reading, and helps you insert the right number of closing braces at the end of an expression. For example,
\score { \notes << { ... } { ... } >> }
Some editors have special support for entering LilyPond, and can help indenting source files. See Editor support for more information.
Read comments on this page, or
add one.
This page is for LilyPond-2.2.6 (stable-branch). |