1 @c -*- coding: latin-1; mode: texinfo; -*-
2 @node Example templates
3 @chapter 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::
18 * Lilypond-book templates::
24 @subsection Notes only
26 The first example gives you a staff with notes, suitable for a solo
27 instrument or a melodic fragment. Cut and paste this into a file,
28 add notes, and you're finished!
30 @lilypond[quote,verbatim,raggedright]
32 melody = \relative c' {
47 @subsection Notes and lyrics
49 The next example demonstrates a simple melody with lyrics. Cut and
50 paste, add notes, then words for the lyrics. This example turns off
51 automatic beaming, which is common for vocal parts. If you want to use
52 automatic beaming, you'll have to change or comment out the relevant
55 @lilypond[quote,verbatim,raggedright]
57 melody = \relative c' {
71 \context Voice = one {
75 \lyricsto "one" \new Lyrics \text
82 @subsection Notes and chords
84 Want to prepare a lead sheet with a melody and chords? Look no further!
86 @lilypond[quote,verbatim,raggedright]
88 melody = \relative c' {
97 harmonies = \chordmode {
98 c4:m f:min7 g:maj c:aug d2:dim b:sus
103 \context ChordNames {
104 \set chordChanges = ##t
107 \context Staff = one \melody
115 @subsection Notes, lyrics, and chords.
117 This template allows you to prepare a song with melody, words, and chords.
119 @lilypond[quote,verbatim,raggedright]
121 melody = \relative c' {
133 harmonies = \chordmode {
139 \context ChordNames {
140 \set chordChanges = ##t
143 \context Voice = one {
147 \lyricsto "one" \new Lyrics \text
150 \midi { \tempo 4=60 }
154 @node Piano templates
155 @section Piano templates
156 @subsection Solo piano
158 Here is a simple piano staff.
160 @lilypond[quote,verbatim,raggedright]
162 upper = \relative c'' {
170 lower = \relative c {
179 \context PianoStaff <<
180 \set PianoStaff.instrument = "Piano "
181 \context Staff = upper \upper
182 \context Staff = lower \lower
185 \midi { \tempo 4=60 }
189 @subsection Piano and melody with lyrics
191 Here is a typical song format: one staff with the melody and lyrics, with
192 piano accompaniment underneath.
194 @lilypond[quote,verbatim,raggedright]
196 melody = \relative c'' {
208 upper = \relative c'' {
216 lower = \relative c {
226 \context Voice = mel {
230 \lyricsto mel \new Lyrics \text
232 \context PianoStaff <<
233 \context Staff = upper \upper
234 \context Staff = lower \lower
238 \context { \RemoveEmptyStaffContext }
240 \midi { \tempo 4=60 }
245 @subsection Piano centered lyrics
247 Instead of having a full staff for the melody and lyrics, you can place
248 the lyrics between the piano staff (and omit the separate melody staff).
250 @lilypond[quote,verbatim,raggedright]
252 upper = \relative c'' {
260 lower = \relative c {
273 \context GrandStaff <<
274 \context Staff = upper {
275 \context Voice = singer \upper }
276 \lyricsto "singer" \new Lyrics \text
277 \context Staff = lower <<
283 \context { \GrandStaff \accepts "Lyrics" }
284 \context { \Lyrics \consists "Bar_engraver" }
286 \midi { \tempo 4=60 }
291 @subsection Piano centered dynamics
293 Many piano scores have the dynamics centered between the two
294 staffs. This requires a bit of tweaking to implement, but
295 since the template is right here, you don't have to do the
298 @lilypond[quote,verbatim,raggedright]
300 upper = \relative c'' {
308 lower = \relative c {
322 s2\sustainDown s2\sustainUp
326 \context PianoStaff <<
327 \context Staff=upper \upper
328 \context Dynamics=dynamics \dynamics
329 \context Staff=lower <<
333 \context Dynamics=pedal \pedal
337 \type "Engraver_group"
339 \alias Voice % So that \cresc works, for example.
340 \consists "Output_property_engraver"
342 minimumVerticalExtent = #'(-1 . 1)
343 pedalSustainStrings = #'("Ped." "*Ped." "*")
344 pedalUnaCordaStrings = #'("una corda" "" "tre corde")
346 \consists "Piano_pedal_engraver"
347 \consists "Script_engraver"
348 \consists "Dynamic_engraver"
349 \consists "Text_engraver"
351 \override TextScript #'font-size = #2
352 \override TextScript #'font-shape = #'italic
353 \override DynamicText #'extra-offset = #'(0 . 2.5)
354 \override Hairpin #'extra-offset = #'(0 . 2.5)
356 \consists "Skip_event_swallow_translator"
358 \consists "Axis_group_engraver"
363 \override VerticalAlignment #'forced-distance = #7
368 \context PianoStaff <<
369 \context Staff=upper << \upper \dynamics >>
370 \context Staff=lower << \lower \dynamics >>
371 \context Dynamics=pedal \pedal
375 \type "Performer_group"
377 \consists "Piano_pedal_performer"
389 @section String quartet
390 @subsection String quartet
392 This template demonstrates a string quartet. It also uses a @code{\global}
393 section for time and key signatures.
395 @lilypond[quote,verbatim,raggedright]
403 violinOne = \new Voice { \relative c''{
404 \set Staff.instrument = "Violin 1 "
409 violinTwo = \new Voice { \relative c''{
410 \set Staff.instrument = "Violin 2 "
415 viola = \new Voice { \relative c' {
416 \set Staff.instrument = "Viola "
422 cello = \new Voice { \relative c' {
423 \set Staff.instrument = "Cello "
432 \new Staff << \global \violinOne >>
433 \new Staff << \global \violinTwo >>
434 \new Staff << \global \viola >>
435 \new Staff << \global \cello >>
442 @subsection String quartet parts
444 The previous example produces a nice string quartet, but what if you
445 needed to print parts? This template demonstrates how to use the
446 @code{\tag} feature to easily split a piece into individual parts.
448 You need to split this template into separate files; the filenames
449 are contained in comments at the beginning of each file. @code{piece.ly}
450 contains all the music definitions. The other files -- @code{score.ly},
451 @code{vn1.ly}, @code{vn2.ly}, @code{vla.ly}, and
452 @code{vlc.ly} -- produce the appropiate part.
463 Violinone = \new Voice { \relative c''{
464 \set Staff.instrument = "Violin 1 "
468 \bar "|." }} %*********************************
469 Violintwo = \new Voice { \relative c''{
470 \set Staff.instrument = "Violin 2 "
474 \bar "|." }} %*********************************
475 Viola = \new Voice { \relative c' {
476 \set Staff.instrument = "Viola "
481 \bar "|." }} %*********************************
482 Cello = \new Voice { \relative c' {
483 \set Staff.instrument = "Cello "
488 \bar "|."}} %**********************************
492 \tag #'(score vn1) \new Staff { << \global \Violinone >> }
493 \tag #'(score vn2) \new Staff { << \global \Violintwo>> }
494 \tag #'(score vla) \new Staff { << \global \Viola>> }
495 \tag #'(score vlc) \new Staff { << \global \Cello>> }
504 #(set-global-staff-size 14)
506 \new StaffGroup \keepWithTag #'score \music
508 \midi { \tempo 4 = 60 }
516 \keepWithTag #'vn1 \music
525 \keepWithTag #'vn2 \music
534 \keepWithTag #'vla \music
543 \keepWithTag #'vlc \music
549 @node Vocal ensembles
550 @section Vocal ensembles
552 @subsection SATB vocal score
554 Here is a standard four-part SATB vocal score. With larger ensembles,
555 it's often useful to include a section which is included in all
556 parts. For example, the time signature and key signatures are almost
557 always the same for all parts.
559 @lilypond[quote,verbatim,raggedright]
566 sopMusic = \relative c'' {
569 sopWords = \lyricmode {
573 altoMusic = \relative c' {
576 altoWords =\lyricmode {
580 tenorMusic = \relative c' {
583 tenorWords = \lyricmode {
587 bassMusic = \relative c {
590 bassWords = \lyricmode {
595 \context ChoirStaff <<
596 \context Lyrics = sopranos { s1 }
597 \context Staff = women <<
599 sopranos { \voiceOne << \global \sopMusic >> }
601 altos { \voiceTwo << \global \altoMusic >> }
603 \context Lyrics = altos { s1 }
604 \context Lyrics = tenors { s1 }
605 \context Staff = men <<
608 tenors { \voiceOne <<\global \tenorMusic >> }
610 basses { \voiceTwo <<\global \bassMusic >> }
612 \context Lyrics = basses { s1 }
613 \context Lyrics = sopranos \lyricsto sopranos \sopWords
614 \context Lyrics = altos \lyricsto altos \altoWords
615 \context Lyrics = tenors \lyricsto tenors \tenorWords
616 \context Lyrics = basses \lyricsto basses \bassWords
621 % a little smaller so lyrics
622 % can be closer to the staff
623 \Staff minimumVerticalExtent = #'(-3 . 3)
630 @subsection 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,raggedright]
645 sopMusic = \relative c'' {
648 sopWords = \lyricmode {
652 altoMusic = \relative c' {
655 altoWords =\lyricmode {
659 tenorMusic = \relative c' {
662 tenorWords = \lyricmode {
665 bassMusic = \relative c {
668 bassWords = \lyricmode {
674 % a little smaller so lyrics
675 % can be closer to the staff
677 minimumVerticalExtent = #'(-3 . 3)
684 \context Lyrics = sopranos { s1 }
685 \context Staff = women <<
687 sopranos { \voiceOne << \global \sopMusic >> }
689 altos { \voiceTwo << \global \altoMusic >> }
691 \context Lyrics = altos { s1 }
692 \context Lyrics = tenors { s1 }
693 \context Staff = men <<
696 tenors { \voiceOne <<\global \tenorMusic >> }
698 basses { \voiceTwo <<\global \bassMusic >> }
700 \context Lyrics = basses { s1 }
701 \context Lyrics = sopranos \lyricsto sopranos \sopWords
702 \context Lyrics = altos \lyricsto altos \altoWords
703 \context Lyrics = tenors \lyricsto tenors \tenorWords
704 \context Lyrics = basses \lyricsto basses \bassWords
709 \set Staff.printPartCombineTexts = ##f
711 << \global \sopMusic >>
712 << \global \altoMusic >>
716 \set Staff.printPartCombineTexts = ##f
718 << \global \tenorMusic >>
719 << \global \bassMusic >>
726 @c bad node name to avoid node name confict
727 @node Ancient notation templates
728 @section Ancient notation templates
730 @subsection Transcription of mensural music
732 When transcribing mensural music, an incipit at the beginning of the
733 piece is useful to indicate the original key and tempo. While today
734 musicians are used to bar lines in order to faster recognize rhythmic
735 patterns, bar lines where not yet invented during the period of
736 mensural music; in fact, the meter often changed after every few
737 notes. As a compromise, bar lines are often printed between the
738 staves rather than on the staves.
740 @lilypond[quote,verbatim,linewidth=11.0\cm]
744 \set Score.skipBars = ##t
747 \once \override Score.SystemStartBracket #'transparent = ##t
748 \override Score.SpacingSpanner #'spacing-increment = #1.0 % tight spacing
751 \once \override Staff.TimeSignature #'style = #'neomensural
752 \override Voice.NoteHead #'style = #'neomensural
753 \override Voice.Rest #'style = #'neomensural
754 \set Staff.printKeyCancellation = ##f
755 \cadenzaOn % turn off bar lines
757 \once \override Staff.BarLine #'transparent = ##f
759 \skip 1*1 % need this extra \skip such that clef change comes
764 \revert Score.SpacingSpanner #'spacing-increment % CHECK: no effect?
765 \cadenzaOff % turn bar lines on again
766 \once \override Staff.Clef #'full-size-change = ##t
767 \set Staff.forceClef = ##t
770 \override Voice.NoteHead #'style = #'default
771 \override Voice.Rest #'style = #'default
773 % FIXME: setting printKeyCancellation back to #t must not
774 % occur in the first bar after the incipit. Dto. for forceClef.
775 % Therefore, we need an extra \skip.
777 \set Staff.printKeyCancellation = ##t
778 \set Staff.forceClef = ##f
780 \skip 1*7 % the actual music
782 % let finis bar go through all staves
783 \override Staff.BarLine #'transparent = ##f
791 \set Staff.instrument = "Discantus "
794 \clef "neomensural-c1"
796 \skip 1*8 % eight bars
806 \once \override NoteHead #'transparent = ##t c'1 |
811 discantusLyrics = \lyricmode {
827 \set Staff.instrument = "Altus "
830 \clef "neomensural-c3"
833 \skip 1*7 % seven bars
838 r2 g2. e4 fis g | % two bars
840 fis g4.( fis16 e fis4) |
842 \once \override NoteHead #'transparent = ##t g1 |
847 altusLyrics = \lyricmode {
852 Ju -- bi -- la -- te | % two bars
861 \set Staff.instrument = "Tenor "
864 \clef "neomensural-c4"
877 r2 d'2. d'4 b e' | % two bars
878 \once \override NoteHead #'transparent = ##t e'1 |
883 tenorLyrics = \lyricmode {
888 Ju -- bi -- la -- te | % two bars
895 \set Staff.instrument = "Bassus "
899 r\maxima % eight bars
910 \once \override NoteHead #'transparent = ##t e1 |
915 bassusLyrics = \lyricmode {
926 \context StaffGroup = choirStaff <<
928 discantusNotes << \global \discantusNotes >>
930 discantusLyrics \lyricsto discantusNotes { \discantusLyrics }
932 altusNotes << \global \altusNotes >>
934 altusLyrics \lyricsto altusNotes { \altusLyrics }
936 tenorNotes << \global \tenorNotes >>
938 tenorLyrics \lyricsto tenorNotes { \tenorLyrics }
940 bassusNotes << \global \bassusNotes >>
942 bassusLyrics \lyricsto bassusNotes { \bassusLyrics }
947 \override BarLine #'transparent = ##t
948 \remove "System_start_delimiter_engraver"
952 \override Slur #'transparent = ##t
963 This is a much more complicated template, for a jazz ensemble. Note that all
964 instruments are notated in @code{\key c \major}. This refers to the key in
965 concert pitch; LilyPond will automatically transpose the key if the music
966 is within a @code{\transpose} section.
968 @c TODO must clean up this jazz combo example
969 @c - transpositions stated in names (ie "trumpet in Bb" or whatever)
970 @c - one global section, instead of "global" (time) and "key"
971 @c - does it need those wierd macros? sl, nsl, etc.
972 @c - maybe ask Amelie Zapf to clean it up, or whether I should just
973 @c make whatever changes I feel like.
975 @c FIXME: produces a warning ; key change merge.
976 @c The `linewidth' argument is for the \header.
978 @lilypond[quote,verbatim,raggedright,linewidth]
986 tagline = "LilyPond example file by Amelie Zapf,
988 texidoc = "Jazz tune for combo
989 (horns, guitar, piano, bass, drums)."
992 #(set-global-staff-size 16)
993 \include "english.ly"
995 %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%
998 \override NoteHead #'style = #'slash
999 \override Stem #'transparent = ##t
1002 \revert NoteHead #'style
1003 \revert Stem #'transparent
1005 cr = \override NoteHead #'style = #'cross
1006 ncr = \revert NoteHead #'style
1008 %% insert chord name style stuff here.
1013 %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%
1019 Key = { \key c \major }
1021 % ############ Horns ############
1023 % ------ Trumpet ------
1024 trpt = \transpose c d \relative c'' {
1028 trpharmony = \transpose c' d {
1033 \set Staff.instrument = #"Trumpet"
1040 % ------ Alto Saxophone ------
1041 alto = \transpose c a \relative c' {
1045 altoharmony = \transpose c' a {
1050 \set Staff.instrument = #"Alto Sax"
1057 % ------ Baritone Saxophone ------
1058 bari = \transpose c a' \relative c {
1060 c1 c \sl d4^"Solo" d d d \nsl
1062 bariharmony = \transpose c' a \chordmode {
1063 \jzchords s1 s d2:maj e:m7
1067 \set Staff.instrument = #"Bari Sax"
1074 % ------ Trombone ------
1075 tbone = \relative c {
1079 tboneharmony = \chordmode {
1084 \set Staff.instrument = #"Trombone"
1091 % ############ Rhythm Section #############
1093 % ------ Guitar ------
1094 gtr = \relative c'' {
1096 c1 \sl b4 b b b \nsl c1
1098 gtrharmony = \chordmode {
1104 \set Staff.instrument = #"Guitar"
1111 %% ------ Piano ------
1112 rhUpper = \relative c'' {
1117 rhLower = \relative c' {
1123 lhUpper = \relative c' {
1128 lhLower = \relative c {
1137 \set Staff.midiInstrument = "acoustic grand"
1139 \context Voice = one \rhUpper
1140 \context Voice = two \rhLower
1146 \set Staff.midiInstrument = "acoustic grand"
1148 \context Voice = one \lhUpper
1149 \context Voice = two \lhLower
1154 \context PianoStaff <<
1155 \set PianoStaff.instrument = #"Piano"
1156 \context Staff = upper \PianoRH
1157 \context Staff = lower \PianoLH
1161 % ------ Bass Guitar ------
1162 Bass = \relative c {
1168 \set Staff.instrument = #"Bass"
1175 % ------ Drums ------
1177 hh4 <hh sn>4 hh <hh sn> hh <hh sn>4
1184 bd4 s bd s bd s bd s bd s bd s
1190 \set DrumStaff.instrument = #"Drums"
1191 \new DrumVoice { \voiceOne \up }
1192 \new DrumVoice { \voiceTwo \down }
1196 %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%
1200 \context StaffGroup = horns <<
1201 \context Staff = trumpet \trumpet
1202 \context Staff = altosax \altosax
1203 \context ChordNames = barichords \bariharmony
1204 \context Staff = barisax \barisax
1205 \context Staff = trombone \trombone
1208 \context StaffGroup = rhythm <<
1209 \context ChordNames = chords \gtrharmony
1210 \context Staff = guitar \guitar
1211 \context PianoStaff = piano \piano
1212 \context Staff = bass \bass
1213 \new DrumStaff { \drumContents }
1218 \context { \RemoveEmptyStaffContext }
1221 \override BarNumber #'padding = #3
1222 \override RehearsalMark #'padding = #2
1227 \midi { \tempo 4 = 75 }
1231 @node Other templates
1232 @section Other templates
1233 @subsection All headers
1235 This template displays all available headers. Some of them are only
1236 used in the Mutopia project; they don't affect the printed output at
1237 all. They are used if you want the piece to be listed with different
1238 information in the Mutopia database than you wish to have printed on the
1239 music. For example, Mutopia lists the composer of the famous D major
1240 violin concerto as TchaikovskyPI, whereas perhaps you wish to print
1241 "Petr Tchaikowski" on your music.
1243 @ The `linewidth' is for \header.
1244 @lilypond[quote,verbatim,raggedright,linewidth]
1247 dedication = "dedication"
1249 subtitle = "Subtitle"
1250 subsubtitle = "Subsubtitle"
1251 composer = "Composer (xxxx-yyyy)"
1255 instrument = "Instrument"
1256 arranger = "Arranger"
1258 texttranslator = "Translator"
1259 copyright = "public domain"
1261 % These are headers used by the Mutopia Project
1262 % http://www.mutopiaproject.org/
1264 mutopiacomposer = ""
1266 mutopiainstrument = ""
1267 date = "composer's dates"
1269 maintainer = "your name here"
1270 maintainerEmail = "your email here"
1271 maintainerWeb = "your home page"
1272 lastupdated = "2004/Aug/26"
1292 @subsection Gregorian template
1294 This example demonstrates how to do modern transcriptions of Gregorian
1295 music. Gregorian music has no measure, no stems; it uses only half and
1296 quarter notes, and two types of barlines, a short one indicating a rest,
1297 and a second one indicating a breath mark.
1299 @lilypond[quote,verbatim,raggedright]
1300 barOne = { \once \override Staff.BarLine #'bar-size = #2
1302 barTwo = { \once \override Staff.BarLine #'extra-offset = #'(0 . 2)
1303 \once \override Staff.BarLine #'bar-size = #2
1305 chant = \relative c' {
1306 \set Score.timing = ##f
1307 \override Staff.Stem #'transparent = ##t
1316 \midi { \tempo 4=60 }
1321 @node Lilypond-book templates
1322 @section Lilypond-book templates
1324 These templates are for use with @code{lilypond-book}. If you're not familiar
1325 with this program, please refer to @ref{LilyPond-book}.
1329 You can include LilyPond fragments in a LaTeX document.
1332 \documentclass[]@{article@}
1333 \usepackage@{graphics@}
1356 You can include LilyPond fragments in Texinfo; in fact, this entire manual
1357 is written in Texinfo.
1365 @@lilypond[verbatim,fragment,raggedright]
1371 @@lilypond[verbatim,fragment,raggedright]