1 @c -*- coding: utf-8; 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,ragged-right]
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,ragged-right]
57 melody = \relative c' {
75 \new Lyrics \lyricsto "one" \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,ragged-right]
88 melody = \relative c' {
97 harmonies = \chordmode {
98 c4:m f:min7 g:maj c:aug d2:dim b:sus
104 \set chordChanges = ##t
115 @subsection Notes, lyrics, and chords.
117 This template allows you to prepare a song with melody, words, and chords.
119 @lilypond[quote,verbatim,ragged-right]
121 melody = \relative c' {
133 harmonies = \chordmode {
140 \set chordChanges = ##t
147 \new Lyrics \lyricsto "one" \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,ragged-right]
162 upper = \relative c'' {
170 lower = \relative c {
180 \set PianoStaff.instrument = "Piano "
181 \new Staff = "upper" \upper
182 \new 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,ragged-right]
196 melody = \relative c'' {
208 upper = \relative c'' {
216 lower = \relative c {
230 \new Lyrics \lyricsto mel \text
233 \new Staff = "upper" \upper
234 \new 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,ragged-right]
252 upper = \relative c'' {
260 lower = \relative c {
274 \new Staff = upper { \new Voice = "singer" \upper }
275 \new Lyrics \lyricsto "singer" \text
282 \context { \GrandStaff \accepts "Lyrics" }
283 \context { \Lyrics \consists "Bar_engraver" }
285 \midi { \tempo 4=60 }
290 @subsection Piano centered dynamics
292 Many piano scores have the dynamics centered between the two
293 staffs. This requires a bit of tweaking to implement, but
294 since the template is right here, you don't have to do the
297 @lilypond[quote,verbatim,ragged-right]
299 upper = \relative c'' {
307 lower = \relative c {
321 s2\sustainDown s2\sustainUp
326 \new Staff = "upper" \upper
327 \new Dynamics = "dynamics" \dynamics
328 \new Staff = "lower" <<
332 \new Dynamics = "pedal" \pedal
336 \type "Engraver_group"
338 \alias Voice % So that \cresc works, for example.
339 \consists "Output_property_engraver"
341 \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
342 pedalSustainStrings = #'("Ped." "*Ped." "*")
343 pedalUnaCordaStrings = #'("una corda" "" "tre corde")
345 \consists "Piano_pedal_engraver"
346 \consists "Script_engraver"
347 \consists "Dynamic_engraver"
348 \consists "Text_engraver"
350 \override TextScript #'font-size = #2
351 \override TextScript #'font-shape = #'italic
352 \override DynamicText #'extra-offset = #'(0 . 2.5)
353 \override Hairpin #'extra-offset = #'(0 . 2.5)
355 \consists "Skip_event_swallow_translator"
357 \consists "Axis_group_engraver"
362 \override VerticalAlignment #'forced-distance = #7
368 \new Staff = "upper" << \upper \dynamics >>
369 \new Staff = "lower" << \lower \dynamics >>
370 \n ew Dynamics = "pedal" \pedal
374 \type "Performer_group"
376 \consists "Piano_pedal_performer"
388 @section String quartet
389 @subsection String quartet
391 This template demonstrates a string quartet. It also uses a @code{\global}
392 section for time and key signatures.
394 @lilypond[quote,verbatim,ragged-right]
402 violinOne = \new Voice { \relative c''{
403 \set Staff.instrument = "Violin 1 "
408 violinTwo = \new Voice { \relative c''{
409 \set Staff.instrument = "Violin 2 "
414 viola = \new Voice { \relative c' {
415 \set Staff.instrument = "Viola "
421 cello = \new Voice { \relative c' {
422 \set Staff.instrument = "Cello "
431 \new Staff << \global \violinOne >>
432 \new Staff << \global \violinTwo >>
433 \new Staff << \global \viola >>
434 \new Staff << \global \cello >>
441 @subsection String quartet parts
443 The previous example produces a nice string quartet, but what if you
444 needed to print parts? This template demonstrates how to use the
445 @code{\tag} feature to easily split a piece into individual parts.
447 You need to split this template into separate files; the filenames
448 are contained in comments at the beginning of each file. @code{piece.ly}
449 contains all the music definitions. The other files -- @code{score.ly},
450 @code{vn1.ly}, @code{vn2.ly}, @code{vla.ly}, and
451 @code{vlc.ly} -- produce the appropiate part.
462 Violinone = \new Voice { \relative c''{
463 \set Staff.instrument = "Violin 1 "
467 \bar "|." }} %*********************************
468 Violintwo = \new Voice { \relative c''{
469 \set Staff.instrument = "Violin 2 "
473 \bar "|." }} %*********************************
474 Viola = \new Voice { \relative c' {
475 \set Staff.instrument = "Viola "
480 \bar "|." }} %*********************************
481 Cello = \new Voice { \relative c' {
482 \set Staff.instrument = "Cello "
487 \bar "|."}} %**********************************
491 \tag #'(score vn1) \new Staff { << \global \Violinone >> }
492 \tag #'(score vn2) \new Staff { << \global \Violintwo>> }
493 \tag #'(score vla) \new Staff { << \global \Viola>> }
494 \tag #'(score vlc) \new Staff { << \global \Cello>> }
503 #(set-global-staff-size 14)
505 \new StaffGroup \keepWithTag #'score \music
507 \midi { \tempo 4 = 60 }
515 \keepWithTag #'vn1 \music
524 \keepWithTag #'vn2 \music
533 \keepWithTag #'vla \music
542 \keepWithTag #'vlc \music
548 @node Vocal ensembles
549 @section Vocal ensembles
551 @subsection SATB vocal score
553 Here is a standard four-part SATB vocal score. With larger ensembles,
554 it's often useful to include a section which is included in all
555 parts. For example, the time signature and key signatures are almost
556 always the same for all parts.
558 @lilypond[quote,verbatim,ragged-right]
565 sopMusic = \relative c'' {
568 sopWords = \lyricmode {
572 altoMusic = \relative c' {
575 altoWords =\lyricmode {
579 tenorMusic = \relative c' {
582 tenorWords = \lyricmode {
586 bassMusic = \relative c {
589 bassWords = \lyricmode {
595 \new Lyrics = sopranos { s1 }
596 \new Staff = women <<
598 "sopranos" { \voiceOne << \global \sopMusic >> }
600 "altos" { \voiceTwo << \global \altoMusic >> }
602 \new Lyrics = "altos" { s1 }
603 \new Lyrics = "tenors" { s1 }
607 "tenors" { \voiceOne <<\global \tenorMusic >> }
609 "basses" { \voiceTwo <<\global \bassMusic >> }
611 \new 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
624 \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
631 @subsection SATB vocal score and automatic piano reduction
633 This template adds an automatic piano reduction to the SATB vocal
634 score. This demonstrates one of the strengths of LilyPond -- you
635 can use a music definition more than once. If you make any changes
636 to the vocal notes (say, tenorMusic), then the changes will also
637 apply to the piano reduction.
639 @lilypond[quote,verbatim,ragged-right]
646 sopMusic = \relative c'' {
649 sopWords = \lyricmode {
653 altoMusic = \relative c' {
656 altoWords =\lyricmode {
660 tenorMusic = \relative c' {
663 tenorWords = \lyricmode {
667 bassMusic = \relative c {
670 bassWords = \lyricmode {
677 \new Lyrics = sopranos { s1 }
678 \new Staff = women <<
680 "sopranos" { \voiceOne << \global \sopMusic >> }
682 "altos" { \voiceTwo << \global \altoMusic >> }
684 \new Lyrics = "altos" { s1 }
685 \new Lyrics = "tenors" { s1 }
689 "tenors" { \voiceOne <<\global \tenorMusic >> }
691 "basses" { \voiceTwo <<\global \bassMusic >> }
693 \new Lyrics = basses { s1 }
695 \context Lyrics = sopranos \lyricsto sopranos \sopWords
696 \context Lyrics = altos \lyricsto altos \altoWords
697 \context Lyrics = tenors \lyricsto tenors \tenorWords
698 \context Lyrics = basses \lyricsto basses \bassWords
702 \set Staff.printPartCombineTexts = ##f
704 << \global \sopMusic >>
705 << \global \altoMusic >>
709 \set Staff.printPartCombineTexts = ##f
711 << \global \tenorMusic >>
712 << \global \bassMusic >>
717 % a little smaller so lyrics
718 % can be closer to the staff
720 \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
727 @c bad node name to avoid node name confict
728 @node Ancient notation templates
729 @section Ancient notation templates
731 @subsection Transcription of mensural music
733 When transcribing mensural music, an incipit at the beginning of the
734 piece is useful to indicate the original key and tempo. While today
735 musicians are used to bar lines in order to faster recognize rhythmic
736 patterns, bar lines were not yet invented during the period of
737 mensural music; in fact, the meter often changed after every few
738 notes. As a compromise, bar lines are often printed between the
739 staves rather than on the staves.
741 @lilypond[quote,verbatim,line-width=11.0\cm]
745 \set Score.skipBars = ##t
748 \once \override Score.SystemStartBracket #'transparent = ##t
749 \override Score.SpacingSpanner #'spacing-increment = #1.0 % tight spacing
752 \once \override Staff.TimeSignature #'style = #'neomensural
753 \override Voice.NoteHead #'style = #'neomensural
754 \override Voice.Rest #'style = #'neomensural
755 \set Staff.printKeyCancellation = ##f
756 \cadenzaOn % turn off bar lines
758 \once \override Staff.BarLine #'transparent = ##f
760 \skip 1*1 % need this extra \skip such that clef change comes
765 \revert Score.SpacingSpanner #'spacing-increment % CHECK: no effect?
766 \cadenzaOff % turn bar lines on again
767 \once \override Staff.Clef #'full-size-change = ##t
768 \set Staff.forceClef = ##t
771 \override Voice.NoteHead #'style = #'default
772 \override Voice.Rest #'style = #'default
774 % FIXME: setting printKeyCancellation back to #t must not
775 % occur in the first bar after the incipit. Dto. for forceClef.
776 % Therefore, we need an extra \skip.
778 \set Staff.printKeyCancellation = ##t
779 \set Staff.forceClef = ##f
781 \skip 1*7 % the actual music
783 % let finis bar go through all staves
784 \override Staff.BarLine #'transparent = ##f
792 \set Staff.instrument = "Discantus "
795 \clef "neomensural-c1"
797 \skip 1*8 % eight bars
807 \once \override NoteHead #'transparent = ##t c'1 |
812 discantusLyrics = \lyricmode {
828 \set Staff.instrument = "Altus "
831 \clef "neomensural-c3"
834 \skip 1*7 % seven bars
839 r2 g2. e4 fis g | % two bars
841 fis g4.( fis16 e fis4) |
843 \once \override NoteHead #'transparent = ##t g1 |
848 altusLyrics = \lyricmode {
853 Ju -- bi -- la -- te | % two bars
862 \set Staff.instrument = "Tenor "
865 \clef "neomensural-c4"
878 r2 d'2. d'4 b e' | % two bars
879 \once \override NoteHead #'transparent = ##t e'1 |
884 tenorLyrics = \lyricmode {
889 Ju -- bi -- la -- te | % two bars
896 \set Staff.instrument = "Bassus "
900 r\maxima % eight bars
911 \once \override NoteHead #'transparent = ##t e1 |
916 bassusLyrics = \lyricmode {
927 \new StaffGroup = choirStaff <<
929 "discantusNotes" << \global \discantusNotes >>
931 "discantusLyrics" \lyricsto discantusNotes { \discantusLyrics }
933 "altusNotes" << \global \altusNotes >>
935 "altusLyrics" \lyricsto altusNotes { \altusLyrics }
937 "tenorNotes" << \global \tenorNotes >>
939 "tenorLyrics" \lyricsto tenorNotes { \tenorLyrics }
941 "bassusNotes" << \global \bassusNotes >>
943 "bassusLyrics" \lyricsto bassusNotes { \bassusLyrics }
948 \override BarLine #'transparent = ##t
949 \remove "System_start_delimiter_engraver"
953 \override Slur #'transparent = ##t
964 This is a much more complicated template, for a jazz ensemble. Note that all
965 instruments are notated in @code{\key c \major}. This refers to the key in
966 concert pitch; LilyPond will automatically transpose the key if the music
967 is within a @code{\transpose} section.
969 @c TODO must clean up this jazz combo example
970 @c - transpositions stated in names (ie "trumpet in Bb" or whatever)
971 @c - one global section, instead of "global" (time) and "key"
972 @c - does it need those wierd macros? sl, nsl, etc.
973 @c - maybe ask Amelie Zapf to clean it up, or whether I should just
974 @c make whatever changes I feel like.
976 @c FIXME: produces a warning ; key change merge.
977 @c The `line-width' argument is for the \header.
979 @lilypond[quote,verbatim,ragged-right,line-width]
987 tagline = "LilyPond example file by Amelie Zapf,
989 texidoc = "Jazz tune for combo
990 (horns, guitar, piano, bass, drums)."
993 #(set-global-staff-size 16)
994 \include "english.ly"
996 %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%
999 \override NoteHead #'style = #'slash
1000 \override Stem #'transparent = ##t
1003 \revert NoteHead #'style
1004 \revert Stem #'transparent
1006 cr = \override NoteHead #'style = #'cross
1007 ncr = \revert NoteHead #'style
1009 %% insert chord name style stuff here.
1014 %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%
1020 Key = { \key c \major }
1022 % ############ Horns ############
1024 % ------ Trumpet ------
1025 trpt = \transpose c d \relative c'' {
1029 trpharmony = \transpose c' d {
1034 \set Staff.instrument = #"Trumpet"
1041 % ------ Alto Saxophone ------
1042 alto = \transpose c a \relative c' {
1046 altoharmony = \transpose c' a {
1051 \set Staff.instrument = #"Alto Sax"
1058 % ------ Baritone Saxophone ------
1059 bari = \transpose c a' \relative c {
1061 c1 c \sl d4^"Solo" d d d \nsl
1063 bariharmony = \transpose c' a \chordmode {
1064 \jzchords s1 s d2:maj e:m7
1068 \set Staff.instrument = #"Bari Sax"
1075 % ------ Trombone ------
1076 tbone = \relative c {
1080 tboneharmony = \chordmode {
1085 \set Staff.instrument = #"Trombone"
1092 % ############ Rhythm Section #############
1094 % ------ Guitar ------
1095 gtr = \relative c'' {
1097 c1 \sl b4 b b b \nsl c1
1099 gtrharmony = \chordmode {
1105 \set Staff.instrument = #"Guitar"
1112 %% ------ Piano ------
1113 rhUpper = \relative c'' {
1118 rhLower = \relative c' {
1124 lhUpper = \relative c' {
1129 lhLower = \relative c {
1138 \set Staff.midiInstrument = "acoustic grand"
1140 \new Voice = "one" \rhUpper
1141 \new Voice = "two" \rhLower
1147 \set Staff.midiInstrument = "acoustic grand"
1149 \new Voice = "one" \lhUpper
1150 \new Voice = "two" \lhLower
1156 \set PianoStaff.instrument = #"Piano"
1157 \new Staff = "upper" \PianoRH
1158 \new Staff = "lower" \PianoLH
1162 % ------ Bass Guitar ------
1163 Bass = \relative c {
1169 \set Staff.instrument = #"Bass"
1176 % ------ Drums ------
1178 hh4 <hh sn>4 hh <hh sn> hh <hh sn>4
1185 bd4 s bd s bd s bd s bd s bd s
1191 \set DrumStaff.instrument = #"Drums"
1192 \new DrumVoice { \voiceOne \up }
1193 \new DrumVoice { \voiceTwo \down }
1197 %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%
1201 \new StaffGroup = "horns" <<
1202 \new Staff = "trumpet" \trumpet
1203 \new Staff = "altosax" \altosax
1204 \new ChordNames = "barichords" \bariharmony
1205 \new Staff = "barisax" \barisax
1206 \new Staff = "trombone" \trombone
1209 \new StaffGroup = "rhythm" <<
1210 \new ChordNames = "chords" \gtrharmony
1211 \new Staff = "guitar" \guitar
1212 \new PianoStaff = piano" \piano
1213 \new Staff = "bass" \bass
1214 \new DrumStaff { \drumContents }
1219 \context { \RemoveEmptyStaffContext }
1222 \override BarNumber #'padding = #3
1223 \override RehearsalMark #'padding = #2
1228 \midi { \tempo 4 = 75 }
1232 @node Other templates
1233 @section Other templates
1234 @subsection All headers
1236 This template displays all available headers. Some of them are only
1237 used in the Mutopia project; they don't affect the printed output at
1238 all. They are used if you want the piece to be listed with different
1239 information in the Mutopia database than you wish to have printed on the
1240 music. For example, Mutopia lists the composer of the famous D major
1241 violin concerto as TchaikovskyPI, whereas perhaps you wish to print
1242 "Petr Tchaikowski" on your music.
1244 @ The `line-width' is for \header.
1245 @lilypond[quote,verbatim,ragged-right,line-width]
1248 dedication = "dedication"
1250 subtitle = "Subtitle"
1251 subsubtitle = "Subsubtitle"
1252 composer = "Composer (xxxx-yyyy)"
1256 instrument = "Instrument"
1257 arranger = "Arranger"
1259 texttranslator = "Translator"
1260 copyright = "public domain"
1262 % These are headers used by the Mutopia Project
1263 % http://www.mutopiaproject.org/
1265 mutopiacomposer = ""
1267 mutopiainstrument = ""
1268 date = "composer's dates"
1270 maintainer = "your name here"
1271 maintainerEmail = "your email here"
1272 maintainerWeb = "your home page"
1273 lastupdated = "2004/Aug/26"
1293 @subsection Gregorian template
1295 This example demonstrates how to do modern transcriptions of Gregorian
1296 music. Gregorian music has no measure, no stems; it uses only half and
1297 quarter notes, and two types of barlines, a short one indicating a rest,
1298 and a second one indicating a breath mark.
1300 @lilypond[quote,verbatim,ragged-right]
1301 barOne = { \once \override Staff.BarLine #'bar-size = #2
1303 barTwo = { \once \override Staff.BarLine #'extra-offset = #'(0 . 2)
1304 \once \override Staff.BarLine #'bar-size = #2
1306 chant = \relative c' {
1307 \set Score.timing = ##f
1308 \override Staff.Stem #'transparent = ##t
1317 \midi { \tempo 4=60 }
1322 @node Lilypond-book templates
1323 @section Lilypond-book templates
1325 These templates are for use with @code{lilypond-book}. If you're not familiar
1326 with this program, please refer to @ref{LilyPond-book}.
1330 You can include LilyPond fragments in a LaTeX document.
1333 \documentclass[]@{article@}
1357 You can include LilyPond fragments in Texinfo; in fact, this entire manual
1358 is written in Texinfo.
1366 @@lilypond[verbatim,fragment,ragged-right]
1372 @@lilypond[verbatim,fragment,ragged-right]