[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.2 Multiple notes at once

This section introduces having more than one note at the same time: multiple instruments, multiple staves for a single instrument (i.e. piano), and chords.

Polyphony in music refers to having more than one voice occurring in a piece of music. Polyphony in LilyPond refers to having more than one voice on the same staff.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.2.1 Music expressions explained

In LilyPond input files, music is represented by music expressions. A single note is a music expression:

 
a'4

[image of music]

Enclosing a note in braces creates a compound music expression. Here we have created a compound music expression with two notes:

 
\relative { a'4 g4 }

[image of music]

Putting a group of music expressions (e.g. notes) in braces means that they are in sequence (i.e. each one follows the previous one). The result is another music expression:

 
\relative { { a'4 g } f4 g }

[image of music]


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Analogy: mathematical expressions

This mechanism is similar to mathematical formulas: a big formula is created by composing small formulas. Such formulas are called expressions, and they can contain other expressions, so you can make arbitrarily complex and large expressions. For example,

 
1

1 + 2

(1 + 2) * 3

((1 + 2) * 3) / (4 * 5)

This is a sequence of expressions, where each expression is contained in the next (larger) one. The simplest expressions are numbers, and larger ones are made by combining expressions with operators (like +, * and /) and parentheses. Like mathematical expressions, music expressions can be nested arbitrarily deep, which is necessary for complex music like polyphonic scores.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Simultaneous music expressions: multiple staves

Music Glossary: (music-glossary)polyphony section ‘polyphony’ in Music Glossary.

This technique is useful for polyphonic music. To enter music with more voices or more staves, we combine expressions in parallel. To indicate that two voices should play at the same time, simply enter a simultaneous combination of music expressions. A ‘simultaneous’ music expression is formed by enclosing expressions inside << and >>. In the following example, three sequences (all containing two separate notes) are combined simultaneously:

 
<<
  \relative { a'2 g }
  \relative { f'2 e }
  \relative { d'2 b }
>>

[image of music]

Note that we have indented each level of the input with a different amount of space. LilyPond does not care how much (or little) space there is at the beginning of a line, but indenting LilyPond code like this makes it much easier for humans to read.

Note: each note is relative to the previous note in the input, only the first is relative to the c'' in the initial \relative command.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Simultaneous music expressions: single staff

To determine the number of staves in a piece, LilyPond looks at the beginning of the first expression. If there is a single note, there is one staff; if there is a simultaneous expression, there is more than one staff. The following example shows a complex expression, but as it begins with a single note it will be set out on a single staff.

 
\relative {
  c''2 <<c e>> |
  << { e2 f } { c2 <<b d>> } >> |
}

[image of music]


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.2.2 Multiple staves

LilyPond input files are constructed out of music expressions, as we saw in Music expressions explained. If the score begins with simultaneous music expressions, LilyPond creates multiples staves. However, it is easier to see what happens if we create each staff explicitly.

To print more than one staff, each piece of music that makes up a staff is marked by adding \new Staff before it. These Staff elements are then combined in parallel with << and >>:

 
<<
  \new Staff { \clef "treble" c''4 }
  \new Staff { \clef "bass" c4 }
>>

[image of music]

The command \new introduces a ‘notation context.’ A notation context is an environment in which musical events (like notes or \clef commands) are interpreted. For simple pieces, such notation contexts are created automatically. For more complex pieces, it is best to mark contexts explicitly.

There are several types of contexts. Score, Staff, and Voice handle melodic notation, while Lyrics sets lyric texts and ChordNames prints chord names.

In terms of syntax, prepending \new to a music expression creates a bigger music expression. In this way it resembles the minus sign in mathematics. The formula (4+5) is an expression, so -(4+5) is a bigger expression.

Time signatures entered in one staff affect all other staves by default. On the other hand, the key signature of one staff does not affect other staves. This different default behavior is because scores with transposing instruments are more common than polyrhythmic scores.

 
<<
  \new Staff { \clef "treble" \key d \major \time 3/4 c''4 }
  \new Staff { \clef "bass" c4 }
>>

[image of music]


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.2.3 Staff groups

Music Glossary: (music-glossary)brace section ‘brace’ in Music Glossary, (music-glossary)staff section ‘staff’ in Music Glossary, (music-glossary)system section ‘system’ in Music Glossary.

Piano music is typeset in two staves connected by a brace. Printing such a staff is similar to the polyphonic example in Multiple staves. However, now this entire expression is inserted inside a PianoStaff:

 
\new PianoStaff <<
  \new Staff …
  \new Staff …
>>

Here is a small example:

 
\new PianoStaff <<
  \new Staff \relative { \time 2/4 c''4 e | g g, | }
  \new Staff \relative { \clef "bass" c4 c' | e c | }
>>

[image of music]

Other staff groupings are introduced with \new GrandStaff, suitable for orchestral scores, and \new ChoirStaff, suitable for vocal scores. These staff groups each form another type of context, one that generates the brace at the left end of every system and also controls the extent of bar lines.

See also

Notation Reference: (notation)Keyboard and other multi-staff instruments section ‘Keyboard and other multi-staff instruments’ in Notation Reference, (notation)Displaying staves section ‘Displaying staves’ in Notation Reference.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.2.4 Combining notes into chords

Music Glossary: (music-glossary)chord section ‘chord’ in Music Glossary

We saw earlier how notes can be combined into chords by indicating they are simultaneous by enclosing them in double angle brackets. However, the normal way of indicating a chord is to surround the pitches with single angle brackets. Note that all the notes in a chord must have the same duration, and that the duration is placed after the closing bracket.

 
\relative { r4 <c'' e g> <c f a>2 }

[image of music]

Think of chords as almost equivalent to single notes: almost everything you can attach to a single note can be attached to a chord, and everything must go outside the angle brackets. For example, you can combine markings like beams and ties with chords. They must be placed outside the angle brackets.

 
\relative {
  r4 <c'' e g>~ <c f a>2 |
  <c e g>8[ <c f a> <c e g> <c f a>]
    <c e g>8\>[ <c f a> <c f a> <c e g>]\! |
  r4 <c e g>8.\p <c f a>16( <c e g>4-. <c f a>) |
}

[image of music]

See also

Notation Reference: (notation)Chorded notes section ‘Chorded notes’ in Notation Reference.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.2.5 Single staff polyphony

Polyphonic music in lilypond, while not difficult, uses concepts that we haven’t discussed yet, so we’re not going to introduce them here. Instead, the following sections introduce these concepts and explain them thoroughly.

See also

Learning Manual: Voices contain music.

Notation Reference: (notation)Simultaneous notes section ‘Simultaneous notes’ in Notation Reference.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by gub on July 13, 2020 using texi2html 1.82.

其他语言:català, česky, deutsch, español, français, magyar, italiano, 日本語, nederlands。
关于 自动语言选择