1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @node Example templates
3 @appendix Example templates
5 This section of the manual contains templates with the LilyPond score
6 already set up for you. Just add notes, run LilyPond, and enjoy
7 beautiful printed scores!
9 @c bad node name for ancient notation to avoid confict
15 * Ancient notation templates::
17 * Lilypond-book templates::
22 @appendixsec Single staff
23 @appendixsubsec Notes only
25 The first example gives you a staff with notes, suitable for a solo
26 instrument or a melodic fragment. Cut and paste this into a file,
27 add notes, and you're finished!
29 @lilypond[quote,verbatim,ragged-right]
31 melody = \relative c' {
46 @appendixsubsec Notes and lyrics
48 The next example demonstrates a simple melody with lyrics. Cut and
49 paste, add notes, then words for the lyrics. This example turns off
50 automatic beaming, which is common for vocal parts. If you want to use
51 automatic beaming, you'll have to change or comment out the relevant
54 @lilypond[quote,verbatim,ragged-right]
56 melody = \relative c' {
74 \new Lyrics \lyricsto "one" \text
81 @appendixsubsec Notes and chords
83 Want to prepare a lead sheet with a melody and chords? Look no further!
85 @lilypond[quote,verbatim,ragged-right]
87 melody = \relative c' {
96 harmonies = \chordmode {
97 c4:m f:min7 g:maj c:aug d2:dim b:sus
103 \set chordChanges = ##t
114 @appendixsubsec Notes, lyrics, and chords.
116 This template allows you to prepare a song with melody, words, and chords.
118 @lilypond[quote,verbatim,ragged-right]
120 melody = \relative c' {
132 harmonies = \chordmode {
139 \set chordChanges = ##t
146 \new Lyrics \lyricsto "one" \text
153 @node Piano templates
154 @appendixsec Piano templates
155 @appendixsubsec Solo piano
157 Here is a simple piano staff.
159 @lilypond[quote,verbatim,ragged-right]
161 upper = \relative c'' {
169 lower = \relative c {
179 \set PianoStaff.instrumentName = "Piano "
180 \new Staff = "upper" \upper
181 \new Staff = "lower" \lower
188 @appendixsubsec Piano and melody with lyrics
190 Here is a typical song format: one staff with the melody and lyrics, with
191 piano accompaniment underneath.
193 @lilypond[quote,verbatim,ragged-right]
195 melody = \relative c'' {
207 upper = \relative c'' {
215 lower = \relative c {
229 \new Lyrics \lyricsto mel \text
232 \new Staff = "upper" \upper
233 \new Staff = "lower" \lower
237 \context { \RemoveEmptyStaffContext }
244 @appendixsubsec Piano centered lyrics
246 Instead of having a full staff for the melody and lyrics, you can place
247 the lyrics between the piano staff (and omit the separate melody staff).
249 @lilypond[quote,verbatim,ragged-right]
251 upper = \relative c'' {
259 lower = \relative c {
273 \new Staff = upper { \new Voice = "singer" \upper }
274 \new Lyrics \lyricsto "singer" \text
281 \context { \GrandStaff \accepts "Lyrics" }
282 \context { \Lyrics \consists "Bar_engraver" }
289 @appendixsubsec Piano centered dynamics
291 Many piano scores have the dynamics centered between the two
292 staffs. This requires a bit of tweaking to implement, but
293 since the template is right here, you don't have to do the
296 @lilypond[quote,verbatim,ragged-right]
298 upper = \relative c'' {
306 lower = \relative c {
320 s2\sustainDown s2\sustainUp
325 \new Staff = "upper" \upper
326 \new Dynamics = "dynamics" \dynamics
327 \new Staff = "lower" <<
331 \new Dynamics = "pedal" \pedal
335 \type "Engraver_group"
337 \alias Voice % So that \cresc works, for example.
338 \consists "Output_property_engraver"
340 \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
341 pedalSustainStrings = #'("Ped." "*Ped." "*")
342 pedalUnaCordaStrings = #'("una corda" "" "tre corde")
344 \consists "Piano_pedal_engraver"
345 \consists "Script_engraver"
346 \consists "Dynamic_engraver"
347 \consists "Text_engraver"
349 \override TextScript #'font-size = #2
350 \override TextScript #'font-shape = #'italic
351 \override DynamicText #'extra-offset = #'(0 . 2.5)
352 \override Hairpin #'extra-offset = #'(0 . 2.5)
354 \consists "Skip_event_swallow_translator"
356 \consists "Axis_group_engraver"
361 \override VerticalAlignment #'forced-distance = #7
367 \new Staff = "upper" << \upper \dynamics >>
368 \new Staff = "lower" << \lower \dynamics >>
369 \new Dynamics = "pedal" \pedal
373 \type "Performer_group"
375 \consists "Piano_pedal_performer"
387 @appendixsec String quartet
388 @appendixsubsec String quartet
390 This template demonstrates a string quartet. It also uses a @code{\global}
391 section for time and key signatures.
393 @lilypond[quote,verbatim,ragged-right]
401 violinOne = \new Voice { \relative c''{
402 \set Staff.instrumentName = "Violin 1 "
407 violinTwo = \new Voice { \relative c''{
408 \set Staff.instrumentName = "Violin 2 "
413 viola = \new Voice { \relative c' {
414 \set Staff.instrumentName = "Viola "
420 cello = \new Voice { \relative c' {
421 \set Staff.instrumentName = "Cello "
430 \new Staff << \global \violinOne >>
431 \new Staff << \global \violinTwo >>
432 \new Staff << \global \viola >>
433 \new Staff << \global \cello >>
440 @appendixsubsec String quartet parts
442 The previous example produces a nice string quartet, but what if you
443 needed to print parts? This template demonstrates how to use the
444 @code{\tag} feature to easily split a piece into individual parts.
446 You need to split this template into separate files; the filenames
447 are contained in comments at the beginning of each file. @code{piece.ly}
448 contains all the music definitions. The other files -- @code{score.ly},
449 @code{vn1.ly}, @code{vn2.ly}, @code{vla.ly}, and
450 @code{vlc.ly} -- produce the appropiate part.
461 Violinone = \new Voice { \relative c''{
462 \set Staff.instrumentName = "Violin 1 "
466 \bar "|." }} %*********************************
467 Violintwo = \new Voice { \relative c''{
468 \set Staff.instrumentName = "Violin 2 "
472 \bar "|." }} %*********************************
473 Viola = \new Voice { \relative c' {
474 \set Staff.instrumentName = "Viola "
479 \bar "|." }} %*********************************
480 Cello = \new Voice { \relative c' {
481 \set Staff.instrumentName = "Cello "
486 \bar "|."}} %**********************************
490 \tag #'score \tag #'vn1 \new Staff { << \global \Violinone >> }
491 \tag #'score \tag #'vn2 \new Staff { << \global \Violintwo>> }
492 \tag #'score \tag #'vla \new Staff { << \global \Viola>> }
493 \tag #'score \tag #'vlc \new Staff { << \global \Cello>> }
502 #(set-global-staff-size 14)
504 \new StaffGroup \keepWithTag #'score \music
514 \keepWithTag #'vn1 \music
523 \keepWithTag #'vn2 \music
532 \keepWithTag #'vla \music
541 \keepWithTag #'vlc \music
547 @node Vocal ensembles
548 @appendixsec Vocal ensembles
550 @appendixsubsec SATB vocal score
552 Here is a standard four-part SATB vocal score. With larger ensembles,
553 it's often useful to include a section which is included in all
554 parts. For example, the time signature and key signatures are almost
555 always the same for all parts.
557 @lilypond[quote,verbatim,ragged-right]
564 sopMusic = \relative c'' {
567 sopWords = \lyricmode {
571 altoMusic = \relative c' {
574 altoWords =\lyricmode {
578 tenorMusic = \relative c' {
581 tenorWords = \lyricmode {
585 bassMusic = \relative c {
588 bassWords = \lyricmode {
594 \new Lyrics = sopranos { s1 }
595 \new Staff = women <<
597 "sopranos" { \voiceOne << \global \sopMusic >> }
599 "altos" { \voiceTwo << \global \altoMusic >> }
601 \new Lyrics = "altos" { s1 }
602 \new Lyrics = "tenors" { s1 }
606 "tenors" { \voiceOne <<\global \tenorMusic >> }
608 "basses" { \voiceTwo <<\global \bassMusic >> }
610 \new Lyrics = basses { s1 }
612 \context Lyrics = sopranos \lyricsto sopranos \sopWords
613 \context Lyrics = altos \lyricsto altos \altoWords
614 \context Lyrics = tenors \lyricsto tenors \tenorWords
615 \context Lyrics = basses \lyricsto basses \bassWords
620 % a little smaller so lyrics
621 % can be closer to the staff
623 \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
630 @appendixsubsec SATB vocal score and automatic piano reduction
632 This template adds an automatic piano reduction to the SATB vocal
633 score. This demonstrates one of the strengths of LilyPond -- you
634 can use a music definition more than once. If you make any changes
635 to the vocal notes (say, tenorMusic), then the changes will also
636 apply to the piano reduction.
638 @lilypond[quote,verbatim,ragged-right]
645 sopMusic = \relative c'' {
648 sopWords = \lyricmode {
652 altoMusic = \relative c' {
655 altoWords =\lyricmode {
659 tenorMusic = \relative c' {
662 tenorWords = \lyricmode {
666 bassMusic = \relative c {
669 bassWords = \lyricmode {
676 \new Lyrics = sopranos { s1 }
677 \new Staff = women <<
679 "sopranos" { \voiceOne << \global \sopMusic >> }
681 "altos" { \voiceTwo << \global \altoMusic >> }
683 \new Lyrics = "altos" { s1 }
684 \new Lyrics = "tenors" { s1 }
688 "tenors" { \voiceOne <<\global \tenorMusic >> }
690 "basses" { \voiceTwo <<\global \bassMusic >> }
692 \new Lyrics = basses { s1 }
694 \context Lyrics = sopranos \lyricsto sopranos \sopWords
695 \context Lyrics = altos \lyricsto altos \altoWords
696 \context Lyrics = tenors \lyricsto tenors \tenorWords
697 \context Lyrics = basses \lyricsto basses \bassWords
701 \set Staff.printPartCombineTexts = ##f
703 << \global \sopMusic >>
704 << \global \altoMusic >>
708 \set Staff.printPartCombineTexts = ##f
710 << \global \tenorMusic >>
711 << \global \bassMusic >>
717 % a little smaller so lyrics
718 % can be closer to the staff
720 \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
726 @appendixsubsec SATB with aligned contexts
728 Here all the lyrics lines are placed using @code{alignAboveContext}
729 and @code{alignBelowContext}.
731 @lilypond[quote,verbatim,ragged-right]
738 sopMusic = \relative c'' {
741 sopWords = \lyricmode {
745 altoMusic = \relative c' {
748 altoWords =\lyricmode {
752 tenorMusic = \relative c' {
755 tenorWords = \lyricmode {
759 bassMusic = \relative c {
762 bassWords = \lyricmode {
768 \new Staff = women <<
770 "sopranos" { \voiceOne << \global \sopMusic >> }
772 "altos" { \voiceTwo << \global \altoMusic >> }
774 \new Lyrics \with {alignAboveContext=women} \lyricsto sopranos \sopWords
775 \new Lyrics \with {alignBelowContext=women} \lyricsto altos \altoWords
776 % we could remove the line about this with the line below, since we want
777 % the alto lyrics to be below the alto Voice anyway.
778 % \new Lyrics \lyricsto altos \altoWords
783 "tenors" { \voiceOne <<\global \tenorMusic >> }
785 "basses" { \voiceTwo <<\global \bassMusic >> }
788 \new Lyrics \with {alignAboveContext=men} \lyricsto tenors \tenorWords
789 \new Lyrics \with {alignBelowContext=men} \lyricsto basses \bassWords
790 % again, we could replace the line above this with the line below.
791 % \new Lyrics \lyricsto basses \bassWords
796 % a little smaller so lyrics
797 % can be closer to the staff
799 \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
807 \new Staff = women <<
809 "sopranos" { \voiceOne << \global \sopMusic >> }
811 "altos" { \voiceTwo << \global \altoMusic >> }
814 \new Lyrics \with {alignAboveContext=women} \lyricsto sopranos \sopWords
815 \new Lyrics \lyricsto altos \altoWords
820 "tenors" { \voiceOne <<\global \tenorMusic >> }
822 "basses" { \voiceTwo <<\global \bassMusic >> }
825 \new Lyrics \with {alignAboveContext=men} \lyricsto tenors \tenorWords
826 \new Lyrics \lyricsto basses \bassWords
831 % a little smaller so lyrics
832 % can be closer to the staff
834 \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
841 @c bad node name to avoid node name confict
842 @node Ancient notation templates
843 @appendixsec Ancient notation templates
845 @appendixsubsec Transcription of mensural music
847 When transcribing mensural music, an incipit at the beginning of the
848 piece is useful to indicate the original key and tempo. While today
849 musicians are used to bar lines in order to faster recognize rhythmic
850 patterns, bar lines were not yet invented during the period of
851 mensural music; in fact, the meter often changed after every few
852 notes. As a compromise, bar lines are often printed between the
853 staves rather than on the staves.
855 @lilypond[quote,verbatim,line-width=11.0\cm]
859 \set Score.skipBars = ##t
862 \once \override Score.SystemStartBracket #'transparent = ##t
863 \override Score.SpacingSpanner #'spacing-increment = #1.0 % tight spacing
866 \once \override Staff.TimeSignature #'style = #'neomensural
867 \override Voice.NoteHead #'style = #'neomensural
868 \override Voice.Rest #'style = #'neomensural
869 \set Staff.printKeyCancellation = ##f
870 \cadenzaOn % turn off bar lines
872 \once \override Staff.BarLine #'transparent = ##f
874 \skip 1*1 % need this extra \skip such that clef change comes
879 \revert Score.SpacingSpanner #'spacing-increment % CHECK: no effect?
880 \cadenzaOff % turn bar lines on again
881 \once \override Staff.Clef #'full-size-change = ##t
882 \set Staff.forceClef = ##t
885 \override Voice.NoteHead #'style = #'default
886 \override Voice.Rest #'style = #'default
888 % FIXME: setting printKeyCancellation back to #t must not
889 % occur in the first bar after the incipit. Dto. for forceClef.
890 % Therefore, we need an extra \skip.
892 \set Staff.printKeyCancellation = ##t
893 \set Staff.forceClef = ##f
895 \skip 1*7 % the actual music
897 % let finis bar go through all staves
898 \override Staff.BarLine #'transparent = ##f
906 \set Staff.instrumentName = "Discantus "
909 \clef "neomensural-c1"
911 \skip 1*8 % eight bars
921 \once \override NoteHead #'transparent = ##t c'1 |
926 discantusLyrics = \lyricmode {
942 \set Staff.instrumentName = "Altus "
945 \clef "neomensural-c3"
948 \skip 1*7 % seven bars
953 r2 g2. e4 fis g | % two bars
955 fis g4.( fis16 e fis4) |
957 \once \override NoteHead #'transparent = ##t g1 |
962 altusLyrics = \lyricmode {
967 Ju -- bi -- la -- te | % two bars
976 \set Staff.instrumentName = "Tenor "
979 \clef "neomensural-c4"
992 r2 d'2. d'4 b e' | % two bars
993 \once \override NoteHead #'transparent = ##t e'1 |
998 tenorLyrics = \lyricmode {
1003 Ju -- bi -- la -- te | % two bars
1010 \set Staff.instrumentName = "Bassus "
1014 r\maxima % eight bars
1025 \once \override NoteHead #'transparent = ##t e1 |
1030 bassusLyrics = \lyricmode {
1041 \new StaffGroup = choirStaff <<
1043 "discantusNotes" << \global \discantusNotes >>
1045 "discantusLyrics" \lyricsto discantusNotes { \discantusLyrics }
1047 "altusNotes" << \global \altusNotes >>
1049 "altusLyrics" \lyricsto altusNotes { \altusLyrics }
1051 "tenorNotes" << \global \tenorNotes >>
1053 "tenorLyrics" \lyricsto tenorNotes { \tenorLyrics }
1055 "bassusNotes" << \global \bassusNotes >>
1057 "bassusLyrics" \lyricsto bassusNotes { \bassusLyrics }
1064 \override BarLine #'transparent = ##t
1066 % incipit should not start with a start delimiter
1067 \remove "System_start_delimiter_engraver"
1073 \override Slur #'transparent = ##t
1075 % Comment in the below "\remove" command to allow line
1076 % breaking also at those barlines where a note overlaps
1077 % into the next bar. The command is commented out in this
1078 % short example score, but especially for large scores, you
1079 % will typically yield better line breaking and thus improve
1080 % overall spacing if you comment in the following command.
1081 %\remove "Forbid_line_break_engraver"
1088 @appendixsubsec Gregorian transcription template
1090 This example demonstrates how to do modern transcription of Gregorian
1091 music. Gregorian music has no measure, no stems; it uses only half and
1092 quarter noteheads, and special marks, indicating rests of different length.
1094 @lilypond[quote,verbatim,ragged-right]
1095 \include "gregorian-init.ly"
1098 chant = \relative c' {
1099 \set Score.timing = ##f
1100 f4 a2 \divisioMinima
1101 g4 b a2 f2 \divisioMaior
1102 g4( f) f( g) a2 \finalis
1105 verba = \lyricmode {
1106 Lo -- rem ip -- sum do -- lor sit a -- met
1111 \new Voice = "melody" {
1114 \new Lyrics = "one" \lyricsto melody \verba
1120 \remove "Time_signature_engraver"
1121 \remove "Bar_engraver"
1122 \override Stem #'transparent = ##t
1126 \override Stem #'length = #0
1138 @appendixsec Jazz combo
1140 This is a much more complicated template, for a jazz ensemble. Note that all
1141 instruments are notated in @code{\key c \major}. This refers to the key in
1142 concert pitch; LilyPond will automatically transpose the key if the music
1143 is within a @code{\transpose} section.
1145 @c TODO must clean up this jazz combo example
1146 @c - transpositions stated in names (ie "trumpet in Bb" or whatever)
1147 @c - one global section, instead of "global" (time) and "key"
1148 @c - does it need those wierd macros? sl, nsl, etc.
1149 @c - maybe ask Amelie Zapf to clean it up, or whether I should just
1150 @c make whatever changes I feel like.
1152 @c FIXME: produces a warning ; key change merge.
1153 @c The `line-width' argument is for the \header.
1155 @lilypond[quote,verbatim,ragged-right,line-width]
1165 "LilyPond example file by Amelie Zapf,"
1169 texidoc = "Jazz tune for combo
1170 (horns, guitar, piano, bass, drums)."
1173 #(set-global-staff-size 16)
1174 \include "english.ly"
1176 %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%
1179 \override NoteHead #'style = #'slash
1180 \override Stem #'transparent = ##t
1183 \revert NoteHead #'style
1184 \revert Stem #'transparent
1186 cr = \override NoteHead #'style = #'cross
1187 ncr = \revert NoteHead #'style
1189 %% insert chord name style stuff here.
1194 %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%
1200 Key = { \key c \major }
1202 % ############ Horns ############
1204 % ------ Trumpet ------
1205 trpt = \transpose c d \relative c'' {
1209 trpharmony = \transpose c' d {
1214 \set Staff.instrumentName = #"Trumpet"
1221 % ------ Alto Saxophone ------
1222 alto = \transpose c a \relative c' {
1226 altoharmony = \transpose c' a {
1231 \set Staff.instrumentName = #"Alto Sax"
1238 % ------ Baritone Saxophone ------
1239 bari = \transpose c a' \relative c {
1241 c1 c \sl d4^"Solo" d d d \nsl
1243 bariharmony = \transpose c' a \chordmode {
1244 \jzchords s1 s d2:maj e:m7
1248 \set Staff.instrumentName = #"Bari Sax"
1255 % ------ Trombone ------
1256 tbone = \relative c {
1260 tboneharmony = \chordmode {
1265 \set Staff.instrumentName = #"Trombone"
1272 % ############ Rhythm Section #############
1274 % ------ Guitar ------
1275 gtr = \relative c'' {
1277 c1 \sl b4 b b b \nsl c1
1279 gtrharmony = \chordmode {
1285 \set Staff.instrumentName = #"Guitar"
1292 %% ------ Piano ------
1293 rhUpper = \relative c'' {
1298 rhLower = \relative c' {
1304 lhUpper = \relative c' {
1309 lhLower = \relative c {
1318 \set Staff.midiInstrument = "acoustic grand"
1320 \new Voice = "one" \rhUpper
1321 \new Voice = "two" \rhLower
1327 \set Staff.midiInstrument = "acoustic grand"
1329 \new Voice = "one" \lhUpper
1330 \new Voice = "two" \lhLower
1336 \set PianoStaff.instrumentName = #"Piano"
1337 \new Staff = "upper" \PianoRH
1338 \new Staff = "lower" \PianoLH
1342 % ------ Bass Guitar ------
1343 Bass = \relative c {
1349 \set Staff.instrumentName = #"Bass"
1356 % ------ Drums ------
1358 hh4 <hh sn>4 hh <hh sn> hh <hh sn>4
1365 bd4 s bd s bd s bd s bd s bd s
1371 \set DrumStaff.instrumentName = #"Drums"
1372 \new DrumVoice { \voiceOne \up }
1373 \new DrumVoice { \voiceTwo \down }
1377 %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%
1381 \new StaffGroup = "horns" <<
1382 \new Staff = "trumpet" \trumpet
1383 \new Staff = "altosax" \altosax
1384 \new ChordNames = "barichords" \bariharmony
1385 \new Staff = "barisax" \barisax
1386 \new Staff = "trombone" \trombone
1389 \new StaffGroup = "rhythm" <<
1390 \new ChordNames = "chords" \gtrharmony
1391 \new Staff = "guitar" \guitar
1392 \new PianoStaff = "piano" \piano
1393 \new Staff = "bass" \bass
1394 \new DrumStaff { \drumContents }
1399 \context { \RemoveEmptyStaffContext }
1402 \override BarNumber #'padding = #3
1403 \override RehearsalMark #'padding = #2
1414 This isn't very useful, and only duplicates material in
1415 "global issues". And if this info changes, this section often
1418 @no de Other templates
1419 @se ction Other templates
1420 @su bsection All headers
1422 This template displays all available headers. Some of them are only
1423 used in the Mutopia project; they don't affect the printed output at
1424 all. They are used if you want the piece to be listed with different
1425 information in the Mutopia database than you wish to have printed on the
1426 music. For example, Mutopia lists the composer of the famous D major
1427 violin concerto as TchaikovskyPI, whereas perhaps you wish to print
1428 "Petr Tchaikowski" on your music.
1430 @ The `line-width' is for \header.
1431 @li lypond[quote,verbatim,ragged-right,line-width]
1434 dedication = "dedication"
1436 subtitle = "Subtitle"
1437 subsubtitle = "Subsubtitle"
1438 composer = "Composer (xxxx-yyyy)"
1442 instrument = "Instrument"
1443 arranger = "Arranger"
1445 texttranslator = "Translator"
1446 copyright = "public domain"
1448 % These are headers used by the Mutopia Project
1449 % http://www.mutopiaproject.org/
1451 mutopiacomposer = ""
1453 mutopiainstrument = ""
1454 date = "composer's dates"
1456 maintainer = "your name here"
1457 maintainerEmail = "your email here"
1458 maintainerWeb = "your home page"
1459 lastupdated = "2004/Aug/26"
1481 @node Lilypond-book templates
1482 @appendixsec Lilypond-book templates
1484 These templates are for use with @code{lilypond-book}. If you're not familiar
1485 with this program, please refer to @ref{LilyPond-book}.
1487 @appendixsubsec LaTeX
1489 You can include LilyPond fragments in a LaTeX document.
1492 \documentclass[]@{article@}
1514 @appendixsubsec Texinfo
1516 You can include LilyPond fragments in Texinfo; in fact, this entire manual
1517 is written in Texinfo.
1525 @@lilypond[verbatim,fragment,ragged-right]
1531 @@lilypond[verbatim,fragment,ragged-right]