7 * Introduction:: Introduction
8 * The first tune:: The first tune
9 * Lyrics and chords:: Lyrics and chords
10 * More movements:: More than one movement in a file
11 * Piano music:: Piano music
12 * end of tutorial:: The end
19 LilyPond prints music from a specification that you, the user, supply.
20 You have to give that specification using a @emph{language}. This
21 document is a gentle introduction to that language, which is called
22 Lilypond, an acronym of Music Definition Language.
24 This tutorial will demonstrate how to use Lilypond by presenting
25 examples of input along with resulting output. We will use English
26 terms for notation. In case you are not familiar with those, you may
27 consult the glossary that is distributed with LilyPond.
29 The examples discussed are included in the distribution, in the
30 subdirectory @file{input/tutorial/}. It is recommended that you
31 experiment with writing Lilypond input yourself, to get a feel for
35 @section The first tune
38 To demonstrate what LilyPond input looks like, we start off with a
39 full fledged, yet simple example. It is a convoluted version
40 of the famous menuet in J. S. Bach's @emph{Klavierbuechlein}.
43 % lines preceded by a percent are comments which
44 % are ignored by Lilypond.
48 \relative c'' \sequential{
53 d4 g,8 a b c d4 g, g |
54 e'4 c8 d e fis g4 g, g |
55 c4 d8()c b a( )b4 c8 b a g |
56 a4 [b8 a] [g fis] g2. |
61 g4 e8 fis g d cis4 b8 cis a4 |
62 a8-. b-. cis-. d-. e-. fis-.
69 % standard settings are too wide for a book
75 Enter it (or copy it, the filename is @file{menuet.ly}), compile it
76 with LilyPond and view the output. Details of this procedure may vary
77 from system to system. To create the output, one would issue the
78 command `@code{ly2dvi menuet}'. @file{ly2dvi} is a program that does
79 the job of running LilyPond and @TeX{}, handling of titles and
80 adjusting of page margins.
82 If all goes well, the file @file{menuet.dvi} will be created.
83 To view this output, issue the command `@code{xdvi menuet}'.
85 Now that we are familiar with the procedure of producing output, we
86 will analyse the input, line by line.
88 % lines preceded by a percent are comments which
89 % are ignored by Lilypond.
91 The percent sign, `@code{%}', introduces a line comment. If you want to
92 make larger comments, you can use block comments. These are delimited
93 by `@code{%@{}' and `@code{%@}}'
99 By default, LilyPond will use definitions for a 20
100 point@footnote{A point is the standard measure of length for
101 printing. One point is 1/72.27 inch.} high staff. We want smaller
102 output (16 point staff height), so we must import the settings for
103 that size, which is done.
109 A lilypond file combines music with directions for outputting that
110 music. The music is combined with the output directions by putting
111 them into a @code{\score} block.
117 This makes LilyPond ready for accepting notes.
123 As we will see, pitches are combinations of octave, note name and
124 chromatic alteration. In this scheme, the octave is indicated by
125 using raised quotes (`@code{'}') and ``lowered'' quotes (commas:
126 `@code{,}'). The central C is denoted by @code{c'}. The C one octave
127 higher is @code{c''}. One and two octaves below the central C is
128 denoted by @code{c} and @code{c,} respectively.
130 For pitches in a long piece you might have to type many quotes. To
131 remedy this, LilyPond has a ``relative'' octave entry mode. In this
132 mode, octaves of notes without quotes are chosen such that a note is
133 as close as possible (graphically, on the staff) to the the preceding
134 note. If you add a high-quote an extra octave is added. The lowered
135 quote (a comma) will subtract an extra octave. Because the first note
136 has no predecessor, you have to give the (absolute) pitch of the note
143 What follows is sequential music, i.e.,
144 notes that are to be played and printed after each other.
150 This command changes the time signature of the current piece: a 3/4
151 sign is printed. This command is also used to generate bar lines in
158 This command changes the current key to G-major. Although this
159 command comes after the @code{\time} command, in the output, the key
160 signature comes before the time signature: LilyPond knows about music
161 typesetting conventions.
167 This command tells LilyPond that the following piece of music must
168 be played twice; @code{"volta"} means that volta brackets should be used
169 for alternatives---if there were any.
175 The subject of the repeat is again sequential music. Since
176 @code{\sequential} is such a common construct, a shorthand is provided:
177 just leave off @code{\sequential}, and the result is the same.
183 This is a note with pitch @code{d} (determined up to octaves). The
184 relative music was started with a @code{c''}, so the real pitch of this
185 note is @code{d''}. The @code{4} designates the duration of the note
186 (it is a quarter note).
192 These are notes with pitch @code{a} and @code{b}. Because their
193 duration is the same as the @code{g}, there is no need to enter the
194 duration (You may enter it anyway, e.g. @code{a4 b4})
200 Three more notes. The `@code{|}' character is a `bar check'. When
201 processing the music, LilyPond will verify that bar checks are found at
202 the start of a measure. This can help you track down errors.
204 So far, no notes were chromatically altered. Here is the first one
205 that is: @code{fis}. Lilypond by default uses Dutch note names, and
206 ``Fis'' is the Dutch note name for ``F sharp''. However, there is no
207 sharp sign in the output. The program keeps track of key signatures,
208 and will only print accidentals if they are needed.
214 LilyPond guesses were beams can be added to eighth and shorter notes.
215 In this case, a beam over 4 eighths is added.
218 c4 d8( )c b a( )b4 c8 b a g |
221 The next line shows how to make a slur:
222 the beginning and ending note of the slur is marked with an opening and
223 closing parenthesis respectively. In the line shown above, this is
224 done for two slurs. Slur markers (parentheses) are put between
231 Automatic beaming can be overridden by inserting beam marks
232 (brackets). Brackets are put around the notes you want beamed.
238 A duration with augmentation dot is notated
239 with the duration number followed by a period.
245 This ends the sequential music to be repeated. LilyPond will typeset
252 This line shows that Lily will print an accidental if that is
253 needed: the first C sharp of the bar will be printed with an accidental,
254 the second one without.
257 a8-. b-. cis-. d-. e-. fis-.
260 You can enter articulation signs either in a verbose form using a
261 shorthand. Here we demonstrate the shorthand: it is formed by a dash
262 and the character for the articulation to use, e.g. `@code{-.}' for
263 staccato as shown above.
270 Rests are denoted by the special notename `@code{r}'. You can also enter
271 an invisible rest by using the special notename `@code{s}'.
277 All articulations have a verbose form, like @code{\fermata}. The
278 command `@code{\fermata}' is not part of the core of the language (most
279 of the other discussed elements are), but it is a shorthand for a more
280 complicated description of a fermata. @code{\fermata} names that
281 description and is therefore called an @emph{identifier}.
296 This specifies a conversion from music to notation output. Most of
297 the details of this conversions (font sizes, dimensions, etc.) have
298 been taken care of, but to fit the output in this document, it has
299 to be smaller. We do this by setting the line width to 14 centimeters
300 (approximately 6 inches).
306 The last brace ends the @code{\score} block.
308 There are two things to note here. The format contains musical
309 concepts like pitches and durations, instead of symbols and positions:
310 the input format tries to capture the meaning of @emph{music}, and not
311 notation. Second, the format tries to be @emph{context-free}:
312 a note will sound the same regardless of the current time signature,
315 The purpose of LilyPond is explained informally by the term `music
316 typesetter'. This is not a fully correct name: not only does the
317 program print musical symbols, it also makes esthetic decisions. All
318 symbols and their placement is @emph{generated} from a high-level musical
319 description. In other words, LilyPond would be best
320 described by `music compiler' or `music to notation compiler'.
325 @node Lyrics and chords
326 @section Lyrics and chords
328 In this section we show how to typeset a song of unknown
329 origin.@footnote{The author would welcome information about the origin
334 title = "The river is flowing";
335 composer = "Traditional (?)";
337 \include "paper16.ly"
338 melody = \notes \relative c' @{
342 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
343 c4 c8 d [es () d] c4 | d4 es8 d c4.
348 The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
349 ri -- ver is flo -- wing down to the sea.
352 accompaniment =\chords @{
354 c2:3- f:3-.7 d:min es4 c8:min r8
355 c2:min f:min7 g:7^3.5 c:min @}
360 \context ChordNames \accompaniment
363 \context Staff = mel @{
364 \property Staff.noAutoBeaming = ##t
365 \property Staff.automaticMelismata = ##t
368 \context Lyrics \text
370 \midi @{ \tempo 4=72;@}
371 \paper @{ linewidth = 10.0\cm; @}
376 The result would look this@footnote{The titling and font size shown
377 may differ, since the titling in this document is not generated by
380 @center @strong{The river is flowing}
385 title = "The river is flowing";
386 composer = "Traditional (?)";
388 \include "paper16.ly"
389 melody = \notes \relative c' {
393 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
394 c4 c8 d [es () d] c4 | d4 es8 d c4.
399 The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
400 ri -- ver is flo -- wing down to the sea.
403 accompaniment =\chords {
405 c2:3- f:3-.7 d:min es4 c8:min r8
406 c2:min f:min7 g:7^3.5 c:min }
411 \context ChordNames \accompaniment
414 \context Staff = mel {
415 \property Staff.noAutoBeaming = ##t
416 \property Staff.automaticMelismata = ##t
419 \context Lyrics \text
421 \midi { \tempo 4=72;}
422 \paper { linewidth = 10.0\cm; }
426 Again, we will dissect the file line by line.
432 Information about the music you are about to typeset goes into a
433 @code{\header} block. The information in this block is not used by
434 LilyPond, but it is included in the output. @file{ly2dvi} uses this
435 information to print titles above the music.
438 title = "The river is flowing";
439 composer = "Traditional (?)";
441 the @code{\header} block contains assignments. An assignment starts
442 with a string. (which is unquoted, in this case). Then comes the
443 equal sign `@code{=}'. After the equal sign comes the expression you
444 want to store. In this case, you want to put in strings. The
445 information has to be quoted here, because it contains spaces. Each
446 assignment is finished with a semicolon.
449 \include "paper16.ly"
452 Smaller size for inclusion in a book.
455 melody = \notes \relative c' @{
458 The structure of the file will be the same as the previous one, a
459 @code{\score} block with music in it. To keep things readable, we will
460 give names to the different parts of music, and use the names to
461 construct the music within the score block.
467 The piece starts with an anacrusis of one eighth.
471 The key is C minor: we have three flats.
475 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
476 c4 c8 d [es () d] c4 | d4 es8 d c4.
481 We use explicit beaming. Since this is a song, we will turn automatic
482 beams off, and use explicit beaming where needed.
488 This ends the definition of @code{melody}. Note that there are no
489 semicolons after assignments at top level.
495 Another identifier assignment. This one is for the lyrics.
496 Lyrics are formed by syllables that have duration, and not by
497 notes. To make LilyPond parse words as syllables, switch it into
498 lyrics mode with @code{\lyrics}. Again, the brace after @code{\lyrics}
499 is a shorthand for @code{\sequential @{}.
502 The4 ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
503 ri- ver is flo- __ wing down to the sea.
507 The syllables themselves are separated by spaces. You can get syllable
508 extenders by entering `@code{__}', and centered hyphens with
509 `@code{-}@code{-}'. We enter the syllables as if they are all quarter notes
510 in length (hence the @code{4}), and use a feature to align the
511 syllables to the music (which obviously isn't all quarter notes.)
514 accompaniment =\chords @{
517 We'll put chords over the music. There is a special mode (analogous
518 to @code{\lyrics} and @code{\notes} mode) where you can give the names
519 of the chords you want, instead of the notes comprising the chord.
525 There is no accompaniment during the anacrusis.
531 A chord is started by the tonic of the chord. The
532 first one lasts a half note. An unadorned note creates a major
533 triad, while a minor triad is wanted. @code{3-} modifies the third to
534 be small. @code{7} modifies (adds) a seventh, which is small by default
535 to create the @code{f a c es} chord. Multiple modifiers must be
542 Some modifiers have predefined names, eg. @code{min} is the same as
543 @code{3-}, so @code{d-min} is a minor @code{d} chord.
546 c2:min f:min7 g:7^3.5 c:min @}
549 A named modifier @code{min} and a normal modifier @code{7} do not have
550 to be separated by a dot. Tones from a chord are removed with chord
551 subtractions. Subtractions are started with a caret, and they are
552 also separated by dots. In this example, @code{g:7^3.5} produces a
553 minor seventh. The brace ends the sequential music.
560 We assemble the music in the @code{\score} block. Melody, lyrics and
561 accompaniment have to sound at the same time, so they should be
562 @code{\simultaneous}.
568 Chord mode generates notes grouped in @code{\simultaneous} music. If
569 you remove the comment sign, you can see the chords in normal
570 notation: they will be printed as note heads on a separate
574 \context ChordNames \accompaniment
577 Normally, the notes that you enter are transformed into note heads.
578 The note heads alone make no sense, they need surrounding information:
579 a key signature, a clef, staff lines, etc. They need @emph{context}. In
580 LilyPond, these symbols are created by objects called `interpretation
581 contexts'. Interpretation contexts only exist during a run of
582 LilyPond. Interpretation contexts that are for printing music (as
583 opposed to playing music) are called `notation contexts'.
585 By default, LilyPond will create a Staff context for you. If you
586 removed the @code{%} sign in the previous line, you would see that
589 We don't want default contexts here, because we want chord names, not
590 note heads. An interpretation context can also created upon explicit
591 request. The keyword for such a request is @code{\context}. It takes
592 two arguments. The first is the name of an interpretation context.
593 The name is a string, it can be quoted with double quotes). The
594 second argument is the music that should be interpreted in this
595 context. For the previous line, we could have written @code{\context
596 Staff \accompaniment}, and get the same effect.
602 The lyrics need to be aligned with the melody. This is done by
603 combining both with @code{\addlyrics}. @code{\addlyrics} takes two
604 pieces of music (usually a melody and lyrics, in that order) and
605 aligns the syllables of the second piece under the notes of the
606 first piece. If you would reverse the order, the notes would be
607 aligned on the lyrics, which is not very useful. (Besides, it looks
611 \context Staff = mel @{
614 This is the argument of @code{\addlyrics}. We instantiate a
615 @code{Staff} context explicitly: should you chose to remove the comment
616 before the ``note heads'' version of the accompaniment, the
617 accompaniment will be on a nameless staff. The melody has to be on a
618 different staff as the accompaniment. This is accomplished by giving
619 the melody staff a different name.
622 \property Staff.noAutoBeaming = ##t
625 An interpretation context has variables that tune its behaviour. One
626 of the variables is @code{noAutoBeaming}. If set and non-zero (i.e.,
627 true) LilyPond will not try to put automatic beaming on the current
631 \property Staff.automaticMelismata = ##t
634 Similarly, we don't want to print a syllable when there is
635 a slur. This sets up the Staff context to signal slurs while
636 @code{\addlyrics} is processed.
643 Finally, we put the melody on the current staff. Note that the
644 @code{\property} directives and @code{\melody} are grouped in sequential
645 music, so the property settings are done before the melody is
649 \context Lyrics \text
652 The second argument of @code{\addlyrics} is the text. The text also
653 should not land on a Staff, but on a interpretation context for
654 syllables, extenders, hyphens etc. This context is called
661 This ends @code{\simultaneous}.
664 \midi @{ \tempo 4=72;@}
667 This makes the music go to a MIDI file. MIDI is great for
668 checking music you enter. You listen to the MIDI file: if you hear
669 something unexpected, it's probably a typing error. @code{\midi} is an
670 `output definition', a declaration that specifies how to output music
671 analogous to @code{\paper @{ @}}. You can specify the tempo using the
672 @code{\tempo} command, in this case the tempo of quarter notes is set
673 to 72 beats per minute.
676 \paper @{ linewidth = 10.0\cm; @}
679 We also want notation output. The linewidth is short so the piece
680 will be set in two lines.
689 @section More movements
691 You probably ran @file{ly2dvi} on the last example, and ended up with a
692 viewable @file{.dvi} file. However, between there are a few steps of
693 which LilyPond is only one. To enhance your understanding of what's
694 happening under the hood when you run ly2dvi, we explain what programs
697 @code{ly2dvi} is a program that calls a number of programs in sequence.
698 The first thing it does, is running LilyPond on the input file. After
699 some calculations, lily comes up with a @file{.tex} file. The contents
700 of this file are very low-level instructions.
702 For example, if you'd put the following in a file called
707 \header @{ title = "Two miniatures"; @}
709 #(set! point-and-click #t)
728 The result should look somewhat like this@footnote{The titling in this
729 manual was not generated by ly2dvi, so details will differ.}
731 @center @strong{Two miniatures}
759 This file is produced by ly2dvi in a few stages, with the help of text
760 formatting tools. LilyPond produces two output files, @file{layout.tex}
761 and @file{layout-1.tex}. They both look like this:
765 \placebox@{-5 \outputscale @}%
766 @{ 8.7229 \outputscale @}%
767 @{\magfontWXGEomMMBo\char90 @}%
769 \placebox@{-4 \outputscale @}%
770 @{ 81.0647 \outputscale @}%
774 @file{ly2dvi} analyses the progress indication that LilyPond spews out,
775 and generates a file called @file{layout_ly1.tex}. This file contains
776 formatting instructions for the title and page layout. A fragment might
780 \geometry@{width=540.602362pt,headheight=2mm, ...
781 \renewcommand@{\@@oddfoot@}@{\parbox@{\textwidth@}@{\mbox@{@} ...
783 \lilypondtitle@{foo@}%
789 @file{ly2dvi} runs it through LaTeX. LaTeX is a text-formatting system
790 built on top of @TeX{}. It's very popular in the academic world. If LaTeX
791 is successful, this will produce a @file{.dvi} file, containing both the
792 titling and notes. @code{ly2dvi} completes its task by deleting the two
793 temporary files, leaving only @file{layout.dvi}.
795 Next, now we'll look at the examples line by line to explain new things.
800 Lilypond and its language are still under development, and occasionally,
801 details of the syntax are changed. This fragment indicates for which
802 version the input file was written. When you compile this file, the
803 version number will be checked, and you will get a warning when the file
806 This version number is also used by the @code{convert-ly} program (See
807 @ref{convert-ly}), which uses it update the file to the latest lily
811 \header @{ title = "Two miniatures"; @}
813 This sets the titling information for the entire file.
816 #(set! point-and-click #t)
819 Editing input files can be quite complicated if you're working with
820 large files: if you're digitizing existing music, you have to
821 synchronize the .ly file, the sheet music on your lap and the sheet
822 music on the screen. The point-and-click mechanism makes it easy to
823 find the origin of an error in the .ly file: @footnote{This feature is
824 presently only available on X-windows using a patched version of xdvi
825 and emacs} when you view the file with Xdvi and click on a note using
826 control-right button, [checkme], you editor will jump to the spot where
827 that note was entered.
829 More information is in in @ref{Point and click}
835 The @code{\score} blocks that follow in the file, don't have
836 @code{\paper} sections, so the settings of this block are substituted: A
837 paper block, at top-level, i.e. not in a @code{\score} block sets the
846 The variable @code{linewidth} normally sets the length of the systems on
847 the page. However, a negative value has a special meaning here. If
848 @code{linewidth} is less than 0, no line breaks are inserted into the
849 score, and the spacing is set to natural length: a short phrase takes up
850 little space, a longer phrase more space.
857 In previous examples, notes were specified in relative octaves,
858 i.e. each note was put in the octave that would put it closest to its
859 predecessor. Besides relative, there is also absolute octave
860 specification, and it is turned on by default. In this input mode, the
861 central C is denoted by @code{c'}. Going down, you get @code{c}
862 @code{c,} @code{c,,} etc. Going up, you get @code{c''} @code{c'''} etc.
864 When you're copying music from existing sheet music, relative octaves
865 are probably the easiest to use: it's less typing work and errors are
866 easily spotted. However, if you write LilyPond input, either by hand
867 (ie. composing) or by computer, absolute octaves is probably less work.
874 The @code{\header} is normally at the top of the file, where it sets
875 values for the rest of the file. If you want to typeset different pieces
876 from one file (eg. if there are multiple movements, or if you're making
877 a etude-book), you can put different @code{\score}
878 blocks into the input file. ly2dvi will assemble all LilyPond
879 output files into a big document. The contents of \header blocks
880 specified within each score, are used for the titling of each movement.
885 For example, the Opus number is put at the right, and the piece string
893 Our third subject is a piece of piano music. The fragment in the input
894 file is a piano reduction of the G major Sinfonia by Giovanni Battista
895 Sammartini. It was composed around 1740.
898 \include "paper16.ly";
900 stemdown = \property Voice.Stem \override #'direction = #-1
901 stemup = \property Voice.Stem \override #'direction = #1
902 stemboth = \property Voice.Stem \revert #'direction
904 viola = \notes \relative c' \context Voice = viola {
911 oboes = \notes \relative c'' \context Voice = oboe {
912 \stemup s4 g8. b,16 c8 r <e'8.-\p g> <f16 a>
913 \grace <e8( g> <d4 f> <c2 e> \times 2/3 { <d8 \< f> <e g> <f a> }
915 { \times 2/3 { a8 g c } \! c2 }
916 \context Voice = oboeTwo {
919 \property Grace.Stem \override #'direction = #-1
924 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |
925 [<d ( f> < )f8. a>] <)b,8 d> r [<d16( f> <f8. )a>] <b,8 d> r |
926 [<c16( e> < )e8. g>] <c8 e,>
929 hoomPah = \notes \repeat unfold 8 \transpose c' { c8 \stemdown c'8 \stemup }
931 bassvoices = \notes \relative c' {
933 \autochange Staff \hoomPah
934 \translator Staff = down
935 \stemdown [c8 c'8] r4
937 < {\stemup r2 <e4 c'> <c8 g'> }
938 \context Voice = reallyLow {\stemdown g2 ~ | g4 c8 } >
942 \context PianoStaff \notes <
943 \context Staff = up < \time 2/2;
947 \context Staff = down < \time 2/2; \clef bass;
954 linewidth = 15.0 \cm; }
958 If it looks like incomprehensible gibberish to you, then you are right.
959 This example has been doctored this example to have as many quirks as
963 stemdown = \property Voice.Stem \override #'direction = #-1
964 stemup = \property Voice.Stem \override #'direction = #1
965 stemboth = \property Voice.Stem \revert #'direction
968 [explain grob push/pop]
971 viola = \notes \relative c' \context Voice = viola @{
973 In this example, you can see multiple parts on a staff. Each part is
974 associated with one notation context. This notation context handles
975 stems and dynamics (among others). The name of this context is
976 @code{Voice}. For each part we have to make sure that there is
977 precisely one Voice context.
981 @code{<} and @code{>} are short hands for @code{\simultaneous @{} and
982 @code{@}}. So the expression enclosed in @code{<} and @code{>} is a
983 chord. @code{\f} places a forte symbol under the chord.
993 Relative octaves work a little differently with chords. The starting
994 point for the note following a chord is the first note of the chord. So
995 the @code{g} gets an octave up quote: it is a fifth above the starting
996 note of the previous chord (the central C).
1001 @code{s} is a `spacer' rest. It does not print anything, but it does
1002 have the duration of a rest.
1004 oboes = \notes \relative c'' \context Voice = oboe @{
1006 Now comes a part for two oboes. They play homophonically, so we
1007 print the notes as one voice that makes chords. Again, we insure that
1008 these notes are indeed processed by precisely one context with
1011 \stemUp s4 g8. b,16 c8 r <e'8.-\p g> <f16 a>
1013 @code{\stemUp} is an identifier reference. It is shorthand for
1014 @code{\property Voice.Stem \override #'direction = #1}. If possible, you
1015 should use predefined identifiers like these for setting properties.
1016 Your input will be less dependent upon the implementation of LilyPond.
1018 \grace <e8( g> < )d4 f> <c2 e>
1020 @code{\grace} introduces grace notes. It takes one argument, in this
1021 case a chord. The slur started on the @code{e} of the chord
1022 will be attached to the next note.@footnote{LilyPond will squirm
1023 about unended Slurs. In this case, you can ignore the warning}.
1027 Tuplets are made with the @code{\times} keyword. It takes two
1028 arguments: a fraction and a piece of music. The duration of the
1029 second argument is multiplied by the first argument. Triplets make
1030 notes occupy 2/3 of their notated duration, so in this case the
1033 @{ <d8 \< f> <e g> <f a> @}
1035 The piece of music to be `tripletted' is sequential music containing
1036 three notes. On the first chord (the @code{d}), a crescendo is started
1041 At this point, the homophonic music splits into two rhythmically
1042 different parts. We can't use a sequence of chords to enter this, so
1043 we make a `chord' of sequences to do it. We start with the upper
1044 voice, which continues with upward stems:
1046 @{ \times 2/3 @{ a8 g c @} \! c2 @}
1048 The crescendo is ended at the half note by the escaped exclamation
1051 \context Voice = oboeTwo @{
1054 We can't share stems with the other voice, so we have to create a new
1055 @code{Voice} context. We give it the name @code{oboeTwo} to distinguish
1056 it from the other context. Stems go down in this voice.
1060 When a grace section is processed, a @code{Grace} context is
1061 created. This context acts like a miniature score of its own. It has
1062 its own time bookkeeping, and you can make notes, beams, slurs
1063 etc. Here we fiddle with a property and make a beam. The argument of
1064 @code{\grace} is sequential music.
1067 \property Grace.Stem \override #'direction = #-1
1071 Normally, grace notes are always stem up, but in this case, the upper
1072 voice interferes. We set the stems down here.
1074 As far as relative mode is concerned, the previous note is the
1075 @code{c'''2} of the upper voice, so we have to go an octave down for
1082 This ends the two-part section.
1085 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |
1087 @code{\stemBoth} ends the forced stem directions. From here, stems are
1088 positioned as if it were single part music.
1090 The bass has a little hoom-pah melody to demonstrate parts switching
1091 between staffs. Since it is repetitive, we use repeats:
1093 hoomPah = \notes \repeat unfold 8
1099 Transposing can be done with @code{\transpose}. It takes two
1100 arguments; the first specifies what central C should be transposed to.
1101 The second is the to-be-transposed music. As you can see, in this
1102 case, the transposition is a no-op, as central C would be transposed to
1105 The purpose of this no-op is circumventing relative mode. Relative mode
1106 can not be used in conjunction with transposition, so relative mode will
1107 leave the contents of @code{\hoomPah} alone. We can use it without
1108 having to worry about getting the motive in a wrong octave.
1110 bassvoices = \notes \relative c' @{
1112 \autochange Staff \hoomPah
1114 Entering the bass part is easy: the hoomPahHoomPah variable is
1115 repeated four times; @code{unfold} means that all four repetitions
1116 should be written out.
1119 \translator Staff = down
1123 \context Voice = reallyLow @{\stemDown g2 ~ | g4 c8 @} >
1125 After skipping some lines, we see @code{~}. This mark makes ties.
1129 For piano music, a special context is needed to get cross staff
1130 beaming right. It is called @code{PianoStaff}.
1132 \context Staff = bottom < \time 2/2; \clef bass;
1134 The bottom staff must have a different clef.
1138 To make some more room on the line, the first (in this case the only)
1139 line is not indented. The line still looks very cramped, but that is due
1140 to the page layout of this document.
1146 * Piano I: autochange, simple chords, arpeggio, glissando, tuplets
1147 unfolded repeat, space rests.
1149 * Piano II: property push/pop, grace notes, multiple voices,
1150 dynamics, stem up/stem down,
1152 * Orchestral: demonstrate Hara-Kiri, part combining, part extraction,
1153 scores, transposition, instrument names,
1157 @node end of tutorial
1160 That's all folks. From here, you can either try fiddling with input
1161 files, or you can read the reference manual.