1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond-learning.tely
4 Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
6 When revising a translation, copy the HEAD committish of the
7 version that you are working on. See TRANSLATION for details.
12 @node Fundamental concepts
13 @chapter Fundamental concepts
15 You've seen in the Tutorial how to produce beautifully printed
16 music from a simple text file. This section introduces the
17 concepts and techniques required to produce equally beautiful
18 but more complex scores.
21 * How LilyPond input files work::
22 * Voices contain music::
23 * Contexts and engravers::
24 * Extending the templates::
28 @node How LilyPond input files work
29 @section How LilyPond input files work
31 The LilyPond input format is quite free-form, giving experienced
32 users a lot of flexibility to structure their files however they
33 wish. But this flexibility can make things confusing for new
34 users. This section will explain some of this structure, but may
35 gloss over some details in favor of simplicity. For a complete
36 description of the input format, see @ruser{File structure}.
39 * Introduction to the LilyPond file structure::
40 * Score is a (single) compound musical expression::
41 * Nesting music expressions::
42 * On the un-nestedness of brackets and ties::
45 @node Introduction to the LilyPond file structure
46 @subsection Introduction to the LilyPond file structure
49 @cindex file structure
51 A basic example of a LilyPond input file is
54 \version @w{"@version{}"}
57 @var{...compound music expression...} % all the music goes here!
64 There are many variations of this basic pattern, but this
65 example serves as a useful starting place.
72 Up to this point none of the examples you have seen has used a
73 @code{\score@{@}} command. This is because LilyPond automatically
74 adds the extra commands which are needed when you give it simple
75 input. LilyPond treats input like this:
84 as shorthand for this:
101 In other words, if the input contains a single music expression,
102 LilyPond will interpret the file as though the music expression
103 was wrapped up inside the commands shown above.
105 @cindex implicit contexts
107 @strong{A word of warning!} Many of the examples in the LilyPond
108 documentation will omit the @code{\new Staff} and @code{\new Voice}
109 commands, leaving them to be created implicitly. For simple
110 examples this works well, but for more complex examples, especially
111 when additional commands are used, the implicit creation of contexts
112 can give surprising results, maybe creating extra unwanted staves.
113 The way to create contexts explicitly is explained in
114 @ref{Contexts and engravers}.
116 @warning{When entering more than a few lines of music it is
117 advisable to always create staves and voices explicitly.}
119 For now, though, let us return to the first example and examine the
120 @code{\score} command, leaving the others to default.
122 A @code{\score} block must always contain just one music expression,
123 and this must appear immediately after the @code{\score} command.
124 Remember that a music expression could be anything from a single
125 note to a huge compound expression like
130 @var{...insert the whole score of a Wagner opera in here...}
136 Since everything is inside @code{@{ ... @}}, it counts
137 as one music expression.
139 As we saw previously, the @code{\score} block can contain other
159 Note that these three commands -- @code{\header}, @code{\layout} and
160 @code{\midi} -- are special: unlike many other commands which begin
161 with a backward slash (@code{\}) they are @emph{not} music expressions
162 and are not part of any music expression. So they may be placed
163 inside a @code{\score} block or outside it. In fact, these commands
164 are commonly placed outside the @code{\score} block -- for example,
165 @code{\header} is often placed above the @code{\score} command, as the
166 example at the beginning of this section shows.
168 Two more commands you have not previously seen are
169 @code{\layout @{ @}} and @code{\midi @{@}}. If these appear as
170 shown they will cause LilyPond to produce a printed output and a
171 MIDI output respectively. They are described fully in the
172 Notation Reference -- @ruser{Score layout}, and
173 @ruser{Creating MIDI files}.
175 @cindex scores, multiple
177 You may code multiple @code{\score} blocks. Each will be
178 treated as a separate score, but they will be all combined into
179 a single output file. A @code{\book} command is not necessary
180 -- one will be implicitly created. However, if you would like
181 separate output files from one @code{.ly} file then the
182 @code{\book} command should be used to separate the different
183 sections: each @code{\book} block will produce a
184 separate output file.
188 Every @code{\book} block creates a separate output file (e.g., a
189 PDF file). If you haven't explicitly added one, LilyPond wraps
190 your entire input code in a @code{\book} block implicitly.
192 Every @code{\score} block is a separate chunk of music within a
195 Every @code{\layout} block affects the @code{\score} or
196 @code{\book} block in which it appears -- i.e., a @code{\layout}
197 block inside a @code{\score} block affects only that @code{\score}
198 block, but a @code{\layout} block outside of a @code{\score} block
199 (and thus in a @code{\book} block, either explicitly or
200 implicitly) will affect every @code{\score} in that @code{\book}.
202 For details see @ruser{Multiple scores in a book}.
206 Another great shorthand is the ability to define variables. All
207 the templates use this
210 melody = \relative c' @{
219 When LilyPond looks at this file, it takes the value of
220 @code{melody} (everything after the equals sign) and inserts it
221 whenever it sees @code{\melody}. There's nothing special about
222 the names -- it could be @code{melody}, @code{global},
224 @code{pianorighthand}, or @code{foofoobarbaz}. For more details,
225 see @ref{Saving typing with variables and functions}.
226 Remember that you can use almost any name you like as long
227 as it contains just alphabetic characters and is distinct from
228 LilyPond command names. The exact
229 limitations on variable names are detailed in
230 @ruser{File structure}.
236 For a complete definition of the input format, see
237 @ruser{File structure}.
239 @node Score is a (single) compound musical expression
240 @subsection Score is a (single) compound musical expression
244 @cindex Compound music expression
245 @cindex Music expression, compound
247 We saw the general organization of LilyPond input files in the
248 previous section, @ref{Introduction to the LilyPond file structure}.
249 But we seemed to skip over the most important part: how do we figure
250 out what to write after @code{\score}?
252 We didn't skip over it at all. The big mystery is simply that
253 there @emph{is} no mystery. This line explains it all:
256 @emph{A @code{\score} block must begin with a compound music expression.}
260 To understand what is meant by a music expression and a compound
261 music expression, you may find it useful to review the tutorial,
262 @ref{Music expressions explained}. In that section, we saw how to
263 build big music expressions from small pieces -- we started from
264 notes, then chords, etc. Now we're going to start from a big
265 music expression and work our way down.
269 @{ % this brace begins the overall compound music expression
271 @var{...insert the whole score of a Wagner opera in here...}
273 @} % this brace ends the overall compound music expression
278 A whole Wagner opera would easily double the length of this
279 manual, so let's just add a singer and piano. We don't need a
280 @code{GrandStaff} for this ensemble, which simply groups a number
281 of staves together with a brace at the left, so we shall remove
282 it. We @emph{do} need a singer and a piano, though.
287 \new Staff = "singer" <<
289 \new PianoStaff = piano <<
296 Remember that we use @code{<< ... >>} instead of @code{@{ ... @}} to
297 show simultaneous music. And we definitely want to show the vocal
298 part and piano part at the same time, not one after the other! Note
299 that the @code{<< ... >>} construct is not really necessary for the
300 Singer staff, as it contains only one sequential music expression;
301 however, using @code{<< ... >>} instead of braces is still necessary
302 if the music in the Staff is made of two simultaneous expressions,
303 e.g. two simultaneous Voices, or a Voice with lyrics. We'll add some
304 real music later; for now let's just put in some dummy notes and
307 @lilypond[verbatim,quote,ragged-right]
310 \new Staff = "singer" <<
311 \new Voice = "vocal" { c'1 }
314 \new PianoStaff = "piano" <<
315 \new Staff = "upper" { c'1 }
316 \new Staff = "lower" { c'1 }
323 Now we have a lot more details. We have the singer's staff: it
324 contains a @code{Voice} (in LilyPond, this term refers to a set of
325 notes, not necessarily vocal notes -- for example, a violin
326 generally plays one voice) and some lyrics. We also have a piano
327 staff: it contains an upper staff (right hand) and a lower staff
330 At this stage, we could start filling in notes. Inside the curly
331 braces next to @code{\new Voice = vocal}, we could start writing
339 But if we did that, the @code{\score} section would get pretty
340 long, and it would be harder to understand what was happening. So
341 let's use variables instead. These were introduced at the end
342 of the previous section, remember? So, adding a few notes, we
343 now have a piece of real music:
345 @lilypond[verbatim,quote,ragged-right]
346 melody = \relative c'' { r4 d8\noBeam g, c4 r }
347 text = \lyricmode { And God said, }
348 upper = \relative c'' { <g d g,>2~ <g d g,> }
349 lower = \relative c { b2 e2 }
353 \new Staff = "singer" <<
354 \new Voice = "vocal" { \melody }
357 \new PianoStaff = "piano" <<
358 \new Staff = "upper" { \upper }
359 \new Staff = "lower" {
370 Be careful about the difference between notes, which are introduced
371 with @code{\relative} or which are directly included in a music
372 expression, and lyrics, which are introduced with
373 @code{\lyricmode}. These are essential to tell LilyPond
374 to interpret the following content as music and text
377 When writing (or reading) a @code{\score} section, just take it
378 slowly and carefully. Start with the outer level, then work on
379 each smaller level. It also really helps to be strict with
380 indentation -- make sure that each item on the same level starts
381 on the same horizontal position in your text editor.
385 Notation Reference: @ruser{Structure of a score}.
387 @node Nesting music expressions
388 @subsection Nesting music expressions
390 @cindex staves, temporary
393 It is not essential to declare all staves at the beginning; they may
394 be introduced temporarily at any point. This is particularly useful
395 for creating ossia sections -- see @rglos{ossia}. Here is a simple
396 example showing how to introduce a new staff temporarily for the
397 duration of three notes:
399 @lilypond[verbatim,quote,ragged-right]
416 Note that the size of the clef is the same as a clef printed
417 following a clef change -- slightly smaller than the clef
418 at the beginning of the line. This is usual for clefs printed
419 in the middle of a line.
421 @cindex staff, positioning
423 The ossia section may be placed above the staff
426 @lilypond[verbatim,quote,ragged-right]
434 alignAboveContext = "main" }
442 This example uses @code{\with}, which will be explained more
443 fully later. It is a means of modifying the default behavior
444 of a single Staff. Here it says that the new staff should be
445 placed above the staff called @qq{main} instead of the default
446 position which is below.
450 Ossia are often written without clef and without
451 time signature and are usually in a smaller font.
452 These require further commands which
453 have not yet been introduced. See @ref{Size of objects},
454 and @ruser{Ossia staves}.
457 @node On the un-nestedness of brackets and ties
458 @subsection On the un-nestedness of brackets and ties
460 @cindex brackets, nesting
462 You have already met a number of different types of bracket in
463 writing the input file to LilyPond. These obey different rules
464 which can be confusing at first. Before we explain the rules
465 let's first review the different types of bracket.
467 @c attempt to force this onto a new page
469 @multitable @columnfractions .3 .7
470 @headitem Bracket Type
472 @item @code{@{ .. @}}
473 @tab Encloses a sequential segment of music
475 @tab Encloses the notes of a chord
476 @item @code{<< .. >>}
477 @tab Encloses simultaneous music expressions
479 @tab Marks the start and end of a slur
480 @item @code{\( .. \)}
481 @tab Marks the start and end of a phrasing slur
483 @tab Marks the start and end of a manual beam
486 To these we should add other constructs which generate lines
487 between or across notes: ties (marked by a tilde, @code{~}),
488 tuplets written as @code{\times x/y @{..@}}, and grace notes
489 written as @code{\grace@{..@}}.
491 Outside LilyPond, the conventional use of brackets requires
492 the different types to be properly nested, like this,
493 @code{<< [ @{ ( .. ) @} ] >>}, with the closing brackets being
494 encountered in exactly the opposite order to the opening
495 brackets. This @strong{is} a requirement for the three types of
496 bracket described by the word @q{Encloses} in the table above --
497 they must nest properly.
498 However, the remaining brackets, described with the word
499 @q{Marks} in the table above together with ties and tuplets,
500 do @strong{not} have to nest
501 properly with any of the brackets. In fact, these are not
502 brackets in the sense that
503 they enclose something -- they are simply markers to indicate
504 where something starts and ends.
506 So, for example, a phrasing slur can start before a manually
507 inserted beam and end before the end of the beam -- not very
508 musical, perhaps, but possible:
510 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
511 { g8\( a b[ c b\) a] }
514 In general, different kinds of brackets, and those implied by
515 tuplets, ties and grace notes, may be mixed freely.
516 This example shows a beam extending into a tuplet (line 1),
517 a slur extending into a tuplet (line 2),
518 a beam and a slur extending into a tuplet, a tie crossing
519 two tuplets, and a phrasing slur extending out of a tuplet
522 @lilypond[quote,verbatim,fragment,ragged-right]
524 r16[ g16 \times 2/3 {r16 e'8] }
525 g16( a \times 2/3 {b d) e' }
526 g8[( a \times 2/3 {b d') e'~]}
527 \times 4/5 {e'32\( a b d' e'} a'4.\)
532 @node Voices contain music
533 @section Voices contain music
535 Singers need voices to sing, and so does LilyPond.
536 The actual music for all instruments in a score
537 is contained in Voices -- the most fundamental
538 of all LilyPond's concepts.
541 * I'm hearing Voices::
542 * Explicitly instantiating voices::
543 * Voices and vocals::
546 @node I'm hearing Voices
547 @subsection I'm hearing Voices
551 @cindex multiple voices
552 @cindex Voice context
553 @cindex context, Voice
554 @cindex simultaneous music
555 @cindex concurrent music
557 The lowest, most fundamental or innermost layers in a LilyPond
558 score are called @q{Voice contexts} or just @q{Voices} for short.
559 Voices are sometimes called @q{layers} in other notation
562 In fact, a Voice layer or context is the only one which can
563 contain music. If a Voice context is not explicitly declared
564 one is created automatically, as we saw at the beginning of
565 this chapter. Some instruments such as an
566 Oboe can play only one note at a time. Music written for
567 such instruments is monophonic and requires just a single
568 voice. Instruments which can play more than one note at a
569 time like the piano will often require multiple voices to
570 encode the different concurrent notes and rhythms they are
573 A single voice can contain many notes in a chord, of course,
574 so when exactly are multiple voices needed? Look first at
575 this example of four chords:
577 @lilypond[quote,verbatim,fragment,ragged-right,relative=1]
579 <d g>4 <d fis> <d a'> <d g>
582 This can be expressed using just the single angle bracket chord
583 symbols, @code{< ... >}, and for this just a single voice is
584 needed. But suppose the F-sharp were actually an eighth-note
585 followed by an eighth-note G, a passing note on the way to the A?
586 Now we have two notes which start at the same time but have
587 different durations: the quarter-note D and the eighth-note
588 F-sharp. How are these to be coded? They cannot be written as
589 a chord because all the notes in a chord must have the same
590 duration. And they cannot be written as two sequential notes
591 as they need to start at the same time. This is when two
594 Let us see how this is done in LilyPond input syntax.
599 The easiest way to enter fragments with more than one voice on a
600 staff is to enter each voice as a sequence (with @code{@{...@}}),
601 and combine them simultaneously with angle brackets, @code{<<...>>}.
602 The fragments must also be separated with double backward slashes,
603 @code{\\}, to place them in separate voices. Without these, the
604 notes would be entered into a single voice, which would usually
605 cause errors. This technique is particularly suited to pieces of
606 music which are largely monophonic with occasional short sections
609 Here's how we split the chords above into two voices and add both
610 the passing note and a slur:
612 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
614 % Voice "1" Voice "2"
615 << { g4 fis8( g) a4 g } \\ { d4 d d d } >> |
618 Notice how the stems of the second voice now point down.
620 Here's another simple example:
622 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
624 % Voice "1" Voice "2"
625 << { r4 g g4. a8 } \\ { d,2 d4 g } >> |
626 << { bes4 bes c bes } \\ { g4 g g8( a) g4 } >> |
627 << { a2. r4 } \\ { fis2. s4 } >> |
630 It is not necessary to use a separate @code{<< \\ >>} construct
631 for each bar. For music with few notes in each bar this layout
632 can help the legibility of the code, but if there are many
633 notes in each bar it may be better to split out each voice
634 separately, like this:
636 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
652 This example has just two voices, but the same construct may be
653 used to encode three or more voices by adding more back-slash
656 The Voice contexts bear the names @code{"1"}, @code{"2"}, etc.
657 In each of these contexts, the vertical direction of slurs,
658 stems, ties, dynamics etc., is set appropriately.
660 @lilypond[quote,verbatim,fragment]
661 \new Staff \relative c' {
664 % Voice "1" Voice "2" Voice "3"
665 << { g4 f e } \\ { r8 e4 d c8 ~ } >> |
666 << { d2 e2 } \\ { c8 b16 a b8 g ~ g2 } \\ { s4 b4 c2 } >> |
670 These voices are all separate from the main voice that contains
671 the notes just outside the @code{<< .. >>} construct. Let's call
672 this the @emph{simultaneous construct}. Slurs and ties may only
673 connect notes within the same voice, so slurs and ties cannot go
674 into or out of a simultaneous construct. Conversely,
675 parallel voices from separate simultaneous constructs on the same
676 staff are the same voice. Other voice-related properties also
677 carry across simultaneous constructs. Here is the same example,
678 with different colors and note heads for each voice. Note that
679 changes in one voice do not affect other voices, but they do
680 persist in the same voice later. Note also that tied notes may be
681 split across the same voices in two constructs, shown here in the
684 @lilypond[quote,verbatim]
685 \new Staff \relative c' {
704 { c8 b16 a b8 g ~ g2 }
714 @funindex \voiceOneStyle
715 @funindex \voiceTwoStyle
716 @funindex \voiceThreeStyle
717 @funindex \voiceFourStyle
718 @funindex \voiceNeutralStyle
720 The commands @code{\voiceXXXStyle} are mainly intended for use in
721 educational documents such as this one. They modify the color
722 of the note head, the stem and the beams, and the style of the
723 note head, so that the voices may be easily distinguished.
724 Voice one is set to red diamonds, voice two to blue triangles,
725 voice three to green crossed circles, and voice four (not used
726 here) to magenta crosses; @code{\voiceNeutralStyle} (also not
727 used here) reverts the style back to the default.
728 We shall see later how commands like these may be created by the
730 See @ref{Visibility and color of objects} and
731 @ref{Using variables for tweaks}.
733 Polyphony does not change the relationship of notes within a
734 @code{\relative @{ @}} block. Each note is still calculated
735 relative to the note immediately preceding it, or to the first
736 note of the preceding chord. So in
739 \relative c' @{ noteA << < noteB noteC > \\ noteD >> noteE @}
743 @code{noteB} is relative to @code{noteA} @*
744 @code{noteC} is relative to @code{noteB}, not @code{noteA}; @*
745 @code{noteD} is relative to @code{noteB}, not @code{noteA} or
747 @code{noteE} is relative to @code{noteD}, not @code{noteA}.
749 An alternative way, which may be clearer if the notes in the
750 voices are widely separated, is to place a @code{\relative}
751 command at the start of each voice:
754 \relative c' @{ noteA ... @}
756 \relative c'' @{ < noteB noteC > ... @}
758 \relative g' @{ noteD ... @}
760 \relative c' @{ noteE ... @}
763 Let us finally analyze the voices in a more complex piece of
765 the notes from the first two bars of the second of Chopin's
766 Deux Nocturnes, Op 32. This example will be used at later
767 stages in this and the next chapter to illustrate several
768 techniques for producing notation, so please ignore for now
769 anything in the underlying code which looks mysterious and
770 concentrate just on the music and the voices -- the
771 complications will all be explained in later sections.
773 @c The following should appear as music without code
774 @lilypond[quote,ragged-right]
775 \new Staff \relative c'' {
784 % Ignore these for now - they are explained in Ch 4
785 \once \override NoteColumn #'force-hshift = #0
787 \once \override NoteColumn #'force-hshift = #0.5
795 The direction of the stems is often used to indicate the
796 continuity of two simultaneous melodic lines. Here the
797 stems of the highest notes are all pointing up and the
798 stems of the lower notes are all pointing down.
799 This is the first indication that more than one voice
802 But the real need for multiple voices arises when notes
803 which start at the same time have different durations.
804 Look at the notes which start at beat three in the first
805 bar. The A-flat is a dotted quarter note, the F is a
806 quarter note and the D-flat is a half note. These
807 cannot be written as a chord as all the notes in a chord
808 must have the same duration. Neither can they be written
809 as sequential notes, as they must start at the same time.
810 This section of the bar requires three voices, and the
811 normal practice would be to write the whole bar as three
812 voices, as shown below, where we have used different note heads
813 and colors for the three voices. Again, the code behind this
814 example will be explained later, so ignore anything you do
817 @c The following should appear as music without code
818 @c The three voice styles should be defined in -init
819 @lilypond[quote,ragged-right]
820 \new Staff \relative c'' {
831 \\ % No Voice three (we want stems down)
834 % Ignore these for now - they are explained in Ch 4
835 \once \override NoteColumn #'force-hshift = #0
837 \once \override NoteColumn #'force-hshift = #0.5
846 Let us try to encode this music from scratch. As we
847 shall see, this encounters some difficulties. We begin as
848 we have learnt, using the @code{<< \\ >>} construct to
849 enter the music of the first bar in three voices:
851 @lilypond[quote,verbatim,fragment,ragged-right]
852 \new Staff \relative c'' {
855 { c2 aes4. bes8 } \\ { aes2 f4 fes } \\ { <ees c>2 des2 }
864 The stem directions are automatically assigned with the
865 odd-numbered voices taking upward stems and the even-numbered
866 voices downward ones. The stems for voices 1 and 2 are right,
867 but the stems in voice 3 should go down in this particular piece
868 of music. We can correct this simply by missing out voice three
869 and placing the music in voice four:
871 @lilypond[quote,verbatim,fragment,ragged-right]
872 \new Staff \relative c'' {
878 \\ % Omit Voice three
887 We see that this fixes the stem direction, but exposes a problem
888 sometimes encountered with multiple voices -- the stems of the notes
889 in one voice can collide with the note heads in other voices. In
890 laying out the notes, LilyPond allows the notes or chords from two
891 voices to occupy the same vertical note column provided the stems are
892 in opposite directions, but the notes from the third and fourth voices
893 are displaced, if necessary, to avoid the note heads colliding. This
894 usually works well, but in this example the notes of the lowest voice
895 are clearly not well placed by default. LilyPond provides several ways
896 to adjust the horizontal placing of notes. We are not quite ready yet
897 to see how to correct this, so we shall leave this problem until a
898 later section --- see the @code{force-hshift} property in @ref{Fixing
899 overlapping notation}.
903 Notation Reference: @ruser{Multiple voices}.
906 @node Explicitly instantiating voices
907 @subsection Explicitly instantiating voices
911 @funindex \voiceThree
915 @cindex Voice contexts, creating
917 Voice contexts can also be created manually
918 inside a @code{<< >>} block to create polyphonic music, using
919 @code{\voiceOne} ... @code{\voiceFour} to indicate the required
920 directions of stems, slurs, etc. In longer scores this method
921 is clearer, as it permits the voices to be separated and to be
922 given more descriptive names.
924 Specifically, the construct @code{<< \\ >>} which we used in
925 the previous section:
930 << @{ e4 f g a @} \\ @{ c,4 d e f @} >>
940 \new Voice = "1" @{ \voiceOne \relative c' @{ e4 f g a @} @}
941 \new Voice = "2" @{ \voiceTwo \relative c' @{ c4 d e f @} @}
945 Both of the above would produce
947 @c The following example should not display the code
948 @lilypond[ragged-right,quote]
950 \new Voice = "1" { \voiceOne \relative c' { e4 f g a } }
951 \new Voice = "2" { \voiceTwo \relative c' { c4 d e f } }
955 The @code{\voiceXXX} commands set the direction of stems, slurs,
956 ties, articulations, text annotations, augmentation dots of dotted
957 notes, and fingerings. @code{\voiceOne} and @code{\voiceThree}
958 make these objects point upwards, while @code{\voiceTwo} and
959 @code{\voiceFour} make them point downwards. These commands also
960 generate a horizontal shift for each voice when this is required
961 to avoid clashes of note heads. The command @code{\oneVoice}
962 reverts the settings back to the normal values for a single voice.
964 Let us see in some simple examples exactly what effect
965 @code{\oneVoice}, @code{\voiceOne} and @code{voiceTwo} have on
966 markup, ties, slurs, and dynamics:
968 @lilypond[quote,ragged-right,verbatim]
970 % Default behavior or behavior after \oneVoice
971 c d8 ~ d e4 ( f g a ) b-> c
975 @lilypond[quote,ragged-right,verbatim]
978 c d8 ~ d e4 ( f g a ) b-> c
980 c, d8 ~ d e4 ( f g a ) b-> c
984 @lilypond[quote,ragged-right,verbatim]
987 c d8 ~ d e4 ( f g a ) b-> c
989 c, d8 ~ d e4 ( f g a ) b-> c
993 Now let's look at three different ways to notate the same passage
994 of polyphonic music, each of which is advantageous in different
995 circumstances, using the example from the previous section.
997 An expression that appears directly inside a @code{<< >>} belongs
998 to the main voice (but, note, @strong{not} in a @code{<< \\ >>}
999 construct). This is useful when extra voices appear while the
1000 main voice is playing. Here is a more correct rendition of our
1001 example. The red diamond-shaped notes
1002 demonstrate that the main melody is now in a single voice context,
1003 permitting a phrasing slur to be drawn over them.
1005 @lilypond[quote,ragged-right,verbatim]
1006 \new Staff \relative c' {
1008 % The following notes are monophonic
1010 % Start simultaneous section of three voices
1012 % Continue the main voice in parallel
1014 % Initiate second voice
1016 % Set stems, etc, down
1018 r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2
1020 % Initiate third voice
1022 % Set stems, etc, up
1030 @cindex nesting music expressions
1031 @cindex nesting simultaneous constructs
1033 @cindex voices, temporary
1034 @cindex voices, nesting
1036 More deeply nested polyphony constructs are possible, and if a
1037 voice appears only briefly this might be a more natural way to
1040 @lilypond[quote,ragged-right,verbatim]
1041 \new Staff \relative c' {
1049 {c8 b16 a b8 g ~ g2}
1060 @cindex spacing notes
1062 This method of nesting new voices briefly is useful
1063 when only small sections of the music
1064 are polyphonic, but when the whole staff is largely polyphonic
1065 it can be clearer to use multiple voices throughout, using
1066 spacing notes to step over sections where the voice is silent,
1069 @lilypond[quote,ragged-right,verbatim]
1070 \new Staff \relative c' <<
1071 % Initiate first voice
1074 c16^( d e f g4 f e | d2 e2) |
1076 % Initiate second voice
1078 % Set stems, etc, down
1080 s4 r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2 |
1082 % Initiate third voice
1084 % Set stems, etc, up
1091 @subsubheading Note columns
1094 @cindex shift commands
1098 @funindex \shiftOnnn
1100 Closely spaced notes in a chord, or notes occurring at the same
1101 time in different voices, are arranged in two, occasionally more,
1102 columns to prevent the note heads overlapping. These are called
1103 note columns. There are separate columns for each voice, and
1104 the currently specified voice-dependent shift is applied to the
1105 note column if there would otherwise be a collision. This can
1106 be seen in the example above. In bar 2 the C in voice two is
1107 shifted to the right relative to the D in voice one, and in the
1108 final chord the C in voice three is also shifted to the right
1109 relative to the other notes.
1111 The @code{\shiftOn}, @code{\shiftOnn}, @code{\shiftOnnn}, and
1112 @code{\shiftOff} commands specify the degree to which notes and
1113 chords of the voice should be shifted if a collision
1114 would otherwise occur. By default, the outer voices (normally
1115 voices one and two) have @code{\shiftOff} specified, while the
1116 inner voices (three and four) have @code{\shiftOn} specified.
1117 When a shift is applied, Voices one and three are shifted to
1118 the right and voices two and four to the left.
1120 @code{\shiftOnn} and @code{\shiftOnnn} define further shift
1121 levels which may be specified temporarily to resolve collisions
1122 in complex situations -- see @ref{Real music example}.
1124 A note column can contain just one note (or chord) from a voice
1125 with stems up and one note (or chord) from a voice with stems
1126 down. If notes from two voices which have their stems in the
1127 same direction are placed at the same position and both voices
1128 have no shift or the same shift specified, the error message
1129 @qq{Too many clashing note columns} will be produced.
1133 Notation Reference: @ruser{Multiple voices}.
1136 @node Voices and vocals
1137 @subsection Voices and vocals
1139 Vocal music presents a special difficulty: we need to combine two
1140 expressions -- notes and lyrics.
1142 @funindex \new Lyrics
1144 @cindex Lyrics context, creating
1145 @cindex lyrics, linking to voice
1147 You have already seen the @code{\addlyrics@{@}} command, which
1148 handles simple scores well. However, this technique is
1149 quite limited. For more complex music, you must introduce the
1150 lyrics in a @code{Lyrics} context using @code{\new Lyrics} and
1152 the lyrics to the notes with @code{\lyricsto@{@}}, using the
1153 name assigned to the Voice.
1155 @lilypond[quote,verbatim,fragment]
1157 \new Voice = "one" \relative c'' {
1160 c4 b8. a16 g4. f8 e4 d c2
1162 \new Lyrics \lyricsto "one" {
1163 No more let sins and sor -- rows grow.
1168 Note that the lyrics must be linked to a @code{Voice} context,
1169 @emph{not} a @code{Staff} context. This is a case where it is
1170 necessary to create @code{Staff} and @code{Voice} contexts
1173 @cindex lyrics and beaming
1174 @cindex beaming and lyrics
1175 @funindex \autoBeamOff
1177 The automatic beaming which LilyPond uses by default works well
1178 for instrumental music, but not so well for music with lyrics,
1179 where beaming is either not required at all or is used to indicate
1180 melismata in the lyrics. In the example above we use the command
1181 @code{\autoBeamOff} to turn off the automatic beaming.
1183 @funindex \new ChoirStaff
1184 @funindex \lyricmode
1185 @cindex vocal score structure
1187 Let us reuse the earlier example from Judas Maccabæus to
1188 illustrate this more flexible technique. We first recast
1189 it to use variables so the music and lyrics can be separated
1190 from the staff structure. We also introduce a ChoirStaff
1191 bracket. The lyrics themselves must be introduced with
1192 @code{\lyricmode} to ensure they are interpreted as lyrics
1195 @lilypond[quote,verbatim]
1196 global = { \time 6/8 \partial 8 \key f \major}
1197 SopOneMusic = \relative c'' {
1198 c8 | c([ bes)] a a([ g)] f | f'4. b, | c4.~ c4 }
1199 SopTwoMusic = \relative c' {
1200 r8 | r4. r4 c8 | a'([ g)] f f([ e)] d | e([ d)] c bes' }
1201 SopOneLyrics = \lyricmode {
1202 Let | flee -- cy flocks the | hills a -- dorn, __ }
1203 SopTwoLyrics = \lyricmode {
1204 Let | flee -- cy flocks the | hills a -- dorn, }
1209 \new Voice = "SopOne" {
1213 \new Lyrics \lyricsto "SopOne" {
1218 \new Voice = "SopTwo" {
1222 \new Lyrics \lyricsto "SopTwo" {
1230 This is the basic structure of all vocal scores. More staves may
1231 be added as required, more voices may be added to the staves,
1232 more verses may be added to the lyrics,
1233 and the variables containing the music can easily be placed
1234 in separate files should they become too long.
1236 @cindex hymn structure
1238 Here is an example of the first line of a hymn with four
1239 verses, set for SATB. In this case the words for all four
1240 parts are the same. Note how we use variables to separate the
1241 music notation and words from the staff structure. See too
1242 how a variable, which we have chosen to call @q{TimeKey}, is used
1243 to hold several commands for use within the two staves. In other
1244 examples this is often called @q{global}.
1246 @lilypond[quote,verbatim]
1247 TimeKey = { \time 4/4 \partial 4 \key c \major}
1248 SopMusic = \relative c' { c4 | e4. e8 g4 g | a a g }
1249 AltoMusic = \relative c' { c4 | c4. c8 e4 e | f f e }
1250 TenorMusic = \relative c { e4 | g4. g8 c4. b8 | a8 b c d e4 }
1251 BassMusic = \relative c { c4 | c4. c8 c4 c | f8 g a b c4 }
1252 VerseOne = \lyricmode {
1253 E -- | ter -- nal fa -- ther, | strong to save, }
1254 VerseTwo = \lyricmode {
1255 O | Christ, whose voice the | wa -- ters heard, }
1256 VerseThree = \lyricmode {
1257 O | Ho -- ly Spi -- rit, | who didst brood }
1258 VerseFour = \lyricmode {
1259 O | Tri -- ni -- ty of | love and pow'r }
1265 \new Voice = "Sop" { \voiceOne \TimeKey \SopMusic }
1266 \new Voice = "Alto" { \voiceTwo \AltoMusic }
1267 \new Lyrics \lyricsto "Sop" { \VerseOne }
1268 \new Lyrics \lyricsto "Sop" { \VerseTwo }
1269 \new Lyrics \lyricsto "Sop" { \VerseThree }
1270 \new Lyrics \lyricsto "Sop" { \VerseFour }
1274 \new Voice = "Tenor" { \voiceOne \TimeKey \TenorMusic }
1275 \new Voice = "Bass" { \voiceTwo \BassMusic }
1281 @cindex verse and refrain
1283 We end with an example to show how we might code a solo verse which
1284 continues into a two-part refrain in two staves. The
1285 positioning of the sequential and simultaneous sections to achieve
1286 this within a single score is quite tricky, so follow the
1287 explanation carefully!
1289 Let's start with a score block containing a @code{ChoirStaff}, as
1290 we would like the brace to appear at the start of the chorus.
1291 Normally you would need angle brackets after @code{\new ChoirStaff}
1292 to bring in all the staves in parallel, but here we want to
1293 defer the parallelism during the solo so we use braces, although
1294 angle brackets here wouldn't hurt. Inside the @code{ChoirStaff} we
1295 want first the staff which will contain the verse. This must
1296 contain notes and lyrics in parallel, so here we need angle
1297 brackets around the @code{\new Voice} and @code{\new Lyrics} to
1298 start them at the same time:
1300 @lilypond[quote,verbatim,ragged-right]
1301 versenotes = \relative c'' {
1304 \time 3/4 g g g b b b
1306 versewords = \lyricmode {
1307 One two three four five six
1312 \new Voice = "verse" {
1315 \new Lyrics \lyricsto verse {
1323 That gives the verse line.
1325 Now we want to continue with refrainA on the same staff while a
1326 second staff is introduced in parallel with it for refrainB, so
1327 this is a parallel section which must be positioned immediately
1328 following the @code{\break} in the verse Voice. Yes, @emph{within}
1329 the verse Voice! Here's that parallel section. More staves
1330 could be introduced here in the same way.
1335 \new Lyrics \lyricsto verse @{
1339 \new Voice = "refrainB" @{
1342 \new Lyrics \lyricsto "refrainB" @{
1349 Here's the final result with two staves in the chorus showing
1350 how the parallel section is positioned within the verse Voice:
1352 @lilypond[quote,verbatim, ragged-right]
1353 versenotes = \relative c'' {
1356 \time 3/4 g g g b b b
1358 refrainnotesA = \relative c'' {
1362 refrainnotesB = \relative c {
1367 versewords = \lyricmode {
1368 One two three four five six
1370 refrainwordsA = \lyricmode {
1373 refrainwordsB = \lyricmode {
1379 \new Voice = "verse" {
1383 \new Lyrics \lyricsto "verse" {
1387 \new Voice = "refrainB" {
1390 \new Lyrics \lyricsto "refrainB" {
1396 \new Lyrics \lyricsto "verse" {
1404 @cindex book, example of using
1407 However, although this is an interesting and useful exercise to
1408 help you to understand how sequential and simultaneous blocks work,
1409 in practice one would perhaps choose to code this as two
1410 @code{\score} blocks within an implicit @code{\book} block, as
1413 @lilypond[quote,verbatim,ragged-right]
1414 versenotes = \relative c'' {
1417 \time 3/4 g g g b b b
1419 refrainnotesA = \relative c'' {
1423 refrainnotesB = \relative c {
1428 versewords = \lyricmode {
1429 One two three four five six
1431 refrainwordsA = \lyricmode {
1434 refrainwordsB = \lyricmode {
1439 \new Voice = "verse" {
1442 \new Lyrics \lyricsto "verse" {
1451 \new Voice = "refrainA" {
1454 \new Lyrics \lyricsto "refrainA" {
1459 \new Voice = "refrainB" {
1462 \new Lyrics \lyricsto "refrainB" {
1472 Notation Reference: @ruser{Vocal music}.
1475 @node Contexts and engravers
1476 @section Contexts and engravers
1478 Contexts and engravers have been mentioned informally
1479 in earlier sections; we now must look at
1480 these concepts in more detail, as they are important
1481 in the fine-tuning of LilyPond output.
1485 * Contexts explained::
1486 * Creating contexts::
1487 * Engravers explained::
1488 * Modifying context properties::
1489 * Adding and removing engravers::
1492 @node Contexts explained
1493 @subsection Contexts explained
1495 @cindex contexts explained
1497 When music is printed, many notational elements which do not
1498 appear explicitly in the input file must be added to the
1499 output. For example, compare the input and output of the
1502 @lilypond[quote,verbatim,relative=2,fragment]
1506 The input is rather sparse, but in the output, bar lines,
1507 accidentals, clef, and time signature have been added. When
1508 LilyPond @emph{interprets} the input the musical information
1509 is inspected in time order, similar to reading a score from left
1510 to right. While reading the input, the program remembers where
1511 measure boundaries are, and which pitches require explicit
1512 accidentals. This information must be held on several levels.
1513 For example, the effect of an accidental is limited
1514 to a single staff, while a bar line must be synchronized across
1517 Within LilyPond, these rules and bits of information are grouped
1518 in @emph{Contexts}. We have already met the
1519 @code{Voice} context.
1520 Others are the @code{Staff} and @code{Score} contexts.
1521 Contexts are hierarchical to reflect the hierarchical nature of
1523 For example: a @code{Staff} context can contain many
1524 @code{Voice} contexts, and a @code{Score} context can
1525 contain many @code{Staff} contexts.
1528 @sourceimage{context-example,5cm,,}
1531 Each context has the responsibility for enforcing some notation rules,
1532 creating some notation objects and maintaining the associated
1533 properties. For example, the @code{Voice} context may introduce an
1534 accidental and then the @code{Staff} context maintains the rule to
1535 show or suppress the accidental for the remainder of the measure.
1537 As another example, the synchronization of bar lines is, by default,
1538 handled in the @code{Score} context.
1539 However, in some music we may not want the bar lines to be
1540 synchronized -- consider a polymetric score in 4/4 and 3/4 time.
1541 In such cases, we must modify the default settings of the
1542 @code{Score} and @code{Staff} contexts.
1544 For very simple scores, contexts are created implicitly, and you need
1545 not be aware of them. For larger pieces, such as anything with more
1546 than one staff, they must be
1547 created explicitly to make sure that you get as many staves as you
1548 need, and that they are in the correct order. For typesetting pieces
1549 with specialized notation, it is usual to modify existing, or
1550 even to define totally new, contexts.
1552 In addition to the @code{Score,} @code{Staff} and
1553 @code{Voice} contexts there are contexts which fit between
1554 the score and staff levels to control staff groups, such as the
1555 @code{PianoStaff} and @code{ChoirStaff} contexts. There
1556 are also alternative staff and voice contexts, and contexts for
1557 lyrics, percussion, fret boards, figured bass, etc.
1559 The names of all context types are formed from one or more
1560 words, each word being capitalized and joined immediately to the
1561 preceding word with no hyphen or underscore, e.g.,
1562 @code{GregorianTranscriptionStaff}.
1566 Notation Reference: @ruser{Contexts explained}.
1569 @node Creating contexts
1570 @subsection Creating contexts
1573 @cindex new contexts
1574 @cindex creating contexts
1575 @cindex contexts, creating
1577 There can be only one top level context: the
1579 context. This is created with the @code{\score} command,
1580 or, in simple scores, it is created automatically.
1582 For scores with only one voice and one staff, the
1583 @code{Voice} and @code{Staff} contexts may be left to be
1584 created automatically, but for more complex scores it is
1585 necessary to create them by hand.
1586 The simplest command that does this is @code{\new}.
1587 It is prepended to a music expression, for example
1590 \new @var{type} @var{music-expression}
1594 where @var{type} is a context name (like @code{Staff} or
1595 @code{Voice}). This command creates a new context, and starts
1596 interpreting the @var{music-expression} within that context.
1598 Note that there is no @code{\new Score} command;
1599 the single top-level @code{Score} context is introduced
1602 You have seen many practical examples which created new
1603 @code{Staff} and @code{Voice} contexts in earlier sections, but
1604 to remind you how these commands are used in practice, here's an
1605 annotated real-music example:
1607 @lilypond[quote,verbatim,ragged-right]
1608 \score { % start of single compound music expression
1609 << % start of simultaneous staves section
1611 \new Staff { % create RH staff
1614 \new Voice { % create voice for RH notes
1615 \relative c'' { % start of RH notes
1621 \new Staff << % create LH staff; needs two simultaneous voices
1624 \new Voice { % create LH voice one
1626 \relative g { % start of LH voice one notes
1627 g8 <bes d> ees, <g c> |
1628 g8 <bes d> ees, <g c> |
1629 } % end of LH voice one notes
1630 } % end of LH voice one
1631 \new Voice { % create LH voice two
1633 \relative g { % start of LH voice two notes
1636 } % end of LH voice two notes
1637 } % end of LH voice two
1638 >> % end of LH staff
1639 >> % end of simultaneous staves section
1640 } % end of single compound music expression
1643 (Note how all the statements which open a block with either a
1644 curly bracket, @code{@{}, or double angle brackets, @code{<<},
1645 are indented by two further spaces, and the corresponding
1646 closing bracket is indented by exactly the same amount. While
1647 this is not required, following this practice will greatly
1648 reduce the number of @q{unmatched bracket} errors, and is
1649 strongly recommended. It enables the structure of the music to
1650 be seen at a glance, and any unmatched brackets will be obvious.
1651 Note too how the LH staff is created using double angle brackets
1652 because it requires two voices for its music, whereas the RH staff
1653 is created with a single music expression surrounded by curly
1654 brackets because it requires only one voice.)
1656 @cindex contexts, naming
1657 @cindex naming contexts
1659 The @code{\new} command may also give a identifying name to the
1660 context to distinguish it from other contexts of the same type,
1663 \new @var{type} = @var{id} @var{music-expression}
1666 Note the distinction between the name of the context type,
1667 @code{Staff}, @code{Voice}, etc, and the identifying name of a
1668 particular instance of that type, which can be any sequence of letters
1669 and digits invented by the user. The identifying name is used to
1670 refer back to that particular instance of a context. We saw this in
1671 use in the section on lyrics, see @ref{Voices and vocals}.
1675 Notation Reference: @ruser{Creating contexts}.
1678 @node Engravers explained
1679 @subsection Engravers explained
1683 Every mark on the printed output of a score produced by LilyPond
1684 is produced by an @code{Engraver}. Thus there is an engraver
1685 to print staves, one to print note heads, one for stems, one for
1686 beams, etc, etc. In total there are over 120 such engravers!
1687 Fortunately, for most scores it is not necessary to know about
1688 more than a few, and for simple scores you do not need to know
1691 Engravers live and operate in Contexts.
1692 Engravers such as the @code{Metronome_mark_engraver}, whose
1693 action and output apply to the score as a whole, operate in
1694 the highest level context -- the @code{Score} context.
1696 The @code{Clef_engraver} and @code{Key_engraver} are to be
1697 found in every @code{Staff} Context, as different staves may require
1698 different clefs and keys.
1700 The @code{Note_heads_engraver} and @code{Stem_engraver} live
1701 in every @code{Voice} context, the lowest level context of all.
1703 Each engraver processes the particular objects associated
1704 with its function, and maintains the properties that relate
1705 to that function. These properties, like the properties
1706 associated with contexts, may be modified to change the
1707 operation of the engraver or the appearance of those elements
1708 in the printed score.
1710 Engravers all have compound names formed from words which
1711 describe their function. Just the first word is capitalized,
1712 and the remainder are joined to it with underscores. Thus
1713 the @code{Staff_symbol_engraver} is responsible for creating the
1714 lines of the staff, the @code{Clef_engraver} determines and sets
1715 the pitch reference point on the staff by drawing a clef symbol.
1717 Here are some of the most common engravers together with their
1718 function. You will see it is usually easy to guess the function
1719 from the name, or vice versa.
1721 @multitable @columnfractions .3 .7
1724 @item Accidental_engraver
1725 @tab Makes accidentals, cautionary and suggested accidentals
1730 @item Completion_heads_engraver
1731 @tab Splits notes which cross bar lines
1732 @c The old Dynamic_engraver is deprecated. -jm
1733 @item New_dynamic_engraver
1734 @tab Creates hairpins and dynamic texts
1735 @item Forbid_line_break_engraver
1736 @tab Prevents line breaks if a musical element is still active
1738 @tab Creates the key signature
1739 @item Metronome_mark_engraver
1740 @tab Engraves metronome marking
1741 @item Note_heads_engraver
1742 @tab Engraves note heads
1745 @item Staff_symbol_engraver
1746 @tab Engraves the five (by default) lines of the staff
1748 @tab Creates stems and single-stem tremolos
1749 @item Time_signature_engraver
1750 @tab Creates time signatures
1755 We shall see later how the output of LilyPond can be changed
1756 by modifying the action of Engravers.
1760 Internals reference: @rinternals{Engravers and performers}.
1763 @node Modifying context properties
1764 @subsection Modifying context properties
1766 @cindex context properties
1767 @cindex context properties, modifying
1768 @cindex modifying context properties
1772 Contexts are responsible for holding the values of a number of
1773 context @emph{properties}. Many of them can be changed to
1774 influence the interpretation of the input and so change the
1775 appearance of the output. They are changed by the
1776 @code{\set} command. This takes the form
1779 \set @emph{ContextName}.@emph{propertyName} = #@emph{value}
1782 Where the @emph{ContextName} is usually @code{Score},
1783 @code{Staff} or @code{Voice}. It may be omitted,
1784 in which case @code{Voice} is assumed.
1786 The names of context properties consist of words joined
1787 together with no hyphens or underscores, all except the
1788 first having a capital letter. Here are a few examples
1789 of some commonly used ones. There are many more.
1791 @c attempt to force this onto a new page
1793 @multitable @columnfractions .25 .15 .45 .15
1794 @headitem propertyName
1800 @tab If true, set extra natural signs before accidentals
1801 @tab @code{#t}, @code{#f}
1802 @item currentBarNumber
1804 @tab Set the current bar number
1808 @tab If true, print slurs both above and below notes
1809 @tab @code{#t}, @code{#f}
1810 @item instrumentName
1812 @tab Set the name to be placed at the start of the staff
1813 @tab @code{"Cello I"}
1816 @tab Increase or decrease the font size
1820 @tab Set the text to print before the start of a verse
1825 where a Boolean is either True (@code{#t}) or False (@code{#f}),
1826 an Integer is a positive whole number, a Real is a positive
1827 or negative decimal number, and text is enclosed in double
1828 apostrophes. Note the occurrence of hash signs,
1829 (@code{#}), in two different places -- as part of the Boolean
1830 value before the @code{t} or @code{f}, and before @emph{value}
1831 in the @code{\set} statement. So when a Boolean is being
1832 entered you need to code two hash signs, e.g., @code{##t}.
1834 Before we can set any of these properties we need to know
1835 in which context they operate. Sometimes this is obvious,
1836 but occasionally it can be tricky. If the wrong context
1837 is specified, no error message is produced, but the expected
1838 action will not take place. For example, the
1839 @code{instrumentName} clearly lives in the @code{Staff} context, since
1840 it is the staff that is to be named.
1841 In this example the first staff is labelled, but not the second,
1842 because we omitted the context name.
1844 @lilypond[quote,verbatim,ragged-right]
1846 \new Staff \relative c'' {
1847 \set Staff.instrumentName = #"Soprano"
1850 \new Staff \relative c' {
1851 \set instrumentName = #"Alto" % Wrong!
1857 Remember the default context name is @code{Voice}, so the second
1858 @code{\set} command set the property @code{instrumentName} in the
1859 @code{Voice} context to @qq{Alto}, but as LilyPond does not look
1860 for any such property in the @code{Voice} context, no
1861 further action took place. This is not an error, and no error
1862 message is logged in the log file.
1864 Similarly, if the property name is mis-spelt no error message is
1865 produced, and clearly the expected action cannot be performed. If
1866 fact, you can set any (fictitious) @q{property} using any name you
1867 like in any context that exists by using the @code{\set} command. But
1868 if the name is not known to LilyPond it will not cause any action to
1869 be taken. Some text editors with special support for LilyPond input
1870 files document property names with bullets when you hover them with
1871 the mouse, like JEdit with LilyPondTool, or highlight unknown property
1872 names differently, like ConTEXT. If you do not use an editor with
1873 such features, it is recommended to check the property name in the
1874 Internals Reference: see @rinternals{Tunable context properties}, or
1875 @rinternals{Contexts}.
1877 The @code{instrumentName} property will take effect only
1878 if it is set in the @code{Staff} context, but
1879 some properties can be set in more than one context.
1880 For example, the property @code{extraNatural} is by
1881 default set to ##t (true) for all staves.
1882 If it is set to ##f (false) in one particular @code{Staff}
1883 context it applies just to the accidentals on that staff.
1884 If it is set to false in the @code{Score} context
1885 it applies to all staves.
1887 So this turns off extra naturals in one staff:
1889 @lilypond[quote,verbatim,ragged-right]
1891 \new Staff \relative c'' {
1894 \new Staff \relative c'' {
1895 \set Staff.extraNatural = ##f
1902 and this turns them off in all staves:
1904 @lilypond[quote,verbatim,ragged-right]
1906 \new Staff \relative c'' {
1909 \new Staff \relative c'' {
1910 \set Score.extraNatural = ##f
1916 As another example, if @code{clefOctavation} is set in
1917 the @code{Score} context this immediately changes the value
1918 of the octavation in all current staves and sets a new default
1919 value which will be applied to all staves.
1921 The opposite command, @code{\unset}, effectively removes the
1922 property from the context, which causes most properties to
1923 revert to their default value. Usually @code{\unset} is not
1924 required as a new @code{\set} command will achieve what is
1927 The @code{\set} and @code{\unset} commands can appear anywhere
1928 in the input file and will take effect from the time they are
1929 encountered until the end of the score or until the property is
1930 @code{\set} or @code{\unset} again. Let's try changing the
1931 font size, which affects the size of the note heads (among
1932 other things) several times. The change is from the default
1933 value, not the most recently set value.
1935 @lilypond[quote,verbatim,ragged-right,relative=1,fragment]
1937 % make note heads smaller
1940 % make note heads larger
1941 \set fontSize = #2.5
1943 % return to default size
1948 We have now seen how to set the values of several different types of
1949 property. Note that integers and numbers are always preceded by a
1950 hash sign, @code{#}, while a true or false value is specified by
1951 @code{##t} and @code{##f}, with two hash signs. A text property
1952 should be enclosed in double quotation signs, as above, although we
1953 shall see later that text can actually be specified in a much more
1954 general way by using the very powerful @code{markup} command.
1956 @unnumberedsubsubsec Setting context properties with @code{\with}
1959 @cindex context properties, setting with \with
1961 Context properties may also be set at the time the context is
1962 created. Sometimes this is a clearer way of specifying a
1963 property value if it is to remain fixed for the duration of
1964 the context. When a context is created with a @code{\new}
1965 command it may be followed immediately by a
1966 @code{\with @{ .. @}} block in which the property values are
1967 set. For example, if we wish to suppress the printing of
1968 extra naturals for the duration of a staff we would write:
1971 \new Staff \with @{ extraNatural = ##f @}
1977 @lilypond[quote,verbatim,ragged-right]
1983 \new Staff \with { extraNatural = ##f }
1990 Properties set in this way may still be changed dynamically using
1991 @code{\set} and returned to their default value with @code{\unset}.
1993 The @code{fontSize} property is treated differently. If this is
1994 set in a @code{\with} clause it effectively resets the default
1995 value of the font size. If it is later changed with @code{\set},
1996 this new default value may be restored with the
1997 @code{\unset fontSize} command.
1999 @unnumberedsubsubsec Setting context properties with @code{\context}
2001 The values of context properties may be set in @emph{all} contexts
2002 of a particular type, such as all @code{Staff} contexts, with a single
2003 command. The context type is identified by using its
2004 type name, like @code{Staff}, prefixed by a back-slash: @code{\Staff}.
2005 The statement which sets the property value is the same as that in a
2006 @code{\with} block, introduced above. It is placed in a
2007 @code{\context} block within a @code{\layout} block. Each
2008 @code{\context} block will affect all contexts of the type specified
2009 throughout the @code{\score} or @code{\book} block in which the
2010 @code{\layout} block appears. Here is a example to show the format:
2012 @lilypond[verbatim,quote]
2029 Context properties set in this way may be overridden for particular
2030 instances of contexts by statements in a @code{\with} block, and by
2031 @code{\set} commands embedded in music statements.
2036 @ruser{Changing context default settings}.
2038 @c uncomment when backslash-node-name issue is resolved -pm
2039 @c @ruser{The set command}.
2041 Internals Reference:
2042 @rinternals{Contexts},
2043 @rinternals{Tunable context properties}.
2046 @node Adding and removing engravers
2047 @subsection Adding and removing engravers
2049 @cindex engravers, adding
2050 @cindex engravers, removing
2055 We have seen that contexts each contain several engravers, each
2056 of which is responsible for producing a particular part of the
2057 output, like bar lines, staves, note heads, stems, etc. If an
2058 engraver is removed from a context, it can no longer produce its
2059 output. This is a crude way of modifying the output, but it
2060 can sometimes be useful.
2062 @subsubheading Changing a single context
2064 To remove an engraver from a single context we use the
2065 @code{\with} command placed immediately after the context creation
2066 command, as in the previous section.
2068 As an illustration, let's repeat an example from the previous section
2069 with the staff lines removed. Remember that the staff lines are
2070 produced by the @code{Staff_symbol_engraver}.
2072 @lilypond[quote,verbatim,ragged-right]
2074 \remove Staff_symbol_engraver
2078 \set fontSize = #-4 % make note heads smaller
2080 \set fontSize = #2.5 % make note heads larger
2082 \unset fontSize % return to default size
2087 @cindex ambitus engraver
2089 Engravers can also be added to individual contexts.
2090 The command to do this is
2092 @code{\consists @var{Engraver_name}},
2095 placed inside a @code{\with} block. Some vocal scores have an ambitus
2096 placed at the beginning of a staff to indicate the range of notes in
2097 that staff -- see @rglos{ambitus}. The ambitus is produced by the
2098 @code{Ambitus_engraver}, which is not normally included in any
2099 context. If we add it to the @code{Voice} context, it calculates the
2100 range from that voice only:
2102 @lilypond[quote,verbatim,ragged-right]
2105 \consists Ambitus_engraver
2120 but if we add the ambitus engraver to the
2121 @code{Staff} context, it calculates the range from all
2122 the notes in all the voices on that staff:
2124 @lilypond[quote,verbatim,ragged-right]
2126 \consists Ambitus_engraver
2142 @subsubheading Changing all contexts of the same type
2146 The examples above show how to remove or add engravers to
2147 individual contexts. It is also possible to remove or add
2148 engravers to every context of a specific type by placing the
2149 commands in the appropriate context in a @code{\layout}
2150 block. For example, if we wanted to show an ambitus for every
2151 staff in a four-staff score, we could write
2153 @lilypond[quote,verbatim,ragged-right]
2157 \relative c'' { c a b g }
2160 \relative c' { c a b g }
2164 \relative c' { c a b g }
2168 \relative c { c a b g }
2174 \consists Ambitus_engraver
2181 The values of context properties may also be set
2182 for all contexts of a particular type by including the
2183 @code{\set} command in a @code{\context} block in the
2188 Notation Reference: @ruser{Modifying context plug-ins},
2189 @ruser{Changing context default settings}.
2192 @node Extending the templates
2193 @section Extending the templates
2195 You've read the tutorial, you know how to write music, you
2196 understand the fundamental concepts. But how can you
2197 get the staves that you want? Well, you can find lots of
2198 templates (see @ref{Templates}) which may give you a start.
2199 But what if you want something that isn't covered there? Read on.
2202 * Soprano and cello::
2203 * Four-part SATB vocal score::
2204 * Building a score from scratch::
2207 @node Soprano and cello
2208 @subsection Soprano and cello
2210 @cindex template, modifying
2212 Start off with the template that seems closest to what you want to end
2213 up with. Let's say that you want to write something for soprano and
2214 cello. In this case, we would start with @q{Notes and lyrics} (for the
2218 \version @w{"@version{}"}
2219 melody = \relative c' @{
2226 text = \lyricmode @{
2232 \new Voice = "one" @{
2236 \new Lyrics \lyricsto "one" \text
2243 Now we want to add a cello part. Let's look at the @q{Notes only} example:
2246 \version @w{"@version{}"}
2247 melody = \relative c' @{
2261 We don't need two @code{\version} commands. We'll need the
2262 @code{melody} section. We don't want two @code{\score} sections
2263 -- if we had two @code{\score}s, we'd get the two parts separately.
2264 We want them together, as a duet. Within the @code{\score}
2265 section, we don't need two @code{\layout} or @code{\midi}.
2267 If we simply cut and paste the @code{melody} section, we would
2268 end up with two @code{melody} definitions. This would not generate
2269 an error, but the second one would be used for both melodies.
2270 So let's rename them to make them distinct. We'll call the
2271 section for the soprano @code{sopranoMusic} and the section for
2272 the cello @code{celloMusic}. While we're doing this, let's rename
2273 @code{text} to be @code{sopranoLyrics}. Remember to rename both
2274 instances of all these names -- both the initial definition (the
2275 @code{melody = \relative c' @{ } part) and the name's use (in the
2276 @code{\score} section).
2278 While we're doing this, let's change the cello part's staff --
2279 celli normally use bass clef. We'll also give the cello some
2283 \version @w{"@version{}"}
2284 sopranoMusic = \relative c' @{
2291 sopranoLyrics = \lyricmode @{
2295 celloMusic = \relative c @{
2304 \new Voice = "one" @{
2308 \new Lyrics \lyricsto "one" \sopranoLyrics
2315 This is looking promising, but the cello part won't appear in the
2316 score -- we haven't used it in the @code{\score} section. If we
2317 want the cello part to appear under the soprano part, we need to add
2320 \new Staff \celloMusic
2324 underneath the soprano stuff. We also need to add @code{<<} and
2325 @code{>>} around the music -- that tells LilyPond that there's
2326 more than one thing (in this case, two @code{Staves}) happening
2327 at once. The @code{\score} looks like this now:
2329 @c Indentation in this example is deliberately poor
2334 \new Voice = "one" @{
2338 \new Lyrics \lyricsto "one" \sopranoLyrics
2340 \new Staff \celloMusic
2348 This looks a bit messy; the indentation is messed up now. That is
2349 easily fixed. Here's the complete soprano and cello template.
2351 @lilypond[quote,verbatim,ragged-right,addversion]
2352 sopranoMusic = \relative c' {
2359 sopranoLyrics = \lyricmode {
2363 celloMusic = \relative c {
2373 \new Voice = "one" {
2377 \new Lyrics \lyricsto "one" \sopranoLyrics
2379 \new Staff \celloMusic
2388 The starting templates can be found in the @q{Templates} appendix,
2389 see @ref{Single staff}.
2392 @node Four-part SATB vocal score
2393 @subsection Four-part SATB vocal score
2395 @cindex template, SATB
2396 @cindex SATB template
2398 Most vocal scores of music written for four-part mixed choir
2399 with orchestral accompaniment such as Mendelssohn's Elijah or
2400 Handel's Messiah have the choral music and words on four
2401 staves, one for each of SATB, with a piano reduction of the
2402 orchestral accompaniment underneath. Here's an example
2403 from Handel's Messiah:
2405 @c The following should appear as music without code
2406 @lilypond[quote,ragged-right]
2407 global = { \key d \major \time 4/4 }
2408 sopranoMusic = \relative c'' {
2410 r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
2412 sopranoWords = \lyricmode {
2413 Wor -- thy is the lamb that was slain
2415 altoMusic = \relative a' {
2417 r4 a2 a4 | fis4. fis8 a2 | g4 fis e2 |
2419 altoWords = \sopranoWords
2420 tenorMusic = \relative c' {
2422 r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
2424 tenorWords = \sopranoWords
2425 bassMusic = \relative c' {
2427 r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
2429 bassWords = \sopranoWords
2430 upper = \relative a' {
2433 r4 <a d fis>2 <a e' a>4 |
2434 <d fis d'>4. <d fis d'>8 <a d a'>2 |
2435 <g cis g'>4 <a d fis> <a cis e>2 |
2437 lower = \relative c, {
2440 <d d'>4 <d d'>2 <cis cis'>4 |
2441 <b b'>4. <b' b'>8 <fis fis'>2 |
2442 <e e'>4 <d d'> <a' a'>2 |
2446 << % combine ChoirStaff and PianoStaff in parallel
2448 \new Staff = "sopranos" <<
2449 \set Staff.instrumentName = "Soprano"
2450 \new Voice = "sopranos" { \global \sopranoMusic }
2452 \new Lyrics \lyricsto "sopranos" { \sopranoWords }
2453 \new Staff = "altos" <<
2454 \set Staff.instrumentName = "Alto"
2455 \new Voice = "altos" { \global \altoMusic }
2457 \new Lyrics \lyricsto "altos" { \altoWords }
2458 \new Staff = "tenors" <<
2459 \set Staff.instrumentName = "Tenor"
2460 \new Voice = "tenors" { \global \tenorMusic }
2462 \new Lyrics \lyricsto "tenors" { \tenorWords }
2463 \new Staff = "basses" <<
2464 \set Staff.instrumentName = "Bass"
2465 \new Voice = "basses" { \global \bassMusic }
2467 \new Lyrics \lyricsto "basses" { \bassWords }
2471 \set PianoStaff.instrumentName = "Piano"
2472 \new Staff = "upper" \upper
2473 \new Staff = "lower" \lower
2479 None of the templates provides this layout exactly. The nearest is
2480 @q{SATB vocal score and automatic piano reduction} -- see @ref{Vocal
2481 ensembles} -- but we need to change the layout and add a piano
2482 accompaniment which is not derived automatically from the vocal parts.
2483 The variables holding the music and words for the vocal parts are
2484 fine, but we shall need to add variables for the piano reduction.
2486 The order in which the contexts appear in the ChoirStaff of
2487 the template do not correspond with the order in the vocal
2488 score shown above. We need to rearrange them so there are
2489 four staves with the words written directly underneath the
2490 notes for each part.
2491 All the voices should be @code{\voiceOne}, which is
2492 the default, so the @code{\voiceXXX} commands should be removed.
2493 We also need to specify the tenor clef for the tenors.
2494 The way in which lyrics are specified in the template has not yet
2495 been encountered so we need to use the method with which we are
2496 familiar. We should also add the names of each staff.
2498 Doing this gives for our ChoirStaff:
2502 \new Staff = "sopranos" <<
2503 \set Staff.instrumentName = "Soprano"
2504 \new Voice = "sopranos" @{ \global \sopranoMusic @}
2506 \new Lyrics \lyricsto "sopranos" @{ \sopranoWords @}
2507 \new Staff = "altos" <<
2508 \set Staff.instrumentName = "Alto"
2509 \new Voice = "altos" @{ \global \altoMusic @}
2511 \new Lyrics \lyricsto "altos" @{ \altoWords @}
2512 \new Staff = "tenors" <<
2513 \set Staff.instrumentName = "Tenor"
2514 \new Voice = "tenors" @{ \global \tenorMusic @}
2516 \new Lyrics \lyricsto "tenors" @{ \tenorWords @}
2517 \new Staff = "basses" <<
2518 \set Staff.instrumentName = "Bass"
2519 \new Voice = "basses" @{ \global \bassMusic @}
2521 \new Lyrics \lyricsto "basses" @{ \bassWords @}
2525 Next we must work out the piano part. This is
2526 easy - we just pull out the piano part from the
2527 @q{Solo piano} template:
2531 \set PianoStaff.instrumentName = "Piano "
2532 \new Staff = "upper" \upper
2533 \new Staff = "lower" \lower
2537 and add the variable definitions for @code{upper}
2540 The ChoirStaff and PianoStaff must be combined
2541 using angle brackets as we want them to be
2542 stacked one above the other:
2545 << % combine ChoirStaff and PianoStaff one above the other
2547 \new Staff = "sopranos" <<
2548 \new Voice = "sopranos" @{ \global \sopranoMusic @}
2550 \new Lyrics \lyricsto "sopranos" @{ \sopranoWords @}
2551 \new Staff = "altos" <<
2552 \new Voice = "altos" @{ \global \altoMusic @}
2554 \new Lyrics \lyricsto "altos" @{ \altoWords @}
2555 \new Staff = "tenors" <<
2556 \clef "G_8" % tenor clef
2557 \new Voice = "tenors" @{ \global \tenorMusic @}
2559 \new Lyrics \lyricsto "tenors" @{ \tenorWords @}
2560 \new Staff = "basses" <<
2562 \new Voice = "basses" @{ \global \bassMusic @}
2564 \new Lyrics \lyricsto "basses" @{ \bassWords @}
2568 \set PianoStaff.instrumentName = "Piano"
2569 \new Staff = "upper" \upper
2570 \new Staff = "lower" \lower
2575 Combining all these together and adding the music
2576 for the three bars of the example above gives:
2578 @lilypond[quote,verbatim,ragged-right,addversion]
2579 global = { \key d \major \time 4/4 }
2580 sopranoMusic = \relative c'' {
2582 r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
2584 sopranoWords = \lyricmode {
2585 Wor -- thy is the lamb that was slain
2587 altoMusic = \relative a' {
2589 r4 a2 a4 | fis4. fis8 a2 | g4 fis fis2 |
2591 altoWords = \sopranoWords
2592 tenorMusic = \relative c' {
2594 r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
2596 tenorWords = \sopranoWords
2597 bassMusic = \relative c' {
2599 r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
2601 bassWords = \sopranoWords
2602 upper = \relative a' {
2605 r4 <a d fis>2 <a e' a>4 |
2606 <d fis d'>4. <d fis d'>8 <a d a'>2 |
2607 <g cis g'>4 <a d fis> <a cis e>2 |
2609 lower = \relative c, {
2612 <d d'>4 <d d'>2 <cis cis'>4 |
2613 <b b'>4. <b' b'>8 <fis fis'>2 |
2614 <e e'>4 <d d'> <a' a'>2 |
2618 << % combine ChoirStaff and PianoStaff in parallel
2620 \new Staff = "sopranos" <<
2621 \set Staff.instrumentName = "Soprano"
2622 \new Voice = "sopranos" { \global \sopranoMusic }
2624 \new Lyrics \lyricsto "sopranos" { \sopranoWords }
2625 \new Staff = "altos" <<
2626 \set Staff.instrumentName = "Alto"
2627 \new Voice = "altos" { \global \altoMusic }
2629 \new Lyrics \lyricsto "altos" { \altoWords }
2630 \new Staff = "tenors" <<
2631 \set Staff.instrumentName = "Tenor"
2632 \new Voice = "tenors" { \global \tenorMusic }
2634 \new Lyrics \lyricsto "tenors" { \tenorWords }
2635 \new Staff = "basses" <<
2636 \set Staff.instrumentName = "Bass"
2637 \new Voice = "basses" { \global \bassMusic }
2639 \new Lyrics \lyricsto "basses" { \bassWords }
2643 \set PianoStaff.instrumentName = "Piano "
2644 \new Staff = "upper" \upper
2645 \new Staff = "lower" \lower
2652 @node Building a score from scratch
2653 @subsection Building a score from scratch
2655 @cindex template, writing your own
2657 After gaining some facility with writing LilyPond code, you
2658 may find that it is easier to build a score from scratch
2659 rather than modifying one of the templates. You can also
2660 develop your own style this way to suit the sort of music you
2661 like. Let's see how to put together the score for an organ
2662 prelude as an example.
2664 We begin with a header section. Here go the title, name
2665 of composer, etc, then come any variable definitions, and
2666 finally the score block. Let's start with these in outline
2667 and fill in the details later.
2669 We'll use the first two bars of Bach's prelude
2670 based on @emph{Jesu, meine Freude} which is written for two
2671 manuals and pedal organ. You can see these two bars of music
2672 at the bottom of this section. The top manual part has two voices,
2673 the lower and pedal organ one each. So we need four
2674 music definitions and one to define the time signature
2678 \version @w{"@version{}"}
2680 title = "Jesu, meine Freude"
2681 composer = "J S Bach"
2683 TimeKey = @{ \time 4/4 \key c \minor @}
2684 ManualOneVoiceOneMusic = @{s1@}
2685 ManualOneVoiceTwoMusic = @{s1@}
2686 ManualTwoMusic = @{s1@}
2687 PedalOrganMusic = @{s1@}
2693 For now we've just used a spacer note, @code{s1},
2694 instead of the real music. We'll add that later.
2696 Next let's see what should go in the score block.
2697 We simply mirror the staff structure we want.
2698 Organ music is usually written on three staves,
2699 one for each manual and one for the pedals. The
2700 manual staves should be bracketed together, so we
2701 need to use a PianoStaff for them. The first
2702 manual part needs two voices and the second manual
2707 \new Staff = "ManualOne" <<
2708 \new Voice @{ \ManualOneVoiceOneMusic @}
2709 \new Voice @{ \ManualOneVoiceTwoMusic @}
2710 >> % end ManualOne Staff context
2711 \new Staff = "ManualTwo" <<
2712 \new Voice @{ \ManualTwoMusic @}
2713 >> % end ManualTwo Staff context
2714 >> % end PianoStaff context
2717 Next we need to add a staff for the pedal organ.
2718 This goes underneath the PianoStaff, but it must
2719 be simultaneous with it, so we need angle brackets
2720 around the two. Missing these out would generate
2721 an error in the log file. It's a common mistake
2722 which you'll make sooner or later! Try copying
2723 the final example at the end of this section,
2724 remove these angle brackets, and compile it to
2725 see what errors it generates.
2728 << % PianoStaff and Pedal Staff must be simultaneous
2730 \new Staff = "ManualOne" <<
2731 \new Voice @{ \ManualOneVoiceOneMusic @}
2732 \new Voice @{ \ManualOneVoiceTwoMusic @}
2733 >> % end ManualOne Staff context
2734 \new Staff = "ManualTwo" <<
2735 \new Voice @{ \ManualTwoMusic @}
2736 >> % end ManualTwo Staff context
2737 >> % end PianoStaff context
2738 \new Staff = "PedalOrgan" <<
2739 \new Voice @{ \PedalOrganMusic @}
2744 It is not necessary to use the simultaneous construct
2745 @code{<< .. >>} for the manual two staff and the pedal organ staff,
2746 since they contain only one music expression, but it does no harm,
2747 and always using angle brackets after @code{\new Staff} is a good
2748 habit to cultivate in case there are multiple voices. The opposite
2749 is true for Voices: these should habitually be followed by braces
2750 @code{@{ .. @}} in case your music is coded in several variables
2751 which need to run consecutively.
2753 Let's add this structure to the score block, and adjust the indenting.
2754 We also add the appropriate clefs, ensure stems, ties and slurs in
2755 each voice on the upper staff point to the right direction with
2756 @code{\voiceOne} and @code{\voiceTwo}, and enter the time signature
2757 and key to each staff using our predefined variable, @code{\TimeKey}.
2761 << % PianoStaff and Pedal Staff must be simultaneous
2763 \new Staff = "ManualOne" <<
2764 \TimeKey % set time signature and key
2766 \new Voice @{ \voiceOne \ManualOneVoiceOneMusic @}
2767 \new Voice @{ \voiceTwo \ManualOneVoiceTwoMusic @}
2768 >> % end ManualOne Staff context
2769 \new Staff = "ManualTwo" <<
2772 \new Voice @{ \ManualTwoMusic @}
2773 >> % end ManualTwo Staff context
2774 >> % end PianoStaff context
2775 \new Staff = "PedalOrgan" <<
2778 \new Voice @{ \PedalOrganMusic @}
2779 >> % end PedalOrgan Staff
2781 @} % end Score context
2784 That completes the structure. Any three-staff organ music
2785 will have a similar structure, although the number of voices
2786 may vary. All that remains now
2787 is to add the music, and combine all the parts together.
2789 @lilypond[quote,verbatim,ragged-right,addversion]
2791 title = "Jesu, meine Freude"
2792 composer = "J S Bach"
2794 TimeKey = { \time 4/4 \key c \minor }
2795 ManualOneVoiceOneMusic = \relative g' {
2796 g4 g f ees | d2 c2 |
2798 ManualOneVoiceTwoMusic = \relative c' {
2799 ees16 d ees8~ ees16 f ees d c8 d~ d c~ |
2800 c c4 b8 c8. g16 c b c d |
2802 ManualTwoMusic = \relative c' {
2803 c16 b c8~ c16 b c g a8 g~ g16 g aes ees |
2804 f ees f d g aes g f ees d e8~ ees16 f ees d |
2806 PedalOrganMusic = \relative c {
2807 r8 c16 d ees d ees8~ ees16 a, b g c b c8 |
2808 r16 g ees f g f g8 c,2 |
2812 << % PianoStaff and Pedal Staff must be simultaneous
2814 \new Staff = "ManualOne" <<
2815 \TimeKey % set time signature and key
2817 \new Voice { \voiceOne \ManualOneVoiceOneMusic }
2818 \new Voice { \voiceTwo \ManualOneVoiceTwoMusic }
2819 >> % end ManualOne Staff context
2820 \new Staff = "ManualTwo" <<
2823 \new Voice { \ManualTwoMusic }
2824 >> % end ManualTwo Staff context
2825 >> % end PianoStaff context
2826 \new Staff = "PedalOrgan" <<
2829 \new Voice { \PedalOrganMusic }
2830 >> % end PedalOrgan Staff context
2832 } % end Score context